@react-fabric/lexical 1.0.0-beta.8 → 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
@@ -23,17 +23,48 @@
23
23
 
24
24
  /* stylelint-disable custom-property-pattern */
25
25
 
26
- @layer util {
27
- .lexicalEditor,
28
- .lexicalToolbar {
26
+ @layer utilities {
27
+ [dir="rtl"] .fabric-lexicalEditor * {
28
+ text-align: start;
29
+ }
30
+
31
+ .fabric-lexicalEditor,
32
+ .fabric-lexicalToolbar {
29
33
  width: 21cm;
30
34
  margin: 0 auto;
35
+
36
+ .fabric-inputWrapper {
37
+ outline: none;
38
+
39
+ button > div {
40
+ outline: 1px solid var(--border-color-soft);
41
+ }
42
+ }
31
43
  }
32
44
 
33
- .lexicalEditor :global {
45
+ .fabric-lexicalEditor {
46
+ .editor-cover {
47
+ position: relative;
48
+ break-after: page;
49
+
50
+ &::after {
51
+ content: "page break";
52
+
53
+ position: absolute;
54
+ inset-inline: 0;
55
+ bottom: 0;
56
+
57
+ border-bottom: 1px dashed #ccc;
58
+
59
+ font-size: 11px;
60
+ line-height: 0;
61
+ color: #ccc;
62
+ text-align: center;
63
+ }
64
+ }
65
+
34
66
  .editor-container.editor-container.editor-container {
35
- /* stylelint-disable-next-line font-family-no-missing-generic-family-keyword */
36
- font-family: "Sakkal Majalla";
67
+ font-family: "Noto Sans Kufi Arabic", "Noto Sans", Arial, sans-serif;
37
68
  font-size: 18px;
38
69
  color: #0f172a;
39
70
  background-color: #fff;
@@ -83,13 +114,12 @@
83
114
  margin-top: 1.5em;
84
115
  margin-bottom: 1.5em;
85
116
  padding-inline-start: 1em;
117
+ border-color: #64748b;
118
+ border-inline-start-width: 4px;
86
119
 
87
120
  font-size: 1.125em;
88
121
  line-height: 1.5;
89
122
  color: #1e293b;
90
-
91
- border-color: #64748b;
92
- border-inline-start-width: 4px;
93
123
  }
94
124
 
95
125
  .editor-code {
@@ -98,13 +128,13 @@
98
128
  margin-top: 1.5em;
99
129
  margin-bottom: 1.5em;
100
130
  padding: 1em;
131
+ border-inline-start-width: 4px;
101
132
 
102
133
  font-size: 1.125em;
103
134
  line-height: 1.5;
104
135
  color: #1e293b;
105
136
 
106
137
  background-color: #e2e8f0;
107
- border-inline-start-width: 4px;
108
138
  }
109
139
 
110
140
  .editor-textUnderline {
@@ -120,11 +150,11 @@
120
150
  }
121
151
 
122
152
  .editor-page-break {
123
- page-break-after: always;
153
+ break-after: always;
124
154
  }
125
155
 
126
156
  .editor-no-break {
127
- page-break-inside: avoid;
157
+ break-inside: avoid;
128
158
  }
129
159
 
130
160
  .editor-textSmall {
@@ -158,6 +188,43 @@
158
188
  text-align: start;
159
189
  }
160
190
 
191
+ .editor-comment {
192
+ width: 100%;
193
+ padding: 0.25em 0.5em;
194
+ border: 2px solid var(--color-marigold-200);
195
+
196
+ font-size: 0.825rem;
197
+ font-weight: initial;
198
+ font-style: initial;
199
+
200
+ background-color: --alpha(var(--color-marigold-100) / 50%);
201
+ }
202
+
203
+ .editor-comment-hilight {
204
+ outline: 2px solid var(--color-marigold-300);
205
+ outline-offset: 8px;
206
+ transition: outline-offset ease 2s;
207
+ }
208
+
209
+ .editor-has-comment::before {
210
+ cursor: pointer;
211
+ content: " ";
212
+
213
+ position: absolute;
214
+ inset-inline-start: 1.5cm;
215
+
216
+ display: inline-block;
217
+
218
+ width: 1rem;
219
+ height: 1rem;
220
+ border-radius: 1rem;
221
+
222
+ opacity: 0.5;
223
+ background-color: var(--color-marigold-700);
224
+
225
+ mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1em' height='1em' viewBox='0 0 24 24'%3E%3C!-- Icon from Material Design Icons by Pictogrammers - https://github.com/Templarian/MaterialDesign/blob/master/LICENSE --%3E%3Cpath fill='currentColor' d='M9 22a1 1 0 0 1-1-1v-3H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6.1l-3.7 3.71c-.2.19-.45.29-.7.29zm1-6v3.08L13.08 16H20V4H4v12zM6 7h12v2H6zm0 4h9v2H6z'/%3E%3C/svg%3E");
226
+ }
227
+
161
228
  @media print {
162
229
  html,
163
230
  body {
@@ -195,7 +262,6 @@
195
262
  margin: 0 auto;
196
263
 
197
264
  background-image: inherit;
198
-
199
265
  -webkit-print-color-adjust: exact;
200
266
  print-color-adjust: exact;
201
267
  }
package/css/styles.css ADDED
@@ -0,0 +1,24 @@
1
+ /*
2
+ * React Fabric
3
+ * @version: 1.0.0
4
+ *
5
+ *
6
+ * The MIT License (MIT)
7
+ * Copyright (c) 2025 Adarsh Pastakia
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
10
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
11
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
12
+ * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
13
+ * subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all copies or substantial
16
+ * portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19
+ * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ @import "./_lexical.css";
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
3
4
  var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
4
- var LexicalCode = require('../../../../node_modules/@lexical/code/LexicalCode.js');
5
- var LexicalList = require('../../../../node_modules/@lexical/list/LexicalList.js');
5
+ var code = require('@lexical/code');
6
+ var list = require('@lexical/list');
6
7
  var LexicalAutoFocusPlugin = require('@lexical/react/LexicalAutoFocusPlugin');
7
8
  var LexicalCheckListPlugin = require('@lexical/react/LexicalCheckListPlugin');
8
9
  var LexicalComposer = require('@lexical/react/LexicalComposer');
@@ -12,27 +13,70 @@ var LexicalHistoryPlugin = require('@lexical/react/LexicalHistoryPlugin');
12
13
  var LexicalListPlugin = require('@lexical/react/LexicalListPlugin');
13
14
  var LexicalRichTextPlugin = require('@lexical/react/LexicalRichTextPlugin');
14
15
  var LexicalTablePlugin = require('@lexical/react/LexicalTablePlugin');
15
- var LexicalRichText = require('../../../../node_modules/@lexical/rich-text/LexicalRichText.js');
16
- var LexicalTable = require('../../../../node_modules/@lexical/table/LexicalTable.js');
16
+ var richText = require('@lexical/rich-text');
17
+ var table = require('@lexical/table');
17
18
  var core = require('@react-fabric/core');
18
19
  var utilities = require('@react-fabric/utilities');
19
- var classNames = require('classnames');
20
20
  var react = require('react');
21
- var StickyNode = require('../nodes/StickyNode.js');
21
+ var CommentPlugin = require('../plugins/CommentPlugin.js');
22
22
  var DraggableBlockPlugin = require('../plugins/DraggableBlockPlugin.js');
23
- var StickyPlugin = require('../plugins/StickyPlugin.js');
24
- var Lexical_module = require('./Lexical.module.css');
25
- var theme = require('./theme.js');
26
23
  var ToolbarPlugin = require('../plugins/ToolbarPlugin.js');
24
+ var theme = require('./theme.js');
27
25
  var jsxRuntime = require('react/jsx-runtime');
28
26
 
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 = react.useRef();
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__*/jsxRuntime.jsxs("div", {
34
+ className: "lexical-scroller area-content overflow-auto",
35
+ children: [!readOnly && /*#__PURE__*/jsxRuntime.jsx("div", {
36
+ className: utilities.cn("fabric-lexicalToolbar", "sticky top-0 z-1"),
37
+ children: /*#__PURE__*/jsxRuntime.jsx(core.Header, {
38
+ className: "bg-default",
39
+ children: /*#__PURE__*/jsxRuntime.jsx(ToolbarPlugin.ToolbarPlugin, {})
40
+ })
41
+ }), children]
42
+ }) : children;
43
+ }
44
+
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 ? utilities.EMPTY_ARRAY : _ref2$nodes,
77
+ onChange = _ref2.onChange,
78
+ onDirty = _ref2.onDirty;
79
+ var editorRef = react.useRef(null);
36
80
  var _useState = react.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 = react.useCallback(function (editor) {
48
92
  editorRef.current = editor;
49
- var handler = utilities.debounce(function (_ref2) {
50
- var editorState = _ref2.editorState,
51
- dirtyElements = _ref2.dirtyElements;
52
- _ref2.dirtyLeaves;
93
+ var handler = utilities.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
  react.useEffect(function () {
85
128
  var _editorRef$current, _editorRef$current2;
@@ -88,9 +131,14 @@ var LexicalEditor = function LexicalEditor(_ref) {
88
131
  react.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 = react.useMemo(function () {
@@ -99,23 +147,12 @@ var LexicalEditor = function LexicalEditor(_ref) {
99
147
  namespace: "MyEditor",
100
148
  editable: !readOnly && !publishMode,
101
149
  theme: theme.LexicalTheme,
102
- nodes: [LexicalRichText.QuoteNode, LexicalRichText.HeadingNode, LexicalCode.CodeHighlightNode, LexicalCode.CodeNode, LexicalList.ListItemNode, LexicalList.ListNode, LexicalTable.TableCellNode, LexicalTable.TableNode, LexicalTable.TableRowNode, StickyNode.StickyNode],
150
+ nodes: [richText.QuoteNode, richText.HeadingNode, code.CodeHighlightNode, code.CodeNode, list.ListItemNode, list.ListNode, table.TableCellNode, table.TableNode, table.TableRowNode].concat(_toConsumableArray(nodes)),
103
151
  onError: onError
104
152
  };
105
- }, []);
106
- var Wrapper = react.useCallback(function (_ref3) {
107
- var children = _ref3.children;
108
- return !publishMode ? /*#__PURE__*/jsxRuntime.jsxs("div", {
109
- className: "lexical-scroller area-content overflow-auto",
110
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
111
- className: classNames(Lexical_module.lexicalToolbar, "sticky top-0 z-1"),
112
- children: /*#__PURE__*/jsxRuntime.jsx(core.Header, {
113
- className: "bg-base",
114
- children: /*#__PURE__*/jsxRuntime.jsx(ToolbarPlugin.ToolbarPlugin, {})
115
- })
116
- }), children]
117
- }) : children;
118
- }, [publishMode]);
153
+ },
154
+ // eslint-disable-next-line @eslint-react/exhaustive-deps
155
+ []);
119
156
  return /*#__PURE__*/jsxRuntime.jsx(core.ErrorBoundary, {
120
157
  children: /*#__PURE__*/jsxRuntime.jsx(LexicalComposer.LexicalComposer, {
121
158
  initialConfig: initialConfig,
@@ -124,7 +161,8 @@ var LexicalEditor = function LexicalEditor(_ref) {
124
161
  colorScheme: "light",
125
162
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
126
163
  role: "none",
127
- className: classNames(Lexical_module.lexicalEditor, "lexical-container relative bg-white min-h-full mx-auto shadow-md print:shadow-none"),
164
+ className: utilities.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__*/jsxRuntime.jsx(LexicalRichTextPlugin.RichTextPlugin, {
173
+ children: [!publishMode && header && /*#__PURE__*/jsxRuntime.jsx("div", {
174
+ className: "editor-header",
175
+ children: header
176
+ }), coverPage && /*#__PURE__*/jsxRuntime.jsx("div", {
177
+ className: "editor-cover px-[2cm] py-[1cm]",
178
+ children: coverPage
179
+ }), /*#__PURE__*/jsxRuntime.jsx(LexicalRichTextPlugin.RichTextPlugin, {
136
180
  contentEditable: /*#__PURE__*/jsxRuntime.jsx(LexicalContentEditable.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__*/jsxRuntime.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.LexicalErrorBoundary
144
- }), /*#__PURE__*/jsxRuntime.jsx(LexicalListPlugin.ListPlugin, {}), /*#__PURE__*/jsxRuntime.jsx(LexicalCheckListPlugin.CheckListPlugin, {}), /*#__PURE__*/jsxRuntime.jsx(LexicalTablePlugin.TablePlugin, {}), /*#__PURE__*/jsxRuntime.jsx(LexicalHistoryPlugin.HistoryPlugin, {}), /*#__PURE__*/jsxRuntime.jsx(StickyPlugin.StickyPlugin, {}), /*#__PURE__*/jsxRuntime.jsx(LexicalAutoFocusPlugin.AutoFocusPlugin, {
189
+ }), /*#__PURE__*/jsxRuntime.jsx(LexicalListPlugin.ListPlugin, {}), /*#__PURE__*/jsxRuntime.jsx(LexicalCheckListPlugin.CheckListPlugin, {}), /*#__PURE__*/jsxRuntime.jsx(LexicalTablePlugin.TablePlugin, {}), /*#__PURE__*/jsxRuntime.jsx(LexicalHistoryPlugin.HistoryPlugin, {}), /*#__PURE__*/jsxRuntime.jsx(LexicalAutoFocusPlugin.AutoFocusPlugin, {
145
190
  defaultSelection: "rootStart"
146
191
  }), editorContainer && /*#__PURE__*/jsxRuntime.jsx(DraggableBlockPlugin.DraggableBlockPlugin, {
147
- anchorElem: editorContainer
192
+ anchorElem: editorContainer,
193
+ isEditable: !readOnly && !publishMode
194
+ }), editorContainer && /*#__PURE__*/jsxRuntime.jsx(CommentPlugin.CommentPlugin, {
195
+ username: username,
196
+ anchorElem: editorContainer,
197
+ isPublishMode: !!publishMode
198
+ }), !publishMode && footer && /*#__PURE__*/jsxRuntime.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
  exports.LexicalEditor = LexicalEditor;