@lexical/react 0.1.10 → 0.1.13
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 +3 -7
- package/DEPRECATED_useLexical.prod.js +1 -1
- package/DEPRECATED_useLexicalAutoFormatter.dev.js +83 -37
- package/DEPRECATED_useLexicalAutoFormatter.prod.js +20 -19
- package/DEPRECATED_useLexicalCharacterLimit.dev.js +20 -17
- package/DEPRECATED_useLexicalCharacterLimit.prod.js +8 -8
- package/DEPRECATED_useLexicalList.dev.js +6 -0
- package/DEPRECATED_useLexicalList.prod.js +1 -1
- package/DEPRECATED_useLexicalPlainText.dev.js +84 -75
- package/DEPRECATED_useLexicalPlainText.prod.js +15 -15
- package/DEPRECATED_useLexicalRichText.dev.js +96 -438
- package/DEPRECATED_useLexicalRichText.prod.js +17 -26
- package/LexicalAutoFormatterPlugin.d.ts +9 -0
- package/LexicalAutoFormatterPlugin.dev.js +83 -37
- package/LexicalAutoFormatterPlugin.js.flow +10 -0
- package/LexicalAutoFormatterPlugin.prod.js +21 -20
- package/LexicalAutoLinkPlugin.d.ts +20 -0
- package/LexicalAutoLinkPlugin.js.flow +23 -0
- package/LexicalCharacterLimitPlugin.d.ts +11 -0
- package/LexicalCharacterLimitPlugin.dev.js +20 -17
- package/LexicalCharacterLimitPlugin.js.flow +12 -0
- package/LexicalCharacterLimitPlugin.prod.js +9 -8
- package/LexicalClearEditorPlugin.d.ts +14 -0
- package/LexicalClearEditorPlugin.dev.js +73 -0
- package/LexicalClearEditorPlugin.js +9 -0
- package/LexicalClearEditorPlugin.js.flow +14 -0
- package/LexicalClearEditorPlugin.prod.js +8 -0
- package/LexicalCollaborationPlugin.d.ts +49 -0
- package/LexicalCollaborationPlugin.dev.js +21 -13
- package/LexicalCollaborationPlugin.js.flow +55 -0
- package/LexicalCollaborationPlugin.prod.js +7 -7
- package/LexicalComposer.d.ts +22 -0
- package/LexicalComposer.dev.js +32 -3
- package/LexicalComposer.js.flow +24 -0
- package/LexicalComposer.prod.js +3 -2
- package/LexicalComposerContext.d.ts +24 -0
- package/LexicalComposerContext.js.flow +27 -0
- package/LexicalContentEditable.d.ts +32 -0
- package/LexicalContentEditable.dev.js +35 -8
- package/LexicalContentEditable.js.flow +35 -0
- package/LexicalContentEditable.prod.js +3 -3
- package/LexicalHashtagPlugin.d.ts +9 -0
- package/LexicalHashtagPlugin.js.flow +10 -0
- package/LexicalHistoryPlugin.d.ts +29 -0
- package/LexicalHistoryPlugin.js.flow +34 -0
- package/LexicalHorizontalRuleNode.d.ts +23 -0
- package/LexicalHorizontalRuleNode.js.flow +25 -0
- package/LexicalLinkPlugin.d.ts +9 -0
- package/LexicalLinkPlugin.js.flow +10 -0
- package/LexicalListPlugin.d.ts +9 -0
- package/LexicalListPlugin.dev.js +6 -0
- package/LexicalListPlugin.js.flow +10 -0
- package/LexicalListPlugin.prod.js +2 -2
- package/LexicalNestedComposer.d.ts +17 -0
- package/LexicalNestedComposer.dev.js +21 -11
- package/LexicalNestedComposer.js.flow +18 -0
- package/LexicalNestedComposer.prod.js +3 -2
- package/LexicalOnChangePlugin.d.ts +12 -0
- package/LexicalOnChangePlugin.js.flow +14 -0
- package/LexicalPlainTextPlugin.d.ts +15 -0
- package/LexicalPlainTextPlugin.dev.js +73 -84
- package/LexicalPlainTextPlugin.js.flow +18 -0
- package/LexicalPlainTextPlugin.prod.js +12 -12
- package/LexicalRichTextPlugin.d.ts +15 -0
- package/LexicalRichTextPlugin.dev.js +85 -447
- package/LexicalRichTextPlugin.js.flow +18 -0
- package/LexicalRichTextPlugin.prod.js +13 -22
- package/LexicalTablePlugin.d.ts +9 -0
- package/LexicalTablePlugin.dev.js +22 -0
- package/LexicalTablePlugin.js.flow +10 -0
- package/LexicalTablePlugin.prod.js +4 -3
- package/LexicalTreeView.d.ts +17 -0
- package/LexicalTreeView.js.flow +19 -0
- package/README.md +0 -1
- package/package.json +9 -5
- package/useLexicalDecoratorMap.d.ts +14 -0
- package/useLexicalDecoratorMap.js.flow +16 -0
- package/useLexicalIsTextContentEmpty.d.ts +13 -0
- package/useLexicalIsTextContentEmpty.js.flow +15 -0
- package/useLexicalNodeSelection.d.ts +12 -0
- package/useLexicalNodeSelection.js.flow +14 -0
- package/withSubscriptions.d.ts +12 -0
- package/withSubscriptions.js.flow +13 -0
- package/LexicalBootstrapPlugin.dev.js +0 -122
- package/LexicalBootstrapPlugin.js +0 -9
- package/LexicalBootstrapPlugin.prod.js +0 -8
|
@@ -4,25 +4,16 @@
|
|
|
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/react/LexicalComposerContext"),
|
|
8
|
-
function
|
|
9
|
-
function
|
|
10
|
-
function
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
function K(a
|
|
14
|
-
|
|
15
|
-
function M(a,e
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var l=b.anchor,t=b.focus;var m=l.getCharacterOffset();const x=t.getCharacterOffset();var n=l.getNode(),q=t.getNode(),p=n.getParentOrThrow();if(n===q&&y.$isTextNode(n)&&(p.canBeEmpty()||1<p.getChildrenSize()))b=G(n),n=x>m,b.__text=b.__text.slice(n?m:x,n?x:m),m=b.getKey(),m={nodeMap:[[m,b]],range:[m]};else if(b=b.getNodes(),0===b.length)m={nodeMap:[],range:[]};else{n=b.length;q=b[0];p=q.getParent();if(null!==p&&(!p.canBeEmpty()||y.$isRootNode(p))){var r=p.__children;if(r.length===n){var v=!0;for(var w=
|
|
21
|
-
0;w<r.length;w++)if(r[w]!==b[w].__key){v=!1;break}v&&(n++,b.push(p))}}p=b[n-1];l=l.isBefore(t);t=new Map;r=[];H(q,l?m:x,!0,r,t);for(q=0;q<n;q++)if(v=b[q],w=v.getKey(),!(t.has(w)||y.$isElementNode(v)&&v.excludeFromCopy())){const R=G(v);y.$isRootNode(v.getParent())&&r.push(v.getKey());t.set(w,R)}H(p,l?x:m,!1,r,t);m={nodeMap:Array.from(t.entries()),range:r}}}f.call(d,"application/x-lexical-editor",h.call(k,{namespace:c,state:m}))}}})}
|
|
22
|
-
function S(a){u.useEffect(()=>{const e=d=>{var b=a.getRootElement();if(document.activeElement===b&&(b=d.data,"string"===typeof b)){try{var c=JSON.parse(b)}catch(f){return}if(c&&"nuanria_messaging"===c.protocol&&"request"===c.type&&(c=c.payload)&&"makeChanges"===c.functionId&&(c=c.args)){const [f,k,h,l,t]=c;a.update(()=>{const m=y.$getSelection();if(y.$isRangeSelection(m)){var n=m.anchor;let q=n.getNode(),p=0,r=0;y.$isTextNode(q)&&0<=f&&0<=k&&(p=f,r=f+k,m.setTextNodeRange(q,p,q,r));if(p!==r||""!==
|
|
23
|
-
h)m.insertRawText(h),q=n.getNode();y.$isTextNode(q)&&(p=l,r=l+t,n=q.getTextContentSize(),p=p>n?n:p,r=r>n?n:r,m.setTextNodeRange(q,p,q,r));d.stopImmediatePropagation()}})}}};window.addEventListener("message",e,!0);return()=>{window.removeEventListener("message",e,!0)}},[a])}
|
|
24
|
-
function T(a){u.useEffect(()=>{const e=a.addListener("command",(d,b)=>{var c=y.$getSelection();if("click"===d&&y.$isNodeSelection(c))return c.clear(),!0;if(!y.$isRangeSelection(c))return!1;switch(d){case "deleteCharacter":return c.deleteCharacter(b),!0;case "deleteWord":return c.deleteWord(b),!0;case "deleteLine":return c.deleteLine(b),!0;case "insertText":return"string"===typeof b?c.insertText(b):(d=b.dataTransfer,null!=d?M(d,c,a):(b=b.data)&&c.insertText(b)),!0;case "removeText":return c.removeText(),
|
|
25
|
-
!0;case "formatText":return c.formatText(b),!0;case "formatElement":return c=c.anchor.getNode(),(y.$isElementNode(c)?c:c.getParentOrThrow()).setFormat(b),!0;case "insertLineBreak":return c.insertLineBreak(b),!0;case "insertParagraph":return c.insertParagraph(),!0;case "indentContent":return c=c.anchor,c="element"===c.type?c.getNode():c.getNode().getParentOrThrow(),c.canInsertTab()?a.execCommand("insertText","\t"):10!==c.getIndent()&&c.setIndent(c.getIndent()+1),!0;case "outdentContent":return c=c.anchor,
|
|
26
|
-
b=c.getNode(),d="element"===c.type?c.getNode():c.getNode().getParentOrThrow(),d.canInsertTab()?"\t"===b.getTextContent()[c.offset-1]&&a.execCommand("deleteCharacter",!0):0!==d.getIndent()&&d.setIndent(d.getIndent()-1),!0;case "keyArrowLeft":d=b.shiftKey;if(N(c,!0))return b.preventDefault(),b=d,d=I(c),c.modify(b?"extend":"move",!d,"character"),!0;break;case "keyArrowRight":d=b.shiftKey;if(N(c,!1))return b.preventDefault(),b=d,d=I(c),c.modify(b?"extend":"move",d,"character"),!0;break;case "keyBackspace":return b.preventDefault(),
|
|
27
|
-
{anchor:b}=c,c.isCollapsed()&&0===b.offset&&0<("element"===b.type?b.getNode():b.getNode().getParentOrThrow()).getIndent()?a.execCommand("outdentContent"):a.execCommand("deleteCharacter",!0);case "keyDelete":return b.preventDefault(),a.execCommand("deleteCharacter",!1);case "keyEnter":return b.preventDefault(),b.shiftKey?a.execCommand("insertLineBreak"):a.execCommand("insertParagraph");case "keyTab":return b.preventDefault(),a.execCommand(b.shiftKey?"outdentContent":"indentContent");case "keyEscape":return a.blur(),
|
|
28
|
-
!0;case "copy":return Q(b,a),!0;case "cut":return P(b,a),!0;case "paste":return O(b,a),!0;case "drop":case "dragstart":return b.preventDefault(),!0}return!1},0);a.execCommand("bootstrapEditor");return e},[a]);S(a)}module.exports=function({contentEditable:a,placeholder:e}){var [d]=g.useLexicalComposerContext();const b=E(d);T(d);d=F(d);return u.createElement(u.Fragment,null,a,b&&e,d)};
|
|
7
|
+
var g=require("@lexical/react/LexicalComposerContext"),h=require("react"),r=require("lexical"),u=require("react-dom"),v=require("@lexical/clipboard");function w(a,e=!0){if(a)return!1;a=r.$getRoot().getTextContent();e&&(a=a.trim());return""===a}
|
|
8
|
+
function x(a){if(!w(a,!1))return!1;a=r.$getRoot().getChildren();const e=a.length;if(1<e)return!1;for(let d=0;d<e;d++){var f=a[d];if(r.$isElementNode(f)){if("paragraph"!==f.__type||0!==f.__indent)return!1;f=f.getChildren();const c=f.length;for(let b=0;b<c;b++)if(!r.$isTextNode(f[d]))return!1}}return!0}function y(a){return()=>x(a)}var z="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?h.useLayoutEffect:h.useEffect;
|
|
9
|
+
function A(a){const [e,f]=h.useState(a.getEditorState().read(y(a.isComposing())));z(()=>a.addListener("update",({editorState:d})=>{const c=a.isComposing();d=d.read(y(c));f(d)}),[a]);return e}function C(a){const [e,f]=h.useState(()=>a.getDecorators());z(()=>a.addListener("decorator",d=>{u.flushSync(()=>{f(d)})}),[a]);return h.useMemo(()=>{const d=[],c=Object.keys(e);for(let p=0;p<c.length;p++){var b=c[p];const t=e[b];b=a.getElementByKey(b);null!==b&&d.push(u.createPortal(t,b))}return d},[e,a])}
|
|
10
|
+
function D(a){a=a.anchor.getNode();return"rtl"===(r.$isRootNode(a)?a:a.getParentOrThrow()).getDirection()}function E(a,e){a=r.$getDecoratorNode(a.focus,e);return r.$isDecoratorNode(a)&&!a.isIsolated()}function F(a,e){G(a,e);e.update(()=>{const f=r.$getSelection();r.$isRangeSelection(f)&&f.removeText()})}
|
|
11
|
+
function G(a,e){a.preventDefault();e.update(()=>{const f=a.clipboardData,d=r.$getSelection();if(null!==d&&null!=f){const c=v.getHtmlContent(e),b=v.$getLexicalContent(e);null!==c&&f.setData("text/html",c);null!==b&&f.setData("application/x-lexical-editor",b);f.setData("text/plain",d.getTextContent())}})}function H(a,e){a.preventDefault();e.update(()=>{const f=r.$getSelection(),d=a.clipboardData;null!=d&&r.$isRangeSelection(f)&&v.$insertDataTransferForRichText(d,f,e)})}const I={tag:"history-merge"};
|
|
12
|
+
function J(a,e){if(null!==e)if(void 0===e)a.update(()=>{var f=r.$getRoot();if(null===f.getFirstChild()){const d=r.$createParagraphNode();f.append(d);f=document.activeElement;(null!==r.$getSelection()||null!==f&&f===a.getRootElement())&&d.select()}},I);else if(null!==e)switch(typeof e){case "string":e=a.parseEditorState(e);a.setEditorState(e,I);break;case "object":a.setEditorState(e,I);break;case "function":a.update(e,I)}}
|
|
13
|
+
function K(a){h.useEffect(()=>{const e=f=>{var d=a.getRootElement();if(document.activeElement===d&&(d=f.data,"string"===typeof d)){try{var c=JSON.parse(d)}catch(b){return}if(c&&"nuanria_messaging"===c.protocol&&"request"===c.type&&(c=c.payload)&&"makeChanges"===c.functionId&&(c=c.args)){const [b,p,t,B,L]=c;a.update(()=>{const q=r.$getSelection();if(r.$isRangeSelection(q)){var n=q.anchor;let k=n.getNode(),l=0,m=0;r.$isTextNode(k)&&0<=b&&0<=p&&(l=b,m=b+p,q.setTextNodeRange(k,l,k,m));if(l!==m||""!==
|
|
14
|
+
t)q.insertRawText(t),k=n.getNode();r.$isTextNode(k)&&(l=B,m=B+L,n=k.getTextContentSize(),l=l>n?n:l,m=m>n?n:m,q.setTextNodeRange(k,l,k,m));f.stopImmediatePropagation()}})}}};window.addEventListener("message",e,!0);return()=>{window.removeEventListener("message",e,!0)}},[a])}
|
|
15
|
+
function M(a,e){z(()=>{const f=a.addListener("command",(d,c)=>{var b=r.$getSelection();if("click"===d&&r.$isNodeSelection(b))return b.clear(),!0;if(!r.$isRangeSelection(b))return!1;switch(d){case "deleteCharacter":return b.deleteCharacter(c),!0;case "deleteWord":return b.deleteWord(c),!0;case "deleteLine":return b.deleteLine(c),!0;case "insertText":return"string"===typeof c?b.insertText(c):(d=c.dataTransfer,null!=d?v.$insertDataTransferForRichText(d,b,a):(c=c.data)&&b.insertText(c)),!0;case "removeText":return b.removeText(),
|
|
16
|
+
!0;case "formatText":return b.formatText(c),!0;case "formatElement":return b=b.anchor.getNode(),(r.$isElementNode(b)?b:b.getParentOrThrow()).setFormat(c),!0;case "insertLineBreak":return b.insertLineBreak(c),!0;case "insertParagraph":return b.insertParagraph(),!0;case "indentContent":return b=b.anchor,b="element"===b.type?b.getNode():b.getNode().getParentOrThrow(),b.canInsertTab()?a.execCommand("insertText","\t"):10!==b.getIndent()&&b.setIndent(b.getIndent()+1),!0;case "outdentContent":return b=b.anchor,
|
|
17
|
+
c=b.getNode(),d="element"===b.type?b.getNode():b.getNode().getParentOrThrow(),d.canInsertTab()?"\t"===c.getTextContent()[b.offset-1]&&a.execCommand("deleteCharacter",!0):0!==d.getIndent()&&d.setIndent(d.getIndent()-1),!0;case "keyArrowLeft":d=c.shiftKey;if(E(b,!0))return c.preventDefault(),c=d,d=D(b),b.modify(c?"extend":"move",!d,"character"),!0;break;case "keyArrowRight":d=c.shiftKey;if(E(b,!1))return c.preventDefault(),c=d,d=D(b),b.modify(c?"extend":"move",d,"character"),!0;break;case "keyBackspace":return c.preventDefault(),
|
|
18
|
+
{anchor:c}=b,b.isCollapsed()&&0===c.offset&&0<("element"===c.type?c.getNode():c.getNode().getParentOrThrow()).getIndent()?a.execCommand("outdentContent"):a.execCommand("deleteCharacter",!0);case "keyDelete":return c.preventDefault(),a.execCommand("deleteCharacter",!1);case "keyEnter":return c.preventDefault(),c.shiftKey?a.execCommand("insertLineBreak"):a.execCommand("insertParagraph");case "keyTab":return c.preventDefault(),a.execCommand(c.shiftKey?"outdentContent":"indentContent");case "keyEscape":return a.blur(),
|
|
19
|
+
!0;case "copy":return G(c,a),!0;case "cut":return F(c,a),!0;case "paste":return H(c,a),!0;case "drop":case "dragstart":return c.preventDefault(),!0}return!1},0);J(a,e);return f},[a]);K(a)}module.exports=function({contentEditable:a,placeholder:e,initialEditorState:f}){const [d]=g.useLexicalComposerContext(),c=A(d);M(d,f);f=C(d);return h.createElement(h.Fragment,null,a,c&&e,f)};
|
|
@@ -71,6 +71,28 @@ function TablePlugin() {
|
|
|
71
71
|
return false;
|
|
72
72
|
}, EditorPriority);
|
|
73
73
|
}, [editor]);
|
|
74
|
+
react.useEffect(() => {
|
|
75
|
+
const listeners = new Map();
|
|
76
|
+
return editor.addListener('mutation', table.TableNode, nodeMutations => {
|
|
77
|
+
// eslint-disable-next-line no-for-of-loops/no-for-of-loops
|
|
78
|
+
for (const [nodeKey, mutation] of nodeMutations) {
|
|
79
|
+
if (mutation === 'created') {
|
|
80
|
+
editor.update(() => {
|
|
81
|
+
const tableElement = editor.getElementByKey(nodeKey);
|
|
82
|
+
const tableNode = lexical.$getNodeByKey(nodeKey);
|
|
83
|
+
|
|
84
|
+
if (tableElement && tableNode) {
|
|
85
|
+
const removeListeners = table.$applyCustomTableHandlers(tableNode, tableElement, editor);
|
|
86
|
+
listeners.set(nodeKey, removeListeners);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
} else if (mutation === 'destroyed') {
|
|
90
|
+
const cleanup = listeners.get(nodeKey);
|
|
91
|
+
if (cleanup) cleanup();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}, [editor]);
|
|
74
96
|
return null;
|
|
75
97
|
}
|
|
76
98
|
|
|
@@ -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 LexicalTablePlugin(): null;
|
|
@@ -4,6 +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
|
|
8
|
-
module.exports=function(){const [
|
|
9
|
-
|
|
7
|
+
var e=require("@lexical/react/LexicalComposerContext"),g=require("@lexical/table"),k=require("lexical"),m=require("react");
|
|
8
|
+
module.exports=function(){const [d]=e.useLexicalComposerContext();m.useEffect(()=>{if(!d.hasNodes([g.TableNode,g.TableCellNode,g.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 d.addListener("command",(a,b)=>{if("insertTable"===a){const {columns:h,rows:f}=b;a=k.$getSelection();if(!k.$isRangeSelection(a))return!0;var c=a.focus;a=c.getNode();null!==a&&(b=g.$createTableNodeWithDimensions(f,
|
|
9
|
+
h),k.$isRootNode(a)?(c=a.getChildAtIndex(c.offset),null!==c?c.insertBefore(b):a.append(b)):a.getTopLevelElementOrThrow().insertAfter(b),b.insertAfter(k.$createParagraphNode()),b.getFirstChildOrThrow().getFirstChildOrThrow().select());return!0}return!1},0)},[d]);m.useEffect(()=>{const a=new Map;return d.addListener("mutation",g.TableNode,b=>{for(const [c,h]of b)"created"===h?d.update(()=>{var f=d.getElementByKey(c);const l=k.$getNodeByKey(c);f&&l&&(f=g.$applyCustomTableHandlers(l,f,d),a.set(c,f))}):
|
|
10
|
+
"destroyed"===h&&(b=a.get(c))&&b()})},[d]);return null};
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type {LexicalEditor} from 'lexical';
|
|
10
|
+
export default function TreeView(props: {
|
|
11
|
+
timeTravelPanelClassName: string;
|
|
12
|
+
timeTravelPanelSliderClassName: string;
|
|
13
|
+
timeTravelPanelButtonClassName: string;
|
|
14
|
+
timeTravelButtonClassName: string;
|
|
15
|
+
viewClassName: string;
|
|
16
|
+
editor: LexicalEditor;
|
|
17
|
+
}): React.ReactNode;
|
|
@@ -0,0 +1,19 @@
|
|
|
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 {LexicalEditor} from 'lexical';
|
|
11
|
+
|
|
12
|
+
declare export default function TreeView(props: {
|
|
13
|
+
timeTravelPanelClassName: string,
|
|
14
|
+
timeTravelPanelSliderClassName: string,
|
|
15
|
+
timeTravelPanelButtonClassName: string,
|
|
16
|
+
timeTravelButtonClassName: string,
|
|
17
|
+
viewClassName: string,
|
|
18
|
+
editor: LexicalEditor,
|
|
19
|
+
}): React$Node;
|
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -12,12 +12,16 @@
|
|
|
12
12
|
"rich-text"
|
|
13
13
|
],
|
|
14
14
|
"license": "MIT",
|
|
15
|
-
"version": "0.1.
|
|
15
|
+
"version": "0.1.13",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@lexical/helpers": "0.1.13",
|
|
18
|
+
"@lexical/clipboard": "0.1.13",
|
|
19
|
+
"@lexical/list": "0.1.13",
|
|
20
|
+
"@lexical/table": "0.1.13",
|
|
21
|
+
"@lexical/yjs": "0.1.13"
|
|
22
|
+
},
|
|
16
23
|
"peerDependencies": {
|
|
17
|
-
"lexical": "0.1.
|
|
18
|
-
"@lexical/helpers": "0.1.10",
|
|
19
|
-
"@lexical/table": "0.1.10",
|
|
20
|
-
"@lexical/yjs": "0.1.10",
|
|
24
|
+
"lexical": "0.1.13",
|
|
21
25
|
"react": ">=17.x",
|
|
22
26
|
"react-dom": ">=17.x"
|
|
23
27
|
},
|
|
@@ -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
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type {DecoratorMap, DecoratorStateValue} from 'lexical';
|
|
10
|
+
export default function useLexicalDecoratorMap<V extends DecoratorStateValue>(
|
|
11
|
+
decoratorMap: DecoratorMap,
|
|
12
|
+
key: string,
|
|
13
|
+
initialValue: (() => V) | V,
|
|
14
|
+
): [V, (arg0: DecoratorStateValue) => void];
|
|
@@ -0,0 +1,16 @@
|
|
|
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 {DecoratorMap, DecoratorStateValue} from 'lexical';
|
|
11
|
+
|
|
12
|
+
declare export default function useLexicalDecoratorMap<V: DecoratorStateValue>(
|
|
13
|
+
decoratorMap: DecoratorMap,
|
|
14
|
+
key: string,
|
|
15
|
+
initialValue: (() => V) | V,
|
|
16
|
+
): [V, (DecoratorStateValue) => void];
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type {LexicalEditor} from 'lexical';
|
|
10
|
+
export default function useLexicalIsTextContentEmpty(
|
|
11
|
+
editor: LexicalEditor,
|
|
12
|
+
trim?: boolean,
|
|
13
|
+
): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
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 {LexicalEditor} from 'lexical';
|
|
11
|
+
|
|
12
|
+
declare export default function useLexicalIsTextContentEmpty(
|
|
13
|
+
editor: LexicalEditor,
|
|
14
|
+
trim?: boolean,
|
|
15
|
+
): boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type {NodeKey} from 'lexical';
|
|
10
|
+
export default function useLexicalNodeSelection(
|
|
11
|
+
key: NodeKey,
|
|
12
|
+
): [boolean, (arg0: boolean) => void, () => void];
|
|
@@ -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
|
+
* @flow strict
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type {NodeKey} from 'lexical';
|
|
11
|
+
|
|
12
|
+
declare export default function useLexicalNodeSelection(
|
|
13
|
+
key: NodeKey,
|
|
14
|
+
): [boolean, (boolean) => void, () => void];
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
*/
|
|
8
|
+
|
|
9
|
+
type UnsubscribeFn = () => void;
|
|
10
|
+
export default function withSubscriptions(
|
|
11
|
+
...unsubscribe: Array<UnsubscribeFn>
|
|
12
|
+
): () => void;
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
type UnsubscribeFn = () => void;
|
|
11
|
+
declare export default function withSubscriptions(
|
|
12
|
+
...unsubscribe: Array<UnsubscribeFn>
|
|
13
|
+
): () => void;
|
|
@@ -1,122 +0,0 @@
|
|
|
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 lexical = require('lexical');
|
|
11
|
-
var react = require('react');
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
15
|
-
*
|
|
16
|
-
* This source code is licensed under the MIT license found in the
|
|
17
|
-
* LICENSE file in the root directory of this source tree.
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
25
|
-
*
|
|
26
|
-
* This source code is licensed under the MIT license found in the
|
|
27
|
-
* LICENSE file in the root directory of this source tree.
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
|
-
const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
|
|
32
|
-
var useLayoutEffect = useLayoutEffectImpl;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
36
|
-
*
|
|
37
|
-
* This source code is licensed under the MIT license found in the
|
|
38
|
-
* LICENSE file in the root directory of this source tree.
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*/
|
|
42
|
-
const BootstrapPriority = 0;
|
|
43
|
-
|
|
44
|
-
function shouldSelectParagraph(editor) {
|
|
45
|
-
const activeElement = document.activeElement;
|
|
46
|
-
return lexical.$getSelection() !== null || activeElement !== null && activeElement === editor.getRootElement();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function initParagraph(root, editor) {
|
|
50
|
-
const paragraph = lexical.$createParagraphNode();
|
|
51
|
-
root.append(paragraph);
|
|
52
|
-
|
|
53
|
-
if (shouldSelectParagraph(editor)) {
|
|
54
|
-
paragraph.select();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function defaultInitEditor(editor) {
|
|
59
|
-
const root = lexical.$getRoot();
|
|
60
|
-
const firstChild = root.getFirstChild();
|
|
61
|
-
|
|
62
|
-
if (firstChild === null) {
|
|
63
|
-
initParagraph(root, editor);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function defaultClearEditor(editor) {
|
|
68
|
-
const root = lexical.$getRoot();
|
|
69
|
-
root.clear();
|
|
70
|
-
initParagraph(root, editor);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function initEditor(editor, initialPayloadFn) {
|
|
74
|
-
editor.update(() => {
|
|
75
|
-
initialPayloadFn(editor);
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function clearEditor(editor, clearEditorFn, callbackFn) {
|
|
80
|
-
editor.update(() => {
|
|
81
|
-
clearEditorFn(editor);
|
|
82
|
-
}, {
|
|
83
|
-
onUpdate: callbackFn
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function useBootstrapEditor(editor, initialPayloadFn, clearEditorFn) {
|
|
88
|
-
useLayoutEffect(() => {
|
|
89
|
-
return editor.addListener('command', (type, payload) => {
|
|
90
|
-
if (type === 'bootstrapEditor') {
|
|
91
|
-
initEditor(editor, initialPayloadFn != null ? initialPayloadFn : defaultInitEditor);
|
|
92
|
-
return true;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (type === 'clearEditor') {
|
|
96
|
-
clearEditor(editor, clearEditorFn != null ? clearEditorFn : defaultClearEditor);
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return false;
|
|
101
|
-
}, BootstrapPriority);
|
|
102
|
-
}, [clearEditorFn, editor, initialPayloadFn]);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
107
|
-
*
|
|
108
|
-
* This source code is licensed under the MIT license found in the
|
|
109
|
-
* LICENSE file in the root directory of this source tree.
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*/
|
|
113
|
-
function LexicalBootstrapPlugin({
|
|
114
|
-
initialPayloadFn,
|
|
115
|
-
clearEditorFn
|
|
116
|
-
}) {
|
|
117
|
-
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
118
|
-
useBootstrapEditor(editor, initialPayloadFn, clearEditorFn);
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
module.exports = LexicalBootstrapPlugin;
|
|
@@ -1,9 +0,0 @@
|
|
|
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 LexicalBootstrapPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalBootstrapPlugin.dev.js') : require('./LexicalBootstrapPlugin.prod.js')
|
|
9
|
-
module.exports = LexicalBootstrapPlugin;
|
|
@@ -1,8 +0,0 @@
|
|
|
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 d=require("@lexical/react/LexicalComposerContext"),e=require("lexical"),f=require("react"),h="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?f.useLayoutEffect:f.useEffect;function k(a,b){const c=e.$createParagraphNode();a.append(c);a=document.activeElement;(null!==e.$getSelection()||null!==a&&a===b.getRootElement())&&c.select()}function l(a){const b=e.$getRoot();null===b.getFirstChild()&&k(b,a)}
|
|
8
|
-
function m(a){const b=e.$getRoot();b.clear();k(b,a)}function n(a,b){a.update(()=>{b(a)})}function p(a,b,c){a.update(()=>{b(a)},{onUpdate:c})}function q(a,b,c){h(()=>a.addListener("command",g=>"bootstrapEditor"===g?(n(a,null!=b?b:l),!0):"clearEditor"===g?(p(a,null!=c?c:m),!0):!1,0),[c,a,b])}module.exports=function({initialPayloadFn:a,clearEditorFn:b}){const [c]=d.useLexicalComposerContext();q(c,a,b);return null};
|