@lexical/react 0.2.2 → 0.2.5

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.
@@ -22,20 +22,10 @@ var react = require('react');
22
22
  function useList(editor) {
23
23
  react.useEffect(() => {
24
24
  return utils.mergeRegister(editor.registerCommand(lexical.INDENT_CONTENT_COMMAND, () => {
25
- const hasHandledIndention = list.indentList();
26
-
27
- if (hasHandledIndention) {
28
- return true;
29
- }
30
-
25
+ list.indentList();
31
26
  return false;
32
27
  }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.OUTDENT_CONTENT_COMMAND, () => {
33
- const hasHandledIndention = list.outdentList();
34
-
35
- if (hasHandledIndention) {
36
- return true;
37
- }
38
-
28
+ list.outdentList();
39
29
  return false;
40
30
  }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.INSERT_ORDERED_LIST_COMMAND, () => {
41
31
  list.insertList(editor, 'ol');
@@ -5,5 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  var b=require("@lexical/list"),c=require("@lexical/utils"),d=require("lexical"),e=require("react");
8
- function f(a){e.useEffect(()=>c.mergeRegister(a.registerCommand(d.INDENT_CONTENT_COMMAND,()=>b.indentList()?!0:!1,d.COMMAND_PRIORITY_LOW),a.registerCommand(d.OUTDENT_CONTENT_COMMAND,()=>b.outdentList()?!0:!1,d.COMMAND_PRIORITY_LOW),a.registerCommand(b.INSERT_ORDERED_LIST_COMMAND,()=>{b.insertList(a,"ol");return!0},d.COMMAND_PRIORITY_LOW),a.registerCommand(b.INSERT_UNORDERED_LIST_COMMAND,()=>{b.insertList(a,"ul");return!0},d.COMMAND_PRIORITY_LOW),a.registerCommand(b.REMOVE_LIST_COMMAND,()=>{b.removeList(a);
9
- return!0},d.COMMAND_PRIORITY_LOW),a.registerCommand(d.INSERT_PARAGRAPH_COMMAND,()=>b.$handleListInsertParagraph()?!0:!1,d.COMMAND_PRIORITY_LOW)),[a])}module.exports=function(a){f(a)};
8
+ function f(a){e.useEffect(()=>c.mergeRegister(a.registerCommand(d.INDENT_CONTENT_COMMAND,()=>{b.indentList();return!1},d.COMMAND_PRIORITY_LOW),a.registerCommand(d.OUTDENT_CONTENT_COMMAND,()=>{b.outdentList();return!1},d.COMMAND_PRIORITY_LOW),a.registerCommand(b.INSERT_ORDERED_LIST_COMMAND,()=>{b.insertList(a,"ol");return!0},d.COMMAND_PRIORITY_LOW),a.registerCommand(b.INSERT_UNORDERED_LIST_COMMAND,()=>{b.insertList(a,"ul");return!0},d.COMMAND_PRIORITY_LOW),a.registerCommand(b.REMOVE_LIST_COMMAND,()=>
9
+ {b.removeList(a);return!0},d.COMMAND_PRIORITY_LOW),a.registerCommand(d.INSERT_PARAGRAPH_COMMAND,()=>b.$handleListInsertParagraph()?!0:!1,d.COMMAND_PRIORITY_LOW)),[a])}module.exports=function(a){f(a)};
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict';
8
+
9
+ var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
10
+ var LexicalDecoratorBlockNode = require('@lexical/react/LexicalDecoratorBlockNode');
11
+ var useLexicalNodeSelection = require('@lexical/react/useLexicalNodeSelection');
12
+ var utils = require('@lexical/utils');
13
+ var lexical = require('lexical');
14
+ var React = require('react');
15
+
16
+ /**
17
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
18
+ *
19
+ * This source code is licensed under the MIT license found in the
20
+ * LICENSE file in the root directory of this source tree.
21
+ *
22
+ *
23
+ */
24
+ function BlockWithAlignableContents({
25
+ children,
26
+ format,
27
+ nodeKey
28
+ }) {
29
+ const [editor] = LexicalComposerContext.useLexicalComposerContext();
30
+ const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey);
31
+ const ref = React.useRef();
32
+ const onDelete = React.useCallback(payload => {
33
+ if (isSelected && lexical.$isNodeSelection(lexical.$getSelection())) {
34
+ const event = payload;
35
+ event.preventDefault();
36
+ editor.update(() => {
37
+ const node = lexical.$getNodeByKey(nodeKey);
38
+
39
+ if (lexical.$isDecoratorNode(node) && node.isTopLevel()) {
40
+ node.remove();
41
+ }
42
+
43
+ setSelected(false);
44
+ });
45
+ }
46
+
47
+ return false;
48
+ }, [editor, isSelected, nodeKey, setSelected]);
49
+ React.useEffect(() => {
50
+ return utils.mergeRegister(editor.registerCommand(lexical.FORMAT_ELEMENT_COMMAND, payload => {
51
+ if (isSelected) {
52
+ const selection = lexical.$getSelection();
53
+
54
+ if (lexical.$isNodeSelection(selection)) {
55
+ const node = lexical.$getNodeByKey(nodeKey);
56
+
57
+ if (LexicalDecoratorBlockNode.$isDecoratorBlockNode(node)) {
58
+ node.setFormat(payload);
59
+ }
60
+ } else if (lexical.$isRangeSelection(selection)) {
61
+ const nodes = selection.getNodes();
62
+
63
+ for (const node of nodes) {
64
+ if (LexicalDecoratorBlockNode.$isDecoratorBlockNode(node)) {
65
+ node.setFormat(payload);
66
+ } else {
67
+ const element = utils.$getNearestBlockElementAncestorOrThrow(node);
68
+ element.setFormat(payload);
69
+ }
70
+ }
71
+ }
72
+
73
+ return true;
74
+ }
75
+
76
+ return false;
77
+ }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.CLICK_COMMAND, payload => {
78
+ const event = payload;
79
+ event.preventDefault();
80
+
81
+ if (event.target === ref.current) {
82
+ if (!event.shiftKey) {
83
+ clearSelection();
84
+ }
85
+
86
+ setSelected(!isSelected);
87
+ return true;
88
+ }
89
+
90
+ return false;
91
+ }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_DELETE_COMMAND, onDelete, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_BACKSPACE_COMMAND, onDelete, lexical.COMMAND_PRIORITY_LOW));
92
+ }, [clearSelection, editor, isSelected, nodeKey, onDelete, setSelected]);
93
+ return /*#__PURE__*/React.createElement("div", {
94
+ className: `embed-block${isSelected ? ' focused' : ''}`,
95
+ ref: ref,
96
+ style: {
97
+ textAlign: format
98
+ }
99
+ }, children);
100
+ }
101
+
102
+ exports.BlockWithAlignableContents = BlockWithAlignableContents;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict'
8
+ const LexicalBlockWithAlignableContents = process.env.NODE_ENV === 'development' ? require('./LexicalBlockWithAlignableContents.dev.js') : require('./LexicalBlockWithAlignableContents.prod.js')
9
+ module.exports = LexicalBlockWithAlignableContents;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ import type {
11
+ ElementFormatType,
12
+ LexicalEditor,
13
+ EditorThemeClasses,
14
+ LexicalNode,
15
+ NodeKey,
16
+ } from 'lexical';
17
+
18
+ type Props = $ReadOnly<{
19
+ children: React$Node,
20
+ format: ?ElementFormatType,
21
+ nodeKey: NodeKey,
22
+ }>;
23
+
24
+ declare export function BlockWithAlignableContents(Props): React$Node;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ var a=require("@lexical/react/LexicalComposerContext"),h=require("@lexical/react/LexicalDecoratorBlockNode"),m=require("@lexical/react/useLexicalNodeSelection"),n=require("@lexical/utils"),r=require("lexical"),t=require("react");
8
+ exports.BlockWithAlignableContents=function({children:u,format:v,nodeKey:g}){const [d]=a.useLexicalComposerContext(),[e,k,p]=m(g),q=t.useRef(),l=t.useCallback(b=>{e&&r.$isNodeSelection(r.$getSelection())&&(b.preventDefault(),d.update(()=>{const c=r.$getNodeByKey(g);r.$isDecoratorNode(c)&&c.isTopLevel()&&c.remove();k(!1)}));return!1},[d,e,g,k]);t.useEffect(()=>n.mergeRegister(d.registerCommand(r.FORMAT_ELEMENT_COMMAND,b=>{if(e){var c=r.$getSelection();if(r.$isNodeSelection(c)){var f=r.$getNodeByKey(g);
9
+ h.$isDecoratorBlockNode(f)&&f.setFormat(b)}else if(r.$isRangeSelection(c)){c=c.getNodes();for(f of c)h.$isDecoratorBlockNode(f)?f.setFormat(b):n.$getNearestBlockElementAncestorOrThrow(f).setFormat(b)}return!0}return!1},r.COMMAND_PRIORITY_LOW),d.registerCommand(r.CLICK_COMMAND,b=>{b.preventDefault();return b.target===q.current?(b.shiftKey||p(),k(!e),!0):!1},r.COMMAND_PRIORITY_LOW),d.registerCommand(r.KEY_DELETE_COMMAND,l,r.COMMAND_PRIORITY_LOW),d.registerCommand(r.KEY_BACKSPACE_COMMAND,l,r.COMMAND_PRIORITY_LOW)),
10
+ [p,d,e,g,l,k]);return t.createElement("div",{className:`embed-block${e?" focused":""}`,ref:q,style:{textAlign:v}},u)};
@@ -56,7 +56,6 @@ function LexicalComposer({
56
56
 
57
57
  if (editor === null) {
58
58
  const newEditor = lexical.createEditor({
59
- context,
60
59
  namespace,
61
60
  nodes,
62
61
  onError: error => onError(error, newEditor),
@@ -4,5 +4,5 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- var a=require("@lexical/react/LexicalComposerContext"),e=require("lexical"),l=require("react"),m="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?l.useLayoutEffect:l.useEffect;
8
- module.exports=function({initialConfig:f,children:n}){const k=l.useMemo(()=>{const {theme:b,namespace:c,editor__DEPRECATED:p,nodes:q,onError:r}=f,g=a.createLexicalComposerContext(null,b);let d=p||null;if(null===d){const h=e.createEditor({context:g,namespace:c,nodes:q,onError:t=>r(t,h),readOnly:!0,theme:b});d=h}return[d,g]},[]);m(()=>{const b=f.readOnly,[c]=k;c.setReadOnly(b||!1)},[]);return l.createElement(a.LexicalComposerContext.Provider,{value:k},n)};
7
+ var a=require("@lexical/react/LexicalComposerContext"),e=require("lexical"),k=require("react"),l="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?k.useLayoutEffect:k.useEffect;
8
+ module.exports=function({initialConfig:f,children:m}){const h=k.useMemo(()=>{const {theme:b,namespace:c,editor__DEPRECATED:n,nodes:p,onError:q}=f,r=a.createLexicalComposerContext(null,b);let d=n||null;if(null===d){const g=e.createEditor({namespace:c,nodes:p,onError:t=>q(t,g),readOnly:!0,theme:b});d=g}return[d,r]},[]);l(()=>{const b=f.readOnly,[c]=h;c.setReadOnly(b||!1)},[]);return k.createElement(a.LexicalComposerContext.Provider,{value:h},m)};
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict';
8
+
9
+ var lexical = require('lexical');
10
+
11
+ /**
12
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
13
+ *
14
+ * This source code is licensed under the MIT license found in the
15
+ * LICENSE file in the root directory of this source tree.
16
+ *
17
+ *
18
+ */
19
+ class DecoratorBlockNode extends lexical.DecoratorNode {
20
+ constructor(format, key) {
21
+ super(key);
22
+ this.__format = format;
23
+ }
24
+
25
+ createDOM() {
26
+ return document.createElement('div');
27
+ }
28
+
29
+ updateDOM() {
30
+ return false;
31
+ }
32
+
33
+ setFormat(format) {
34
+ const self = this.getWritable();
35
+ self.__format = format;
36
+ }
37
+
38
+ }
39
+ function $isDecoratorBlockNode(node) {
40
+ return node instanceof DecoratorBlockNode;
41
+ }
42
+
43
+ exports.$isDecoratorBlockNode = $isDecoratorBlockNode;
44
+ exports.DecoratorBlockNode = DecoratorBlockNode;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict'
8
+ const LexicalDecoratorBlockNode = process.env.NODE_ENV === 'development' ? require('./LexicalDecoratorBlockNode.dev.js') : require('./LexicalDecoratorBlockNode.prod.js')
9
+ module.exports = LexicalDecoratorBlockNode;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ import type {
11
+ ElementFormatType,
12
+ LexicalNode,
13
+ LexicalCommand,
14
+ NodeKey,
15
+ } from 'lexical';
16
+
17
+ import {DecoratorNode} from 'lexical';
18
+
19
+ declare export class DecoratorBlockNode<T> extends DecoratorNode<T> {
20
+ __format: ?ElementFormatType;
21
+ constructor(format?: ?ElementFormatType, key?: NodeKey): void;
22
+ createDOM(): HTMLElement;
23
+ setFormat(format: ElementFormatType): void;
24
+ }
25
+
26
+ declare export function $isDecoratorBlockNode(
27
+ node: ?LexicalNode,
28
+ ): boolean %checks(node instanceof DecoratorBlockNode);
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ var b=require("lexical");class c extends b.DecoratorNode{constructor(a,d){super(d);this.__format=a}createDOM(){return document.createElement("div")}updateDOM(){return!1}setFormat(a){this.getWritable().__format=a}}exports.$isDecoratorBlockNode=function(a){return a instanceof c};exports.DecoratorBlockNode=c;
@@ -20,6 +20,6 @@ export declare class HorizontalRuleNode extends DecoratorNode<JSX.Element | null
20
20
  export function $createHorizontalRuleNode(): HorizontalRuleNode;
21
21
  export function $isHorizontalRuleNode(
22
22
  node: LexicalNode | null | undefined,
23
- ): boolean;
23
+ ): node is HorizontalRuleNode;
24
24
 
25
25
  export var INSERT_HORIZONTAL_RULE_COMMAND: LexicalCommand<void>;
@@ -78,6 +78,12 @@ function toggleLink(url) {
78
78
  return;
79
79
  }
80
80
 
81
+ if (link.$isLinkNode(parent)) {
82
+ linkNode = parent;
83
+ parent.setURL(url);
84
+ return;
85
+ }
86
+
81
87
  if (!parent.is(prevParent)) {
82
88
  prevParent = parent;
83
89
  linkNode = link.$createLinkNode(url);
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- var g=require("@lexical/link"),k=require("@lexical/react/LexicalComposerContext"),m=require("lexical"),n=require("react");
8
- function p(e){var b=m.$getSelection();null!==b&&m.$setSelection(b);b=m.$getSelection();if(null!==b)if(b=b.extract(),null===e)b.forEach(f=>{f=f.getParent();if(g.$isLinkNode(f)){const c=f.getChildren();for(let a=0;a<c.length;a++)f.insertBefore(c[a]);f.remove()}});else{if(1===b.length){var h=b[0];if(g.$isLinkNode(h)){h.setURL(e);return}h=h.getParent();if(g.$isLinkNode(h)){h.setURL(e);return}}let f=null,c=null;b.forEach(a=>{var d=a.getParent();if(d!==c&&null!==d&&(!m.$isElementNode(a)||a.isInline()))if(d.is(f)||
9
- (f=d,c=g.$createLinkNode(e),g.$isLinkNode(d)?null===a.getPreviousSibling()?d.insertBefore(c):d.insertAfter(c):a.insertBefore(c)),g.$isLinkNode(a)){if(null!==c){d=a.getChildren();for(let l=0;l<d.length;l++)c.append(d[l])}a.remove()}else null!==c&&c.append(a)})}}
10
- module.exports=function(){const [e]=k.useLexicalComposerContext();n.useEffect(()=>{if(!e.hasNodes([g.LinkNode]))throw Error("LinkPlugin: LinkNode not registered on editor");},[e]);n.useEffect(()=>e.registerCommand(g.TOGGLE_LINK_COMMAND,b=>{p(b);return!0},m.COMMAND_PRIORITY_EDITOR),[e]);return null};
7
+ var f=require("@lexical/link"),k=require("@lexical/react/LexicalComposerContext"),m=require("lexical"),n=require("react");
8
+ function p(e){var d=m.$getSelection();null!==d&&m.$setSelection(d);d=m.$getSelection();if(null!==d)if(d=d.extract(),null===e)d.forEach(g=>{g=g.getParent();if(f.$isLinkNode(g)){const a=g.getChildren();for(let b=0;b<a.length;b++)g.insertBefore(a[b]);g.remove()}});else{if(1===d.length){var h=d[0];if(f.$isLinkNode(h)){h.setURL(e);return}h=h.getParent();if(f.$isLinkNode(h)){h.setURL(e);return}}let g=null,a=null;d.forEach(b=>{var c=b.getParent();if(c!==a&&null!==c&&(!m.$isElementNode(b)||b.isInline()))if(f.$isLinkNode(c))a=
9
+ c,c.setURL(e);else if(c.is(g)||(g=c,a=f.$createLinkNode(e),f.$isLinkNode(c)?null===b.getPreviousSibling()?c.insertBefore(a):c.insertAfter(a):b.insertBefore(a)),f.$isLinkNode(b)){if(null!==a){c=b.getChildren();for(let l=0;l<c.length;l++)a.append(c[l])}b.remove()}else null!==a&&a.append(b)})}}
10
+ module.exports=function(){const [e]=k.useLexicalComposerContext();n.useEffect(()=>{if(!e.hasNodes([f.LinkNode]))throw Error("LinkPlugin: LinkNode not registered on editor");},[e]);n.useEffect(()=>e.registerCommand(f.TOGGLE_LINK_COMMAND,d=>{p(d);return!0},m.COMMAND_PRIORITY_EDITOR),[e]);return null};
@@ -23,20 +23,10 @@ var react = require('react');
23
23
  function useList(editor) {
24
24
  react.useEffect(() => {
25
25
  return utils.mergeRegister(editor.registerCommand(lexical.INDENT_CONTENT_COMMAND, () => {
26
- const hasHandledIndention = list.indentList();
27
-
28
- if (hasHandledIndention) {
29
- return true;
30
- }
31
-
26
+ list.indentList();
32
27
  return false;
33
28
  }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.OUTDENT_CONTENT_COMMAND, () => {
34
- const hasHandledIndention = list.outdentList();
35
-
36
- if (hasHandledIndention) {
37
- return true;
38
- }
39
-
29
+ list.outdentList();
40
30
  return false;
41
31
  }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.INSERT_ORDERED_LIST_COMMAND, () => {
42
32
  list.insertList(editor, 'ol');
@@ -5,5 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  var b=require("@lexical/react/LexicalComposerContext"),c=require("@lexical/list"),d=require("@lexical/utils"),e=require("lexical"),f=require("react");
8
- function g(a){f.useEffect(()=>d.mergeRegister(a.registerCommand(e.INDENT_CONTENT_COMMAND,()=>c.indentList()?!0:!1,e.COMMAND_PRIORITY_LOW),a.registerCommand(e.OUTDENT_CONTENT_COMMAND,()=>c.outdentList()?!0:!1,e.COMMAND_PRIORITY_LOW),a.registerCommand(c.INSERT_ORDERED_LIST_COMMAND,()=>{c.insertList(a,"ol");return!0},e.COMMAND_PRIORITY_LOW),a.registerCommand(c.INSERT_UNORDERED_LIST_COMMAND,()=>{c.insertList(a,"ul");return!0},e.COMMAND_PRIORITY_LOW),a.registerCommand(c.REMOVE_LIST_COMMAND,()=>{c.removeList(a);
9
- return!0},e.COMMAND_PRIORITY_LOW),a.registerCommand(e.INSERT_PARAGRAPH_COMMAND,()=>c.$handleListInsertParagraph()?!0:!1,e.COMMAND_PRIORITY_LOW)),[a])}module.exports=function(){const [a]=b.useLexicalComposerContext();g(a);return null};
8
+ function g(a){f.useEffect(()=>d.mergeRegister(a.registerCommand(e.INDENT_CONTENT_COMMAND,()=>{c.indentList();return!1},e.COMMAND_PRIORITY_LOW),a.registerCommand(e.OUTDENT_CONTENT_COMMAND,()=>{c.outdentList();return!1},e.COMMAND_PRIORITY_LOW),a.registerCommand(c.INSERT_ORDERED_LIST_COMMAND,()=>{c.insertList(a,"ol");return!0},e.COMMAND_PRIORITY_LOW),a.registerCommand(c.INSERT_UNORDERED_LIST_COMMAND,()=>{c.insertList(a,"ul");return!0},e.COMMAND_PRIORITY_LOW),a.registerCommand(c.REMOVE_LIST_COMMAND,()=>
9
+ {c.removeList(a);return!0},e.COMMAND_PRIORITY_LOW),a.registerCommand(e.INSERT_PARAGRAPH_COMMAND,()=>c.$handleListInsertParagraph()?!0:!1,e.COMMAND_PRIORITY_LOW)),[a])}module.exports=function(){const [a]=b.useLexicalComposerContext();g(a);return null};
@@ -8,5 +8,7 @@
8
8
 
9
9
  import type {EditorState, LexicalEditor} from 'lexical';
10
10
  export default function OnChangePlugin(arg0: {
11
+ ignoreInitialChange?: boolean;
12
+ ignoreSelectionChange?: boolean;
11
13
  onChange: (editorState: EditorState, editor: LexicalEditor) => void;
12
14
  }): null;
@@ -10,5 +10,7 @@
10
10
  import type {EditorState, LexicalEditor} from 'lexical';
11
11
 
12
12
  declare export default function OnChangePlugin({
13
+ ignoreInitialChange?: boolean,
14
+ ignoreSelectionChange?: boolean,
13
15
  onChange: (editorState: EditorState, editor: LexicalEditor) => void,
14
16
  }): null;
@@ -186,7 +186,7 @@ function printObjectSelection(selection) {
186
186
  }
187
187
 
188
188
  function printGridSelection(selection) {
189
- return `: grid\n └ { grid: ${selection.gridKey}, anchorCell: ${selection.anchorCellKey}, focusCell: ${selection.focusCellKey} }`;
189
+ return `: grid\n └ { grid: ${selection.gridKey}, anchorCell: ${selection.anchor.key}, focusCell: ${selection.focus.key} }`;
190
190
  }
191
191
 
192
192
  function generateContent(editorState) {
@@ -240,7 +240,7 @@ function printNode(node) {
240
240
  return '';
241
241
  }
242
242
 
243
- const FORMAT_PREDICATES = [node => node.hasFormat('bold') && 'Bold', node => node.hasFormat('code') && 'Code', node => node.hasFormat('italic') && 'Italic', node => node.hasFormat('strikethrough') && 'Strikethrough', node => node.hasFormat('underline') && 'Underline'];
243
+ const FORMAT_PREDICATES = [node => node.hasFormat('bold') && 'Bold', node => node.hasFormat('code') && 'Code', node => node.hasFormat('italic') && 'Italic', node => node.hasFormat('strikethrough') && 'Strikethrough', node => node.hasFormat('subscript') && 'Subscript', node => node.hasFormat('superscript') && 'Superscript', node => node.hasFormat('underline') && 'Underline'];
244
244
  const DETAIL_PREDICATES = [node => node.isDirectionless() && 'Directionless', node => node.isUnmergeable() && 'Unmergeable'];
245
245
  const MODE_PREDICATES = [node => node.isToken() && 'Token', node => node.isSegmented() && 'Segmented', node => node.isInert() && 'Inert'];
246
246
 
@@ -7,10 +7,10 @@
7
7
  var k=require("lexical"),q=require("react");const t=Object.freeze({"\t":"\\t","\n":"\\n"}),D=new RegExp(Object.keys(t).join("|"),"g"),E=Object.freeze({ancestorHasNextSibling:"|",ancestorIsLastChild:" ",hasNextSibling:"\u251c",isLastChild:"\u2514",selectedChar:"^",selectedLine:">"});
8
8
  function F(a){let b="";const c=G(a),e=a.anchor;a=a.focus;const d=e.offset,f=a.offset;b=b+`: range ${""!==c?`{ ${c} }`:""}`+`\n \u251c anchor { key: ${e.key}, offset: ${null===d?"null":d}, type: ${e.type} }`;return b+=`\n \u2514 focus { key: ${a.key}, offset: ${null===f?"null":f}, type: ${a.type} }`}
9
9
  function H(a){let b=" root\n";a=a.read(()=>{const c=k.$getSelection();J(k.$getRoot(),(e,d)=>{const f=`(${e.getKey()})`,g=e.getType()||"",m=e.isSelected();var v=b,u=m?E.selectedLine:" ",r=d.join(" ");if(k.$isTextNode(e)){var l=e.getTextContent(!0);const n=0===l.length?"(empty)":`"${K(l)}"`;l=[G(e),L(e),M(e)].filter(Boolean).join(", ");l=[n,0!==l.length?`{ ${l} }`:null].filter(Boolean).join(" ").trim()}else l="";b=v+`${u} ${r} ${f} ${g} ${l}\n`;b+=N({indent:d,isSelected:m,node:e,nodeKeyDisplay:f,selection:c,
10
- typeDisplay:g})});return null===c?": null":k.$isRangeSelection(c)?F(c):k.$isGridSelection(c)?`: grid\n \u2514 { grid: ${c.gridKey}, anchorCell: ${c.anchorCellKey}, focusCell: ${c.focusCellKey} }`:`: node\n \u2514 [${Array.from(c._nodes).join(", ")}]`});return b+"\n selection"+a}
11
- function J(a,b,c=[]){a=a.getChildren();const e=a.length;a.forEach((d,f)=>{b(d,c.concat(f===e-1?E.isLastChild:E.hasNextSibling));k.$isElementNode(d)&&J(d,b,c.concat(f===e-1?E.ancestorIsLastChild:E.ancestorHasNextSibling))})}function K(a){return Object.entries(t).reduce((b,[c,e])=>b.replace(new RegExp(c,"g"),String(e)),a)}
12
- const O=[a=>a.hasFormat("bold")&&"Bold",a=>a.hasFormat("code")&&"Code",a=>a.hasFormat("italic")&&"Italic",a=>a.hasFormat("strikethrough")&&"Strikethrough",a=>a.hasFormat("underline")&&"Underline"],P=[a=>a.isDirectionless()&&"Directionless",a=>a.isUnmergeable()&&"Unmergeable"],Q=[a=>a.isToken()&&"Token",a=>a.isSegmented()&&"Segmented",a=>a.isInert()&&"Inert"];function L(a){let b=P.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="detail: "+b);return b}
13
- function M(a){let b=Q.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="mode: "+b);return b}function G(a){let b=O.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="format: "+b);return b}
10
+ typeDisplay:g})});return null===c?": null":k.$isRangeSelection(c)?F(c):k.$isGridSelection(c)?`: grid\n \u2514 { grid: ${c.gridKey}, anchorCell: ${c.anchor.key}, focusCell: ${c.focus.key} }`:`: node\n \u2514 [${Array.from(c._nodes).join(", ")}]`});return b+"\n selection"+a}function J(a,b,c=[]){a=a.getChildren();const e=a.length;a.forEach((d,f)=>{b(d,c.concat(f===e-1?E.isLastChild:E.hasNextSibling));k.$isElementNode(d)&&J(d,b,c.concat(f===e-1?E.ancestorIsLastChild:E.ancestorHasNextSibling))})}
11
+ function K(a){return Object.entries(t).reduce((b,[c,e])=>b.replace(new RegExp(c,"g"),String(e)),a)}
12
+ const O=[a=>a.hasFormat("bold")&&"Bold",a=>a.hasFormat("code")&&"Code",a=>a.hasFormat("italic")&&"Italic",a=>a.hasFormat("strikethrough")&&"Strikethrough",a=>a.hasFormat("subscript")&&"Subscript",a=>a.hasFormat("superscript")&&"Superscript",a=>a.hasFormat("underline")&&"Underline"],P=[a=>a.isDirectionless()&&"Directionless",a=>a.isUnmergeable()&&"Unmergeable"],Q=[a=>a.isToken()&&"Token",a=>a.isSegmented()&&"Segmented",a=>a.isInert()&&"Inert"];
13
+ function L(a){let b=P.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="detail: "+b);return b}function M(a){let b=Q.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="mode: "+b);return b}function G(a){let b=O.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="format: "+b);return b}
14
14
  function N({indent:a,isSelected:b,node:c,nodeKeyDisplay:e,selection:d,typeDisplay:f}){if(!k.$isTextNode(c)||!k.$isRangeSelection(d)||!b||k.$isElementNode(c))return"";b=d.anchor;var g=d.focus;if(""===c.getTextContent()||b.getNode()===d.focus.getNode()&&b.offset===g.offset)return"";g=d.anchor;const m=d.focus,v=c.getTextContent(!0),u=v.length;b=d=-1;if("text"===g.type&&"text"===m.type){const n=g.getNode(),w=m.getNode();n===w&&c===n&&g.offset!==m.offset?[d,b]=g.offset<m.offset?[g.offset,m.offset]:[m.offset,
15
15
  g.offset]:c===n?[d,b]=n.isBefore(w)?[g.offset,u]:[0,g.offset]:c===w?[d,b]=w.isBefore(n)?[m.offset,u]:[0,m.offset]:[d,b]=[0,u]}c=(v.slice(0,d).match(D)||[]).length;g=(v.slice(d,b).match(D)||[]).length;const [r,l]=[d+c,b+c+g];if(r===l)return"";c=a[a.length-1]===E.hasNextSibling?E.ancestorHasNextSibling:E.ancestorIsLastChild;a=[...a.slice(0,a.length-1),c];c=Array(r).fill(" ");d=Array(l-r).fill(E.selectedChar);e=Array(e.length+(f.length+3)).fill(" ");return[E.selectedLine,a.join(" "),[...e,...c,...d].join("")].join(" ")+
16
16
  "\n"}
package/package.json CHANGED
@@ -8,27 +8,27 @@
8
8
  "rich-text"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.2.2",
11
+ "version": "0.2.5",
12
12
  "dependencies": {
13
- "@lexical/clipboard": "0.2.2",
14
- "@lexical/list": "0.2.2",
15
- "@lexical/table": "0.2.2",
16
- "@lexical/yjs": "0.2.2",
17
- "@lexical/hashtag": "0.2.2",
18
- "@lexical/selection": "0.2.2",
19
- "@lexical/utils": "0.2.2",
20
- "@lexical/dragon": "0.2.2",
21
- "@lexical/plain-text": "0.2.2",
22
- "@lexical/rich-text": "0.2.2",
23
- "@lexical/code": "0.2.2",
24
- "@lexical/text": "0.2.2",
25
- "@lexical/link": "0.2.2",
26
- "@lexical/overflow": "0.2.2",
27
- "@lexical/history": "0.2.2",
28
- "@lexical/markdown": "0.2.2"
13
+ "@lexical/clipboard": "0.2.5",
14
+ "@lexical/list": "0.2.5",
15
+ "@lexical/table": "0.2.5",
16
+ "@lexical/yjs": "0.2.5",
17
+ "@lexical/hashtag": "0.2.5",
18
+ "@lexical/selection": "0.2.5",
19
+ "@lexical/utils": "0.2.5",
20
+ "@lexical/dragon": "0.2.5",
21
+ "@lexical/plain-text": "0.2.5",
22
+ "@lexical/rich-text": "0.2.5",
23
+ "@lexical/code": "0.2.5",
24
+ "@lexical/text": "0.2.5",
25
+ "@lexical/link": "0.2.5",
26
+ "@lexical/overflow": "0.2.5",
27
+ "@lexical/history": "0.2.5",
28
+ "@lexical/markdown": "0.2.5"
29
29
  },
30
30
  "peerDependencies": {
31
- "lexical": "0.2.2",
31
+ "lexical": "0.2.5",
32
32
  "react": ">=17.x",
33
33
  "react-dom": ">=17.x"
34
34
  },