@mdxeditor/editor 0.0.0-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 (286) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +28 -0
  3. package/dist/FormatConstants.d.ts +9 -0
  4. package/dist/FormatConstants.js +10 -0
  5. package/dist/MDXEditor.d.ts +92 -0
  6. package/dist/MDXEditor.js +142 -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 +133 -0
  12. package/dist/exportMarkdownFromLexical.js +202 -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/code_block.svg.js +5 -0
  30. package/dist/icons/content_copy.svg.js +5 -0
  31. package/dist/icons/delete_big.svg.js +5 -0
  32. package/dist/icons/delete_small.svg.js +5 -0
  33. package/dist/icons/difference.svg.js +5 -0
  34. package/dist/icons/edit.svg.js +5 -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 +7 -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/frontmatter.svg.js +5 -0
  45. package/dist/icons/horizontal_rule.svg.js +5 -0
  46. package/dist/icons/insert_col_left.svg.js +5 -0
  47. package/dist/icons/insert_col_right.svg.js +5 -0
  48. package/dist/icons/insert_row_above.svg.js +5 -0
  49. package/dist/icons/insert_row_below.svg.js +5 -0
  50. package/dist/icons/link.svg.js +5 -0
  51. package/dist/icons/link_off.svg.js +5 -0
  52. package/dist/icons/markdown.svg.js +5 -0
  53. package/dist/icons/more_horiz.svg.js +5 -0
  54. package/dist/icons/more_vert.svg.js +5 -0
  55. package/dist/icons/open_in_new.svg.js +5 -0
  56. package/dist/icons/redo.svg.js +5 -0
  57. package/dist/icons/rich_text.svg.js +5 -0
  58. package/dist/icons/sandpack.svg.js +5 -0
  59. package/dist/icons/settings.svg.js +7 -0
  60. package/dist/icons/table.svg.js +5 -0
  61. package/dist/icons/undo.svg.js +5 -0
  62. package/dist/importMarkdownToLexical.d.ts +91 -0
  63. package/dist/importMarkdownToLexical.js +69 -0
  64. package/dist/index.d.ts +54 -0
  65. package/dist/index.js +175 -0
  66. package/dist/jsx-editors/GenericJsxEditor.d.ts +8 -0
  67. package/dist/jsx-editors/GenericJsxEditor.js +56 -0
  68. package/dist/plugins/codeblock/CodeBlockNode.d.ts +100 -0
  69. package/dist/plugins/codeblock/CodeBlockNode.js +158 -0
  70. package/dist/plugins/codeblock/CodeBlockVisitor.d.ts +4 -0
  71. package/dist/plugins/codeblock/CodeBlockVisitor.js +14 -0
  72. package/dist/plugins/codeblock/MdastCodeVisitor.d.ts +3 -0
  73. package/dist/plugins/codeblock/MdastCodeVisitor.js +16 -0
  74. package/dist/plugins/codeblock/index.d.ts +697 -0
  75. package/dist/plugins/codeblock/index.js +73 -0
  76. package/dist/plugins/codemirror/CodeMirrorEditor.d.ts +3 -0
  77. package/dist/plugins/codemirror/CodeMirrorEditor.js +42 -0
  78. package/dist/plugins/codemirror/index.d.ts +912 -0
  79. package/dist/plugins/codemirror/index.js +62 -0
  80. package/dist/plugins/core/Icon.d.ts +6 -0
  81. package/dist/plugins/core/Icon.js +94 -0
  82. package/dist/plugins/core/LexicalLinebreakVisitor.d.ts +4 -0
  83. package/dist/plugins/core/LexicalLinebreakVisitor.js +10 -0
  84. package/dist/plugins/core/LexicalParagraphVisitor.d.ts +4 -0
  85. package/dist/plugins/core/LexicalParagraphVisitor.js +10 -0
  86. package/dist/plugins/core/LexicalRootVisitor.d.ts +4 -0
  87. package/dist/plugins/core/LexicalRootVisitor.js +10 -0
  88. package/dist/plugins/core/LexicalTextVisitor.d.ts +5 -0
  89. package/dist/plugins/core/LexicalTextVisitor.js +85 -0
  90. package/dist/plugins/core/MdastBreakVisitor.d.ts +3 -0
  91. package/dist/plugins/core/MdastBreakVisitor.js +10 -0
  92. package/dist/plugins/core/MdastFormattingVisitor.d.ts +4 -0
  93. package/dist/plugins/core/MdastFormattingVisitor.js +36 -0
  94. package/dist/plugins/core/MdastInlineCodeVisitor.d.ts +3 -0
  95. package/dist/plugins/core/MdastInlineCodeVisitor.js +27 -0
  96. package/dist/plugins/core/MdastParagraphVisitor.d.ts +3 -0
  97. package/dist/plugins/core/MdastParagraphVisitor.js +15 -0
  98. package/dist/plugins/core/MdastRootVisitor.d.ts +3 -0
  99. package/dist/plugins/core/MdastRootVisitor.js +9 -0
  100. package/dist/plugins/core/MdastTextVisitor.d.ts +3 -0
  101. package/dist/plugins/core/MdastTextVisitor.js +10 -0
  102. package/dist/plugins/core/NestedLexicalEditor.d.ts +92 -0
  103. package/dist/plugins/core/NestedLexicalEditor.js +180 -0
  104. package/dist/plugins/core/PropertyPopover.d.ts +23 -0
  105. package/dist/plugins/core/PropertyPopover.js +39 -0
  106. package/dist/plugins/core/SharedHistoryPlugin.d.ts +2 -0
  107. package/dist/plugins/core/SharedHistoryPlugin.js +10 -0
  108. package/dist/plugins/core/index.d.ts +506 -0
  109. package/dist/plugins/core/index.js +420 -0
  110. package/dist/plugins/core/ui/DownshiftAutoComplete.d.ts +15 -0
  111. package/dist/plugins/core/ui/DownshiftAutoComplete.js +83 -0
  112. package/dist/plugins/core/ui/PopoverUtils.d.ts +4 -0
  113. package/dist/plugins/core/ui/PopoverUtils.js +17 -0
  114. package/dist/plugins/diff-source/DiffSourceWrapper.d.ts +4 -0
  115. package/dist/plugins/diff-source/DiffSourceWrapper.js +11 -0
  116. package/dist/plugins/diff-source/DiffViewer.d.ts +2 -0
  117. package/dist/plugins/diff-source/DiffViewer.js +59 -0
  118. package/dist/plugins/diff-source/SourceEditor.d.ts +4 -0
  119. package/dist/plugins/diff-source/SourceEditor.js +47 -0
  120. package/dist/plugins/diff-source/index.d.ts +635 -0
  121. package/dist/plugins/diff-source/index.js +57 -0
  122. package/dist/plugins/directives/DirectiveNode.d.ts +51 -0
  123. package/dist/plugins/directives/DirectiveNode.js +92 -0
  124. package/dist/plugins/directives/DirectiveVisitor.d.ts +4 -0
  125. package/dist/plugins/directives/DirectiveVisitor.js +10 -0
  126. package/dist/plugins/directives/MdastDirectiveVisitor.d.ts +3 -0
  127. package/dist/plugins/directives/MdastDirectiveVisitor.js +13 -0
  128. package/dist/plugins/directives/index.d.ts +683 -0
  129. package/dist/plugins/directives/index.js +53 -0
  130. package/dist/plugins/frontmatter/FrontmatterEditor.d.ts +6 -0
  131. package/dist/plugins/frontmatter/FrontmatterEditor.js +85 -0
  132. package/dist/plugins/frontmatter/FrontmatterNode.d.ts +35 -0
  133. package/dist/plugins/frontmatter/FrontmatterNode.js +71 -0
  134. package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.d.ts +4 -0
  135. package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.js +10 -0
  136. package/dist/plugins/frontmatter/MdastFrontmatterVisitor.d.ts +3 -0
  137. package/dist/plugins/frontmatter/MdastFrontmatterVisitor.js +10 -0
  138. package/dist/plugins/frontmatter/index.d.ts +627 -0
  139. package/dist/plugins/frontmatter/index.js +76 -0
  140. package/dist/plugins/headings/LexicalHeadingVisitor.d.ts +4 -0
  141. package/dist/plugins/headings/LexicalHeadingVisitor.js +11 -0
  142. package/dist/plugins/headings/MdastHeadingVisitor.d.ts +3 -0
  143. package/dist/plugins/headings/MdastHeadingVisitor.js +10 -0
  144. package/dist/plugins/headings/index.d.ts +617 -0
  145. package/dist/plugins/headings/index.js +69 -0
  146. package/dist/plugins/image/ImageDialog.d.ts +2 -0
  147. package/dist/plugins/image/ImageDialog.js +70 -0
  148. package/dist/plugins/image/ImageEditor.d.ts +10 -0
  149. package/dist/plugins/image/ImageEditor.js +227 -0
  150. package/dist/plugins/image/ImageNode.d.ts +65 -0
  151. package/dist/plugins/image/ImageNode.js +152 -0
  152. package/dist/plugins/image/ImageResizer.d.ts +18 -0
  153. package/dist/plugins/image/ImageResizer.js +214 -0
  154. package/dist/plugins/image/LexicalImageVisitor.d.ts +4 -0
  155. package/dist/plugins/image/LexicalImageVisitor.js +35 -0
  156. package/dist/plugins/image/MdastImageVisitor.d.ts +6 -0
  157. package/dist/plugins/image/MdastImageVisitor.js +87 -0
  158. package/dist/plugins/image/index.d.ts +714 -0
  159. package/dist/plugins/image/index.js +300 -0
  160. package/dist/plugins/jsx/LexicalJsxNode.d.ts +54 -0
  161. package/dist/plugins/jsx/LexicalJsxNode.js +102 -0
  162. package/dist/plugins/jsx/LexicalJsxVisitor.d.ts +4 -0
  163. package/dist/plugins/jsx/LexicalJsxVisitor.js +12 -0
  164. package/dist/plugins/jsx/MdastMdxJsEsmVisitor.d.ts +3 -0
  165. package/dist/plugins/jsx/MdastMdxJsEsmVisitor.js +8 -0
  166. package/dist/plugins/jsx/MdastMdxJsxElementVisitor.d.ts +3 -0
  167. package/dist/plugins/jsx/MdastMdxJsxElementVisitor.js +12 -0
  168. package/dist/plugins/jsx/index.d.ts +688 -0
  169. package/dist/plugins/jsx/index.js +78 -0
  170. package/dist/plugins/link/AutoLinkPlugin.d.ts +9 -0
  171. package/dist/plugins/link/AutoLinkPlugin.js +18 -0
  172. package/dist/plugins/link/LexicalLinkVisitor.d.ts +4 -0
  173. package/dist/plugins/link/LexicalLinkVisitor.js +10 -0
  174. package/dist/plugins/link/MdastLinkVisitor.d.ts +3 -0
  175. package/dist/plugins/link/MdastLinkVisitor.js +14 -0
  176. package/dist/plugins/link/index.d.ts +92 -0
  177. package/dist/plugins/link/index.js +33 -0
  178. package/dist/plugins/link-dialog/LinkDialog.d.ts +16 -0
  179. package/dist/plugins/link-dialog/LinkDialog.js +148 -0
  180. package/dist/plugins/link-dialog/index.d.ts +595 -0
  181. package/dist/plugins/link-dialog/index.js +260 -0
  182. package/dist/plugins/lists/LexicalListItemVisitor.d.ts +4 -0
  183. package/dist/plugins/lists/LexicalListItemVisitor.js +23 -0
  184. package/dist/plugins/lists/LexicalListVisitor.d.ts +4 -0
  185. package/dist/plugins/lists/LexicalListVisitor.js +13 -0
  186. package/dist/plugins/lists/MdastListItemVisitor.d.ts +3 -0
  187. package/dist/plugins/lists/MdastListItemVisitor.js +10 -0
  188. package/dist/plugins/lists/MdastListVisitor.d.ts +3 -0
  189. package/dist/plugins/lists/MdastListVisitor.js +20 -0
  190. package/dist/plugins/lists/index.d.ts +613 -0
  191. package/dist/plugins/lists/index.js +119 -0
  192. package/dist/plugins/markdown-shortcut/index.d.ts +71 -0
  193. package/dist/plugins/markdown-shortcut/index.js +90 -0
  194. package/dist/plugins/quote/LexicalQuoteVisitor.d.ts +4 -0
  195. package/dist/plugins/quote/LexicalQuoteVisitor.js +12 -0
  196. package/dist/plugins/quote/MdastBlockQuoteVisitor.d.ts +3 -0
  197. package/dist/plugins/quote/MdastBlockQuoteVisitor.js +10 -0
  198. package/dist/plugins/quote/index.d.ts +417 -0
  199. package/dist/plugins/quote/index.js +26 -0
  200. package/dist/plugins/sandpack/SandpackEditor.d.ts +7 -0
  201. package/dist/plugins/sandpack/SandpackEditor.js +37 -0
  202. package/dist/plugins/sandpack/index.d.ts +951 -0
  203. package/dist/plugins/sandpack/index.js +93 -0
  204. package/dist/plugins/sandpack/useCodeMirrorRef.d.ts +4 -0
  205. package/dist/plugins/sandpack/useCodeMirrorRef.js +96 -0
  206. package/dist/plugins/table/LexicalTableVisitor.d.ts +4 -0
  207. package/dist/plugins/table/LexicalTableVisitor.js +10 -0
  208. package/dist/plugins/table/MdastTableVisitor.d.ts +3 -0
  209. package/dist/plugins/table/MdastTableVisitor.js +10 -0
  210. package/dist/plugins/table/TableEditor.d.ts +21 -0
  211. package/dist/plugins/table/TableEditor.js +388 -0
  212. package/dist/plugins/table/TableNode.d.ts +52 -0
  213. package/dist/plugins/table/TableNode.js +152 -0
  214. package/dist/plugins/table/index.d.ts +614 -0
  215. package/dist/plugins/table/index.js +69 -0
  216. package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.d.ts +4 -0
  217. package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.js +10 -0
  218. package/dist/plugins/thematic-break/MdastThematicBreakVisitor.d.ts +3 -0
  219. package/dist/plugins/thematic-break/MdastThematicBreakVisitor.js +10 -0
  220. package/dist/plugins/thematic-break/index.d.ts +603 -0
  221. package/dist/plugins/thematic-break/index.js +39 -0
  222. package/dist/plugins/toolbar/components/BlockTypeSelect.d.ts +6 -0
  223. package/dist/plugins/toolbar/components/BlockTypeSelect.js +54 -0
  224. package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.d.ts +5 -0
  225. package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.js +33 -0
  226. package/dist/plugins/toolbar/components/ChangeAdmonitionType.d.ts +6 -0
  227. package/dist/plugins/toolbar/components/ChangeAdmonitionType.js +30 -0
  228. package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.d.ts +7 -0
  229. package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.js +32 -0
  230. package/dist/plugins/toolbar/components/CodeToggle.d.ts +6 -0
  231. package/dist/plugins/toolbar/components/CodeToggle.js +19 -0
  232. package/dist/plugins/toolbar/components/CreateLink.d.ts +6 -0
  233. package/dist/plugins/toolbar/components/CreateLink.js +20 -0
  234. package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.d.ts +18 -0
  235. package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.js +25 -0
  236. package/dist/plugins/toolbar/components/InsertAdmonition.d.ts +6 -0
  237. package/dist/plugins/toolbar/components/InsertAdmonition.js +29 -0
  238. package/dist/plugins/toolbar/components/InsertCodeBlock.d.ts +7 -0
  239. package/dist/plugins/toolbar/components/InsertCodeBlock.js +20 -0
  240. package/dist/plugins/toolbar/components/InsertFrontmatter.d.ts +6 -0
  241. package/dist/plugins/toolbar/components/InsertFrontmatter.js +24 -0
  242. package/dist/plugins/toolbar/components/InsertImage.d.ts +6 -0
  243. package/dist/plugins/toolbar/components/InsertImage.js +14 -0
  244. package/dist/plugins/toolbar/components/InsertSandpack.d.ts +6 -0
  245. package/dist/plugins/toolbar/components/InsertSandpack.js +13 -0
  246. package/dist/plugins/toolbar/components/InsertTable.d.ts +6 -0
  247. package/dist/plugins/toolbar/components/InsertTable.js +20 -0
  248. package/dist/plugins/toolbar/components/InsertThematicBreak.d.ts +6 -0
  249. package/dist/plugins/toolbar/components/InsertThematicBreak.js +11 -0
  250. package/dist/plugins/toolbar/components/KitchenSinkToolbar.d.ts +7 -0
  251. package/dist/plugins/toolbar/components/KitchenSinkToolbar.js +58 -0
  252. package/dist/plugins/toolbar/components/ListsToggle.d.ts +7 -0
  253. package/dist/plugins/toolbar/components/ListsToggle.js +23 -0
  254. package/dist/plugins/toolbar/components/ShowSandpackInfo.d.ts +7 -0
  255. package/dist/plugins/toolbar/components/ShowSandpackInfo.js +31 -0
  256. package/dist/plugins/toolbar/components/UndoRedo.d.ts +5 -0
  257. package/dist/plugins/toolbar/components/UndoRedo.js +58 -0
  258. package/dist/plugins/toolbar/index.d.ts +492 -0
  259. package/dist/plugins/toolbar/index.js +40 -0
  260. package/dist/plugins/toolbar/primitives/DialogButton.d.ts +40 -0
  261. package/dist/plugins/toolbar/primitives/DialogButton.js +114 -0
  262. package/dist/plugins/toolbar/primitives/TooltipWrap.d.ts +8 -0
  263. package/dist/plugins/toolbar/primitives/TooltipWrap.js +12 -0
  264. package/dist/plugins/toolbar/primitives/select.d.ts +50 -0
  265. package/dist/plugins/toolbar/primitives/select.js +55 -0
  266. package/dist/plugins/toolbar/primitives/toolbar.d.ts +163 -0
  267. package/dist/plugins/toolbar/primitives/toolbar.js +115 -0
  268. package/dist/style.css +1715 -0
  269. package/dist/styles/globals.css.js +4 -0
  270. package/dist/styles/lexical-theme.module.css.js +62 -0
  271. package/dist/styles/lexicalTheme.d.ts +2 -0
  272. package/dist/styles/lexicalTheme.js +31 -0
  273. package/dist/styles/ui.module.css.js +308 -0
  274. package/dist/utils/detectMac.d.ts +3 -0
  275. package/dist/utils/detectMac.js +13 -0
  276. package/dist/utils/fp.d.ts +47 -0
  277. package/dist/utils/fp.js +14 -0
  278. package/dist/utils/isPartOftheEditorUI.d.ts +1 -0
  279. package/dist/utils/isPartOftheEditorUI.js +12 -0
  280. package/dist/utils/lexicalHelpers.d.ts +11 -0
  281. package/dist/utils/lexicalHelpers.js +62 -0
  282. package/dist/utils/uuid4.d.ts +1 -0
  283. package/dist/utils/uuid4.js +10 -0
  284. package/dist/utils/voidEmitter.d.ts +14 -0
  285. package/dist/utils/voidEmitter.js +15 -0
  286. package/package.json +435 -0
@@ -0,0 +1,62 @@
1
+ import { coreSystem } from "../core/index.js";
2
+ import { codeBlockSystem } from "../codeblock/index.js";
3
+ import { CodeMirrorEditor } from "./CodeMirrorEditor.js";
4
+ import { system } from "../../gurx/realmFactory.js";
5
+ import { realmPlugin } from "../../gurx/react.js";
6
+ const defaultCodeBlockLanguages = {
7
+ js: "JavaScript",
8
+ ts: "TypeScript",
9
+ tsx: "TypeScript (React)",
10
+ jsx: "JavaScript (React)",
11
+ css: "CSS"
12
+ };
13
+ const codeMirrorSystem = system(
14
+ (r, [, { insertCodeBlock }]) => {
15
+ const codeBlockLanguages = r.node(defaultCodeBlockLanguages);
16
+ const insertCodeMirror = r.node();
17
+ r.link(
18
+ r.pipe(
19
+ insertCodeMirror,
20
+ r.o.map(({ language, code }) => {
21
+ return {
22
+ code,
23
+ language,
24
+ meta: ""
25
+ };
26
+ })
27
+ ),
28
+ insertCodeBlock
29
+ );
30
+ return {
31
+ codeBlockLanguages,
32
+ insertCodeMirror
33
+ };
34
+ },
35
+ [coreSystem, codeBlockSystem]
36
+ );
37
+ const [
38
+ /** @internal */
39
+ codeMirrorPlugin,
40
+ /** @internal */
41
+ codeMirrorHooks
42
+ ] = realmPlugin({
43
+ id: "codemirror",
44
+ systemSpec: codeMirrorSystem,
45
+ applyParamsToSystem(r, params) {
46
+ r.pubKey("codeBlockLanguages", params.codeBlockLanguages);
47
+ },
48
+ init(r, { codeBlockLanguages }) {
49
+ r.pubKey("appendCodeBlockEditorDescriptor", {
50
+ match(language, meta) {
51
+ return codeBlockLanguages.hasOwnProperty(language) && meta === "";
52
+ },
53
+ priority: 1,
54
+ Editor: CodeMirrorEditor
55
+ });
56
+ }
57
+ });
58
+ export {
59
+ codeMirrorHooks,
60
+ codeMirrorPlugin,
61
+ codeMirrorSystem
62
+ };
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export type IconKey = 'add_column' | 'add_photo' | 'add_row' | 'arrow_drop_down' | 'check' | 'check_small' | 'close' | 'code' | 'content_copy' | 'delete_big' | 'delete_small' | 'sandpack' | 'difference' | 'edit' | 'admonition' | 'format_align_center' | 'format_align_left' | 'format_align_right' | 'format_bold' | 'format_italic' | 'format_list_bulleted' | 'format_list_checked' | 'format_list_numbered' | 'format_underlined' | 'code_block' | 'frontmatter' | 'horizontal_rule' | 'insert_col_left' | 'insert_col_right' | 'insert_row_above' | 'insert_row_below' | 'link' | 'link_off' | 'markdown' | 'more_horiz' | 'more_vert' | 'open_in_new' | 'redo' | 'rich_text' | 'settings' | 'table' | 'undo';
3
+ declare const Icon: React.FC<{
4
+ name: IconKey;
5
+ }>;
6
+ export default Icon;
@@ -0,0 +1,94 @@
1
+ import React__default from "react";
2
+ import SvgAddColumn from "../../icons/add_column.svg.js";
3
+ import SvgAddPhoto from "../../icons/add_photo.svg.js";
4
+ import SvgAddRow from "../../icons/add_row.svg.js";
5
+ import SvgArrowDropDown from "../../icons/arrow_drop_down.svg.js";
6
+ import SvgCheck from "../../icons/check.svg.js";
7
+ import SvgCheckSmall from "../../icons/check_small.svg.js";
8
+ import SvgClose from "../../icons/close.svg.js";
9
+ import SvgCode from "../../icons/code.svg.js";
10
+ import SvgContentCopy from "../../icons/content_copy.svg.js";
11
+ import SvgDeleteBig from "../../icons/delete_big.svg.js";
12
+ import SvgDeleteSmall from "../../icons/delete_small.svg.js";
13
+ import SvgSandpack from "../../icons/sandpack.svg.js";
14
+ import SvgDifference from "../../icons/difference.svg.js";
15
+ import SvgEdit from "../../icons/edit.svg.js";
16
+ import SvgAdmonition from "../../icons/admonition.svg.js";
17
+ import SvgFormatAlignCenter from "../../icons/format_align_center.svg.js";
18
+ import SvgFormatAlignLeft from "../../icons/format_align_left.svg.js";
19
+ import SvgFormatAlignRight from "../../icons/format_align_right.svg.js";
20
+ import SvgFormatBold from "../../icons/format_bold.svg.js";
21
+ import SvgFormatItalic from "../../icons/format_italic.svg.js";
22
+ import SvgFormatListBulleted from "../../icons/format_list_bulleted.svg.js";
23
+ import SvgFormatListChecked from "../../icons/format_list_checked.svg.js";
24
+ import SvgFormatListNumbered from "../../icons/format_list_numbered.svg.js";
25
+ import SvgFormatUnderlined from "../../icons/format_underlined.svg.js";
26
+ import SvgCodeBlock from "../../icons/code_block.svg.js";
27
+ import SvgFrontmatter from "../../icons/frontmatter.svg.js";
28
+ import SvgHorizontalRule from "../../icons/horizontal_rule.svg.js";
29
+ import SvgInsertColLeft from "../../icons/insert_col_left.svg.js";
30
+ import SvgInsertColRight from "../../icons/insert_col_right.svg.js";
31
+ import SvgInsertRowAbove from "../../icons/insert_row_above.svg.js";
32
+ import SvgInsertRowBelow from "../../icons/insert_row_below.svg.js";
33
+ import SvgLink from "../../icons/link.svg.js";
34
+ import SvgLinkOff from "../../icons/link_off.svg.js";
35
+ import SvgMarkdown from "../../icons/markdown.svg.js";
36
+ import SvgMoreHoriz from "../../icons/more_horiz.svg.js";
37
+ import SvgMoreVert from "../../icons/more_vert.svg.js";
38
+ import SvgOpenInNew from "../../icons/open_in_new.svg.js";
39
+ import SvgRedo from "../../icons/redo.svg.js";
40
+ import SvgRichText from "../../icons/rich_text.svg.js";
41
+ import SvgSettings from "../../icons/settings.svg.js";
42
+ import SvgTable from "../../icons/table.svg.js";
43
+ import SvgUndo from "../../icons/undo.svg.js";
44
+ const IconMap = {
45
+ add_column: SvgAddColumn,
46
+ add_photo: SvgAddPhoto,
47
+ add_row: SvgAddRow,
48
+ arrow_drop_down: SvgArrowDropDown,
49
+ check: SvgCheck,
50
+ check_small: SvgCheckSmall,
51
+ close: SvgClose,
52
+ code: SvgCode,
53
+ content_copy: SvgContentCopy,
54
+ delete_big: SvgDeleteBig,
55
+ delete_small: SvgDeleteSmall,
56
+ sandpack: SvgSandpack,
57
+ difference: SvgDifference,
58
+ edit: SvgEdit,
59
+ admonition: SvgAdmonition,
60
+ format_align_center: SvgFormatAlignCenter,
61
+ format_align_left: SvgFormatAlignLeft,
62
+ format_align_right: SvgFormatAlignRight,
63
+ format_bold: SvgFormatBold,
64
+ format_italic: SvgFormatItalic,
65
+ format_list_bulleted: SvgFormatListBulleted,
66
+ format_list_checked: SvgFormatListChecked,
67
+ format_list_numbered: SvgFormatListNumbered,
68
+ format_underlined: SvgFormatUnderlined,
69
+ code_block: SvgCodeBlock,
70
+ frontmatter: SvgFrontmatter,
71
+ horizontal_rule: SvgHorizontalRule,
72
+ insert_col_left: SvgInsertColLeft,
73
+ insert_col_right: SvgInsertColRight,
74
+ insert_row_above: SvgInsertRowAbove,
75
+ insert_row_below: SvgInsertRowBelow,
76
+ link: SvgLink,
77
+ link_off: SvgLinkOff,
78
+ markdown: SvgMarkdown,
79
+ more_horiz: SvgMoreHoriz,
80
+ more_vert: SvgMoreVert,
81
+ open_in_new: SvgOpenInNew,
82
+ redo: SvgRedo,
83
+ rich_text: SvgRichText,
84
+ settings: SvgSettings,
85
+ table: SvgTable,
86
+ undo: SvgUndo
87
+ };
88
+ const Icon = ({ name }) => {
89
+ const IconComponent = IconMap[name];
90
+ return /* @__PURE__ */ React__default.createElement(IconComponent, null);
91
+ };
92
+ export {
93
+ Icon as default
94
+ };
@@ -0,0 +1,4 @@
1
+ import { LineBreakNode } from 'lexical';
2
+ import * as Mdast from 'mdast';
3
+ import { LexicalExportVisitor } from '../../exportMarkdownFromLexical';
4
+ export declare const LexicalLinebreakVisitor: LexicalExportVisitor<LineBreakNode, Mdast.Text>;
@@ -0,0 +1,10 @@
1
+ import { $isLineBreakNode } from "lexical";
2
+ const LexicalLinebreakVisitor = {
3
+ testLexicalNode: $isLineBreakNode,
4
+ visitLexicalNode: ({ mdastParent, actions }) => {
5
+ actions.appendToParent(mdastParent, { type: "text", value: "\n" });
6
+ }
7
+ };
8
+ export {
9
+ LexicalLinebreakVisitor
10
+ };
@@ -0,0 +1,4 @@
1
+ import { ParagraphNode } from 'lexical';
2
+ import * as Mdast from 'mdast';
3
+ import { LexicalExportVisitor } from '../../exportMarkdownFromLexical';
4
+ export declare const LexicalParagraphVisitor: LexicalExportVisitor<ParagraphNode, Mdast.Paragraph>;
@@ -0,0 +1,10 @@
1
+ import { $isParagraphNode } from "lexical";
2
+ const LexicalParagraphVisitor = {
3
+ testLexicalNode: $isParagraphNode,
4
+ visitLexicalNode: ({ actions }) => {
5
+ actions.addAndStepInto("paragraph");
6
+ }
7
+ };
8
+ export {
9
+ LexicalParagraphVisitor
10
+ };
@@ -0,0 +1,4 @@
1
+ import { RootNode as LexicalRootNode } from 'lexical';
2
+ import * as Mdast from 'mdast';
3
+ import { LexicalExportVisitor } from '../../exportMarkdownFromLexical';
4
+ export declare const LexicalRootVisitor: LexicalExportVisitor<LexicalRootNode, Mdast.Content>;
@@ -0,0 +1,10 @@
1
+ import { $isRootNode } from "lexical";
2
+ const LexicalRootVisitor = {
3
+ testLexicalNode: $isRootNode,
4
+ visitLexicalNode: ({ actions }) => {
5
+ actions.addAndStepInto("root");
6
+ }
7
+ };
8
+ export {
9
+ LexicalRootVisitor
10
+ };
@@ -0,0 +1,5 @@
1
+ import { TextNode } from 'lexical';
2
+ import * as Mdast from 'mdast';
3
+ import { LexicalExportVisitor } from '../../exportMarkdownFromLexical';
4
+ export declare function isMdastText(mdastNode: Mdast.Content): mdastNode is Mdast.Text;
5
+ export declare const LexicalTextVisitor: LexicalExportVisitor<TextNode, Mdast.Text>;
@@ -0,0 +1,85 @@
1
+ import { $isTextNode } from "lexical";
2
+ import { IS_CODE, IS_ITALIC, IS_BOLD, IS_UNDERLINE } from "../../FormatConstants.js";
3
+ function isMdastText(mdastNode) {
4
+ return mdastNode.type === "text";
5
+ }
6
+ const LexicalTextVisitor = {
7
+ shouldJoin: (prevNode, currentNode) => {
8
+ return ["text", "emphasis", "strong", "mdxJsxTextElement"].includes(prevNode.type) && prevNode.type === currentNode.type;
9
+ },
10
+ join(prevNode, currentNode) {
11
+ if (isMdastText(prevNode) && isMdastText(currentNode)) {
12
+ return {
13
+ type: "text",
14
+ value: prevNode.value + currentNode.value
15
+ };
16
+ } else {
17
+ return {
18
+ ...prevNode,
19
+ children: [...prevNode.children, ...currentNode.children]
20
+ };
21
+ }
22
+ },
23
+ testLexicalNode: $isTextNode,
24
+ visitLexicalNode: ({ lexicalNode, mdastParent, actions }) => {
25
+ const previousSibling = lexicalNode.getPreviousSibling();
26
+ const prevFormat = $isTextNode(previousSibling) ? previousSibling.getFormat() : 0;
27
+ const textContent = lexicalNode.getTextContent();
28
+ const format = lexicalNode.getFormat() ?? 0;
29
+ if (format & IS_CODE) {
30
+ actions.addAndStepInto("inlineCode", {
31
+ value: textContent
32
+ });
33
+ return;
34
+ }
35
+ let localParentNode = mdastParent;
36
+ if (prevFormat & format & IS_ITALIC) {
37
+ localParentNode = actions.appendToParent(localParentNode, {
38
+ type: "emphasis",
39
+ children: []
40
+ });
41
+ }
42
+ if (prevFormat & format & IS_BOLD) {
43
+ localParentNode = actions.appendToParent(localParentNode, {
44
+ type: "strong",
45
+ children: []
46
+ });
47
+ }
48
+ if (prevFormat & format & IS_UNDERLINE) {
49
+ localParentNode = actions.appendToParent(localParentNode, {
50
+ type: "mdxJsxTextElement",
51
+ name: "u",
52
+ children: [],
53
+ attributes: []
54
+ });
55
+ }
56
+ if (format & IS_ITALIC && !(prevFormat & IS_ITALIC)) {
57
+ localParentNode = actions.appendToParent(localParentNode, {
58
+ type: "emphasis",
59
+ children: []
60
+ });
61
+ }
62
+ if (format & IS_BOLD && !(prevFormat & IS_BOLD)) {
63
+ localParentNode = actions.appendToParent(localParentNode, {
64
+ type: "strong",
65
+ children: []
66
+ });
67
+ }
68
+ if (format & IS_UNDERLINE && !(prevFormat & IS_UNDERLINE)) {
69
+ localParentNode = actions.appendToParent(localParentNode, {
70
+ type: "mdxJsxTextElement",
71
+ name: "u",
72
+ children: [],
73
+ attributes: []
74
+ });
75
+ }
76
+ actions.appendToParent(localParentNode, {
77
+ type: "text",
78
+ value: textContent
79
+ });
80
+ }
81
+ };
82
+ export {
83
+ LexicalTextVisitor,
84
+ isMdastText
85
+ };
@@ -0,0 +1,3 @@
1
+ import * as Mdast from 'mdast';
2
+ import { MdastImportVisitor } from '../../importMarkdownToLexical';
3
+ export declare const MdastBreakVisitor: MdastImportVisitor<Mdast.Paragraph>;
@@ -0,0 +1,10 @@
1
+ import { $createLineBreakNode } from "lexical";
2
+ const MdastBreakVisitor = {
3
+ testNode: "break",
4
+ visitNode: function({ lexicalParent }) {
5
+ lexicalParent.append($createLineBreakNode());
6
+ }
7
+ };
8
+ export {
9
+ MdastBreakVisitor
10
+ };
@@ -0,0 +1,4 @@
1
+ import * as Mdast from 'mdast';
2
+ import { MdxJsxTextElement } from 'mdast-util-mdx';
3
+ import { MdastImportVisitor } from '../../importMarkdownToLexical';
4
+ export declare const MdastFormattingVisitor: MdastImportVisitor<Mdast.Emphasis | Mdast.Strong | MdxJsxTextElement>;
@@ -0,0 +1,36 @@
1
+ import { IS_UNDERLINE, IS_ITALIC, IS_BOLD } from "../../FormatConstants.js";
2
+ function isOpeningUnderlineNode(node) {
3
+ return node.type === "html" && node.value === "<u>";
4
+ }
5
+ function isClosingUnderlineNode(node) {
6
+ return node.type === "html" && node.value === "</u>";
7
+ }
8
+ function isJsxUnderlineNode(node) {
9
+ return node.type === "mdxJsxTextElement" && node.name === "u";
10
+ }
11
+ const MdastFormattingVisitor = {
12
+ testNode(mdastNode) {
13
+ return mdastNode.type === "emphasis" || mdastNode.type === "strong" || isJsxUnderlineNode(mdastNode) || isOpeningUnderlineNode(mdastNode) || isClosingUnderlineNode(mdastNode);
14
+ },
15
+ visitNode({ mdastNode, lexicalParent, actions, mdastParent }) {
16
+ if (isOpeningUnderlineNode(mdastNode)) {
17
+ actions.addFormatting(IS_UNDERLINE, mdastParent);
18
+ return;
19
+ }
20
+ if (isClosingUnderlineNode(mdastNode)) {
21
+ actions.removeFormatting(IS_UNDERLINE, mdastParent);
22
+ return;
23
+ }
24
+ if (mdastNode.type === "emphasis") {
25
+ actions.addFormatting(IS_ITALIC);
26
+ } else if (mdastNode.type === "strong") {
27
+ actions.addFormatting(IS_BOLD);
28
+ } else if (isJsxUnderlineNode(mdastNode)) {
29
+ actions.addFormatting(IS_UNDERLINE);
30
+ }
31
+ actions.visitChildren(mdastNode, lexicalParent);
32
+ }
33
+ };
34
+ export {
35
+ MdastFormattingVisitor
36
+ };
@@ -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;