@lexical/text 0.6.5 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -79,8 +79,8 @@ function $rootTextContent() {
79
79
  const root = lexical.$getRoot();
80
80
  return root.getTextContent();
81
81
  }
82
- function $canShowPlaceholder(isComposing, isEditable) {
83
- if (!isEditable || !$isRootTextContentEmpty(isComposing, false)) {
82
+ function $canShowPlaceholder(isComposing) {
83
+ if (!$isRootTextContentEmpty(isComposing, false)) {
84
84
  return false;
85
85
  }
86
86
 
@@ -119,8 +119,8 @@ function $canShowPlaceholder(isComposing, isEditable) {
119
119
 
120
120
  return true;
121
121
  }
122
- function $canShowPlaceholderCurry(isEditorComposing, isEditable) {
123
- return () => $canShowPlaceholder(isEditorComposing, isEditable);
122
+ function $canShowPlaceholderCurry(isEditorComposing) {
123
+ return () => $canShowPlaceholder(isEditorComposing);
124
124
  }
125
125
  function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
126
126
  const isTargetNode = node => {
@@ -4,9 +4,9 @@
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 h=require("lexical");function r(c,e=!0){if(c)return!1;c=t();e&&(c=c.trim());return""===c}function t(){return h.$getRoot().getTextContent()}function u(c,e){if(!e||!r(c,!1))return!1;c=h.$getRoot().getChildren();e=c.length;if(1<e)return!1;for(let f=0;f<e;f++){var b=c[f];if(h.$isElementNode(b)){if("paragraph"!==b.__type||0!==b.__indent)return!1;b=b.getChildren();let n=b.length;for(let p=0;p<n;p++)if(!h.$isTextNode(b[f]))return!1}}return!0}exports.$canShowPlaceholder=u;
8
- exports.$canShowPlaceholderCurry=function(c,e){return()=>u(c,e)};exports.$findTextIntersectionFromCharacters=function(c,e){var b=c.getFirstChild();c=0;a:for(;null!==b;){if(h.$isElementNode(b)){var f=b.getFirstChild();if(null!==f){b=f;continue}}else if(h.$isTextNode(b)){f=b.getTextContentSize();if(c+f>e)return{node:b,offset:e-c};c+=f}f=b.getNextSibling();if(null!==f)b=f;else{for(b=b.getParent();null!==b;){f=b.getNextSibling();if(null!==f){b=f;continue a}b=b.getParent()}break}}return null};
9
- exports.$isRootTextContentEmpty=r;exports.$isRootTextContentEmptyCurry=function(c,e){return()=>r(c,e)};exports.$rootTextContent=t;
10
- exports.registerLexicalTextEntity=function(c,e,b,f){let n=a=>{const d=h.$createTextNode(a.getTextContent());d.setFormat(a.getFormat());a.replace(d)},p=c.registerNodeTransform(h.TextNode,a=>{if(a.isSimpleText()){var d=a.getPreviousSibling(),l=a.getTextContent(),m=a;if(h.$isTextNode(d)){var k=d.getTextContent(),g=e(k+l);if(d instanceof b){if(null===g||0!==d.getLatest().__mode){n(d);return}g=g.end-k.length;if(0<g){m=l.slice(0,g);m=k+m;d.select();d.setTextContent(m);g===l.length?a.remove():(d=l.slice(g),
11
- a.setTextContent(d));return}}else if(null===g||g.start<k.length)return}for(;;){a=e(l);l=g=null===a?"":l.slice(a.end);if(""===g){if(k=m.getNextSibling(),h.$isTextNode(k))if(g=m.getTextContent()+k.getTextContent(),g=e(g),null===g){k instanceof b?n(k):k.markDirty();break}else if(0!==g.start)break}else if(k=e(g),null!==k&&0===k.start)break;if(null===a)break;if(0===a.start&&h.$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=f(q);q.replace(a);
12
- if(null==m)break}}});c=c.registerNodeTransform(b,a=>{var d=a.getTextContent();const l=e(d);null===l||0!==l.start?n(a):d.length>l.end?a.splitText(l.end):(d=a.getPreviousSibling(),h.$isTextNode(d)&&d.isTextEntity()&&(n(d),n(a)),d=a.getNextSibling(),h.$isTextNode(d)&&d.isTextEntity()&&(n(d),a instanceof b&&n(a)))});return[p,c]}
7
+ 'use strict';var h=require("lexical");function r(c,g=!0){if(c)return!1;c=t();g&&(c=c.trim());return""===c}function t(){return h.$getRoot().getTextContent()}function u(c){if(!r(c,!1))return!1;c=h.$getRoot().getChildren();let g=c.length;if(1<g)return!1;for(let e=0;e<g;e++){var b=c[e];if(h.$isElementNode(b)){if("paragraph"!==b.__type||0!==b.__indent)return!1;b=b.getChildren();let n=b.length;for(let p=0;p<n;p++)if(!h.$isTextNode(b[e]))return!1}}return!0}exports.$canShowPlaceholder=u;
8
+ exports.$canShowPlaceholderCurry=function(c){return()=>u(c)};exports.$findTextIntersectionFromCharacters=function(c,g){var b=c.getFirstChild();c=0;a:for(;null!==b;){if(h.$isElementNode(b)){var e=b.getFirstChild();if(null!==e){b=e;continue}}else if(h.$isTextNode(b)){e=b.getTextContentSize();if(c+e>g)return{node:b,offset:g-c};c+=e}e=b.getNextSibling();if(null!==e)b=e;else{for(b=b.getParent();null!==b;){e=b.getNextSibling();if(null!==e){b=e;continue a}b=b.getParent()}break}}return null};
9
+ exports.$isRootTextContentEmpty=r;exports.$isRootTextContentEmptyCurry=function(c,g){return()=>r(c,g)};exports.$rootTextContent=t;
10
+ exports.registerLexicalTextEntity=function(c,g,b,e){let n=a=>{const d=h.$createTextNode(a.getTextContent());d.setFormat(a.getFormat());a.replace(d)},p=c.registerNodeTransform(h.TextNode,a=>{if(a.isSimpleText()){var d=a.getPreviousSibling(),l=a.getTextContent(),m=a;if(h.$isTextNode(d)){var k=d.getTextContent(),f=g(k+l);if(d instanceof b){if(null===f||0!==d.getLatest().__mode){n(d);return}f=f.end-k.length;if(0<f){m=l.slice(0,f);m=k+m;d.select();d.setTextContent(m);f===l.length?a.remove():(d=l.slice(f),
11
+ a.setTextContent(d));return}}else if(null===f||f.start<k.length)return}for(;;){a=g(l);l=f=null===a?"":l.slice(a.end);if(""===f){if(k=m.getNextSibling(),h.$isTextNode(k))if(f=m.getTextContent()+k.getTextContent(),f=g(f),null===f){k instanceof b?n(k):k.markDirty();break}else if(0!==f.start)break}else if(k=g(f),null!==k&&0===k.start)break;if(null===a)break;if(0===a.start&&h.$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);
12
+ if(null==m)break}}});c=c.registerNodeTransform(b,a=>{var d=a.getTextContent();const l=g(d);null===l||0!==l.start?n(a):d.length>l.end?a.splitText(l.end):(d=a.getPreviousSibling(),h.$isTextNode(d)&&d.isTextEntity()&&(n(d),n(a)),d=a.getNextSibling(),h.$isTextNode(d)&&d.isTextEntity()&&(n(d),a instanceof b&&n(a)))});return[p,c]}
package/index.d.ts CHANGED
@@ -19,8 +19,8 @@ export declare function $findTextIntersectionFromCharacters(root: RootNode, targ
19
19
  export declare function $isRootTextContentEmpty(isEditorComposing: boolean, trim?: boolean): boolean;
20
20
  export declare function $isRootTextContentEmptyCurry(isEditorComposing: boolean, trim?: boolean): () => boolean;
21
21
  export declare function $rootTextContent(): string;
22
- export declare function $canShowPlaceholder(isComposing: boolean, isEditable: boolean): boolean;
23
- export declare function $canShowPlaceholderCurry(isEditorComposing: boolean, isEditable: boolean): () => boolean;
22
+ export declare function $canShowPlaceholder(isComposing: boolean): boolean;
23
+ export declare function $canShowPlaceholderCurry(isEditorComposing: boolean): () => boolean;
24
24
  export declare type EntityMatch = {
25
25
  end: number;
26
26
  start: number;
package/package.json CHANGED
@@ -9,10 +9,10 @@
9
9
  "text"
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "0.6.5",
12
+ "version": "0.7.0",
13
13
  "main": "LexicalText.js",
14
14
  "peerDependencies": {
15
- "lexical": "0.6.5"
15
+ "lexical": "0.7.0"
16
16
  },
17
17
  "repository": {
18
18
  "type": "git",