@lexical/react 0.12.3 → 0.12.5
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/LexicalClickableLinkPlugin.dev.js +1 -1
- package/LexicalClickableLinkPlugin.prod.js +2 -2
- package/LexicalHistoryPlugin.js.flow +2 -8
- package/LexicalNestedComposer.dev.js +3 -0
- package/LexicalNestedComposer.prod.js +4 -4
- package/LexicalTreeView.dev.js +1 -0
- package/LexicalTreeView.prod.js +14 -15
- package/package.json +19 -19
- package/useLexicalNodeSelection.dev.js +6 -4
- package/useLexicalNodeSelection.prod.js +3 -2
|
@@ -50,7 +50,7 @@ function LexicalClickableLinkPlugin({
|
|
|
50
50
|
if (clickedNode !== null) {
|
|
51
51
|
const maybeLinkNode = utils.$findMatchingParent(clickedNode, lexical.$isElementNode);
|
|
52
52
|
if (link.$isLinkNode(maybeLinkNode)) {
|
|
53
|
-
url = maybeLinkNode.getURL();
|
|
53
|
+
url = maybeLinkNode.sanitizeUrl(maybeLinkNode.getURL());
|
|
54
54
|
urlTarget = maybeLinkNode.getTarget();
|
|
55
55
|
} else {
|
|
56
56
|
const a = findMatchingDOM(target, utils.isHTMLAnchorElement);
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
'use strict';var e=require("@lexical/link"),m=require("@lexical/react/LexicalComposerContext"),q=require("@lexical/utils"),r=require("lexical"),t=require("react");
|
|
8
|
-
module.exports=function({newTab:n=!0}){let [h]=m.useLexicalComposerContext();t.useEffect(()=>{let l=
|
|
9
|
-
if(null!==f&&""!==f){d=h.getEditorState().read(r.$getSelection);if(!r.$isRangeSelection(d)||d.isCollapsed())d="auxclick"===
|
|
8
|
+
module.exports=function({newTab:n=!0}){let [h]=m.useLexicalComposerContext();t.useEffect(()=>{let l=b=>{const c=b.target;if(c instanceof Node){var d=r.getNearestEditorFromDOMNode(c);if(null!==d){var f=null,k=null;d.update(()=>{var a=r.$getNearestNodeFromDOMNode(c);if(null!==a)if(a=q.$findMatchingParent(a,r.$isElementNode),e.$isLinkNode(a))f=a.sanitizeUrl(a.getURL()),k=a.getTarget();else{a:{a=q.isHTMLAnchorElement;let g=c;for(;null!=g;){if(a(g)){a=g;break a}g=g.parentNode}a=null}null!==a&&(f=a.href,
|
|
9
|
+
k=a.target)}});if(null!==f&&""!==f){d=h.getEditorState().read(r.$getSelection);if(!r.$isRangeSelection(d)||d.isCollapsed())d="auxclick"===b.type&&1===b.button,window.open(f,n||d||b.metaKey||b.ctrlKey||"_blank"===k?"_blank":"_self");b.preventDefault()}}}},p=b=>{1===b.button&&h.isEditable()&&l(b)};return h.registerRootListener((b,c)=>{null!==c&&(c.removeEventListener("click",l),c.removeEventListener("mouseup",p));null!==b&&(b.addEventListener("click",l),b.addEventListener("mouseup",p))})},[h,n]);return null}
|
|
@@ -7,18 +7,12 @@
|
|
|
7
7
|
* @flow strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type {
|
|
11
|
-
EditorState,
|
|
12
|
-
GridSelection,
|
|
13
|
-
LexicalEditor,
|
|
14
|
-
NodeSelection,
|
|
15
|
-
RangeSelection,
|
|
16
|
-
} from 'lexical';
|
|
10
|
+
import type {BaseSelection, EditorState, LexicalEditor} from 'lexical';
|
|
17
11
|
|
|
18
12
|
export type HistoryStateEntry = {
|
|
19
13
|
editor: LexicalEditor,
|
|
20
14
|
editorState: EditorState,
|
|
21
|
-
undoSelection?:
|
|
15
|
+
undoSelection?: BaseSelection | null,
|
|
22
16
|
};
|
|
23
17
|
|
|
24
18
|
export type HistoryState = {
|
|
@@ -45,6 +45,7 @@ function LexicalNestedComposer({
|
|
|
45
45
|
const parentNodes = initialEditor._nodes = new Map(parentEditor._nodes);
|
|
46
46
|
for (const [type, entry] of parentNodes) {
|
|
47
47
|
initialEditor._nodes.set(type, {
|
|
48
|
+
exportDOM: entry.exportDOM,
|
|
48
49
|
klass: entry.klass,
|
|
49
50
|
replace: entry.replace,
|
|
50
51
|
replaceWithKlass: entry.replaceWithKlass,
|
|
@@ -61,7 +62,9 @@ function LexicalNestedComposer({
|
|
|
61
62
|
replace = options.with;
|
|
62
63
|
replaceWithKlass = options.withKlass || null;
|
|
63
64
|
}
|
|
65
|
+
const registeredKlass = initialEditor._nodes.get(klass.getType());
|
|
64
66
|
initialEditor._nodes.set(klass.getType(), {
|
|
67
|
+
exportDOM: registeredKlass ? registeredKlass.exportDOM : undefined,
|
|
65
68
|
klass,
|
|
66
69
|
replace,
|
|
67
70
|
replaceWithKlass,
|
|
@@ -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
|
-
'use strict';var d=require("@lexical/react/LexicalCollaborationContext"),
|
|
8
|
-
exports.LexicalNestedComposer=function({initialEditor:a,children:h,initialNodes:e,initialTheme:
|
|
9
|
-
transforms:new Set})}else{c=a._nodes=new Map(f._nodes);for(const [
|
|
10
|
-
{value:y},!z||
|
|
7
|
+
'use strict';var d=require("@lexical/react/LexicalCollaborationContext"),m=require("@lexical/react/LexicalComposerContext"),r=require("react");function t(a){let h=new URLSearchParams;h.append("code",a);for(let e=1;e<arguments.length;e++)h.append("v",arguments[e]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${h} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
|
|
8
|
+
exports.LexicalNestedComposer=function({initialEditor:a,children:h,initialNodes:e,initialTheme:u,skipCollabChecks:v}){let q=r.useRef(!1),n=r.useContext(m.LexicalComposerContext);null==n&&t(9);let [f,{getTheme:w}]=n,y=r.useMemo(()=>{var b=u||w()||void 0;const x=m.createLexicalComposerContext(n,b);void 0!==b&&(a._config.theme=b);a._parentEditor=f;if(e)for(var c of e){var g=b=null;"function"!==typeof c&&(g=c,c=g.replace,b=g.with,g=g.withKlass||null);const k=a._nodes.get(c.getType());a._nodes.set(c.getType(),
|
|
9
|
+
{exportDOM:k?k.exportDOM:void 0,klass:c,replace:b,replaceWithKlass:g,transforms:new Set})}else{c=a._nodes=new Map(f._nodes);for(const [k,l]of c)a._nodes.set(k,{exportDOM:l.exportDOM,klass:l.klass,replace:l.replace,replaceWithKlass:l.replaceWithKlass,transforms:new Set})}a._config.namespace=f._config.namespace;a._editable=f._editable;return[a,x]},[]),{isCollabActive:z,yjsDocMap:A}=d.useCollaborationContext(),p=v||q.current||A.has(a.getKey());r.useEffect(()=>{p&&(q.current=!0)},[p]);r.useEffect(()=>
|
|
10
|
+
f.registerEditableListener(b=>{a.setEditable(b)}),[a,f]);return r.createElement(m.LexicalComposerContext.Provider,{value:y},!z||p?h:null)}
|
package/LexicalTreeView.dev.js
CHANGED
|
@@ -250,6 +250,7 @@ function printRangeSelection(selection) {
|
|
|
250
250
|
return res;
|
|
251
251
|
}
|
|
252
252
|
function printNodeSelection(selection) {
|
|
253
|
+
if (!lexical.$isNodeSelection(selection)) return '';
|
|
253
254
|
return `: node\n └ [${Array.from(selection._nodes).join(', ')}]`;
|
|
254
255
|
}
|
|
255
256
|
function printGridSelection(selection) {
|
package/LexicalTreeView.prod.js
CHANGED
|
@@ -4,21 +4,20 @@
|
|
|
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
|
-
'use strict';var g=require("@lexical/html"),
|
|
7
|
+
'use strict';var g=require("@lexical/html"),v=require("@lexical/link"),x=require("@lexical/mark"),I=require("@lexical/utils"),M=require("lexical"),N=require("react");let O=Object.freeze({"\t":"\\t","\n":"\\n"}),P=new RegExp(Object.keys(O).join("|"),"g"),Q=Object.freeze({ancestorHasNextSibling:"|",ancestorIsLastChild:" ",hasNextSibling:"\u251c",isLastChild:"\u2514",selectedChar:"^",selectedLine:">"});
|
|
8
8
|
function R(a){let [b,c]=N.useState([]);N.useEffect(()=>{let l=new Set;for(let [e]of a._commands)l.add(a.registerCommand(e,p=>{c(d=>{d=[...d];d.push({payload:p,type:e.type?e.type:"UNKNOWN"});10<d.length&&d.shift();return d});return!1},M.COMMAND_PRIORITY_HIGH));return()=>l.forEach(e=>e())},[a]);return N.useMemo(()=>b,[b])}
|
|
9
|
-
function U(a){let b="";var c=V(a);b+=`: range ${""!==c?`{ ${c} }`:""} ${""!==a.style?`{ style: ${a.style} } `:""}`;c=a.anchor;a=a.focus;let l=c.offset,e=a.offset;b+=`\n \u251c anchor { key: ${c.key}, offset: ${null===l?"null":l}, type: ${c.type} }`;return b+=`\n \u2514 focus { key: ${a.key}, offset: ${null===e?"null":e}, type: ${a.type} }`}
|
|
10
|
-
function W(a,b,c){let l=a.getEditorState(),e=a._config,p=a._compositionKey,d=a._editable;if(c){let m="";l.read(()=>{var k=g.$generateHtmlFromNodes(a);let t=document.createElement("div");t.innerHTML=k.trim();m=X(t,0).innerHTML});return m}let h=" root\n";c=l.read(()=>{const m=M.$getSelection();Y(M.$getRoot(),(k,t)=>{const y=`(${k.getKey()})`,
|
|
11
|
-
k.getTextContent();var u=0===n.length?"(empty)":`"${Z(n)}"`;n=[V(k),
|
|
12
|
-
h=A+`${H} ${F} ${y} ${
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
let
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
d.offset]:c===v?[e,b]=v.isBefore(q)?[d.offset,k]:[0,d.offset]:c===q?[e,b]=q.isBefore(v)?[h.offset,k]:[0,h.offset]:[e,b]=[0,k]}c=(m.slice(0,e).match(P)||[]).length;d=(m.slice(e,b).match(P)||[]).length;let [t,y]=[e+c,b+c+d];if(t===y)return"";c=a[a.length-1]===Q.hasNextSibling?Q.ancestorHasNextSibling:Q.ancestorIsLastChild;a=[...a.slice(0,a.length-1),c];c=Array(t+1).fill(" ");e=Array(y-t).fill(Q.selectedChar);l=Array(l.length+(p.length+3)).fill(" ");return[Q.selectedLine,a.join(" "),[...l,...c,...e].join("")].join(" ")+
|
|
9
|
+
function U(a){let b="";var c=V(a);b+=`: range ${""!==c?`{ ${c} }`:""} ${""!==a.style?`{ style: ${a.style} } `:""}`;c=a.anchor;a=a.focus;let l=c.offset,e=a.offset;b+=`\n \u251c anchor { key: ${c.key}, offset: ${null===l?"null":l}, type: ${c.type} }`;return b+=`\n \u2514 focus { key: ${a.key}, offset: ${null===e?"null":e}, type: ${a.type} }`}function aa(a){return M.$isNodeSelection(a)?`: node\n \u2514 [${Array.from(a._nodes).join(", ")}]`:""}
|
|
10
|
+
function W(a,b,c){let l=a.getEditorState(),e=a._config,p=a._compositionKey,d=a._editable;if(c){let m="";l.read(()=>{var k=g.$generateHtmlFromNodes(a);let t=document.createElement("div");t.innerHTML=k.trim();m=X(t,0).innerHTML});return m}let h=" root\n";c=l.read(()=>{const m=M.$getSelection();Y(M.$getRoot(),(k,t)=>{const y=`(${k.getKey()})`,w=k.getType()||"",q=k.isSelected(),J=x.$isMarkNode(k)?` id: [ ${k.getIDs().join(", ")} ] `:"";var A=h,H=q?Q.selectedLine:" ",F=t.join(" ");if(M.$isTextNode(k)){var n=
|
|
11
|
+
k.getTextContent();var u=0===n.length?"(empty)":`"${Z(n)}"`;n=[V(k),ba(k),ca(k)].filter(Boolean).join(", ");n=[u,0!==n.length?`{ ${n} }`:null].filter(Boolean).join(" ").trim()}else if(v.$isLinkNode(k)){n=k.getURL();n=0===n.length?"(empty)":`"${Z(n)}"`;u=k.getTarget();null!=u&&(u="target: "+u);var B=Boolean;var C=k.getRel();null!=C&&(C="rel: "+C);let r=k.getTitle();null!=r&&(r="title: "+r);u=[u,C,r].filter(B).join(", ");n=[n,0!==u.length?`{ ${u} }`:null].filter(Boolean).join(" ").trim()}else n="";
|
|
12
|
+
h=A+`${H} ${F} ${y} ${w} ${J} ${n}\n`;h+=da({indent:t,isSelected:q,node:k,nodeKeyDisplay:y,selection:m,typeDisplay:w})});return null===m?": null":M.$isRangeSelection(m)?U(m):M.DEPRECATED_$isGridSelection(m)?`: grid\n \u2514 { grid: ${m.gridKey}, anchorCell: ${m.anchor.key}, focusCell: ${m.focus.key} }`:aa(m)});h+="\n selection"+c;h+="\n\n commands:";if(b.length)for(let {type:m,payload:k}of b)h+=`\n \u2514 { type: ${m}, payload: ${k instanceof Event?k.constructor.name:k} }`;else h+="\n \u2514 None dispatched.";
|
|
13
|
+
h+="\n\n editor:";h+=`\n \u2514 namespace ${e.namespace}`;null!==p&&(h+=`\n \u2514 compositionKey ${p}`);return h+=`\n \u2514 editable ${String(d)}`}function Y(a,b,c=[]){a=a.getChildren();let l=a.length;a.forEach((e,p)=>{b(e,c.concat(p===l-1?Q.isLastChild:Q.hasNextSibling));M.$isElementNode(e)&&Y(e,b,c.concat(p===l-1?Q.ancestorIsLastChild:Q.ancestorHasNextSibling))})}function Z(a){return Object.entries(O).reduce((b,[c,l])=>b.replace(new RegExp(c,"g"),String(l)),a)}
|
|
14
|
+
let ea=[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"],fa=[a=>a.isDirectionless()&&"Directionless",a=>a.isUnmergeable()&&"Unmergeable"],ha=[a=>a.isToken()&&"Token",a=>a.isSegmented()&&"Segmented"];
|
|
15
|
+
function ba(a){let b=fa.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="detail: "+b);return b}function ca(a){let b=ha.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="mode: "+b);return b}function V(a){let b=ea.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="format: "+b);return b}
|
|
16
|
+
function da({indent:a,isSelected:b,node:c,nodeKeyDisplay:l,selection:e,typeDisplay:p}){if(!M.$isTextNode(c)||!M.$isRangeSelection(e)||!b||M.$isElementNode(c))return"";b=e.anchor;var d=e.focus;if(""===c.getTextContent()||b.getNode()===e.focus.getNode()&&b.offset===d.offset)return"";d=e.anchor;let h=e.focus,m=c.getTextContent(),k=m.length;b=e=-1;if("text"===d.type&&"text"===h.type){let w=d.getNode(),q=h.getNode();w===q&&c===w&&d.offset!==h.offset?[e,b]=d.offset<h.offset?[d.offset,h.offset]:[h.offset,
|
|
17
|
+
d.offset]:c===w?[e,b]=w.isBefore(q)?[d.offset,k]:[0,d.offset]:c===q?[e,b]=q.isBefore(w)?[h.offset,k]:[0,h.offset]:[e,b]=[0,k]}c=(m.slice(0,e).match(P)||[]).length;d=(m.slice(e,b).match(P)||[]).length;let [t,y]=[e+c,b+c+d];if(t===y)return"";c=a[a.length-1]===Q.hasNextSibling?Q.ancestorHasNextSibling:Q.ancestorIsLastChild;a=[...a.slice(0,a.length-1),c];c=Array(t+1).fill(" ");e=Array(y-t).fill(Q.selectedChar);l=Array(l.length+(p.length+3)).fill(" ");return[Q.selectedLine,a.join(" "),[...l,...c,...e].join("")].join(" ")+
|
|
19
18
|
"\n"}function X(a,b){let c=Array(b++ +1).join(" "),l=Array(b-1).join(" "),e;for(let p=0;p<a.children.length;p++)e=document.createTextNode("\n"+c),a.insertBefore(e,a.children[p]),X(a.children[p],b),a.lastElementChild===a.children[p]&&(e=document.createTextNode("\n"+l),a.appendChild(e));return a}
|
|
20
|
-
exports.TreeView=function({treeTypeButtonClassName:a,timeTravelButtonClassName:b,timeTravelPanelSliderClassName:c,timeTravelPanelButtonClassName:l,viewClassName:e,timeTravelPanelClassName:p,editor:d}){let [h,m]=N.useState([]),[k,t]=N.useState(""),[y,
|
|
19
|
+
exports.TreeView=function({treeTypeButtonClassName:a,timeTravelButtonClassName:b,timeTravelPanelSliderClassName:c,timeTravelPanelButtonClassName:l,viewClassName:e,timeTravelPanelClassName:p,editor:d}){let [h,m]=N.useState([]),[k,t]=N.useState(""),[y,w]=N.useState(!1),[q,J]=N.useState(!1),A=N.useRef(0),H=N.useRef(null),F=N.useRef(null),[n,u]=N.useState(!1),[B,C]=N.useState(!1),[r,ia]=N.useState(!1),K=N.useRef(null),D=R(d),L=N.useCallback(f=>{const z=W(d,D,q);t(z);y||m(G=>[...G,[Date.now(),f]])},[D,
|
|
21
20
|
d,y,q]);N.useEffect(()=>{let f=d.getEditorState();!r&&1E3>f._nodeMap.size&&t(W(d,D,q))},[D,d,r,q]);N.useEffect(()=>I.mergeRegister(d.registerUpdateListener(({editorState:f})=>{if(!r&&1E3<f._nodeMap.size&&(K.current=f,C(!0),!r))return;L(f)}),d.registerEditableListener(()=>{let f=W(d,D,q);t(f)})),[D,d,q,B,L,r]);let E=h.length;N.useEffect(()=>{if(n){let f,z=()=>{const G=A.current;G===E-1?u(!1):f=setTimeout(()=>{A.current++;const S=A.current,T=F.current;null!==T&&(T.value=String(S));d.setEditorState(h[S][1]);
|
|
22
|
-
z()},h[G+1][0]-h[G][0])};z();return()=>{clearTimeout(f)}}},[h,n,d,E]);N.useEffect(()=>{let f=H.current;if(null!==f)return f.__lexicalEditor=d,()=>{f.__lexicalEditor=null}},[d]);return N.createElement("div",{className:e},!r&&B?N.createElement("div",{style:{padding:20}},N.createElement("span",{style:{marginRight:20}},"Detected large EditorState, this can impact debugging performance."),N.createElement("button",{onClick:()=>{
|
|
23
|
-
border:"1px solid white",color:"white",cursor:"pointer",padding:5}},"Show full tree")):null,r?null:N.createElement("button",{onClick:()=>J(!q),className:a,type:"button"},q?"Tree":"Export DOM"),!y&&(r||!B)&&2<E&&N.createElement("button",{onClick:()=>{let f=d.getRootElement();null!==f&&(f.contentEditable="false",A.current=E-1,
|
|
24
|
-
onClick:()=>{A.current===E-1&&(A.current=1);u(!n)},type:"button"},n?"Pause":"Play"),N.createElement("input",{className:c,ref:F,onChange:f=>{f=Number(f.target.value);let z=h[f];z&&(A.current=f,d.setEditorState(z[1]))},type:"range",min:"1",max:E-1}),N.createElement("button",{className:l,onClick:()=>{var f=d.getRootElement();if(null!==f){f.contentEditable="true";f=h.length-1;d.setEditorState(h[f][1]);let z=F.current;null!==z&&(z.value=String(f));
|
|
21
|
+
z()},h[G+1][0]-h[G][0])};z();return()=>{clearTimeout(f)}}},[h,n,d,E]);N.useEffect(()=>{let f=H.current;if(null!==f)return f.__lexicalEditor=d,()=>{f.__lexicalEditor=null}},[d]);return N.createElement("div",{className:e},!r&&B?N.createElement("div",{style:{padding:20}},N.createElement("span",{style:{marginRight:20}},"Detected large EditorState, this can impact debugging performance."),N.createElement("button",{onClick:()=>{ia(!0);let f=K.current;null!==f&&(K.current=null,L(f))},style:{background:"transparent",
|
|
22
|
+
border:"1px solid white",color:"white",cursor:"pointer",padding:5}},"Show full tree")):null,r?null:N.createElement("button",{onClick:()=>J(!q),className:a,type:"button"},q?"Tree":"Export DOM"),!y&&(r||!B)&&2<E&&N.createElement("button",{onClick:()=>{let f=d.getRootElement();null!==f&&(f.contentEditable="false",A.current=E-1,w(!0))},className:b,type:"button"},"Time Travel"),(r||!B)&&N.createElement("pre",{ref:H},k),y&&(r||!B)&&N.createElement("div",{className:p},N.createElement("button",{className:l,
|
|
23
|
+
onClick:()=>{A.current===E-1&&(A.current=1);u(!n)},type:"button"},n?"Pause":"Play"),N.createElement("input",{className:c,ref:F,onChange:f=>{f=Number(f.target.value);let z=h[f];z&&(A.current=f,d.setEditorState(z[1]))},type:"range",min:"1",max:E-1}),N.createElement("button",{className:l,onClick:()=>{var f=d.getRootElement();if(null!==f){f.contentEditable="true";f=h.length-1;d.setEditorState(h[f][1]);let z=F.current;null!==z&&(z.value=String(f));w(!1);u(!1)}},type:"button"},"Exit")))}
|
package/package.json
CHANGED
|
@@ -8,29 +8,29 @@
|
|
|
8
8
|
"rich-text"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.12.
|
|
11
|
+
"version": "0.12.5",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@lexical/clipboard": "0.12.
|
|
14
|
-
"@lexical/code": "0.12.
|
|
15
|
-
"@lexical/dragon": "0.12.
|
|
16
|
-
"@lexical/hashtag": "0.12.
|
|
17
|
-
"@lexical/history": "0.12.
|
|
18
|
-
"@lexical/link": "0.12.
|
|
19
|
-
"@lexical/list": "0.12.
|
|
20
|
-
"@lexical/mark": "0.12.
|
|
21
|
-
"@lexical/markdown": "0.12.
|
|
22
|
-
"@lexical/overflow": "0.12.
|
|
23
|
-
"@lexical/plain-text": "0.12.
|
|
24
|
-
"@lexical/rich-text": "0.12.
|
|
25
|
-
"@lexical/selection": "0.12.
|
|
26
|
-
"@lexical/table": "0.12.
|
|
27
|
-
"@lexical/text": "0.12.
|
|
28
|
-
"@lexical/utils": "0.12.
|
|
29
|
-
"@lexical/yjs": "0.12.
|
|
13
|
+
"@lexical/clipboard": "0.12.5",
|
|
14
|
+
"@lexical/code": "0.12.5",
|
|
15
|
+
"@lexical/dragon": "0.12.5",
|
|
16
|
+
"@lexical/hashtag": "0.12.5",
|
|
17
|
+
"@lexical/history": "0.12.5",
|
|
18
|
+
"@lexical/link": "0.12.5",
|
|
19
|
+
"@lexical/list": "0.12.5",
|
|
20
|
+
"@lexical/mark": "0.12.5",
|
|
21
|
+
"@lexical/markdown": "0.12.5",
|
|
22
|
+
"@lexical/overflow": "0.12.5",
|
|
23
|
+
"@lexical/plain-text": "0.12.5",
|
|
24
|
+
"@lexical/rich-text": "0.12.5",
|
|
25
|
+
"@lexical/selection": "0.12.5",
|
|
26
|
+
"@lexical/table": "0.12.5",
|
|
27
|
+
"@lexical/text": "0.12.5",
|
|
28
|
+
"@lexical/utils": "0.12.5",
|
|
29
|
+
"@lexical/yjs": "0.12.5",
|
|
30
30
|
"react-error-boundary": "^3.1.4"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"lexical": "0.12.
|
|
33
|
+
"lexical": "0.12.5",
|
|
34
34
|
"react": ">=17.x",
|
|
35
35
|
"react-dom": ">=17.x"
|
|
36
36
|
},
|
|
@@ -48,10 +48,12 @@ function useLexicalNodeSelection(key) {
|
|
|
48
48
|
selection = lexical.$createNodeSelection();
|
|
49
49
|
lexical.$setSelection(selection);
|
|
50
50
|
}
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
if (lexical.$isNodeSelection(selection)) {
|
|
52
|
+
if (selected) {
|
|
53
|
+
selection.add(key);
|
|
54
|
+
} else {
|
|
55
|
+
selection.delete(key);
|
|
56
|
+
}
|
|
55
57
|
}
|
|
56
58
|
});
|
|
57
59
|
}, [editor, key]);
|
|
@@ -4,5 +4,6 @@
|
|
|
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
|
-
'use strict';var
|
|
8
|
-
exports.useLexicalNodeSelection=function(
|
|
7
|
+
'use strict';var b=require("@lexical/react/LexicalComposerContext"),f=require("lexical"),h=require("react");function k(c,a){return c.getEditorState().read(()=>{let g=f.$getNodeByKey(a);return null===g?!1:g.isSelected()})}
|
|
8
|
+
exports.useLexicalNodeSelection=function(c){let [a]=b.useLexicalComposerContext(),[g,l]=h.useState(()=>k(a,c));h.useEffect(()=>{let e=!0,d=a.registerUpdateListener(()=>{e&&l(k(a,c))});return()=>{e=!1;d()}},[a,c]);let m=h.useCallback(e=>{a.update(()=>{let d=f.$getSelection();f.$isNodeSelection(d)||(d=f.$createNodeSelection(),f.$setSelection(d));f.$isNodeSelection(d)&&(e?d.add(c):d.delete(c))})},[a,c]),n=h.useCallback(()=>{a.update(()=>{const e=f.$getSelection();f.$isNodeSelection(e)&&e.clear()})},
|
|
9
|
+
[a]);return[g,m,n]}
|