@lexical/text 0.9.2 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -294,6 +294,7 @@ function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
294
294
  }
295
295
 
296
296
  const replacementNode = createNode(nodeToReplace);
297
+ replacementNode.setFormat(nodeToReplace.getFormat());
297
298
  nodeToReplace.replace(replacementNode);
298
299
 
299
300
  if (currentNode == null) {
@@ -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 g=require("lexical");function r(c,h=!0){if(c)return!1;c=t();h&&(c=c.trim());return""===c}function t(){return g.$getRoot().getTextContent()}function u(c){if(!r(c,!1))return!1;c=g.$getRoot().getChildren();let h=c.length;if(1<h)return!1;for(let e=0;e<h;e++){var a=c[e];if(g.$isDecoratorNode(a))return!1;if(g.$isElementNode(a)){if(!g.$isParagraphNode(a)||0!==a.__indent)return!1;a=a.getChildren();let n=a.length;for(let p=0;p<n;p++)if(!g.$isTextNode(a[e]))return!1}}return!0}
8
- exports.$canShowPlaceholder=u;exports.$canShowPlaceholderCurry=function(c){return()=>u(c)};exports.$findTextIntersectionFromCharacters=function(c,h){var a=c.getFirstChild();c=0;a:for(;null!==a;){if(g.$isElementNode(a)){var e=a.getFirstChild();if(null!==e){a=e;continue}}else if(g.$isTextNode(a)){e=a.getTextContentSize();if(c+e>h)return{node:a,offset:h-c};c+=e}e=a.getNextSibling();if(null!==e)a=e;else{for(a=a.getParent();null!==a;){e=a.getNextSibling();if(null!==e){a=e;continue a}a=a.getParent()}break}}return null};
7
+ 'use strict';var g=require("lexical");function r(c,h=!0){if(c)return!1;c=t();h&&(c=c.trim());return""===c}function t(){return g.$getRoot().getTextContent()}function u(c){if(!r(c,!1))return!1;c=g.$getRoot().getChildren();let h=c.length;if(1<h)return!1;for(let e=0;e<h;e++){var b=c[e];if(g.$isDecoratorNode(b))return!1;if(g.$isElementNode(b)){if(!g.$isParagraphNode(b)||0!==b.__indent)return!1;b=b.getChildren();let n=b.length;for(let q=0;q<n;q++)if(!g.$isTextNode(b[e]))return!1}}return!0}
8
+ exports.$canShowPlaceholder=u;exports.$canShowPlaceholderCurry=function(c){return()=>u(c)};exports.$findTextIntersectionFromCharacters=function(c,h){var b=c.getFirstChild();c=0;a:for(;null!==b;){if(g.$isElementNode(b)){var e=b.getFirstChild();if(null!==e){b=e;continue}}else if(g.$isTextNode(b)){e=b.getTextContentSize();if(c+e>h)return{node:b,offset:h-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
9
  exports.$isRootTextContentEmpty=r;exports.$isRootTextContentEmptyCurry=function(c,h){return()=>r(c,h)};exports.$rootTextContent=t;
10
- exports.registerLexicalTextEntity=function(c,h,a,e){let n=b=>{const d=g.$createTextNode(b.getTextContent());d.setFormat(b.getFormat());b.replace(d)},p=c.registerNodeTransform(g.TextNode,b=>{if(b.isSimpleText()){var d=b.getPreviousSibling(),l=b.getTextContent(),m=b;if(g.$isTextNode(d)){var k=d.getTextContent(),f=h(k+l);if(d instanceof a){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?b.remove():(d=l.slice(f),
11
- b.setTextContent(d));return}}else if(null===f||f.start<k.length)return}for(;;){b=h(l);l=f=null===b?"":l.slice(b.end);if(""===f){if(k=m.getNextSibling(),g.$isTextNode(k))if(f=m.getTextContent()+k.getTextContent(),f=h(f),null===f){k instanceof a?n(k):k.markDirty();break}else if(0!==f.start)break}else if(k=h(f),null!==k&&0===k.start)break;if(null===b)break;if(0===b.start&&g.$isTextNode(d)&&d.isTextEntity())continue;let q;0===b.start?[q,m]=m.splitText(b.end):[,q,m]=m.splitText(b.start,b.end);b=e(q);q.replace(b);
12
- if(null==m)break}}});c=c.registerNodeTransform(a,b=>{var d=b.getTextContent();const l=h(d);null===l||0!==l.start?n(b):d.length>l.end?b.splitText(l.end):(d=b.getPreviousSibling(),g.$isTextNode(d)&&d.isTextEntity()&&(n(d),n(b)),d=b.getNextSibling(),g.$isTextNode(d)&&d.isTextEntity()&&(n(d),b instanceof a&&n(b)))});return[p,c]}
10
+ exports.registerLexicalTextEntity=function(c,h,b,e){let n=a=>{const d=g.$createTextNode(a.getTextContent());d.setFormat(a.getFormat());a.replace(d)},q=c.registerNodeTransform(g.TextNode,a=>{if(a.isSimpleText()){var d=a.getPreviousSibling(),l=a.getTextContent(),m=a;if(g.$isTextNode(d)){var k=d.getTextContent(),f=h(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=h(l);l=f=null===a?"":l.slice(a.end);if(""===f){if(k=m.getNextSibling(),g.$isTextNode(k))if(f=m.getTextContent()+k.getTextContent(),f=h(f),null===f){k instanceof b?n(k):k.markDirty();break}else if(0!==f.start)break}else if(k=h(f),null!==k&&0===k.start)break;if(null===a)break;if(0===a.start&&g.$isTextNode(d)&&d.isTextEntity())continue;let p;0===a.start?[p,m]=m.splitText(a.end):[,p,m]=m.splitText(a.start,a.end);a=e(p);a.setFormat(p.getFormat());
12
+ p.replace(a);if(null==m)break}}});c=c.registerNodeTransform(b,a=>{var d=a.getTextContent();const l=h(d);null===l||0!==l.start?n(a):d.length>l.end?a.splitText(l.end):(d=a.getPreviousSibling(),g.$isTextNode(d)&&d.isTextEntity()&&(n(d),n(a)),d=a.getNextSibling(),g.$isTextNode(d)&&d.isTextEntity()&&(n(d),a instanceof b&&n(a)))});return[q,c]}
package/package.json CHANGED
@@ -9,10 +9,10 @@
9
9
  "text"
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "0.9.2",
12
+ "version": "0.11.0",
13
13
  "main": "LexicalText.js",
14
14
  "peerDependencies": {
15
- "lexical": "0.9.2"
15
+ "lexical": "0.11.0"
16
16
  },
17
17
  "repository": {
18
18
  "type": "git",