lexical 0.2.3 → 0.2.4
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/Lexical.d.ts +37 -12
- package/Lexical.dev.js +10 -2
- package/Lexical.js.flow +1 -0
- package/Lexical.prod.js +24 -24
- package/package.json +1 -1
package/Lexical.d.ts
CHANGED
|
@@ -435,7 +435,9 @@ export declare class GridSelection {
|
|
|
435
435
|
getNodes(): Array<LexicalNode>;
|
|
436
436
|
getTextContent(): string;
|
|
437
437
|
}
|
|
438
|
-
export function $isGridSelection(
|
|
438
|
+
export function $isGridSelection(
|
|
439
|
+
x: unknown | null | undefined,
|
|
440
|
+
): x is GridSelection;
|
|
439
441
|
export declare class NodeSelection {
|
|
440
442
|
_nodes: Set<NodeKey>;
|
|
441
443
|
dirty: boolean;
|
|
@@ -452,7 +454,9 @@ export declare class NodeSelection {
|
|
|
452
454
|
getNodes(): Array<LexicalNode>;
|
|
453
455
|
getTextContent(): string;
|
|
454
456
|
}
|
|
455
|
-
export function $isNodeSelection(
|
|
457
|
+
export function $isNodeSelection(
|
|
458
|
+
x: unknown | null | undefined,
|
|
459
|
+
): x is NodeSelection;
|
|
456
460
|
export declare class RangeSelection {
|
|
457
461
|
anchor: PointType;
|
|
458
462
|
focus: PointType;
|
|
@@ -534,7 +538,9 @@ declare class _Point {
|
|
|
534
538
|
export function $createRangeSelection(): RangeSelection;
|
|
535
539
|
export function $createNodeSelection(): NodeSelection;
|
|
536
540
|
export function $createGridSelection(): GridSelection;
|
|
537
|
-
export function $isRangeSelection(
|
|
541
|
+
export function $isRangeSelection(
|
|
542
|
+
x: unknown | null | undefined,
|
|
543
|
+
): x is RangeSelection;
|
|
538
544
|
export function $getSelection():
|
|
539
545
|
| null
|
|
540
546
|
| RangeSelection
|
|
@@ -612,7 +618,9 @@ export declare class TextNode extends LexicalNode {
|
|
|
612
618
|
mergeWithSibling(target: TextNode): TextNode;
|
|
613
619
|
}
|
|
614
620
|
export function $createTextNode(text?: string): TextNode;
|
|
615
|
-
export function $isTextNode(
|
|
621
|
+
export function $isTextNode(
|
|
622
|
+
node: LexicalNode | null | undefined,
|
|
623
|
+
): node is TextNode;
|
|
616
624
|
|
|
617
625
|
/**
|
|
618
626
|
* LexicalLineBreakNode
|
|
@@ -626,7 +634,9 @@ export declare class LineBreakNode extends LexicalNode {
|
|
|
626
634
|
updateDOM(): false;
|
|
627
635
|
}
|
|
628
636
|
export function $createLineBreakNode(): LineBreakNode;
|
|
629
|
-
export function $isLineBreakNode(
|
|
637
|
+
export function $isLineBreakNode(
|
|
638
|
+
node: LexicalNode | null | undefined,
|
|
639
|
+
): node is LineBreakNode;
|
|
630
640
|
|
|
631
641
|
/**
|
|
632
642
|
* LexicalRootNode
|
|
@@ -646,7 +656,9 @@ export declare class RootNode extends ElementNode {
|
|
|
646
656
|
append(...nodesToAppend: Array<LexicalNode>): ElementNode;
|
|
647
657
|
canBeEmpty(): false;
|
|
648
658
|
}
|
|
649
|
-
export function $isRootNode(
|
|
659
|
+
export function $isRootNode(
|
|
660
|
+
node: LexicalNode | null | undefined,
|
|
661
|
+
): node is RootNode;
|
|
650
662
|
|
|
651
663
|
/**
|
|
652
664
|
* LexicalElementNode
|
|
@@ -702,7 +714,9 @@ export declare class ElementNode extends LexicalNode {
|
|
|
702
714
|
nodesToInsert: Array<LexicalNode>,
|
|
703
715
|
): ElementNode;
|
|
704
716
|
}
|
|
705
|
-
export function $isElementNode(
|
|
717
|
+
export function $isElementNode(
|
|
718
|
+
node: LexicalNode | null | undefined,
|
|
719
|
+
): node is ElementNode;
|
|
706
720
|
|
|
707
721
|
/**
|
|
708
722
|
* LexicalDecoratorNode
|
|
@@ -711,8 +725,11 @@ export declare class DecoratorNode<X> extends LexicalNode {
|
|
|
711
725
|
constructor(key?: NodeKey);
|
|
712
726
|
decorate(editor: LexicalEditor): X;
|
|
713
727
|
isIsolated(): boolean;
|
|
728
|
+
isTopLevel(): boolean;
|
|
714
729
|
}
|
|
715
|
-
export function $isDecoratorNode(
|
|
730
|
+
export function $isDecoratorNode(
|
|
731
|
+
node: LexicalNode | null | undefined,
|
|
732
|
+
): node is DecoratorNode<unknown>;
|
|
716
733
|
|
|
717
734
|
/**
|
|
718
735
|
* LexicalHorizontalRuleNode
|
|
@@ -742,16 +759,24 @@ export declare class ParagraphNode extends ElementNode {
|
|
|
742
759
|
collapseAtStart(): boolean;
|
|
743
760
|
}
|
|
744
761
|
export function $createParagraphNode(): ParagraphNode;
|
|
745
|
-
export function $isParagraphNode(
|
|
762
|
+
export function $isParagraphNode(
|
|
763
|
+
node: LexicalNode | null | undefined,
|
|
764
|
+
): node is ParagraphNode;
|
|
746
765
|
export declare class GridNode extends ElementNode {}
|
|
747
|
-
export function $isGridNode(
|
|
766
|
+
export function $isGridNode(
|
|
767
|
+
node: LexicalNode | null | undefined,
|
|
768
|
+
): node is GridNode;
|
|
748
769
|
export declare class GridRowNode extends ElementNode {}
|
|
749
|
-
export function $isGridRowNode(
|
|
770
|
+
export function $isGridRowNode(
|
|
771
|
+
node: LexicalNode | null | undefined,
|
|
772
|
+
): node is GridRowNode;
|
|
750
773
|
export declare class GridCellNode extends ElementNode {
|
|
751
774
|
__colSpan: number;
|
|
752
775
|
constructor(colSpan: number, key?: NodeKey);
|
|
753
776
|
}
|
|
754
|
-
export function $isGridCellNode(
|
|
777
|
+
export function $isGridCellNode(
|
|
778
|
+
node: LexicalNode | null | undefined,
|
|
779
|
+
): node is GridCellNode;
|
|
755
780
|
|
|
756
781
|
/**
|
|
757
782
|
* LexicalUtils
|
package/Lexical.dev.js
CHANGED
|
@@ -2509,7 +2509,7 @@ function updateEditorState(rootElement, currentEditorState, pendingEditorState,
|
|
|
2509
2509
|
|
|
2510
2510
|
const domSelection = getDOMSelection();
|
|
2511
2511
|
|
|
2512
|
-
if (domSelection !== null && (needsUpdate || pendingSelection === null || pendingSelection.dirty)) {
|
|
2512
|
+
if (!editor._readOnly && domSelection !== null && (needsUpdate || pendingSelection === null || pendingSelection.dirty)) {
|
|
2513
2513
|
reconcileSelection(currentSelection, pendingSelection, editor, domSelection);
|
|
2514
2514
|
}
|
|
2515
2515
|
|
|
@@ -7092,6 +7092,14 @@ function getElementOuterTag(node, format) {
|
|
|
7092
7092
|
return 'code';
|
|
7093
7093
|
}
|
|
7094
7094
|
|
|
7095
|
+
if (format & IS_SUBSCRIPT) {
|
|
7096
|
+
return 'sub';
|
|
7097
|
+
}
|
|
7098
|
+
|
|
7099
|
+
if (format & IS_SUPERSCRIPT) {
|
|
7100
|
+
return 'sup';
|
|
7101
|
+
}
|
|
7102
|
+
|
|
7095
7103
|
return null;
|
|
7096
7104
|
}
|
|
7097
7105
|
|
|
@@ -8356,7 +8364,7 @@ class LexicalEditor {
|
|
|
8356
8364
|
*
|
|
8357
8365
|
*
|
|
8358
8366
|
*/
|
|
8359
|
-
const VERSION = '0.2.
|
|
8367
|
+
const VERSION = '0.2.4';
|
|
8360
8368
|
|
|
8361
8369
|
/**
|
|
8362
8370
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
package/Lexical.js.flow
CHANGED
|
@@ -762,6 +762,7 @@ declare export class DecoratorNode<X> extends LexicalNode {
|
|
|
762
762
|
constructor(key?: NodeKey): void;
|
|
763
763
|
decorate(editor: LexicalEditor): X;
|
|
764
764
|
isIsolated(): boolean;
|
|
765
|
+
isTopLevel(): boolean;
|
|
765
766
|
}
|
|
766
767
|
declare export function $isDecoratorNode(
|
|
767
768
|
node: ?LexicalNode,
|
package/Lexical.prod.js
CHANGED
|
@@ -53,11 +53,11 @@ function zc(a,b,c){var d=b.__type;const f=a._nodes.get(d);void 0===f&&q(23,d);a=
|
|
|
53
53
|
function Bc(a,b){const c=b._dirtyLeaves,d=b._dirtyElements;a=a._nodeMap;const f=B()._compositionKey,e=new Map;var g=c;let h=g.size;for(var l=d,k=l.size;0<h||0<k;){if(0<h){b._dirtyLeaves=new Set;for(const m of g)g=a.get(m),w(g)&&g.isSimpleText()&&!g.isUnmergeable()&&ab(g),void 0!==g&&void 0!==g&&g.__key!==f&&g.isAttached()&&zc(b,g,e),c.add(m);g=b._dirtyLeaves;h=g.size;if(0<h){Ba++;continue}}b._dirtyLeaves=new Set;b._dirtyElements=new Map;for(const m of l)l=m[0],k=m[1],"root"!==l&&k&&(g=a.get(l),void 0!==
|
|
54
54
|
g&&void 0!==g&&g.__key!==f&&g.isAttached()&&zc(b,g,e),d.set(l,k));g=b._dirtyLeaves;h=g.size;l=b._dirtyElements;k=l.size;Ba++}b._dirtyLeaves=c;b._dirtyElements=d}function db(a,b){var c=new Map;c=new Cc(c);const d={originalSelection:a._selection},f=U,e=X,g=V;U=c;X=!1;V=b;try{const h=new Map(a._nodeMap),l=h.get("root");bb(l,h,b,null,d)}finally{U=f,X=e,V=g}c._selection=Dc(d.remappedSelection||d.originalSelection);return c}
|
|
55
55
|
function Ec(a){var b=a._pendingEditorState,c=a._rootElement;if(null!==c&&null!==b){var d=a._editorState,f=d._selection,e=b._selection,g=0!==a._dirtyType;a._pendingEditorState=null;a._editorState=b;var h=U,l=X,k=V,m=a._updating;V=a;U=b;X=!1;a._updating=!0;try{var n=a._observer;let na=null;if(g&&null!==n){var u=a._dirtyType,p=a._dirtyElements,A=a._dirtyLeaves;n.disconnect();try{R=Yb=Q="";ac=2===u;dc=null;T=a;Zb=a._config;$b=a._nodes;cc=T._listeners.mutation;ec=p;fc=A;gc=d._nodeMap;hc=b._nodeMap;bc=
|
|
56
|
-
b._readOnly;ic=new Map(a._keyToDOMMap);const Ca=new Map;jc=Ca;wc("root",null);jc=ic=Zb=hc=gc=fc=ec=$b=T=void 0;na=Ca}finally{n.observe(c,{characterData:!0,childList:!0,subtree:!0})}}const Xa=window.getSelection();if(null!==Xa&&(g||null===e||e.dirty)){n=Xa;const Ca=n.anchorNode,
|
|
57
|
-
E.offset;f=H;x=W;"text"===y.type&&(f=ua(H));"text"===E.type&&(x=ua(W));if(null!==f&&null!==x)if(
|
|
58
|
-
|
|
59
|
-
new Set,a._dirtyElements=new Map,a._normalizedNodes=new Set,a._updateTags=new Set);g=a._decorators;k=a._pendingDecorators||g;m=b._nodeMap;for(var S in k)m.has(S)||(k===g&&(k=Ea(a)),delete k[S]);S=a._pendingDecorators;null!==S&&(a._decorators=S,a._pendingDecorators=null,
|
|
60
|
-
a._updating=!0;try{for(S=0;S<b.length;S++)b[S]()}finally{a._updating=d}}b=a._updates;if(0!==b.length){const [na,Xa]=b.shift();Oc(a,na,Xa)}}}function Fc(a,b,c,d){a._listeners.mutation.forEach((f,e)=>{f=d.get(f);void 0!==f&&e(f)})}function
|
|
56
|
+
b._readOnly;ic=new Map(a._keyToDOMMap);const Ca=new Map;jc=Ca;wc("root",null);jc=ic=Zb=hc=gc=fc=ec=$b=T=void 0;na=Ca}finally{n.observe(c,{characterData:!0,childList:!0,subtree:!0})}}const Xa=window.getSelection();if(!a._readOnly&&null!==Xa&&(g||null===e||e.dirty)){n=Xa;const Ca=n.anchorNode,Jc=n.focusNode,Fd=n.anchorOffset,Gd=n.focusOffset,Ya=document.activeElement,da=a._rootElement;if(!a._updateTags.has("collaboration")||Ya===da)if(J(e)){var y=e.anchor,E=e.focus,x=E.key,H=xc(a,y.key),W=xc(a,x),Kc=
|
|
57
|
+
y.offset,Lc=E.offset;f=H;x=W;"text"===y.type&&(f=ua(H));"text"===E.type&&(x=ua(W));if(null!==f&&null!==x)if(Fd!==Kc||Gd!==Lc||Ca!==f||Jc!==x||"Range"===n.type&&e.isCollapsed())try{n.setBaseAndExtent(f,Kc,x,Lc);if(e.isCollapsed()&&da===Ya){const ea=3===f.nodeType?f.parentNode:f;if(null!==ea){const Za=ea.getBoundingClientRect();if(Za.bottom>window.innerHeight)ea.scrollIntoView(!1);else if(0>Za.top)ea.scrollIntoView();else if(da){const Mc=da.getBoundingClientRect();Za.bottom>Mc.bottom?ea.scrollIntoView(!1):
|
|
58
|
+
Za.top<Mc.top&&ea.scrollIntoView()}a._updateTags.add("scroll-into-view")}}Pb=!0}catch(ea){}else null===da||null!==Ya&&da.contains(Ya)||da.focus({preventScroll:!0})}else null!==f&&ra(a,Ca,Jc)&&n.removeAllRanges()}var Nc=na;null!==Nc&&Fc(a,d,b,Nc)}catch(na){a._onError(na);yc||(Gc(a,null,c,b),Hc(a),a._dirtyType=2,yc=!0,Ec(a),yc=!1);return}finally{a._updating=m,U=h,X=l,V=k}b._readOnly=!0;c=a._dirtyLeaves;e=a._dirtyElements;h=a._normalizedNodes;l=a._updateTags;g&&(a._dirtyType=0,a._cloneNotNeeded.clear(),
|
|
59
|
+
a._dirtyLeaves=new Set,a._dirtyElements=new Map,a._normalizedNodes=new Set,a._updateTags=new Set);g=a._decorators;k=a._pendingDecorators||g;m=b._nodeMap;for(var S in k)m.has(S)||(k===g&&(k=Ea(a)),delete k[S]);S=a._pendingDecorators;null!==S&&(a._decorators=S,a._pendingDecorators=null,Ic("decorator",a,!0,S));S=Fa(d);g=Fa(b);S!==g&&Ic("textcontent",a,!0,g);Ic("update",a,!0,{dirtyElements:e,dirtyLeaves:c,editorState:b,normalizedNodes:h,prevEditorState:d,tags:l});b=a._deferred;a._deferred=[];if(0!==b.length){d=
|
|
60
|
+
a._updating;a._updating=!0;try{for(S=0;S<b.length;S++)b[S]()}finally{a._updating=d}}b=a._updates;if(0!==b.length){const [na,Xa]=b.shift();Oc(a,na,Xa)}}}function Fc(a,b,c,d){a._listeners.mutation.forEach((f,e)=>{f=d.get(f);void 0!==f&&e(f)})}function Ic(a,b,c,...d){const f=b._updating;b._updating=c;try{const e=Array.from(b._listeners[a]);for(a=0;a<e.length;a++)e[a](...d)}finally{b._updating=f}}
|
|
61
61
|
function P(a,b,c){if(!1===a._updating||V!==a){let e=!1;a.update(()=>{e=P(a,b,c)});return e}const d=Ka(a);for(let e=4;0<=e;e--)for(let g=0;g<d.length;g++){var f=d[g]._commands.get(b);if(void 0!==f&&(f=f[e],void 0!==f))for(const h of f)if(!0===h(c,a))return!0}return!1}function Pc(a){const b=a._updates;let c=!1;for(;0!==b.length;){const [d,f]=b.shift();let e,g;void 0!==f&&(e=f.onUpdate,g=f.tag,f.skipTransforms&&(c=!0),e&&a._deferred.push(e),g&&a._updateTags.add(g));d()}return c}
|
|
62
62
|
function Oc(a,b,c){const d=a._updateTags;var f=!1;if(void 0!==c){var e=c.onUpdate;f=c.tag;null!=f&&d.add(f);f=c.skipTransforms}e&&a._deferred.push(e);c=a._editorState;e=a._pendingEditorState;let g=!1;null===e&&(e=a._pendingEditorState=new Cc(new Map(c._nodeMap)),g=!0);const h=U,l=X,k=V,m=a._updating;U=e;X=!1;a._updating=!0;V=a;try{g&&(e._selection=Qc(a));const n=a._compositionKey;b();f=Pc(a);Rc(e,a);0!==a._dirtyType&&(f?Ac(e,a):Bc(e,a),Pc(a),Va(c,e,a._dirtyLeaves,a._dirtyElements));n!==a._compositionKey&&
|
|
63
63
|
(e._flushSync=!0);const u=e._selection;if(J(u)){const p=e._nodeMap,A=u.focus.key;void 0!==p.get(u.anchor.key)&&void 0!==p.get(A)||q(30)}else Sc(u)&&0===u._nodes.size&&(e._selection=null)}catch(n){a._onError(n);a._pendingEditorState=c;a._dirtyType=2;a._cloneNotNeeded.clear();a._dirtyLeaves=new Set;a._dirtyElements.clear();Ec(a);return}finally{U=h,X=l,V=k,a._updating=m,Ba=0}0!==a._dirtyType||Tc(e,a)?e._flushSync?(e._flushSync=!1,Ec(a)):g&&qa(()=>{Ec(a)}):(e._flushSync=!1,g&&(d.clear(),a._deferred=[],
|
|
@@ -132,37 +132,37 @@ class zd extends yd{static getType(){return"root"}static clone(){return new zd}c
|
|
|
132
132
|
__format:this.__format,__indent:this.__indent,__key:"root",__parent:null,__type:"root"}}}function M(a){return a instanceof zd}function Tc(a,b){b=b.getEditorState()._selection;a=a._selection;if(null!==a){if(a.dirty||!a.is(b))return!0}else if(null!==b)return!0;return!1}function Ad(){return new Cc(new Map([["root",new zd]]))}
|
|
133
133
|
class Cc{constructor(a,b){this._nodeMap=a;this._selection=b||null;this._readOnly=this._flushSync=!1}isEmpty(){return 1===this._nodeMap.size&&null===this._selection}read(a){a:{const c=U,d=X,f=V;U=this;X=!0;V=null;try{var b=a();break a}finally{U=c,X=d,V=f}b=void 0}return b}clone(a){a=new Cc(this._nodeMap,void 0===a?this._selection:a);a._readOnly=!0;return a}toJSON(){const a=this._selection;return{_nodeMap:Array.from(this._nodeMap.entries()),_selection:J(a)?{anchor:{key:a.anchor.key,offset:a.anchor.offset,
|
|
134
134
|
type:a.anchor.type},focus:{key:a.focus.key,offset:a.focus.offset,type:a.focus.type},type:"range"}:Sc(a)?{nodes:Array.from(a._nodes),type:"node"}:hd(a)?{anchorCellKey:a.anchorCellKey,focusCellKey:a.focusCellKey,gridKey:a.gridKey,type:"grid"}:null}}}
|
|
135
|
-
class Bd extends wd{static getType(){return"linebreak"}static clone(a){return new Bd(a.__key)}constructor(a){super(a)}getTextContent(){return"\n"}createDOM(){return document.createElement("br")}updateDOM(){return!1}static importDOM(){return{br:()=>({conversion:Cd,priority:0})}}}function Cd(){return{node:md()}}function md(){return new Bd}function xa(a){return a instanceof Bd}function Dd(a,b){return b&1?"strong":b&2?"em":"span"}
|
|
136
|
-
function
|
|
137
|
-
function
|
|
138
|
-
class
|
|
139
|
-
(this.getLatest().__detail&2)}hasFormat(a){a=ca[a];return 0!==(this.getFormat()&a)}isSimpleText(){return"text"===this.__type&&0===this.__mode}getTextContent(a,b){return!a&&this.isInert()||!1===b&&this.isDirectionless()?"":this.getLatest().__text}getFormatFlags(a,b){const c=this.getLatest().__format;return va(c,a,b)}createDOM(a){var b=this.__format,c=b
|
|
140
|
-
c,this);a=a.theme.text;void 0!==a&&
|
|
141
|
-
l
|
|
135
|
+
class Bd extends wd{static getType(){return"linebreak"}static clone(a){return new Bd(a.__key)}constructor(a){super(a)}getTextContent(){return"\n"}createDOM(){return document.createElement("br")}updateDOM(){return!1}static importDOM(){return{br:()=>({conversion:Cd,priority:0})}}}function Cd(){return{node:md()}}function md(){return new Bd}function xa(a){return a instanceof Bd}function Dd(a,b){return b&16?"code":b&32?"sub":b&64?"sup":null}function Ed(a,b){return b&1?"strong":b&2?"em":"span"}
|
|
136
|
+
function Hd(a,b,c,d,f){a=d.classList;d=Pa(f,"base");void 0!==d&&a.add(...d);d=Pa(f,"underlineStrikethrough");let e=!1;const g=b&8&&b&4;var h=c&8&&c&4;void 0!==d&&(h?(e=!0,g||a.add(...d)):g&&a.remove(...d));for(const l in ca)h=ca[l],d=Pa(f,l),void 0!==d&&(c&h?!e||"underline"!==l&&"strikethrough"!==l?(0===(b&h)||g&&"underline"===l||"strikethrough"===l)&&a.add(...d):b&h&&a.remove(...d):b&h&&a.remove(...d))}
|
|
137
|
+
function Id(a,b,c){const d=b.firstChild;c=c.isComposing();a+=c?"\u200b":"";if(null==d)b.textContent=a;else if(b=d.nodeValue,b!==a)if(c){c=b.length;const f=a.length;let e=0,g=0;for(;e<c&&e<f&&b[e]===a[e];)e++;for(;g+e<c&&g+e<f&&b[c-g-1]===a[f-g-1];)g++;a=[e,c-e-g,a.slice(e,f-g)];const [h,l,k]=a;0!==l&&d.deleteData(h,l);d.insertData(h,k)}else d.nodeValue=a}
|
|
138
|
+
class Jd extends wd{static getType(){return"text"}static clone(a){return new Jd(a.__text,a.__key)}constructor(a,b){super(b);this.__text=a;this.__format=0;this.__style="";this.__detail=this.__mode=0}getFormat(){return this.getLatest().__format}getStyle(){return this.getLatest().__style}isToken(){return 1===this.getLatest().__mode}isSegmented(){return 2===this.getLatest().__mode}isInert(){return 3===this.getLatest().__mode}isDirectionless(){return 0!==(this.getLatest().__detail&1)}isUnmergeable(){return 0!==
|
|
139
|
+
(this.getLatest().__detail&2)}hasFormat(a){a=ca[a];return 0!==(this.getFormat()&a)}isSimpleText(){return"text"===this.__type&&0===this.__mode}getTextContent(a,b){return!a&&this.isInert()||!1===b&&this.isDirectionless()?"":this.getLatest().__text}getFormatFlags(a,b){const c=this.getLatest().__format;return va(c,a,b)}createDOM(a){var b=this.__format,c=Dd(this,b);const d=Ed(this,b),f=document.createElement(null===c?d:c);let e=f;null!==c&&(e=document.createElement(d),f.appendChild(e));c=e;Id(this.__text,
|
|
140
|
+
c,this);a=a.theme.text;void 0!==a&&Hd(d,0,b,c,a);b=this.__style;""!==b&&(f.style.cssText=b);return f}updateDOM(a,b,c){const d=this.__text;var f=a.__format,e=this.__format,g=Dd(this,f);const h=Dd(this,e);var l=Ed(this,f);const k=Ed(this,e);if((null===g?l:g)!==(null===h?k:h))return!0;if(g===h&&l!==k)return f=b.firstChild,null==f&&q(20),a=g=document.createElement(k),Id(d,a,this),c=c.theme.text,void 0!==c&&Hd(k,0,e,a,c),b.replaceChild(g,f),!1;l=b;null!==h&&null!==g&&(l=b.firstChild,null==l&&q(21));Id(d,
|
|
141
|
+
l,this);c=c.theme.text;void 0!==c&&f!==e&&Hd(k,f,e,l,c);e=this.__style;a.__style!==e&&(b.style.cssText=e);return!1}static importDOM(){return{"#text":()=>({conversion:Kd,priority:0}),b:()=>({conversion:Ld,priority:0}),em:()=>({conversion:Md,priority:0}),i:()=>({conversion:Md,priority:0}),span:()=>({conversion:Nd,priority:0}),strong:()=>({conversion:Md,priority:0}),u:()=>({conversion:Md,priority:0})}}selectionTransform(){}setFormat(a){F();const b=this.getWritable();b.__format=a;return b}setStyle(a){F();
|
|
142
142
|
const b=this.getWritable();b.__style=a;return b}toggleFormat(a){a=ca[a];return this.setFormat(this.getFormat()^a)}toggleDirectionless(){F();const a=this.getWritable();a.__detail^=1;return a}toggleUnmergeable(){F();const a=this.getWritable();a.__detail^=2;return a}setMode(a){F();a=ha[a];const b=this.getWritable();b.__mode=a;return b}setTextContent(a){F();const b=this.getWritable();b.__text=a;return b}select(a,b){F();const c=K();var d=this.getTextContent();const f=this.__key;"string"===typeof d?(d=
|
|
143
143
|
d.length,void 0===a&&(a=d),void 0===b&&(b=d)):b=a=0;if(J(c))d=B()._compositionKey,d!==c.anchor.key&&d!==c.focus.key||D(f),c.setTextNodeRange(this,a,this,b);else return pd(f,a,f,b,"text","text");return c}spliceText(a,b,c,d){F();const f=this.getWritable(),e=f.__text,g=c.length;let h=a;0>h&&(h=g+h,0>h&&(h=0));const l=K();d&&J(l)&&(a+=g,l.setTextNodeRange(f,a,f,a));b=e.slice(0,h)+c+e.slice(h+b);return f.setTextContent(b)}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...a){F();
|
|
144
144
|
var b=this.getLatest(),c=b.getTextContent(),d=b.__key,f=B()._compositionKey,e=new Set(a);a=[];var g=c.length,h="";for(var l=0;l<g;l++)""!==h&&e.has(l)&&(a.push(h),h=""),h+=c[l];""!==h&&a.push(h);e=a.length;if(0===e)return[];if(a[0]===c)return[b];var k=a[0];c=b.getParentOrThrow();l=c.__key;const m=b.getFormat(),n=b.getStyle(),u=b.__detail;g=!1;b.isSegmented()?(h=L(k),h.__parent=l,h.__format=m,h.__style=n,h.__detail=u,g=!0):(h=b.getWritable(),h.__text=k);b=K();h=[h];k=k.length;for(let y=1;y<e;y++){var p=
|
|
145
145
|
a[y],A=p.length;p=L(p).getWritable();p.__format=m;p.__style=n;p.__detail=u;const E=p.__key;A=k+A;if(J(b)){const x=b.anchor,H=b.focus;x.key===d&&"text"===x.type&&x.offset>k&&x.offset<=A&&(x.key=E,x.offset-=k,b.dirty=!0);H.key===d&&"text"===H.type&&H.offset>k&&H.offset<=A&&(H.key=E,H.offset-=k,b.dirty=!0)}f===d&&D(E);k=A;p.__parent=l;h.push(p)}za(this);f=c.getWritable().__children;d=f.indexOf(d);a=h.map(y=>y.__key);g?(f.splice(d,0,...a),this.remove()):f.splice(d,1,...a);J(b)&&qd(b,c,d,e-1);return h}mergeWithSibling(a){const b=
|
|
146
146
|
a===this.getPreviousSibling();b||a===this.getNextSibling()||q(22);const c=this.__key,d=a.__key,f=this.__text,e=f.length;B()._compositionKey===d&&D(c);const g=K();if(J(g)){const h=g.anchor,l=g.focus;null!==h&&h.key===d&&(td(h,b,c,a,e),g.dirty=!0);null!==l&&l.key===d&&(td(l,b,c,a,e),g.dirty=!0)}this.setTextContent(b?a.__text+f:f+a.__text);a.remove();return this.getLatest()}isTextEntity(){return!1}}
|
|
147
|
-
function
|
|
148
|
-
function L(a=""){return new
|
|
149
|
-
class
|
|
150
|
-
this.insertAfter(a);return a}collapseAtStart(){const a=this.getChildren();if(0===a.length||w(a[0])&&""===a[0].getTextContent().trim()){if(null!==this.getNextSibling())return this.selectNext(),this.remove(),!0;if(null!==this.getPreviousSibling())return this.selectPrevious(),this.remove(),!0}return!1}}function
|
|
147
|
+
function Nd(a){const b="700"===a.style.fontWeight;return{forChild:c=>{w(c)&&b&&c.toggleFormat("bold");return c},node:null}}function Ld(a){const b="normal"===a.style.fontWeight;return{forChild:c=>{w(c)&&!b&&c.toggleFormat("bold");return c},node:null}}function Kd(a){return{node:L(a.textContent)}}const Od={em:"italic",i:"italic",strong:"bold",u:"underline"};function Md(a){const b=Od[a.nodeName.toLowerCase()];return void 0===b?{node:null}:{forChild:c=>{w(c)&&c.toggleFormat(b);return c},node:null}}
|
|
148
|
+
function L(a=""){return new Jd(a)}function w(a){return a instanceof Jd}
|
|
149
|
+
class Pd extends yd{static getType(){return"paragraph"}static clone(a){return new Pd(a.__key)}createDOM(a){const b=document.createElement("p");a=Pa(a.theme,"paragraph");void 0!==a&&b.classList.add(...a);return b}updateDOM(){return!1}static importDOM(){return{p:()=>({conversion:Qd,priority:0})}}exportDOM(a){({element:a}=super.exportDOM(a));a&&0===this.getTextContentSize()&&a.append(document.createElement("br"));return{element:a}}insertNewAfter(){const a=dd(),b=this.getDirection();a.setDirection(b);
|
|
150
|
+
this.insertAfter(a);return a}collapseAtStart(){const a=this.getChildren();if(0===a.length||w(a[0])&&""===a[0].getTextContent().trim()){if(null!==this.getNextSibling())return this.selectNext(),this.remove(),!0;if(null!==this.getPreviousSibling())return this.selectPrevious(),this.remove(),!0}return!1}}function Qd(){return{node:dd()}}function dd(){return new Pd}
|
|
151
151
|
function Gc(a,b,c,d){const f=a._keyToDOMMap;f.clear();a._editorState=Ad();a._pendingEditorState=d;a._compositionKey=null;a._dirtyType=0;a._cloneNotNeeded.clear();a._dirtyLeaves=new Set;a._dirtyElements.clear();a._normalizedNodes=new Set;a._updateTags=new Set;a._updates=[];d=a._observer;null!==d&&(d.disconnect(),a._observer=null);null!==b&&(b.textContent="");null!==c&&(c.textContent="",f.set("root",c))}
|
|
152
|
-
function
|
|
153
|
-
function cb(a){var b=a||{},c=b.namespace||Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5);const d=b.theme||{},f=b.context||{},e=b.parentEditor||null,g=b.disableEvents||!1,h=Ad();a=b.editorState;const l=[zd,
|
|
152
|
+
function Rd(a){const b=new Map,c=new Set;a.forEach(d=>{d=d.klass.importDOM;if(!c.has(d)){c.add(d);var f=d();null!==f&&Object.keys(f).forEach(e=>{let g=b.get(e);void 0===g&&(g=[],b.set(e,g));g.push(f[e])})}});return b}
|
|
153
|
+
function cb(a){var b=a||{},c=b.namespace||Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5);const d=b.theme||{},f=b.context||{},e=b.parentEditor||null,g=b.disableEvents||!1,h=Ad();a=b.editorState;const l=[zd,Jd,Bd,Pd,...(b.nodes||[])],k=b.onError;b=b.readOnly||!1;const m=new Map;for(let n=0;n<l.length;n++){const u=l[n],p=u.getType();m.set(p,{klass:u,transforms:new Set})}c=new Sd(h,e,m,{context:f,disableEvents:g,namespace:c,theme:d},k,Rd(m),b);void 0!==a&&(c._pendingEditorState=a,c._dirtyType=
|
|
154
154
|
2);return c}
|
|
155
|
-
class
|
|
155
|
+
class Sd{constructor(a,b,c,d,f,e){this._parentEditor=b;this._rootElement=null;this._editorState=a;this._compositionKey=this._pendingEditorState=null;this._deferred=[];this._keyToDOMMap=new Map;this._updates=[];this._updating=!1;this._listeners={decorator:new Set,mutation:new Map,readonly:new Set,root:new Set,textcontent:new Set,update:new Set};this._commands=new Map;this._config=d;this._nodes=c;this._decorators={};this._pendingDecorators=null;this._dirtyType=0;this._cloneNotNeeded=new Set;this._dirtyLeaves=
|
|
156
156
|
new Set;this._dirtyElements=new Map;this._normalizedNodes=new Set;this._updateTags=new Set;this._observer=null;this._key=""+pa++;this._onError=f;this._htmlConversions=e;this._readOnly=!1}isComposing(){return null!=this._compositionKey}registerUpdateListener(a){const b=this._listeners.update;b.add(a);return()=>{b.delete(a)}}registerReadOnlyListener(a){const b=this._listeners.readonly;b.add(a);return()=>{b.delete(a)}}registerDecoratorListener(a){const b=this._listeners.decorator;b.add(a);return()=>
|
|
157
157
|
{b.delete(a)}}registerTextContentListener(a){const b=this._listeners.textcontent;b.add(a);return()=>{b.delete(a)}}registerRootListener(a){const b=this._listeners.root;a(this._rootElement,null);b.add(a);return()=>{a(null,this._rootElement);b.delete(a)}}registerCommand(a,b,c){void 0===c&&q(56);const d=this._commands;d.has(a)||d.set(a,[new Set,new Set,new Set,new Set,new Set]);const f=d.get(a);void 0===f&&q(81,a);const e=f[c];e.add(b);return()=>{e.delete(b);f.every(g=>0===g.size)&&d.delete(a)}}registerMutationListener(a,
|
|
158
158
|
b){void 0===this._nodes.get(a.getType())&&q(57,a.name);const c=this._listeners.mutation;c.set(b,a);return()=>{c.delete(b)}}registerNodeTransform(a,b){const c=a.getType(),d=this._nodes.get(c);void 0===d&&q(57,a.name);const f=d.transforms;f.add(b);Ha(this,c);return()=>{f.delete(b)}}hasNodes(a){for(let b=0;b<a.length;b++){const c=a[b].getType();if(!this._nodes.has(c))return!1}return!0}dispatchCommand(a,b){return P(this,a,b)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(a){const b=
|
|
159
159
|
this._rootElement;if(a!==b){var c=this._pendingEditorState||this._editorState;this._rootElement=a;Gc(this,b,a,c);if(null!==b&&!this._config.disableEvents){0!==Ob&&(Ob--,0===Ob&&b.ownerDocument.removeEventListener("selectionchange",Wb));c=b.__lexicalEditor;if(null!=c){if(null!==c._parentEditor){var d=Ka(c);d=d[d.length-1]._key;Vb.get(d)===c&&Vb.delete(d)}else Vb.delete(c._key);b.__lexicalEditor=null}c=Ub(b);for(d=0;d<c.length;d++)c[d]();b.__lexicalEventHandles=[]}null!==a&&(c=a.style,c.userSelect=
|
|
160
|
-
"text",c.whiteSpace="pre-wrap",c.wordBreak="break-word",a.setAttribute("data-lexical-editor","true"),this._dirtyType=2,Hc(this),this._updateTags.add("history-merge"),Ec(this),this._config.disableEvents||Xb(a,this));
|
|
160
|
+
"text",c.whiteSpace="pre-wrap",c.wordBreak="break-word",a.setAttribute("data-lexical-editor","true"),this._dirtyType=2,Hc(this),this._updateTags.add("history-merge"),Ec(this),this._config.disableEvents||Xb(a,this));Ic("root",this,!1,a,b)}}getElementByKey(a){return this._keyToDOMMap.get(a)||null}getEditorState(){return this._editorState}setEditorState(a,b){a.isEmpty()&&q(19);Tb(this);const c=this._pendingEditorState,d=this._updateTags;b=void 0!==b?b.tag:null;null===c||c.isEmpty()||(null!=b&&d.add(b),
|
|
161
161
|
Ec(this));this._pendingEditorState=a;this._dirtyType=2;this._compositionKey=null;null!=b&&d.add(b);Ec(this)}parseEditorState(a){a=JSON.parse(a);return db(a,this)}update(a,b){I(this,a,b)}focus(a){const b=this._rootElement;null!==b&&(b.setAttribute("autocapitalize","off"),I(this,()=>{const c=K(),d=Ga();null!==c?c.dirty=!0:0!==d.getChildrenSize()&&d.selectEnd()},{onUpdate:()=>{b.removeAttribute("autocapitalize");a&&a()}}))}blur(){var a=this._rootElement;null!==a&&a.blur();a=window.getSelection();null!==
|
|
162
|
-
a&&a.removeAllRanges()}isReadOnly(){return this._readOnly}setReadOnly(a){this._readOnly=a;
|
|
162
|
+
a&&a.removeAllRanges()}isReadOnly(){return this._readOnly}setReadOnly(a){this._readOnly=a;Ic("readonly",this,!0,a)}toJSON(){return{editorState:this._editorState}}}class Td extends yd{constructor(a,b){super(b)}}function kd(a){return a instanceof Td}class Ud extends yd{}function id(a){return a instanceof Ud}class Vd extends yd{}function jd(a){return a instanceof Vd}exports.$createGridSelection=function(){return new gd("root","root","root")};exports.$createLineBreakNode=md;
|
|
163
163
|
exports.$createNodeFromParse=function(a,b){F();const c=B();return bb(a,b,c,null)};exports.$createNodeSelection=function(){return new ed(new Set)};exports.$createParagraphNode=dd;exports.$createRangeSelection=function(){const a=Y("root",0,"element"),b=Y("root",0,"element");return new fd(a,b,0)};exports.$createTextNode=L;exports.$getDecoratorNode=Sa;exports.$getNearestNodeFromDOMNode=sa;exports.$getNodeByKey=G;exports.$getPreviousSelection=Na;exports.$getRoot=Ga;exports.$getSelection=K;
|
|
164
|
-
exports.$isDecoratorNode=t;exports.$isElementNode=C;exports.$isGridCellNode=kd;exports.$isGridNode=id;exports.$isGridRowNode=jd;exports.$isGridSelection=hd;exports.$isLeafNode=wa;exports.$isLineBreakNode=xa;exports.$isNodeSelection=Sc;exports.$isParagraphNode=function(a){return a instanceof
|
|
164
|
+
exports.$isDecoratorNode=t;exports.$isElementNode=C;exports.$isGridCellNode=kd;exports.$isGridNode=id;exports.$isGridRowNode=jd;exports.$isGridSelection=hd;exports.$isLeafNode=wa;exports.$isLineBreakNode=xa;exports.$isNodeSelection=Sc;exports.$isParagraphNode=function(a){return a instanceof Pd};exports.$isRangeSelection=J;exports.$isRootNode=M;exports.$isTextNode=w;
|
|
165
165
|
exports.$nodesOfType=function(a){var b=z();const c=b._readOnly,d=a.getType();b=b._nodeMap;const f=[];for(const [,e]of b)e instanceof a&&e.__type===d&&(c||e.isAttached())&&f.push(e);return f};exports.$setCompositionKey=D;exports.$setSelection=Ia;exports.BLUR_COMMAND=Db;exports.CAN_REDO_COMMAND={};exports.CAN_UNDO_COMMAND={};exports.CLEAR_EDITOR_COMMAND={};exports.CLEAR_HISTORY_COMMAND={};exports.CLICK_COMMAND=fb;exports.COMMAND_PRIORITY_CRITICAL=4;exports.COMMAND_PRIORITY_EDITOR=0;
|
|
166
|
-
exports.COMMAND_PRIORITY_HIGH=3;exports.COMMAND_PRIORITY_LOW=1;exports.COMMAND_PRIORITY_NORMAL=2;exports.COPY_COMMAND=Ab;exports.CUT_COMMAND=Bb;exports.DELETE_CHARACTER_COMMAND=gb;exports.DELETE_LINE_COMMAND=mb;exports.DELETE_WORD_COMMAND=lb;exports.DRAGSTART_COMMAND=zb;exports.DROP_COMMAND=yb;exports.DecoratorNode=xd;exports.ElementNode=yd;exports.FOCUS_COMMAND=Cb;exports.FORMAT_ELEMENT_COMMAND={};exports.FORMAT_TEXT_COMMAND=O;exports.GridCellNode=
|
|
166
|
+
exports.COMMAND_PRIORITY_HIGH=3;exports.COMMAND_PRIORITY_LOW=1;exports.COMMAND_PRIORITY_NORMAL=2;exports.COPY_COMMAND=Ab;exports.CUT_COMMAND=Bb;exports.DELETE_CHARACTER_COMMAND=gb;exports.DELETE_LINE_COMMAND=mb;exports.DELETE_WORD_COMMAND=lb;exports.DRAGSTART_COMMAND=zb;exports.DROP_COMMAND=yb;exports.DecoratorNode=xd;exports.ElementNode=yd;exports.FOCUS_COMMAND=Cb;exports.FORMAT_ELEMENT_COMMAND={};exports.FORMAT_TEXT_COMMAND=O;exports.GridCellNode=Td;exports.GridNode=Ud;exports.GridRowNode=Vd;
|
|
167
167
|
exports.INDENT_CONTENT_COMMAND={};exports.INSERT_LINE_BREAK_COMMAND=hb;exports.INSERT_PARAGRAPH_COMMAND=ib;exports.INSERT_TEXT_COMMAND=N;exports.KEY_ARROW_DOWN_COMMAND=sb;exports.KEY_ARROW_LEFT_COMMAND=qb;exports.KEY_ARROW_RIGHT_COMMAND=pb;exports.KEY_ARROW_UP_COMMAND=rb;exports.KEY_BACKSPACE_COMMAND=ub;exports.KEY_DELETE_COMMAND=wb;exports.KEY_ENTER_COMMAND=tb;exports.KEY_ESCAPE_COMMAND=vb;exports.KEY_MODIFIER_COMMAND=Eb;exports.KEY_TAB_COMMAND=xb;exports.OUTDENT_CONTENT_COMMAND={};
|
|
168
|
-
exports.PASTE_COMMAND=jb;exports.ParagraphNode=
|
|
168
|
+
exports.PASTE_COMMAND=jb;exports.ParagraphNode=Pd;exports.REDO_COMMAND=ob;exports.REMOVE_TEXT_COMMAND=kb;exports.SELECTION_CHANGE_COMMAND=eb;exports.TextNode=Jd;exports.UNDO_COMMAND=nb;exports.VERSION="0.2.4";exports.createCommand=function(){return{}};exports.createEditor=cb;
|