@lexical/code-core 0.41.1-nightly.20260309.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/CodeExtension.d.ts +4 -0
- package/CodeHighlightNode.d.ts +34 -0
- package/CodeNode.d.ts +47 -0
- package/FlatStructureUtils.d.ts +25 -0
- package/LICENSE +21 -0
- package/LexicalCodeCore.dev.js +664 -0
- package/LexicalCodeCore.dev.mjs +649 -0
- package/LexicalCodeCore.js +11 -0
- package/LexicalCodeCore.js.flow +107 -0
- package/LexicalCodeCore.mjs +25 -0
- package/LexicalCodeCore.node.mjs +23 -0
- package/LexicalCodeCore.prod.js +9 -0
- package/LexicalCodeCore.prod.mjs +9 -0
- package/README.md +7 -0
- package/index.d.ts +12 -0
- package/package.json +41 -0
|
@@ -0,0 +1,34 @@
|
|
|
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 { EditorConfig, LexicalNode, LexicalUpdateJSON, NodeKey, SerializedTextNode, Spread } from 'lexical';
|
|
9
|
+
import { ElementNode, TextNode } from 'lexical';
|
|
10
|
+
type SerializedCodeHighlightNode = Spread<{
|
|
11
|
+
highlightType: string | null | undefined;
|
|
12
|
+
}, SerializedTextNode>;
|
|
13
|
+
/** @noInheritDoc */
|
|
14
|
+
export declare class CodeHighlightNode extends TextNode {
|
|
15
|
+
/** @internal */
|
|
16
|
+
__highlightType: string | null | undefined;
|
|
17
|
+
constructor(text?: string, highlightType?: string | null | undefined, key?: NodeKey);
|
|
18
|
+
static getType(): string;
|
|
19
|
+
static clone(node: CodeHighlightNode): CodeHighlightNode;
|
|
20
|
+
getHighlightType(): string | null | undefined;
|
|
21
|
+
setHighlightType(highlightType?: string | null | undefined): this;
|
|
22
|
+
canHaveFormat(): boolean;
|
|
23
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
24
|
+
updateDOM(prevNode: this, dom: HTMLElement, config: EditorConfig): boolean;
|
|
25
|
+
static importJSON(serializedNode: SerializedCodeHighlightNode): CodeHighlightNode;
|
|
26
|
+
updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedCodeHighlightNode>): this;
|
|
27
|
+
exportJSON(): SerializedCodeHighlightNode;
|
|
28
|
+
setFormat(format: number): this;
|
|
29
|
+
isParentRequired(): true;
|
|
30
|
+
createParentElementNode(): ElementNode;
|
|
31
|
+
}
|
|
32
|
+
export declare function $createCodeHighlightNode(text?: string, highlightType?: string | null | undefined): CodeHighlightNode;
|
|
33
|
+
export declare function $isCodeHighlightNode(node: LexicalNode | CodeHighlightNode | null | undefined): node is CodeHighlightNode;
|
|
34
|
+
export {};
|
package/CodeNode.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
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 { CodeHighlightNode } from '@lexical/code';
|
|
9
|
+
import type { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalEditor, LexicalNode, LexicalUpdateJSON, NodeKey, ParagraphNode, RangeSelection, SerializedElementNode, Spread, TabNode } from 'lexical';
|
|
10
|
+
import { ElementNode } from 'lexical';
|
|
11
|
+
export type SerializedCodeNode = Spread<{
|
|
12
|
+
language: string | null | undefined;
|
|
13
|
+
theme?: string | undefined;
|
|
14
|
+
}, SerializedElementNode>;
|
|
15
|
+
export declare const DEFAULT_CODE_LANGUAGE = "javascript";
|
|
16
|
+
export declare const getDefaultCodeLanguage: () => string;
|
|
17
|
+
/** @noInheritDoc */
|
|
18
|
+
export declare class CodeNode extends ElementNode {
|
|
19
|
+
/** @internal */
|
|
20
|
+
__language: string | null | undefined;
|
|
21
|
+
/** @internal */
|
|
22
|
+
__theme: string | undefined;
|
|
23
|
+
/** @internal */
|
|
24
|
+
__isSyntaxHighlightSupported: boolean;
|
|
25
|
+
static getType(): string;
|
|
26
|
+
static clone(node: CodeNode): CodeNode;
|
|
27
|
+
constructor(language?: string | null | undefined, key?: NodeKey);
|
|
28
|
+
afterCloneFrom(prevNode: this): void;
|
|
29
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
30
|
+
updateDOM(prevNode: this, dom: HTMLElement, config: EditorConfig): boolean;
|
|
31
|
+
exportDOM(editor: LexicalEditor): DOMExportOutput;
|
|
32
|
+
static importDOM(): DOMConversionMap | null;
|
|
33
|
+
static importJSON(serializedNode: SerializedCodeNode): CodeNode;
|
|
34
|
+
updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedCodeNode>): this;
|
|
35
|
+
exportJSON(): SerializedCodeNode;
|
|
36
|
+
insertNewAfter(selection: RangeSelection, restoreSelection?: boolean): null | ParagraphNode | CodeHighlightNode | TabNode;
|
|
37
|
+
canIndent(): false;
|
|
38
|
+
collapseAtStart(): boolean;
|
|
39
|
+
setLanguage(language: string | null | undefined): this;
|
|
40
|
+
getLanguage(): string | null | undefined;
|
|
41
|
+
setIsSyntaxHighlightSupported(isSupported: boolean): this;
|
|
42
|
+
getIsSyntaxHighlightSupported(): boolean;
|
|
43
|
+
setTheme(theme: string | null | undefined): this;
|
|
44
|
+
getTheme(): string | undefined;
|
|
45
|
+
}
|
|
46
|
+
export declare function $createCodeNode(language?: string | null | undefined, theme?: string | null | undefined): CodeNode;
|
|
47
|
+
export declare function $isCodeNode(node: LexicalNode | null | undefined): node is CodeNode;
|
|
@@ -0,0 +1,25 @@
|
|
|
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 { CodeHighlightNode } from './CodeHighlightNode';
|
|
9
|
+
import type { LineBreakNode, TabNode } from 'lexical';
|
|
10
|
+
export declare function $getFirstCodeNodeOfLine(anchor: CodeHighlightNode | TabNode | LineBreakNode): CodeHighlightNode | TabNode | LineBreakNode;
|
|
11
|
+
export declare function $getLastCodeNodeOfLine(anchor: CodeHighlightNode | TabNode | LineBreakNode): CodeHighlightNode | TabNode | LineBreakNode;
|
|
12
|
+
/**
|
|
13
|
+
* Determines the visual writing direction of a code line.
|
|
14
|
+
*
|
|
15
|
+
* Scans the line segments (CodeHighlightNode/TabNode) from start to end
|
|
16
|
+
* and returns the first strong direction found ("ltr" or "rtl").
|
|
17
|
+
* If no strong character is found, falls back to the parent element's
|
|
18
|
+
* direction. Returns null if indeterminate.
|
|
19
|
+
*/
|
|
20
|
+
export declare function $getCodeLineDirection(anchor: CodeHighlightNode | TabNode | LineBreakNode): 'ltr' | 'rtl' | null;
|
|
21
|
+
export declare function $getStartOfCodeInLine(anchor: CodeHighlightNode | TabNode, offset: number): null | {
|
|
22
|
+
node: CodeHighlightNode | TabNode | LineBreakNode;
|
|
23
|
+
offset: number;
|
|
24
|
+
};
|
|
25
|
+
export declare function $getEndOfCodeInLine(anchor: CodeHighlightNode | TabNode): CodeHighlightNode | TabNode;
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|