@lexical/text 0.3.10 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,13 +8,7 @@
8
8
 
9
9
  var lexical = require('lexical');
10
10
 
11
- /**
12
- * Copyright (c) Meta Platforms, Inc. and affiliates.
13
- *
14
- * This source code is licensed under the MIT license found in the
15
- * LICENSE file in the root directory of this source tree.
16
- *
17
- */
11
+ /** @module @lexical/text */
18
12
  function $findTextIntersectionFromCharacters(root, targetCharacters) {
19
13
  let node = root.getFirstChild();
20
14
  let currentCharacters = 0;
@@ -168,9 +162,9 @@ function $rootTextContent() {
168
162
  const root = lexical.$getRoot();
169
163
  return root.getTextContent();
170
164
  }
171
- function $canShowPlaceholder(isComposing, // TODO 0.4 make mandatory
172
- isReadOnly = false) {
173
- if (isReadOnly || !$isRootTextContentEmpty(isComposing, false)) {
165
+ function $canShowPlaceholder(isComposing, // TODO 0.5 make mandatory
166
+ isEditable = true) {
167
+ if (!isEditable || !$isRootTextContentEmpty(isComposing, false)) {
174
168
  return false;
175
169
  }
176
170
 
@@ -209,9 +203,9 @@ isReadOnly = false) {
209
203
 
210
204
  return true;
211
205
  }
212
- function $canShowPlaceholderCurry(isEditorComposing, // TODO 0.4 make mandatory
213
- isReadOnly = false) {
214
- return () => $canShowPlaceholder(isEditorComposing, isReadOnly);
206
+ function $canShowPlaceholderCurry(isEditorComposing, // TODO 0.5 make mandatory
207
+ isEditable = true) {
208
+ return () => $canShowPlaceholder(isEditorComposing, isEditable);
215
209
  }
216
210
  function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
217
211
  const isTargetNode = node => {
@@ -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,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};
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=!0){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=!0){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; 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};
package/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /** @module @lexical/text */
1
2
  /**
2
3
  * Copyright (c) Meta Platforms, Inc. and affiliates.
3
4
  *
@@ -20,8 +21,8 @@ export declare function $findNodeWithOffsetFromJoinedText(offsetInJoinedText: nu
20
21
  export declare function $isRootTextContentEmpty(isEditorComposing: boolean, trim?: boolean): boolean;
21
22
  export declare function $isRootTextContentEmptyCurry(isEditorComposing: boolean, trim?: boolean): () => boolean;
22
23
  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;
24
+ export declare function $canShowPlaceholder(isComposing: boolean, isEditable?: boolean): boolean;
25
+ export declare function $canShowPlaceholderCurry(isEditorComposing: boolean, isEditable?: boolean): () => boolean;
25
26
  export declare type EntityMatch = {
26
27
  end: number;
27
28
  start: number;
package/package.json CHANGED
@@ -9,10 +9,10 @@
9
9
  "text"
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "0.3.10",
12
+ "version": "0.4.1",
13
13
  "main": "LexicalText.js",
14
14
  "peerDependencies": {
15
- "lexical": "0.3.10"
15
+ "lexical": "0.4.1"
16
16
  },
17
17
  "repository": {
18
18
  "type": "git",