@react-fabric/lexical 1.0.0-beta.6 → 1.0.0-beta.60
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/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +62 -20
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.js +1 -1
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +11 -11
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +643 -245
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.js +1 -1
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +29 -22
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +13 -6
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.js +1 -1
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +3 -3
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +242 -141
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.js +1 -1
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +11 -10
- package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +594 -255
- package/dist/cjs/node_modules/@lexical/list/LexicalList.js +1 -1
- package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +23 -16
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +102 -53
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.js +1 -1
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +10 -10
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +275 -194
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +5 -1
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +28 -18
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +2293 -878
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.js +1 -1
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +53 -40
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +471 -193
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +13 -1
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +47 -32
- package/dist/cjs/node_modules/prismjs/prism.js +1 -1
- package/dist/cjs/packages/lexical/src/components/StickyComponent.js +1 -1
- package/dist/cjs/packages/lexical/src/editor/LexicalEditor.js +30 -5
- package/dist/cjs/packages/lexical/src/hooks/useFormatWatcher.js +86 -83
- package/dist/cjs/packages/lexical/src/plugins/ToolbarPlugin.js +25 -17
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +62 -20
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.js +1 -1
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +3 -3
- package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +637 -246
- package/dist/esm/node_modules/@lexical/code/LexicalCode.js +1 -1
- package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +4 -4
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +14 -7
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.js +1 -1
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +3 -3
- package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +244 -144
- package/dist/esm/node_modules/@lexical/link/LexicalLink.js +1 -1
- package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +4 -4
- package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +590 -257
- package/dist/esm/node_modules/@lexical/list/LexicalList.js +1 -1
- package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +5 -4
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +104 -55
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.js +1 -1
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +4 -4
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +267 -196
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +4 -2
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +4 -4
- package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +2283 -881
- package/dist/esm/node_modules/@lexical/table/LexicalTable.js +1 -1
- package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +4 -4
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +457 -194
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +8 -2
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +3 -3
- package/dist/esm/node_modules/prismjs/prism.js +1 -1
- package/dist/esm/packages/lexical/src/components/StickyComponent.js +1 -1
- package/dist/esm/packages/lexical/src/editor/LexicalEditor.js +30 -5
- package/dist/esm/packages/lexical/src/hooks/useFormatWatcher.js +88 -85
- package/dist/esm/packages/lexical/src/plugins/ToolbarPlugin.js +25 -17
- package/dist/types/editor/LexicalEditor.d.ts +25 -0
- package/dist/types/hooks/useFormatWatcher.d.ts +2 -2
- package/dist/types/nodes/StickyNode.d.ts +0 -1
- package/package.json +14 -13
- package/src/components/StickyComponent.tsx +2 -2
- package/src/editor/LexicalEditor.tsx +57 -26
- package/src/hooks/useFormatWatcher.ts +35 -31
- package/src/plugins/ToolbarPlugin.tsx +27 -17
- package/dist/cjs/editor/Lexical.module.css +0 -1
- package/dist/esm/editor/Lexical.module.css +0 -1
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.60",
|
|
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.60",
|
|
40
|
+
"@react-fabric/form": "^1.0.0-beta.60",
|
|
41
|
+
"@react-fabric/utilities": "^1.0.0-beta.60",
|
|
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": "a79f053ee7e13422c06d7d9c35d4f0c2610cdf5d"
|
|
55
56
|
}
|
|
@@ -26,7 +26,7 @@
|
|
|
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
32
|
import { mdiClose, mdiFormatColorFill } from "@mdi/js";
|
|
@@ -261,7 +261,7 @@ export const StickyComponent = ({
|
|
|
261
261
|
placeholder={
|
|
262
262
|
<div className="sticky-placeholder">Sticky note...</div>
|
|
263
263
|
}
|
|
264
|
-
ErrorBoundary={LexicalErrorBoundary}
|
|
264
|
+
ErrorBoundary={LexicalErrorBoundary as any}
|
|
265
265
|
/>
|
|
266
266
|
<AutoFocusPlugin />
|
|
267
267
|
</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">
|
|
@@ -53,16 +53,17 @@ import {
|
|
|
53
53
|
$getNearestNodeOfType,
|
|
54
54
|
mergeRegister,
|
|
55
55
|
} from "@lexical/utils";
|
|
56
|
+
import { isNil } from "@react-fabric/utilities";
|
|
56
57
|
import {
|
|
57
58
|
$createParagraphNode,
|
|
58
59
|
$getSelection,
|
|
59
60
|
$isRangeSelection,
|
|
60
61
|
$isRootOrShadowRoot,
|
|
61
62
|
$isTextNode,
|
|
63
|
+
$setSelection,
|
|
62
64
|
CAN_REDO_COMMAND,
|
|
63
65
|
CAN_UNDO_COMMAND,
|
|
64
66
|
COMMAND_PRIORITY_CRITICAL,
|
|
65
|
-
FOCUS_COMMAND,
|
|
66
67
|
INDENT_CONTENT_COMMAND,
|
|
67
68
|
OUTDENT_CONTENT_COMMAND,
|
|
68
69
|
SELECTION_CHANGE_COMMAND,
|
|
@@ -71,7 +72,7 @@ import {
|
|
|
71
72
|
type RangeSelection,
|
|
72
73
|
type TextNode,
|
|
73
74
|
} from "lexical";
|
|
74
|
-
import { useCallback, useEffect, useState
|
|
75
|
+
import { useCallback, useEffect, useState } from "react";
|
|
75
76
|
|
|
76
77
|
const blockTypeToBlockName = {
|
|
77
78
|
bullet: "Bulleted List",
|
|
@@ -111,9 +112,9 @@ export function getSelectedNode(
|
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
export const useFormatWatcher = () => {
|
|
114
|
-
const [, startTransition] = useTransition();
|
|
115
115
|
const [editor] = useLexicalComposerContext();
|
|
116
116
|
const [activeEditor, setActiveEditor] = useState(editor);
|
|
117
|
+
const [currentSelection, setCurrentSelection] = useState<AnyObject>();
|
|
117
118
|
const [blockType, setBlockType] =
|
|
118
119
|
useState<keyof typeof blockTypeToBlockName>("paragraph");
|
|
119
120
|
const [rootType, setRootType] =
|
|
@@ -166,7 +167,9 @@ export const useFormatWatcher = () => {
|
|
|
166
167
|
setIsSubscript(selection.hasFormat("subscript"));
|
|
167
168
|
setIsSuperscript(selection.hasFormat("superscript"));
|
|
168
169
|
setIsCode(selection.hasFormat("code"));
|
|
169
|
-
|
|
170
|
+
editor.read(() => {
|
|
171
|
+
setIsRTL($isParentElementRTL(selection));
|
|
172
|
+
});
|
|
170
173
|
|
|
171
174
|
// Update links
|
|
172
175
|
const node = getSelectedNode(selection);
|
|
@@ -218,41 +221,46 @@ export const useFormatWatcher = () => {
|
|
|
218
221
|
) + "",
|
|
219
222
|
);
|
|
220
223
|
setFontColor(
|
|
221
|
-
$getSelectionStyleValueForProperty(
|
|
224
|
+
$getSelectionStyleValueForProperty(
|
|
225
|
+
selection,
|
|
226
|
+
"color",
|
|
227
|
+
// @ts-expect-error ignore
|
|
228
|
+
// eslint-disable-next-line no-new-wrappers
|
|
229
|
+
new String("#000"),
|
|
230
|
+
),
|
|
222
231
|
);
|
|
223
232
|
setBgColor(
|
|
224
233
|
$getSelectionStyleValueForProperty(
|
|
225
234
|
selection,
|
|
226
235
|
"background-color",
|
|
227
|
-
|
|
236
|
+
// @ts-expect-error ignore
|
|
237
|
+
// eslint-disable-next-line no-new-wrappers
|
|
238
|
+
new String("#fff"),
|
|
228
239
|
),
|
|
229
240
|
);
|
|
230
241
|
setFontFamily(
|
|
231
242
|
$getSelectionStyleValueForProperty(selection, "font-family", "inherit"),
|
|
232
243
|
);
|
|
233
244
|
}
|
|
234
|
-
}, [
|
|
245
|
+
}, []);
|
|
235
246
|
|
|
236
247
|
useEffect(() => {
|
|
237
248
|
return editor.registerCommand(
|
|
238
|
-
|
|
249
|
+
SELECTION_CHANGE_COMMAND,
|
|
239
250
|
(_payload, newEditor) => {
|
|
240
251
|
setActiveEditor(newEditor);
|
|
252
|
+
setCurrentSelection($getSelection());
|
|
253
|
+
$updateToolbar();
|
|
241
254
|
return false;
|
|
242
255
|
},
|
|
243
256
|
COMMAND_PRIORITY_CRITICAL,
|
|
244
257
|
);
|
|
245
|
-
}, [editor]);
|
|
258
|
+
}, [editor, $updateToolbar]);
|
|
246
259
|
|
|
247
260
|
useEffect(() => {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
$updateToolbar();
|
|
252
|
-
return false;
|
|
253
|
-
},
|
|
254
|
-
COMMAND_PRIORITY_CRITICAL,
|
|
255
|
-
);
|
|
261
|
+
activeEditor.getEditorState().read(() => {
|
|
262
|
+
$updateToolbar();
|
|
263
|
+
});
|
|
256
264
|
}, [activeEditor, $updateToolbar]);
|
|
257
265
|
|
|
258
266
|
useEffect(() => {
|
|
@@ -286,16 +294,15 @@ export const useFormatWatcher = () => {
|
|
|
286
294
|
|
|
287
295
|
const applyStyleText = useCallback(
|
|
288
296
|
(styles: Record<string, string>) => {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}, 100);
|
|
297
|
+
// activeEditor.focus();
|
|
298
|
+
activeEditor.update(() => {
|
|
299
|
+
if (!isNil(currentSelection)) {
|
|
300
|
+
$setSelection(currentSelection.clone());
|
|
301
|
+
$patchStyleText(currentSelection, styles);
|
|
302
|
+
}
|
|
303
|
+
});
|
|
297
304
|
},
|
|
298
|
-
[
|
|
305
|
+
[activeEditor, currentSelection],
|
|
299
306
|
);
|
|
300
307
|
|
|
301
308
|
const formatBulletList = () => {
|
|
@@ -432,23 +439,20 @@ export const useFormatWatcher = () => {
|
|
|
432
439
|
|
|
433
440
|
const onSizeChange = useCallback(
|
|
434
441
|
(value: string) => {
|
|
435
|
-
startTransition(() => setFontColor(value));
|
|
436
442
|
applyStyleText({ "font-size": +value + "px" });
|
|
437
443
|
},
|
|
438
444
|
[applyStyleText],
|
|
439
445
|
);
|
|
440
446
|
|
|
441
447
|
const onFontColorSelect = useCallback(
|
|
442
|
-
(value: string) => {
|
|
443
|
-
startTransition(() => setFontColor(value));
|
|
448
|
+
(value: string = "#000000") => {
|
|
444
449
|
applyStyleText({ color: value });
|
|
445
450
|
},
|
|
446
451
|
[applyStyleText],
|
|
447
452
|
);
|
|
448
453
|
|
|
449
454
|
const onBgColorSelect = useCallback(
|
|
450
|
-
(value: string) => {
|
|
451
|
-
startTransition(() => setBgColor(value));
|
|
455
|
+
(value: string = "#ffffff") => {
|
|
452
456
|
applyStyleText({ "background-color": value });
|
|
453
457
|
},
|
|
454
458
|
[applyStyleText],
|
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
* @version
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* React Fabric
|
|
3
|
+
* @version: 1.0.0
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* The MIT License (MIT)
|
|
7
|
+
* Copyright (c) 2025 Adarsh Pastakia
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
|
+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
11
|
+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
+
* subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
16
|
+
* portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
20
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
6
22
|
*/
|
|
7
23
|
|
|
8
24
|
import {
|
|
@@ -159,9 +175,8 @@ export const ToolbarPlugin = () => {
|
|
|
159
175
|
<ButtonGroup variant="link">
|
|
160
176
|
<ButtonWrapper
|
|
161
177
|
value="start"
|
|
162
|
-
rtlFlip
|
|
163
178
|
label={t("tool.alignStart")}
|
|
164
|
-
icon={CoreIcons.alignLeft}
|
|
179
|
+
icon={{ icon: CoreIcons.alignLeft, rtlFlip: true }}
|
|
165
180
|
onClick={() =>
|
|
166
181
|
watch.activeEditor.dispatchCommand(FORMAT_ELEMENT_COMMAND, "start")
|
|
167
182
|
}
|
|
@@ -176,18 +191,16 @@ export const ToolbarPlugin = () => {
|
|
|
176
191
|
/>
|
|
177
192
|
<ButtonWrapper
|
|
178
193
|
value="end"
|
|
179
|
-
rtlFlip
|
|
180
194
|
label={t("tool.alignEnd")}
|
|
181
|
-
icon={CoreIcons.alignRight}
|
|
195
|
+
icon={{ icon: CoreIcons.alignRight, rtlFlip: true }}
|
|
182
196
|
onClick={() =>
|
|
183
197
|
watch.activeEditor.dispatchCommand(FORMAT_ELEMENT_COMMAND, "end")
|
|
184
198
|
}
|
|
185
199
|
/>
|
|
186
200
|
<ButtonWrapper
|
|
187
201
|
value="justify"
|
|
188
|
-
rtlFlip
|
|
189
202
|
label={t("tool.alignJustify")}
|
|
190
|
-
icon={CoreIcons.alignJustify}
|
|
203
|
+
icon={{ icon: CoreIcons.alignJustify, rtlFlip: true }}
|
|
191
204
|
onClick={() =>
|
|
192
205
|
watch.activeEditor.dispatchCommand(
|
|
193
206
|
FORMAT_ELEMENT_COMMAND,
|
|
@@ -197,16 +210,14 @@ export const ToolbarPlugin = () => {
|
|
|
197
210
|
/>
|
|
198
211
|
<ButtonWrapper
|
|
199
212
|
value="justify"
|
|
200
|
-
rtlFlip
|
|
201
213
|
label={t("tool.indentOut")}
|
|
202
|
-
icon={CoreIcons.formatIndentDecrease}
|
|
214
|
+
icon={{ icon: CoreIcons.formatIndentDecrease, rtlFlip: true }}
|
|
203
215
|
onClick={() => watch.outdent()}
|
|
204
216
|
/>
|
|
205
217
|
<ButtonWrapper
|
|
206
218
|
value="justify"
|
|
207
|
-
rtlFlip
|
|
208
219
|
label={t("tool.identIn")}
|
|
209
|
-
icon={CoreIcons.formatIndentIncrease}
|
|
220
|
+
icon={{ icon: CoreIcons.formatIndentIncrease, rtlFlip: true }}
|
|
210
221
|
onClick={() => watch.indent()}
|
|
211
222
|
/>
|
|
212
223
|
</ButtonGroup>
|
|
@@ -252,13 +263,13 @@ export const ToolbarPlugin = () => {
|
|
|
252
263
|
<ColorInput
|
|
253
264
|
{...{ noOutline: true }}
|
|
254
265
|
value={watch.fontColor}
|
|
255
|
-
onChange={(v
|
|
266
|
+
onChange={(v) => watch.onFontColorSelect(v ?? undefined)}
|
|
256
267
|
decorateStart={<Icon icon={CoreIcons.formatText} />}
|
|
257
268
|
/>
|
|
258
269
|
<ColorInput
|
|
259
270
|
{...{ noOutline: true }}
|
|
260
271
|
value={watch.bgColor}
|
|
261
|
-
onChange={(v
|
|
272
|
+
onChange={(v) => watch.onBgColorSelect(v ?? undefined)}
|
|
262
273
|
decorateStart={<Icon icon={CoreIcons.formatFill} />}
|
|
263
274
|
/>
|
|
264
275
|
<ButtonWrapper
|
|
@@ -273,7 +284,6 @@ export const ToolbarPlugin = () => {
|
|
|
273
284
|
icon={CoreIcons.formatClear}
|
|
274
285
|
onClick={() => watch.clearFormatting()}
|
|
275
286
|
/>
|
|
276
|
-
<Divider />
|
|
277
287
|
</div>
|
|
278
288
|
);
|
|
279
289
|
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@layer util{.lexicalEditor,.lexicalToolbar{margin:0 auto;width:21cm}.lexicalEditor :global{.editor-container.editor-container.editor-container{background-color:#fff;color:#0f172a;font-family:Sakkal Majalla;font-size:18px}.editor-heading-h1{font-size:1.5em;margin-bottom:1.5em;text-transform:capitalize}.editor-heading-h1,.editor-heading-h2{font-weight:600;line-height:1.5;margin-top:1.5em;padding:0 4px}.editor-heading-h2{font-size:1.25em;margin-bottom:1em}.editor-heading-h6{color:#b45309;font-size:.875em;font-weight:600;line-height:1.25;margin-bottom:1.5em;margin-top:1.5em}.editor-paragraph{font-size:1em}.editor-paragraph,.editor-quote{line-height:1.5;margin-bottom:1.5em;margin-top:1.5em}.editor-quote{border-color:#64748b;padding-inline-start:1em}.editor-code,.editor-quote{border-inline-start-width:4px;color:#1e293b;display:block;font-size:1.125em}.editor-code{background-color:#e2e8f0;line-height:1.5;margin-bottom:1.5em;margin-top:1.5em;padding:1em}.editor-textUnderline{text-decoration:underline}.editor-textStrikethrough{text-decoration:line-through}.editor-textUnderlineStrikethrough{text-decoration:underline line-through}.editor-page-break{page-break-after:always}.editor-no-break{page-break-inside:avoid}.editor-textSmall{font-size:.875em}.editor-textBold{font-weight:600}.editor-textItalic{font-style:italic}.editor-textMuted{color:#4b5563}.editor-list-ul{list-style:disc;padding-inline-start:.5em}.editor-list-ol{list-style:decimal;padding-inline-start:.5em}.editor-listItem{margin-inline-start:1em;text-align:start}@media print{body,html{margin:0;min-height:100vh}div,h1,h2,h3,h4,h5,h6,p,span{box-sizing:border-box}body.report-template{background-size:0;min-height:100vh}body:after{background-image:inherit;content:"";height:100vh;inset:0;margin:0 auto;max-width:21cm;position:fixed;-webkit-print-color-adjust:exact;print-color-adjust:exact;width:100vw;z-index:10}.editor-page-break>div,.sticky__container{display:none}.editor-container{position:relative}.editor-editor{box-sizing:border-box;padding:0 2cm}}}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@layer util{.lexicalEditor,.lexicalToolbar{margin:0 auto;width:21cm}.lexicalEditor :global{.editor-container.editor-container.editor-container{background-color:#fff;color:#0f172a;font-family:Sakkal Majalla;font-size:18px}.editor-heading-h1{font-size:1.5em;margin-bottom:1.5em;text-transform:capitalize}.editor-heading-h1,.editor-heading-h2{font-weight:600;line-height:1.5;margin-top:1.5em;padding:0 4px}.editor-heading-h2{font-size:1.25em;margin-bottom:1em}.editor-heading-h6{color:#b45309;font-size:.875em;font-weight:600;line-height:1.25;margin-bottom:1.5em;margin-top:1.5em}.editor-paragraph{font-size:1em}.editor-paragraph,.editor-quote{line-height:1.5;margin-bottom:1.5em;margin-top:1.5em}.editor-quote{border-color:#64748b;padding-inline-start:1em}.editor-code,.editor-quote{border-inline-start-width:4px;color:#1e293b;display:block;font-size:1.125em}.editor-code{background-color:#e2e8f0;line-height:1.5;margin-bottom:1.5em;margin-top:1.5em;padding:1em}.editor-textUnderline{text-decoration:underline}.editor-textStrikethrough{text-decoration:line-through}.editor-textUnderlineStrikethrough{text-decoration:underline line-through}.editor-page-break{page-break-after:always}.editor-no-break{page-break-inside:avoid}.editor-textSmall{font-size:.875em}.editor-textBold{font-weight:600}.editor-textItalic{font-style:italic}.editor-textMuted{color:#4b5563}.editor-list-ul{list-style:disc;padding-inline-start:.5em}.editor-list-ol{list-style:decimal;padding-inline-start:.5em}.editor-listItem{margin-inline-start:1em;text-align:start}@media print{body,html{margin:0;min-height:100vh}div,h1,h2,h3,h4,h5,h6,p,span{box-sizing:border-box}body.report-template{background-size:0;min-height:100vh}body:after{background-image:inherit;content:"";height:100vh;inset:0;margin:0 auto;max-width:21cm;position:fixed;-webkit-print-color-adjust:exact;print-color-adjust:exact;width:100vw;z-index:10}.editor-page-break>div,.sticky__container{display:none}.editor-container{position:relative}.editor-editor{box-sizing:border-box;padding:0 2cm}}}}
|