@lexical/react 0.1.11 → 0.1.12
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 +14 -9
- package/DEPRECATED_useLexicalAutoFormatter.prod.js +18 -18
- package/DEPRECATED_useLexicalPlainText.dev.js +33 -27
- package/DEPRECATED_useLexicalPlainText.prod.js +12 -12
- package/DEPRECATED_useLexicalRichText.dev.js +43 -388
- package/DEPRECATED_useLexicalRichText.prod.js +17 -25
- package/LexicalAutoFormatterPlugin.d.ts +9 -0
- package/LexicalAutoFormatterPlugin.dev.js +14 -9
- package/LexicalAutoFormatterPlugin.prod.js +18 -18
- package/LexicalAutoLinkPlugin.d.ts +20 -0
- package/LexicalCharacterLimitPlugin.d.ts +11 -0
- package/LexicalClearEditorPlugin.d.ts +14 -0
- package/LexicalClearEditorPlugin.dev.js +22 -1
- package/LexicalClearEditorPlugin.prod.js +2 -1
- package/LexicalCollaborationPlugin.d.ts +49 -0
- package/LexicalCollaborationPlugin.js.flow +1 -1
- package/LexicalComposer.d.ts +22 -0
- package/LexicalComposer.dev.js +27 -5
- package/LexicalComposer.js.flow +2 -1
- package/LexicalComposer.prod.js +3 -3
- package/LexicalComposerContext.d.ts +24 -0
- package/LexicalComposerContext.js.flow +1 -1
- package/LexicalContentEditable.d.ts +32 -0
- package/LexicalContentEditable.dev.js +22 -1
- package/LexicalContentEditable.prod.js +3 -3
- package/LexicalHashtagPlugin.d.ts +9 -0
- package/LexicalHashtagPlugin.js.flow +0 -10
- package/LexicalHistoryPlugin.d.ts +29 -0
- package/LexicalHorizontalRuleNode.d.ts +23 -0
- package/LexicalLinkPlugin.d.ts +9 -0
- package/LexicalListPlugin.d.ts +9 -0
- package/LexicalNestedComposer.d.ts +20 -0
- package/LexicalOnChangePlugin.d.ts +12 -0
- package/LexicalPlainTextPlugin.d.ts +15 -0
- package/LexicalPlainTextPlugin.dev.js +11 -26
- package/LexicalPlainTextPlugin.prod.js +8 -8
- package/LexicalRichTextPlugin.d.ts +15 -0
- package/LexicalRichTextPlugin.dev.js +24 -390
- package/LexicalRichTextPlugin.prod.js +13 -21
- package/LexicalTablePlugin.d.ts +9 -0
- package/LexicalTreeView.d.ts +17 -0
- package/package.json +6 -5
- package/useLexicalDecoratorMap.d.ts +14 -0
- package/useLexicalIsTextContentEmpty.d.ts +13 -0
- package/useLexicalNodeSelection.d.ts +12 -0
- package/withSubscriptions.d.ts +12 -0
|
@@ -4,24 +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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
0;
|
|
20
|
-
function S(a,e){if(null!==e)if(void 0===e)a.update(()=>{var f=y.$getRoot();if(null===f.getFirstChild()){const c=y.$createParagraphNode();f.append(c);f=document.activeElement;(null!==y.$getSelection()||null!==f&&f===a.getRootElement())&&c.select()}},Q);else if(null!==e)switch(typeof e){case "string":e=a.parseEditorState(e);a.setEditorState(e,Q);break;case "object":a.setEditorState(e,Q);break;case "function":a.update(e,Q)}}
|
|
21
|
-
function T(a){u.useEffect(()=>{const e=f=>{var c=a.getRootElement();if(document.activeElement===c&&(c=f.data,"string"===typeof c)){try{var d=JSON.parse(c)}catch(b){return}if(d&&"nuanria_messaging"===d.protocol&&"request"===d.type&&(d=d.payload)&&"makeChanges"===d.functionId&&(d=d.args)){const [b,k,h,l,t]=d;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<=b&&0<=k&&(p=b,r=b+k,m.setTextNodeRange(q,p,q,r));if(p!==r||""!==
|
|
22
|
-
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));f.stopImmediatePropagation()}})}}};window.addEventListener("message",e,!0);return()=>{window.removeEventListener("message",e,!0)}},[a])}
|
|
23
|
-
function U(a,e){u.useLayoutEffect(()=>{const f=a.addListener("command",(c,d)=>{var b=y.$getSelection();if("click"===c&&y.$isNodeSelection(b))return b.clear(),!0;if(!y.$isRangeSelection(b))return!1;switch(c){case "deleteCharacter":return b.deleteCharacter(d),!0;case "deleteWord":return b.deleteWord(d),!0;case "deleteLine":return b.deleteLine(d),!0;case "insertText":return"string"===typeof d?b.insertText(d):(c=d.dataTransfer,null!=c?L(c,b,a):(d=d.data)&&b.insertText(d)),!0;case "removeText":return b.removeText(),
|
|
24
|
-
!0;case "formatText":return b.formatText(d),!0;case "formatElement":return b=b.anchor.getNode(),(y.$isElementNode(b)?b:b.getParentOrThrow()).setFormat(d),!0;case "insertLineBreak":return b.insertLineBreak(d),!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,
|
|
25
|
-
d=b.getNode(),c="element"===b.type?b.getNode():b.getNode().getParentOrThrow(),c.canInsertTab()?"\t"===d.getTextContent()[b.offset-1]&&a.execCommand("deleteCharacter",!0):0!==c.getIndent()&&c.setIndent(c.getIndent()-1),!0;case "keyArrowLeft":c=d.shiftKey;if(M(b,!0))return d.preventDefault(),d=c,c=I(b),b.modify(d?"extend":"move",!c,"character"),!0;break;case "keyArrowRight":c=d.shiftKey;if(M(b,!1))return d.preventDefault(),d=c,c=I(b),b.modify(d?"extend":"move",c,"character"),!0;break;case "keyBackspace":return d.preventDefault(),
|
|
26
|
-
{anchor:d}=b,b.isCollapsed()&&0===d.offset&&0<("element"===d.type?d.getNode():d.getNode().getParentOrThrow()).getIndent()?a.execCommand("outdentContent"):a.execCommand("deleteCharacter",!0);case "keyDelete":return d.preventDefault(),a.execCommand("deleteCharacter",!1);case "keyEnter":return d.preventDefault(),d.shiftKey?a.execCommand("insertLineBreak"):a.execCommand("insertParagraph");case "keyTab":return d.preventDefault(),a.execCommand(d.shiftKey?"outdentContent":"indentContent");case "keyEscape":return a.blur(),
|
|
27
|
-
!0;case "copy":return P(d,a),!0;case "cut":return O(d,a),!0;case "paste":return N(d,a),!0;case "drop":case "dragstart":return d.preventDefault(),!0}return!1},0);S(a,e);return f},[a]);T(a)}module.exports=function({contentEditable:a,placeholder:e,initialEditorState:f}){const [c]=g.useLexicalComposerContext(),d=E(c);U(c,f);f=F(c);return u.createElement(u.Fragment,null,a,d&&e,f)};
|
|
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)};
|
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -12,12 +12,13 @@
|
|
|
12
12
|
"rich-text"
|
|
13
13
|
],
|
|
14
14
|
"license": "MIT",
|
|
15
|
-
"version": "0.1.
|
|
15
|
+
"version": "0.1.12",
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"lexical": "0.1.
|
|
18
|
-
"@lexical/helpers": "0.1.
|
|
19
|
-
"@lexical/table": "0.1.
|
|
20
|
-
"@lexical/yjs": "0.1.
|
|
17
|
+
"lexical": "0.1.12",
|
|
18
|
+
"@lexical/helpers": "0.1.12",
|
|
19
|
+
"@lexical/table": "0.1.12",
|
|
20
|
+
"@lexical/yjs": "0.1.12",
|
|
21
|
+
"@lexical/clipboard": "0.1.12",
|
|
21
22
|
"react": ">=17.x",
|
|
22
23
|
"react-dom": ">=17.x"
|
|
23
24
|
},
|
|
@@ -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,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,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,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;
|