@react-fabric/lexical 1.0.0-beta.9 → 1.0.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 (148) hide show
  1. package/{src/editor/Lexical.module.css → css/_lexical.css} +79 -13
  2. package/css/styles.css +24 -0
  3. package/dist/cjs/{packages/lexical/src/editor → editor}/LexicalEditor.js +98 -45
  4. package/dist/cjs/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +147 -140
  5. package/dist/cjs/i18n/ar/lexical.json.js +30 -0
  6. package/dist/cjs/i18n/en/lexical.json.js +30 -0
  7. package/{src/plugins/StickyPlugin.ts → dist/cjs/i18n/index.js} +10 -15
  8. package/dist/cjs/index.js +36 -0
  9. package/dist/cjs/plugins/CommentPlugin.js +481 -0
  10. package/dist/cjs/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +17 -20
  11. package/dist/cjs/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +58 -37
  12. package/dist/esm/{packages/lexical/src/editor → editor}/LexicalEditor.js +101 -48
  13. package/dist/esm/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +95 -88
  14. package/dist/esm/i18n/ar/lexical.json.js +25 -0
  15. package/dist/esm/i18n/en/lexical.json.js +25 -0
  16. package/dist/esm/i18n/index.js +33 -0
  17. package/dist/esm/index.js +34 -0
  18. package/dist/esm/plugins/CommentPlugin.js +481 -0
  19. package/dist/esm/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +15 -18
  20. package/dist/esm/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +59 -38
  21. package/dist/types/editor/LexicalEditor.d.ts +33 -4
  22. package/dist/types/hooks/useFormatWatcher.d.ts +7 -4
  23. package/dist/types/i18n/index.d.ts +1 -0
  24. package/dist/types/index.d.ts +27 -0
  25. package/dist/types/plugins/CommentPlugin.d.ts +5 -0
  26. package/dist/types/plugins/DraggableBlockPlugin.d.ts +3 -2
  27. package/dist/types/plugins/ToolbarPlugin.d.ts +1 -1
  28. package/dist/types/utils/index.d.ts +3 -6
  29. package/package.json +18 -18
  30. package/src/editor/LexicalEditor.tsx +95 -55
  31. package/src/hooks/useFormatWatcher.ts +50 -74
  32. package/src/i18n/ar/lexical.json +18 -0
  33. package/src/i18n/en/lexical.json +18 -0
  34. package/src/i18n/index.ts +28 -0
  35. package/src/index.ts +24 -17
  36. package/src/plugins/CommentPlugin.tsx +523 -0
  37. package/src/plugins/DraggableBlockPlugin.tsx +23 -68
  38. package/src/plugins/ToolbarPlugin.tsx +83 -131
  39. package/src/utils/index.ts +12 -108
  40. package/dist/cjs/_virtual/prism.js +0 -5
  41. package/dist/cjs/editor/Lexical.module.css +0 -1
  42. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -432
  43. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -21
  44. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -27
  45. package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +0 -1139
  46. package/dist/cjs/node_modules/@lexical/code/LexicalCode.js +0 -25
  47. package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +0 -50
  48. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +0 -245
  49. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.js +0 -19
  50. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +0 -18
  51. package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +0 -471
  52. package/dist/cjs/node_modules/@lexical/link/LexicalLink.js +0 -17
  53. package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +0 -24
  54. package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +0 -1275
  55. package/dist/cjs/node_modules/@lexical/list/LexicalList.js +0 -29
  56. package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +0 -29
  57. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -789
  58. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.js +0 -29
  59. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -26
  60. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -976
  61. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +0 -35
  62. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -35
  63. package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +0 -2792
  64. package/dist/cjs/node_modules/@lexical/table/LexicalTable.js +0 -23
  65. package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +0 -55
  66. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -888
  67. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +0 -35
  68. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -66
  69. package/dist/cjs/node_modules/@mdi/js/mdi.js +0 -8
  70. package/dist/cjs/node_modules/prismjs/components/prism-c.js +0 -82
  71. package/dist/cjs/node_modules/prismjs/components/prism-clike.js +0 -33
  72. package/dist/cjs/node_modules/prismjs/components/prism-cpp.js +0 -101
  73. package/dist/cjs/node_modules/prismjs/components/prism-css.js +0 -66
  74. package/dist/cjs/node_modules/prismjs/components/prism-java.js +0 -126
  75. package/dist/cjs/node_modules/prismjs/components/prism-javascript.js +0 -174
  76. package/dist/cjs/node_modules/prismjs/components/prism-markdown.js +0 -417
  77. package/dist/cjs/node_modules/prismjs/components/prism-markup.js +0 -188
  78. package/dist/cjs/node_modules/prismjs/components/prism-objectivec.js +0 -14
  79. package/dist/cjs/node_modules/prismjs/components/prism-powershell.js +0 -60
  80. package/dist/cjs/node_modules/prismjs/components/prism-python.js +0 -67
  81. package/dist/cjs/node_modules/prismjs/components/prism-rust.js +0 -130
  82. package/dist/cjs/node_modules/prismjs/components/prism-sql.js +0 -34
  83. package/dist/cjs/node_modules/prismjs/components/prism-swift.js +0 -150
  84. package/dist/cjs/node_modules/prismjs/components/prism-typescript.js +0 -62
  85. package/dist/cjs/node_modules/prismjs/prism.js +0 -1951
  86. package/dist/cjs/packages/lexical/src/components/StickyComponent.js +0 -221
  87. package/dist/cjs/packages/lexical/src/index.js +0 -7
  88. package/dist/cjs/packages/lexical/src/nodes/StickyNode.js +0 -218
  89. package/dist/cjs/packages/lexical/src/plugins/StickyPlugin.js +0 -20
  90. package/dist/esm/_virtual/prism.js +0 -5
  91. package/dist/esm/editor/Lexical.module.css +0 -1
  92. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -423
  93. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -19
  94. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -18
  95. package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +0 -1121
  96. package/dist/esm/node_modules/@lexical/code/LexicalCode.js +0 -21
  97. package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +0 -32
  98. package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +0 -244
  99. package/dist/esm/node_modules/@lexical/html/LexicalHtml.js +0 -18
  100. package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +0 -17
  101. package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +0 -463
  102. package/dist/esm/node_modules/@lexical/link/LexicalLink.js +0 -17
  103. package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +0 -16
  104. package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +0 -1262
  105. package/dist/esm/node_modules/@lexical/list/LexicalList.js +0 -23
  106. package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +0 -16
  107. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -781
  108. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.js +0 -23
  109. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -18
  110. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -957
  111. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +0 -26
  112. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -16
  113. package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +0 -2754
  114. package/dist/esm/node_modules/@lexical/table/LexicalTable.js +0 -20
  115. package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +0 -17
  116. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -839
  117. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +0 -26
  118. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -17
  119. package/dist/esm/node_modules/@mdi/js/mdi.js +0 -7
  120. package/dist/esm/node_modules/prismjs/components/prism-c.js +0 -82
  121. package/dist/esm/node_modules/prismjs/components/prism-clike.js +0 -33
  122. package/dist/esm/node_modules/prismjs/components/prism-cpp.js +0 -101
  123. package/dist/esm/node_modules/prismjs/components/prism-css.js +0 -66
  124. package/dist/esm/node_modules/prismjs/components/prism-java.js +0 -126
  125. package/dist/esm/node_modules/prismjs/components/prism-javascript.js +0 -174
  126. package/dist/esm/node_modules/prismjs/components/prism-markdown.js +0 -417
  127. package/dist/esm/node_modules/prismjs/components/prism-markup.js +0 -188
  128. package/dist/esm/node_modules/prismjs/components/prism-objectivec.js +0 -14
  129. package/dist/esm/node_modules/prismjs/components/prism-powershell.js +0 -60
  130. package/dist/esm/node_modules/prismjs/components/prism-python.js +0 -67
  131. package/dist/esm/node_modules/prismjs/components/prism-rust.js +0 -130
  132. package/dist/esm/node_modules/prismjs/components/prism-sql.js +0 -34
  133. package/dist/esm/node_modules/prismjs/components/prism-swift.js +0 -150
  134. package/dist/esm/node_modules/prismjs/components/prism-typescript.js +0 -62
  135. package/dist/esm/node_modules/prismjs/prism.js +0 -1951
  136. package/dist/esm/packages/lexical/src/components/StickyComponent.js +0 -221
  137. package/dist/esm/packages/lexical/src/index.js +0 -3
  138. package/dist/esm/packages/lexical/src/nodes/StickyNode.js +0 -216
  139. package/dist/esm/packages/lexical/src/plugins/StickyPlugin.js +0 -20
  140. package/dist/types/components/StickyComponent.d.ts +0 -9
  141. package/dist/types/nodes/StickyNode.d.ts +0 -35
  142. package/dist/types/plugins/StickyPlugin.d.ts +0 -1
  143. package/src/components/StickyComponent.tsx +0 -271
  144. package/src/nodes/StickyNode.tsx +0 -249
  145. /package/dist/cjs/{packages/lexical/src/editor → editor}/theme.js +0 -0
  146. /package/dist/cjs/{packages/lexical/src/utils → utils}/index.js +0 -0
  147. /package/dist/esm/{packages/lexical/src/editor → editor}/theme.js +0 -0
  148. /package/dist/esm/{packages/lexical/src/utils → utils}/index.js +0 -0
@@ -13,7 +13,7 @@ var jsxRuntime = require('react/jsx-runtime');
13
13
 
14
14
  var _excluded = ["label"];
15
15
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
17
  var blockTypeToBlockName = {
18
18
  bullet: "Bulleted List",
19
19
  code: "Block",
@@ -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) {
@@ -47,7 +47,7 @@ var ButtonWrapper = function ButtonWrapper(_ref) {
47
47
  }, rest))
48
48
  });
49
49
  };
50
- var ToolbarPlugin = function ToolbarPlugin() {
50
+ function ToolbarPlugin() {
51
51
  var watch = useFormatWatcher.useFormatWatcher();
52
52
  var _useTranslation = reactI18next.useTranslation("lexical"),
53
53
  t = _useTranslation.t;
@@ -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,39 +243,37 @@ 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
 
258
279
  exports.ToolbarPlugin = ToolbarPlugin;
@@ -1,8 +1,9 @@
1
1
  'use client';
2
2
 
3
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
3
4
  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';
5
+ import { CodeHighlightNode, CodeNode } from '@lexical/code';
6
+ import { ListItemNode, ListNode } from '@lexical/list';
6
7
  import { AutoFocusPlugin } from '@lexical/react/LexicalAutoFocusPlugin';
7
8
  import { CheckListPlugin } from '@lexical/react/LexicalCheckListPlugin';
8
9
  import { LexicalComposer } from '@lexical/react/LexicalComposer';
@@ -12,27 +13,70 @@ import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
12
13
  import { ListPlugin } from '@lexical/react/LexicalListPlugin';
13
14
  import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
14
15
  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';
17
- import { Header, ErrorBoundary, ThemeProvider } from '@react-fabric/core';
18
- import { debounce } from '@react-fabric/utilities';
19
- import classNames from 'classnames';
16
+ import { QuoteNode, HeadingNode } from '@lexical/rich-text';
17
+ import { TableCellNode, TableNode, TableRowNode } from '@lexical/table';
18
+ import { ErrorBoundary, ThemeProvider, Header } from '@react-fabric/core';
19
+ import { debounce, EMPTY_ARRAY, cn } from '@react-fabric/utilities';
20
20
  import { useRef, useState, useCallback, useEffect, useMemo } from 'react';
21
- import { StickyNode } from '../nodes/StickyNode.js';
21
+ import { CommentPlugin } from '../plugins/CommentPlugin.js';
22
22
  import { DraggableBlockPlugin } from '../plugins/DraggableBlockPlugin.js';
23
- import { StickyPlugin } from '../plugins/StickyPlugin.js';
24
- import classes from './Lexical.module.css';
25
- import { LexicalTheme } from './theme.js';
26
23
  import { ToolbarPlugin } from '../plugins/ToolbarPlugin.js';
27
- import { jsxs, jsx } from 'react/jsx-runtime';
24
+ import { LexicalTheme } from './theme.js';
25
+ import { jsx, jsxs } from 'react/jsx-runtime';
26
+
27
+ function Wrapper(_ref) {
28
+ var children = _ref.children,
29
+ _ref$publishMode = _ref.publishMode,
30
+ publishMode = _ref$publishMode === void 0 ? false : _ref$publishMode,
31
+ _ref$readOnly = _ref.readOnly,
32
+ readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly;
33
+ return !publishMode ? /*#__PURE__*/jsxs("div", {
34
+ className: "lexical-scroller area-content overflow-auto",
35
+ children: [!readOnly && /*#__PURE__*/jsx("div", {
36
+ className: cn("fabric-lexicalToolbar", "sticky top-0 z-1"),
37
+ children: /*#__PURE__*/jsx(Header, {
38
+ className: "bg-default",
39
+ children: /*#__PURE__*/jsx(ToolbarPlugin, {})
40
+ })
41
+ }), children]
42
+ }) : children;
43
+ }
28
44
 
29
- var LexicalEditor = function LexicalEditor(_ref) {
30
- var value = _ref.value,
31
- readOnly = _ref.readOnly,
32
- publishMode = _ref.publishMode,
33
- onChange = _ref.onChange,
34
- onDirty = _ref.onDirty;
35
- var editorRef = useRef();
45
+ /**
46
+ * LexicalEditor component is a rich text editor built using Lexical.
47
+ * It supports various features such as code highlighting, lists, tables, and sticky notes.
48
+ * It provides a customizable toolbar and handles editor state changes.
49
+ * It also supports drag-and-drop functionality for blocks.
50
+ * It can be used in both read-only and editable modes, and supports publishing mode for exporting content.
51
+ * It uses a custom theme and provides error handling for Lexical updates.
52
+ *
53
+ * @example
54
+ * ```jsx
55
+ * <LexicalEditor
56
+ * value={initialValue}
57
+ * readOnly={false}
58
+ * publishMode={false}
59
+ * onChange={(value) => console.log("Editor value changed:", value)}
60
+ * onDirty={(isDirty) => console.log("Editor is dirty:", isDirty)}
61
+ * />
62
+ * ```
63
+ * @see {@link https://lexical.dev/docs/}
64
+ */
65
+ function LexicalEditor(_ref2) {
66
+ var value = _ref2.value,
67
+ readOnly = _ref2.readOnly,
68
+ publishMode = _ref2.publishMode,
69
+ header = _ref2.header,
70
+ footer = _ref2.footer,
71
+ coverPage = _ref2.coverPage,
72
+ isRtl = _ref2.isRtl,
73
+ _ref2$username = _ref2.username,
74
+ username = _ref2$username === void 0 ? "Guest" : _ref2$username,
75
+ _ref2$nodes = _ref2.nodes,
76
+ nodes = _ref2$nodes === void 0 ? EMPTY_ARRAY : _ref2$nodes,
77
+ onChange = _ref2.onChange,
78
+ onDirty = _ref2.onDirty;
79
+ var editorRef = useRef(null);
36
80
  var _useState = useState(null),
37
81
  _useState2 = _slicedToArray(_useState, 2),
38
82
  editorContainer = _useState2[0],
@@ -46,10 +90,9 @@ var LexicalEditor = function LexicalEditor(_ref) {
46
90
  };
47
91
  var initEditor = useCallback(function (editor) {
48
92
  editorRef.current = editor;
49
- var handler = debounce(function (_ref2) {
50
- var editorState = _ref2.editorState,
51
- dirtyElements = _ref2.dirtyElements;
52
- _ref2.dirtyLeaves;
93
+ var handler = debounce(function (_ref3) {
94
+ var editorState = _ref3.editorState,
95
+ dirtyElements = _ref3.dirtyElements;
53
96
  editorState.read(function () {
54
97
  if (dirtyElements.size > 0) {
55
98
  onDirty === null || onDirty === void 0 || onDirty(true);
@@ -75,11 +118,11 @@ var LexicalEditor = function LexicalEditor(_ref) {
75
118
  // COMMAND_PRIORITY_HIGH,
76
119
  // ),
77
120
  // );
78
-
79
121
  return function () {
80
122
  handle === null || handle === void 0 || handle();
81
123
  // cb?.();
82
124
  };
125
+ // eslint-disable-next-line @eslint-react/exhaustive-deps
83
126
  }, []);
84
127
  useEffect(function () {
85
128
  var _editorRef$current, _editorRef$current2;
@@ -88,9 +131,14 @@ var LexicalEditor = function LexicalEditor(_ref) {
88
131
  useEffect(function () {
89
132
  var _editorRef$current3;
90
133
  (_editorRef$current3 = editorRef.current) === null || _editorRef$current3 === void 0 || _editorRef$current3.registerRootListener(function (rootElement) {
91
- rootElement && setTimeout(function () {
92
- return rootElement.contentEditable = "".concat(!readOnly && !publishMode);
93
- }, 100);
134
+ if (rootElement) {
135
+ var tmr = setTimeout(function () {
136
+ return rootElement.contentEditable = "".concat(!readOnly && !publishMode);
137
+ }, 100);
138
+ return function () {
139
+ clearTimeout(tmr);
140
+ };
141
+ }
94
142
  });
95
143
  }, [readOnly, publishMode]);
96
144
  var initialConfig = useMemo(function () {
@@ -99,23 +147,12 @@ var LexicalEditor = function LexicalEditor(_ref) {
99
147
  namespace: "MyEditor",
100
148
  editable: !readOnly && !publishMode,
101
149
  theme: LexicalTheme,
102
- nodes: [QuoteNode, HeadingNode, CodeHighlightNode, CodeNode, ListItemNode, ListNode, TableCellNode, TableNode, TableRowNode, StickyNode],
150
+ nodes: [QuoteNode, HeadingNode, CodeHighlightNode, CodeNode, ListItemNode, ListNode, TableCellNode, TableNode, TableRowNode].concat(_toConsumableArray(nodes)),
103
151
  onError: onError
104
152
  };
105
- }, []);
106
- var Wrapper = useCallback(function (_ref3) {
107
- var children = _ref3.children;
108
- return !publishMode ? /*#__PURE__*/jsxs("div", {
109
- className: "lexical-scroller area-content overflow-auto",
110
- children: [/*#__PURE__*/jsx("div", {
111
- className: classNames(classes.lexicalToolbar, "sticky top-0 z-1"),
112
- children: /*#__PURE__*/jsx(Header, {
113
- className: "bg-base",
114
- children: /*#__PURE__*/jsx(ToolbarPlugin, {})
115
- })
116
- }), children]
117
- }) : children;
118
- }, [publishMode]);
153
+ },
154
+ // eslint-disable-next-line @eslint-react/exhaustive-deps
155
+ []);
119
156
  return /*#__PURE__*/jsx(ErrorBoundary, {
120
157
  children: /*#__PURE__*/jsx(LexicalComposer, {
121
158
  initialConfig: initialConfig,
@@ -124,7 +161,8 @@ var LexicalEditor = function LexicalEditor(_ref) {
124
161
  colorScheme: "light",
125
162
  children: /*#__PURE__*/jsxs("div", {
126
163
  role: "none",
127
- className: classNames(classes.lexicalEditor, "lexical-container relative bg-white min-h-full mx-auto shadow-md print:shadow-none"),
164
+ className: cn("fabric-lexicalEditor", "lexical-container relative bg-white min-h-full mx-auto shadow-md print:shadow-none"),
165
+ dir: isRtl ? "rtl" : "ltr",
128
166
  onDragOver: function onDragOver(e) {
129
167
  return e.stopPropagation();
130
168
  },
@@ -132,25 +170,40 @@ var LexicalEditor = function LexicalEditor(_ref) {
132
170
  return e.stopPropagation();
133
171
  },
134
172
  ref: setEditorContainer,
135
- children: [/*#__PURE__*/jsx(RichTextPlugin, {
173
+ children: [!publishMode && header && /*#__PURE__*/jsx("div", {
174
+ className: "editor-header",
175
+ children: header
176
+ }), coverPage && /*#__PURE__*/jsx("div", {
177
+ className: "editor-cover px-[2cm] py-[1cm]",
178
+ children: coverPage
179
+ }), /*#__PURE__*/jsx(RichTextPlugin, {
136
180
  contentEditable: /*#__PURE__*/jsx(ContentEditable, {
137
- className: "lexical-editor px-[2cm] py-[1cm] min-h-screen"
181
+ readOnly: !!readOnly || publishMode,
182
+ className: "lexical-editor min-h-screen px-[2cm] py-[1cm]"
138
183
  }),
139
184
  placeholder: /*#__PURE__*/jsx("div", {
140
185
  className: "text-muted overflow-hidden absolute mt-6 top-[1cm] left-[2cm] select-none pointer-events-none",
141
186
  children: "Enter some text..."
142
187
  }),
143
188
  ErrorBoundary: LexicalErrorBoundary
144
- }), /*#__PURE__*/jsx(ListPlugin, {}), /*#__PURE__*/jsx(CheckListPlugin, {}), /*#__PURE__*/jsx(TablePlugin, {}), /*#__PURE__*/jsx(HistoryPlugin, {}), /*#__PURE__*/jsx(StickyPlugin, {}), /*#__PURE__*/jsx(AutoFocusPlugin, {
189
+ }), /*#__PURE__*/jsx(ListPlugin, {}), /*#__PURE__*/jsx(CheckListPlugin, {}), /*#__PURE__*/jsx(TablePlugin, {}), /*#__PURE__*/jsx(HistoryPlugin, {}), /*#__PURE__*/jsx(AutoFocusPlugin, {
145
190
  defaultSelection: "rootStart"
146
191
  }), editorContainer && /*#__PURE__*/jsx(DraggableBlockPlugin, {
147
- anchorElem: editorContainer
192
+ anchorElem: editorContainer,
193
+ isEditable: !readOnly && !publishMode
194
+ }), editorContainer && /*#__PURE__*/jsx(CommentPlugin, {
195
+ username: username,
196
+ anchorElem: editorContainer,
197
+ isPublishMode: !!publishMode
198
+ }), !publishMode && footer && /*#__PURE__*/jsx("div", {
199
+ className: "editor-footer",
200
+ children: footer
148
201
  })]
149
202
  })
150
203
  })
151
204
  })
152
205
  })
153
206
  });
154
- };
207
+ }
155
208
 
156
209
  export { LexicalEditor };