@lexical/react 0.1.7 → 0.1.8

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 (101) hide show
  1. package/DEPRECATED_useLexical.dev.js +84 -0
  2. package/DEPRECATED_useLexical.js +9 -2
  3. package/DEPRECATED_useLexical.prod.js +8 -0
  4. package/DEPRECATED_useLexicalAutoFormatter.dev.js +642 -0
  5. package/DEPRECATED_useLexicalAutoFormatter.js +9 -11
  6. package/DEPRECATED_useLexicalAutoFormatter.prod.js +22 -0
  7. package/DEPRECATED_useLexicalCanShowPlaceholder.dev.js +136 -0
  8. package/DEPRECATED_useLexicalCanShowPlaceholder.js +9 -3
  9. package/DEPRECATED_useLexicalCanShowPlaceholder.prod.js +8 -0
  10. package/DEPRECATED_useLexicalCharacterLimit.dev.js +294 -0
  11. package/DEPRECATED_useLexicalCharacterLimit.js +9 -8
  12. package/DEPRECATED_useLexicalCharacterLimit.prod.js +14 -0
  13. package/DEPRECATED_useLexicalDecorators.dev.js +82 -0
  14. package/DEPRECATED_useLexicalDecorators.js +9 -2
  15. package/DEPRECATED_useLexicalDecorators.prod.js +8 -0
  16. package/DEPRECATED_useLexicalEditor.dev.js +52 -0
  17. package/DEPRECATED_useLexicalEditor.js +9 -1
  18. package/DEPRECATED_useLexicalEditor.prod.js +7 -0
  19. package/DEPRECATED_useLexicalEditorEvents.dev.js +96 -0
  20. package/DEPRECATED_useLexicalEditorEvents.js +9 -2
  21. package/DEPRECATED_useLexicalEditorEvents.prod.js +8 -0
  22. package/DEPRECATED_useLexicalHistory.dev.js +339 -0
  23. package/DEPRECATED_useLexicalHistory.js +9 -7
  24. package/DEPRECATED_useLexicalHistory.prod.js +13 -0
  25. package/DEPRECATED_useLexicalList.dev.js +64 -0
  26. package/DEPRECATED_useLexicalList.js +9 -1
  27. package/DEPRECATED_useLexicalList.prod.js +7 -0
  28. package/DEPRECATED_useLexicalPlainText.dev.js +755 -0
  29. package/DEPRECATED_useLexicalPlainText.js +9 -16
  30. package/DEPRECATED_useLexicalPlainText.prod.js +22 -0
  31. package/DEPRECATED_useLexicalRichText.dev.js +1326 -0
  32. package/DEPRECATED_useLexicalRichText.js +9 -30
  33. package/DEPRECATED_useLexicalRichText.prod.js +35 -0
  34. package/LexicalAutoFormatterPlugin.dev.js +645 -0
  35. package/LexicalAutoFormatterPlugin.js +9 -12
  36. package/LexicalAutoFormatterPlugin.prod.js +23 -0
  37. package/LexicalAutoLinkPlugin.dev.js +227 -0
  38. package/LexicalAutoLinkPlugin.js +9 -6
  39. package/LexicalAutoLinkPlugin.prod.js +12 -0
  40. package/LexicalBootstrapPlugin.dev.js +124 -0
  41. package/LexicalBootstrapPlugin.js +9 -0
  42. package/LexicalBootstrapPlugin.prod.js +8 -0
  43. package/LexicalCharacterLimitPlugin.dev.js +352 -0
  44. package/LexicalCharacterLimitPlugin.js +9 -8
  45. package/LexicalCharacterLimitPlugin.prod.js +14 -0
  46. package/LexicalCollaborationPlugin.dev.js +235 -0
  47. package/LexicalCollaborationPlugin.js +9 -8
  48. package/LexicalCollaborationPlugin.prod.js +14 -0
  49. package/LexicalComposer.dev.js +76 -0
  50. package/LexicalComposer.js +9 -3
  51. package/LexicalComposer.prod.js +9 -0
  52. package/LexicalComposerContext.dev.js +53 -0
  53. package/LexicalComposerContext.js +9 -1
  54. package/LexicalComposerContext.prod.js +7 -0
  55. package/LexicalContentEditable.dev.js +71 -0
  56. package/LexicalContentEditable.js +9 -3
  57. package/LexicalContentEditable.prod.js +9 -0
  58. package/LexicalHashtagPlugin.dev.js +152 -0
  59. package/LexicalHashtagPlugin.js +9 -4
  60. package/LexicalHashtagPlugin.prod.js +10 -0
  61. package/LexicalHistoryPlugin.dev.js +344 -0
  62. package/LexicalHistoryPlugin.js +9 -7
  63. package/LexicalHistoryPlugin.prod.js +13 -0
  64. package/LexicalHorizontalRulePlugin.dev.js +51 -0
  65. package/LexicalHorizontalRulePlugin.js +9 -1
  66. package/LexicalHorizontalRulePlugin.prod.js +7 -0
  67. package/LexicalLinkPlugin.dev.js +137 -0
  68. package/LexicalLinkPlugin.js +9 -3
  69. package/LexicalLinkPlugin.prod.js +9 -0
  70. package/LexicalListPlugin.dev.js +67 -0
  71. package/LexicalListPlugin.js +9 -2
  72. package/LexicalListPlugin.prod.js +8 -0
  73. package/LexicalNestedComposer.dev.js +60 -0
  74. package/LexicalNestedComposer.js +9 -2
  75. package/LexicalNestedComposer.prod.js +8 -0
  76. package/LexicalOnChangePlugin.dev.js +57 -0
  77. package/LexicalOnChangePlugin.js +9 -1
  78. package/LexicalOnChangePlugin.prod.js +7 -0
  79. package/LexicalPlainTextPlugin.dev.js +565 -0
  80. package/LexicalPlainTextPlugin.js +9 -13
  81. package/LexicalPlainTextPlugin.prod.js +17 -0
  82. package/LexicalRichTextPlugin.dev.js +1136 -0
  83. package/LexicalRichTextPlugin.js +9 -27
  84. package/LexicalRichTextPlugin.prod.js +31 -0
  85. package/LexicalTablePlugin.dev.js +95 -0
  86. package/LexicalTablePlugin.js +9 -3
  87. package/LexicalTablePlugin.prod.js +9 -0
  88. package/LexicalTreeView.dev.js +340 -0
  89. package/LexicalTreeView.js +9 -13
  90. package/LexicalTreeView.prod.js +19 -0
  91. package/README.md +1 -0
  92. package/package.json +4 -4
  93. package/useLexicalDecoratorMap.dev.js +83 -0
  94. package/useLexicalDecoratorMap.js +9 -2
  95. package/useLexicalDecoratorMap.prod.js +8 -0
  96. package/useLexicalIsTextContentEmpty.dev.js +84 -0
  97. package/useLexicalIsTextContentEmpty.js +9 -2
  98. package/useLexicalIsTextContentEmpty.prod.js +8 -0
  99. package/withSubscriptions.dev.js +23 -0
  100. package/withSubscriptions.js +9 -1
  101. package/withSubscriptions.prod.js +7 -0
@@ -1,16 +1,9 @@
1
- 'use strict';var l=require("lexical"),u=require("react"),v=require("@lexical/react/withSubscriptions");
2
- function w(a){u.useEffect(()=>{const d=f=>{var c=a.getRootElement();if(document.activeElement===c&&(c=f.data,"string"===typeof c)){try{var b=JSON.parse(c)}catch(e){return}if(b&&"nuanria_messaging"===b.protocol&&"request"===b.type&&(b=b.payload)&&"makeChanges"===b.functionId&&(b=b.args)){const [e,g,h,k,n]=b;a.update(()=>{l.$log("useLexicalDragonSupport");const t=l.$getSelection();if(null!==t){var m=t.anchor;let q=m.getNode(),p=0,r=0;l.$isTextNode(q)&&0<=e&&0<=g&&(p=e,r=e+g,t.setTextNodeRange(q,p,q,
3
- r));if(p!==r||""!==h)t.insertRawText(h),q=m.getNode();l.$isTextNode(q)&&(p=k,r=k+n,m=q.getTextContentSize(),p=p>m?m:p,r=r>m?m:r,t.setTextNodeRange(q,p,q,r));f.stopImmediatePropagation()}})}}};window.addEventListener("message",d,!0);return()=>{window.removeEventListener("message",d,!0)}},[a])}function x(a,d){a=a.getData("text/plain");null!=a&&d.insertRawText(a)}
4
- function y(a,d){var f=a.focus;a=f.offset;"element"===f.type?d=f.getNode().getChildAtIndex(d?a-1:a):(f=f.getNode(),d=d&&0===a||!d&&a===f.getTextContentSize()?d?f.getPreviousSibling():f.getNextSibling():null);return l.$isDecoratorNode(d)}function z(a,d){a.preventDefault();d.update(()=>{l.$log("onPasteForPlainText");const f=l.$getSelection(),c=a.clipboardData;null!=c&&null!==f&&x(c,f)})}
5
- function A(a,d){B(a,d);d.update(()=>{l.$log("onCutForPlainText");const f=l.$getSelection();null!==f&&f.removeText()})}function B(a,d){a.preventDefault();d.update(()=>{l.$log("onCopyForPlainText");const f=a.clipboardData,c=l.$getSelection();if(null!==c&&null!=f){var b=window.getSelection();if(!b.isCollapsed){var e=b.getRangeAt(0);e&&(b=document.createElement("div"),e=e.cloneContents(),b.appendChild(e),f.setData("text/html",b.innerHTML));f.setData("text/plain",c.getTextContent())}}})}
6
- var C="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?u.useLayoutEffect:u.useEffect;function D(a,d){const f=l.$createParagraphNode();a.append(f);a=document.activeElement;(null!==l.$getSelection()||null!==a&&a===d.getRootElement())&&f.select()}function E(a){a.update(()=>{l.$log("initEditor");const d=l.$getRoot();null===d.getFirstChild()&&D(d,a)})}
7
- function F(a,d){a.update(()=>{l.$log("clearEditor");const f=l.$getRoot();f.clear();D(f,a)},{onUpdate:d})}
8
- function G(a,d){C(()=>{const f=v(a.addListener("command",(c,b)=>{const e=l.$getSelection();if(null===e)return!1;switch(c){case "deleteCharacter":return e.deleteCharacter(b),!0;case "deleteWord":return e.deleteWord(b),!0;case "deleteLine":return e.deleteLine(b),!0;case "insertText":return"string"===typeof b?e.insertText(b):(c=b.dataTransfer,null!=c?x(c,e):(b=b.data)&&e.insertText(b)),!0;case "removeText":return e.removeText(),!0;case "insertLineBreak":return e.insertLineBreak(b),!0;case "insertParagraph":return e.insertLineBreak(),
9
- !0;case "indentContent":case "outdentContent":case "insertHorizontalRule":case "insertImage":case "insertTable":case "formatElement":case "formatText":return!0;case "keyArrowLeft":c=b.shiftKey;if(y(e,!0))return b.preventDefault(),b=c,c="rtl"===e.anchor.getNode().getParentOrThrow().getDirection(),e.modify(b?"extend":"move",!c,"character"),!0;break;case "keyArrowRight":c=b.shiftKey;if(y(e,!1))return b.preventDefault(),b=c,c="rtl"===e.anchor.getNode().getParentOrThrow().getDirection(),e.modify(b?"extend":
10
- "move",c,"character"),!0;break;case "keyBackspace":return b.preventDefault(),a.execCommand("deleteCharacter",!0);case "keyDelete":return b.preventDefault(),a.execCommand("deleteCharacter",!1);case "keyEnter":return b.preventDefault(),a.execCommand("insertLineBreak");case "clearEditor":F(a);break;case "copy":return B(b,a),!0;case "cut":return A(b,a),!0;case "paste":return z(b,a),!0;case "drop":case "dragstart":return b.preventDefault(),!0}return!1},0));d&&E(a);return f},[a,d]);w(a)}
11
- function H(a,d,f,c,b){if(null===a||0===f.size&&0===c.size)return 0;var e=d._selection,g=a._selection;if(b)return 1;if(null===e||null===g||!g.isCollapsed()||!e.isCollapsed())return 0;var h=Array.from(f);c=Array.from(c);f=d._nodeMap;b=[];for(var k=0;k<h.length;k++){const n=f.get(h[k]);void 0!==n&&b.push(n)}for(h=0;h<c.length;h++)c[h][1]&&(k=f.get(c[h][0]),void 0===k||l.$isRootNode(k)||b.push(k));if(0===b.length)return 0;if(1<b.length)return c=d._nodeMap,d=c.get(e.anchor.key),g=c.get(g.anchor.key),d&&
12
- g&&!a._nodeMap.has(d.__key)&&l.$isTextNode(d)&&1===d.__text.length&&1===e.anchor.offset?2:0;d=b[0];a=a._nodeMap.get(d.__key);if(!l.$isTextNode(a)||!l.$isTextNode(d)||a.__mode!==d.__mode)return 0;a=a.__text;d=d.__text;if(a===d)return 0;e=e.anchor;g=g.anchor;if(e.key!==g.key||"text"!==e.type)return 0;e=e.offset;g=g.offset;a=d.length-a.length;return 1===a&&g===e-1?2:-1===a&&g===e+1?3:-1===a&&g===e?4:0}
13
- function I(a,d){let f=Date.now(),c=0;return(b,e,g,h,k,n)=>{const t=Date.now();if(n.has("historic"))return c=0,f=t,2;const m=H(b,e,h,k,a.isComposing()),q=(()=>{if(n.has("without-history"))return 0;if(null===b)return 1;var p=e._selection;const r=b._selection;if(!(0<h.size||0<k.size))return null===r&&null!==p?0:2;p=null===g||g.editor===a;return 0!==m&&m===c&&t<f+d&&p?0:1})();f=t;c=m;return q}}
14
- function J(a,d,f=1E3){const c=u.useMemo(()=>d||{current:null,redoStack:[],undoStack:[]},[d]),b=u.useCallback(()=>{c.undoStack=[];c.redoStack=[];c.current=null},[c]);u.useEffect(()=>{const e=I(a,f);return v(a.addListener("command",g=>{switch(g){case "undo":g=c.redoStack;var h=c.undoStack;if(0!==h.length){var k=c.current;const n=h.pop();null!==k&&(g.push(k),a.execCommand("canRedo",!0));0===h.length&&a.execCommand("canUndo",!1);c.current=n;n.editor.setEditorState(n.editorState.clone(n.undoSelection),
15
- {tag:"historic"})}return!0;case "redo":return g=c.redoStack,h=c.undoStack,0!==g.length&&(k=c.current,null!==k&&(h.push(k),a.execCommand("canUndo",!0)),h=g.pop(),0===g.length&&a.execCommand("canRedo",!1),c.current=h,h.editor.setEditorState(h.editorState,{tag:"historic"})),!0;case "clearEditor":return b(),!1;case "clearHistory":return b(),!0;default:return!1}},0),a.addListener("update",({editorState:g,prevEditorState:h,dirtyLeaves:k,dirtyElements:n,tags:t})=>{const m=c.current,q=c.redoStack,p=c.undoStack,
16
- r=null===m?null:m.editorState;if(null===m||g!==r){k=e(h,g,m,k,n,t);if(1===k)0!==q.length&&(c.redoStack=[]),null!==m&&(p.push({...m,undoSelection:h.read(l.$getSelection)}),a.execCommand("canUndo",!0));else if(2===k)return;c.current={editor:a,editorState:g}}}))},[b,f,a,c])}function K(a,d,f=1E3){return J(a,d,f)}module.exports=function(a,d){G(a,!0);K(a,d)};
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 DEPRECATED_useLexicalPlainText = process.env.NODE_ENV === 'development' ? require('./DEPRECATED_useLexicalPlainText.dev.js') : require('./DEPRECATED_useLexicalPlainText.prod.js')
9
+ module.exports = DEPRECATED_useLexicalPlainText;
@@ -0,0 +1,22 @@
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';var m=require("@lexical/react/withSubscriptions"),u=require("lexical"),v=require("react");
8
+ function w(a,e,c,b,d){if(null===a||0===c.size&&0===b.size)return 0;var g=e._selection,f=a._selection;if(d)return 1;if(null===g||null===f||!f.isCollapsed()||!g.isCollapsed())return 0;var h=Array.from(c);b=Array.from(b);c=e._nodeMap;d=[];for(var k=0;k<h.length;k++){const n=c.get(h[k]);void 0!==n&&d.push(n)}for(h=0;h<b.length;h++)b[h][1]&&(k=c.get(b[h][0]),void 0===k||u.$isRootNode(k)||d.push(k));if(0===d.length)return 0;if(1<d.length)return b=e._nodeMap,e=b.get(g.anchor.key),f=b.get(f.anchor.key),e&&
9
+ f&&!a._nodeMap.has(e.__key)&&u.$isTextNode(e)&&1===e.__text.length&&1===g.anchor.offset?2:0;e=d[0];a=a._nodeMap.get(e.__key);if(!u.$isTextNode(a)||!u.$isTextNode(e)||a.__mode!==e.__mode)return 0;a=a.__text;e=e.__text;if(a===e)return 0;g=g.anchor;f=f.anchor;if(g.key!==f.key||"text"!==g.type)return 0;g=g.offset;f=f.offset;a=e.length-a.length;return 1===a&&f===g-1?2:-1===a&&f===g+1?3:-1===a&&f===g?4:0}
10
+ function x(a,e){let c=Date.now(),b=0;return(d,g,f,h,k,n)=>{const t=Date.now();if(n.has("historic"))return b=0,c=t,2;const l=w(d,g,h,k,a.isComposing()),r=(()=>{if(n.has("without-history"))return 0;if(null===d)return 1;var p=g._selection;const q=d._selection;if(!(0<h.size||0<k.size))return null===q&&null!==p?0:2;p=null===f||f.editor===a;return 0!==l&&l===b&&t<c+e&&p?0:1})();c=t;b=l;return r}}
11
+ function y(a,e,c=1E3){const b=v.useMemo(()=>e||{current:null,redoStack:[],undoStack:[]},[e]),d=v.useCallback(()=>{b.undoStack=[];b.redoStack=[];b.current=null},[b]);v.useEffect(()=>{const g=x(a,c);return m(a.addListener("command",f=>{switch(f){case "undo":f=b.redoStack;var h=b.undoStack;if(0!==h.length){var k=b.current;const n=h.pop();null!==k&&(f.push(k),a.execCommand("canRedo",!0));0===h.length&&a.execCommand("canUndo",!1);b.current=n;n.editor.setEditorState(n.editorState.clone(n.undoSelection),
12
+ {tag:"historic"})}return!0;case "redo":return f=b.redoStack,h=b.undoStack,0!==f.length&&(k=b.current,null!==k&&(h.push(k),a.execCommand("canUndo",!0)),h=f.pop(),0===f.length&&a.execCommand("canRedo",!1),b.current=h,h.editor.setEditorState(h.editorState,{tag:"historic"})),!0;case "clearEditor":return d(),!1;case "clearHistory":return d(),!0;default:return!1}},0),a.addListener("update",({editorState:f,prevEditorState:h,dirtyLeaves:k,dirtyElements:n,tags:t})=>{const l=b.current,r=b.redoStack,p=b.undoStack,
13
+ q=null===l?null:l.editorState;if(null===l||f!==q){k=g(h,f,l,k,n,t);if(1===k)0!==r.length&&(b.redoStack=[]),null!==l&&(p.push({...l,undoSelection:h.read(u.$getSelection)}),a.execCommand("canUndo",!0));else if(2===k)return;b.current={editor:a,editorState:f}}}))},[d,c,a,b])}function z(a,e,c=1E3){return y(a,e,c)}function A(a,e){a=a.getData("text/plain");null!=a&&e.insertRawText(a)}
14
+ function B(a,e){var c=a.focus;a=c.offset;"element"===c.type?e=c.getNode().getChildAtIndex(e?a-1:a):(c=c.getNode(),e=e&&0===a||!e&&a===c.getTextContentSize()?e?c.getPreviousSibling():c.getNextSibling():null);return u.$isDecoratorNode(e)}function C(a,e){a.preventDefault();e.update(()=>{u.$log("onPasteForPlainText");const c=u.$getSelection(),b=a.clipboardData;null!=b&&null!==c&&A(b,c)})}
15
+ function D(a,e){E(a,e);e.update(()=>{u.$log("onCutForPlainText");const c=u.$getSelection();null!==c&&c.removeText()})}function E(a,e){a.preventDefault();e.update(()=>{u.$log("onCopyForPlainText");const c=a.clipboardData,b=u.$getSelection();if(null!==b&&null!=c){var d=window.getSelection();if(!d.isCollapsed){var g=d.getRangeAt(0);g&&(d=document.createElement("div"),g=g.cloneContents(),d.appendChild(g),c.setData("text/html",d.innerHTML));c.setData("text/plain",b.getTextContent())}}})}
16
+ var F="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?v.useLayoutEffect:v.useEffect;
17
+ function G(a){v.useEffect(()=>{const e=c=>{var b=a.getRootElement();if(document.activeElement===b&&(b=c.data,"string"===typeof b)){try{var d=JSON.parse(b)}catch(g){return}if(d&&"nuanria_messaging"===d.protocol&&"request"===d.type&&(d=d.payload)&&"makeChanges"===d.functionId&&(d=d.args)){const [g,f,h,k,n]=d;a.update(()=>{u.$log("useLexicalDragonSupport");const t=u.$getSelection();if(null!==t){var l=t.anchor;let r=l.getNode(),p=0,q=0;u.$isTextNode(r)&&0<=g&&0<=f&&(p=g,q=g+f,t.setTextNodeRange(r,p,r,
18
+ q));if(p!==q||""!==h)t.insertRawText(h),r=l.getNode();u.$isTextNode(r)&&(p=k,q=k+n,l=r.getTextContentSize(),p=p>l?l:p,q=q>l?l:q,t.setTextNodeRange(r,p,r,q));c.stopImmediatePropagation()}})}}};window.addEventListener("message",e,!0);return()=>{window.removeEventListener("message",e,!0)}},[a])}
19
+ function H(a){F(()=>{const e=a.addListener("command",(c,b)=>{const d=u.$getSelection();if(null===d)return!1;switch(c){case "deleteCharacter":return d.deleteCharacter(b),!0;case "deleteWord":return d.deleteWord(b),!0;case "deleteLine":return d.deleteLine(b),!0;case "insertText":return"string"===typeof b?d.insertText(b):(c=b.dataTransfer,null!=c?A(c,d):(b=b.data)&&d.insertText(b)),!0;case "removeText":return d.removeText(),!0;case "insertLineBreak":return d.insertLineBreak(b),!0;case "insertParagraph":return d.insertLineBreak(),
20
+ !0;case "indentContent":case "outdentContent":case "insertHorizontalRule":case "insertImage":case "insertTable":case "formatElement":case "formatText":return!0;case "keyArrowLeft":c=b.shiftKey;if(B(d,!0))return b.preventDefault(),b=c,c="rtl"===d.anchor.getNode().getParentOrThrow().getDirection(),d.modify(b?"extend":"move",!c,"character"),!0;break;case "keyArrowRight":c=b.shiftKey;if(B(d,!1))return b.preventDefault(),b=c,c="rtl"===d.anchor.getNode().getParentOrThrow().getDirection(),d.modify(b?"extend":
21
+ "move",c,"character"),!0;break;case "keyBackspace":return b.preventDefault(),a.execCommand("deleteCharacter",!0);case "keyDelete":return b.preventDefault(),a.execCommand("deleteCharacter",!1);case "keyEnter":return b.preventDefault(),a.execCommand("insertLineBreak");case "copy":return E(b,a),!0;case "cut":return D(b,a),!0;case "paste":return C(b,a),!0;case "drop":case "dragstart":return b.preventDefault(),!0}return!1},0);a.execCommand("bootstrapEditor");return e},[a]);G(a)}
22
+ module.exports=function(a,e){H(a);z(a,e)};