lexical 0.3.7 → 0.3.8
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.dev.js +28 -70
- package/Lexical.prod.js +63 -64
- package/LexicalCommands.d.ts +4 -4
- package/LexicalConstants.d.ts +1 -0
- package/LexicalEditor.d.ts +23 -2
- package/LexicalUtils.d.ts +2 -2
- package/LexicalVersion.d.ts +1 -1
- package/index.d.ts +1 -1
- package/package.json +1 -1
package/Lexical.dev.js
CHANGED
|
@@ -115,7 +115,8 @@ const IS_STRIKETHROUGH = 1 << 2;
|
|
|
115
115
|
const IS_UNDERLINE = 1 << 3;
|
|
116
116
|
const IS_CODE = 1 << 4;
|
|
117
117
|
const IS_SUBSCRIPT = 1 << 5;
|
|
118
|
-
const IS_SUPERSCRIPT = 1 << 6;
|
|
118
|
+
const IS_SUPERSCRIPT = 1 << 6;
|
|
119
|
+
const IS_ALL_FORMATTING = IS_BOLD | IS_ITALIC | IS_STRIKETHROUGH | IS_UNDERLINE | IS_CODE | IS_SUBSCRIPT | IS_SUPERSCRIPT; // Text node details
|
|
119
120
|
|
|
120
121
|
const IS_DIRECTIONLESS = 1;
|
|
121
122
|
const IS_UNMERGEABLE = 1 << 1; // Element node formatting
|
|
@@ -125,10 +126,11 @@ const IS_ALIGN_CENTER = 2;
|
|
|
125
126
|
const IS_ALIGN_RIGHT = 3;
|
|
126
127
|
const IS_ALIGN_JUSTIFY = 4; // Reconciliation
|
|
127
128
|
|
|
128
|
-
const NON_BREAKING_SPACE = '\u00A0';
|
|
129
|
+
const NON_BREAKING_SPACE = '\u00A0';
|
|
130
|
+
const ZERO_WIDTH_SPACE = '\u200b'; // For iOS/Safari we use a non breaking space, otherwise the cursor appears
|
|
129
131
|
// overlapping the composed text.
|
|
130
132
|
|
|
131
|
-
const COMPOSITION_SUFFIX = IS_SAFARI || IS_IOS ? NON_BREAKING_SPACE :
|
|
133
|
+
const COMPOSITION_SUFFIX = IS_SAFARI || IS_IOS ? NON_BREAKING_SPACE : ZERO_WIDTH_SPACE;
|
|
132
134
|
const DOUBLE_LINE_BREAK = '\n\n'; // For FF, we need to use a non-breaking space, or it gets composition
|
|
133
135
|
// in a stuck state.
|
|
134
136
|
|
|
@@ -2153,16 +2155,20 @@ function onSelectionChange(domSelection, editor, isActive) {
|
|
|
2153
2155
|
}
|
|
2154
2156
|
}
|
|
2155
2157
|
} else {
|
|
2156
|
-
|
|
2157
|
-
const
|
|
2158
|
-
|
|
2158
|
+
let combinedFormat = IS_ALL_FORMATTING;
|
|
2159
|
+
const nodes = selection.getNodes();
|
|
2160
|
+
const nodesLength = nodes.length;
|
|
2159
2161
|
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
}
|
|
2162
|
+
for (let i = 0; i < nodesLength; i++) {
|
|
2163
|
+
const node = nodes[i];
|
|
2163
2164
|
|
|
2164
|
-
|
|
2165
|
-
|
|
2165
|
+
if ($isTextNode(node)) {
|
|
2166
|
+
combinedFormat &= node.getFormat();
|
|
2167
|
+
|
|
2168
|
+
if (combinedFormat === 0) {
|
|
2169
|
+
break;
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2166
2172
|
}
|
|
2167
2173
|
|
|
2168
2174
|
selection.format = combinedFormat;
|
|
@@ -2239,41 +2245,6 @@ function onBeforeInput(event, editor) {
|
|
|
2239
2245
|
IS_FIREFOX && isFirefoxClipboardEvents()) {
|
|
2240
2246
|
return;
|
|
2241
2247
|
} else if (inputType === 'insertCompositionText') {
|
|
2242
|
-
// This logic handles insertion of text between different
|
|
2243
|
-
// format text types. We have to detect a change in type
|
|
2244
|
-
// during composition and see if the previous text contains
|
|
2245
|
-
// part of the composed text to work out the actual text that
|
|
2246
|
-
// we need to insert.
|
|
2247
|
-
const composedText = event.data; // TODO: evaluate if this is Android only. It doesn't always seem
|
|
2248
|
-
// to have any real impact, so could probably be refactored or removed
|
|
2249
|
-
// for an alternative approach.
|
|
2250
|
-
|
|
2251
|
-
if (composedText) {
|
|
2252
|
-
updateEditor(editor, () => {
|
|
2253
|
-
const selection = $getSelection();
|
|
2254
|
-
|
|
2255
|
-
if ($isRangeSelection(selection)) {
|
|
2256
|
-
const anchor = selection.anchor;
|
|
2257
|
-
const node = anchor.getNode();
|
|
2258
|
-
const prevNode = node.getPreviousSibling();
|
|
2259
|
-
|
|
2260
|
-
if (anchor.offset === 0 && $isTextNode(node) && $isTextNode(prevNode) && node.getTextContent() === COMPOSITION_START_CHAR && prevNode.getFormat() !== selection.format) {
|
|
2261
|
-
const prevTextContent = prevNode.getTextContent();
|
|
2262
|
-
|
|
2263
|
-
if (composedText.indexOf(prevTextContent) === 0) {
|
|
2264
|
-
const insertedText = composedText.slice(prevTextContent.length);
|
|
2265
|
-
dispatchCommand(editor, CONTROLLED_TEXT_INSERTION_COMMAND, insertedText);
|
|
2266
|
-
setTimeout(() => {
|
|
2267
|
-
updateEditor(editor, () => {
|
|
2268
|
-
node.select();
|
|
2269
|
-
});
|
|
2270
|
-
}, ANDROID_COMPOSITION_LATENCY);
|
|
2271
|
-
}
|
|
2272
|
-
}
|
|
2273
|
-
}
|
|
2274
|
-
});
|
|
2275
|
-
}
|
|
2276
|
-
|
|
2277
2248
|
return;
|
|
2278
2249
|
}
|
|
2279
2250
|
|
|
@@ -2336,7 +2307,7 @@ function onBeforeInput(event, editor) {
|
|
|
2336
2307
|
if (inputType === 'insertText') {
|
|
2337
2308
|
if (data === '\n') {
|
|
2338
2309
|
event.preventDefault();
|
|
2339
|
-
dispatchCommand(editor, INSERT_LINE_BREAK_COMMAND,
|
|
2310
|
+
dispatchCommand(editor, INSERT_LINE_BREAK_COMMAND, false);
|
|
2340
2311
|
} else if (data === DOUBLE_LINE_BREAK) {
|
|
2341
2312
|
event.preventDefault();
|
|
2342
2313
|
dispatchCommand(editor, INSERT_PARAGRAPH_COMMAND, undefined);
|
|
@@ -2379,7 +2350,7 @@ function onBeforeInput(event, editor) {
|
|
|
2379
2350
|
{
|
|
2380
2351
|
// Used for Android
|
|
2381
2352
|
$setCompositionKey(null);
|
|
2382
|
-
dispatchCommand(editor, INSERT_LINE_BREAK_COMMAND,
|
|
2353
|
+
dispatchCommand(editor, INSERT_LINE_BREAK_COMMAND, false);
|
|
2383
2354
|
break;
|
|
2384
2355
|
}
|
|
2385
2356
|
|
|
@@ -2391,7 +2362,7 @@ function onBeforeInput(event, editor) {
|
|
|
2391
2362
|
|
|
2392
2363
|
if (isInsertLineBreak) {
|
|
2393
2364
|
isInsertLineBreak = false;
|
|
2394
|
-
dispatchCommand(editor, INSERT_LINE_BREAK_COMMAND,
|
|
2365
|
+
dispatchCommand(editor, INSERT_LINE_BREAK_COMMAND, false);
|
|
2395
2366
|
} else {
|
|
2396
2367
|
dispatchCommand(editor, INSERT_PARAGRAPH_COMMAND, undefined);
|
|
2397
2368
|
}
|
|
@@ -4335,7 +4306,7 @@ class RangeSelection {
|
|
|
4335
4306
|
if (selectedNodesLength === 0) {
|
|
4336
4307
|
return [];
|
|
4337
4308
|
} else if (selectedNodesLength === 1) {
|
|
4338
|
-
if ($isTextNode(firstNode)) {
|
|
4309
|
+
if ($isTextNode(firstNode) && !this.isCollapsed()) {
|
|
4339
4310
|
const startOffset = anchorOffset > focusOffset ? focusOffset : anchorOffset;
|
|
4340
4311
|
const endOffset = anchorOffset > focusOffset ? anchorOffset : focusOffset;
|
|
4341
4312
|
const splitNodes = firstNode.splitText(startOffset, endOffset);
|
|
@@ -7846,6 +7817,10 @@ class TextNode extends LexicalNode {
|
|
|
7846
7817
|
conversion: convertBringAttentionToElement,
|
|
7847
7818
|
priority: 0
|
|
7848
7819
|
}),
|
|
7820
|
+
code: node => ({
|
|
7821
|
+
conversion: convertTextFormatElement,
|
|
7822
|
+
priority: 0
|
|
7823
|
+
}),
|
|
7849
7824
|
em: node => ({
|
|
7850
7825
|
conversion: convertTextFormatElement,
|
|
7851
7826
|
priority: 0
|
|
@@ -8205,11 +8180,7 @@ function convertSpanElement(domNode) {
|
|
|
8205
8180
|
|
|
8206
8181
|
const hasUnderlineTextDecoration = span.style.textDecoration === 'underline'; // Google Docs uses span tags + vertical-align to specify subscript and superscript
|
|
8207
8182
|
|
|
8208
|
-
const verticalAlign = span.style.verticalAlign;
|
|
8209
|
-
|
|
8210
|
-
const backgroundColor = span.style.backgroundColor;
|
|
8211
|
-
const textColor = span.style.color; //TODO: font-size and coloring of subscript & superscript
|
|
8212
|
-
|
|
8183
|
+
const verticalAlign = span.style.verticalAlign;
|
|
8213
8184
|
return {
|
|
8214
8185
|
forChild: lexicalNode => {
|
|
8215
8186
|
if (!$isTextNode(lexicalNode)) {
|
|
@@ -8240,20 +8211,6 @@ function convertSpanElement(domNode) {
|
|
|
8240
8211
|
lexicalNode.toggleFormat('superscript');
|
|
8241
8212
|
}
|
|
8242
8213
|
|
|
8243
|
-
let cssString = '';
|
|
8244
|
-
|
|
8245
|
-
if (textColor && textColor !== 'rgb(0, 0, 0)') {
|
|
8246
|
-
cssString += `color: ${textColor};`;
|
|
8247
|
-
}
|
|
8248
|
-
|
|
8249
|
-
if (backgroundColor && backgroundColor !== 'transparent') {
|
|
8250
|
-
cssString += `background-color: ${backgroundColor};`;
|
|
8251
|
-
}
|
|
8252
|
-
|
|
8253
|
-
if (cssString !== '') {
|
|
8254
|
-
lexicalNode.setStyle(cssString);
|
|
8255
|
-
}
|
|
8256
|
-
|
|
8257
8214
|
return lexicalNode;
|
|
8258
8215
|
},
|
|
8259
8216
|
node: null
|
|
@@ -8297,6 +8254,7 @@ function convertTextDOMNode(domNode) {
|
|
|
8297
8254
|
}
|
|
8298
8255
|
|
|
8299
8256
|
const nodeNameToTextFormat = {
|
|
8257
|
+
code: 'code',
|
|
8300
8258
|
em: 'italic',
|
|
8301
8259
|
i: 'italic',
|
|
8302
8260
|
strong: 'bold',
|
|
@@ -8961,7 +8919,7 @@ class LexicalEditor {
|
|
|
8961
8919
|
* LICENSE file in the root directory of this source tree.
|
|
8962
8920
|
*
|
|
8963
8921
|
*/
|
|
8964
|
-
const VERSION = '0.3.
|
|
8922
|
+
const VERSION = '0.3.8';
|
|
8965
8923
|
|
|
8966
8924
|
/**
|
|
8967
8925
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
package/Lexical.prod.js
CHANGED
|
@@ -4,22 +4,22 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
'use strict';let aa={},ba={},ca={},
|
|
7
|
+
'use strict';let aa={},ba={},ca={},ea={},fa={},ha={},ja={},ka={},la={},ma={},q={},na={},oa={},pa={},qa={},ra={},sa={},wa={},xa={},ya={},za={},Aa={},Ba={},Ca={},Da={},Ea={},Fa={},Ga={},Ha={},Ia={},Ja={},Ka={},La={},Ma={};function t(a){throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?code=${a} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
|
|
8
8
|
let Na="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,Qa=Na&&"documentMode"in document?document.documentMode:null,u=Na&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Ra=Na&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Sa=Na&&"InputEvent"in window&&!Qa?"getTargetRanges"in new window.InputEvent("input"):!1,Ta=Na&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Ua=Na&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&
|
|
9
9
|
!window.MSStream,Va=Ta||Ua?"\u00a0":"\u200b",Wa=Ra?"\u00a0":Va,Xa=/^[^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]/,Ya=/^[^\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]/,Za={bold:1,code:16,italic:2,strikethrough:4,subscript:32,superscript:64,underline:8},$a={directionless:1,
|
|
10
10
|
unmergeable:2},ab={center:2,justify:4,left:1,right:3},bb={2:"center",4:"justify",1:"left",3:"right"},cb={inert:3,normal:0,segmented:2,token:1},db={3:"inert",0:"normal",2:"segmented",1:"token"},eb=!1,fb=0;function gb(a){fb=a.timeStamp}function hb(a,b,c){return b.__lexicalLineBreak===a||void 0!==a[`__lexicalKey_${c._key}`]}function ib(a){return a.getEditorState().read(()=>{let b=v();return null!==b?b.clone():null})}
|
|
11
|
-
function jb(a,b,c){eb=!0;let d=100<performance.now()-fb;try{x(a,()=>{let f=v()||ib(a);var e=new Map,g=a.getRootElement(),h=a._editorState;let k=!1,m="";for(var l=0;l<b.length;l++){var n=b[l],r=n.type,p=n.target,w=kb(p,h);if(!A(w))if("characterData"===r){if(n=d&&B(w))a:{n=f;r=p;var y=w;if(
|
|
12
|
-
p=p.nodeValue,null!==p&&lb(w,p,n,r,!1))}else if("childList"===r){k=!0;r=n.addedNodes;for(y=0;y<r.length;y++){z=r[y];var
|
|
13
|
-
e.length;h++)l=a.getElementByKey(e[h]),null!==l&&(null==g?(
|
|
11
|
+
function jb(a,b,c){eb=!0;let d=100<performance.now()-fb;try{x(a,()=>{let f=v()||ib(a);var e=new Map,g=a.getRootElement(),h=a._editorState;let k=!1,m="";for(var l=0;l<b.length;l++){var n=b[l],r=n.type,p=n.target,w=kb(p,h);if(!A(w))if("characterData"===r){if(n=d&&B(w))a:{n=f;r=p;var y=w;if(D(n)){var z=n.anchor.getNode();if(z.is(y)&&n.format!==z.getFormat()){n=!1;break a}}n=3===r.nodeType&&y.isAttached()}n&&(y=window.getSelection(),r=n=null,null!==y&&y.anchorNode===p&&(n=y.anchorOffset,r=y.focusOffset),
|
|
12
|
+
p=p.nodeValue,null!==p&&lb(w,p,n,r,!1))}else if("childList"===r){k=!0;r=n.addedNodes;for(y=0;y<r.length;y++){z=r[y];var C=mb(z),F=z.parentNode;null==F||null!==C||"BR"===z.nodeName&&hb(z,F,a)||(Ra&&(C=z.innerText||z.nodeValue)&&(m+=C),F.removeChild(z))}n=n.removedNodes;r=n.length;if(0<r){y=0;for(z=0;z<r;z++)F=n[z],"BR"===F.nodeName&&hb(F,p,a)&&(p.appendChild(F),y++);r!==y&&(p===g&&(w=h._nodeMap.get("root")),e.set(p,w))}}}if(0<e.size)for(let [da,R]of e)if(E(R))for(e=R.__children,g=da.firstChild,h=0;h<
|
|
13
|
+
e.length;h++)l=a.getElementByKey(e[h]),null!==l&&(null==g?(da.appendChild(l),g=l):g!==l&&da.replaceChild(l,g),g=g.nextSibling);else B(R)&&R.markDirty();e=c.takeRecords();if(0<e.length){for(g=0;g<e.length;g++)for(l=e[g],h=l.addedNodes,l=l.target,w=0;w<h.length;w++)p=h[w],n=p.parentNode,null==n||"BR"!==p.nodeName||hb(p,l,a)||n.removeChild(p);c.takeRecords()}null!==f&&(k&&(f.dirty=!0,ob(f)),Ra&&pb()&&f.insertRawText(m))})}finally{eb=!1}}
|
|
14
14
|
function qb(a){let b=a._observer;if(null!==b){let c=b.takeRecords();jb(a,c,b)}}function rb(a){0===fb&&window.addEventListener("textInput",gb,!0);a._observer=new MutationObserver((b,c)=>{jb(a,b,c)})}let sb=1,tb="function"===typeof queueMicrotask?queueMicrotask:a=>{Promise.resolve().then(a)};
|
|
15
15
|
function ub(a,b,c){let d=a.getRootElement();try{var f;if(f=null!==d&&d.contains(b)&&d.contains(c)&&null!==b){let e=document.activeElement,g=null!==e?e.nodeName:null;f=!A(kb(b))||"INPUT"!==g&&"TEXTAREA"!==g}return f&&vb(b)===a}catch(e){return!1}}function vb(a){for(;null!=a;){let b=a.__lexicalEditor;if(null!=b&&!b.isReadOnly())return b;a=a.parentNode}return null}function wb(a){return G(a)||a.isSegmented()}function G(a){return a.isToken()||a.isInert()}
|
|
16
16
|
function xb(a){for(;null!=a;){if(3===a.nodeType)return a;a=a.firstChild}return null}function yb(a,b,c){b=Za[b];return a&b&&(null===c||0===(c&b))?a^b:null===c||c&b?a|b:a}function zb(a){return B(a)||Ab(a)||A(a)}function Bb(a){var b=a.getParent();if(null!==b){b=b.getWritable().__children;let c=b.indexOf(a.__key);-1===c&&t(31);Cb(a);b.splice(c,1)}}
|
|
17
17
|
function Db(a){99<Eb&&t(14);var b=a.getLatest(),c=b.__parent,d=H();let f=I(),e=d._nodeMap;d=f._dirtyElements;if(null!==c)a:for(;null!==c;){if(d.has(c))break a;let g=e.get(c);if(void 0===g)break;d.set(c,!1);c=g.__parent}b=b.__key;f._dirtyType=1;E(a)?d.set(b,!0):f._dirtyLeaves.add(b)}function Cb(a){let b=a.getPreviousSibling();a=a.getNextSibling();null!==b&&Db(b);null!==a&&Db(a)}
|
|
18
|
-
function J(a){K();var b=I();let c=b._compositionKey;a!==c&&(b._compositionKey=a,null!==c&&(b=L(c),null!==b&&b.getWritable()),null!==a&&(a=L(a),null!==a&&a.getWritable()))}function L(a,b){a=(b||H())._nodeMap.get(a);return void 0===a?null:a}function
|
|
18
|
+
function J(a){K();var b=I();let c=b._compositionKey;a!==c&&(b._compositionKey=a,null!==c&&(b=L(c),null!==b&&b.getWritable()),null!==a&&(a=L(a),null!==a&&a.getWritable()))}function L(a,b){a=(b||H())._nodeMap.get(a);return void 0===a?null:a}function mb(a,b){let c=I();a=a[`__lexicalKey_${c._key}`];return void 0!==a?L(a,b):null}function kb(a,b){for(;null!=a;){let c=mb(a,b);if(null!==c)return c;a=a.parentNode}return null}
|
|
19
19
|
function Fb(a){let b=Object.assign({},a._decorators);return a._pendingDecorators=b}function Gb(a){return a.read(()=>Hb().getTextContent())}function Ib(a,b){x(a,()=>{var c=H();if(!c.isEmpty())if("root"===b)Hb().markDirty();else{c=c._nodeMap;for(let [,d]of c)d.markDirty()}},null===a._pendingEditorState?{tag:"history-merge"}:void 0)}function Hb(){return H()._nodeMap.get("root")}function ob(a){let b=H();null!==a&&(a.dirty=!0,a._cachedNodes=null);b._selection=a}
|
|
20
20
|
function Jb(a){var b=I(),c;a:{for(c=a;null!=c;){let 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?L("root"):null):L(c)}function Kb(a){let b=[];for(;null!==a;)b.push(a),a=a._parentEditor;return b}function Lb(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}
|
|
21
21
|
function Mb(a,b,c){a=window.getSelection();if(null!==a){var d=a.anchorNode,{anchorOffset:f,focusOffset:e}=a;if(null!==d&&3===d.nodeType&&(a=kb(d),B(a))){d=d.nodeValue;if(d===Va&&c){let g=c.length;d=c;e=f=g}null!==d&&lb(a,d,f,e,b)}}}
|
|
22
|
-
function lb(a,b,c,d,f){let e=a;if(e.isAttached()&&(f||!e.isDirty())){var g=e.isComposing();a=b;(g||f)&&b[b.length-1]===Va&&(a=b.slice(0,-1));b=e.getTextContent();if(f||a!==b)if(""===a)if(J(null),Ta||Ua)e.remove();else{let h=I();setTimeout(()=>{h.update(()=>{e.isAttached()&&e.remove()})},20)}else f=e.getParent(),b=Nb(),G(e)||null!==I()._compositionKey&&!g||null!==f&&
|
|
22
|
+
function lb(a,b,c,d,f){let e=a;if(e.isAttached()&&(f||!e.isDirty())){var g=e.isComposing();a=b;(g||f)&&b[b.length-1]===Va&&(a=b.slice(0,-1));b=e.getTextContent();if(f||a!==b)if(""===a)if(J(null),Ta||Ua)e.remove();else{let h=I();setTimeout(()=>{h.update(()=>{e.isAttached()&&e.remove()})},20)}else f=e.getParent(),b=Nb(),G(e)||null!==I()._compositionKey&&!g||null!==f&&D(b)&&!f.canInsertTextBefore()&&0===b.anchor.offset?e.markDirty():(g=v(),D(g)&&null!==c&&null!==d&&(g.setTextNodeRange(e,c,e,d),e.isSegmented()&&
|
|
23
23
|
(c=e.getTextContent(),c=M(c),e.replace(c),e=c)),e.setTextContent(a))}}
|
|
24
24
|
function Ob(a,b){var c=a.anchor,d=a.focus,f=c.getNode(),e=window.getSelection();e=null!==e?e.anchorNode:null;let g=c.key,h=I().getElementByKey(g);b=b.length;(c=g!==d.key||!B(f)||2>b&&c.offset!==d.offset&&!f.isComposing()||wb(f)||f.isDirty()&&1<b||null!==h&&!f.isComposing()&&e!==xb(h)||f.getFormat()!==a.format)||(f.isSegmented()?c=!0:a.isCollapsed()?(a=a.anchor.offset,c=f.getParentOrThrow(),d=f.isToken(),(b=0===a)&&!(b=!f.canInsertTextBefore()||!c.canInsertTextBefore()||d)&&(b=f.getPreviousSibling(),
|
|
25
25
|
b=(B(b)||E(b)&&b.isInline())&&!b.canInsertTextAfter()),f=f.getTextContentSize()===a&&(!f.canInsertTextBefore()||!c.canInsertTextBefore()||d),c=b||f):c=!1);return c}function Pb(a,b){var c=a[b];return"string"===typeof c?(c=c.split(" "),a[b]=c):c}function Qb(a,b,c,d,f){0!==c.size&&(c=d.__key,b=b.get(d.__type),void 0===b&&t(33),b=b.klass,d=a.get(b),void 0===d&&(d=new Map,a.set(b,d)),d.has(c)||d.set(c,f))}
|
|
@@ -27,44 +27,43 @@ function Rb(a,b,c){let d=a.getParent(),f=c;null!==d&&(b&&0===c?(f=a.getIndexWith
|
|
|
27
27
|
function pb(){var a=window.event;a=a&&a.inputType;return"insertFromPaste"===a||"insertFromPasteAsQuotation"===a}function Tb(a){return!N(a)&&!a.isLastChild()&&!a.isInline()}function Xb(a,b){a=a._keyToDOMMap.get(b);void 0===a&&t(34);return a}function Yb(a,b,c,d,f){a=a.__children;let e=a.length;for(let g=0;g<e;g++){let h=a[g],k=d.get(h);void 0!==k&&k.__parent===b&&(E(k)&&Yb(k,h,c,d,f),c.has(h)||f.delete(h),d.delete(h))}}
|
|
28
28
|
function Zb(a,b,c,d){a=a._nodeMap;b=b._nodeMap;for(let f of c){let e=b.get(f);void 0===e||e.isAttached()||(a.has(f)||c.delete(f),b.delete(f))}for(let [f]of d)c=b.get(f),void 0===c||c.isAttached()||(E(c)&&Yb(c,f,a,b,d),a.has(f)||d.delete(f),b.delete(f))}function $b(a,b){let c=a.__mode,d=a.__format;a=a.__style;let f=b.__mode,e=b.__format;b=b.__style;return(null===c||c===f)&&(null===d||d===e)&&(null===a||a===b)}
|
|
29
29
|
function ac(a,b){let c=a.mergeWithSibling(b),d=I()._normalizedNodes;d.add(a.__key);d.add(b.__key);return c}function bc(a){if(""===a.__text&&a.isSimpleText()&&!a.isUnmergeable())a.remove();else{for(var b;null!==(b=a.getPreviousSibling())&&B(b)&&b.isSimpleText()&&!b.isUnmergeable();)if(""===b.__text)b.remove();else{$b(b,a)&&(a=ac(b,a));break}for(var c;null!==(c=a.getNextSibling())&&B(c)&&c.isSimpleText()&&!c.isUnmergeable();)if(""===c.__text)c.remove();else{$b(a,c)&&ac(a,c);break}}}
|
|
30
|
-
let O="",P="",Q="",cc,
|
|
30
|
+
let O="",P="",Q="",cc,S,dc,ec=!1,fc=!1,gc,hc=null,ic,jc,kc,lc,mc,nc;function oc(a,b){let c=kc.get(a);if(null!==b){let d=pc(a);b.removeChild(d)}lc.has(a)||S._keyToDOMMap.delete(a);E(c)&&(a=c.__children,qc(a,0,a.length-1,null));void 0!==c&&Qb(nc,dc,gc,c,"destroyed")}function qc(a,b,c,d){for(;b<=c;++b){let f=a[b];void 0!==f&&oc(f,d)}}function rc(a,b){a.setProperty("text-align",b)}function sc(a,b){a.style.setProperty("padding-inline-start",0===b?"":20*b+"px")}
|
|
31
31
|
function tc(a,b){a=a.style;0===b?rc(a,""):1===b?rc(a,"left"):2===b?rc(a,"center"):3===b?rc(a,"right"):4===b&&rc(a,"justify")}
|
|
32
|
-
function uc(a,b,c){let d=lc.get(a);void 0===d&&t(60);let f=d.createDOM(cc,
|
|
32
|
+
function uc(a,b,c){let d=lc.get(a);void 0===d&&t(60);let f=d.createDOM(cc,S);var e=S._keyToDOMMap;f["__lexicalKey_"+S._key]=a;e.set(a,f);B(d)?f.setAttribute("data-lexical-text","true"):A(d)&&f.setAttribute("data-lexical-decorator","true");if(E(d)){a=d.__indent;0!==a&&sc(f,a);a=d.__children;var g=a.length;if(0!==g){e=a;--g;let h=P;P="";vc(e,0,g,f,null);wc(d,f);P=h}e=d.__format;0!==e&&tc(f,e);xc(null,a,f);Tb(d)&&(O+="\n\n",Q+="\n\n")}else e=d.getTextContent(),A(d)?(g=d.decorate(S,cc),null!==g&&yc(a,
|
|
33
33
|
g),f.contentEditable="false"):B(d)&&(d.isDirectionless()||(P+=e),d.isInert()&&(a=f.style,a.pointerEvents="none",a.userSelect="none",f.contentEditable="false",a.setProperty("-webkit-user-select","none"))),O+=e,Q+=e;null!==b&&(null!=c?b.insertBefore(f,c):(c=b.__lexicalLineBreak,null!=c?b.insertBefore(f,c):b.appendChild(f)));Qb(nc,dc,gc,d,"created");return f}function vc(a,b,c,d,f){let e=O;for(O="";b<=c;++b)uc(a[b],d,f);d.__lexicalTextContent=O;O=e+O}
|
|
34
34
|
function zc(a,b){a=b.get(a[a.length-1]);return Ab(a)||A(a)}function xc(a,b,c){a=null!==a&&(0===a.length||zc(a,kc));b=null!==b&&(0===b.length||zc(b,lc));a?b||(b=c.__lexicalLineBreak,null!=b&&c.removeChild(b),c.__lexicalLineBreak=null):b&&(b=document.createElement("br"),c.__lexicalLineBreak=b,c.appendChild(b))}
|
|
35
35
|
function wc(a,b){var c=b.__lexicalDir;if(b.__lexicalDirTextContent!==P||c!==hc){let e=""===P;if(e)var d=hc;else d=P,d=Xa.test(d)?"rtl":Ya.test(d)?"ltr":null;if(d!==c){let g=b.classList,h=cc.theme;var f=null!==c?h[c]:void 0;let k=null!==d?h[d]:void 0;void 0!==f&&("string"===typeof f&&(f=f.split(" "),f=h[c]=f),g.remove(...f));null===d||e&&"ltr"===d?b.removeAttribute("dir"):(void 0!==k&&("string"===typeof k&&(c=k.split(" "),k=h[d]=c),void 0!==k&&g.add(...k)),b.dir=d);fc||(a.getWritable().__dir=d)}hc=
|
|
36
36
|
d;b.__lexicalDirTextContent=P;b.__lexicalDir=d}}
|
|
37
|
-
function Ac(a,b){var c=kc.get(a),d=lc.get(a);void 0!==c&&void 0!==d||t(61);var f=ec||jc.has(a)||ic.has(a);let e=Xb(
|
|
38
|
-
a!==c.__format&&tc(e,a);a=c.__children;c=d.__children;if(a!==c||f){var g=a,h=c;f=d;b=P;P="";let p=O;O="";var k=g.length,m=h.length;if(1===k&&1===m){var l=g[0];h=h[0];if(l===h)Ac(l,e);else{var n=pc(l);h=uc(h,null,null);e.replaceChild(h,n);oc(l,null)}}else if(0===k)0!==m&&vc(h,0,m-1,e,null);else if(0===m)0!==k&&(l=null==e.__lexicalLineBreak,qc(g,0,k-1,l?null:e),l&&(e.textContent=""));else{let w=k-1;k=m-1;let y=e.firstChild,z=0;for(m=0;z<=w&&m<=k;){var r=g[z];let
|
|
39
|
-
z++,m++;else{void 0===l&&(l=new Set(g));void 0===n&&(n=new Set(h));let F=n.has(r),
|
|
40
|
-
cc),null!==f&&yc(a,f),O+=c,Q+=c):B(d)&&!d.isDirectionless()&&(P+=c),O+=c,Q+=c;!fc&&N(d)&&d.__cachedText!==Q&&(d=d.getWritable(),d.__cachedText=Q);return e}function yc(a,b){let c=
|
|
37
|
+
function Ac(a,b){var c=kc.get(a),d=lc.get(a);void 0!==c&&void 0!==d||t(61);var f=ec||jc.has(a)||ic.has(a);let e=Xb(S,a);if(c===d&&!f)return E(c)?(d=e.__lexicalTextContent,void 0!==d&&(O+=d,Q+=d),d=e.__lexicalDirTextContent,void 0!==d&&(P+=d)):(d=c.getTextContent(),B(c)&&!c.isDirectionless()&&(P+=d),Q+=d,O+=d),e;c!==d&&f&&Qb(nc,dc,gc,d,"updated");if(d.updateDOM(c,e,cc))return d=uc(a,null,null),null===b&&t(62),b.replaceChild(d,e),oc(a,null),d;if(E(c)&&E(d)){a=d.__indent;a!==c.__indent&&sc(e,a);a=d.__format;
|
|
38
|
+
a!==c.__format&&tc(e,a);a=c.__children;c=d.__children;if(a!==c||f){var g=a,h=c;f=d;b=P;P="";let p=O;O="";var k=g.length,m=h.length;if(1===k&&1===m){var l=g[0];h=h[0];if(l===h)Ac(l,e);else{var n=pc(l);h=uc(h,null,null);e.replaceChild(h,n);oc(l,null)}}else if(0===k)0!==m&&vc(h,0,m-1,e,null);else if(0===m)0!==k&&(l=null==e.__lexicalLineBreak,qc(g,0,k-1,l?null:e),l&&(e.textContent=""));else{let w=k-1;k=m-1;let y=e.firstChild,z=0;for(m=0;z<=w&&m<=k;){var r=g[z];let C=h[m];if(r===C)y=Ac(C,e).nextSibling,
|
|
39
|
+
z++,m++;else{void 0===l&&(l=new Set(g));void 0===n&&(n=new Set(h));let F=n.has(r),da=l.has(C);F?(da?(r=Xb(S,C),r===y?y=Ac(C,e).nextSibling:(null!=y?e.insertBefore(r,y):e.appendChild(r),Ac(C,e)),z++):uc(C,e,y),m++):(y=pc(r).nextSibling,oc(r,e),z++)}}l=z>w;n=m>k;l&&!n?(l=h[k+1],l=void 0===l?null:S.getElementByKey(l),vc(h,m,k,e,l)):n&&!l&&qc(g,z,w,e)}Tb(f)&&(O+="\n\n");e.__lexicalTextContent=O;O=p+O;wc(f,e);P=b;N(d)||xc(a,c,e)}Tb(d)&&(O+="\n\n",Q+="\n\n")}else c=d.getTextContent(),A(d)?(f=d.decorate(S,
|
|
40
|
+
cc),null!==f&&yc(a,f),O+=c,Q+=c):B(d)&&!d.isDirectionless()&&(P+=c),O+=c,Q+=c;!fc&&N(d)&&d.__cachedText!==Q&&(d=d.getWritable(),d.__cachedText=Q);return e}function yc(a,b){let c=S._pendingDecorators,d=S._decorators;if(null===c){if(d[a]===b)return;c=Fb(S)}c[a]=b}function pc(a){a=mc.get(a);void 0===a&&t(34);return a}
|
|
41
41
|
let T=Object.freeze({}),Gc=[["keydown",Bc],["compositionstart",Cc],["compositionend",Dc],["input",Ec],["click",Fc],["cut",T],["copy",T],["dragstart",T],["dragover",T],["dragend",T],["paste",T],["focus",T],["blur",T],["drop",T]];Sa&&Gc.push(["beforeinput",(a,b)=>Hc(a,b)]);let Ic=0,Jc=0,Kc=0,Lc=!1,Mc=!1,Nc=!1,Oc=[0,0,"root",0];function Pc(a,b){return null!==a&&null!==a.nodeValue&&3===a.nodeType&&0!==b&&b!==a.nodeValue.length}
|
|
42
|
-
function Qc(a,b,c){let {anchorNode:d,anchorOffset:f,focusNode:e,focusOffset:g}=a;if(Lc&&(Lc=!1,Pc(d,f)&&Pc(e,g)))return;x(b,()=>{if(!c)ob(null);else if(ub(b,d,e)){var h=v();if(
|
|
43
|
-
(r
|
|
44
|
-
function
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
function
|
|
52
|
-
function
|
|
53
|
-
function Bc(a,b){Ic=a.timeStamp;Jc=a.keyCode;if(!b.isComposing()){var {keyCode:c,shiftKey:d,ctrlKey:f,metaKey:e,altKey:g}=a;if(39!==c||f||e||g)if(39!==c||g||d||!f&&!e)if(37!==c||f||e||g)if(37!==c||g||d||!f&&!e)if(38!==c||f||e)if(40!==c||f||e)if(13===c&&d)Mc=!0,U(b,ya,a);else if(32===c)U(b,za,a);else if(u&&f&&79===c)a.preventDefault(),Mc=!0,U(b,da,!0);else if(13!==c||d){var h=u?g||e?!1:8===c||72===c&&f:f||g||e?!1:8===c;h?8===c?U(b,Aa,a):(a.preventDefault(),U(b,ca,!0)):27===c?U(b,Ba,a):(h=u?d||g||e?
|
|
42
|
+
function Qc(a,b,c){let {anchorNode:d,anchorOffset:f,focusNode:e,focusOffset:g}=a;if(Lc&&(Lc=!1,Pc(d,f)&&Pc(e,g)))return;x(b,()=>{if(!c)ob(null);else if(ub(b,d,e)){var h=v();if(D(h)){var k=h.anchor,m=k.getNode();if(h.isCollapsed()){"Range"===a.type&&(h.dirty=!0);var l=window.event;l=l?l.timeStamp:performance.now();let [n,r,p,w]=Oc;l<w+200&&k.offset===r&&k.key===p?h.format=n:"text"===k.type?h.format=m.getFormat():"element"===k.type&&(h.format=0)}else{k=127;m=h.getNodes();l=m.length;for(let n=0;n<l;n++){let r=
|
|
43
|
+
m[n];if(B(r)&&(k&=r.getFormat(),0===k))break}h.format=k}}U(b,aa,void 0)}})}function Fc(a,b){x(b,()=>{var c=v(),d=window.getSelection();let f=Nb();if(D(c)){var e=c.anchor;let g=e.getNode();d&&"element"===e.type&&0===e.offset&&c.isCollapsed()&&!N(g)&&1===Hb().getChildrenSize()&&g.getTopLevelElementOrThrow().isEmpty()&&null!==f&&c.is(f)&&(d.removeAllRanges(),c.dirty=!0)}else d&&Rc(c)&&d.isCollapsed&&(c=d.anchorNode,e=[1,3],null!==c&&e.includes(c.nodeType)&&(d=Sc(f,d,b),ob(d)));U(b,ba,a)})}
|
|
44
|
+
function Tc(a,b){b.getTargetRanges&&(b=b.getTargetRanges()[0])&&a.applyDOMRange(b)}function Uc(a,b){return a!==b||E(a)||E(b)||!G(a)||!G(b)}
|
|
45
|
+
function Hc(a,b){let c=a.inputType;"deleteCompositionText"===c||Ra&&pb()||"insertCompositionText"!==c&&x(b,()=>{let d=v();if("deleteContentBackward"===c){if(null===d){var f=Nb();if(!D(f))return;ob(f.clone())}if(D(d)){229===Jc&&a.timeStamp<Ic+30&&d.anchor.key===d.focus.key?(J(null),Ic=0,setTimeout(()=>{x(b,()=>{J(null)})},30),D(d)&&(f=d.anchor.getNode(),f.markDirty(),d.format=f.getFormat())):(a.preventDefault(),U(b,ca,!1));return}}if(D(d)){f=a.data;d.dirty||!d.isCollapsed()||N(d.anchor.getNode())||
|
|
46
|
+
Tc(d,a);var e=d.focus,g=d.anchor.getNode();e=e.getNode();if("insertText"===c)"\n"===f?(a.preventDefault(),U(b,ea,!1)):"\n\n"===f?(a.preventDefault(),U(b,fa,void 0)):null==f&&a.dataTransfer?(f=a.dataTransfer.getData("text/plain"),a.preventDefault(),d.insertRawText(f)):null!=f&&Ob(d,f)&&(a.preventDefault(),U(b,ha,f));else switch(a.preventDefault(),c){case "insertFromYank":case "insertFromDrop":case "insertReplacementText":U(b,ha,a);break;case "insertFromComposition":J(null);U(b,ha,a);break;case "insertLineBreak":J(null);
|
|
47
|
+
U(b,ea,!1);break;case "insertParagraph":J(null);Mc?(Mc=!1,U(b,ea,!1)):U(b,fa,void 0);break;case "insertFromPaste":case "insertFromPasteAsQuotation":U(b,ja,a);break;case "deleteByComposition":Uc(g,e)&&U(b,ka,void 0);break;case "deleteByDrag":case "deleteByCut":U(b,ka,void 0);break;case "deleteContent":U(b,ca,!1);break;case "deleteWordBackward":U(b,la,!0);break;case "deleteWordForward":U(b,la,!1);break;case "deleteHardLineBackward":case "deleteSoftLineBackward":U(b,ma,!0);break;case "deleteContentForward":case "deleteHardLineForward":case "deleteSoftLineForward":U(b,
|
|
48
|
+
ma,!1);break;case "formatStrikeThrough":U(b,q,"strikethrough");break;case "formatBold":U(b,q,"bold");break;case "formatItalic":U(b,q,"italic");break;case "formatUnderline":U(b,q,"underline");break;case "historyUndo":U(b,na,void 0);break;case "historyRedo":U(b,oa,void 0)}}})}
|
|
49
|
+
function Ec(a,b){a.stopPropagation();x(b,()=>{var c=v(),d=a.data;null!=d&&D(c)&&Ob(c,d)?(Nc&&(Vc(b,d),Nc=!1),U(b,ha,d),d=d.length,Ra&&1<d&&"insertCompositionText"===a.inputType&&!b.isComposing()&&(c.anchor.offset-=d),Ta||Ua||!b.isComposing()||(Ic=0,J(null))):(Mb(b,!1),Nc&&(Vc(b,d||void 0),Nc=!1));K();c=I();qb(c)})}
|
|
50
|
+
function Cc(a,b){x(b,()=>{let c=v();if(D(c)&&!b.isComposing()){let d=c.anchor;J(d.key);(a.timeStamp<Ic+30||"element"===d.type||!c.isCollapsed()||c.anchor.getNode().getFormat()!==c.format)&&U(b,ha,Wa)}})}
|
|
51
|
+
function Vc(a,b){var c=a._compositionKey;J(null);if(null!==c&&null!=b){if(""===b){b=L(c);a=xb(a.getElementByKey(c));null!==a&&null!==a.nodeValue&&B(b)&&lb(b,a.nodeValue,null,null,!0);return}if("\n"===b[b.length-1]&&(c=v(),D(c))){b=c.focus;c.anchor.set(b.key,b.offset,b.type);U(a,ya,null);return}}Mb(a,!0,b)}function Dc(a,b){Ra?Nc=!0:x(b,()=>{Vc(b,a.data)})}
|
|
52
|
+
function Bc(a,b){Ic=a.timeStamp;Jc=a.keyCode;if(!b.isComposing()){var {keyCode:c,shiftKey:d,ctrlKey:f,metaKey:e,altKey:g}=a;if(39!==c||f||e||g)if(39!==c||g||d||!f&&!e)if(37!==c||f||e||g)if(37!==c||g||d||!f&&!e)if(38!==c||f||e)if(40!==c||f||e)if(13===c&&d)Mc=!0,U(b,ya,a);else if(32===c)U(b,za,a);else if(u&&f&&79===c)a.preventDefault(),Mc=!0,U(b,ea,!0);else if(13!==c||d){var h=u?g||e?!1:8===c||72===c&&f:f||g||e?!1:8===c;h?8===c?U(b,Aa,a):(a.preventDefault(),U(b,ca,!0)):27===c?U(b,Ba,a):(h=u?d||g||e?
|
|
54
53
|
!1:46===c||68===c&&f:f||g||e?!1:46===c,h?46===c?U(b,Ca,a):(a.preventDefault(),U(b,ca,!1)):8===c&&(u?g:f)?(a.preventDefault(),U(b,la,!0)):46===c&&(u?g:f)?(a.preventDefault(),U(b,la,!1)):u&&e&&8===c?(a.preventDefault(),U(b,ma,!0)):u&&e&&46===c?(a.preventDefault(),U(b,ma,!1)):66===c&&!g&&(u?e:f)?(a.preventDefault(),U(b,q,"bold")):85===c&&!g&&(u?e:f)?(a.preventDefault(),U(b,q,"underline")):73===c&&!g&&(u?e:f)?(a.preventDefault(),U(b,q,"italic")):9!==c||g||f||e?90===c&&!d&&(u?e:f)?(a.preventDefault(),
|
|
55
54
|
U(b,na,void 0)):(h=u?90===c&&e&&d:89===c&&f||90===c&&f&&d,h?(a.preventDefault(),U(b,oa,void 0)):Rc(b._editorState._selection)&&(h=d?!1:67===c?u?e:f:!1,h?(a.preventDefault(),U(b,Ia,a)):(h=d?!1:88===c?u?e:f:!1,h&&(a.preventDefault(),U(b,Ja,a))))):U(b,Da,a))}else Mc=!1,U(b,ya,a);else U(b,xa,a);else U(b,wa,a);else U(b,sa,a);else U(b,ra,a);else U(b,qa,a);else U(b,pa,a);(f||d||g||e)&&U(b,Ma,a)}}function Wc(a){let b=a.__lexicalEventHandles;void 0===b&&(b=[],a.__lexicalEventHandles=b);return b}let Xc=new Map;
|
|
56
55
|
function Yc(){let a=window.getSelection();if(a){var b=vb(a.anchorNode);if(null!==b){var c=Kb(b);c=c[c.length-1];var d=c._key,f=Xc.get(d),e=f||c;e!==b&&Qc(a,e,!1);Qc(a,b,!0);b!==c?Xc.set(d,b):f&&Xc.delete(d)}}}
|
|
57
|
-
function Zc(a,b){0===Kc&&a.ownerDocument.addEventListener("selectionchange",Yc);Kc++;a.__lexicalEditor=b;let c=Wc(a);for(let d=0;d<Gc.length;d++){let [f,e]=Gc[d],g="function"===typeof e?h=>{b.isReadOnly()||e(h,b)}:h=>{if(!b.isReadOnly())switch(f){case "cut":return U(b,Ja,h);case "copy":return U(b,Ia,h);case "paste":return U(b,
|
|
56
|
+
function Zc(a,b){0===Kc&&a.ownerDocument.addEventListener("selectionchange",Yc);Kc++;a.__lexicalEditor=b;let c=Wc(a);for(let d=0;d<Gc.length;d++){let [f,e]=Gc[d],g="function"===typeof e?h=>{b.isReadOnly()||e(h,b)}:h=>{if(!b.isReadOnly())switch(f){case "cut":return U(b,Ja,h);case "copy":return U(b,Ia,h);case "paste":return U(b,ja,h);case "dragstart":return U(b,Fa,h);case "dragover":return U(b,Ga,h);case "dragend":return U(b,Ha,h);case "focus":return U(b,Ka,h);case "blur":return U(b,La,h);case "drop":return U(b,
|
|
58
57
|
Ea,h)}};a.addEventListener(f,g);c.push(()=>{a.removeEventListener(f,g)})}}
|
|
59
58
|
class V{constructor(a,b,c){this._selection=null;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(),d=this.offset;a=a.offset;if(E(b)){var f=b.getDescendantByIndex(d);b=null!=f?f:b}E(c)&&(f=c.getDescendantByIndex(a),c=null!=f?f:c);return b===c?d<a:b.isBefore(c)}getNode(){let a=L(this.key);null===a&&t(20);return a}set(a,b,c){let d=this._selection,f=this.key;this.key=a;this.offset=b;this.type=c;
|
|
60
59
|
X||(I()._compositionKey===f&&J(a),null!==d&&(d._cachedNodes=null,d.dirty=!0))}}function $c(a,b){let c=b.__key,d=a.offset,f="element";if(B(b))f="text",b=b.getTextContentSize(),d>b&&(d=b);else if(!E(b)){var e=b.getNextSibling();if(B(e))c=e.__key,d=0;else if(e=b.getParent())c=e.__key,d=b.getIndexWithinParent()+1}a.set(c,d,f)}function ad(a,b){if(E(b)){let c=b.getLastDescendant();E(c)||B(c)?$c(a,c):$c(a,b)}else $c(a,b)}
|
|
61
60
|
function bd(a,b,c){let d=a.getNode(),f=d.getChildAtIndex(a.offset),e=M(),g=N(d)?cd().append(e):e;e.setFormat(c);null===f?d.append(g):f.insertBefore(g);a.is(b)&&b.set(e.__key,0,"text");a.set(e.__key,0,"text")}function dd(a,b,c,d){a.key=b;a.offset=c;a.type=d}
|
|
62
61
|
class ed{constructor(a){this.dirty=!1;this._nodes=a;this._cachedNodes=null}is(a){if(!Rc(a))return!1;let b=this._nodes,c=a._nodes;return b.size===c.size&&Array.from(b).every(d=>c.has(d))}add(a){this.dirty=!0;this._nodes.add(a);this._cachedNodes=null}delete(a){this.dirty=!0;this._nodes.delete(a);this._cachedNodes=null}clear(){this.dirty=!0;this._nodes.clear();this._cachedNodes=null}has(a){return this._nodes.has(a)}clone(){return new ed(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(){}insertText(){}getNodes(){var a=
|
|
63
|
-
this._cachedNodes;if(null!==a)return a;var b=this._nodes;a=[];for(let c of b)b=L(c),null!==b&&a.push(b);X||(this._cachedNodes=a);return a}getTextContent(){let a=this.getNodes(),b="";for(let c=0;c<a.length;c++)b+=a[c].getTextContent();return b}}function
|
|
62
|
+
this._cachedNodes;if(null!==a)return a;var b=this._nodes;a=[];for(let c of b)b=L(c),null!==b&&a.push(b);X||(this._cachedNodes=a);return a}getTextContent(){let a=this.getNodes(),b="";for(let c=0;c<a.length;c++)b+=a[c].getTextContent();return b}}function D(a){return a instanceof fd}
|
|
64
63
|
class gd{constructor(a,b,c){this.gridKey=a;this.anchor=b;this.focus=c;this.dirty=!1;this._cachedNodes=null;b._selection=this;c._selection=this}is(a){return hd(a)?this.gridKey===a.gridKey&&this.anchor.is(this.focus):!1}set(a,b,c){this.dirty=!0;this.gridKey=a;this.anchor.key=b;this.focus.key=c;this._cachedNodes=null}clone(){return new gd(this.gridKey,this.anchor,this.focus)}isCollapsed(){return!1}isBackward(){return this.focus.isBefore(this.anchor)}getCharacterOffsets(){return id(this)}extract(){return this.getNodes()}insertRawText(){}insertText(){}getShape(){var a=
|
|
65
64
|
L(this.anchor.key);null===a&&t(21);var b=a.getIndexWithinParent();a=a.getParentOrThrow().getIndexWithinParent();var c=L(this.focus.key);null===c&&t(22);var d=c.getIndexWithinParent();let f=c.getParentOrThrow().getIndexWithinParent();c=Math.min(b,d);b=Math.max(b,d);d=Math.min(a,f);a=Math.max(a,f);return{fromX:Math.min(c,b),fromY:Math.min(d,a),toX:Math.max(c,b),toY:Math.max(d,a)}}getNodes(){var a=this._cachedNodes;if(null!==a)return a;a=new Set;let {fromX:b,fromY:c,toX:d,toY:f}=this.getShape();var e=
|
|
66
65
|
L(this.gridKey);jd(e)||t(23);a.add(e);e=e.getChildren();for(let k=c;k<=f;k++){var g=e[k];a.add(g);kd(g)||t(24);g=g.getChildren();for(let m=b;m<=d;m++){var h=g[m];ld(h)||t(25);a.add(h);for(h=h.getChildren();0<h.length;){let l=h.shift();a.add(l);E(l)&&h.unshift(...l.getChildren())}}}a=Array.from(a);X||(this._cachedNodes=a);return a}getTextContent(){let a=this.getNodes(),b="";for(let c=0;c<a.length;c++)b+=a[c].getTextContent();return b}}function hd(a){return a instanceof gd}
|
|
67
|
-
class fd{constructor(a,b,c){this.anchor=a;this.focus=b;this.dirty=!1;this.format=c;this._cachedNodes=null;a._selection=this;b._selection=this}is(a){return
|
|
66
|
+
class fd{constructor(a,b,c){this.anchor=a;this.focus=b;this.dirty=!1;this.format=c;this._cachedNodes=null;a._selection=this;b._selection=this}is(a){return D(a)?this.anchor.is(a.anchor)&&this.focus.is(a.focus)&&this.format===a.format:!1}isBackward(){return this.focus.isBefore(this.anchor)}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){var a=this._cachedNodes;if(null!==a)return a;var b=this.anchor,c=this.focus;a=b.getNode();let d=c.getNode();E(a)&&(b=a.getDescendantByIndex(b.offset),a=null!=
|
|
68
67
|
b?b:a);E(d)&&(c=d.getDescendantByIndex(c.offset),d=null!=c?c:d);a=a.is(d)?E(a)&&(0<a.getChildrenSize()||a.excludeFromCopy())?[]:[a]:a.getNodesBetween(d);X||(this._cachedNodes=a);return a}setTextNodeRange(a,b,c,d){dd(this.anchor,a.__key,b,"text");dd(this.focus,c.__key,d,"text");this._cachedNodes=null;this.dirty=!0}getTextContent(){let a=this.getNodes();if(0===a.length)return"";let b=a[0],c=a[a.length-1],d=this.anchor.isBefore(this.focus),[f,e]=id(this),g="",h=!0;for(let k=0;k<a.length;k++){let m=a[k];
|
|
69
68
|
if(E(m)&&!m.isInline())h||(g+="\n"),h=m.isEmpty()?!1:!0;else if(h=!1,B(m)){let l=m.getTextContent();m===b?l=m===c?f<e?l.slice(f,e):l.slice(e,f):d?l.slice(f):l.slice(e):m===c&&(l=d?l.slice(0,e):l.slice(0,f));g+=l}else!A(m)&&!Ab(m)||m===c&&this.isCollapsed()||(g+=m.getTextContent())}return g}applyDOMRange(a){let b=I(),c=b.getEditorState()._selection;a=md(a.startContainer,a.startOffset,a.endContainer,a.endOffset,b,c);if(null!==a){var [d,f]=a;dd(this.anchor,d.key,d.offset,d.type);dd(this.focus,f.key,
|
|
70
69
|
f.offset,f.type);this._cachedNodes=null}}clone(){let a=this.anchor,b=this.focus;return new fd(new V(a.key,a.offset,a.type),new V(b.key,b.offset,b.type),this.format)}toggleFormat(a){this.format=yb(this.format,a,null);this.dirty=!0}hasFormat(a){return 0!==(this.format&Za[a])}insertRawText(a){let b=a.split(/\r?\n/);if(1===b.length)this.insertText(a);else{a=[];let c=b.length;for(let d=0;d<c;d++){let f=b[d];""!==f&&a.push(M(f));d!==c-1&&a.push(nd())}this.insertNodes(a)}}insertText(a){var b=this.anchor,
|
|
@@ -82,60 +81,60 @@ null!==l?l.insertBefore(p):e.append(p),e=p;else!E(p)||E(p)&&p.isInline()||A(e)&&
|
|
|
82
81
|
e=d):E(e)||pd(d)?E(d)&&!d.canInsertAfter(e)?(f=h.constructor.clone(h),E(f)||t(29),f.append(d),e.insertAfter(f)):e.insertAfter(d):(e.insertBefore(d),e=d),h.isEmpty()&&!h.canBeEmpty()&&h.remove()}else b||(B(e)?e.select():(c=e.getParentOrThrow(),e=e.getIndexWithinParent()+1,c.select(e,e)));return!0}insertParagraph(){this.isCollapsed()||this.removeText();var a=this.anchor,b=a.offset,c=[];if("text"===a.type){var d=a.getNode();var f=d.getNextSiblings().reverse();var e=d.getParentOrThrow();var g=e.isInline(),
|
|
83
82
|
h=g?e.getTextContentSize():d.getTextContentSize();0===b?f.push(d):(g&&(c=e.getNextSiblings()),b===h||g&&b===d.getTextContentSize()||([,d]=d.splitText(b),f.push(d)))}else{e=a.getNode();if(N(e)){f=cd();c=e.getChildAtIndex(b);f.select();null!==c?c.insertBefore(f):e.append(f);return}f=e.getChildren().slice(b).reverse()}d=f.length;if(0===b&&0<d&&e.isInline()){if(c=e.getParentOrThrow(),f=c.insertNewAfter(this),E(f))for(c=c.getChildren(),e=0;e<c.length;e++)f.append(c[e])}else if(g=e.insertNewAfter(this),
|
|
84
83
|
null===g)this.insertLineBreak();else if(E(g))if(h=e.getFirstChild(),0===b&&(e.is(a.getNode())||h&&h.is(a.getNode()))&&0<d)e.insertBefore(g);else{e=null;b=c.length;a=g.getParentOrThrow();if(0<b)for(h=0;h<b;h++)a.append(c[h]);if(0!==d)for(c=0;c<d;c++)b=f[c],null===e?g.append(b):e.insertBefore(b),e=b;g.canBeEmpty()||0!==g.getChildrenSize()?g.selectStart():(g.selectPrevious(),g.remove())}}insertLineBreak(a){let b=nd();var c=this.anchor;"element"===c.type&&(c=c.getNode(),N(c)&&this.insertParagraph());
|
|
85
|
-
a?this.insertNodes([b],!0):this.insertNodes([b])&&b.selectNext(0,0)}getCharacterOffsets(){return id(this)}extract(){var a=this.getNodes(),b=a.length,c=b-1,d=this.anchor;let f=this.focus;var e=a[0];let g=a[c],[h,k]=id(this);if(0===b)return[];if(1===b)return B(e)?(a=h>k?k:h,c=e.splitText(a,h>k?h:k),a=0===a?c[0]:c[1],null!=a?[a]:[]):[e];b=d.isBefore(f);B(e)&&(d=b?h:k,d===e.getTextContentSize()?a.shift():0!==d&&([,e]=e.splitText(d),a[0]=e));B(g)&&(e=g.getTextContent().length,b=b?
|
|
86
|
-
e&&([g]=g.splitText(b),a[c]=g));return a}modify(a,b,c){var d=this.focus,f=this.anchor,e="move"===a,g=Sb(d,b);if(A(g)&&!g.isIsolated())a=b?g.getPreviousSibling():g.getNextSibling(),B(a)?(g=a.__key,b=b?a.getTextContent().length:0,d.set(g,b,"text"),e&&f.set(g,b,"text")):(c=g.getParentOrThrow(),E(a)?(c=a.__key,g=b?a.getChildrenSize():0):(g=g.getIndexWithinParent(),c=c.__key,b||g++),d.set(c,g,"element"),e&&f.set(c,g,"element"));else if(d=window.getSelection())d.modify(a,b?"backward":
|
|
87
|
-
(b=d.getRangeAt(0),this.applyDOMRange(b),this.dirty=!0,e||d.anchorNode===b.startContainer&&d.anchorOffset===b.startOffset||(e=this.focus,b=this.anchor,d=b.key,f=b.offset,g=b.type,dd(b,e.key,e.offset,e.type),dd(e,d,f,g),this._cachedNodes=null))}deleteCharacter(a){if(this.isCollapsed()){var b=this.anchor,c=this.focus,d=b.getNode();if(!a&&("element"===b.type&&E(d)&&b.offset===d.getChildrenSize()||"text"===b.type&&b.offset===d.getTextContentSize())&&(d=d.getNextSibling()||
|
|
88
|
-
E(d)&&!d.canExtractContents()))return;this.modify("extend",a,"character");if(!this.isCollapsed()){var f="text"===c.type?c.getNode():null;d="text"===b.type?b.getNode():null;if(null!==f&&f.isSegmented()){if(b=c.offset,c=f.getTextContentSize(),f.is(d)||a&&b!==c||!a&&0!==b){qd(f,a,b);return}}else if(null!==d&&d.isSegmented()&&(b=b.offset,c=d.getTextContentSize(),d.is(f)||a&&0!==b||!a&&b!==c)){qd(d,a,b);return}d=this.anchor;f=this.focus;b=d.getNode();c=f.getNode();
|
|
89
|
-
d.offset,g=f.offset;let h=e<g;c=h?e:g;g=h?g:e;e=g-1;c!==e&&(b=b.getTextContent().slice(c,g),/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(b)||(a?f.offset=e:d.offset=e))}}else if(a&&0===b.offset&&("element"===b.type?b.getNode():b.getNode().getParentOrThrow()).collapseAtStart(this))return}this.removeText()}deleteLine(a){this.isCollapsed()&&this.modify("extend",a,"lineboundary");this.removeText()}deleteWord(a){this.isCollapsed()&&this.modify("extend",a,"word");
|
|
90
|
-
function Rc(a){return a instanceof ed}function rd(a){let b=a.offset;if("text"===a.type)return b;a=a.getNode();return b===a.getChildrenSize()?a.getTextContent().length:0}function id(a){let b=a.anchor;a=a.focus;return"element"===b.type&&"element"===a.type&&b.key===a.key&&b.offset===a.offset?[0,0]:[rd(b),rd(a)]}
|
|
84
|
+
a?this.insertNodes([b],!0):this.insertNodes([b])&&b.selectNext(0,0)}getCharacterOffsets(){return id(this)}extract(){var a=this.getNodes(),b=a.length,c=b-1,d=this.anchor;let f=this.focus;var e=a[0];let g=a[c],[h,k]=id(this);if(0===b)return[];if(1===b)return B(e)&&!this.isCollapsed()?(a=h>k?k:h,c=e.splitText(a,h>k?h:k),a=0===a?c[0]:c[1],null!=a?[a]:[]):[e];b=d.isBefore(f);B(e)&&(d=b?h:k,d===e.getTextContentSize()?a.shift():0!==d&&([,e]=e.splitText(d),a[0]=e));B(g)&&(e=g.getTextContent().length,b=b?
|
|
85
|
+
k:h,0===b?a.pop():b!==e&&([g]=g.splitText(b),a[c]=g));return a}modify(a,b,c){var d=this.focus,f=this.anchor,e="move"===a,g=Sb(d,b);if(A(g)&&!g.isIsolated())a=b?g.getPreviousSibling():g.getNextSibling(),B(a)?(g=a.__key,b=b?a.getTextContent().length:0,d.set(g,b,"text"),e&&f.set(g,b,"text")):(c=g.getParentOrThrow(),E(a)?(c=a.__key,g=b?a.getChildrenSize():0):(g=g.getIndexWithinParent(),c=c.__key,b||g++),d.set(c,g,"element"),e&&f.set(c,g,"element"));else if(d=window.getSelection())d.modify(a,b?"backward":
|
|
86
|
+
"forward",c),0<d.rangeCount&&(b=d.getRangeAt(0),this.applyDOMRange(b),this.dirty=!0,e||d.anchorNode===b.startContainer&&d.anchorOffset===b.startOffset||(e=this.focus,b=this.anchor,d=b.key,f=b.offset,g=b.type,dd(b,e.key,e.offset,e.type),dd(e,d,f,g),this._cachedNodes=null))}deleteCharacter(a){if(this.isCollapsed()){var b=this.anchor,c=this.focus,d=b.getNode();if(!a&&("element"===b.type&&E(d)&&b.offset===d.getChildrenSize()||"text"===b.type&&b.offset===d.getTextContentSize())&&(d=d.getNextSibling()||
|
|
87
|
+
d.getParentOrThrow().getNextSibling(),E(d)&&!d.canExtractContents()))return;this.modify("extend",a,"character");if(!this.isCollapsed()){var f="text"===c.type?c.getNode():null;d="text"===b.type?b.getNode():null;if(null!==f&&f.isSegmented()){if(b=c.offset,c=f.getTextContentSize(),f.is(d)||a&&b!==c||!a&&0!==b){qd(f,a,b);return}}else if(null!==d&&d.isSegmented()&&(b=b.offset,c=d.getTextContentSize(),d.is(f)||a&&0!==b||!a&&b!==c)){qd(d,a,b);return}d=this.anchor;f=this.focus;b=d.getNode();c=f.getNode();
|
|
88
|
+
if(b===c&&"text"===d.type&&"text"===f.type){var e=d.offset,g=f.offset;let h=e<g;c=h?e:g;g=h?g:e;e=g-1;c!==e&&(b=b.getTextContent().slice(c,g),/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(b)||(a?f.offset=e:d.offset=e))}}else if(a&&0===b.offset&&("element"===b.type?b.getNode():b.getNode().getParentOrThrow()).collapseAtStart(this))return}this.removeText()}deleteLine(a){this.isCollapsed()&&this.modify("extend",a,"lineboundary");this.removeText()}deleteWord(a){this.isCollapsed()&&this.modify("extend",a,"word");
|
|
89
|
+
this.removeText()}}function Rc(a){return a instanceof ed}function rd(a){let b=a.offset;if("text"===a.type)return b;a=a.getNode();return b===a.getChildrenSize()?a.getTextContent().length:0}function id(a){let b=a.anchor;a=a.focus;return"element"===b.type&&"element"===a.type&&b.key===a.key&&b.offset===a.offset?[0,0]:[rd(b),rd(a)]}
|
|
91
90
|
function qd(a,b,c){let d=a.getTextContent().split(/(?=\s)/g),f=d.length,e=0,g=0;for(let h=0;h<f;h++){let k=d[h],m=h===f-1;g=e;e+=k.length;if(b&&e===c||e>c||m){d.splice(h,1);m&&(g=void 0);break}}b=d.join("").trim();""===b?a.remove():(a.setTextContent(b),a.select(g,g))}
|
|
92
91
|
function sd(a,b,c){var d=b;if(1===a.nodeType){let g=!1;var f=a.childNodes;var e=f.length;d===e&&(g=!0,d=e-1);f=Jb(f[d]);if(B(f))d=g?f.getTextContentSize():0;else{e=Jb(a);if(null===e)return null;if(E(e)){a=e.getChildAtIndex(d);if(b=E(a))b=a.getParent(),b=null===c||null===b||!b.canBeEmpty()||b!==c.getNode();b&&(c=g?a.getLastDescendant():a.getFirstDescendant(),null===c?(e=a,d=0):(a=c,e=a.getParentOrThrow()));B(a)?(f=a,e=null,d=g?a.getTextContentSize():0):a!==e&&g&&d++}else d=e.getIndexWithinParent(),
|
|
93
92
|
d=0===b&&A(e)&&Jb(a)===e?d:d+1,e=e.getParentOrThrow();if(E(e))return new V(e.__key,d,"element")}}else f=Jb(a);return B(f)?new V(f.__key,d,"text"):null}
|
|
94
93
|
function td(a,b,c){var d=a.offset,f=a.getNode();0===d?(d=f.getPreviousSibling(),f=f.getParent(),b)?(c||!b)&&null===d&&E(f)&&f.isInline()&&(b=f.getPreviousSibling(),B(b)&&(a.key=b.__key,a.offset=b.getTextContent().length)):E(d)&&!c&&d.isInline()?(a.key=d.__key,a.offset=d.getChildrenSize(),a.type="element"):B(d)&&!d.isInert()&&(a.key=d.__key,a.offset=d.getTextContent().length):d===f.getTextContent().length&&(d=f.getNextSibling(),f=f.getParent(),b&&E(d)&&d.isInline()?(a.key=d.__key,a.offset=0,a.type=
|
|
95
|
-
"element"):(c||b)&&null===d&&E(f)&&f.isInline()&&!f.canInsertTextAfter()&&(b=f.getNextSibling(),B(b)&&(a.key=b.__key,a.offset=0)))}function od(a,b,c){if("text"===a.type&&"text"===b.type){var d=a.isBefore(b);let f=a.is(b);td(a,d,f);td(b,!d,f);f&&(b.key=a.key,b.offset=a.offset,b.type=a.type);d=I();d.isComposing()&&d._compositionKey!==a.key&&
|
|
96
|
-
function md(a,b,c,d,f,e){if(null===a||null===c||!ub(f,a,c))return null;b=sd(a,b,
|
|
94
|
+
"element"):(c||b)&&null===d&&E(f)&&f.isInline()&&!f.canInsertTextAfter()&&(b=f.getNextSibling(),B(b)&&(a.key=b.__key,a.offset=0)))}function od(a,b,c){if("text"===a.type&&"text"===b.type){var d=a.isBefore(b);let f=a.is(b);td(a,d,f);td(b,!d,f);f&&(b.key=a.key,b.offset=a.offset,b.type=a.type);d=I();d.isComposing()&&d._compositionKey!==a.key&&D(c)&&(d=c.anchor,c=c.focus,dd(a,d.key,d.offset,d.type),dd(b,c.key,c.offset,c.type))}}
|
|
95
|
+
function md(a,b,c,d,f,e){if(null===a||null===c||!ub(f,a,c))return null;b=sd(a,b,D(e)?e.anchor:null);if(null===b)return null;d=sd(c,d,D(e)?e.focus:null);if(null===d||"element"===b.type&&"element"===d.type&&(a=Jb(a),c=Jb(c),A(a)&&A(c)))return null;od(b,d,e);return[b,d]}function pd(a){return E(a)&&!a.isInline()}function ud(a,b,c,d,f,e){let g=H();a=new fd(new V(a,b,f),new V(c,d,e),0);a.dirty=!0;return g._selection=a}
|
|
97
96
|
function vd(a){let b=a.getEditorState()._selection,c=window.getSelection();return Rc(b)||hd(b)?b.clone():Sc(b,c,a)}
|
|
98
|
-
function Sc(a,b,c){var d=window.event,f=d?d.type:void 0;let e="selectionchange"===f;d=!eb&&(e||"beforeinput"===f||"compositionstart"===f||"compositionend"===f||"click"===f&&d&&3===d.detail||void 0===f);let g;if(!
|
|
99
|
-
function Nb(){return I()._editorState._selection}function
|
|
97
|
+
function Sc(a,b,c){var d=window.event,f=d?d.type:void 0;let e="selectionchange"===f;d=!eb&&(e||"beforeinput"===f||"compositionstart"===f||"compositionend"===f||"click"===f&&d&&3===d.detail||void 0===f);let g;if(!D(a)||d){if(null===b)return null;d=b.anchorNode;f=b.focusNode;g=b.anchorOffset;b=b.focusOffset;if(e&&D(a)&&!ub(c,d,f))return a.clone()}else return a.clone();c=md(d,g,f,b,c,a);if(null===c)return null;let [h,k]=c;return new fd(h,k,D(a)?a.format:0)}function v(){return H()._selection}
|
|
98
|
+
function Nb(){return I()._editorState._selection}function Cd(a,b,c,d=1){var f=a.anchor,e=a.focus,g=f.getNode(),h=e.getNode();if(b.is(g)||b.is(h))if(g=b.__key,a.isCollapsed())b=f.offset,c<=b&&(c=Math.max(0,b+d),f.set(g,c,"element"),e.set(g,c,"element"),Dd(a));else{var k=a.isBackward();h=k?e:f;var m=h.getNode();f=k?f:e;e=f.getNode();b.is(m)&&(m=h.offset,c<=m&&h.set(g,Math.max(0,m+d),"element"));b.is(e)&&(b=f.offset,c<=b&&f.set(g,Math.max(0,b+d),"element"));Dd(a)}}
|
|
100
99
|
function Dd(a){var b=a.anchor,c=b.offset;let d=a.focus;var f=d.offset,e=b.getNode(),g=d.getNode();if(a.isCollapsed())E(e)&&(g=e.getChildrenSize(),g=(f=c>=g)?e.getChildAtIndex(g-1):e.getChildAtIndex(c),B(g)&&(c=0,f&&(c=g.getTextContentSize()),b.set(g.__key,c,"text"),d.set(g.__key,c,"text")));else{if(E(e)){let h=e.getChildrenSize();c=(a=c>=h)?e.getChildAtIndex(h-1):e.getChildAtIndex(c);B(c)&&(e=0,a&&(e=c.getTextContentSize()),b.set(c.__key,e,"text"))}E(g)&&(c=g.getChildrenSize(),f=(b=f>=c)?g.getChildAtIndex(c-
|
|
101
|
-
1):g.getChildAtIndex(f),B(f)&&(g=0,b&&(g=f.getTextContentSize()),d.set(f.__key,g,"text")))}}function Ed(a,b){b=b.getEditorState()._selection;a=a._selection;if(
|
|
100
|
+
1):g.getChildAtIndex(f),B(f)&&(g=0,b&&(g=f.getTextContentSize()),d.set(f.__key,g,"text")))}}function Ed(a,b){b=b.getEditorState()._selection;a=a._selection;if(D(a)){var c=a.anchor;let d=a.focus,f;"text"===c.type&&(f=c.getNode(),f.selectionTransform(b,a));"text"===d.type&&(c=d.getNode(),f!==c&&c.selectionTransform(b,a))}}
|
|
102
101
|
function Fd(a,b,c,d,f){let e=null,g=0,h=null;null!==d?(e=d.__key,B(d)?(g=d.getTextContentSize(),h="text"):E(d)&&(g=d.getChildrenSize(),h="element")):null!==f&&(e=f.__key,B(f)?h="text":E(f)&&(h="element"));null!==e&&null!==h?a.set(e,g,h):(g=b.getIndexWithinParent(),-1===g&&(g=c.getChildrenSize()),a.set(c.__key,g,"element"))}function Gd(a,b,c,d,f){"text"===a.type?(a.key=c,b||(a.offset+=f)):a.offset>d.getIndexWithinParent()&&--a.offset}let Y=null,Z=null,X=!1,Hd=!1,Eb=0;function K(){X&&t(13)}
|
|
103
102
|
function H(){null===Y&&t(15);return Y}function I(){null===Z&&t(16);return Z}function Id(a,b,c){var d=b.__type;let f=a._nodes.get(d);void 0===f&&t(30);a=c.get(d);void 0===a&&(a=Array.from(f.transforms),c.set(d,a));c=a.length;for(d=0;d<c&&(a[d](b),b.isAttached());d++);}function Jd(a,b){b=b._dirtyLeaves;a=a._nodeMap;for(let c of b)b=a.get(c),B(b)&&b.isAttached()&&b.isSimpleText()&&!b.isUnmergeable()&&bc(b)}
|
|
104
103
|
function Kd(a,b){let c=b._dirtyLeaves,d=b._dirtyElements;a=a._nodeMap;let f=I()._compositionKey,e=new Map;var g=c;let h=g.size;for(var k=d,m=k.size;0<h||0<m;){if(0<h){b._dirtyLeaves=new Set;for(let l of g)g=a.get(l),B(g)&&g.isAttached()&&g.isSimpleText()&&!g.isUnmergeable()&&bc(g),void 0!==g&&void 0!==g&&g.__key!==f&&g.isAttached()&&Id(b,g,e),c.add(l);g=b._dirtyLeaves;h=g.size;if(0<h){Eb++;continue}}b._dirtyLeaves=new Set;b._dirtyElements=new Map;for(let l of k)if(k=l[0],m=l[1],"root"===k||m)g=a.get(k),
|
|
105
104
|
void 0!==g&&void 0!==g&&g.__key!==f&&g.isAttached()&&Id(b,g,e),d.set(k,m);g=b._dirtyLeaves;h=g.size;k=b._dirtyElements;m=k.size;Eb++}b._dirtyLeaves=c;b._dirtyElements=d}function Ld(a,b){var c=b.get(a.type);void 0===c&&t(17);c=c.klass;a.type!==c.getType()&&t(18);c=c.importJSON(a);a=a.children;if(E(c)&&Array.isArray(a))for(let d=0;d<a.length;d++){let f=Ld(a[d],b);c.append(f)}return c}function Md(a,b){let c=Y,d=X,f=Z;Y=a;X=!0;Z=null;try{return b()}finally{Y=c,X=d,Z=f}}
|
|
106
|
-
function Nd(a){var b=a._pendingEditorState,c=a._rootElement,d=a._headless;if((null!==c||d)&&null!==b){var f=a._editorState,e=f._selection,g=b._selection,h=0!==a._dirtyType,k=Y,m=X,l=Z,n=a._updating,r=a._observer,p=null;a._pendingEditorState=null;a._editorState=b;if(!d&&h&&null!==r){Z=a;Y=b;X=!1;a._updating=!0;try{var w=a._dirtyType,y=a._dirtyElements,z=a._dirtyLeaves;r.disconnect();P=Q=O="";ec=2===w;hc=null;
|
|
107
|
-
fc=b._readOnly;mc=new Map(a._keyToDOMMap);var
|
|
108
|
-
new Set,a._dirtyElements=new Map,a._normalizedNodes=new Set,a._updateTags=new Set);y=a._decorators;var F=a._pendingDecorators||y,
|
|
109
|
-
Vb=
|
|
110
|
-
c&&c===
|
|
111
|
-
W,ta)&&d.removeAllRanges()}}finally{Z=l,Y=k}}if(null!==p)for(c=p,e=Array.from(a._listeners.mutation),g=e.length,k=0;k<g;k++){let [W,ta]=e[k];l=c.get(ta);void 0!==l&&W(l)}null!==z&&(a._decorators=z,a._pendingDecorators=null,Pd("decorator",a,!0,z));c=Gb(f);e=Gb(b);c!==e&&Pd("textcontent",a,!0,e);Pd("update",a,!0,{dirtyElements:r,dirtyLeaves:n,editorState:b,normalizedNodes:
|
|
105
|
+
function Nd(a){var b=a._pendingEditorState,c=a._rootElement,d=a._headless;if((null!==c||d)&&null!==b){var f=a._editorState,e=f._selection,g=b._selection,h=0!==a._dirtyType,k=Y,m=X,l=Z,n=a._updating,r=a._observer,p=null;a._pendingEditorState=null;a._editorState=b;if(!d&&h&&null!==r){Z=a;Y=b;X=!1;a._updating=!0;try{var w=a._dirtyType,y=a._dirtyElements,z=a._dirtyLeaves;r.disconnect();P=Q=O="";ec=2===w;hc=null;S=a;cc=a._config;dc=a._nodes;gc=S._listeners.mutation;ic=y;jc=z;kc=f._nodeMap;lc=b._nodeMap;
|
|
106
|
+
fc=b._readOnly;mc=new Map(a._keyToDOMMap);var C=new Map;nc=C;Ac("root",null);nc=mc=cc=lc=kc=jc=ic=dc=S=void 0;p=C}catch(W){W instanceof Error&&a._onError(W);if(Hd)throw W;Od(a,null,c,b);rb(a);a._dirtyType=2;Hd=!0;Nd(a);Hd=!1;return}finally{r.observe(c,{characterData:!0,childList:!0,subtree:!0}),a._updating=n,Y=k,X=m,Z=l}}b._readOnly=!0;n=a._dirtyLeaves;r=a._dirtyElements;C=a._normalizedNodes;w=a._updateTags;z=a._pendingDecorators;m=a._deferred;h&&(a._dirtyType=0,a._cloneNotNeeded.clear(),a._dirtyLeaves=
|
|
107
|
+
new Set,a._dirtyElements=new Map,a._normalizedNodes=new Set,a._updateTags=new Set);y=a._decorators;var F=a._pendingDecorators||y,da=b._nodeMap;for(Oa in F)da.has(Oa)||(F===y&&(F=Fb(a)),delete F[Oa]);d=d?null:window.getSelection();if(!a._readOnly&&null!==d&&(h||null===g||g.dirty)){Z=a;Y=b;try{a:{let W=d.anchorNode,ta=d.focusNode,le=d.anchorOffset,me=d.focusOffset,nb=document.activeElement;if(!w.has("collaboration")||nb===c)if(D(g)){var R=g.anchor,Ub=g.focus,wd=R.key,ua=Ub.key,xd=Xb(a,wd),yd=Xb(a,ua),
|
|
108
|
+
Vb=R.offset,zd=Ub.offset,Wb=g.format,Ad=g.isCollapsed();h=xd;ua=yd;var Oa=!1;"text"===R.type&&(h=xb(xd),Oa=R.getNode().getFormat()!==Wb);"text"===Ub.type&&(ua=xb(yd));if(null!==h&&null!==ua){if(Ad&&(null===e||Oa||D(e)&&e.format!==Wb)){var ne=performance.now();Oc=[Wb,Vb,wd,ne]}if(le===Vb&&me===zd&&W===h&&ta===ua&&("Range"!==d.type||!Ad)&&(null===c||null!==nb&&c.contains(nb)||c.focus({preventScroll:!0}),!Ua&&!Ta||"element"!==R.type))break a;try{d.setBaseAndExtent(h,Vb,ua,zd);if(g.isCollapsed()&&null!==
|
|
109
|
+
c&&c===nb){let Pa=R.getNode();if(E(Pa)){let ia=Pa.getDescendantByIndex(R.offset);null!==ia&&(Pa=ia)}let va=a.getElementByKey(Pa.__key);if(null!==va){let ia=va.getBoundingClientRect();if(ia.bottom>window.innerHeight)va.scrollIntoView(!1);else if(0>ia.top)va.scrollIntoView();else{let Bd=c.getBoundingClientRect();Math.floor(ia.bottom)>Math.floor(Bd.bottom)?va.scrollIntoView(!1):Math.floor(ia.top)<Math.floor(Bd.top)&&va.scrollIntoView()}w.add("scroll-into-view")}}Lc=!0}catch(Pa){}}}else null!==e&&ub(a,
|
|
110
|
+
W,ta)&&d.removeAllRanges()}}finally{Z=l,Y=k}}if(null!==p)for(c=p,e=Array.from(a._listeners.mutation),g=e.length,k=0;k<g;k++){let [W,ta]=e[k];l=c.get(ta);void 0!==l&&W(l)}null!==z&&(a._decorators=z,a._pendingDecorators=null,Pd("decorator",a,!0,z));c=Gb(f);e=Gb(b);c!==e&&Pd("textcontent",a,!0,e);Pd("update",a,!0,{dirtyElements:r,dirtyLeaves:n,editorState:b,normalizedNodes:C,prevEditorState:f,tags:w});a._deferred=[];if(0!==m.length){b=a._updating;a._updating=!0;try{for(f=0;f<m.length;f++)m[f]()}finally{a._updating=
|
|
112
111
|
b}}b=a._updates;if(0!==b.length&&(b=b.shift())){let [W,ta]=b;Qd(a,W,ta)}}}function Pd(a,b,c,...d){let f=b._updating;b._updating=c;try{let e=Array.from(b._listeners[a]);for(a=0;a<e.length;a++)e[a].apply(null,d)}finally{b._updating=f}}
|
|
113
112
|
function U(a,b,c){if(!1===a._updating||Z!==a){let e=!1;a.update(()=>{e=U(a,b,c)});return e}let d=Kb(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)){f=Array.from(f);let h=f.length;for(let k=0;k<h;k++)if(!0===f[k](c,a))return!0}}return!1}
|
|
114
113
|
function Rd(a,b){let c=a._updates;for(b=b||!1;0!==c.length;){var d=c.shift();if(d){let [f,e]=d,g;void 0!==e&&(d=e.onUpdate,g=e.tag,e.skipTransforms&&(b=!0),d&&a._deferred.push(d),g&&a._updateTags.add(g));f()}}return b}
|
|
115
114
|
function Qd(a,b,c){let 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||!1}e&&a._deferred.push(e);c=a._editorState;e=a._pendingEditorState;let g=!1;null===e&&(e=a._pendingEditorState=new Sd(new Map(c._nodeMap)),g=!0);let h=Y,k=X,m=Z,l=a._updating;Y=e;X=!1;a._updating=!0;Z=a;try{g&&!a._headless&&(e._selection=vd(a));let n=a._compositionKey;b();f=Rd(a,f);Ed(e,a);0!==a._dirtyType&&(f?Jd(e,a):Kd(e,a),Rd(a),Zb(c,e,a._dirtyLeaves,a._dirtyElements));
|
|
116
|
-
n!==a._compositionKey&&(e._flushSync=!0);let r=e._selection;if(
|
|
115
|
+
n!==a._compositionKey&&(e._flushSync=!0);let r=e._selection;if(D(r)){let p=e._nodeMap,w=r.focus.key;void 0!==p.get(r.anchor.key)&&void 0!==p.get(w)||t(19)}else Rc(r)&&0===r._nodes.size&&(e._selection=null)}catch(n){n instanceof Error&&a._onError(n);a._pendingEditorState=c;a._dirtyType=2;a._cloneNotNeeded.clear();a._dirtyLeaves=new Set;a._dirtyElements.clear();Nd(a);return}finally{Y=h,X=k,Z=m,a._updating=l,Eb=0}0!==a._dirtyType||Td(e,a)?e._flushSync?(e._flushSync=!1,Nd(a)):g&&tb(()=>{Nd(a)}):(e._flushSync=
|
|
117
116
|
!1,g&&(d.clear(),a._deferred=[],a._pendingEditorState=null))}function x(a,b,c){a._updating?a._updates.push([b,c]):Qd(a,b,c)}
|
|
118
|
-
function Ud(a,b,c){K();var d=a.__key;let f=a.getParent();if(null!==f){var e=v(),g=!1;if(
|
|
117
|
+
function Ud(a,b,c){K();var d=a.__key;let f=a.getParent();if(null!==f){var e=v(),g=!1;if(D(e)&&b){var h=e.anchor;let k=e.focus;h.key===d&&(Fd(h,a,f,a.getPreviousSibling(),a.getNextSibling()),g=!0);k.key===d&&(Fd(k,a,f,a.getPreviousSibling(),a.getNextSibling()),g=!0)}h=f.getWritable().__children;d=h.indexOf(d);-1===d&&t(31);Cb(a);h.splice(d,1);a.getWritable().__parent=null;D(e)&&b&&!g&&Cd(e,f,d,-1);c||null===f||N(f)||f.canBeEmpty()||!f.isEmpty()||Ud(f,b);null!==f&&N(f)&&f.isEmpty()&&f.selectEnd()}}
|
|
119
118
|
function Vd(a){a=L(a);null===a&&t(63);return a}
|
|
120
119
|
class Wd{static getType(){t(64)}static clone(){t(65)}constructor(a){this.__type=this.constructor.getType();this.__parent=null;if(null!=a)this.__key=a;else{K();99<Eb&&t(14);a=I();var b=H(),c=""+sb++;b._nodeMap.set(c,this);E(this)?a._dirtyElements.set(c,!0):a._dirtyLeaves.add(c);a._cloneNotNeeded.add(c);a._dirtyType=1;this.__key=c}}getType(){return this.__type}isAttached(){for(var a=this.__key;null!==a;){if("root"===a)return!0;a=L(a);if(null===a)break;a=a.__parent}return!1}isSelected(){let a=v();if(null==
|
|
121
|
-
a)return!1;let b=a.getNodes().some(c=>c.__key===this.__key);return B(this)?b:
|
|
120
|
+
a)return!1;let b=a.getNodes().some(c=>c.__key===this.__key);return B(this)?b:D(a)&&"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(){let a=this.getParent();return null===a?-1:a.__children.indexOf(this.__key)}getParent(){let a=this.getLatest().__parent;return null===a?null:L(a)}getParentOrThrow(){let a=this.getParent();null===a&&t(66);return a}getTopLevelElement(){let a=this;for(;null!==
|
|
122
121
|
a;){let b=a.getParent();if(N(b)&&E(a))return a;a=b}return null}getTopLevelElementOrThrow(){let a=this.getTopLevelElement();null===a&&t(67);return a}getParents(){let a=[],b=this.getParent();for(;null!==b;)a.push(b),b=b.getParent();return a}getParentKeys(){let a=[],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;let b=a.indexOf(this.__key);return 0>=b?null:L(a[b-1])}getPreviousSiblings(){var a=
|
|
123
122
|
this.getParent();if(null===a)return[];a=a.__children;let b=a.indexOf(this.__key);return a.slice(0,b).map(c=>Vd(c))}getNextSibling(){var a=this.getParent();if(null===a)return null;a=a.__children;let b=a.length,c=a.indexOf(this.__key);return c>=b-1?null:L(a[c+1])}getNextSiblings(){var a=this.getParent();if(null===a)return[];a=a.__children;let b=a.indexOf(this.__key);return a.slice(b+1).map(c=>Vd(c))}getCommonAncestor(a){let b=this.getParents();var c=a.getParents();E(this)&&b.unshift(this);E(a)&&c.unshift(a);
|
|
124
123
|
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++){let f=b[d];if(c.has(f))return f}return null}is(a){return null==a?!1:this.__key===a.__key}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===b){b=a.__children.indexOf(c.__key);break}c=a}return d<b}isParentOf(a){let b=
|
|
125
124
|
this.__key;if(b===a.__key)return!1;for(;null!==a;){if(a.__key===b)return!0;a=a.getParent()}return!1}getNodesBetween(a){let b=this.isBefore(a),c=[],d=new Set;for(var f=this;;){var e=f.__key;d.has(e)||(d.add(e),c.push(f));if(f===a)break;e=E(f)?b?f.getFirstChild():f.getLastChild():null;if(null!==e)f=e;else if(e=b?f.getNextSibling():f.getPreviousSibling(),null!==e)f=e;else{f=f.getParentOrThrow();d.has(f.__key)||c.push(f);if(f===a)break;e=f;do null===e&&t(68),f=b?e.getNextSibling():e.getPreviousSibling(),
|
|
126
125
|
e=e.getParent(),null!==e&&(null!==f||d.has(e.__key)||c.push(e));while(null===f)}}b||c.reverse();return c}isDirty(){let a=I()._dirtyLeaves;return null!==a&&a.has(this.__key)}getLatest(){let a=L(this.__key);null===a&&t(69);return a}getWritable(){K();var a=H(),b=I();a=a._nodeMap;let c=this.__key,d=this.getLatest(),f=d.__parent;b=b._cloneNotNeeded;var e=v();null!==e&&(e._cachedNodes=null);if(b.has(c))return Db(d),d;e=d.constructor.clone(d);e.__parent=f;E(d)&&E(e)?(e.__children=Array.from(d.__children),
|
|
127
126
|
e.__indent=d.__indent,e.__format=d.__format,e.__dir=d.__dir):B(d)&&B(e)&&(e.__format=d.__format,e.__style=d.__style,e.__mode=d.__mode,e.__detail=d.__detail);b.add(c);e.__key=c;Db(e);a.set(c,e);return e}getTextContent(){return""}getTextContentSize(a,b){return this.getTextContent(a,b).length}createDOM(){t(70)}updateDOM(){t(71)}exportDOM(a){return{element:this.createDOM(a._config,a)}}exportJSON(){t(72)}static importJSON(){t(18)}remove(a){K();Ud(this,!0,a)}replace(a){K();let b=this.__key;a=a.getWritable();
|
|
128
|
-
Bb(a);var c=this.getParentOrThrow(),d=c.getWritable().__children;let f=d.indexOf(this.__key),e=a.__key;-1===f&&t(31);d.splice(f,0,e);a.__parent=c.__key;Ud(this,!1);Cb(a);d=v();
|
|
129
|
-
e+1,h="element"===d.type&&d.key===h&&d.offset===e+1));e=this.getParentOrThrow().getWritable();d=c.__key;c.__parent=b.__parent;let k=e.__children;b=k.indexOf(b.__key);-1===b&&t(31);k.splice(b+1,0,d);Cb(c);
|
|
130
|
-
t(31);e.splice(b,0,f);Cb(c);c=v();
|
|
127
|
+
Bb(a);var c=this.getParentOrThrow(),d=c.getWritable().__children;let f=d.indexOf(this.__key),e=a.__key;-1===f&&t(31);d.splice(f,0,e);a.__parent=c.__key;Ud(this,!1);Cb(a);d=v();D(d)&&(c=d.anchor,d=d.focus,c.key===b&&ad(c,a),d.key===b&&ad(d,a));I()._compositionKey===b&&J(e);return a}insertAfter(a){K();var b=this.getWritable(),c=a.getWritable(),d=c.getParent();let f=v();var e=a.getIndexWithinParent(),g=!1,h=!1;null!==d&&(Bb(c),D(f)&&(h=d.__key,g=f.anchor,d=f.focus,g="element"===g.type&&g.key===h&&g.offset===
|
|
128
|
+
e+1,h="element"===d.type&&d.key===h&&d.offset===e+1));e=this.getParentOrThrow().getWritable();d=c.__key;c.__parent=b.__parent;let k=e.__children;b=k.indexOf(b.__key);-1===b&&t(31);k.splice(b+1,0,d);Cb(c);D(f)&&(Cd(f,e,b+1),c=e.__key,g&&f.anchor.set(c,b+2,"element"),h&&f.focus.set(c,b+2,"element"));return a}insertBefore(a){K();var b=this.getWritable(),c=a.getWritable();Bb(c);let d=this.getParentOrThrow().getWritable(),f=c.__key;c.__parent=b.__parent;let e=d.__children;b=e.indexOf(b.__key);-1===b&&
|
|
129
|
+
t(31);e.splice(b,0,f);Cb(c);c=v();D(c)&&Cd(c,d,b);return a}selectPrevious(a,b){K();let c=this.getPreviousSibling(),d=this.getParentOrThrow();return null===c?d.select(0,0):E(c)?c.select():B(c)?c.select(a,b):(a=c.getIndexWithinParent()+1,d.select(a,a))}selectNext(a,b){K();let c=this.getNextSibling(),d=this.getParentOrThrow();return null===c?d.select():E(c)?c.select(0,0):B(c)?c.select(a,b):(a=c.getIndexWithinParent(),d.select(a,a))}markDirty(){this.getWritable()}}
|
|
131
130
|
class Xd extends Wd{constructor(a){super(a)}decorate(){t(47)}isIsolated(){return!1}isTopLevel(){return!1}}function A(a){return a instanceof Xd}
|
|
132
131
|
class Yd extends Wd{constructor(a){super(a);this.__children=[];this.__indent=this.__format=0;this.__dir=null}getFormat(){return this.getLatest().__format}getFormatType(){let a=this.getFormat();return bb[a]||""}getIndent(){return this.getLatest().__indent}getChildren(){let a=this.getLatest().__children,b=[];for(let c=0;c<a.length;c++){let d=L(a[c]);null!==d&&b.push(d)}return b}getChildrenKeys(){return this.getLatest().__children}getChildrenSize(){return this.getLatest().__children.length}isEmpty(){return 0===
|
|
133
132
|
this.getChildrenSize()}isDirty(){let a=I()._dirtyElements;return null!==a&&a.has(this.__key)}isLastChild(){let a=this.getLatest();return a.getParentOrThrow().getLastChild()===a}getAllTextNodes(a){let b=[],c=this.getLatest().__children;for(let f=0;f<c.length;f++){var d=L(c[f]);!B(d)||!a&&d.isInert()?E(d)&&(d=d.getAllTextNodes(a),b.push(...d)):b.push(d)}return b}getFirstDescendant(){let a=this.getFirstChild();for(;null!==a;){if(E(a)){let b=a.getFirstChild();if(null!==b){a=b;continue}}break}return a}getLastDescendant(){let a=
|
|
134
133
|
this.getLastChild();for(;null!==a;){if(E(a)){let b=a.getLastChild();if(null!==b){a=b;continue}}break}return a}getDescendantByIndex(a){let b=this.getChildren(),c=b.length;if(a>=c)return a=b[c-1],E(a)&&a.getLastDescendant()||a||null;a=b[a];return E(a)&&a.getFirstDescendant()||a||null}getFirstChild(){let a=this.getLatest().__children;return 0===a.length?null:L(a[0])}getFirstChildOrThrow(){let a=this.getFirstChild();null===a&&t(45);return a}getLastChild(){let a=this.getLatest().__children,b=a.length;
|
|
135
|
-
return 0===b?null:L(a[b-1])}getChildAtIndex(a){a=this.getLatest().__children[a];return void 0===a?null:L(a)}getTextContent(a,b){let c="",d=this.getChildren(),f=d.length;for(let e=0;e<f;e++){let g=d[e];c+=g.getTextContent(a,b);E(g)&&e!==f-1&&!g.isInline()&&(c+="\n\n")}return c}getDirection(){return this.getLatest().__dir}hasFormat(a){return""!==a?(a=ab[a],0!==(this.getFormat()&a)):!1}select(a,b){K();let c=v();var d=this.getChildrenSize();void 0===a&&(a=d);void 0===b&&(b=d);d=this.__key;if(
|
|
134
|
+
return 0===b?null:L(a[b-1])}getChildAtIndex(a){a=this.getLatest().__children[a];return void 0===a?null:L(a)}getTextContent(a,b){let c="",d=this.getChildren(),f=d.length;for(let e=0;e<f;e++){let g=d[e];c+=g.getTextContent(a,b);E(g)&&e!==f-1&&!g.isInline()&&(c+="\n\n")}return c}getDirection(){return this.getLatest().__dir}hasFormat(a){return""!==a?(a=ab[a],0!==(this.getFormat()&a)):!1}select(a,b){K();let c=v();var d=this.getChildrenSize();void 0===a&&(a=d);void 0===b&&(b=d);d=this.__key;if(D(c))c.anchor.set(d,
|
|
136
135
|
a,"element"),c.focus.set(d,b,"element"),c.dirty=!0;else return ud(d,a,d,b,"element","element");return c}selectStart(){let a=this.getFirstDescendant();return E(a)||B(a)?a.select(0,0):null!==a?a.selectPrevious():this.select(0,0)}selectEnd(){let a=this.getLastDescendant();return E(a)||B(a)?a.select():null!==a?a.selectNext():this.select()}clear(){K();let a=this.getWritable();this.getChildren().forEach(b=>b.remove());return a}append(...a){K();return this.splice(this.getChildrenSize(),0,a)}setDirection(a){K();
|
|
137
136
|
let b=this.getWritable();b.__dir=a;return b}setFormat(a){K();this.getWritable().__format=""!==a?ab[a]:0;return this}setIndent(a){K();this.getWritable().__indent=a;return this}splice(a,b,c){K();let d=this.getWritable();var f=d.__key;let e=d.__children,g=c.length;var h=[];for(let k=0;k<g;k++){let m=c[k],l=m.getWritable();m.__key===f&&t(46);Bb(l);l.__parent=f;h.push(l.__key)}(c=this.getChildAtIndex(a-1))&&Db(c);(f=this.getChildAtIndex(a+b))&&Db(f);a===e.length?(e.push(...h),a=[]):a=e.splice(a,b,...h);
|
|
138
|
-
if(a.length&&(b=v(),
|
|
137
|
+
if(a.length&&(b=v(),D(b))){let k=new Set(a),m=new Set(h);h=r=>{for(r=r.getNode();r;){const p=r.__key;if(k.has(p)&&!m.has(p))return!0;r=r.getParent()}return!1};let {anchor:l,focus:n}=b;h(l)&&Fd(l,l.getNode(),this,c,f);h(n)&&Fd(n,n.getNode(),this,c,f);h=a.length;for(b=0;b<h;b++)c=L(a[b]),null!=c&&(c.getWritable().__parent=null);0!==e.length||this.canBeEmpty()||N(this)||this.remove()}return d}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),
|
|
139
138
|
type:"element",version:1}}insertNewAfter(){return null}canInsertTab(){return!1}canIndent(){return!0}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}canMergeWith(){return!1}extractWithChild(){return!1}}function E(a){return a instanceof Yd}
|
|
140
139
|
class Zd extends Yd{static getType(){return"root"}static clone(){return new Zd}constructor(){super("root");this.__cachedText=null}getTopLevelElementOrThrow(){t(51)}getTextContent(a,b){let c=this.__cachedText;return!X&&0!==I()._dirtyType||null===c||a&&!1===b?super.getTextContent(a,b):c}remove(){t(52)}replace(){t(53)}insertBefore(){t(54)}insertAfter(){t(55)}updateDOM(){return!1}append(...a){for(let b=0;b<a.length;b++){let c=a[b];E(c)||A(c)||t(56)}return super.append(...a)}static importJSON(a){let b=
|
|
141
140
|
Hb();b.setFormat(a.format);b.setIndent(a.indent);b.setDirection(a.direction);return b}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"root",version:1}}}function N(a){return a instanceof Zd}function Td(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 $d(){return new Sd(new Map([["root",new Zd]]))}
|
|
@@ -148,15 +147,15 @@ function ge(a,b,c){let d=b.firstChild;c=c.isComposing();a+=c?Va:"";if(null==d)b.
|
|
|
148
147
|
class he extends Wd{static getType(){return"text"}static clone(a){return new he(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}getDetail(){return this.getLatest().__detail}getMode(){let a=this.getLatest();return db[a.__mode]}getStyle(){return this.getLatest().__style}isToken(){return 1===this.getLatest().__mode}isComposing(){return this.__key===I()._compositionKey}isSegmented(){return 2===
|
|
149
148
|
this.getLatest().__mode}isInert(){return 3===this.getLatest().__mode}isDirectionless(){return 0!==(this.getLatest().__detail&1)}isUnmergeable(){return 0!==(this.getLatest().__detail&2)}hasFormat(a){a=Za[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){let c=this.getLatest().__format;return yb(c,a,b)}createDOM(a){var b=this.__format,
|
|
150
149
|
c=de(this,b);let d=ee(this,b),f=document.createElement(null===c?d:c),e=f;null!==c&&(e=document.createElement(d),f.appendChild(e));c=e;ge(this.__text,c,this);a=a.theme.text;void 0!==a&&fe(d,0,b,c,a);b=this.__style;""!==b&&(f.style.cssText=b);return f}updateDOM(a,b,c){let d=this.__text;var f=a.__format,e=this.__format,g=de(this,f);let h=de(this,e);var k=ee(this,f);let m=ee(this,e);if((null===g?k:g)!==(null===h?m:h))return!0;if(g===h&&k!==m)return f=b.firstChild,null==f&&t(48),a=g=document.createElement(m),
|
|
151
|
-
ge(d,a,this),c=c.theme.text,void 0!==c&&fe(m,0,e,a,c),b.replaceChild(g,f),!1;k=b;null!==h&&null!==g&&(k=b.firstChild,null==k&&t(49));ge(d,k,this);c=c.theme.text;void 0!==c&&f!==e&&fe(m,f,e,k,c);e=this.__style;a.__style!==e&&(b.style.cssText=e);return!1}static importDOM(){return{"#text":()=>({conversion:ie,priority:0}),b:()=>({conversion:je,priority:0}),
|
|
152
|
-
u:()=>({conversion:ke,priority:0})}}static importJSON(a){let b=M(a.text);b.setFormat(a.format);b.setDetail(a.detail);b.setMode(a.mode);b.setStyle(a.style);return b}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),type:"text",version:1}}selectionTransform(){}setFormat(a){K();let b=this.getWritable();b.__format="string"===typeof a?Za[a]:a;return b}setDetail(a){K();let b=this.getWritable();
|
|
153
|
-
|
|
154
|
-
typeof d?(d=d.length,void 0===a&&(a=d),void 0===b&&(b=d)):b=a=0;if(
|
|
155
|
-
this.getLatest(),c=b.getTextContent(),d=b.__key,f=I()._compositionKey,e=new Set(a);a=[];var g=c.length,h="";for(var k=0;k<g;k++)""!==h&&e.has(k)&&(a.push(h),h=""),h+=c[k];""!==h&&a.push(h);e=a.length;if(0===e)return[];if(a[0]===c)return[b];var m=a[0];c=b.getParentOrThrow();k=c.__key;let l=b.getFormat(),n=b.getStyle(),r=b.__detail;g=!1;b.isSegmented()?(h=M(m),h.__parent=k,h.__format=l,h.__style=n,h.__detail=r,g=!0):(h=b.getWritable(),h.__text=m);b=v();h=[h];m=m.length;for(let y=1;y<e;y++){var p=
|
|
156
|
-
w=p.length;p=M(p).getWritable();p.__format=l;p.__style=n;p.__detail=r;let z=p.__key;w=m+w;if(
|
|
157
|
-
a===this.getPreviousSibling();b||a===this.getNextSibling()||t(50);var c=this.__key;let d=a.__key,f=this.__text,e=f.length;I()._compositionKey===d&&J(c);let g=v();if(
|
|
158
|
-
function oe(a){let b="700"===a.style.fontWeight,c="line-through"===a.style.textDecoration,d="italic"===a.style.fontStyle,f="underline"===a.style.textDecoration,e=a.style.verticalAlign
|
|
159
|
-
|
|
150
|
+
ge(d,a,this),c=c.theme.text,void 0!==c&&fe(m,0,e,a,c),b.replaceChild(g,f),!1;k=b;null!==h&&null!==g&&(k=b.firstChild,null==k&&t(49));ge(d,k,this);c=c.theme.text;void 0!==c&&f!==e&&fe(m,f,e,k,c);e=this.__style;a.__style!==e&&(b.style.cssText=e);return!1}static importDOM(){return{"#text":()=>({conversion:ie,priority:0}),b:()=>({conversion:je,priority:0}),code:()=>({conversion:ke,priority:0}),em:()=>({conversion:ke,priority:0}),i:()=>({conversion:ke,priority:0}),span:()=>({conversion:oe,priority:0}),
|
|
151
|
+
strong:()=>({conversion:ke,priority:0}),u:()=>({conversion:ke,priority:0})}}static importJSON(a){let b=M(a.text);b.setFormat(a.format);b.setDetail(a.detail);b.setMode(a.mode);b.setStyle(a.style);return b}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),type:"text",version:1}}selectionTransform(){}setFormat(a){K();let b=this.getWritable();b.__format="string"===typeof a?Za[a]:a;return b}setDetail(a){K();let b=this.getWritable();
|
|
152
|
+
b.__detail="string"===typeof a?$a[a]:a;return b}setStyle(a){K();let b=this.getWritable();b.__style=a;return b}toggleFormat(a){a=Za[a];return this.setFormat(this.getFormat()^a)}toggleDirectionless(){K();let a=this.getWritable();a.__detail^=1;return a}toggleUnmergeable(){K();let a=this.getWritable();a.__detail^=2;return a}setMode(a){K();a=cb[a];let b=this.getWritable();b.__mode=a;return b}setTextContent(a){K();let b=this.getWritable();b.__text=a;return b}select(a,b){K();let c=v();var d=this.getTextContent();
|
|
153
|
+
let f=this.__key;"string"===typeof d?(d=d.length,void 0===a&&(a=d),void 0===b&&(b=d)):b=a=0;if(D(c))d=I()._compositionKey,d!==c.anchor.key&&d!==c.focus.key||J(f),c.setTextNodeRange(this,a,this,b);else return ud(f,a,f,b,"text","text");return c}spliceText(a,b,c,d){K();let f=this.getWritable(),e=f.__text,g=c.length,h=a;0>h&&(h=g+h,0>h&&(h=0));let k=v();d&&D(k)&&(a+=g,k.setTextNodeRange(f,a,f,a));b=e.slice(0,h)+c+e.slice(h+b);f.__text=b;return f}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...a){K();
|
|
154
|
+
var b=this.getLatest(),c=b.getTextContent(),d=b.__key,f=I()._compositionKey,e=new Set(a);a=[];var g=c.length,h="";for(var k=0;k<g;k++)""!==h&&e.has(k)&&(a.push(h),h=""),h+=c[k];""!==h&&a.push(h);e=a.length;if(0===e)return[];if(a[0]===c)return[b];var m=a[0];c=b.getParentOrThrow();k=c.__key;let l=b.getFormat(),n=b.getStyle(),r=b.__detail;g=!1;b.isSegmented()?(h=M(m),h.__parent=k,h.__format=l,h.__style=n,h.__detail=r,g=!0):(h=b.getWritable(),h.__text=m);b=v();h=[h];m=m.length;for(let y=1;y<e;y++){var p=
|
|
155
|
+
a[y],w=p.length;p=M(p).getWritable();p.__format=l;p.__style=n;p.__detail=r;let z=p.__key;w=m+w;if(D(b)){let C=b.anchor,F=b.focus;C.key===d&&"text"===C.type&&C.offset>m&&C.offset<=w&&(C.key=z,C.offset-=m,b.dirty=!0);F.key===d&&"text"===F.type&&F.offset>m&&F.offset<=w&&(F.key=z,F.offset-=m,b.dirty=!0)}f===d&&J(z);m=w;p.__parent=k;h.push(p)}Cb(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);D(b)&&Cd(b,c,d,e-1);return h}mergeWithSibling(a){var b=
|
|
156
|
+
a===this.getPreviousSibling();b||a===this.getNextSibling()||t(50);var c=this.__key;let d=a.__key,f=this.__text,e=f.length;I()._compositionKey===d&&J(c);let g=v();if(D(g)){let h=g.anchor,k=g.focus;null!==h&&h.key===d&&(Gd(h,b,c,a,e),g.dirty=!0);null!==k&&k.key===d&&(Gd(k,b,c,a,e),g.dirty=!0)}c=a.__text;this.setTextContent(b?c+f:f+c);b=this.getWritable();a.remove();return b}isTextEntity(){return!1}}
|
|
157
|
+
function oe(a){let b="700"===a.style.fontWeight,c="line-through"===a.style.textDecoration,d="italic"===a.style.fontStyle,f="underline"===a.style.textDecoration,e=a.style.verticalAlign;return{forChild:g=>{if(!B(g))return g;b&&g.toggleFormat("bold");c&&g.toggleFormat("strikethrough");d&&g.toggleFormat("italic");f&&g.toggleFormat("underline");"sub"===e&&g.toggleFormat("subscript");"super"===e&&g.toggleFormat("superscript");return g},node:null}}
|
|
158
|
+
function je(a){let b="normal"===a.style.fontWeight;return{forChild:c=>{B(c)&&!b&&c.toggleFormat("bold");return c},node:null}}function ie(a){let {parentElement:b}=a;a=a.textContent||"";let c=a.trim();return null!=b&&"pre"===b.tagName.toLowerCase()||0!==c.length||!a.includes("\n")?{node:M(a)}:{node:null}}let pe={code:"code",em:"italic",i:"italic",strong:"bold",u:"underline"};
|
|
160
159
|
function ke(a){let b=pe[a.nodeName.toLowerCase()];return void 0===b?{node:null}:{forChild:c=>{B(c)&&c.toggleFormat(b);return c},node:null}}function M(a=""){return new he(a)}function B(a){return a instanceof he}
|
|
161
160
|
class qe extends Yd{static getType(){return"paragraph"}static clone(a){return new qe(a.__key)}createDOM(a){let b=document.createElement("p");a=Pb(a.theme,"paragraph");void 0!==a&&b.classList.add(...a);return b}updateDOM(){return!1}static importDOM(){return{p:()=>({conversion:re,priority:0})}}exportDOM(a){({element:a}=super.exportDOM(a));a&&this.isEmpty()&&a.append(document.createElement("br"));return{element:a}}static importJSON(a){let b=cd();b.setFormat(a.format);b.setIndent(a.indent);b.setDirection(a.direction);
|
|
162
161
|
return b}exportJSON(){return{...super.exportJSON(),type:"paragraph",version:1}}insertNewAfter(){let a=cd(),b=this.getDirection();a.setDirection(b);this.insertAfter(a);return a}collapseAtStart(){let a=this.getChildren();if(0===a.length||B(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 re(){return{node:cd()}}
|
|
@@ -172,11 +171,11 @@ b&&d.add(b),Nd(this));this._pendingEditorState=a;this._dirtyType=2;this._dirtyEl
|
|
|
172
171
|
g,this._dirtyLeaves=h,this._cloneNotNeeded=k,this._dirtyType=m,Y=d,X=f,Z=e}return c}update(a,b){x(this,a,b)}focus(a,b={}){let c=this._rootElement;null!==c&&(c.setAttribute("autocapitalize","off"),x(this,()=>{let d=v(),f=Hb();null!==d?d.dirty=!0:0!==f.getChildrenSize()&&("rootStart"===b.defaultSelection?f.selectStart():f.selectEnd())},{onUpdate:()=>{c.removeAttribute("autocapitalize");a&&a()}}))}blur(){var a=this._rootElement;null!==a&&a.blur();a=window.getSelection();null!==a&&a.removeAllRanges()}isReadOnly(){return this._readOnly}setReadOnly(a){this._readOnly!==
|
|
173
172
|
a&&(this._readOnly=a,Pd("readonly",this,!0,a))}toJSON(){return{editorState:this._editorState.toJSON()}}}class ue extends Yd{constructor(a,b){super(b);this.__colSpan=a}exportJSON(){return{...super.exportJSON(),colSpan:this.__colSpan}}}function ld(a){return a instanceof ue}class ve extends Yd{}function jd(a){return a instanceof ve}class we extends Yd{}function kd(a){return a instanceof we}
|
|
174
173
|
exports.$createGridSelection=function(){let a=new V("root",0,"element"),b=new V("root",0,"element");return new gd("root",a,b)};exports.$createLineBreakNode=nd;exports.$createNodeSelection=function(){return new ed(new Set)};exports.$createParagraphNode=cd;exports.$createRangeSelection=function(){let a=new V("root",0,"element"),b=new V("root",0,"element");return new fd(a,b,0)};exports.$createTextNode=M;exports.$getDecoratorNode=Sb;exports.$getNearestNodeFromDOMNode=kb;exports.$getNodeByKey=L;
|
|
175
|
-
exports.$getPreviousSelection=Nb;exports.$getRoot=Hb;exports.$getSelection=v;exports.$isDecoratorNode=A;exports.$isElementNode=E;exports.$isGridCellNode=ld;exports.$isGridNode=jd;exports.$isGridRowNode=kd;exports.$isGridSelection=hd;exports.$isLeafNode=zb;exports.$isLineBreakNode=Ab;exports.$isNodeSelection=Rc;exports.$isParagraphNode=function(a){return a instanceof qe};exports.$isRangeSelection=
|
|
174
|
+
exports.$getPreviousSelection=Nb;exports.$getRoot=Hb;exports.$getSelection=v;exports.$isDecoratorNode=A;exports.$isElementNode=E;exports.$isGridCellNode=ld;exports.$isGridNode=jd;exports.$isGridRowNode=kd;exports.$isGridSelection=hd;exports.$isLeafNode=zb;exports.$isLineBreakNode=Ab;exports.$isNodeSelection=Rc;exports.$isParagraphNode=function(a){return a instanceof qe};exports.$isRangeSelection=D;exports.$isRootNode=N;exports.$isTextNode=B;
|
|
176
175
|
exports.$nodesOfType=function(a){var b=H();let c=b._readOnly,d=a.getType();b=b._nodeMap;let f=[];for(let [,e]of b)e instanceof a&&e.__type===d&&(c||e.isAttached())&&f.push(e);return f};exports.$parseSerializedNode=function(a){return Ld(a,I()._nodes)};exports.$setCompositionKey=J;exports.$setSelection=ob;exports.BLUR_COMMAND=La;exports.CAN_REDO_COMMAND={};exports.CAN_UNDO_COMMAND={};exports.CLEAR_EDITOR_COMMAND={};exports.CLEAR_HISTORY_COMMAND={};exports.CLICK_COMMAND=ba;
|
|
177
176
|
exports.COMMAND_PRIORITY_CRITICAL=4;exports.COMMAND_PRIORITY_EDITOR=0;exports.COMMAND_PRIORITY_HIGH=3;exports.COMMAND_PRIORITY_LOW=1;exports.COMMAND_PRIORITY_NORMAL=2;exports.CONTROLLED_TEXT_INSERTION_COMMAND=ha;exports.COPY_COMMAND=Ia;exports.CUT_COMMAND=Ja;exports.DELETE_CHARACTER_COMMAND=ca;exports.DELETE_LINE_COMMAND=ma;exports.DELETE_WORD_COMMAND=la;exports.DRAGEND_COMMAND=Ha;exports.DRAGOVER_COMMAND=Ga;exports.DRAGSTART_COMMAND=Fa;exports.DROP_COMMAND=Ea;exports.DecoratorNode=Xd;
|
|
178
|
-
exports.ElementNode=Yd;exports.FOCUS_COMMAND=Ka;exports.FORMAT_ELEMENT_COMMAND={};exports.FORMAT_TEXT_COMMAND=q;exports.GridCellNode=ue;exports.GridNode=ve;exports.GridRowNode=we;exports.INDENT_CONTENT_COMMAND={};exports.INSERT_LINE_BREAK_COMMAND=
|
|
179
|
-
exports.KEY_ENTER_COMMAND=ya;exports.KEY_ESCAPE_COMMAND=Ba;exports.KEY_MODIFIER_COMMAND=Ma;exports.KEY_SPACE_COMMAND=za;exports.KEY_TAB_COMMAND=Da;exports.LineBreakNode=be;exports.MOVE_TO_END=qa;exports.MOVE_TO_START=sa;exports.OUTDENT_CONTENT_COMMAND={};exports.PASTE_COMMAND=
|
|
177
|
+
exports.ElementNode=Yd;exports.FOCUS_COMMAND=Ka;exports.FORMAT_ELEMENT_COMMAND={};exports.FORMAT_TEXT_COMMAND=q;exports.GridCellNode=ue;exports.GridNode=ve;exports.GridRowNode=we;exports.INDENT_CONTENT_COMMAND={};exports.INSERT_LINE_BREAK_COMMAND=ea;exports.INSERT_PARAGRAPH_COMMAND=fa;exports.KEY_ARROW_DOWN_COMMAND=xa;exports.KEY_ARROW_LEFT_COMMAND=ra;exports.KEY_ARROW_RIGHT_COMMAND=pa;exports.KEY_ARROW_UP_COMMAND=wa;exports.KEY_BACKSPACE_COMMAND=Aa;exports.KEY_DELETE_COMMAND=Ca;
|
|
178
|
+
exports.KEY_ENTER_COMMAND=ya;exports.KEY_ESCAPE_COMMAND=Ba;exports.KEY_MODIFIER_COMMAND=Ma;exports.KEY_SPACE_COMMAND=za;exports.KEY_TAB_COMMAND=Da;exports.LineBreakNode=be;exports.MOVE_TO_END=qa;exports.MOVE_TO_START=sa;exports.OUTDENT_CONTENT_COMMAND={};exports.PASTE_COMMAND=ja;exports.ParagraphNode=qe;exports.REDO_COMMAND=oa;exports.REMOVE_TEXT_COMMAND=ka;exports.RootNode=Zd;exports.SELECTION_CHANGE_COMMAND=aa;exports.TextNode=he;exports.UNDO_COMMAND=na;exports.VERSION="0.3.8";
|
|
180
179
|
exports.createCommand=function(){return{}};
|
|
181
180
|
exports.createEditor=function(a){var b=a||{},c=Z,d=b.theme||{};let f=void 0===a?c:b.parentEditor||null,e=b.disableEvents||!1,g=$d(),h=b.namespace||(null!==f?f._config.namespace:Lb()),k=b.editorState,m=[Zd,he,be,qe,...(b.nodes||[])],l=b.onError;b=b.readOnly||!1;if(void 0===a&&null!==c)a=c._nodes;else for(a=new Map,c=0;c<m.length;c++){let n=m[c],r=n.getType();a.set(r,{klass:n,transforms:new Set})}d=new te(g,f,a,{disableEvents:e,namespace:h,theme:d},l?l:console.error,se(a),b);void 0!==k&&(d._pendingEditorState=
|
|
182
181
|
k,d._dirtyType=2);return d}
|
package/LexicalCommands.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ export declare const CLICK_COMMAND: LexicalCommand<MouseEvent>;
|
|
|
12
12
|
export declare const DELETE_CHARACTER_COMMAND: LexicalCommand<boolean>;
|
|
13
13
|
export declare const INSERT_LINE_BREAK_COMMAND: LexicalCommand<boolean>;
|
|
14
14
|
export declare const INSERT_PARAGRAPH_COMMAND: LexicalCommand<void>;
|
|
15
|
-
export declare const CONTROLLED_TEXT_INSERTION_COMMAND: LexicalCommand<string>;
|
|
16
|
-
export declare const PASTE_COMMAND: LexicalCommand<ClipboardEvent>;
|
|
15
|
+
export declare const CONTROLLED_TEXT_INSERTION_COMMAND: LexicalCommand<InputEvent | string>;
|
|
16
|
+
export declare const PASTE_COMMAND: LexicalCommand<ClipboardEvent | InputEvent>;
|
|
17
17
|
export declare const REMOVE_TEXT_COMMAND: LexicalCommand<void>;
|
|
18
18
|
export declare const DELETE_WORD_COMMAND: LexicalCommand<boolean>;
|
|
19
19
|
export declare const DELETE_LINE_COMMAND: LexicalCommand<boolean>;
|
|
@@ -39,8 +39,8 @@ export declare const FORMAT_ELEMENT_COMMAND: LexicalCommand<ElementFormatType>;
|
|
|
39
39
|
export declare const DRAGSTART_COMMAND: LexicalCommand<DragEvent>;
|
|
40
40
|
export declare const DRAGOVER_COMMAND: LexicalCommand<DragEvent>;
|
|
41
41
|
export declare const DRAGEND_COMMAND: LexicalCommand<DragEvent>;
|
|
42
|
-
export declare const COPY_COMMAND: LexicalCommand<ClipboardEvent>;
|
|
43
|
-
export declare const CUT_COMMAND: LexicalCommand<ClipboardEvent>;
|
|
42
|
+
export declare const COPY_COMMAND: LexicalCommand<ClipboardEvent | KeyboardEvent>;
|
|
43
|
+
export declare const CUT_COMMAND: LexicalCommand<ClipboardEvent | KeyboardEvent>;
|
|
44
44
|
export declare const CLEAR_EDITOR_COMMAND: LexicalCommand<void>;
|
|
45
45
|
export declare const CLEAR_HISTORY_COMMAND: LexicalCommand<void>;
|
|
46
46
|
export declare const CAN_REDO_COMMAND: LexicalCommand<boolean>;
|
package/LexicalConstants.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export declare const IS_UNDERLINE: number;
|
|
|
23
23
|
export declare const IS_CODE: number;
|
|
24
24
|
export declare const IS_SUBSCRIPT: number;
|
|
25
25
|
export declare const IS_SUPERSCRIPT: number;
|
|
26
|
+
export declare const IS_ALL_FORMATTING: number;
|
|
26
27
|
export declare const IS_DIRECTIONLESS = 1;
|
|
27
28
|
export declare const IS_UNMERGEABLE: number;
|
|
28
29
|
export declare const IS_ALIGN_LEFT = 1;
|
package/LexicalEditor.d.ts
CHANGED
|
@@ -115,7 +115,28 @@ export declare const COMMAND_PRIORITY_LOW = 1;
|
|
|
115
115
|
export declare const COMMAND_PRIORITY_NORMAL = 2;
|
|
116
116
|
export declare const COMMAND_PRIORITY_HIGH = 3;
|
|
117
117
|
export declare const COMMAND_PRIORITY_CRITICAL = 4;
|
|
118
|
-
export declare type LexicalCommand<
|
|
118
|
+
export declare type LexicalCommand<TPayload> = Record<string, never>;
|
|
119
|
+
/**
|
|
120
|
+
* Type helper for extracting the payload type from a command.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* const MY_COMMAND = createCommand<SomeType>();
|
|
125
|
+
*
|
|
126
|
+
* // ...
|
|
127
|
+
*
|
|
128
|
+
* editor.registerCommand(MY_COMMAND, payload => {
|
|
129
|
+
* // Type of `payload` is inferred here. But lets say we want to extract a function to delegate to
|
|
130
|
+
* handleMyCommand(editor, payload);
|
|
131
|
+
* return true;
|
|
132
|
+
* });
|
|
133
|
+
*
|
|
134
|
+
* function handleMyCommand(editor: LexicalEditor, payload: CommandPayloadType<typeof MY_COMMAND>) {
|
|
135
|
+
* // `payload` is of type `SomeType`, extracted from the command.
|
|
136
|
+
* }
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
export declare type CommandPayloadType<TCommand extends LexicalCommand<unknown>> = TCommand extends LexicalCommand<infer TPayload> ? TPayload : never;
|
|
119
140
|
declare type Commands = Map<LexicalCommand<unknown>, Array<Set<CommandListener<unknown>>>>;
|
|
120
141
|
declare type Listeners = {
|
|
121
142
|
decorator: Set<DecoratorListener>;
|
|
@@ -183,7 +204,7 @@ export declare class LexicalEditor {
|
|
|
183
204
|
registerMutationListener(klass: Klass<LexicalNode>, listener: MutationListener): () => void;
|
|
184
205
|
registerNodeTransform<T extends LexicalNode>(klass: Klass<T>, listener: Transform<T>): () => void;
|
|
185
206
|
hasNodes<T extends Klass<LexicalNode>>(nodes: Array<T>): boolean;
|
|
186
|
-
dispatchCommand<
|
|
207
|
+
dispatchCommand<TCommand extends LexicalCommand<unknown>, TPayload extends CommandPayloadType<TCommand>>(type: TCommand, payload: TPayload): boolean;
|
|
187
208
|
getDecorators<T>(): Record<NodeKey, T>;
|
|
188
209
|
getRootElement(): null | HTMLElement;
|
|
189
210
|
getKey(): string;
|
package/LexicalUtils.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import type { EditorThemeClasses, Klass, LexicalCommand, MutatedNodes, MutationListeners, NodeMutation, RegisteredNode, RegisteredNodes } from './LexicalEditor';
|
|
8
|
+
import type { CommandPayloadType, EditorThemeClasses, Klass, LexicalCommand, MutatedNodes, MutationListeners, NodeMutation, RegisteredNode, RegisteredNodes } from './LexicalEditor';
|
|
9
9
|
import type { EditorState } from './LexicalEditorState';
|
|
10
10
|
import type { LexicalNode, NodeKey } from './LexicalNode';
|
|
11
11
|
import type { GridSelection, NodeSelection, PointType, RangeSelection } from './LexicalSelection';
|
|
@@ -86,7 +86,7 @@ export declare function setMutatedNode(mutatedNodes: MutatedNodes, registeredNod
|
|
|
86
86
|
export declare function $nodesOfType<T extends LexicalNode>(klass: Klass<T>): Array<LexicalNode>;
|
|
87
87
|
export declare function $getDecoratorNode(focus: PointType, isBackward: boolean): null | LexicalNode;
|
|
88
88
|
export declare function isFirefoxClipboardEvents(): boolean;
|
|
89
|
-
export declare function dispatchCommand<
|
|
89
|
+
export declare function dispatchCommand<TCommand extends LexicalCommand<unknown>, TPayload extends CommandPayloadType<TCommand>>(editor: LexicalEditor, type: TCommand, payload: TPayload): boolean;
|
|
90
90
|
export declare function $textContentRequiresDoubleLinebreakAtEnd(node: ElementNode): boolean;
|
|
91
91
|
export declare function getElementByKeyOrThrow(editor: LexicalEditor, key: NodeKey): HTMLElement;
|
|
92
92
|
export declare function scrollIntoViewIfNeeded(editor: LexicalEditor, anchor: PointType, rootElement: HTMLElement, tags: Set<string>): void;
|
package/LexicalVersion.d.ts
CHANGED
package/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
export type { CommandListenerPriority, EditorConfig, EditorThemeClasses, IntentionallyMarkedAsDirtyElement, Klass, LexicalCommand, LexicalEditor, NodeMutation, ReadOnlyListener, SerializedEditor, Spread, } from './LexicalEditor';
|
|
8
|
+
export type { CommandListenerPriority, CommandPayloadType, EditorConfig, EditorThemeClasses, IntentionallyMarkedAsDirtyElement, Klass, LexicalCommand, LexicalEditor, NodeMutation, ReadOnlyListener, SerializedEditor, Spread, } from './LexicalEditor';
|
|
9
9
|
export type { EditorState, SerializedEditorState } from './LexicalEditorState';
|
|
10
10
|
export type { DOMChildConversion, DOMConversion, DOMConversionFn, DOMConversionMap, DOMConversionOutput, DOMExportOutput, LexicalNode, NodeKey, NodeMap, SerializedLexicalNode, } from './LexicalNode';
|
|
11
11
|
export type { BaseSelection, ElementPointType as ElementPoint, GridSelection, GridSelectionShape, NodeSelection, Point, RangeSelection, TextPointType as TextPoint, } from './LexicalSelection';
|