@lexical/react 0.2.3 → 0.2.6

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.
Files changed (37) hide show
  1. package/DEPRECATED_useLexicalAutoFormatter.dev.js +2 -15
  2. package/DEPRECATED_useLexicalAutoFormatter.prod.js +1 -1
  3. package/DEPRECATED_useLexicalCharacterLimit.prod.js +1 -1
  4. package/DEPRECATED_useLexicalList.dev.js +4 -14
  5. package/DEPRECATED_useLexicalList.prod.js +2 -2
  6. package/LexicalAutoLinkPlugin.prod.js +1 -1
  7. package/LexicalBlockWithAlignableContents.dev.js +102 -0
  8. package/LexicalBlockWithAlignableContents.js +9 -0
  9. package/LexicalBlockWithAlignableContents.js.flow +24 -0
  10. package/LexicalBlockWithAlignableContents.prod.js +10 -0
  11. package/LexicalCharacterLimitPlugin.prod.js +1 -1
  12. package/LexicalCheckListPlugin.dev.js +247 -0
  13. package/LexicalCheckListPlugin.js +9 -0
  14. package/LexicalCheckListPlugin.js.flow +10 -0
  15. package/LexicalCheckListPlugin.prod.js +14 -0
  16. package/LexicalComposer.dev.js +0 -1
  17. package/LexicalComposer.prod.js +2 -2
  18. package/LexicalComposerContext.prod.js +1 -1
  19. package/LexicalDecoratorBlockNode.dev.js +44 -0
  20. package/LexicalDecoratorBlockNode.js +9 -0
  21. package/LexicalDecoratorBlockNode.js.flow +28 -0
  22. package/LexicalDecoratorBlockNode.prod.js +7 -0
  23. package/LexicalHorizontalRuleNode.d.ts +1 -1
  24. package/LexicalLinkPlugin.dev.js +6 -0
  25. package/LexicalLinkPlugin.prod.js +4 -4
  26. package/LexicalListPlugin.dev.js +4 -14
  27. package/LexicalListPlugin.prod.js +2 -2
  28. package/LexicalMarkdownShortcutPlugin.dev.js +7 -18
  29. package/LexicalMarkdownShortcutPlugin.js.flow +5 -1
  30. package/LexicalMarkdownShortcutPlugin.prod.js +1 -1
  31. package/LexicalNestedComposer.prod.js +1 -1
  32. package/LexicalOnChangePlugin.d.ts +2 -0
  33. package/LexicalOnChangePlugin.js.flow +2 -0
  34. package/LexicalTablePlugin.prod.js +1 -1
  35. package/LexicalTreeView.dev.js +5 -3
  36. package/LexicalTreeView.prod.js +13 -13
  37. package/package.json +19 -18
@@ -7,7 +7,6 @@
7
7
  'use strict';
8
8
 
9
9
  var markdown = require('@lexical/markdown');
10
- var LexicalHorizontalRuleNode = require('@lexical/react/LexicalHorizontalRuleNode');
11
10
  var react = require('react');
12
11
 
13
12
  /**
@@ -18,22 +17,10 @@ var react = require('react');
18
17
  *
19
18
  *
20
19
  */
21
- function useMarkdownShortcuts(editor) {
20
+ function useLexicalAutoFormatter(editor) {
22
21
  react.useEffect(() => {
23
- return markdown.registerMarkdownShortcuts(editor, LexicalHorizontalRuleNode.$createHorizontalRuleNode);
22
+ return markdown.registerMarkdownShortcuts(editor, markdown.TRANSFORMERS);
24
23
  }, [editor]);
25
24
  }
26
25
 
27
- /**
28
- * Copyright (c) Meta Platforms, Inc. and affiliates.
29
- *
30
- * This source code is licensed under the MIT license found in the
31
- * LICENSE file in the root directory of this source tree.
32
- *
33
- *
34
- */
35
- function useLexicalAutoFormatter(editor) {
36
- useMarkdownShortcuts(editor);
37
- }
38
-
39
26
  module.exports = useLexicalAutoFormatter;
@@ -4,4 +4,4 @@
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 b=require("@lexical/markdown"),c=require("@lexical/react/LexicalHorizontalRuleNode"),d=require("react");function e(a){d.useEffect(()=>b.registerMarkdownShortcuts(a,c.$createHorizontalRuleNode),[a])}module.exports=function(a){e(a)};
7
+ var a=require("@lexical/markdown"),c=require("react");module.exports=function(b){c.useEffect(()=>a.registerMarkdownShortcuts(b,a.TRANSFORMERS),[b])};
@@ -8,6 +8,6 @@ var k=require("@lexical/overflow"),q=require("@lexical/text"),w=require("@lexica
8
8
  function C(a){const d=a.getChildren(),f=d.length;for(let e=0;e<f;e++)a.insertBefore(d[e]);a.remove();return 0<f?d[f-1]:null}
9
9
  function D(a){const d=a.getPreviousSibling();if(k.$isOverflowNode(d)){var f=a.getFirstChild(),e=d.getChildren(),m=e.length;if(null===f)a.append(...e);else for(var c=0;c<m;c++)f.insertBefore(e[c]);c=x.$getSelection();if(x.$isRangeSelection(c)){f=c.anchor;e=f.getNode();c=c.focus;const g=f.getNode();e.is(d)?f.set(a.getKey(),f.offset,"element"):e.is(a)&&f.set(a.getKey(),m+f.offset,"element");g.is(d)?c.set(a.getKey(),c.offset,"element"):g.is(a)&&c.set(a.getKey(),m+c.offset,"element")}d.remove()}}
10
10
  exports.mergePrevious=D;
11
- exports.useCharacterLimit=function(a,d,f=Object.freeze({})){const {strlen:e=c=>c.length,remainingCharacters:m=()=>{}}=f;y.useEffect(()=>{if(!a.hasNodes([k.OverflowNode]))throw Error("Minified Lexical error #58; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");},[a]);y.useEffect(()=>{let c=a.getEditorState().read(q.$rootTextContentCurry),g=0;return w.mergeRegister(a.registerTextContentListener(n=>{c=n}),a.registerUpdateListener(({dirtyLeaves:n})=>
11
+ exports.useCharacterLimit=function(a,d,f=Object.freeze({})){const {strlen:e=c=>c.length,remainingCharacters:m=()=>{}}=f;y.useEffect(()=>{if(!a.hasNodes([k.OverflowNode]))throw Error("Minified Lexical error #49; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");},[a]);y.useEffect(()=>{let c=a.getEditorState().read(q.$rootTextContentCurry),g=0;return w.mergeRegister(a.registerTextContentListener(n=>{c=n}),a.registerUpdateListener(({dirtyLeaves:n})=>
12
12
  {var r=a.isComposing();n=0<n.size;if(!r&&n){r=e(c);n=r>d||null!==g&&g>d;m(d-r);if(null===g||n){const p=z(c,d,e);a.update(()=>{const B=w.$dfs(),E=B.length;let t=0;for(let v=0;v<E;v+=1){var {node:b}=B[v];if(k.$isOverflowNode(b)){var l=t;if(t+b.getTextContentSize()<=p){var h=b.getParent();l=b.getPreviousSibling();var u=b.getNextSibling();C(b);b=x.$getSelection();!x.$isRangeSelection(b)||b.anchor.getNode().isAttached()&&b.focus.getNode().isAttached()||(x.$isTextNode(l)?l.select():x.$isTextNode(u)?u.select():
13
13
  null!==h&&h.select())}else l<p&&(h=b.getFirstDescendant(),u=null!==h?h.getTextContentSize():0,l+=u,h=x.$isTextNode(h)&&h.isSimpleText(),l=l<=p,(h||l)&&C(b))}else x.$isLeafNode(b)&&(l=t,t+=b.getTextContentSize(),t>p&&!k.$isOverflowNode(b.getParent())&&(h=x.$getSelection(),l<p&&x.$isTextNode(b)&&b.isSimpleText()?([,b]=b.splitText(p-l),b=A(b)):b=A(b),null!==h&&x.$setSelection(h),D(b)))}},{tag:"history-merge"})}g=r}}))},[a,d,m,e])};
@@ -22,26 +22,16 @@ 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
- list.insertList(editor, 'ol');
31
+ list.insertList(editor, 'number');
42
32
  return true;
43
33
  }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.INSERT_UNORDERED_LIST_COMMAND, () => {
44
- list.insertList(editor, 'ul');
34
+ list.insertList(editor, 'bullet');
45
35
  return true;
46
36
  }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.REMOVE_LIST_COMMAND, () => {
47
37
  list.removeList(editor);
@@ -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,"number");return!0},d.COMMAND_PRIORITY_LOW),a.registerCommand(b.INSERT_UNORDERED_LIST_COMMAND,()=>{b.insertList(a,"bullet");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)};
@@ -7,6 +7,6 @@
7
7
  var h=require("@lexical/link"),k=require("@lexical/react/LexicalComposerContext"),p=require("@lexical/utils"),v=require("lexical"),w=require("react");function x(a,b){for(let c=0;c<b.length;c++){const d=b[c](a);if(d)return d}return null}function y(a){a=a.getPreviousSibling();v.$isElementNode(a)&&(a=a.getLastDescendant());return null===a||v.$isLineBreakNode(a)||v.$isTextNode(a)&&a.getTextContent().endsWith(" ")}
8
8
  function A(a){a=a.getNextSibling();v.$isElementNode(a)&&(a=a.getFirstDescendant());return null===a||v.$isLineBreakNode(a)||v.$isTextNode(a)&&a.getTextContent().startsWith(" ")}
9
9
  function B(a,b,c){var d=a.getChildren();const e=d.length;for(let g=0;g<e;g++){const f=d[g];if(!v.$isTextNode(f)||!f.isSimpleText()){C(a);c(null,a.getURL());return}}d=a.getTextContent();b=x(d,b);null===b||b.text!==d?(C(a),c(null,a.getURL())):y(a)&&A(a)?(d=a.getURL(),null!==b&&d!==b.url&&(a.setURL(b.url),c(b.url,d))):(C(a),c(null,a.getURL()))}function C(a){const b=a.getChildren();var c=b.length;for(--c;0<=c;c--)a.insertAfter(b[c]);a.remove();return b.map(d=>d.getLatest())}
10
- function D(a,b,c){w.useEffect(()=>{if(!a.hasNodes([h.AutoLinkNode]))throw Error("Minified Lexical error #53; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");const d=(...e)=>{c&&c(...e)};return p.mergeRegister(a.registerNodeTransform(v.TextNode,e=>{var g=e.getParentOrThrow();if(h.$isAutoLinkNode(g))B(g,b,d);else if(!h.$isLinkNode(g)){if(e.isSimpleText()){g=e.getTextContent();const E=g.length;let u=g,z=0,t=e;for(var f;(f=
10
+ function D(a,b,c){w.useEffect(()=>{if(!a.hasNodes([h.AutoLinkNode]))throw Error("Minified Lexical error #5; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");const d=(...e)=>{c&&c(...e)};return p.mergeRegister(a.registerNodeTransform(v.TextNode,e=>{var g=e.getParentOrThrow();if(h.$isAutoLinkNode(g))B(g,b,d);else if(!h.$isLinkNode(g)){if(e.isSimpleText()){g=e.getTextContent();const E=g.length;let u=g,z=0,t=e;for(var f;(f=
11
11
  x(u,b))&&null!==f;){var l=f.index,n=z+l;const q=f.length;var r=void 0;r=0<n?" "===g[n-1]:y(e);n=n+q<E?" "===g[n+q]:A(e);if(r&&n){var m=void 0;0===l?[m,t]=t.splitText(q):[,m,t]=t.splitText(l,l+q);r=h.$createAutoLinkNode(f.url);r.append(v.$createTextNode(f.text));m.replace(r);d(f.url,null)}l+=q;u=u.substring(l);z+=l}}f=e.getPreviousSibling();m=e.getNextSibling();e=e.getTextContent();h.$isAutoLinkNode(f)&&!e.startsWith(" ")&&(C(f),d(null,f.getURL()));h.$isAutoLinkNode(m)&&!e.endsWith(" ")&&(C(m),d(null,
12
12
  m.getURL()))}}),a.registerNodeTransform(h.AutoLinkNode,e=>{B(e,b,d)}))},[a,b,c])}module.exports=function({matchers:a,onChange:b}){const [c]=k.useLexicalComposerContext();D(c,a,b);return null};
@@ -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)};
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  var m=require("@lexical/react/LexicalComposerContext"),u=require("react"),v=require("@lexical/overflow"),z=require("@lexical/text"),A=require("@lexical/utils"),C=require("lexical");
8
- function D(b,c,n=Object.freeze({})){const {strlen:g=d=>d.length,remainingCharacters:q=()=>{}}=n;u.useEffect(()=>{if(!b.hasNodes([v.OverflowNode]))throw Error("Minified Lexical error #58; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");},[b]);u.useEffect(()=>{let d=b.getEditorState().read(z.$rootTextContentCurry),e=0;return A.mergeRegister(b.registerTextContentListener(p=>{d=p}),b.registerUpdateListener(({dirtyLeaves:p})=>
8
+ function D(b,c,n=Object.freeze({})){const {strlen:g=d=>d.length,remainingCharacters:q=()=>{}}=n;u.useEffect(()=>{if(!b.hasNodes([v.OverflowNode]))throw Error("Minified Lexical error #49; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");},[b]);u.useEffect(()=>{let d=b.getEditorState().read(z.$rootTextContentCurry),e=0;return A.mergeRegister(b.registerTextContentListener(p=>{d=p}),b.registerUpdateListener(({dirtyLeaves:p})=>
9
9
  {var w=b.isComposing();p=0<p.size;if(!w&&p){w=g(d);p=w>c||null!==e&&e>c;q(c-w);if(null===e||p){const r=F(d,c,g);b.update(()=>{const B=A.$dfs(),J=B.length;let x=0;for(let y=0;y<J;y+=1){var {node:a}=B[y];if(v.$isOverflowNode(a)){var f=x;if(x+a.getTextContentSize()<=r){var h=a.getParent();f=a.getPreviousSibling();var k=a.getNextSibling();G(a);a=C.$getSelection();!C.$isRangeSelection(a)||a.anchor.getNode().isAttached()&&a.focus.getNode().isAttached()||(C.$isTextNode(f)?f.select():C.$isTextNode(k)?k.select():
10
10
  null!==h&&h.select())}else f<r&&(h=a.getFirstDescendant(),k=null!==h?h.getTextContentSize():0,f+=k,h=C.$isTextNode(h)&&h.isSimpleText(),f=f<=r,(h||f)&&G(a))}else if(C.$isLeafNode(a)&&(f=x,x+=a.getTextContentSize(),x>r&&!v.$isOverflowNode(a.getParent())&&(h=C.$getSelection(),f<r&&C.$isTextNode(a)&&a.isSimpleText()?([,a]=a.splitText(r-f),a=H(a)):a=H(a),null!==h&&C.$setSelection(h),f=a.getPreviousSibling(),v.$isOverflowNode(f)))){k=a.getFirstChild();var t=f.getChildren();h=t.length;if(null===k)a.append(...t);
11
11
  else for(var l=0;l<h;l++)k.insertBefore(t[l]);l=C.$getSelection();if(C.$isRangeSelection(l)){k=l.anchor;t=k.getNode();l=l.focus;const E=k.getNode();t.is(f)?k.set(a.getKey(),k.offset,"element"):t.is(a)&&k.set(a.getKey(),h+k.offset,"element");E.is(f)?l.set(a.getKey(),l.offset,"element"):E.is(a)&&l.set(a.getKey(),h+l.offset,"element")}f.remove()}}},{tag:"history-merge"})}e=w}}))},[b,c,q,g])}
@@ -0,0 +1,247 @@
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 list = require('@lexical/list');
10
+ var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
11
+ var utils = require('@lexical/utils');
12
+ var lexical = require('lexical');
13
+ var react = require('react');
14
+
15
+ /**
16
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
17
+ *
18
+ * This source code is licensed under the MIT license found in the
19
+ * LICENSE file in the root directory of this source tree.
20
+ *
21
+ *
22
+ */
23
+ function ListPlugin() {
24
+ const [editor] = LexicalComposerContext.useLexicalComposerContext();
25
+ react.useEffect(() => {
26
+ return utils.mergeRegister(editor.registerCommand(list.INSERT_CHECK_LIST_COMMAND, () => {
27
+ list.insertList(editor, 'check');
28
+ return true;
29
+ }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_ARROW_DOWN_COMMAND, event => {
30
+ return handleArrownUpOrDown(event, editor, false);
31
+ }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_ARROW_UP_COMMAND, event => {
32
+ return handleArrownUpOrDown(event, editor, true);
33
+ }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_ESCAPE_COMMAND, event => {
34
+ const activeItem = getActiveCheckListItem();
35
+
36
+ if (activeItem != null) {
37
+ const rootElement = editor.getRootElement();
38
+
39
+ if (rootElement != null) {
40
+ rootElement.focus();
41
+ }
42
+
43
+ return true;
44
+ }
45
+
46
+ return false;
47
+ }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_SPACE_COMMAND, event => {
48
+ const activeItem = getActiveCheckListItem();
49
+
50
+ if (activeItem != null) {
51
+ editor.update(() => {
52
+ const listItemNode = lexical.$getNearestNodeFromDOMNode(activeItem);
53
+
54
+ if (list.$isListItemNode(listItemNode)) {
55
+ event.preventDefault();
56
+ listItemNode.toggleChecked();
57
+ }
58
+ });
59
+ return true;
60
+ }
61
+
62
+ return false;
63
+ }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_ARROW_LEFT_COMMAND, event => {
64
+ return editor.getEditorState().read(() => {
65
+ const selection = lexical.$getSelection();
66
+
67
+ if (lexical.$isRangeSelection(selection) && selection.isCollapsed()) {
68
+ const {
69
+ anchor
70
+ } = selection;
71
+ const isElement = anchor.type === 'element';
72
+
73
+ if (isElement || anchor.offset === 0) {
74
+ const anchorNode = anchor.getNode();
75
+ const elementNode = utils.$findMatchingParent(anchorNode, node => lexical.$isElementNode(node) && !node.isInline());
76
+
77
+ if (list.$isListItemNode(elementNode) && (isElement || elementNode.getFirstDescendant() === anchorNode)) {
78
+ const domNode = editor.getElementByKey(elementNode.__key);
79
+
80
+ if (domNode != null && document.activeElement !== domNode) {
81
+ domNode.focus();
82
+ event.preventDefault();
83
+ return true;
84
+ }
85
+ }
86
+ }
87
+ }
88
+
89
+ return false;
90
+ });
91
+ }, lexical.COMMAND_PRIORITY_LOW), listenPointerDown());
92
+ });
93
+ return null;
94
+ }
95
+ let listenersCount = 0;
96
+
97
+ function listenPointerDown() {
98
+ if (listenersCount++ === 0) {
99
+ // $FlowFixMe[speculation-ambiguous]
100
+ document.addEventListener('click', handleClick); // $FlowFixMe[speculation-ambiguous]
101
+
102
+ document.addEventListener('pointerdown', handlePointerDown);
103
+ }
104
+
105
+ return () => {
106
+ if (--listenersCount === 0) {
107
+ // $FlowFixMe[speculation-ambiguous]
108
+ document.removeEventListener('click', handleClick); // $FlowFixMe[speculation-ambiguous]
109
+
110
+ document.removeEventListener('pointerdown', handlePointerDown);
111
+ }
112
+ };
113
+ }
114
+
115
+ function handleCheckItemEvent(event, callback) {
116
+ const target = event.target;
117
+
118
+ if (!(target instanceof HTMLElement)) {
119
+ return;
120
+ } // Ignore clicks on LI that have nested lists
121
+ // $FlowFixMe
122
+
123
+
124
+ const firstChild = target.firstChild;
125
+
126
+ if (firstChild != null && (firstChild.tagName === 'UL' || firstChild.tagName === 'OL')) {
127
+ return;
128
+ }
129
+
130
+ const parentNode = target.parentNode; // $FlowFixMe[prop-missing] internal field
131
+
132
+ if (!parentNode || parentNode.__lexicalListType !== 'check') {
133
+ return;
134
+ }
135
+
136
+ const pageX = event.pageX;
137
+ const rect = target.getBoundingClientRect();
138
+
139
+ if (target.dir === 'rtl' ? pageX < rect.right && pageX > rect.right - 20 : pageX > rect.left && pageX < rect.left + 20) {
140
+ callback();
141
+ }
142
+ }
143
+
144
+ function handleClick(event) {
145
+ handleCheckItemEvent(event, () => {
146
+ const editor = findEditor(event.target);
147
+
148
+ if (editor != null) {
149
+ editor.update(() => {
150
+ const node = lexical.$getNearestNodeFromDOMNode(event.target);
151
+
152
+ if (list.$isListItemNode(node)) {
153
+ event.target.focus();
154
+ node.toggleChecked();
155
+ }
156
+ });
157
+ }
158
+ });
159
+ }
160
+
161
+ function handlePointerDown(event) {
162
+ handleCheckItemEvent(event, () => {
163
+ // Prevents caret moving when clicking on check mark
164
+ event.preventDefault();
165
+ });
166
+ }
167
+
168
+ function findEditor(target) {
169
+ let node = target;
170
+
171
+ while (node) {
172
+ if (node.__lexicalEditor) {
173
+ return node.__lexicalEditor;
174
+ }
175
+
176
+ node = node.parentNode;
177
+ }
178
+
179
+ return null;
180
+ }
181
+
182
+ function getActiveCheckListItem() {
183
+ const {
184
+ activeElement
185
+ } = document;
186
+ return activeElement != null && activeElement.tagName === 'LI' && activeElement.parentNode != null && // $FlowFixMe[prop-missing] internal field
187
+ activeElement.parentNode.__lexicalListType === 'check' ? activeElement : null;
188
+ }
189
+
190
+ function findCheckListItemSibling(node, backward) {
191
+ let sibling = backward ? node.getPreviousSibling() : node.getNextSibling();
192
+ let parent = node; // Going up in a tree to get non-null sibling
193
+
194
+ while (sibling == null && list.$isListItemNode(parent)) {
195
+ // Get li -> parent ul/ol -> parent li
196
+ parent = parent.getParentOrThrow().getParent();
197
+
198
+ if (parent != null) {
199
+ sibling = backward ? parent.getPreviousSibling() : parent.getNextSibling();
200
+ }
201
+ } // Going down in a tree to get first non-nested list item
202
+
203
+
204
+ while (list.$isListItemNode(sibling)) {
205
+ const firstChild = backward ? sibling.getLastChild() : sibling.getFirstChild();
206
+
207
+ if (!list.$isListNode(firstChild)) {
208
+ return sibling;
209
+ }
210
+
211
+ sibling = backward ? firstChild.getLastChild() : firstChild.getFirstChild();
212
+ }
213
+
214
+ return null;
215
+ }
216
+
217
+ function handleArrownUpOrDown(event, editor, backward) {
218
+ const activeItem = getActiveCheckListItem();
219
+
220
+ if (activeItem != null) {
221
+ editor.update(() => {
222
+ const listItem = lexical.$getNearestNodeFromDOMNode(activeItem);
223
+
224
+ if (!list.$isListItemNode(listItem)) {
225
+ return;
226
+ }
227
+
228
+ const nextListItem = findCheckListItemSibling(listItem, backward);
229
+
230
+ if (nextListItem != null) {
231
+ nextListItem.selectStart();
232
+ const dom = editor.getElementByKey(nextListItem.__key);
233
+
234
+ if (dom != null) {
235
+ event.preventDefault();
236
+ setTimeout(() => {
237
+ dom.focus();
238
+ }, 0);
239
+ }
240
+ }
241
+ });
242
+ }
243
+
244
+ return false;
245
+ }
246
+
247
+ module.exports = ListPlugin;
@@ -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 LexicalCheckListPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalCheckListPlugin.dev.js') : require('./LexicalCheckListPlugin.prod.js')
9
+ module.exports = LexicalCheckListPlugin;
@@ -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
+ * @flow strict
8
+ */
9
+
10
+ declare export default function LexicalCheckListPlugin(): null;
@@ -0,0 +1,14 @@
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 e=require("@lexical/list"),g=require("@lexical/react/LexicalComposerContext"),k=require("@lexical/utils"),l=require("lexical"),m=require("react");let n=0;function p(){0===n++&&(document.addEventListener("click",q),document.addEventListener("pointerdown",r));return()=>{0===--n&&(document.removeEventListener("click",q),document.removeEventListener("pointerdown",r))}}
8
+ function t(a,c){const b=a.target;if(b instanceof HTMLElement){var d=b.firstChild;(null==d||"UL"!==d.tagName&&"OL"!==d.tagName)&&(d=b.parentNode)&&"check"===d.__lexicalListType&&(a=a.pageX,d=b.getBoundingClientRect(),("rtl"===b.dir?a<d.right&&a>d.right-20:a>d.left&&a<d.left+20)&&c())}}function q(a){t(a,()=>{const c=u(a.target);null!=c&&c.update(()=>{const b=l.$getNearestNodeFromDOMNode(a.target);e.$isListItemNode(b)&&(a.target.focus(),b.toggleChecked())})})}
9
+ function r(a){t(a,()=>{a.preventDefault()})}function u(a){for(;a;){if(a.__lexicalEditor)return a.__lexicalEditor;a=a.parentNode}return null}function v(){const {activeElement:a}=document;return null!=a&&"LI"===a.tagName&&null!=a.parentNode&&"check"===a.parentNode.__lexicalListType?a:null}
10
+ function w(a,c){let b=c?a.getPreviousSibling():a.getNextSibling();for(;null==b&&e.$isListItemNode(a);)a=a.getParentOrThrow().getParent(),null!=a&&(b=c?a.getPreviousSibling():a.getNextSibling());for(;e.$isListItemNode(b);){a=c?b.getLastChild():b.getFirstChild();if(!e.$isListNode(a))return b;b=c?a.getLastChild():a.getFirstChild()}return null}
11
+ function x(a,c,b){const d=v();null!=d&&c.update(()=>{var f=l.$getNearestNodeFromDOMNode(d);if(e.$isListItemNode(f)&&(f=w(f,b),null!=f)){f.selectStart();const h=c.getElementByKey(f.__key);null!=h&&(a.preventDefault(),setTimeout(()=>{h.focus()},0))}});return!1}
12
+ module.exports=function(){const [a]=g.useLexicalComposerContext();m.useEffect(()=>k.mergeRegister(a.registerCommand(e.INSERT_CHECK_LIST_COMMAND,()=>{e.insertList(a,"check");return!0},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_DOWN_COMMAND,c=>x(c,a,!1),l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_UP_COMMAND,c=>x(c,a,!0),l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ESCAPE_COMMAND,()=>{if(null!=v()){const c=a.getRootElement();null!=c&&c.focus();return!0}return!1},l.COMMAND_PRIORITY_LOW),
13
+ a.registerCommand(l.KEY_SPACE_COMMAND,c=>{const b=v();return null!=b?(a.update(()=>{const d=l.$getNearestNodeFromDOMNode(b);e.$isListItemNode(d)&&(c.preventDefault(),d.toggleChecked())}),!0):!1},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_LEFT_COMMAND,c=>a.getEditorState().read(()=>{var b=l.$getSelection();if(l.$isRangeSelection(b)&&b.isCollapsed()){var {anchor:d}=b;if((b="element"===d.type)||0===d.offset){d=d.getNode();const f=k.$findMatchingParent(d,h=>l.$isElementNode(h)&&!h.isInline());
14
+ if(e.$isListItemNode(f)&&(b||f.getFirstDescendant()===d)&&(b=a.getElementByKey(f.__key),null!=b&&document.activeElement!==b))return b.focus(),c.preventDefault(),!0}}return!1}),l.COMMAND_PRIORITY_LOW),p()));return null};
@@ -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)};
@@ -4,4 +4,4 @@
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 c=require("react");const d=c.createContext(null);exports.LexicalComposerContext=d;exports.createLexicalComposerContext=function(a,e){let b=null;null!=a&&(b=a[1]);return{getTheme:function(){return null!=e?e:null!=b?b.getTheme():null}}};exports.useLexicalComposerContext=function(){const a=c.useContext(d);if(null==a)throw Error("Minified Lexical error #0; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return a};
7
+ var c=require("react");const d=c.createContext(null);exports.LexicalComposerContext=d;exports.createLexicalComposerContext=function(a,e){let b=null;null!=a&&(b=a[1]);return{getTheme:function(){return null!=e?e:null!=b?b.getTheme():null}}};exports.useLexicalComposerContext=function(){const a=c.useContext(d);if(null==a)throw Error("Minified Lexical error #6; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return a};
@@ -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,26 +23,16 @@ 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
- list.insertList(editor, 'ol');
32
+ list.insertList(editor, 'number');
43
33
  return true;
44
34
  }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.INSERT_UNORDERED_LIST_COMMAND, () => {
45
- list.insertList(editor, 'ul');
35
+ list.insertList(editor, 'bullet');
46
36
  return true;
47
37
  }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.REMOVE_LIST_COMMAND, () => {
48
38
  list.removeList(editor);
@@ -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,"number");return!0},e.COMMAND_PRIORITY_LOW),a.registerCommand(c.INSERT_UNORDERED_LIST_COMMAND,()=>{c.insertList(a,"bullet");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};
@@ -6,9 +6,8 @@
6
6
  */
7
7
  'use strict';
8
8
 
9
- var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
10
9
  var markdown = require('@lexical/markdown');
11
- var LexicalHorizontalRuleNode = require('@lexical/react/LexicalHorizontalRuleNode');
10
+ var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
12
11
  var react = require('react');
13
12
 
14
13
  /**
@@ -19,23 +18,13 @@ var react = require('react');
19
18
  *
20
19
  *
21
20
  */
22
- function useMarkdownShortcuts(editor) {
23
- react.useEffect(() => {
24
- return markdown.registerMarkdownShortcuts(editor, LexicalHorizontalRuleNode.$createHorizontalRuleNode);
25
- }, [editor]);
26
- }
27
-
28
- /**
29
- * Copyright (c) Meta Platforms, Inc. and affiliates.
30
- *
31
- * This source code is licensed under the MIT license found in the
32
- * LICENSE file in the root directory of this source tree.
33
- *
34
- *
35
- */
36
- function LexicalMarkdownShortcutPlugin() {
21
+ function LexicalMarkdownShortcutPlugin({
22
+ transformers
23
+ }) {
37
24
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
38
- useMarkdownShortcuts(editor);
25
+ react.useEffect(() => {
26
+ return markdown.registerMarkdownShortcuts(editor, transformers);
27
+ }, [editor, transformers]);
39
28
  return null;
40
29
  }
41
30
 
@@ -7,4 +7,8 @@
7
7
  * @flow strict
8
8
  */
9
9
 
10
- declare export default function LexicalMarkdownShortcutPlugin(): React$Node;
10
+ import type {Transformer} from '@lexical/markdown';
11
+
12
+ declare export default function LexicalMarkdownShortcutPlugin({
13
+ transformers: Array<Transformer>,
14
+ }): React$Node;
@@ -4,4 +4,4 @@
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 b=require("@lexical/react/LexicalComposerContext"),c=require("@lexical/markdown"),d=require("@lexical/react/LexicalHorizontalRuleNode"),e=require("react");function f(a){e.useEffect(()=>c.registerMarkdownShortcuts(a,d.$createHorizontalRuleNode),[a])}module.exports=function(){const [a]=b.useLexicalComposerContext();f(a);return null};
7
+ var c=require("@lexical/markdown"),d=require("@lexical/react/LexicalComposerContext"),e=require("react");module.exports=function({transformers:a}){const [b]=d.useLexicalComposerContext();e.useEffect(()=>c.registerMarkdownShortcuts(b,a),[b,a]);return null};
@@ -5,5 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  var c=require("@lexical/react/LexicalCollaborationPlugin"),d=require("@lexical/react/LexicalComposerContext"),h=require("react");
8
- module.exports=function({initialEditor:a,children:k,initialTheme:l}){const e=h.useContext(d.LexicalComposerContext);if(null==e)throw Error("Minified Lexical error #72; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");const p=h.useMemo(()=>{const [g,m]=e,f=l||m.getTheme()||void 0,n=d.createLexicalComposerContext(e,f);void 0!==f&&(a._config.theme=f);a._parentEditor=g;a._nodes=g._nodes;return[a,n]},[]);var {yjsDocMap:b}=c.useCollaborationContext();
8
+ module.exports=function({initialEditor:a,children:k,initialTheme:l}){const e=h.useContext(d.LexicalComposerContext);if(null==e)throw Error("Minified Lexical error #8; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");const p=h.useMemo(()=>{const [g,m]=e,f=l||m.getTheme()||void 0,n=d.createLexicalComposerContext(e,f);void 0!==f&&(a._config.theme=f);a._parentEditor=g;a._nodes=g._nodes;return[a,n]},[]);var {yjsDocMap:b}=c.useCollaborationContext();
9
9
  const q=void 0!==b.get("main");b=b.has(a.getKey());return h.createElement(d.LexicalComposerContext.Provider,{value:p},!q||b?k: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;
@@ -5,6 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  var e=require("@lexical/react/LexicalComposerContext"),f=require("@lexical/table"),k=require("lexical"),m=require("react");
8
- module.exports=function(){const [c]=e.useLexicalComposerContext();m.useEffect(()=>{if(!c.hasNodes([f.TableNode,f.TableCellNode,f.TableRowNode]))throw Error("Minified Lexical error #54; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return c.registerCommand(f.INSERT_TABLE_COMMAND,a=>{const {columns:h,rows:g}=a;a=k.$getSelection();if(!k.$isRangeSelection(a))return!0;var d=a.focus;a=d.getNode();if(null!==a){const b=f.$createTableNodeWithDimensions(Number(g),
8
+ module.exports=function(){const [c]=e.useLexicalComposerContext();m.useEffect(()=>{if(!c.hasNodes([f.TableNode,f.TableCellNode,f.TableRowNode]))throw Error("Minified Lexical error #7; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return c.registerCommand(f.INSERT_TABLE_COMMAND,a=>{const {columns:h,rows:g}=a;a=k.$getSelection();if(!k.$isRangeSelection(a))return!0;var d=a.focus;a=d.getNode();if(null!==a){const b=f.$createTableNodeWithDimensions(Number(g),
9
9
  Number(h));k.$isRootNode(a)?(d=a.getChildAtIndex(d.offset),null!==d?d.insertBefore(b):a.append(b),b.insertBefore(k.$createParagraphNode())):a.getTopLevelElementOrThrow().insertAfter(b);b.insertAfter(k.$createParagraphNode());b.getFirstChildOrThrow().getFirstChildOrThrow().select()}return!0},k.COMMAND_PRIORITY_EDITOR)},[c]);m.useEffect(()=>{const a=new Map;return c.registerMutationListener(f.TableNode,h=>{for(const [g,d]of h)"created"===d?c.update(()=>{var b=c.getElementByKey(g);const l=k.$getNodeByKey(g);
10
10
  b&&l&&(b=f.applyTableHandlers(l,b,c),a.set(g,b))}):"destroyed"===d&&(h=a.get(g))&&(h.removeListeners(),a.delete(g))})},[c]);return null};
@@ -6,6 +6,7 @@
6
6
  */
7
7
  'use strict';
8
8
 
9
+ var mark = require('@lexical/mark');
9
10
  var lexical = require('lexical');
10
11
  var React = require('react');
11
12
 
@@ -186,7 +187,7 @@ function printObjectSelection(selection) {
186
187
  }
187
188
 
188
189
  function printGridSelection(selection) {
189
- return `: grid\n └ { grid: ${selection.gridKey}, anchorCell: ${selection.anchorCellKey}, focusCell: ${selection.focusCellKey} }`;
190
+ return `: grid\n └ { grid: ${selection.gridKey}, anchorCell: ${selection.anchor.key}, focusCell: ${selection.focus.key} }`;
190
191
  }
191
192
 
192
193
  function generateContent(editorState) {
@@ -198,7 +199,8 @@ function generateContent(editorState) {
198
199
  const nodeKeyDisplay = `(${nodeKey})`;
199
200
  const typeDisplay = node.getType() || '';
200
201
  const isSelected = node.isSelected();
201
- res += `${isSelected ? SYMBOLS.selectedLine : ' '} ${indent.join(' ')} ${nodeKeyDisplay} ${typeDisplay} ${printNode(node)}\n`;
202
+ const idsDisplay = mark.$isMarkNode(node) ? ` id: [ ${node.getIDs().join(', ')} ] ` : '';
203
+ res += `${isSelected ? SYMBOLS.selectedLine : ' '} ${indent.join(' ')} ${nodeKeyDisplay} ${typeDisplay} ${idsDisplay} ${printNode(node)}\n`;
202
204
  res += printSelectedCharsLine({
203
205
  indent,
204
206
  isSelected,
@@ -240,7 +242,7 @@ function printNode(node) {
240
242
  return '';
241
243
  }
242
244
 
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'];
245
+ 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
246
  const DETAIL_PREDICATES = [node => node.isDirectionless() && 'Directionless', node => node.isUnmergeable() && 'Unmergeable'];
245
247
  const MODE_PREDICATES = [node => node.isToken() && 'Token', node => node.isSegmented() && 'Segmented', node => node.isInert() && 'Inert'];
246
248
 
@@ -4,17 +4,17 @@
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 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
- 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
- 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}
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
- 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(" ")+
7
+ var l=require("@lexical/mark"),p=require("lexical"),r=require("react");const D=Object.freeze({"\t":"\\t","\n":"\\n"}),E=new RegExp(Object.keys(D).join("|"),"g"),F=Object.freeze({ancestorHasNextSibling:"|",ancestorIsLastChild:" ",hasNextSibling:"\u251c",isLastChild:"\u2514",selectedChar:"^",selectedLine:">"});
8
+ function G(a){let b="";const c=H(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
+ function J(a){let b=" root\n";a=a.read(()=>{const c=p.$getSelection();K(p.$getRoot(),(e,d)=>{const f=`(${e.getKey()})`,g=e.getType()||"",m=e.isSelected(),v=l.$isMarkNode(e)?` id: [ ${e.getIDs().join(", ")} ] `:"";var u=b,q=m?F.selectedLine:" ",w=d.join(" ");if(p.$isTextNode(e)){var k=e.getTextContent(!0);const t=0===k.length?"(empty)":`"${L(k)}"`;k=[H(e),M(e),N(e)].filter(Boolean).join(", ");k=[t,0!==k.length?`{ ${k} }`:null].filter(Boolean).join(" ").trim()}else k="";b=u+`${q} ${w} ${f} ${g} ${v} ${k}\n`;
10
+ b+=O({indent:d,isSelected:m,node:e,nodeKeyDisplay:f,selection:c,typeDisplay:g})});return null===c?": null":p.$isRangeSelection(c)?G(c):p.$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}
11
+ function K(a,b,c=[]){a=a.getChildren();const e=a.length;a.forEach((d,f)=>{b(d,c.concat(f===e-1?F.isLastChild:F.hasNextSibling));p.$isElementNode(d)&&K(d,b,c.concat(f===e-1?F.ancestorIsLastChild:F.ancestorHasNextSibling))})}function L(a){return Object.entries(D).reduce((b,[c,e])=>b.replace(new RegExp(c,"g"),String(e)),a)}
12
+ const P=[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"],Q=[a=>a.isDirectionless()&&"Directionless",a=>a.isUnmergeable()&&"Unmergeable"],R=[a=>a.isToken()&&"Token",a=>a.isSegmented()&&"Segmented",a=>a.isInert()&&"Inert"];
13
+ function M(a){let b=Q.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="detail: "+b);return b}function N(a){let b=R.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="mode: "+b);return b}function H(a){let b=P.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="format: "+b);return b}
14
+ function O({indent:a,isSelected:b,node:c,nodeKeyDisplay:e,selection:d,typeDisplay:f}){if(!p.$isTextNode(c)||!p.$isRangeSelection(d)||!b||p.$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 k=g.getNode(),t=m.getNode();k===t&&c===k&&g.offset!==m.offset?[d,b]=g.offset<m.offset?[g.offset,m.offset]:[m.offset,
15
+ g.offset]:c===k?[d,b]=k.isBefore(t)?[g.offset,u]:[0,g.offset]:c===t?[d,b]=t.isBefore(k)?[m.offset,u]:[0,m.offset]:[d,b]=[0,u]}c=(v.slice(0,d).match(E)||[]).length;g=(v.slice(d,b).match(E)||[]).length;const [q,w]=[d+c,b+c+g];if(q===w)return"";c=a[a.length-1]===F.hasNextSibling?F.ancestorHasNextSibling:F.ancestorIsLastChild;a=[...a.slice(0,a.length-1),c];c=Array(q).fill(" ");d=Array(w-q).fill(F.selectedChar);e=Array(e.length+(f.length+3)).fill(" ");return[F.selectedLine,a.join(" "),[...e,...c,...d].join("")].join(" ")+
16
16
  "\n"}
17
- module.exports=function({timeTravelButtonClassName:a,timeTravelPanelSliderClassName:b,timeTravelPanelButtonClassName:c,viewClassName:e,timeTravelPanelClassName:d,editor:f}){const [g,m]=q.useState([]),[v,u]=q.useState(""),[r,l]=q.useState(!1),n=q.useRef(0),w=q.useRef(null),B=q.useRef(null),[z,C]=q.useState(!1);q.useEffect(()=>{u(H(f.getEditorState()));return f.registerUpdateListener(({editorState:h})=>{const p=f._compositionKey,x=H(f.getEditorState());u([x,null!==p&&`Composition key: ${p}`].filter(Boolean).join("\n\n"));r||
18
- m(A=>[...A,[Date.now(),h]])})},[r,f]);const y=g.length;q.useEffect(()=>{if(z){let h;const p=()=>{const x=n.current;x===y-1?C(!1):h=setTimeout(()=>{n.current++;const A=n.current,I=B.current;null!==I&&(I.value=String(A));f.setEditorState(g[A][1]);p()},g[x+1][0]-g[x][0])};p();return()=>{window.clearTimeout(h)}}},[g,z,f,y]);q.useEffect(()=>{const h=w.current;if(null!==h)return h.__lexicalEditor=f,()=>{h.__lexicalEditor=null}},[f]);return q.createElement("div",{className:e},!r&&2<y&&q.createElement("button",
19
- {onClick:()=>{const h=f.getRootElement();null!==h&&(h.contentEditable="false",n.current=y-1,l(!0))},className:a},"Time Travel"),q.createElement("pre",{ref:w},v),r&&q.createElement("div",{className:d},q.createElement("button",{className:c,onClick:()=>{C(!z)}},z?"Pause":"Play"),q.createElement("input",{className:b,ref:B,onChange:h=>{h=Number(h.target.value);const p=g[h];p&&(n.current=h,f.setEditorState(p[1]))},type:"range",min:"1",max:y-1}),q.createElement("button",{className:c,onClick:()=>{var h=f.getRootElement();
20
- if(null!==h){h.contentEditable="true";h=g.length-1;f.setEditorState(g[h][1]);const p=B.current;null!==p&&(p.value=String(h));l(!1);C(!1)}}},"Exit")))};
17
+ module.exports=function({timeTravelButtonClassName:a,timeTravelPanelSliderClassName:b,timeTravelPanelButtonClassName:c,viewClassName:e,timeTravelPanelClassName:d,editor:f}){const [g,m]=r.useState([]),[v,u]=r.useState(""),[q,w]=r.useState(!1),k=r.useRef(0),t=r.useRef(null),B=r.useRef(null),[z,C]=r.useState(!1);r.useEffect(()=>{u(J(f.getEditorState()));return f.registerUpdateListener(({editorState:h})=>{const n=f._compositionKey,x=J(f.getEditorState());u([x,null!==n&&`Composition key: ${n}`].filter(Boolean).join("\n\n"));q||
18
+ m(A=>[...A,[Date.now(),h]])})},[q,f]);const y=g.length;r.useEffect(()=>{if(z){let h;const n=()=>{const x=k.current;x===y-1?C(!1):h=setTimeout(()=>{k.current++;const A=k.current,I=B.current;null!==I&&(I.value=String(A));f.setEditorState(g[A][1]);n()},g[x+1][0]-g[x][0])};n();return()=>{window.clearTimeout(h)}}},[g,z,f,y]);r.useEffect(()=>{const h=t.current;if(null!==h)return h.__lexicalEditor=f,()=>{h.__lexicalEditor=null}},[f]);return r.createElement("div",{className:e},!q&&2<y&&r.createElement("button",
19
+ {onClick:()=>{const h=f.getRootElement();null!==h&&(h.contentEditable="false",k.current=y-1,w(!0))},className:a},"Time Travel"),r.createElement("pre",{ref:t},v),q&&r.createElement("div",{className:d},r.createElement("button",{className:c,onClick:()=>{C(!z)}},z?"Pause":"Play"),r.createElement("input",{className:b,ref:B,onChange:h=>{h=Number(h.target.value);const n=g[h];n&&(k.current=h,f.setEditorState(n[1]))},type:"range",min:"1",max:y-1}),r.createElement("button",{className:c,onClick:()=>{var h=f.getRootElement();
20
+ if(null!==h){h.contentEditable="true";h=g.length-1;f.setEditorState(g[h][1]);const n=B.current;null!==n&&(n.value=String(h));w(!1);C(!1)}}},"Exit")))};
package/package.json CHANGED
@@ -8,27 +8,28 @@
8
8
  "rich-text"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.2.3",
11
+ "version": "0.2.6",
12
12
  "dependencies": {
13
- "@lexical/clipboard": "0.2.3",
14
- "@lexical/list": "0.2.3",
15
- "@lexical/table": "0.2.3",
16
- "@lexical/yjs": "0.2.3",
17
- "@lexical/hashtag": "0.2.3",
18
- "@lexical/selection": "0.2.3",
19
- "@lexical/utils": "0.2.3",
20
- "@lexical/dragon": "0.2.3",
21
- "@lexical/plain-text": "0.2.3",
22
- "@lexical/rich-text": "0.2.3",
23
- "@lexical/code": "0.2.3",
24
- "@lexical/text": "0.2.3",
25
- "@lexical/link": "0.2.3",
26
- "@lexical/overflow": "0.2.3",
27
- "@lexical/history": "0.2.3",
28
- "@lexical/markdown": "0.2.3"
13
+ "@lexical/clipboard": "0.2.6",
14
+ "@lexical/list": "0.2.6",
15
+ "@lexical/table": "0.2.6",
16
+ "@lexical/yjs": "0.2.6",
17
+ "@lexical/hashtag": "0.2.6",
18
+ "@lexical/selection": "0.2.6",
19
+ "@lexical/utils": "0.2.6",
20
+ "@lexical/dragon": "0.2.6",
21
+ "@lexical/plain-text": "0.2.6",
22
+ "@lexical/rich-text": "0.2.6",
23
+ "@lexical/code": "0.2.6",
24
+ "@lexical/text": "0.2.6",
25
+ "@lexical/link": "0.2.6",
26
+ "@lexical/overflow": "0.2.6",
27
+ "@lexical/history": "0.2.6",
28
+ "@lexical/markdown": "0.2.6",
29
+ "@lexical/mark": "0.2.6"
29
30
  },
30
31
  "peerDependencies": {
31
- "lexical": "0.2.3",
32
+ "lexical": "0.2.6",
32
33
  "react": ">=17.x",
33
34
  "react-dom": ">=17.x"
34
35
  },