@webiny/lexical-editor 5.43.2 → 6.0.0-alpha.0

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.
Files changed (196) hide show
  1. package/commands/image.js +2 -8
  2. package/commands/image.js.map +1 -1
  3. package/commands/index.js +4 -49
  4. package/commands/index.js.map +1 -1
  5. package/commands/list.js +4 -10
  6. package/commands/list.js.map +1 -1
  7. package/commands/quote.js +2 -8
  8. package/commands/quote.js.map +1 -1
  9. package/commands/toolbar.js +2 -8
  10. package/commands/toolbar.js.map +1 -1
  11. package/components/Editor/EnsureHeadingTagPlugin.js +10 -16
  12. package/components/Editor/EnsureHeadingTagPlugin.js.map +1 -1
  13. package/components/Editor/HeadingEditor.js +13 -21
  14. package/components/Editor/HeadingEditor.js.map +1 -1
  15. package/components/Editor/ParagraphEditor.js +12 -19
  16. package/components/Editor/ParagraphEditor.js.map +1 -1
  17. package/components/Editor/RichTextEditor.js +92 -105
  18. package/components/Editor/RichTextEditor.js.map +1 -1
  19. package/components/Editor/normalizeInputValue.js +2 -8
  20. package/components/Editor/normalizeInputValue.js.map +1 -1
  21. package/components/LexicalEditorConfig/LexicalEditorConfig.js +39 -49
  22. package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -1
  23. package/components/LexicalEditorConfig/components/Node.js +17 -26
  24. package/components/LexicalEditorConfig/components/Node.js.map +1 -1
  25. package/components/LexicalEditorConfig/components/Plugin.js +17 -26
  26. package/components/LexicalEditorConfig/components/Plugin.js.map +1 -1
  27. package/components/LexicalEditorConfig/components/ToolbarElement.js +17 -26
  28. package/components/LexicalEditorConfig/components/ToolbarElement.js.map +1 -1
  29. package/components/LexicalHtmlRenderer.js +37 -46
  30. package/components/LexicalHtmlRenderer.js.map +1 -1
  31. package/components/Toolbar/StaticToolbar.d.ts +3 -1
  32. package/components/Toolbar/StaticToolbar.js +19 -23
  33. package/components/Toolbar/StaticToolbar.js.map +1 -1
  34. package/components/Toolbar/Toolbar.js +66 -75
  35. package/components/Toolbar/Toolbar.js.map +1 -1
  36. package/components/ToolbarActions/BoldAction.js +16 -21
  37. package/components/ToolbarActions/BoldAction.js.map +1 -1
  38. package/components/ToolbarActions/BulletListAction.js +26 -31
  39. package/components/ToolbarActions/BulletListAction.js.map +1 -1
  40. package/components/ToolbarActions/CodeHighlightAction.js +16 -21
  41. package/components/ToolbarActions/CodeHighlightAction.js.map +1 -1
  42. package/components/ToolbarActions/FontColorAction.js +32 -42
  43. package/components/ToolbarActions/FontColorAction.js.map +1 -1
  44. package/components/ToolbarActions/FontSizeAction.js +53 -71
  45. package/components/ToolbarActions/FontSizeAction.js.map +1 -1
  46. package/components/ToolbarActions/ImageAction.js +19 -34
  47. package/components/ToolbarActions/ImageAction.js.map +1 -1
  48. package/components/ToolbarActions/ItalicAction.js +16 -21
  49. package/components/ToolbarActions/ItalicAction.js.map +1 -1
  50. package/components/ToolbarActions/LinkAction.js +19 -24
  51. package/components/ToolbarActions/LinkAction.js.map +1 -1
  52. package/components/ToolbarActions/NumberedListAction.js +26 -33
  53. package/components/ToolbarActions/NumberedListAction.js.map +1 -1
  54. package/components/ToolbarActions/QuoteAction.js +20 -25
  55. package/components/ToolbarActions/QuoteAction.js.map +1 -1
  56. package/components/ToolbarActions/TextAlignmentAction.js +36 -45
  57. package/components/ToolbarActions/TextAlignmentAction.js.map +1 -1
  58. package/components/ToolbarActions/TypographyAction.js +43 -55
  59. package/components/ToolbarActions/TypographyAction.js.map +1 -1
  60. package/components/ToolbarActions/UnderlineAction.js +16 -21
  61. package/components/ToolbarActions/UnderlineAction.js.map +1 -1
  62. package/context/FontColorActionContext.js +2 -9
  63. package/context/FontColorActionContext.js.map +1 -1
  64. package/context/RichTextEditorContext.js +15 -26
  65. package/context/RichTextEditorContext.js.map +1 -1
  66. package/context/SharedHistoryContext.js +12 -20
  67. package/context/SharedHistoryContext.js.map +1 -1
  68. package/context/TextAlignmentActionContextProps.js +2 -9
  69. package/context/TextAlignmentActionContextProps.js.map +1 -1
  70. package/context/TypographyActionContext.js +2 -9
  71. package/context/TypographyActionContext.js.map +1 -1
  72. package/hooks/index.js +8 -93
  73. package/hooks/index.js.map +1 -1
  74. package/hooks/useCurrentElement.d.ts +2 -2
  75. package/hooks/useCurrentElement.js +12 -18
  76. package/hooks/useCurrentElement.js.map +1 -1
  77. package/hooks/useCurrentSelection.js +27 -40
  78. package/hooks/useCurrentSelection.js.map +1 -1
  79. package/hooks/useFontColorPicker.js +5 -11
  80. package/hooks/useFontColorPicker.js.map +1 -1
  81. package/hooks/useIsMounted.js +6 -14
  82. package/hooks/useIsMounted.js.map +1 -1
  83. package/hooks/useList.js +31 -35
  84. package/hooks/useList.js.map +1 -1
  85. package/hooks/useQuote.js +12 -17
  86. package/hooks/useQuote.js.map +1 -1
  87. package/hooks/useRichTextEditor.js +5 -11
  88. package/hooks/useRichTextEditor.js.map +1 -1
  89. package/hooks/useTextAlignmentAction.js +5 -11
  90. package/hooks/useTextAlignmentAction.js.map +1 -1
  91. package/hooks/useTypographyAction.js +5 -11
  92. package/hooks/useTypographyAction.js.map +1 -1
  93. package/index.js +49 -322
  94. package/index.js.map +1 -1
  95. package/package.json +8 -7
  96. package/plugins/BlurEventPlugin/BlurEventPlugin.js +16 -22
  97. package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -1
  98. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +9 -14
  99. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -1
  100. package/plugins/CodeHighlightPlugin/index.js +1 -16
  101. package/plugins/CodeHighlightPlugin/index.js.map +1 -1
  102. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.d.ts +16 -0
  103. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +158 -0
  104. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js.map +1 -0
  105. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.d.ts +8 -0
  106. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js +62 -0
  107. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js.map +1 -0
  108. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +2 -1
  109. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +5 -16
  110. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +11 -180
  111. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
  112. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.d.ts +2 -3
  113. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js +54 -68
  114. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js.map +1 -1
  115. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.d.ts +1 -1
  116. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js +16 -26
  117. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js.map +1 -1
  118. package/plugins/FloatingLinkEditorPlugin/index.js +1 -16
  119. package/plugins/FloatingLinkEditorPlugin/index.js.map +1 -1
  120. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js +3 -9
  121. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js.map +1 -1
  122. package/plugins/FontColorPlugin/FontColorPlugin.js +19 -22
  123. package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -1
  124. package/plugins/FontColorPlugin/applyColorToNode.js +4 -10
  125. package/plugins/FontColorPlugin/applyColorToNode.js.map +1 -1
  126. package/plugins/FontColorPlugin/applyColorToSelection.js +28 -44
  127. package/plugins/FontColorPlugin/applyColorToSelection.js.map +1 -1
  128. package/plugins/ImagesPlugin/ImagesPlugin.js +59 -58
  129. package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -1
  130. package/plugins/LexicalUpdateStatePlugin/UpdateStatePlugin.js +23 -23
  131. package/plugins/LexicalUpdateStatePlugin/UpdateStatePlugin.js.map +1 -1
  132. package/plugins/LexicalUpdateStatePlugin/index.js +1 -16
  133. package/plugins/LexicalUpdateStatePlugin/index.js.map +1 -1
  134. package/plugins/LinkPlugin/LinkPlugin.js +30 -37
  135. package/plugins/LinkPlugin/LinkPlugin.js.map +1 -1
  136. package/plugins/ListPLugin/ListPlugin.js +10 -15
  137. package/plugins/ListPLugin/ListPlugin.js.map +1 -1
  138. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +11 -16
  139. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js.map +1 -1
  140. package/plugins/TypographyPlugin/TypographyPlugin.js +16 -21
  141. package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -1
  142. package/types.d.ts +3 -3
  143. package/types.js +6 -38
  144. package/types.js.map +1 -1
  145. package/ui/ContentEditable.js +7 -14
  146. package/ui/ContentEditable.js.map +1 -1
  147. package/ui/Divider.js +3 -10
  148. package/ui/Divider.js.map +1 -1
  149. package/ui/DropDown.js +61 -88
  150. package/ui/DropDown.js.map +1 -1
  151. package/ui/ImageResizer.js +78 -83
  152. package/ui/ImageResizer.js.map +1 -1
  153. package/ui/LinkPreview.js +22 -29
  154. package/ui/LinkPreview.js.map +1 -1
  155. package/ui/Placeholder.js +10 -16
  156. package/ui/Placeholder.js.map +1 -1
  157. package/ui/TextInput.js +11 -18
  158. package/ui/TextInput.js.map +1 -1
  159. package/ui/ToolbarActionDialog.js +30 -42
  160. package/ui/ToolbarActionDialog.js.map +1 -1
  161. package/utils/canUseDOM.js +1 -7
  162. package/utils/canUseDOM.js.map +1 -1
  163. package/utils/files.js +9 -26
  164. package/utils/files.js.map +1 -1
  165. package/utils/generateInitialLexicalValue.js +2 -8
  166. package/utils/generateInitialLexicalValue.js.map +1 -1
  167. package/utils/getDOMRangeRect.js +4 -10
  168. package/utils/getDOMRangeRect.js.map +1 -1
  169. package/utils/getSelectedNode.js +9 -16
  170. package/utils/getSelectedNode.js.map +1 -1
  171. package/utils/getTransparentImage.js +1 -7
  172. package/utils/getTransparentImage.js.map +1 -1
  173. package/utils/insertImage.js +8 -14
  174. package/utils/insertImage.js.map +1 -1
  175. package/utils/isAnchorLink.js +1 -7
  176. package/utils/isAnchorLink.js.map +1 -1
  177. package/utils/isChildOfFloatingToolbar.js +3 -9
  178. package/utils/isChildOfFloatingToolbar.js.map +1 -1
  179. package/utils/isHTMLElement.js +1 -7
  180. package/utils/isHTMLElement.js.map +1 -1
  181. package/utils/isValidJSON.js +3 -9
  182. package/utils/isValidJSON.js.map +1 -1
  183. package/utils/isValidLexicalData.d.ts +1 -1
  184. package/utils/isValidLexicalData.js +6 -12
  185. package/utils/isValidLexicalData.js.map +1 -1
  186. package/utils/point.js +35 -60
  187. package/utils/point.js.map +1 -1
  188. package/utils/rect.js +114 -149
  189. package/utils/rect.js.map +1 -1
  190. package/utils/sanitizeUrl.js +6 -13
  191. package/utils/sanitizeUrl.js.map +1 -1
  192. package/utils/setFloatingElemPosition.js +11 -19
  193. package/utils/setFloatingElemPosition.js.map +1 -1
  194. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.d.ts +0 -2
  195. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js +0 -96
  196. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_emotion","_LexicalComposer","_text","_LexicalOnChangePlugin","_LexicalAutoFocusPlugin","_LexicalClearEditorPlugin","_LexicalRichTextPlugin","_LexicalErrorBoundary","_reactComposition","_LexicalHistoryPlugin","_LexicalContentEditable","_lexicalTheme","_lexicalNodes","_RichTextEditorContext","_isValidLexicalData","_LexicalUpdateStatePlugin","_BlurEventPlugin","_Placeholder","_generateInitialLexicalValue","_SharedHistoryContext","_LexicalEditorConfig","_normalizeInputValue","_excluded","BaseRichTextEditor","_ref","toolbar","staticToolbar","onChange","nodes","placeholder","children","onBlur","focus","styles","width","height","contentEditableStyles","placeholderStyles","_ref$generateInitialV","generateInitialValue","generateInitialLexicalValue","props","_objectWithoutProperties2","default","themeEmotionMap","toTypographyEmotionMap","css","theme","themeStylesTransformer","editorTheme","useRef","createTheme","config","useLexicalEditorConfig","_useSharedHistoryCont","useSharedHistoryContext","historyState","placeholderElem","createElement","Placeholder","scrollRef","_useState","useState","undefined","_useState2","_slicedToArray2","floatingAnchorElem","setFloatingAnchorElem","onRef","_floatingAnchorElem","sizeStyle","configNodes","map","node","configPlugins","plugins","plugin","Fragment","key","name","element","value","normalizeInputValue","editorValue","isValidLexicalData","initialConfig","editorState","namespace","onError","concat","_toConsumableArray2","allNodes","_objectSpread2","current","emotionMap","handleOnChange","editor","read","getEditorState","isEditorEmpty","$isRootTextContentEmpty","isComposing","newValue","JSON","stringify","toJSON","SharedHistoryContext","LexicalComposer","length","RichTextEditorProvider","toolbarActionPlugins","className","ref","style","overflow","position","OnChangePlugin","UpdateStatePlugin","ClearEditorPlugin","HistoryPlugin","externalHistoryState","BlurEventPlugin","AutoFocusPlugin","RichTextPlugin","contentEditable","ContentEditable","outline","ErrorBoundary","LexicalErrorBoundary","RichTextEditor","exports","makeDecoratable","LexicalEditorWithConfig"],"sources":["RichTextEditor.tsx"],"sourcesContent":["import React, { Fragment, useRef, useState } from \"react\";\nimport { css } from \"emotion\";\nimport { CSSObject } from \"@emotion/react\";\nimport { Klass, LexicalEditor, LexicalNode } from \"lexical\";\nimport { EditorState } from \"lexical/LexicalEditorState\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { $isRootTextContentEmpty } from \"@lexical/text\";\nimport { OnChangePlugin } from \"@lexical/react/LexicalOnChangePlugin\";\nimport { AutoFocusPlugin } from \"@lexical/react/LexicalAutoFocusPlugin\";\nimport { ClearEditorPlugin } from \"@lexical/react/LexicalClearEditorPlugin\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport { HistoryPlugin } from \"@lexical/react/LexicalHistoryPlugin\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport {\n createTheme,\n EditorTheme,\n ThemeEmotionMap,\n toTypographyEmotionMap\n} from \"@webiny/lexical-theme\";\nimport { allNodes } from \"@webiny/lexical-nodes\";\nimport { RichTextEditorProvider } from \"~/context/RichTextEditorContext\";\nimport { isValidLexicalData } from \"~/utils/isValidLexicalData\";\nimport { UpdateStatePlugin } from \"~/plugins/LexicalUpdateStatePlugin\";\nimport { BlurEventPlugin } from \"~/plugins/BlurEventPlugin/BlurEventPlugin\";\nimport { LexicalValue, ToolbarActionPlugin } from \"~/types\";\nimport { Placeholder } from \"~/ui/Placeholder\";\nimport { generateInitialLexicalValue } from \"~/utils/generateInitialLexicalValue\";\nimport { SharedHistoryContext, useSharedHistoryContext } from \"~/context/SharedHistoryContext\";\nimport {\n LexicalEditorWithConfig,\n useLexicalEditorConfig\n} from \"~/components/LexicalEditorConfig/LexicalEditorConfig\";\nimport { normalizeInputValue } from \"./normalizeInputValue\";\n\nexport interface RichTextEditorProps {\n children?: React.ReactNode | React.ReactNode[];\n classes?: string;\n contentEditableStyles?: React.CSSProperties;\n focus?: boolean;\n height?: number | string;\n nodes?: Klass<LexicalNode>[];\n onBlur?: (editorState: LexicalValue) => void;\n onChange?: (json: LexicalValue) => void;\n placeholder?: string;\n placeholderStyles?: React.CSSProperties;\n staticToolbar?: React.ReactNode;\n styles?: React.CSSProperties;\n tag?: string;\n theme: EditorTheme;\n themeEmotionMap?: ThemeEmotionMap;\n toolbarActionPlugins?: ToolbarActionPlugin[];\n themeStylesTransformer?: (cssObject: Record<string, any>) => CSSObject;\n toolbar?: React.ReactNode;\n value: LexicalValue | null | undefined;\n width?: number | string;\n generateInitialValue?: () => LexicalValue;\n}\n\nconst BaseRichTextEditor = ({\n toolbar,\n staticToolbar,\n onChange,\n nodes,\n placeholder,\n children,\n onBlur,\n focus,\n styles,\n width,\n height,\n contentEditableStyles,\n placeholderStyles,\n generateInitialValue = generateInitialLexicalValue,\n ...props\n}: RichTextEditorProps) => {\n const themeEmotionMap =\n props.themeEmotionMap ??\n toTypographyEmotionMap(css, props.theme, props.themeStylesTransformer);\n\n const editorTheme = useRef(createTheme(props.theme));\n const config = useLexicalEditorConfig();\n const { historyState } = useSharedHistoryContext();\n const placeholderElem = (\n <Placeholder styles={placeholderStyles}>{placeholder || \"Enter text...\"}</Placeholder>\n );\n const scrollRef = useRef(null);\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLElement | undefined>(\n undefined\n );\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem);\n }\n };\n\n const sizeStyle = {\n height: height || \"\",\n width: width || \"\"\n };\n\n const configNodes = config.nodes.map(node => node.node);\n const configPlugins = config.plugins.map(plugin => (\n <Fragment key={plugin.name}>{plugin.element}</Fragment>\n ));\n\n const value = normalizeInputValue(props.value);\n const editorValue = isValidLexicalData(value) ? value : generateInitialValue();\n\n const initialConfig = {\n editorState: null,\n namespace: \"webiny\",\n onError: () => {\n // Ignore errors. We don't want to break the app because of errors caused by config/value updates.\n // These are usually resolved in the next component render cycle.\n },\n nodes: [...allNodes, ...configNodes, ...(nodes || [])],\n theme: { ...editorTheme.current, emotionMap: themeEmotionMap }\n };\n\n function handleOnChange(editorState: EditorState, editor: LexicalEditor) {\n editorState.read(() => {\n if (typeof onChange === \"function\") {\n const editorState = editor.getEditorState();\n const isEditorEmpty = $isRootTextContentEmpty(editor.isComposing(), true);\n\n const newValue = JSON.stringify(editorState.toJSON());\n\n // We don't want to call \"onChange\" if editor text is empty, and original `value` is empty.\n if (!value && isEditorEmpty) {\n return;\n }\n\n if (value !== newValue) {\n onChange(newValue);\n }\n }\n });\n }\n\n return (\n /**\n * Once the LexicalComposer is mounted, it caches the `initialConfig` internally, and all future\n * updates to the config will be ignored. This is a problem because we pull in Nodes from our config,\n * and initially, there can be multiple re-renders, while the config object is settled.\n *\n * To bypass this issue, we generate a naive `key` based on the number of Nodes.\n */\n <SharedHistoryContext>\n <LexicalComposer initialConfig={initialConfig} key={initialConfig.nodes.length}>\n <RichTextEditorProvider\n theme={props.theme}\n themeEmotionMap={themeEmotionMap}\n toolbarActionPlugins={props.toolbarActionPlugins}\n >\n {staticToolbar ? staticToolbar : null}\n <div\n /* This className is necessary for targeting of editor container from CSS files. */\n className={\"editor-shell\"}\n ref={scrollRef}\n style={{ ...styles, ...sizeStyle, overflow: \"auto\", position: \"relative\" }}\n >\n {/* State plugins. */}\n <OnChangePlugin onChange={handleOnChange} />\n <UpdateStatePlugin value={editorValue} />\n <ClearEditorPlugin />\n <HistoryPlugin externalHistoryState={historyState} />\n {/* Event plugins. */}\n {onBlur && <BlurEventPlugin onBlur={onBlur} />}\n {focus && <AutoFocusPlugin />}\n {/* External plugins and components. */}\n {configPlugins}\n {children}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\" style={{ ...sizeStyle }}>\n <div className=\"editor\" ref={onRef}>\n <ContentEditable\n style={{ outline: 0, ...contentEditableStyles }}\n />\n </div>\n </div>\n }\n placeholder={placeholderElem}\n ErrorBoundary={LexicalErrorBoundary}\n />\n {/* Toolbar. */}\n {floatingAnchorElem && toolbar}\n </div>\n </RichTextEditorProvider>\n </LexicalComposer>\n </SharedHistoryContext>\n );\n};\n\n/**\n * @description Main editor container\n */\nexport const RichTextEditor = makeDecoratable(\"RichTextEditor\", (props: RichTextEditorProps) => {\n return (\n <LexicalEditorWithConfig>\n <BaseRichTextEditor {...props} />\n </LexicalEditorWithConfig>\n );\n});\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAIA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAJ,OAAA;AACA,IAAAK,uBAA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E,UAAC1F,KAA0B,EAAK;EAC5F,oBACI5C,MAAA,CAAA8C,OAAA,CAAAe,aAAA,CAACtC,oBAAA,CAAAgH,uBAAuB,qBACpBvI,MAAA,CAAA8C,OAAA,CAAAe,aAAA,CAACnC,kBAAkB,EAAKkB,KAAQ,CACX,CAAC;AAElC,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","Fragment","useRef","useState","css","LexicalComposer","$isRootTextContentEmpty","OnChangePlugin","AutoFocusPlugin","ClearEditorPlugin","RichTextPlugin","LexicalErrorBoundary","makeDecoratable","HistoryPlugin","ContentEditable","createTheme","toTypographyEmotionMap","allNodes","RichTextEditorProvider","isValidLexicalData","UpdateStatePlugin","BlurEventPlugin","Placeholder","generateInitialLexicalValue","SharedHistoryContext","useSharedHistoryContext","LexicalEditorWithConfig","useLexicalEditorConfig","normalizeInputValue","BaseRichTextEditor","toolbar","staticToolbar","onChange","nodes","placeholder","children","onBlur","focus","styles","width","height","contentEditableStyles","placeholderStyles","generateInitialValue","props","themeEmotionMap","theme","themeStylesTransformer","editorTheme","config","historyState","placeholderElem","createElement","scrollRef","floatingAnchorElem","setFloatingAnchorElem","undefined","onRef","_floatingAnchorElem","sizeStyle","configNodes","map","node","configPlugins","plugins","plugin","key","name","element","value","editorValue","initialConfig","editorState","namespace","onError","current","emotionMap","handleOnChange","editor","read","getEditorState","isEditorEmpty","isComposing","newValue","JSON","stringify","toJSON","length","toolbarActionPlugins","className","ref","style","overflow","position","externalHistoryState","contentEditable","outline","ErrorBoundary","RichTextEditor"],"sources":["RichTextEditor.tsx"],"sourcesContent":["import React, { Fragment, useRef, useState } from \"react\";\nimport { css } from \"emotion\";\nimport { CSSObject } from \"@emotion/react\";\nimport { Klass, LexicalEditor, LexicalNode } from \"lexical\";\nimport { EditorState } from \"lexical/LexicalEditorState\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { $isRootTextContentEmpty } from \"@lexical/text\";\nimport { OnChangePlugin } from \"@lexical/react/LexicalOnChangePlugin\";\nimport { AutoFocusPlugin } from \"@lexical/react/LexicalAutoFocusPlugin\";\nimport { ClearEditorPlugin } from \"@lexical/react/LexicalClearEditorPlugin\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport { HistoryPlugin } from \"@lexical/react/LexicalHistoryPlugin\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport {\n createTheme,\n EditorTheme,\n ThemeEmotionMap,\n toTypographyEmotionMap\n} from \"@webiny/lexical-theme\";\nimport { allNodes } from \"@webiny/lexical-nodes\";\nimport { RichTextEditorProvider } from \"~/context/RichTextEditorContext\";\nimport { isValidLexicalData } from \"~/utils/isValidLexicalData\";\nimport { UpdateStatePlugin } from \"~/plugins/LexicalUpdateStatePlugin\";\nimport { BlurEventPlugin } from \"~/plugins/BlurEventPlugin/BlurEventPlugin\";\nimport { LexicalValue, ToolbarActionPlugin } from \"~/types\";\nimport { Placeholder } from \"~/ui/Placeholder\";\nimport { generateInitialLexicalValue } from \"~/utils/generateInitialLexicalValue\";\nimport { SharedHistoryContext, useSharedHistoryContext } from \"~/context/SharedHistoryContext\";\nimport {\n LexicalEditorWithConfig,\n useLexicalEditorConfig\n} from \"~/components/LexicalEditorConfig/LexicalEditorConfig\";\nimport { normalizeInputValue } from \"./normalizeInputValue\";\n\nexport interface RichTextEditorProps {\n children?: React.ReactNode | React.ReactNode[];\n classes?: string;\n contentEditableStyles?: React.CSSProperties;\n focus?: boolean;\n height?: number | string;\n nodes?: Klass<LexicalNode>[];\n onBlur?: (editorState: LexicalValue) => void;\n onChange?: (json: LexicalValue) => void;\n placeholder?: string;\n placeholderStyles?: React.CSSProperties;\n staticToolbar?: React.ReactNode;\n styles?: React.CSSProperties;\n tag?: string;\n theme: EditorTheme;\n themeEmotionMap?: ThemeEmotionMap;\n toolbarActionPlugins?: ToolbarActionPlugin[];\n themeStylesTransformer?: (cssObject: Record<string, any>) => CSSObject;\n toolbar?: React.ReactNode;\n value: LexicalValue | null | undefined;\n width?: number | string;\n generateInitialValue?: () => LexicalValue;\n}\n\nconst BaseRichTextEditor = ({\n toolbar,\n staticToolbar,\n onChange,\n nodes,\n placeholder,\n children,\n onBlur,\n focus,\n styles,\n width,\n height,\n contentEditableStyles,\n placeholderStyles,\n generateInitialValue = generateInitialLexicalValue,\n ...props\n}: RichTextEditorProps) => {\n const themeEmotionMap =\n props.themeEmotionMap ??\n toTypographyEmotionMap(css, props.theme, props.themeStylesTransformer);\n\n const editorTheme = useRef(createTheme(props.theme));\n const config = useLexicalEditorConfig();\n const { historyState } = useSharedHistoryContext();\n const placeholderElem = (\n <Placeholder styles={placeholderStyles}>{placeholder || \"Enter text...\"}</Placeholder>\n );\n const scrollRef = useRef(null);\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLElement | undefined>(\n undefined\n );\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem);\n }\n };\n\n const sizeStyle = {\n height: height || \"\",\n width: width || \"\"\n };\n\n const configNodes = config.nodes.map(node => node.node);\n const configPlugins = config.plugins.map(plugin => (\n <Fragment key={plugin.name}>{plugin.element}</Fragment>\n ));\n\n const value = normalizeInputValue(props.value);\n const editorValue = isValidLexicalData(value) ? value : generateInitialValue();\n\n const initialConfig = {\n editorState: null,\n namespace: \"webiny\",\n onError: () => {\n // Ignore errors. We don't want to break the app because of errors caused by config/value updates.\n // These are usually resolved in the next component render cycle.\n },\n nodes: [...allNodes, ...configNodes, ...(nodes || [])],\n theme: { ...editorTheme.current, emotionMap: themeEmotionMap }\n };\n\n function handleOnChange(editorState: EditorState, editor: LexicalEditor) {\n editorState.read(() => {\n if (typeof onChange === \"function\") {\n const editorState = editor.getEditorState();\n const isEditorEmpty = $isRootTextContentEmpty(editor.isComposing(), true);\n\n const newValue = JSON.stringify(editorState.toJSON());\n\n // We don't want to call \"onChange\" if editor text is empty, and original `value` is empty.\n if (!value && isEditorEmpty) {\n return;\n }\n\n if (value !== newValue) {\n onChange(newValue);\n }\n }\n });\n }\n\n return (\n /**\n * Once the LexicalComposer is mounted, it caches the `initialConfig` internally, and all future\n * updates to the config will be ignored. This is a problem because we pull in Nodes from our config,\n * and initially, there can be multiple re-renders, while the config object is settled.\n *\n * To bypass this issue, we generate a naive `key` based on the number of Nodes.\n */\n <SharedHistoryContext>\n <LexicalComposer initialConfig={initialConfig} key={initialConfig.nodes.length}>\n <RichTextEditorProvider\n theme={props.theme}\n themeEmotionMap={themeEmotionMap}\n toolbarActionPlugins={props.toolbarActionPlugins}\n >\n {staticToolbar ? staticToolbar : null}\n <div\n /* This className is necessary for targeting of editor container from CSS files. */\n className={\"editor-shell\"}\n ref={scrollRef}\n style={{ ...styles, ...sizeStyle, overflow: \"auto\", position: \"relative\" }}\n >\n {/* State plugins. */}\n <OnChangePlugin onChange={handleOnChange} />\n <UpdateStatePlugin value={editorValue} />\n <ClearEditorPlugin />\n <HistoryPlugin externalHistoryState={historyState} />\n {/* Event plugins. */}\n {onBlur && <BlurEventPlugin onBlur={onBlur} />}\n {focus && <AutoFocusPlugin />}\n {/* External plugins and components. */}\n {configPlugins}\n {children}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\" style={{ ...sizeStyle }}>\n <div className=\"editor\" ref={onRef}>\n <ContentEditable\n style={{ outline: 0, ...contentEditableStyles }}\n />\n </div>\n </div>\n }\n placeholder={placeholderElem}\n ErrorBoundary={LexicalErrorBoundary}\n />\n {/* Toolbar. */}\n {floatingAnchorElem && toolbar}\n </div>\n </RichTextEditorProvider>\n </LexicalComposer>\n </SharedHistoryContext>\n );\n};\n\n/**\n * @description Main editor container\n */\nexport const RichTextEditor = makeDecoratable(\"RichTextEditor\", (props: RichTextEditorProps) => {\n return (\n <LexicalEditorWithConfig>\n <BaseRichTextEditor {...props} />\n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eAAe,CAAC,gBAAgB,EAAGgC,KAA0B,IAAK;EAC5F,oBACI5C,KAAA,CAAAoD,aAAA,CAAC1B,uBAAuB,qBACpB1B,KAAA,CAAAoD,aAAA,CAACvB,kBAAkB,EAAKe,KAAQ,CACX,CAAC;AAElC,CAAC,CAAC","ignoreList":[]}
@@ -1,10 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.normalizeInputValue = normalizeInputValue;
7
- var isValueEmpty = function isValueEmpty(value) {
1
+ const isValueEmpty = value => {
8
2
  return [undefined, null, "", '""', "null"].includes(value);
9
3
  };
10
4
 
@@ -12,7 +6,7 @@ var isValueEmpty = function isValueEmpty(value) {
12
6
  * Value passed to the `RichTextEditor` component can be anything. This function normalizes some of the more common shapes
13
7
  * of input into a value that is either a `null` or a `LexicalValue`.
14
8
  */
15
- function normalizeInputValue(value) {
9
+ export function normalizeInputValue(value) {
16
10
  if (isValueEmpty(value)) {
17
11
  return null;
18
12
  }
@@ -1 +1 @@
1
- {"version":3,"names":["isValueEmpty","value","undefined","includes","normalizeInputValue"],"sources":["normalizeInputValue.ts"],"sourcesContent":["import { LexicalValue, NormalizedInputValue } from \"~/types\";\n\nconst isValueEmpty = (value: any) => {\n return [undefined, null, \"\", '\"\"', \"null\"].includes(value);\n};\n\n/**\n * Value passed to the `RichTextEditor` component can be anything. This function normalizes some of the more common shapes\n * of input into a value that is either a `null` or a `LexicalValue`.\n */\nexport function normalizeInputValue(value: LexicalValue | null | undefined) {\n if (isValueEmpty(value)) {\n return null;\n }\n\n return value as NormalizedInputValue;\n}\n"],"mappings":";;;;;;AAEA,IAAMA,YAAY,GAAG,SAAfA,YAAYA,CAAIC,KAAU,EAAK;EACjC,OAAO,CAACC,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,CAACC,QAAQ,CAACF,KAAK,CAAC;AAC9D,CAAC;;AAED;AACA;AACA;AACA;AACO,SAASG,mBAAmBA,CAACH,KAAsC,EAAE;EACxE,IAAID,YAAY,CAACC,KAAK,CAAC,EAAE;IACrB,OAAO,IAAI;EACf;EAEA,OAAOA,KAAK;AAChB","ignoreList":[]}
1
+ {"version":3,"names":["isValueEmpty","value","undefined","includes","normalizeInputValue"],"sources":["normalizeInputValue.ts"],"sourcesContent":["import { LexicalValue, NormalizedInputValue } from \"~/types\";\n\nconst isValueEmpty = (value: any) => {\n return [undefined, null, \"\", '\"\"', \"null\"].includes(value);\n};\n\n/**\n * Value passed to the `RichTextEditor` component can be anything. This function normalizes some of the more common shapes\n * of input into a value that is either a `null` or a `LexicalValue`.\n */\nexport function normalizeInputValue(value: LexicalValue | null | undefined) {\n if (isValueEmpty(value)) {\n return null;\n }\n\n return value as NormalizedInputValue;\n}\n"],"mappings":"AAEA,MAAMA,YAAY,GAAIC,KAAU,IAAK;EACjC,OAAO,CAACC,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,CAACC,QAAQ,CAACF,KAAK,CAAC;AAC9D,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,SAASG,mBAAmBA,CAACH,KAAsC,EAAE;EACxE,IAAID,YAAY,CAACC,KAAK,CAAC,EAAE;IACrB,OAAO,IAAI;EACf;EAEA,OAAOA,KAAK;AAChB","ignoreList":[]}
@@ -1,67 +1,57 @@
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.LexicalEditorWithConfig = exports.LexicalEditorConfig = void 0;
9
- exports.useLexicalEditorConfig = useLexicalEditorConfig;
10
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
- var _react = _interopRequireWildcard(require("react"));
12
- var _reactComposition = require("@webiny/react-composition");
13
- var _reactProperties = require("@webiny/react-properties");
14
- var _ToolbarElement = require("./components/ToolbarElement");
15
- var _Plugin = require("./components/Plugin");
16
- var _Node = require("./components/Node");
17
- var LexicalEditorConfigApply = (0, _reactComposition.makeDecoratable)("LexicalEditorConfigApply", function (_ref) {
18
- var children = _ref.children;
19
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
1
+ import React, { useContext, useMemo, useState } from "react";
2
+ import { makeDecoratable, Compose } from "@webiny/react-composition";
3
+ import { Properties, toObject } from "@webiny/react-properties";
4
+ import { ToolbarElement } from "./components/ToolbarElement";
5
+ import { Plugin } from "./components/Plugin";
6
+ import { Node } from "./components/Node";
7
+ const LexicalEditorConfigApply = makeDecoratable("LexicalEditorConfigApply", ({
8
+ children
9
+ }) => {
10
+ return /*#__PURE__*/React.createElement(React.Fragment, null, children);
20
11
  });
21
- var createHOC = function createHOC(newChildren) {
22
- return function (BaseComponent) {
23
- return function ConfigHOC(_ref2) {
24
- var children = _ref2.children;
25
- return /*#__PURE__*/_react.default.createElement(BaseComponent, null, newChildren, children);
26
- };
12
+ const createHOC = newChildren => BaseComponent => {
13
+ return function ConfigHOC({
14
+ children
15
+ }) {
16
+ return /*#__PURE__*/React.createElement(BaseComponent, null, newChildren, children);
27
17
  };
28
18
  };
29
- var LexicalEditorConfig = exports.LexicalEditorConfig = function LexicalEditorConfig(_ref3) {
30
- var children = _ref3.children;
31
- return /*#__PURE__*/_react.default.createElement(_reactComposition.Compose, {
19
+ export const LexicalEditorConfig = ({
20
+ children
21
+ }) => {
22
+ return /*#__PURE__*/React.createElement(Compose, {
32
23
  component: LexicalEditorConfigApply,
33
24
  with: createHOC(children)
34
25
  });
35
26
  };
36
- LexicalEditorConfig.ToolbarElement = _ToolbarElement.ToolbarElement;
37
- LexicalEditorConfig.Plugin = _Plugin.Plugin;
38
- LexicalEditorConfig.Node = _Node.Node;
39
- var ViewContext = /*#__PURE__*/_react.default.createContext({
27
+ LexicalEditorConfig.ToolbarElement = ToolbarElement;
28
+ LexicalEditorConfig.Plugin = Plugin;
29
+ LexicalEditorConfig.Node = Node;
30
+ const ViewContext = /*#__PURE__*/React.createContext({
40
31
  properties: []
41
32
  });
42
- var LexicalEditorWithConfig = exports.LexicalEditorWithConfig = function LexicalEditorWithConfig(_ref4) {
43
- var children = _ref4.children;
44
- var _useState = (0, _react.useState)([]),
45
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
46
- properties = _useState2[0],
47
- setProperties = _useState2[1];
48
- var context = {
49
- properties: properties
33
+ export const LexicalEditorWithConfig = ({
34
+ children
35
+ }) => {
36
+ const [properties, setProperties] = useState([]);
37
+ const context = {
38
+ properties
50
39
  };
51
- var stateUpdater = function stateUpdater(properties) {
40
+ const stateUpdater = properties => {
52
41
  setProperties(properties);
53
42
  };
54
- return /*#__PURE__*/_react.default.createElement(ViewContext.Provider, {
43
+ return /*#__PURE__*/React.createElement(ViewContext.Provider, {
55
44
  value: context
56
- }, /*#__PURE__*/_react.default.createElement(_reactProperties.Properties, {
45
+ }, /*#__PURE__*/React.createElement(Properties, {
57
46
  onChange: stateUpdater
58
- }, /*#__PURE__*/_react.default.createElement(LexicalEditorConfigApply, null), children));
47
+ }, /*#__PURE__*/React.createElement(LexicalEditorConfigApply, null), children));
59
48
  };
60
- function useLexicalEditorConfig() {
61
- var _useContext = (0, _react.useContext)(ViewContext),
62
- properties = _useContext.properties;
63
- var config = (0, _react.useMemo)(function () {
64
- return (0, _reactProperties.toObject)(properties);
49
+ export function useLexicalEditorConfig() {
50
+ const {
51
+ properties
52
+ } = useContext(ViewContext);
53
+ const config = useMemo(() => {
54
+ return toObject(properties);
65
55
  }, [properties]);
66
56
  return {
67
57
  toolbarElements: config.toolbarElements || [],
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactComposition","_reactProperties","_ToolbarElement","_Plugin","_Node","LexicalEditorConfigApply","makeDecoratable","_ref","children","default","createElement","Fragment","createHOC","newChildren","BaseComponent","ConfigHOC","_ref2","LexicalEditorConfig","exports","_ref3","Compose","component","with","ToolbarElement","Plugin","Node","ViewContext","React","createContext","properties","LexicalEditorWithConfig","_ref4","_useState","useState","_useState2","_slicedToArray2","setProperties","context","stateUpdater","Provider","value","Properties","onChange","useLexicalEditorConfig","_useContext","useContext","config","useMemo","toObject","toolbarElements","plugins","nodes"],"sources":["LexicalEditorConfig.tsx"],"sourcesContent":["import React, { useContext, useMemo, useState } from \"react\";\nimport { makeDecoratable, Compose, Decorator, GenericComponent } from \"@webiny/react-composition\";\nimport { Property, Properties, toObject } from \"@webiny/react-properties\";\nimport { ToolbarElement, ToolbarElementConfig } from \"./components/ToolbarElement\";\nimport { Plugin, PluginConfig } from \"./components/Plugin\";\nimport { Node, NodeConfig } from \"./components/Node\";\n\nconst LexicalEditorConfigApply = makeDecoratable(\"LexicalEditorConfigApply\", ({ children }) => {\n return <>{children}</>;\n});\n\nconst createHOC =\n (newChildren: React.ReactNode): Decorator<GenericComponent> =>\n BaseComponent => {\n return function ConfigHOC({ children }) {\n return (\n <BaseComponent>\n {newChildren}\n {children}\n </BaseComponent>\n );\n };\n };\n\nexport const LexicalEditorConfig = ({ children }: { children: React.ReactNode }) => {\n return <Compose component={LexicalEditorConfigApply} with={createHOC(children)} />;\n};\n\nLexicalEditorConfig.ToolbarElement = ToolbarElement;\nLexicalEditorConfig.Plugin = Plugin;\nLexicalEditorConfig.Node = Node;\n\ninterface ViewContext {\n properties: Property[];\n}\n\nconst ViewContext = React.createContext<ViewContext>({ properties: [] });\n\nexport const LexicalEditorWithConfig = ({ children }: { children: React.ReactNode }) => {\n const [properties, setProperties] = useState<Property[]>([]);\n const context = { properties };\n\n const stateUpdater = (properties: Property[]) => {\n setProperties(properties);\n };\n\n return (\n <ViewContext.Provider value={context}>\n <Properties onChange={stateUpdater}>\n <LexicalEditorConfigApply />\n {children}\n </Properties>\n </ViewContext.Provider>\n );\n};\n\ninterface LexicalEditorConfigData {\n toolbarElements: ToolbarElementConfig[];\n plugins: PluginConfig[];\n nodes: NodeConfig[];\n}\n\nexport function useLexicalEditorConfig() {\n const { properties } = useContext(ViewContext);\n\n const config = useMemo(() => {\n return toObject<LexicalEditorConfigData>(properties);\n }, [properties]);\n\n return {\n toolbarElements: config.toolbarElements || [],\n plugins: config.plugins || [],\n nodes: config.nodes || []\n };\n}\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAEA,IAAMM,wBAAwB,GAAG,IAAAC,iCAAe,EAAC,0BAA0B,EAAE,UAAAC,IAAA,EAAkB;EAAA,IAAfC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;EACpF,oBAAOX,MAAA,CAAAY,OAAA,CAAAC,aAAA,CAAAb,MAAA,CAAAY,OAAA,CAAAE,QAAA,QAAGH,QAAW,CAAC;AAC1B,CAAC,CAAC;AAEF,IAAMI,SAAS,GACX,SADEA,SAASA,CACVC,WAA4B;EAAA,OAC7B,UAAAC,aAAa,EAAI;IACb,OAAO,SAASC,SAASA,CAAAC,KAAA,EAAe;MAAA,IAAZR,QAAQ,GAAAQ,KAAA,CAARR,QAAQ;MAChC,oBACIX,MAAA,CAAAY,OAAA,CAAAC,aAAA,CAACI,aAAa,QACTD,WAAW,EACXL,QACU,CAAC;IAExB,CAAC;EACL,CAAC;AAAA;AAEE,IAAMS,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG,SAAtBA,mBAAmBA,CAAAE,KAAA,EAAoD;EAAA,IAA9CX,QAAQ,GAAAW,KAAA,CAARX,QAAQ;EAC1C,oBAAOX,MAAA,CAAAY,OAAA,CAAAC,aAAA,CAACV,iBAAA,CAAAoB,OAAO;IAACC,SAAS,EAAEhB,wBAAyB;IAACiB,IAAI,EAAEV,SAAS,CAACJ,Q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AO,IAAAC,yBAAQ,EAA0BnB,UAAU,CAAC;EACxD,CAAC,EAAE,CAACA,UAAU,CAAC,CAAC;EAEhB,OAAO;IACHoB,eAAe,EAAEH,MAAM,CAACG,eAAe,IAAI,EAAE;IAC7CC,OAAO,EAAEJ,MAAM,CAACI,OAAO,IAAI,EAAE;IAC7BC,KAAK,EAAEL,MAAM,CAACK,KAAK,IAAI;EAC3B,CAAC;AACL","ignoreList":[]}
1
+ {"version":3,"names":["React","useContext","useMemo","useState","makeDecoratable","Compose","Properties","toObject","ToolbarElement","Plugin","Node","LexicalEditorConfigApply","children","createElement","Fragment","createHOC","newChildren","BaseComponent","ConfigHOC","LexicalEditorConfig","component","with","ViewContext","createContext","properties","LexicalEditorWithConfig","setProperties","context","stateUpdater","Provider","value","onChange","useLexicalEditorConfig","config","toolbarElements","plugins","nodes"],"sources":["LexicalEditorConfig.tsx"],"sourcesContent":["import React, { useContext, useMemo, useState } from \"react\";\nimport { makeDecoratable, Compose, Decorator, GenericComponent } from \"@webiny/react-composition\";\nimport { Property, Properties, toObject } from \"@webiny/react-properties\";\nimport { ToolbarElement, ToolbarElementConfig } from \"./components/ToolbarElement\";\nimport { Plugin, PluginConfig } from \"./components/Plugin\";\nimport { Node, NodeConfig } from \"./components/Node\";\n\nconst LexicalEditorConfigApply = makeDecoratable(\"LexicalEditorConfigApply\", ({ children }) => {\n return <>{children}</>;\n});\n\nconst createHOC =\n (newChildren: React.ReactNode): Decorator<GenericComponent> =>\n BaseComponent => {\n return function ConfigHOC({ children }) {\n return (\n <BaseComponent>\n {newChildren}\n {children}\n </BaseComponent>\n );\n };\n };\n\nexport const LexicalEditorConfig = ({ children }: { children: React.ReactNode }) => {\n return <Compose component={LexicalEditorConfigApply} with={createHOC(children)} />;\n};\n\nLexicalEditorConfig.ToolbarElement = ToolbarElement;\nLexicalEditorConfig.Plugin = Plugin;\nLexicalEditorConfig.Node = Node;\n\ninterface ViewContext {\n properties: Property[];\n}\n\nconst ViewContext = React.createContext<ViewContext>({ properties: [] });\n\nexport const LexicalEditorWithConfig = ({ children }: { children: React.ReactNode }) => {\n const [properties, setProperties] = useState<Property[]>([]);\n const context = { properties };\n\n const stateUpdater = (properties: Property[]) => {\n setProperties(properties);\n };\n\n return (\n <ViewContext.Provider value={context}>\n <Properties onChange={stateUpdater}>\n <LexicalEditorConfigApply />\n {children}\n </Properties>\n </ViewContext.Provider>\n );\n};\n\ninterface LexicalEditorConfigData {\n toolbarElements: ToolbarElementConfig[];\n plugins: PluginConfig[];\n nodes: NodeConfig[];\n}\n\nexport function useLexicalEditorConfig() {\n const { properties } = useContext(ViewContext);\n\n const config = useMemo(() => {\n return toObject<LexicalEditorConfigData>(properties);\n }, [properties]);\n\n return {\n toolbarElements: config.toolbarElements || [],\n plugins: config.plugins || [],\n nodes: config.nodes || []\n };\n}\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAC5D,SAASC,eAAe,EAAEC,OAAO,QAAqC,2BAA2B;AACjG,SAAmBC,UAAU,EAAEC,QAAQ,QAAQ,0BAA0B;AACzE,SAASC,cAAc;AACvB,SAASC,MAAM;AACf,SAASC,IAAI;AAEb,MAAMC,wBAAwB,GAAGP,eAAe,CAAC,0BAA0B,EAAE,CAAC;EAAEQ;AAAS,CAAC,KAAK;EAC3F,oBAAOZ,KAAA,CAAAa,aAAA,CAAAb,KAAA,CAAAc,QAAA,QAAGF,QAAW,CAAC;AAC1B,CAAC,CAAC;AAEF,MAAMG,SAAS,GACVC,WAA4B,IAC7BC,aAAa,IAAI;EACb,OAAO,SAASC,SAASA,CAAC;IAAEN;EAAS,CAAC,EAAE;IACpC,oBACIZ,KAAA,CAAAa,aAAA,CAACI,aAAa,QACTD,WAAW,EACXJ,QACU,CAAC;EAExB,CAAC;AACL,CAAC;AAEL,OAAO,MAAMO,mBAAmB,GAAGA,CAAC;EAAEP;AAAwC,CAAC,KAAK;EAChF,oBAAOZ,KAA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H,MAAM,CAACG,KAAK,IAAI;EAC3B,CAAC;AACL","ignoreList":[]}
@@ -1,36 +1,27 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.Node = void 0;
8
- var _react = _interopRequireDefault(require("react"));
9
- var _reactProperties = require("@webiny/react-properties");
10
- var Node = exports.Node = function Node(_ref) {
11
- var name = _ref.name,
12
- node = _ref.node,
13
- _ref$after = _ref.after,
14
- after = _ref$after === void 0 ? undefined : _ref$after,
15
- _ref$before = _ref.before,
16
- before = _ref$before === void 0 ? undefined : _ref$before,
17
- _ref$remove = _ref.remove,
18
- remove = _ref$remove === void 0 ? false : _ref$remove;
19
- var placeBefore = before !== undefined ? "node:".concat(before) : undefined;
20
- var placeAfter = after !== undefined ? "node:".concat(after) : undefined;
21
- return /*#__PURE__*/_react.default.createElement(_reactProperties.Property, {
22
- id: "nodes:".concat(name),
1
+ import React from "react";
2
+ import { Property } from "@webiny/react-properties";
3
+ export const Node = ({
4
+ name,
5
+ node,
6
+ after = undefined,
7
+ before = undefined,
8
+ remove = false
9
+ }) => {
10
+ const placeBefore = before !== undefined ? `node:${before}` : undefined;
11
+ const placeAfter = after !== undefined ? `node:${after}` : undefined;
12
+ return /*#__PURE__*/React.createElement(Property, {
13
+ id: `nodes:${name}`,
23
14
  name: "nodes",
24
15
  array: true,
25
16
  before: placeBefore,
26
17
  after: placeAfter,
27
18
  remove: remove
28
- }, /*#__PURE__*/_react.default.createElement(_reactProperties.Property, {
29
- id: "node:".concat(name, ":name"),
19
+ }, /*#__PURE__*/React.createElement(Property, {
20
+ id: `node:${name}:name`,
30
21
  name: "name",
31
22
  value: name
32
- }), node ? /*#__PURE__*/_react.default.createElement(_reactProperties.Property, {
33
- id: "node:".concat(name, ":node"),
23
+ }), node ? /*#__PURE__*/React.createElement(Property, {
24
+ id: `node:${name}:node`,
34
25
  name: "node",
35
26
  value: node
36
27
  }) : null);
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_reactProperties","Node","exports","_ref","name","node","_ref$after","after","undefined","_ref$before","before","_ref$remove","remove","placeBefore","concat","placeAfter","default","createElement","Property","id","array","value"],"sources":["Node.tsx"],"sourcesContent":["import React from \"react\";\nimport { Property } from \"@webiny/react-properties\";\nimport { Klass, LexicalNode } from \"lexical\";\n\nexport interface NodeConfig {\n name: string;\n node: Klass<LexicalNode>;\n}\n\nexport interface NodeProps {\n name: string;\n node?: Klass<LexicalNode>;\n remove?: boolean;\n before?: string;\n after?: string;\n}\n\nexport const Node = ({\n name,\n node,\n after = undefined,\n before = undefined,\n remove = false\n}: NodeProps) => {\n const placeBefore = before !== undefined ? `node:${before}` : undefined;\n const placeAfter = after !== undefined ? `node:${after}` : undefined;\n\n return (\n <Property\n id={`nodes:${name}`}\n name={\"nodes\"}\n array={true}\n before={placeBefore}\n after={placeAfter}\n remove={remove}\n >\n <Property id={`node:${name}:name`} name={\"name\"} value={name} />\n {node ? <Property id={`node:${name}:node`} name={\"node\"} value={node} /> : null}\n </Property>\n );\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAgBO,IAAME,IAAI,GAAAC,OAAA,CAAAD,IAAA,GAAG,SAAPA,IAAIA,CAAAE,IAAA,EAMA;EAAA,IALbC,IAAI,GAAAD,IAAA,CAAJC,IAAI;IACJC,IAAI,GAAAF,IAAA,CAAJE,IAAI;IAAAC,UAAA,GAAAH,IAAA,CACJI,KAAK;IAALA,KAAK,GAAAD,UAAA,cAAGE,SAAS,GAAAF,UAAA;IAAAG,WAAA,GAAAN,IAAA,CACjBO,MAAM;IAANA,MAAM,GAAAD,WAAA,cAAGD,SAAS,GAAAC,WAAA;IAAAE,WAAA,GAAAR,IAAA,CAClBS,MAAM;IAANA,MAAM,GAAAD,WAAA,cAAG,KAAK,GAAAA,WAAA;EAEd,IAAME,WAAW,GAAGH,MAAM,KAAKF,SAAS,WAAAM,MAAA,CAAWJ,MAAM,IAAKF,SAAS;EACvE,IAAMO,UAAU,GAAGR,KAAK,KAAKC,SAAS,WAAAM,MAAA,CAAWP,KAAK,IAAKC,SAAS;EAEpE,oBACIX,MAAA,CAAAmB,OAAA,CAAAC,aAAA,CAACjB,gBAAA,CAAAkB,QAAQ;IACLC,EAAE,WAAAL,MAAA,CAAWV,IAAI,CAAG;IACpBA,IAAI,EAAE,OAAQ;IACdgB,KAAK,EAAE,IAAK;IACZV,MAAM,EAAEG,WAAY;IACpBN,KAAK,EAAEQ,UAAW;IAClBH,MAAM,EAAEA;EAAO,gBAEff,MAAA,CAAAmB,OAAA,CAAAC,aAAA,CAACjB,gBAAA,CAAAkB,QAAQ;IAACC,EAAE,UAAAL,MAAA,CAAUV,IAAI,UAAQ;IAACA,IAAI,EAAE,MAAO;IAACiB,KAAK,EAAEjB;EAAK,CAAE,CAAC,EAC/DC,IAAI,gBAAGR,MAAA,CAAAmB,OAAA,CAAAC,aAAA,CAACjB,gBAAA,CAAAkB,QAAQ;IAACC,EAAE,UAAAL,MAAA,CAAUV,IAAI,UAAQ;IAACA,IAAI,EAAE,MAAO;IAACiB,KAAK,EAAEhB;EAAK,CAAE,CAAC,GAAG,IACrE,CAAC;AAEnB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","Property","Node","name","node","after","undefined","before","remove","placeBefore","placeAfter","createElement","id","array","value"],"sources":["Node.tsx"],"sourcesContent":["import React from \"react\";\nimport { Property } from \"@webiny/react-properties\";\nimport { Klass, LexicalNode } from \"lexical\";\n\nexport interface NodeConfig {\n name: string;\n node: Klass<LexicalNode>;\n}\n\nexport interface NodeProps {\n name: string;\n node?: Klass<LexicalNode>;\n remove?: boolean;\n before?: string;\n after?: string;\n}\n\nexport const Node = ({\n name,\n node,\n after = undefined,\n before = undefined,\n remove = false\n}: NodeProps) => {\n const placeBefore = before !== undefined ? `node:${before}` : undefined;\n const placeAfter = after !== undefined ? `node:${after}` : undefined;\n\n return (\n <Property\n id={`nodes:${name}`}\n name={\"nodes\"}\n array={true}\n before={placeBefore}\n after={placeAfter}\n remove={remove}\n >\n <Property id={`node:${name}:name`} name={\"name\"} value={name} />\n {node ? <Property id={`node:${name}:node`} name={\"node\"} value={node} /> : null}\n </Property>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,QAAQ,0BAA0B;AAgBnD,OAAO,MAAMC,IAAI,GAAGA,CAAC;EACjBC,IAAI;EACJC,IAAI;EACJC,KAAK,GAAGC,SAAS;EACjBC,MAAM,GAAGD,SAAS;EAClBE,MAAM,GAAG;AACF,CAAC,KAAK;EACb,MAAMC,WAAW,GAAGF,MAAM,KAAKD,SAAS,GAAG,QAAQC,MAAM,EAAE,GAAGD,SAAS;EACvE,MAAMI,UAAU,GAAGL,KAAK,KAAKC,SAAS,GAAG,QAAQD,KAAK,EAAE,GAAGC,SAAS;EAEpE,oBACIN,KAAA,CAAAW,aAAA,CAACV,QAAQ;IACLW,EAAE,EAAE,SAAST,IAAI,EAAG;IACpBA,IAAI,EAAE,OAAQ;IACdU,KAAK,EAAE,IAAK;IACZN,MAAM,EAAEE,WAAY;IACpBJ,KAAK,EAAEK,UAAW;IAClBF,MAAM,EAAEA;EAAO,gBAEfR,KAAA,CAAAW,aAAA,CAACV,QAAQ;IAACW,EAAE,EAAE,QAAQT,IAAI,OAAQ;IAACA,IAAI,EAAE,MAAO;IAACW,KAAK,EAAEX;EAAK,CAAE,CAAC,EAC/DC,IAAI,gBAAGJ,KAAA,CAAAW,aAAA,CAACV,QAAQ;IAACW,EAAE,EAAE,QAAQT,IAAI,OAAQ;IAACA,IAAI,EAAE,MAAO;IAACW,KAAK,EAAEV;EAAK,CAAE,CAAC,GAAG,IACrE,CAAC;AAEnB,CAAC","ignoreList":[]}
@@ -1,36 +1,27 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.Plugin = void 0;
8
- var _react = _interopRequireDefault(require("react"));
9
- var _reactProperties = require("@webiny/react-properties");
10
- var Plugin = exports.Plugin = function Plugin(_ref) {
11
- var name = _ref.name,
12
- element = _ref.element,
13
- _ref$after = _ref.after,
14
- after = _ref$after === void 0 ? undefined : _ref$after,
15
- _ref$before = _ref.before,
16
- before = _ref$before === void 0 ? undefined : _ref$before,
17
- _ref$remove = _ref.remove,
18
- remove = _ref$remove === void 0 ? false : _ref$remove;
19
- var placeBefore = before !== undefined ? "plugin:".concat(before) : undefined;
20
- var placeAfter = after !== undefined ? "plugin:".concat(after) : undefined;
21
- return /*#__PURE__*/_react.default.createElement(_reactProperties.Property, {
22
- id: "plugins:".concat(name),
1
+ import React from "react";
2
+ import { Property } from "@webiny/react-properties";
3
+ export const Plugin = ({
4
+ name,
5
+ element,
6
+ after = undefined,
7
+ before = undefined,
8
+ remove = false
9
+ }) => {
10
+ const placeBefore = before !== undefined ? `plugin:${before}` : undefined;
11
+ const placeAfter = after !== undefined ? `plugin:${after}` : undefined;
12
+ return /*#__PURE__*/React.createElement(Property, {
13
+ id: `plugins:${name}`,
23
14
  name: "plugins",
24
15
  array: true,
25
16
  before: placeBefore,
26
17
  after: placeAfter,
27
18
  remove: remove
28
- }, /*#__PURE__*/_react.default.createElement(_reactProperties.Property, {
29
- id: "plugin:".concat(name, ":name"),
19
+ }, /*#__PURE__*/React.createElement(Property, {
20
+ id: `plugin:${name}:name`,
30
21
  name: "name",
31
22
  value: name
32
- }), element ? /*#__PURE__*/_react.default.createElement(_reactProperties.Property, {
33
- id: "plugin:".concat(name, ":element"),
23
+ }), element ? /*#__PURE__*/React.createElement(Property, {
24
+ id: `plugin:${name}:element`,
34
25
  name: "element",
35
26
  value: element
36
27
  }) : null);
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_reactProperties","Plugin","exports","_ref","name","element","_ref$after","after","undefined","_ref$before","before","_ref$remove","remove","placeBefore","concat","placeAfter","default","createElement","Property","id","array","value"],"sources":["Plugin.tsx"],"sourcesContent":["import React from \"react\";\nimport { Property } from \"@webiny/react-properties\";\n\nexport interface PluginConfig {\n name: string;\n element: React.ReactElement;\n}\n\nexport interface PluginProps {\n name: string;\n element?: React.ReactElement<unknown>;\n remove?: boolean;\n before?: string;\n after?: string;\n}\n\nexport const Plugin = ({\n name,\n element,\n after = undefined,\n before = undefined,\n remove = false\n}: PluginProps) => {\n const placeBefore = before !== undefined ? `plugin:${before}` : undefined;\n const placeAfter = after !== undefined ? `plugin:${after}` : undefined;\n\n return (\n <Property\n id={`plugins:${name}`}\n name={\"plugins\"}\n array={true}\n before={placeBefore}\n after={placeAfter}\n remove={remove}\n >\n <Property id={`plugin:${name}:name`} name={\"name\"} value={name} />\n {element ? (\n <Property id={`plugin:${name}:element`} name={\"element\"} value={element} />\n ) : null}\n </Property>\n );\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAeO,IAAME,MAAM,GAAAC,OAAA,CAAAD,MAAA,GAAG,SAATA,MAAMA,CAAAE,IAAA,EAMA;EAAA,IALfC,IAAI,GAAAD,IAAA,CAAJC,IAAI;IACJC,OAAO,GAAAF,IAAA,CAAPE,OAAO;IAAAC,UAAA,GAAAH,IAAA,CACPI,KAAK;IAALA,KAAK,GAAAD,UAAA,cAAGE,SAAS,GAAAF,UAAA;IAAAG,WAAA,GAAAN,IAAA,CACjBO,MAAM;IAANA,MAAM,GAAAD,WAAA,cAAGD,SAAS,GAAAC,WAAA;IAAAE,WAAA,GAAAR,IAAA,CAClBS,MAAM;IAANA,MAAM,GAAAD,WAAA,cAAG,KAAK,GAAAA,WAAA;EAEd,IAAME,WAAW,GAAGH,MAAM,KAAKF,SAAS,aAAAM,MAAA,CAAaJ,MAAM,IAAKF,SAAS;EACzE,IAAMO,UAAU,GAAGR,KAAK,KAAKC,SAAS,aAAAM,MAAA,CAAaP,KAAK,IAAKC,SAAS;EAEtE,oBACIX,MAAA,CAAAmB,OAAA,CAAAC,aAAA,CAACjB,gBAAA,CAAAkB,QAAQ;IACLC,EAAE,aAAAL,MAAA,CAAaV,IAAI,CAAG;IACtBA,IAAI,EAAE,SAAU;IAChBgB,KAAK,EAAE,IAAK;IACZV,MAAM,EAAEG,WAAY;IACpBN,KAAK,EAAEQ,UAAW;IAClBH,MAAM,EAAEA;EAAO,gBAEff,MAAA,CAAAmB,OAAA,CAAAC,aAAA,CAACjB,gBAAA,CAAAkB,QAAQ;IAACC,EAAE,YAAAL,MAAA,CAAYV,IAAI,UAAQ;IAACA,IAAI,EAAE,MAAO;IAACiB,KAAK,EAAEjB;EAAK,CAAE,CAAC,EACjEC,OAAO,gBACJR,MAAA,CAAAmB,OAAA,CAAAC,aAAA,CAACjB,gBAAA,CAAAkB,QAAQ;IAACC,EAAE,YAAAL,MAAA,CAAYV,IAAI,aAAW;IAACA,IAAI,EAAE,SAAU;IAACiB,KAAK,EAAEhB;EAAQ,CAAE,CAAC,GAC3E,IACE,CAAC;AAEnB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","Property","Plugin","name","element","after","undefined","before","remove","placeBefore","placeAfter","createElement","id","array","value"],"sources":["Plugin.tsx"],"sourcesContent":["import React from \"react\";\nimport { Property } from \"@webiny/react-properties\";\n\nexport interface PluginConfig {\n name: string;\n element: React.ReactElement;\n}\n\nexport interface PluginProps {\n name: string;\n element?: React.ReactElement<unknown>;\n remove?: boolean;\n before?: string;\n after?: string;\n}\n\nexport const Plugin = ({\n name,\n element,\n after = undefined,\n before = undefined,\n remove = false\n}: PluginProps) => {\n const placeBefore = before !== undefined ? `plugin:${before}` : undefined;\n const placeAfter = after !== undefined ? `plugin:${after}` : undefined;\n\n return (\n <Property\n id={`plugins:${name}`}\n name={\"plugins\"}\n array={true}\n before={placeBefore}\n after={placeAfter}\n remove={remove}\n >\n <Property id={`plugin:${name}:name`} name={\"name\"} value={name} />\n {element ? (\n <Property id={`plugin:${name}:element`} name={\"element\"} value={element} />\n ) : null}\n </Property>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,QAAQ,0BAA0B;AAenD,OAAO,MAAMC,MAAM,GAAGA,CAAC;EACnBC,IAAI;EACJC,OAAO;EACPC,KAAK,GAAGC,SAAS;EACjBC,MAAM,GAAGD,SAAS;EAClBE,MAAM,GAAG;AACA,CAAC,KAAK;EACf,MAAMC,WAAW,GAAGF,MAAM,KAAKD,SAAS,GAAG,UAAUC,MAAM,EAAE,GAAGD,SAAS;EACzE,MAAMI,UAAU,GAAGL,KAAK,KAAKC,SAAS,GAAG,UAAUD,KAAK,EAAE,GAAGC,SAAS;EAEtE,oBACIN,KAAA,CAAAW,aAAA,CAACV,QAAQ;IACLW,EAAE,EAAE,WAAWT,IAAI,EAAG;IACtBA,IAAI,EAAE,SAAU;IAChBU,KAAK,EAAE,IAAK;IACZN,MAAM,EAAEE,WAAY;IACpBJ,KAAK,EAAEK,UAAW;IAClBF,MAAM,EAAEA;EAAO,gBAEfR,KAAA,CAAAW,aAAA,CAACV,QAAQ;IAACW,EAAE,EAAE,UAAUT,IAAI,OAAQ;IAACA,IAAI,EAAE,MAAO;IAACW,KAAK,EAAEX;EAAK,CAAE,CAAC,EACjEC,OAAO,gBACJJ,KAAA,CAAAW,aAAA,CAACV,QAAQ;IAACW,EAAE,EAAE,UAAUT,IAAI,UAAW;IAACA,IAAI,EAAE,SAAU;IAACW,KAAK,EAAEV;EAAQ,CAAE,CAAC,GAC3E,IACE,CAAC;AAEnB,CAAC","ignoreList":[]}
@@ -1,36 +1,27 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.ToolbarElement = void 0;
8
- var _react = _interopRequireDefault(require("react"));
9
- var _reactProperties = require("@webiny/react-properties");
10
- var ToolbarElement = exports.ToolbarElement = function ToolbarElement(_ref) {
11
- var name = _ref.name,
12
- element = _ref.element,
13
- _ref$after = _ref.after,
14
- after = _ref$after === void 0 ? undefined : _ref$after,
15
- _ref$before = _ref.before,
16
- before = _ref$before === void 0 ? undefined : _ref$before,
17
- _ref$remove = _ref.remove,
18
- remove = _ref$remove === void 0 ? false : _ref$remove;
19
- var placeBefore = before !== undefined ? "element:".concat(before) : undefined;
20
- var placeAfter = after !== undefined ? "element:".concat(after) : undefined;
21
- return /*#__PURE__*/_react.default.createElement(_reactProperties.Property, {
22
- id: "element:".concat(name),
1
+ import React from "react";
2
+ import { Property } from "@webiny/react-properties";
3
+ export const ToolbarElement = ({
4
+ name,
5
+ element,
6
+ after = undefined,
7
+ before = undefined,
8
+ remove = false
9
+ }) => {
10
+ const placeBefore = before !== undefined ? `element:${before}` : undefined;
11
+ const placeAfter = after !== undefined ? `element:${after}` : undefined;
12
+ return /*#__PURE__*/React.createElement(Property, {
13
+ id: `element:${name}`,
23
14
  name: "toolbarElements",
24
15
  array: true,
25
16
  before: placeBefore,
26
17
  after: placeAfter,
27
18
  remove: remove
28
- }, /*#__PURE__*/_react.default.createElement(_reactProperties.Property, {
29
- id: "element:".concat(name, ":name"),
19
+ }, /*#__PURE__*/React.createElement(Property, {
20
+ id: `element:${name}:name`,
30
21
  name: "name",
31
22
  value: name
32
- }), element ? /*#__PURE__*/_react.default.createElement(_reactProperties.Property, {
33
- id: "element:".concat(name, ":element"),
23
+ }), element ? /*#__PURE__*/React.createElement(Property, {
24
+ id: `element:${name}:element`,
34
25
  name: "element",
35
26
  value: element
36
27
  }) : null);
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_reactProperties","ToolbarElement","exports","_ref","name","element","_ref$after","after","undefined","_ref$before","before","_ref$remove","remove","placeBefore","concat","placeAfter","default","createElement","Property","id","array","value"],"sources":["ToolbarElement.tsx"],"sourcesContent":["import React from \"react\";\nimport { Property } from \"@webiny/react-properties\";\n\nexport interface ToolbarElementConfig {\n name: string;\n element: React.ReactElement;\n}\n\nexport interface ToolbarElementProps {\n name: string;\n element?: React.ReactElement<unknown>;\n remove?: boolean;\n before?: string;\n after?: string;\n}\n\nexport const ToolbarElement = ({\n name,\n element,\n after = undefined,\n before = undefined,\n remove = false\n}: ToolbarElementProps) => {\n const placeBefore = before !== undefined ? `element:${before}` : undefined;\n const placeAfter = after !== undefined ? `element:${after}` : undefined;\n\n return (\n <Property\n id={`element:${name}`}\n name={\"toolbarElements\"}\n array={true}\n before={placeBefore}\n after={placeAfter}\n remove={remove}\n >\n <Property id={`element:${name}:name`} name={\"name\"} value={name} />\n {element ? (\n <Property id={`element:${name}:element`} name={\"element\"} value={element} />\n ) : null}\n </Property>\n );\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAeO,IAAME,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,SAAjBA,cAAcA,CAAAE,IAAA,EAMA;EAAA,IALvBC,IAAI,GAAAD,IAAA,CAAJC,IAAI;IACJC,OAAO,GAAAF,IAAA,CAAPE,OAAO;IAAAC,UAAA,GAAAH,IAAA,CACPI,KAAK;IAALA,KAAK,GAAAD,UAAA,cAAGE,SAAS,GAAAF,UAAA;IAAAG,WAAA,GAAAN,IAAA,CACjBO,MAAM;IAANA,MAAM,GAAAD,WAAA,cAAGD,SAAS,GAAAC,WAAA;IAAAE,WAAA,GAAAR,IAAA,CAClBS,MAAM;IAANA,MAAM,GAAAD,WAAA,cAAG,KAAK,GAAAA,WAAA;EAEd,IAAME,WAAW,GAAGH,MAAM,KAAKF,SAAS,cAAAM,MAAA,CAAcJ,MAAM,IAAKF,SAAS;EAC1E,IAAMO,UAAU,GAAGR,KAAK,KAAKC,SAAS,cAAAM,MAAA,CAAcP,KAAK,IAAKC,SAAS;EAEvE,oBACIX,MAAA,CAAAmB,OAAA,CAAAC,aAAA,CAACjB,gBAAA,CAAAkB,QAAQ;IACLC,EAAE,aAAAL,MAAA,CAAaV,IAAI,CAAG;IACtBA,IAAI,EAAE,iBAAkB;IACxBgB,KAAK,EAAE,IAAK;IACZV,MAAM,EAAEG,WAAY;IACpBN,KAAK,EAAEQ,UAAW;IAClBH,MAAM,EAAEA;EAAO,gBAEff,MAAA,CAAAmB,OAAA,CAAAC,aAAA,CAACjB,gBAAA,CAAAkB,QAAQ;IAACC,EAAE,aAAAL,MAAA,CAAaV,IAAI,UAAQ;IAACA,IAAI,EAAE,MAAO;IAACiB,KAAK,EAAEjB;EAAK,CAAE,CAAC,EAClEC,OAAO,gBACJR,MAAA,CAAAmB,OAAA,CAAAC,aAAA,CAACjB,gBAAA,CAAAkB,QAAQ;IAACC,EAAE,aAAAL,MAAA,CAAaV,IAAI,aAAW;IAACA,IAAI,EAAE,SAAU;IAACiB,KAAK,EAAEhB;EAAQ,CAAE,CAAC,GAC5E,IACE,CAAC;AAEnB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","Property","ToolbarElement","name","element","after","undefined","before","remove","placeBefore","placeAfter","createElement","id","array","value"],"sources":["ToolbarElement.tsx"],"sourcesContent":["import React from \"react\";\nimport { Property } from \"@webiny/react-properties\";\n\nexport interface ToolbarElementConfig {\n name: string;\n element: React.ReactElement;\n}\n\nexport interface ToolbarElementProps {\n name: string;\n element?: React.ReactElement<unknown>;\n remove?: boolean;\n before?: string;\n after?: string;\n}\n\nexport const ToolbarElement = ({\n name,\n element,\n after = undefined,\n before = undefined,\n remove = false\n}: ToolbarElementProps) => {\n const placeBefore = before !== undefined ? `element:${before}` : undefined;\n const placeAfter = after !== undefined ? `element:${after}` : undefined;\n\n return (\n <Property\n id={`element:${name}`}\n name={\"toolbarElements\"}\n array={true}\n before={placeBefore}\n after={placeAfter}\n remove={remove}\n >\n <Property id={`element:${name}:name`} name={\"name\"} value={name} />\n {element ? (\n <Property id={`element:${name}:element`} name={\"element\"} value={element} />\n ) : null}\n </Property>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,QAAQ,0BAA0B;AAenD,OAAO,MAAMC,cAAc,GAAGA,CAAC;EAC3BC,IAAI;EACJC,OAAO;EACPC,KAAK,GAAGC,SAAS;EACjBC,MAAM,GAAGD,SAAS;EAClBE,MAAM,GAAG;AACQ,CAAC,KAAK;EACvB,MAAMC,WAAW,GAAGF,MAAM,KAAKD,SAAS,GAAG,WAAWC,MAAM,EAAE,GAAGD,SAAS;EAC1E,MAAMI,UAAU,GAAGL,KAAK,KAAKC,SAAS,GAAG,WAAWD,KAAK,EAAE,GAAGC,SAAS;EAEvE,oBACIN,KAAA,CAAAW,aAAA,CAACV,QAAQ;IACLW,EAAE,EAAE,WAAWT,IAAI,EAAG;IACtBA,IAAI,EAAE,iBAAkB;IACxBU,KAAK,EAAE,IAAK;IACZN,MAAM,EAAEE,WAAY;IACpBJ,KAAK,EAAEK,UAAW;IAClBF,MAAM,EAAEA;EAAO,gBAEfR,KAAA,CAAAW,aAAA,CAACV,QAAQ;IAACW,EAAE,EAAE,WAAWT,IAAI,OAAQ;IAACA,IAAI,EAAE,MAAO;IAACW,KAAK,EAAEX;EAAK,CAAE,CAAC,EAClEC,OAAO,gBACJJ,KAAA,CAAAW,aAAA,CAACV,QAAQ;IAACW,EAAE,EAAE,WAAWT,IAAI,UAAW;IAACA,IAAI,EAAE,SAAU;IAACW,KAAK,EAAEV;EAAQ,CAAE,CAAC,GAC5E,IACE,CAAC;AAEnB,CAAC","ignoreList":[]}
@@ -1,66 +1,57 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.LexicalHtmlRenderer = void 0;
9
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
12
- var _react = _interopRequireWildcard(require("react"));
13
- var _emotion = require("emotion");
14
- var _LexicalComposer = require("@lexical/react/LexicalComposer");
15
- var _LexicalRichTextPlugin = require("@lexical/react/LexicalRichTextPlugin");
16
- var _LexicalContentEditable = require("@lexical/react/LexicalContentEditable");
17
- var _LexicalErrorBoundary = _interopRequireDefault(require("@lexical/react/LexicalErrorBoundary"));
18
- var _lexicalNodes = require("@webiny/lexical-nodes");
19
- var _lexicalTheme = require("@webiny/lexical-theme");
20
- var _isValidLexicalData = require("../utils/isValidLexicalData");
21
- var _generateInitialLexicalValue = require("../utils/generateInitialLexicalValue");
22
- var _LexicalUpdateStatePlugin = require("../plugins/LexicalUpdateStatePlugin");
23
- var _RichTextEditorContext = require("../context/RichTextEditorContext");
24
- var _excluded = ["nodes", "value"];
25
- var LexicalHtmlRenderer = exports.LexicalHtmlRenderer = function LexicalHtmlRenderer(_ref) {
26
- var nodes = _ref.nodes,
27
- value = _ref.value,
28
- props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
29
- var theme = (0, _objectSpread2.default)({
1
+ import React, { useRef } from "react";
2
+ import { css } from "emotion";
3
+ import { LexicalComposer } from "@lexical/react/LexicalComposer";
4
+ import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
5
+ import { ContentEditable } from "@lexical/react/LexicalContentEditable";
6
+ import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary";
7
+ import { allNodes } from "@webiny/lexical-nodes";
8
+ import { createTheme, toTypographyEmotionMap } from "@webiny/lexical-theme";
9
+ import { isValidLexicalData } from "../utils/isValidLexicalData";
10
+ import { generateInitialLexicalValue } from "../utils/generateInitialLexicalValue";
11
+ import { UpdateStatePlugin } from "../plugins/LexicalUpdateStatePlugin";
12
+ import { RichTextEditorProvider } from "../context/RichTextEditorContext";
13
+ export const LexicalHtmlRenderer = ({
14
+ nodes,
15
+ value,
16
+ ...props
17
+ }) => {
18
+ const theme = {
30
19
  styles: {},
31
- emotionMap: {}
32
- }, props.theme);
33
- var themeEmotionMap = props?.themeEmotionMap ?? (0, _lexicalTheme.toTypographyEmotionMap)(_emotion.css, theme, props.themeStylesTransformer);
34
- var editorTheme = (0, _react.useRef)((0, _lexicalTheme.createTheme)(theme));
35
- var editorValue = (0, _isValidLexicalData.isValidLexicalData)(value) ? value : (0, _generateInitialLexicalValue.generateInitialLexicalValue)();
36
- var initialConfig = {
20
+ emotionMap: {},
21
+ ...props.theme
22
+ };
23
+ const themeEmotionMap = props?.themeEmotionMap ?? toTypographyEmotionMap(css, theme, props.themeStylesTransformer);
24
+ const editorTheme = useRef(createTheme(theme));
25
+ const editorValue = isValidLexicalData(value) ? value : generateInitialLexicalValue();
26
+ const initialConfig = {
37
27
  // We update the state via the `<LexicalUpdateStatePlugin/>`.
38
28
  editorState: null,
39
29
  namespace: "webiny",
40
- onError: function onError() {
30
+ onError: () => {
41
31
  // Ignore errors. We don't want to break the app because of errors caused by config/value updates.
42
32
  // These are usually resolved in the next component render cycle.
43
33
  },
44
34
  editable: false,
45
- nodes: [].concat((0, _toConsumableArray2.default)(_lexicalNodes.allNodes), (0, _toConsumableArray2.default)(nodes || [])),
46
- theme: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, editorTheme.current), {}, {
35
+ nodes: [...allNodes, ...(nodes || [])],
36
+ theme: {
37
+ ...editorTheme.current,
47
38
  emotionMap: themeEmotionMap,
48
39
  styles: theme.styles
49
- })
40
+ }
50
41
  };
51
- return /*#__PURE__*/_react.default.createElement(_LexicalComposer.LexicalComposer, {
42
+ return /*#__PURE__*/React.createElement(LexicalComposer, {
52
43
  initialConfig: initialConfig,
53
44
  key: initialConfig.nodes.length
54
- }, /*#__PURE__*/_react.default.createElement(_RichTextEditorContext.RichTextEditorProvider, {
45
+ }, /*#__PURE__*/React.createElement(RichTextEditorProvider, {
55
46
  theme: theme,
56
47
  themeEmotionMap: themeEmotionMap
57
- }, /*#__PURE__*/_react.default.createElement(_LexicalRichTextPlugin.RichTextPlugin, {
58
- contentEditable: /*#__PURE__*/_react.default.createElement("div", {
48
+ }, /*#__PURE__*/React.createElement(RichTextPlugin, {
49
+ contentEditable: /*#__PURE__*/React.createElement("div", {
59
50
  className: "editor"
60
- }, /*#__PURE__*/_react.default.createElement(_LexicalContentEditable.ContentEditable, null)),
61
- ErrorBoundary: _LexicalErrorBoundary.default,
51
+ }, /*#__PURE__*/React.createElement(ContentEditable, null)),
52
+ ErrorBoundary: LexicalErrorBoundary,
62
53
  placeholder: null
63
- }), /*#__PURE__*/_react.default.createElement(_LexicalUpdateStatePlugin.UpdateStatePlugin, {
54
+ }), /*#__PURE__*/React.createElement(UpdateStatePlugin, {
64
55
  value: editorValue
65
56
  })));
66
57
  };