@lexical/text
Advanced tools
Comparing version 0.6.5 to 0.7.0
@@ -22,4 +22,4 @@ /** @module @lexical/text */ | ||
export declare function $rootTextContent(): string; | ||
export declare function $canShowPlaceholder(isComposing: boolean, isEditable: boolean): boolean; | ||
export declare function $canShowPlaceholderCurry(isEditorComposing: boolean, isEditable: boolean): () => boolean; | ||
export declare function $canShowPlaceholder(isComposing: boolean): boolean; | ||
export declare function $canShowPlaceholderCurry(isEditorComposing: boolean): () => boolean; | ||
export declare type EntityMatch = { | ||
@@ -26,0 +26,0 @@ end: number; |
@@ -82,4 +82,4 @@ /** | ||
} | ||
function $canShowPlaceholder(isComposing, isEditable) { | ||
if (!isEditable || !$isRootTextContentEmpty(isComposing, false)) { | ||
function $canShowPlaceholder(isComposing) { | ||
if (!$isRootTextContentEmpty(isComposing, false)) { | ||
return false; | ||
@@ -123,4 +123,4 @@ } | ||
} | ||
function $canShowPlaceholderCurry(isEditorComposing, isEditable) { | ||
return () => $canShowPlaceholder(isEditorComposing, isEditable); | ||
function $canShowPlaceholderCurry(isEditorComposing) { | ||
return () => $canShowPlaceholder(isEditorComposing); | ||
} | ||
@@ -127,0 +127,0 @@ function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) { |
@@ -7,7 +7,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; | ||
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}; | ||
exports.$isRootTextContentEmpty=r;exports.$isRootTextContentEmptyCurry=function(c,e){return()=>r(c,e)};exports.$rootTextContent=t; | ||
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), | ||
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); | ||
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]} | ||
'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; | ||
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}; | ||
exports.$isRootTextContentEmpty=r;exports.$isRootTextContentEmptyCurry=function(c,g){return()=>r(c,g)};exports.$rootTextContent=t; | ||
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), | ||
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); | ||
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]} |
@@ -12,6 +12,6 @@ { | ||
"license": "MIT", | ||
"version": "0.6.5", | ||
"version": "0.7.0", | ||
"main": "LexicalText.js", | ||
"peerDependencies": { | ||
"lexical": "0.6.5" | ||
"lexical": "0.7.0" | ||
}, | ||
@@ -18,0 +18,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14783