@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
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
var tool = {
|
|
4
|
+
alignStart: "Align Start",
|
|
5
|
+
alignCenter: "Align Center",
|
|
6
|
+
alignEnd: "Align End",
|
|
7
|
+
alignJustify: "Align Justify",
|
|
8
|
+
bold: "Bold",
|
|
9
|
+
italic: "Italic",
|
|
10
|
+
underline: "Underline",
|
|
11
|
+
strikethrough: "Strikethrough",
|
|
12
|
+
indentOut: "Indent Out",
|
|
13
|
+
indentIn: "Indent In",
|
|
14
|
+
hilight: "Highlight",
|
|
15
|
+
clear: "Clear Formatting"
|
|
16
|
+
};
|
|
17
|
+
var en = {
|
|
18
|
+
tool: tool
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { en as default, tool };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { addTranslationBundle } from '@react-fabric/core';
|
|
4
|
+
import ar from './ar.json.js';
|
|
5
|
+
import en from './en.json.js';
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* React Fabric
|
|
9
|
+
* @version: 1.0.0
|
|
10
|
+
*
|
|
11
|
+
*
|
|
12
|
+
* The MIT License (MIT)
|
|
13
|
+
* Copyright (c) 2024 Adarsh Pastakia
|
|
14
|
+
*
|
|
15
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
16
|
+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
17
|
+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
18
|
+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
19
|
+
* subject to the following conditions:
|
|
20
|
+
*
|
|
21
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
22
|
+
* portions of the Software.
|
|
23
|
+
*
|
|
24
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
25
|
+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
26
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
27
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
addTranslationBundle("lexical", {
|
|
31
|
+
en: en,
|
|
32
|
+
ar: ar
|
|
33
|
+
});
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
4
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
5
|
-
import { eventFiles } from '
|
|
6
|
-
import { mergeRegister } from '
|
|
5
|
+
import { eventFiles } from '@lexical/rich-text';
|
|
6
|
+
import { mergeRegister } from '@lexical/utils';
|
|
7
7
|
import { DRAGOVER_COMMAND, COMMAND_PRIORITY_LOW, DROP_COMMAND, COMMAND_PRIORITY_HIGH, $getNodeByKey, $getNearestNodeFromDOMNode, $getRoot } from 'lexical';
|
|
8
8
|
import { useRef, useState, useEffect } from 'react';
|
|
9
9
|
import { createPortal } from 'react-dom';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
4
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
5
|
-
import {
|
|
5
|
+
import { Dropdown, Button, Menu, MenuItem, Divider, ButtonGroup, ToggleButtonGroup, Icon, Tooltip } from '@react-fabric/core';
|
|
6
6
|
import { ColorInput } from '@react-fabric/form';
|
|
7
7
|
import { getValue } from '@react-fabric/utilities';
|
|
8
8
|
import { FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND } from 'lexical';
|
|
@@ -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__*/jsx(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__*/jsxs(Menu, {
|
|
@@ -114,7 +114,8 @@ var ToolbarPlugin = function ToolbarPlugin() {
|
|
|
114
114
|
children: /*#__PURE__*/jsxs(Dropdown, {
|
|
115
115
|
children: [/*#__PURE__*/jsx(Button, {
|
|
116
116
|
variant: "link",
|
|
117
|
-
altIcon:
|
|
117
|
+
altIcon: "icon-[mdi--menu-down]",
|
|
118
|
+
tabIndex: -1,
|
|
118
119
|
children: getValue(watch.fontSize + "", "16")
|
|
119
120
|
}), /*#__PURE__*/jsx(Menu, {
|
|
120
121
|
className: "hide-icons",
|
|
@@ -135,48 +136,66 @@ var ToolbarPlugin = function ToolbarPlugin() {
|
|
|
135
136
|
variant: "link",
|
|
136
137
|
children: [/*#__PURE__*/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(FORMAT_ELEMENT_COMMAND, "start");
|
|
143
148
|
}
|
|
144
149
|
}), /*#__PURE__*/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(FORMAT_ELEMENT_COMMAND, "center");
|
|
150
157
|
}
|
|
151
158
|
}), /*#__PURE__*/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(FORMAT_ELEMENT_COMMAND, "end");
|
|
158
169
|
}
|
|
159
170
|
}), /*#__PURE__*/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(FORMAT_ELEMENT_COMMAND, "justify");
|
|
166
181
|
}
|
|
167
182
|
}), /*#__PURE__*/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__*/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__*/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(FORMAT_TEXT_COMMAND, "bold");
|
|
195
215
|
}
|
|
196
216
|
}), /*#__PURE__*/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(FORMAT_TEXT_COMMAND, "italic");
|
|
202
223
|
}
|
|
203
224
|
}), /*#__PURE__*/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(FORMAT_TEXT_COMMAND, "underline");
|
|
209
231
|
}
|
|
210
232
|
}), /*#__PURE__*/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(FORMAT_TEXT_COMMAND, "strikethrough");
|
|
216
239
|
}
|
|
@@ -220,38 +243,36 @@ var ToolbarPlugin = function ToolbarPlugin() {
|
|
|
220
243
|
}), /*#__PURE__*/jsx(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__*/jsx(Icon, {
|
|
228
|
-
icon:
|
|
250
|
+
icon: "icon-[mdi--format-text]"
|
|
229
251
|
})
|
|
230
252
|
}), /*#__PURE__*/jsx(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__*/jsx(Icon, {
|
|
238
|
-
icon:
|
|
259
|
+
icon: "icon-[mdi--format-color-fill]"
|
|
239
260
|
})
|
|
240
261
|
}), /*#__PURE__*/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__*/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
|
|
|
@@ -10,4 +10,29 @@ export interface EditorProps {
|
|
|
10
10
|
onChange?: (value: KeyValue) => void;
|
|
11
11
|
onDirty?: (isDirty: boolean) => void;
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* LexicalEditor component is a rich text editor built using Lexical.
|
|
15
|
+
* It supports various features such as code highlighting, lists, tables, and sticky notes.
|
|
16
|
+
* It provides a customizable toolbar and handles editor state changes.
|
|
17
|
+
* It also supports drag-and-drop functionality for blocks.
|
|
18
|
+
* It can be used in both read-only and editable modes, and supports publishing mode for exporting content.
|
|
19
|
+
* It uses a custom theme and provides error handling for Lexical updates.
|
|
20
|
+
*
|
|
21
|
+
* @param {EditorProps} props - The properties for the LexicalEditor component.
|
|
22
|
+
* @returns {JSX.Element} The rendered LexicalEditor component.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```jsx
|
|
26
|
+
* <LexicalEditor
|
|
27
|
+
* value={initialValue}
|
|
28
|
+
* readOnly={false}
|
|
29
|
+
* publishMode={false}
|
|
30
|
+
* onChange={(value) => console.log("Editor value changed:", value)}
|
|
31
|
+
* onDirty={(isDirty) => console.log("Editor is dirty:", isDirty)}
|
|
32
|
+
* />
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/story/lexical-playground--playground}
|
|
36
|
+
* @see {@link https://lexical.dev/docs/}
|
|
37
|
+
*/
|
|
13
38
|
export declare const LexicalEditor: ({ value, readOnly, publishMode, onChange, onDirty, }: EditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -21,14 +21,15 @@ export declare const useFormatWatcher: () => {
|
|
|
21
21
|
canUndo: boolean;
|
|
22
22
|
canRedo: boolean;
|
|
23
23
|
isRTL: boolean;
|
|
24
|
+
align: string;
|
|
24
25
|
isEditable: boolean;
|
|
25
26
|
codeLanguage: string;
|
|
26
27
|
activeEditor: import("lexical").LexicalEditor;
|
|
27
28
|
indent: () => void;
|
|
28
29
|
outdent: () => void;
|
|
29
30
|
clearFormatting: () => void;
|
|
30
|
-
onFontColorSelect: (value
|
|
31
|
-
onBgColorSelect: (value
|
|
31
|
+
onFontColorSelect: (value?: string) => void;
|
|
32
|
+
onBgColorSelect: (value?: string) => void;
|
|
32
33
|
formatQuote: () => void;
|
|
33
34
|
onSizeChange: (value: string) => void;
|
|
34
35
|
formatBlock: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { DecoratorNode, type DOMConversionMap, type DOMExportOutput, type EditorConfig, type LexicalEditor, type LexicalNode, type NodeKey, type SerializedLexicalNode, type Spread } from "lexical";
|
|
3
2
|
type StickyNoteColor = "pink" | "yellow" | "green" | "blue";
|
|
4
3
|
interface StickyNodeType {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-fabric/lexical",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.61",
|
|
4
4
|
"description": "RUF: Lexical editor",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
"types": "dist/types/index.d.ts",
|
|
12
12
|
"directories": {
|
|
13
13
|
"src": "src",
|
|
14
|
+
"styles": "css",
|
|
14
15
|
"test": "tests"
|
|
15
16
|
},
|
|
16
17
|
"files": [
|
|
18
|
+
"css",
|
|
17
19
|
"src",
|
|
18
20
|
"dist"
|
|
19
21
|
],
|
|
@@ -33,23 +35,22 @@
|
|
|
33
35
|
"watch": "npm-run-all -p watch:rollup watch:dts"
|
|
34
36
|
},
|
|
35
37
|
"dependencies": {
|
|
36
|
-
"@lexical/
|
|
37
|
-
"@
|
|
38
|
-
"@react-fabric/
|
|
39
|
-
"@react-fabric/
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"lexical": "^0.17.1"
|
|
38
|
+
"@lexical/react": "~0.35.0",
|
|
39
|
+
"@react-fabric/core": "^1.0.0-beta.61",
|
|
40
|
+
"@react-fabric/form": "^1.0.0-beta.61",
|
|
41
|
+
"@react-fabric/utilities": "^1.0.0-beta.61",
|
|
42
|
+
"classnames": "~2.5.1",
|
|
43
|
+
"lexical": "~0.35.0"
|
|
43
44
|
},
|
|
44
45
|
"peerDependencies": {
|
|
45
|
-
"i18next": "
|
|
46
|
-
"react": "
|
|
47
|
-
"react-dom": "
|
|
48
|
-
"react-i18next": "
|
|
46
|
+
"i18next": "~25.6.0",
|
|
47
|
+
"react": "~19.2.0",
|
|
48
|
+
"react-dom": "~19.2.0",
|
|
49
|
+
"react-i18next": "~16.2.1"
|
|
49
50
|
},
|
|
50
51
|
"engines": {
|
|
51
52
|
"node": ">=18.12.0",
|
|
52
53
|
"npm": ">=8.19.0"
|
|
53
54
|
},
|
|
54
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "a0b0c571bf9c189fa3355bbc3b896ecc4b9d6a04"
|
|
55
56
|
}
|
|
@@ -26,10 +26,9 @@
|
|
|
26
26
|
import { AutoFocusPlugin } from "@lexical/react/LexicalAutoFocusPlugin";
|
|
27
27
|
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
28
28
|
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
29
|
-
import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary";
|
|
29
|
+
import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
|
|
30
30
|
import { LexicalNestedComposer } from "@lexical/react/LexicalNestedComposer";
|
|
31
31
|
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
32
|
-
import { mdiClose, mdiFormatColorFill } from "@mdi/js";
|
|
33
32
|
import { Icon } from "@react-fabric/core";
|
|
34
33
|
import { $getNodeByKey, createEditor, type NodeKey } from "lexical";
|
|
35
34
|
import { useEffect, useMemo, useRef } from "react";
|
|
@@ -228,7 +227,7 @@ export const StickyComponent = ({
|
|
|
228
227
|
aria-label="Change sticky note color"
|
|
229
228
|
title="Color"
|
|
230
229
|
>
|
|
231
|
-
<Icon icon=
|
|
230
|
+
<Icon icon="icon-[mdi--format-color-fill]" />
|
|
232
231
|
</button>
|
|
233
232
|
<button
|
|
234
233
|
onClick={handleDelete}
|
|
@@ -236,7 +235,7 @@ export const StickyComponent = ({
|
|
|
236
235
|
aria-label="Delete sticky note"
|
|
237
236
|
title="Delete"
|
|
238
237
|
>
|
|
239
|
-
<Icon icon=
|
|
238
|
+
<Icon icon="icon-[mdi--close]" />
|
|
240
239
|
</button>
|
|
241
240
|
</div>
|
|
242
241
|
<div className="text-sm font-semibold">{user}</div>
|
|
@@ -261,7 +260,7 @@ export const StickyComponent = ({
|
|
|
261
260
|
placeholder={
|
|
262
261
|
<div className="sticky-placeholder">Sticky note...</div>
|
|
263
262
|
}
|
|
264
|
-
ErrorBoundary={LexicalErrorBoundary}
|
|
263
|
+
ErrorBoundary={LexicalErrorBoundary as any}
|
|
265
264
|
/>
|
|
266
265
|
<AutoFocusPlugin />
|
|
267
266
|
</LexicalNestedComposer>
|
|
@@ -25,7 +25,10 @@ import { CodeHighlightNode, CodeNode } from "@lexical/code";
|
|
|
25
25
|
import { ListItemNode, ListNode } from "@lexical/list";
|
|
26
26
|
import { AutoFocusPlugin } from "@lexical/react/LexicalAutoFocusPlugin";
|
|
27
27
|
import { CheckListPlugin } from "@lexical/react/LexicalCheckListPlugin";
|
|
28
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
type InitialConfigType,
|
|
30
|
+
LexicalComposer,
|
|
31
|
+
} from "@lexical/react/LexicalComposer";
|
|
29
32
|
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
30
33
|
import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
|
|
31
34
|
import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
|
|
@@ -42,9 +45,8 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
|
42
45
|
import { StickyNode } from "../nodes/StickyNode";
|
|
43
46
|
import { DraggableBlockPlugin } from "../plugins/DraggableBlockPlugin";
|
|
44
47
|
import { StickyPlugin } from "../plugins/StickyPlugin";
|
|
45
|
-
import classes from "./Lexical.module.css";
|
|
46
|
-
import { LexicalTheme } from "./theme";
|
|
47
48
|
import { ToolbarPlugin } from "../plugins/ToolbarPlugin";
|
|
49
|
+
import { LexicalTheme } from "./theme";
|
|
48
50
|
|
|
49
51
|
export interface EditorProps {
|
|
50
52
|
value?: string | AnyObject;
|
|
@@ -62,6 +64,31 @@ export interface EditorProps {
|
|
|
62
64
|
onDirty?: (isDirty: boolean) => void;
|
|
63
65
|
}
|
|
64
66
|
|
|
67
|
+
/**
|
|
68
|
+
* LexicalEditor component is a rich text editor built using Lexical.
|
|
69
|
+
* It supports various features such as code highlighting, lists, tables, and sticky notes.
|
|
70
|
+
* It provides a customizable toolbar and handles editor state changes.
|
|
71
|
+
* It also supports drag-and-drop functionality for blocks.
|
|
72
|
+
* It can be used in both read-only and editable modes, and supports publishing mode for exporting content.
|
|
73
|
+
* It uses a custom theme and provides error handling for Lexical updates.
|
|
74
|
+
*
|
|
75
|
+
* @param {EditorProps} props - The properties for the LexicalEditor component.
|
|
76
|
+
* @returns {JSX.Element} The rendered LexicalEditor component.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```jsx
|
|
80
|
+
* <LexicalEditor
|
|
81
|
+
* value={initialValue}
|
|
82
|
+
* readOnly={false}
|
|
83
|
+
* publishMode={false}
|
|
84
|
+
* onChange={(value) => console.log("Editor value changed:", value)}
|
|
85
|
+
* onDirty={(isDirty) => console.log("Editor is dirty:", isDirty)}
|
|
86
|
+
* />
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/story/lexical-playground--playground}
|
|
90
|
+
* @see {@link https://lexical.dev/docs/}
|
|
91
|
+
*/
|
|
65
92
|
export const LexicalEditor = ({
|
|
66
93
|
value,
|
|
67
94
|
readOnly,
|
|
@@ -69,7 +96,7 @@ export const LexicalEditor = ({
|
|
|
69
96
|
onChange,
|
|
70
97
|
onDirty,
|
|
71
98
|
}: EditorProps) => {
|
|
72
|
-
const editorRef = useRef<LXE>();
|
|
99
|
+
const editorRef = useRef<LXE>(null);
|
|
73
100
|
const [editorContainer, setEditorContainer] = useState<HTMLDivElement | null>(
|
|
74
101
|
null,
|
|
75
102
|
);
|
|
@@ -135,25 +162,26 @@ export const LexicalEditor = ({
|
|
|
135
162
|
}, [readOnly, publishMode]);
|
|
136
163
|
|
|
137
164
|
const initialConfig = useMemo(
|
|
138
|
-
() =>
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
165
|
+
() =>
|
|
166
|
+
({
|
|
167
|
+
editorState: initEditor,
|
|
168
|
+
namespace: "MyEditor",
|
|
169
|
+
editable: !readOnly && !publishMode,
|
|
170
|
+
theme: LexicalTheme,
|
|
171
|
+
nodes: [
|
|
172
|
+
QuoteNode,
|
|
173
|
+
HeadingNode,
|
|
174
|
+
CodeHighlightNode,
|
|
175
|
+
CodeNode,
|
|
176
|
+
ListItemNode,
|
|
177
|
+
ListNode,
|
|
178
|
+
TableCellNode,
|
|
179
|
+
TableNode,
|
|
180
|
+
TableRowNode,
|
|
181
|
+
StickyNode,
|
|
182
|
+
],
|
|
183
|
+
onError,
|
|
184
|
+
}) as InitialConfigType,
|
|
157
185
|
[],
|
|
158
186
|
);
|
|
159
187
|
|
|
@@ -162,7 +190,7 @@ export const LexicalEditor = ({
|
|
|
162
190
|
return !publishMode ? (
|
|
163
191
|
<div className="lexical-scroller area-content overflow-auto">
|
|
164
192
|
<div
|
|
165
|
-
className={classNames(
|
|
193
|
+
className={classNames("fabric-lexicalToolbar", "sticky top-0 z-1")}
|
|
166
194
|
>
|
|
167
195
|
<Header className="bg-base">
|
|
168
196
|
<ToolbarPlugin />
|
|
@@ -185,7 +213,7 @@ export const LexicalEditor = ({
|
|
|
185
213
|
<div
|
|
186
214
|
role="none"
|
|
187
215
|
className={classNames(
|
|
188
|
-
|
|
216
|
+
"fabric-lexicalEditor",
|
|
189
217
|
"lexical-container relative bg-white min-h-full mx-auto shadow-md print:shadow-none",
|
|
190
218
|
)}
|
|
191
219
|
onDragOver={(e) => e.stopPropagation()}
|
|
@@ -194,7 +222,10 @@ export const LexicalEditor = ({
|
|
|
194
222
|
>
|
|
195
223
|
<RichTextPlugin
|
|
196
224
|
contentEditable={
|
|
197
|
-
<ContentEditable
|
|
225
|
+
<ContentEditable
|
|
226
|
+
readOnly={!!readOnly || publishMode}
|
|
227
|
+
className="lexical-editor px-[2cm] py-[1cm] min-h-screen"
|
|
228
|
+
/>
|
|
198
229
|
}
|
|
199
230
|
placeholder={
|
|
200
231
|
<div className="text-muted overflow-hidden absolute mt-6 top-[1cm] left-[2cm] select-none pointer-events-none">
|