@lexical/code 0.12.5 → 0.13.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 +1 -0
- package/LexicalCode.dev.js +3 -0
- package/LexicalCode.js.flow +2 -2
- package/LexicalCode.prod.js +2 -2
- package/package.json +3 -3
package/CodeHighlightNode.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export declare class CodeHighlightNode extends TextNode {
|
|
|
39
39
|
static getType(): string;
|
|
40
40
|
static clone(node: CodeHighlightNode): CodeHighlightNode;
|
|
41
41
|
getHighlightType(): string | null | undefined;
|
|
42
|
+
canHaveFormat(): boolean;
|
|
42
43
|
createDOM(config: EditorConfig): HTMLElement;
|
|
43
44
|
updateDOM(prevNode: CodeHighlightNode, dom: HTMLElement, config: EditorConfig): boolean;
|
|
44
45
|
static importJSON(serializedNode: SerializedCodeHighlightNode): CodeHighlightNode;
|
package/LexicalCode.dev.js
CHANGED
|
@@ -409,6 +409,9 @@ class CodeHighlightNode extends lexical.TextNode {
|
|
|
409
409
|
const self = this.getLatest();
|
|
410
410
|
return self.__highlightType;
|
|
411
411
|
}
|
|
412
|
+
canHaveFormat() {
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
412
415
|
createDOM(config) {
|
|
413
416
|
const element = super.createDOM(config);
|
|
414
417
|
const className = getHighlightThemeClass(config.theme, this.__highlightType);
|
package/LexicalCode.js.flow
CHANGED
|
@@ -65,7 +65,7 @@ declare export function $createCodeHighlightNode(
|
|
|
65
65
|
|
|
66
66
|
declare export function $isCodeHighlightNode(
|
|
67
67
|
node: ?LexicalNode,
|
|
68
|
-
):
|
|
68
|
+
): node is CodeHighlightNode;
|
|
69
69
|
|
|
70
70
|
declare export var CODE_LANGUAGE_FRIENDLY_NAME_MAP: {[string]: string};
|
|
71
71
|
declare export var CODE_LANGUAGE_MAP: {[string]: string};
|
|
@@ -117,7 +117,7 @@ declare export function $createCodeNode(language: ?string): CodeNode;
|
|
|
117
117
|
|
|
118
118
|
declare export function $isCodeNode(
|
|
119
119
|
node: ?LexicalNode,
|
|
120
|
-
):
|
|
120
|
+
): node is CodeNode;
|
|
121
121
|
|
|
122
122
|
declare export class CodeNode extends ElementNode {
|
|
123
123
|
__language: string | null | void;
|
package/LexicalCode.prod.js
CHANGED
|
@@ -14,8 +14,8 @@ this.__key&&a.anchor.offset===e)return c[e-1].remove(),c[e-2].remove(),a=q.$crea
|
|
|
14
14
|
function C(a){return q.$applyNodeReplacement(new y(a))}function G(a){return a instanceof y}function z(a){let b;m.isHTMLElement(a)&&(b=a.getAttribute("data-highlight-language"));return{node:C(b)}}function aa(a){let b=null!==a.style.fontFamily.match("monospace");return b||da(a)?{after:c=>{let e=a.parentNode;null!=e&&a!==e.lastChild&&c.push(q.$createLineBreakNode());return c},node:b?C():null}:{node:null}}function ba(){return{node:C()}}function B(){return{node:null}}
|
|
15
15
|
function ca(a){return{after:b=>{a.parentNode&&a.parentNode.nextSibling&&b.push(q.$createLineBreakNode());return b},node:null}}function da(a){for(a=a.parentElement;null!==a;){if(null!==a.style.fontFamily.match("monospace"))return!0;a=a.parentElement}return!1}function A(a){return a.classList.contains("js-file-line-container")}
|
|
16
16
|
let H={c:"C",clike:"C-like",cpp:"C++",css:"CSS",html:"HTML",java:"Java",js:"JavaScript",markdown:"Markdown",objc:"Objective-C",plain:"Plain Text",py:"Python",rust:"Rust",sql:"SQL",swift:"Swift",typescript:"TypeScript",xml:"XML"},I={cpp:"cpp",java:"java",javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain",ts:"typescript"};function K(a){return I[a]||a}
|
|
17
|
-
class L extends q.TextNode{constructor(a,b,c){super(a,c);this.__highlightType=b}static getType(){return"code-highlight"}static clone(a){return new L(a.__text,a.__highlightType||void 0,a.__key)}getHighlightType(){return this.getLatest().__highlightType}createDOM(a){let b=super.createDOM(a);a=M(a.theme,this.__highlightType);m.addClassNamesToElement(b,a);return b}updateDOM(a,b,c){let e=super.updateDOM(a,b,c);a=M(c.theme,a.__highlightType);c=M(c.theme,this.__highlightType);a!==
|
|
18
|
-
a),c&&m.addClassNamesToElement(b,c));return e}static importJSON(a){let b=F(a.text,a.highlightType);b.setFormat(a.format);b.setDetail(a.detail);b.setMode(a.mode);b.setStyle(a.style);return b}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType(),type:"code-highlight",version:1}}setFormat(){return this}isParentRequired(){return!0}createParentElementNode(){return C()}}function M(a,b){return b&&a&&a.codeHighlight&&a.codeHighlight[b]}
|
|
17
|
+
class L extends q.TextNode{constructor(a,b,c){super(a,c);this.__highlightType=b}static getType(){return"code-highlight"}static clone(a){return new L(a.__text,a.__highlightType||void 0,a.__key)}getHighlightType(){return this.getLatest().__highlightType}canHaveFormat(){return!1}createDOM(a){let b=super.createDOM(a);a=M(a.theme,this.__highlightType);m.addClassNamesToElement(b,a);return b}updateDOM(a,b,c){let e=super.updateDOM(a,b,c);a=M(c.theme,a.__highlightType);c=M(c.theme,this.__highlightType);a!==
|
|
18
|
+
c&&(a&&m.removeClassNamesFromElement(b,a),c&&m.addClassNamesToElement(b,c));return e}static importJSON(a){let b=F(a.text,a.highlightType);b.setFormat(a.format);b.setDetail(a.detail);b.setMode(a.mode);b.setStyle(a.style);return b}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType(),type:"code-highlight",version:1}}setFormat(){return this}isParentRequired(){return!0}createParentElementNode(){return C()}}function M(a,b){return b&&a&&a.codeHighlight&&a.codeHighlight[b]}
|
|
19
19
|
function F(a,b){return q.$applyNodeReplacement(new L(a,b))}function E(a){return a instanceof L}function D(a){let b=a;for(;E(a)||q.$isTabNode(a);)b=a,a=a.getPreviousSibling();return b}function N(a){let b=a;for(;E(a)||q.$isTabNode(a);)b=a,a=a.getNextSibling();return b}let O={defaultLanguage:"javascript",tokenize(a,b){return d.tokenize(a,d.languages[b||""]||d.languages[this.defaultLanguage])}};
|
|
20
20
|
function P(a,b){let c=null;var e=null,f=a;let g=b,h=a.getTextContent();for(;;){if(0===g){f=f.getPreviousSibling();if(null===f)break;if(!(E(f)||q.$isTabNode(f)||q.$isLineBreakNode(f)))throw Error("Expected a valid Code Node: CodeHighlightNode, TabNode, LineBreakNode");if(q.$isLineBreakNode(f)){c={node:f,offset:1};break}g=Math.max(0,f.getTextContentSize()-1);h=f.getTextContent()}else g--;let k=h[g];E(f)&&" "!==k&&(e={node:f,offset:g})}if(null!==e)return e;e=null;b<a.getTextContentSize()?E(a)&&(e=a.getTextContent()[b]):
|
|
21
21
|
(f=a.getNextSibling(),E(f)&&(e=f.getTextContent()[0]));if(null!==e&&" "!==e)return c;a:for(e=a,f=a.getTextContent(),a=a.getTextContentSize();;){if(!E(e)||b===a){e=e.getNextSibling();if(null===e||q.$isLineBreakNode(e)){a=null;break a}E(e)&&(b=0,f=e.getTextContent(),a=e.getTextContentSize())}if(E(e)){if(" "!==f[b]){a={node:e,offset:b};break a}b++}}return null!==a?a:c}function Q(a){a=N(a);if(q.$isLineBreakNode(a))throw Error("Unexpected lineBreakNode in getEndOfCodeInLine");return a}
|
package/package.json
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"code"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.13.0",
|
|
12
12
|
"main": "LexicalCode.js",
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"lexical": "0.
|
|
14
|
+
"lexical": "0.13.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@lexical/utils": "0.
|
|
17
|
+
"@lexical/utils": "0.13.0",
|
|
18
18
|
"prismjs": "^1.27.0"
|
|
19
19
|
},
|
|
20
20
|
"repository": {
|