@webiny/lexical-editor 0.0.0-unstable.1145e7667f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +17 -0
- package/commands/webiny-list.d.ts +7 -0
- package/commands/webiny-list.js +13 -0
- package/commands/webiny-list.js.map +1 -0
- package/commands/webiny-quote.d.ts +5 -0
- package/commands/webiny-quote.js +9 -0
- package/commands/webiny-quote.js.map +1 -0
- package/components/AddRichTextEditorNodeType.d.ts +6 -0
- package/components/AddRichTextEditorNodeType.js +28 -0
- package/components/AddRichTextEditorNodeType.js.map +1 -0
- package/components/AddRichTextEditorPlugin.d.ts +12 -0
- package/components/AddRichTextEditorPlugin.js +33 -0
- package/components/AddRichTextEditorPlugin.js.map +1 -0
- package/components/AddToolbarAction.d.ts +7 -0
- package/components/AddToolbarAction.js +33 -0
- package/components/AddToolbarAction.js.map +1 -0
- package/components/Editor/HeadingEditor.d.ts +7 -0
- package/components/Editor/HeadingEditor.js +29 -0
- package/components/Editor/HeadingEditor.js.map +1 -0
- package/components/Editor/ParagraphEditor.d.ts +7 -0
- package/components/Editor/ParagraphEditor.js +30 -0
- package/components/Editor/ParagraphEditor.js.map +1 -0
- package/components/Editor/RichTextEditor.d.ts +26 -0
- package/components/Editor/RichTextEditor.js +138 -0
- package/components/Editor/RichTextEditor.js.map +1 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.d.ts +9 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.js +17 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -0
- package/components/LexicalHtmlRenderer.d.ts +16 -0
- package/components/LexicalHtmlRenderer.js +67 -0
- package/components/LexicalHtmlRenderer.js.map +1 -0
- package/components/Toolbar/HeadingToolbar.d.ts +12 -0
- package/components/Toolbar/HeadingToolbar.js +23 -0
- package/components/Toolbar/HeadingToolbar.js.map +1 -0
- package/components/Toolbar/ParagraphToolbar.d.ts +12 -0
- package/components/Toolbar/ParagraphToolbar.js +23 -0
- package/components/Toolbar/ParagraphToolbar.js.map +1 -0
- package/components/Toolbar/Toolbar.css +423 -0
- package/components/Toolbar/Toolbar.d.ts +13 -0
- package/components/Toolbar/Toolbar.js +181 -0
- package/components/Toolbar/Toolbar.js.map +1 -0
- package/components/ToolbarActions/BoldAction.d.ts +2 -0
- package/components/ToolbarActions/BoldAction.js +43 -0
- package/components/ToolbarActions/BoldAction.js.map +1 -0
- package/components/ToolbarActions/BulletListAction.d.ts +2 -0
- package/components/ToolbarActions/BulletListAction.js +51 -0
- package/components/ToolbarActions/BulletListAction.js.map +1 -0
- package/components/ToolbarActions/CodeHighlightAction.d.ts +2 -0
- package/components/ToolbarActions/CodeHighlightAction.js +43 -0
- package/components/ToolbarActions/CodeHighlightAction.js.map +1 -0
- package/components/ToolbarActions/FontColorAction.d.ts +11 -0
- package/components/ToolbarActions/FontColorAction.js +83 -0
- package/components/ToolbarActions/FontColorAction.js.map +1 -0
- package/components/ToolbarActions/FontSizeAction.d.ts +2 -0
- package/components/ToolbarActions/FontSizeAction.js +101 -0
- package/components/ToolbarActions/FontSizeAction.js.map +1 -0
- package/components/ToolbarActions/ItalicAction.d.ts +2 -0
- package/components/ToolbarActions/ItalicAction.js +43 -0
- package/components/ToolbarActions/ItalicAction.js.map +1 -0
- package/components/ToolbarActions/LinkAction.d.ts +2 -0
- package/components/ToolbarActions/LinkAction.js +64 -0
- package/components/ToolbarActions/LinkAction.js.map +1 -0
- package/components/ToolbarActions/NumberedListAction.d.ts +2 -0
- package/components/ToolbarActions/NumberedListAction.js +53 -0
- package/components/ToolbarActions/NumberedListAction.js.map +1 -0
- package/components/ToolbarActions/QuoteAction.d.ts +2 -0
- package/components/ToolbarActions/QuoteAction.js +53 -0
- package/components/ToolbarActions/QuoteAction.js.map +1 -0
- package/components/ToolbarActions/TypographyAction.d.ts +11 -0
- package/components/ToolbarActions/TypographyAction.js +118 -0
- package/components/ToolbarActions/TypographyAction.js.map +1 -0
- package/components/ToolbarActions/UnderlineAction.d.ts +2 -0
- package/components/ToolbarActions/UnderlineAction.js +43 -0
- package/components/ToolbarActions/UnderlineAction.js.map +1 -0
- package/components/ToolbarPresets/HeadingToolbarPreset.d.ts +2 -0
- package/components/ToolbarPresets/HeadingToolbarPreset.js +52 -0
- package/components/ToolbarPresets/HeadingToolbarPreset.js.map +1 -0
- package/components/ToolbarPresets/ParagraphToolbarPreset.d.ts +2 -0
- package/components/ToolbarPresets/ParagraphToolbarPreset.js +67 -0
- package/components/ToolbarPresets/ParagraphToolbarPreset.js.map +1 -0
- package/context/FontColorActionContext.d.ts +6 -0
- package/context/FontColorActionContext.js +10 -0
- package/context/FontColorActionContext.js.map +1 -0
- package/context/RichTextEditorContext.d.ts +21 -0
- package/context/RichTextEditorContext.js +56 -0
- package/context/RichTextEditorContext.js.map +1 -0
- package/context/SharedHistoryContext.d.ts +11 -0
- package/context/SharedHistoryContext.js +26 -0
- package/context/SharedHistoryContext.js.map +1 -0
- package/context/TypographyActionContext.d.ts +7 -0
- package/context/TypographyActionContext.js +10 -0
- package/context/TypographyActionContext.js.map +1 -0
- package/hooks/useFontColorPicker.d.ts +2 -0
- package/hooks/useFontColorPicker.js +15 -0
- package/hooks/useFontColorPicker.js.map +1 -0
- package/hooks/useRichTextEditor.d.ts +2 -0
- package/hooks/useRichTextEditor.js +15 -0
- package/hooks/useRichTextEditor.js.map +1 -0
- package/hooks/useTypographyAction.d.ts +1 -0
- package/hooks/useTypographyAction.js +15 -0
- package/hooks/useTypographyAction.js.map +1 -0
- package/hooks/useWebinyList.d.ts +2 -0
- package/hooks/useWebinyList.js +39 -0
- package/hooks/useWebinyList.js.map +1 -0
- package/hooks/useWebinyQuote.d.ts +2 -0
- package/hooks/useWebinyQuote.js +20 -0
- package/hooks/useWebinyQuote.js.map +1 -0
- package/images/icons/LICENSE.md +5 -0
- package/images/icons/chat-square-quote.svg +1 -0
- package/images/icons/chevron-down.svg +1 -0
- package/images/icons/code.svg +1 -0
- package/images/icons/font-color.svg +1 -0
- package/images/icons/link.svg +1 -0
- package/images/icons/list-ol.svg +1 -0
- package/images/icons/list-ul.svg +1 -0
- package/images/icons/pencil-fill.svg +1 -0
- package/images/icons/text-center.svg +1 -0
- package/images/icons/text-left.svg +1 -0
- package/images/icons/text-paragraph.svg +1 -0
- package/images/icons/text-right.svg +1 -0
- package/images/icons/type-bold.svg +1 -0
- package/images/icons/type-h1.svg +1 -0
- package/images/icons/type-h2.svg +1 -0
- package/images/icons/type-h3.svg +1 -0
- package/images/icons/type-h4.svg +1 -0
- package/images/icons/type-h5.svg +1 -0
- package/images/icons/type-h6.svg +1 -0
- package/images/icons/type-italic.svg +1 -0
- package/images/icons/type-strikethrough.svg +1 -0
- package/images/icons/type-underline.svg +1 -0
- package/images/icons/unlink_icon.svg +1 -0
- package/index.d.ts +40 -0
- package/index.js +281 -0
- package/index.js.map +1 -0
- package/nodes/FontColorNode.d.ts +43 -0
- package/nodes/FontColorNode.js +127 -0
- package/nodes/FontColorNode.js.map +1 -0
- package/nodes/TypographyElementNode.d.ts +42 -0
- package/nodes/TypographyElementNode.js +154 -0
- package/nodes/TypographyElementNode.js.map +1 -0
- package/nodes/WebinyQuoteNode.d.ts +29 -0
- package/nodes/WebinyQuoteNode.js +148 -0
- package/nodes/WebinyQuoteNode.js.map +1 -0
- package/nodes/list-node/WebinyListItemNode.d.ts +46 -0
- package/nodes/list-node/WebinyListItemNode.js +441 -0
- package/nodes/list-node/WebinyListItemNode.js.map +1 -0
- package/nodes/list-node/WebinyListNode.d.ts +38 -0
- package/nodes/list-node/WebinyListNode.js +253 -0
- package/nodes/list-node/WebinyListNode.js.map +1 -0
- package/nodes/list-node/formatList.d.ts +12 -0
- package/nodes/list-node/formatList.js +423 -0
- package/nodes/list-node/formatList.js.map +1 -0
- package/nodes/webinyNodes.d.ts +7 -0
- package/nodes/webinyNodes.js +21 -0
- package/nodes/webinyNodes.js.map +1 -0
- package/package.json +41 -0
- package/plugins/AutoLinkPlugin/AutoLinkPlugin.d.ts +11 -0
- package/plugins/AutoLinkPlugin/AutoLinkPlugin.js +46 -0
- package/plugins/AutoLinkPlugin/AutoLinkPlugin.js.map +1 -0
- package/plugins/AutoLinkPlugin/index.d.ts +1 -0
- package/plugins/AutoLinkPlugin/index.js +16 -0
- package/plugins/AutoLinkPlugin/index.js.map +1 -0
- package/plugins/BlurEventPlugin/BlurEventPlugin.d.ts +7 -0
- package/plugins/BlurEventPlugin/BlurEventPlugin.js +28 -0
- package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -0
- package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.d.ts +17 -0
- package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.js +88 -0
- package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.js.map +1 -0
- package/plugins/ClickableLinkPlugin/index.d.ts +1 -0
- package/plugins/ClickableLinkPlugin/index.js +16 -0
- package/plugins/ClickableLinkPlugin/index.js.map +1 -0
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.d.ts +1 -0
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +20 -0
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -0
- package/plugins/CodeHighlightPlugin/index.d.ts +1 -0
- package/plugins/CodeHighlightPlugin/index.js +16 -0
- package/plugins/CodeHighlightPlugin/index.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +118 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +7 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +222 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/index.d.ts +1 -0
- package/plugins/FloatingLinkEditorPlugin/index.js +16 -0
- package/plugins/FloatingLinkEditorPlugin/index.js.map +1 -0
- package/plugins/FontColorPlugin/FontColorPlugin.d.ts +2 -0
- package/plugins/FontColorPlugin/FontColorPlugin.js +38 -0
- package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -0
- package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.d.ts +8 -0
- package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js +34 -0
- package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js.map +1 -0
- package/plugins/LexicalUpdateStatePlugin/index.d.ts +1 -0
- package/plugins/LexicalUpdateStatePlugin/index.js +16 -0
- package/plugins/LexicalUpdateStatePlugin/index.js.map +1 -0
- package/plugins/TypographyPlugin/TypographyPlugin.d.ts +2 -0
- package/plugins/TypographyPlugin/TypographyPlugin.js +31 -0
- package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -0
- package/plugins/WebinyListPLugin/WebinyListPlugin.d.ts +1 -0
- package/plugins/WebinyListPLugin/WebinyListPlugin.js +25 -0
- package/plugins/WebinyListPLugin/WebinyListPlugin.js.map +1 -0
- package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.d.ts +1 -0
- package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.js +24 -0
- package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.js.map +1 -0
- package/themes/webinyLexicalTheme.css +420 -0
- package/themes/webinyLexicalTheme.d.ts +9 -0
- package/themes/webinyLexicalTheme.js +87 -0
- package/themes/webinyLexicalTheme.js.map +1 -0
- package/types.d.ts +61 -0
- package/types.js +12 -0
- package/types.js.map +1 -0
- package/ui/Divider.d.ts +2 -0
- package/ui/Divider.js +13 -0
- package/ui/Divider.js.map +1 -0
- package/ui/DropDown.d.ts +26 -0
- package/ui/DropDown.js +173 -0
- package/ui/DropDown.js.map +1 -0
- package/ui/Input.css +32 -0
- package/ui/LinkPreview.css +69 -0
- package/ui/LinkPreview.d.ts +12 -0
- package/ui/LinkPreview.js +101 -0
- package/ui/LinkPreview.js.map +1 -0
- package/ui/Placeholder.css +23 -0
- package/ui/Placeholder.d.ts +13 -0
- package/ui/Placeholder.js +24 -0
- package/ui/Placeholder.js.map +1 -0
- package/ui/TextInput.d.ts +18 -0
- package/ui/TextInput.js +39 -0
- package/ui/TextInput.js.map +1 -0
- package/ui/ToolbarActionDialog.d.ts +12 -0
- package/ui/ToolbarActionDialog.js +106 -0
- package/ui/ToolbarActionDialog.js.map +1 -0
- package/utils/generateInitialLexicalValue.d.ts +5 -0
- package/utils/generateInitialLexicalValue.js +29 -0
- package/utils/generateInitialLexicalValue.js.map +1 -0
- package/utils/getDOMRangeRect.d.ts +10 -0
- package/utils/getDOMRangeRect.js +27 -0
- package/utils/getDOMRangeRect.js.map +1 -0
- package/utils/getLexicalTextSelectionState.d.ts +5 -0
- package/utils/getLexicalTextSelectionState.js +141 -0
- package/utils/getLexicalTextSelectionState.js.map +1 -0
- package/utils/getSelectedNode.d.ts +2 -0
- package/utils/getSelectedNode.js +30 -0
- package/utils/getSelectedNode.js.map +1 -0
- package/utils/isValidJSON.d.ts +1 -0
- package/utils/isValidJSON.js +18 -0
- package/utils/isValidJSON.js.map +1 -0
- package/utils/isValidLexicalData.d.ts +2 -0
- package/utils/isValidLexicalData.js +24 -0
- package/utils/isValidLexicalData.js.map +1 -0
- package/utils/nodes/clearNodeFormating.d.ts +2 -0
- package/utils/nodes/clearNodeFormating.js +28 -0
- package/utils/nodes/clearNodeFormating.js.map +1 -0
- package/utils/nodes/formatToParagraph.d.ts +2 -0
- package/utils/nodes/formatToParagraph.js +19 -0
- package/utils/nodes/formatToParagraph.js.map +1 -0
- package/utils/nodes/formatToQuote.d.ts +2 -0
- package/utils/nodes/formatToQuote.js +20 -0
- package/utils/nodes/formatToQuote.js.map +1 -0
- package/utils/nodes/list-node.d.ts +11 -0
- package/utils/nodes/list-node.js +107 -0
- package/utils/nodes/list-node.js.map +1 -0
- package/utils/point.d.ts +21 -0
- package/utils/point.js +77 -0
- package/utils/point.js.map +1 -0
- package/utils/rect.d.ts +47 -0
- package/utils/rect.js +169 -0
- package/utils/rect.js.map +1 -0
- package/utils/sanitizeUrl.d.ts +8 -0
- package/utils/sanitizeUrl.js +27 -0
- package/utils/sanitizeUrl.js.map +1 -0
- package/utils/setFloatingElemPosition.d.ts +3 -0
- package/utils/setFloatingElemPosition.js +40 -0
- package/utils/setFloatingElemPosition.js.map +1 -0
- package/utils/styleObjectToString.d.ts +2 -0
- package/utils/styleObjectToString.js +22 -0
- package/utils/styleObjectToString.js.map +1 -0
- package/utils/toTypographyEmotionMap.d.ts +3 -0
- package/utils/toTypographyEmotionMap.js +36 -0
- package/utils/toTypographyEmotionMap.js.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["PREVIEW_CACHE","URL_MATCHER","useSuspenseRequest","url","cached","match","preview","fetch","encodeURI","then","response","json","catch","Promise","LinkPreviewContent","img","title","domain","description","Glimmer","props","animationDelay","String","index","style","LinkPreview","height","width"],"sources":["LinkPreview.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport \"./LinkPreview.css\";\n\nimport * as React from \"react\";\nimport { CSSProperties, Suspense } from \"react\";\n\ntype Preview = {\n title: string;\n description: string;\n img: string;\n domain: string;\n} | null;\n\n// Cached responses or running request promises\nconst PREVIEW_CACHE: Record<string, Promise<Preview> | { preview: Preview }> = {};\n\nconst URL_MATCHER =\n /((https?:\\/\\/(www\\.)?)|(www\\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;\n\nfunction useSuspenseRequest(url: string) {\n let cached = PREVIEW_CACHE[url];\n\n if (!url.match(URL_MATCHER)) {\n return { preview: null };\n }\n\n if (!cached) {\n cached = PREVIEW_CACHE[url] = fetch(`/api/link-preview?url=${encodeURI(url)}`)\n .then(response => response.json())\n .then(preview => {\n PREVIEW_CACHE[url] = preview;\n return preview;\n })\n .catch(() => {\n PREVIEW_CACHE[url] = { preview: null };\n });\n }\n\n if (cached instanceof Promise) {\n throw cached;\n }\n\n return cached;\n}\n\nfunction LinkPreviewContent({\n url\n}: Readonly<{\n url: string;\n}>): JSX.Element | null {\n const { preview } = useSuspenseRequest(url);\n if (preview === null) {\n return null;\n }\n return (\n <div className=\"LinkPreview__container\">\n {preview.img && (\n <div className=\"LinkPreview__imageWrapper\">\n <img src={preview.img} alt={preview.title} className=\"LinkPreview__image\" />\n </div>\n )}\n {preview.domain && <div className=\"LinkPreview__domain\">{preview.domain}</div>}\n {preview.title && <div className=\"LinkPreview__title\">{preview.title}</div>}\n {preview.description && (\n <div className=\"LinkPreview__description\">{preview.description}</div>\n )}\n </div>\n );\n}\n\nfunction Glimmer(props: { style: CSSProperties; index: number }): JSX.Element {\n return (\n <div\n className=\"LinkPreview__glimmer\"\n {...props}\n style={{\n animationDelay: String((props.index || 0) * 300),\n ...(props.style || {})\n }}\n />\n );\n}\n\nexport function LinkPreview({\n url\n}: Readonly<{\n url: string;\n}>): JSX.Element {\n return (\n <Suspense\n fallback={\n <>\n <Glimmer style={{ height: \"80px\" }} index={0} />\n <Glimmer style={{ width: \"60%\" }} index={1} />\n <Glimmer style={{ width: \"80%\" }} index={2} />\n </>\n }\n >\n <LinkPreviewContent url={url} />\n </Suspense>\n );\n}\n"],"mappings":";;;;;;;;;AAQA;AAEA;AAVA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA;AACA,IAAMA,aAAsE,GAAG,CAAC,CAAC;AAEjF,IAAMC,WAAW,GACb,iHAAiH;AAErH,SAASC,kBAAkB,CAACC,GAAW,EAAE;EACrC,IAAIC,MAAM,GAAGJ,aAAa,CAACG,GAAG,CAAC;EAE/B,IAAI,CAACA,GAAG,CAACE,KAAK,CAACJ,WAAW,CAAC,EAAE;IACzB,OAAO;MAAEK,OAAO,EAAE;IAAK,CAAC;EAC5B;EAEA,IAAI,CAACF,MAAM,EAAE;IAC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oBACI;IACI,SAAS,EAAC;EAAsB,GAC5BA,KAAK;IACT,KAAK;MACDC,cAAc,EAAEC,MAAM,CAAC,CAACF,KAAK,CAACG,KAAK,IAAI,CAAC,IAAI,GAAG;IAAC,GAC5CH,KAAK,CAACI,KAAK,IAAI,CAAC,CAAC;EACvB,GACJ;AAEV;AAEO,SAASC,WAAW,QAIV;EAAA,IAHbtB,GAAG,SAAHA,GAAG;EAIH,oBACI,oBAAC,cAAQ;IACL,QAAQ,eACJ,uDACI,oBAAC,OAAO;MAAC,KAAK,EAAE;QAAEuB,MAAM,EAAE;MAAO,CAAE;MAAC,KAAK,EAAE;IAAE,EAAG,eAChD,oBAAC,OAAO;MAAC,KAAK,EAAE;QAAEC,KAAK,EAAE;MAAM,CAAE;MAAC,KAAK,EAAE;IAAE,EAAG,eAC9C,oBAAC,OAAO;MAAC,KAAK,EAAE;QAAEA,KAAK,EAAE;MAAM,CAAE;MAAC,KAAK,EAAE;IAAE,EAAG;EAErD,gBAED,oBAAC,kBAAkB;IAAC,GAAG,EAAExB;EAAI,EAAG,CACzB;AAEnB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
.Placeholder__root {
|
|
11
|
+
font-size: 15px;
|
|
12
|
+
color: #999;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
position: absolute;
|
|
15
|
+
text-overflow: ellipsis;
|
|
16
|
+
top: 0px;
|
|
17
|
+
left: 15px;
|
|
18
|
+
right: 28px;
|
|
19
|
+
user-select: none;
|
|
20
|
+
white-space: nowrap;
|
|
21
|
+
display: inline-block;
|
|
22
|
+
pointer-events: none;
|
|
23
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import "./Placeholder.css";
|
|
9
|
+
import { ReactNode } from "react";
|
|
10
|
+
export declare function Placeholder({ children, className }: {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
className?: string;
|
|
13
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.Placeholder = Placeholder;
|
|
8
|
+
require("./Placeholder.css");
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
/**
|
|
11
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the MIT license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
function Placeholder(_ref) {
|
|
19
|
+
var children = _ref.children,
|
|
20
|
+
className = _ref.className;
|
|
21
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
22
|
+
className: className || "Placeholder__root"
|
|
23
|
+
}, children);
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Placeholder","children","className"],"sources":["Placeholder.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport \"./Placeholder.css\";\n\nimport * as React from \"react\";\nimport { ReactNode } from \"react\";\n\nexport function Placeholder({\n children,\n className\n}: {\n children: ReactNode;\n className?: string;\n}): JSX.Element {\n return <div className={className || \"Placeholder__root\"}>{children}</div>;\n}\n"],"mappings":";;;;;;;AAQA;AAEA;AAVA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOO,SAASA,WAAW,OAMX;EAAA,IALZC,QAAQ,QAARA,QAAQ;IACRC,SAAS,QAATA,SAAS;EAKT,oBAAO;IAAK,SAAS,EAAEA,SAAS,IAAI;EAAoB,GAAED,QAAQ,CAAO;AAC7E"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
/// <reference types="react" />
|
|
9
|
+
import "./Input.css";
|
|
10
|
+
declare type Props = Readonly<{
|
|
11
|
+
"data-test-id"?: string;
|
|
12
|
+
label: string;
|
|
13
|
+
onChange: (val: string) => void;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}>;
|
|
17
|
+
export default function TextInput({ label, value, onChange, placeholder, "data-test-id": dataTestId }: Props): JSX.Element;
|
|
18
|
+
export {};
|
package/ui/TextInput.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = TextInput;
|
|
8
|
+
require("./Input.css");
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
/**
|
|
11
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the MIT license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
function TextInput(_ref) {
|
|
19
|
+
var label = _ref.label,
|
|
20
|
+
value = _ref.value,
|
|
21
|
+
_onChange = _ref.onChange,
|
|
22
|
+
_ref$placeholder = _ref.placeholder,
|
|
23
|
+
placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
|
|
24
|
+
dataTestId = _ref["data-test-id"];
|
|
25
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
26
|
+
className: "Input__wrapper"
|
|
27
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
28
|
+
className: "Input__label"
|
|
29
|
+
}, label), /*#__PURE__*/React.createElement("input", {
|
|
30
|
+
type: "text",
|
|
31
|
+
className: "Input__input",
|
|
32
|
+
placeholder: placeholder,
|
|
33
|
+
value: value,
|
|
34
|
+
onChange: function onChange(e) {
|
|
35
|
+
_onChange(e.target.value);
|
|
36
|
+
},
|
|
37
|
+
"data-test-id": dataTestId
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TextInput","label","value","onChange","placeholder","dataTestId","e","target"],"sources":["TextInput.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport \"./Input.css\";\n\nimport * as React from \"react\";\n\ntype Props = Readonly<{\n \"data-test-id\"?: string;\n label: string;\n onChange: (val: string) => void;\n placeholder?: string;\n value: string;\n}>;\n\nexport default function TextInput({\n label,\n value,\n onChange,\n placeholder = \"\",\n \"data-test-id\": dataTestId\n}: Props): JSX.Element {\n return (\n <div className=\"Input__wrapper\">\n <label className=\"Input__label\">{label}</label>\n <input\n type=\"text\"\n className=\"Input__input\"\n placeholder={placeholder}\n value={value}\n onChange={e => {\n onChange(e.target.value);\n }}\n data-test-id={dataTestId}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;AAQA;AAEA;AAVA;AACA;AACA;AACA;AACA;AACA;AACA;;AAce,SAASA,SAAS,OAMV;EAAA,IALnBC,KAAK,QAALA,KAAK;IACLC,KAAK,QAALA,KAAK;IACLC,SAAQ,QAARA,QAAQ;IAAA,wBACRC,WAAW;IAAXA,WAAW,iCAAG,EAAE;IACAC,UAAU,QAA1B,cAAc;EAEd,oBACI;IAAK,SAAS,EAAC;EAAgB,gBAC3B;IAAO,SAAS,EAAC;EAAc,GAAEJ,KAAK,CAAS,eAC/C;IACI,IAAI,EAAC,MAAM;IACX,SAAS,EAAC,cAAc;IACxB,WAAW,EAAEG,WAAY;IACzB,KAAK,EAAEF,KAAM;IACb,QAAQ,EAAE,kBAAAI,CAAC,EAAI;MACXH,SAAQ,CAACG,CAAC,CAACC,MAAM,CAACL,KAAK,CAAC;IAC5B,CAAE;IACF,gBAAcG;EAAW,EAC3B,CACA;AAEd"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
interface ToolbarActionDialogProps {
|
|
3
|
+
disabled: boolean;
|
|
4
|
+
buttonLabel?: string;
|
|
5
|
+
buttonAriaLabel: string;
|
|
6
|
+
buttonClassName: string;
|
|
7
|
+
buttonIconClassName: string;
|
|
8
|
+
children: React.ReactNode | React.ReactNode[];
|
|
9
|
+
stopCloseOnClickSelf?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const ToolbarActionDialog: React.FC<ToolbarActionDialogProps>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.ToolbarActionDialog = void 0;
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
function MenuContainer(_ref) {
|
|
12
|
+
var children = _ref.children,
|
|
13
|
+
menuContainerRef = _ref.menuContainerRef,
|
|
14
|
+
onClose = _ref.onClose;
|
|
15
|
+
var handleKeyDown = function handleKeyDown(event) {
|
|
16
|
+
var key = event.key;
|
|
17
|
+
if (["Escape", "ArrowUp", "ArrowDown", "Tab"].includes(key)) {
|
|
18
|
+
event.preventDefault();
|
|
19
|
+
}
|
|
20
|
+
if (key === "Escape" || key === "Tab") {
|
|
21
|
+
onClose();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var handleContainerClick = function handleContainerClick(e) {
|
|
25
|
+
e.preventDefault();
|
|
26
|
+
console.log("click", e);
|
|
27
|
+
};
|
|
28
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
29
|
+
style: {
|
|
30
|
+
position: "relative"
|
|
31
|
+
}
|
|
32
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
33
|
+
onClick: function onClick(e) {
|
|
34
|
+
return handleContainerClick(e);
|
|
35
|
+
},
|
|
36
|
+
style: {
|
|
37
|
+
position: "absolute",
|
|
38
|
+
top: -10,
|
|
39
|
+
left: 0,
|
|
40
|
+
width: 240,
|
|
41
|
+
backgroundColor: "#fff"
|
|
42
|
+
},
|
|
43
|
+
ref: menuContainerRef !== null && menuContainerRef !== void 0 ? menuContainerRef : null,
|
|
44
|
+
onKeyDown: handleKeyDown
|
|
45
|
+
}, children));
|
|
46
|
+
}
|
|
47
|
+
var ToolbarActionDialog = function ToolbarActionDialog(_ref2) {
|
|
48
|
+
var disabled = _ref2.disabled,
|
|
49
|
+
buttonAriaLabel = _ref2.buttonAriaLabel,
|
|
50
|
+
buttonClassName = _ref2.buttonClassName,
|
|
51
|
+
buttonIconClassName = _ref2.buttonIconClassName,
|
|
52
|
+
buttonLabel = _ref2.buttonLabel,
|
|
53
|
+
children = _ref2.children,
|
|
54
|
+
stopCloseOnClickSelf = _ref2.stopCloseOnClickSelf;
|
|
55
|
+
var menuWindowRef = (0, React.useRef)(null);
|
|
56
|
+
var _useState = (0, React.useState)(false),
|
|
57
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
58
|
+
showDropDown = _useState2[0],
|
|
59
|
+
setShowDropDown = _useState2[1];
|
|
60
|
+
var handleClose = function handleClose() {
|
|
61
|
+
if (menuWindowRef && menuWindowRef.current) {
|
|
62
|
+
setShowDropDown(false);
|
|
63
|
+
menuWindowRef.current.focus();
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
(0, React.useEffect)(function () {
|
|
67
|
+
if (!showDropDown) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
var handle = function handle(event) {
|
|
71
|
+
/* const target = event.target;
|
|
72
|
+
if (!button.contains(target as Node)) {
|
|
73
|
+
setShowDropDown(false);
|
|
74
|
+
}*/
|
|
75
|
+
console.log("handle", event);
|
|
76
|
+
};
|
|
77
|
+
document.addEventListener("click", handle);
|
|
78
|
+
return function () {
|
|
79
|
+
document.removeEventListener("click", handle);
|
|
80
|
+
};
|
|
81
|
+
}, [showDropDown, stopCloseOnClickSelf]);
|
|
82
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
83
|
+
style: {
|
|
84
|
+
position: "relative"
|
|
85
|
+
}
|
|
86
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
87
|
+
style: {
|
|
88
|
+
position: "relative"
|
|
89
|
+
},
|
|
90
|
+
disabled: disabled,
|
|
91
|
+
"aria-label": buttonAriaLabel || buttonLabel,
|
|
92
|
+
className: buttonClassName,
|
|
93
|
+
onClick: function onClick() {
|
|
94
|
+
setShowDropDown(!showDropDown);
|
|
95
|
+
}
|
|
96
|
+
}, buttonIconClassName && /*#__PURE__*/React.createElement("span", {
|
|
97
|
+
className: buttonIconClassName
|
|
98
|
+
}), buttonLabel && /*#__PURE__*/React.createElement("span", {
|
|
99
|
+
className: "text dropdown-button-text"
|
|
100
|
+
}, buttonLabel), /*#__PURE__*/React.createElement("i", {
|
|
101
|
+
className: "chevron-down"
|
|
102
|
+
})), showDropDown && /*#__PURE__*/React.createElement(MenuContainer, {
|
|
103
|
+
onClose: handleClose
|
|
104
|
+
}, children));
|
|
105
|
+
};
|
|
106
|
+
exports.ToolbarActionDialog = ToolbarActionDialog;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MenuContainer","children","menuContainerRef","onClose","handleKeyDown","event","key","includes","preventDefault","handleContainerClick","e","console","log","position","top","left","width","backgroundColor","ToolbarActionDialog","disabled","buttonAriaLabel","buttonClassName","buttonIconClassName","buttonLabel","stopCloseOnClickSelf","menuWindowRef","useRef","useState","showDropDown","setShowDropDown","handleClose","current","focus","useEffect","handle","document","addEventListener","removeEventListener"],"sources":["ToolbarActionDialog.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport * as React from \"react\";\n\nfunction MenuContainer({\n children,\n menuContainerRef,\n onClose\n}: {\n children: React.ReactNode | React.ReactNode[];\n menuContainerRef?: React.Ref<HTMLDivElement>;\n onClose: () => void;\n}) {\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const key = event.key;\n\n if ([\"Escape\", \"ArrowUp\", \"ArrowDown\", \"Tab\"].includes(key)) {\n event.preventDefault();\n }\n\n if (key === \"Escape\" || key === \"Tab\") {\n onClose();\n }\n };\n\n const handleContainerClick = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {\n e.preventDefault();\n console.log(\"click\", e);\n };\n\n return (\n <div style={{ position: \"relative\" }}>\n <div\n onClick={e => handleContainerClick(e)}\n style={{\n position: \"absolute\",\n top: -10,\n left: 0,\n width: 240,\n backgroundColor: \"#fff\"\n }}\n ref={menuContainerRef ?? null}\n onKeyDown={handleKeyDown}\n >\n {children}\n </div>\n </div>\n );\n}\ninterface ToolbarActionDialogProps {\n disabled: boolean;\n buttonLabel?: string;\n buttonAriaLabel: string;\n buttonClassName: string;\n buttonIconClassName: string;\n children: React.ReactNode | React.ReactNode[];\n stopCloseOnClickSelf?: boolean;\n}\n\nexport const ToolbarActionDialog: React.FC<ToolbarActionDialogProps> = ({\n disabled,\n buttonAriaLabel,\n buttonClassName,\n buttonIconClassName,\n buttonLabel,\n children,\n stopCloseOnClickSelf\n}): JSX.Element => {\n const menuWindowRef = useRef<HTMLDivElement>(null);\n const [showDropDown, setShowDropDown] = useState(false);\n\n const handleClose = () => {\n if (menuWindowRef && menuWindowRef.current) {\n setShowDropDown(false);\n menuWindowRef.current.focus();\n }\n };\n\n useEffect(() => {\n if (!showDropDown) {\n return;\n }\n\n const handle = (event: MouseEvent) => {\n /* const target = event.target;\n if (!button.contains(target as Node)) {\n setShowDropDown(false);\n }*/\n console.log(\"handle\", event);\n };\n document.addEventListener(\"click\", handle);\n\n return () => {\n document.removeEventListener(\"click\", handle);\n };\n }, [showDropDown, stopCloseOnClickSelf]);\n\n return (\n <div style={{ position: \"relative\" }}>\n <button\n style={{ position: \"relative\" }}\n disabled={disabled}\n aria-label={buttonAriaLabel || buttonLabel}\n className={buttonClassName}\n onClick={() => {\n setShowDropDown(!showDropDown);\n }}\n >\n {buttonIconClassName && <span className={buttonIconClassName} />}\n {buttonLabel && <span className=\"text dropdown-button-text\">{buttonLabel}</span>}\n <i className=\"chevron-down\" />\n </button>\n {showDropDown && <MenuContainer onClose={handleClose}>{children}</MenuContainer>}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;AAAA;AAGA,SAASA,aAAa,OAQnB;EAAA,IAPCC,QAAQ,QAARA,QAAQ;IACRC,gBAAgB,QAAhBA,gBAAgB;IAChBC,OAAO,QAAPA,OAAO;EAMP,IAAMC,aAAa,GAAG,SAAhBA,aAAa,CAAIC,KAA0C,EAAK;IAClE,IAAMC,GAAG,GAAGD,KAAK,CAACC,GAAG;IAErB,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,C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|
+
});
|
|
6
|
+
exports.generateInitialLexicalValue = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* @description Basic JSON data string that will initialize the editor.
|
|
9
|
+
*/
|
|
10
|
+
var generateInitialLexicalValue = function generateInitialLexicalValue() {
|
|
11
|
+
return JSON.stringify({
|
|
12
|
+
root: {
|
|
13
|
+
children: [{
|
|
14
|
+
children: [],
|
|
15
|
+
direction: null,
|
|
16
|
+
format: "",
|
|
17
|
+
indent: 0,
|
|
18
|
+
type: "paragraph",
|
|
19
|
+
version: 1
|
|
20
|
+
}],
|
|
21
|
+
direction: null,
|
|
22
|
+
format: "",
|
|
23
|
+
indent: 0,
|
|
24
|
+
type: "root",
|
|
25
|
+
version: 1
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
exports.generateInitialLexicalValue = generateInitialLexicalValue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["generateInitialLexicalValue","JSON","stringify","root","children","direction","format","indent","type","version"],"sources":["generateInitialLexicalValue.ts"],"sourcesContent":["import { LexicalValue } from \"~/types\";\n\n/**\n * @description Basic JSON data string that will initialize the editor.\n */\nexport const generateInitialLexicalValue = (): LexicalValue => {\n return JSON.stringify({\n root: {\n children: [\n {\n children: [],\n direction: null,\n format: \"\",\n indent: 0,\n type: \"paragraph\",\n version: 1\n }\n ],\n direction: null,\n format: \"\",\n indent: 0,\n type: \"root\",\n version: 1\n }\n });\n};\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACO,IAAMA,2BAA2B,GAAG,SAA9BA,2BAA2B,GAAuB;EAC3D,OAAOC,IAAI,CAACC,SAAS,CAAC;IAClBC,IAAI,EAAE;MACFC,QAAQ,EAAE,CACN;QACIA,QAAQ,EAAE,EAAE;QACZC,SAAS,EAAE,IAAI;QACfC,MAAM,EAAE,EAAE;QACVC,MAAM,EAAE,CAAC;QACTC,IAAI,EAAE,WAAW;QACjBC,OAAO,EAAE;MACb,CAAC,CACJ;MACDJ,SAAS,EAAE,IAAI;MACfC,MAAM,EAAE,EAAE;MACVC,MAAM,EAAE,CAAC;MACTC,IAAI,EAAE,MAAM;MACZC,OAAO,EAAE;IACb;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="web" />
|
|
2
|
+
/// <reference types="react" />
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export declare function getDOMRangeRect(nativeSelection: Selection, rootElement: HTMLElement): DOMRect;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getDOMRangeRect = getDOMRangeRect;
|
|
7
|
+
/**
|
|
8
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the MIT license found in the
|
|
11
|
+
* LICENSE file in the root directory of this source tree.
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
function getDOMRangeRect(nativeSelection, rootElement) {
|
|
15
|
+
var domRange = nativeSelection.getRangeAt(0);
|
|
16
|
+
var rect;
|
|
17
|
+
if (nativeSelection.anchorNode === rootElement) {
|
|
18
|
+
var inner = rootElement;
|
|
19
|
+
while (inner.firstElementChild != null) {
|
|
20
|
+
inner = inner.firstElementChild;
|
|
21
|
+
}
|
|
22
|
+
rect = inner.getBoundingClientRect();
|
|
23
|
+
} else {
|
|
24
|
+
rect = domRange.getBoundingClientRect();
|
|
25
|
+
}
|
|
26
|
+
return rect;
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getDOMRangeRect","nativeSelection","rootElement","domRange","getRangeAt","rect","anchorNode","inner","firstElementChild","getBoundingClientRect"],"sources":["getDOMRangeRect.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nexport function getDOMRangeRect(nativeSelection: Selection, rootElement: HTMLElement): DOMRect {\n const domRange = nativeSelection.getRangeAt(0);\n\n let rect;\n\n if (nativeSelection.anchorNode === rootElement) {\n let inner = rootElement;\n while (inner.firstElementChild != null) {\n inner = inner.firstElementChild as HTMLElement;\n }\n rect = inner.getBoundingClientRect();\n } else {\n rect = domRange.getBoundingClientRect();\n }\n\n return rect;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAe,CAACC,eAA0B,EAAEC,WAAwB,EAAW;EAC3F,IAAMC,QAAQ,GAAGF,eAAe,CAACG,UAAU,CAAC,CAAC,CAAC;EAE9C,IAAIC,IAAI;EAER,IAAIJ,eAAe,CAACK,UAAU,KAAKJ,WAAW,EAAE;IAC5C,IAAIK,KAAK,GAAGL,WAAW;IACvB,OAAOK,KAAK,CAACC,iBAAiB,IAAI,IAAI,EAAE;MACpCD,KAAK,GAAGA,KAAK,CAACC,iBAAgC;IAClD;IACAH,IAAI,GAAGE,KAAK,CAACE,qBAAqB,EAAE;EACxC,CAAC,MAAM;IACHJ,IAAI,GAAGF,QAAQ,CAACM,qBAAqB,EAAE;EAC3C;EAEA,OAAOJ,IAAI;AACf"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TextFormatting, TextBlockSelection, ToolbarState } from "../types";
|
|
2
|
+
import { ElementNode, LexicalEditor, LexicalNode, RangeSelection, TextNode } from "lexical";
|
|
3
|
+
export declare const getSelectionTextFormat: (selection: RangeSelection | undefined) => TextFormatting;
|
|
4
|
+
export declare const getToolbarState: (selection: RangeSelection, node: LexicalNode, parent: LexicalNode | null, element: LexicalNode | null, anchorNode: ElementNode | TextNode) => ToolbarState;
|
|
5
|
+
export declare const getLexicalTextSelectionState: (activeEditor: LexicalEditor, selection: RangeSelection) => TextBlockSelection | null;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getToolbarState = exports.getSelectionTextFormat = exports.getLexicalTextSelectionState = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _lexical = require("lexical");
|
|
10
|
+
var _utils = require("@lexical/utils");
|
|
11
|
+
var _getSelectedNode = require("./getSelectedNode");
|
|
12
|
+
var _link = require("@lexical/link");
|
|
13
|
+
var _WebinyListNode = require("../nodes/list-node/WebinyListNode");
|
|
14
|
+
var _richText = require("@lexical/rich-text");
|
|
15
|
+
var _TypographyElementNode = require("../nodes/TypographyElementNode");
|
|
16
|
+
var _FontColorNode = require("../nodes/FontColorNode");
|
|
17
|
+
var _WebinyQuoteNode = require("../nodes/WebinyQuoteNode");
|
|
18
|
+
var getSelectionTextFormat = function getSelectionTextFormat(selection) {
|
|
19
|
+
return !(0, _lexical.$isRangeSelection)(selection) ? {
|
|
20
|
+
italic: false,
|
|
21
|
+
bold: false,
|
|
22
|
+
underline: false,
|
|
23
|
+
code: false
|
|
24
|
+
} : {
|
|
25
|
+
bold: selection.hasFormat("bold"),
|
|
26
|
+
italic: selection.hasFormat("italic"),
|
|
27
|
+
underline: selection.hasFormat("underline"),
|
|
28
|
+
code: selection.hasFormat("code")
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
exports.getSelectionTextFormat = getSelectionTextFormat;
|
|
32
|
+
var getDefaultToolbarState = function getDefaultToolbarState() {
|
|
33
|
+
return {
|
|
34
|
+
bold: false,
|
|
35
|
+
italic: false,
|
|
36
|
+
underline: false,
|
|
37
|
+
code: false,
|
|
38
|
+
link: {
|
|
39
|
+
isSelected: false
|
|
40
|
+
},
|
|
41
|
+
list: {
|
|
42
|
+
isSelected: false
|
|
43
|
+
},
|
|
44
|
+
typography: {
|
|
45
|
+
isSelected: false
|
|
46
|
+
},
|
|
47
|
+
fontColor: {
|
|
48
|
+
isSelected: false
|
|
49
|
+
},
|
|
50
|
+
quote: {
|
|
51
|
+
isSelected: false
|
|
52
|
+
},
|
|
53
|
+
textType: undefined
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
var getToolbarState = function getToolbarState(selection, node, parent, element, anchorNode) {
|
|
57
|
+
var textFormat = getSelectionTextFormat(selection);
|
|
58
|
+
var state = getDefaultToolbarState();
|
|
59
|
+
state = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state), {}, {
|
|
60
|
+
bold: textFormat.bold,
|
|
61
|
+
italic: textFormat.italic,
|
|
62
|
+
underline: textFormat.underline,
|
|
63
|
+
code: textFormat.code
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// link
|
|
67
|
+
state.link.isSelected = (0, _link.$isLinkNode)(parent) || (0, _link.$isLinkNode)(node);
|
|
68
|
+
if (state.link.isSelected) {
|
|
69
|
+
state.textType = "link";
|
|
70
|
+
}
|
|
71
|
+
// font color
|
|
72
|
+
if ((0, _FontColorNode.$isFontColorNode)(node)) {
|
|
73
|
+
state.fontColor.isSelected = true;
|
|
74
|
+
}
|
|
75
|
+
if ((0, _WebinyListNode.$isWebinyListNode)(element)) {
|
|
76
|
+
var parentList = (0, _utils.$getNearestNodeOfType)(anchorNode, _WebinyListNode.WebinyListNode);
|
|
77
|
+
var type = parentList ? parentList.getListType() : element.getListType();
|
|
78
|
+
state.textType = type;
|
|
79
|
+
}
|
|
80
|
+
if ((0, _richText.$isHeadingNode)(node) || (0, _richText.$isHeadingNode)(element)) {
|
|
81
|
+
state.textType = "heading";
|
|
82
|
+
}
|
|
83
|
+
if ((0, _lexical.$isParagraphNode)(element)) {
|
|
84
|
+
state.textType = "paragraph";
|
|
85
|
+
}
|
|
86
|
+
if ((0, _TypographyElementNode.$isTypographyElementNode)(element)) {
|
|
87
|
+
state.typography.isSelected = true;
|
|
88
|
+
var value = element === null || element === void 0 ? void 0 : element.getTypographyValue();
|
|
89
|
+
if (value.tag.includes("h")) {
|
|
90
|
+
state.textType = "heading";
|
|
91
|
+
}
|
|
92
|
+
if (value.tag.includes("p")) {
|
|
93
|
+
state.textType = "paragraph";
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if ((0, _TypographyElementNode.$isTypographyElementNode)(element)) {
|
|
97
|
+
state.fontColor.isSelected = true;
|
|
98
|
+
}
|
|
99
|
+
if ((0, _WebinyQuoteNode.$isWebinyQuoteNode)(element)) {
|
|
100
|
+
state.textType = "quoteblock";
|
|
101
|
+
state.quote.isSelected = true;
|
|
102
|
+
}
|
|
103
|
+
return state;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/*
|
|
107
|
+
* @desc Get selection data and provide processed toolbar state and data about the text, element and parent nodes.
|
|
108
|
+
*/
|
|
109
|
+
exports.getToolbarState = getToolbarState;
|
|
110
|
+
var getLexicalTextSelectionState = function getLexicalTextSelectionState(activeEditor, selection) {
|
|
111
|
+
if ((0, _lexical.$isRangeSelection)(selection)) {
|
|
112
|
+
var anchorNode = selection.anchor.getNode();
|
|
113
|
+
var element = anchorNode.getKey() === "root" ? anchorNode : (0, _utils.$findMatchingParent)(anchorNode, function (e) {
|
|
114
|
+
var parent = e.getParent();
|
|
115
|
+
return parent !== null && (0, _lexical.$isRootOrShadowRoot)(parent);
|
|
116
|
+
});
|
|
117
|
+
if (element === null) {
|
|
118
|
+
element = anchorNode.getTopLevelElementOrThrow();
|
|
119
|
+
}
|
|
120
|
+
var elementKey = element.getKey();
|
|
121
|
+
var elementDOM = activeEditor.getElementByKey(elementKey);
|
|
122
|
+
|
|
123
|
+
// Update links
|
|
124
|
+
var node = (0, _getSelectedNode.getSelectedNode)(selection);
|
|
125
|
+
var parent = node.getParent();
|
|
126
|
+
var isElementDom = elementDOM !== null;
|
|
127
|
+
return {
|
|
128
|
+
// node/element data from selection
|
|
129
|
+
elementKey: elementKey,
|
|
130
|
+
element: element,
|
|
131
|
+
parent: parent,
|
|
132
|
+
node: node,
|
|
133
|
+
anchorNode: anchorNode,
|
|
134
|
+
selection: selection,
|
|
135
|
+
isElementDom: isElementDom,
|
|
136
|
+
state: getToolbarState(selection, node, parent, element, anchorNode)
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
return null;
|
|
140
|
+
};
|
|
141
|
+
exports.getLexicalTextSelectionState = getLexicalTextSelectionState;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getSelectionTextFormat","selection","$isRangeSelection","italic","bold","underline","code","hasFormat","getDefaultToolbarState","link","isSelected","list","typography","fontColor","quote","textType","undefined","getToolbarState","node","parent","element","anchorNode","textFormat","state","$isLinkNode","$isFontColorNode","$isWebinyListNode","parentList","$getNearestNodeOfType","WebinyListNode","type","getListType","$isHeadingNode","$isParagraphNode","$isTypographyElementNode","value","getTypographyValue","tag","includes","$isWebinyQuoteNode","getLexicalTextSelectionState","activeEditor","anchor","getNode","getKey","$findMatchingParent","e","getParent","$isRootOrShadowRoot","getTopLevelElementOrThrow","elementKey","elementDOM","getElementByKey","getSelectedNode","isElementDom"],"sources":["getLexicalTextSelectionState.ts"],"sourcesContent":["import { TextFormatting, TextBlockSelection, ToolbarState, TypographyValue } from \"~/types\";\nimport {\n $isParagraphNode,\n $isRangeSelection,\n $isRootOrShadowRoot,\n ElementNode,\n LexicalEditor,\n LexicalNode,\n RangeSelection,\n TextNode\n} from \"lexical\";\nimport { $findMatchingParent, $getNearestNodeOfType } from \"@lexical/utils\";\nimport { getSelectedNode } from \"~/utils/getSelectedNode\";\nimport { $isLinkNode } from \"@lexical/link\";\nimport { $isWebinyListNode, WebinyListNode } from \"~/nodes/list-node/WebinyListNode\";\nimport { $isHeadingNode } from \"@lexical/rich-text\";\nimport { $isTypographyElementNode } from \"~/nodes/TypographyElementNode\";\nimport { $isFontColorNode } from \"~/nodes/FontColorNode\";\nimport { $isWebinyQuoteNode } from \"~/nodes/WebinyQuoteNode\";\n\nexport const getSelectionTextFormat = (selection: RangeSelection | undefined): TextFormatting => {\n return !$isRangeSelection(selection)\n ? {\n italic: false,\n bold: false,\n underline: false,\n code: false\n }\n : {\n bold: selection.hasFormat(\"bold\"),\n italic: selection.hasFormat(\"italic\"),\n underline: selection.hasFormat(\"underline\"),\n code: selection.hasFormat(\"code\")\n };\n};\n\nconst getDefaultToolbarState = (): ToolbarState => {\n return {\n bold: false,\n italic: false,\n underline: false,\n code: false,\n link: { isSelected: false },\n list: { isSelected: false },\n typography: { isSelected: false },\n fontColor: { isSelected: false },\n quote: { isSelected: false },\n textType: undefined\n };\n};\n\nexport const getToolbarState = (\n selection: RangeSelection,\n node: LexicalNode,\n parent: LexicalNode | null,\n element: LexicalNode | null,\n anchorNode: ElementNode | TextNode\n): ToolbarState => {\n const textFormat = getSelectionTextFormat(selection);\n let state: ToolbarState = getDefaultToolbarState();\n state = {\n ...state,\n bold: textFormat.bold,\n italic: textFormat.italic,\n underline: textFormat.underline,\n code: textFormat.code\n };\n\n // link\n state.link.isSelected = $isLinkNode(parent) || $isLinkNode(node);\n if (state.link.isSelected) {\n state.textType = \"link\";\n }\n // font color\n if ($isFontColorNode(node)) {\n state.fontColor.isSelected = true;\n }\n if ($isWebinyListNode(element)) {\n const parentList = $getNearestNodeOfType<WebinyListNode>(anchorNode, WebinyListNode);\n const type = parentList ? parentList.getListType() : element.getListType();\n state.textType = type;\n }\n if ($isHeadingNode(node) || $isHeadingNode(element)) {\n state.textType = \"heading\";\n }\n if ($isParagraphNode(element)) {\n state.textType = \"paragraph\";\n }\n if ($isTypographyElementNode(element)) {\n state.typography.isSelected = true;\n const value = element?.getTypographyValue() as TypographyValue;\n if (value.tag.includes(\"h\")) {\n state.textType = \"heading\";\n }\n if (value.tag.includes(\"p\")) {\n state.textType = \"paragraph\";\n }\n }\n if ($isTypographyElementNode(element)) {\n state.fontColor.isSelected = true;\n }\n if ($isWebinyQuoteNode(element)) {\n state.textType = \"quoteblock\";\n state.quote.isSelected = true;\n }\n\n return state;\n};\n\n/*\n * @desc Get selection data and provide processed toolbar state and data about the text, element and parent nodes.\n */\nexport const getLexicalTextSelectionState = (\n activeEditor: LexicalEditor,\n selection: RangeSelection\n): TextBlockSelection | null => {\n if ($isRangeSelection(selection)) {\n const anchorNode = selection.anchor.getNode();\n let element =\n anchorNode.getKey() === \"root\"\n ? anchorNode\n : $findMatchingParent(anchorNode, e => {\n const parent = e.getParent();\n return parent !== null && $isRootOrShadowRoot(parent);\n });\n\n if (element === null) {\n element = anchorNode.getTopLevelElementOrThrow();\n }\n\n const elementKey = element.getKey();\n const elementDOM = activeEditor.getElementByKey(elementKey);\n\n // Update links\n const node = getSelectedNode(selection);\n const parent = node.getParent();\n const isElementDom = elementDOM !== null;\n\n return {\n // node/element data from selection\n elementKey,\n element,\n parent,\n node,\n anchorNode,\n selection,\n isElementDom,\n state: getToolbarState(selection, node, parent, element, anchorNode)\n };\n }\n return null;\n};\n"],"mappings":";;;;;;;;AACA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEO,IAAMA,sBAAsB,GAAG,SAAzBA,sBAAsB,CAAIC,SAAqC,EAAqB;EAC7F,OAAO,CAAC,IAAAC,0BAAiB,EAACD,SAAS,CAAC,GAC9B;IACIE,MAAM,EAAE,KAAK;IACbC,IAAI,EAAE,KAAK;IACXC,SAAS,EAAE,KAAK;IAChBC,IAAI,EAAE;EACV,CAAC,GACD;IACIF,IAAI,EAAEH,SAAS,CAACM,SAAS,CAAC,MAAM,CAAC;IACjCJ,MAAM,EAAEF,SAAS,CAACM,SAAS,CAAC,QAAQ,CAAC;IACrCF,SAAS,EAAEJ,SAAS,CAACM,SAAS,CAAC,WAAW,CAA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;EACA,OAAO,IAAI;AACf,CAAC;AAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getSelectedNode = getSelectedNode;
|
|
7
|
+
var _selection = require("@lexical/selection");
|
|
8
|
+
/**
|
|
9
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
10
|
+
*
|
|
11
|
+
* This source code is licensed under the MIT license found in the
|
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
function getSelectedNode(selection) {
|
|
17
|
+
var anchor = selection.anchor;
|
|
18
|
+
var focus = selection.focus;
|
|
19
|
+
var anchorNode = selection.anchor.getNode();
|
|
20
|
+
var focusNode = selection.focus.getNode();
|
|
21
|
+
if (anchorNode === focusNode) {
|
|
22
|
+
return anchorNode;
|
|
23
|
+
}
|
|
24
|
+
var isBackward = selection.isBackward();
|
|
25
|
+
if (isBackward) {
|
|
26
|
+
return (0, _selection.$isAtNodeEnd)(focus) ? anchorNode : focusNode;
|
|
27
|
+
} else {
|
|
28
|
+
return (0, _selection.$isAtNodeEnd)(anchor) ? focusNode : anchorNode;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getSelectedNode","selection","anchor","focus","anchorNode","getNode","focusNode","isBackward","$isAtNodeEnd"],"sources":["getSelectedNode.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport { $isAtNodeEnd } from \"@lexical/selection\";\nimport { ElementNode, RangeSelection, TextNode } from \"lexical\";\n\nexport function getSelectedNode(selection: RangeSelection): TextNode | ElementNode {\n const anchor = selection.anchor;\n const focus = selection.focus;\n const anchorNode = selection.anchor.getNode();\n const focusNode = selection.focus.getNode();\n if (anchorNode === focusNode) {\n return anchorNode;\n }\n const isBackward = selection.isBackward();\n if (isBackward) {\n return $isAtNodeEnd(focus) ? anchorNode : focusNode;\n } else {\n return $isAtNodeEnd(anchor) ? focusNode : anchorNode;\n }\n}\n"],"mappings":";;;;;;AAOA;AAPA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIO,SAASA,eAAe,CAACC,SAAyB,EAA0B;EAC/E,IAAMC,MAAM,GAAGD,SAAS,CAACC,MAAM;EAC/B,IAAMC,KAAK,GAAGF,SAAS,CAACE,KAAK;EAC7B,IAAMC,UAAU,GAAGH,SAAS,CAACC,MAAM,CAACG,OAAO,EAAE;EAC7C,IAAMC,SAAS,GAAGL,SAAS,CAACE,KAAK,CAACE,OAAO,EAAE;EAC3C,IAAID,UAAU,KAAKE,SAAS,EAAE;IAC1B,OAAOF,UAAU;EACrB;EACA,IAAMG,UAAU,GAAGN,SAAS,CAACM,UAAU,EAAE;EACzC,IAAIA,UAAU,EAAE;IACZ,OAAO,IAAAC,uBAAY,EAACL,KAAK,CAAC,GAAGC,UAAU,GAAGE,SAAS;EACvD,CAAC,MAAM;IACH,OAAO,IAAAE,uBAAY,EAACN,MAAM,CAAC,GAAGI,SAAS,GAAGF,UAAU;EACxD;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isValidJSON: (value: string | undefined | null) => boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isValidJSON = void 0;
|
|
7
|
+
var isValidJSON = function isValidJSON(value) {
|
|
8
|
+
if (!value) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
var o = JSON.parse(value);
|
|
13
|
+
return !!o && typeof o === "object" && !Array.isArray(o);
|
|
14
|
+
} catch (_unused) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
exports.isValidJSON = isValidJSON;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isValidJSON","value","o","JSON","parse","Array","isArray"],"sources":["isValidJSON.ts"],"sourcesContent":["export const isValidJSON = (value: string | undefined | null): boolean => {\n if (!value) {\n return false;\n }\n try {\n const o = JSON.parse(value);\n return !!o && typeof o === \"object\" && !Array.isArray(o);\n } catch {\n return false;\n }\n};\n"],"mappings":";;;;;;AAAO,IAAMA,WAAW,GAAG,SAAdA,WAAW,CAAIC,KAAgC,EAAc;EACtE,IAAI,CAACA,KAAK,EAAE;IACR,OAAO,KAAK;EAChB;EACA,IAAI;IACA,IAAMC,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACH,KAAK,CAAC;IAC3B,OAAO,CAAC,CAACC,CAAC,IAAI,OAAOA,CAAC,KAAK,QAAQ,IAAI,CAACG,KAAK,CAACC,OAAO,CAACJ,CAAC,CAAC;EAC5D,CAAC,CAAC,gBAAM;IACJ,OAAO,KAAK;EAChB;AACJ,CAAC;AAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isValidLexicalData = void 0;
|
|
7
|
+
var _isValidJSON = require("./isValidJSON");
|
|
8
|
+
/*
|
|
9
|
+
* @description Checks for valid lexical data.
|
|
10
|
+
*
|
|
11
|
+
* Check for first level of properties that empty editor state data need to have.
|
|
12
|
+
* @see generateInitialLexicalValue
|
|
13
|
+
*/
|
|
14
|
+
var isValidLexicalData = function isValidLexicalData(editorStateValue) {
|
|
15
|
+
if (!editorStateValue) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
if (!(0, _isValidJSON.isValidJSON)(editorStateValue)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
var data = JSON.parse(editorStateValue);
|
|
22
|
+
return !!data["root"];
|
|
23
|
+
};
|
|
24
|
+
exports.isValidLexicalData = isValidLexicalData;
|