@mdxeditor/editor 0.0.1 → 0.0.4-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 (300) 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/close.svg.js +5 -0
  27. package/dist/icons/code.svg.js +5 -0
  28. package/dist/icons/content_copy.svg.js +5 -0
  29. package/dist/icons/delete_big.svg.js +5 -0
  30. package/dist/icons/delete_small.svg.js +5 -0
  31. package/dist/icons/difference.svg.js +5 -0
  32. package/dist/icons/edit.svg.js +5 -0
  33. package/dist/icons/format_align_center.svg.js +5 -0
  34. package/dist/icons/format_align_left.svg.js +5 -0
  35. package/dist/icons/format_align_right.svg.js +5 -0
  36. package/dist/icons/format_bold.svg.js +5 -0
  37. package/dist/icons/format_italic.svg.js +5 -0
  38. package/dist/icons/format_list_bulleted.svg.js +5 -0
  39. package/dist/icons/format_list_checked.svg.js +5 -0
  40. package/dist/icons/format_list_numbered.svg.js +5 -0
  41. package/dist/icons/format_underlined.svg.js +5 -0
  42. package/dist/icons/frame_source.svg.js +5 -0
  43. package/dist/icons/frontmatter.svg.js +5 -0
  44. package/dist/icons/horizontal_rule.svg.js +5 -0
  45. package/dist/icons/insert_col_left.svg.js +5 -0
  46. package/dist/icons/insert_col_right.svg.js +5 -0
  47. package/dist/icons/insert_row_above.svg.js +5 -0
  48. package/dist/icons/insert_row_below.svg.js +5 -0
  49. package/dist/icons/link.svg.js +5 -0
  50. package/dist/icons/link_off.svg.js +5 -0
  51. package/dist/icons/markdown.svg.js +5 -0
  52. package/dist/icons/more_horiz.svg.js +5 -0
  53. package/dist/icons/more_vert.svg.js +5 -0
  54. package/dist/icons/open_in_new.svg.js +5 -0
  55. package/dist/icons/redo.svg.js +5 -0
  56. package/dist/icons/rich_text.svg.js +5 -0
  57. package/dist/icons/sandpack.svg.js +5 -0
  58. package/dist/icons/settings.svg.js +5 -0
  59. package/dist/icons/table.svg.js +5 -0
  60. package/dist/icons/undo.svg.js +5 -0
  61. package/dist/importMarkdownToLexical.d.ts +101 -0
  62. package/dist/importMarkdownToLexical.js +93 -0
  63. package/dist/index.d.ts +62 -726
  64. package/dist/index.js +207 -4501
  65. package/dist/jsx-editors/GenericJsxEditor.d.ts +8 -0
  66. package/dist/jsx-editors/GenericJsxEditor.js +56 -0
  67. package/dist/plugins/codeblock/CodeBlockNode.d.ts +100 -0
  68. package/dist/plugins/codeblock/CodeBlockNode.js +158 -0
  69. package/dist/plugins/codeblock/CodeBlockVisitor.d.ts +4 -0
  70. package/dist/plugins/codeblock/CodeBlockVisitor.js +14 -0
  71. package/dist/plugins/codeblock/MdastCodeVisitor.d.ts +3 -0
  72. package/dist/plugins/codeblock/MdastCodeVisitor.js +16 -0
  73. package/dist/plugins/codeblock/index.d.ts +787 -0
  74. package/dist/plugins/codeblock/index.js +73 -0
  75. package/dist/plugins/codemirror/CodeMirrorEditor.d.ts +3 -0
  76. package/dist/plugins/codemirror/CodeMirrorEditor.js +42 -0
  77. package/dist/plugins/codemirror/index.d.ts +1038 -0
  78. package/dist/plugins/codemirror/index.js +62 -0
  79. package/dist/plugins/core/GenericHTMLNode.d.ts +38 -0
  80. package/dist/plugins/core/GenericHTMLNode.js +117 -0
  81. package/dist/plugins/core/Icon.d.ts +6 -0
  82. package/dist/plugins/core/Icon.js +92 -0
  83. package/dist/plugins/core/LexicalGenericHTMLNodeVisitor.d.ts +4 -0
  84. package/dist/plugins/core/LexicalGenericHTMLNodeVisitor.js +15 -0
  85. package/dist/plugins/core/LexicalLinebreakVisitor.d.ts +4 -0
  86. package/dist/plugins/core/LexicalLinebreakVisitor.js +10 -0
  87. package/dist/plugins/core/LexicalParagraphVisitor.d.ts +4 -0
  88. package/dist/plugins/core/LexicalParagraphVisitor.js +10 -0
  89. package/dist/plugins/core/LexicalRootVisitor.d.ts +4 -0
  90. package/dist/plugins/core/LexicalRootVisitor.js +10 -0
  91. package/dist/plugins/core/LexicalTextVisitor.d.ts +5 -0
  92. package/dist/plugins/core/LexicalTextVisitor.js +102 -0
  93. package/dist/plugins/core/MdastBreakVisitor.d.ts +3 -0
  94. package/dist/plugins/core/MdastBreakVisitor.js +10 -0
  95. package/dist/plugins/core/MdastFormattingVisitor.d.ts +4 -0
  96. package/dist/plugins/core/MdastFormattingVisitor.js +36 -0
  97. package/dist/plugins/core/MdastHTMLNode.d.ts +13 -0
  98. package/dist/plugins/core/MdastHTMLNode.js +122 -0
  99. package/dist/plugins/core/MdastHTMLVisitor.d.ts +3 -0
  100. package/dist/plugins/core/MdastHTMLVisitor.js +12 -0
  101. package/dist/plugins/core/MdastInlineCodeVisitor.d.ts +3 -0
  102. package/dist/plugins/core/MdastInlineCodeVisitor.js +27 -0
  103. package/dist/plugins/core/MdastParagraphVisitor.d.ts +3 -0
  104. package/dist/plugins/core/MdastParagraphVisitor.js +15 -0
  105. package/dist/plugins/core/MdastRootVisitor.d.ts +3 -0
  106. package/dist/plugins/core/MdastRootVisitor.js +9 -0
  107. package/dist/plugins/core/MdastTextVisitor.d.ts +3 -0
  108. package/dist/plugins/core/MdastTextVisitor.js +10 -0
  109. package/dist/plugins/core/NestedLexicalEditor.d.ts +92 -0
  110. package/dist/plugins/core/NestedLexicalEditor.js +185 -0
  111. package/dist/plugins/core/PropertyPopover.d.ts +23 -0
  112. package/dist/plugins/core/PropertyPopover.js +39 -0
  113. package/dist/plugins/core/SharedHistoryPlugin.d.ts +2 -0
  114. package/dist/plugins/core/SharedHistoryPlugin.js +10 -0
  115. package/dist/plugins/core/index.d.ts +583 -0
  116. package/dist/plugins/core/index.js +490 -0
  117. package/dist/plugins/core/ui/DownshiftAutoComplete.d.ts +15 -0
  118. package/dist/plugins/core/ui/DownshiftAutoComplete.js +83 -0
  119. package/dist/plugins/core/ui/PopoverUtils.d.ts +4 -0
  120. package/dist/plugins/core/ui/PopoverUtils.js +17 -0
  121. package/dist/plugins/diff-source/DiffSourceWrapper.d.ts +4 -0
  122. package/dist/plugins/diff-source/DiffSourceWrapper.js +14 -0
  123. package/dist/plugins/diff-source/DiffViewer.d.ts +2 -0
  124. package/dist/plugins/diff-source/DiffViewer.js +59 -0
  125. package/dist/plugins/diff-source/SourceEditor.d.ts +4 -0
  126. package/dist/plugins/diff-source/SourceEditor.js +53 -0
  127. package/dist/plugins/diff-source/index.d.ts +725 -0
  128. package/dist/plugins/diff-source/index.js +56 -0
  129. package/dist/plugins/directives/DirectiveNode.d.ts +51 -0
  130. package/dist/plugins/directives/DirectiveNode.js +92 -0
  131. package/dist/plugins/directives/DirectiveVisitor.d.ts +4 -0
  132. package/dist/plugins/directives/DirectiveVisitor.js +10 -0
  133. package/dist/plugins/directives/MdastDirectiveVisitor.d.ts +3 -0
  134. package/dist/plugins/directives/MdastDirectiveVisitor.js +13 -0
  135. package/dist/plugins/directives/index.d.ts +773 -0
  136. package/dist/plugins/directives/index.js +53 -0
  137. package/dist/plugins/frontmatter/FrontmatterEditor.d.ts +6 -0
  138. package/dist/plugins/frontmatter/FrontmatterEditor.js +85 -0
  139. package/dist/plugins/frontmatter/FrontmatterNode.d.ts +35 -0
  140. package/dist/plugins/frontmatter/FrontmatterNode.js +71 -0
  141. package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.d.ts +4 -0
  142. package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.js +10 -0
  143. package/dist/plugins/frontmatter/MdastFrontmatterVisitor.d.ts +3 -0
  144. package/dist/plugins/frontmatter/MdastFrontmatterVisitor.js +10 -0
  145. package/dist/plugins/frontmatter/index.d.ts +717 -0
  146. package/dist/plugins/frontmatter/index.js +76 -0
  147. package/dist/plugins/headings/LexicalHeadingVisitor.d.ts +4 -0
  148. package/dist/plugins/headings/LexicalHeadingVisitor.js +11 -0
  149. package/dist/plugins/headings/MdastHeadingVisitor.d.ts +3 -0
  150. package/dist/plugins/headings/MdastHeadingVisitor.js +10 -0
  151. package/dist/plugins/headings/index.d.ts +707 -0
  152. package/dist/plugins/headings/index.js +69 -0
  153. package/dist/plugins/image/ImageDialog.d.ts +2 -0
  154. package/dist/plugins/image/ImageDialog.js +70 -0
  155. package/dist/plugins/image/ImageEditor.d.ts +10 -0
  156. package/dist/plugins/image/ImageEditor.js +227 -0
  157. package/dist/plugins/image/ImageNode.d.ts +65 -0
  158. package/dist/plugins/image/ImageNode.js +152 -0
  159. package/dist/plugins/image/ImageResizer.d.ts +18 -0
  160. package/dist/plugins/image/ImageResizer.js +214 -0
  161. package/dist/plugins/image/LexicalImageVisitor.d.ts +4 -0
  162. package/dist/plugins/image/LexicalImageVisitor.js +35 -0
  163. package/dist/plugins/image/MdastImageVisitor.d.ts +6 -0
  164. package/dist/plugins/image/MdastImageVisitor.js +87 -0
  165. package/dist/plugins/image/index.d.ts +804 -0
  166. package/dist/plugins/image/index.js +300 -0
  167. package/dist/plugins/jsx/LexicalJsxNode.d.ts +54 -0
  168. package/dist/plugins/jsx/LexicalJsxNode.js +102 -0
  169. package/dist/plugins/jsx/LexicalJsxVisitor.d.ts +4 -0
  170. package/dist/plugins/jsx/LexicalJsxVisitor.js +24 -0
  171. package/dist/plugins/jsx/MdastMdxJsEsmVisitor.d.ts +3 -0
  172. package/dist/plugins/jsx/MdastMdxJsEsmVisitor.js +8 -0
  173. package/dist/plugins/jsx/MdastMdxJsxElementVisitor.d.ts +3 -0
  174. package/dist/plugins/jsx/MdastMdxJsxElementVisitor.js +12 -0
  175. package/dist/plugins/jsx/index.d.ts +779 -0
  176. package/dist/plugins/jsx/index.js +82 -0
  177. package/dist/plugins/link/AutoLinkPlugin.d.ts +9 -0
  178. package/dist/plugins/link/AutoLinkPlugin.js +18 -0
  179. package/dist/plugins/link/LexicalLinkVisitor.d.ts +4 -0
  180. package/dist/plugins/link/LexicalLinkVisitor.js +10 -0
  181. package/dist/plugins/link/MdastLinkVisitor.d.ts +3 -0
  182. package/dist/plugins/link/MdastLinkVisitor.js +14 -0
  183. package/dist/plugins/link/index.d.ts +101 -0
  184. package/dist/plugins/link/index.js +33 -0
  185. package/dist/plugins/link-dialog/LinkDialog.d.ts +16 -0
  186. package/dist/plugins/link-dialog/LinkDialog.js +148 -0
  187. package/dist/plugins/link-dialog/index.d.ts +669 -0
  188. package/dist/plugins/link-dialog/index.js +254 -0
  189. package/dist/plugins/lists/LexicalListItemVisitor.d.ts +4 -0
  190. package/dist/plugins/lists/LexicalListItemVisitor.js +23 -0
  191. package/dist/plugins/lists/LexicalListVisitor.d.ts +4 -0
  192. package/dist/plugins/lists/LexicalListVisitor.js +13 -0
  193. package/dist/plugins/lists/MdastListItemVisitor.d.ts +3 -0
  194. package/dist/plugins/lists/MdastListItemVisitor.js +10 -0
  195. package/dist/plugins/lists/MdastListVisitor.d.ts +3 -0
  196. package/dist/plugins/lists/MdastListVisitor.js +20 -0
  197. package/dist/plugins/lists/index.d.ts +703 -0
  198. package/dist/plugins/lists/index.js +122 -0
  199. package/dist/plugins/markdown-shortcut/index.d.ts +80 -0
  200. package/dist/plugins/markdown-shortcut/index.js +90 -0
  201. package/dist/plugins/quote/LexicalQuoteVisitor.d.ts +4 -0
  202. package/dist/plugins/quote/LexicalQuoteVisitor.js +12 -0
  203. package/dist/plugins/quote/MdastBlockQuoteVisitor.d.ts +3 -0
  204. package/dist/plugins/quote/MdastBlockQuoteVisitor.js +10 -0
  205. package/dist/plugins/quote/index.d.ts +480 -0
  206. package/dist/plugins/quote/index.js +26 -0
  207. package/dist/plugins/sandpack/SandpackEditor.d.ts +7 -0
  208. package/dist/plugins/sandpack/SandpackEditor.js +37 -0
  209. package/dist/plugins/sandpack/index.d.ts +1077 -0
  210. package/dist/plugins/sandpack/index.js +93 -0
  211. package/dist/plugins/sandpack/useCodeMirrorRef.d.ts +4 -0
  212. package/dist/plugins/sandpack/useCodeMirrorRef.js +96 -0
  213. package/dist/plugins/table/LexicalTableVisitor.d.ts +4 -0
  214. package/dist/plugins/table/LexicalTableVisitor.js +10 -0
  215. package/dist/plugins/table/MdastTableVisitor.d.ts +3 -0
  216. package/dist/plugins/table/MdastTableVisitor.js +10 -0
  217. package/dist/plugins/table/TableEditor.d.ts +21 -0
  218. package/dist/plugins/table/TableEditor.js +388 -0
  219. package/dist/plugins/table/TableNode.d.ts +52 -0
  220. package/dist/plugins/table/TableNode.js +152 -0
  221. package/dist/plugins/table/index.d.ts +704 -0
  222. package/dist/plugins/table/index.js +69 -0
  223. package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.d.ts +4 -0
  224. package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.js +10 -0
  225. package/dist/plugins/thematic-break/MdastThematicBreakVisitor.d.ts +3 -0
  226. package/dist/plugins/thematic-break/MdastThematicBreakVisitor.js +10 -0
  227. package/dist/plugins/thematic-break/index.d.ts +693 -0
  228. package/dist/plugins/thematic-break/index.js +39 -0
  229. package/dist/plugins/toolbar/components/BlockTypeSelect.d.ts +6 -0
  230. package/dist/plugins/toolbar/components/BlockTypeSelect.js +54 -0
  231. package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.d.ts +5 -0
  232. package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.js +33 -0
  233. package/dist/plugins/toolbar/components/ChangeAdmonitionType.d.ts +6 -0
  234. package/dist/plugins/toolbar/components/ChangeAdmonitionType.js +30 -0
  235. package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.d.ts +7 -0
  236. package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.js +32 -0
  237. package/dist/plugins/toolbar/components/CodeToggle.d.ts +6 -0
  238. package/dist/plugins/toolbar/components/CodeToggle.js +19 -0
  239. package/dist/plugins/toolbar/components/CreateLink.d.ts +6 -0
  240. package/dist/plugins/toolbar/components/CreateLink.js +20 -0
  241. package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.d.ts +18 -0
  242. package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.js +25 -0
  243. package/dist/plugins/toolbar/components/InsertAdmonition.d.ts +6 -0
  244. package/dist/plugins/toolbar/components/InsertAdmonition.js +29 -0
  245. package/dist/plugins/toolbar/components/InsertCodeBlock.d.ts +7 -0
  246. package/dist/plugins/toolbar/components/InsertCodeBlock.js +20 -0
  247. package/dist/plugins/toolbar/components/InsertFrontmatter.d.ts +6 -0
  248. package/dist/plugins/toolbar/components/InsertFrontmatter.js +24 -0
  249. package/dist/plugins/toolbar/components/InsertImage.d.ts +6 -0
  250. package/dist/plugins/toolbar/components/InsertImage.js +14 -0
  251. package/dist/plugins/toolbar/components/InsertSandpack.d.ts +6 -0
  252. package/dist/plugins/toolbar/components/InsertSandpack.js +13 -0
  253. package/dist/plugins/toolbar/components/InsertTable.d.ts +6 -0
  254. package/dist/plugins/toolbar/components/InsertTable.js +20 -0
  255. package/dist/plugins/toolbar/components/InsertThematicBreak.d.ts +6 -0
  256. package/dist/plugins/toolbar/components/InsertThematicBreak.js +11 -0
  257. package/dist/plugins/toolbar/components/KitchenSinkToolbar.d.ts +7 -0
  258. package/dist/plugins/toolbar/components/KitchenSinkToolbar.js +58 -0
  259. package/dist/plugins/toolbar/components/ListsToggle.d.ts +7 -0
  260. package/dist/plugins/toolbar/components/ListsToggle.js +23 -0
  261. package/dist/plugins/toolbar/components/ShowSandpackInfo.d.ts +7 -0
  262. package/dist/plugins/toolbar/components/ShowSandpackInfo.js +31 -0
  263. package/dist/plugins/toolbar/components/UndoRedo.d.ts +5 -0
  264. package/dist/plugins/toolbar/components/UndoRedo.js +58 -0
  265. package/dist/plugins/toolbar/index.d.ts +564 -0
  266. package/dist/plugins/toolbar/index.js +40 -0
  267. package/dist/plugins/toolbar/primitives/DialogButton.d.ts +40 -0
  268. package/dist/plugins/toolbar/primitives/DialogButton.js +114 -0
  269. package/dist/plugins/toolbar/primitives/TooltipWrap.d.ts +8 -0
  270. package/dist/plugins/toolbar/primitives/TooltipWrap.js +12 -0
  271. package/dist/plugins/toolbar/primitives/select.d.ts +50 -0
  272. package/dist/plugins/toolbar/primitives/select.js +55 -0
  273. package/dist/plugins/toolbar/primitives/toolbar.d.ts +163 -0
  274. package/dist/plugins/toolbar/primitives/toolbar.js +115 -0
  275. package/dist/style.css +1093 -288
  276. package/dist/styles/globals.css.js +4 -0
  277. package/dist/styles/lexical-theme.module.css.js +62 -0
  278. package/dist/styles/lexicalTheme.d.ts +2 -0
  279. package/dist/styles/lexicalTheme.js +31 -0
  280. package/dist/styles/ui.module.css.js +311 -0
  281. package/dist/utils/detectMac.d.ts +3 -0
  282. package/dist/utils/detectMac.js +13 -0
  283. package/dist/utils/fp.d.ts +47 -0
  284. package/dist/utils/fp.js +44 -0
  285. package/dist/utils/isPartOftheEditorUI.d.ts +1 -0
  286. package/dist/utils/isPartOftheEditorUI.js +12 -0
  287. package/dist/utils/lexicalHelpers.d.ts +11 -0
  288. package/dist/utils/lexicalHelpers.js +80 -0
  289. package/dist/utils/makeHslTransparent.d.ts +1 -0
  290. package/dist/utils/makeHslTransparent.js +6 -0
  291. package/dist/utils/mergeStyleAttributes.d.ts +1 -0
  292. package/dist/utils/mergeStyleAttributes.js +22 -0
  293. package/dist/utils/uuid4.d.ts +1 -0
  294. package/dist/utils/uuid4.js +10 -0
  295. package/dist/utils/voidEmitter.d.ts +14 -0
  296. package/dist/utils/voidEmitter.js +15 -0
  297. package/dist/utils/whitespaceConversion.d.ts +2 -0
  298. package/dist/utils/whitespaceConversion.js +9 -0
  299. package/package.json +326 -39
  300. package/dist/index.cjs +0 -1
@@ -0,0 +1,122 @@
1
+ import { coreSystem } from "../core/index.js";
2
+ import { MdastListVisitor } from "./MdastListVisitor.js";
3
+ import { MdastListItemVisitor } from "./MdastListItemVisitor.js";
4
+ import { LexicalListVisitor } from "./LexicalListVisitor.js";
5
+ import { LexicalListItemVisitor } from "./LexicalListItemVisitor.js";
6
+ import { $isListNode, ListNode, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, INSERT_CHECK_LIST_COMMAND, REMOVE_LIST_COMMAND, ListItemNode, $getListDepth, $isListItemNode } from "@lexical/list";
7
+ import { $isRootOrShadowRoot, INDENT_CONTENT_COMMAND, COMMAND_PRIORITY_CRITICAL, $getSelection, $isRangeSelection, $isElementNode } from "lexical";
8
+ import { TabIndentationPlugin } from "@lexical/react/LexicalTabIndentationPlugin.js";
9
+ import { CheckListPlugin } from "@lexical/react/LexicalCheckListPlugin.js";
10
+ import { ListPlugin } from "@lexical/react/LexicalListPlugin.js";
11
+ import { $findMatchingParent, $getNearestNodeOfType } from "@lexical/utils";
12
+ import { gfmTaskListItem } from "micromark-extension-gfm-task-list-item";
13
+ import { gfmTaskListItemFromMarkdown, gfmTaskListItemToMarkdown } from "mdast-util-gfm-task-list-item";
14
+ import { system } from "../../gurx/realmFactory.js";
15
+ import { realmPlugin } from "../../gurx/react.js";
16
+ const ListTypeCommandMap = /* @__PURE__ */ new Map([
17
+ ["number", INSERT_ORDERED_LIST_COMMAND],
18
+ ["bullet", INSERT_UNORDERED_LIST_COMMAND],
19
+ ["check", INSERT_CHECK_LIST_COMMAND],
20
+ ["", REMOVE_LIST_COMMAND]
21
+ ]);
22
+ const listsSystem = system(
23
+ (r, [{ activeEditor, currentSelection }]) => {
24
+ const currentListType = r.node("");
25
+ const applyListType = r.node();
26
+ r.sub(r.pipe(applyListType, r.o.withLatestFrom(activeEditor)), ([listType, theEditor]) => {
27
+ theEditor == null ? void 0 : theEditor.dispatchCommand(ListTypeCommandMap.get(listType), void 0);
28
+ });
29
+ r.sub(r.pipe(currentSelection, r.o.withLatestFrom(activeEditor)), ([selection, theEditor]) => {
30
+ if (!selection || !theEditor) {
31
+ return;
32
+ }
33
+ const anchorNode = selection.anchor.getNode();
34
+ let element = anchorNode.getKey() === "root" ? anchorNode : $findMatchingParent(anchorNode, (e) => {
35
+ const parent = e.getParent();
36
+ return parent !== null && $isRootOrShadowRoot(parent);
37
+ });
38
+ if (element === null) {
39
+ element = anchorNode.getTopLevelElementOrThrow();
40
+ }
41
+ const elementKey = element.getKey();
42
+ const elementDOM = theEditor.getElementByKey(elementKey);
43
+ if (elementDOM !== null) {
44
+ if ($isListNode(element)) {
45
+ const parentList = $getNearestNodeOfType(anchorNode, ListNode);
46
+ const type = parentList ? parentList.getListType() : element.getListType();
47
+ r.pub(currentListType, type);
48
+ } else {
49
+ r.pub(currentListType, null);
50
+ }
51
+ }
52
+ });
53
+ return { currentListType, applyListType };
54
+ },
55
+ [coreSystem]
56
+ );
57
+ const [
58
+ /** @internal */
59
+ listsPlugin,
60
+ /** @internal */
61
+ listsPluginHooks
62
+ ] = realmPlugin({
63
+ id: "lists",
64
+ systemSpec: listsSystem,
65
+ init: (realm) => {
66
+ var _a;
67
+ realm.pubKey("addMdastExtension", gfmTaskListItemFromMarkdown);
68
+ realm.pubKey("addSyntaxExtension", gfmTaskListItem);
69
+ realm.pubKey("addImportVisitor", MdastListVisitor);
70
+ realm.pubKey("addImportVisitor", MdastListItemVisitor);
71
+ realm.pubKey("addLexicalNode", ListItemNode);
72
+ realm.pubKey("addLexicalNode", ListNode);
73
+ realm.pubKey("addExportVisitor", LexicalListVisitor);
74
+ realm.pubKey("addExportVisitor", LexicalListItemVisitor);
75
+ realm.pubKey("addToMarkdownExtension", gfmTaskListItemToMarkdown);
76
+ (_a = realm.getKeyValue("rootEditor")) == null ? void 0 : _a.registerCommand(INDENT_CONTENT_COMMAND, () => !isIndentPermitted(7), COMMAND_PRIORITY_CRITICAL);
77
+ realm.pubKey("addComposerChild", TabIndentationPlugin);
78
+ realm.pubKey("addComposerChild", ListPlugin);
79
+ realm.pubKey("addComposerChild", CheckListPlugin);
80
+ realm.pubKey("addNestedEditorChild", TabIndentationPlugin);
81
+ realm.pubKey("addNestedEditorChild", ListPlugin);
82
+ realm.pubKey("addNestedEditorChild", CheckListPlugin);
83
+ }
84
+ });
85
+ function getElementNodesInSelection(selection) {
86
+ const nodesInSelection = selection.getNodes();
87
+ if (nodesInSelection.length === 0) {
88
+ return /* @__PURE__ */ new Set([selection.anchor.getNode().getParentOrThrow(), selection.focus.getNode().getParentOrThrow()]);
89
+ }
90
+ return new Set(nodesInSelection.map((n) => $isElementNode(n) ? n : n.getParentOrThrow()));
91
+ }
92
+ function isIndentPermitted(maxDepth) {
93
+ const selection = $getSelection();
94
+ if (!$isRangeSelection(selection)) {
95
+ return false;
96
+ }
97
+ const elementNodesInSelection = getElementNodesInSelection(selection);
98
+ let totalDepth = 0;
99
+ for (const elementNode of elementNodesInSelection) {
100
+ if ($isListNode(elementNode)) {
101
+ totalDepth = Math.max($getListDepth(elementNode) + 1, totalDepth);
102
+ } else if ($isListItemNode(elementNode)) {
103
+ const parent = elementNode.getParent();
104
+ if ((parent == null ? void 0 : parent.getChildren().length) === 1) {
105
+ const grandParentListItem = parent == null ? void 0 : parent.getParent();
106
+ if ($isListItemNode(grandParentListItem) && grandParentListItem.getChildren().length === 1) {
107
+ return false;
108
+ }
109
+ }
110
+ if (!$isListNode(parent)) {
111
+ throw new Error("ListMaxIndentLevelPlugin: A ListItemNode must have a ListNode for a parent.");
112
+ }
113
+ totalDepth = Math.max($getListDepth(parent) + 1, totalDepth);
114
+ }
115
+ }
116
+ return totalDepth <= maxDepth;
117
+ }
118
+ export {
119
+ listsPlugin,
120
+ listsPluginHooks,
121
+ listsSystem
122
+ };
@@ -0,0 +1,80 @@
1
+ import type { IconKey } from '../core/Icon';
2
+ import type { Options } from 'mdast-util-to-markdown';
3
+ import type { Config } from 'mdast-util-from-markdown/lib';
4
+ import type { Extension } from 'micromark-util-types';
5
+ import type { Content } from 'mdast';
6
+ import type { MdastImportVisitor, LexicalVisitor } from '../..';
7
+ import type { EditorSubscription, EditorInFocus, BlockType } from '../core';
8
+ import type { InitialEditorStateType } from '@lexical/react/LexicalComposer';
9
+ import type { JsxComponentDescriptor } from '../jsx';
10
+ import type { HistoryState } from '@lexical/history';
11
+ import type { PluginConstructor, SystemSpec, Realm, RealmNode } from '../../gurx';
12
+ import React from 'react';
13
+ import type { LexicalEditor, RangeSelection, Klass, LexicalNode, TextFormatType, DecoratorNode, ElementNode } from 'lexical';
14
+ /** @internal */
15
+ export declare const markdownShortcutPlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
16
+ activeEditor: RealmNode<LexicalEditor | null>;
17
+ inFocus: RealmNode<boolean>;
18
+ historyState: RealmNode<HistoryState>;
19
+ currentSelection: RealmNode<RangeSelection | null>;
20
+ jsxIsAvailable: RealmNode<boolean>;
21
+ jsxComponentDescriptors: RealmNode<JsxComponentDescriptor[]>;
22
+ initialRootEditorState: RealmNode<InitialEditorStateType>;
23
+ rootEditor: RealmNode<LexicalEditor | null>;
24
+ createRootEditorSubscription: RealmNode<EditorSubscription>;
25
+ createActiveEditorSubscription: RealmNode<EditorSubscription>;
26
+ importVisitors: RealmNode<MdastImportVisitor<Content>[]>;
27
+ syntaxExtensions: RealmNode<Extension[]>;
28
+ mdastExtensions: RealmNode<(Partial<Config> | Partial<Config>[])[] | null | undefined>;
29
+ usedLexicalNodes: RealmNode<Klass<LexicalNode>[]>;
30
+ addImportVisitor: RealmNode<MdastImportVisitor<Content>>;
31
+ addLexicalNode: RealmNode<Klass<LexicalNode>>;
32
+ addSyntaxExtension: RealmNode<Extension>;
33
+ addMdastExtension: RealmNode<Partial<Config> | Partial<Config>[]>;
34
+ toMarkdownExtensions: RealmNode<Options[]>;
35
+ toMarkdownOptions: RealmNode<Options>;
36
+ addToMarkdownExtension: RealmNode<Options>;
37
+ addExportVisitor: RealmNode<LexicalVisitor>;
38
+ exportVisitors: RealmNode<LexicalVisitor[]>;
39
+ initialMarkdown: RealmNode<string>;
40
+ setMarkdown: RealmNode<string>;
41
+ markdown: RealmNode<string>;
42
+ markdownSignal: RealmNode<string>;
43
+ editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
44
+ contentEditableClassName: RealmNode<string>;
45
+ placeholder: RealmNode<React.ReactNode>;
46
+ autoFocus: RealmNode<boolean | {
47
+ defaultSelection?: "rootStart" | "rootEnd" | undefined;
48
+ preventScroll?: boolean | undefined;
49
+ }>;
50
+ readOnly: RealmNode<boolean>;
51
+ composerChildren: RealmNode<React.ComponentType<{}>[]>;
52
+ addComposerChild: RealmNode<React.ComponentType<{}>>;
53
+ topAreaChildren: RealmNode<React.ComponentType<{}>[]>;
54
+ addTopAreaChild: RealmNode<React.ComponentType<{}>>;
55
+ nestedEditorChildren: RealmNode<React.ComponentType<{}>[]>;
56
+ addNestedEditorChild: RealmNode<React.ComponentType<{}>>;
57
+ editorWrappers: RealmNode<React.ComponentType<{
58
+ children: React.ReactNode;
59
+ }>[]>;
60
+ addEditorWrapper: RealmNode<React.ComponentType<{
61
+ children: React.ReactNode;
62
+ }>>;
63
+ currentFormat: RealmNode<number>;
64
+ editorInFocus: RealmNode<EditorInFocus | null>;
65
+ applyFormat: RealmNode<TextFormatType>;
66
+ currentBlockType: RealmNode<BlockType>;
67
+ applyBlockType: RealmNode<BlockType>;
68
+ convertSelectionToNode: RealmNode<() => ElementNode>;
69
+ insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
70
+ onBlur: RealmNode<FocusEvent>;
71
+ iconComponentFor: RealmNode<(name: IconKey) => React.ReactNode>;
72
+ markdownProcessingError: RealmNode<{
73
+ error: string;
74
+ source: string;
75
+ } | null>;
76
+ markdownErrorSignal: RealmNode<{
77
+ error: string;
78
+ source: string;
79
+ }>;
80
+ }>], (_: Realm) => {}>, object>;
@@ -0,0 +1,90 @@
1
+ import { QUOTE, LINK, ORDERED_LIST, UNORDERED_LIST, CHECK_LIST, CODE, BOLD_ITALIC_STAR, BOLD_ITALIC_UNDERSCORE, BOLD_STAR, BOLD_UNDERSCORE, INLINE_CODE, ITALIC_STAR, ITALIC_UNDERSCORE } from "@lexical/markdown";
2
+ import { MarkdownShortcutPlugin } from "@lexical/react/LexicalMarkdownShortcutPlugin.js";
3
+ import React__default from "react";
4
+ import { CodeBlockNode, $createCodeBlockNode } from "../codeblock/CodeBlockNode.js";
5
+ import { coreSystem } from "../core/index.js";
6
+ import { HeadingNode, $isHeadingNode, $createHeadingNode } from "@lexical/rich-text";
7
+ import { realmPlugin } from "../../gurx/react.js";
8
+ import { system } from "../../gurx/realmFactory.js";
9
+ const [markdownShortcutPlugin] = realmPlugin({
10
+ id: "markdown-shortcut",
11
+ dependencies: [],
12
+ systemSpec: system((_) => ({}), [coreSystem]),
13
+ init: (realm, _, pluginIds) => {
14
+ const allowedHeadingLevels = pluginIds.includes("headings") ? (
15
+ // @ts-expect-error we query the realm for the allowed heading levels
16
+ realm.getKeyValue("allowedHeadingLevels")
17
+ ) : [];
18
+ const transformers = pickTransformersForActivePlugins(pluginIds, allowedHeadingLevels);
19
+ realm.pubKey("addComposerChild", () => /* @__PURE__ */ React__default.createElement(MarkdownShortcutPlugin, { transformers }));
20
+ realm.pubKey("addNestedEditorChild", () => /* @__PURE__ */ React__default.createElement(MarkdownShortcutPlugin, { transformers }));
21
+ }
22
+ });
23
+ const createBlockNode = (createNode) => {
24
+ return (parentNode, children, match) => {
25
+ const node = createNode(match);
26
+ node.append(...children);
27
+ parentNode.replace(node);
28
+ node.select(0, 0);
29
+ };
30
+ };
31
+ function pickTransformersForActivePlugins(pluginIds, allowedHeadingLevels) {
32
+ const transformers = [
33
+ BOLD_ITALIC_STAR,
34
+ BOLD_ITALIC_UNDERSCORE,
35
+ BOLD_STAR,
36
+ BOLD_UNDERSCORE,
37
+ INLINE_CODE,
38
+ ITALIC_STAR,
39
+ ITALIC_UNDERSCORE
40
+ // HIGHLIGHT,
41
+ // STRIKETHROUGH
42
+ ];
43
+ if (pluginIds.includes("headings")) {
44
+ const minHeadingLevel = Math.min(...allowedHeadingLevels);
45
+ const maxHeadingLevel = Math.max(...allowedHeadingLevels);
46
+ const headingRegExp = new RegExp(`^(#{${minHeadingLevel},${maxHeadingLevel}})\\s`);
47
+ const HEADING = {
48
+ dependencies: [HeadingNode],
49
+ export: (node, exportChildren) => {
50
+ if (!$isHeadingNode(node)) {
51
+ return null;
52
+ }
53
+ const level = Number(node.getTag().slice(1));
54
+ return "#".repeat(level) + " " + exportChildren(node);
55
+ },
56
+ regExp: headingRegExp,
57
+ replace: createBlockNode((match) => {
58
+ const tag = `h${match[1].length}`;
59
+ return $createHeadingNode(tag);
60
+ }),
61
+ type: "element"
62
+ };
63
+ transformers.push(HEADING);
64
+ }
65
+ if (pluginIds.includes("quote")) {
66
+ transformers.push(QUOTE);
67
+ }
68
+ if (pluginIds.includes("link")) {
69
+ transformers.push(LINK);
70
+ }
71
+ if (pluginIds.includes("lists")) {
72
+ transformers.push(ORDERED_LIST, UNORDERED_LIST, CHECK_LIST);
73
+ }
74
+ if (pluginIds.includes("codeblock")) {
75
+ const codeTransformerCopy = {
76
+ ...CODE,
77
+ dependencies: [CodeBlockNode],
78
+ replace: (parentNode, _children, match) => {
79
+ const codeBlockNode = $createCodeBlockNode({ code: "", language: match ? match[1] : "", meta: "" });
80
+ parentNode.replace(codeBlockNode);
81
+ setTimeout(() => codeBlockNode.select(), 80);
82
+ }
83
+ };
84
+ transformers.push(codeTransformerCopy);
85
+ }
86
+ return transformers;
87
+ }
88
+ export {
89
+ markdownShortcutPlugin
90
+ };
@@ -0,0 +1,4 @@
1
+ import { QuoteNode } from '@lexical/rich-text';
2
+ import * as Mdast from 'mdast';
3
+ import { LexicalExportVisitor } from '../../exportMarkdownFromLexical';
4
+ export declare const LexicalQuoteVisitor: LexicalExportVisitor<QuoteNode, Mdast.Blockquote>;
@@ -0,0 +1,12 @@
1
+ import { $isQuoteNode } from "@lexical/rich-text";
2
+ const LexicalQuoteVisitor = {
3
+ testLexicalNode: $isQuoteNode,
4
+ visitLexicalNode: ({ lexicalNode, mdastParent, actions }) => {
5
+ const paragraph = { type: "paragraph", children: [] };
6
+ actions.appendToParent(mdastParent, { type: "blockquote", children: [paragraph] });
7
+ actions.visitChildren(lexicalNode, paragraph);
8
+ }
9
+ };
10
+ export {
11
+ LexicalQuoteVisitor
12
+ };
@@ -0,0 +1,3 @@
1
+ import * as Mdast from 'mdast';
2
+ import { MdastImportVisitor } from '../../importMarkdownToLexical';
3
+ export declare const MdastBlockQuoteVisitor: MdastImportVisitor<Mdast.Blockquote>;
@@ -0,0 +1,10 @@
1
+ import { $createQuoteNode } from "@lexical/rich-text";
2
+ const MdastBlockQuoteVisitor = {
3
+ testNode: "blockquote",
4
+ visitNode({ actions }) {
5
+ actions.addAndStepInto($createQuoteNode());
6
+ }
7
+ };
8
+ export {
9
+ MdastBlockQuoteVisitor
10
+ };