@react-fabric/lexical 1.0.0-beta.54 → 1.0.0-beta.56
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/dist/cjs/packages/lexical/src/editor/LexicalEditor.js +1 -0
- package/dist/cjs/packages/lexical/src/hooks/useFormatWatcher.js +2 -6
- package/dist/cjs/packages/lexical/src/plugins/ToolbarPlugin.js +1 -1
- package/dist/esm/packages/lexical/src/editor/LexicalEditor.js +1 -0
- package/dist/esm/packages/lexical/src/hooks/useFormatWatcher.js +4 -8
- package/dist/esm/packages/lexical/src/plugins/ToolbarPlugin.js +1 -1
- package/package.json +4 -4
- package/src/editor/LexicalEditor.tsx +4 -1
- package/src/hooks/useFormatWatcher.ts +4 -3
- package/src/plugins/ToolbarPlugin.tsx +0 -1
|
@@ -158,6 +158,7 @@ var LexicalEditor = function LexicalEditor(_ref) {
|
|
|
158
158
|
ref: setEditorContainer,
|
|
159
159
|
children: [/*#__PURE__*/jsxRuntime.jsx(LexicalRichTextPlugin.RichTextPlugin, {
|
|
160
160
|
contentEditable: /*#__PURE__*/jsxRuntime.jsx(LexicalContentEditable.ContentEditable, {
|
|
161
|
+
readOnly: readOnly || publishMode,
|
|
161
162
|
className: "lexical-editor px-[2cm] py-[1cm] min-h-screen"
|
|
162
163
|
}),
|
|
163
164
|
placeholder: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -45,9 +45,6 @@ function getSelectedNode(selection) {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
var useFormatWatcher = function useFormatWatcher() {
|
|
48
|
-
var _useTransition = react.useTransition(),
|
|
49
|
-
_useTransition2 = _slicedToArray(_useTransition, 2),
|
|
50
|
-
startTransition = _useTransition2[1];
|
|
51
48
|
var _useLexicalComposerCo = LexicalComposerContext.useLexicalComposerContext(),
|
|
52
49
|
_useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
|
|
53
50
|
editor = _useLexicalComposerCo2[0];
|
|
@@ -240,8 +237,10 @@ var useFormatWatcher = function useFormatWatcher() {
|
|
|
240
237
|
}, lexical.COMMAND_PRIORITY_CRITICAL));
|
|
241
238
|
}, [$updateToolbar, activeEditor, editor]);
|
|
242
239
|
var applyStyleText = react.useCallback(function (styles) {
|
|
240
|
+
// activeEditor.focus();
|
|
243
241
|
activeEditor.update(function () {
|
|
244
242
|
if (!utilities.isNil(currentSelection)) {
|
|
243
|
+
lexical.$setSelection(currentSelection.clone());
|
|
245
244
|
LexicalSelection.$patchStyleText(currentSelection, styles);
|
|
246
245
|
}
|
|
247
246
|
});
|
|
@@ -373,9 +372,6 @@ var useFormatWatcher = function useFormatWatcher() {
|
|
|
373
372
|
});
|
|
374
373
|
}, [activeEditor]);
|
|
375
374
|
var onSizeChange = react.useCallback(function (value) {
|
|
376
|
-
startTransition(function () {
|
|
377
|
-
return setFontColor(value);
|
|
378
|
-
});
|
|
379
375
|
applyStyleText({
|
|
380
376
|
"font-size": +value + "px"
|
|
381
377
|
});
|
|
@@ -158,6 +158,7 @@ var LexicalEditor = function LexicalEditor(_ref) {
|
|
|
158
158
|
ref: setEditorContainer,
|
|
159
159
|
children: [/*#__PURE__*/jsx(RichTextPlugin, {
|
|
160
160
|
contentEditable: /*#__PURE__*/jsx(ContentEditable, {
|
|
161
|
+
readOnly: readOnly || publishMode,
|
|
161
162
|
className: "lexical-editor px-[2cm] py-[1cm] min-h-screen"
|
|
162
163
|
}),
|
|
163
164
|
placeholder: /*#__PURE__*/jsx("div", {
|
|
@@ -12,8 +12,8 @@ import { $isParentElementRTL, $getSelectionStyleValueForProperty, $patchStyleTex
|
|
|
12
12
|
import { $isTableNode } from '../../../../node_modules/@lexical/table/LexicalTable.js';
|
|
13
13
|
import { $findMatchingParent, $getNearestNodeOfType, mergeRegister, $getNearestBlockElementAncestorOrThrow } from '../../../../node_modules/@lexical/utils/LexicalUtils.js';
|
|
14
14
|
import { isNil } from '@react-fabric/utilities';
|
|
15
|
-
import { $getSelection, $isRangeSelection, $isRootOrShadowRoot, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_CRITICAL, CAN_UNDO_COMMAND, CAN_REDO_COMMAND, $createParagraphNode, INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND, $isTextNode } from 'lexical';
|
|
16
|
-
import {
|
|
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';
|
|
17
17
|
|
|
18
18
|
var blockTypeToBlockName = {
|
|
19
19
|
bullet: "Bulleted List",
|
|
@@ -45,9 +45,6 @@ function getSelectedNode(selection) {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
var useFormatWatcher = function useFormatWatcher() {
|
|
48
|
-
var _useTransition = useTransition(),
|
|
49
|
-
_useTransition2 = _slicedToArray(_useTransition, 2),
|
|
50
|
-
startTransition = _useTransition2[1];
|
|
51
48
|
var _useLexicalComposerCo = useLexicalComposerContext(),
|
|
52
49
|
_useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
|
|
53
50
|
editor = _useLexicalComposerCo2[0];
|
|
@@ -240,8 +237,10 @@ var useFormatWatcher = function useFormatWatcher() {
|
|
|
240
237
|
}, COMMAND_PRIORITY_CRITICAL));
|
|
241
238
|
}, [$updateToolbar, activeEditor, editor]);
|
|
242
239
|
var applyStyleText = useCallback(function (styles) {
|
|
240
|
+
// activeEditor.focus();
|
|
243
241
|
activeEditor.update(function () {
|
|
244
242
|
if (!isNil(currentSelection)) {
|
|
243
|
+
$setSelection(currentSelection.clone());
|
|
245
244
|
$patchStyleText(currentSelection, styles);
|
|
246
245
|
}
|
|
247
246
|
});
|
|
@@ -373,9 +372,6 @@ var useFormatWatcher = function useFormatWatcher() {
|
|
|
373
372
|
});
|
|
374
373
|
}, [activeEditor]);
|
|
375
374
|
var onSizeChange = useCallback(function (value) {
|
|
376
|
-
startTransition(function () {
|
|
377
|
-
return setFontColor(value);
|
|
378
|
-
});
|
|
379
375
|
applyStyleText({
|
|
380
376
|
"font-size": +value + "px"
|
|
381
377
|
});
|
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.56",
|
|
4
4
|
"description": "RUF: Lexical editor",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@lexical/react": "^0.27.1",
|
|
39
|
-
"@react-fabric/core": "^1.0.0-beta.
|
|
40
|
-
"@react-fabric/form": "^1.0.0-beta.
|
|
39
|
+
"@react-fabric/core": "^1.0.0-beta.55",
|
|
40
|
+
"@react-fabric/form": "^1.0.0-beta.56",
|
|
41
41
|
"@react-fabric/utilities": "^1.0.0-beta.52",
|
|
42
42
|
"classnames": "^2.5.1",
|
|
43
43
|
"lexical": "^0.27.1"
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"node": ">=18.12.0",
|
|
53
53
|
"npm": ">=8.19.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "fd9dd6cfd1a58efb5c4bfb6446928a78cb4f4266"
|
|
56
56
|
}
|
|
@@ -222,7 +222,10 @@ export const LexicalEditor = ({
|
|
|
222
222
|
>
|
|
223
223
|
<RichTextPlugin
|
|
224
224
|
contentEditable={
|
|
225
|
-
<ContentEditable
|
|
225
|
+
<ContentEditable
|
|
226
|
+
readOnly={readOnly || publishMode}
|
|
227
|
+
className="lexical-editor px-[2cm] py-[1cm] min-h-screen"
|
|
228
|
+
/>
|
|
226
229
|
}
|
|
227
230
|
placeholder={
|
|
228
231
|
<div className="text-muted overflow-hidden absolute mt-6 top-[1cm] left-[2cm] select-none pointer-events-none">
|
|
@@ -60,6 +60,7 @@ import {
|
|
|
60
60
|
$isRangeSelection,
|
|
61
61
|
$isRootOrShadowRoot,
|
|
62
62
|
$isTextNode,
|
|
63
|
+
$setSelection,
|
|
63
64
|
CAN_REDO_COMMAND,
|
|
64
65
|
CAN_UNDO_COMMAND,
|
|
65
66
|
COMMAND_PRIORITY_CRITICAL,
|
|
@@ -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,7 +112,6 @@ 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
117
|
const [currentSelection, setCurrentSelection] = useState<AnyObject>();
|
|
@@ -292,8 +292,10 @@ export const useFormatWatcher = () => {
|
|
|
292
292
|
|
|
293
293
|
const applyStyleText = useCallback(
|
|
294
294
|
(styles: Record<string, string>) => {
|
|
295
|
+
// activeEditor.focus();
|
|
295
296
|
activeEditor.update(() => {
|
|
296
297
|
if (!isNil(currentSelection)) {
|
|
298
|
+
$setSelection(currentSelection.clone());
|
|
297
299
|
$patchStyleText(currentSelection, styles);
|
|
298
300
|
}
|
|
299
301
|
});
|
|
@@ -435,7 +437,6 @@ export const useFormatWatcher = () => {
|
|
|
435
437
|
|
|
436
438
|
const onSizeChange = useCallback(
|
|
437
439
|
(value: string) => {
|
|
438
|
-
startTransition(() => setFontColor(value));
|
|
439
440
|
applyStyleText({ "font-size": +value + "px" });
|
|
440
441
|
},
|
|
441
442
|
[applyStyleText],
|