@lexical/text 0.2.8 → 0.3.1
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/LexicalText.d.ts +3 -1
- package/LexicalText.dev.js +5 -5
- package/LexicalText.js.flow +1 -1
- package/LexicalText.prod.js +5 -5
- package/package.json +2 -2
package/LexicalText.d.ts
CHANGED
@@ -5,8 +5,10 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*
|
7
7
|
*/
|
8
|
+
|
8
9
|
import type {ElementNode, LexicalEditor, RootNode, TextNode} from 'lexical';
|
9
10
|
import {Class} from 'utility-types';
|
11
|
+
|
10
12
|
export type TextNodeWithOffset = {
|
11
13
|
node: TextNode;
|
12
14
|
offset: number;
|
@@ -37,7 +39,7 @@ export function $isRootTextContentEmptyCurry(
|
|
37
39
|
isEditorComposing: boolean,
|
38
40
|
trim?: boolean,
|
39
41
|
): () => boolean;
|
40
|
-
export function $
|
42
|
+
export function $rootTextContent(): string;
|
41
43
|
export function $canShowPlaceholder(isComposing: boolean): boolean;
|
42
44
|
export function $canShowPlaceholderCurry(
|
43
45
|
isEditorComposing: boolean,
|
package/LexicalText.dev.js
CHANGED
@@ -14,7 +14,6 @@ var lexical = require('lexical');
|
|
14
14
|
* This source code is licensed under the MIT license found in the
|
15
15
|
* LICENSE file in the root directory of this source tree.
|
16
16
|
*
|
17
|
-
*
|
18
17
|
*/
|
19
18
|
function $findTextIntersectionFromCharacters(root, targetCharacters) {
|
20
19
|
let node = root.getFirstChild();
|
@@ -154,7 +153,7 @@ function $isRootTextContentEmpty(isEditorComposing, trim = true) {
|
|
154
153
|
return false;
|
155
154
|
}
|
156
155
|
|
157
|
-
let text = $
|
156
|
+
let text = $rootTextContent();
|
158
157
|
|
159
158
|
if (trim) {
|
160
159
|
text = text.trim();
|
@@ -165,7 +164,7 @@ function $isRootTextContentEmpty(isEditorComposing, trim = true) {
|
|
165
164
|
function $isRootTextContentEmptyCurry(isEditorComposing, trim) {
|
166
165
|
return () => $isRootTextContentEmpty(isEditorComposing, trim);
|
167
166
|
}
|
168
|
-
function $
|
167
|
+
function $rootTextContent() {
|
169
168
|
const root = lexical.$getRoot();
|
170
169
|
return root.getTextContent();
|
171
170
|
}
|
@@ -268,7 +267,8 @@ function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
|
|
268
267
|
} else if (prevMatch === null || prevMatch.start < previousText.length) {
|
269
268
|
return;
|
270
269
|
}
|
271
|
-
}
|
270
|
+
} // eslint-disable-next-line no-constant-condition
|
271
|
+
|
272
272
|
|
273
273
|
while (true) {
|
274
274
|
match = getMatch(text);
|
@@ -372,5 +372,5 @@ exports.$findTextIntersectionFromCharacters = $findTextIntersectionFromCharacter
|
|
372
372
|
exports.$isRootTextContentEmpty = $isRootTextContentEmpty;
|
373
373
|
exports.$isRootTextContentEmptyCurry = $isRootTextContentEmptyCurry;
|
374
374
|
exports.$joinTextNodesInElementNode = $joinTextNodesInElementNode;
|
375
|
-
exports.$
|
375
|
+
exports.$rootTextContent = $rootTextContent;
|
376
376
|
exports.registerLexicalTextEntity = registerLexicalTextEntity;
|
package/LexicalText.js.flow
CHANGED
@@ -37,7 +37,7 @@ declare export function $isRootTextContentEmptyCurry(
|
|
37
37
|
isEditorComposing: boolean,
|
38
38
|
trim?: boolean,
|
39
39
|
): () => boolean;
|
40
|
-
declare export function $
|
40
|
+
declare export function $rootTextContent(): string;
|
41
41
|
declare export function $canShowPlaceholder(isComposing: boolean): boolean;
|
42
42
|
declare export function $canShowPlaceholderCurry(
|
43
43
|
isEditorComposing: boolean,
|
package/LexicalText.prod.js
CHANGED
@@ -4,11 +4,11 @@
|
|
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
|
-
var k=require("lexical");function r(b,f=!0){if(b)return!1;b=t();f&&(b=b.trim());return""===b}function t(){return k.$getRoot().getTextContent()}function u(b){if(!r(b,!1))return!1;b=k.$getRoot().getChildren();
|
8
|
-
exports.$canShowPlaceholderCurry=function(b){return()=>u(b)};exports.$findNodeWithOffsetFromJoinedText=function(b,f,c,e){e=e.getChildren();
|
7
|
+
'use strict';var k=require("lexical");function r(b,f=!0){if(b)return!1;b=t();f&&(b=b.trim());return""===b}function t(){return k.$getRoot().getTextContent()}function u(b){if(!r(b,!1))return!1;b=k.$getRoot().getChildren();let f=b.length;if(1<f)return!1;for(let e=0;e<f;e++){var c=b[e];if(k.$isElementNode(c)){if("paragraph"!==c.__type||0!==c.__indent)return!1;c=c.getChildren();let p=c.length;for(let g=0;g<p;g++)if(!k.$isTextNode(c[e]))return!1}}return!0}exports.$canShowPlaceholder=u;
|
8
|
+
exports.$canShowPlaceholderCurry=function(b){return()=>u(b)};exports.$findNodeWithOffsetFromJoinedText=function(b,f,c,e){e=e.getChildren();let p=e.length,g=0,a=!1;for(let l=0;l<p&&!(g>f);++l){let m=e[l],n=k.$isTextNode(m);var d=n?m.getTextContent().length:c;d=g+d;if((!1===a&&g===b||0===g&&g===b||g<b&&b<=d)&&k.$isTextNode(m))return{node:m,offset:b-g};g=d;a=n}return null};
|
9
9
|
exports.$findTextIntersectionFromCharacters=function(b,f){var c=b.getFirstChild();b=0;a:for(;null!==c;){if(k.$isElementNode(c)){var e=c.getFirstChild();if(null!==e){c=e;continue}}else if(k.$isTextNode(c)){e=c.getTextContentSize();if(b+e>f)return{node:c,offset:f-b};b+=e}e=c.getNextSibling();if(null!==e)c=e;else{for(c=c.getParent();null!==c;){e=c.getNextSibling();if(null!==e){c=e;continue a}c=c.getParent()}break}}return null};exports.$isRootTextContentEmpty=r;
|
10
10
|
exports.$isRootTextContentEmptyCurry=function(b,f){return()=>r(b,f)};
|
11
|
-
exports.$joinTextNodesInElementNode=function(b,f,c){let e="";b=b.getChildren();
|
12
|
-
exports.registerLexicalTextEntity=function(b,f,c,e){
|
11
|
+
exports.$joinTextNodesInElementNode=function(b,f,c){let e="";b=b.getChildren();let p=b.length;for(let g=0;g<p;++g){let a=b[g];if(k.$isTextNode(a)){let d=a.getTextContent();if(a.is(c.node)){if(c.offset>d.length)throw Error("Minified Lexical error #2; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");e+=a.getTextContent().substr(0,c.offset);break}else e+=d}else e+=f}return e};exports.$rootTextContent=t;
|
12
|
+
exports.registerLexicalTextEntity=function(b,f,c,e){let p=a=>{const d=k.$createTextNode(a.getTextContent());d.setFormat(a.getFormat());a.replace(d)},g=b.registerNodeTransform(k.TextNode,a=>{if(a.isSimpleText()){var d=a.getPreviousSibling(),l=a.getTextContent(),m=a;if(k.$isTextNode(d)){var n=d.getTextContent(),h=f(n+l);if(d instanceof c){if(null===h||0!==d.getLatest().__mode){p(d);return}h=h.end-n.length;if(0<h){m=l.slice(0,h);m=n+m;d.select();d.setTextContent(m);h===l.length?a.remove():(d=l.slice(h),
|
13
13
|
a.setTextContent(d));return}}else if(null===h||h.start<n.length)return}for(;;){a=f(l);l=h=null===a?"":l.slice(a.end);if(""===h){if(n=m.getNextSibling(),k.$isTextNode(n))if(h=m.getTextContent()+n.getTextContent(),h=f(h),null===h){n instanceof c?p(n):n.markDirty();break}else if(0!==h.start)break}else if(n=f(h),null!==n&&0===n.start)break;if(null===a)break;if(0===a.start&&k.$isTextNode(d)&&d.isTextEntity())continue;let q;0===a.start?[q,m]=m.splitText(a.end):[,q,m]=m.splitText(a.start,a.end);a=e(q);q.replace(a);
|
14
|
-
if(null==m)break}}});b=b.registerNodeTransform(c,a=>{var d=a.getTextContent();const l=f(d);null===l||0!==l.start?p(a):d.length>l.end?a.splitText(l.end):(d=a.getPreviousSibling(),k.$isTextNode(d)&&d.isTextEntity()&&(p(d),p(a)),d=a.getNextSibling(),k.$isTextNode(d)&&d.isTextEntity()&&(p(d),a instanceof c&&p(a)))});return[g,b]}
|
14
|
+
if(null==m)break}}});b=b.registerNodeTransform(c,a=>{var d=a.getTextContent();const l=f(d);null===l||0!==l.start?p(a):d.length>l.end?a.splitText(l.end):(d=a.getPreviousSibling(),k.$isTextNode(d)&&d.isTextEntity()&&(p(d),p(a)),d=a.getNextSibling(),k.$isTextNode(d)&&d.isTextEntity()&&(p(d),a instanceof c&&p(a)))});return[g,b]}
|
package/package.json
CHANGED