lexical 0.0.2 → 0.1.0
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/CodeNode.js +3 -0
- package/HashtagNode.js +3 -0
- package/HeadingNode.js +3 -0
- package/LICENSE +14 -13
- package/Lexical.js +119 -0
- package/LinkNode.js +3 -0
- package/ListItemNode.js +8 -0
- package/ListNode.js +5 -0
- package/ParagraphNode.js +3 -0
- package/QuoteNode.js +3 -0
- package/README.md +3 -37
- package/TableCellNode.js +3 -0
- package/TableNode.js +7 -0
- package/TableRowNode.js +2 -0
- package/package.json +18 -20
- package/.npmignore +0 -3
- package/.travis.yml +0 -4
- package/HISTORY +0 -0
- package/Makefile +0 -28
- package/bin/lexical +0 -18
- package/index.js +0 -1
- package/lib/lexical.js +0 -68
- package/test/lexical.test.js +0 -19
- package/test/mocha.opt +0 -1
package/CodeNode.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var d=require("@lexical/core"),e=require("@lexical/core/ParagraphNode");function f(a,...b){b.forEach(c=>{null!=c&&"string"===typeof c&&a.classList.add(...c.split(" "))})}
|
|
2
|
+
class g extends d.ElementNode{static getType(){return"code"}static clone(a){return new g(a.__language,a.__key)}constructor(a,b){super(b);this.__language=a}createDOM(a){const b=document.createElement("code");f(b,a.theme.code);b.setAttribute("spellcheck","false");return b}updateDOM(){return!1}insertNewAfter(a){const b=this.getChildren(),c=b.length;return 2<=c&&"\n"===b[c-1].getTextContent()&&"\n"===b[c-2].getTextContent()&&a.isCollapsed()&&a.anchor.key===this.__key&&a.anchor.offset===c?(b[c-1].remove(),
|
|
3
|
+
b[c-2].remove(),a=e.$createParagraphNode(),this.insertAfter(a),a):null}canInsertTab(){return!0}collapseAtStart(){const a=e.$createParagraphNode();this.getChildren().forEach(b=>a.append(b));this.replace(a);return!0}setLanguage(a){this.getWritable().__language=a}getLanguage(){return this.getLatest().__language}}exports.$createCodeNode=function(a){return new g(a)};exports.$isCodeNode=function(a){return a instanceof g};exports.CodeNode=g;
|
package/HashtagNode.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var c=require("@lexical/core");function d(b,...a){a.forEach(f=>{null!=f&&"string"===typeof f&&b.classList.add(...f.split(" "))})}
|
|
2
|
+
class e extends c.TextNode{static getType(){return"hashtag"}static clone(b){return new e(b.__text,b.__key)}constructor(b,a){super(b,a)}createDOM(b){const a=super.createDOM(b);d(a,b.theme.hashtag);return a}setTextContent(b){let a=super.setTextContent(b);return null===a.getParent()||a.isComposing()?this:(b=b.indexOf("#"),-1===b||"#"===a.getTextContent()?a=g(a):0<b&&([a]=a.splitText(b),a=g(a)),c.$isTextNode(a)&&a.isAttached()&&(b=a.getTextContent().slice(1).search(/[\s.,\\\/#!$%\^&\*;:{}=\-`~()@]/),
|
|
3
|
+
0===b?a=g(a):0<b&&([a]=a.splitText(b+1),a=g(a))),a)}canInsertTextBefore(){return!1}canInsertTextAfter(){return!0}}function g(b){var a=b.getTextContent();a=h(b)?c.$createTextNode(a):k(a);b.replace(a);return a}function k(b=""){return new e(b)}function h(b){return b instanceof e}exports.$createHashtagNode=k;exports.$isHashtagNode=h;exports.$toggleHashtag=g;exports.HashtagNode=e;
|
package/HeadingNode.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var d=require("@lexical/core"),e=require("@lexical/core/ParagraphNode");function f(a,...b){b.forEach(c=>{null!=c&&"string"===typeof c&&a.classList.add(...c.split(" "))})}
|
|
2
|
+
class g extends d.ElementNode{static getType(){return"heading"}static clone(a){return new g(a.__tag,a.__key)}constructor(a,b){super(b);this.__tag=a}getTag(){return this.__tag}createDOM(a){const b=this.__tag,c=document.createElement(b);a=a.theme.heading;void 0!==a&&f(c,a[b]);return c}updateDOM(){return!1}insertNewAfter(){const a=e.$createParagraphNode(),b=this.getDirection();a.setDirection(b);this.insertAfter(a);return a}collapseAtStart(){const a=e.$createParagraphNode();this.getChildren().forEach(b=>
|
|
3
|
+
a.append(b));this.replace(a);return!0}}exports.$createHeadingNode=function(a){return new g(a)};exports.$isHeadingNode=function(a){return a instanceof g};exports.HeadingNode=g;
|
package/LICENSE
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2020 Dominic Gannaway
|
|
4
4
|
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
the Software without restriction, including without limitation the rights
|
|
8
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
the Software, and to permit persons to whom the Software is
|
|
10
|
-
subject to the following conditions:
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
11
|
|
|
12
12
|
The above copyright notice and this permission notice shall be included in all
|
|
13
13
|
copies or substantial portions of the Software.
|
|
14
14
|
|
|
15
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/Lexical.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
'use strict';const aa=/^[^A-Za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02b8\u0300-\u0590\u0800-\u1fff\u200e\u2c00-\ufb1c\ufe00-\ufe6f\ufefd-\uffff]*[\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc]/,ba=/^[^\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc]*[A-Za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02b8\u0300-\u0590\u0800-\u1fff\u200e\u2c00-\ufb1c\ufe00-\ufe6f\ufefd-\uffff]/,p={bold:1,underline:8,strikethrough:4,italic:2,code:16,subscript:32,superscript:64},ca={left:1,right:3,center:2,justify:4},da={normal:0,token:1,segmented:2,
|
|
2
|
+
inert:3};function q(a){throw Error(`Minified Lexical error #${a}; see codes.json for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}let ea=!1,fa=0;function ha(a){fa=a.timeStamp}function ia(a){return a.getEditorState().read(()=>{const b=t();return null!==b?b.clone():null})}
|
|
3
|
+
function la(a,b,c){ea=!0;const d=100<performance.now()-fa;try{ma(a,()=>{na("onMutation");var e=!1;for(var f=0;f<b.length;f++){var g=b[f],h=g.type,l=g.target,k=oa(l);if(!v(k))if("characterData"===h){if(d&&3===l.nodeType&&y(k)&&k.isAttached()){h=l;l=k;k=a;g=window.getSelection();var m=null,n=null;null!==g&&g.anchorNode===h&&(m=g.anchorOffset,n=g.focusOffset);A("textmutation",k,!1,{node:l,anchorOffset:m,focusOffset:n,text:h.nodeValue})}}else if("childList"===h){e=!0;h=g.addedNodes;k=g.removedNodes;g=
|
|
4
|
+
g.nextSibling;for(m=0;m<k.length;m++){n=k[m];var r=pa(n);let u=g;null!==r&&r.isAttached()&&(r=r.getNextSibling(),null!==r&&(r=r.getKey(),r=a.getElementByKey(r),null!==r&&null!==r.parentNode&&(u=r)));if(null!=u)for(;null!=u;){r=u.parentNode;if(r===l){l.insertBefore(n,u);break}u=r}else l.appendChild(n)}for(l=0;l<h.length;l++)k=h[l],g=pa(k),m=k.parentNode,null!=m&&null===g&&m.removeChild(k)}}f=c.takeRecords();if(0<f.length){for(h=0;h<f.length;h++)for(k=f[h],l=k.addedNodes,k=k.target,g=0;g<l.length;g++)m=
|
|
5
|
+
l[g],n=m.parentNode,null!=n&&"BR"===m.nodeName&&k.__lexicalLineBreak!==m&&void 0===m.__lexicalInternalRef&&n.removeChild(m);c.takeRecords()}e&&(e=t()||ia(a),null!==e&&(e.dirty=!0,qa(e)))},!0)}finally{ea=!1}}function ra(a){const b=a._observer;if(null!==b){const c=b.takeRecords();la(a,c,b)}}function sa(a){0===fa&&window.addEventListener("textInput",ha,!0);a._observer=new MutationObserver((b,c)=>{la(a,b,c)})}let ta=0;const ua=window.Promise,va="function"===typeof queueMicrotask?queueMicrotask:a=>ua.resolve().then(a);
|
|
6
|
+
function wa(a,b,c){a=a.getRootElement();try{return null!==a&&a.contains(b)&&a.contains(c)&&null!=b&&!v(oa(b))}catch(d){return!1}}function Aa(a){for(;null!=a;){if(3===a.nodeType)return a;a=a.firstChild}return null}function Ba(a,b,c){b=p[b];return a&b&&(null===c||0===(c&b))?a^b:null===c||c&b?a|b:a}function Ca(a){return y(a)||Da(a)||v(a)}
|
|
7
|
+
function Ea(a){99<Fa&&q(26);var b=a.getLatest(),c=b.__parent,d=B();const e=C(),f=d._nodeMap;d=e._dirtyElements;if(null!==c)a:for(;null!==c;){if(d.has(c))break a;const g=f.get(c);if(void 0===g)break;d.set(c,!1);c=g.__parent}b=b.__key;e._dirtyType=1;D(a)?d.set(b,!0):e._dirtyLeaves.add(b)}function E(a){const b=a.getPreviousSibling();a=a.getNextSibling();null!==b&&Ea(b);null!==a&&Ea(a)}
|
|
8
|
+
function F(a){G();var b=C();const c=b._compositionKey;b._compositionKey=a;null!==c&&(b=I(c),null!==b&&b.getWritable());null!==a&&(a=I(a),null!==a&&a.getWritable())}function J(){return C()._compositionKey}function I(a){a=B()._nodeMap.get(a);return void 0===a?null:a}function pa(a){const b=C();a=a["__lexicalKey_"+b._key];return void 0!==a?I(a):null}function oa(a){for(;null!=a;){const b=pa(a);if(null!==b)return b;a=a.parentNode}return null}
|
|
9
|
+
function Ga(a){const b=Object.assign({},a._decorators);return a._pendingDecorators=b}function na(a){C()._log.push(a)}function Ha(a){return a.read(()=>Ia().getTextContent())}function Ja(a,b){ma(a,()=>{var c=B();if(!c.isEmpty())if("root"===b)Ia().markDirty();else{c=Array.from(c._nodeMap);for(let d=0;d<c.length;d++)c[d][1].markDirty()}},!0,null===a._pendingEditorState?{tag:"without-history"}:void 0)}function Ia(){return B()._nodeMap.get("root")}function qa(a){B()._selection=a}
|
|
10
|
+
function Ka(a){var b=C(),c;a:{for(c=a;null!=c;){const d=c["__lexicalKey_"+b._key];if(void 0!==d){c=d;break a}c=c.parentNode}c=null}return null===c?(b=b.getRootElement(),a===b?I("root"):null):I(c)}function La(a){const b=[];for(;null!==a;)b.push(a),a=a._parentEditor;return b}function K(a){return a.isToken()||a.isInert()}
|
|
11
|
+
class Ma{constructor(a,b,c){this.key=a;this.offset=b;this.type=c}is(a){return this.key===a.key&&this.offset===a.offset&&this.type===a.type}isBefore(a){let b=this.getNode(),c=a.getNode();const d=this.offset;a=a.offset;D(b)&&(b=b.getDescendantByIndex(d));D(c)&&(c=c.getDescendantByIndex(a));return b===c?d<a:b.isBefore(c)}getCharacterOffset(){return"text"===this.type?this.offset:0}getNode(){const a=I(this.key);null===a&&q(5);return a}set(a,b,c){const d=t(),e=this.key;this.key=a;this.offset=b;this.type=
|
|
12
|
+
c;N||(J()===e&&F(a),null===d||d.anchor!==this&&d.focus!==this||(d.dirty=!0))}}function O(a,b,c){return new Ma(a,b,c)}function Na(a,b){const c=b.getKey();let d=a.offset,e="element";y(b)&&(e="text",b=b.getTextContentSize(),d>b&&(d=b));a.set(c,d,e)}function Oa(a,b){if(D(b)){const c=b.getLastDescendant();D(c)||y(c)?Na(a,c):Na(a,b)}else y(b)&&Na(a,b)}
|
|
13
|
+
function Pa(a,b,c){b=a.getNode();const d=b.getChildAtIndex(a.offset),e=P();e.setFormat(c);null===d?b.append(e):d.insertBefore(e);a.set(e.getKey(),0,"text")}function Q(a,b,c,d){a.key=b;a.offset=c;a.type=d}
|
|
14
|
+
class Qa{constructor(a,b,c){this.anchor=a;this.focus=b;this.dirty=!1;this.format=c}is(a){return null===a?!1:this.anchor.is(a.anchor)&&this.focus.is(a.focus)}isBackward(){return this.focus.isBefore(this.anchor)}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const a=this.anchor,b=this.focus;let c=a.getNode(),d=b.getNode();D(c)&&(c=c.getDescendantByIndex(a.offset));D(d)&&(d=d.getDescendantByIndex(b.offset));return c.is(d)?D(c)?[]:[c]:c.getNodesBetween(d)}setTextNodeRange(a,b,c,d){Q(this.anchor,
|
|
15
|
+
a.__key,b,"text");Q(this.focus,c.__key,d,"text");this.dirty=!0}getTextContent(){const a=this.getNodes();if(0===a.length)return"";const b=a[0],c=a[a.length-1];var d=this.anchor,e=this.focus;const f=d.isBefore(e);d=d.getCharacterOffset();e=e.getCharacterOffset();let g="",h=!0;for(let l=0;l<a.length;l++){const k=a[l];if(D(k))h||(g+="\n"),h=k.isEmpty()?!1:!0;else if(h=!1,y(k)){let m=k.getTextContent();k===b?m=k===c?d<e?m.slice(d,e):m.slice(e,d):f?m.slice(d):m.slice(e):k===c&&(m=f?m.slice(0,e):m.slice(0,
|
|
16
|
+
d));g+=m}else!v(k)&&!Da(k)||k===c&&this.isCollapsed()||(g+=k.getTextContent())}return g}applyDOMRange(a){const b=C();a=Ra(a.startContainer,a.startOffset,a.endContainer,a.endOffset,b);if(null!==a){var [c,d]=a;Q(this.anchor,c.key,c.offset,c.type);Q(this.focus,d.key,d.offset,d.type)}}clone(){const a=this.anchor,b=this.focus;return new Qa(O(a.key,a.offset,a.type),O(b.key,b.offset,b.type),this.format)}toggleFormatType(a){this.format=Ba(this.format,a,null);this.dirty=!0}hasFormat(a){return 0!==(this.format&
|
|
17
|
+
p[a])}insertText(a){var b=this.anchor,c=this.focus,d=this.isCollapsed()||b.isBefore(c),e=this.format;d&&"element"===b.type?Pa(b,c,e):d||"element"!==c.type||Pa(c,b,e);var f=this.getNodes(),g=f.length,h=d?c:b;b=(d?b:c).offset;var l=h.offset;c=f[0];y(c)||q(6);d=c.getTextContent().length;var k=c.getParentOrThrow();if(!this.isCollapsed()||b!==d||!c.isSegmented()&&!c.isToken()&&c.canInsertTextAfter()&&k.canInsertTextAfter())if(!this.isCollapsed()||0!==b||!c.isSegmented()&&!c.isToken()&&c.canInsertTextBefore()&&
|
|
18
|
+
k.canInsertTextBefore())c.isSegmented()&&b!==d&&(k=P(c.getTextContent()),c.replace(k),c=k);else{m=c.getPreviousSibling();if(!y(m)||K(m)||m.isSegmented())m=P(),k.canInsertTextBefore()?c.insertBefore(m):k.insertBefore(m);m.select();c=m;if(""!==a){this.insertText(a);return}}else{var m=c.getNextSibling();if(!y(m)||K(m)||m.isSegmented())m=P(),k.canInsertTextAfter()?c.insertAfter(m):k.insertAfter(m);m.select(0,0);c=m;if(""!==a){this.insertText(a);return}}if(1===g)if(K(c))c.remove();else{f=c.getFormat();
|
|
19
|
+
if(b===l&&f!==e)if(""===c.getTextContent())c.setFormat(e);else{f=P(a);f.setFormat(e);f.select();0===b?c.insertBefore(f):([g]=c.splitText(b),g.insertAfter(f));return}c=c.spliceText(b,l-b,a,!0);""===c.getTextContent()?c.remove():c.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=a.length)}else{k=f[g-1];e=new Set([...c.getParentKeys(),...k.getParentKeys()]);var n=D(c)?c:c.getParentOrThrow();m=D(k)?k:k.getParentOrThrow();"text"===h.type&&(0!==l||""===k.getTextContent())||"element"===h.type&&
|
|
20
|
+
k.getIndexWithinParent()<l?y(k)&&!K(k)&&l!==k.getTextContentSize()?(k.isSegmented()&&(h=P(k.getTextContent()),k.replace(h),k=h),k=k.spliceText(0,l,""),e.add(k.getKey())):k.remove():e.add(k.getKey());h=m.getChildren();l=new Set(f);const r=n.is(m);if(m.canBeEmpty()){for(n=h.length-1;0<=n;n--){const u=h[n];if(u.is(c))break;u.isAttached()&&(!l.has(u)||u.is(k)?r||c.insertAfter(u):u.remove())}if(!r)for(h=m,l=null;null!==h;){k=h.getChildren();m=k.length;if(0===m||k[m-1].is(l))e.delete(h.getKey()),l=h;h=
|
|
21
|
+
h.getParent()}}else n.append(m);K(c)?b===d?c.select():c.remove():(c=c.spliceText(b,d-b,a,!0),""===c.getTextContent()?c.remove():c.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=a.length));for(a=1;a<g;a++)b=f[a],c=b.getKey(),e.has(c)||D(b)&&!b.canSelectionRemove()||b.remove()}}removeText(){this.insertText("")}formatText(a){const b=this.getNodes(),c=b.length-1;let d=b[0],e=b[c];if(this.isCollapsed())this.toggleFormatType(a);else{var f=this.anchor,g=this.focus,h=d.getTextContent().length,
|
|
22
|
+
l=g.offset,k=0;for(var m=0;m<b.length;m++){var n=b[m];if(y(n)){k=n.getFormatFlags(a,null);break}}var r=f.offset;n=(m=f.isBefore(g))?r:l;m=m?l:r;if(n===d.getTextContentSize()){const u=d.getNextSibling();y(u)&&(n=r=0,d=u,k=d.getFormatFlags(a,null))}if(d.is(e))y(d)&&("element"===f.type&&"element"===g.type?(d.setFormat(k),d.select(n,m),this.format=k):(n=r>l?l:r,m=r>l?r:l,n!==m&&(0===n&&m===h?(d.setFormat(k),d.select(n,m)):(a=d.splitText(n,m),a=0===n?a[0]:a[1],a.setFormat(k),a.select(0,m-n)),this.format=
|
|
23
|
+
k)));else for(y(d)&&(0!==n&&([,d]=d.splitText(n)),d.setFormat(k)),f=k,y(e)&&(f=e.getFormatFlags(a,k),k=e.getTextContent().length,0!==m&&(m!==k&&([e]=e.splitText(m)),e.setFormat(f))),k=1;k<c;k++)m=b[k],g=m.getKey(),y(m)&&g!==d.getKey()&&g!==e.getKey()&&!m.isToken()&&(g=m.getFormatFlags(a,f),m.setFormat(g))}}insertNodes(a,b){this.isCollapsed()||this.removeText();var c=this.anchor,d=c.offset,e=c.getNode(),f=e;"element"===c.type&&(f=c.getNode(),c=f.getChildAtIndex(d-1),f=null===c?f:c);c=[];var g=e.getNextSiblings(),
|
|
24
|
+
h=e.getTopLevelElementOrThrow();if(y(e))if(f=e.getTextContent().length,0===d&&0!==f)f=e.getPreviousSibling(),f=null!==f?f:e.getParentOrThrow(),c.push(e);else if(d===f)f=e;else{if(K(e))return!1;[f,e]=e.splitText(d);c.push(e)}e=f;c.push(...g);d=a[0];var l=!1;for(g=0;g<a.length;g++){const n=a[g];if(D(n)){if(n.is(d)){if(D(f)&&f.isEmpty()&&f.canReplaceWith(n)){f.replace(n);f=n;l=!0;continue}var k=n.getFirstDescendant();if(Ca(k)){k=k.getParentOrThrow();l=k.getChildren();var m=l.length;if(D(f))for(let r=
|
|
25
|
+
0;r<m;r++)f.append(l[r]);else{for(--m;0<=m;m--)f.insertAfter(l[m]);f=f.getParentOrThrow()}k.remove();l=!0;if(k.is(n))continue}}y(f)&&(f=h)}else l&&R(f.getParent())&&q(7);l=!1;if(D(f))if(D(n)){if(n.canBeEmpty()||!n.isEmpty())f=f.insertAfter(n)}else k=f.getFirstChild(),null!==k?k.insertBefore(n):f.append(n),f=n;else D(n)?(f=n.getParentOrThrow(),g--):f=f.insertAfter(n)}b&&(y(e)?e.select():(a=f.getPreviousSibling(),y(a)?a.select():(a=f.getIndexWithinParent(),f.getParentOrThrow().select(a,a))));if(D(f)){if(a=
|
|
26
|
+
f.getLastDescendant(),b||(null===a?f.select():y(a)?a.select():a.selectNext()),0!==c.length)for(b=c.length-1;0<=b;b--)a=c[b],h=a.getParentOrThrow(),D(f)&&!D(a)?(f.append(a),f=a):D(a)&&!a.canInsertAfter(f)?(e=h.constructor.clone(h),D(e)||q(8),e.append(a),f.insertAfter(e)):f.insertAfter(a),h.isEmpty()&&!h.canBeEmpty()&&h.remove()}else b||(y(f)?f.select():(c=f.getParentOrThrow(),f=f.getIndexWithinParent()+1,c.select(f,f)));return!0}insertParagraph(){this.isCollapsed()||this.removeText();var a=this.anchor,
|
|
27
|
+
b=a.offset;if("text"===a.type){var c=a.getNode(),d=c.getTextContent().length;a=c.getNextSiblings().reverse();var e=c.getParentOrThrow();0===b?a.push(c):b!==d&&([,b]=c.splitText(b),a.push(b))}else e=a.getNode(),a=e.getChildren().slice(b).reverse();b=e.insertNewAfter(this);if(null===b)this.insertLineBreak();else if(D(b)){e=a.length;c=null;if(0!==e)for(d=0;d<e;d++){const f=a[d];null===c?b.append(f):c.insertBefore(f);c=f}b.canBeEmpty()||0!==b.getChildrenSize()?b.selectStart():(b.selectPrevious(),b.remove())}}insertLineBreak(a){const b=
|
|
28
|
+
Sa();a?this.insertNodes([b],!0):this.insertNodes([b])&&b.selectNext(0,0)}extract(){var a=this.getNodes(),b=a.length,c=b-1,d=this.anchor;const e=this.focus;var f=a[0];let g=a[c];var h=d.getCharacterOffset();const l=e.getCharacterOffset();if(0===b)return[];if(1===b)return y(f)?(a=h>l?l:h,c=f.splitText(a,h>l?h:l),a=0===a?c[0]:c[1],null!=a?[a]:[]):[f];b=d.isBefore(e);y(f)&&(d=b?h:l,d===f.getTextContentSize()?a.shift():0!==d&&([,f]=f.splitText(d),a[0]=f));y(g)&&(f=g.getTextContent().length,h=b?l:h,0===
|
|
29
|
+
h?a.pop():h!==f&&([g]=g.splitText(h),a[c]=g));return a}modify(a,b,c){var d=this.focus,e=this.anchor,f="move"===a;var g=d.offset;if("element"===d.type)g=d.getNode().getChildAtIndex(b?g-1:g);else{var h=d.getNode();g=b&&0===g||!b&&g===h.getTextContentSize()?b?h.getPreviousSibling():h.getNextSibling():null}if(v(g)&&(h=b?g.getPreviousSibling():g.getNextSibling(),!y(h))){a=g.getParentOrThrow().getKey();c=g.getIndexWithinParent();b||c++;d.set(a,c,"element");f&&e.set(a,c,"element");return}d=window.getSelection();
|
|
30
|
+
d.modify(a,b?"backward":"forward",c);0<d.rangeCount&&(b=d.getRangeAt(0),this.applyDOMRange(b),f||d.anchorNode===b.startContainer&&d.anchorOffset===b.startOffset||(f=this.focus,b=this.anchor,d=b.key,e=b.offset,a=b.type,Q(b,f.key,f.offset,f.type),Q(f,d,e,a)))}deleteCharacter(a){if(this.isCollapsed()){var b=this.anchor,c=this.focus,d=b.getNode();if(D(d)&&!d.canSelectionRemove()||!a&&("element"===b.type&&b.offset===d.getChildrenSize()||"text"===b.type&&b.offset===d.getTextContentSize())&&(d=d.getNextSibling()||
|
|
31
|
+
d.getParentOrThrow().getNextSibling(),D(d)&&!d.canExtractContents()))return;this.modify("extend",a,"character");if(!this.isCollapsed()){var e="text"===c.type?c.getNode():null;d="text"===b.type?b.getNode():null;if(null!==e&&e.isSegmented()){if(b=c.offset,c=e.getTextContentSize(),e.is(d)||a&&b!==c||!a&&0!==b){Ta(e,a);return}}else if(null!==d&&d.isSegmented()&&(b=b.offset,c=d.getTextContentSize(),d.is(e)||a&&0!==b||!a&&b!==c)){Ta(d,a);return}d=this.anchor;e=this.focus;b=d.getNode();c=e.getNode();if(b===
|
|
32
|
+
c&&"text"===d.type&&"text"===e.type){var f=d.offset,g=e.offset;const h=f<g;c=h?f:g;g=h?g:f;f=g-1;c!==f&&(b=b.getTextContent().slice(c,g),/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(b)||(a?e.offset=f:d.offset=f))}}else if(a&&0===b.offset&&("element"===b.type?b.getNode():b.getNode().getParentOrThrow()).collapseAtStart(this))return}this.removeText();a=this.anchor;"text"===a.type&&(a=a.getNode(),d=a.getTextContent(),e=this.anchor.offset,0===e&&a.isSimpleText()?(e=a.getPreviousSibling(),y(e)&&"hashtag"===e.getType()&&
|
|
33
|
+
(e.select(),b=e.getTextContent(),e.setTextContent(b+d),a.remove())):y(a)&&"hashtag"===a.getType()&&e===a.getTextContentSize()&&(e=a.getNextSibling(),y(e)&&e.isSimpleText()&&(b=e.getTextContent(),a.setTextContent(d+b),e.remove())))}deleteLine(a){this.isCollapsed()&&this.modify("extend",a,"lineboundary");this.removeText()}deleteWord(a){this.isCollapsed()&&this.modify("extend",a,"word");this.removeText()}}
|
|
34
|
+
function Ta(a,b){var c=a.getTextContent().split(/\s/g);b?c.pop():c.shift();c=c.join(" ");""===c?a.remove():(a=a.setTextContent(c),b?a.select():a.select(0,0))}
|
|
35
|
+
function Ua(a,b){if(1===a.nodeType){let e=!1;var c=a.childNodes;var d=c.length;b===d&&(e=!0,b=d-1);c=Ka(c[b]);if(y(c))b=e?c.getTextContentSize():0;else{d=Ka(a);if(null===d)return null;D(d)?(a=d.getChildAtIndex(b),D(a)&&(d=e?a.getLastDescendant():a.getFirstDescendant(),null===d?(d=a,b=0):(a=d,d=a.getParentOrThrow())),y(a)?(c=a,d=null,b=e?c.getTextContentSize():0):a!==d&&e&&b++):(b=d.getIndexWithinParent()+1,d=d.getParentOrThrow());if(R(d))return null;if(D(d))return O(d.__key,b,"element")}}else c=Ka(a);
|
|
36
|
+
return y(c)?O(c.__key,b,"text"):null}
|
|
37
|
+
function Ra(a,b,c,d,e){if(null===a||null===c||!wa(e,a,c))return null;a=Ua(a,b);if(null===a)return null;c=Ua(c,d);if(null===c)return null;if("text"===a.type&&"text"===c.type){d=a.getNode();const f=c.getNode(),g=d.getTextContentSize(),h=a.offset,l=c.offset;d===f&&h===l?0===b&&(d=d.getPreviousSibling(),y(d)&&!d.isInert()&&(b=d.getTextContentSize(),d=d.__key,a.key=d,c.key=d,a.offset=b,c.offset=b)):h===g&&(b=d.getNextSibling(),y(b)&&!b.isInert()&&(a.key=b.__key,a.offset=0));b=e.getEditorState()._selection;
|
|
38
|
+
e.isComposing()&&e._compositionKey!==a.key&&null!==b&&(e=b.anchor,b=b.focus,Q(a,e.key,e.offset,e.type),Q(c,b.key,b.offset,b.type))}return[a,c]}function Va(a,b,c,d,e,f){const g=B();a=new Qa(O(a,b,e),O(c,d,f),0);a.dirty=!0;return g._selection=a}
|
|
39
|
+
function Wa(a){const b=a.getEditorState()._selection;var c=(c=window.event)&&c.type;c=!ea&&("selectionchange"===c||"beforeinput"===c||"compositionstart"===c||"compositionend"===c||"click"===c&&3===window.event.detail||void 0===c);let d,e;if(null===b||c){var f=window.getSelection();if(null===f)return null;c=f.anchorNode;d=f.focusNode;e=f.anchorOffset;f=f.focusOffset}else return a=b.anchor,c=b.focus,new Qa(O(a.key,a.offset,a.type),O(c.key,c.offset,c.type),b.format);a=Ra(c,e,d,f,a);if(null===a)return null;
|
|
40
|
+
const [g,h]=a;return new Qa(g,h,null===b?0:b.format)}function t(){return B()._selection}
|
|
41
|
+
function Xa(a,b,c,d=1){var e=a.anchor,f=a.focus,g=e.getNode(),h=f.getNode();if((b.is(g)||b.is(h))&&D(g))if(g=b.getKey(),a.isCollapsed())b=e.offset,c<=b&&(c=Math.max(0,b+d),e.set(g,c,"element"),f.set(g,c,"element"),Ya(a));else{var l=a.isBackward();h=l?f:e;var k=h.getNode();e=l?e:f;f=e.getNode();b.is(k)&&(k=h.offset,c<=k&&h.set(g,Math.max(0,k+d),"element"));b.is(f)&&(b=e.offset,c<=b&&e.set(g,Math.max(0,b+d),"element"));Ya(a)}}
|
|
42
|
+
function Ya(a){var b=a.anchor,c=b.offset;const d=a.focus;var e=d.offset,f=b.getNode(),g=d.getNode();if(a.isCollapsed())D(f)&&(g=f.getChildrenSize(),g=(e=c>=g)?f.getChildAtIndex(g-1):f.getChildAtIndex(c),y(g)&&(c=0,e&&(c=g.getTextContentSize()),b.set(g.getKey(),c,"text"),d.set(g.getKey(),c,"text")));else{if(D(f)){const h=f.getChildrenSize();c=(a=c>=h)?f.getChildAtIndex(h-1):f.getChildAtIndex(c);y(c)&&(f=0,a&&(f=c.getTextContentSize()),b.set(c.getKey(),f,"text"))}D(g)&&(c=g.getChildrenSize(),e=(b=e>=
|
|
43
|
+
c)?g.getChildAtIndex(c-1):g.getChildAtIndex(e),y(e)&&(g=0,b&&(g=e.getTextContentSize()),d.set(e.getKey(),g,"text")))}}function Za(a,b){b=b.getEditorState()._selection;a=a._selection;if(null!==a){var c=a.anchor;const d=a.focus;let e;"text"===c.type&&(e=c.getNode(),e.selectionTransform(b,a));"text"===d.type&&(c=d.getNode(),e!==c&&c.selectionTransform(b,a))}}
|
|
44
|
+
function $a(a,b,c){let d=null,e=0;var f=b.getPreviousSibling();y(f)?(d=f.__key,e=f.getTextContentSize()):(f=b.getNextSibling(),y(f)&&(d=f.__key));null!==d?a.set(d,e,"text"):(e=b.getIndexWithinParent(),a.set(c.__key,e,"element"))}function ab(a,b,c,d,e){"text"===a.type?(a.key=c,b||(a.offset+=e)):a.offset>d.getIndexWithinParent()&&--a.offset}
|
|
45
|
+
function bb(a,b){G();var c=a.__key;const d=a.getParent();if(null!==d){var e=t(),f=!1;if(null!==e&&b){var g=e.anchor;const h=e.focus;g.key===c&&($a(g,a,d),f=!0);h.key===c&&($a(h,a,d),f=!0)}g=d.getWritable().__children;c=g.indexOf(c);-1===c&&q(16);E(a);g.splice(c,1);a.getWritable().__parent=null;null!==e&&b&&!f&&Xa(e,d,c,-1);null===d||R(d)||d.canBeEmpty()||0!==d.getChildrenSize()||bb(d,b)}}
|
|
46
|
+
class cb{static getType(){q(31,this.name)}static clone(){q(32,this.name)}constructor(a){this.__type=this.constructor.getType();if(!a){G();99<Fa&&q(26);a=C();const b=B(),c=""+ta++;b._nodeMap.set(c,this);D(this)?a._dirtyElements.set(c,!0):a._dirtyLeaves.add(c);a._cloneNotNeeded.add(c);a._dirtyType=1;a=c}this.__key=a;this.__parent=null}getType(){return this.__type}isAttached(){for(var a=this.__key;null!==a;){if("root"===a)return!0;a=I(a);if(null===a)break;a=a.__parent}return!1}isSelected(){const a=t();
|
|
47
|
+
if(null==a)return!1;const b=(new Set(a.getNodes().map(c=>c.__key))).has(this.__key);return y(this)?b:"element"===a.anchor.type&&"element"===a.focus.type&&a.anchor.key===a.focus.key&&a.anchor.offset===a.focus.offset?!1:b}getKey(){return this.__key}getIndexWithinParent(){const a=this.getParent();return null===a?-1:a.__children.indexOf(this.__key)}getParent(){const a=this.getLatest().__parent;return null===a?null:I(a)}getParentOrThrow(){const a=this.getParent();null===a&&q(33,this.__key);return a}getTopLevelElement(){let a=
|
|
48
|
+
this;for(;null!==a;){const b=a.getParent();if(R(b)&&D(a))return a;a=b}return null}getTopLevelElementOrThrow(){const a=this.getTopLevelElement();null===a&&q(34,this.__key);return a}getParents(){const a=[];let b=this.getParent();for(;null!==b;)a.push(b),b=b.getParent();return a}getParentKeys(){const a=[];let b=this.getParent();for(;null!==b;)a.push(b.__key),b=b.getParent();return a}getPreviousSibling(){var a=this.getParent();if(null===a)return null;a=a.__children;const b=a.indexOf(this.__key);return 0>=
|
|
49
|
+
b?null:I(a[b-1])}getPreviousSiblings(){var a=this.getParent();if(null===a)return[];a=a.__children;const b=a.indexOf(this.__key);return a.slice(0,b).map(c=>db(c))}getNextSibling(){var a=this.getParent();if(null===a)return null;a=a.__children;const b=a.length,c=a.indexOf(this.__key);return c>=b-1?null:I(a[c+1])}getNextSiblings(){var a=this.getParent();if(null===a)return[];a=a.__children;const b=a.indexOf(this.__key);return a.slice(b+1).map(c=>db(c))}getCommonAncestor(a){const b=this.getParents();var c=
|
|
50
|
+
a.getParents();D(this)&&b.unshift(this);D(a)&&c.unshift(a);a=b.length;var d=c.length;if(0===a||0===d||b[a-1]!==c[d-1])return null;c=new Set(c);for(d=0;d<a;d++){const e=b[d];if(c.has(e))return e}return null}is(a){return null==a?!1:this.getKey()===a.getKey()}isBefore(a){if(a.isParentOf(this))return!0;if(this.isParentOf(a))return!1;var b=this.getCommonAncestor(a);let c=this;for(;;){var d=c.getParentOrThrow();if(d===b){d=d.__children.indexOf(c.__key);break}c=d}for(c=a;;){a=c.getParentOrThrow();if(a===
|
|
51
|
+
b){b=a.__children.indexOf(c.__key);break}c=a}return d<b}isParentOf(a){const b=this.__key;if(b===a.__key)return!1;for(;null!==a;){if(a.__key===b)return!0;a=a.getParent()}return!1}getNodesBetween(a){const b=this.isBefore(a),c=[],d=new Set;var e=this;let f=null;for(;;){var g=e.__key;d.has(g)||(d.add(g),c.push(e));if(e===a)break;g=D(e)?b?e.getFirstChild():e.getLastChild():null;if(null!==g)null===f&&(f=e),e=g;else if(g=b?e.getNextSibling():e.getPreviousSibling(),null!==g)e=g;else{g=e.getParentOrThrow();
|
|
52
|
+
d.has(g.__key)||c.push(g);if(g===a)break;e=g;g.is(f)&&(f=null);do null===e&&q(35),g=b?e.getNextSibling():e.getPreviousSibling(),e=e.getParent(),null!==e&&(e.is(f)&&(f=null),null!==g||d.has(e.__key)||c.push(e));while(null===g);e=g}}b||c.reverse();return c}isDirty(){const a=C()._dirtyLeaves;return null!==a&&a.has(this.__key)}isComposing(){return this.__key===J()}getLatest(){const a=I(this.__key);null===a&&q(36);return a}getWritable(){G();var a=B(),b=C();a=a._nodeMap;const c=this.__key,d=this.getLatest(),
|
|
53
|
+
e=d.__parent;b=b._cloneNotNeeded;if(b.has(c))return Ea(d),d;const f=d.constructor.clone(d);f.__parent=e;D(d)&&D(f)?(f.__children=Array.from(d.__children),f.__indent=d.__indent,f.__format=d.__format,f.__dir=d.__dir):y(d)&&y(f)?(f.__format=d.__format,f.__style=d.__style,f.__mode=d.__mode,f.__detail=d.__detail):v(d)&&v(f)&&(f.__ref=d.__ref);b.add(c);f.__key=c;Ea(f);a.set(c,f);return f}getTextContent(){return""}getTextContentSize(a,b){return this.getTextContent(a,b).length}createDOM(){q(37)}updateDOM(){q(38)}remove(){G();
|
|
54
|
+
bb(this,!0)}replace(a){G();const b=this.__key;a=a.getWritable();var c=a.getParent();if(null!==c){c=c.getWritable().__children;var d=c.indexOf(a.__key);-1===d&&q(16);E(a);c.splice(d,1)}d=this.getParentOrThrow();var e=d.getWritable().__children;const f=e.indexOf(this.__key);c=a.__key;-1===f&&q(16);e.splice(f,0,c);a.__parent=d.__key;bb(this,!1);E(a);e=t();null!==e&&(d=e.anchor,e=e.focus,d.key===b&&Oa(d,a),e.key===b&&Oa(e,a));J()===b&&F(c);return a}insertAfter(a){G();var b=this.getWritable(),c=a.getWritable(),
|
|
55
|
+
d=c.getParent();if(null!==d){d=d.getWritable().__children;var e=d.indexOf(c.__key);-1===e&&q(16);E(c);d.splice(e,1)}d=this.getParentOrThrow().getWritable();e=c.__key;c.__parent=b.__parent;const f=d.__children;b=f.indexOf(b.__key);-1===b&&q(16);f.splice(b+1,0,e);E(c);c=t();null!==c&&Xa(c,d,b+1);return a}insertBefore(a){G();var b=this.getWritable(),c=a.getWritable(),d=c.getParent();if(null!==d){d=d.getWritable().__children;var e=d.indexOf(c.__key);-1===e&&q(16);E(c);d.splice(e,1)}d=this.getParentOrThrow().getWritable();
|
|
56
|
+
e=c.__key;c.__parent=b.__parent;const f=d.__children;b=f.indexOf(b.__key);-1===b&&q(16);f.splice(b,0,e);E(c);c=t();null!==c&&Xa(c,d,b);return a}selectPrevious(a,b){G();const c=this.getPreviousSibling(),d=this.getParentOrThrow();return null===c?d.select(0,0):D(c)?c.select():y(c)?c.select(a,b):(a=c.getIndexWithinParent()+1,d.select(a,a))}selectNext(a,b){G();const c=this.getNextSibling(),d=this.getParentOrThrow();return null===c?d.select():D(c)?c.select(0,0):y(c)?c.select(a,b):(a=c.getIndexWithinParent(),
|
|
57
|
+
d.select(a,a))}markDirty(){this.getWritable()}}function db(a){const b=I(a);null===b&&q(39,a);return b}
|
|
58
|
+
class eb extends cb{constructor(a){super(a);this.__children=[];this.__indent=this.__format=0;this.__dir=null}getFormat(){return this.getLatest().__format}getIndent(){return this.getLatest().__indent}getChildren(){const a=this.getLatest().__children,b=[];for(let c=0;c<a.length;c++){const d=I(a[c]);null!==d&&b.push(d)}return b}getChildrenKeys(){return this.getLatest().__children}getChildrenSize(){return this.getLatest().__children.length}isEmpty(){return 0===this.getChildrenSize()}isDirty(){const a=
|
|
59
|
+
C()._dirtyElements;return null!==a&&a.has(this.__key)}getAllTextNodes(a){const b=[],c=this.getLatest().__children;for(let e=0;e<c.length;e++){var d=I(c[e]);!y(d)||!a&&d.isInert()?D(d)&&(d=d.getAllTextNodes(a),b.push(...d)):b.push(d)}return b}getFirstDescendant(){let a=this.getFirstChild();for(;null!==a;){if(D(a)){const b=a.getFirstChild();if(null!==b){a=b;continue}}break}return a}getLastDescendant(){let a=this.getLastChild();for(;null!==a;){if(D(a)){const b=a.getLastChild();if(null!==b){a=b;continue}}break}return a}getDescendantByIndex(a){const b=
|
|
60
|
+
this.getChildren(),c=b.length;if(0===c)return this;if(a>=c)return a=b[c-1],D(a)&&a.getLastDescendant()||a;a=b[a];return D(a)&&a.getFirstDescendant()||a}getFirstChild(){const a=this.getLatest().__children;return 0===a.length?null:I(a[0])}getFirstChildOrThrow(){const a=this.getFirstChild();null===a&&q(15,this.__key);return a}getLastChild(){const a=this.getLatest().__children,b=a.length;return 0===b?null:I(a[b-1])}getChildAtIndex(a){a=this.getLatest().__children[a];return void 0===a?null:I(a)}getTextContent(a,
|
|
61
|
+
b){let c="";const d=this.getChildren(),e=d.length;for(let f=0;f<e;f++){const g=d[f];c+=g.getTextContent(a,b);D(g)&&f!==e-1&&(c+="\n\n")}return c}getDirection(){return this.__dir}hasFormat(a){a=ca[a];return 0!==(this.getFormat()&a)}select(a,b){G();const c=t();var d=this.getChildrenSize();void 0===a&&(a=d);void 0===b&&(b=d);d=this.__key;if(null===c)return Va(d,a,d,b,"element","element");c.anchor.set(d,a,"element");c.focus.set(d,b,"element");c.dirty=!0;return c}selectStart(){const a=this.getFirstDescendant();
|
|
62
|
+
return D(a)||y(a)?a.select(0,0):null!==a?a.selectPrevious():this.select(0,0)}selectEnd(){const a=this.getLastDescendant();return D(a)||y(a)?a.select():null!==a?a.selectNext():this.select()}clear(){G();const a=this.getWritable();this.getChildren().forEach(b=>b.remove());return a}append(...a){G();const b=this.getWritable(),c=b.__key,d=b.__children,e=a.length;var f=this.getLastChild();null!==f&&Ea(f);for(f=0;f<e;f++){const h=a[f].getWritable();var g=h.getParent();if(null!==g){g=g.getWritable().__children;
|
|
63
|
+
const l=g.indexOf(h.__key);-1===l&&q(16);g.splice(l,1)}h.__parent=c;d.push(h.__key)}return b}setDirection(a){G();const b=this.getWritable();b.__dir=a;return b}setFormat(a){G();this.getWritable().__format=ca[a];return this}setIndent(a){G();this.getWritable().__indent=a;return this}insertNewAfter(){return null}canInsertTab(){return!1}collapseAtStart(){return!1}excludeFromCopy(){return!1}canExtractContents(){return!0}canReplaceWith(){return!0}canInsertAfter(){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}canSelectionRemove(){return!0}canMergeWith(){return!1}}
|
|
64
|
+
function D(a){return a instanceof eb}class fb extends cb{constructor(a,b){super(b);this.__ref=a||null}decorate(){q(4)}}function v(a){return a instanceof fb}
|
|
65
|
+
class gb extends eb{static getType(){return"root"}static clone(){return new gb}constructor(){super("root");this.__cachedText=null}getTextContent(a,b){const c=this.__cachedText;return!N&&0!==C()._dirtyType||null===c||a&&!1===b?super.getTextContent(a,b):c}select(){q(9)}remove(){q(10)}replace(){q(11)}insertBefore(){q(12)}insertAfter(){q(13)}updateDOM(){return!1}append(...a){for(let b=0;b<a.length;b++){const c=a[b];D(c)||v(c)||q(46)}return super.append(...a)}canBeEmpty(){return!1}}
|
|
66
|
+
function R(a){return a instanceof gb}function hb(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 ib(){return new jb(new Map([["root",new gb]]))}
|
|
67
|
+
class jb{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=S,d=N,e=T;S=this;N=!0;T=null;try{var b=a();break a}finally{S=c,N=d,T=e}b=void 0}return b}clone(a){a=new jb(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:null===a?null:{anchor:{key:a.anchor.key,offset:a.anchor.offset,
|
|
68
|
+
type:a.anchor.type},focus:{key:a.focus.key,offset:a.focus.offset,type:a.focus.type}}}}}let U="",V="",X="",kb,Y,lb=!1,mb=!1,nb=null,ob,pb,qb,rb,sb;function tb(a,b){const c=qb.get(a);if(null!==b){const d=ub(a);b.removeChild(d)}rb.has(a)||Y._keyToDOMMap.delete(a);D(c)&&(a=c.__children,vb(a,0,a.length-1,null))}function vb(a,b,c,d){for(;b<=c;++b){const e=a[b];void 0!==e&&tb(e,d)}}function wb(a,b){a.setProperty("text-align",b)}
|
|
69
|
+
function xb(a,b){a.style.setProperty("padding-inline-start",0===b?"":40*b+"px")}function yb(a,b){a=a.style;0===b?wb(a,""):1===b?wb(a,"left"):2===b?wb(a,"center"):3===b?wb(a,"right"):4===b&&wb(a,"justify")}
|
|
70
|
+
function zb(a,b,c){var d=rb.get(a);void 0===d&&q(42);const e=d.createDOM(kb,Y);var f=Y._keyToDOMMap;e["__lexicalKey_"+Y._key]=a;f.set(a,e);y(d)?e.setAttribute("data-lexical-text","true"):v(d)&&e.setAttribute("data-lexical-decorator","true");if(D(d)){a=d.__indent;0!==a&&xb(e,a);a=d.__children;var g=a.length;if(0!==g){f=a;--g;const h=V;V="";Ab(f,0,g,e,null);Bb(d,e);V=h}d=d.__format;0!==d&&yb(e,d);Cb(null,a,e)}else v(d)?(d=d.decorate(Y),null!==d&&Db(a,d),e.contentEditable="false"):(a=d.getTextContent(),
|
|
71
|
+
y(d)&&(d.isDirectionless()||(V+=a),d.isInert()&&(d=e.style,d.pointerEvents="none",d.userSelect="none",e.contentEditable="false",d.setProperty("-webkit-user-select","none"))),U+=a,X+=a);null!==b&&(null!=c?b.insertBefore(e,c):(c=b.__lexicalLineBreak,null!=c?b.insertBefore(e,c):b.appendChild(e)));return e}function Ab(a,b,c,d,e){const f=U;for(U="";b<=c;++b)zb(a[b],d,e);d.__lexicalTextContent=U;U=f+U}function Eb(a,b){a=b.get(a[a.length-1]);return Da(a)||v(a)}
|
|
72
|
+
function Cb(a,b,c){a=null!==a&&(0===a.length||Eb(a,qb));b=null!==b&&(0===b.length||Eb(b,rb));a?b||(b=c.__lexicalLineBreak,null!=b&&c.removeChild(b),c.__lexicalLineBreak=null):b&&(b=document.createElement("br"),c.__lexicalLineBreak=b,c.appendChild(b))}
|
|
73
|
+
function Bb(a,b){const c=b.__lexicalDir;if(b.__lexicalDirTextContent!==V||c!==nb){var d=""===V;if(d)var e=nb;else e=V,e=aa.test(e)?"rtl":ba.test(e)?"ltr":null;if(e!==c){const f=b.classList,g=kb.theme;null===e||d&&"ltr"===e?(b.removeAttribute("dir"),d=g[c],void 0!==d&&("string"===typeof d&&(d=d.split(" "),d=g[c]=d),f.remove(...d))):null!==e&&(d=g[e],void 0!==d&&("string"===typeof d&&(d=d.split(" "),d=g[c]=d),f.add(...d)),b.dir=e);mb||(a.getWritable().__dir=e)}nb=e;b.__lexicalDirTextContent=V;b.__lexicalDir=
|
|
74
|
+
e}}
|
|
75
|
+
function Fb(a,b){var c=qb.get(a),d=rb.get(a);void 0!==c&&void 0!==d||q(43);var e=lb||pb.has(a)||ob.has(a);const f=Gb(Y,a);if(c===d&&!e)return D(c)?(d=f.__lexicalTextContent,void 0!==d&&(U+=d,X+=d),d=f.__lexicalDirTextContent,void 0!==d&&(V+=d)):v(c)||(d=c.getTextContent(),y(c)&&!c.isDirectionless()&&(V+=d),X+=d,U+=d),f;if(d.updateDOM(c,f,kb))return d=zb(a,null,null),null===b&&q(44),b.replaceChild(d,f),tb(a,null),d;if(D(c)&&D(d)){if(a=d.__indent,a!==c.__indent&&xb(f,a),a=d.__format,a!==c.__format&&yb(f,
|
|
76
|
+
a),c=c.__children,a=d.__children,c!==a||e){var g=c,h=a;e=d;b=V;V="";const u=U;U="";var l=g.length,k=h.length;if(1===l&&1===k){var m=g[0];h=h[0];if(m===h)Fb(m,f);else{var n=ub(m);h=zb(h,null,null);f.replaceChild(h,n);tb(m,null)}}else if(0===l)0!==k&&Ab(h,0,k-1,f,null);else if(0===k)0!==l&&(m=null==f.__lexicalLineBreak,vb(g,0,l-1,m?null:f),m&&(f.textContent=""));else{const H=l-1;l=k-1;let w=f.firstChild,z=0;for(k=0;z<=H&&k<=l;){var r=g[z];const x=h[k];if(r===x)w=Fb(x,f).nextSibling,z++,k++;else{void 0===
|
|
77
|
+
m&&(m=new Set(g));void 0===n&&(n=new Set(h));const L=n.has(r),xa=m.has(x);L?(xa?(r=Gb(Y,x),r===w?w=Fb(x,f).nextSibling:(null!=w?f.insertBefore(r,w):f.appendChild(r),Fb(x,f)),z++):zb(x,f,w),k++):(w=ub(r).nextSibling,tb(r,f),z++)}}m=z>H;n=k>l;m&&!n?(m=h[l+1],m=void 0===m?null:Y.getElementByKey(m),Ab(h,k,l,f,m)):n&&!m&&vb(g,z,H,f)}f.__lexicalTextContent=U;U=u+U;Bb(e,f);V=b;R(d)||Cb(c,a,f)}}else v(d)?(c=d.decorate(Y),null!==c&&Db(a,c)):(c=d.getTextContent(),y(d)&&!d.isDirectionless()&&(V+=c),U+=c,X+=
|
|
78
|
+
c);!mb&&R(d)&&d.__cachedText!==X&&(d=d.getWritable(),d.__cachedText=X);return f}function Db(a,b){let c=Y._pendingDecorators;const d=Y._decorators;if(null===c){if(d[a]===b)return;c=Ga(Y)}c[a]=b}function ub(a){a=sb.get(a);void 0===a&&q(45);return a}function Gb(a,b){a=a._keyToDOMMap.get(b);void 0===a&&q(45);return a}function Hb(a,b,c,d,e){a=a.__children;const f=a.length;for(let g=0;g<f;g++){const h=a[g],l=d.get(h);void 0!==l&&l.__parent===b&&(D(l)&&Hb(l,h,c,d,e),c.has(h)||e.delete(h),d.delete(h))}}
|
|
79
|
+
function Mb(a,b,c,d){var e=Array.from(c),f=e.length;const g=Array.from(d),h=g.length;a=a._nodeMap;b=b._nodeMap;for(let l=0;l<f;l++){const k=e[l],m=b.get(k);void 0===m||m.isAttached()||(a.has(k)||c.delete(k),b.delete(k))}for(c=0;c<h;c++)e=g[c][0],f=b.get(e),void 0===f||f.isAttached()||(D(f)&&Hb(f,e,a,b,d),a.has(e)||d.delete(e),b.delete(e))}
|
|
80
|
+
function Nb(a,b,c,d,e={}){var f=a.__type,g=c._registeredNodes.get(f);void 0===g&&q(24,f);f=g.klass;g=a.__key;a.__key=void 0;f=f.clone(a);a.__key=g;g=f.__key;R(f)&&B()._nodeMap.set("root",f);f.__parent=d;if(D(f)){d=a.__children;for(let l=0;l<d.length;l++){var h=b.get(d[l]);void 0!==h&&(h=Nb(h,b,c,g,e).getKey(),f.__children.push(h))}f.__indent=a.__indent;f.__format=a.__format;f.__dir=a.__dir}else y(f)?(f.__format=a.__format,f.__style=a.__style,f.__mode=a.__mode,f.__detail=a.__detail):v(f)&&(b=a.__ref,
|
|
81
|
+
c=null,null!==b&&"editorstate"===b.type&&(c=Ob(b.id,b.editorState)),f.__ref=c);b=null!=e?e.originalSelection:void 0;null!=b&&(a.__key===b.anchor.key&&(e.remappedSelection=e.remappedSelection||{anchor:{...b.anchor},focus:{...b.focus}},e.remappedSelection.anchor.key=f.__key),a.__key===b.focus.key&&(e.remappedSelection=e.remappedSelection||{anchor:{...b.anchor},focus:{...b.focus}},e.remappedSelection.focus.key=f.__key));return f}
|
|
82
|
+
function Pb(a,b){const c=a.__mode,d=a.__format;a=a.__style;const e=b.__mode,f=b.__format;b=b.__style;return(null===c||c===e)&&(null===d||d===f)&&(null===a||a===b)}function Qb(a,b){const c=a.mergeWithSibling(b),d=C()._normalizedNodes;d.add(a.__key);d.add(b.__key);return c}
|
|
83
|
+
function Rb(a){if(""===a.__text&&a.isSimpleText()&&!a.isUnmergeable())a.remove();else{for(var b;null!==(b=a.getPreviousSibling())&&y(b)&&b.isSimpleText()&&!b.isUnmergeable();)if(""===b.__text)b.remove();else{Pb(b,a)&&(a=Qb(b,a));break}for(var c;null!==(c=a.getNextSibling())&&y(c)&&c.isSimpleText()&&!c.isUnmergeable();)if(""===c.__text)c.remove();else{Pb(a,c)&&Qb(a,c);break}}}let S=null,T=null,N=!1,Sb=!1,Fa=0;function G(){N&&q(25)}function B(){null===S&&q(27);return S}
|
|
84
|
+
function C(){null===T&&q(28);return T}function Tb(a,b,c){var d=b.__type;const e=a._registeredNodes.get(d);void 0===e&&q(23,d);a=c.get(d);void 0===a&&(a=Array.from(e.transforms),c.set(d,a));c=a.length;for(d=0;d<c&&(a[d](b),b.isAttached());d++);}function Ub(a,b){var c=b._dirtyLeaves;a=a._nodeMap;b=c.size;c=Array.from(c);for(let d=0;d<b;d++){const e=a.get(c[d]);y(e)&&e.isSimpleText()&&!e.isUnmergeable()&&Rb(e)}}
|
|
85
|
+
function Vb(a,b){const c=b._dirtyLeaves,d=b._dirtyElements;a=a._nodeMap;const e=J(),f=new Map;var g=c,h=g.size,l=d;let k=l.size;for(;0<h||0<k;){if(0<h){b._dirtyLeaves=new Set;g=Array.from(g);for(var m=0;m<h;m++){var n=g[m];const r=a.get(n);y(r)&&r.isSimpleText()&&!r.isUnmergeable()&&Rb(r);void 0!==r&&void 0!==r&&r.__key!==e&&r.isAttached()&&Tb(b,r,f);c.add(n)}g=b._dirtyLeaves;h=g.size;if(0<h){Fa++;continue}}b._dirtyLeaves=new Set;b._dirtyElements=new Map;h=Array.from(l);for(l=0;l<k;l++)m=h[l],g=m[0],
|
|
86
|
+
m=m[1],"root"!==g&&m&&(m=h[l][1],n=a.get(g),void 0!==n&&void 0!==n&&n.__key!==e&&n.isAttached()&&Tb(b,n,f),d.set(g,m));g=b._dirtyLeaves;h=g.size;l=b._dirtyElements;k=l.size;Fa++}b._dirtyLeaves=c;b._dirtyElements=d}
|
|
87
|
+
function Z(a){var b=a._pendingEditorState,c=a._rootElement;if(null!==c&&null!==b){var d=a._editorState,e=d._selection,f=b._selection,g=0!==a._dirtyType;a._pendingEditorState=null;a._editorState=b;var h=S,l=N,k=T,m=a._updating;T=a;S=b;N=!1;a._updating=!0;try{var n=a._observer;if(g&&null!==n){var r=a._dirtyType,u=a._dirtyElements,H=a._dirtyLeaves;n.disconnect();try{V=X=U="",lb=2===r,nb=null,Y=a,kb=a._config,ob=u,pb=H,qb=d._nodeMap,rb=b._nodeMap,mb=b._readOnly,sb=new Map(a._keyToDOMMap),Fb("root",null),
|
|
88
|
+
sb=kb=rb=qb=pb=ob=Y=void 0}finally{n.observe(c,{childList:!0,subtree:!0,characterData:!0})}}const W=window.getSelection();if(null!==W&&(g||null===f||f.dirty)){n=W;const ya=n.anchorNode,Ib=n.focusNode,gc=n.anchorOffset,hc=n.focusOffset,za=document.activeElement,ja=a._rootElement;if(!a._updateTags.has("collaboration")||za===ja)if(null===f)null!==e&&wa(a,ya,Ib)&&n.removeAllRanges();else{var w=f.anchor,z=f.focus,x=z.key,L=Gb(a,w.key),xa=Gb(a,x),Jb=w.offset,Kb=z.offset;e=L;x=xa;"text"===w.type&&(e=Aa(L));
|
|
89
|
+
"text"===z.type&&(x=Aa(xa));if(null!==e&&null!==x)if(gc===Jb&&hc===Kb&&ya===e&&Ib===x)null===ja||null!==za&&ja.contains(za)||ja.focus({preventScroll:!0});else try{if(n.setBaseAndExtent(e,Jb,x,Kb),f.isCollapsed()&&ja===za){const ka=3===e.nodeType?e.parentNode:e;if(null!==ka){const Lb=ka.getBoundingClientRect();Lb.bottom>window.innerHeight?ka.scrollIntoView(!1):0>Lb.top&&ka.scrollIntoView()}}}catch(ka){}}}}catch(W){A("error",a,!1,W,W._log);Sb||(Wb(a,null,c,b),sa(a),a._dirtyType=2,Sb=!0,a._log.push("ReconcileRecover"),
|
|
90
|
+
Z(a),Sb=!1);return}finally{a._updating=m,S=h,N=l,T=k}b._readOnly=!0;c=a._dirtyLeaves;f=a._dirtyElements;h=a._normalizedNodes;l=a._updateTags;k=a._log;a._log=[];g&&(a._dirtyType=0,a._cloneNotNeeded.clear(),a._dirtyLeaves=new Set,a._dirtyElements=new Map,a._normalizedNodes=new Set,a._updateTags=new Set);g=a._decorators;m=a._pendingDecorators||g;w=b._nodeMap;for(var M in m)w.has(M)||(m===g&&(m=Ga(a)),delete m[M]);M=a._pendingDecorators;null!==M&&(a._decorators=M,a._pendingDecorators=null,A("decorator",
|
|
91
|
+
a,!0,M));M=Ha(d);g=Ha(b);M!==g&&A("textcontent",a,!0,g);A("update",a,!0,{tags:l,normalizedNodes:h,prevEditorState:d,editorState:b,dirtyLeaves:c,dirtyElements:f,log:k});b=a._deferred;a._deferred=[];if(0!==b.length){d=a._updating;a._updating=!0;try{for(M=0;M<b.length;M++)b[M]()}finally{a._updating=d}}b=a._updates;if(0!==b.length){const [W,ya]=b.shift();Xb(a,W,!1,ya)}}}
|
|
92
|
+
function A(a,b,c,...d){const e=b._updating;b._updating=c;try{const f=Array.from(b._listeners[a]);for(a=0;a<f.length;a++)f[a](...d)}finally{b._updating=e}}function Yb(a,b,c){if(!1===a._updating||T!==a){let e=!1;a.update(()=>{e=Yb(a,b,c)});return e}const d=La(a);for(let e=4;0<=e;e--)for(let f=0;f<d.length;f++){const g=Array.from(d[f]._listeners.command[e]);for(let h=0;h<g.length;h++)if(!0===g[h](b,c,a))return!0}return!1}
|
|
93
|
+
function Zb(a,b){for(a=a._updates;0!==a.length;){const [c,d]=a.shift(),e=void 0!==d&&d.onUpdate;e&&b.push(e);c()}}
|
|
94
|
+
function Xb(a,b,c,d){c=a._deferred;let e,f,g=!1;void 0!==d&&(e=d.onUpdate,f=d.tag,g=d.skipTransforms);e&&c.push(e);const h=a._editorState;d=a._pendingEditorState;let l=!1;null===d&&(d=a._pendingEditorState=new jb(new Map(h._nodeMap)),l=!0);const k=S,m=N,n=T,r=a._updating;S=d;N=!1;a._updating=!0;T=a;try{l&&(d._selection=Wa(a));const u=a._compositionKey;b();Zb(a,c);Za(d,a);0!==a._dirtyType&&(d.isEmpty()&&q(29),g?Ub(d,a):Vb(d,a),Zb(a,c),Mb(h,d,a._dirtyLeaves,a._dirtyElements));u!==a._compositionKey&&
|
|
95
|
+
(d._flushSync=!0);const H=d._selection;if(null!==H){const w=d._nodeMap,z=H.focus.key;void 0!==w.get(H.anchor.key)&&void 0!==w.get(z)||q(30)}}catch(u){A("error",a,!1,u,a._log);a._pendingEditorState=h;a._dirtyType=2;a._cloneNotNeeded.clear();a._dirtyLeaves=new Set;a._dirtyElements.clear();a._log.push("UpdateRecover");Z(a);return}finally{S=k,N=m,T=n,a._updating=r,Fa=0}0!==a._dirtyType||hb(d,a)?(null!=f&&a._updateTags.add(f),d._flushSync?(d._flushSync=!1,Z(a)):l&&va(()=>{Z(a)})):(e&&(b=c.indexOf(e),c.splice(b,
|
|
96
|
+
1)),d._flushSync=!1,l&&(a._pendingEditorState=null))}function ma(a,b,c,d){a._updating?a._updates.push([b,d]):Xb(a,b,c,d)}class $b extends cb{static getType(){return"linebreak"}static clone(a){return new $b(a.__key)}constructor(a){super(a)}getTextContent(){return"\n"}createDOM(){return document.createElement("br")}updateDOM(){return!1}}function Sa(){return new $b}function Da(a){return a instanceof $b}
|
|
97
|
+
function Wb(a,b,c,d){const e=a._keyToDOMMap;e.clear();a._editorState=ib();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._log=[];a._updates=[];d=a._observer;null!==d&&(d.disconnect(),a._observer=null);null!==b&&(b.textContent="");null!==c&&(c.textContent="",e.set("root",c))}
|
|
98
|
+
function ac(a,b){const c=b.getType();let d=a.get(c);void 0===d&&(d={count:0,klass:b,transforms:new Set},a.set(c,d));const e=d;e.count++;return()=>{1===e.count?a.delete(c):e.count--}}
|
|
99
|
+
class bc{constructor(a,b,c){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,error:new Set,textcontent:new Set,textmutation:new Set,root:new Set,update:new Set,command:[new Set,new Set,new Set,new Set,new Set]};this._config=c;this._registeredNodes=new Map;this.registerNodes([gb,cc,$b]);this._decorators={};this._pendingDecorators=
|
|
100
|
+
null;this._dirtyType=0;this._cloneNotNeeded=new Set;this._dirtyLeaves=new Set;this._dirtyElements=new Map;this._normalizedNodes=new Set;this._updateTags=new Set;this._observer=null;this._log=[];this._key=""+ta++}isComposing(){return null!=this._compositionKey}registerNodes(a){const b=a.length,c=this._registeredNodes,d=[];for(let e=0;e<b;e++)d.push(ac(c,a[e]));return()=>{for(let e=0;e<b;e++)d[e]()}}addListener(a,b,c){const d=this._listeners[a];if("command"===a&&void 0!==c){const f=d[c];f.add(b);return()=>
|
|
101
|
+
{f.delete(b)}}d.add(b);const e="root"===a;e&&b(this._rootElement,null);return()=>{d.delete(b);e&&b(null,this._rootElement)}}addTransform(a,b){const c=a.getType(),d=this._registeredNodes.get(c);void 0===d&&q(18,a.name);const e=d.transforms;e.add(b);Ja(this,c);return()=>{e.delete(b)}}execCommand(a,b){return Yb(this,a,b)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}setRootElement(a){const b=this._rootElement;if(a!==b){const c=this._pendingEditorState||this._editorState;
|
|
102
|
+
this._rootElement=a;Wb(this,b,a,c);null!==b&&(b.__lexicalEditor=null);null!==a&&(a.setAttribute("data-lexical-editor","true"),this._dirtyType=2,sa(this),this._updateTags.add("without-history"),Z(this),a.__lexicalEditor=this);A("root",this,!1,a,b)}}getElementByKey(a){return this._keyToDOMMap.get(a)||null}getEditorState(){return this._editorState}setEditorState(a,b){a.isEmpty()&&q(19);ra(this);const c=this._pendingEditorState,d=this._updateTags;b=void 0!==b?b.tag:null;null===c||c.isEmpty()||(null!=
|
|
103
|
+
b&&d.add(b),Z(this));this._pendingEditorState=a;this._dirtyType=2;this._compositionKey=null;null!=b&&d.add(b);Z(this)}parseEditorState(a){const b=JSON.parse(a);a=new Map;a=new jb(a);const c={originalSelection:b._selection},d=N,e=T;S=a;N=!1;T=this;try{var f=new Map(b._nodeMap);const g=f.get("root");Nb(g,f,this,null,c)}finally{S=a,N=d,T=e}f=c.remappedSelection||c.originalSelection;f=null===f?null:new Qa(O(f.anchor.key,f.anchor.offset,f.anchor.type),O(f.focus.key,f.focus.offset,f.focus.type),0);a._selection=
|
|
104
|
+
f;return a}update(a,b){ma(this,a,!1,b)}focus(a){const b=this._rootElement;null!==b&&(b.setAttribute("autocapitalize","off"),ma(this,()=>{const c=t(),d=Ia();null!==c?c.dirty=!0:0!==d.getChildrenSize()&&d.selectEnd()},!0,{onUpdate:()=>{b.removeAttribute("autocapitalize");a&&a()}}))}}function dc(a,b){return b&1?"strong":b&2?"em":"span"}function ec(a,b){var c=a[b];return"string"===typeof c?(c=c.split(" "),a[b]=c):c}
|
|
105
|
+
function fc(a,b,c,d,e){a=d.classList;d=ec(e,"base");void 0!==d&&a.add(...d);d=ec(e,"underlineStrikethrough");let f=!1;const g=b&8&&b&4;var h=c&8&&c&4;void 0!==d&&(h?(f=!0,g||a.add(...d)):g&&a.remove(...d));for(const l in p)h=p[l],d=ec(e,l),void 0!==d&&(c&h?!f||"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))}
|
|
106
|
+
function ic(a,b,c){const d=b.firstChild;c=c.isComposing()?"\u00a0":"";a+=c;null==d?b.textContent=a:d.nodeValue!==a&&(d.nodeValue=a)}
|
|
107
|
+
class cc extends cb{static getType(){return"text"}static clone(a){return new cc(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!==
|
|
108
|
+
(this.getLatest().__detail&2)}hasFormat(a){a=p[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 Ba(c,a,b)}createDOM(a){var b=this.__format,c=b&16?"code":null;const d=dc(this,b),e=document.createElement(null===c?d:c);let f=e;null!==c&&(f=document.createElement(d),e.appendChild(f));c=f;ic(this.__text,
|
|
109
|
+
c,this);a=a.theme.text;void 0!==a&&fc(d,0,b,c,a);b=this.__style;""!==b&&(e.style.cssText=b);return e}updateDOM(a,b,c){const d=this.__text;var e=a.__format,f=this.__format,g=e&16?"code":null;const h=f&16?"code":null;var l=dc(this,e);const k=dc(this,f);if((null===g?l:g)!==(null===h?k:h))return!0;if(g===h&&l!==k)return e=b.firstChild,null==e&&q(20),a=g=document.createElement(k),ic(d,a,this),c=c.theme.text,void 0!==c&&fc(k,0,f,a,c),b.replaceChild(g,e),!1;l=b;null!==h&&null!==g&&(l=b.firstChild,null==
|
|
110
|
+
l&&q(21));ic(d,l,this);c=c.theme.text;void 0!==c&&e!==f&&fc(k,e,f,l,c);f=this.__style;a.__style!==f&&(b.style.cssText=f);return!1}selectionTransform(){}setFormat(a){G();const b=this.getWritable();this.getWritable().__format=a;return b}setStyle(a){G();const b=this.getWritable();this.getWritable().__style=a;return b}toggleFormat(a){a=p[a];return this.setFormat(this.getFormat()^a)}toggleDirectionless(){const a=this.getWritable();a.__detail^=1;return a}toggleUnmergeable(){const a=this.getWritable();a.__detail^=
|
|
111
|
+
2;return a}setMode(a){a=da[a];const b=this.getWritable();b.__mode=a;return b}setTextContent(a){G();const b=this.getWritable();b.__text=a;return b}select(a,b){G();const c=t();var d=this.getTextContent();const e=this.__key;"string"===typeof d?(d=d.length,void 0===a&&(a=d),void 0===b&&(b=d)):b=a=0;if(null===c)return Va(e,a,e,b,"text","text");d=J();d!==c.anchor.key&&d!==c.focus.key||F(e);c.setTextNodeRange(this,a,this,b);return c}spliceText(a,b,c,d){G();const e=this.getWritable(),f=e.__text,g=c.length;
|
|
112
|
+
let h=a;0>h&&(h=g+h,0>h&&(h=0));const l=t();d&&null!==l&&(a+=g,l.setTextNodeRange(e,a,e,a));b=f.slice(0,h)+c+f.slice(h+b);return e.setTextContent(b)}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...a){G();var b=this.getLatest(),c=b.getTextContent(),d=b.__key,e=J(),f=new Set(a);a=[];var g=c.length,h="";for(var l=0;l<g;l++)""!==h&&f.has(l)&&(a.push(h),h=""),h+=c[l];""!==h&&a.push(h);f=a.length;if(0===f)return[];if(a[0]===c)return[b];var k=a[0];c=b.getParentOrThrow();l=c.__key;
|
|
113
|
+
const m=b.getFormat(),n=b.getStyle(),r=b.__detail;g=!1;b.isSegmented()?(h=P(k),h.__parent=l,h.__format=m,h.__style=n,h.__detail=r,g=!0):(h=b.getWritable(),h.__text=k);b=t();h=[h];k=k.length;for(let w=1;w<f;w++){var u=a[w],H=u.length;u=P(u).getWritable();u.__format=m;u.__style=n;u.__detail=r;const z=u.__key;H=k+H;if(null!==b){const x=b.anchor,L=b.focus;x.key===d&&"text"===x.type&&x.offset>k&&x.offset<=H&&(x.key=z,x.offset-=k,b.dirty=!0);L.key===d&&"text"===L.type&&L.offset>k&&L.offset<=H&&(L.key=z,
|
|
114
|
+
L.offset-=k,b.dirty=!0)}e===d&&F(z);k=H;u.__parent=l;h.push(u)}E(this);e=c.getWritable().__children;d=e.indexOf(d);a=h.map(w=>w.__key);g?(e.splice(d,0,...a),this.remove()):e.splice(d,1,...a);null!==b&&Xa(b,c,d,f-1);return h}mergeWithSibling(a){const b=a===this.getPreviousSibling();b||a===this.getNextSibling()||q(22);const c=this.__key,d=a.__key,e=this.__text,f=e.length;J()===d&&F(c);const g=t();if(null!==g){const h=g.anchor,l=g.focus;null!==h&&h.key===d&&(ab(h,b,c,a,f),g.dirty=!0);null!==l&&l.key===
|
|
115
|
+
d&&(ab(l,b,c,a,f),g.dirty=!0)}this.setTextContent(b?a.__text+e:e+a.__text);a.remove();return this.getLatest()}}function P(a=""){return new cc(a)}function y(a){return a instanceof cc}
|
|
116
|
+
class jc{constructor(a,b){this.id=a;this._type="editorstate";this._editorState=b;this._editor=null}get(a){let b=this._editorState;"string"===typeof b&&(this._editorState=b=a.parseEditorState(b));return b}set(a,b){this._editorState=b;this._editor=a}toJSON(){const a=this._editorState;return{id:this.id,type:this._type,editorState:null===a||"string"===typeof a?a:JSON.stringify(a.toJSON())}}isEmpty(){return null===this._editorState}}function Ob(a,b){return new jc(a,b)}exports.$createLineBreakNode=Sa;
|
|
117
|
+
exports.$createNodeFromParse=function(a,b){G();const c=C();return Nb(a,b,c,null)};exports.$createSelection=function(){const a=O("root",0,"element"),b=O("root",0,"element");return new Qa(a,b,0)};exports.$createTextNode=P;exports.$flushMutations=function(){G();const a=C();ra(a)};exports.$getCompositionKey=J;exports.$getNearestNodeFromDOMNode=oa;exports.$getNodeByKey=I;exports.$getPreviousSelection=function(){return C()._editorState._selection};exports.$getRoot=Ia;exports.$getSelection=t;
|
|
118
|
+
exports.$isDecoratorNode=v;exports.$isElementNode=D;exports.$isLeafNode=Ca;exports.$isLineBreakNode=Da;exports.$isRootNode=R;exports.$isTextNode=y;exports.$log=na;exports.$setCompositionKey=F;exports.$setSelection=qa;exports.DecoratorNode=fb;exports.ElementNode=eb;exports.TextNode=cc;exports.VERSION="0.1.0";
|
|
119
|
+
exports.createEditor=function(a){var b=a||{};a=b.theme||{};const c=b.context||{},d=b.parentEditor||null,e=b.htmlTransforms||{},f=ib();b=b.initialEditorState;a=new bc(f,d,{context:c,theme:a,htmlTransforms:e});void 0!==b&&(a._pendingEditorState=b,a._dirtyType=2);return a};exports.createEditorStateRef=Ob;exports.isEditorStateRef=function(a){return a instanceof jc};
|
package/LinkNode.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var d=require("@lexical/core");function e(a,...b){b.forEach(c=>{null!=c&&"string"===typeof c&&a.classList.add(...c.split(" "))})}
|
|
2
|
+
class f extends d.ElementNode{static getType(){return"link"}static clone(a){return new f(a.__url,a.__key)}constructor(a,b){super(b);this.__url=a}createDOM(a){const b=document.createElement("a");b.href=this.__url;e(b,a.theme.link);return b}updateDOM(a,b){const c=this.__url;c!==a.__url&&(b.href=c);return!1}getURL(){return this.getLatest().__url}setURL(a){this.getWritable().__url=a}insertNewAfter(a){a=this.getParentOrThrow().insertNewAfter(a);if(null!==a){const b=g(this.__url);a.append(b);return b}return null}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}}
|
|
3
|
+
function g(a){return new f(a)}exports.$createLinkNode=g;exports.$isLinkNode=function(a){return a instanceof f};exports.LinkNode=f;
|
package/ListItemNode.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use strict';var f=require("@lexical/core"),g=require("@lexical/core/ParagraphNode"),l=require("@lexical/core/ListNode"),m=require("@lexical/core/ListItemNode");function n(a){throw Error(`Minified Lexical error #${a}; see codes.json for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}function p(a,...c){c.forEach(b=>{null!=b&&"string"===typeof b&&a.classList.add(...b.split(" "))})}
|
|
2
|
+
function q(a,...c){c.forEach(b=>{a.classList.remove(...b.split(" "))})}
|
|
3
|
+
class r extends f.ElementNode{static getType(){return"listitem"}static clone(a){return new r(a.__key)}constructor(a){super(a)}createDOM(a){const c=document.createElement("li");c.value=t(this);u(c,a.theme,this);return c}updateDOM(a,c,b){c.value=t(this);u(c,b.theme,this);return!1}append(...a){for(let c=0;c<a.length;c++){const b=a[c];if(f.$isElementNode(b)&&this.canMergeWith(b)){const d=b.getChildren();this.append(...d);b.remove()}else super.append(b)}return this}replace(a){if(v(a))return super.replace(a);const c=
|
|
4
|
+
this.getParentOrThrow();if(l.$isListNode(c)){var b=c.__children;const e=b.length;var d=b.indexOf(this.__key);if(0===d)c.insertBefore(a);else if(d===e-1)c.insertAfter(a);else{b=l.$createListNode(c.__tag);const h=c.getChildren();for(d+=1;d<e;d++)b.append(h[d]);c.insertAfter(a);a.insertAfter(b)}this.remove();1===e&&c.remove()}return a}insertAfter(a){var c=this.getNextSiblings();if(v(a))return c.forEach(d=>d.markDirty()),super.insertAfter(a);var b=this.getParentOrThrow();l.$isListNode(b)||n(1);if(l.$isListNode(a)&&
|
|
5
|
+
a.getTag()===b.getTag()){c=a;a=a.getChildren();for(b=a.length-1;0<=b;b--)c=a[b],this.insertAfter(c);return c}b.insertAfter(a);if(0!==c.length){const d=l.$createListNode(b.getTag());c.forEach(e=>d.append(e));a.insertAfter(d)}return a}insertNewAfter(){var a=this.getNextSibling();const c=this.getPreviousSibling();var b=this.getParent();l.$isListNode(b)||n(2);for(var d=b;null!==d;)d=d.getParent(),l.$isListNode(d)&&(b=d);d=!0;var e=this.getFirstChild();if(l.$isListNode(e))d=!1;else for(e=this;null!==e;)m.$isListItemNode(e)&&
|
|
6
|
+
0<e.getNextSiblings().length&&(d=!1),e=e.getParent();f.$isElementNode(b)&&""===this.getTextContent()&&(null===c||null===a)&&d?(null===a?(a=g.$createParagraphNode(),b.insertAfter(a)):(a=g.$createParagraphNode(),b.insertBefore(a)),this.remove(),b.isEmpty()&&b.remove()):(a=w(),this.insertAfter(a));return a}collapseAtStart(a){const c=g.$createParagraphNode();this.getChildren().forEach(h=>c.append(h));var b=this.getParentOrThrow(),d=b.getParentOrThrow();const e=v(d);1===b.getChildrenSize()?e?(b.remove(),
|
|
7
|
+
d.select()):(b.replace(c),b=a.anchor,a=a.focus,d=c.getKey(),"element"===b.type&&b.getNode().is(this)&&b.set(d,b.offset,"element"),"element"===a.type&&a.getNode().is(this)&&a.set(d,a.offset,"element")):(b.insertBefore(c),this.remove());return!0}canInsertAfter(a){return v(a)}canReplaceWith(a){return v(a)}canMergeWith(a){return g.$isParagraphNode(a)||v(a)}}function t(a){let c=1;a=a.getPreviousSiblings();for(let b=0;b<a.length;b++){const d=a[b];v(d)&&!l.$isListNode(d.getFirstChild())&&c++}return c}
|
|
8
|
+
function u(a,c,b){const d=[],e=[],h=(c=c.list)?c.listitem:void 0;if(c&&c.nested)var k=c.nested.listitem;void 0!==h&&(c=h.split(" "),d.push(...c));void 0!==k&&(k=k.split(" "),b.getChildren().some(x=>l.$isListNode(x))?d.push(...k):e.push(...k));0<d.length&&p(a,...d);0<e.length&&q(a,...e)}function w(){return new r}function v(a){return a instanceof r}exports.$createListItemNode=w;exports.$isListItemNode=v;exports.ListItemNode=r;
|
package/ListNode.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
'use strict';var f=require("@lexical/core"),h=require("@lexical/core/ListItemNode"),m=require("@lexical/core/ListNode");function n(b,...a){a.forEach(c=>{null!=c&&"string"===typeof c&&b.classList.add(...c.split(" "))})}function p(b,...a){a.forEach(c=>{b.classList.remove(...c.split(" "))})}
|
|
2
|
+
class t extends f.ElementNode{static getType(){return"list"}static clone(b){return new t(b.__tag,b.__start,b.__key)}constructor(b,a,c){super(c);this.__tag=b;this.__start=a}getTag(){return this.__tag}createDOM(b){const a=document.createElement(this.__tag);1!==this.__start&&a.setAttribute("start",String(this.__start));u(a,b.theme,this);return a}updateDOM(b,a,c){if(b.__tag!==this.__tag)return!0;u(a,c.theme,this);return!1}canBeEmpty(){return!1}append(...b){for(let c=0;c<b.length;c++){var a=b[c];if(h.$isListItemNode(a))super.append(a);
|
|
3
|
+
else{const e=h.$createListItemNode();v(a)?e.append(a):(a=f.$createTextNode(a.getTextContent()),e.append(a));super.append(e)}}return this}}
|
|
4
|
+
function u(b,a,c){const e=[],g=[];a=a.list;if(void 0!==a){a:{var k=1;for(var d=c.getParent();null!=d;){if(h.$isListItemNode(d)){d=d.getParent();if(m.$isListNode(d)){k++;d=d.getParent();continue}throw Error("Minified Lexical error #2; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");}break a}}d=k%5;const q=a[c.__tag+(0===d?5:d)],r=a[c.__tag];let l;a=a.nested;void 0!==a&&a.list&&(l=a.list);void 0!==r&&e.push(r);if(void 0!==
|
|
5
|
+
q)for(a=q.split(" "),e.push(...a),a=1;6>a;a++)a!==d&&g.push(c.__tag+a);void 0!==l&&(c=l.split(" "),1<k?e.push(...c):g.push(...c))}0<e.length&&n(b,...e);0<g.length&&p(b,...g)}function v(b){return b instanceof t}exports.$createListNode=function(b,a=1){return new t(b,a)};exports.$isListNode=v;exports.ListNode=t;
|
package/ParagraphNode.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var c=require("@lexical/core");function d(a,...b){b.forEach(e=>{null!=e&&"string"===typeof e&&a.classList.add(...e.split(" "))})}
|
|
2
|
+
class f extends c.ElementNode{static getType(){return"paragraph"}static clone(a){return new f(a.__key)}constructor(a){super(a)}createDOM(a){const b=document.createElement("p");d(b,a.theme.paragraph);return b}updateDOM(){return!1}insertNewAfter(){const a=g(),b=this.getDirection();a.setDirection(b);this.insertAfter(a);return a}collapseAtStart(){var a=this.getChildren();const b=this.getNextSibling();return c.$isElementNode(b)&&0===this.getIndexWithinParent()&&(0===a.length||c.$isTextNode(a[0])&&""===
|
|
3
|
+
a[0].getTextContent().trim())?(a=b.getFirstChild(),c.$isTextNode(a)?a.select(0,0):b.select(0,0),this.remove(),!0):!1}}function g(){return new f}exports.$createParagraphNode=g;exports.$isParagraphNode=function(a){return a instanceof f};exports.ParagraphNode=f;
|
package/QuoteNode.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var c=require("@lexical/core"),e=require("@lexical/core/ParagraphNode");function f(a,...b){b.forEach(d=>{null!=d&&"string"===typeof d&&a.classList.add(...d.split(" "))})}
|
|
2
|
+
class g extends c.ElementNode{static getType(){return"quote"}static clone(a){return new g(a.__key)}constructor(a){super(a)}createDOM(a){const b=document.createElement("blockquote");f(b,a.theme.quote);return b}updateDOM(){return!1}insertNewAfter(){const a=e.$createParagraphNode(),b=this.getDirection();a.setDirection(b);this.insertAfter(a);return a}collapseAtStart(){const a=e.$createParagraphNode();this.getChildren().forEach(b=>a.append(b));this.replace(a);return!0}}exports.$createQuoteNode=function(){return new g};
|
|
3
|
+
exports.$isQuoteNode=function(a){return a instanceof g};exports.QuoteNode=g;
|
package/README.md
CHANGED
|
@@ -1,39 +1,5 @@
|
|
|
1
|
-
lexical
|
|
2
|
-
===
|
|
1
|
+
# `@lexical/core`
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
Lexical is an extensible JavaScript text-editor that provides reliable, accessible and performant typing experiences for the web.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
```bash
|
|
9
|
-
$ sudo npm install lexical -g
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
## Quick Start
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
$ lexical xdf
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## License
|
|
19
|
-
|
|
20
|
-
The MIT License (MIT)
|
|
21
|
-
|
|
22
|
-
Copyright (c) 2013 xdf
|
|
23
|
-
|
|
24
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
25
|
-
this software and associated documentation files (the "Software"), to deal in
|
|
26
|
-
the Software without restriction, including without limitation the rights to
|
|
27
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
28
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
29
|
-
subject to the following conditions:
|
|
30
|
-
|
|
31
|
-
The above copyright notice and this permission notice shall be included in all
|
|
32
|
-
copies or substantial portions of the Software.
|
|
33
|
-
|
|
34
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
35
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
36
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
37
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
38
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
39
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
5
|
+
The `@lexical/core` package contains only the core Lexical engine and nodes. This package is intended to be used in conjunction with packages that wire Lexical up to applications, such as `@lexical/react`.
|
package/TableCellNode.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var c=require("@lexical/core");function e(a,...b){b.forEach(d=>{null!=d&&"string"===typeof d&&a.classList.add(...d.split(" "))})}
|
|
2
|
+
class f extends c.ElementNode{static getType(){return"table-cell"}static clone(a){return new f(!1,a.__key)}constructor(a=!1,b){super(b);this.__isHeader=a}getTag(){return this.__isHeader?"th":"td"}createDOM(a){const b=document.createElement(this.getTag());e(b,a.theme.tableCell,!0===this.__isHeader&&a.theme.tableCellHeader);return b}updateDOM(){return!1}collapseAtStart(){return!0}canSelectionRemove(){return!1}}exports.$createTableCellNode=function(a){return new f(a)};
|
|
3
|
+
exports.$isTableCellNode=function(a){return a instanceof f};exports.TableCellNode=f;
|
package/TableNode.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use strict';var r=require("@lexical/core");function v(a,...e){e.forEach(g=>{null!=g&&"string"===typeof g&&a.classList.add(...g.split(" "))})}const x=document.createElement("style");x.appendChild(document.createTextNode("::selection{background-color: transparent}"));function A(a){for(;null!=a;){const e=a.nodeName;if("TD"===e||"TH"===e){a=a._cell;if(void 0===a)break;return a}a=a.parentNode}return null}
|
|
2
|
+
function B(a){const e=[],g={rows:0,columns:0,cells:e};(new MutationObserver(b=>{var d=a.firstChild;let h=0,f=0,n=!1;for(let k=0;k<b.length;k++){const l=b[k].target.nodeName;if("TABLE"===l||"TR"===l){n=!0;break}}if(n){for(e.length=0;null!=d;){b=d.nodeName;if("TD"===b||"TH"===b)b={elem:d,highlighted:!1,x:h,y:f},d._cell=b,void 0===e[f]&&(e[f]=[]),e[f][h]=b;else if(b=d.firstChild,null!=b){d=b;continue}b=d.nextSibling;if(null!=b)h++,d=b;else if(b=d.parentNode,null!=b){d=b.nextSibling;if(null==d)break;
|
|
3
|
+
f++;h=0}}g.columns=h+1;g.rows=f+1}})).observe(a,{childList:!0,subtree:!0});return g}function C(a,e,g,b,d){const h=[];for(let f=0;f<d.length;f++){const n=d[f];for(let k=0;k<n.length;k++){const l=n[k],q=l.elem.style;k>=a&&k<=e&&f>=g&&f<=b?(l.highlighted||(l.highlighted=!0,q.setProperty("background-color","rgb(163, 187, 255)"),q.setProperty("caret-color","transparent")),h.push(l)):l.highlighted&&(l.highlighted=!1,q.removeProperty("background-color"),q.removeProperty("caret-color"))}}return h}
|
|
4
|
+
function D(a,e,g){const b=B(e);if(null!==g.getRootElement()){var d=!1,h=!1,f=-1,n=-1,k=-1,l=-1,q=[];e.addEventListener("mousemove",m=>{if(d){var c=A(m.target);if(null!==c){m.preventDefault();m=c.x;c=c.y;if(!h&&(f!==m||n!==c)){const t=window.getSelection();t.setBaseAndExtent(t.anchorNode,0,t.anchorNode,0);h=!0;document.body&&document.body.appendChild(x);null===u&&(u=g.addListener("command",(w,y)=>{if("deleteCharacter"===w){if(q.length===b.columns*b.rows)return a.selectPrevious(),a.remove(),z(),!0;
|
|
5
|
+
q.forEach(({elem:p})=>{p=r.$getNearestNodeFromDOMNode(p);r.$isElementNode(p)&&p.clear()});return!0}return"formatText"===w?(F(y),!0):!1},1))}else if(m===k&&c===l)return;k=m;l=c;h&&(q=C(Math.min(f,k),Math.max(f,k),Math.min(n,l),Math.max(n,l),b.cells))}}});var z=()=>{d=h=!1;l=k=n=f=-1;C(-1,-1,-1,-1,b.cells);q=[];null!==u&&(u(),u=null);const m=x.parentNode;null!=m&&m.removeChild(x)};e.addEventListener("mouseleave",()=>{});var F=m=>{let c=r.$getSelection();null===c&&(c=r.$createSelection());const t=c,
|
|
6
|
+
w=t.anchor,y=t.focus;q.forEach(p=>{p=r.$getNearestNodeFromDOMNode(p.elem);r.$isElementNode(p)&&(w.set(p.getKey(),0,"element"),y.set(p.getKey(),p.getChildrenSize(),"element"),t.formatText(m))});c.anchor.set(c.anchor.key,c.anchor.offset,c.anchor.type);c.focus.set(c.anchor.key,c.anchor.offset,c.anchor.type);r.$setSelection(c)},u=null;e.addEventListener("mousedown",m=>{d?h&&z():setTimeout(()=>{h&&z();const c=A(m.target);null!==c&&(d=!0,f=c.x,n=c.y,document.addEventListener("mouseup",()=>{d=!1},{capture:!0,
|
|
7
|
+
once:!0}))},0)})}}class E extends r.ElementNode{static getType(){return"table"}static clone(a){return new E(a.__key)}constructor(a){super(a)}createDOM(a,e){const g=document.createElement("table");v(g,a.theme.table);D(this,g,e);return g}updateDOM(){return!1}canExtractContents(){return!1}canBeEmpty(){return!1}}exports.$createTableNode=function(){return new E};exports.$isTableNode=function(a){return a instanceof E};exports.TableNode=E;
|
package/TableRowNode.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var c=require("@lexical/core");function e(a,...b){b.forEach(d=>{null!=d&&"string"===typeof d&&a.classList.add(...d.split(" "))})}class f extends c.ElementNode{static getType(){return"table-row"}static clone(a){return new f(a.__key)}constructor(a){super(a)}createDOM(a){const b=document.createElement("tr");e(b,a.theme.tableRow);return b}updateDOM(){return!1}canBeEmpty(){return!1}canSelectionRemove(){return!1}}exports.$createTableRowNode=function(){return new f};
|
|
2
|
+
exports.$isTableRowNode=function(a){return a instanceof f};exports.TableRowNode=f;
|
package/package.json
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lexical",
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"lexical": "./bin/lexical"
|
|
7
|
-
},
|
|
8
|
-
"main": "index.js",
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git://github.com/xudafeng/lexical.git"
|
|
12
|
-
},
|
|
13
|
-
"dependencies": {
|
|
3
|
+
"author": {
|
|
4
|
+
"name": "Dominic Gannaway",
|
|
5
|
+
"email": "dg@domgan.com"
|
|
14
6
|
},
|
|
7
|
+
"description": "Lexical is an extensible text editor library that provides excellent reliability, accessible and performance.",
|
|
15
8
|
"keywords": [
|
|
9
|
+
"react",
|
|
10
|
+
"lexical",
|
|
11
|
+
"editor",
|
|
12
|
+
"contenteditable",
|
|
13
|
+
"rich-text"
|
|
16
14
|
],
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"version": "0.1.0",
|
|
17
|
+
"main": "Lexical.js",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/facebook/lexical",
|
|
21
|
+
"directory": "packages/lexical-core"
|
|
22
|
+
}
|
|
23
|
+
}
|
package/.npmignore
DELETED
package/.travis.yml
DELETED
package/HISTORY
DELETED
|
File without changes
|
package/Makefile
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
TESTS = test/*.test.js
|
|
2
|
-
TIMEOUT = 1000
|
|
3
|
-
MOCHA_OPTS =
|
|
4
|
-
|
|
5
|
-
install:
|
|
6
|
-
@npm install --registry=http://r.cnpmjs.org --disturl=http://dist.cnpmjs.org
|
|
7
|
-
|
|
8
|
-
jshint: install
|
|
9
|
-
@./node_modules/.bin/jshint .
|
|
10
|
-
|
|
11
|
-
test: install
|
|
12
|
-
@NODE_ENV=test ./node_modules/.bin/mocha \
|
|
13
|
-
--harmony \
|
|
14
|
-
--reporter $(REPORTER) \
|
|
15
|
-
--timeout $(TIMEOUT) \
|
|
16
|
-
$(MOCHA_OPTS) \
|
|
17
|
-
$(TESTS)
|
|
18
|
-
|
|
19
|
-
test-cov cov: install
|
|
20
|
-
@NODE_ENV=test node --harmony \
|
|
21
|
-
node_modules/.bin/istanbul cover --preserve-comments \
|
|
22
|
-
./node_modules/.bin/_mocha \
|
|
23
|
-
-- -u exports \
|
|
24
|
-
--reporter $(REPORTER) \
|
|
25
|
-
--timeout $(TIMEOUT) \
|
|
26
|
-
$(MOCHA_OPTS) \
|
|
27
|
-
$(TESTS)
|
|
28
|
-
@./node_modules/.bin/cov coverage
|
package/bin/lexical
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/* ================================================================
|
|
3
|
-
* killing by xdf(xudafeng[at]126.com)
|
|
4
|
-
*
|
|
5
|
-
* first created at : Thu Jun 12 2014 01:24:59 GMT+0800 (CST)
|
|
6
|
-
*
|
|
7
|
-
* ================================================================
|
|
8
|
-
* Copyright 2013 xdf
|
|
9
|
-
*
|
|
10
|
-
* Licensed under the MIT License
|
|
11
|
-
* You may not use this file except in compliance with the License.
|
|
12
|
-
*
|
|
13
|
-
* ================================================================ */
|
|
14
|
-
|
|
15
|
-
"use strict";
|
|
16
|
-
|
|
17
|
-
module.exports = require('../lib/lexical');
|
|
18
|
-
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./lib/lexical');
|
package/lib/lexical.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/* ================================================================
|
|
2
|
-
* killing by xdf(xudafeng[at]126.com)
|
|
3
|
-
*
|
|
4
|
-
* first created at : Thu Jun 12 2014 01:24:59 GMT+0800 (CST)
|
|
5
|
-
*
|
|
6
|
-
* ================================================================
|
|
7
|
-
* Copyright 2014 xdf
|
|
8
|
-
*
|
|
9
|
-
* Licensed under the MIT License
|
|
10
|
-
* You may not use this file except in compliance with the License.
|
|
11
|
-
*
|
|
12
|
-
* ================================================================ */
|
|
13
|
-
|
|
14
|
-
"use strict";
|
|
15
|
-
|
|
16
|
-
var exec = require('child_process').exec;
|
|
17
|
-
var p = process.argv[2];
|
|
18
|
-
|
|
19
|
-
var WRAP = '\n';
|
|
20
|
-
var BLANK = ' ';
|
|
21
|
-
|
|
22
|
-
if(!p){
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function filter(list){
|
|
27
|
-
var a = [];
|
|
28
|
-
list.forEach(function(i){
|
|
29
|
-
if(!!i){
|
|
30
|
-
a.push(i);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
return a;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
exec('ps -ef | grep ' + p, function (error, stdout) {
|
|
37
|
-
if(error) throw error;
|
|
38
|
-
|
|
39
|
-
var items = stdout.split(WRAP);
|
|
40
|
-
var list = [];
|
|
41
|
-
|
|
42
|
-
items.forEach(function(i){
|
|
43
|
-
var content = i.split(BLANK);
|
|
44
|
-
content = filter(content);
|
|
45
|
-
content = content.reverse();
|
|
46
|
-
|
|
47
|
-
if(!!content[0]){
|
|
48
|
-
|
|
49
|
-
if(!new RegExp('grep|kill').test(content[1])){
|
|
50
|
-
content = content.reverse();
|
|
51
|
-
list.push(content[1]);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
if(!list.length){
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
exec('sudo kill -SIGKILL ' + list.join(BLANK), function(error){
|
|
61
|
-
if(error) throw error;
|
|
62
|
-
|
|
63
|
-
list.forEach(function(i){
|
|
64
|
-
console.log('PID: \x1B[36m' + i + '\x1B[39m has been killed.');
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
package/test/lexical.test.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/* ================================================================
|
|
2
|
-
* lexical by xdf(xudafeng[at]126.com)
|
|
3
|
-
*
|
|
4
|
-
* first created at : Fri Jun 13 2014 14:09:02 GMT+0800 (CST)
|
|
5
|
-
*
|
|
6
|
-
* ================================================================
|
|
7
|
-
* Copyright 2013 xdf
|
|
8
|
-
*
|
|
9
|
-
* Licensed under the MIT License
|
|
10
|
-
* You may not use this file except in compliance with the License.
|
|
11
|
-
*
|
|
12
|
-
* ================================================================ */
|
|
13
|
-
|
|
14
|
-
"use strict";
|
|
15
|
-
|
|
16
|
-
var lexical = require('../');
|
|
17
|
-
|
|
18
|
-
describe('', function(){
|
|
19
|
-
});
|
package/test/mocha.opt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
--require should
|