@lexical/text 0.25.1-nightly.20250228.0 → 0.26.1-nightly.20250303.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LexicalText.dev.js +7 -1
- package/LexicalText.dev.mjs +7 -1
- package/LexicalText.prod.js +1 -1
- package/LexicalText.prod.mjs +1 -1
- package/package.json +2 -2
package/LexicalText.dev.js
CHANGED
@@ -182,6 +182,12 @@ function $findTextIntersectionFromCharacters(root, targetCharacters) {
|
|
182
182
|
*
|
183
183
|
*/
|
184
184
|
|
185
|
+
// Do not require this module directly! Use normal `invariant` calls.
|
186
|
+
|
187
|
+
function formatDevErrorMessage(message) {
|
188
|
+
throw new Error(message);
|
189
|
+
}
|
190
|
+
|
185
191
|
/**
|
186
192
|
* Returns a tuple that can be rested (...) into mergeRegister to clean up
|
187
193
|
* node transforms listeners that transforms text into another node, eg. a HashtagNode.
|
@@ -286,7 +292,7 @@ function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
|
|
286
292
|
[, nodeToReplace, currentNode] = currentNode.splitText(match.start + prevMatchLengthToSkip, match.end + prevMatchLengthToSkip);
|
287
293
|
}
|
288
294
|
if (!(nodeToReplace !== undefined)) {
|
289
|
-
|
295
|
+
formatDevErrorMessage(`${'nodeToReplace'} should not be undefined. You may want to check splitOffsets passed to the splitText.`);
|
290
296
|
}
|
291
297
|
const replacementNode = createNode(nodeToReplace);
|
292
298
|
replacementNode.setFormat(nodeToReplace.getFormat());
|
package/LexicalText.dev.mjs
CHANGED
@@ -180,6 +180,12 @@ function $findTextIntersectionFromCharacters(root, targetCharacters) {
|
|
180
180
|
*
|
181
181
|
*/
|
182
182
|
|
183
|
+
// Do not require this module directly! Use normal `invariant` calls.
|
184
|
+
|
185
|
+
function formatDevErrorMessage(message) {
|
186
|
+
throw new Error(message);
|
187
|
+
}
|
188
|
+
|
183
189
|
/**
|
184
190
|
* Returns a tuple that can be rested (...) into mergeRegister to clean up
|
185
191
|
* node transforms listeners that transforms text into another node, eg. a HashtagNode.
|
@@ -284,7 +290,7 @@ function registerLexicalTextEntity(editor, getMatch, targetNode, createNode) {
|
|
284
290
|
[, nodeToReplace, currentNode] = currentNode.splitText(match.start + prevMatchLengthToSkip, match.end + prevMatchLengthToSkip);
|
285
291
|
}
|
286
292
|
if (!(nodeToReplace !== undefined)) {
|
287
|
-
|
293
|
+
formatDevErrorMessage(`${'nodeToReplace'} should not be undefined. You may want to check splitOffsets passed to the splitText.`);
|
288
294
|
}
|
289
295
|
const replacementNode = createNode(nodeToReplace);
|
290
296
|
replacementNode.setFormat(nodeToReplace.getFormat());
|
package/LexicalText.prod.js
CHANGED
@@ -6,4 +6,4 @@
|
|
6
6
|
*
|
7
7
|
*/
|
8
8
|
|
9
|
-
"use strict";var t=require("lexical");function e(){return t.$getRoot().getTextContent()}function n(t,n=!0){if(t)return!1;let r=e();return n&&(r=r.trim()),""===r}function r(e){if(!n(e,!1))return!1;const r=t.$getRoot().getChildren(),o=r.length;if(o>1)return!1;for(let e=0;e<o;e++){const n=r[e];if(t.$isDecoratorNode(n))return!1;if(t.$isElementNode(n)){if(!t.$isParagraphNode(n))return!1;if(0!==n.__indent)return!1;const r=n.getChildren(),o=r.length;for(let n=0;n<o;n++){const n=r[e];if(!t.$isTextNode(n))return!1}}}return!0}function o(t){
|
9
|
+
"use strict";var t=require("lexical");function e(){return t.$getRoot().getTextContent()}function n(t,n=!0){if(t)return!1;let r=e();return n&&(r=r.trim()),""===r}function r(e){if(!n(e,!1))return!1;const r=t.$getRoot().getChildren(),o=r.length;if(o>1)return!1;for(let e=0;e<o;e++){const n=r[e];if(t.$isDecoratorNode(n))return!1;if(t.$isElementNode(n)){if(!t.$isParagraphNode(n))return!1;if(0!==n.__indent)return!1;const r=n.getChildren(),o=r.length;for(let n=0;n<o;n++){const n=r[e];if(!t.$isTextNode(n))return!1}}}return!0}function o(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}exports.$canShowPlaceholder=r,exports.$canShowPlaceholderCurry=function(t){return()=>r(t)},exports.$findTextIntersectionFromCharacters=function(e,n){let r=e.getFirstChild(),o=0;t:for(;null!==r;){if(t.$isElementNode(r)){const t=r.getFirstChild();if(null!==t){r=t;continue}}else if(t.$isTextNode(r)){const t=r.getTextContentSize();if(o+t>n)return{node:r,offset:n-o};o+=t}const e=r.getNextSibling();if(null!==e){r=e;continue}let i=r.getParent();for(;null!==i;){const t=i.getNextSibling();if(null!==t){r=t;continue t}i=i.getParent()}break}return null},exports.$isRootTextContentEmpty=n,exports.$isRootTextContentEmptyCurry=function(t,e){return()=>n(t,e)},exports.$rootTextContent=e,exports.registerLexicalTextEntity=function(e,n,r,i){const s=t=>t instanceof r,l=e=>{const n=t.$createTextNode(e.getTextContent());n.setFormat(e.getFormat()),e.replace(n)};return[e.registerNodeTransform(t.TextNode,(e=>{if(!e.isSimpleText())return;let r,u=e.getPreviousSibling(),c=e.getTextContent(),f=e;if(t.$isTextNode(u)){const t=u.getTextContent(),r=n(t+c);if(s(u)){if(null===r||0!==(t=>t.getLatest().__mode)(u))return void l(u);{const n=r.end-t.length;if(n>0){const r=t+c.slice(0,n);if(u.select(),u.setTextContent(r),n===c.length)e.remove();else{const t=c.slice(n);e.setTextContent(t)}return}}}else if(null===r||r.start<t.length)return}let d=0;for(;;){r=n(c);let e,a=null===r?"":c.slice(r.end);if(c=a,""===a){const e=f.getNextSibling();if(t.$isTextNode(e)){a=f.getTextContent()+e.getTextContent();const t=n(a);if(null===t)return void(s(e)?l(e):e.markDirty());if(0!==t.start)return}}if(null===r)return;if(0===r.start&&t.$isTextNode(u)&&u.isTextEntity()){d+=r.end;continue}0===r.start?[e,f]=f.splitText(r.end):[,e,f]=f.splitText(r.start+d,r.end+d),void 0===e&&o(165,"nodeToReplace");const x=i(e);if(x.setFormat(e.getFormat()),e.replace(x),null==f)return;d=0,u=x}})),e.registerNodeTransform(r,(e=>{const r=e.getTextContent(),o=n(r);if(null===o||0!==o.start)return void l(e);if(r.length>o.end)return void e.splitText(o.end);const i=e.getPreviousSibling();t.$isTextNode(i)&&i.isTextEntity()&&(l(i),l(e));const u=e.getNextSibling();t.$isTextNode(u)&&u.isTextEntity()&&(l(u),s(e)&&l(e))}))]};
|
package/LexicalText.prod.mjs
CHANGED
@@ -6,4 +6,4 @@
|
|
6
6
|
*
|
7
7
|
*/
|
8
8
|
|
9
|
-
import{$getRoot as t,$isDecoratorNode as e,$isElementNode as n,$isParagraphNode as r,$isTextNode as i,TextNode as o,$createTextNode as l}from"lexical";function s(){return t().getTextContent()}function
|
9
|
+
import{$getRoot as t,$isDecoratorNode as e,$isElementNode as n,$isParagraphNode as r,$isTextNode as i,TextNode as o,$createTextNode as l}from"lexical";function s(){return t().getTextContent()}function f(t,e=!0){if(t)return!1;let n=s();return e&&(n=n.trim()),""===n}function u(t,e){return()=>f(t,e)}function c(o){if(!f(o,!1))return!1;const l=t().getChildren(),s=l.length;if(s>1)return!1;for(let t=0;t<s;t++){const o=l[t];if(e(o))return!1;if(n(o)){if(!r(o))return!1;if(0!==o.__indent)return!1;const e=o.getChildren(),n=e.length;for(let r=0;r<n;r++){const n=e[t];if(!i(n))return!1}}}return!0}function g(t){return()=>c(t)}function a(t,e){let r=t.getFirstChild(),o=0;t:for(;null!==r;){if(n(r)){const t=r.getFirstChild();if(null!==t){r=t;continue}}else if(i(r)){const t=r.getTextContentSize();if(o+t>e)return{node:r,offset:e-o};o+=t}const t=r.getNextSibling();if(null!==t){r=t;continue}let l=r.getParent();for(;null!==l;){const t=l.getNextSibling();if(null!==t){r=t;continue t}l=l.getParent()}break}return null}function d(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function x(t,e,n,r){const s=t=>t instanceof n,f=t=>{const e=l(t.getTextContent());e.setFormat(t.getFormat()),t.replace(e)};return[t.registerNodeTransform(o,(t=>{if(!t.isSimpleText())return;let n,o=t.getPreviousSibling(),l=t.getTextContent(),u=t;if(i(o)){const n=o.getTextContent(),r=e(n+l);if(s(o)){if(null===r||0!==(t=>t.getLatest().__mode)(o))return void f(o);{const e=r.end-n.length;if(e>0){const r=n+l.slice(0,e);if(o.select(),o.setTextContent(r),e===l.length)t.remove();else{const n=l.slice(e);t.setTextContent(n)}return}}}else if(null===r||r.start<n.length)return}let c=0;for(;;){n=e(l);let t,g=null===n?"":l.slice(n.end);if(l=g,""===g){const t=u.getNextSibling();if(i(t)){g=u.getTextContent()+t.getTextContent();const n=e(g);if(null===n)return void(s(t)?f(t):t.markDirty());if(0!==n.start)return}}if(null===n)return;if(0===n.start&&i(o)&&o.isTextEntity()){c+=n.end;continue}0===n.start?[t,u]=u.splitText(n.end):[,t,u]=u.splitText(n.start+c,n.end+c),void 0===t&&d(165,"nodeToReplace");const a=r(t);if(a.setFormat(t.getFormat()),t.replace(a),null==u)return;c=0,o=a}})),t.registerNodeTransform(n,(t=>{const n=t.getTextContent(),r=e(n);if(null===r||0!==r.start)return void f(t);if(n.length>r.end)return void t.splitText(r.end);const o=t.getPreviousSibling();i(o)&&o.isTextEntity()&&(f(o),f(t));const l=t.getNextSibling();i(l)&&l.isTextEntity()&&(f(l),s(t)&&f(t))}))]}export{c as $canShowPlaceholder,g as $canShowPlaceholderCurry,a as $findTextIntersectionFromCharacters,f as $isRootTextContentEmpty,u as $isRootTextContentEmptyCurry,s as $rootTextContent,x as registerLexicalTextEntity};
|
package/package.json
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
"text"
|
10
10
|
],
|
11
11
|
"license": "MIT",
|
12
|
-
"version": "0.
|
12
|
+
"version": "0.26.1-nightly.20250303.0",
|
13
13
|
"main": "LexicalText.js",
|
14
14
|
"types": "index.d.ts",
|
15
15
|
"repository": {
|
@@ -37,6 +37,6 @@
|
|
37
37
|
}
|
38
38
|
},
|
39
39
|
"dependencies": {
|
40
|
-
"lexical": "0.
|
40
|
+
"lexical": "0.26.1-nightly.20250303.0"
|
41
41
|
}
|
42
42
|
}
|