@lexical/code-core 0.41.1-nightly.20260317.0 → 0.41.1-nightly.20260319.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/CodeHighlightNode.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare class CodeHighlightNode extends TextNode {
|
|
|
17
17
|
constructor(text?: string, highlightType?: string | null | undefined, key?: NodeKey);
|
|
18
18
|
static getType(): string;
|
|
19
19
|
static clone(node: CodeHighlightNode): CodeHighlightNode;
|
|
20
|
+
afterCloneFrom(prevNode: this): void;
|
|
20
21
|
getHighlightType(): string | null | undefined;
|
|
21
22
|
setHighlightType(highlightType?: string | null | undefined): this;
|
|
22
23
|
canHaveFormat(): boolean;
|
package/LexicalCodeCore.dev.js
CHANGED
|
@@ -566,6 +566,10 @@ class CodeHighlightNode extends lexical.TextNode {
|
|
|
566
566
|
static clone(node) {
|
|
567
567
|
return new CodeHighlightNode(node.__text, node.__highlightType || undefined, node.__key);
|
|
568
568
|
}
|
|
569
|
+
afterCloneFrom(prevNode) {
|
|
570
|
+
super.afterCloneFrom(prevNode);
|
|
571
|
+
this.__highlightType = prevNode.__highlightType;
|
|
572
|
+
}
|
|
569
573
|
getHighlightType() {
|
|
570
574
|
const self = this.getLatest();
|
|
571
575
|
return self.__highlightType;
|
package/LexicalCodeCore.dev.mjs
CHANGED
|
@@ -564,6 +564,10 @@ class CodeHighlightNode extends TextNode {
|
|
|
564
564
|
static clone(node) {
|
|
565
565
|
return new CodeHighlightNode(node.__text, node.__highlightType || undefined, node.__key);
|
|
566
566
|
}
|
|
567
|
+
afterCloneFrom(prevNode) {
|
|
568
|
+
super.afterCloneFrom(prevNode);
|
|
569
|
+
this.__highlightType = prevNode.__highlightType;
|
|
570
|
+
}
|
|
567
571
|
getHighlightType() {
|
|
568
572
|
const self = this.getLatest();
|
|
569
573
|
return self.__highlightType;
|
package/LexicalCodeCore.prod.js
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
"use strict";var e=require("lexical");function t(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function n(t,n){let r=t;for(let i=e.$getSiblingCaret(t,n);i&&(y(i.origin)||e.$isTabNode(i.origin));i=i.getAdjacentCaret())r=i.origin;return r}function r(e){return n(e,"previous")}function i(e){return n(e,"next")}const o="javascript";function s(t,n){for(const r of t.childNodes){if(e.isHTMLElement(r)&&r.tagName===n)return!0;s(r,n)}return!1}const a="data-language",l="data-highlight-language",
|
|
9
|
+
"use strict";var e=require("lexical");function t(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function n(t,n){let r=t;for(let i=e.$getSiblingCaret(t,n);i&&(y(i.origin)||e.$isTabNode(i.origin));i=i.getAdjacentCaret())r=i.origin;return r}function r(e){return n(e,"previous")}function i(e){return n(e,"next")}const o="javascript";function s(t,n){for(const r of t.childNodes){if(e.isHTMLElement(r)&&r.tagName===n)return!0;s(r,n)}return!1}const a="data-language",l="data-highlight-language",g="data-theme";class u extends e.ElementNode{__language;__theme;__isSyntaxHighlightSupported;static getType(){return"code"}static clone(e){return new u(e.__language,e.__key)}constructor(e,t){super(t),this.__language=e||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(e){super.afterCloneFrom(e),this.__language=e.__language,this.__theme=e.__theme,this.__isSyntaxHighlightSupported=e.__isSyntaxHighlightSupported}createDOM(t){const n=document.createElement("code");e.addClassNamesToElement(n,t.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(n.setAttribute(a,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute(l,r));const i=this.getTheme();i&&n.setAttribute(g,i);const o=this.getStyle();return o&&n.setAttribute("style",o),n}updateDOM(e,t,n){const r=this.__language,i=e.__language;r?r!==i&&t.setAttribute(a,r):i&&t.removeAttribute(a);const o=this.__isSyntaxHighlightSupported;e.__isSyntaxHighlightSupported&&i?o&&r?r!==i&&t.setAttribute(l,r):t.removeAttribute(l):o&&r&&t.setAttribute(l,r);const s=this.__theme,u=e.__theme;s?s!==u&&t.setAttribute(g,s):u&&t.removeAttribute(g);const h=this.__style,c=e.__style;return h?h!==c&&t.setAttribute("style",h):c&&t.removeAttribute("style"),!1}exportDOM(t){const n=document.createElement("pre");e.addClassNamesToElement(n,t._config.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(n.setAttribute(a,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute(l,r));const i=this.getTheme();i&&n.setAttribute(g,i);const o=this.getStyle();return o&&n.setAttribute("style",o),{element:n}}static importDOM(){return{code:e=>null!=e.textContent&&(/\r?\n/.test(e.textContent)||s(e,"BR"))?{conversion:d,priority:1}:null,div:()=>({conversion:p,priority:1}),pre:()=>({conversion:d,priority:0}),table:e=>x(e)?{conversion:f,priority:3}:null,td:e=>{const t=e,n=t.closest("table");return t.classList.contains("js-file-line")||n&&x(n)?{conversion:_,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&x(t)?{conversion:_,priority:3}:null}}}static importJSON(e){return h().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setLanguage(e.language).setTheme(e.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(t,n=!0){const i=this.getChildren(),o=i.length;if(o>=2&&"\n"===i[o-1].getTextContent()&&"\n"===i[o-2].getTextContent()&&t.isCollapsed()&&t.anchor.key===this.__key&&t.anchor.offset===o){i[o-1].remove(),i[o-2].remove();const t=e.$createParagraphNode();return this.insertAfter(t,n),t}const{anchor:s,focus:a}=t,l=(s.isBefore(a)?s:a).getNode();if(e.$isTextNode(l)){let t=r(l);const n=[];for(;;)if(e.$isTabNode(t))n.push(e.$createTabNode()),t=t.getNextSibling();else{if(!y(t))break;{let e=0;const r=t.getTextContent(),i=t.getTextContentSize();for(;e<i&&" "===r[e];)e++;if(0!==e&&n.push(T(" ".repeat(e))),e!==i)break;t=t.getNextSibling()}}const i=l.splitText(s.offset)[0],o=0===s.offset?0:1,a=i.getIndexWithinParent()+o,g=l.getParentOrThrow(),u=[e.$createLineBreakNode(),...n];g.splice(a,0,u);const h=n[n.length-1];h?h.select():0===s.offset?i.selectPrevious():i.getNextSibling().selectNext(0,0)}if(c(l)){const{offset:n}=t.anchor;l.splice(n,0,[e.$createLineBreakNode()]),l.select(n+1,n+1)}return null}canIndent(){return!1}collapseAtStart(){const t=e.$createParagraphNode();return this.getChildren().forEach(e=>t.append(e)),this.replace(t),!0}setLanguage(e){const t=this.getWritable();return t.__language=e||void 0,t}getLanguage(){return this.getLatest().__language}setIsSyntaxHighlightSupported(e){const t=this.getWritable();return t.__isSyntaxHighlightSupported=e,t}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}setTheme(e){const t=this.getWritable();return t.__theme=e||void 0,t}getTheme(){return this.getLatest().__theme}}function h(t,n){return e.$create(u).setLanguage(t).setTheme(n)}function c(e){return e instanceof u}function d(e){return{node:h(e.getAttribute(a))}}function p(e){const t=e,n=m(t);return n||function(e){let t=e.parentElement;for(;null!==t;){if(m(t))return!0;t=t.parentElement}return!1}(t)?{node:n?h():null}:{node:null}}function f(){return{node:h()}}function _(){return{node:null}}function m(e){return null!==e.style.fontFamily.match("monospace")}function x(e){return e.classList.contains("js-file-line-container")}class S extends e.TextNode{__highlightType;constructor(e="",t,n){super(e,n),this.__highlightType=t}static getType(){return"code-highlight"}static clone(e){return new S(e.__text,e.__highlightType||void 0,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__highlightType=e.__highlightType}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(e){const t=this.getWritable();return t.__highlightType=e||void 0,t}canHaveFormat(){return!1}createDOM(t){const n=super.createDOM(t),r=N(t.theme,this.__highlightType);return e.addClassNamesToElement(n,r),n}updateDOM(t,n,r){const i=super.updateDOM(t,n,r),o=N(r.theme,t.__highlightType),s=N(r.theme,this.__highlightType);return o!==s&&(o&&e.removeClassNamesFromElement(n,o),s&&e.addClassNamesToElement(n,s)),i}static importJSON(e){return T().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHighlightType(e.highlightType)}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(e){return this}isParentRequired(){return!0}createParentElementNode(){return h()}}function N(e,t){return t&&e&&e.codeHighlight&&e.codeHighlight[t]}function T(t="",n){return e.$applyNodeReplacement(new S(t,n))}function y(e){return e instanceof S}const C=e.defineExtension({name:"@lexical/code",nodes:()=>[u,S]});exports.$createCodeHighlightNode=T,exports.$createCodeNode=h,exports.$getCodeLineDirection=function(t){const n=r(t),o=i(t);let s=n;for(;null!==s;){if(y(s)){const t=e.getTextDirection(s.getTextContent());if(null!==t)return t}if(s===o)break;s=s.getNextSibling()}const a=n.getParent();if(e.$isElementNode(a)){const e=a.getDirection();if("ltr"===e||"rtl"===e)return e}return null},exports.$getEndOfCodeInLine=function(n){const r=i(n);return e.$isLineBreakNode(r)&&t(168),r},exports.$getFirstCodeNodeOfLine=r,exports.$getLastCodeNodeOfLine=i,exports.$getStartOfCodeInLine=function(n,r){let i=null,o=null,s=n,a=r,l=n.getTextContent();for(;;){if(0===a){if(s=s.getPreviousSibling(),null===s)break;if(y(s)||e.$isTabNode(s)||e.$isLineBreakNode(s)||t(167),e.$isLineBreakNode(s)){i={node:s,offset:1};break}a=Math.max(0,s.getTextContentSize()-1),l=s.getTextContent()}else a--;const n=l[a];y(s)&&" "!==n&&(o={node:s,offset:a})}if(null!==o)return o;let g=null;if(r<n.getTextContentSize())y(n)&&(g=n.getTextContent()[r]);else{const e=n.getNextSibling();y(e)&&(g=e.getTextContent()[0])}if(null!==g&&" "!==g)return i;{const t=function(t,n){let r=t,i=n,o=t.getTextContent(),s=t.getTextContentSize();for(;;){if(!y(r)||i===s){if(r=r.getNextSibling(),null===r||e.$isLineBreakNode(r))return null;y(r)&&(i=0,o=r.getTextContent(),s=r.getTextContentSize())}if(y(r)){if(" "!==o[i])return{node:r,offset:i};i++}}}(n,r);return null!==t?t:i}},exports.$isCodeHighlightNode=y,exports.$isCodeNode=c,exports.CodeExtension=C,exports.CodeHighlightNode=S,exports.CodeNode=u,exports.DEFAULT_CODE_LANGUAGE=o,exports.getDefaultCodeLanguage=()=>o;
|
package/LexicalCodeCore.prod.mjs
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import{getTextDirection as t,$isElementNode as e,$isTabNode as n,$isLineBreakNode as r,$getSiblingCaret as i,$create as o,ElementNode as s,addClassNamesToElement as u,$createParagraphNode as l,$isTextNode as g,$createTabNode as
|
|
9
|
+
import{getTextDirection as t,$isElementNode as e,$isTabNode as n,$isLineBreakNode as r,$getSiblingCaret as i,$create as o,ElementNode as s,addClassNamesToElement as u,$createParagraphNode as l,$isTextNode as g,$createTabNode as h,$createLineBreakNode as a,isHTMLElement as c,$applyNodeReplacement as p,TextNode as f,removeClassNamesFromElement as _,defineExtension as d}from"lexical";function m(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 S(t,e){let r=t;for(let o=i(t,e);o&&(R(o.origin)||n(o.origin));o=o.getAdjacentCaret())r=o.origin;return r}function x(t){return S(t,"previous")}function y(t){return S(t,"next")}function T(n){const r=x(n),i=y(n);let o=r;for(;null!==o;){if(R(o)){const e=t(o.getTextContent());if(null!==e)return e}if(o===i)break;o=o.getNextSibling()}const s=r.getParent();if(e(s)){const t=s.getDirection();if("ltr"===t||"rtl"===t)return t}return null}function b(t,e){let i=null,o=null,s=t,u=e,l=t.getTextContent();for(;;){if(0===u){if(s=s.getPreviousSibling(),null===s)break;if(R(s)||n(s)||r(s)||m(167),r(s)){i={node:s,offset:1};break}u=Math.max(0,s.getTextContentSize()-1),l=s.getTextContent()}else u--;const t=l[u];R(s)&&" "!==t&&(o={node:s,offset:u})}if(null!==o)return o;let g=null;if(e<t.getTextContentSize())R(t)&&(g=t.getTextContent()[e]);else{const e=t.getNextSibling();R(e)&&(g=e.getTextContent()[0])}if(null!==g&&" "!==g)return i;{const n=function(t,e){let n=t,i=e,o=t.getTextContent(),s=t.getTextContentSize();for(;;){if(!R(n)||i===s){if(n=n.getNextSibling(),null===n||r(n))return null;R(n)&&(i=0,o=n.getTextContent(),s=n.getTextContentSize())}if(R(n)){if(" "!==o[i])return{node:n,offset:i};i++}}}(t,e);return null!==n?n:i}}function v(t){const e=y(t);return r(e)&&m(168),e}const C="javascript",A=()=>C;function N(t,e){for(const n of t.childNodes){if(c(n)&&n.tagName===e)return!0;N(n,e)}return!1}const O="data-language",H="data-highlight-language",L="data-theme";class F extends s{__language;__theme;__isSyntaxHighlightSupported;static getType(){return"code"}static clone(t){return new F(t.__language,t.__key)}constructor(t,e){super(e),this.__language=t||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(t){super.afterCloneFrom(t),this.__language=t.__language,this.__theme=t.__theme,this.__isSyntaxHighlightSupported=t.__isSyntaxHighlightSupported}createDOM(t){const e=document.createElement("code");u(e,t.theme.code),e.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(e.setAttribute(O,n),this.getIsSyntaxHighlightSupported()&&e.setAttribute(H,n));const r=this.getTheme();r&&e.setAttribute(L,r);const i=this.getStyle();return i&&e.setAttribute("style",i),e}updateDOM(t,e,n){const r=this.__language,i=t.__language;r?r!==i&&e.setAttribute(O,r):i&&e.removeAttribute(O);const o=this.__isSyntaxHighlightSupported;t.__isSyntaxHighlightSupported&&i?o&&r?r!==i&&e.setAttribute(H,r):e.removeAttribute(H):o&&r&&e.setAttribute(H,r);const s=this.__theme,u=t.__theme;s?s!==u&&e.setAttribute(L,s):u&&e.removeAttribute(L);const l=this.__style,g=t.__style;return l?l!==g&&e.setAttribute("style",l):g&&e.removeAttribute("style"),!1}exportDOM(t){const e=document.createElement("pre");u(e,t._config.theme.code),e.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(e.setAttribute(O,n),this.getIsSyntaxHighlightSupported()&&e.setAttribute(H,n));const r=this.getTheme();r&&e.setAttribute(L,r);const i=this.getStyle();return i&&e.setAttribute("style",i),{element:e}}static importDOM(){return{code:t=>null!=t.textContent&&(/\r?\n/.test(t.textContent)||N(t,"BR"))?{conversion:M,priority:1}:null,div:()=>({conversion:w,priority:1}),pre:()=>({conversion:M,priority:0}),table:t=>I(t)?{conversion:D,priority:3}:null,td:t=>{const e=t,n=e.closest("table");return e.classList.contains("js-file-line")||n&&I(n)?{conversion:P,priority:3}:null},tr:t=>{const e=t.closest("table");return e&&I(e)?{conversion:P,priority:3}:null}}}static importJSON(t){return J().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setLanguage(t.language).setTheme(t.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(t,e=!0){const r=this.getChildren(),i=r.length;if(i>=2&&"\n"===r[i-1].getTextContent()&&"\n"===r[i-2].getTextContent()&&t.isCollapsed()&&t.anchor.key===this.__key&&t.anchor.offset===i){r[i-1].remove(),r[i-2].remove();const t=l();return this.insertAfter(t,e),t}const{anchor:o,focus:s}=t,u=(o.isBefore(s)?o:s).getNode();if(g(u)){let t=x(u);const e=[];for(;;)if(n(t))e.push(h()),t=t.getNextSibling();else{if(!R(t))break;{let n=0;const r=t.getTextContent(),i=t.getTextContentSize();for(;n<i&&" "===r[n];)n++;if(0!==n&&e.push(j(" ".repeat(n))),n!==i)break;t=t.getNextSibling()}}const r=u.splitText(o.offset)[0],i=0===o.offset?0:1,s=r.getIndexWithinParent()+i,l=u.getParentOrThrow(),g=[a(),...e];l.splice(s,0,g);const c=e[e.length-1];c?c.select():0===o.offset?r.selectPrevious():r.getNextSibling().selectNext(0,0)}if(k(u)){const{offset:e}=t.anchor;u.splice(e,0,[a()]),u.select(e+1,e+1)}return null}canIndent(){return!1}collapseAtStart(){const t=l();return this.getChildren().forEach(e=>t.append(e)),this.replace(t),!0}setLanguage(t){const e=this.getWritable();return e.__language=t||void 0,e}getLanguage(){return this.getLatest().__language}setIsSyntaxHighlightSupported(t){const e=this.getWritable();return e.__isSyntaxHighlightSupported=t,e}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}setTheme(t){const e=this.getWritable();return e.__theme=t||void 0,e}getTheme(){return this.getLatest().__theme}}function J(t,e){return o(F).setLanguage(t).setTheme(e)}function k(t){return t instanceof F}function M(t){return{node:J(t.getAttribute(O))}}function w(t){const e=t,n=E(e);return n||function(t){let e=t.parentElement;for(;null!==e;){if(E(e))return!0;e=e.parentElement}return!1}(e)?{node:n?J():null}:{node:null}}function D(){return{node:J()}}function P(){return{node:null}}function E(t){return null!==t.style.fontFamily.match("monospace")}function I(t){return t.classList.contains("js-file-line-container")}class z extends f{__highlightType;constructor(t="",e,n){super(t,n),this.__highlightType=e}static getType(){return"code-highlight"}static clone(t){return new z(t.__text,t.__highlightType||void 0,t.__key)}afterCloneFrom(t){super.afterCloneFrom(t),this.__highlightType=t.__highlightType}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(t){const e=this.getWritable();return e.__highlightType=t||void 0,e}canHaveFormat(){return!1}createDOM(t){const e=super.createDOM(t),n=W(t.theme,this.__highlightType);return u(e,n),e}updateDOM(t,e,n){const r=super.updateDOM(t,e,n),i=W(n.theme,t.__highlightType),o=W(n.theme,this.__highlightType);return i!==o&&(i&&_(e,i),o&&u(e,o)),r}static importJSON(t){return j().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setHighlightType(t.highlightType)}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(t){return this}isParentRequired(){return!0}createParentElementNode(){return J()}}function W(t,e){return e&&t&&t.codeHighlight&&t.codeHighlight[e]}function j(t="",e){return p(new z(t,e))}function R(t){return t instanceof z}const B=d({name:"@lexical/code",nodes:()=>[F,z]});export{j as $createCodeHighlightNode,J as $createCodeNode,T as $getCodeLineDirection,v as $getEndOfCodeInLine,x as $getFirstCodeNodeOfLine,y as $getLastCodeNodeOfLine,b as $getStartOfCodeInLine,R as $isCodeHighlightNode,k as $isCodeNode,B as CodeExtension,z as CodeHighlightNode,F as CodeNode,C as DEFAULT_CODE_LANGUAGE,A as getDefaultCodeLanguage};
|
package/package.json
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
"code"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.41.1-nightly.
|
|
11
|
+
"version": "0.41.1-nightly.20260319.0",
|
|
12
12
|
"main": "LexicalCodeCore.js",
|
|
13
13
|
"types": "index.d.ts",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"lexical": "0.41.1-nightly.
|
|
15
|
+
"lexical": "0.41.1-nightly.20260319.0"
|
|
16
16
|
},
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|