@mdxeditor/editor 0.10.0 → 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-3725ebef.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-0def7994.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-6488d3ea.cjs +0 -1
  276. package/dist/CodeBlockEditor-884743e8.js +0 -79
  277. package/dist/FrontmatterEditor-435d0430.js +0 -118
  278. package/dist/FrontmatterEditor-95b69d31.cjs +0 -1
  279. package/dist/ImageEditor-43997418.cjs +0 -1
  280. package/dist/JsxEditor-1b8aa6c6.cjs +0 -1
  281. package/dist/JsxEditor-b2e4afc2.js +0 -108
  282. package/dist/LeafDirectiveEditor-792cbb83.js +0 -59
  283. package/dist/LeafDirectiveEditor-c0daefa4.cjs +0 -1
  284. package/dist/SandpackEditor-56a51f80.js +0 -100
  285. package/dist/SandpackEditor-a09311db.cjs +0 -1
  286. package/dist/SourceEditor-1fc83319.cjs +0 -1
  287. package/dist/SourceEditor-32f2b4d8.js +0 -64
  288. package/dist/TableEditor-616848bc.cjs +0 -1
  289. package/dist/TableEditor-777ac58a.js +0 -426
  290. package/dist/index-51585eed.cjs +0 -1
  291. package/dist/index-d34aa66b.js +0 -4361
  292. package/dist/index.cjs +0 -1
  293. package/dist/useCodeMirrorRef-8f68c999.cjs +0 -1
@@ -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,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,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,11 @@
1
+ import { $createTextNode } from "lexical";
2
+ import { IS_CODE } from "../../FormatConstants.js";
3
+ const MdastInlineCodeVisitor = {
4
+ testNode: "inlineCode",
5
+ visitNode({ mdastNode, actions }) {
6
+ actions.addAndStepInto($createTextNode(mdastNode.value).setFormat(IS_CODE));
7
+ }
8
+ };
9
+ export {
10
+ MdastInlineCodeVisitor
11
+ };
@@ -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,96 @@
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';
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
+ * An emitter (usually constructed in the lexical node) that will activate the editor when the node is focused.
77
+ */
78
+ focusEmitter?: VoidEmitter;
79
+ }
80
+ /**
81
+ * 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.
82
+ *
83
+ * @example
84
+ * You can use a type param to specify the type of the mdast node
85
+ *
86
+ * ```tsx
87
+ *
88
+ * interface CalloutDirectiveNode extends LeafDirective {
89
+ * name: 'callout'
90
+ * children: Mdast.PhrasingContent[]
91
+ * }
92
+ *
93
+ * return <NestedLexicalEditor<CalloutDirectiveNode> getContent={node => node.children} getUpdatedMdastNode={(node, children) => ({ ...node, children })} />
94
+ * ```
95
+ */
96
+ export declare const NestedLexicalEditor: <T extends Mdast.Content>(props: NestedEditorProps<T>) => React.JSX.Element;
@@ -0,0 +1,181 @@
1
+ import { $addUpdateTag, $getNodeByKey, createEditor, $getRoot, BLUR_COMMAND, COMMAND_PRIORITY_EDITOR, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_HIGH, KEY_BACKSPACE_COMMAND, COMMAND_PRIORITY_CRITICAL } from "lexical";
2
+ import React__default from "react";
3
+ import { corePluginHooks, NESTED_EDITOR_UPDATED_COMMAND } from "./index.js";
4
+ import { ContentEditable } from "@lexical/react/LexicalContentEditable";
5
+ import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary";
6
+ import { LexicalNestedComposer } from "@lexical/react/LexicalNestedComposer";
7
+ import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
8
+ import { lexicalTheme } from "../../styles/lexicalTheme.js";
9
+ import { exportLexicalTreeToMdast } from "../../exportMarkdownFromLexical.js";
10
+ import { importMdastTreeToLexical } from "../../importMarkdownToLexical.js";
11
+ import styles from "../../styles/ui.module.css.js";
12
+ import { SharedHistoryPlugin } from "./SharedHistoryPlugin.js";
13
+ import { mergeRegister } from "@lexical/utils";
14
+ import { isPartOftheEditorUI } from "../../utils/isPartOftheEditorUI.js";
15
+ const NestedEditorsContext = React__default.createContext(void 0);
16
+ function useNestedEditorContext() {
17
+ const context = React__default.useContext(NestedEditorsContext);
18
+ if (!context) {
19
+ throw new Error("useNestedEditor must be used within a NestedEditorsProvider");
20
+ }
21
+ return context;
22
+ }
23
+ function useMdastNodeUpdater() {
24
+ const { parentEditor, mdastNode, lexicalNode } = useNestedEditorContext();
25
+ return function updateMdastNode(node) {
26
+ parentEditor.update(() => {
27
+ $addUpdateTag("history-push");
28
+ const currentNode = $getNodeByKey(lexicalNode.getKey());
29
+ if (currentNode) {
30
+ currentNode.setMdastNode({ ...mdastNode, ...node });
31
+ }
32
+ });
33
+ };
34
+ }
35
+ function useLexicalNodeRemove() {
36
+ const { parentEditor, lexicalNode } = useNestedEditorContext();
37
+ return () => {
38
+ parentEditor.update(() => {
39
+ const node = $getNodeByKey(lexicalNode.getKey());
40
+ node.selectNext();
41
+ node.remove();
42
+ });
43
+ };
44
+ }
45
+ const NestedLexicalEditor = function(props) {
46
+ const { getContent, getUpdatedMdastNode, contentEditableProps, block = false } = props;
47
+ const { mdastNode, lexicalNode } = useNestedEditorContext();
48
+ const updateMdastNode = useMdastNodeUpdater();
49
+ const removeNode = useLexicalNodeRemove();
50
+ const content = getContent(mdastNode);
51
+ const [rootEditor] = corePluginHooks.useEmitterValues("rootEditor");
52
+ const [importVisitors, exportVisitors, usedLexicalNodes, jsxComponentDescriptors, jsxIsAvailable, nestedEditorChildren] = corePluginHooks.useEmitterValues(
53
+ "importVisitors",
54
+ "exportVisitors",
55
+ "usedLexicalNodes",
56
+ "jsxComponentDescriptors",
57
+ "jsxIsAvailable",
58
+ "nestedEditorChildren"
59
+ );
60
+ const setEditorInFocus = corePluginHooks.usePublisher("editorInFocus");
61
+ const [editor] = React__default.useState(() => {
62
+ const editor2 = createEditor({
63
+ nodes: usedLexicalNodes,
64
+ theme: lexicalTheme
65
+ });
66
+ return editor2;
67
+ });
68
+ React__default.useEffect(() => {
69
+ var _a;
70
+ (_a = props.focusEmitter) == null ? void 0 : _a.subscribe(() => {
71
+ editor.focus();
72
+ });
73
+ }, [editor, props.focusEmitter]);
74
+ React__default.useEffect(() => {
75
+ editor.update(() => {
76
+ $getRoot().clear();
77
+ let theContent = content;
78
+ if (block) {
79
+ if (theContent.length === 0) {
80
+ theContent = [{ type: "paragraph", children: [] }];
81
+ }
82
+ } else {
83
+ theContent = [{ type: "paragraph", children: content }];
84
+ }
85
+ importMdastTreeToLexical({
86
+ root: $getRoot(),
87
+ mdastRoot: {
88
+ type: "root",
89
+ children: theContent
90
+ },
91
+ visitors: importVisitors
92
+ });
93
+ });
94
+ }, [editor, block, importVisitors]);
95
+ React__default.useEffect(() => {
96
+ function updateParentNode() {
97
+ editor.getEditorState().read(() => {
98
+ const mdast = exportLexicalTreeToMdast({
99
+ root: $getRoot(),
100
+ visitors: exportVisitors,
101
+ jsxComponentDescriptors,
102
+ jsxIsAvailable
103
+ });
104
+ const content2 = block ? mdast.children : mdast.children[0].children;
105
+ updateMdastNode(getUpdatedMdastNode(structuredClone(mdastNode), content2));
106
+ });
107
+ }
108
+ return mergeRegister(
109
+ editor.registerCommand(
110
+ BLUR_COMMAND,
111
+ (payload) => {
112
+ const relatedTarget = payload.relatedTarget;
113
+ if (isPartOftheEditorUI(relatedTarget, rootEditor.getRootElement())) {
114
+ return false;
115
+ }
116
+ updateParentNode();
117
+ setEditorInFocus(null);
118
+ return true;
119
+ },
120
+ COMMAND_PRIORITY_EDITOR
121
+ ),
122
+ // triggered by codemirror
123
+ editor.registerCommand(
124
+ NESTED_EDITOR_UPDATED_COMMAND,
125
+ () => {
126
+ updateParentNode();
127
+ return true;
128
+ },
129
+ COMMAND_PRIORITY_EDITOR
130
+ ),
131
+ editor.registerCommand(
132
+ SELECTION_CHANGE_COMMAND,
133
+ () => {
134
+ setEditorInFocus({ editorType: "lexical", rootNode: lexicalNode });
135
+ return false;
136
+ },
137
+ COMMAND_PRIORITY_HIGH
138
+ ),
139
+ editor.registerCommand(
140
+ KEY_BACKSPACE_COMMAND,
141
+ (_, editor2) => {
142
+ const editorElement = editor2.getRootElement();
143
+ if ((editorElement == null ? void 0 : editorElement.innerText) === "\n") {
144
+ removeNode();
145
+ return true;
146
+ }
147
+ return false;
148
+ },
149
+ COMMAND_PRIORITY_CRITICAL
150
+ )
151
+ );
152
+ }, [
153
+ block,
154
+ editor,
155
+ exportVisitors,
156
+ getUpdatedMdastNode,
157
+ jsxComponentDescriptors,
158
+ jsxIsAvailable,
159
+ lexicalNode,
160
+ mdastNode,
161
+ removeNode,
162
+ setEditorInFocus,
163
+ updateMdastNode,
164
+ rootEditor
165
+ ]);
166
+ return /* @__PURE__ */ React__default.createElement(LexicalNestedComposer, { initialEditor: editor }, /* @__PURE__ */ React__default.createElement(
167
+ RichTextPlugin,
168
+ {
169
+ contentEditable: /* @__PURE__ */ React__default.createElement(ContentEditable, { ...contentEditableProps, className: styles.nestedEditor }),
170
+ placeholder: null,
171
+ ErrorBoundary: LexicalErrorBoundary
172
+ }
173
+ ), /* @__PURE__ */ React__default.createElement(SharedHistoryPlugin, null), nestedEditorChildren.map((Child, index) => /* @__PURE__ */ React__default.createElement(Child, { key: index })));
174
+ };
175
+ export {
176
+ NestedEditorsContext,
177
+ NestedLexicalEditor,
178
+ useLexicalNodeRemove,
179
+ useMdastNodeUpdater,
180
+ useNestedEditorContext
181
+ };
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ /**
3
+ * The properties of the {@link PropertyPopover} React component.
4
+ */
5
+ export interface PropertyPopoverProps {
6
+ /**
7
+ * The properties to edit. The key is the name of the property, and the value is the initial value.
8
+ */
9
+ properties: Record<string, string>;
10
+ /**
11
+ * Triggered when the user edits the property values.
12
+ */
13
+ onChange: (values: Record<string, string>) => void;
14
+ /**
15
+ * The title to display in the popover.
16
+ */
17
+ title: string;
18
+ }
19
+ /**
20
+ * A React component that can be used in custom editors to edit the properties of the node.
21
+ * Displays a simple, static key/value editing UI in a popover.
22
+ */
23
+ export declare const PropertyPopover: React.FC<PropertyPopoverProps>;
@@ -0,0 +1,36 @@
1
+ import * as RadixPopover from "@radix-ui/react-popover";
2
+ import React__default from "react";
3
+ import { useForm } from "react-hook-form";
4
+ import SettingsIcon from "../../icons/settings.svg.js";
5
+ import styles from "../../styles/ui.module.css.js";
6
+ import { PopoverPortal, PopoverContent } from "./ui/PopoverUtils.js";
7
+ const PropertyPopover = ({ title, properties, onChange }) => {
8
+ const [open, setOpen] = React__default.useState(false);
9
+ const { register, handleSubmit, reset } = useForm({ defaultValues: properties });
10
+ return /* @__PURE__ */ React__default.createElement(RadixPopover.Root, { open, onOpenChange: (v) => setOpen(v) }, /* @__PURE__ */ React__default.createElement(RadixPopover.Trigger, { className: styles.iconButton }, /* @__PURE__ */ React__default.createElement(SettingsIcon, { style: { display: "block" } })), /* @__PURE__ */ React__default.createElement(PopoverPortal, null, /* @__PURE__ */ React__default.createElement(PopoverContent, null, /* @__PURE__ */ React__default.createElement(
11
+ "form",
12
+ {
13
+ onSubmit: handleSubmit((values) => {
14
+ onChange(values);
15
+ setOpen(false);
16
+ })
17
+ },
18
+ /* @__PURE__ */ React__default.createElement("h3", { className: styles.propertyPanelTitle }, title, " Attributes"),
19
+ /* @__PURE__ */ React__default.createElement("table", { className: styles.propertyEditorTable }, /* @__PURE__ */ React__default.createElement("thead", null, /* @__PURE__ */ React__default.createElement("tr", null, /* @__PURE__ */ React__default.createElement("th", { className: styles.readOnlyColumnCell }, "Attribute"), /* @__PURE__ */ React__default.createElement("th", null, "Value"))), /* @__PURE__ */ React__default.createElement("tbody", null, Object.keys(properties).map((propName) => /* @__PURE__ */ React__default.createElement("tr", { key: propName }, /* @__PURE__ */ React__default.createElement("th", { className: styles.readOnlyColumnCell }, " ", propName, " "), /* @__PURE__ */ React__default.createElement("td", null, /* @__PURE__ */ React__default.createElement("input", { ...register(propName), className: styles.propertyEditorInput }))))), /* @__PURE__ */ React__default.createElement("tfoot", null, /* @__PURE__ */ React__default.createElement("tr", null, /* @__PURE__ */ React__default.createElement("td", { colSpan: 2 }, /* @__PURE__ */ React__default.createElement("div", { className: styles.buttonsFooter }, /* @__PURE__ */ React__default.createElement("button", { type: "submit", className: styles.primaryButton }, "Save"), /* @__PURE__ */ React__default.createElement(
20
+ "button",
21
+ {
22
+ type: "reset",
23
+ className: styles.secondaryButton,
24
+ onClick: (e) => {
25
+ e.preventDefault();
26
+ reset(properties);
27
+ setOpen(false);
28
+ }
29
+ },
30
+ "Cancel"
31
+ ))))))
32
+ ))));
33
+ };
34
+ export {
35
+ PropertyPopover
36
+ };
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const SharedHistoryPlugin: () => React.JSX.Element;