@lexical/markdown 0.2.3 → 0.2.6

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.
@@ -6,13 +6,91 @@
6
6
  *
7
7
  */
8
8
 
9
- import type {DecoratorNode, LexicalEditor} from 'lexical';
9
+ import type {
10
+ LexicalEditor,
11
+ ElementNode,
12
+ LexicalNode,
13
+ TextFormatType,
14
+ } from 'lexical';
10
15
 
11
- export function registerMarkdownShortcuts<T>(
16
+ export type Transformer =
17
+ | ElementTransformer
18
+ | TextFormatTransformer
19
+ | TextMatchTransformer;
20
+
21
+ export type ElementTransformer = {
22
+ export: (
23
+ node: LexicalNode,
24
+ traverseChildren: (node: ElementNode) => string,
25
+ ) => string | null;
26
+ regExp: RegExp;
27
+ replace: (
28
+ parentNode: ElementNode,
29
+ children: Array<LexicalNode>,
30
+ match: Array<string>,
31
+ isImport: boolean,
32
+ ) => void;
33
+ type: 'element';
34
+ };
35
+
36
+ export type TextFormatTransformer = $ReadOnly<{
37
+ format: $ReadOnlyArray<TextFormatType>;
38
+ tag: string;
39
+ type: 'text-format';
40
+ }>;
41
+
42
+ export type TextMatchTransformer = $ReadOnly<{
43
+ export: (
44
+ node: LexicalNode,
45
+ exportChildren: (node: ElementNode) => string,
46
+ exportFormat: (node: TextNode, textContent: string) => string,
47
+ ) => string | null;
48
+ importRegExp: RegExp;
49
+ regExp: RegExp;
50
+ replace: (node: TextNode, match: RegExp$matchResult) => void;
51
+ trigger: string;
52
+ type: 'text-match';
53
+ }>;
54
+
55
+ // TODO:
56
+ // transformers should be required argument, breaking change
57
+ export function registerMarkdownShortcuts(
12
58
  editor: LexicalEditor,
13
- createHorizontalRuleNode: () => DecoratorNode<T>,
59
+ transformers?: Array<Transformer>,
14
60
  ): () => void;
61
+
62
+ // TODO:
63
+ // transformers should be required argument, breaking change
15
64
  export function $convertFromMarkdownString(
16
- markdownString: string,
17
- editor: LexicalEditor,
65
+ markdown: string,
66
+ transformers?: Array<Transformer>,
18
67
  ): void;
68
+
69
+ // TODO:
70
+ // transformers should be required argument, breaking change
71
+ export function $convertToMarkdownString(
72
+ transformers?: Array<Transformer>,
73
+ ): string;
74
+
75
+ export const BOLD_ITALIC_STAR: TextFormatTransformer;
76
+ export const BOLD_ITALIC_UNDERSCORE: TextFormatTransformer;
77
+ export const BOLD_STAR: TextFormatTransformer;
78
+ export const BOLD_UNDERSCORE: TextFormatTransformer;
79
+ export const INLINE_CODE: TextFormatTransformer;
80
+ export const ITALIC_STAR: TextFormatTransformer;
81
+ export const ITALIC_UNDERSCORE: TextFormatTransformer;
82
+ export const STRIKETHROUGH: TextFormatTransformer;
83
+
84
+ export const UNORDERED_LIST: ElementTransformer;
85
+ export const CODE: ElementTransformer;
86
+ export const HEADING: ElementTransformer;
87
+ export const ORDERED_LIST: ElementTransformer;
88
+ export const QUOTE: ElementTransformer;
89
+ export const CHECK_LIST: ElementTransformer;
90
+
91
+ export const LINK: TextMatchTransformer;
92
+
93
+ export const TRANSFORMERS: Array<Transformer>;
94
+ export const ELEMENT_TRANSFORMERS: Array<ElementTransformer>;
95
+ export const TEXT_FORMAT_TRANSFORMERS: Array<TextFormatTransformer>;
96
+ export const TEXT_MATCH_TRANSFORMERS: Array<TextFormatTransformer>;