@webiny/lexical-editor 6.3.0 → 6.4.0-beta.1

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 (252) hide show
  1. package/commands/image.js +2 -1
  2. package/commands/image.js.map +1 -1
  3. package/commands/index.js +0 -2
  4. package/commands/list.js +4 -3
  5. package/commands/list.js.map +1 -1
  6. package/commands/quote.js +2 -1
  7. package/commands/quote.js.map +1 -1
  8. package/commands/toolbar.js +2 -1
  9. package/commands/toolbar.js.map +1 -1
  10. package/commands/typography.js +2 -1
  11. package/commands/typography.js.map +1 -1
  12. package/components/Editor/EnsureHeadingTagPlugin.js +8 -15
  13. package/components/Editor/EnsureHeadingTagPlugin.js.map +1 -1
  14. package/components/Editor/RichTextEditor.js +82 -121
  15. package/components/Editor/RichTextEditor.js.map +1 -1
  16. package/components/Editor/normalizeInputValue.js +11 -13
  17. package/components/Editor/normalizeInputValue.js.map +1 -1
  18. package/components/LexicalEditorConfig/LexicalEditorConfig.js +24 -15
  19. package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -1
  20. package/components/LexicalEditorConfig/components/Node.js +21 -26
  21. package/components/LexicalEditorConfig/components/Node.js.map +1 -1
  22. package/components/LexicalEditorConfig/components/Plugin.js +21 -26
  23. package/components/LexicalEditorConfig/components/Plugin.js.map +1 -1
  24. package/components/LexicalEditorConfig/components/ToolbarElement.js +21 -26
  25. package/components/LexicalEditorConfig/components/ToolbarElement.js.map +1 -1
  26. package/components/LexicalHtmlRenderer.js +35 -40
  27. package/components/LexicalHtmlRenderer.js.map +1 -1
  28. package/components/Toolbar/StaticToolbar.js +11 -16
  29. package/components/Toolbar/StaticToolbar.js.map +1 -1
  30. package/components/ToolbarActions/BoldAction.js +16 -19
  31. package/components/ToolbarActions/BoldAction.js.map +1 -1
  32. package/components/ToolbarActions/BulletListAction.js +24 -32
  33. package/components/ToolbarActions/BulletListAction.js.map +1 -1
  34. package/components/ToolbarActions/CodeHighlightAction.js +16 -19
  35. package/components/ToolbarActions/CodeHighlightAction.js.map +1 -1
  36. package/components/ToolbarActions/FontColorAction.js +32 -38
  37. package/components/ToolbarActions/FontColorAction.js.map +1 -1
  38. package/components/ToolbarActions/ImageAction.js +28 -30
  39. package/components/ToolbarActions/ImageAction.js.map +1 -1
  40. package/components/ToolbarActions/ItalicAction.js +16 -19
  41. package/components/ToolbarActions/ItalicAction.js.map +1 -1
  42. package/components/ToolbarActions/LinkAction.js +25 -30
  43. package/components/ToolbarActions/LinkAction.js.map +1 -1
  44. package/components/ToolbarActions/NumberedListAction.js +28 -37
  45. package/components/ToolbarActions/NumberedListAction.js.map +1 -1
  46. package/components/ToolbarActions/QuoteAction.js +22 -27
  47. package/components/ToolbarActions/QuoteAction.js.map +1 -1
  48. package/components/ToolbarActions/TextAlignmentAction.js +38 -50
  49. package/components/ToolbarActions/TextAlignmentAction.js.map +1 -1
  50. package/components/ToolbarActions/TypographyAction.js +69 -99
  51. package/components/ToolbarActions/TypographyAction.js.map +1 -1
  52. package/components/ToolbarActions/UnderlineAction.js +16 -19
  53. package/components/ToolbarActions/UnderlineAction.js.map +1 -1
  54. package/context/FontColorActionContext.js +3 -2
  55. package/context/FontColorActionContext.js.map +1 -1
  56. package/context/RichTextEditorContext.js +26 -29
  57. package/context/RichTextEditorContext.js.map +1 -1
  58. package/context/SharedHistoryContext.js +11 -15
  59. package/context/SharedHistoryContext.js.map +1 -1
  60. package/context/TextAlignmentActionContextProps.js +3 -2
  61. package/context/TextAlignmentActionContextProps.js.map +1 -1
  62. package/context/TypographyActionContext.js +3 -2
  63. package/context/TypographyActionContext.js.map +1 -1
  64. package/exports/admin/lexical.js +2 -20
  65. package/hooks/index.js +0 -2
  66. package/hooks/useCurrentElement.js +18 -21
  67. package/hooks/useCurrentElement.js.map +1 -1
  68. package/hooks/useCurrentSelection.js +39 -48
  69. package/hooks/useCurrentSelection.js.map +1 -1
  70. package/hooks/useFontColorPicker.js +5 -6
  71. package/hooks/useFontColorPicker.js.map +1 -1
  72. package/hooks/useIsMounted.js +7 -8
  73. package/hooks/useIsMounted.js.map +1 -1
  74. package/hooks/useRichTextEditor.js +5 -6
  75. package/hooks/useRichTextEditor.js.map +1 -1
  76. package/hooks/useTextAlignmentAction.js +5 -6
  77. package/hooks/useTextAlignmentAction.js.map +1 -1
  78. package/hooks/useTypographyAction.js +5 -6
  79. package/hooks/useTypographyAction.js.map +1 -1
  80. package/images/icons/chat-square-quote.js +19 -0
  81. package/images/icons/chat-square-quote.js.map +1 -0
  82. package/images/icons/chevron-down.js +18 -0
  83. package/images/icons/chevron-down.js.map +1 -0
  84. package/images/icons/code.js +17 -0
  85. package/images/icons/code.js.map +1 -0
  86. package/images/icons/font-color.js +17 -0
  87. package/images/icons/font-color.js.map +1 -0
  88. package/images/icons/indent.js +18 -0
  89. package/images/icons/indent.js.map +1 -0
  90. package/images/icons/insert-image.js +20 -0
  91. package/images/icons/insert-image.js.map +1 -0
  92. package/images/icons/justify.js +19 -0
  93. package/images/icons/justify.js.map +1 -0
  94. package/images/icons/link.js +19 -0
  95. package/images/icons/link.js.map +1 -0
  96. package/images/icons/list-ol.js +20 -0
  97. package/images/icons/list-ol.js.map +1 -0
  98. package/images/icons/list-ul.js +18 -0
  99. package/images/icons/list-ul.js.map +1 -0
  100. package/images/icons/outdent.js +18 -0
  101. package/images/icons/outdent.js.map +1 -0
  102. package/images/icons/pencil-fill.js +17 -0
  103. package/images/icons/pencil-fill.js.map +1 -0
  104. package/images/icons/text-center.js +18 -0
  105. package/images/icons/text-center.js.map +1 -0
  106. package/images/icons/text-left.js +18 -0
  107. package/images/icons/text-left.js.map +1 -0
  108. package/images/icons/text-paragraph.js +18 -0
  109. package/images/icons/text-paragraph.js.map +1 -0
  110. package/images/icons/text-right.js +18 -0
  111. package/images/icons/text-right.js.map +1 -0
  112. package/images/icons/type-bold.js +17 -0
  113. package/images/icons/type-bold.js.map +1 -0
  114. package/images/icons/type-h1.js +17 -0
  115. package/images/icons/type-h1.js.map +1 -0
  116. package/images/icons/type-h2.js +17 -0
  117. package/images/icons/type-h2.js.map +1 -0
  118. package/images/icons/type-h3.js +17 -0
  119. package/images/icons/type-h3.js.map +1 -0
  120. package/images/icons/type-h4.js +17 -0
  121. package/images/icons/type-h4.js.map +1 -0
  122. package/images/icons/type-h5.js +17 -0
  123. package/images/icons/type-h5.js.map +1 -0
  124. package/images/icons/type-h6.js +17 -0
  125. package/images/icons/type-h6.js.map +1 -0
  126. package/images/icons/type-italic.js +17 -0
  127. package/images/icons/type-italic.js.map +1 -0
  128. package/images/icons/type-strikethrough.js +17 -0
  129. package/images/icons/type-strikethrough.js.map +1 -0
  130. package/images/icons/type-underline.js +17 -0
  131. package/images/icons/type-underline.js.map +1 -0
  132. package/images/icons/unlink_icon.js +27 -0
  133. package/images/icons/unlink_icon.js.map +1 -0
  134. package/index.js +5 -18
  135. package/package.json +7 -7
  136. package/plugins/BlurEventPlugin/BlurEventPlugin.js +11 -14
  137. package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -1
  138. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +7 -8
  139. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -1
  140. package/plugins/CodeHighlightPlugin/index.js +0 -2
  141. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +16 -24
  142. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js.map +1 -1
  143. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js +37 -51
  144. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js.map +1 -1
  145. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +6 -5
  146. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
  147. package/plugins/FloatingLinkEditorPlugin/index.js +0 -2
  148. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js +6 -9
  149. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js.map +1 -1
  150. package/plugins/FloatingLinkEditorPlugin/types.js +0 -3
  151. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js +101 -108
  152. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js.map +1 -1
  153. package/plugins/FontColorPlugin/FontColorPlugin.js +14 -19
  154. package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -1
  155. package/plugins/FontColorPlugin/applyColorToNode.js +5 -4
  156. package/plugins/FontColorPlugin/applyColorToNode.js.map +1 -1
  157. package/plugins/FontColorPlugin/applyColorToSelection.js +42 -60
  158. package/plugins/FontColorPlugin/applyColorToSelection.js.map +1 -1
  159. package/plugins/ImagesPlugin/ImagesPlugin.js +79 -121
  160. package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -1
  161. package/plugins/LinkPlugin/LinkPlugin.js +46 -52
  162. package/plugins/LinkPlugin/LinkPlugin.js.map +1 -1
  163. package/plugins/ListPLugin/ListPlugin.js +44 -52
  164. package/plugins/ListPLugin/ListPlugin.js.map +1 -1
  165. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +18 -19
  166. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js.map +1 -1
  167. package/plugins/StateHandlingPlugin.js +55 -64
  168. package/plugins/StateHandlingPlugin.js.map +1 -1
  169. package/plugins/TypographyPlugin/TypographyPlugin.js +13 -20
  170. package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -1
  171. package/static/svg/chat-square-quote.123cfa24.svg +1 -0
  172. package/static/svg/chevron-down.d9636921.svg +1 -0
  173. package/static/svg/code.912b1f4d.svg +1 -0
  174. package/static/svg/font-color.4f0c0de5.svg +1 -0
  175. package/static/svg/indent.4d78e483.svg +3 -0
  176. package/static/svg/insert-image.354465f1.svg +4 -0
  177. package/static/svg/justify.dab42aec.svg +3 -0
  178. package/static/svg/link.b774de25.svg +1 -0
  179. package/static/svg/list-ol.d64946f3.svg +1 -0
  180. package/static/svg/list-ul.1d54da3f.svg +1 -0
  181. package/static/svg/outdent.5c13ff16.svg +3 -0
  182. package/static/svg/pencil-fill.94cb216b.svg +1 -0
  183. package/static/svg/text-center.a411e780.svg +1 -0
  184. package/static/svg/text-left.54f41f4e.svg +1 -0
  185. package/static/svg/text-paragraph.61674422.svg +1 -0
  186. package/static/svg/text-right.9288b7a2.svg +1 -0
  187. package/static/svg/type-bold.7e3e270b.svg +1 -0
  188. package/static/svg/type-h1.f292ffe1.svg +1 -0
  189. package/static/svg/type-h2.a9d1aa48.svg +1 -0
  190. package/static/svg/type-h3.4a29ff88.svg +1 -0
  191. package/static/svg/type-h4.7f48750c.svg +1 -0
  192. package/static/svg/type-h5.14b4ac56.svg +1 -0
  193. package/static/svg/type-h6.4e9dfe2d.svg +1 -0
  194. package/static/svg/type-italic.d8e45748.svg +1 -0
  195. package/static/svg/type-strikethrough.2694a816.svg +1 -0
  196. package/static/svg/type-underline.104a0ed5.svg +1 -0
  197. package/static/svg/unlink_icon.074ceed3.svg +1 -0
  198. package/types.js +0 -8
  199. package/ui/ContentEditable.js +6 -14
  200. package/ui/ContentEditable.js.map +1 -1
  201. package/ui/Divider.js +6 -5
  202. package/ui/Divider.js.map +1 -1
  203. package/ui/DropDown.js +146 -176
  204. package/ui/DropDown.js.map +1 -1
  205. package/ui/ImageResizer.js +173 -204
  206. package/ui/ImageResizer.js.map +1 -1
  207. package/ui/LinkPreview.js +61 -84
  208. package/ui/LinkPreview.js.map +1 -1
  209. package/ui/Placeholder.js +9 -20
  210. package/ui/Placeholder.js.map +1 -1
  211. package/ui/TextInput.js +17 -30
  212. package/ui/TextInput.js.map +1 -1
  213. package/ui/ToolbarActionDialog.js +64 -73
  214. package/ui/ToolbarActionDialog.js.map +1 -1
  215. package/utils/canUseDOM.js +2 -1
  216. package/utils/canUseDOM.js.map +1 -1
  217. package/utils/files.js +9 -8
  218. package/utils/files.js.map +1 -1
  219. package/utils/getDOMRangeRect.js +10 -20
  220. package/utils/getDOMRangeRect.js.map +1 -1
  221. package/utils/getSelectedNode.js +9 -20
  222. package/utils/getSelectedNode.js.map +1 -1
  223. package/utils/getTransparentImage.js +2 -3
  224. package/utils/getTransparentImage.js.map +1 -1
  225. package/utils/insertImage.js +9 -11
  226. package/utils/insertImage.js.map +1 -1
  227. package/utils/isAnchorLink.js +2 -3
  228. package/utils/isAnchorLink.js.map +1 -1
  229. package/utils/isChildOfFloatingToolbar.js +6 -9
  230. package/utils/isChildOfFloatingToolbar.js.map +1 -1
  231. package/utils/isHTMLElement.js +3 -9
  232. package/utils/isHTMLElement.js.map +1 -1
  233. package/utils/isValidJSON.js +9 -10
  234. package/utils/isValidJSON.js.map +1 -1
  235. package/utils/isValidLexicalData.js +17 -20
  236. package/utils/isValidLexicalData.js.map +1 -1
  237. package/utils/point.js +32 -45
  238. package/utils/point.js.map +1 -1
  239. package/utils/rect.js +92 -125
  240. package/utils/rect.js.map +1 -1
  241. package/utils/sanitizeUrl.js +8 -21
  242. package/utils/sanitizeUrl.js.map +1 -1
  243. package/utils/setFloatingElemPosition.js +23 -27
  244. package/utils/setFloatingElemPosition.js.map +1 -1
  245. package/commands/index.js.map +0 -1
  246. package/exports/admin/lexical.js.map +0 -1
  247. package/hooks/index.js.map +0 -1
  248. package/index.js.map +0 -1
  249. package/plugins/CodeHighlightPlugin/index.js.map +0 -1
  250. package/plugins/FloatingLinkEditorPlugin/index.js.map +0 -1
  251. package/plugins/FloatingLinkEditorPlugin/types.js.map +0 -1
  252. package/types.js.map +0 -1
@@ -1,59 +1,51 @@
1
1
  import { useEffect } from "react";
2
- import { $getSelection, $isRangeSelection, mergeRegister, COMMAND_PRIORITY_LOW, INDENT_CONTENT_COMMAND, INSERT_PARAGRAPH_COMMAND, KEY_BACKSPACE_COMMAND, OUTDENT_CONTENT_COMMAND } from "lexical";
3
- import { $handleListInsertParagraph, indentList, insertList, outdentList, removeList, $isListNode, ListNode, ListItemNode } from "@webiny/lexical-nodes";
2
+ import { $getSelection, $isRangeSelection, COMMAND_PRIORITY_LOW, INDENT_CONTENT_COMMAND, INSERT_PARAGRAPH_COMMAND, KEY_BACKSPACE_COMMAND, OUTDENT_CONTENT_COMMAND, mergeRegister } from "lexical";
3
+ import { $handleListInsertParagraph, $isListNode, ListItemNode, ListNode, indentList, insertList, outdentList, removeList } from "@webiny/lexical-nodes";
4
4
  import { INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, REMOVE_LIST_COMMAND } from "../../commands/index.js";
5
5
  import { useRichTextEditor } from "../../hooks/index.js";
6
6
  import { getNodeFromSelection } from "../../hooks/useCurrentElement.js";
7
- export function ListPlugin() {
8
- const {
9
- editor
10
- } = useRichTextEditor();
11
- useEffect(() => {
12
- if (!editor.hasNodes([ListNode, ListItemNode])) {
13
- throw new Error("ListPlugin: ListNode and/or ListItemNode not registered in the editor!");
14
- }
15
- }, [editor]);
16
- useEffect(() => {
17
- return mergeRegister(editor.registerCommand(INDENT_CONTENT_COMMAND, () => {
18
- indentList();
19
- return false;
20
- }, COMMAND_PRIORITY_LOW), editor.registerCommand(OUTDENT_CONTENT_COMMAND, () => {
21
- outdentList();
22
- return false;
23
- }, COMMAND_PRIORITY_LOW), editor.registerCommand(INSERT_ORDERED_LIST_COMMAND, ({
24
- themeStyleId
25
- }) => {
26
- insertList(editor, "number", themeStyleId);
27
- return true;
28
- }, COMMAND_PRIORITY_LOW), editor.registerCommand(INSERT_UNORDERED_LIST_COMMAND, ({
29
- themeStyleId
30
- }) => {
31
- insertList(editor, "bullet", themeStyleId);
32
- return true;
33
- }, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_BACKSPACE_COMMAND, event => {
34
- const selection = $getSelection();
35
- if ($isRangeSelection(selection)) {
36
- const node = getNodeFromSelection(selection);
37
- if (!$isListNode(node)) {
38
- return false;
39
- }
40
-
41
- // Check if list have one list item remain, without text.
42
- if (node.getChildren().length === 1 && !node.getTextContent()) {
43
- event.preventDefault();
44
- removeList(editor);
45
- return true;
46
- }
47
- }
48
- return false;
49
- }, COMMAND_PRIORITY_LOW), editor.registerCommand(REMOVE_LIST_COMMAND, () => {
50
- removeList(editor);
51
- return true;
52
- }, COMMAND_PRIORITY_LOW), editor.registerCommand(INSERT_PARAGRAPH_COMMAND, () => {
53
- return $handleListInsertParagraph();
54
- }, COMMAND_PRIORITY_LOW));
55
- }, [editor]);
56
- return null;
7
+ function ListPlugin() {
8
+ const { editor } = useRichTextEditor();
9
+ useEffect(()=>{
10
+ if (!editor.hasNodes([
11
+ ListNode,
12
+ ListItemNode
13
+ ])) throw new Error("ListPlugin: ListNode and/or ListItemNode not registered in the editor!");
14
+ }, [
15
+ editor
16
+ ]);
17
+ useEffect(()=>mergeRegister(editor.registerCommand(INDENT_CONTENT_COMMAND, ()=>{
18
+ indentList();
19
+ return false;
20
+ }, COMMAND_PRIORITY_LOW), editor.registerCommand(OUTDENT_CONTENT_COMMAND, ()=>{
21
+ outdentList();
22
+ return false;
23
+ }, COMMAND_PRIORITY_LOW), editor.registerCommand(INSERT_ORDERED_LIST_COMMAND, ({ themeStyleId })=>{
24
+ insertList(editor, "number", themeStyleId);
25
+ return true;
26
+ }, COMMAND_PRIORITY_LOW), editor.registerCommand(INSERT_UNORDERED_LIST_COMMAND, ({ themeStyleId })=>{
27
+ insertList(editor, "bullet", themeStyleId);
28
+ return true;
29
+ }, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_BACKSPACE_COMMAND, (event)=>{
30
+ const selection = $getSelection();
31
+ if ($isRangeSelection(selection)) {
32
+ const node = getNodeFromSelection(selection);
33
+ if (!$isListNode(node)) return false;
34
+ if (1 === node.getChildren().length && !node.getTextContent()) {
35
+ event.preventDefault();
36
+ removeList(editor);
37
+ return true;
38
+ }
39
+ }
40
+ return false;
41
+ }, COMMAND_PRIORITY_LOW), editor.registerCommand(REMOVE_LIST_COMMAND, ()=>{
42
+ removeList(editor);
43
+ return true;
44
+ }, COMMAND_PRIORITY_LOW), editor.registerCommand(INSERT_PARAGRAPH_COMMAND, ()=>$handleListInsertParagraph(), COMMAND_PRIORITY_LOW)), [
45
+ editor
46
+ ]);
47
+ return null;
57
48
  }
49
+ export { ListPlugin };
58
50
 
59
51
  //# sourceMappingURL=ListPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","$getSelection","$isRangeSelection","mergeRegister","COMMAND_PRIORITY_LOW","INDENT_CONTENT_COMMAND","INSERT_PARAGRAPH_COMMAND","KEY_BACKSPACE_COMMAND","OUTDENT_CONTENT_COMMAND","$handleListInsertParagraph","indentList","insertList","outdentList","removeList","$isListNode","ListNode","ListItemNode","INSERT_ORDERED_LIST_COMMAND","INSERT_UNORDERED_LIST_COMMAND","REMOVE_LIST_COMMAND","useRichTextEditor","getNodeFromSelection","ListPlugin","editor","hasNodes","Error","registerCommand","themeStyleId","event","selection","node","getChildren","length","getTextContent","preventDefault"],"sources":["ListPlugin.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport {\n $getSelection,\n $isRangeSelection,\n mergeRegister,\n COMMAND_PRIORITY_LOW,\n INDENT_CONTENT_COMMAND,\n INSERT_PARAGRAPH_COMMAND,\n KEY_BACKSPACE_COMMAND,\n OUTDENT_CONTENT_COMMAND\n} from \"lexical\";\nimport {\n $handleListInsertParagraph,\n indentList,\n insertList,\n outdentList,\n removeList,\n $isListNode,\n ListNode,\n ListItemNode\n} from \"@webiny/lexical-nodes\";\nimport {\n INSERT_ORDERED_LIST_COMMAND,\n INSERT_UNORDERED_LIST_COMMAND,\n REMOVE_LIST_COMMAND\n} from \"~/commands/index.js\";\nimport { useRichTextEditor } from \"~/hooks/index.js\";\nimport { getNodeFromSelection } from \"~/hooks/useCurrentElement.js\";\n\nexport function ListPlugin(): null {\n const { editor } = useRichTextEditor();\n\n useEffect(() => {\n if (!editor.hasNodes([ListNode, ListItemNode])) {\n throw new Error(\n \"ListPlugin: ListNode and/or ListItemNode not registered in the editor!\"\n );\n }\n }, [editor]);\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n INDENT_CONTENT_COMMAND,\n () => {\n indentList();\n return false;\n },\n COMMAND_PRIORITY_LOW\n ),\n editor.registerCommand(\n OUTDENT_CONTENT_COMMAND,\n () => {\n outdentList();\n return false;\n },\n COMMAND_PRIORITY_LOW\n ),\n editor.registerCommand(\n INSERT_ORDERED_LIST_COMMAND,\n ({ themeStyleId }) => {\n insertList(editor, \"number\", themeStyleId);\n return true;\n },\n COMMAND_PRIORITY_LOW\n ),\n editor.registerCommand(\n INSERT_UNORDERED_LIST_COMMAND,\n ({ themeStyleId }) => {\n insertList(editor, \"bullet\", themeStyleId);\n return true;\n },\n COMMAND_PRIORITY_LOW\n ),\n editor.registerCommand(\n KEY_BACKSPACE_COMMAND,\n (event: KeyboardEvent) => {\n const selection = $getSelection();\n if ($isRangeSelection(selection)) {\n const node = getNodeFromSelection(selection);\n if (!$isListNode(node)) {\n return false;\n }\n\n // Check if list have one list item remain, without text.\n if (node.getChildren().length === 1 && !node.getTextContent()) {\n event.preventDefault();\n removeList(editor);\n return true;\n }\n }\n return false;\n },\n COMMAND_PRIORITY_LOW\n ),\n editor.registerCommand(\n REMOVE_LIST_COMMAND,\n () => {\n removeList(editor);\n return true;\n },\n COMMAND_PRIORITY_LOW\n ),\n editor.registerCommand(\n INSERT_PARAGRAPH_COMMAND,\n () => {\n return $handleListInsertParagraph();\n },\n COMMAND_PRIORITY_LOW\n )\n );\n }, [editor]);\n\n return null;\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AACjC,SACIC,aAAa,EACbC,iBAAiB,EACjBC,aAAa,EACbC,oBAAoB,EACpBC,sBAAsB,EACtBC,wBAAwB,EACxBC,qBAAqB,EACrBC,uBAAuB,QACpB,SAAS;AAChB,SACIC,0BAA0B,EAC1BC,UAAU,EACVC,UAAU,EACVC,WAAW,EACXC,UAAU,EACVC,WAAW,EACXC,QAAQ,EACRC,YAAY,QACT,uBAAuB;AAC9B,SACIC,2BAA2B,EAC3BC,6BAA6B,EAC7BC,mBAAmB;AAEvB,SAASC,iBAAiB;AAC1B,SAASC,oBAAoB;AAE7B,OAAO,SAASC,UAAUA,CAAA,EAAS;EAC/B,MAAM;IAAEC;EAAO,CAAC,GAAGH,iBAAiB,CAAC,CAAC;EAEtCpB,SAAS,CAAC,MAAM;IACZ,IAAI,CAACuB,MAAM,CAACC,QAAQ,CAAC,CAACT,QAAQ,EAAEC,YAAY,CAAC,CAAC,EAAE;MAC5C,MAAM,IAAIS,KAAK,CACX,wEACJ,CAAC;IACL;EACJ,CAAC,EAAE,CAACF,MAAM,CAAC,CAAC;EAEZvB,SAAS,CAAC,MAAM;IACZ,OAAOG,aAAa,CAChBoB,MAAM,CAACG,eAAe,CAClBrB,sBAAsB,EACtB,MAAM;MACFK,UAAU,CAAC,CAAC;MACZ,OAAO,KAAK;IAChB,CAAC,EACDN,oBACJ,CAAC,EACDmB,MAAM,CAACG,eAAe,CAClBlB,uBAAuB,EACvB,MAAM;MACFI,WAAW,CAAC,CAAC;MACb,OAAO,KAAK;IAChB,CAAC,EACDR,oBACJ,CAAC,EACDmB,MAAM,CAACG,eAAe,CAClBT,2BAA2B,EAC3B,CAAC;MAAEU;IAAa,CAAC,KAAK;MAClBhB,UAAU,CAACY,MAAM,EAAE,QAAQ,EAAEI,YAAY,CAAC;MAC1C,OAAO,IAAI;IACf,CAAC,EACDvB,oBACJ,CAAC,EACDmB,MAAM,CAACG,eAAe,CAClBR,6BAA6B,EAC7B,CAAC;MAAES;IAAa,CAAC,KAAK;MAClBhB,UAAU,CAACY,MAAM,EAAE,QAAQ,EAAEI,YAAY,CAAC;MAC1C,OAAO,IAAI;IACf,CAAC,EACDvB,oBACJ,CAAC,EACDmB,MAAM,CAACG,eAAe,CAClBnB,qBAAqB,EACpBqB,KAAoB,IAAK;MACtB,MAAMC,SAAS,GAAG5B,aAAa,CAAC,CAAC;MACjC,IAAIC,iBAAiB,CAAC2B,SAAS,CAAC,EAAE;QAC9B,MAAMC,IAAI,GAAGT,oBAAoB,CAACQ,SAAS,CAAC;QAC5C,IAAI,CAACf,WAAW,CAACgB,IAAI,CAAC,EAAE;UACpB,OAAO,KAAK;QAChB;;QAEA;QACA,IAAIA,IAAI,CAACC,WAAW,CAAC,CAAC,CAACC,MAAM,KAAK,CAAC,IAAI,CAACF,IAAI,CAACG,cAAc,CAAC,CAAC,EAAE;UAC3DL,KAAK,CAACM,cAAc,CAAC,CAAC;UACtBrB,UAAU,CAACU,MAAM,CAAC;UAClB,OAAO,IAAI;QACf;MACJ;MACA,OAAO,KAAK;IAChB,CAAC,EACDnB,oBACJ,CAAC,EACDmB,MAAM,CAACG,eAAe,CAClBP,mBAAmB,EACnB,MAAM;MACFN,UAAU,CAACU,MAAM,CAAC;MAClB,OAAO,IAAI;IACf,CAAC,EACDnB,oBACJ,CAAC,EACDmB,MAAM,CAACG,eAAe,CAClBpB,wBAAwB,EACxB,MAAM;MACF,OAAOG,0BAA0B,CAAC,CAAC;IACvC,CAAC,EACDL,oBACJ,CACJ,CAAC;EACL,CAAC,EAAE,CAACmB,MAAM,CAAC,CAAC;EAEZ,OAAO,IAAI;AACf","ignoreList":[]}
1
+ {"version":3,"file":"plugins/ListPLugin/ListPlugin.js","sources":["../../../src/plugins/ListPLugin/ListPlugin.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport {\n $getSelection,\n $isRangeSelection,\n mergeRegister,\n COMMAND_PRIORITY_LOW,\n INDENT_CONTENT_COMMAND,\n INSERT_PARAGRAPH_COMMAND,\n KEY_BACKSPACE_COMMAND,\n OUTDENT_CONTENT_COMMAND\n} from \"lexical\";\nimport {\n $handleListInsertParagraph,\n indentList,\n insertList,\n outdentList,\n removeList,\n $isListNode,\n ListNode,\n ListItemNode\n} from \"@webiny/lexical-nodes\";\nimport {\n INSERT_ORDERED_LIST_COMMAND,\n INSERT_UNORDERED_LIST_COMMAND,\n REMOVE_LIST_COMMAND\n} from \"~/commands/index.js\";\nimport { useRichTextEditor } from \"~/hooks/index.js\";\nimport { getNodeFromSelection } from \"~/hooks/useCurrentElement.js\";\n\nexport function ListPlugin(): null {\n const { editor } = useRichTextEditor();\n\n useEffect(() => {\n if (!editor.hasNodes([ListNode, ListItemNode])) {\n throw new Error(\n \"ListPlugin: ListNode and/or ListItemNode not registered in the editor!\"\n );\n }\n }, [editor]);\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n INDENT_CONTENT_COMMAND,\n () => {\n indentList();\n return false;\n },\n COMMAND_PRIORITY_LOW\n ),\n editor.registerCommand(\n OUTDENT_CONTENT_COMMAND,\n () => {\n outdentList();\n return false;\n },\n COMMAND_PRIORITY_LOW\n ),\n editor.registerCommand(\n INSERT_ORDERED_LIST_COMMAND,\n ({ themeStyleId }) => {\n insertList(editor, \"number\", themeStyleId);\n return true;\n },\n COMMAND_PRIORITY_LOW\n ),\n editor.registerCommand(\n INSERT_UNORDERED_LIST_COMMAND,\n ({ themeStyleId }) => {\n insertList(editor, \"bullet\", themeStyleId);\n return true;\n },\n COMMAND_PRIORITY_LOW\n ),\n editor.registerCommand(\n KEY_BACKSPACE_COMMAND,\n (event: KeyboardEvent) => {\n const selection = $getSelection();\n if ($isRangeSelection(selection)) {\n const node = getNodeFromSelection(selection);\n if (!$isListNode(node)) {\n return false;\n }\n\n // Check if list have one list item remain, without text.\n if (node.getChildren().length === 1 && !node.getTextContent()) {\n event.preventDefault();\n removeList(editor);\n return true;\n }\n }\n return false;\n },\n COMMAND_PRIORITY_LOW\n ),\n editor.registerCommand(\n REMOVE_LIST_COMMAND,\n () => {\n removeList(editor);\n return true;\n },\n COMMAND_PRIORITY_LOW\n ),\n editor.registerCommand(\n INSERT_PARAGRAPH_COMMAND,\n () => {\n return $handleListInsertParagraph();\n },\n COMMAND_PRIORITY_LOW\n )\n );\n }, [editor]);\n\n return null;\n}\n"],"names":["ListPlugin","editor","useRichTextEditor","useEffect","ListNode","ListItemNode","Error","mergeRegister","INDENT_CONTENT_COMMAND","indentList","COMMAND_PRIORITY_LOW","OUTDENT_CONTENT_COMMAND","outdentList","INSERT_ORDERED_LIST_COMMAND","themeStyleId","insertList","INSERT_UNORDERED_LIST_COMMAND","KEY_BACKSPACE_COMMAND","event","selection","$getSelection","$isRangeSelection","node","getNodeFromSelection","$isListNode","removeList","REMOVE_LIST_COMMAND","INSERT_PARAGRAPH_COMMAND","$handleListInsertParagraph"],"mappings":";;;;;;AA6BO,SAASA;IACZ,MAAM,EAAEC,MAAM,EAAE,GAAGC;IAEnBC,UAAU;QACN,IAAI,CAACF,OAAO,QAAQ,CAAC;YAACG;YAAUC;SAAa,GACzC,MAAM,IAAIC,MACN;IAGZ,GAAG;QAACL;KAAO;IAEXE,UAAU,IACCI,cACHN,OAAO,eAAe,CAClBO,wBACA;YACIC;YACA,OAAO;QACX,GACAC,uBAEJT,OAAO,eAAe,CAClBU,yBACA;YACIC;YACA,OAAO;QACX,GACAF,uBAEJT,OAAO,eAAe,CAClBY,6BACA,CAAC,EAAEC,YAAY,EAAE;YACbC,WAAWd,QAAQ,UAAUa;YAC7B,OAAO;QACX,GACAJ,uBAEJT,OAAO,eAAe,CAClBe,+BACA,CAAC,EAAEF,YAAY,EAAE;YACbC,WAAWd,QAAQ,UAAUa;YAC7B,OAAO;QACX,GACAJ,uBAEJT,OAAO,eAAe,CAClBgB,uBACA,CAACC;YACG,MAAMC,YAAYC;YAClB,IAAIC,kBAAkBF,YAAY;gBAC9B,MAAMG,OAAOC,qBAAqBJ;gBAClC,IAAI,CAACK,YAAYF,OACb,OAAO;gBAIX,IAAIA,AAA8B,MAA9BA,KAAK,WAAW,GAAG,MAAM,IAAU,CAACA,KAAK,cAAc,IAAI;oBAC3DJ,MAAM,cAAc;oBACpBO,WAAWxB;oBACX,OAAO;gBACX;YACJ;YACA,OAAO;QACX,GACAS,uBAEJT,OAAO,eAAe,CAClByB,qBACA;YACID,WAAWxB;YACX,OAAO;QACX,GACAS,uBAEJT,OAAO,eAAe,CAClB0B,0BACA,IACWC,8BAEXlB,wBAGT;QAACT;KAAO;IAEX,OAAO;AACX"}
@@ -1,26 +1,25 @@
1
1
  import { useEffect } from "react";
2
- import { formatToQuote, QuoteNode } from "@webiny/lexical-nodes";
2
+ import { QuoteNode, formatToQuote } from "@webiny/lexical-nodes";
3
3
  import { COMMAND_PRIORITY_LOW, mergeRegister } from "lexical";
4
4
  import { useRichTextEditor } from "../../hooks/index.js";
5
5
  import { INSERT_QUOTE_COMMAND } from "../../commands/index.js";
6
- export function QuotePlugin() {
7
- const {
8
- editor
9
- } = useRichTextEditor();
10
- useEffect(() => {
11
- if (!editor.hasNodes([QuoteNode])) {
12
- throw new Error("QuoteNodePlugin: QuoteNode is not registered in the editor!");
13
- }
14
- }, [editor]);
15
- useEffect(() => {
16
- return mergeRegister(editor.registerCommand(INSERT_QUOTE_COMMAND, ({
17
- themeStyleId
18
- }) => {
19
- formatToQuote(editor, themeStyleId);
20
- return false;
21
- }, COMMAND_PRIORITY_LOW));
22
- }, [editor]);
23
- return null;
6
+ function QuotePlugin() {
7
+ const { editor } = useRichTextEditor();
8
+ useEffect(()=>{
9
+ if (!editor.hasNodes([
10
+ QuoteNode
11
+ ])) throw new Error("QuoteNodePlugin: QuoteNode is not registered in the editor!");
12
+ }, [
13
+ editor
14
+ ]);
15
+ useEffect(()=>mergeRegister(editor.registerCommand(INSERT_QUOTE_COMMAND, ({ themeStyleId })=>{
16
+ formatToQuote(editor, themeStyleId);
17
+ return false;
18
+ }, COMMAND_PRIORITY_LOW)), [
19
+ editor
20
+ ]);
21
+ return null;
24
22
  }
23
+ export { QuotePlugin };
25
24
 
26
25
  //# sourceMappingURL=QuoteNodePlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","formatToQuote","QuoteNode","COMMAND_PRIORITY_LOW","mergeRegister","useRichTextEditor","INSERT_QUOTE_COMMAND","QuotePlugin","editor","hasNodes","Error","registerCommand","themeStyleId"],"sources":["QuoteNodePlugin.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { formatToQuote, QuoteNode } from \"@webiny/lexical-nodes\";\nimport { COMMAND_PRIORITY_LOW, mergeRegister } from \"lexical\";\nimport { useRichTextEditor } from \"~/hooks/index.js\";\nimport { INSERT_QUOTE_COMMAND } from \"~/commands/index.js\";\n\nexport function QuotePlugin() {\n const { editor } = useRichTextEditor();\n\n useEffect(() => {\n if (!editor.hasNodes([QuoteNode])) {\n throw new Error(\"QuoteNodePlugin: QuoteNode is not registered in the editor!\");\n }\n }, [editor]);\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n INSERT_QUOTE_COMMAND,\n ({ themeStyleId }) => {\n formatToQuote(editor, themeStyleId);\n return false;\n },\n COMMAND_PRIORITY_LOW\n )\n );\n }, [editor]);\n\n return null;\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AACjC,SAASC,aAAa,EAAEC,SAAS,QAAQ,uBAAuB;AAChE,SAASC,oBAAoB,EAAEC,aAAa,QAAQ,SAAS;AAC7D,SAASC,iBAAiB;AAC1B,SAASC,oBAAoB;AAE7B,OAAO,SAASC,WAAWA,CAAA,EAAG;EAC1B,MAAM;IAAEC;EAAO,CAAC,GAAGH,iBAAiB,CAAC,CAAC;EAEtCL,SAAS,CAAC,MAAM;IACZ,IAAI,CAACQ,MAAM,CAACC,QAAQ,CAAC,CAACP,SAAS,CAAC,CAAC,EAAE;MAC/B,MAAM,IAAIQ,KAAK,CAAC,6DAA6D,CAAC;IAClF;EACJ,CAAC,EAAE,CAACF,MAAM,CAAC,CAAC;EAEZR,SAAS,CAAC,MAAM;IACZ,OAAOI,aAAa,CAChBI,MAAM,CAACG,eAAe,CAClBL,oBAAoB,EACpB,CAAC;MAAEM;IAAa,CAAC,KAAK;MAClBX,aAAa,CAACO,MAAM,EAAEI,YAAY,CAAC;MACnC,OAAO,KAAK;IAChB,CAAC,EACDT,oBACJ,CACJ,CAAC;EACL,CAAC,EAAE,CAACK,MAAM,CAAC,CAAC;EAEZ,OAAO,IAAI;AACf","ignoreList":[]}
1
+ {"version":3,"file":"plugins/QuoteNodePlugin/QuoteNodePlugin.js","sources":["../../../src/plugins/QuoteNodePlugin/QuoteNodePlugin.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { formatToQuote, QuoteNode } from \"@webiny/lexical-nodes\";\nimport { COMMAND_PRIORITY_LOW, mergeRegister } from \"lexical\";\nimport { useRichTextEditor } from \"~/hooks/index.js\";\nimport { INSERT_QUOTE_COMMAND } from \"~/commands/index.js\";\n\nexport function QuotePlugin() {\n const { editor } = useRichTextEditor();\n\n useEffect(() => {\n if (!editor.hasNodes([QuoteNode])) {\n throw new Error(\"QuoteNodePlugin: QuoteNode is not registered in the editor!\");\n }\n }, [editor]);\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n INSERT_QUOTE_COMMAND,\n ({ themeStyleId }) => {\n formatToQuote(editor, themeStyleId);\n return false;\n },\n COMMAND_PRIORITY_LOW\n )\n );\n }, [editor]);\n\n return null;\n}\n"],"names":["QuotePlugin","editor","useRichTextEditor","useEffect","QuoteNode","Error","mergeRegister","INSERT_QUOTE_COMMAND","themeStyleId","formatToQuote","COMMAND_PRIORITY_LOW"],"mappings":";;;;;AAMO,SAASA;IACZ,MAAM,EAAEC,MAAM,EAAE,GAAGC;IAEnBC,UAAU;QACN,IAAI,CAACF,OAAO,QAAQ,CAAC;YAACG;SAAU,GAC5B,MAAM,IAAIC,MAAM;IAExB,GAAG;QAACJ;KAAO;IAEXE,UAAU,IACCG,cACHL,OAAO,eAAe,CAClBM,sBACA,CAAC,EAAEC,YAAY,EAAE;YACbC,cAAcR,QAAQO;YACtB,OAAO;QACX,GACAE,wBAGT;QAACT;KAAO;IAEX,OAAO;AACX"}
@@ -1,75 +1,66 @@
1
- import React, { useEffect, useRef, useMemo } from "react";
1
+ import react, { useEffect, useMemo, useRef } from "react";
2
2
  import debounce from "lodash/debounce.js";
3
- import { OnChangePlugin as BaseOnChangePlugin } from "@lexical/react/LexicalOnChangePlugin";
3
+ import { OnChangePlugin } from "@lexical/react/LexicalOnChangePlugin";
4
4
  import { $isRootTextContentEmpty } from "@lexical/text";
5
5
  import { generateInitialLexicalValue, prepareLexicalState } from "@webiny/lexical-nodes";
6
6
  import { normalizeInputValue } from "../components/Editor/normalizeInputValue.js";
7
7
  import { useRichTextEditor } from "../hooks/index.js";
8
8
  import { parseLexicalState } from "../utils/isValidLexicalData.js";
9
- export const StateHandlingPlugin = props => {
10
- const {
11
- editor
12
- } = useRichTextEditor();
13
- const lastEmittedRef = useRef("");
14
- const lastOnChangeTimestampRef = useRef(0);
15
- const value = normalizeInputValue(props.value);
16
- const editorInputValue = prepareLexicalState(value);
17
- const handleOnChange = useMemo(() => {
18
- return debounce((editorState, editor) => {
19
- editorState.read(() => {
20
- if (typeof props.onChange === "function") {
21
- const editorState = editor.getEditorState();
22
- const isEditorEmpty = $isRootTextContentEmpty(editor.isComposing(), true);
23
- if (!value && isEditorEmpty) {
24
- return;
25
- }
26
- const newValue = JSON.stringify(editorState.toJSON());
27
- if (newValue !== lastEmittedRef.current) {
28
- lastEmittedRef.current = newValue;
29
- lastOnChangeTimestampRef.current = Date.now();
30
- props.onChange(newValue);
31
- }
32
- }
33
- });
34
- }, 300);
35
- }, [props.onChange, editor]);
36
- useEffect(() => {
37
- if (!value || !editor || value === lastEmittedRef.current) {
38
- return;
39
- }
40
- const now = Date.now();
41
- if (now - lastOnChangeTimestampRef.current < 500) {
42
- return;
43
- }
44
- const parsedState = parseLexicalState(editorInputValue);
45
- let newState;
46
- const currentSerialized = JSON.stringify(editor.getEditorState().toJSON());
47
- if (currentSerialized === editorInputValue) {
48
- return;
49
- }
50
- try {
51
- newState = editor.parseEditorState(parsedState || generateInitialLexicalValue());
52
- } catch {
53
- // Ignore errors
54
- }
55
-
56
- // We must set the state outside the `editor.update()` callback to prevent freezing.
57
- // https://lexical.dev/docs/api/classes/lexical.LexicalEditor#seteditorstate
58
- if (newState) {
59
- const state = newState;
60
- queueMicrotask(() => {
9
+ const StateHandlingPlugin = (props)=>{
10
+ const { editor } = useRichTextEditor();
11
+ const lastEmittedRef = useRef("");
12
+ const lastOnChangeTimestampRef = useRef(0);
13
+ const value = normalizeInputValue(props.value);
14
+ const editorInputValue = prepareLexicalState(value);
15
+ const handleOnChange = useMemo(()=>debounce((editorState, editor)=>{
16
+ editorState.read(()=>{
17
+ if ("function" == typeof props.onChange) {
18
+ const editorState = editor.getEditorState();
19
+ const isEditorEmpty = $isRootTextContentEmpty(editor.isComposing(), true);
20
+ if (!value && isEditorEmpty) return;
21
+ const newValue = JSON.stringify(editorState.toJSON());
22
+ if (newValue !== lastEmittedRef.current) {
23
+ lastEmittedRef.current = newValue;
24
+ lastOnChangeTimestampRef.current = Date.now();
25
+ props.onChange(newValue);
26
+ }
27
+ }
28
+ });
29
+ }, 300), [
30
+ props.onChange,
31
+ editor
32
+ ]);
33
+ useEffect(()=>{
34
+ if (!value || !editor || value === lastEmittedRef.current) return;
35
+ const now = Date.now();
36
+ if (now - lastOnChangeTimestampRef.current < 500) return;
37
+ const parsedState = parseLexicalState(editorInputValue);
38
+ let newState;
39
+ const currentSerialized = JSON.stringify(editor.getEditorState().toJSON());
40
+ if (currentSerialized === editorInputValue) return;
61
41
  try {
62
- editor.setEditorState(state);
63
- } catch (e) {
64
- console.error(e);
42
+ newState = editor.parseEditorState(parsedState || generateInitialLexicalValue());
43
+ } catch {}
44
+ if (newState) {
45
+ const state = newState;
46
+ queueMicrotask(()=>{
47
+ try {
48
+ editor.setEditorState(state);
49
+ } catch (e) {
50
+ console.error(e);
51
+ }
52
+ });
65
53
  }
66
- });
67
- }
68
- }, [value, editor, editorInputValue]);
69
- return /*#__PURE__*/React.createElement(BaseOnChangePlugin, {
70
- onChange: handleOnChange,
71
- ignoreSelectionChange: true
72
- });
54
+ }, [
55
+ value,
56
+ editor,
57
+ editorInputValue
58
+ ]);
59
+ return /*#__PURE__*/ react.createElement(OnChangePlugin, {
60
+ onChange: handleOnChange,
61
+ ignoreSelectionChange: true
62
+ });
73
63
  };
64
+ export { StateHandlingPlugin };
74
65
 
75
66
  //# sourceMappingURL=StateHandlingPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEffect","useRef","useMemo","debounce","OnChangePlugin","BaseOnChangePlugin","$isRootTextContentEmpty","generateInitialLexicalValue","prepareLexicalState","normalizeInputValue","useRichTextEditor","parseLexicalState","StateHandlingPlugin","props","editor","lastEmittedRef","lastOnChangeTimestampRef","value","editorInputValue","handleOnChange","editorState","read","onChange","getEditorState","isEditorEmpty","isComposing","newValue","JSON","stringify","toJSON","current","Date","now","parsedState","newState","currentSerialized","parseEditorState","state","queueMicrotask","setEditorState","e","console","error","createElement","ignoreSelectionChange"],"sources":["StateHandlingPlugin.tsx"],"sourcesContent":["import React, { useEffect, useRef, useMemo } from \"react\";\nimport debounce from \"lodash/debounce.js\";\nimport { OnChangePlugin as BaseOnChangePlugin } from \"@lexical/react/LexicalOnChangePlugin\";\nimport type { EditorState, LexicalEditor } from \"lexical\";\nimport { $isRootTextContentEmpty } from \"@lexical/text\";\nimport { generateInitialLexicalValue, prepareLexicalState } from \"@webiny/lexical-nodes\";\nimport { normalizeInputValue } from \"~/components/Editor/normalizeInputValue.js\";\nimport type { LexicalValue } from \"~/types.js\";\nimport { useRichTextEditor } from \"~/hooks/index.js\";\nimport { parseLexicalState } from \"~/utils/isValidLexicalData.js\";\n\ninterface OnChangeProps {\n value: string | null | undefined;\n onChange?: (value: LexicalValue) => void;\n}\n\nexport const StateHandlingPlugin = (props: OnChangeProps) => {\n const { editor } = useRichTextEditor();\n const lastEmittedRef = useRef(\"\");\n const lastOnChangeTimestampRef = useRef(0);\n\n const value = normalizeInputValue(props.value);\n const editorInputValue = prepareLexicalState(value);\n\n const handleOnChange = useMemo(() => {\n return debounce((editorState: EditorState, editor: LexicalEditor) => {\n editorState.read(() => {\n if (typeof props.onChange === \"function\") {\n const editorState = editor.getEditorState();\n const isEditorEmpty = $isRootTextContentEmpty(editor.isComposing(), true);\n\n if (!value && isEditorEmpty) {\n return;\n }\n\n const newValue = JSON.stringify(editorState.toJSON());\n\n if (newValue !== lastEmittedRef.current) {\n lastEmittedRef.current = newValue;\n lastOnChangeTimestampRef.current = Date.now();\n props.onChange(newValue);\n }\n }\n });\n }, 300);\n }, [props.onChange, editor]);\n\n useEffect(() => {\n if (!value || !editor || value === lastEmittedRef.current) {\n return;\n }\n\n const now = Date.now();\n if (now - lastOnChangeTimestampRef.current < 500) {\n return;\n }\n\n const parsedState = parseLexicalState(editorInputValue);\n\n let newState: EditorState | undefined;\n\n const currentSerialized = JSON.stringify(editor.getEditorState().toJSON());\n\n if (currentSerialized === editorInputValue) {\n return;\n }\n\n try {\n newState = editor.parseEditorState(parsedState || generateInitialLexicalValue());\n } catch {\n // Ignore errors\n }\n\n // We must set the state outside the `editor.update()` callback to prevent freezing.\n // https://lexical.dev/docs/api/classes/lexical.LexicalEditor#seteditorstate\n if (newState) {\n const state = newState;\n queueMicrotask(() => {\n try {\n editor.setEditorState(state);\n } catch (e) {\n console.error(e);\n }\n });\n }\n }, [value, editor, editorInputValue]);\n\n return <BaseOnChangePlugin onChange={handleOnChange} ignoreSelectionChange={true} />;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,MAAM,EAAEC,OAAO,QAAQ,OAAO;AACzD,OAAOC,QAAQ,MAAM,oBAAoB;AACzC,SAASC,cAAc,IAAIC,kBAAkB,QAAQ,sCAAsC;AAE3F,SAASC,uBAAuB,QAAQ,eAAe;AACvD,SAASC,2BAA2B,EAAEC,mBAAmB,QAAQ,uBAAuB;AACxF,SAASC,mBAAmB;AAE5B,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAO1B,OAAO,MAAMC,mBAAmB,GAAIC,KAAoB,IAAK;EACzD,MAAM;IAAEC;EAAO,CAAC,GAAGJ,iBAAiB,CAAC,CAAC;EACtC,MAAMK,cAAc,GAAGd,MAAM,CAAC,EAAE,CAAC;EACjC,MAAMe,wBAAwB,GAAGf,MAAM,CAAC,CAAC,CAAC;EAE1C,MAAMgB,KAAK,GAAGR,mBAAmB,CAACI,KAAK,CAACI,KAAK,CAAC;EAC9C,MAAMC,gBAAgB,GAAGV,mBAAmB,CAACS,KAAK,CAAC;EAEnD,MAAME,cAAc,GAAGjB,OAAO,CAAC,MAAM;IACjC,OAAOC,QAAQ,CAAC,CAACiB,WAAwB,EAAEN,MAAqB,KAAK;MACjEM,WAAW,CAACC,IAAI,CAAC,MAAM;QACnB,IAAI,OAAOR,KAAK,CAACS,QAAQ,KAAK,UAAU,EAAE;UACtC,MAAMF,WAAW,GAAGN,MAAM,CAACS,cAAc,CAAC,CAAC;UAC3C,MAAMC,aAAa,GAAGlB,uBAAuB,CAACQ,MAAM,CAACW,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC;UAEzE,IAAI,CAACR,KAAK,IAAIO,aAAa,EAAE;YACzB;UACJ;UAEA,MAAME,QAAQ,GAAGC,IAAI,CAACC,SAAS,CAACR,WAAW,CAACS,MAAM,CAAC,CAAC,CAAC;UAErD,IAAIH,QAAQ,KAAKX,cAAc,CAACe,OAAO,EAAE;YACrCf,cAAc,CAACe,OAAO,GAAGJ,QAAQ;YACjCV,wBAAwB,CAACc,OAAO,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC;YAC7CnB,KAAK,CAACS,QAAQ,CAACI,QAAQ,CAAC;UAC5B;QACJ;MACJ,CAAC,CAAC;IACN,CAAC,EAAE,GAAG,CAAC;EACX,CAAC,EAAE,CAACb,KAAK,CAACS,QAAQ,EAAER,MAAM,CAAC,CAAC;EAE5Bd,SAAS,CAAC,MAAM;IACZ,IAAI,CAACiB,KAAK,IAAI,CAACH,MAAM,IAAIG,KAAK,KAAKF,cAAc,CAACe,OAAO,EAAE;MACvD;IACJ;IAEA,MAAME,GAAG,GAAGD,IAAI,CAACC,GAAG,CAAC,CAAC;IACtB,IAAIA,GAAG,GAAGhB,wBAAwB,CAACc,OAAO,GAAG,GAAG,EAAE;MAC9C;IACJ;IAEA,MAAMG,WAAW,GAAGtB,iBAAiB,CAACO,gBAAgB,CAAC;IAEvD,IAAIgB,QAAiC;IAErC,MAAMC,iBAAiB,GAAGR,IAAI,CAACC,SAAS,CAACd,MAAM,CAACS,cAAc,CAAC,CAAC,CAACM,MAAM,CAAC,CAAC,CAAC;IAE1E,IAAIM,iBAAiB,KAAKjB,gBAAgB,EAAE;MACxC;IACJ;IAEA,IAAI;MACAgB,QAAQ,GAAGpB,MAAM,CAACsB,gBAAgB,CAACH,WAAW,IAAI1B,2BAA2B,CAAC,CAAC,CAAC;IACpF,CAAC,CAAC,MAAM;MACJ;IAAA;;IAGJ;IACA;IACA,IAAI2B,QAAQ,EAAE;MACV,MAAMG,KAAK,GAAGH,QAAQ;MACtBI,cAAc,CAAC,MAAM;QACjB,IAAI;UACAxB,MAAM,CAACyB,cAAc,CAACF,KAAK,CAAC;QAChC,CAAC,CAAC,OAAOG,CAAC,EAAE;UACRC,OAAO,CAACC,KAAK,CAACF,CAAC,CAAC;QACpB;MACJ,CAAC,CAAC;IACN;EACJ,CAAC,EAAE,CAACvB,KAAK,EAAEH,MAAM,EAAEI,gBAAgB,CAAC,CAAC;EAErC,oBAAOnB,KAAA,CAAA4C,aAAA,CAACtC,kBAAkB;IAACiB,QAAQ,EAAEH,cAAe;IAACyB,qBAAqB,EAAE;EAAK,CAAE,CAAC;AACxF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"plugins/StateHandlingPlugin.js","sources":["../../src/plugins/StateHandlingPlugin.tsx"],"sourcesContent":["import React, { useEffect, useRef, useMemo } from \"react\";\nimport debounce from \"lodash/debounce.js\";\nimport { OnChangePlugin as BaseOnChangePlugin } from \"@lexical/react/LexicalOnChangePlugin\";\nimport type { EditorState, LexicalEditor } from \"lexical\";\nimport { $isRootTextContentEmpty } from \"@lexical/text\";\nimport { generateInitialLexicalValue, prepareLexicalState } from \"@webiny/lexical-nodes\";\nimport { normalizeInputValue } from \"~/components/Editor/normalizeInputValue.js\";\nimport type { LexicalValue } from \"~/types.js\";\nimport { useRichTextEditor } from \"~/hooks/index.js\";\nimport { parseLexicalState } from \"~/utils/isValidLexicalData.js\";\n\ninterface OnChangeProps {\n value: string | null | undefined;\n onChange?: (value: LexicalValue) => void;\n}\n\nexport const StateHandlingPlugin = (props: OnChangeProps) => {\n const { editor } = useRichTextEditor();\n const lastEmittedRef = useRef(\"\");\n const lastOnChangeTimestampRef = useRef(0);\n\n const value = normalizeInputValue(props.value);\n const editorInputValue = prepareLexicalState(value);\n\n const handleOnChange = useMemo(() => {\n return debounce((editorState: EditorState, editor: LexicalEditor) => {\n editorState.read(() => {\n if (typeof props.onChange === \"function\") {\n const editorState = editor.getEditorState();\n const isEditorEmpty = $isRootTextContentEmpty(editor.isComposing(), true);\n\n if (!value && isEditorEmpty) {\n return;\n }\n\n const newValue = JSON.stringify(editorState.toJSON());\n\n if (newValue !== lastEmittedRef.current) {\n lastEmittedRef.current = newValue;\n lastOnChangeTimestampRef.current = Date.now();\n props.onChange(newValue);\n }\n }\n });\n }, 300);\n }, [props.onChange, editor]);\n\n useEffect(() => {\n if (!value || !editor || value === lastEmittedRef.current) {\n return;\n }\n\n const now = Date.now();\n if (now - lastOnChangeTimestampRef.current < 500) {\n return;\n }\n\n const parsedState = parseLexicalState(editorInputValue);\n\n let newState: EditorState | undefined;\n\n const currentSerialized = JSON.stringify(editor.getEditorState().toJSON());\n\n if (currentSerialized === editorInputValue) {\n return;\n }\n\n try {\n newState = editor.parseEditorState(parsedState || generateInitialLexicalValue());\n } catch {\n // Ignore errors\n }\n\n // We must set the state outside the `editor.update()` callback to prevent freezing.\n // https://lexical.dev/docs/api/classes/lexical.LexicalEditor#seteditorstate\n if (newState) {\n const state = newState;\n queueMicrotask(() => {\n try {\n editor.setEditorState(state);\n } catch (e) {\n console.error(e);\n }\n });\n }\n }, [value, editor, editorInputValue]);\n\n return <BaseOnChangePlugin onChange={handleOnChange} ignoreSelectionChange={true} />;\n};\n"],"names":["StateHandlingPlugin","props","editor","useRichTextEditor","lastEmittedRef","useRef","lastOnChangeTimestampRef","value","normalizeInputValue","editorInputValue","prepareLexicalState","handleOnChange","useMemo","debounce","editorState","isEditorEmpty","$isRootTextContentEmpty","newValue","JSON","Date","useEffect","now","parsedState","parseLexicalState","newState","currentSerialized","generateInitialLexicalValue","state","queueMicrotask","e","console","BaseOnChangePlugin"],"mappings":";;;;;;;;AAgBO,MAAMA,sBAAsB,CAACC;IAChC,MAAM,EAAEC,MAAM,EAAE,GAAGC;IACnB,MAAMC,iBAAiBC,OAAO;IAC9B,MAAMC,2BAA2BD,OAAO;IAExC,MAAME,QAAQC,oBAAoBP,MAAM,KAAK;IAC7C,MAAMQ,mBAAmBC,oBAAoBH;IAE7C,MAAMI,iBAAiBC,QAAQ,IACpBC,SAAS,CAACC,aAA0BZ;YACvCY,YAAY,IAAI,CAAC;gBACb,IAAI,AAA0B,cAA1B,OAAOb,MAAM,QAAQ,EAAiB;oBACtC,MAAMa,cAAcZ,OAAO,cAAc;oBACzC,MAAMa,gBAAgBC,wBAAwBd,OAAO,WAAW,IAAI;oBAEpE,IAAI,CAACK,SAASQ,eACV;oBAGJ,MAAME,WAAWC,KAAK,SAAS,CAACJ,YAAY,MAAM;oBAElD,IAAIG,aAAab,eAAe,OAAO,EAAE;wBACrCA,eAAe,OAAO,GAAGa;wBACzBX,yBAAyB,OAAO,GAAGa,KAAK,GAAG;wBAC3ClB,MAAM,QAAQ,CAACgB;oBACnB;gBACJ;YACJ;QACJ,GAAG,MACJ;QAAChB,MAAM,QAAQ;QAAEC;KAAO;IAE3BkB,UAAU;QACN,IAAI,CAACb,SAAS,CAACL,UAAUK,UAAUH,eAAe,OAAO,EACrD;QAGJ,MAAMiB,MAAMF,KAAK,GAAG;QACpB,IAAIE,MAAMf,yBAAyB,OAAO,GAAG,KACzC;QAGJ,MAAMgB,cAAcC,kBAAkBd;QAEtC,IAAIe;QAEJ,MAAMC,oBAAoBP,KAAK,SAAS,CAAChB,OAAO,cAAc,GAAG,MAAM;QAEvE,IAAIuB,sBAAsBhB,kBACtB;QAGJ,IAAI;YACAe,WAAWtB,OAAO,gBAAgB,CAACoB,eAAeI;QACtD,EAAE,OAAM,CAER;QAIA,IAAIF,UAAU;YACV,MAAMG,QAAQH;YACdI,eAAe;gBACX,IAAI;oBACA1B,OAAO,cAAc,CAACyB;gBAC1B,EAAE,OAAOE,GAAG;oBACRC,QAAQ,KAAK,CAACD;gBAClB;YACJ;QACJ;IACJ,GAAG;QAACtB;QAAOL;QAAQO;KAAiB;IAEpC,OAAO,WAAP,GAAO,oBAACsB,gBAAkBA;QAAC,UAAUpB;QAAgB,uBAAuB;;AAChF"}
@@ -1,27 +1,20 @@
1
1
  import { useEffect } from "react";
2
2
  import { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR } from "lexical";
3
- import { formatToParagraph, formatToHeading } from "@webiny/lexical-nodes";
3
+ import { formatToHeading, formatToParagraph } from "@webiny/lexical-nodes";
4
4
  import { useRichTextEditor } from "../../hooks/index.js";
5
5
  import { ADD_TYPOGRAPHY_COMMAND } from "../../commands/index.js";
6
- export const TypographyPlugin = () => {
7
- const {
8
- editor
9
- } = useRichTextEditor();
10
- useEffect(() => {
11
- return editor.registerCommand(ADD_TYPOGRAPHY_COMMAND, payload => {
12
- const selection = $getSelection();
13
- // paragraph
14
- if ($isRangeSelection(selection) && payload.value.id && payload.value.tag === "p") {
15
- formatToParagraph(editor, payload.value.id);
16
- }
17
- // heading
18
- if ($isRangeSelection(selection) && payload.value.id && payload.value.tag.includes("h")) {
19
- formatToHeading(editor, payload.value.tag, payload.value.id);
20
- }
21
- return true;
22
- }, COMMAND_PRIORITY_EDITOR);
23
- }, [editor]);
24
- return null;
6
+ const TypographyPlugin = ()=>{
7
+ const { editor } = useRichTextEditor();
8
+ useEffect(()=>editor.registerCommand(ADD_TYPOGRAPHY_COMMAND, (payload)=>{
9
+ const selection = $getSelection();
10
+ if ($isRangeSelection(selection) && payload.value.id && "p" === payload.value.tag) formatToParagraph(editor, payload.value.id);
11
+ if ($isRangeSelection(selection) && payload.value.id && payload.value.tag.includes("h")) formatToHeading(editor, payload.value.tag, payload.value.id);
12
+ return true;
13
+ }, COMMAND_PRIORITY_EDITOR), [
14
+ editor
15
+ ]);
16
+ return null;
25
17
  };
18
+ export { TypographyPlugin };
26
19
 
27
20
  //# sourceMappingURL=TypographyPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","$getSelection","$isRangeSelection","COMMAND_PRIORITY_EDITOR","formatToParagraph","formatToHeading","useRichTextEditor","ADD_TYPOGRAPHY_COMMAND","TypographyPlugin","editor","registerCommand","payload","selection","value","id","tag","includes"],"sources":["TypographyPlugin.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR } from \"lexical\";\nimport { formatToParagraph, formatToHeading } from \"@webiny/lexical-nodes\";\nimport type { HeadingTagType } from \"@lexical/rich-text\";\nimport { useRichTextEditor } from \"~/hooks/index.js\";\nimport type { TypographyPayload } from \"~/commands/index.js\";\nimport { ADD_TYPOGRAPHY_COMMAND } from \"~/commands/index.js\";\n\nexport const TypographyPlugin = () => {\n const { editor } = useRichTextEditor();\n\n useEffect(() => {\n return editor.registerCommand<TypographyPayload>(\n ADD_TYPOGRAPHY_COMMAND,\n payload => {\n const selection = $getSelection();\n // paragraph\n if ($isRangeSelection(selection) && payload.value.id && payload.value.tag === \"p\") {\n formatToParagraph(editor, payload.value.id);\n }\n // heading\n if (\n $isRangeSelection(selection) &&\n payload.value.id &&\n payload.value.tag.includes(\"h\")\n ) {\n formatToHeading(editor, payload.value.tag as HeadingTagType, payload.value.id);\n }\n return true;\n },\n COMMAND_PRIORITY_EDITOR\n );\n }, [editor]);\n\n return null;\n};\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AACjC,SAASC,aAAa,EAAEC,iBAAiB,EAAEC,uBAAuB,QAAQ,SAAS;AACnF,SAASC,iBAAiB,EAAEC,eAAe,QAAQ,uBAAuB;AAE1E,SAASC,iBAAiB;AAE1B,SAASC,sBAAsB;AAE/B,OAAO,MAAMC,gBAAgB,GAAGA,CAAA,KAAM;EAClC,MAAM;IAAEC;EAAO,CAAC,GAAGH,iBAAiB,CAAC,CAAC;EAEtCN,SAAS,CAAC,MAAM;IACZ,OAAOS,MAAM,CAACC,eAAe,CACzBH,sBAAsB,EACtBI,OAAO,IAAI;MACP,MAAMC,SAAS,GAAGX,aAAa,CAAC,CAAC;MACjC;MACA,IAAIC,iBAAiB,CAACU,SAAS,CAAC,IAAID,OAAO,CAACE,KAAK,CAACC,EAAE,IAAIH,OAAO,CAACE,KAAK,CAACE,GAAG,KAAK,GAAG,EAAE;QAC/EX,iBAAiB,CAACK,MAAM,EAAEE,OAAO,CAACE,KAAK,CAACC,EAAE,CAAC;MAC/C;MACA;MACA,IACIZ,iBAAiB,CAACU,SAAS,CAAC,IAC5BD,OAAO,CAACE,KAAK,CAACC,EAAE,IAChBH,OAAO,CAACE,KAAK,CAACE,GAAG,CAACC,QAAQ,CAAC,GAAG,CAAC,EACjC;QACEX,eAAe,CAACI,MAAM,EAAEE,OAAO,CAACE,KAAK,CAACE,GAAG,EAAoBJ,OAAO,CAACE,KAAK,CAACC,EAAE,CAAC;MAClF;MACA,OAAO,IAAI;IACf,CAAC,EACDX,uBACJ,CAAC;EACL,CAAC,EAAE,CAACM,MAAM,CAAC,CAAC;EAEZ,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"plugins/TypographyPlugin/TypographyPlugin.js","sources":["../../../src/plugins/TypographyPlugin/TypographyPlugin.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR } from \"lexical\";\nimport { formatToParagraph, formatToHeading } from \"@webiny/lexical-nodes\";\nimport type { HeadingTagType } from \"@lexical/rich-text\";\nimport { useRichTextEditor } from \"~/hooks/index.js\";\nimport type { TypographyPayload } from \"~/commands/index.js\";\nimport { ADD_TYPOGRAPHY_COMMAND } from \"~/commands/index.js\";\n\nexport const TypographyPlugin = () => {\n const { editor } = useRichTextEditor();\n\n useEffect(() => {\n return editor.registerCommand<TypographyPayload>(\n ADD_TYPOGRAPHY_COMMAND,\n payload => {\n const selection = $getSelection();\n // paragraph\n if ($isRangeSelection(selection) && payload.value.id && payload.value.tag === \"p\") {\n formatToParagraph(editor, payload.value.id);\n }\n // heading\n if (\n $isRangeSelection(selection) &&\n payload.value.id &&\n payload.value.tag.includes(\"h\")\n ) {\n formatToHeading(editor, payload.value.tag as HeadingTagType, payload.value.id);\n }\n return true;\n },\n COMMAND_PRIORITY_EDITOR\n );\n }, [editor]);\n\n return null;\n};\n"],"names":["TypographyPlugin","editor","useRichTextEditor","useEffect","ADD_TYPOGRAPHY_COMMAND","payload","selection","$getSelection","$isRangeSelection","formatToParagraph","formatToHeading","COMMAND_PRIORITY_EDITOR"],"mappings":";;;;;AAQO,MAAMA,mBAAmB;IAC5B,MAAM,EAAEC,MAAM,EAAE,GAAGC;IAEnBC,UAAU,IACCF,OAAO,eAAe,CACzBG,wBACAC,CAAAA;YACI,MAAMC,YAAYC;YAElB,IAAIC,kBAAkBF,cAAcD,QAAQ,KAAK,CAAC,EAAE,IAAIA,AAAsB,QAAtBA,QAAQ,KAAK,CAAC,GAAG,EACrEI,kBAAkBR,QAAQI,QAAQ,KAAK,CAAC,EAAE;YAG9C,IACIG,kBAAkBF,cAClBD,QAAQ,KAAK,CAAC,EAAE,IAChBA,QAAQ,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,MAE3BK,gBAAgBT,QAAQI,QAAQ,KAAK,CAAC,GAAG,EAAoBA,QAAQ,KAAK,CAAC,EAAE;YAEjF,OAAO;QACX,GACAM,0BAEL;QAACV;KAAO;IAEX,OAAO;AACX"}
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chat-square-quote"><path d="M14 1a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1h-2.5a2 2 0 0 0-1.6.8L8 14.333 6.1 11.8a2 2 0 0 0-1.6-.8H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1h12zM2 0a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2.5a1 1 0 0 1 .8.4l1.9 2.533a1 1 0 0 0 1.6 0l1.9-2.533a1 1 0 0 1 .8-.4H14a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2z"/><path d="M7.066 4.76A1.665 1.665 0 0 0 4 5.668a1.667 1.667 0 0 0 2.561 1.406c-.131.389-.375.804-.777 1.22a.417.417 0 1 0 .6.58c1.486-1.54 1.293-3.214.682-4.112zm4 0A1.665 1.665 0 0 0 8 5.668a1.667 1.667 0 0 0 2.561 1.406c-.131.389-.375.804-.777 1.22a.417.417 0 1 0 .6.58c1.486-1.54 1.293-3.214.682-4.112z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chevron-down"><path fill-rule="evenodd" d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-code"><path d="M5.854 4.854a.5.5 0 1 0-.708-.708l-3.5 3.5a.5.5 0 0 0 0 .708l3.5 3.5a.5.5 0 0 0 .708-.708L2.707 8l3.147-3.146zm4.292 0a.5.5 0 0 1 .708-.708l3.5 3.5a.5.5 0 0 1 0 .708l-3.5 3.5a.5.5 0 0 1-.708-.708L13.293 8l-3.147-3.146z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 512 512"><path fill="#777" d="M221.631 109 109.92 392h58.055l24.079-61h127.892l24.079 61h58.055L290.369 109Zm-8.261 168L256 169l42.63 108Z"/></svg>
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-text-indent-left" viewBox="0 0 16 16">
2
+ <path d="M2 3.5a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5zm.646 2.146a.5.5 0 0 1 .708 0l2 2a.5.5 0 0 1 0 .708l-2 2a.5.5 0 0 1-.708-.708L4.293 8 2.646 6.354a.5.5 0 0 1 0-.708zM7 6.5a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 3a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5zm-5 3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/>
3
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-image" viewBox="0 0 16 16">
2
+ <path d="M6.002 5.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0z"/>
3
+ <path d="M2.002 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V3a2 2 0 0 0-2-2h-12zm12 1a1 1 0 0 1 1 1v6.5l-3.777-1.947a.5.5 0 0 0-.577.093l-3.71 3.71-2.66-1.772a.5.5 0 0 0-.63.062L1.002 12V3a1 1 0 0 1 1-1h12z"/>
4
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-justify" viewBox="0 0 16 16">
2
+ <path fill-rule="evenodd" d="M2 12.5a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5zm0-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5zm0-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5zm0-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/>
3
+ </svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-link"><path d="M6.354 5.5H4a3 3 0 0 0 0 6h3a3 3 0 0 0 2.83-4H9c-.086 0-.17.01-.25.031A2 2 0 0 1 7 10.5H4a2 2 0 1 1 0-4h1.535c.218-.376.495-.714.82-1z"/><path d="M9 5.5a3 3 0 0 0-2.83 4h1.098A2 2 0 0 1 9 6.5h3a2 2 0 1 1 0 4h-1.535a4.02 4.02 0 0 1-.82 1H12a3 3 0 1 0 0-6H9z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-list-ol"><path fill-rule="evenodd" d="M5 11.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5z"/><path d="M1.713 11.865v-.474H2c.217 0 .363-.137.363-.317 0-.185-.158-.31-.361-.31-.223 0-.367.152-.373.31h-.59c.016-.467.373-.787.986-.787.588-.002.954.291.957.703a.595.595 0 0 1-.492.594v.033a.615.615 0 0 1 .569.631c.003.533-.502.8-1.051.8-.656 0-1-.37-1.008-.794h.582c.008.178.186.306.422.309.254 0 .424-.145.422-.35-.002-.195-.155-.348-.414-.348h-.3zm-.004-4.699h-.604v-.035c0-.408.295-.844.958-.844.583 0 .96.326.96.756 0 .389-.257.617-.476.848l-.537.572v.03h1.054V9H1.143v-.395l.957-.99c.138-.142.293-.304.293-.508 0-.18-.147-.32-.342-.32a.33.33 0 0 0-.342.338v.041zM2.564 5h-.635V2.924h-.031l-.598.42v-.567l.629-.443h.635V5z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-list-ul"><path fill-rule="evenodd" d="M5 11.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zm-3 1a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm0 4a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm0 4a1 1 0 1 0 0-2 1 1 0 0 0 0 2z"/></svg>
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-text-indent-right" viewBox="0 0 16 16">
2
+ <path d="M2 3.5a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5zm10.646 2.146a.5.5 0 0 1 .708.708L11.707 8l1.647 1.646a.5.5 0 0 1-.708.708l-2-2a.5.5 0 0 1 0-.708l2-2zM2 6.5a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 3a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/>
3
+ </svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil-fill"><path d="M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793 14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708l-3-3zm.646 6.061L9.793 2.5 3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207l6.5-6.5zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.499.499 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11l.178-.178z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-text-center"><path fill-rule="evenodd" d="M4 12.5a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5zm2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-text-left"><path fill-rule="evenodd" d="M2 12.5a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm0-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5zm0-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm0-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-text-paragraph"><path fill-rule="evenodd" d="M2 12.5a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm0-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5zm0-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5zm4-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-text-right"><path fill-rule="evenodd" d="M6 12.5a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-4-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5zm4-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-4-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-type-bold"><path d="M8.21 13c2.106 0 3.412-1.087 3.412-2.823 0-1.306-.984-2.283-2.324-2.386v-.055a2.176 2.176 0 0 0 1.852-2.14c0-1.51-1.162-2.46-3.014-2.46H3.843V13H8.21zM5.908 4.674h1.696c.963 0 1.517.451 1.517 1.244 0 .834-.629 1.32-1.73 1.32H5.908V4.673zm0 6.788V8.598h1.73c1.217 0 1.88.492 1.88 1.415 0 .943-.643 1.449-1.832 1.449H5.907z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-type-h1"><path d="M8.637 13V3.669H7.379V7.62H2.758V3.67H1.5V13h1.258V8.728h4.62V13h1.259zm5.329 0V3.669h-1.244L10.5 5.316v1.265l2.16-1.565h.062V13h1.244z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-type-h2"><path d="M7.638 13V3.669H6.38V7.62H1.759V3.67H.5V13h1.258V8.728h4.62V13h1.259zm3.022-6.733v-.048c0-.889.63-1.668 1.716-1.668.957 0 1.675.608 1.675 1.572 0 .855-.554 1.504-1.067 2.085l-3.513 3.999V13H15.5v-1.094h-4.245v-.075l2.481-2.844c.875-.998 1.586-1.784 1.586-2.953 0-1.463-1.155-2.556-2.919-2.556-1.941 0-2.966 1.326-2.966 2.74v.049h1.223z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-type-h3"><path d="M7.637 13V3.669H6.379V7.62H1.758V3.67H.5V13h1.258V8.728h4.62V13h1.259zm3.625-4.272h1.018c1.142 0 1.935.67 1.949 1.674.013 1.005-.78 1.737-2.01 1.73-1.08-.007-1.853-.588-1.935-1.32H9.108c.069 1.327 1.224 2.386 3.083 2.386 1.935 0 3.343-1.155 3.309-2.789-.027-1.51-1.251-2.16-2.037-2.249v-.068c.704-.123 1.764-.91 1.723-2.229-.035-1.353-1.176-2.4-2.954-2.385-1.873.006-2.857 1.162-2.898 2.358h1.196c.062-.69.711-1.299 1.696-1.299.998 0 1.695.622 1.695 1.525.007.922-.718 1.592-1.695 1.592h-.964v1.074z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-type-h1"><path d="M7.637 13V3.669H6.379V7.62H1.758V3.67H.5V13h1.258V8.728h4.62V13Zm5.337.2v-2.328H9.108V9.828l3.441-6.35h1.632v6.141H15.5v1.253h-1.319V13.2Zm-2.615-3.581h2.615V6.7L13 4.689l-.872 1.7z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-type-h1"><path d="M7.637 13V3.669H6.379V7.62H1.758V3.67H.5V13h1.258V8.728h4.62V13Zm2.755-5.791a3.763 3.763 0 0 1 2.113-.517 2.973 2.973 0 0 1 2.995 3.1 3.45 3.45 0 0 1-.9 2.442 3.111 3.111 0 0 1-2.393.968 3.327 3.327 0 0 1-2.094-.671 2.758 2.758 0 0 1-1.007-2h1.284a1.387 1.387 0 0 0 .511 1.1 2.384 2.384 0 0 0 1.4.421 1.819 1.819 0 0 0 1.479-.638 2.042 2.042 0 0 0 .437-1.514 2.17 2.17 0 0 0-.567-1.584 1.958 1.958 0 0 0-1.468-.58 2.358 2.358 0 0 0-1.79.789H9.108V3.478h5.931v1.134h-4.647Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-type-h1"><path d="M7.637 13V3.669H6.379V7.62H1.758V3.67H.5V13h1.258V8.728h4.62V13Zm5.039-6.13a2.823 2.823 0 0 1 1.419.364 2.69 2.69 0 0 1 1.022 1.05 3.327 3.327 0 0 1 .383 1.642 3.594 3.594 0 0 1-.39 1.7 2.878 2.878 0 0 1-1.1 1.158 3.165 3.165 0 0 1-1.635.416 2.812 2.812 0 0 1-1.734-.545A3.49 3.49 0 0 1 9.51 11.1a6.515 6.515 0 0 1-.4-2.411A7.726 7.726 0 0 1 9.542 6a4.289 4.289 0 0 1 1.233-1.851 2.831 2.831 0 0 1 1.889-.673A2.7 2.7 0 0 1 13.8 3.7a2.463 2.463 0 0 1 .812.586 2.886 2.886 0 0 1 .514.8 2.768 2.768 0 0 1 .223.861H14a1.488 1.488 0 0 0-.453-.923 1.346 1.346 0 0 0-.935-.329 1.509 1.509 0 0 0-1.072.425 2.839 2.839 0 0 0-.71 1.18 6.808 6.808 0 0 0-.323 1.771 2.639 2.639 0 0 1 .918-.889 2.48 2.48 0 0 1 1.251-.312Zm-.285 5.117a1.617 1.617 0 0 0 .91-.256 1.752 1.752 0 0 0 .614-.713 2.336 2.336 0 0 0 .223-1.037 2.211 2.211 0 0 0-.217-1.01 1.6 1.6 0 0 0-.6-.666 1.671 1.671 0 0 0-.892-.236 1.833 1.833 0 0 0-1.164.377 2.4 2.4 0 0 0-.743 1.009 3.749 3.749 0 0 0 .6 1.845 1.5 1.5 0 0 0 1.269.687Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-type-italic"><path d="M7.991 11.674 9.53 4.455c.123-.595.246-.71 1.347-.807l.11-.52H7.211l-.11.52c1.06.096 1.128.212 1.005.807L6.57 11.674c-.123.595-.246.71-1.346.806l-.11.52h3.774l.11-.52c-1.06-.095-1.129-.211-1.006-.806z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-type-strikethrough"><path d="M6.333 5.686c0 .31.083.581.27.814H5.166a2.776 2.776 0 0 1-.099-.76c0-1.627 1.436-2.768 3.48-2.768 1.969 0 3.39 1.175 3.445 2.85h-1.23c-.11-1.08-.964-1.743-2.25-1.743-1.23 0-2.18.602-2.18 1.607zm2.194 7.478c-2.153 0-3.589-1.107-3.705-2.81h1.23c.144 1.06 1.129 1.703 2.544 1.703 1.34 0 2.31-.705 2.31-1.675 0-.827-.547-1.374-1.914-1.675L8.046 8.5H1v-1h14v1h-3.504c.468.437.675.994.675 1.697 0 1.826-1.436 2.967-3.644 2.967z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-type-underline"><path d="M5.313 3.136h-1.23V9.54c0 2.105 1.47 3.623 3.917 3.623s3.917-1.518 3.917-3.623V3.136h-1.23v6.323c0 1.49-.978 2.57-2.687 2.57-1.709 0-2.687-1.08-2.687-2.57V3.136zM12.5 15h-9v-1h9v1z"/></svg>
@@ -0,0 +1 @@
1
+ <?xml version="1.0" ?><svg class="icon icon-tabler icon-tabler-unlink" fill="none" height="24" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h24v24H0z" fill="none" stroke="none"/><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"/><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"/><line x1="16" x2="16" y1="21" y2="19"/><line x1="19" x2="21" y1="16" y2="16"/><line x1="3" x2="5" y1="8" y2="8"/><line x1="8" x2="8" y1="3" y2="5"/></svg>
package/types.js CHANGED
@@ -1,9 +1 @@
1
1
  export { FontColorPicker } from "./components/ToolbarActions/FontColorAction.js";
2
-
3
- /* Commands payload types */
4
-
5
- /* Lexical editor interfaces */
6
-
7
- // lexical types
8
-
9
- //# sourceMappingURL=types.js.map
@@ -1,19 +1,11 @@
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
1
  import "./ContentEditable.css";
9
2
  import { ContentEditable } from "@lexical/react/LexicalContentEditable";
10
- import * as React from "react";
11
- export function LexicalContentEditable({
12
- className
13
- }) {
14
- return /*#__PURE__*/React.createElement(ContentEditable, {
15
- className: className || "ContentEditable__root"
16
- });
3
+ import * as __rspack_external_react from "react";
4
+ function LexicalContentEditable({ className }) {
5
+ return /*#__PURE__*/ __rspack_external_react.createElement(ContentEditable, {
6
+ className: className || "ContentEditable__root"
7
+ });
17
8
  }
9
+ export { LexicalContentEditable };
18
10
 
19
11
  //# sourceMappingURL=ContentEditable.js.map