@lexical/code 0.3.8 → 0.3.9
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 +48 -0
- package/CodeHighlighter.d.ts +29 -0
- package/CodeNode.d.ts +46 -0
- package/LexicalCode.dev.js +803 -781
- package/LexicalCode.prod.js +29 -26
- package/index.d.ts +3 -73
- package/package.json +3 -3
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import { EditorConfig, LexicalNode, NodeKey, SerializedTextNode, Spread, TextNode } from 'lexical';
|
|
9
|
+
import 'prismjs/components/prism-clike';
|
|
10
|
+
import 'prismjs/components/prism-javascript';
|
|
11
|
+
import 'prismjs/components/prism-markup';
|
|
12
|
+
import 'prismjs/components/prism-markdown';
|
|
13
|
+
import 'prismjs/components/prism-c';
|
|
14
|
+
import 'prismjs/components/prism-css';
|
|
15
|
+
import 'prismjs/components/prism-objectivec';
|
|
16
|
+
import 'prismjs/components/prism-sql';
|
|
17
|
+
import 'prismjs/components/prism-python';
|
|
18
|
+
import 'prismjs/components/prism-rust';
|
|
19
|
+
import 'prismjs/components/prism-swift';
|
|
20
|
+
export declare const DEFAULT_CODE_LANGUAGE = "javascript";
|
|
21
|
+
declare type SerializedCodeHighlightNode = Spread<{
|
|
22
|
+
highlightType: string | null | undefined;
|
|
23
|
+
type: 'code-highlight';
|
|
24
|
+
version: 1;
|
|
25
|
+
}, SerializedTextNode>;
|
|
26
|
+
export declare const CODE_LANGUAGE_FRIENDLY_NAME_MAP: Record<string, string>;
|
|
27
|
+
export declare const CODE_LANGUAGE_MAP: Record<string, string>;
|
|
28
|
+
export declare function normalizeCodeLang(lang: string): string;
|
|
29
|
+
export declare function getLanguageFriendlyName(lang: string): string;
|
|
30
|
+
export declare const getDefaultCodeLanguage: () => string;
|
|
31
|
+
export declare const getCodeLanguages: () => Array<string>;
|
|
32
|
+
export declare class CodeHighlightNode extends TextNode {
|
|
33
|
+
__highlightType: string | null | undefined;
|
|
34
|
+
constructor(text: string, highlightType?: string | null | undefined, key?: NodeKey);
|
|
35
|
+
static getType(): string;
|
|
36
|
+
static clone(node: CodeHighlightNode): CodeHighlightNode;
|
|
37
|
+
getHighlightType(): string | null | undefined;
|
|
38
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
39
|
+
updateDOM(prevNode: CodeHighlightNode, dom: HTMLElement, config: EditorConfig): boolean;
|
|
40
|
+
static importJSON(serializedNode: SerializedCodeHighlightNode): CodeHighlightNode;
|
|
41
|
+
exportJSON(): SerializedCodeHighlightNode;
|
|
42
|
+
setFormat(format: number): this;
|
|
43
|
+
}
|
|
44
|
+
export declare function $createCodeHighlightNode(text: string, highlightType?: string | null | undefined): CodeHighlightNode;
|
|
45
|
+
export declare function $isCodeHighlightNode(node: LexicalNode | CodeHighlightNode | null | undefined): node is CodeHighlightNode;
|
|
46
|
+
export declare function getFirstCodeHighlightNodeOfLine(anchor: LexicalNode): CodeHighlightNode | null | undefined;
|
|
47
|
+
export declare function getLastCodeHighlightNodeOfLine(anchor: LexicalNode): CodeHighlightNode | null | undefined;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { LexicalEditor, LexicalNode } from 'lexical';
|
|
9
|
+
import 'prismjs/components/prism-clike';
|
|
10
|
+
import 'prismjs/components/prism-javascript';
|
|
11
|
+
import 'prismjs/components/prism-markup';
|
|
12
|
+
import 'prismjs/components/prism-markdown';
|
|
13
|
+
import 'prismjs/components/prism-c';
|
|
14
|
+
import 'prismjs/components/prism-css';
|
|
15
|
+
import 'prismjs/components/prism-objectivec';
|
|
16
|
+
import 'prismjs/components/prism-sql';
|
|
17
|
+
import 'prismjs/components/prism-python';
|
|
18
|
+
import 'prismjs/components/prism-rust';
|
|
19
|
+
import 'prismjs/components/prism-swift';
|
|
20
|
+
import { TextNode } from 'lexical';
|
|
21
|
+
export declare function getStartOfCodeInLine(anchor: LexicalNode): {
|
|
22
|
+
node: TextNode | null;
|
|
23
|
+
offset: number;
|
|
24
|
+
};
|
|
25
|
+
export declare function getEndOfCodeInLine(anchor: LexicalNode): {
|
|
26
|
+
node: TextNode | null;
|
|
27
|
+
offset: number;
|
|
28
|
+
};
|
|
29
|
+
export declare function registerCodeHighlighting(editor: LexicalEditor): () => void;
|
package/CodeNode.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { DOMConversionMap, EditorConfig, LexicalNode, NodeKey, ParagraphNode, RangeSelection, SerializedElementNode, Spread } from 'lexical';
|
|
9
|
+
import 'prismjs/components/prism-clike';
|
|
10
|
+
import 'prismjs/components/prism-javascript';
|
|
11
|
+
import 'prismjs/components/prism-markup';
|
|
12
|
+
import 'prismjs/components/prism-markdown';
|
|
13
|
+
import 'prismjs/components/prism-c';
|
|
14
|
+
import 'prismjs/components/prism-css';
|
|
15
|
+
import 'prismjs/components/prism-objectivec';
|
|
16
|
+
import 'prismjs/components/prism-sql';
|
|
17
|
+
import 'prismjs/components/prism-python';
|
|
18
|
+
import 'prismjs/components/prism-rust';
|
|
19
|
+
import 'prismjs/components/prism-swift';
|
|
20
|
+
import { ElementNode } from 'lexical';
|
|
21
|
+
import { CodeHighlightNode } from '@lexical/code';
|
|
22
|
+
declare type SerializedCodeNode = Spread<{
|
|
23
|
+
language: string | null | undefined;
|
|
24
|
+
type: 'code';
|
|
25
|
+
version: 1;
|
|
26
|
+
}, SerializedElementNode>;
|
|
27
|
+
export declare class CodeNode extends ElementNode {
|
|
28
|
+
__language: string | null | undefined;
|
|
29
|
+
static getType(): string;
|
|
30
|
+
static clone(node: CodeNode): CodeNode;
|
|
31
|
+
constructor(language?: string | null | undefined, key?: NodeKey);
|
|
32
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
33
|
+
updateDOM(prevNode: CodeNode, dom: HTMLElement): boolean;
|
|
34
|
+
static importDOM(): DOMConversionMap | null;
|
|
35
|
+
static importJSON(serializedNode: SerializedCodeNode): CodeNode;
|
|
36
|
+
exportJSON(): SerializedCodeNode;
|
|
37
|
+
insertNewAfter(selection: RangeSelection): null | ParagraphNode | CodeHighlightNode;
|
|
38
|
+
canInsertTab(): boolean;
|
|
39
|
+
canIndent(): false;
|
|
40
|
+
collapseAtStart(): true;
|
|
41
|
+
setLanguage(language: string): void;
|
|
42
|
+
getLanguage(): string | null | undefined;
|
|
43
|
+
}
|
|
44
|
+
export declare function $createCodeNode(language?: string | null | undefined): CodeNode;
|
|
45
|
+
export declare function $isCodeNode(node: LexicalNode | null | undefined): node is CodeNode;
|
|
46
|
+
export {};
|