@mdxeditor/editor 0.10.1 → 0.11.0

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 (293) hide show
  1. package/README.md +4 -3
  2. package/dist/FormatConstants.d.ts +9 -0
  3. package/dist/FormatConstants.js +10 -0
  4. package/dist/MDXEditor.d.ts +60 -0
  5. package/dist/MDXEditor.js +105 -0
  6. package/dist/directive-editors/AdmonitionDirectiveDescriptor.d.ts +17 -0
  7. package/dist/directive-editors/AdmonitionDirectiveDescriptor.js +29 -0
  8. package/dist/directive-editors/GenericDirectiveEditor.d.ts +8 -0
  9. package/dist/directive-editors/GenericDirectiveEditor.js +32 -0
  10. package/dist/exportMarkdownFromLexical.d.ts +114 -0
  11. package/dist/exportMarkdownFromLexical.js +199 -0
  12. package/dist/gurx/index.d.ts +3 -0
  13. package/dist/gurx/react.d.ts +121 -0
  14. package/dist/gurx/react.js +112 -0
  15. package/dist/gurx/realm.d.ts +133 -0
  16. package/dist/gurx/realm.js +491 -0
  17. package/dist/gurx/realmFactory.d.ts +58 -0
  18. package/dist/gurx/realmFactory.js +28 -0
  19. package/dist/icons/add_column.svg.js +8 -0
  20. package/dist/icons/add_photo.svg.js +8 -0
  21. package/dist/icons/add_row.svg.js +8 -0
  22. package/dist/icons/arrow_drop_down.svg.js +8 -0
  23. package/dist/icons/arrow_right.svg.js +8 -0
  24. package/dist/icons/check.svg.js +8 -0
  25. package/dist/icons/close.svg.js +8 -0
  26. package/dist/icons/code.svg.js +8 -0
  27. package/dist/icons/content_copy.svg.js +8 -0
  28. package/dist/icons/delete.svg.js +8 -0
  29. package/dist/icons/delete_small.svg.js +8 -0
  30. package/dist/icons/deployed_code.svg.js +8 -0
  31. package/dist/icons/difference.svg.js +8 -0
  32. package/dist/icons/edit.svg.js +8 -0
  33. package/dist/icons/emergency_home.svg.js +8 -0
  34. package/dist/icons/format_align_center.svg.js +8 -0
  35. package/dist/icons/format_align_left.svg.js +8 -0
  36. package/dist/icons/format_align_right.svg.js +8 -0
  37. package/dist/icons/format_bold.svg.js +8 -0
  38. package/dist/icons/format_italic.svg.js +8 -0
  39. package/dist/icons/format_list_bulleted.svg.js +8 -0
  40. package/dist/icons/format_list_numbered.svg.js +8 -0
  41. package/dist/icons/format_underlined.svg.js +8 -0
  42. package/dist/icons/frame_source.svg.js +8 -0
  43. package/dist/icons/frontmatter.svg.js +8 -0
  44. package/dist/icons/horizontal_rule.svg.js +8 -0
  45. package/dist/icons/insert_col_left.svg.js +8 -0
  46. package/dist/icons/insert_col_right.svg.js +8 -0
  47. package/dist/icons/insert_row_above.svg.js +8 -0
  48. package/dist/icons/insert_row_below.svg.js +8 -0
  49. package/dist/icons/link.svg.js +8 -0
  50. package/dist/icons/link_off.svg.js +8 -0
  51. package/dist/icons/markdown.svg.js +8 -0
  52. package/dist/icons/more_horiz.svg.js +8 -0
  53. package/dist/icons/open_in_new.svg.js +8 -0
  54. package/dist/icons/redo.svg.js +8 -0
  55. package/dist/icons/rich_text.svg.js +8 -0
  56. package/dist/icons/settings.svg.js +8 -0
  57. package/dist/icons/table.svg.js +8 -0
  58. package/dist/icons/undo.svg.js +8 -0
  59. package/dist/importMarkdownToLexical.d.ts +84 -0
  60. package/dist/importMarkdownToLexical.js +65 -0
  61. package/dist/index.d.ts +49 -1105
  62. package/dist/index.js +140 -72
  63. package/dist/jsx-editors/GenericJsxEditor.d.ts +8 -0
  64. package/dist/jsx-editors/GenericJsxEditor.js +56 -0
  65. package/dist/node_modules/react-diff-view/style/index.css.js +4 -0
  66. package/dist/plugins/codeblock/CodeBlockNode.d.ts +99 -0
  67. package/dist/plugins/codeblock/CodeBlockNode.js +155 -0
  68. package/dist/plugins/codeblock/CodeBlockVisitor.d.ts +4 -0
  69. package/dist/plugins/codeblock/CodeBlockVisitor.js +14 -0
  70. package/dist/plugins/codeblock/MdastCodeVisitor.d.ts +3 -0
  71. package/dist/plugins/codeblock/MdastCodeVisitor.js +16 -0
  72. package/dist/plugins/codeblock/index.d.ts +617 -0
  73. package/dist/plugins/codeblock/index.js +73 -0
  74. package/dist/plugins/codemirror/CodeMirrorEditor.d.ts +3 -0
  75. package/dist/plugins/codemirror/CodeMirrorEditor.js +33 -0
  76. package/dist/plugins/codemirror/index.d.ts +800 -0
  77. package/dist/plugins/codemirror/index.js +62 -0
  78. package/dist/plugins/core/LexicalLinebreakVisitor.d.ts +4 -0
  79. package/dist/plugins/core/LexicalLinebreakVisitor.js +10 -0
  80. package/dist/plugins/core/LexicalParagraphVisitor.d.ts +4 -0
  81. package/dist/plugins/core/LexicalParagraphVisitor.js +10 -0
  82. package/dist/plugins/core/LexicalRootVisitor.d.ts +4 -0
  83. package/dist/plugins/core/LexicalRootVisitor.js +10 -0
  84. package/dist/plugins/core/LexicalTextVisitor.d.ts +5 -0
  85. package/dist/plugins/core/LexicalTextVisitor.js +85 -0
  86. package/dist/plugins/core/MdastFormattingVisitor.d.ts +4 -0
  87. package/dist/plugins/core/MdastFormattingVisitor.js +36 -0
  88. package/dist/plugins/core/MdastInlineCodeVisitor.d.ts +3 -0
  89. package/dist/plugins/core/MdastInlineCodeVisitor.js +11 -0
  90. package/dist/plugins/core/MdastParagraphVisitor.d.ts +3 -0
  91. package/dist/plugins/core/MdastParagraphVisitor.js +15 -0
  92. package/dist/plugins/core/MdastRootVisitor.d.ts +3 -0
  93. package/dist/plugins/core/MdastRootVisitor.js +9 -0
  94. package/dist/plugins/core/MdastTextVisitor.d.ts +3 -0
  95. package/dist/plugins/core/MdastTextVisitor.js +10 -0
  96. package/dist/plugins/core/NestedLexicalEditor.d.ts +96 -0
  97. package/dist/plugins/core/NestedLexicalEditor.js +181 -0
  98. package/dist/plugins/core/PropertyPopover.d.ts +23 -0
  99. package/dist/plugins/core/PropertyPopover.js +36 -0
  100. package/dist/plugins/core/SharedHistoryPlugin.d.ts +2 -0
  101. package/dist/plugins/core/SharedHistoryPlugin.js +10 -0
  102. package/dist/plugins/core/index.d.ts +423 -0
  103. package/dist/plugins/core/index.js +346 -0
  104. package/dist/plugins/core/ui/PopoverUtils.d.ts +4 -0
  105. package/dist/plugins/core/ui/PopoverUtils.js +17 -0
  106. package/dist/plugins/diff-source/DiffSourceWrapper.d.ts +4 -0
  107. package/dist/plugins/diff-source/DiffSourceWrapper.js +11 -0
  108. package/dist/plugins/diff-source/DiffViewer.d.ts +2 -0
  109. package/dist/plugins/diff-source/DiffViewer.js +18 -0
  110. package/dist/plugins/diff-source/SourceEditor.d.ts +2 -0
  111. package/dist/plugins/diff-source/SourceEditor.js +27 -0
  112. package/dist/plugins/diff-source/index.d.ts +544 -0
  113. package/dist/plugins/diff-source/index.js +55 -0
  114. package/dist/plugins/directives/DirectiveNode.d.ts +51 -0
  115. package/dist/plugins/directives/DirectiveNode.js +92 -0
  116. package/dist/plugins/directives/DirectiveVisitor.d.ts +4 -0
  117. package/dist/plugins/directives/DirectiveVisitor.js +10 -0
  118. package/dist/plugins/directives/MdastDirectiveVisitor.d.ts +3 -0
  119. package/dist/plugins/directives/MdastDirectiveVisitor.js +13 -0
  120. package/dist/plugins/directives/index.d.ts +603 -0
  121. package/dist/plugins/directives/index.js +53 -0
  122. package/dist/plugins/frontmatter/FrontmatterEditor.d.ts +6 -0
  123. package/dist/plugins/frontmatter/FrontmatterEditor.js +69 -0
  124. package/dist/plugins/frontmatter/FrontmatterNode.d.ts +35 -0
  125. package/dist/plugins/frontmatter/FrontmatterNode.js +71 -0
  126. package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.d.ts +4 -0
  127. package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.js +10 -0
  128. package/dist/plugins/frontmatter/MdastFrontmatterVisitor.d.ts +3 -0
  129. package/dist/plugins/frontmatter/MdastFrontmatterVisitor.js +10 -0
  130. package/dist/plugins/frontmatter/index.d.ts +523 -0
  131. package/dist/plugins/frontmatter/index.js +53 -0
  132. package/dist/plugins/headings/LexicalHeadingVisitor.d.ts +4 -0
  133. package/dist/plugins/headings/LexicalHeadingVisitor.js +11 -0
  134. package/dist/plugins/headings/MdastHeadingVisitor.d.ts +3 -0
  135. package/dist/plugins/headings/MdastHeadingVisitor.js +10 -0
  136. package/dist/plugins/headings/index.d.ts +118 -0
  137. package/dist/plugins/headings/index.js +20 -0
  138. package/dist/plugins/image/ImageEditor.d.ts +9 -0
  139. package/dist/{ImageEditor-8db2f131.js → plugins/image/ImageEditor.js} +40 -52
  140. package/dist/plugins/image/ImageNode.d.ts +63 -0
  141. package/dist/plugins/image/ImageNode.js +136 -0
  142. package/dist/plugins/image/ImageResizer.d.ts +18 -0
  143. package/dist/plugins/image/ImageResizer.js +214 -0
  144. package/dist/plugins/image/LexicalImageVisitor.d.ts +4 -0
  145. package/dist/plugins/image/LexicalImageVisitor.js +36 -0
  146. package/dist/plugins/image/MdastImageVisitor.d.ts +6 -0
  147. package/dist/plugins/image/MdastImageVisitor.js +87 -0
  148. package/dist/plugins/image/index.d.ts +557 -0
  149. package/dist/plugins/image/index.js +246 -0
  150. package/dist/plugins/jsx/LexicalJsxNode.d.ts +54 -0
  151. package/dist/plugins/jsx/LexicalJsxNode.js +102 -0
  152. package/dist/plugins/jsx/LexicalJsxVisitor.d.ts +4 -0
  153. package/dist/plugins/jsx/LexicalJsxVisitor.js +12 -0
  154. package/dist/plugins/jsx/MdastMdxJsEsmVisitor.d.ts +3 -0
  155. package/dist/plugins/jsx/MdastMdxJsEsmVisitor.js +8 -0
  156. package/dist/plugins/jsx/MdastMdxJsxElementVisitor.d.ts +3 -0
  157. package/dist/plugins/jsx/MdastMdxJsxElementVisitor.js +12 -0
  158. package/dist/plugins/jsx/index.d.ts +599 -0
  159. package/dist/plugins/jsx/index.js +59 -0
  160. package/dist/plugins/link/LexicalLinkVisitor.d.ts +4 -0
  161. package/dist/plugins/link/LexicalLinkVisitor.js +10 -0
  162. package/dist/plugins/link/MdastLinkVisitor.d.ts +3 -0
  163. package/dist/plugins/link/MdastLinkVisitor.js +14 -0
  164. package/dist/plugins/link/index.d.ts +68 -0
  165. package/dist/plugins/link/index.js +22 -0
  166. package/dist/plugins/link-dialog/LinkDialog.d.ts +12 -0
  167. package/dist/plugins/link-dialog/LinkDialog.js +174 -0
  168. package/dist/plugins/link-dialog/index.d.ts +508 -0
  169. package/dist/plugins/link-dialog/index.js +242 -0
  170. package/dist/plugins/lists/LexicalListItemVisitor.d.ts +4 -0
  171. package/dist/plugins/lists/LexicalListItemVisitor.js +22 -0
  172. package/dist/plugins/lists/LexicalListVisitor.d.ts +4 -0
  173. package/dist/plugins/lists/LexicalListVisitor.js +13 -0
  174. package/dist/plugins/lists/MdastListItemVisitor.d.ts +3 -0
  175. package/dist/plugins/lists/MdastListItemVisitor.js +10 -0
  176. package/dist/plugins/lists/MdastListVisitor.d.ts +3 -0
  177. package/dist/plugins/lists/MdastListVisitor.js +18 -0
  178. package/dist/plugins/lists/index.d.ts +533 -0
  179. package/dist/plugins/lists/index.js +111 -0
  180. package/dist/plugins/markdown-shortcut/index.d.ts +63 -0
  181. package/dist/plugins/markdown-shortcut/index.js +34 -0
  182. package/dist/plugins/quote/LexicalQuoteVisitor.d.ts +4 -0
  183. package/dist/plugins/quote/LexicalQuoteVisitor.js +12 -0
  184. package/dist/plugins/quote/MdastBlockQuoteVisitor.d.ts +3 -0
  185. package/dist/plugins/quote/MdastBlockQuoteVisitor.js +10 -0
  186. package/dist/plugins/quote/index.d.ts +361 -0
  187. package/dist/plugins/quote/index.js +26 -0
  188. package/dist/plugins/sandpack/SandpackEditor.d.ts +7 -0
  189. package/dist/plugins/sandpack/SandpackEditor.js +35 -0
  190. package/dist/plugins/sandpack/index.d.ts +839 -0
  191. package/dist/plugins/sandpack/index.js +93 -0
  192. package/dist/plugins/sandpack/useCodeMirrorRef.d.ts +4 -0
  193. package/dist/{useCodeMirrorRef-5356dfa5.js → plugins/sandpack/useCodeMirrorRef.js} +22 -10
  194. package/dist/plugins/table/LexicalTableVisitor.d.ts +4 -0
  195. package/dist/plugins/table/LexicalTableVisitor.js +10 -0
  196. package/dist/plugins/table/MdastTableVisitor.d.ts +3 -0
  197. package/dist/plugins/table/MdastTableVisitor.js +10 -0
  198. package/dist/plugins/table/TableEditor.d.ts +21 -0
  199. package/dist/plugins/table/TableEditor.js +384 -0
  200. package/dist/plugins/table/TableNode.d.ts +52 -0
  201. package/dist/plugins/table/TableNode.js +147 -0
  202. package/dist/plugins/table/index.d.ts +523 -0
  203. package/dist/plugins/table/index.js +59 -0
  204. package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.d.ts +4 -0
  205. package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.js +10 -0
  206. package/dist/plugins/thematic-break/MdastThematicBreakVisitor.d.ts +3 -0
  207. package/dist/plugins/thematic-break/MdastThematicBreakVisitor.js +10 -0
  208. package/dist/plugins/thematic-break/index.d.ts +523 -0
  209. package/dist/plugins/thematic-break/index.js +39 -0
  210. package/dist/plugins/toolbar/components/BlockTypeSelect.d.ts +6 -0
  211. package/dist/plugins/toolbar/components/BlockTypeSelect.js +52 -0
  212. package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.d.ts +5 -0
  213. package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.js +35 -0
  214. package/dist/plugins/toolbar/components/ChangeAdmonitionType.d.ts +6 -0
  215. package/dist/plugins/toolbar/components/ChangeAdmonitionType.js +30 -0
  216. package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.d.ts +7 -0
  217. package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.js +32 -0
  218. package/dist/plugins/toolbar/components/CodeToggle.d.ts +6 -0
  219. package/dist/plugins/toolbar/components/CodeToggle.js +20 -0
  220. package/dist/plugins/toolbar/components/CreateLink.d.ts +6 -0
  221. package/dist/plugins/toolbar/components/CreateLink.js +11 -0
  222. package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.d.ts +18 -0
  223. package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.js +27 -0
  224. package/dist/plugins/toolbar/components/InsertAdmonition.d.ts +6 -0
  225. package/dist/plugins/toolbar/components/InsertAdmonition.js +29 -0
  226. package/dist/plugins/toolbar/components/InsertCodeBlock.d.ts +7 -0
  227. package/dist/plugins/toolbar/components/InsertCodeBlock.js +20 -0
  228. package/dist/plugins/toolbar/components/InsertFrontmatter.d.ts +6 -0
  229. package/dist/plugins/toolbar/components/InsertFrontmatter.js +11 -0
  230. package/dist/plugins/toolbar/components/InsertImage.d.ts +6 -0
  231. package/dist/plugins/toolbar/components/InsertImage.js +23 -0
  232. package/dist/plugins/toolbar/components/InsertSandpack.d.ts +6 -0
  233. package/dist/plugins/toolbar/components/InsertSandpack.js +13 -0
  234. package/dist/plugins/toolbar/components/InsertTable.d.ts +6 -0
  235. package/dist/plugins/toolbar/components/InsertTable.js +20 -0
  236. package/dist/plugins/toolbar/components/InsertThematicBreak.d.ts +6 -0
  237. package/dist/plugins/toolbar/components/InsertThematicBreak.js +11 -0
  238. package/dist/plugins/toolbar/components/KitchenSinkToolbar.d.ts +7 -0
  239. package/dist/plugins/toolbar/components/KitchenSinkToolbar.js +58 -0
  240. package/dist/plugins/toolbar/components/ListsToggle.d.ts +7 -0
  241. package/dist/plugins/toolbar/components/ListsToggle.js +23 -0
  242. package/dist/plugins/toolbar/components/ShowSandpackInfo.d.ts +7 -0
  243. package/dist/plugins/toolbar/components/ShowSandpackInfo.js +32 -0
  244. package/dist/plugins/toolbar/components/UndoRedo.d.ts +5 -0
  245. package/dist/plugins/toolbar/components/UndoRedo.js +59 -0
  246. package/dist/plugins/toolbar/index.d.ts +428 -0
  247. package/dist/plugins/toolbar/index.js +39 -0
  248. package/dist/plugins/toolbar/primitives/DialogButton.d.ts +40 -0
  249. package/dist/plugins/toolbar/primitives/DialogButton.js +115 -0
  250. package/dist/plugins/toolbar/primitives/TooltipWrap.d.ts +8 -0
  251. package/dist/plugins/toolbar/primitives/TooltipWrap.js +12 -0
  252. package/dist/plugins/toolbar/primitives/select.d.ts +50 -0
  253. package/dist/plugins/toolbar/primitives/select.js +44 -0
  254. package/dist/plugins/toolbar/primitives/toolbar.d.ts +160 -0
  255. package/dist/plugins/toolbar/primitives/toolbar.js +111 -0
  256. package/dist/style.css +556 -249
  257. package/dist/styles/globals.css.js +4 -0
  258. package/dist/styles/lexical-theme.module.css.js +53 -0
  259. package/dist/styles/lexicalTheme.d.ts +2 -0
  260. package/dist/styles/lexicalTheme.js +28 -0
  261. package/dist/styles/ui.module.css.js +254 -0
  262. package/dist/utils/detectMac.d.ts +2 -0
  263. package/dist/utils/detectMac.js +6 -0
  264. package/dist/utils/fp.d.ts +47 -0
  265. package/dist/utils/fp.js +10 -0
  266. package/dist/utils/isPartOftheEditorUI.d.ts +1 -0
  267. package/dist/utils/isPartOftheEditorUI.js +12 -0
  268. package/dist/utils/lexicalHelpers.d.ts +11 -0
  269. package/dist/utils/lexicalHelpers.js +49 -0
  270. package/dist/utils/uuid4.d.ts +1 -0
  271. package/dist/utils/uuid4.js +10 -0
  272. package/dist/utils/voidEmitter.d.ts +14 -0
  273. package/dist/utils/voidEmitter.js +15 -0
  274. package/package.json +246 -14
  275. package/dist/CodeBlockEditor-02116cba.js +0 -79
  276. package/dist/CodeBlockEditor-1c7b46dc.cjs +0 -1
  277. package/dist/FrontmatterEditor-37a4c091.cjs +0 -1
  278. package/dist/FrontmatterEditor-988a8fb6.js +0 -118
  279. package/dist/ImageEditor-524159e9.cjs +0 -1
  280. package/dist/JsxEditor-606e9d86.js +0 -108
  281. package/dist/JsxEditor-98a94a9d.cjs +0 -1
  282. package/dist/LeafDirectiveEditor-38a73f5c.js +0 -59
  283. package/dist/LeafDirectiveEditor-dfa1ce78.cjs +0 -1
  284. package/dist/SandpackEditor-90425f26.cjs +0 -1
  285. package/dist/SandpackEditor-c771b4d0.js +0 -100
  286. package/dist/SourceEditor-19eb2c9e.js +0 -64
  287. package/dist/SourceEditor-46ed1f77.cjs +0 -1
  288. package/dist/TableEditor-4a993dab.cjs +0 -1
  289. package/dist/TableEditor-c28b3ca2.js +0 -426
  290. package/dist/index-1ab1a12e.js +0 -4363
  291. package/dist/index-8217810f.cjs +0 -1
  292. package/dist/index.cjs +0 -1
  293. package/dist/useCodeMirrorRef-7055e7de.cjs +0 -1
@@ -0,0 +1,118 @@
1
+ import type { RefObject, ComponentType, ReactNode } from 'react';
2
+ import type { LexicalVisitor } from '../../exportMarkdownFromLexical';
3
+ import type { Options } from 'mdast-util-to-markdown';
4
+ import type { Config } from 'mdast-util-from-markdown/lib';
5
+ import type { Extension } from 'micromark-util-types';
6
+ import type { Content } from 'mdast';
7
+ import type { MdastImportVisitor } from '../../importMarkdownToLexical';
8
+ import type { EditorSubscription, EditorInFocus, BlockType } from '../core';
9
+ import type { InitialEditorStateType } from '@lexical/react/LexicalComposer';
10
+ import type { JsxComponentDescriptor } from '../jsx';
11
+ import type { HistoryState } from '@lexical/history';
12
+ import type { LexicalEditor, RangeSelection, Klass, LexicalNode, TextFormatType, ElementNode, DecoratorNode } from 'lexical';
13
+ import type { SystemSpec, Realm, RealmNode, PluginConstructor } from '../../gurx';
14
+ /// <reference types="react" />
15
+ /**
16
+ * @internal
17
+ */
18
+ export declare const headingsSystem: SystemSpec<[SystemSpec<[], (r: Realm) => {
19
+ activeEditor: RealmNode<LexicalEditor | null>;
20
+ inFocus: RealmNode<boolean>;
21
+ historyState: RealmNode<HistoryState>;
22
+ currentSelection: RealmNode<RangeSelection | null>;
23
+ jsxIsAvailable: RealmNode<boolean>;
24
+ jsxComponentDescriptors: RealmNode<JsxComponentDescriptor[]>;
25
+ initialRootEditorState: RealmNode<InitialEditorStateType>;
26
+ rootEditor: RealmNode<LexicalEditor | null>;
27
+ createRootEditorSubscription: RealmNode<EditorSubscription>;
28
+ createActiveEditorSubscription: RealmNode<EditorSubscription>;
29
+ importVisitors: RealmNode<MdastImportVisitor<Content>[]>;
30
+ syntaxExtensions: RealmNode<Extension[]>;
31
+ mdastExtensions: RealmNode<(Partial<Config> | Partial<Config>[])[] | null | undefined>;
32
+ usedLexicalNodes: RealmNode<Klass<LexicalNode>[]>;
33
+ addImportVisitor: RealmNode<MdastImportVisitor<Content>>;
34
+ addLexicalNode: RealmNode<Klass<LexicalNode>>;
35
+ addSyntaxExtension: RealmNode<Extension>;
36
+ addMdastExtension: RealmNode<Partial<Config> | Partial<Config>[]>;
37
+ toMarkdownExtensions: RealmNode<Options[]>;
38
+ toMarkdownOptions: RealmNode<Options>;
39
+ addToMarkdownExtension: RealmNode<Options>;
40
+ addExportVisitor: RealmNode<LexicalVisitor>;
41
+ exportVisitors: RealmNode<LexicalVisitor[]>;
42
+ initialMarkdown: RealmNode<string>;
43
+ setMarkdown: RealmNode<string>;
44
+ markdown: RealmNode<string>;
45
+ editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
46
+ contentEditableClassName: RealmNode<string>;
47
+ composerChildren: RealmNode<ComponentType<{}>[]>;
48
+ addComposerChild: RealmNode<ComponentType<{}>>;
49
+ topAreaChildren: RealmNode<ComponentType<{}>[]>;
50
+ addTopAreaChild: RealmNode<ComponentType<{}>>;
51
+ nestedEditorChildren: RealmNode<ComponentType<{}>[]>;
52
+ addNestedEditorChild: RealmNode<ComponentType<{}>>;
53
+ editorWrappers: RealmNode<ComponentType<{
54
+ children: ReactNode;
55
+ }>[]>;
56
+ addEditorWrapper: RealmNode<ComponentType<{
57
+ children: ReactNode;
58
+ }>>;
59
+ currentFormat: RealmNode<number>;
60
+ editorInFocus: RealmNode<EditorInFocus | null>;
61
+ applyFormat: RealmNode<TextFormatType>;
62
+ currentBlockType: RealmNode<BlockType>;
63
+ applyBlockType: RealmNode<BlockType>;
64
+ convertSelectionToNode: RealmNode<() => ElementNode>;
65
+ insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
66
+ }>], (_: Realm) => {}>;
67
+ /**
68
+ * @internal
69
+ */
70
+ export declare const headingsPlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
71
+ activeEditor: RealmNode<LexicalEditor | null>;
72
+ inFocus: RealmNode<boolean>;
73
+ historyState: RealmNode<HistoryState>;
74
+ currentSelection: RealmNode<RangeSelection | null>;
75
+ jsxIsAvailable: RealmNode<boolean>;
76
+ jsxComponentDescriptors: RealmNode<JsxComponentDescriptor[]>;
77
+ initialRootEditorState: RealmNode<InitialEditorStateType>;
78
+ rootEditor: RealmNode<LexicalEditor | null>;
79
+ createRootEditorSubscription: RealmNode<EditorSubscription>;
80
+ createActiveEditorSubscription: RealmNode<EditorSubscription>;
81
+ importVisitors: RealmNode<MdastImportVisitor<Content>[]>;
82
+ syntaxExtensions: RealmNode<Extension[]>;
83
+ mdastExtensions: RealmNode<(Partial<Config> | Partial<Config>[])[] | null | undefined>;
84
+ usedLexicalNodes: RealmNode<Klass<LexicalNode>[]>;
85
+ addImportVisitor: RealmNode<MdastImportVisitor<Content>>;
86
+ addLexicalNode: RealmNode<Klass<LexicalNode>>;
87
+ addSyntaxExtension: RealmNode<Extension>;
88
+ addMdastExtension: RealmNode<Partial<Config> | Partial<Config>[]>;
89
+ toMarkdownExtensions: RealmNode<Options[]>;
90
+ toMarkdownOptions: RealmNode<Options>;
91
+ addToMarkdownExtension: RealmNode<Options>;
92
+ addExportVisitor: RealmNode<LexicalVisitor>;
93
+ exportVisitors: RealmNode<LexicalVisitor[]>;
94
+ initialMarkdown: RealmNode<string>;
95
+ setMarkdown: RealmNode<string>;
96
+ markdown: RealmNode<string>;
97
+ editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
98
+ contentEditableClassName: RealmNode<string>;
99
+ composerChildren: RealmNode<ComponentType<{}>[]>;
100
+ addComposerChild: RealmNode<ComponentType<{}>>;
101
+ topAreaChildren: RealmNode<ComponentType<{}>[]>;
102
+ addTopAreaChild: RealmNode<ComponentType<{}>>;
103
+ nestedEditorChildren: RealmNode<ComponentType<{}>[]>;
104
+ addNestedEditorChild: RealmNode<ComponentType<{}>>;
105
+ editorWrappers: RealmNode<ComponentType<{
106
+ children: ReactNode;
107
+ }>[]>;
108
+ addEditorWrapper: RealmNode<ComponentType<{
109
+ children: ReactNode;
110
+ }>>;
111
+ currentFormat: RealmNode<number>;
112
+ editorInFocus: RealmNode<EditorInFocus | null>;
113
+ applyFormat: RealmNode<TextFormatType>;
114
+ currentBlockType: RealmNode<BlockType>;
115
+ applyBlockType: RealmNode<BlockType>;
116
+ convertSelectionToNode: RealmNode<() => ElementNode>;
117
+ insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
118
+ }>], (_: Realm) => {}>, object>;
@@ -0,0 +1,20 @@
1
+ import { coreSystem } from "../core/index.js";
2
+ import { MdastHeadingVisitor } from "./MdastHeadingVisitor.js";
3
+ import { HeadingNode } from "@lexical/rich-text";
4
+ import { LexicalHeadingVisitor } from "./LexicalHeadingVisitor.js";
5
+ import { system } from "../../gurx/realmFactory.js";
6
+ import { realmPlugin } from "../../gurx/react.js";
7
+ const headingsSystem = system((_) => ({}), [coreSystem]);
8
+ const [headingsPlugin] = realmPlugin({
9
+ id: "headings",
10
+ systemSpec: headingsSystem,
11
+ init: (realm) => {
12
+ realm.pubKey("addImportVisitor", MdastHeadingVisitor);
13
+ realm.pubKey("addLexicalNode", HeadingNode);
14
+ realm.pubKey("addExportVisitor", LexicalHeadingVisitor);
15
+ }
16
+ });
17
+ export {
18
+ headingsPlugin,
19
+ headingsSystem
20
+ };
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ export interface ImageEditorProps {
3
+ nodeKey: string;
4
+ src: string;
5
+ title?: string;
6
+ width: number | 'inherit';
7
+ height: number | 'inherit';
8
+ }
9
+ export declare function ImageEditor({ src, title, nodeKey, width, height }: ImageEditorProps): JSX.Element;
@@ -1,46 +1,12 @@
1
- import React__default, { useRef, useState, useCallback, useEffect, Suspense } from "react";
1
+ import React__default from "react";
2
2
  import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
3
3
  import { useLexicalNodeSelection } from "@lexical/react/useLexicalNodeSelection";
4
4
  import { mergeRegister } from "@lexical/utils";
5
5
  import { $isNodeSelection, $getSelection, $getNodeByKey, $setSelection, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_LOW, CLICK_COMMAND, DRAGSTART_COMMAND, KEY_DELETE_COMMAND, KEY_BACKSPACE_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND } from "lexical";
6
- import { $ as $isImageNode, s as styles } from "./index-1ab1a12e.js";
6
+ import styles from "../../styles/ui.module.css.js";
7
7
  import classNames from "classnames";
8
- import "@lexical/react/LexicalComposer";
9
- import "@lexical/react/LexicalContentEditable";
10
- import "@lexical/react/LexicalErrorBoundary";
11
- import "@lexical/react/LexicalHorizontalRulePlugin";
12
- import "@lexical/react/LexicalLinkPlugin";
13
- import "@lexical/react/LexicalListPlugin";
14
- import "@lexical/react/LexicalRichTextPlugin";
15
- import "@lexical/react/LexicalTabIndentationPlugin";
16
- import "@lexical/code";
17
- import "@lexical/link";
18
- import "@lexical/list";
19
- import "@lexical/react/LexicalHorizontalRuleNode";
20
- import "@lexical/rich-text";
21
- import "mdast-util-directive";
22
- import "mdast-util-from-markdown";
23
- import "mdast-util-frontmatter";
24
- import "mdast-util-gfm-table";
25
- import "mdast-util-mdx";
26
- import "micromark-extension-directive";
27
- import "micromark-extension-frontmatter";
28
- import "micromark-extension-gfm-table";
29
- import "micromark-extension-mdxjs";
30
- import "@lexical/selection";
31
- import "@lexical/react/LexicalHistoryPlugin";
32
- import "mdast-util-to-markdown";
33
- import "@radix-ui/react-popover";
34
- import "@radix-ui/react-tooltip";
35
- import "downshift";
36
- import "@lexical/markdown";
37
- import "@lexical/react/LexicalMarkdownShortcutPlugin";
38
- import "react-diff-view";
39
- import "unidiff";
40
- import "@radix-ui/react-toolbar";
41
- import "@radix-ui/react-select";
42
- import "@radix-ui/react-dialog";
43
- import "@lexical/react/LexicalNestedComposer";
8
+ import { $isImageNode } from "./ImageNode.js";
9
+ import ImageResizer from "./ImageResizer.js";
44
10
  const imageCache = /* @__PURE__ */ new Set();
45
11
  function useSuspenseImage(src) {
46
12
  if (!imageCache.has(src)) {
@@ -58,19 +24,22 @@ function LazyImage({
58
24
  title,
59
25
  className,
60
26
  imageRef,
61
- src
27
+ src,
28
+ width,
29
+ height
62
30
  }) {
63
31
  useSuspenseImage(src);
64
- return /* @__PURE__ */ React__default.createElement("img", { className: className || void 0, src, title, ref: imageRef, draggable: "false" });
32
+ return /* @__PURE__ */ React__default.createElement("img", { className: className || void 0, src, title, ref: imageRef, draggable: "false", width, height });
65
33
  }
66
- function ImageEditor({ src, title, nodeKey }) {
67
- const imageRef = useRef(null);
68
- const buttonRef = useRef(null);
34
+ function ImageEditor({ src, title, nodeKey, width, height }) {
35
+ const imageRef = React__default.useRef(null);
36
+ const buttonRef = React__default.useRef(null);
69
37
  const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey);
70
38
  const [editor] = useLexicalComposerContext();
71
- const [selection, setSelection] = useState(null);
72
- const activeEditorRef = useRef(null);
73
- const onDelete = useCallback(
39
+ const [selection, setSelection] = React__default.useState(null);
40
+ const activeEditorRef = React__default.useRef(null);
41
+ const [isResizing, setIsResizing] = React__default.useState(false);
42
+ const onDelete = React__default.useCallback(
74
43
  (payload) => {
75
44
  if (isSelected && $isNodeSelection($getSelection())) {
76
45
  const event = payload;
@@ -84,7 +53,7 @@ function ImageEditor({ src, title, nodeKey }) {
84
53
  },
85
54
  [isSelected, nodeKey]
86
55
  );
87
- const onEnter = useCallback(
56
+ const onEnter = React__default.useCallback(
88
57
  (event) => {
89
58
  const latestSelection = $getSelection();
90
59
  const buttonElem = buttonRef.current;
@@ -99,7 +68,7 @@ function ImageEditor({ src, title, nodeKey }) {
99
68
  },
100
69
  [isSelected]
101
70
  );
102
- const onEscape = useCallback(
71
+ const onEscape = React__default.useCallback(
103
72
  (event) => {
104
73
  if (buttonRef.current === event.target) {
105
74
  $setSelection(null);
@@ -116,7 +85,7 @@ function ImageEditor({ src, title, nodeKey }) {
116
85
  },
117
86
  [editor, setSelected]
118
87
  );
119
- useEffect(() => {
88
+ React__default.useEffect(() => {
120
89
  let isMounted = true;
121
90
  const unregister = mergeRegister(
122
91
  editor.registerUpdateListener(({ editorState }) => {
@@ -136,6 +105,9 @@ function ImageEditor({ src, title, nodeKey }) {
136
105
  CLICK_COMMAND,
137
106
  (payload) => {
138
107
  const event = payload;
108
+ if (isResizing) {
109
+ return true;
110
+ }
139
111
  if (event.target === imageRef.current) {
140
112
  if (event.shiftKey) {
141
113
  setSelected(!isSelected);
@@ -169,12 +141,28 @@ function ImageEditor({ src, title, nodeKey }) {
169
141
  isMounted = false;
170
142
  unregister();
171
143
  };
172
- }, [clearSelection, editor, isSelected, nodeKey, onDelete, onEnter, onEscape, setSelected]);
144
+ }, [clearSelection, editor, isResizing, isSelected, nodeKey, onDelete, onEnter, onEscape, setSelected]);
145
+ const onResizeEnd = (nextWidth, nextHeight) => {
146
+ setTimeout(() => {
147
+ setIsResizing(false);
148
+ }, 200);
149
+ editor.update(() => {
150
+ const node = $getNodeByKey(nodeKey);
151
+ if ($isImageNode(node)) {
152
+ node.setWidthAndHeight(nextWidth, nextHeight);
153
+ }
154
+ });
155
+ };
156
+ const onResizeStart = () => {
157
+ setIsResizing(true);
158
+ };
173
159
  const draggable = $isNodeSelection(selection);
174
160
  const isFocused = isSelected;
175
- return /* @__PURE__ */ React__default.createElement(Suspense, { fallback: null }, /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("div", { draggable, className: styles.imageWrapper, "data-editor-block-type": "image" }, /* @__PURE__ */ React__default.createElement(
161
+ return /* @__PURE__ */ React__default.createElement(React__default.Suspense, { fallback: null }, /* @__PURE__ */ React__default.createElement("div", { className: styles.imageWrapper, "data-editor-block-type": "image" }, /* @__PURE__ */ React__default.createElement("div", { draggable }, /* @__PURE__ */ React__default.createElement(
176
162
  LazyImage,
177
163
  {
164
+ width,
165
+ height,
178
166
  className: classNames({
179
167
  [styles.focusedImage]: isFocused
180
168
  }),
@@ -182,7 +170,7 @@ function ImageEditor({ src, title, nodeKey }) {
182
170
  title: title || "",
183
171
  imageRef
184
172
  }
185
- ))));
173
+ )), draggable && isFocused && /* @__PURE__ */ React__default.createElement(ImageResizer, { editor, imageRef, onResizeStart, onResizeEnd })));
186
174
  }
187
175
  export {
188
176
  ImageEditor
@@ -0,0 +1,63 @@
1
+ /// <reference types="react" />
2
+ import type { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalEditor, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
3
+ import { DecoratorNode } from 'lexical';
4
+ /**
5
+ * A serialized representation of an {@link ImageNode}.
6
+ */
7
+ export type SerializedImageNode = Spread<{
8
+ altText: string;
9
+ title?: string;
10
+ width?: number;
11
+ height?: number;
12
+ src: string;
13
+ type: 'image';
14
+ version: 1;
15
+ }, SerializedLexicalNode>;
16
+ /**
17
+ * A lexical node that represents an image. Use {@link "$createImageNode"} to construct one.
18
+ */
19
+ export declare class ImageNode extends DecoratorNode<JSX.Element> {
20
+ __src: string;
21
+ __altText: string;
22
+ __title: string | undefined;
23
+ __width: 'inherit' | number;
24
+ __height: 'inherit' | number;
25
+ static getType(): string;
26
+ static clone(node: ImageNode): ImageNode;
27
+ static importJSON(serializedNode: SerializedImageNode): ImageNode;
28
+ exportDOM(): DOMExportOutput;
29
+ static importDOM(): DOMConversionMap | null;
30
+ constructor(src: string, altText: string, title: string | undefined, width?: 'inherit' | number, height?: 'inherit' | number, key?: NodeKey);
31
+ exportJSON(): SerializedImageNode;
32
+ setWidthAndHeight(width: 'inherit' | number, height: 'inherit' | number): void;
33
+ createDOM(config: EditorConfig): HTMLElement;
34
+ updateDOM(): false;
35
+ getSrc(): string;
36
+ getAltText(): string;
37
+ getTitle(): string | undefined;
38
+ getHeight(): 'inherit' | number;
39
+ getWidth(): 'inherit' | number;
40
+ hasExplicitDimensions(): boolean;
41
+ setTitle(title: string | undefined): void;
42
+ decorate(_parentEditor: LexicalEditor): JSX.Element;
43
+ }
44
+ /**
45
+ * The payload to create an {@link ImageNode}.
46
+ */
47
+ export interface CreateImageNodeOptions {
48
+ altText: string;
49
+ width?: number;
50
+ height?: number;
51
+ title?: string;
52
+ key?: NodeKey;
53
+ src: string;
54
+ }
55
+ /**
56
+ * Creates an {@link ImageNode}.
57
+ * @param options - The payload to create an image. The keys map to the img tag attributes.
58
+ */
59
+ export declare function $createImageNode(options: CreateImageNodeOptions): ImageNode;
60
+ /**
61
+ * Retruns true if the node is an {@link ImageNode}.
62
+ */
63
+ export declare function $isImageNode(node: LexicalNode | null | undefined): node is ImageNode;
@@ -0,0 +1,136 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ import React__default from "react";
8
+ import { DecoratorNode } from "lexical";
9
+ import { ImageEditor } from "./ImageEditor.js";
10
+ function convertImageElement(domNode) {
11
+ if (domNode instanceof HTMLImageElement) {
12
+ const { alt: altText, src, title, width, height } = domNode;
13
+ const node = $createImageNode({ altText, src, title, width, height });
14
+ return { node };
15
+ }
16
+ return null;
17
+ }
18
+ class ImageNode extends DecoratorNode {
19
+ constructor(src, altText, title, width, height, key) {
20
+ super(key);
21
+ __publicField(this, "__src");
22
+ __publicField(this, "__altText");
23
+ __publicField(this, "__title");
24
+ __publicField(this, "__width");
25
+ __publicField(this, "__height");
26
+ this.__src = src;
27
+ this.__title = title;
28
+ this.__altText = altText;
29
+ this.__width = width || "inherit";
30
+ this.__height = height || "inherit";
31
+ }
32
+ static getType() {
33
+ return "image";
34
+ }
35
+ static clone(node) {
36
+ return new ImageNode(node.__src, node.__altText, node.__title, node.__width, node.__height, node.__key);
37
+ }
38
+ static importJSON(serializedNode) {
39
+ const { altText, title, src, width, height } = serializedNode;
40
+ const node = $createImageNode({
41
+ altText,
42
+ title,
43
+ src,
44
+ height,
45
+ width
46
+ });
47
+ return node;
48
+ }
49
+ exportDOM() {
50
+ const element = document.createElement("img");
51
+ element.setAttribute("src", this.__src);
52
+ element.setAttribute("alt", this.__altText);
53
+ if (this.__title) {
54
+ element.setAttribute("title", this.__title);
55
+ }
56
+ if (this.__width) {
57
+ element.setAttribute("width", this.__width.toString());
58
+ }
59
+ if (this.__height) {
60
+ element.setAttribute("height", this.__height.toString());
61
+ }
62
+ return { element };
63
+ }
64
+ static importDOM() {
65
+ return {
66
+ img: () => ({
67
+ conversion: convertImageElement,
68
+ priority: 0
69
+ })
70
+ };
71
+ }
72
+ exportJSON() {
73
+ return {
74
+ altText: this.getAltText(),
75
+ title: this.getTitle(),
76
+ height: this.__height === "inherit" ? 0 : this.__height,
77
+ width: this.__width === "inherit" ? 0 : this.__width,
78
+ src: this.getSrc(),
79
+ type: "image",
80
+ version: 1
81
+ };
82
+ }
83
+ setWidthAndHeight(width, height) {
84
+ const writable = this.getWritable();
85
+ writable.__width = width;
86
+ writable.__height = height;
87
+ }
88
+ createDOM(config) {
89
+ const span = document.createElement("span");
90
+ const theme = config.theme;
91
+ const className = theme.image;
92
+ if (className !== void 0) {
93
+ span.className = className;
94
+ }
95
+ return span;
96
+ }
97
+ updateDOM() {
98
+ return false;
99
+ }
100
+ getSrc() {
101
+ return this.__src;
102
+ }
103
+ getAltText() {
104
+ return this.__altText;
105
+ }
106
+ getTitle() {
107
+ return this.__title;
108
+ }
109
+ getHeight() {
110
+ return this.__height;
111
+ }
112
+ getWidth() {
113
+ return this.__width;
114
+ }
115
+ hasExplicitDimensions() {
116
+ return this.__width !== "inherit" || this.__height !== "inherit";
117
+ }
118
+ setTitle(title) {
119
+ this.getWritable().__title = title;
120
+ }
121
+ decorate(_parentEditor) {
122
+ return /* @__PURE__ */ React__default.createElement(ImageEditor, { src: this.getSrc(), title: this.getTitle(), nodeKey: this.getKey(), width: this.__width, height: this.__height });
123
+ }
124
+ }
125
+ function $createImageNode(options) {
126
+ const { altText, title, src, key, width, height } = options;
127
+ return new ImageNode(src, altText, title, width, height, key);
128
+ }
129
+ function $isImageNode(node) {
130
+ return node instanceof ImageNode;
131
+ }
132
+ export {
133
+ $createImageNode,
134
+ $isImageNode,
135
+ ImageNode
136
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /// <reference types="react" />
9
+ import type { LexicalEditor } from 'lexical';
10
+ export default function ImageResizer({ onResizeStart, onResizeEnd, imageRef, maxWidth, editor }: {
11
+ editor: LexicalEditor;
12
+ imageRef: {
13
+ current: null | HTMLElement;
14
+ };
15
+ maxWidth?: number;
16
+ onResizeEnd: (width: 'inherit' | number, height: 'inherit' | number) => void;
17
+ onResizeStart: () => void;
18
+ }): JSX.Element;