@lexical/markdown 0.3.1 → 0.3.4
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/LexicalMarkdown.dev.js +0 -6
- package/README.md +5 -5
- package/autoFormatUtils.d.ts +12 -0
- package/convertFromPlainTextUtils.d.ts +10 -0
- package/convertToMarkdown.d.ts +8 -0
- package/index.d.ts +17 -0
- package/package.json +8 -8
- package/utils.d.ts +74 -0
- package/v2/MarkdownExport.d.ts +9 -0
- package/v2/MarkdownImport.d.ts +9 -0
- package/v2/MarkdownShortcuts.d.ts +10 -0
- package/v2/MarkdownTransformers.d.ts +44 -0
- package/v2/utils.d.ts +15 -0
- package/LexicalMarkdown.d.ts +0 -98
package/LexicalMarkdown.dev.js
CHANGED
|
@@ -18,7 +18,6 @@ var richText = require('@lexical/rich-text');
|
|
|
18
18
|
* This source code is licensed under the MIT license found in the
|
|
19
19
|
* LICENSE file in the root directory of this source tree.
|
|
20
20
|
*
|
|
21
|
-
*
|
|
22
21
|
*/
|
|
23
22
|
function indexBy(list, callback) {
|
|
24
23
|
const index = {};
|
|
@@ -51,7 +50,6 @@ const PUNCTUATION_OR_SPACE = /[!-/:-@[-`{-~\s]/;
|
|
|
51
50
|
* This source code is licensed under the MIT license found in the
|
|
52
51
|
* LICENSE file in the root directory of this source tree.
|
|
53
52
|
*
|
|
54
|
-
*
|
|
55
53
|
*/
|
|
56
54
|
function createMarkdownExport(transformers) {
|
|
57
55
|
const byType = transformersByType(transformers); // Export only uses text formats that are responsible for single format
|
|
@@ -200,7 +198,6 @@ function hasFormat(node, format) {
|
|
|
200
198
|
* This source code is licensed under the MIT license found in the
|
|
201
199
|
* LICENSE file in the root directory of this source tree.
|
|
202
200
|
*
|
|
203
|
-
*
|
|
204
201
|
*/
|
|
205
202
|
const CODE_BLOCK_REG_EXP = /^```(\w{1,10})?\s?$/;
|
|
206
203
|
function createMarkdownImport(transformers) {
|
|
@@ -436,7 +433,6 @@ function createTextFormatTransformersIndex(textTransformers) {
|
|
|
436
433
|
* This source code is licensed under the MIT license found in the
|
|
437
434
|
* LICENSE file in the root directory of this source tree.
|
|
438
435
|
*
|
|
439
|
-
*
|
|
440
436
|
*/
|
|
441
437
|
|
|
442
438
|
function runElementTransformers(parentNode, anchorNode, anchorOffset, elementTransformers) {
|
|
@@ -726,7 +722,6 @@ function registerMarkdownShortcuts(editor, transformers = TRANSFORMERS) {
|
|
|
726
722
|
* This source code is licensed under the MIT license found in the
|
|
727
723
|
* LICENSE file in the root directory of this source tree.
|
|
728
724
|
*
|
|
729
|
-
|
|
730
725
|
*/
|
|
731
726
|
|
|
732
727
|
const replaceWithBlock = createNode => {
|
|
@@ -939,7 +934,6 @@ const LINK = {
|
|
|
939
934
|
* This source code is licensed under the MIT license found in the
|
|
940
935
|
* LICENSE file in the root directory of this source tree.
|
|
941
936
|
*
|
|
942
|
-
*
|
|
943
937
|
*/
|
|
944
938
|
const ELEMENT_TRANSFORMERS = [HEADING, QUOTE, CODE, UNORDERED_LIST, ORDERED_LIST]; // Order of text format transformers matters:
|
|
945
939
|
//
|
package/README.md
CHANGED
|
@@ -22,21 +22,21 @@ editor.update(() => {
|
|
|
22
22
|
|
|
23
23
|
It can also be used for initializing editor's state from markdown string. Here's an example with react `<RichTextPlugin>`
|
|
24
24
|
```jsx
|
|
25
|
-
<LexicalComposer
|
|
26
|
-
<RichTextPlugin initialEditorState={() => {
|
|
25
|
+
<LexicalComposer initialEditorState={() => {
|
|
27
26
|
$convertFromMarkdownString(markdown, TRANSFORMERS);
|
|
28
|
-
}}
|
|
27
|
+
}}>
|
|
28
|
+
<RichTextPlugin />
|
|
29
29
|
</LexicalComposer>
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
## Shortcuts
|
|
33
|
-
Can use `<
|
|
33
|
+
Can use `<MarkdownShortcutPlugin>` if using React
|
|
34
34
|
```jsx
|
|
35
35
|
import { TRANSFORMERS } from '@lexical/markdown';
|
|
36
36
|
import {MarkdownShortcutPlugin} from '@lexical/react/LexicalMarkdownShortcutPlugin';
|
|
37
37
|
|
|
38
38
|
<LexicalComposer>
|
|
39
|
-
<
|
|
39
|
+
<MarkdownShortcutPlugin transformers={TRANSFORMERS} />
|
|
40
40
|
</LexicalComposer>
|
|
41
41
|
```
|
|
42
42
|
|
|
@@ -0,0 +1,12 @@
|
|
|
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 { AutoFormatTriggerState, ScanningContext } from './utils';
|
|
9
|
+
import type { DecoratorNode, EditorState, LexicalEditor } from 'lexical';
|
|
10
|
+
export declare function updateAutoFormatting<T>(editor: LexicalEditor, scanningContext: ScanningContext, createHorizontalRuleNode: () => DecoratorNode<T>): void;
|
|
11
|
+
export declare function getTriggerState(editorState: EditorState): null | AutoFormatTriggerState;
|
|
12
|
+
export declare function findScanningContext(editor: LexicalEditor, currentTriggerState: null | AutoFormatTriggerState, priorTriggerState: null | AutoFormatTriggerState): null | ScanningContext;
|
|
@@ -0,0 +1,10 @@
|
|
|
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 { DecoratorNode, LexicalEditor, RootNode } from 'lexical';
|
|
9
|
+
export declare function convertStringToLexical(text: string, editor: LexicalEditor): null | RootNode;
|
|
10
|
+
export declare function convertMarkdownForElementNodes<T>(editor: LexicalEditor, createHorizontalRuleNode: null | (() => DecoratorNode<T>)): void;
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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 { ElementTransformer, TextFormatTransformer, TextMatchTransformer, Transformer } from './v2/MarkdownTransformers';
|
|
9
|
+
import { registerMarkdownShortcuts } from './v2/MarkdownShortcuts';
|
|
10
|
+
import { BOLD_ITALIC_STAR, BOLD_ITALIC_UNDERSCORE, BOLD_STAR, BOLD_UNDERSCORE, CHECK_LIST, CODE, HEADING, INLINE_CODE, ITALIC_STAR, ITALIC_UNDERSCORE, LINK, ORDERED_LIST, QUOTE, STRIKETHROUGH, UNORDERED_LIST } from './v2/MarkdownTransformers';
|
|
11
|
+
declare const ELEMENT_TRANSFORMERS: Array<ElementTransformer>;
|
|
12
|
+
declare const TEXT_FORMAT_TRANSFORMERS: Array<TextFormatTransformer>;
|
|
13
|
+
declare const TEXT_MATCH_TRANSFORMERS: Array<TextMatchTransformer>;
|
|
14
|
+
declare const TRANSFORMERS: Array<Transformer>;
|
|
15
|
+
declare function $convertFromMarkdownString(markdown: string, transformers?: Array<Transformer>): void;
|
|
16
|
+
declare function $convertToMarkdownString(transformers?: Array<Transformer>): string;
|
|
17
|
+
export { $convertFromMarkdownString, $convertToMarkdownString, BOLD_ITALIC_STAR, BOLD_ITALIC_UNDERSCORE, BOLD_STAR, BOLD_UNDERSCORE, CHECK_LIST, CODE, ELEMENT_TRANSFORMERS, ElementTransformer, HEADING, INLINE_CODE, ITALIC_STAR, ITALIC_UNDERSCORE, LINK, ORDERED_LIST, QUOTE, registerMarkdownShortcuts, STRIKETHROUGH, TEXT_FORMAT_TRANSFORMERS, TEXT_MATCH_TRANSFORMERS, TextFormatTransformer, TextMatchTransformer, Transformer, TRANSFORMERS, UNORDERED_LIST, };
|
package/package.json
CHANGED
|
@@ -8,18 +8,18 @@
|
|
|
8
8
|
"markdown"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.3.
|
|
11
|
+
"version": "0.3.4",
|
|
12
12
|
"main": "LexicalMarkdown.js",
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"lexical": "0.3.
|
|
14
|
+
"lexical": "0.3.4"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@lexical/utils": "0.3.
|
|
18
|
-
"@lexical/code": "0.3.
|
|
19
|
-
"@lexical/text": "0.3.
|
|
20
|
-
"@lexical/rich-text": "0.3.
|
|
21
|
-
"@lexical/list": "0.3.
|
|
22
|
-
"@lexical/link": "0.3.
|
|
17
|
+
"@lexical/utils": "0.3.4",
|
|
18
|
+
"@lexical/code": "0.3.4",
|
|
19
|
+
"@lexical/text": "0.3.4",
|
|
20
|
+
"@lexical/rich-text": "0.3.4",
|
|
21
|
+
"@lexical/list": "0.3.4",
|
|
22
|
+
"@lexical/link": "0.3.4"
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|
package/utils.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
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 { TextNodeWithOffset } from '@lexical/text';
|
|
9
|
+
import type { DecoratorNode, ElementNode, LexicalEditor, LexicalNode, NodeKey, TextFormatType } from 'lexical';
|
|
10
|
+
export declare type AutoFormatTriggerState = Readonly<{
|
|
11
|
+
anchorOffset: number;
|
|
12
|
+
hasParentNode: boolean;
|
|
13
|
+
isCodeBlock: boolean;
|
|
14
|
+
isParentAListItemNode: boolean;
|
|
15
|
+
isSelectionCollapsed: boolean;
|
|
16
|
+
isSimpleText: boolean;
|
|
17
|
+
nodeKey: NodeKey;
|
|
18
|
+
textContent: string;
|
|
19
|
+
}>;
|
|
20
|
+
export declare type MarkdownFormatKind = 'noTransformation' | 'paragraphH1' | 'paragraphH2' | 'paragraphH3' | 'paragraphH4' | 'paragraphH5' | 'paragraphH6' | 'paragraphBlockQuote' | 'paragraphUnorderedList' | 'paragraphOrderedList' | 'paragraphCodeBlock' | 'horizontalRule' | 'bold' | 'code' | 'italic' | 'underline' | 'strikethrough' | 'italic_bold' | 'strikethrough_italic' | 'strikethrough_bold' | 'strikethrough_italic_bold' | 'link';
|
|
21
|
+
export declare type ScanningContext = {
|
|
22
|
+
currentElementNode: null | ElementNode;
|
|
23
|
+
editor: LexicalEditor;
|
|
24
|
+
isAutoFormatting: boolean;
|
|
25
|
+
isWithinCodeBlock: boolean;
|
|
26
|
+
joinedText: string | null | undefined;
|
|
27
|
+
markdownCriteria: MarkdownCriteria;
|
|
28
|
+
patternMatchResults: PatternMatchResults;
|
|
29
|
+
textNodeWithOffset: TextNodeWithOffset | null | undefined;
|
|
30
|
+
triggerState: AutoFormatTriggerState | null | undefined;
|
|
31
|
+
};
|
|
32
|
+
export declare type MarkdownCriteria = Readonly<{
|
|
33
|
+
export?: (node: LexicalNode, traverseChildren: (node: ElementNode) => string) => string | null;
|
|
34
|
+
exportFormat?: TextFormatType;
|
|
35
|
+
exportTag?: string;
|
|
36
|
+
exportTagClose?: string;
|
|
37
|
+
markdownFormatKind: MarkdownFormatKind | null | undefined;
|
|
38
|
+
regEx: RegExp;
|
|
39
|
+
regExForAutoFormatting: RegExp;
|
|
40
|
+
requiresParagraphStart: boolean | null | undefined;
|
|
41
|
+
}>;
|
|
42
|
+
declare type CaptureGroupDetail = {
|
|
43
|
+
offsetInParent: number;
|
|
44
|
+
text: string;
|
|
45
|
+
};
|
|
46
|
+
export declare type PatternMatchResults = {
|
|
47
|
+
regExCaptureGroups: Array<CaptureGroupDetail>;
|
|
48
|
+
};
|
|
49
|
+
export declare type MarkdownCriteriaWithPatternMatchResults = {
|
|
50
|
+
markdownCriteria: null | MarkdownCriteria;
|
|
51
|
+
patternMatchResults: null | PatternMatchResults;
|
|
52
|
+
};
|
|
53
|
+
export declare type MarkdownCriteriaArray = Array<MarkdownCriteria>;
|
|
54
|
+
export declare type AutoFormatTriggerKind = 'space_trigger' | 'codeBlock_trigger';
|
|
55
|
+
export declare type AutoFormatTrigger = {
|
|
56
|
+
triggerKind: AutoFormatTriggerKind;
|
|
57
|
+
triggerString: string;
|
|
58
|
+
};
|
|
59
|
+
export declare const triggers: Array<AutoFormatTrigger>;
|
|
60
|
+
export declare const allMarkdownCriteria: MarkdownCriteriaArray;
|
|
61
|
+
export declare function getAllTriggers(): Array<AutoFormatTrigger>;
|
|
62
|
+
export declare function getAllMarkdownCriteriaForParagraphs(): MarkdownCriteriaArray;
|
|
63
|
+
export declare function getAllMarkdownCriteriaForTextNodes(): MarkdownCriteriaArray;
|
|
64
|
+
export declare function getAllMarkdownCriteria(): MarkdownCriteriaArray;
|
|
65
|
+
export declare function getInitialScanningContext(editor: LexicalEditor, isAutoFormatting: boolean, textNodeWithOffset: null | TextNodeWithOffset, triggerState: null | AutoFormatTriggerState): ScanningContext;
|
|
66
|
+
export declare function resetScanningContext(scanningContext: ScanningContext): ScanningContext;
|
|
67
|
+
export declare function getCodeBlockCriteria(): MarkdownCriteria;
|
|
68
|
+
export declare function getPatternMatchResultsForCriteria(markdownCriteria: MarkdownCriteria, scanningContext: ScanningContext, parentElementNode: ElementNode): null | PatternMatchResults;
|
|
69
|
+
export declare function getPatternMatchResultsForCodeBlock(scanningContext: ScanningContext, text: string): null | PatternMatchResults;
|
|
70
|
+
export declare function hasPatternMatchResults(scanningContext: ScanningContext): boolean;
|
|
71
|
+
export declare function getTextNodeWithOffsetOrThrow(scanningContext: ScanningContext): TextNodeWithOffset;
|
|
72
|
+
export declare function transformTextNodeForMarkdownCriteria<T>(scanningContext: ScanningContext, elementNode: ElementNode, createHorizontalRuleNode: null | (() => DecoratorNode<T>)): void;
|
|
73
|
+
export declare function getParentElementNodeOrThrow(scanningContext: ScanningContext): ElementNode;
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
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 { Transformer } from '@lexical/markdown';
|
|
9
|
+
export declare function createMarkdownExport(transformers: Array<Transformer>): () => string;
|
|
@@ -0,0 +1,9 @@
|
|
|
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 { Transformer } from '@lexical/markdown';
|
|
9
|
+
export declare function createMarkdownImport(transformers: Array<Transformer>): (markdownString: string) => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
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 { Transformer } from '@lexical/markdown';
|
|
9
|
+
import type { LexicalEditor } from 'lexical';
|
|
10
|
+
export declare function registerMarkdownShortcuts(editor: LexicalEditor, transformers?: Array<Transformer>): () => void;
|
|
@@ -0,0 +1,44 @@
|
|
|
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 { ElementNode, LexicalNode, TextFormatType, TextNode } from 'lexical';
|
|
9
|
+
export declare type Transformer = ElementTransformer | TextFormatTransformer | TextMatchTransformer;
|
|
10
|
+
export declare type ElementTransformer = {
|
|
11
|
+
export: (node: LexicalNode, traverseChildren: (node: ElementNode) => string) => string | null;
|
|
12
|
+
regExp: RegExp;
|
|
13
|
+
replace: (parentNode: ElementNode, children: Array<LexicalNode>, match: Array<string>, isImport: boolean) => void;
|
|
14
|
+
type: 'element';
|
|
15
|
+
};
|
|
16
|
+
export declare type TextFormatTransformer = Readonly<{
|
|
17
|
+
format: ReadonlyArray<TextFormatType>;
|
|
18
|
+
tag: string;
|
|
19
|
+
intraword?: boolean;
|
|
20
|
+
type: 'text-format';
|
|
21
|
+
}>;
|
|
22
|
+
export declare type TextMatchTransformer = Readonly<{
|
|
23
|
+
export: (node: LexicalNode, exportChildren: (node: ElementNode) => string, exportFormat: (node: TextNode, textContent: string) => string) => string | null;
|
|
24
|
+
importRegExp: RegExp;
|
|
25
|
+
regExp: RegExp;
|
|
26
|
+
replace: (node: TextNode, match: RegExpMatchArray) => void;
|
|
27
|
+
trigger: string;
|
|
28
|
+
type: 'text-match';
|
|
29
|
+
}>;
|
|
30
|
+
export declare const HEADING: ElementTransformer;
|
|
31
|
+
export declare const QUOTE: ElementTransformer;
|
|
32
|
+
export declare const CODE: ElementTransformer;
|
|
33
|
+
export declare const UNORDERED_LIST: ElementTransformer;
|
|
34
|
+
export declare const CHECK_LIST: ElementTransformer;
|
|
35
|
+
export declare const ORDERED_LIST: ElementTransformer;
|
|
36
|
+
export declare const INLINE_CODE: TextFormatTransformer;
|
|
37
|
+
export declare const BOLD_ITALIC_STAR: TextFormatTransformer;
|
|
38
|
+
export declare const BOLD_ITALIC_UNDERSCORE: TextFormatTransformer;
|
|
39
|
+
export declare const BOLD_STAR: TextFormatTransformer;
|
|
40
|
+
export declare const BOLD_UNDERSCORE: TextFormatTransformer;
|
|
41
|
+
export declare const STRIKETHROUGH: TextFormatTransformer;
|
|
42
|
+
export declare const ITALIC_STAR: TextFormatTransformer;
|
|
43
|
+
export declare const ITALIC_UNDERSCORE: TextFormatTransformer;
|
|
44
|
+
export declare const LINK: TextMatchTransformer;
|
package/v2/utils.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
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 { ElementTransformer, TextFormatTransformer, TextMatchTransformer, Transformer } from '@lexical/markdown';
|
|
9
|
+
export declare function indexBy<T>(list: Array<T>, callback: (arg0: T) => string): Readonly<Record<string, Array<T>>>;
|
|
10
|
+
export declare function transformersByType(transformers: Array<Transformer>): Readonly<{
|
|
11
|
+
element: Array<ElementTransformer>;
|
|
12
|
+
textFormat: Array<TextFormatTransformer>;
|
|
13
|
+
textMatch: Array<TextMatchTransformer>;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const PUNCTUATION_OR_SPACE: RegExp;
|
package/LexicalMarkdown.d.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
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
|
-
|
|
9
|
-
import type {
|
|
10
|
-
LexicalEditor,
|
|
11
|
-
ElementNode,
|
|
12
|
-
LexicalNode,
|
|
13
|
-
TextNode,
|
|
14
|
-
TextFormatType,
|
|
15
|
-
} from 'lexical';
|
|
16
|
-
|
|
17
|
-
export type Transformer =
|
|
18
|
-
| ElementTransformer
|
|
19
|
-
| TextFormatTransformer
|
|
20
|
-
| TextMatchTransformer;
|
|
21
|
-
|
|
22
|
-
export type ElementTransformer = {
|
|
23
|
-
export: (
|
|
24
|
-
node: LexicalNode,
|
|
25
|
-
traverseChildren: (node: ElementNode) => string,
|
|
26
|
-
) => string | null;
|
|
27
|
-
regExp: RegExp;
|
|
28
|
-
replace: (
|
|
29
|
-
parentNode: ElementNode,
|
|
30
|
-
children: Array<LexicalNode>,
|
|
31
|
-
match: Array<string>,
|
|
32
|
-
isImport: boolean,
|
|
33
|
-
) => void;
|
|
34
|
-
type: 'element';
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export type TextFormatTransformer = {
|
|
38
|
-
format: Array<TextFormatType>;
|
|
39
|
-
tag: string;
|
|
40
|
-
intraword?: boolean;
|
|
41
|
-
type: 'text-format';
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export type TextMatchTransformer = {
|
|
45
|
-
export: (
|
|
46
|
-
node: LexicalNode,
|
|
47
|
-
exportChildren: (node: ElementNode) => string,
|
|
48
|
-
exportFormat: (node: TextNode, textContent: string) => string,
|
|
49
|
-
) => string | null;
|
|
50
|
-
importRegExp: RegExp;
|
|
51
|
-
regExp: RegExp;
|
|
52
|
-
replace: (node: TextNode, match: RegExpMatchArray) => void;
|
|
53
|
-
trigger: string;
|
|
54
|
-
type: 'text-match';
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
// TODO:
|
|
58
|
-
// transformers should be required argument, breaking change
|
|
59
|
-
export function registerMarkdownShortcuts(
|
|
60
|
-
editor: LexicalEditor,
|
|
61
|
-
transformers?: Array<Transformer>,
|
|
62
|
-
): () => void;
|
|
63
|
-
|
|
64
|
-
// TODO:
|
|
65
|
-
// transformers should be required argument, breaking change
|
|
66
|
-
export function $convertFromMarkdownString(
|
|
67
|
-
markdown: string,
|
|
68
|
-
transformers?: Array<Transformer>,
|
|
69
|
-
): void;
|
|
70
|
-
|
|
71
|
-
// TODO:
|
|
72
|
-
// transformers should be required argument, breaking change
|
|
73
|
-
export function $convertToMarkdownString(
|
|
74
|
-
transformers?: Array<Transformer>,
|
|
75
|
-
): string;
|
|
76
|
-
|
|
77
|
-
export const BOLD_ITALIC_STAR: TextFormatTransformer;
|
|
78
|
-
export const BOLD_ITALIC_UNDERSCORE: TextFormatTransformer;
|
|
79
|
-
export const BOLD_STAR: TextFormatTransformer;
|
|
80
|
-
export const BOLD_UNDERSCORE: TextFormatTransformer;
|
|
81
|
-
export const INLINE_CODE: TextFormatTransformer;
|
|
82
|
-
export const ITALIC_STAR: TextFormatTransformer;
|
|
83
|
-
export const ITALIC_UNDERSCORE: TextFormatTransformer;
|
|
84
|
-
export const STRIKETHROUGH: TextFormatTransformer;
|
|
85
|
-
|
|
86
|
-
export const UNORDERED_LIST: ElementTransformer;
|
|
87
|
-
export const CODE: ElementTransformer;
|
|
88
|
-
export const HEADING: ElementTransformer;
|
|
89
|
-
export const ORDERED_LIST: ElementTransformer;
|
|
90
|
-
export const QUOTE: ElementTransformer;
|
|
91
|
-
export const CHECK_LIST: ElementTransformer;
|
|
92
|
-
|
|
93
|
-
export const LINK: TextMatchTransformer;
|
|
94
|
-
|
|
95
|
-
export const TRANSFORMERS: Array<Transformer>;
|
|
96
|
-
export const ELEMENT_TRANSFORMERS: Array<ElementTransformer>;
|
|
97
|
-
export const TEXT_FORMAT_TRANSFORMERS: Array<TextFormatTransformer>;
|
|
98
|
-
export const TEXT_MATCH_TRANSFORMERS: Array<TextFormatTransformer>;
|