@lexical/react 0.1.4 → 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.
- package/DEPRECATED_useLexical.dev.js +84 -0
- package/DEPRECATED_useLexical.js +9 -2
- package/DEPRECATED_useLexical.prod.js +8 -0
- package/DEPRECATED_useLexicalAutoFormatter.dev.js +642 -0
- package/DEPRECATED_useLexicalAutoFormatter.js +9 -12
- package/DEPRECATED_useLexicalAutoFormatter.prod.js +22 -0
- package/DEPRECATED_useLexicalCanShowPlaceholder.dev.js +136 -0
- package/DEPRECATED_useLexicalCanShowPlaceholder.js +9 -3
- package/DEPRECATED_useLexicalCanShowPlaceholder.prod.js +8 -0
- package/DEPRECATED_useLexicalCharacterLimit.dev.js +294 -0
- package/DEPRECATED_useLexicalCharacterLimit.js +9 -9
- package/DEPRECATED_useLexicalCharacterLimit.prod.js +14 -0
- package/DEPRECATED_useLexicalDecorators.dev.js +82 -0
- package/DEPRECATED_useLexicalDecorators.js +9 -2
- package/DEPRECATED_useLexicalDecorators.prod.js +8 -0
- package/DEPRECATED_useLexicalEditor.dev.js +52 -0
- package/DEPRECATED_useLexicalEditor.js +9 -1
- package/DEPRECATED_useLexicalEditor.prod.js +7 -0
- package/DEPRECATED_useLexicalEditorEvents.dev.js +96 -0
- package/DEPRECATED_useLexicalEditorEvents.js +9 -2
- package/DEPRECATED_useLexicalEditorEvents.prod.js +8 -0
- package/DEPRECATED_useLexicalHistory.dev.js +339 -0
- package/DEPRECATED_useLexicalHistory.js +9 -7
- package/DEPRECATED_useLexicalHistory.prod.js +13 -0
- package/DEPRECATED_useLexicalList.dev.js +64 -0
- package/DEPRECATED_useLexicalList.js +9 -12
- package/DEPRECATED_useLexicalList.prod.js +7 -0
- package/DEPRECATED_useLexicalPlainText.dev.js +755 -0
- package/DEPRECATED_useLexicalPlainText.js +9 -17
- package/DEPRECATED_useLexicalPlainText.prod.js +22 -0
- package/DEPRECATED_useLexicalRichText.dev.js +1326 -0
- package/DEPRECATED_useLexicalRichText.js +9 -30
- package/DEPRECATED_useLexicalRichText.prod.js +35 -0
- package/LexicalAutoFormatterPlugin.dev.js +645 -0
- package/LexicalAutoFormatterPlugin.js +9 -13
- package/LexicalAutoFormatterPlugin.prod.js +23 -0
- package/LexicalAutoLinkPlugin.dev.js +227 -0
- package/LexicalAutoLinkPlugin.js +9 -5
- package/LexicalAutoLinkPlugin.prod.js +12 -0
- package/LexicalBootstrapPlugin.dev.js +124 -0
- package/LexicalBootstrapPlugin.js +9 -0
- package/LexicalBootstrapPlugin.prod.js +8 -0
- package/LexicalCharacterLimitPlugin.dev.js +352 -0
- package/LexicalCharacterLimitPlugin.js +9 -10
- package/LexicalCharacterLimitPlugin.prod.js +14 -0
- package/LexicalCollaborationPlugin.dev.js +235 -0
- package/LexicalCollaborationPlugin.js +9 -8
- package/LexicalCollaborationPlugin.prod.js +14 -0
- package/LexicalComposer.dev.js +76 -0
- package/LexicalComposer.js +9 -2
- package/LexicalComposer.prod.js +9 -0
- package/LexicalComposerContext.dev.js +53 -0
- package/LexicalComposerContext.js +9 -1
- package/LexicalComposerContext.prod.js +7 -0
- package/LexicalContentEditable.dev.js +71 -0
- package/LexicalContentEditable.js +9 -3
- package/LexicalContentEditable.prod.js +9 -0
- package/LexicalHashtagPlugin.dev.js +152 -0
- package/LexicalHashtagPlugin.js +9 -4
- package/LexicalHashtagPlugin.prod.js +10 -0
- package/LexicalHistoryPlugin.dev.js +344 -0
- package/LexicalHistoryPlugin.js +9 -7
- package/LexicalHistoryPlugin.prod.js +13 -0
- package/LexicalHorizontalRulePlugin.dev.js +51 -0
- package/LexicalHorizontalRulePlugin.js +9 -1
- package/LexicalHorizontalRulePlugin.prod.js +7 -0
- package/LexicalLinkPlugin.dev.js +137 -0
- package/LexicalLinkPlugin.js +9 -3
- package/LexicalLinkPlugin.prod.js +9 -0
- package/LexicalListPlugin.dev.js +67 -0
- package/LexicalListPlugin.js +9 -12
- package/LexicalListPlugin.prod.js +8 -0
- package/LexicalNestedComposer.dev.js +60 -0
- package/LexicalNestedComposer.js +9 -1
- package/LexicalNestedComposer.prod.js +8 -0
- package/LexicalOnChangePlugin.dev.js +57 -0
- package/LexicalOnChangePlugin.js +9 -1
- package/LexicalOnChangePlugin.prod.js +7 -0
- package/LexicalPlainTextPlugin.dev.js +565 -0
- package/LexicalPlainTextPlugin.js +9 -13
- package/LexicalPlainTextPlugin.prod.js +17 -0
- package/LexicalRichTextPlugin.dev.js +1136 -0
- package/LexicalRichTextPlugin.js +9 -26
- package/LexicalRichTextPlugin.prod.js +31 -0
- package/LexicalTablePlugin.dev.js +95 -0
- package/LexicalTablePlugin.js +9 -4
- package/LexicalTablePlugin.prod.js +9 -0
- package/LexicalTreeView.dev.js +340 -0
- package/LexicalTreeView.js +9 -12
- package/LexicalTreeView.prod.js +19 -0
- package/README.md +11 -6
- package/package.json +4 -4
- package/useLexicalDecoratorMap.dev.js +83 -0
- package/useLexicalDecoratorMap.js +9 -1
- package/useLexicalDecoratorMap.prod.js +8 -0
- package/useLexicalIsTextContentEmpty.dev.js +84 -0
- package/useLexicalIsTextContentEmpty.js +9 -2
- package/useLexicalIsTextContentEmpty.prod.js +8 -0
- package/withSubscriptions.dev.js +23 -0
- package/withSubscriptions.js +9 -1
- package/withSubscriptions.prod.js +7 -0
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
f.modify(c?"extend":"move",d,"character"),!0;break;case "keyBackspace":return c.preventDefault(),a.execCommand("deleteCharacter",!0);case "keyDelete":return c.preventDefault(),a.execCommand("deleteCharacter",!1);case "keyEnter":return c.preventDefault(),a.execCommand("insertLineBreak");case "clearEditor":G(a);break;case "copy":return C(c,a),!0;case "cut":return B(c,a),!0;case "paste":return A(c,a),!0;case "drop":case "dragstart":return c.preventDefault(),!0}return!1},0));b&&F(a);return e},[a,b]);
|
|
11
|
-
x(a)}function I(a,b,e){b=Array.from(b);e=Array.from(e);a=a._nodeMap;const d=[];for(var c=0;c<b.length;c++){const f=a.get(b[c]);void 0!==f&&d.push(f)}for(b=0;b<e.length;b++)e[b][1]&&(c=a.get(e[b][0]),void 0===c||h.$isRootNode(c)||d.push(c));return d}
|
|
12
|
-
function J(a,b,e,d,c){if(null===a||0===e.size&&0===d.size)return 0;var f=b._selection,g=a._selection;if(c)return 1;if(null===f||null===g||!g.isCollapsed()||!f.isCollapsed())return 0;e=I(b,e,d);if(0===e.length)return 0;if(1<e.length){b=b._nodeMap;g=b.get(g.anchor.key);const k=b.get(f.anchor.key);return h.$isTextNode(k)&&h.$isElementNode(g)&&!a._nodeMap.has(k.__key)&&1===k.__text.length&&1===f.anchor.offset?e.every(l=>l===k||!h.$isTextNode(l))?2:0:0}b=e[0];a=a._nodeMap.get(b.__key);if(!h.$isTextNode(a)||
|
|
13
|
-
!h.$isTextNode(b)||a.__mode!==b.__mode)return 0;a=a.__text;b=b.__text;if(a===b)return 0;f=f.anchor;g=g.anchor;if(f.key!==g.key||"text"!==f.type)return 0;f=f.offset;g=g.offset;a=b.length-a.length;return 1===a&&g===f-1?2:-1===a&&g===f+1?3:-1===a&&g===f?4:0}
|
|
14
|
-
function K(a,b){let e=Date.now(),d=0;return(c,f,g,k,l,r)=>{const t=Date.now();if(r.has("historic"))return d=0,e=t,2;const m=J(c,f,k,l,a.isComposing()),p=(()=>{if(r.has("without-history"))return 0;if(null===c)return 1;var n=f._selection;const q=c._selection;if(!(0<k.size||0<l.size))return null===q&&null!==n?0:2;n=null===g||g.editor===a;return 0!==m&&m===d&&t<e+b&&n?0:1})();e=t;d=m;return p}}
|
|
15
|
-
function L(a,b,e=1E3){const d=v.useMemo(()=>b||{current:null,redoStack:[],undoStack:[]},[b]),c=v.useCallback(()=>{d.undoStack=[];d.redoStack=[];d.current=null},[d]);v.useEffect(()=>{const f=K(a,e);return w(a.addListener("command",g=>{switch(g){case "undo":g=d.redoStack;var k=d.undoStack;if(0!==k.length){var l=d.current;const r=k.pop();null!==l&&(g.push(l),a.execCommand("canRedo",!0));0===k.length&&a.execCommand("canUndo",!1);d.current=r;r.editor.setEditorState(r.editorState.clone(r.undoSelection),
|
|
16
|
-
{tag:"historic"})}return!0;case "redo":return g=d.redoStack,k=d.undoStack,0!==g.length&&(l=d.current,null!==l&&(k.push(l),a.execCommand("canUndo",!0)),k=g.pop(),0===g.length&&a.execCommand("canRedo",!1),d.current=k,k.editor.setEditorState(k.editorState,{tag:"historic"})),!0;case "clearEditor":return c(),!1;case "clearHistory":return c(),!0;default:return!1}},0),a.addListener("update",({editorState:g,prevEditorState:k,dirtyLeaves:l,dirtyElements:r,tags:t})=>{const m=d.current,p=d.redoStack,n=d.undoStack,
|
|
17
|
-
q=null===m?null:m.editorState;if(null===m||g!==q){l=f(k,g,m,l,r,t);if(1===l)0!==p.length&&(d.redoStack=[]),null!==m&&(n.push({...m,undoSelection:k.read(h.$getSelection)}),a.execCommand("canUndo",!0));else if(2===l)return;d.current={editor:a,editorState:g}}}))},[c,e,a,d])}function M(a,b,e=1E3){return L(a,b,e)}module.exports=function(a,b){H(a,!0);M(a,b)};
|
|
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)};
|