@react-fabric/lexical 1.0.0-beta.53 → 1.0.0-beta.55

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.
@@ -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
  });
@@ -249,7 +249,7 @@ var ToolbarPlugin = function ToolbarPlugin() {
249
249
  onClick: function onClick() {
250
250
  return watch.clearFormatting();
251
251
  }
252
- }), /*#__PURE__*/jsxRuntime.jsx(core.Divider, {})]
252
+ })]
253
253
  });
254
254
  };
255
255
 
@@ -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 { useTransition, useState, useCallback, useEffect } from 'react';
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
  });
@@ -249,7 +249,7 @@ var ToolbarPlugin = function ToolbarPlugin() {
249
249
  onClick: function onClick() {
250
250
  return watch.clearFormatting();
251
251
  }
252
- }), /*#__PURE__*/jsx(Divider, {})]
252
+ })]
253
253
  });
254
254
  };
255
255
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-fabric/lexical",
3
- "version": "1.0.0-beta.53",
3
+ "version": "1.0.0-beta.55",
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.53",
40
- "@react-fabric/form": "^1.0.0-beta.53",
39
+ "@react-fabric/core": "^1.0.0-beta.55",
40
+ "@react-fabric/form": "^1.0.0-beta.55",
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": "1042327831f9c908912c552d5c2704b765a6f9c2"
55
+ "gitHead": "c8454798fb7546174ee8c7ea10e491c5e903e789"
56
56
  }
@@ -222,7 +222,10 @@ export const LexicalEditor = ({
222
222
  >
223
223
  <RichTextPlugin
224
224
  contentEditable={
225
- <ContentEditable className="lexical-editor px-[2cm] py-[1cm] min-h-screen" />
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, useTransition } from "react";
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],
@@ -289,7 +289,6 @@ export const ToolbarPlugin = () => {
289
289
  icon={CoreIcons.formatClear}
290
290
  onClick={() => watch.clearFormatting()}
291
291
  />
292
- <Divider />
293
292
  </div>
294
293
  );
295
294
  };