@lexical/text 0.3.5 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- package/LexicalText.dev.js +6 -4
- package/LexicalText.prod.js +4 -3
- package/index.d.ts +4 -5
- package/package.json +2 -5
package/LexicalText.dev.js
CHANGED
@@ -168,8 +168,9 @@ function $rootTextContent() {
|
|
168
168
|
const root = lexical.$getRoot();
|
169
169
|
return root.getTextContent();
|
170
170
|
}
|
171
|
-
function $canShowPlaceholder(isComposing
|
172
|
-
|
171
|
+
function $canShowPlaceholder(isComposing, // TODO 0.4 make mandatory
|
172
|
+
isReadOnly = false) {
|
173
|
+
if (isReadOnly || !$isRootTextContentEmpty(isComposing, false)) {
|
173
174
|
return false;
|
174
175
|
}
|
175
176
|
|
@@ -208,8 +209,9 @@ function $canShowPlaceholder(isComposing) {
|
|
208
209
|
|
209
210
|
return true;
|
210
211
|
}
|
211
|
-
function $canShowPlaceholderCurry(isEditorComposing
|
212
|
-
|
212
|
+
function $canShowPlaceholderCurry(isEditorComposing, // TODO 0.4 make mandatory
|
213
|
+
isReadOnly = false) {
|
214
|
+
return () => $canShowPlaceholder(isEditorComposing, isReadOnly);
|
213
215
|
}
|
214
216
|
function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
|
215
217
|
const isTargetNode = node => {
|
package/LexicalText.prod.js
CHANGED
@@ -4,11 +4,12 @@
|
|
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';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(
|
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};
|
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,f=!1){if(f||!r(b,!1))return!1;b=k.$getRoot().getChildren();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,f=!1){return()=>u(b,f)};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();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;
|
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; visit https://lexical.dev/docs/error?code=2 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};
|
12
|
+
exports.$rootTextContent=t;
|
12
13
|
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
14
|
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
15
|
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/index.d.ts
CHANGED
@@ -5,8 +5,7 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*
|
7
7
|
*/
|
8
|
-
import type { ElementNode, LexicalEditor, RootNode } from 'lexical';
|
9
|
-
import type { Klass } from 'shared/types';
|
8
|
+
import type { ElementNode, Klass, LexicalEditor, RootNode } from 'lexical';
|
10
9
|
import { TextNode } from 'lexical';
|
11
10
|
export declare type TextNodeWithOffset = {
|
12
11
|
node: TextNode;
|
@@ -21,10 +20,10 @@ export declare function $findNodeWithOffsetFromJoinedText(offsetInJoinedText: nu
|
|
21
20
|
export declare function $isRootTextContentEmpty(isEditorComposing: boolean, trim?: boolean): boolean;
|
22
21
|
export declare function $isRootTextContentEmptyCurry(isEditorComposing: boolean, trim?: boolean): () => boolean;
|
23
22
|
export declare function $rootTextContent(): string;
|
24
|
-
export declare function $canShowPlaceholder(isComposing: boolean): boolean;
|
25
|
-
export declare function $canShowPlaceholderCurry(isEditorComposing: boolean): () => boolean;
|
23
|
+
export declare function $canShowPlaceholder(isComposing: boolean, isReadOnly?: boolean): boolean;
|
24
|
+
export declare function $canShowPlaceholderCurry(isEditorComposing: boolean, isReadOnly?: boolean): () => boolean;
|
26
25
|
export declare type EntityMatch = {
|
27
26
|
end: number;
|
28
27
|
start: number;
|
29
28
|
};
|
30
|
-
export declare function registerLexicalTextEntity<
|
29
|
+
export declare function registerLexicalTextEntity<T extends TextNode>(editor: LexicalEditor, getMatch: (text: string) => null | EntityMatch, targetNode: Klass<T>, createNode: (textNode: TextNode) => T): Array<() => void>;
|
package/package.json
CHANGED
@@ -9,17 +9,14 @@
|
|
9
9
|
"text"
|
10
10
|
],
|
11
11
|
"license": "MIT",
|
12
|
-
"version": "0.3.
|
12
|
+
"version": "0.3.8",
|
13
13
|
"main": "LexicalText.js",
|
14
14
|
"peerDependencies": {
|
15
|
-
"lexical": "0.3.
|
15
|
+
"lexical": "0.3.8"
|
16
16
|
},
|
17
17
|
"repository": {
|
18
18
|
"type": "git",
|
19
19
|
"url": "https://github.com/facebook/lexical",
|
20
20
|
"directory": "packages/lexical-text"
|
21
|
-
},
|
22
|
-
"devDependencies": {
|
23
|
-
"utility-types": "^3.10.0"
|
24
21
|
}
|
25
22
|
}
|