@mdxeditor/editor 0.0.0-development

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +28 -0
  3. package/dist/FormatConstants.d.ts +9 -0
  4. package/dist/FormatConstants.js +10 -0
  5. package/dist/MDXEditor.d.ts +92 -0
  6. package/dist/MDXEditor.js +142 -0
  7. package/dist/directive-editors/AdmonitionDirectiveDescriptor.d.ts +17 -0
  8. package/dist/directive-editors/AdmonitionDirectiveDescriptor.js +28 -0
  9. package/dist/directive-editors/GenericDirectiveEditor.d.ts +8 -0
  10. package/dist/directive-editors/GenericDirectiveEditor.js +32 -0
  11. package/dist/exportMarkdownFromLexical.d.ts +133 -0
  12. package/dist/exportMarkdownFromLexical.js +202 -0
  13. package/dist/gurx/index.d.ts +3 -0
  14. package/dist/gurx/react.d.ts +152 -0
  15. package/dist/gurx/react.js +206 -0
  16. package/dist/gurx/realm.d.ts +148 -0
  17. package/dist/gurx/realm.js +489 -0
  18. package/dist/gurx/realmFactory.d.ts +79 -0
  19. package/dist/gurx/realmFactory.js +32 -0
  20. package/dist/icons/add_column.svg.js +5 -0
  21. package/dist/icons/add_photo.svg.js +5 -0
  22. package/dist/icons/add_row.svg.js +5 -0
  23. package/dist/icons/admonition.svg.js +5 -0
  24. package/dist/icons/arrow_drop_down.svg.js +5 -0
  25. package/dist/icons/check.svg.js +5 -0
  26. package/dist/icons/check_small.svg.js +5 -0
  27. package/dist/icons/close.svg.js +5 -0
  28. package/dist/icons/code.svg.js +5 -0
  29. package/dist/icons/code_block.svg.js +5 -0
  30. package/dist/icons/content_copy.svg.js +5 -0
  31. package/dist/icons/delete_big.svg.js +5 -0
  32. package/dist/icons/delete_small.svg.js +5 -0
  33. package/dist/icons/difference.svg.js +5 -0
  34. package/dist/icons/edit.svg.js +5 -0
  35. package/dist/icons/format_align_center.svg.js +5 -0
  36. package/dist/icons/format_align_left.svg.js +5 -0
  37. package/dist/icons/format_align_right.svg.js +5 -0
  38. package/dist/icons/format_bold.svg.js +5 -0
  39. package/dist/icons/format_italic.svg.js +5 -0
  40. package/dist/icons/format_list_bulleted.svg.js +7 -0
  41. package/dist/icons/format_list_checked.svg.js +5 -0
  42. package/dist/icons/format_list_numbered.svg.js +5 -0
  43. package/dist/icons/format_underlined.svg.js +5 -0
  44. package/dist/icons/frontmatter.svg.js +5 -0
  45. package/dist/icons/horizontal_rule.svg.js +5 -0
  46. package/dist/icons/insert_col_left.svg.js +5 -0
  47. package/dist/icons/insert_col_right.svg.js +5 -0
  48. package/dist/icons/insert_row_above.svg.js +5 -0
  49. package/dist/icons/insert_row_below.svg.js +5 -0
  50. package/dist/icons/link.svg.js +5 -0
  51. package/dist/icons/link_off.svg.js +5 -0
  52. package/dist/icons/markdown.svg.js +5 -0
  53. package/dist/icons/more_horiz.svg.js +5 -0
  54. package/dist/icons/more_vert.svg.js +5 -0
  55. package/dist/icons/open_in_new.svg.js +5 -0
  56. package/dist/icons/redo.svg.js +5 -0
  57. package/dist/icons/rich_text.svg.js +5 -0
  58. package/dist/icons/sandpack.svg.js +5 -0
  59. package/dist/icons/settings.svg.js +7 -0
  60. package/dist/icons/table.svg.js +5 -0
  61. package/dist/icons/undo.svg.js +5 -0
  62. package/dist/importMarkdownToLexical.d.ts +91 -0
  63. package/dist/importMarkdownToLexical.js +69 -0
  64. package/dist/index.d.ts +54 -0
  65. package/dist/index.js +175 -0
  66. package/dist/jsx-editors/GenericJsxEditor.d.ts +8 -0
  67. package/dist/jsx-editors/GenericJsxEditor.js +56 -0
  68. package/dist/plugins/codeblock/CodeBlockNode.d.ts +100 -0
  69. package/dist/plugins/codeblock/CodeBlockNode.js +158 -0
  70. package/dist/plugins/codeblock/CodeBlockVisitor.d.ts +4 -0
  71. package/dist/plugins/codeblock/CodeBlockVisitor.js +14 -0
  72. package/dist/plugins/codeblock/MdastCodeVisitor.d.ts +3 -0
  73. package/dist/plugins/codeblock/MdastCodeVisitor.js +16 -0
  74. package/dist/plugins/codeblock/index.d.ts +697 -0
  75. package/dist/plugins/codeblock/index.js +73 -0
  76. package/dist/plugins/codemirror/CodeMirrorEditor.d.ts +3 -0
  77. package/dist/plugins/codemirror/CodeMirrorEditor.js +42 -0
  78. package/dist/plugins/codemirror/index.d.ts +912 -0
  79. package/dist/plugins/codemirror/index.js +62 -0
  80. package/dist/plugins/core/Icon.d.ts +6 -0
  81. package/dist/plugins/core/Icon.js +94 -0
  82. package/dist/plugins/core/LexicalLinebreakVisitor.d.ts +4 -0
  83. package/dist/plugins/core/LexicalLinebreakVisitor.js +10 -0
  84. package/dist/plugins/core/LexicalParagraphVisitor.d.ts +4 -0
  85. package/dist/plugins/core/LexicalParagraphVisitor.js +10 -0
  86. package/dist/plugins/core/LexicalRootVisitor.d.ts +4 -0
  87. package/dist/plugins/core/LexicalRootVisitor.js +10 -0
  88. package/dist/plugins/core/LexicalTextVisitor.d.ts +5 -0
  89. package/dist/plugins/core/LexicalTextVisitor.js +85 -0
  90. package/dist/plugins/core/MdastBreakVisitor.d.ts +3 -0
  91. package/dist/plugins/core/MdastBreakVisitor.js +10 -0
  92. package/dist/plugins/core/MdastFormattingVisitor.d.ts +4 -0
  93. package/dist/plugins/core/MdastFormattingVisitor.js +36 -0
  94. package/dist/plugins/core/MdastInlineCodeVisitor.d.ts +3 -0
  95. package/dist/plugins/core/MdastInlineCodeVisitor.js +27 -0
  96. package/dist/plugins/core/MdastParagraphVisitor.d.ts +3 -0
  97. package/dist/plugins/core/MdastParagraphVisitor.js +15 -0
  98. package/dist/plugins/core/MdastRootVisitor.d.ts +3 -0
  99. package/dist/plugins/core/MdastRootVisitor.js +9 -0
  100. package/dist/plugins/core/MdastTextVisitor.d.ts +3 -0
  101. package/dist/plugins/core/MdastTextVisitor.js +10 -0
  102. package/dist/plugins/core/NestedLexicalEditor.d.ts +92 -0
  103. package/dist/plugins/core/NestedLexicalEditor.js +180 -0
  104. package/dist/plugins/core/PropertyPopover.d.ts +23 -0
  105. package/dist/plugins/core/PropertyPopover.js +39 -0
  106. package/dist/plugins/core/SharedHistoryPlugin.d.ts +2 -0
  107. package/dist/plugins/core/SharedHistoryPlugin.js +10 -0
  108. package/dist/plugins/core/index.d.ts +506 -0
  109. package/dist/plugins/core/index.js +420 -0
  110. package/dist/plugins/core/ui/DownshiftAutoComplete.d.ts +15 -0
  111. package/dist/plugins/core/ui/DownshiftAutoComplete.js +83 -0
  112. package/dist/plugins/core/ui/PopoverUtils.d.ts +4 -0
  113. package/dist/plugins/core/ui/PopoverUtils.js +17 -0
  114. package/dist/plugins/diff-source/DiffSourceWrapper.d.ts +4 -0
  115. package/dist/plugins/diff-source/DiffSourceWrapper.js +11 -0
  116. package/dist/plugins/diff-source/DiffViewer.d.ts +2 -0
  117. package/dist/plugins/diff-source/DiffViewer.js +59 -0
  118. package/dist/plugins/diff-source/SourceEditor.d.ts +4 -0
  119. package/dist/plugins/diff-source/SourceEditor.js +47 -0
  120. package/dist/plugins/diff-source/index.d.ts +635 -0
  121. package/dist/plugins/diff-source/index.js +57 -0
  122. package/dist/plugins/directives/DirectiveNode.d.ts +51 -0
  123. package/dist/plugins/directives/DirectiveNode.js +92 -0
  124. package/dist/plugins/directives/DirectiveVisitor.d.ts +4 -0
  125. package/dist/plugins/directives/DirectiveVisitor.js +10 -0
  126. package/dist/plugins/directives/MdastDirectiveVisitor.d.ts +3 -0
  127. package/dist/plugins/directives/MdastDirectiveVisitor.js +13 -0
  128. package/dist/plugins/directives/index.d.ts +683 -0
  129. package/dist/plugins/directives/index.js +53 -0
  130. package/dist/plugins/frontmatter/FrontmatterEditor.d.ts +6 -0
  131. package/dist/plugins/frontmatter/FrontmatterEditor.js +85 -0
  132. package/dist/plugins/frontmatter/FrontmatterNode.d.ts +35 -0
  133. package/dist/plugins/frontmatter/FrontmatterNode.js +71 -0
  134. package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.d.ts +4 -0
  135. package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.js +10 -0
  136. package/dist/plugins/frontmatter/MdastFrontmatterVisitor.d.ts +3 -0
  137. package/dist/plugins/frontmatter/MdastFrontmatterVisitor.js +10 -0
  138. package/dist/plugins/frontmatter/index.d.ts +627 -0
  139. package/dist/plugins/frontmatter/index.js +76 -0
  140. package/dist/plugins/headings/LexicalHeadingVisitor.d.ts +4 -0
  141. package/dist/plugins/headings/LexicalHeadingVisitor.js +11 -0
  142. package/dist/plugins/headings/MdastHeadingVisitor.d.ts +3 -0
  143. package/dist/plugins/headings/MdastHeadingVisitor.js +10 -0
  144. package/dist/plugins/headings/index.d.ts +617 -0
  145. package/dist/plugins/headings/index.js +69 -0
  146. package/dist/plugins/image/ImageDialog.d.ts +2 -0
  147. package/dist/plugins/image/ImageDialog.js +70 -0
  148. package/dist/plugins/image/ImageEditor.d.ts +10 -0
  149. package/dist/plugins/image/ImageEditor.js +227 -0
  150. package/dist/plugins/image/ImageNode.d.ts +65 -0
  151. package/dist/plugins/image/ImageNode.js +152 -0
  152. package/dist/plugins/image/ImageResizer.d.ts +18 -0
  153. package/dist/plugins/image/ImageResizer.js +214 -0
  154. package/dist/plugins/image/LexicalImageVisitor.d.ts +4 -0
  155. package/dist/plugins/image/LexicalImageVisitor.js +35 -0
  156. package/dist/plugins/image/MdastImageVisitor.d.ts +6 -0
  157. package/dist/plugins/image/MdastImageVisitor.js +87 -0
  158. package/dist/plugins/image/index.d.ts +714 -0
  159. package/dist/plugins/image/index.js +300 -0
  160. package/dist/plugins/jsx/LexicalJsxNode.d.ts +54 -0
  161. package/dist/plugins/jsx/LexicalJsxNode.js +102 -0
  162. package/dist/plugins/jsx/LexicalJsxVisitor.d.ts +4 -0
  163. package/dist/plugins/jsx/LexicalJsxVisitor.js +12 -0
  164. package/dist/plugins/jsx/MdastMdxJsEsmVisitor.d.ts +3 -0
  165. package/dist/plugins/jsx/MdastMdxJsEsmVisitor.js +8 -0
  166. package/dist/plugins/jsx/MdastMdxJsxElementVisitor.d.ts +3 -0
  167. package/dist/plugins/jsx/MdastMdxJsxElementVisitor.js +12 -0
  168. package/dist/plugins/jsx/index.d.ts +688 -0
  169. package/dist/plugins/jsx/index.js +78 -0
  170. package/dist/plugins/link/AutoLinkPlugin.d.ts +9 -0
  171. package/dist/plugins/link/AutoLinkPlugin.js +18 -0
  172. package/dist/plugins/link/LexicalLinkVisitor.d.ts +4 -0
  173. package/dist/plugins/link/LexicalLinkVisitor.js +10 -0
  174. package/dist/plugins/link/MdastLinkVisitor.d.ts +3 -0
  175. package/dist/plugins/link/MdastLinkVisitor.js +14 -0
  176. package/dist/plugins/link/index.d.ts +92 -0
  177. package/dist/plugins/link/index.js +33 -0
  178. package/dist/plugins/link-dialog/LinkDialog.d.ts +16 -0
  179. package/dist/plugins/link-dialog/LinkDialog.js +148 -0
  180. package/dist/plugins/link-dialog/index.d.ts +595 -0
  181. package/dist/plugins/link-dialog/index.js +260 -0
  182. package/dist/plugins/lists/LexicalListItemVisitor.d.ts +4 -0
  183. package/dist/plugins/lists/LexicalListItemVisitor.js +23 -0
  184. package/dist/plugins/lists/LexicalListVisitor.d.ts +4 -0
  185. package/dist/plugins/lists/LexicalListVisitor.js +13 -0
  186. package/dist/plugins/lists/MdastListItemVisitor.d.ts +3 -0
  187. package/dist/plugins/lists/MdastListItemVisitor.js +10 -0
  188. package/dist/plugins/lists/MdastListVisitor.d.ts +3 -0
  189. package/dist/plugins/lists/MdastListVisitor.js +20 -0
  190. package/dist/plugins/lists/index.d.ts +613 -0
  191. package/dist/plugins/lists/index.js +119 -0
  192. package/dist/plugins/markdown-shortcut/index.d.ts +71 -0
  193. package/dist/plugins/markdown-shortcut/index.js +90 -0
  194. package/dist/plugins/quote/LexicalQuoteVisitor.d.ts +4 -0
  195. package/dist/plugins/quote/LexicalQuoteVisitor.js +12 -0
  196. package/dist/plugins/quote/MdastBlockQuoteVisitor.d.ts +3 -0
  197. package/dist/plugins/quote/MdastBlockQuoteVisitor.js +10 -0
  198. package/dist/plugins/quote/index.d.ts +417 -0
  199. package/dist/plugins/quote/index.js +26 -0
  200. package/dist/plugins/sandpack/SandpackEditor.d.ts +7 -0
  201. package/dist/plugins/sandpack/SandpackEditor.js +37 -0
  202. package/dist/plugins/sandpack/index.d.ts +951 -0
  203. package/dist/plugins/sandpack/index.js +93 -0
  204. package/dist/plugins/sandpack/useCodeMirrorRef.d.ts +4 -0
  205. package/dist/plugins/sandpack/useCodeMirrorRef.js +96 -0
  206. package/dist/plugins/table/LexicalTableVisitor.d.ts +4 -0
  207. package/dist/plugins/table/LexicalTableVisitor.js +10 -0
  208. package/dist/plugins/table/MdastTableVisitor.d.ts +3 -0
  209. package/dist/plugins/table/MdastTableVisitor.js +10 -0
  210. package/dist/plugins/table/TableEditor.d.ts +21 -0
  211. package/dist/plugins/table/TableEditor.js +388 -0
  212. package/dist/plugins/table/TableNode.d.ts +52 -0
  213. package/dist/plugins/table/TableNode.js +152 -0
  214. package/dist/plugins/table/index.d.ts +614 -0
  215. package/dist/plugins/table/index.js +69 -0
  216. package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.d.ts +4 -0
  217. package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.js +10 -0
  218. package/dist/plugins/thematic-break/MdastThematicBreakVisitor.d.ts +3 -0
  219. package/dist/plugins/thematic-break/MdastThematicBreakVisitor.js +10 -0
  220. package/dist/plugins/thematic-break/index.d.ts +603 -0
  221. package/dist/plugins/thematic-break/index.js +39 -0
  222. package/dist/plugins/toolbar/components/BlockTypeSelect.d.ts +6 -0
  223. package/dist/plugins/toolbar/components/BlockTypeSelect.js +54 -0
  224. package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.d.ts +5 -0
  225. package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.js +33 -0
  226. package/dist/plugins/toolbar/components/ChangeAdmonitionType.d.ts +6 -0
  227. package/dist/plugins/toolbar/components/ChangeAdmonitionType.js +30 -0
  228. package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.d.ts +7 -0
  229. package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.js +32 -0
  230. package/dist/plugins/toolbar/components/CodeToggle.d.ts +6 -0
  231. package/dist/plugins/toolbar/components/CodeToggle.js +19 -0
  232. package/dist/plugins/toolbar/components/CreateLink.d.ts +6 -0
  233. package/dist/plugins/toolbar/components/CreateLink.js +20 -0
  234. package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.d.ts +18 -0
  235. package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.js +25 -0
  236. package/dist/plugins/toolbar/components/InsertAdmonition.d.ts +6 -0
  237. package/dist/plugins/toolbar/components/InsertAdmonition.js +29 -0
  238. package/dist/plugins/toolbar/components/InsertCodeBlock.d.ts +7 -0
  239. package/dist/plugins/toolbar/components/InsertCodeBlock.js +20 -0
  240. package/dist/plugins/toolbar/components/InsertFrontmatter.d.ts +6 -0
  241. package/dist/plugins/toolbar/components/InsertFrontmatter.js +24 -0
  242. package/dist/plugins/toolbar/components/InsertImage.d.ts +6 -0
  243. package/dist/plugins/toolbar/components/InsertImage.js +14 -0
  244. package/dist/plugins/toolbar/components/InsertSandpack.d.ts +6 -0
  245. package/dist/plugins/toolbar/components/InsertSandpack.js +13 -0
  246. package/dist/plugins/toolbar/components/InsertTable.d.ts +6 -0
  247. package/dist/plugins/toolbar/components/InsertTable.js +20 -0
  248. package/dist/plugins/toolbar/components/InsertThematicBreak.d.ts +6 -0
  249. package/dist/plugins/toolbar/components/InsertThematicBreak.js +11 -0
  250. package/dist/plugins/toolbar/components/KitchenSinkToolbar.d.ts +7 -0
  251. package/dist/plugins/toolbar/components/KitchenSinkToolbar.js +58 -0
  252. package/dist/plugins/toolbar/components/ListsToggle.d.ts +7 -0
  253. package/dist/plugins/toolbar/components/ListsToggle.js +23 -0
  254. package/dist/plugins/toolbar/components/ShowSandpackInfo.d.ts +7 -0
  255. package/dist/plugins/toolbar/components/ShowSandpackInfo.js +31 -0
  256. package/dist/plugins/toolbar/components/UndoRedo.d.ts +5 -0
  257. package/dist/plugins/toolbar/components/UndoRedo.js +58 -0
  258. package/dist/plugins/toolbar/index.d.ts +492 -0
  259. package/dist/plugins/toolbar/index.js +40 -0
  260. package/dist/plugins/toolbar/primitives/DialogButton.d.ts +40 -0
  261. package/dist/plugins/toolbar/primitives/DialogButton.js +114 -0
  262. package/dist/plugins/toolbar/primitives/TooltipWrap.d.ts +8 -0
  263. package/dist/plugins/toolbar/primitives/TooltipWrap.js +12 -0
  264. package/dist/plugins/toolbar/primitives/select.d.ts +50 -0
  265. package/dist/plugins/toolbar/primitives/select.js +55 -0
  266. package/dist/plugins/toolbar/primitives/toolbar.d.ts +163 -0
  267. package/dist/plugins/toolbar/primitives/toolbar.js +115 -0
  268. package/dist/style.css +1715 -0
  269. package/dist/styles/globals.css.js +4 -0
  270. package/dist/styles/lexical-theme.module.css.js +62 -0
  271. package/dist/styles/lexicalTheme.d.ts +2 -0
  272. package/dist/styles/lexicalTheme.js +31 -0
  273. package/dist/styles/ui.module.css.js +308 -0
  274. package/dist/utils/detectMac.d.ts +3 -0
  275. package/dist/utils/detectMac.js +13 -0
  276. package/dist/utils/fp.d.ts +47 -0
  277. package/dist/utils/fp.js +14 -0
  278. package/dist/utils/isPartOftheEditorUI.d.ts +1 -0
  279. package/dist/utils/isPartOftheEditorUI.js +12 -0
  280. package/dist/utils/lexicalHelpers.d.ts +11 -0
  281. package/dist/utils/lexicalHelpers.js +62 -0
  282. package/dist/utils/uuid4.d.ts +1 -0
  283. package/dist/utils/uuid4.js +10 -0
  284. package/dist/utils/voidEmitter.d.ts +14 -0
  285. package/dist/utils/voidEmitter.js +15 -0
  286. package/package.json +435 -0
@@ -0,0 +1,52 @@
1
+ /// <reference types="react" />
2
+ import { DecoratorNode, LexicalEditor, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
3
+ import * as Mdast from 'mdast';
4
+ /**
5
+ * A serialized representation of a {@link TableNode}.
6
+ */
7
+ export type SerializedTableNode = Spread<{
8
+ mdastNode: Mdast.Table;
9
+ }, SerializedLexicalNode>;
10
+ type CoordinatesSubscription = (coords: [colIndex: number, rowIndex: number]) => void;
11
+ /**
12
+ * A lexical node that represents a table, with features specific to the markdown tables.
13
+ * Use {@link "$createTableNode"} to construct one.
14
+ */
15
+ export declare class TableNode extends DecoratorNode<JSX.Element> {
16
+ __mdastNode: Mdast.Table;
17
+ focusEmitter: {
18
+ publish: (coords: [colIndex: number, rowIndex: number]) => void;
19
+ subscribe: (cb: CoordinatesSubscription) => void;
20
+ };
21
+ static getType(): string;
22
+ static clone(node: TableNode): TableNode;
23
+ static importJSON(serializedNode: SerializedTableNode): TableNode;
24
+ exportJSON(): SerializedTableNode;
25
+ getMdastNode(): Mdast.Table;
26
+ getRowCount(): number;
27
+ getColCount(): number;
28
+ constructor(mdastNode?: Mdast.Table, key?: NodeKey);
29
+ createDOM(): HTMLElement;
30
+ updateDOM(): false;
31
+ updateCellContents(colIndex: number, rowIndex: number, children: Mdast.PhrasingContent[]): void;
32
+ insertColumnAt(colIndex: number): void;
33
+ deleteColumnAt(colIndex: number): void;
34
+ insertRowAt(y: number): void;
35
+ deleteRowAt(rowIndex: number): void;
36
+ addRowToBottom(): void;
37
+ addColumnToRight(): void;
38
+ setColumnAlign(colIndex: number, align: Mdast.AlignType): void;
39
+ decorate(parentEditor: LexicalEditor): JSX.Element;
40
+ select(coords?: [colIndex: number, rowIndex: number]): void;
41
+ isInline(): false;
42
+ }
43
+ /**
44
+ * Retruns true if the given node is a {@link TableNode}.
45
+ */
46
+ export declare function $isTableNode(node: LexicalNode | null | undefined): node is TableNode;
47
+ /**
48
+ * Creates a {@link TableNode}
49
+ * @param mdastNode - The mdast node to create the {@link TableNode} from.
50
+ */
51
+ export declare function $createTableNode(mdastNode: Mdast.Table): TableNode;
52
+ export {};
@@ -0,0 +1,152 @@
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 { DecoratorNode } from "lexical";
8
+ import React__default from "react";
9
+ import { noop } from "../../utils/fp.js";
10
+ import { TableEditor } from "./TableEditor.js";
11
+ const EMPTY_CELL = { type: "tableCell", children: [] };
12
+ function coordinatesEmitter() {
13
+ let subscription = noop;
14
+ return {
15
+ publish: (coords) => {
16
+ subscription(coords);
17
+ },
18
+ subscribe: (cb) => {
19
+ subscription = cb;
20
+ }
21
+ };
22
+ }
23
+ class TableNode extends DecoratorNode {
24
+ constructor(mdastNode, key) {
25
+ super(key);
26
+ __publicField(this, "__mdastNode");
27
+ __publicField(this, "focusEmitter", coordinatesEmitter());
28
+ this.__mdastNode = mdastNode || { type: "table", children: [] };
29
+ }
30
+ static getType() {
31
+ return "table";
32
+ }
33
+ static clone(node) {
34
+ return new TableNode(structuredClone(node.__mdastNode), node.__key);
35
+ }
36
+ static importJSON(serializedNode) {
37
+ return $createTableNode(serializedNode.mdastNode);
38
+ }
39
+ exportJSON() {
40
+ return {
41
+ mdastNode: structuredClone(this.__mdastNode),
42
+ type: "table",
43
+ version: 1
44
+ };
45
+ }
46
+ getMdastNode() {
47
+ return this.__mdastNode;
48
+ }
49
+ getRowCount() {
50
+ return this.__mdastNode.children.length;
51
+ }
52
+ getColCount() {
53
+ var _a;
54
+ return ((_a = this.__mdastNode.children[0]) == null ? void 0 : _a.children.length) || 0;
55
+ }
56
+ createDOM() {
57
+ return document.createElement("div");
58
+ }
59
+ updateDOM() {
60
+ return false;
61
+ }
62
+ updateCellContents(colIndex, rowIndex, children) {
63
+ const self = this.getWritable();
64
+ const table = self.__mdastNode;
65
+ const row = table.children[rowIndex];
66
+ const cells = row.children;
67
+ const cell = cells[colIndex];
68
+ const cellsClone = Array.from(cells);
69
+ const cellClone = { ...cell, children };
70
+ const rowClone = { ...row, children: cellsClone };
71
+ cellsClone[colIndex] = cellClone;
72
+ table.children[rowIndex] = rowClone;
73
+ }
74
+ insertColumnAt(colIndex) {
75
+ const self = this.getWritable();
76
+ const table = self.__mdastNode;
77
+ for (let rowIndex = 0; rowIndex < table.children.length; rowIndex++) {
78
+ const row = table.children[rowIndex];
79
+ const cells = row.children;
80
+ const cellsClone = Array.from(cells);
81
+ const rowClone = { ...row, children: cellsClone };
82
+ cellsClone.splice(colIndex, 0, structuredClone(EMPTY_CELL));
83
+ table.children[rowIndex] = rowClone;
84
+ }
85
+ if (table.align && table.align.length > 0) {
86
+ table.align.splice(colIndex, 0, "left");
87
+ }
88
+ }
89
+ deleteColumnAt(colIndex) {
90
+ const self = this.getWritable();
91
+ const table = self.__mdastNode;
92
+ for (let rowIndex = 0; rowIndex < table.children.length; rowIndex++) {
93
+ const row = table.children[rowIndex];
94
+ const cells = row.children;
95
+ const cellsClone = Array.from(cells);
96
+ const rowClone = { ...row, children: cellsClone };
97
+ cellsClone.splice(colIndex, 1);
98
+ table.children[rowIndex] = rowClone;
99
+ }
100
+ }
101
+ insertRowAt(y) {
102
+ const self = this.getWritable();
103
+ const table = self.__mdastNode;
104
+ const newRow = {
105
+ type: "tableRow",
106
+ children: Array.from({ length: this.getColCount() }, () => structuredClone(EMPTY_CELL))
107
+ };
108
+ table.children.splice(y, 0, newRow);
109
+ }
110
+ deleteRowAt(rowIndex) {
111
+ if (this.getRowCount() === 1) {
112
+ this.selectNext();
113
+ this.remove();
114
+ } else {
115
+ this.getWritable().__mdastNode.children.splice(rowIndex, 1);
116
+ }
117
+ }
118
+ addRowToBottom() {
119
+ this.insertRowAt(this.getRowCount());
120
+ }
121
+ addColumnToRight() {
122
+ this.insertColumnAt(this.getColCount());
123
+ }
124
+ setColumnAlign(colIndex, align) {
125
+ const self = this.getWritable();
126
+ const table = self.__mdastNode;
127
+ if (table.align == null) {
128
+ table.align = [];
129
+ }
130
+ table.align[colIndex] = align;
131
+ }
132
+ decorate(parentEditor) {
133
+ return /* @__PURE__ */ React__default.createElement(TableEditor, { lexicalTable: this, mdastNode: this.__mdastNode, parentEditor });
134
+ }
135
+ select(coords) {
136
+ this.focusEmitter.publish(coords || [0, 0]);
137
+ }
138
+ isInline() {
139
+ return false;
140
+ }
141
+ }
142
+ function $isTableNode(node) {
143
+ return node instanceof TableNode;
144
+ }
145
+ function $createTableNode(mdastNode) {
146
+ return new TableNode(mdastNode);
147
+ }
148
+ export {
149
+ $createTableNode,
150
+ $isTableNode,
151
+ TableNode
152
+ };