@lexical/text
Advanced tools
Comparing version 0.3.5 to 0.3.6
@@ -8,4 +8,3 @@ /** | ||
*/ | ||
import type { ElementNode, LexicalEditor, RootNode } from 'lexical'; | ||
import type { Klass } from 'shared/types'; | ||
import type { ElementNode, Klass, LexicalEditor, RootNode } from 'lexical'; | ||
import { TextNode } from 'lexical'; | ||
@@ -25,4 +24,4 @@ export declare type TextNodeWithOffset = { | ||
export declare function $rootTextContent(): string; | ||
export declare function $canShowPlaceholder(isComposing: boolean): boolean; | ||
export declare function $canShowPlaceholderCurry(isEditorComposing: boolean): () => boolean; | ||
export declare function $canShowPlaceholder(isComposing: boolean, isReadOnly?: boolean): boolean; | ||
export declare function $canShowPlaceholderCurry(isEditorComposing: boolean, isReadOnly?: boolean): () => boolean; | ||
export declare type EntityMatch = { | ||
@@ -32,2 +31,2 @@ end: number; | ||
}; | ||
export declare function registerLexicalTextEntity<N extends TextNode>(editor: LexicalEditor, getMatch: (text: string) => null | EntityMatch, targetNode: Klass<N>, createNode: (textNode: TextNode) => N): Array<() => void>; | ||
export declare function registerLexicalTextEntity<T extends TextNode>(editor: LexicalEditor, getMatch: (text: string) => null | EntityMatch, targetNode: Klass<T>, createNode: (textNode: TextNode) => T): Array<() => void>; |
@@ -171,4 +171,5 @@ /** | ||
} | ||
function $canShowPlaceholder(isComposing) { | ||
if (!$isRootTextContentEmpty(isComposing, false)) { | ||
function $canShowPlaceholder(isComposing, // TODO 0.4 make mandatory | ||
isReadOnly = false) { | ||
if (isReadOnly || !$isRootTextContentEmpty(isComposing, false)) { | ||
return false; | ||
@@ -212,4 +213,5 @@ } | ||
} | ||
function $canShowPlaceholderCurry(isEditorComposing) { | ||
return () => $canShowPlaceholder(isEditorComposing); | ||
function $canShowPlaceholderCurry(isEditorComposing, // TODO 0.4 make mandatory | ||
isReadOnly = false) { | ||
return () => $canShowPlaceholder(isEditorComposing, isReadOnly); | ||
} | ||
@@ -216,0 +218,0 @@ function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) { |
@@ -7,4 +7,4 @@ /** | ||
*/ | ||
'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(!r(b,!1))return!1;b=k.$getRoot().getChildren();let 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; | ||
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}; | ||
'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; | ||
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}; | ||
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; | ||
@@ -11,0 +11,0 @@ exports.$isRootTextContentEmptyCurry=function(b,f){return()=>r(b,f)}; |
@@ -12,6 +12,6 @@ { | ||
"license": "MIT", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"main": "LexicalText.js", | ||
"peerDependencies": { | ||
"lexical": "0.3.5" | ||
"lexical": "0.3.6" | ||
}, | ||
@@ -22,6 +22,3 @@ "repository": { | ||
"directory": "packages/lexical-text" | ||
}, | ||
"devDependencies": { | ||
"utility-types": "^3.10.0" | ||
} | ||
} |
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
19916
0
366