@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.
- package/{src/editor/Lexical.module.css → css/_lexical.css} +8 -4
- package/css/styles.css +24 -0
- package/dist/cjs/{packages/lexical/src/components → components}/StickyComponent.js +3 -4
- package/dist/cjs/{packages/lexical/src/editor → editor}/LexicalEditor.js +35 -10
- package/dist/cjs/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +154 -145
- package/dist/cjs/i18n/ar.json.js +24 -0
- package/dist/cjs/i18n/en.json.js +24 -0
- package/dist/cjs/i18n/index.js +33 -0
- package/dist/cjs/{packages/lexical/src/index.js → index.js} +1 -0
- package/dist/cjs/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +5 -5
- package/dist/cjs/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +55 -34
- package/dist/esm/{packages/lexical/src/components → components}/StickyComponent.js +3 -4
- package/dist/esm/{packages/lexical/src/editor → editor}/LexicalEditor.js +34 -9
- package/dist/esm/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +102 -93
- package/dist/esm/i18n/ar.json.js +21 -0
- package/dist/esm/i18n/en.json.js +21 -0
- package/dist/esm/i18n/index.js +33 -0
- package/dist/esm/{packages/lexical/src/index.js → index.js} +1 -0
- package/dist/esm/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +2 -2
- package/dist/esm/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +56 -35
- package/dist/types/editor/LexicalEditor.d.ts +25 -0
- package/dist/types/hooks/useFormatWatcher.d.ts +3 -2
- package/dist/types/i18n/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/nodes/StickyNode.d.ts +0 -1
- package/package.json +14 -13
- package/src/components/StickyComponent.tsx +4 -5
- package/src/editor/LexicalEditor.tsx +57 -26
- package/src/hooks/useFormatWatcher.ts +38 -31
- package/src/i18n/ar.json +16 -0
- package/src/i18n/en.json +16 -0
- package/src/i18n/index.ts +28 -0
- package/src/index.ts +2 -0
- package/src/plugins/ToolbarPlugin.tsx +56 -35
- package/dist/cjs/_virtual/prism.js +0 -5
- package/dist/cjs/editor/Lexical.module.css +0 -1
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -432
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -21
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -27
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +0 -1139
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.js +0 -25
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +0 -50
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +0 -245
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.js +0 -19
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +0 -18
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +0 -471
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.js +0 -17
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +0 -24
- package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +0 -1275
- package/dist/cjs/node_modules/@lexical/list/LexicalList.js +0 -29
- package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +0 -29
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -789
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.js +0 -29
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -26
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -976
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +0 -35
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -35
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +0 -2792
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.js +0 -23
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +0 -55
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -888
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +0 -35
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -66
- package/dist/cjs/node_modules/@mdi/js/mdi.js +0 -8
- package/dist/cjs/node_modules/prismjs/components/prism-c.js +0 -82
- package/dist/cjs/node_modules/prismjs/components/prism-clike.js +0 -33
- package/dist/cjs/node_modules/prismjs/components/prism-cpp.js +0 -101
- package/dist/cjs/node_modules/prismjs/components/prism-css.js +0 -66
- package/dist/cjs/node_modules/prismjs/components/prism-java.js +0 -126
- package/dist/cjs/node_modules/prismjs/components/prism-javascript.js +0 -174
- package/dist/cjs/node_modules/prismjs/components/prism-markdown.js +0 -417
- package/dist/cjs/node_modules/prismjs/components/prism-markup.js +0 -188
- package/dist/cjs/node_modules/prismjs/components/prism-objectivec.js +0 -14
- package/dist/cjs/node_modules/prismjs/components/prism-powershell.js +0 -60
- package/dist/cjs/node_modules/prismjs/components/prism-python.js +0 -67
- package/dist/cjs/node_modules/prismjs/components/prism-rust.js +0 -130
- package/dist/cjs/node_modules/prismjs/components/prism-sql.js +0 -34
- package/dist/cjs/node_modules/prismjs/components/prism-swift.js +0 -150
- package/dist/cjs/node_modules/prismjs/components/prism-typescript.js +0 -62
- package/dist/cjs/node_modules/prismjs/prism.js +0 -1951
- package/dist/esm/_virtual/prism.js +0 -5
- package/dist/esm/editor/Lexical.module.css +0 -1
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -423
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -19
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -18
- package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +0 -1121
- package/dist/esm/node_modules/@lexical/code/LexicalCode.js +0 -21
- package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +0 -32
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +0 -244
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.js +0 -18
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +0 -17
- package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +0 -463
- package/dist/esm/node_modules/@lexical/link/LexicalLink.js +0 -17
- package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +0 -16
- package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +0 -1262
- package/dist/esm/node_modules/@lexical/list/LexicalList.js +0 -23
- package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +0 -16
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -781
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.js +0 -23
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -18
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -957
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +0 -26
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -16
- package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +0 -2754
- package/dist/esm/node_modules/@lexical/table/LexicalTable.js +0 -20
- package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +0 -17
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -839
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +0 -26
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -17
- package/dist/esm/node_modules/@mdi/js/mdi.js +0 -7
- package/dist/esm/node_modules/prismjs/components/prism-c.js +0 -82
- package/dist/esm/node_modules/prismjs/components/prism-clike.js +0 -33
- package/dist/esm/node_modules/prismjs/components/prism-cpp.js +0 -101
- package/dist/esm/node_modules/prismjs/components/prism-css.js +0 -66
- package/dist/esm/node_modules/prismjs/components/prism-java.js +0 -126
- package/dist/esm/node_modules/prismjs/components/prism-javascript.js +0 -174
- package/dist/esm/node_modules/prismjs/components/prism-markdown.js +0 -417
- package/dist/esm/node_modules/prismjs/components/prism-markup.js +0 -188
- package/dist/esm/node_modules/prismjs/components/prism-objectivec.js +0 -14
- package/dist/esm/node_modules/prismjs/components/prism-powershell.js +0 -60
- package/dist/esm/node_modules/prismjs/components/prism-python.js +0 -67
- package/dist/esm/node_modules/prismjs/components/prism-rust.js +0 -130
- package/dist/esm/node_modules/prismjs/components/prism-sql.js +0 -34
- package/dist/esm/node_modules/prismjs/components/prism-swift.js +0 -150
- package/dist/esm/node_modules/prismjs/components/prism-typescript.js +0 -62
- package/dist/esm/node_modules/prismjs/prism.js +0 -1951
- /package/dist/cjs/{packages/lexical/src/editor → editor}/theme.js +0 -0
- /package/dist/cjs/{packages/lexical/src/nodes → nodes}/StickyNode.js +0 -0
- /package/dist/cjs/{packages/lexical/src/plugins → plugins}/StickyPlugin.js +0 -0
- /package/dist/cjs/{packages/lexical/src/utils → utils}/index.js +0 -0
- /package/dist/esm/{packages/lexical/src/editor → editor}/theme.js +0 -0
- /package/dist/esm/{packages/lexical/src/nodes → nodes}/StickyNode.js +0 -0
- /package/dist/esm/{packages/lexical/src/plugins → plugins}/StickyPlugin.js +0 -0
- /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:
|
|
29
|
-
code:
|
|
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:
|
|
34
|
-
number:
|
|
35
|
-
quote:
|
|
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:
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
271
|
+
icon: "icon-[mdi--format-clear]",
|
|
251
272
|
onClick: function onClick() {
|
|
252
273
|
return watch.clearFormatting();
|
|
253
274
|
}
|
|
254
|
-
})
|
|
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:
|
|
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:
|
|
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 '
|
|
5
|
-
import { ListItemNode, ListNode } from '
|
|
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 '
|
|
16
|
-
import { TableCellNode, TableNode, TableRowNode } from '
|
|
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(
|
|
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(
|
|
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 '
|
|
7
|
-
import { $isLinkNode } from '
|
|
8
|
-
import { $isListNode, ListNode, INSERT_UNORDERED_LIST_COMMAND, REMOVE_LIST_COMMAND, INSERT_CHECK_LIST_COMMAND, INSERT_ORDERED_LIST_COMMAND } from '
|
|
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 '
|
|
11
|
-
import { $isParentElementRTL, $getSelectionStyleValueForProperty, $patchStyleText, $setBlocksType, $isAtNodeEnd } from '
|
|
12
|
-
import { $isTableNode } from '
|
|
13
|
-
import { $findMatchingParent, $getNearestNodeOfType, mergeRegister, $getNearestBlockElementAncestorOrThrow } from '
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
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(
|
|
55
|
+
var _useState3 = useState(),
|
|
58
56
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var _useState5 = useState("
|
|
57
|
+
currentSelection = _useState4[0],
|
|
58
|
+
setCurrentSelection = _useState4[1];
|
|
59
|
+
var _useState5 = useState("paragraph"),
|
|
62
60
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
var _useState7 = useState(
|
|
61
|
+
blockType = _useState6[0],
|
|
62
|
+
setBlockType = _useState6[1];
|
|
63
|
+
var _useState7 = useState("root"),
|
|
66
64
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
var _useState9 = useState(
|
|
65
|
+
rootType = _useState8[0],
|
|
66
|
+
setRootType = _useState8[1];
|
|
67
|
+
var _useState9 = useState(null),
|
|
70
68
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
var _useState11 = useState("
|
|
69
|
+
selectedElementKey = _useState10[0],
|
|
70
|
+
setSelectedElementKey = _useState10[1];
|
|
71
|
+
var _useState11 = useState("16"),
|
|
74
72
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
var _useState13 = useState("#
|
|
73
|
+
fontSize = _useState12[0],
|
|
74
|
+
setFontSize = _useState12[1];
|
|
75
|
+
var _useState13 = useState("#000"),
|
|
78
76
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
var _useState15 = useState("
|
|
77
|
+
fontColor = _useState14[0],
|
|
78
|
+
setFontColor = _useState14[1];
|
|
79
|
+
var _useState15 = useState("#fff"),
|
|
82
80
|
_useState16 = _slicedToArray(_useState15, 2),
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
var _useState17 = useState(
|
|
81
|
+
bgColor = _useState16[0],
|
|
82
|
+
setBgColor = _useState16[1];
|
|
83
|
+
var _useState17 = useState("Arial"),
|
|
86
84
|
_useState18 = _slicedToArray(_useState17, 2),
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
var _useState19 = useState(
|
|
85
|
+
fontFamily = _useState18[0],
|
|
86
|
+
setFontFamily = _useState18[1];
|
|
87
|
+
var _useState19 = useState(""),
|
|
90
88
|
_useState20 = _slicedToArray(_useState19, 2),
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
align = _useState20[0],
|
|
90
|
+
setAlign = _useState20[1];
|
|
93
91
|
var _useState21 = useState(false),
|
|
94
92
|
_useState22 = _slicedToArray(_useState21, 2),
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
isLink = _useState22[0],
|
|
94
|
+
setIsLink = _useState22[1];
|
|
97
95
|
var _useState23 = useState(false),
|
|
98
96
|
_useState24 = _slicedToArray(_useState23, 2),
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
isBold = _useState24[0],
|
|
98
|
+
setIsBold = _useState24[1];
|
|
101
99
|
var _useState25 = useState(false),
|
|
102
100
|
_useState26 = _slicedToArray(_useState25, 2),
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
isItalic = _useState26[0],
|
|
102
|
+
setIsItalic = _useState26[1];
|
|
105
103
|
var _useState27 = useState(false),
|
|
106
104
|
_useState28 = _slicedToArray(_useState27, 2),
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
isUnderline = _useState28[0],
|
|
106
|
+
setIsUnderline = _useState28[1];
|
|
109
107
|
var _useState29 = useState(false),
|
|
110
108
|
_useState30 = _slicedToArray(_useState29, 2),
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
isStrikethrough = _useState30[0],
|
|
110
|
+
setIsStrikethrough = _useState30[1];
|
|
113
111
|
var _useState31 = useState(false),
|
|
114
112
|
_useState32 = _slicedToArray(_useState31, 2),
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
isSubscript = _useState32[0],
|
|
114
|
+
setIsSubscript = _useState32[1];
|
|
117
115
|
var _useState33 = useState(false),
|
|
118
116
|
_useState34 = _slicedToArray(_useState33, 2),
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
isSuperscript = _useState34[0],
|
|
118
|
+
setIsSuperscript = _useState34[1];
|
|
121
119
|
var _useState35 = useState(false),
|
|
122
120
|
_useState36 = _slicedToArray(_useState35, 2),
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
isCode = _useState36[0],
|
|
122
|
+
setIsCode = _useState36[1];
|
|
125
123
|
var _useState37 = useState(false),
|
|
126
124
|
_useState38 = _slicedToArray(_useState37, 2),
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
var _useState39 = useState(
|
|
125
|
+
canUndo = _useState38[0],
|
|
126
|
+
setCanUndo = _useState38[1];
|
|
127
|
+
var _useState39 = useState(false),
|
|
130
128
|
_useState40 = _slicedToArray(_useState39, 2),
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
var _useState41 = useState(
|
|
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
|
-
|
|
137
|
-
isEditable =
|
|
138
|
-
setIsEditable =
|
|
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
|
-
|
|
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",
|
|
198
|
-
|
|
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
|
-
}, [
|
|
216
|
+
}, []);
|
|
202
217
|
useEffect(function () {
|
|
203
|
-
return editor.registerCommand(
|
|
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
|
-
|
|
226
|
+
activeEditor.getEditorState().read(function () {
|
|
210
227
|
$updateToolbar();
|
|
211
|
-
|
|
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
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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 (
|
|
375
|
-
|
|
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 (
|
|
383
|
-
|
|
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 };
|