@mdxeditor/editor 0.0.1 → 0.0.5-development

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.
Files changed (302) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +15 -75
  3. package/dist/FormatConstants.d.ts +9 -0
  4. package/dist/FormatConstants.js +10 -0
  5. package/dist/MDXEditor.d.ts +103 -0
  6. package/dist/MDXEditor.js +144 -0
  7. package/dist/directive-editors/AdmonitionDirectiveDescriptor.d.ts +17 -0
  8. package/dist/directive-editors/AdmonitionDirectiveDescriptor.js +28 -0
  9. package/dist/directive-editors/GenericDirectiveEditor.d.ts +8 -0
  10. package/dist/directive-editors/GenericDirectiveEditor.js +32 -0
  11. package/dist/exportMarkdownFromLexical.d.ts +138 -0
  12. package/dist/exportMarkdownFromLexical.js +239 -0
  13. package/dist/gurx/index.d.ts +3 -0
  14. package/dist/gurx/react.d.ts +152 -0
  15. package/dist/gurx/react.js +206 -0
  16. package/dist/gurx/realm.d.ts +148 -0
  17. package/dist/gurx/realm.js +489 -0
  18. package/dist/gurx/realmFactory.d.ts +79 -0
  19. package/dist/gurx/realmFactory.js +32 -0
  20. package/dist/icons/add_column.svg.js +5 -0
  21. package/dist/icons/add_photo.svg.js +5 -0
  22. package/dist/icons/add_row.svg.js +5 -0
  23. package/dist/icons/admonition.svg.js +5 -0
  24. package/dist/icons/arrow_drop_down.svg.js +5 -0
  25. package/dist/icons/check.svg.js +5 -0
  26. package/dist/icons/check_small.svg.js +5 -0
  27. package/dist/icons/close.svg.js +5 -0
  28. package/dist/icons/code.svg.js +5 -0
  29. package/dist/icons/content_copy.svg.js +5 -0
  30. package/dist/icons/delete_big.svg.js +5 -0
  31. package/dist/icons/delete_small.svg.js +5 -0
  32. package/dist/icons/difference.svg.js +5 -0
  33. package/dist/icons/edit.svg.js +5 -0
  34. package/dist/icons/extension.svg.js +7 -0
  35. package/dist/icons/format_align_center.svg.js +5 -0
  36. package/dist/icons/format_align_left.svg.js +5 -0
  37. package/dist/icons/format_align_right.svg.js +5 -0
  38. package/dist/icons/format_bold.svg.js +5 -0
  39. package/dist/icons/format_italic.svg.js +5 -0
  40. package/dist/icons/format_list_bulleted.svg.js +5 -0
  41. package/dist/icons/format_list_checked.svg.js +5 -0
  42. package/dist/icons/format_list_numbered.svg.js +5 -0
  43. package/dist/icons/format_underlined.svg.js +5 -0
  44. package/dist/icons/frame_source.svg.js +5 -0
  45. package/dist/icons/frontmatter.svg.js +5 -0
  46. package/dist/icons/horizontal_rule.svg.js +5 -0
  47. package/dist/icons/insert_col_left.svg.js +5 -0
  48. package/dist/icons/insert_col_right.svg.js +5 -0
  49. package/dist/icons/insert_row_above.svg.js +5 -0
  50. package/dist/icons/insert_row_below.svg.js +5 -0
  51. package/dist/icons/link.svg.js +5 -0
  52. package/dist/icons/link_off.svg.js +5 -0
  53. package/dist/icons/markdown.svg.js +5 -0
  54. package/dist/icons/more_horiz.svg.js +5 -0
  55. package/dist/icons/more_vert.svg.js +5 -0
  56. package/dist/icons/open_in_new.svg.js +5 -0
  57. package/dist/icons/redo.svg.js +5 -0
  58. package/dist/icons/rich_text.svg.js +5 -0
  59. package/dist/icons/sandpack.svg.js +5 -0
  60. package/dist/icons/settings.svg.js +5 -0
  61. package/dist/icons/table.svg.js +5 -0
  62. package/dist/icons/undo.svg.js +5 -0
  63. package/dist/importMarkdownToLexical.d.ts +101 -0
  64. package/dist/importMarkdownToLexical.js +93 -0
  65. package/dist/index.d.ts +62 -726
  66. package/dist/index.js +207 -4501
  67. package/dist/jsx-editors/GenericJsxEditor.d.ts +8 -0
  68. package/dist/jsx-editors/GenericJsxEditor.js +56 -0
  69. package/dist/plugins/codeblock/CodeBlockNode.d.ts +100 -0
  70. package/dist/plugins/codeblock/CodeBlockNode.js +158 -0
  71. package/dist/plugins/codeblock/CodeBlockVisitor.d.ts +4 -0
  72. package/dist/plugins/codeblock/CodeBlockVisitor.js +14 -0
  73. package/dist/plugins/codeblock/MdastCodeVisitor.d.ts +3 -0
  74. package/dist/plugins/codeblock/MdastCodeVisitor.js +16 -0
  75. package/dist/plugins/codeblock/index.d.ts +787 -0
  76. package/dist/plugins/codeblock/index.js +73 -0
  77. package/dist/plugins/codemirror/CodeMirrorEditor.d.ts +3 -0
  78. package/dist/plugins/codemirror/CodeMirrorEditor.js +42 -0
  79. package/dist/plugins/codemirror/index.d.ts +1038 -0
  80. package/dist/plugins/codemirror/index.js +62 -0
  81. package/dist/plugins/core/GenericHTMLNode.d.ts +38 -0
  82. package/dist/plugins/core/GenericHTMLNode.js +117 -0
  83. package/dist/plugins/core/Icon.d.ts +6 -0
  84. package/dist/plugins/core/Icon.js +96 -0
  85. package/dist/plugins/core/LexicalGenericHTMLNodeVisitor.d.ts +4 -0
  86. package/dist/plugins/core/LexicalGenericHTMLNodeVisitor.js +15 -0
  87. package/dist/plugins/core/LexicalLinebreakVisitor.d.ts +4 -0
  88. package/dist/plugins/core/LexicalLinebreakVisitor.js +10 -0
  89. package/dist/plugins/core/LexicalParagraphVisitor.d.ts +4 -0
  90. package/dist/plugins/core/LexicalParagraphVisitor.js +10 -0
  91. package/dist/plugins/core/LexicalRootVisitor.d.ts +4 -0
  92. package/dist/plugins/core/LexicalRootVisitor.js +10 -0
  93. package/dist/plugins/core/LexicalTextVisitor.d.ts +5 -0
  94. package/dist/plugins/core/LexicalTextVisitor.js +102 -0
  95. package/dist/plugins/core/MdastBreakVisitor.d.ts +3 -0
  96. package/dist/plugins/core/MdastBreakVisitor.js +10 -0
  97. package/dist/plugins/core/MdastFormattingVisitor.d.ts +4 -0
  98. package/dist/plugins/core/MdastFormattingVisitor.js +36 -0
  99. package/dist/plugins/core/MdastHTMLNode.d.ts +13 -0
  100. package/dist/plugins/core/MdastHTMLNode.js +122 -0
  101. package/dist/plugins/core/MdastHTMLVisitor.d.ts +3 -0
  102. package/dist/plugins/core/MdastHTMLVisitor.js +12 -0
  103. package/dist/plugins/core/MdastInlineCodeVisitor.d.ts +3 -0
  104. package/dist/plugins/core/MdastInlineCodeVisitor.js +27 -0
  105. package/dist/plugins/core/MdastParagraphVisitor.d.ts +3 -0
  106. package/dist/plugins/core/MdastParagraphVisitor.js +15 -0
  107. package/dist/plugins/core/MdastRootVisitor.d.ts +3 -0
  108. package/dist/plugins/core/MdastRootVisitor.js +9 -0
  109. package/dist/plugins/core/MdastTextVisitor.d.ts +3 -0
  110. package/dist/plugins/core/MdastTextVisitor.js +10 -0
  111. package/dist/plugins/core/NestedLexicalEditor.d.ts +92 -0
  112. package/dist/plugins/core/NestedLexicalEditor.js +185 -0
  113. package/dist/plugins/core/PropertyPopover.d.ts +23 -0
  114. package/dist/plugins/core/PropertyPopover.js +39 -0
  115. package/dist/plugins/core/SharedHistoryPlugin.d.ts +2 -0
  116. package/dist/plugins/core/SharedHistoryPlugin.js +10 -0
  117. package/dist/plugins/core/index.d.ts +583 -0
  118. package/dist/plugins/core/index.js +490 -0
  119. package/dist/plugins/core/ui/DownshiftAutoComplete.d.ts +15 -0
  120. package/dist/plugins/core/ui/DownshiftAutoComplete.js +83 -0
  121. package/dist/plugins/core/ui/PopoverUtils.d.ts +4 -0
  122. package/dist/plugins/core/ui/PopoverUtils.js +17 -0
  123. package/dist/plugins/diff-source/DiffSourceWrapper.d.ts +4 -0
  124. package/dist/plugins/diff-source/DiffSourceWrapper.js +14 -0
  125. package/dist/plugins/diff-source/DiffViewer.d.ts +2 -0
  126. package/dist/plugins/diff-source/DiffViewer.js +59 -0
  127. package/dist/plugins/diff-source/SourceEditor.d.ts +4 -0
  128. package/dist/plugins/diff-source/SourceEditor.js +53 -0
  129. package/dist/plugins/diff-source/index.d.ts +725 -0
  130. package/dist/plugins/diff-source/index.js +56 -0
  131. package/dist/plugins/directives/DirectiveNode.d.ts +51 -0
  132. package/dist/plugins/directives/DirectiveNode.js +92 -0
  133. package/dist/plugins/directives/DirectiveVisitor.d.ts +4 -0
  134. package/dist/plugins/directives/DirectiveVisitor.js +10 -0
  135. package/dist/plugins/directives/MdastDirectiveVisitor.d.ts +3 -0
  136. package/dist/plugins/directives/MdastDirectiveVisitor.js +13 -0
  137. package/dist/plugins/directives/index.d.ts +773 -0
  138. package/dist/plugins/directives/index.js +53 -0
  139. package/dist/plugins/frontmatter/FrontmatterEditor.d.ts +6 -0
  140. package/dist/plugins/frontmatter/FrontmatterEditor.js +85 -0
  141. package/dist/plugins/frontmatter/FrontmatterNode.d.ts +35 -0
  142. package/dist/plugins/frontmatter/FrontmatterNode.js +71 -0
  143. package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.d.ts +4 -0
  144. package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.js +10 -0
  145. package/dist/plugins/frontmatter/MdastFrontmatterVisitor.d.ts +3 -0
  146. package/dist/plugins/frontmatter/MdastFrontmatterVisitor.js +10 -0
  147. package/dist/plugins/frontmatter/index.d.ts +717 -0
  148. package/dist/plugins/frontmatter/index.js +76 -0
  149. package/dist/plugins/headings/LexicalHeadingVisitor.d.ts +4 -0
  150. package/dist/plugins/headings/LexicalHeadingVisitor.js +11 -0
  151. package/dist/plugins/headings/MdastHeadingVisitor.d.ts +3 -0
  152. package/dist/plugins/headings/MdastHeadingVisitor.js +10 -0
  153. package/dist/plugins/headings/index.d.ts +707 -0
  154. package/dist/plugins/headings/index.js +69 -0
  155. package/dist/plugins/image/ImageDialog.d.ts +2 -0
  156. package/dist/plugins/image/ImageDialog.js +70 -0
  157. package/dist/plugins/image/ImageEditor.d.ts +10 -0
  158. package/dist/plugins/image/ImageEditor.js +227 -0
  159. package/dist/plugins/image/ImageNode.d.ts +65 -0
  160. package/dist/plugins/image/ImageNode.js +152 -0
  161. package/dist/plugins/image/ImageResizer.d.ts +18 -0
  162. package/dist/plugins/image/ImageResizer.js +214 -0
  163. package/dist/plugins/image/LexicalImageVisitor.d.ts +4 -0
  164. package/dist/plugins/image/LexicalImageVisitor.js +35 -0
  165. package/dist/plugins/image/MdastImageVisitor.d.ts +6 -0
  166. package/dist/plugins/image/MdastImageVisitor.js +87 -0
  167. package/dist/plugins/image/index.d.ts +804 -0
  168. package/dist/plugins/image/index.js +300 -0
  169. package/dist/plugins/jsx/LexicalJsxNode.d.ts +54 -0
  170. package/dist/plugins/jsx/LexicalJsxNode.js +102 -0
  171. package/dist/plugins/jsx/LexicalJsxVisitor.d.ts +4 -0
  172. package/dist/plugins/jsx/LexicalJsxVisitor.js +24 -0
  173. package/dist/plugins/jsx/MdastMdxJsEsmVisitor.d.ts +3 -0
  174. package/dist/plugins/jsx/MdastMdxJsEsmVisitor.js +8 -0
  175. package/dist/plugins/jsx/MdastMdxJsxElementVisitor.d.ts +3 -0
  176. package/dist/plugins/jsx/MdastMdxJsxElementVisitor.js +12 -0
  177. package/dist/plugins/jsx/index.d.ts +779 -0
  178. package/dist/plugins/jsx/index.js +82 -0
  179. package/dist/plugins/link/AutoLinkPlugin.d.ts +9 -0
  180. package/dist/plugins/link/AutoLinkPlugin.js +18 -0
  181. package/dist/plugins/link/LexicalLinkVisitor.d.ts +4 -0
  182. package/dist/plugins/link/LexicalLinkVisitor.js +10 -0
  183. package/dist/plugins/link/MdastLinkVisitor.d.ts +3 -0
  184. package/dist/plugins/link/MdastLinkVisitor.js +14 -0
  185. package/dist/plugins/link/index.d.ts +101 -0
  186. package/dist/plugins/link/index.js +33 -0
  187. package/dist/plugins/link-dialog/LinkDialog.d.ts +16 -0
  188. package/dist/plugins/link-dialog/LinkDialog.js +148 -0
  189. package/dist/plugins/link-dialog/index.d.ts +669 -0
  190. package/dist/plugins/link-dialog/index.js +254 -0
  191. package/dist/plugins/lists/LexicalListItemVisitor.d.ts +4 -0
  192. package/dist/plugins/lists/LexicalListItemVisitor.js +23 -0
  193. package/dist/plugins/lists/LexicalListVisitor.d.ts +4 -0
  194. package/dist/plugins/lists/LexicalListVisitor.js +13 -0
  195. package/dist/plugins/lists/MdastListItemVisitor.d.ts +3 -0
  196. package/dist/plugins/lists/MdastListItemVisitor.js +10 -0
  197. package/dist/plugins/lists/MdastListVisitor.d.ts +3 -0
  198. package/dist/plugins/lists/MdastListVisitor.js +20 -0
  199. package/dist/plugins/lists/index.d.ts +703 -0
  200. package/dist/plugins/lists/index.js +122 -0
  201. package/dist/plugins/markdown-shortcut/index.d.ts +80 -0
  202. package/dist/plugins/markdown-shortcut/index.js +90 -0
  203. package/dist/plugins/quote/LexicalQuoteVisitor.d.ts +4 -0
  204. package/dist/plugins/quote/LexicalQuoteVisitor.js +12 -0
  205. package/dist/plugins/quote/MdastBlockQuoteVisitor.d.ts +3 -0
  206. package/dist/plugins/quote/MdastBlockQuoteVisitor.js +10 -0
  207. package/dist/plugins/quote/index.d.ts +480 -0
  208. package/dist/plugins/quote/index.js +26 -0
  209. package/dist/plugins/sandpack/SandpackEditor.d.ts +7 -0
  210. package/dist/plugins/sandpack/SandpackEditor.js +37 -0
  211. package/dist/plugins/sandpack/index.d.ts +1077 -0
  212. package/dist/plugins/sandpack/index.js +93 -0
  213. package/dist/plugins/sandpack/useCodeMirrorRef.d.ts +4 -0
  214. package/dist/plugins/sandpack/useCodeMirrorRef.js +96 -0
  215. package/dist/plugins/table/LexicalTableVisitor.d.ts +4 -0
  216. package/dist/plugins/table/LexicalTableVisitor.js +10 -0
  217. package/dist/plugins/table/MdastTableVisitor.d.ts +3 -0
  218. package/dist/plugins/table/MdastTableVisitor.js +10 -0
  219. package/dist/plugins/table/TableEditor.d.ts +21 -0
  220. package/dist/plugins/table/TableEditor.js +388 -0
  221. package/dist/plugins/table/TableNode.d.ts +52 -0
  222. package/dist/plugins/table/TableNode.js +152 -0
  223. package/dist/plugins/table/index.d.ts +704 -0
  224. package/dist/plugins/table/index.js +69 -0
  225. package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.d.ts +4 -0
  226. package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.js +10 -0
  227. package/dist/plugins/thematic-break/MdastThematicBreakVisitor.d.ts +3 -0
  228. package/dist/plugins/thematic-break/MdastThematicBreakVisitor.js +10 -0
  229. package/dist/plugins/thematic-break/index.d.ts +693 -0
  230. package/dist/plugins/thematic-break/index.js +39 -0
  231. package/dist/plugins/toolbar/components/BlockTypeSelect.d.ts +6 -0
  232. package/dist/plugins/toolbar/components/BlockTypeSelect.js +54 -0
  233. package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.d.ts +5 -0
  234. package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.js +33 -0
  235. package/dist/plugins/toolbar/components/ChangeAdmonitionType.d.ts +6 -0
  236. package/dist/plugins/toolbar/components/ChangeAdmonitionType.js +30 -0
  237. package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.d.ts +7 -0
  238. package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.js +32 -0
  239. package/dist/plugins/toolbar/components/CodeToggle.d.ts +6 -0
  240. package/dist/plugins/toolbar/components/CodeToggle.js +19 -0
  241. package/dist/plugins/toolbar/components/CreateLink.d.ts +6 -0
  242. package/dist/plugins/toolbar/components/CreateLink.js +20 -0
  243. package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.d.ts +18 -0
  244. package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.js +25 -0
  245. package/dist/plugins/toolbar/components/InsertAdmonition.d.ts +6 -0
  246. package/dist/plugins/toolbar/components/InsertAdmonition.js +29 -0
  247. package/dist/plugins/toolbar/components/InsertCodeBlock.d.ts +7 -0
  248. package/dist/plugins/toolbar/components/InsertCodeBlock.js +20 -0
  249. package/dist/plugins/toolbar/components/InsertFrontmatter.d.ts +6 -0
  250. package/dist/plugins/toolbar/components/InsertFrontmatter.js +24 -0
  251. package/dist/plugins/toolbar/components/InsertImage.d.ts +6 -0
  252. package/dist/plugins/toolbar/components/InsertImage.js +14 -0
  253. package/dist/plugins/toolbar/components/InsertSandpack.d.ts +6 -0
  254. package/dist/plugins/toolbar/components/InsertSandpack.js +13 -0
  255. package/dist/plugins/toolbar/components/InsertTable.d.ts +6 -0
  256. package/dist/plugins/toolbar/components/InsertTable.js +20 -0
  257. package/dist/plugins/toolbar/components/InsertThematicBreak.d.ts +6 -0
  258. package/dist/plugins/toolbar/components/InsertThematicBreak.js +11 -0
  259. package/dist/plugins/toolbar/components/KitchenSinkToolbar.d.ts +7 -0
  260. package/dist/plugins/toolbar/components/KitchenSinkToolbar.js +58 -0
  261. package/dist/plugins/toolbar/components/ListsToggle.d.ts +7 -0
  262. package/dist/plugins/toolbar/components/ListsToggle.js +23 -0
  263. package/dist/plugins/toolbar/components/ShowSandpackInfo.d.ts +7 -0
  264. package/dist/plugins/toolbar/components/ShowSandpackInfo.js +31 -0
  265. package/dist/plugins/toolbar/components/UndoRedo.d.ts +5 -0
  266. package/dist/plugins/toolbar/components/UndoRedo.js +58 -0
  267. package/dist/plugins/toolbar/index.d.ts +564 -0
  268. package/dist/plugins/toolbar/index.js +40 -0
  269. package/dist/plugins/toolbar/primitives/DialogButton.d.ts +40 -0
  270. package/dist/plugins/toolbar/primitives/DialogButton.js +114 -0
  271. package/dist/plugins/toolbar/primitives/TooltipWrap.d.ts +8 -0
  272. package/dist/plugins/toolbar/primitives/TooltipWrap.js +12 -0
  273. package/dist/plugins/toolbar/primitives/select.d.ts +50 -0
  274. package/dist/plugins/toolbar/primitives/select.js +55 -0
  275. package/dist/plugins/toolbar/primitives/toolbar.d.ts +163 -0
  276. package/dist/plugins/toolbar/primitives/toolbar.js +115 -0
  277. package/dist/style.css +1093 -288
  278. package/dist/styles/globals.css.js +4 -0
  279. package/dist/styles/lexical-theme.module.css.js +62 -0
  280. package/dist/styles/lexicalTheme.d.ts +2 -0
  281. package/dist/styles/lexicalTheme.js +31 -0
  282. package/dist/styles/ui.module.css.js +311 -0
  283. package/dist/utils/detectMac.d.ts +3 -0
  284. package/dist/utils/detectMac.js +13 -0
  285. package/dist/utils/fp.d.ts +47 -0
  286. package/dist/utils/fp.js +44 -0
  287. package/dist/utils/isPartOftheEditorUI.d.ts +1 -0
  288. package/dist/utils/isPartOftheEditorUI.js +12 -0
  289. package/dist/utils/lexicalHelpers.d.ts +11 -0
  290. package/dist/utils/lexicalHelpers.js +80 -0
  291. package/dist/utils/makeHslTransparent.d.ts +1 -0
  292. package/dist/utils/makeHslTransparent.js +6 -0
  293. package/dist/utils/mergeStyleAttributes.d.ts +1 -0
  294. package/dist/utils/mergeStyleAttributes.js +22 -0
  295. package/dist/utils/uuid4.d.ts +1 -0
  296. package/dist/utils/uuid4.js +10 -0
  297. package/dist/utils/voidEmitter.d.ts +14 -0
  298. package/dist/utils/voidEmitter.js +15 -0
  299. package/dist/utils/whitespaceConversion.d.ts +2 -0
  300. package/dist/utils/whitespaceConversion.js +9 -0
  301. package/package.json +326 -39
  302. package/dist/index.cjs +0 -1
@@ -0,0 +1,122 @@
1
+ const MDX_NODE_TYPES = ["mdxJsxTextElement", "mdxJsxFlowElement"];
2
+ function isMdastHTMLNode(node) {
3
+ var _a;
4
+ return MDX_NODE_TYPES.includes(node.type) && htmlTags.includes(((_a = node.name) == null ? void 0 : _a.toLowerCase()) ?? "");
5
+ }
6
+ const htmlTags = [
7
+ "a",
8
+ "abbr",
9
+ "address",
10
+ "area",
11
+ "article",
12
+ "aside",
13
+ "audio",
14
+ "b",
15
+ "base",
16
+ "bdi",
17
+ "bdo",
18
+ "blockquote",
19
+ "body",
20
+ "br",
21
+ "button",
22
+ "canvas",
23
+ "caption",
24
+ "cite",
25
+ "code",
26
+ "col",
27
+ "colgroup",
28
+ "data",
29
+ "datalist",
30
+ "dd",
31
+ "del",
32
+ "details",
33
+ "dfn",
34
+ "dialog",
35
+ "div",
36
+ "dl",
37
+ "dt",
38
+ "em",
39
+ "embed",
40
+ "fieldset",
41
+ "figcaption",
42
+ "figure",
43
+ "footer",
44
+ "form",
45
+ "h1",
46
+ "h2",
47
+ "h3",
48
+ "h4",
49
+ "h5",
50
+ "h6",
51
+ "head",
52
+ "header",
53
+ "hgroup",
54
+ "hr",
55
+ "html",
56
+ "i",
57
+ "iframe",
58
+ // 'img',
59
+ "input",
60
+ "ins",
61
+ "kbd",
62
+ "label",
63
+ "legend",
64
+ "li",
65
+ "link",
66
+ "main",
67
+ "map",
68
+ "mark",
69
+ "meta",
70
+ "meter",
71
+ "nav",
72
+ "noscript",
73
+ "object",
74
+ "ol",
75
+ "optgroup",
76
+ "option",
77
+ "output",
78
+ "p",
79
+ "param",
80
+ "picture",
81
+ "pre",
82
+ "progress",
83
+ "q",
84
+ "rp",
85
+ "rt",
86
+ "ruby",
87
+ "s",
88
+ "samp",
89
+ "script",
90
+ "section",
91
+ "select",
92
+ "small",
93
+ "source",
94
+ "span",
95
+ "strong",
96
+ "style",
97
+ "sub",
98
+ "summary",
99
+ "sup",
100
+ "table",
101
+ "tbody",
102
+ "td",
103
+ "template",
104
+ "textarea",
105
+ "tfoot",
106
+ "th",
107
+ "thead",
108
+ "time",
109
+ "title",
110
+ "tr",
111
+ "track",
112
+ "u",
113
+ "ul",
114
+ "var",
115
+ "video",
116
+ "wbr"
117
+ ];
118
+ export {
119
+ MDX_NODE_TYPES,
120
+ htmlTags,
121
+ isMdastHTMLNode
122
+ };
@@ -0,0 +1,3 @@
1
+ import { MdastImportVisitor } from '../../importMarkdownToLexical';
2
+ import { MdastHTMLNode } from './MdastHTMLNode';
3
+ export declare const MdastHTMLVisitor: MdastImportVisitor<MdastHTMLNode>;
@@ -0,0 +1,12 @@
1
+ import { $createGenericHTMLNode } from "./GenericHTMLNode.js";
2
+ import { isMdastHTMLNode } from "./MdastHTMLNode.js";
3
+ const MdastHTMLVisitor = {
4
+ testNode: isMdastHTMLNode,
5
+ visitNode: function({ mdastNode, actions }) {
6
+ actions.addAndStepInto($createGenericHTMLNode(mdastNode.name, mdastNode.type, mdastNode.attributes));
7
+ },
8
+ priority: -100
9
+ };
10
+ export {
11
+ MdastHTMLVisitor
12
+ };
@@ -0,0 +1,3 @@
1
+ import * as Mdast from 'mdast';
2
+ import { MdastImportVisitor } from '../../importMarkdownToLexical';
3
+ export declare const MdastInlineCodeVisitor: MdastImportVisitor<Mdast.InlineCode>;
@@ -0,0 +1,27 @@
1
+ import { $createTextNode } from "lexical";
2
+ import { IS_CODE } from "../../FormatConstants.js";
3
+ function isOpeningCodeNode(node) {
4
+ return node.type === "html" && node.value === "<code>";
5
+ }
6
+ function isClosingCodeNode(node) {
7
+ return node.type === "html" && node.value === "</code>";
8
+ }
9
+ const MdastInlineCodeVisitor = {
10
+ testNode: (node) => {
11
+ return node.type === "inlineCode" || isOpeningCodeNode(node) || isClosingCodeNode(node);
12
+ },
13
+ visitNode({ mdastNode, actions, mdastParent }) {
14
+ if (isOpeningCodeNode(mdastNode)) {
15
+ actions.addFormatting(IS_CODE, mdastParent);
16
+ return;
17
+ }
18
+ if (isClosingCodeNode(mdastNode)) {
19
+ actions.removeFormatting(IS_CODE, mdastParent);
20
+ return;
21
+ }
22
+ actions.addAndStepInto($createTextNode(mdastNode.value).setFormat(IS_CODE));
23
+ }
24
+ };
25
+ export {
26
+ MdastInlineCodeVisitor
27
+ };
@@ -0,0 +1,3 @@
1
+ import * as Mdast from 'mdast';
2
+ import { MdastImportVisitor } from '../../importMarkdownToLexical';
3
+ export declare const MdastParagraphVisitor: MdastImportVisitor<Mdast.Paragraph>;
@@ -0,0 +1,15 @@
1
+ import { $createParagraphNode } from "lexical";
2
+ const lexicalTypesThatShouldSkipParagraphs = ["listitem", "quote", "admonition"];
3
+ const MdastParagraphVisitor = {
4
+ testNode: "paragraph",
5
+ visitNode: function({ mdastNode, lexicalParent, actions }) {
6
+ if (lexicalTypesThatShouldSkipParagraphs.includes(lexicalParent.getType())) {
7
+ actions.visitChildren(mdastNode, lexicalParent);
8
+ } else {
9
+ actions.addAndStepInto($createParagraphNode());
10
+ }
11
+ }
12
+ };
13
+ export {
14
+ MdastParagraphVisitor
15
+ };
@@ -0,0 +1,3 @@
1
+ import * as Mdast from 'mdast';
2
+ import { MdastImportVisitor } from '../../importMarkdownToLexical';
3
+ export declare const MdastRootVisitor: MdastImportVisitor<Mdast.Content>;
@@ -0,0 +1,9 @@
1
+ const MdastRootVisitor = {
2
+ testNode: "root",
3
+ visitNode({ actions, mdastNode, lexicalParent }) {
4
+ actions.visitChildren(mdastNode, lexicalParent);
5
+ }
6
+ };
7
+ export {
8
+ MdastRootVisitor
9
+ };
@@ -0,0 +1,3 @@
1
+ import * as Mdast from 'mdast';
2
+ import { MdastImportVisitor } from '../../importMarkdownToLexical';
3
+ export declare const MdastTextVisitor: MdastImportVisitor<Mdast.Text>;
@@ -0,0 +1,10 @@
1
+ import { $createTextNode } from "lexical";
2
+ const MdastTextVisitor = {
3
+ testNode: "text",
4
+ visitNode({ mdastNode, actions }) {
5
+ actions.addAndStepInto($createTextNode(mdastNode.value).setFormat(actions.getParentFormatting()));
6
+ }
7
+ };
8
+ export {
9
+ MdastTextVisitor
10
+ };
@@ -0,0 +1,92 @@
1
+ import { DecoratorNode, EditorConfig, LexicalEditor } from 'lexical';
2
+ import * as Mdast from 'mdast';
3
+ import type { Data, Node } from 'unist';
4
+ import React from 'react';
5
+ import { ContentEditable } from '@lexical/react/LexicalContentEditable.js';
6
+ import { VoidEmitter } from '../../utils/voidEmitter';
7
+ /**
8
+ * The value of the {@link NestedEditorsContext} React context.
9
+ */
10
+ export interface NestedEditorsContextValue<T extends Node> {
11
+ /**
12
+ * The parent lexical editor
13
+ */
14
+ parentEditor: LexicalEditor;
15
+ /**
16
+ * The parent editor config
17
+ */
18
+ config: EditorConfig;
19
+ /**
20
+ * The mdast node that is being edited
21
+ */
22
+ mdastNode: T;
23
+ /**
24
+ * The lexical node that is being edited
25
+ */
26
+ lexicalNode: DecoratorNode<any> & {
27
+ /**
28
+ * Use this method to update the mdast node. This will also update the mdast tree of the parent editor.
29
+ */
30
+ setMdastNode: (mdastNode: any) => void;
31
+ };
32
+ /**
33
+ * Subscribe to the emitter and implement the logic to focus the custom editor.
34
+ */
35
+ focusEmitter: VoidEmitter;
36
+ }
37
+ /**
38
+ * Use this context to provide the necessary values to the {@link NestedLexicalEditor} React component.
39
+ * Place it as a wrapper in your custom lexical node decorators.
40
+ */
41
+ export declare const NestedEditorsContext: React.Context<NestedEditorsContextValue<Node<Data>> | undefined>;
42
+ /**
43
+ * A hook to get the current {@link NestedEditorsContext} value. Use this in your custom editor components.
44
+ */
45
+ export declare function useNestedEditorContext<T extends Mdast.Content>(): NestedEditorsContextValue<T>;
46
+ /**
47
+ * A hook that returns a function that can be used to update the mdast node. Use this in your custom editor components.
48
+ */
49
+ export declare function useMdastNodeUpdater<T extends Mdast.Content>(): (node: Partial<T>) => void;
50
+ /**
51
+ * A hook that returns a function that removes the lexical node from the editor.
52
+ */
53
+ export declare function useLexicalNodeRemove(): () => void;
54
+ /**
55
+ * The properties of the {@link NestedLexicalEditor} React component.
56
+ * @typeParam T - The type of the mdast node of the editor.
57
+ */
58
+ export interface NestedEditorProps<T extends Mdast.Content> {
59
+ /**
60
+ * A function that returns the phrasing content of the mdast node. In most cases, this will be the `children` property of the mdast node, but you can also have multiple nested nodes with their own children.
61
+ */
62
+ getContent: (mdastNode: T) => Mdast.Content[];
63
+ /**
64
+ * A function that should return the updated mdast node based on the original mdast node and the new content (serialized as mdast tree) produced by the editor.
65
+ */
66
+ getUpdatedMdastNode: (mdastNode: T, children: Mdast.Content[]) => T;
67
+ /**
68
+ * Props passed to the {@link https://github.com/facebook/lexical/blob/main/packages/lexical-react/src/LexicalContentEditable.tsx | ContentEditable} component.
69
+ */
70
+ contentEditableProps?: React.ComponentProps<typeof ContentEditable>;
71
+ /**
72
+ * Whether or not the editor edits blocks (multiple paragraphs)
73
+ */
74
+ block?: boolean;
75
+ }
76
+ /**
77
+ * A nested editor React component that allows editing of the contents of complex markdown nodes that have nested markdown content (for example, custom directives or JSX elements). See the {@link NestedEditorProps} for more details on the compoment props.
78
+ *
79
+ * @example
80
+ * You can use a type param to specify the type of the mdast node
81
+ *
82
+ * ```tsx
83
+ *
84
+ * interface CalloutDirectiveNode extends LeafDirective {
85
+ * name: 'callout'
86
+ * children: Mdast.PhrasingContent[]
87
+ * }
88
+ *
89
+ * return <NestedLexicalEditor<CalloutDirectiveNode> getContent={node => node.children} getUpdatedMdastNode={(node, children) => ({ ...node, children })} />
90
+ * ```
91
+ */
92
+ export declare const NestedLexicalEditor: <T extends Mdast.Content>(props: NestedEditorProps<T>) => React.JSX.Element;
@@ -0,0 +1,185 @@
1
+ import { $addUpdateTag, $getNodeByKey, createEditor, $getRoot, BLUR_COMMAND, COMMAND_PRIORITY_EDITOR, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_HIGH, KEY_BACKSPACE_COMMAND, COMMAND_PRIORITY_CRITICAL } from "lexical";
2
+ import React__default from "react";
3
+ import { NESTED_EDITOR_UPDATED_COMMAND, corePluginHooks } from "./index.js";
4
+ import { ContentEditable } from "@lexical/react/LexicalContentEditable.js";
5
+ import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary.js";
6
+ import { LexicalNestedComposer } from "@lexical/react/LexicalNestedComposer.js";
7
+ import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin.js";
8
+ import { lexicalTheme } from "../../styles/lexicalTheme.js";
9
+ import { exportLexicalTreeToMdast } from "../../exportMarkdownFromLexical.js";
10
+ import { importMdastTreeToLexical } from "../../importMarkdownToLexical.js";
11
+ import styles from "../../styles/ui.module.css.js";
12
+ import { SharedHistoryPlugin } from "./SharedHistoryPlugin.js";
13
+ import { mergeRegister } from "@lexical/utils";
14
+ import { isPartOftheEditorUI } from "../../utils/isPartOftheEditorUI.js";
15
+ const NestedEditorsContext = React__default.createContext(void 0);
16
+ function useNestedEditorContext() {
17
+ const context = React__default.useContext(NestedEditorsContext);
18
+ if (!context) {
19
+ throw new Error("useNestedEditor must be used within a NestedEditorsProvider");
20
+ }
21
+ return context;
22
+ }
23
+ function useMdastNodeUpdater() {
24
+ const { parentEditor, mdastNode, lexicalNode } = useNestedEditorContext();
25
+ return function updateMdastNode(node) {
26
+ parentEditor.update(
27
+ () => {
28
+ $addUpdateTag("history-push");
29
+ const currentNode = $getNodeByKey(lexicalNode.getKey());
30
+ if (currentNode) {
31
+ currentNode.setMdastNode({ ...mdastNode, ...node });
32
+ }
33
+ },
34
+ { discrete: true }
35
+ );
36
+ parentEditor.dispatchCommand(NESTED_EDITOR_UPDATED_COMMAND, void 0);
37
+ };
38
+ }
39
+ function useLexicalNodeRemove() {
40
+ const { parentEditor, lexicalNode } = useNestedEditorContext();
41
+ return () => {
42
+ parentEditor.update(() => {
43
+ const node = $getNodeByKey(lexicalNode.getKey());
44
+ node.selectNext();
45
+ node.remove();
46
+ });
47
+ };
48
+ }
49
+ const NestedLexicalEditor = function(props) {
50
+ const { getContent, getUpdatedMdastNode, contentEditableProps, block = false } = props;
51
+ const { mdastNode, lexicalNode, focusEmitter } = useNestedEditorContext();
52
+ const updateMdastNode = useMdastNodeUpdater();
53
+ const removeNode = useLexicalNodeRemove();
54
+ const content = getContent(mdastNode);
55
+ const [rootEditor] = corePluginHooks.useEmitterValues("rootEditor");
56
+ const [importVisitors, exportVisitors, usedLexicalNodes, jsxComponentDescriptors, jsxIsAvailable, nestedEditorChildren] = corePluginHooks.useEmitterValues(
57
+ "importVisitors",
58
+ "exportVisitors",
59
+ "usedLexicalNodes",
60
+ "jsxComponentDescriptors",
61
+ "jsxIsAvailable",
62
+ "nestedEditorChildren"
63
+ );
64
+ const setEditorInFocus = corePluginHooks.usePublisher("editorInFocus");
65
+ const [editor] = React__default.useState(() => {
66
+ const editor2 = createEditor({
67
+ nodes: usedLexicalNodes,
68
+ theme: lexicalTheme
69
+ });
70
+ return editor2;
71
+ });
72
+ React__default.useEffect(() => {
73
+ focusEmitter == null ? void 0 : focusEmitter.subscribe(() => {
74
+ editor.focus();
75
+ });
76
+ }, [editor, focusEmitter]);
77
+ React__default.useEffect(() => {
78
+ editor.update(() => {
79
+ $getRoot().clear();
80
+ let theContent = content;
81
+ if (block) {
82
+ if (theContent.length === 0) {
83
+ theContent = [{ type: "paragraph", children: [] }];
84
+ }
85
+ } else {
86
+ theContent = [{ type: "paragraph", children: content }];
87
+ }
88
+ importMdastTreeToLexical({
89
+ root: $getRoot(),
90
+ mdastRoot: {
91
+ type: "root",
92
+ children: theContent
93
+ },
94
+ visitors: importVisitors
95
+ });
96
+ });
97
+ }, [editor, block, importVisitors]);
98
+ React__default.useEffect(() => {
99
+ function updateParentNode() {
100
+ editor.getEditorState().read(() => {
101
+ const mdast = exportLexicalTreeToMdast({
102
+ root: $getRoot(),
103
+ visitors: exportVisitors,
104
+ jsxComponentDescriptors,
105
+ jsxIsAvailable,
106
+ addImportStatements: false
107
+ });
108
+ const content2 = block ? mdast.children : mdast.children[0].children;
109
+ updateMdastNode(getUpdatedMdastNode(structuredClone(mdastNode), content2));
110
+ });
111
+ }
112
+ return mergeRegister(
113
+ editor.registerCommand(
114
+ BLUR_COMMAND,
115
+ (payload) => {
116
+ const relatedTarget = payload.relatedTarget;
117
+ if (isPartOftheEditorUI(relatedTarget, rootEditor.getRootElement())) {
118
+ return false;
119
+ }
120
+ updateParentNode();
121
+ setEditorInFocus(null);
122
+ return true;
123
+ },
124
+ COMMAND_PRIORITY_EDITOR
125
+ ),
126
+ // triggered by codemirror
127
+ editor.registerCommand(
128
+ NESTED_EDITOR_UPDATED_COMMAND,
129
+ () => {
130
+ updateParentNode();
131
+ return true;
132
+ },
133
+ COMMAND_PRIORITY_EDITOR
134
+ ),
135
+ editor.registerCommand(
136
+ SELECTION_CHANGE_COMMAND,
137
+ () => {
138
+ setEditorInFocus({ editorType: "lexical", rootNode: lexicalNode });
139
+ return false;
140
+ },
141
+ COMMAND_PRIORITY_HIGH
142
+ ),
143
+ editor.registerCommand(
144
+ KEY_BACKSPACE_COMMAND,
145
+ (_, editor2) => {
146
+ const editorElement = editor2.getRootElement();
147
+ if ((editorElement == null ? void 0 : editorElement.innerText) === "\n") {
148
+ removeNode();
149
+ return true;
150
+ }
151
+ return false;
152
+ },
153
+ COMMAND_PRIORITY_CRITICAL
154
+ )
155
+ );
156
+ }, [
157
+ block,
158
+ editor,
159
+ exportVisitors,
160
+ getUpdatedMdastNode,
161
+ jsxComponentDescriptors,
162
+ jsxIsAvailable,
163
+ lexicalNode,
164
+ mdastNode,
165
+ removeNode,
166
+ setEditorInFocus,
167
+ updateMdastNode,
168
+ rootEditor
169
+ ]);
170
+ return /* @__PURE__ */ React__default.createElement(LexicalNestedComposer, { initialEditor: editor }, /* @__PURE__ */ React__default.createElement(
171
+ RichTextPlugin,
172
+ {
173
+ contentEditable: /* @__PURE__ */ React__default.createElement(ContentEditable, { ...contentEditableProps, className: styles.nestedEditor }),
174
+ placeholder: null,
175
+ ErrorBoundary: LexicalErrorBoundary
176
+ }
177
+ ), /* @__PURE__ */ React__default.createElement(SharedHistoryPlugin, null), nestedEditorChildren.map((Child, index) => /* @__PURE__ */ React__default.createElement(Child, { key: index })));
178
+ };
179
+ export {
180
+ NestedEditorsContext,
181
+ NestedLexicalEditor,
182
+ useLexicalNodeRemove,
183
+ useMdastNodeUpdater,
184
+ useNestedEditorContext
185
+ };
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ /**
3
+ * The properties of the {@link PropertyPopover} React component.
4
+ */
5
+ export interface PropertyPopoverProps {
6
+ /**
7
+ * The properties to edit. The key is the name of the property, and the value is the initial value.
8
+ */
9
+ properties: Record<string, string>;
10
+ /**
11
+ * Triggered when the user edits the property values.
12
+ */
13
+ onChange: (values: Record<string, string>) => void;
14
+ /**
15
+ * The title to display in the popover.
16
+ */
17
+ title: string;
18
+ }
19
+ /**
20
+ * A React component that can be used in custom editors to edit the properties of the node.
21
+ * Displays a simple, static key/value editing UI in a popover.
22
+ */
23
+ export declare const PropertyPopover: React.FC<PropertyPopoverProps>;
@@ -0,0 +1,39 @@
1
+ import * as RadixPopover from "@radix-ui/react-popover";
2
+ import React__default from "react";
3
+ import { useForm } from "react-hook-form";
4
+ import styles from "../../styles/ui.module.css.js";
5
+ import { PopoverPortal, PopoverContent } from "./ui/PopoverUtils.js";
6
+ import { corePluginHooks } from "./index.js";
7
+ const PropertyPopover = ({ title, properties, onChange }) => {
8
+ const [open, setOpen] = React__default.useState(false);
9
+ const [iconComponentFor] = corePluginHooks.useEmitterValues("iconComponentFor");
10
+ const { register, handleSubmit, reset } = useForm({ defaultValues: properties });
11
+ return /* @__PURE__ */ React__default.createElement(RadixPopover.Root, { open, onOpenChange: (v) => setOpen(v) }, /* @__PURE__ */ React__default.createElement(RadixPopover.Trigger, { className: styles.iconButton }, /* @__PURE__ */ React__default.createElement("div", null, iconComponentFor("settings"))), /* @__PURE__ */ React__default.createElement(PopoverPortal, null, /* @__PURE__ */ React__default.createElement(PopoverContent, null, /* @__PURE__ */ React__default.createElement(
12
+ "form",
13
+ {
14
+ onSubmit: (e) => {
15
+ void handleSubmit(onChange)(e);
16
+ setOpen(false);
17
+ e.preventDefault();
18
+ e.stopPropagation();
19
+ }
20
+ },
21
+ /* @__PURE__ */ React__default.createElement("h3", { className: styles.propertyPanelTitle }, title, " Attributes"),
22
+ /* @__PURE__ */ React__default.createElement("table", { className: styles.propertyEditorTable }, /* @__PURE__ */ React__default.createElement("thead", null, /* @__PURE__ */ React__default.createElement("tr", null, /* @__PURE__ */ React__default.createElement("th", { className: styles.readOnlyColumnCell }, "Attribute"), /* @__PURE__ */ React__default.createElement("th", null, "Value"))), /* @__PURE__ */ React__default.createElement("tbody", null, Object.keys(properties).map((propName) => /* @__PURE__ */ React__default.createElement("tr", { key: propName }, /* @__PURE__ */ React__default.createElement("th", { className: styles.readOnlyColumnCell }, " ", propName, " "), /* @__PURE__ */ React__default.createElement("td", null, /* @__PURE__ */ React__default.createElement("input", { ...register(propName), className: styles.propertyEditorInput }))))), /* @__PURE__ */ React__default.createElement("tfoot", null, /* @__PURE__ */ React__default.createElement("tr", null, /* @__PURE__ */ React__default.createElement("td", { colSpan: 2 }, /* @__PURE__ */ React__default.createElement("div", { className: styles.buttonsFooter }, /* @__PURE__ */ React__default.createElement("button", { type: "submit", className: styles.primaryButton }, "Save"), /* @__PURE__ */ React__default.createElement(
23
+ "button",
24
+ {
25
+ type: "reset",
26
+ className: styles.secondaryButton,
27
+ onClick: (e) => {
28
+ e.preventDefault();
29
+ reset(properties);
30
+ setOpen(false);
31
+ }
32
+ },
33
+ "Cancel"
34
+ ))))))
35
+ ))));
36
+ };
37
+ export {
38
+ PropertyPopover
39
+ };
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const SharedHistoryPlugin: () => React.JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin.js";
2
+ import React__default from "react";
3
+ import { corePluginHooks } from "./index.js";
4
+ const SharedHistoryPlugin = () => {
5
+ const [historyState] = corePluginHooks.useEmitterValues("historyState");
6
+ return /* @__PURE__ */ React__default.createElement(HistoryPlugin, { externalHistoryState: historyState });
7
+ };
8
+ export {
9
+ SharedHistoryPlugin
10
+ };