@lexical/text 0.3.3 → 0.3.6
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 +2 -2
- package/index.d.ts +29 -0
- package/package.json +2 -5
- package/LexicalText.d.ts +0 -56
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,8 +4,8 @@
|
|
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
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;
|
package/index.d.ts
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
*/
|
8
|
+
import type { ElementNode, Klass, LexicalEditor, RootNode } from 'lexical';
|
9
|
+
import { TextNode } from 'lexical';
|
10
|
+
export declare type TextNodeWithOffset = {
|
11
|
+
node: TextNode;
|
12
|
+
offset: number;
|
13
|
+
};
|
14
|
+
export declare function $findTextIntersectionFromCharacters(root: RootNode, targetCharacters: number): null | {
|
15
|
+
node: TextNode;
|
16
|
+
offset: number;
|
17
|
+
};
|
18
|
+
export declare function $joinTextNodesInElementNode(elementNode: ElementNode, separator: string, stopAt: TextNodeWithOffset): string;
|
19
|
+
export declare function $findNodeWithOffsetFromJoinedText(offsetInJoinedText: number, joinedTextLength: number, separatorLength: number, elementNode: ElementNode): TextNodeWithOffset | null;
|
20
|
+
export declare function $isRootTextContentEmpty(isEditorComposing: boolean, trim?: boolean): boolean;
|
21
|
+
export declare function $isRootTextContentEmptyCurry(isEditorComposing: boolean, trim?: boolean): () => boolean;
|
22
|
+
export declare function $rootTextContent(): string;
|
23
|
+
export declare function $canShowPlaceholder(isComposing: boolean, isReadOnly?: boolean): boolean;
|
24
|
+
export declare function $canShowPlaceholderCurry(isEditorComposing: boolean, isReadOnly?: boolean): () => boolean;
|
25
|
+
export declare type EntityMatch = {
|
26
|
+
end: number;
|
27
|
+
start: number;
|
28
|
+
};
|
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.6",
|
13
13
|
"main": "LexicalText.js",
|
14
14
|
"peerDependencies": {
|
15
|
-
"lexical": "0.3.
|
15
|
+
"lexical": "0.3.6"
|
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
|
}
|
package/LexicalText.d.ts
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
-
*
|
4
|
-
* This source code is licensed under the MIT license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*
|
7
|
-
*/
|
8
|
-
|
9
|
-
import type {ElementNode, LexicalEditor, RootNode, TextNode} from 'lexical';
|
10
|
-
import {Class} from 'utility-types';
|
11
|
-
|
12
|
-
export type TextNodeWithOffset = {
|
13
|
-
node: TextNode;
|
14
|
-
offset: number;
|
15
|
-
};
|
16
|
-
export function $findTextIntersectionFromCharacters(
|
17
|
-
root: RootNode,
|
18
|
-
targetCharacters: number,
|
19
|
-
): null | {
|
20
|
-
node: TextNode;
|
21
|
-
offset: number;
|
22
|
-
};
|
23
|
-
export function $joinTextNodesInElementNode(
|
24
|
-
elementNode: ElementNode,
|
25
|
-
separator: string,
|
26
|
-
stopAt: TextNodeWithOffset,
|
27
|
-
): string;
|
28
|
-
export function $findNodeWithOffsetFromJoinedText(
|
29
|
-
offsetInJoinedText: number,
|
30
|
-
joinedTextLength: number,
|
31
|
-
separatorLength: number,
|
32
|
-
elementNode: ElementNode,
|
33
|
-
): TextNodeWithOffset | null | undefined;
|
34
|
-
export function $isRootTextContentEmpty(
|
35
|
-
isEditorComposing: boolean,
|
36
|
-
trim?: boolean,
|
37
|
-
): boolean;
|
38
|
-
export function $isRootTextContentEmptyCurry(
|
39
|
-
isEditorComposing: boolean,
|
40
|
-
trim?: boolean,
|
41
|
-
): () => boolean;
|
42
|
-
export function $rootTextContent(): string;
|
43
|
-
export function $canShowPlaceholder(isComposing: boolean): boolean;
|
44
|
-
export function $canShowPlaceholderCurry(
|
45
|
-
isEditorComposing: boolean,
|
46
|
-
): () => boolean;
|
47
|
-
export type EntityMatch = {
|
48
|
-
end: number;
|
49
|
-
start: number;
|
50
|
-
};
|
51
|
-
export function registerLexicalTextEntity<N extends TextNode>(
|
52
|
-
editor: LexicalEditor,
|
53
|
-
getMatch: (text: string) => null | EntityMatch,
|
54
|
-
targetNode: Class<N>,
|
55
|
-
createNode: (textNode: TextNode) => N,
|
56
|
-
): Array<() => void>;
|