@react-fabric/lexical 1.0.0-beta.6 → 1.0.0-beta.61

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 (134) hide show
  1. package/{src/editor/Lexical.module.css → css/_lexical.css} +8 -4
  2. package/css/styles.css +24 -0
  3. package/dist/cjs/{packages/lexical/src/components → components}/StickyComponent.js +3 -4
  4. package/dist/cjs/{packages/lexical/src/editor → editor}/LexicalEditor.js +35 -10
  5. package/dist/cjs/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +154 -145
  6. package/dist/cjs/i18n/ar.json.js +24 -0
  7. package/dist/cjs/i18n/en.json.js +24 -0
  8. package/dist/cjs/i18n/index.js +33 -0
  9. package/dist/cjs/{packages/lexical/src/index.js → index.js} +1 -0
  10. package/dist/cjs/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +5 -5
  11. package/dist/cjs/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +55 -34
  12. package/dist/esm/{packages/lexical/src/components → components}/StickyComponent.js +3 -4
  13. package/dist/esm/{packages/lexical/src/editor → editor}/LexicalEditor.js +34 -9
  14. package/dist/esm/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +102 -93
  15. package/dist/esm/i18n/ar.json.js +21 -0
  16. package/dist/esm/i18n/en.json.js +21 -0
  17. package/dist/esm/i18n/index.js +33 -0
  18. package/dist/esm/{packages/lexical/src/index.js → index.js} +1 -0
  19. package/dist/esm/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +2 -2
  20. package/dist/esm/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +56 -35
  21. package/dist/types/editor/LexicalEditor.d.ts +25 -0
  22. package/dist/types/hooks/useFormatWatcher.d.ts +3 -2
  23. package/dist/types/i18n/index.d.ts +1 -0
  24. package/dist/types/index.d.ts +1 -0
  25. package/dist/types/nodes/StickyNode.d.ts +0 -1
  26. package/package.json +14 -13
  27. package/src/components/StickyComponent.tsx +4 -5
  28. package/src/editor/LexicalEditor.tsx +57 -26
  29. package/src/hooks/useFormatWatcher.ts +38 -31
  30. package/src/i18n/ar.json +16 -0
  31. package/src/i18n/en.json +16 -0
  32. package/src/i18n/index.ts +28 -0
  33. package/src/index.ts +2 -0
  34. package/src/plugins/ToolbarPlugin.tsx +56 -35
  35. package/dist/cjs/_virtual/prism.js +0 -5
  36. package/dist/cjs/editor/Lexical.module.css +0 -1
  37. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -432
  38. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -21
  39. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -27
  40. package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +0 -1139
  41. package/dist/cjs/node_modules/@lexical/code/LexicalCode.js +0 -25
  42. package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +0 -50
  43. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +0 -245
  44. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.js +0 -19
  45. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +0 -18
  46. package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +0 -471
  47. package/dist/cjs/node_modules/@lexical/link/LexicalLink.js +0 -17
  48. package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +0 -24
  49. package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +0 -1275
  50. package/dist/cjs/node_modules/@lexical/list/LexicalList.js +0 -29
  51. package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +0 -29
  52. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -789
  53. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.js +0 -29
  54. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -26
  55. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -976
  56. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +0 -35
  57. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -35
  58. package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +0 -2792
  59. package/dist/cjs/node_modules/@lexical/table/LexicalTable.js +0 -23
  60. package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +0 -55
  61. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -888
  62. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +0 -35
  63. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -66
  64. package/dist/cjs/node_modules/@mdi/js/mdi.js +0 -8
  65. package/dist/cjs/node_modules/prismjs/components/prism-c.js +0 -82
  66. package/dist/cjs/node_modules/prismjs/components/prism-clike.js +0 -33
  67. package/dist/cjs/node_modules/prismjs/components/prism-cpp.js +0 -101
  68. package/dist/cjs/node_modules/prismjs/components/prism-css.js +0 -66
  69. package/dist/cjs/node_modules/prismjs/components/prism-java.js +0 -126
  70. package/dist/cjs/node_modules/prismjs/components/prism-javascript.js +0 -174
  71. package/dist/cjs/node_modules/prismjs/components/prism-markdown.js +0 -417
  72. package/dist/cjs/node_modules/prismjs/components/prism-markup.js +0 -188
  73. package/dist/cjs/node_modules/prismjs/components/prism-objectivec.js +0 -14
  74. package/dist/cjs/node_modules/prismjs/components/prism-powershell.js +0 -60
  75. package/dist/cjs/node_modules/prismjs/components/prism-python.js +0 -67
  76. package/dist/cjs/node_modules/prismjs/components/prism-rust.js +0 -130
  77. package/dist/cjs/node_modules/prismjs/components/prism-sql.js +0 -34
  78. package/dist/cjs/node_modules/prismjs/components/prism-swift.js +0 -150
  79. package/dist/cjs/node_modules/prismjs/components/prism-typescript.js +0 -62
  80. package/dist/cjs/node_modules/prismjs/prism.js +0 -1951
  81. package/dist/esm/_virtual/prism.js +0 -5
  82. package/dist/esm/editor/Lexical.module.css +0 -1
  83. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -423
  84. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -19
  85. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -18
  86. package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +0 -1121
  87. package/dist/esm/node_modules/@lexical/code/LexicalCode.js +0 -21
  88. package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +0 -32
  89. package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +0 -244
  90. package/dist/esm/node_modules/@lexical/html/LexicalHtml.js +0 -18
  91. package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +0 -17
  92. package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +0 -463
  93. package/dist/esm/node_modules/@lexical/link/LexicalLink.js +0 -17
  94. package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +0 -16
  95. package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +0 -1262
  96. package/dist/esm/node_modules/@lexical/list/LexicalList.js +0 -23
  97. package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +0 -16
  98. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -781
  99. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.js +0 -23
  100. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -18
  101. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -957
  102. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +0 -26
  103. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -16
  104. package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +0 -2754
  105. package/dist/esm/node_modules/@lexical/table/LexicalTable.js +0 -20
  106. package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +0 -17
  107. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -839
  108. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +0 -26
  109. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -17
  110. package/dist/esm/node_modules/@mdi/js/mdi.js +0 -7
  111. package/dist/esm/node_modules/prismjs/components/prism-c.js +0 -82
  112. package/dist/esm/node_modules/prismjs/components/prism-clike.js +0 -33
  113. package/dist/esm/node_modules/prismjs/components/prism-cpp.js +0 -101
  114. package/dist/esm/node_modules/prismjs/components/prism-css.js +0 -66
  115. package/dist/esm/node_modules/prismjs/components/prism-java.js +0 -126
  116. package/dist/esm/node_modules/prismjs/components/prism-javascript.js +0 -174
  117. package/dist/esm/node_modules/prismjs/components/prism-markdown.js +0 -417
  118. package/dist/esm/node_modules/prismjs/components/prism-markup.js +0 -188
  119. package/dist/esm/node_modules/prismjs/components/prism-objectivec.js +0 -14
  120. package/dist/esm/node_modules/prismjs/components/prism-powershell.js +0 -60
  121. package/dist/esm/node_modules/prismjs/components/prism-python.js +0 -67
  122. package/dist/esm/node_modules/prismjs/components/prism-rust.js +0 -130
  123. package/dist/esm/node_modules/prismjs/components/prism-sql.js +0 -34
  124. package/dist/esm/node_modules/prismjs/components/prism-swift.js +0 -150
  125. package/dist/esm/node_modules/prismjs/components/prism-typescript.js +0 -62
  126. package/dist/esm/node_modules/prismjs/prism.js +0 -1951
  127. /package/dist/cjs/{packages/lexical/src/editor → editor}/theme.js +0 -0
  128. /package/dist/cjs/{packages/lexical/src/nodes → nodes}/StickyNode.js +0 -0
  129. /package/dist/cjs/{packages/lexical/src/plugins → plugins}/StickyPlugin.js +0 -0
  130. /package/dist/cjs/{packages/lexical/src/utils → utils}/index.js +0 -0
  131. /package/dist/esm/{packages/lexical/src/editor → editor}/theme.js +0 -0
  132. /package/dist/esm/{packages/lexical/src/nodes → nodes}/StickyNode.js +0 -0
  133. /package/dist/esm/{packages/lexical/src/plugins → plugins}/StickyPlugin.js +0 -0
  134. /package/dist/esm/{packages/lexical/src/utils → utils}/index.js +0 -0
@@ -25,14 +25,14 @@ var blockTypeToBlockName = {
25
25
  quote: "Quote"
26
26
  };
27
27
  var blockTypeToBlockIcon = {
28
- bullet: core.CoreIcons.formatListBullet,
29
- code: core.CoreIcons.formatCodeBlock,
28
+ bullet: "icon-[mdi--format-list-bulleted]",
29
+ code: "icon-[mdi--code-block-tags]",
30
30
  h1: " ",
31
31
  h2: " ",
32
32
  paragraph: "",
33
- h6: core.CoreIcons.formatCommentBlock,
34
- number: core.CoreIcons.formatListNumber,
35
- quote: core.CoreIcons.formatQuoteBlock
33
+ h6: "icon-[mdi--comment-text-outline]",
34
+ number: "icon-[mdi--format-list-numbered]",
35
+ quote: "icon-[mdi--format-quote-open]"
36
36
  };
37
37
  var SIZES = Object.freeze(["8", "9", "10", "11", "12", "13", "14", "16", "18", "20", "24", "28", "32", "36", "48", "64", "72"]);
38
38
  var ButtonWrapper = function ButtonWrapper(_ref) {
@@ -64,7 +64,7 @@ var ToolbarPlugin = function ToolbarPlugin() {
64
64
  children: [/*#__PURE__*/jsxRuntime.jsx(core.Button, {
65
65
  variant: "link",
66
66
  tabIndex: -1,
67
- altIcon: core.CoreIcons.caretDown,
67
+ altIcon: "icon-[mdi--menu-down]",
68
68
  icon: blockTypeToBlockIcon[watch.blockType],
69
69
  children: blockTypeToBlockName[watch.blockType]
70
70
  }), /*#__PURE__*/jsxRuntime.jsxs(core.Menu, {
@@ -114,7 +114,8 @@ var ToolbarPlugin = function ToolbarPlugin() {
114
114
  children: /*#__PURE__*/jsxRuntime.jsxs(core.Dropdown, {
115
115
  children: [/*#__PURE__*/jsxRuntime.jsx(core.Button, {
116
116
  variant: "link",
117
- altIcon: core.CoreIcons.caretDown,
117
+ altIcon: "icon-[mdi--menu-down]",
118
+ tabIndex: -1,
118
119
  children: utilities.getValue(watch.fontSize + "", "16")
119
120
  }), /*#__PURE__*/jsxRuntime.jsx(core.Menu, {
120
121
  className: "hide-icons",
@@ -135,48 +136,66 @@ var ToolbarPlugin = function ToolbarPlugin() {
135
136
  variant: "link",
136
137
  children: [/*#__PURE__*/jsxRuntime.jsx(ButtonWrapper, {
137
138
  value: "start",
138
- rtlFlip: true,
139
139
  label: t("tool.alignStart"),
140
- icon: core.CoreIcons.alignLeft,
140
+ variant: watch.align === "start" ? "soft" : "link",
141
+ color: watch.align === "start" ? "primary" : "default",
142
+ icon: {
143
+ icon: "icon-[mdi--format-align-left]",
144
+ rtlFlip: true
145
+ },
141
146
  onClick: function onClick() {
142
147
  return watch.activeEditor.dispatchCommand(lexical.FORMAT_ELEMENT_COMMAND, "start");
143
148
  }
144
149
  }), /*#__PURE__*/jsxRuntime.jsx(ButtonWrapper, {
145
150
  value: "center",
146
151
  label: t("tool.alignCenter"),
147
- icon: core.CoreIcons.alignCenter,
152
+ variant: watch.align === "center" ? "soft" : "link",
153
+ color: watch.align === "center" ? "primary" : "default",
154
+ icon: "icon-[mdi--format-align-center]",
148
155
  onClick: function onClick() {
149
156
  return watch.activeEditor.dispatchCommand(lexical.FORMAT_ELEMENT_COMMAND, "center");
150
157
  }
151
158
  }), /*#__PURE__*/jsxRuntime.jsx(ButtonWrapper, {
152
159
  value: "end",
153
- rtlFlip: true,
154
160
  label: t("tool.alignEnd"),
155
- icon: core.CoreIcons.alignRight,
161
+ variant: watch.align === "end" ? "soft" : "link",
162
+ color: watch.align === "end" ? "primary" : "default",
163
+ icon: {
164
+ icon: "icon-[mdi--format-align-right]",
165
+ rtlFlip: true
166
+ },
156
167
  onClick: function onClick() {
157
168
  return watch.activeEditor.dispatchCommand(lexical.FORMAT_ELEMENT_COMMAND, "end");
158
169
  }
159
170
  }), /*#__PURE__*/jsxRuntime.jsx(ButtonWrapper, {
160
171
  value: "justify",
161
- rtlFlip: true,
162
172
  label: t("tool.alignJustify"),
163
- icon: core.CoreIcons.alignJustify,
173
+ variant: watch.align === "justify" ? "soft" : "link",
174
+ color: watch.align === "justify" ? "primary" : "default",
175
+ icon: {
176
+ icon: "icon-[mdi--format-align-justify]",
177
+ rtlFlip: true
178
+ },
164
179
  onClick: function onClick() {
165
180
  return watch.activeEditor.dispatchCommand(lexical.FORMAT_ELEMENT_COMMAND, "justify");
166
181
  }
167
182
  }), /*#__PURE__*/jsxRuntime.jsx(ButtonWrapper, {
168
183
  value: "justify",
169
- rtlFlip: true,
170
184
  label: t("tool.indentOut"),
171
- icon: core.CoreIcons.formatIndentDecrease,
185
+ icon: {
186
+ icon: "icon-[mdi--format-indent-decrease]",
187
+ rtlFlip: true
188
+ },
172
189
  onClick: function onClick() {
173
190
  return watch.outdent();
174
191
  }
175
192
  }), /*#__PURE__*/jsxRuntime.jsx(ButtonWrapper, {
176
193
  value: "justify",
177
- rtlFlip: true,
178
- label: t("tool.identIn"),
179
- icon: core.CoreIcons.formatIndentIncrease,
194
+ label: t("tool.indentIn"),
195
+ icon: {
196
+ icon: "icon-[mdi--format-indent-increase]",
197
+ rtlFlip: true
198
+ },
180
199
  onClick: function onClick() {
181
200
  return watch.indent();
182
201
  }
@@ -189,28 +208,32 @@ var ToolbarPlugin = function ToolbarPlugin() {
189
208
  children: [/*#__PURE__*/jsxRuntime.jsx(ButtonWrapper, {
190
209
  value: "bold",
191
210
  label: t("tool.bold"),
192
- icon: core.CoreIcons.formatBold,
211
+ icon: "icon-[mdi--format-bold]",
212
+ color: textFormat.includes("bold") ? "primary" : "default",
193
213
  onClick: function onClick() {
194
214
  return watch.activeEditor.dispatchCommand(lexical.FORMAT_TEXT_COMMAND, "bold");
195
215
  }
196
216
  }), /*#__PURE__*/jsxRuntime.jsx(ButtonWrapper, {
197
217
  value: "italic",
198
218
  label: t("tool.italic"),
199
- icon: core.CoreIcons.formatItalic,
219
+ icon: "icon-[mdi--format-italic]",
220
+ color: textFormat.includes("italic") ? "primary" : "default",
200
221
  onClick: function onClick() {
201
222
  return watch.activeEditor.dispatchCommand(lexical.FORMAT_TEXT_COMMAND, "italic");
202
223
  }
203
224
  }), /*#__PURE__*/jsxRuntime.jsx(ButtonWrapper, {
204
225
  value: "underline",
205
226
  label: t("tool.underline"),
206
- icon: core.CoreIcons.formatUnderline,
227
+ icon: "icon-[mdi--format-underline]",
228
+ color: textFormat.includes("underline") ? "primary" : "default",
207
229
  onClick: function onClick() {
208
230
  return watch.activeEditor.dispatchCommand(lexical.FORMAT_TEXT_COMMAND, "underline");
209
231
  }
210
232
  }), /*#__PURE__*/jsxRuntime.jsx(ButtonWrapper, {
211
233
  value: "strikethrough",
212
234
  label: t("tool.strikethrough"),
213
- icon: core.CoreIcons.formatStrikethrough,
235
+ icon: "icon-[mdi--format-strikethrough-variant]",
236
+ color: textFormat.includes("strikethrough") ? "primary" : "default",
214
237
  onClick: function onClick() {
215
238
  return watch.activeEditor.dispatchCommand(lexical.FORMAT_TEXT_COMMAND, "strikethrough");
216
239
  }
@@ -220,38 +243,36 @@ var ToolbarPlugin = function ToolbarPlugin() {
220
243
  }), /*#__PURE__*/jsxRuntime.jsx(form.ColorInput, {
221
244
  noOutline: true,
222
245
  value: watch.fontColor,
223
- onChange: function onChange() {
224
- var v = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "#000";
225
- return watch.onFontColorSelect(v);
246
+ onChange: function onChange(v) {
247
+ return watch.onFontColorSelect(v !== null && v !== void 0 ? v : undefined);
226
248
  },
227
249
  decorateStart: /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
228
- icon: core.CoreIcons.formatText
250
+ icon: "icon-[mdi--format-text]"
229
251
  })
230
252
  }), /*#__PURE__*/jsxRuntime.jsx(form.ColorInput, {
231
253
  noOutline: true,
232
254
  value: watch.bgColor,
233
- onChange: function onChange() {
234
- var v = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "#fff";
235
- return watch.onBgColorSelect(v);
255
+ onChange: function onChange(v) {
256
+ return watch.onBgColorSelect(v !== null && v !== void 0 ? v : undefined);
236
257
  },
237
258
  decorateStart: /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
238
- icon: core.CoreIcons.formatFill
259
+ icon: "icon-[mdi--format-color-fill]"
239
260
  })
240
261
  }), /*#__PURE__*/jsxRuntime.jsx(ButtonWrapper, {
241
262
  value: "hilight",
242
263
  label: t("tool.hilight"),
243
- icon: core.CoreIcons.formatHilight,
264
+ icon: "icon-[mdi--format-color-highlight]",
244
265
  onClick: function onClick() {
245
266
  return watch.onBgColorSelect("#fde68a");
246
267
  }
247
268
  }), /*#__PURE__*/jsxRuntime.jsx(ButtonWrapper, {
248
269
  value: "hilight",
249
270
  label: t("tool.clear"),
250
- icon: core.CoreIcons.formatClear,
271
+ icon: "icon-[mdi--format-clear]",
251
272
  onClick: function onClick() {
252
273
  return watch.clearFormatting();
253
274
  }
254
- }), /*#__PURE__*/jsxRuntime.jsx(core.Divider, {})]
275
+ })]
255
276
  });
256
277
  };
257
278
 
@@ -4,10 +4,9 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
4
  import { AutoFocusPlugin } from '@lexical/react/LexicalAutoFocusPlugin';
5
5
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
6
6
  import { ContentEditable } from '@lexical/react/LexicalContentEditable';
7
- import LexicalErrorBoundary from '@lexical/react/LexicalErrorBoundary';
7
+ import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
8
8
  import { LexicalNestedComposer } from '@lexical/react/LexicalNestedComposer';
9
9
  import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
10
- import { mdiFormatColorFill, mdiClose } from '../../../../node_modules/@mdi/js/mdi.js';
11
10
  import { Icon } from '@react-fabric/core';
12
11
  import { createEditor, $getNodeByKey } from 'lexical';
13
12
  import { useRef, useEffect, useMemo } from 'react';
@@ -174,7 +173,7 @@ var StickyComponent = function StickyComponent(_ref) {
174
173
  "aria-label": "Change sticky note color",
175
174
  title: "Color",
176
175
  children: /*#__PURE__*/jsx(Icon, {
177
- icon: mdiFormatColorFill
176
+ icon: "icon-[mdi--format-color-fill]"
178
177
  })
179
178
  }), /*#__PURE__*/jsx("button", {
180
179
  onClick: handleDelete,
@@ -182,7 +181,7 @@ var StickyComponent = function StickyComponent(_ref) {
182
181
  "aria-label": "Delete sticky note",
183
182
  title: "Delete",
184
183
  children: /*#__PURE__*/jsx(Icon, {
185
- icon: mdiClose
184
+ icon: "icon-[mdi--close]"
186
185
  })
187
186
  })]
188
187
  }), /*#__PURE__*/jsx("div", {
@@ -1,8 +1,8 @@
1
1
  'use client';
2
2
 
3
3
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
- import { CodeHighlightNode, CodeNode } from '../../../../node_modules/@lexical/code/LexicalCode.js';
5
- import { ListItemNode, ListNode } from '../../../../node_modules/@lexical/list/LexicalList.js';
4
+ import { CodeHighlightNode, CodeNode } from '@lexical/code';
5
+ import { ListItemNode, ListNode } from '@lexical/list';
6
6
  import { AutoFocusPlugin } from '@lexical/react/LexicalAutoFocusPlugin';
7
7
  import { CheckListPlugin } from '@lexical/react/LexicalCheckListPlugin';
8
8
  import { LexicalComposer } from '@lexical/react/LexicalComposer';
@@ -12,8 +12,8 @@ import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
12
12
  import { ListPlugin } from '@lexical/react/LexicalListPlugin';
13
13
  import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
14
14
  import { TablePlugin } from '@lexical/react/LexicalTablePlugin';
15
- import { QuoteNode, HeadingNode } from '../../../../node_modules/@lexical/rich-text/LexicalRichText.js';
16
- import { TableCellNode, TableNode, TableRowNode } from '../../../../node_modules/@lexical/table/LexicalTable.js';
15
+ import { QuoteNode, HeadingNode } from '@lexical/rich-text';
16
+ import { TableCellNode, TableNode, TableRowNode } from '@lexical/table';
17
17
  import { Header, ErrorBoundary, ThemeProvider } from '@react-fabric/core';
18
18
  import { debounce } from '@react-fabric/utilities';
19
19
  import classNames from 'classnames';
@@ -21,18 +21,42 @@ import { useRef, useState, useCallback, useEffect, useMemo } from 'react';
21
21
  import { StickyNode } from '../nodes/StickyNode.js';
22
22
  import { DraggableBlockPlugin } from '../plugins/DraggableBlockPlugin.js';
23
23
  import { StickyPlugin } from '../plugins/StickyPlugin.js';
24
- import classes from './Lexical.module.css';
25
- import { LexicalTheme } from './theme.js';
26
24
  import { ToolbarPlugin } from '../plugins/ToolbarPlugin.js';
25
+ import { LexicalTheme } from './theme.js';
27
26
  import { jsxs, jsx } from 'react/jsx-runtime';
28
27
 
28
+ /**
29
+ * LexicalEditor component is a rich text editor built using Lexical.
30
+ * It supports various features such as code highlighting, lists, tables, and sticky notes.
31
+ * It provides a customizable toolbar and handles editor state changes.
32
+ * It also supports drag-and-drop functionality for blocks.
33
+ * It can be used in both read-only and editable modes, and supports publishing mode for exporting content.
34
+ * It uses a custom theme and provides error handling for Lexical updates.
35
+ *
36
+ * @param {EditorProps} props - The properties for the LexicalEditor component.
37
+ * @returns {JSX.Element} The rendered LexicalEditor component.
38
+ *
39
+ * @example
40
+ * ```jsx
41
+ * <LexicalEditor
42
+ * value={initialValue}
43
+ * readOnly={false}
44
+ * publishMode={false}
45
+ * onChange={(value) => console.log("Editor value changed:", value)}
46
+ * onDirty={(isDirty) => console.log("Editor is dirty:", isDirty)}
47
+ * />
48
+ * ```
49
+ *
50
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/story/lexical-playground--playground}
51
+ * @see {@link https://lexical.dev/docs/}
52
+ */
29
53
  var LexicalEditor = function LexicalEditor(_ref) {
30
54
  var value = _ref.value,
31
55
  readOnly = _ref.readOnly,
32
56
  publishMode = _ref.publishMode,
33
57
  onChange = _ref.onChange,
34
58
  onDirty = _ref.onDirty;
35
- var editorRef = useRef();
59
+ var editorRef = useRef(null);
36
60
  var _useState = useState(null),
37
61
  _useState2 = _slicedToArray(_useState, 2),
38
62
  editorContainer = _useState2[0],
@@ -108,7 +132,7 @@ var LexicalEditor = function LexicalEditor(_ref) {
108
132
  return !publishMode ? /*#__PURE__*/jsxs("div", {
109
133
  className: "lexical-scroller area-content overflow-auto",
110
134
  children: [/*#__PURE__*/jsx("div", {
111
- className: classNames(classes.lexicalToolbar, "sticky top-0 z-1"),
135
+ className: classNames("fabric-lexicalToolbar", "sticky top-0 z-1"),
112
136
  children: /*#__PURE__*/jsx(Header, {
113
137
  className: "bg-base",
114
138
  children: /*#__PURE__*/jsx(ToolbarPlugin, {})
@@ -124,7 +148,7 @@ var LexicalEditor = function LexicalEditor(_ref) {
124
148
  colorScheme: "light",
125
149
  children: /*#__PURE__*/jsxs("div", {
126
150
  role: "none",
127
- className: classNames(classes.lexicalEditor, "lexical-container relative bg-white min-h-full mx-auto shadow-md print:shadow-none"),
151
+ className: classNames("fabric-lexicalEditor", "lexical-container relative bg-white min-h-full mx-auto shadow-md print:shadow-none"),
128
152
  onDragOver: function onDragOver(e) {
129
153
  return e.stopPropagation();
130
154
  },
@@ -134,6 +158,7 @@ var LexicalEditor = function LexicalEditor(_ref) {
134
158
  ref: setEditorContainer,
135
159
  children: [/*#__PURE__*/jsx(RichTextPlugin, {
136
160
  contentEditable: /*#__PURE__*/jsx(ContentEditable, {
161
+ readOnly: !!readOnly || publishMode,
137
162
  className: "lexical-editor px-[2cm] py-[1cm] min-h-screen"
138
163
  }),
139
164
  placeholder: /*#__PURE__*/jsx("div", {
@@ -3,16 +3,17 @@
3
3
  import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
4
4
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
5
5
  import _regeneratorRuntime from '@babel/runtime/regenerator';
6
- import { $isCodeNode, CODE_LANGUAGE_MAP, $createCodeNode } from '../../../../node_modules/@lexical/code/LexicalCode.js';
7
- import { $isLinkNode } from '../../../../node_modules/@lexical/link/LexicalLink.js';
8
- import { $isListNode, ListNode, INSERT_UNORDERED_LIST_COMMAND, REMOVE_LIST_COMMAND, INSERT_CHECK_LIST_COMMAND, INSERT_ORDERED_LIST_COMMAND } from '../../../../node_modules/@lexical/list/LexicalList.js';
6
+ import { $isCodeNode, CODE_LANGUAGE_MAP, $createCodeNode } from '@lexical/code';
7
+ import { $isLinkNode } from '@lexical/link';
8
+ import { $isListNode, ListNode, INSERT_UNORDERED_LIST_COMMAND, REMOVE_LIST_COMMAND, INSERT_CHECK_LIST_COMMAND, INSERT_ORDERED_LIST_COMMAND } from '@lexical/list';
9
9
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
10
- import { $isHeadingNode, $createQuoteNode, $createHeadingNode, $isQuoteNode } from '../../../../node_modules/@lexical/rich-text/LexicalRichText.js';
11
- import { $isParentElementRTL, $getSelectionStyleValueForProperty, $patchStyleText, $setBlocksType, $isAtNodeEnd } from '../../../../node_modules/@lexical/selection/LexicalSelection.js';
12
- import { $isTableNode } from '../../../../node_modules/@lexical/table/LexicalTable.js';
13
- import { $findMatchingParent, $getNearestNodeOfType, mergeRegister, $getNearestBlockElementAncestorOrThrow } from '../../../../node_modules/@lexical/utils/LexicalUtils.js';
14
- import { $getSelection, $isRangeSelection, $isRootOrShadowRoot, FOCUS_COMMAND, COMMAND_PRIORITY_CRITICAL, SELECTION_CHANGE_COMMAND, CAN_UNDO_COMMAND, CAN_REDO_COMMAND, $createParagraphNode, INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND, $isTextNode } from 'lexical';
15
- import { useTransition, useState, useCallback, useEffect } from 'react';
10
+ import { $isHeadingNode, $createQuoteNode, $createHeadingNode, $isQuoteNode } from '@lexical/rich-text';
11
+ import { $isParentElementRTL, $getSelectionStyleValueForProperty, $patchStyleText, $setBlocksType, $isAtNodeEnd } from '@lexical/selection';
12
+ import { $isTableNode } from '@lexical/table';
13
+ import { $findMatchingParent, $getNearestNodeOfType, mergeRegister, $getNearestBlockElementAncestorOrThrow } from '@lexical/utils';
14
+ import { isNil } from '@react-fabric/utilities';
15
+ import { $getSelection, $isRangeSelection, $isRootOrShadowRoot, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_CRITICAL, CAN_UNDO_COMMAND, CAN_REDO_COMMAND, $setSelection, $createParagraphNode, INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND, $isTextNode } from 'lexical';
16
+ import { useState, useCallback, useEffect } from 'react';
16
17
 
17
18
  var blockTypeToBlockName = {
18
19
  bullet: "Bulleted List",
@@ -44,9 +45,6 @@ function getSelectedNode(selection) {
44
45
  }
45
46
  }
46
47
  var useFormatWatcher = function useFormatWatcher() {
47
- var _useTransition = useTransition(),
48
- _useTransition2 = _slicedToArray(_useTransition, 2),
49
- startTransition = _useTransition2[1];
50
48
  var _useLexicalComposerCo = useLexicalComposerContext(),
51
49
  _useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
52
50
  editor = _useLexicalComposerCo2[0];
@@ -54,88 +52,96 @@ var useFormatWatcher = function useFormatWatcher() {
54
52
  _useState2 = _slicedToArray(_useState, 2),
55
53
  activeEditor = _useState2[0],
56
54
  setActiveEditor = _useState2[1];
57
- var _useState3 = useState("paragraph"),
55
+ var _useState3 = useState(),
58
56
  _useState4 = _slicedToArray(_useState3, 2),
59
- blockType = _useState4[0],
60
- setBlockType = _useState4[1];
61
- var _useState5 = useState("root"),
57
+ currentSelection = _useState4[0],
58
+ setCurrentSelection = _useState4[1];
59
+ var _useState5 = useState("paragraph"),
62
60
  _useState6 = _slicedToArray(_useState5, 2),
63
- rootType = _useState6[0],
64
- setRootType = _useState6[1];
65
- var _useState7 = useState(null),
61
+ blockType = _useState6[0],
62
+ setBlockType = _useState6[1];
63
+ var _useState7 = useState("root"),
66
64
  _useState8 = _slicedToArray(_useState7, 2),
67
- selectedElementKey = _useState8[0],
68
- setSelectedElementKey = _useState8[1];
69
- var _useState9 = useState("16"),
65
+ rootType = _useState8[0],
66
+ setRootType = _useState8[1];
67
+ var _useState9 = useState(null),
70
68
  _useState10 = _slicedToArray(_useState9, 2),
71
- fontSize = _useState10[0],
72
- setFontSize = _useState10[1];
73
- var _useState11 = useState("#000"),
69
+ selectedElementKey = _useState10[0],
70
+ setSelectedElementKey = _useState10[1];
71
+ var _useState11 = useState("16"),
74
72
  _useState12 = _slicedToArray(_useState11, 2),
75
- fontColor = _useState12[0],
76
- setFontColor = _useState12[1];
77
- var _useState13 = useState("#fff"),
73
+ fontSize = _useState12[0],
74
+ setFontSize = _useState12[1];
75
+ var _useState13 = useState("#000"),
78
76
  _useState14 = _slicedToArray(_useState13, 2),
79
- bgColor = _useState14[0],
80
- setBgColor = _useState14[1];
81
- var _useState15 = useState("Arial"),
77
+ fontColor = _useState14[0],
78
+ setFontColor = _useState14[1];
79
+ var _useState15 = useState("#fff"),
82
80
  _useState16 = _slicedToArray(_useState15, 2),
83
- fontFamily = _useState16[0],
84
- setFontFamily = _useState16[1];
85
- var _useState17 = useState(false),
81
+ bgColor = _useState16[0],
82
+ setBgColor = _useState16[1];
83
+ var _useState17 = useState("Arial"),
86
84
  _useState18 = _slicedToArray(_useState17, 2),
87
- isLink = _useState18[0],
88
- setIsLink = _useState18[1];
89
- var _useState19 = useState(false),
85
+ fontFamily = _useState18[0],
86
+ setFontFamily = _useState18[1];
87
+ var _useState19 = useState(""),
90
88
  _useState20 = _slicedToArray(_useState19, 2),
91
- isBold = _useState20[0],
92
- setIsBold = _useState20[1];
89
+ align = _useState20[0],
90
+ setAlign = _useState20[1];
93
91
  var _useState21 = useState(false),
94
92
  _useState22 = _slicedToArray(_useState21, 2),
95
- isItalic = _useState22[0],
96
- setIsItalic = _useState22[1];
93
+ isLink = _useState22[0],
94
+ setIsLink = _useState22[1];
97
95
  var _useState23 = useState(false),
98
96
  _useState24 = _slicedToArray(_useState23, 2),
99
- isUnderline = _useState24[0],
100
- setIsUnderline = _useState24[1];
97
+ isBold = _useState24[0],
98
+ setIsBold = _useState24[1];
101
99
  var _useState25 = useState(false),
102
100
  _useState26 = _slicedToArray(_useState25, 2),
103
- isStrikethrough = _useState26[0],
104
- setIsStrikethrough = _useState26[1];
101
+ isItalic = _useState26[0],
102
+ setIsItalic = _useState26[1];
105
103
  var _useState27 = useState(false),
106
104
  _useState28 = _slicedToArray(_useState27, 2),
107
- isSubscript = _useState28[0],
108
- setIsSubscript = _useState28[1];
105
+ isUnderline = _useState28[0],
106
+ setIsUnderline = _useState28[1];
109
107
  var _useState29 = useState(false),
110
108
  _useState30 = _slicedToArray(_useState29, 2),
111
- isSuperscript = _useState30[0],
112
- setIsSuperscript = _useState30[1];
109
+ isStrikethrough = _useState30[0],
110
+ setIsStrikethrough = _useState30[1];
113
111
  var _useState31 = useState(false),
114
112
  _useState32 = _slicedToArray(_useState31, 2),
115
- isCode = _useState32[0],
116
- setIsCode = _useState32[1];
113
+ isSubscript = _useState32[0],
114
+ setIsSubscript = _useState32[1];
117
115
  var _useState33 = useState(false),
118
116
  _useState34 = _slicedToArray(_useState33, 2),
119
- canUndo = _useState34[0],
120
- setCanUndo = _useState34[1];
117
+ isSuperscript = _useState34[0],
118
+ setIsSuperscript = _useState34[1];
121
119
  var _useState35 = useState(false),
122
120
  _useState36 = _slicedToArray(_useState35, 2),
123
- canRedo = _useState36[0],
124
- setCanRedo = _useState36[1];
121
+ isCode = _useState36[0],
122
+ setIsCode = _useState36[1];
125
123
  var _useState37 = useState(false),
126
124
  _useState38 = _slicedToArray(_useState37, 2),
127
- isRTL = _useState38[0],
128
- setIsRTL = _useState38[1];
129
- var _useState39 = useState(""),
125
+ canUndo = _useState38[0],
126
+ setCanUndo = _useState38[1];
127
+ var _useState39 = useState(false),
130
128
  _useState40 = _slicedToArray(_useState39, 2),
131
- codeLanguage = _useState40[0],
132
- setCodeLanguage = _useState40[1];
133
- var _useState41 = useState(function () {
129
+ canRedo = _useState40[0],
130
+ setCanRedo = _useState40[1];
131
+ var _useState41 = useState(false),
132
+ _useState42 = _slicedToArray(_useState41, 2),
133
+ isRTL = _useState42[0],
134
+ setIsRTL = _useState42[1];
135
+ var _useState43 = useState(""),
136
+ _useState44 = _slicedToArray(_useState43, 2),
137
+ codeLanguage = _useState44[0],
138
+ setCodeLanguage = _useState44[1];
139
+ var _useState45 = useState(function () {
134
140
  return editor.isEditable();
135
141
  }),
136
- _useState42 = _slicedToArray(_useState41, 2),
137
- isEditable = _useState42[0],
138
- setIsEditable = _useState42[1];
142
+ _useState46 = _slicedToArray(_useState45, 2),
143
+ isEditable = _useState46[0],
144
+ setIsEditable = _useState46[1];
139
145
  var $updateToolbar = useCallback(function () {
140
146
  var selection = $getSelection();
141
147
  if ($isRangeSelection(selection)) {
@@ -158,7 +164,9 @@ var useFormatWatcher = function useFormatWatcher() {
158
164
  setIsSubscript(selection.hasFormat("subscript"));
159
165
  setIsSuperscript(selection.hasFormat("superscript"));
160
166
  setIsCode(selection.hasFormat("code"));
161
- setIsRTL($isParentElementRTL(selection));
167
+ editor.read(function () {
168
+ setIsRTL($isParentElementRTL(selection));
169
+ });
162
170
 
163
171
  // Update links
164
172
  var node = getSelectedNode(selection);
@@ -176,6 +184,7 @@ var useFormatWatcher = function useFormatWatcher() {
176
184
  }
177
185
  if (elementDOM !== null) {
178
186
  setSelectedElementKey(elementKey);
187
+ elementDOM && setAlign(getComputedStyle(elementDOM).textAlign);
179
188
  if ($isListNode(element)) {
180
189
  var parentList = $getNearestNodeOfType(anchorNode, ListNode);
181
190
  var type = parentList ? parentList.getListType() : element.getListType();
@@ -194,22 +203,29 @@ var useFormatWatcher = function useFormatWatcher() {
194
203
  }
195
204
  // Handle buttons
196
205
  setFontSize(parseInt($getSelectionStyleValueForProperty(selection, "font-size", "16")) + "");
197
- setFontColor($getSelectionStyleValueForProperty(selection, "color", "#000"));
198
- setBgColor($getSelectionStyleValueForProperty(selection, "background-color", "#fff"));
206
+ setFontColor($getSelectionStyleValueForProperty(selection, "color",
207
+ // @ts-expect-error ignore
208
+ // eslint-disable-next-line no-new-wrappers
209
+ new String("#000")));
210
+ setBgColor($getSelectionStyleValueForProperty(selection, "background-color",
211
+ // @ts-expect-error ignore
212
+ // eslint-disable-next-line no-new-wrappers
213
+ new String("#fff")));
199
214
  setFontFamily($getSelectionStyleValueForProperty(selection, "font-family", "inherit"));
200
215
  }
201
- }, [activeEditor]);
216
+ }, []);
202
217
  useEffect(function () {
203
- return editor.registerCommand(FOCUS_COMMAND, function (_payload, newEditor) {
218
+ return editor.registerCommand(SELECTION_CHANGE_COMMAND, function (_payload, newEditor) {
204
219
  setActiveEditor(newEditor);
220
+ setCurrentSelection($getSelection());
221
+ $updateToolbar();
205
222
  return false;
206
223
  }, COMMAND_PRIORITY_CRITICAL);
207
- }, [editor]);
224
+ }, [editor, $updateToolbar]);
208
225
  useEffect(function () {
209
- return activeEditor.registerCommand(SELECTION_CHANGE_COMMAND, function (_payload, newEditor) {
226
+ activeEditor.getEditorState().read(function () {
210
227
  $updateToolbar();
211
- return false;
212
- }, COMMAND_PRIORITY_CRITICAL);
228
+ });
213
229
  }, [activeEditor, $updateToolbar]);
214
230
  useEffect(function () {
215
231
  return mergeRegister(editor.registerEditableListener(function (editable) {
@@ -228,15 +244,14 @@ var useFormatWatcher = function useFormatWatcher() {
228
244
  }, COMMAND_PRIORITY_CRITICAL));
229
245
  }, [$updateToolbar, activeEditor, editor]);
230
246
  var applyStyleText = useCallback(function (styles) {
231
- setTimeout(function () {
232
- editor.update(function () {
233
- var selection = $getSelection();
234
- if ($isRangeSelection(selection)) {
235
- $patchStyleText(selection, styles);
236
- }
237
- });
238
- }, 100);
239
- }, [editor]);
247
+ // activeEditor.focus();
248
+ activeEditor.update(function () {
249
+ if (!isNil(currentSelection)) {
250
+ $setSelection(currentSelection.clone());
251
+ $patchStyleText(currentSelection, styles);
252
+ }
253
+ });
254
+ }, [activeEditor, currentSelection]);
240
255
  var formatBulletList = function formatBulletList() {
241
256
  setTimeout(function () {
242
257
  if (blockType !== "bullet") {
@@ -364,25 +379,18 @@ var useFormatWatcher = function useFormatWatcher() {
364
379
  });
365
380
  }, [activeEditor]);
366
381
  var onSizeChange = useCallback(function (value) {
367
- startTransition(function () {
368
- return setFontColor(value);
369
- });
370
382
  applyStyleText({
371
383
  "font-size": +value + "px"
372
384
  });
373
385
  }, [applyStyleText]);
374
- var onFontColorSelect = useCallback(function (value) {
375
- startTransition(function () {
376
- return setFontColor(value);
377
- });
386
+ var onFontColorSelect = useCallback(function () {
387
+ var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "#000000";
378
388
  applyStyleText({
379
389
  color: value
380
390
  });
381
391
  }, [applyStyleText]);
382
- var onBgColorSelect = useCallback(function (value) {
383
- startTransition(function () {
384
- return setBgColor(value);
385
- });
392
+ var onBgColorSelect = useCallback(function () {
393
+ var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "#ffffff";
386
394
  applyStyleText({
387
395
  "background-color": value
388
396
  });
@@ -428,6 +436,7 @@ var useFormatWatcher = function useFormatWatcher() {
428
436
  canUndo: canUndo,
429
437
  canRedo: canRedo,
430
438
  isRTL: isRTL,
439
+ align: align,
431
440
  isEditable: isEditable,
432
441
  codeLanguage: codeLanguage,
433
442
  activeEditor: activeEditor,
@@ -0,0 +1,21 @@
1
+ 'use client';
2
+
3
+ var tool = {
4
+ alignCenter: "محاذاة المركز",
5
+ alignJustify: "محاذاة وضبط",
6
+ alignEnd: "محاذاة النهاية",
7
+ alignStart: "محاذاة البداية",
8
+ bold: "عريض",
9
+ clear: "مسح التنسيق",
10
+ hilight: "تسليط الضوء",
11
+ indentIn: "المسافة البادئة في",
12
+ underline: "تسطير",
13
+ strikethrough: "يتوسطه خط",
14
+ italic: "مائل",
15
+ indentOut: "مسافة بادئة للخارج"
16
+ };
17
+ var ar = {
18
+ tool: tool
19
+ };
20
+
21
+ export { ar as default, tool };