@mdxeditor/editor 0.9.0 → 0.10.0-alpha.1

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 (289) hide show
  1. package/dist/FormatConstants.d.ts +9 -0
  2. package/dist/FormatConstants.js +10 -0
  3. package/dist/MDXEditor.d.ts +31 -0
  4. package/dist/MDXEditor.js +105 -0
  5. package/dist/directive-editors/AdmonitionDirectiveDescriptor.d.ts +4 -0
  6. package/dist/directive-editors/AdmonitionDirectiveDescriptor.js +29 -0
  7. package/dist/directive-editors/GenericDirectiveEditor.d.ts +3 -0
  8. package/dist/directive-editors/GenericDirectiveEditor.js +32 -0
  9. package/dist/exportMarkdownFromLexical.d.ts +114 -0
  10. package/dist/exportMarkdownFromLexical.js +199 -0
  11. package/dist/gurx/index.d.ts +3 -0
  12. package/dist/gurx/react.d.ts +121 -0
  13. package/dist/gurx/react.js +112 -0
  14. package/dist/gurx/realm.d.ts +133 -0
  15. package/dist/gurx/realm.js +491 -0
  16. package/dist/gurx/realmFactory.d.ts +58 -0
  17. package/dist/gurx/realmFactory.js +28 -0
  18. package/dist/icons/add_column.svg.js +8 -0
  19. package/dist/icons/add_photo.svg.js +8 -0
  20. package/dist/icons/add_row.svg.js +8 -0
  21. package/dist/icons/arrow_drop_down.svg.js +8 -0
  22. package/dist/icons/arrow_right.svg.js +8 -0
  23. package/dist/icons/check.svg.js +8 -0
  24. package/dist/icons/close.svg.js +8 -0
  25. package/dist/icons/code.svg.js +8 -0
  26. package/dist/icons/content_copy.svg.js +8 -0
  27. package/dist/icons/delete.svg.js +8 -0
  28. package/dist/icons/delete_small.svg.js +8 -0
  29. package/dist/icons/deployed_code.svg.js +8 -0
  30. package/dist/icons/difference.svg.js +8 -0
  31. package/dist/icons/edit.svg.js +8 -0
  32. package/dist/icons/emergency_home.svg.js +8 -0
  33. package/dist/icons/format_align_center.svg.js +8 -0
  34. package/dist/icons/format_align_left.svg.js +8 -0
  35. package/dist/icons/format_align_right.svg.js +8 -0
  36. package/dist/icons/format_bold.svg.js +8 -0
  37. package/dist/icons/format_italic.svg.js +8 -0
  38. package/dist/icons/format_list_bulleted.svg.js +8 -0
  39. package/dist/icons/format_list_numbered.svg.js +8 -0
  40. package/dist/icons/format_underlined.svg.js +8 -0
  41. package/dist/icons/frame_source.svg.js +8 -0
  42. package/dist/icons/frontmatter.svg.js +8 -0
  43. package/dist/icons/horizontal_rule.svg.js +8 -0
  44. package/dist/icons/insert_col_left.svg.js +8 -0
  45. package/dist/icons/insert_col_right.svg.js +8 -0
  46. package/dist/icons/insert_row_above.svg.js +8 -0
  47. package/dist/icons/insert_row_below.svg.js +8 -0
  48. package/dist/icons/link.svg.js +8 -0
  49. package/dist/icons/link_off.svg.js +8 -0
  50. package/dist/icons/markdown.svg.js +8 -0
  51. package/dist/icons/more_horiz.svg.js +8 -0
  52. package/dist/icons/open_in_new.svg.js +8 -0
  53. package/dist/icons/redo.svg.js +8 -0
  54. package/dist/icons/rich_text.svg.js +8 -0
  55. package/dist/icons/settings.svg.js +8 -0
  56. package/dist/icons/table.svg.js +8 -0
  57. package/dist/icons/undo.svg.js +8 -0
  58. package/dist/importMarkdownToLexical.d.ts +84 -0
  59. package/dist/importMarkdownToLexical.js +65 -0
  60. package/dist/index.d.ts +49 -1094
  61. package/dist/index.js +133 -72
  62. package/dist/jsx-editors/GenericJsxEditor.d.ts +3 -0
  63. package/dist/jsx-editors/GenericJsxEditor.js +56 -0
  64. package/dist/node_modules/react-diff-view/style/index.css.js +4 -0
  65. package/dist/plugins/codeblock/CodeBlockNode.d.ts +99 -0
  66. package/dist/plugins/codeblock/CodeBlockNode.js +155 -0
  67. package/dist/plugins/codeblock/CodeBlockVisitor.d.ts +4 -0
  68. package/dist/plugins/codeblock/CodeBlockVisitor.js +14 -0
  69. package/dist/plugins/codeblock/MdastCodeVisitor.d.ts +3 -0
  70. package/dist/plugins/codeblock/MdastCodeVisitor.js +16 -0
  71. package/dist/plugins/codeblock/index.d.ts +604 -0
  72. package/dist/plugins/codeblock/index.js +73 -0
  73. package/dist/plugins/codemirror/CodeMirrorEditor.d.ts +3 -0
  74. package/dist/plugins/codemirror/CodeMirrorEditor.js +33 -0
  75. package/dist/plugins/codemirror/index.d.ts +786 -0
  76. package/dist/plugins/codemirror/index.js +62 -0
  77. package/dist/plugins/core/LexicalLinebreakVisitor.d.ts +4 -0
  78. package/dist/plugins/core/LexicalLinebreakVisitor.js +10 -0
  79. package/dist/plugins/core/LexicalParagraphVisitor.d.ts +4 -0
  80. package/dist/plugins/core/LexicalParagraphVisitor.js +10 -0
  81. package/dist/plugins/core/LexicalRootVisitor.d.ts +4 -0
  82. package/dist/plugins/core/LexicalRootVisitor.js +10 -0
  83. package/dist/plugins/core/LexicalTextVisitor.d.ts +5 -0
  84. package/dist/plugins/core/LexicalTextVisitor.js +85 -0
  85. package/dist/plugins/core/MdastFormattingVisitor.d.ts +4 -0
  86. package/dist/plugins/core/MdastFormattingVisitor.js +36 -0
  87. package/dist/plugins/core/MdastInlineCodeVisitor.d.ts +3 -0
  88. package/dist/plugins/core/MdastInlineCodeVisitor.js +11 -0
  89. package/dist/plugins/core/MdastParagraphVisitor.d.ts +3 -0
  90. package/dist/plugins/core/MdastParagraphVisitor.js +15 -0
  91. package/dist/plugins/core/MdastRootVisitor.d.ts +3 -0
  92. package/dist/plugins/core/MdastRootVisitor.js +9 -0
  93. package/dist/plugins/core/MdastTextVisitor.d.ts +3 -0
  94. package/dist/plugins/core/MdastTextVisitor.js +10 -0
  95. package/dist/plugins/core/NestedLexicalEditor.d.ts +69 -0
  96. package/dist/plugins/core/NestedLexicalEditor.js +181 -0
  97. package/dist/plugins/core/PropertyPopover.d.ts +8 -0
  98. package/dist/plugins/core/PropertyPopover.js +36 -0
  99. package/dist/plugins/core/SharedHistoryPlugin.d.ts +2 -0
  100. package/dist/plugins/core/SharedHistoryPlugin.js +10 -0
  101. package/dist/plugins/core/index.d.ts +419 -0
  102. package/dist/plugins/core/index.js +343 -0
  103. package/dist/plugins/core/ui/PopoverUtils.d.ts +4 -0
  104. package/dist/plugins/core/ui/PopoverUtils.js +17 -0
  105. package/dist/plugins/diff-source/DiffSourceWrapper.d.ts +4 -0
  106. package/dist/plugins/diff-source/DiffSourceWrapper.js +11 -0
  107. package/dist/plugins/diff-source/DiffViewer.d.ts +2 -0
  108. package/dist/plugins/diff-source/DiffViewer.js +18 -0
  109. package/dist/plugins/diff-source/SourceEditor.d.ts +2 -0
  110. package/dist/plugins/diff-source/SourceEditor.js +25 -0
  111. package/dist/plugins/diff-source/index.d.ts +530 -0
  112. package/dist/plugins/diff-source/index.js +55 -0
  113. package/dist/plugins/directives/DirectiveNode.d.ts +51 -0
  114. package/dist/plugins/directives/DirectiveNode.js +92 -0
  115. package/dist/plugins/directives/DirectiveVisitor.d.ts +4 -0
  116. package/dist/plugins/directives/DirectiveVisitor.js +10 -0
  117. package/dist/plugins/directives/MdastDirectiveVisitor.d.ts +3 -0
  118. package/dist/plugins/directives/MdastDirectiveVisitor.js +13 -0
  119. package/dist/plugins/directives/index.d.ts +591 -0
  120. package/dist/plugins/directives/index.js +53 -0
  121. package/dist/plugins/frontmatter/FrontmatterEditor.d.ts +6 -0
  122. package/dist/plugins/frontmatter/FrontmatterEditor.js +69 -0
  123. package/dist/plugins/frontmatter/FrontmatterNode.d.ts +35 -0
  124. package/dist/plugins/frontmatter/FrontmatterNode.js +71 -0
  125. package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.d.ts +4 -0
  126. package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.js +10 -0
  127. package/dist/plugins/frontmatter/MdastFrontmatterVisitor.d.ts +3 -0
  128. package/dist/plugins/frontmatter/MdastFrontmatterVisitor.js +10 -0
  129. package/dist/plugins/frontmatter/index.d.ts +510 -0
  130. package/dist/plugins/frontmatter/index.js +53 -0
  131. package/dist/plugins/headings/LexicalHeadingVisitor.d.ts +4 -0
  132. package/dist/plugins/headings/LexicalHeadingVisitor.js +11 -0
  133. package/dist/plugins/headings/MdastHeadingVisitor.d.ts +3 -0
  134. package/dist/plugins/headings/MdastHeadingVisitor.js +10 -0
  135. package/dist/plugins/headings/index.d.ts +105 -0
  136. package/dist/plugins/headings/index.js +20 -0
  137. package/dist/plugins/image/ImageEditor.d.ts +7 -0
  138. package/dist/{ImageEditor-ad505654.js → plugins/image/ImageEditor.js} +12 -47
  139. package/dist/plugins/image/ImageNode.d.ts +53 -0
  140. package/dist/plugins/image/ImageNode.js +108 -0
  141. package/dist/plugins/image/LexicalImageVisitor.d.ts +4 -0
  142. package/dist/plugins/image/LexicalImageVisitor.js +15 -0
  143. package/dist/plugins/image/MdastImageVisitor.d.ts +3 -0
  144. package/dist/plugins/image/MdastImageVisitor.js +16 -0
  145. package/dist/plugins/image/index.d.ts +541 -0
  146. package/dist/plugins/image/index.js +244 -0
  147. package/dist/plugins/jsx/LexicalJsxNode.d.ts +54 -0
  148. package/dist/plugins/jsx/LexicalJsxNode.js +99 -0
  149. package/dist/plugins/jsx/LexicalJsxVisitor.d.ts +4 -0
  150. package/dist/plugins/jsx/LexicalJsxVisitor.js +12 -0
  151. package/dist/plugins/jsx/MdastMdxJsEsmVisitor.d.ts +3 -0
  152. package/dist/plugins/jsx/MdastMdxJsEsmVisitor.js +8 -0
  153. package/dist/plugins/jsx/MdastMdxJsxElementVisitor.d.ts +3 -0
  154. package/dist/plugins/jsx/MdastMdxJsxElementVisitor.js +12 -0
  155. package/dist/plugins/jsx/index.d.ts +461 -0
  156. package/dist/plugins/jsx/index.js +37 -0
  157. package/dist/plugins/link/LexicalLinkVisitor.d.ts +4 -0
  158. package/dist/plugins/link/LexicalLinkVisitor.js +10 -0
  159. package/dist/plugins/link/MdastLinkVisitor.d.ts +3 -0
  160. package/dist/plugins/link/MdastLinkVisitor.js +14 -0
  161. package/dist/plugins/link/index.d.ts +108 -0
  162. package/dist/plugins/link/index.js +24 -0
  163. package/dist/plugins/link-dialog/LinkDialog.d.ts +12 -0
  164. package/dist/plugins/link-dialog/LinkDialog.js +174 -0
  165. package/dist/plugins/link-dialog/index.d.ts +496 -0
  166. package/dist/plugins/link-dialog/index.js +242 -0
  167. package/dist/plugins/lists/LexicalListItemVisitor.d.ts +4 -0
  168. package/dist/plugins/lists/LexicalListItemVisitor.js +22 -0
  169. package/dist/plugins/lists/LexicalListVisitor.d.ts +4 -0
  170. package/dist/plugins/lists/LexicalListVisitor.js +14 -0
  171. package/dist/plugins/lists/MdastListItemVisitor.d.ts +3 -0
  172. package/dist/plugins/lists/MdastListItemVisitor.js +10 -0
  173. package/dist/plugins/lists/MdastListVisitor.d.ts +3 -0
  174. package/dist/plugins/lists/MdastListVisitor.js +18 -0
  175. package/dist/plugins/lists/index.d.ts +521 -0
  176. package/dist/plugins/lists/index.js +111 -0
  177. package/dist/plugins/markdown-shortcut/index.d.ts +51 -0
  178. package/dist/plugins/markdown-shortcut/index.js +34 -0
  179. package/dist/plugins/quote/LexicalQuoteVisitor.d.ts +4 -0
  180. package/dist/plugins/quote/LexicalQuoteVisitor.js +14 -0
  181. package/dist/plugins/quote/MdastBlockQuoteVisitor.d.ts +3 -0
  182. package/dist/plugins/quote/MdastBlockQuoteVisitor.js +10 -0
  183. package/dist/plugins/quote/index.d.ts +348 -0
  184. package/dist/plugins/quote/index.js +26 -0
  185. package/dist/plugins/sandpack/SandpackEditor.d.ts +7 -0
  186. package/dist/plugins/sandpack/SandpackEditor.js +35 -0
  187. package/dist/plugins/sandpack/index.d.ts +826 -0
  188. package/dist/plugins/sandpack/index.js +93 -0
  189. package/dist/plugins/sandpack/useCodeMirrorRef.d.ts +4 -0
  190. package/dist/{useCodeMirrorRef-177e9901.js → plugins/sandpack/useCodeMirrorRef.js} +22 -10
  191. package/dist/plugins/table/LexicalTableVisitor.d.ts +4 -0
  192. package/dist/plugins/table/LexicalTableVisitor.js +10 -0
  193. package/dist/plugins/table/MdastTableVisitor.d.ts +3 -0
  194. package/dist/plugins/table/MdastTableVisitor.js +10 -0
  195. package/dist/plugins/table/TableEditor.d.ts +21 -0
  196. package/dist/{TableEditor-44bef804.js → plugins/table/TableEditor.js} +109 -161
  197. package/dist/plugins/table/TableNode.d.ts +52 -0
  198. package/dist/plugins/table/TableNode.js +147 -0
  199. package/dist/plugins/table/index.d.ts +511 -0
  200. package/dist/plugins/table/index.js +59 -0
  201. package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.d.ts +4 -0
  202. package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.js +10 -0
  203. package/dist/plugins/thematic-break/MdastThematicBreakVisitor.d.ts +3 -0
  204. package/dist/plugins/thematic-break/MdastThematicBreakVisitor.js +10 -0
  205. package/dist/plugins/thematic-break/index.d.ts +510 -0
  206. package/dist/plugins/thematic-break/index.js +39 -0
  207. package/dist/plugins/toolbar/components/BlockTypeSelect.d.ts +2 -0
  208. package/dist/plugins/toolbar/components/BlockTypeSelect.js +52 -0
  209. package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.d.ts +2 -0
  210. package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.js +35 -0
  211. package/dist/plugins/toolbar/components/ChangeAdmonitionType.d.ts +2 -0
  212. package/dist/plugins/toolbar/components/ChangeAdmonitionType.js +30 -0
  213. package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.d.ts +2 -0
  214. package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.js +32 -0
  215. package/dist/plugins/toolbar/components/CodeToggle.d.ts +2 -0
  216. package/dist/plugins/toolbar/components/CodeToggle.js +20 -0
  217. package/dist/plugins/toolbar/components/CreateLink.d.ts +2 -0
  218. package/dist/plugins/toolbar/components/CreateLink.js +11 -0
  219. package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.d.ts +4 -0
  220. package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.js +27 -0
  221. package/dist/plugins/toolbar/components/InsertAdmonition.d.ts +2 -0
  222. package/dist/plugins/toolbar/components/InsertAdmonition.js +29 -0
  223. package/dist/plugins/toolbar/components/InsertCodeBlock.d.ts +2 -0
  224. package/dist/plugins/toolbar/components/InsertCodeBlock.js +20 -0
  225. package/dist/plugins/toolbar/components/InsertFrontmatter.d.ts +2 -0
  226. package/dist/plugins/toolbar/components/InsertFrontmatter.js +11 -0
  227. package/dist/plugins/toolbar/components/InsertImage.d.ts +2 -0
  228. package/dist/plugins/toolbar/components/InsertImage.js +23 -0
  229. package/dist/plugins/toolbar/components/InsertSandpack.d.ts +2 -0
  230. package/dist/plugins/toolbar/components/InsertSandpack.js +13 -0
  231. package/dist/plugins/toolbar/components/InsertTable.d.ts +2 -0
  232. package/dist/plugins/toolbar/components/InsertTable.js +20 -0
  233. package/dist/plugins/toolbar/components/InsertThematicBreak.d.ts +2 -0
  234. package/dist/plugins/toolbar/components/InsertThematicBreak.js +11 -0
  235. package/dist/plugins/toolbar/components/KitchenSinkToolbar.d.ts +2 -0
  236. package/dist/plugins/toolbar/components/KitchenSinkToolbar.js +58 -0
  237. package/dist/plugins/toolbar/components/ListsToggle.d.ts +2 -0
  238. package/dist/plugins/toolbar/components/ListsToggle.js +23 -0
  239. package/dist/plugins/toolbar/components/ShowSandpackInfo.d.ts +2 -0
  240. package/dist/plugins/toolbar/components/ShowSandpackInfo.js +32 -0
  241. package/dist/plugins/toolbar/components/UndoRedo.d.ts +2 -0
  242. package/dist/plugins/toolbar/components/UndoRedo.js +59 -0
  243. package/dist/plugins/toolbar/index.d.ts +416 -0
  244. package/dist/plugins/toolbar/index.js +39 -0
  245. package/dist/plugins/toolbar/primitives/DialogButton.d.ts +40 -0
  246. package/dist/plugins/toolbar/primitives/DialogButton.js +115 -0
  247. package/dist/plugins/toolbar/primitives/TooltipWrap.d.ts +5 -0
  248. package/dist/plugins/toolbar/primitives/TooltipWrap.js +12 -0
  249. package/dist/plugins/toolbar/primitives/select.d.ts +31 -0
  250. package/dist/plugins/toolbar/primitives/select.js +44 -0
  251. package/dist/plugins/toolbar/primitives/toolbar.d.ts +85 -0
  252. package/dist/plugins/toolbar/primitives/toolbar.js +111 -0
  253. package/dist/style.css +480 -240
  254. package/dist/styles/globals.css.js +4 -0
  255. package/dist/styles/lexical-theme.module.css.js +53 -0
  256. package/dist/styles/lexicalTheme.d.ts +2 -0
  257. package/dist/styles/lexicalTheme.js +28 -0
  258. package/dist/styles/ui.module.css.js +227 -0
  259. package/dist/utils/detectMac.d.ts +2 -0
  260. package/dist/utils/detectMac.js +6 -0
  261. package/dist/utils/fp.d.ts +47 -0
  262. package/dist/utils/fp.js +10 -0
  263. package/dist/utils/isPartOftheEditorUI.d.ts +1 -0
  264. package/dist/utils/isPartOftheEditorUI.js +12 -0
  265. package/dist/utils/lexicalHelpers.d.ts +11 -0
  266. package/dist/utils/lexicalHelpers.js +49 -0
  267. package/dist/utils/uuid4.d.ts +1 -0
  268. package/dist/utils/uuid4.js +10 -0
  269. package/dist/utils/voidEmitter.d.ts +14 -0
  270. package/dist/utils/voidEmitter.js +15 -0
  271. package/package.json +184 -14
  272. package/dist/CodeBlockEditor-ce4c85ed.js +0 -79
  273. package/dist/CodeBlockEditor-ed222322.cjs +0 -1
  274. package/dist/FrontmatterEditor-914aa241.cjs +0 -1
  275. package/dist/FrontmatterEditor-e2f25a6a.js +0 -118
  276. package/dist/ImageEditor-c4e65554.cjs +0 -1
  277. package/dist/JsxEditor-6cff258d.cjs +0 -1
  278. package/dist/JsxEditor-88d55ef8.js +0 -108
  279. package/dist/LeafDirectiveEditor-0e1328e6.cjs +0 -1
  280. package/dist/LeafDirectiveEditor-34ead530.js +0 -59
  281. package/dist/SandpackEditor-a999ca47.cjs +0 -1
  282. package/dist/SandpackEditor-b1e22784.js +0 -99
  283. package/dist/SourceEditor-0c46ec47.cjs +0 -1
  284. package/dist/SourceEditor-e509d0a5.js +0 -64
  285. package/dist/TableEditor-ced03ce4.cjs +0 -1
  286. package/dist/index-21fcefae.cjs +0 -1
  287. package/dist/index-ce0832cc.js +0 -4361
  288. package/dist/index.cjs +0 -1
  289. package/dist/useCodeMirrorRef-6cb866bd.cjs +0 -1
@@ -0,0 +1,115 @@
1
+ import * as Dialog from "@radix-ui/react-dialog";
2
+ import * as RadixToolbar from "@radix-ui/react-toolbar";
3
+ import React__default from "react";
4
+ import classNames from "classnames";
5
+ import { useCombobox } from "downshift";
6
+ import DropDownIcon from "../../../icons/arrow_drop_down.svg.js";
7
+ import CheckIcon from "../../../icons/check.svg.js";
8
+ import CloseIcon from "../../../icons/close.svg.js";
9
+ import { corePluginHooks } from "../../core/index.js";
10
+ import styles from "../../../styles/ui.module.css.js";
11
+ import { TooltipWrap } from "./TooltipWrap.js";
12
+ const MAX_SUGGESTIONS = 20;
13
+ const DialogButton = React__default.forwardRef(
14
+ ({ autocompleteSuggestions = [], submitButtonTitle, dialogInputPlaceholder, onSubmit, tooltipTitle, buttonContent }, forwardedRef) => {
15
+ const [editorRootElementRef] = corePluginHooks.useEmitterValues("editorRootElementRef");
16
+ const [open, setOpen] = React__default.useState(false);
17
+ const onSubmitCallback = React__default.useCallback(
18
+ (value) => {
19
+ onSubmit(value);
20
+ setOpen(false);
21
+ },
22
+ [onSubmit]
23
+ );
24
+ return /* @__PURE__ */ React__default.createElement(Dialog.Root, { open, onOpenChange: setOpen }, /* @__PURE__ */ React__default.createElement(Dialog.Trigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(RadixToolbar.Button, { className: styles.toolbarButton, ref: forwardedRef }, /* @__PURE__ */ React__default.createElement(TooltipWrap, { title: tooltipTitle }, buttonContent))), /* @__PURE__ */ React__default.createElement(Dialog.Portal, { container: editorRootElementRef == null ? void 0 : editorRootElementRef.current }, /* @__PURE__ */ React__default.createElement(Dialog.Overlay, { className: styles.dialogOverlay }), /* @__PURE__ */ React__default.createElement(Dialog.Content, { className: styles.dialogContent }, /* @__PURE__ */ React__default.createElement(
25
+ DialogForm,
26
+ {
27
+ submitButtonTitle,
28
+ autocompleteSuggestions,
29
+ onSubmitCallback,
30
+ dialogInputPlaceholder
31
+ }
32
+ ))));
33
+ }
34
+ );
35
+ const DialogForm = ({ autocompleteSuggestions, onSubmitCallback, dialogInputPlaceholder, submitButtonTitle }) => {
36
+ const [items, setItems] = React__default.useState(autocompleteSuggestions.slice(0, MAX_SUGGESTIONS));
37
+ const enableAutoComplete = autocompleteSuggestions.length > 0;
38
+ const { isOpen, getToggleButtonProps, getMenuProps, getInputProps, highlightedIndex, getItemProps, selectedItem } = useCombobox({
39
+ initialInputValue: "",
40
+ onInputValueChange({ inputValue }) {
41
+ inputValue = (inputValue == null ? void 0 : inputValue.toLowerCase()) || "";
42
+ const matchingItems = [];
43
+ for (const suggestion of autocompleteSuggestions) {
44
+ if (suggestion.toLowerCase().includes(inputValue)) {
45
+ matchingItems.push(suggestion);
46
+ if (matchingItems.length >= MAX_SUGGESTIONS) {
47
+ break;
48
+ }
49
+ }
50
+ }
51
+ setItems(matchingItems);
52
+ },
53
+ items,
54
+ itemToString(item) {
55
+ return item ?? "";
56
+ }
57
+ });
58
+ const onSubmitEH = (e) => {
59
+ e.preventDefault();
60
+ onSubmitCallback(selectedItem || "");
61
+ };
62
+ const onKeyDownEH = React__default.useCallback(
63
+ (e) => {
64
+ var _a;
65
+ if (e.key === "Escape") {
66
+ (_a = e.target.form) == null ? void 0 : _a.reset();
67
+ } else if (e.key === "Enter" && (!isOpen || items.length === 0)) {
68
+ e.preventDefault();
69
+ onSubmitCallback(e.target.value);
70
+ }
71
+ },
72
+ [isOpen, items, onSubmitCallback]
73
+ );
74
+ const downshiftInputProps = getInputProps();
75
+ const inputProps = {
76
+ ...downshiftInputProps,
77
+ onKeyDown: (e) => {
78
+ onKeyDownEH(e);
79
+ downshiftInputProps.onKeyDown(e);
80
+ }
81
+ };
82
+ const dropdownIsVisible = isOpen && items.length > 0;
83
+ return /* @__PURE__ */ React__default.createElement("form", { onSubmit: onSubmitEH, className: classNames(styles.linkDialogEditForm) }, /* @__PURE__ */ React__default.createElement("div", { className: styles.linkDialogInputContainer }, /* @__PURE__ */ React__default.createElement("div", { "data-visible-dropdown": dropdownIsVisible, className: styles.linkDialogInputWrapper }, /* @__PURE__ */ React__default.createElement(
84
+ "input",
85
+ {
86
+ placeholder: dialogInputPlaceholder,
87
+ className: styles.linkDialogInput,
88
+ ...inputProps,
89
+ autoFocus: true,
90
+ size: 30,
91
+ "data-editor-dialog": true
92
+ }
93
+ ), enableAutoComplete && /* @__PURE__ */ React__default.createElement("button", { "aria-label": "toggle menu", type: "button", ...getToggleButtonProps() }, /* @__PURE__ */ React__default.createElement(DropDownIcon, null))), /* @__PURE__ */ React__default.createElement("div", { className: styles.linkDialogAutocompleteContainer }, /* @__PURE__ */ React__default.createElement("ul", { ...getMenuProps(), "data-visible": dropdownIsVisible }, items.map((item, index) => /* @__PURE__ */ React__default.createElement(
94
+ "li",
95
+ {
96
+ "data-selected": selectedItem === item,
97
+ "data-highlighted": highlightedIndex === index,
98
+ key: `${item}${index}`,
99
+ ...getItemProps({ item, index })
100
+ },
101
+ item
102
+ ))))), /* @__PURE__ */ React__default.createElement(
103
+ "button",
104
+ {
105
+ type: "submit",
106
+ title: submitButtonTitle,
107
+ "aria-label": submitButtonTitle,
108
+ className: classNames(styles.actionButton, styles.primaryActionButton)
109
+ },
110
+ /* @__PURE__ */ React__default.createElement(CheckIcon, null)
111
+ ), /* @__PURE__ */ React__default.createElement(Dialog.Close, { className: styles.actionButton }, /* @__PURE__ */ React__default.createElement(CloseIcon, null)));
112
+ };
113
+ export {
114
+ DialogButton
115
+ };
@@ -0,0 +1,5 @@
1
+ import React, { ReactNode } from 'react';
2
+ export declare const TooltipWrap: React.ForwardRefExoticComponent<{
3
+ title: string;
4
+ children: ReactNode;
5
+ } & React.RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,12 @@
1
+ import * as Tooltip from "@radix-ui/react-tooltip";
2
+ import classNames from "classnames";
3
+ import React__default from "react";
4
+ import styles from "../../../styles/ui.module.css.js";
5
+ import { corePluginHooks } from "../../core/index.js";
6
+ const TooltipWrap = React__default.forwardRef(({ title, children }, ref) => {
7
+ const [editorRootElementRef] = corePluginHooks.useEmitterValues("editorRootElementRef");
8
+ return /* @__PURE__ */ React__default.createElement(Tooltip.Provider, { delayDuration: 100 }, /* @__PURE__ */ React__default.createElement(Tooltip.Root, null, /* @__PURE__ */ React__default.createElement(Tooltip.Trigger, { ref, asChild: true }, /* @__PURE__ */ React__default.createElement("span", null, children)), /* @__PURE__ */ React__default.createElement(Tooltip.Portal, { container: editorRootElementRef == null ? void 0 : editorRootElementRef.current }, /* @__PURE__ */ React__default.createElement(Tooltip.Content, { className: classNames(styles.tooltipContent), sideOffset: 10 }, title))));
9
+ });
10
+ export {
11
+ TooltipWrap
12
+ };
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ export declare const SelectItem: React.ForwardRefExoticComponent<{
3
+ className?: string | undefined;
4
+ children: React.ReactNode;
5
+ value: string;
6
+ } & React.RefAttributes<HTMLDivElement | null>>;
7
+ export declare const SelectTrigger: React.FC<{
8
+ title: string;
9
+ placeholder: string;
10
+ className?: string;
11
+ }>;
12
+ export declare const SelectContent: React.FC<{
13
+ children: React.ReactNode;
14
+ className?: string;
15
+ }>;
16
+ export declare const SelectButtonTrigger: React.FC<{
17
+ children: React.ReactNode;
18
+ title: string;
19
+ className?: string;
20
+ }>;
21
+ export interface SelectProps<T extends string> {
22
+ value: T;
23
+ onChange: (value: T) => void;
24
+ triggerTitle: string;
25
+ placeholder: string;
26
+ items: ({
27
+ label: string;
28
+ value: T;
29
+ } | 'separator')[];
30
+ }
31
+ export declare const Select: <T extends string>(props: SelectProps<T>) => React.JSX.Element;
@@ -0,0 +1,44 @@
1
+ import React__default from "react";
2
+ import * as RadixSelect from "@radix-ui/react-select";
3
+ import DropDownIcon from "../../../icons/arrow_drop_down.svg.js";
4
+ import classNames from "classnames";
5
+ import styles from "../../../styles/ui.module.css.js";
6
+ import { TooltipWrap } from "./TooltipWrap.js";
7
+ import { corePluginHooks } from "../../core/index.js";
8
+ const SelectItem = React__default.forwardRef(
9
+ ({ children, className, ...props }, forwardedRef) => {
10
+ return /* @__PURE__ */ React__default.createElement(RadixSelect.Item, { ...props, ref: forwardedRef, className: classNames(className, styles.selectItem) }, /* @__PURE__ */ React__default.createElement(RadixSelect.ItemText, null, children));
11
+ }
12
+ );
13
+ const SelectTrigger = ({ title, placeholder, className }) => {
14
+ return /* @__PURE__ */ React__default.createElement(TooltipWrap, { title }, /* @__PURE__ */ React__default.createElement(RadixSelect.Trigger, { "aria-label": placeholder, className: classNames(styles.selectTrigger, className), "data-toolbar-item": true }, /* @__PURE__ */ React__default.createElement(RadixSelect.Value, { placeholder }), /* @__PURE__ */ React__default.createElement(RadixSelect.Icon, { className: styles.selectDropdownArrow }, /* @__PURE__ */ React__default.createElement(DropDownIcon, null))));
15
+ };
16
+ const SelectContent = ({
17
+ children,
18
+ className = styles.selectContainer
19
+ }) => {
20
+ const [editorRootElementRef] = corePluginHooks.useEmitterValues("editorRootElementRef");
21
+ return /* @__PURE__ */ React__default.createElement(RadixSelect.Portal, { container: editorRootElementRef == null ? void 0 : editorRootElementRef.current }, /* @__PURE__ */ React__default.createElement(RadixSelect.Content, { className, onCloseAutoFocus: (e) => e.preventDefault(), position: "popper" }, /* @__PURE__ */ React__default.createElement(RadixSelect.Viewport, { "data-editor-dropdown": true }, children)));
22
+ };
23
+ const SelectButtonTrigger = ({
24
+ children,
25
+ title,
26
+ className
27
+ }) => {
28
+ return /* @__PURE__ */ React__default.createElement(TooltipWrap, { title }, /* @__PURE__ */ React__default.createElement(RadixSelect.Trigger, { className: classNames(styles.toolbarButtonSelectTrigger, className) }, children, /* @__PURE__ */ React__default.createElement(RadixSelect.Icon, { className: styles.selectDropdownArrow }, /* @__PURE__ */ React__default.createElement(DropDownIcon, null))));
29
+ };
30
+ const Select = (props) => {
31
+ return /* @__PURE__ */ React__default.createElement(RadixSelect.Root, { value: props.value, onValueChange: props.onChange }, /* @__PURE__ */ React__default.createElement(SelectTrigger, { title: props.triggerTitle, placeholder: props.placeholder }), /* @__PURE__ */ React__default.createElement(SelectContent, null, props.items.map((item, index) => {
32
+ if (item === "separator") {
33
+ return /* @__PURE__ */ React__default.createElement(RadixSelect.Separator, { key: index });
34
+ }
35
+ return /* @__PURE__ */ React__default.createElement(SelectItem, { key: index, value: item.value }, item.label);
36
+ })));
37
+ };
38
+ export {
39
+ Select,
40
+ SelectButtonTrigger,
41
+ SelectContent,
42
+ SelectItem,
43
+ SelectTrigger
44
+ };
@@ -0,0 +1,85 @@
1
+ import * as RadixToolbar from '@radix-ui/react-toolbar';
2
+ import React from 'react';
3
+ import { EditorInFocus } from '../../core';
4
+ export declare const Root: (props: RadixToolbar.ToolbarProps & React.RefAttributes<HTMLDivElement>) => React.JSX.Element;
5
+ export declare const Button: React.ForwardRefExoticComponent<Omit<RadixToolbar.ToolbarButtonProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<object>>;
6
+ export declare const ButtonWithTooltip: ({ title, children, ...props }: Omit<RadixToolbar.ToolbarButtonProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<object> & {
7
+ title: string;
8
+ }) => React.JSX.Element;
9
+ export declare const ToolbarToggleItem: React.ForwardRefExoticComponent<Omit<RadixToolbar.ToolbarToggleItemProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<object>>;
10
+ export declare const SingleToggleGroup: React.ForwardRefExoticComponent<(Omit<RadixToolbar.ToolbarToggleGroupSingleProps & React.RefAttributes<HTMLDivElement>, "ref"> | Omit<RadixToolbar.ToolbarToggleGroupMultipleProps & React.RefAttributes<HTMLDivElement>, "ref">) & React.RefAttributes<object>>;
11
+ export declare const ToggleSingleGroupWithItem: React.ForwardRefExoticComponent<Omit<RadixToolbar.ToolbarToggleGroupSingleProps, "type"> & {
12
+ on: boolean;
13
+ title: string;
14
+ disabled?: boolean | undefined;
15
+ } & React.RefAttributes<HTMLDivElement>>;
16
+ export declare const MultipleChoiceToggleGroup: React.FC<{
17
+ items: {
18
+ title: string;
19
+ contents: React.ReactNode;
20
+ active: boolean;
21
+ onChange: (active: boolean) => void;
22
+ disabled?: boolean;
23
+ }[];
24
+ }>;
25
+ interface SingleChoiceToggleGroupProps<T extends string> {
26
+ items: {
27
+ title: string;
28
+ value: T;
29
+ contents: React.ReactNode;
30
+ }[];
31
+ onChange: (value: T) => void;
32
+ value: T;
33
+ className?: string;
34
+ }
35
+ export declare const SingleChoiceToggleGroup: <T extends string>({ value, onChange, className, items }: SingleChoiceToggleGroupProps<T>) => React.JSX.Element;
36
+ /**
37
+ * The properties of the {@link ButtonOrDropdownButton} React component.
38
+ */
39
+ export interface ButtonOrDropdownButtonProps<T extends string> {
40
+ /**
41
+ * The contents of the button - usually an icon.
42
+ */
43
+ children: React.ReactNode;
44
+ /**
45
+ * The title used for the tooltip.
46
+ */
47
+ title: string;
48
+ /**
49
+ * The function to execute when the button is clicked or an item is chosen from the dropdown.
50
+ * If there is only one item in the dropdown, the value will be an empty string.
51
+ */
52
+ onChoose: (value: T) => void;
53
+ /**
54
+ * The items to show in the dropdown.
55
+ */
56
+ items: {
57
+ /**
58
+ * The value to pass to the `onChoose` function when this item is chosen.
59
+ */
60
+ value: T;
61
+ /**
62
+ * The label to show in the dropdown.
63
+ */
64
+ label: string;
65
+ }[];
66
+ }
67
+ /**
68
+ * Use this primitive to create a toolbar button that can be either a button or a dropdown, depending on the number of items passed.
69
+ *
70
+ * @see {@link ButtonOrDropdownButtonProps} for the properties of the React component.
71
+ */
72
+ export declare const ButtonOrDropdownButton: <T extends string>(props: ButtonOrDropdownButtonProps<T>) => React.JSX.Element;
73
+ type ConditionalContentsOption = {
74
+ when: (rootNode: EditorInFocus | null) => boolean;
75
+ contents: () => React.ReactNode;
76
+ };
77
+ type FallBackOption = {
78
+ fallback: () => React.ReactNode;
79
+ };
80
+ interface ConditionalContentsProps {
81
+ options: (ConditionalContentsOption | FallBackOption)[];
82
+ }
83
+ export declare const ConditionalContents: React.FC<ConditionalContentsProps>;
84
+ export declare const Separator: React.ForwardRefExoticComponent<RadixToolbar.ToolbarSeparatorProps & React.RefAttributes<HTMLDivElement>>;
85
+ export {};
@@ -0,0 +1,111 @@
1
+ import * as RadixSelect from "@radix-ui/react-select";
2
+ import * as RadixToolbar from "@radix-ui/react-toolbar";
3
+ import classNames from "classnames";
4
+ import React__default from "react";
5
+ import styles from "../../../styles/ui.module.css.js";
6
+ import { TooltipWrap } from "./TooltipWrap.js";
7
+ import { SelectButtonTrigger, SelectContent, SelectItem } from "./select.js";
8
+ import { corePluginHooks } from "../../core/index.js";
9
+ function decorate(Component, decoratedProps) {
10
+ return (props) => {
11
+ const className = classNames(decoratedProps.className, props.className);
12
+ return /* @__PURE__ */ React__default.createElement(Component, { ...decoratedProps, ...props, className });
13
+ };
14
+ }
15
+ function decorateWithRef(Component, decoratedProps) {
16
+ return React__default.forwardRef((props, ref) => {
17
+ const className = classNames(decoratedProps.className, props.className);
18
+ return /* @__PURE__ */ React__default.createElement(Component, { ...decoratedProps, ...props, className, ref });
19
+ });
20
+ }
21
+ function addTooltipToChildren(Component) {
22
+ return ({ title, children, ...props }) => {
23
+ return /* @__PURE__ */ React__default.createElement(Component, { ...props }, /* @__PURE__ */ React__default.createElement(TooltipWrap, { title }, children));
24
+ };
25
+ }
26
+ const Root = decorate(RadixToolbar.Root, { className: styles.toolbarRoot });
27
+ const Button = decorateWithRef(RadixToolbar.Button, { className: styles.toolbarButton, "data-toolbar-item": true });
28
+ const ButtonWithTooltip = addTooltipToChildren(Button);
29
+ const ToolbarToggleItem = decorateWithRef(RadixToolbar.ToggleItem, {
30
+ className: styles.toolbarToggleItem,
31
+ "data-toolbar-item": true
32
+ });
33
+ const SingleToggleGroup = decorateWithRef(RadixToolbar.ToggleGroup, {
34
+ type: "single",
35
+ className: styles.toolbarToggleSingleGroup
36
+ });
37
+ const ToggleSingleGroupWithItem = React__default.forwardRef(({ on, title, children, disabled, ...props }, forwardedRef) => {
38
+ return /* @__PURE__ */ React__default.createElement(
39
+ RadixToolbar.ToggleGroup,
40
+ {
41
+ type: "single",
42
+ className: styles.toolbarToggleSingleGroup,
43
+ ...props,
44
+ value: on ? "on" : "off",
45
+ ref: forwardedRef
46
+ },
47
+ /* @__PURE__ */ React__default.createElement(ToolbarToggleItem, { title, value: "on", disabled }, /* @__PURE__ */ React__default.createElement(TooltipWrap, { title }, children))
48
+ );
49
+ });
50
+ const MultipleChoiceToggleGroup = ({ items }) => {
51
+ return /* @__PURE__ */ React__default.createElement("div", { className: styles.toolbarGroupOfGroups }, items.map((item, index) => /* @__PURE__ */ React__default.createElement(
52
+ ToggleSingleGroupWithItem,
53
+ {
54
+ key: index,
55
+ title: item.title,
56
+ on: item.active,
57
+ onValueChange: (v) => item.onChange(v === "on"),
58
+ disabled: item.disabled
59
+ },
60
+ item.contents
61
+ )));
62
+ };
63
+ const SingleChoiceToggleGroup = ({ value, onChange, className, items }) => {
64
+ return /* @__PURE__ */ React__default.createElement("div", { className: styles.toolbarGroupOfGroups }, /* @__PURE__ */ React__default.createElement(
65
+ RadixToolbar.ToggleGroup,
66
+ {
67
+ type: "single",
68
+ className: classNames(styles.toolbarToggleSingleGroup, className),
69
+ onValueChange: onChange,
70
+ value: value || "",
71
+ onFocus: (e) => e.preventDefault()
72
+ },
73
+ items.map((item, index) => /* @__PURE__ */ React__default.createElement(ToolbarToggleItem, { key: index, value: item.value }, /* @__PURE__ */ React__default.createElement(TooltipWrap, { title: item.title }, item.contents)))
74
+ ));
75
+ };
76
+ const ButtonOrDropdownButton = (props) => {
77
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, props.items.length === 1 ? /* @__PURE__ */ React__default.createElement(ButtonWithTooltip, { title: props.title, onClick: () => props.onChoose("") }, props.children) : /* @__PURE__ */ React__default.createElement(RadixSelect.Root, { value: "", onValueChange: props.onChoose }, /* @__PURE__ */ React__default.createElement(SelectButtonTrigger, { title: props.title }, props.children), /* @__PURE__ */ React__default.createElement(SelectContent, { className: styles.toolbarButtonDropdownContainer }, props.items.map((item, index) => /* @__PURE__ */ React__default.createElement(SelectItem, { key: index, value: item.value }, item.label)))));
78
+ };
79
+ function isConditionalContentsOption(option) {
80
+ return Object.hasOwn(option, "when");
81
+ }
82
+ const ConditionalContents = ({ options }) => {
83
+ const [editorInFocus] = corePluginHooks.useEmitterValues("editorInFocus");
84
+ const contents = React__default.useMemo(() => {
85
+ const option = options.find((option2) => {
86
+ if (isConditionalContentsOption(option2)) {
87
+ if (option2.when(editorInFocus)) {
88
+ return true;
89
+ }
90
+ } else {
91
+ return true;
92
+ }
93
+ });
94
+ return option ? isConditionalContentsOption(option) ? option.contents() : option.fallback() : null;
95
+ }, [options, editorInFocus]);
96
+ return /* @__PURE__ */ React__default.createElement("div", { style: { display: "flex" } }, contents);
97
+ };
98
+ const Separator = RadixToolbar.Separator;
99
+ export {
100
+ Button,
101
+ ButtonOrDropdownButton,
102
+ ButtonWithTooltip,
103
+ ConditionalContents,
104
+ MultipleChoiceToggleGroup,
105
+ Root,
106
+ Separator,
107
+ SingleChoiceToggleGroup,
108
+ SingleToggleGroup,
109
+ ToggleSingleGroupWithItem,
110
+ ToolbarToggleItem
111
+ };