@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.
- package/{src/editor/Lexical.module.css → css/_lexical.css} +79 -13
- package/css/styles.css +24 -0
- package/dist/cjs/{packages/lexical/src/editor → editor}/LexicalEditor.js +98 -45
- package/dist/cjs/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +147 -140
- package/dist/cjs/i18n/ar/lexical.json.js +30 -0
- package/dist/cjs/i18n/en/lexical.json.js +30 -0
- package/{src/plugins/StickyPlugin.ts → dist/cjs/i18n/index.js} +10 -15
- package/dist/cjs/index.js +36 -0
- package/dist/cjs/plugins/CommentPlugin.js +481 -0
- package/dist/cjs/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +17 -20
- package/dist/cjs/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +58 -37
- package/dist/esm/{packages/lexical/src/editor → editor}/LexicalEditor.js +101 -48
- package/dist/esm/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +95 -88
- package/dist/esm/i18n/ar/lexical.json.js +25 -0
- package/dist/esm/i18n/en/lexical.json.js +25 -0
- package/dist/esm/i18n/index.js +33 -0
- package/dist/esm/index.js +34 -0
- package/dist/esm/plugins/CommentPlugin.js +481 -0
- package/dist/esm/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +15 -18
- package/dist/esm/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +59 -38
- package/dist/types/editor/LexicalEditor.d.ts +33 -4
- package/dist/types/hooks/useFormatWatcher.d.ts +7 -4
- package/dist/types/i18n/index.d.ts +1 -0
- package/dist/types/index.d.ts +27 -0
- package/dist/types/plugins/CommentPlugin.d.ts +5 -0
- package/dist/types/plugins/DraggableBlockPlugin.d.ts +3 -2
- package/dist/types/plugins/ToolbarPlugin.d.ts +1 -1
- package/dist/types/utils/index.d.ts +3 -6
- package/package.json +18 -18
- package/src/editor/LexicalEditor.tsx +95 -55
- package/src/hooks/useFormatWatcher.ts +50 -74
- package/src/i18n/ar/lexical.json +18 -0
- package/src/i18n/en/lexical.json +18 -0
- package/src/i18n/index.ts +28 -0
- package/src/index.ts +24 -17
- package/src/plugins/CommentPlugin.tsx +523 -0
- package/src/plugins/DraggableBlockPlugin.tsx +23 -68
- package/src/plugins/ToolbarPlugin.tsx +83 -131
- package/src/utils/index.ts +12 -108
- 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/cjs/packages/lexical/src/components/StickyComponent.js +0 -221
- package/dist/cjs/packages/lexical/src/index.js +0 -7
- package/dist/cjs/packages/lexical/src/nodes/StickyNode.js +0 -218
- package/dist/cjs/packages/lexical/src/plugins/StickyPlugin.js +0 -20
- 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/esm/packages/lexical/src/components/StickyComponent.js +0 -221
- package/dist/esm/packages/lexical/src/index.js +0 -3
- package/dist/esm/packages/lexical/src/nodes/StickyNode.js +0 -216
- package/dist/esm/packages/lexical/src/plugins/StickyPlugin.js +0 -20
- package/dist/types/components/StickyComponent.d.ts +0 -9
- package/dist/types/nodes/StickyNode.d.ts +0 -35
- package/dist/types/plugins/StickyPlugin.d.ts +0 -1
- package/src/components/StickyComponent.tsx +0 -271
- package/src/nodes/StickyNode.tsx +0 -249
- /package/dist/cjs/{packages/lexical/src/editor → editor}/theme.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/utils → utils}/index.js +0 -0
|
@@ -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';
|
|
@@ -13,7 +13,7 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
13
13
|
|
|
14
14
|
var _excluded = ["label"];
|
|
15
15
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t),
|
|
16
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17
17
|
var blockTypeToBlockName = {
|
|
18
18
|
bullet: "Bulleted List",
|
|
19
19
|
code: "Block",
|
|
@@ -25,14 +25,14 @@ var blockTypeToBlockName = {
|
|
|
25
25
|
quote: "Quote"
|
|
26
26
|
};
|
|
27
27
|
var blockTypeToBlockIcon = {
|
|
28
|
-
bullet:
|
|
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) {
|
|
@@ -47,7 +47,7 @@ var ButtonWrapper = function ButtonWrapper(_ref) {
|
|
|
47
47
|
}, rest))
|
|
48
48
|
});
|
|
49
49
|
};
|
|
50
|
-
|
|
50
|
+
function ToolbarPlugin() {
|
|
51
51
|
var watch = useFormatWatcher();
|
|
52
52
|
var _useTranslation = useTranslation("lexical"),
|
|
53
53
|
t = _useTranslation.t;
|
|
@@ -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,39 +243,37 @@ 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
|
|
|
258
279
|
export { ToolbarPlugin };
|
|
@@ -1,13 +1,42 @@
|
|
|
1
|
+
import type { SerializedEditorState, SerializedLexicalNode } from "lexical";
|
|
2
|
+
import { type Klass, type LexicalNode, type LexicalNodeReplacement } from "lexical";
|
|
1
3
|
export interface EditorProps {
|
|
2
|
-
value?: string |
|
|
4
|
+
value?: string | SerializedEditorState<SerializedLexicalNode>;
|
|
5
|
+
isRtl?: boolean;
|
|
3
6
|
readOnly?: boolean;
|
|
4
7
|
/**
|
|
5
8
|
* publish mode removes all wrapping and renders plain lexical view for exporting to pdf using puppeteer
|
|
6
9
|
*/
|
|
7
10
|
publishMode?: boolean;
|
|
8
|
-
header?:
|
|
9
|
-
footer?:
|
|
11
|
+
header?: React.ReactElement;
|
|
12
|
+
footer?: React.ReactElement;
|
|
13
|
+
coverPage?: React.ReactElement;
|
|
14
|
+
/**
|
|
15
|
+
* Username is used for comment plugin to identify the comment author. It can be used to conditionally render delete option for comments.
|
|
16
|
+
*/
|
|
17
|
+
username?: string;
|
|
18
|
+
nodes?: ReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement>;
|
|
10
19
|
onChange?: (value: KeyValue) => void;
|
|
11
20
|
onDirty?: (isDirty: boolean) => void;
|
|
12
21
|
}
|
|
13
|
-
|
|
22
|
+
/**
|
|
23
|
+
* LexicalEditor component is a rich text editor built using Lexical.
|
|
24
|
+
* It supports various features such as code highlighting, lists, tables, and sticky notes.
|
|
25
|
+
* It provides a customizable toolbar and handles editor state changes.
|
|
26
|
+
* It also supports drag-and-drop functionality for blocks.
|
|
27
|
+
* It can be used in both read-only and editable modes, and supports publishing mode for exporting content.
|
|
28
|
+
* It uses a custom theme and provides error handling for Lexical updates.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```jsx
|
|
32
|
+
* <LexicalEditor
|
|
33
|
+
* value={initialValue}
|
|
34
|
+
* readOnly={false}
|
|
35
|
+
* publishMode={false}
|
|
36
|
+
* onChange={(value) => console.log("Editor value changed:", value)}
|
|
37
|
+
* onDirty={(isDirty) => console.log("Editor is dirty:", isDirty)}
|
|
38
|
+
* />
|
|
39
|
+
* ```
|
|
40
|
+
* @see {@link https://lexical.dev/docs/}
|
|
41
|
+
*/
|
|
42
|
+
export declare function LexicalEditor({ value, readOnly, publishMode, header, footer, coverPage, isRtl, username, nodes, onChange, onDirty, }: EditorProps): import("react").JSX.Element;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type HeadingTagType } from "@lexical/rich-text";
|
|
2
2
|
import { type ElementNode, type RangeSelection, type TextNode } from "lexical";
|
|
3
|
+
type RootTypeToRootName = "root" | "table";
|
|
3
4
|
export declare function getSelectedNode(selection: RangeSelection): TextNode | ElementNode;
|
|
4
5
|
export declare const useFormatWatcher: () => {
|
|
5
6
|
editor: import("lexical").LexicalEditor;
|
|
6
|
-
blockType: "number" | "
|
|
7
|
-
rootType:
|
|
7
|
+
blockType: "number" | "code" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "bullet" | "check" | "paragraph" | "quote";
|
|
8
|
+
rootType: RootTypeToRootName;
|
|
8
9
|
selectedElementKey: string | null;
|
|
9
10
|
fontSize: string;
|
|
10
11
|
fontColor: string;
|
|
@@ -21,14 +22,15 @@ export declare const useFormatWatcher: () => {
|
|
|
21
22
|
canUndo: boolean;
|
|
22
23
|
canRedo: boolean;
|
|
23
24
|
isRTL: boolean;
|
|
25
|
+
align: string;
|
|
24
26
|
isEditable: boolean;
|
|
25
27
|
codeLanguage: string;
|
|
26
28
|
activeEditor: import("lexical").LexicalEditor;
|
|
27
29
|
indent: () => void;
|
|
28
30
|
outdent: () => void;
|
|
29
31
|
clearFormatting: () => void;
|
|
30
|
-
onFontColorSelect: (value
|
|
31
|
-
onBgColorSelect: (value
|
|
32
|
+
onFontColorSelect: (value?: string) => void;
|
|
33
|
+
onBgColorSelect: (value?: string) => void;
|
|
32
34
|
formatQuote: () => void;
|
|
33
35
|
onSizeChange: (value: string) => void;
|
|
34
36
|
formatBlock: () => void;
|
|
@@ -38,3 +40,4 @@ export declare const useFormatWatcher: () => {
|
|
|
38
40
|
formatCheckList: () => void;
|
|
39
41
|
formatNumberedList: () => void;
|
|
40
42
|
};
|
|
43
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Fabric
|
|
3
|
+
* @version 1.0.0
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2024 Adarsh Pastakia
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
export declare const LEXICAL_PACKAGE = "@react-fabric/lexical";
|
|
26
|
+
export declare const LEXICAL_VERSION = "1.0.0";
|
|
27
|
+
import "./i18n";
|
|
1
28
|
export { LexicalEditor } from "./editor/LexicalEditor";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare function ToolbarPlugin(): import("react").JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LngLatLike } from "@react-fabric/utilities";
|
|
1
2
|
export declare function isHTMLElement(x: unknown): x is HTMLElement;
|
|
2
3
|
export declare class Point {
|
|
3
4
|
private readonly _x;
|
|
@@ -38,7 +39,7 @@ export declare class Rect {
|
|
|
38
39
|
contains({ x, y }: Point): ContainsPointReturn;
|
|
39
40
|
contains({ top, left, bottom, right }: Rect): boolean;
|
|
40
41
|
intersectsWith(rect: Rect): boolean;
|
|
41
|
-
generateNewRect({ left, top, right, bottom
|
|
42
|
+
generateNewRect({ left, top, right, bottom }: {
|
|
42
43
|
left?: number | undefined;
|
|
43
44
|
top?: number | undefined;
|
|
44
45
|
right?: number | undefined;
|
|
@@ -49,9 +50,5 @@ export declare class Rect {
|
|
|
49
50
|
static fromPoints(startPoint: Point, endPoint: Point): Rect;
|
|
50
51
|
static fromDOM(dom: HTMLElement): Rect;
|
|
51
52
|
}
|
|
52
|
-
export declare const
|
|
53
|
-
export declare const convertToDMS: (coord: number, isLat?: boolean) => string;
|
|
54
|
-
export declare const getLocationAsText: (latlon: AnyObject) => string;
|
|
55
|
-
export declare const getLocationUrl: (latlon: AnyObject) => string;
|
|
56
|
-
export declare const bookmarksFilterHookMatcher: (bookmark: KeyValue, query: string) => any;
|
|
53
|
+
export declare const getLocationUrl: (latlon: LngLatLike) => string;
|
|
57
54
|
export {};
|
package/package.json
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-fabric/lexical",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "RUF: Lexical editor",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"repository": "https://github.com/adarshpastakia/react-
|
|
7
|
+
"repository": "https://github.com/adarshpastakia/react-fabric/tree/main/packages/lexical",
|
|
8
8
|
"source": "src/index.ts",
|
|
9
9
|
"main": "dist/cjs/index.js",
|
|
10
10
|
"module": "dist/esm/index.js",
|
|
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
|
],
|
|
@@ -22,8 +24,6 @@
|
|
|
22
24
|
"registry": "https://registry.npmjs.org/"
|
|
23
25
|
},
|
|
24
26
|
"scripts": {
|
|
25
|
-
"makelink": "yarn link",
|
|
26
|
-
"removelink": "yarn unlink",
|
|
27
27
|
"prebuild": "rm -rf ./dist",
|
|
28
28
|
"build:dts": "tsc -p ./tsconfig.build.json",
|
|
29
29
|
"build:rollup": "rollup -c ../../rollup.config.mjs",
|
|
@@ -33,23 +33,23 @@
|
|
|
33
33
|
"watch": "npm-run-all -p watch:rollup watch:dts"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@lexical/
|
|
37
|
-
"@lexical/react": "
|
|
38
|
-
"@react-fabric/core": "^1.0.
|
|
39
|
-
"@react-fabric/
|
|
40
|
-
"@react-fabric/
|
|
41
|
-
"
|
|
42
|
-
"lexical": "
|
|
36
|
+
"@lexical/code": "0.49.0",
|
|
37
|
+
"@lexical/react": "0.49.0",
|
|
38
|
+
"@react-fabric/core": "^1.0.1",
|
|
39
|
+
"@react-fabric/date": "^1.0.1",
|
|
40
|
+
"@react-fabric/form": "^1.0.1",
|
|
41
|
+
"@react-fabric/utilities": "^1.0.1",
|
|
42
|
+
"lexical": "0.49.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"i18next": "
|
|
46
|
-
"react": "
|
|
47
|
-
"react-dom": "
|
|
48
|
-
"react-i18next": "
|
|
45
|
+
"i18next": "~26.3.6",
|
|
46
|
+
"react": "~19.3.0",
|
|
47
|
+
"react-dom": "~19.3.0",
|
|
48
|
+
"react-i18next": "~17.0.11"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
|
-
"node": ">=
|
|
52
|
-
"npm": ">=
|
|
51
|
+
"node": ">=24.0.0",
|
|
52
|
+
"npm": ">=11.0.0"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "1419a9df05b5e3850e1d2b4e896ab63df702c7e8"
|
|
55
55
|
}
|