@lexical/text 0.14.5 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LexicalText.dev.js +24 -20
- package/LexicalText.dev.mjs +24 -20
- package/LexicalText.js +2 -0
- package/LexicalText.mjs +2 -0
- package/LexicalText.node.mjs +2 -0
- package/LexicalText.prod.js +9 -6
- package/LexicalText.prod.mjs +3 -1
- package/package.json +2 -2
package/LexicalText.dev.js
CHANGED
@@ -3,7 +3,9 @@
|
|
3
3
|
*
|
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
|
*/
|
8
|
+
|
7
9
|
'use strict';
|
8
10
|
|
9
11
|
var lexical = require('lexical');
|
@@ -179,6 +181,7 @@ function $findTextIntersectionFromCharacters(root, targetCharacters) {
|
|
179
181
|
* LICENSE file in the root directory of this source tree.
|
180
182
|
*
|
181
183
|
*/
|
184
|
+
|
182
185
|
/**
|
183
186
|
* Returns a tuple that can be rested (...) into mergeRegister to clean up
|
184
187
|
* node transforms listeners that transforms text into another node, eg. a HashtagNode.
|
@@ -202,7 +205,7 @@ function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
|
|
202
205
|
const isTargetNode = node => {
|
203
206
|
return node instanceof targetNode;
|
204
207
|
};
|
205
|
-
const replaceWithSimpleText = node => {
|
208
|
+
const $replaceWithSimpleText = node => {
|
206
209
|
const textNode = lexical.$createTextNode(node.getTextContent());
|
207
210
|
textNode.setFormat(node.getFormat());
|
208
211
|
node.replace(textNode);
|
@@ -210,11 +213,11 @@ function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
|
|
210
213
|
const getMode = node => {
|
211
214
|
return node.getLatest().__mode;
|
212
215
|
};
|
213
|
-
const textNodeTransform = node => {
|
216
|
+
const $textNodeTransform = node => {
|
214
217
|
if (!node.isSimpleText()) {
|
215
218
|
return;
|
216
219
|
}
|
217
|
-
|
220
|
+
let prevSibling = node.getPreviousSibling();
|
218
221
|
let text = node.getTextContent();
|
219
222
|
let currentNode = node;
|
220
223
|
let match;
|
@@ -224,7 +227,7 @@ function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
|
|
224
227
|
const prevMatch = getMatch(combinedText);
|
225
228
|
if (isTargetNode(prevSibling)) {
|
226
229
|
if (prevMatch === null || getMode(prevSibling) !== 0) {
|
227
|
-
replaceWithSimpleText(prevSibling);
|
230
|
+
$replaceWithSimpleText(prevSibling);
|
228
231
|
return;
|
229
232
|
} else {
|
230
233
|
const diff = prevMatch.end - previousText.length;
|
@@ -246,7 +249,7 @@ function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
|
|
246
249
|
return;
|
247
250
|
}
|
248
251
|
}
|
249
|
-
|
252
|
+
let prevMatchLengthToSkip = 0;
|
250
253
|
// eslint-disable-next-line no-constant-condition
|
251
254
|
while (true) {
|
252
255
|
match = getMatch(text);
|
@@ -259,7 +262,7 @@ function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
|
|
259
262
|
const nextMatch = getMatch(nextText);
|
260
263
|
if (nextMatch === null) {
|
261
264
|
if (isTargetNode(nextSibling)) {
|
262
|
-
replaceWithSimpleText(nextSibling);
|
265
|
+
$replaceWithSimpleText(nextSibling);
|
263
266
|
} else {
|
264
267
|
nextSibling.markDirty();
|
265
268
|
}
|
@@ -268,23 +271,22 @@ function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
|
|
268
271
|
return;
|
269
272
|
}
|
270
273
|
}
|
271
|
-
} else {
|
272
|
-
const nextMatch = getMatch(nextText);
|
273
|
-
if (nextMatch !== null && nextMatch.start === 0) {
|
274
|
-
return;
|
275
|
-
}
|
276
274
|
}
|
277
275
|
if (match === null) {
|
278
276
|
return;
|
279
277
|
}
|
280
278
|
if (match.start === 0 && lexical.$isTextNode(prevSibling) && prevSibling.isTextEntity()) {
|
279
|
+
prevMatchLengthToSkip += match.end;
|
281
280
|
continue;
|
282
281
|
}
|
283
282
|
let nodeToReplace;
|
284
283
|
if (match.start === 0) {
|
285
284
|
[nodeToReplace, currentNode] = currentNode.splitText(match.end);
|
286
285
|
} else {
|
287
|
-
[, nodeToReplace, currentNode] = currentNode.splitText(match.start, match.end);
|
286
|
+
[, nodeToReplace, currentNode] = currentNode.splitText(match.start + prevMatchLengthToSkip, match.end + prevMatchLengthToSkip);
|
287
|
+
}
|
288
|
+
if (!(nodeToReplace !== undefined)) {
|
289
|
+
throw Error(`${'nodeToReplace'} should not be undefined. You may want to check splitOffsets passed to the splitText.`);
|
288
290
|
}
|
289
291
|
const replacementNode = createNode(nodeToReplace);
|
290
292
|
replacementNode.setFormat(nodeToReplace.getFormat());
|
@@ -292,13 +294,15 @@ function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
|
|
292
294
|
if (currentNode == null) {
|
293
295
|
return;
|
294
296
|
}
|
297
|
+
prevMatchLengthToSkip = 0;
|
298
|
+
prevSibling = replacementNode;
|
295
299
|
}
|
296
300
|
};
|
297
|
-
const reverseNodeTransform = node => {
|
301
|
+
const $reverseNodeTransform = node => {
|
298
302
|
const text = node.getTextContent();
|
299
303
|
const match = getMatch(text);
|
300
304
|
if (match === null || match.start !== 0) {
|
301
|
-
replaceWithSimpleText(node);
|
305
|
+
$replaceWithSimpleText(node);
|
302
306
|
return;
|
303
307
|
}
|
304
308
|
if (text.length > match.end) {
|
@@ -308,21 +312,21 @@ function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
|
|
308
312
|
}
|
309
313
|
const prevSibling = node.getPreviousSibling();
|
310
314
|
if (lexical.$isTextNode(prevSibling) && prevSibling.isTextEntity()) {
|
311
|
-
replaceWithSimpleText(prevSibling);
|
312
|
-
replaceWithSimpleText(node);
|
315
|
+
$replaceWithSimpleText(prevSibling);
|
316
|
+
$replaceWithSimpleText(node);
|
313
317
|
}
|
314
318
|
const nextSibling = node.getNextSibling();
|
315
319
|
if (lexical.$isTextNode(nextSibling) && nextSibling.isTextEntity()) {
|
316
|
-
replaceWithSimpleText(nextSibling);
|
320
|
+
$replaceWithSimpleText(nextSibling);
|
317
321
|
|
318
322
|
// This may have already been converted in the previous block
|
319
323
|
if (isTargetNode(node)) {
|
320
|
-
replaceWithSimpleText(node);
|
324
|
+
$replaceWithSimpleText(node);
|
321
325
|
}
|
322
326
|
}
|
323
327
|
};
|
324
|
-
const removePlainTextTransform = editor.registerNodeTransform(lexical.TextNode, textNodeTransform);
|
325
|
-
const removeReverseNodeTransform = editor.registerNodeTransform(targetNode, reverseNodeTransform);
|
328
|
+
const removePlainTextTransform = editor.registerNodeTransform(lexical.TextNode, $textNodeTransform);
|
329
|
+
const removeReverseNodeTransform = editor.registerNodeTransform(targetNode, $reverseNodeTransform);
|
326
330
|
return [removePlainTextTransform, removeReverseNodeTransform];
|
327
331
|
}
|
328
332
|
|
package/LexicalText.dev.mjs
CHANGED
@@ -3,7 +3,9 @@
|
|
3
3
|
*
|
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
|
*/
|
8
|
+
|
7
9
|
import { $getRoot, $isDecoratorNode, $isElementNode, $isParagraphNode, $isTextNode, TextNode, $createTextNode } from 'lexical';
|
8
10
|
|
9
11
|
/**
|
@@ -177,6 +179,7 @@ function $findTextIntersectionFromCharacters(root, targetCharacters) {
|
|
177
179
|
* LICENSE file in the root directory of this source tree.
|
178
180
|
*
|
179
181
|
*/
|
182
|
+
|
180
183
|
/**
|
181
184
|
* Returns a tuple that can be rested (...) into mergeRegister to clean up
|
182
185
|
* node transforms listeners that transforms text into another node, eg. a HashtagNode.
|
@@ -200,7 +203,7 @@ function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
|
|
200
203
|
const isTargetNode = node => {
|
201
204
|
return node instanceof targetNode;
|
202
205
|
};
|
203
|
-
const replaceWithSimpleText = node => {
|
206
|
+
const $replaceWithSimpleText = node => {
|
204
207
|
const textNode = $createTextNode(node.getTextContent());
|
205
208
|
textNode.setFormat(node.getFormat());
|
206
209
|
node.replace(textNode);
|
@@ -208,11 +211,11 @@ function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
|
|
208
211
|
const getMode = node => {
|
209
212
|
return node.getLatest().__mode;
|
210
213
|
};
|
211
|
-
const textNodeTransform = node => {
|
214
|
+
const $textNodeTransform = node => {
|
212
215
|
if (!node.isSimpleText()) {
|
213
216
|
return;
|
214
217
|
}
|
215
|
-
|
218
|
+
let prevSibling = node.getPreviousSibling();
|
216
219
|
let text = node.getTextContent();
|
217
220
|
let currentNode = node;
|
218
221
|
let match;
|
@@ -222,7 +225,7 @@ function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
|
|
222
225
|
const prevMatch = getMatch(combinedText);
|
223
226
|
if (isTargetNode(prevSibling)) {
|
224
227
|
if (prevMatch === null || getMode(prevSibling) !== 0) {
|
225
|
-
replaceWithSimpleText(prevSibling);
|
228
|
+
$replaceWithSimpleText(prevSibling);
|
226
229
|
return;
|
227
230
|
} else {
|
228
231
|
const diff = prevMatch.end - previousText.length;
|
@@ -244,7 +247,7 @@ function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
|
|
244
247
|
return;
|
245
248
|
}
|
246
249
|
}
|
247
|
-
|
250
|
+
let prevMatchLengthToSkip = 0;
|
248
251
|
// eslint-disable-next-line no-constant-condition
|
249
252
|
while (true) {
|
250
253
|
match = getMatch(text);
|
@@ -257,7 +260,7 @@ function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
|
|
257
260
|
const nextMatch = getMatch(nextText);
|
258
261
|
if (nextMatch === null) {
|
259
262
|
if (isTargetNode(nextSibling)) {
|
260
|
-
replaceWithSimpleText(nextSibling);
|
263
|
+
$replaceWithSimpleText(nextSibling);
|
261
264
|
} else {
|
262
265
|
nextSibling.markDirty();
|
263
266
|
}
|
@@ -266,23 +269,22 @@ function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
|
|
266
269
|
return;
|
267
270
|
}
|
268
271
|
}
|
269
|
-
} else {
|
270
|
-
const nextMatch = getMatch(nextText);
|
271
|
-
if (nextMatch !== null && nextMatch.start === 0) {
|
272
|
-
return;
|
273
|
-
}
|
274
272
|
}
|
275
273
|
if (match === null) {
|
276
274
|
return;
|
277
275
|
}
|
278
276
|
if (match.start === 0 && $isTextNode(prevSibling) && prevSibling.isTextEntity()) {
|
277
|
+
prevMatchLengthToSkip += match.end;
|
279
278
|
continue;
|
280
279
|
}
|
281
280
|
let nodeToReplace;
|
282
281
|
if (match.start === 0) {
|
283
282
|
[nodeToReplace, currentNode] = currentNode.splitText(match.end);
|
284
283
|
} else {
|
285
|
-
[, nodeToReplace, currentNode] = currentNode.splitText(match.start, match.end);
|
284
|
+
[, nodeToReplace, currentNode] = currentNode.splitText(match.start + prevMatchLengthToSkip, match.end + prevMatchLengthToSkip);
|
285
|
+
}
|
286
|
+
if (!(nodeToReplace !== undefined)) {
|
287
|
+
throw Error(`${'nodeToReplace'} should not be undefined. You may want to check splitOffsets passed to the splitText.`);
|
286
288
|
}
|
287
289
|
const replacementNode = createNode(nodeToReplace);
|
288
290
|
replacementNode.setFormat(nodeToReplace.getFormat());
|
@@ -290,13 +292,15 @@ function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
|
|
290
292
|
if (currentNode == null) {
|
291
293
|
return;
|
292
294
|
}
|
295
|
+
prevMatchLengthToSkip = 0;
|
296
|
+
prevSibling = replacementNode;
|
293
297
|
}
|
294
298
|
};
|
295
|
-
const reverseNodeTransform = node => {
|
299
|
+
const $reverseNodeTransform = node => {
|
296
300
|
const text = node.getTextContent();
|
297
301
|
const match = getMatch(text);
|
298
302
|
if (match === null || match.start !== 0) {
|
299
|
-
replaceWithSimpleText(node);
|
303
|
+
$replaceWithSimpleText(node);
|
300
304
|
return;
|
301
305
|
}
|
302
306
|
if (text.length > match.end) {
|
@@ -306,21 +310,21 @@ function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
|
|
306
310
|
}
|
307
311
|
const prevSibling = node.getPreviousSibling();
|
308
312
|
if ($isTextNode(prevSibling) && prevSibling.isTextEntity()) {
|
309
|
-
replaceWithSimpleText(prevSibling);
|
310
|
-
replaceWithSimpleText(node);
|
313
|
+
$replaceWithSimpleText(prevSibling);
|
314
|
+
$replaceWithSimpleText(node);
|
311
315
|
}
|
312
316
|
const nextSibling = node.getNextSibling();
|
313
317
|
if ($isTextNode(nextSibling) && nextSibling.isTextEntity()) {
|
314
|
-
replaceWithSimpleText(nextSibling);
|
318
|
+
$replaceWithSimpleText(nextSibling);
|
315
319
|
|
316
320
|
// This may have already been converted in the previous block
|
317
321
|
if (isTargetNode(node)) {
|
318
|
-
replaceWithSimpleText(node);
|
322
|
+
$replaceWithSimpleText(node);
|
319
323
|
}
|
320
324
|
}
|
321
325
|
};
|
322
|
-
const removePlainTextTransform = editor.registerNodeTransform(TextNode, textNodeTransform);
|
323
|
-
const removeReverseNodeTransform = editor.registerNodeTransform(targetNode, reverseNodeTransform);
|
326
|
+
const removePlainTextTransform = editor.registerNodeTransform(TextNode, $textNodeTransform);
|
327
|
+
const removeReverseNodeTransform = editor.registerNodeTransform(targetNode, $reverseNodeTransform);
|
324
328
|
return [removePlainTextTransform, removeReverseNodeTransform];
|
325
329
|
}
|
326
330
|
|
package/LexicalText.js
CHANGED
@@ -3,7 +3,9 @@
|
|
3
3
|
*
|
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
|
*/
|
8
|
+
|
7
9
|
'use strict'
|
8
10
|
const LexicalText = process.env.NODE_ENV === 'development' ? require('./LexicalText.dev.js') : require('./LexicalText.prod.js');
|
9
11
|
module.exports = LexicalText;
|
package/LexicalText.mjs
CHANGED
@@ -3,7 +3,9 @@
|
|
3
3
|
*
|
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
|
*/
|
8
|
+
|
7
9
|
import * as modDev from './LexicalText.dev.mjs';
|
8
10
|
import * as modProd from './LexicalText.prod.mjs';
|
9
11
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
package/LexicalText.node.mjs
CHANGED
@@ -3,7 +3,9 @@
|
|
3
3
|
*
|
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
|
*/
|
8
|
+
|
7
9
|
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalText.dev.mjs') : import('./LexicalText.prod.mjs'));
|
8
10
|
export const $canShowPlaceholder = mod.$canShowPlaceholder;
|
9
11
|
export const $canShowPlaceholderCurry = mod.$canShowPlaceholderCurry;
|
package/LexicalText.prod.js
CHANGED
@@ -3,10 +3,13 @@
|
|
3
3
|
*
|
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
|
*/
|
7
|
-
|
8
|
-
|
9
|
-
exports.$
|
10
|
-
exports
|
11
|
-
|
12
|
-
|
8
|
+
|
9
|
+
'use strict';var g=require("lexical");function r(){return g.$getRoot().getTextContent()}function u(b,e=!0){if(b)return!1;b=r();e&&(b=b.trim());return""===b}function v(b){if(!u(b,!1))return!1;b=g.$getRoot().getChildren();let e=b.length;if(1<e)return!1;for(let f=0;f<e;f++){var a=b[f];if(g.$isDecoratorNode(a))return!1;if(g.$isElementNode(a)){if(!g.$isParagraphNode(a)||0!==a.__indent)return!1;a=a.getChildren();let n=a.length;for(let t=0;t<n;t++)if(!g.$isTextNode(a[f]))return!1}}return!0}var w;
|
10
|
+
function x(b){let e=new URLSearchParams;e.append("code",b);for(let a=1;a<arguments.length;a++)e.append("v",arguments[a]);throw Error(`Minified Lexical error #${b}; visit https://lexical.dev/docs/error?${e} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}w=x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x["default"]:x;exports.$canShowPlaceholder=v;exports.$canShowPlaceholderCurry=function(b){return()=>v(b)};
|
11
|
+
exports.$findTextIntersectionFromCharacters=function(b,e){var a=b.getFirstChild();b=0;a:for(;null!==a;){if(g.$isElementNode(a)){var f=a.getFirstChild();if(null!==f){a=f;continue}}else if(g.$isTextNode(a)){f=a.getTextContentSize();if(b+f>e)return{node:a,offset:e-b};b+=f}f=a.getNextSibling();if(null!==f)a=f;else{for(a=a.getParent();null!==a;){f=a.getNextSibling();if(null!==f){a=f;continue a}a=a.getParent()}break}}return null};exports.$isRootTextContentEmpty=u;
|
12
|
+
exports.$isRootTextContentEmptyCurry=function(b,e){return()=>u(b,e)};exports.$rootTextContent=r;
|
13
|
+
exports.registerLexicalTextEntity=function(b,e,a,f){let n=d=>{const c=g.$createTextNode(d.getTextContent());c.setFormat(d.getFormat());d.replace(c)},t=b.registerNodeTransform(g.TextNode,d=>{if(d.isSimpleText()){var c=d.getPreviousSibling(),k=d.getTextContent(),m=d;if(g.$isTextNode(c)){var l=c.getTextContent();var h=e(l+k);if(c instanceof a){if(null===h||0!==c.getLatest().__mode){n(c);return}h=h.end-l.length;if(0<h){m=k.slice(0,h);m=l+m;c.select();c.setTextContent(m);h===k.length?d.remove():(k=k.slice(h),
|
14
|
+
d.setTextContent(k));return}}else if(null===h||h.start<l.length)return}for(d=0;;){l=e(k);var p=null===l?"":k.slice(l.end);k=p;if(""===p&&(h=m.getNextSibling(),g.$isTextNode(h)))if(p=m.getTextContent()+h.getTextContent(),p=e(p),null===p){h instanceof a?n(h):h.markDirty();break}else if(0!==p.start)break;if(null===l)break;if(0===l.start&&g.$isTextNode(c)&&c.isTextEntity()){d+=l.end;continue}let q;0===l.start?[q,m]=m.splitText(l.end):[,q,m]=m.splitText(l.start+d,l.end+d);void 0===q&&w(165,"nodeToReplace");
|
15
|
+
c=f(q);c.setFormat(q.getFormat());q.replace(c);if(null==m)break;d=0}}});b=b.registerNodeTransform(a,d=>{var c=d.getTextContent();const k=e(c);null===k||0!==k.start?n(d):c.length>k.end?d.splitText(k.end):(c=d.getPreviousSibling(),g.$isTextNode(c)&&c.isTextEntity()&&(n(c),n(d)),c=d.getNextSibling(),g.$isTextNode(c)&&c.isTextEntity()&&(n(c),d instanceof a&&n(d)))});return[t,b]}
|
package/LexicalText.prod.mjs
CHANGED
@@ -3,5 +3,7 @@
|
|
3
3
|
*
|
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
|
*/
|
7
|
-
|
8
|
+
|
9
|
+
import{$getRoot as t,$isDecoratorNode as e,$isElementNode as n,$isParagraphNode as r,$isTextNode as i,TextNode as o,$createTextNode as l}from"lexical";function s(){return t().getTextContent()}function u(t,e=!0){if(t)return!1;let n=s();return e&&(n=n.trim()),""===n}function f(t,e){return()=>u(t,e)}function c(o){if(!u(o,!1))return!1;const l=t().getChildren(),s=l.length;if(s>1)return!1;for(let t=0;t<s;t++){const o=l[t];if(e(o))return!1;if(n(o)){if(!r(o))return!1;if(0!==o.__indent)return!1;const e=o.getChildren(),n=e.length;for(let r=0;r<n;r++){const n=e[t];if(!i(n))return!1}}}return!0}function g(t){return()=>c(t)}function a(t,e){let r=t.getFirstChild(),o=0;t:for(;null!==r;){if(n(r)){const t=r.getFirstChild();if(null!==t){r=t;continue}}else if(i(r)){const t=r.getTextContentSize();if(o+t>e)return{node:r,offset:e-o};o+=t}const t=r.getNextSibling();if(null!==t){r=t;continue}let l=r.getParent();for(;null!==l;){const t=l.getNextSibling();if(null!==t){r=t;continue t}l=l.getParent()}break}return null}function d(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var x=d((function(t){const e=new URLSearchParams;e.append("code",t);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${t}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));function T(t,e,n,r){const s=t=>t instanceof n,u=t=>{const e=l(t.getTextContent());e.setFormat(t.getFormat()),t.replace(e)};return[t.registerNodeTransform(o,(t=>{if(!t.isSimpleText())return;let n,o=t.getPreviousSibling(),l=t.getTextContent(),f=t;if(i(o)){const n=o.getTextContent(),r=e(n+l);if(s(o)){if(null===r||0!==(t=>t.getLatest().__mode)(o))return void u(o);{const e=r.end-n.length;if(e>0){const r=n+l.slice(0,e);if(o.select(),o.setTextContent(r),e===l.length)t.remove();else{const n=l.slice(e);t.setTextContent(n)}return}}}else if(null===r||r.start<n.length)return}let c=0;for(;;){n=e(l);let t,g=null===n?"":l.slice(n.end);if(l=g,""===g){const t=f.getNextSibling();if(i(t)){g=f.getTextContent()+t.getTextContent();const n=e(g);if(null===n)return void(s(t)?u(t):t.markDirty());if(0!==n.start)return}}if(null===n)return;if(0===n.start&&i(o)&&o.isTextEntity()){c+=n.end;continue}0===n.start?[t,f]=f.splitText(n.end):[,t,f]=f.splitText(n.start+c,n.end+c),void 0===t&&x(165,"nodeToReplace");const a=r(t);if(a.setFormat(t.getFormat()),t.replace(a),null==f)return;c=0,o=a}})),t.registerNodeTransform(n,(t=>{const n=t.getTextContent(),r=e(n);if(null===r||0!==r.start)return void u(t);if(n.length>r.end)return void t.splitText(r.end);const o=t.getPreviousSibling();i(o)&&o.isTextEntity()&&(u(o),u(t));const l=t.getNextSibling();i(l)&&l.isTextEntity()&&(u(l),s(t)&&u(t))}))]}export{c as $canShowPlaceholder,g as $canShowPlaceholderCurry,a as $findTextIntersectionFromCharacters,u as $isRootTextContentEmpty,f as $isRootTextContentEmptyCurry,s as $rootTextContent,T as registerLexicalTextEntity};
|
package/package.json
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
"text"
|
10
10
|
],
|
11
11
|
"license": "MIT",
|
12
|
-
"version": "0.
|
12
|
+
"version": "0.16.0",
|
13
13
|
"main": "LexicalText.js",
|
14
14
|
"types": "index.d.ts",
|
15
15
|
"repository": {
|
@@ -37,6 +37,6 @@
|
|
37
37
|
}
|
38
38
|
},
|
39
39
|
"dependencies": {
|
40
|
-
"lexical": "0.
|
40
|
+
"lexical": "0.16.0"
|
41
41
|
}
|
42
42
|
}
|