@mdxeditor/editor 3.2.0 → 3.3.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 (60) hide show
  1. package/dist/MDXEditor.js +2 -5
  2. package/dist/defaultSvgIcons.js +330 -0
  3. package/dist/index.d.ts +7 -6
  4. package/dist/plugins/codeblock/CodeBlockNode.js +1 -0
  5. package/dist/plugins/codemirror/CodeMirrorEditor.js +45 -6
  6. package/dist/plugins/image/ImageEditor.js +17 -2
  7. package/dist/plugins/sandpack/SandpackEditor.js +24 -7
  8. package/dist/plugins/sandpack/useCodeMirrorRef.js +10 -1
  9. package/dist/plugins/table/TableEditor.js +16 -16
  10. package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.js +3 -4
  11. package/dist/style.css +317 -277
  12. package/dist/styles/ui.module.css.js +113 -104
  13. package/package.json +5 -3
  14. package/dist/icons/add_column.svg.js +0 -5
  15. package/dist/icons/add_photo.svg.js +0 -5
  16. package/dist/icons/add_row.svg.js +0 -5
  17. package/dist/icons/admonition.svg.js +0 -5
  18. package/dist/icons/arrow_drop_down.svg.js +0 -5
  19. package/dist/icons/check.svg.js +0 -5
  20. package/dist/icons/check_small.svg.js +0 -5
  21. package/dist/icons/close.svg.js +0 -5
  22. package/dist/icons/code.svg.js +0 -5
  23. package/dist/icons/content_copy.svg.js +0 -5
  24. package/dist/icons/delete_big.svg.js +0 -5
  25. package/dist/icons/delete_small.svg.js +0 -5
  26. package/dist/icons/difference.svg.js +0 -5
  27. package/dist/icons/edit.svg.js +0 -5
  28. package/dist/icons/extension.svg.js +0 -5
  29. package/dist/icons/format_align_center.svg.js +0 -5
  30. package/dist/icons/format_align_left.svg.js +0 -5
  31. package/dist/icons/format_align_right.svg.js +0 -5
  32. package/dist/icons/format_bold.svg.js +0 -5
  33. package/dist/icons/format_italic.svg.js +0 -5
  34. package/dist/icons/format_list_bulleted.svg.js +0 -5
  35. package/dist/icons/format_list_checked.svg.js +0 -5
  36. package/dist/icons/format_list_numbered.svg.js +0 -5
  37. package/dist/icons/format_underlined.svg.js +0 -5
  38. package/dist/icons/frame_source.svg.js +0 -5
  39. package/dist/icons/frontmatter.svg.js +0 -5
  40. package/dist/icons/horizontal_rule.svg.js +0 -5
  41. package/dist/icons/insert_col_left.svg.js +0 -5
  42. package/dist/icons/insert_col_right.svg.js +0 -5
  43. package/dist/icons/insert_row_above.svg.js +0 -5
  44. package/dist/icons/insert_row_below.svg.js +0 -5
  45. package/dist/icons/link.svg.js +0 -5
  46. package/dist/icons/link_off.svg.js +0 -5
  47. package/dist/icons/markdown.svg.js +0 -5
  48. package/dist/icons/more_horiz.svg.js +0 -5
  49. package/dist/icons/more_vert.svg.js +0 -5
  50. package/dist/icons/open_in_new.svg.js +0 -5
  51. package/dist/icons/redo.svg.js +0 -5
  52. package/dist/icons/rich_text.svg.js +0 -5
  53. package/dist/icons/sandpack.svg.js +0 -5
  54. package/dist/icons/settings.svg.js +0 -5
  55. package/dist/icons/strikethrough_s.svg.js +0 -5
  56. package/dist/icons/subscript.svg.js +0 -5
  57. package/dist/icons/superscript.svg.js +0 -5
  58. package/dist/icons/table.svg.js +0 -5
  59. package/dist/icons/undo.svg.js +0 -5
  60. package/dist/plugins/core/Icon.js +0 -102
@@ -18,7 +18,7 @@ function useCodeMirrorRef(nodeKey, editorType, language, focusEmitter) {
18
18
  }, [editorType, lexicalNode, setEditorInFocus]);
19
19
  const onKeyDownHandler = React__default.useCallback(
20
20
  (e) => {
21
- var _a, _b, _c, _d;
21
+ var _a, _b, _c, _d, _e, _f;
22
22
  if (e.key === "ArrowDown") {
23
23
  const state = (_b = (_a = codeMirrorRef.current) == null ? void 0 : _a.getCodemirror()) == null ? void 0 : _b.state;
24
24
  if (state) {
@@ -66,6 +66,15 @@ function useCodeMirrorRef(nodeKey, editorType, language, focusEmitter) {
66
66
  }
67
67
  } else if (e.key === "Enter") {
68
68
  e.stopPropagation();
69
+ } else if (e.key === "Backspace" || e.key === "Delete") {
70
+ const state = (_f = (_e = codeMirrorRef.current) == null ? void 0 : _e.getCodemirror()) == null ? void 0 : _f.state;
71
+ const docLength = state == null ? void 0 : state.doc.length;
72
+ if (docLength === 0) {
73
+ activeEditor == null ? void 0 : activeEditor.update(() => {
74
+ const node = $getNodeByKey(nodeKey);
75
+ node.remove();
76
+ });
77
+ }
69
78
  }
70
79
  },
71
80
  [activeEditor, nodeKey]
@@ -137,7 +137,21 @@ const TableEditor = ({ mdastNode, parentEditor, lexicalTable }) => {
137
137
  const className = AlignToTailwindClassMap[currentColumnAlign];
138
138
  return /* @__PURE__ */ React__default.createElement("col", { key: colIndex, className });
139
139
  }), readOnly ? null : /* @__PURE__ */ React__default.createElement("col", null)),
140
- readOnly || /* @__PURE__ */ React__default.createElement("thead", null, /* @__PURE__ */ React__default.createElement("tr", null, /* @__PURE__ */ React__default.createElement("th", { className: styles.tableToolsColumn, "data-tool-cell": true }, /* @__PURE__ */ React__default.createElement(
140
+ readOnly || /* @__PURE__ */ React__default.createElement("thead", null, /* @__PURE__ */ React__default.createElement("tr", null, /* @__PURE__ */ React__default.createElement("th", { className: styles.tableToolsColumn }), Array.from({ length: mdastNode.children[0].children.length }, (_, colIndex) => {
141
+ return /* @__PURE__ */ React__default.createElement("th", { key: colIndex, "data-tool-cell": true }, /* @__PURE__ */ React__default.createElement(
142
+ ColumnEditor,
143
+ {
144
+ ...{
145
+ setActiveCellWithBoundaries,
146
+ parentEditor,
147
+ colIndex,
148
+ highlightedCoordinates,
149
+ lexicalTable,
150
+ align: (mdastNode.align ?? [])[colIndex]
151
+ }
152
+ }
153
+ ));
154
+ }), /* @__PURE__ */ React__default.createElement("th", { className: styles.tableToolsColumn, "data-tool-cell": true }, /* @__PURE__ */ React__default.createElement(
141
155
  "button",
142
156
  {
143
157
  className: styles.iconButton,
@@ -152,21 +166,7 @@ const TableEditor = ({ mdastNode, parentEditor, lexicalTable }) => {
152
166
  }
153
167
  },
154
168
  iconComponentFor("delete_small")
155
- )), Array.from({ length: mdastNode.children[0].children.length }, (_, colIndex) => {
156
- return /* @__PURE__ */ React__default.createElement("th", { key: colIndex, "data-tool-cell": true }, /* @__PURE__ */ React__default.createElement(
157
- ColumnEditor,
158
- {
159
- ...{
160
- setActiveCellWithBoundaries,
161
- parentEditor,
162
- colIndex,
163
- highlightedCoordinates,
164
- lexicalTable,
165
- align: (mdastNode.align ?? [])[colIndex]
166
- }
167
- }
168
- ));
169
- }), /* @__PURE__ */ React__default.createElement("th", { className: styles.tableToolsColumn }))),
169
+ )))),
170
170
  /* @__PURE__ */ React__default.createElement("tbody", null, mdastNode.children.map((row, rowIndex) => {
171
171
  const CellElement = getCellType(rowIndex);
172
172
  return /* @__PURE__ */ React__default.createElement("tr", { key: rowIndex }, readOnly || /* @__PURE__ */ React__default.createElement(CellElement, { className: styles.toolCell, "data-tool-cell": true }, /* @__PURE__ */ React__default.createElement(RowEditor, { ...{ setActiveCellWithBoundaries, parentEditor, rowIndex, highlightedCoordinates, lexicalTable } })), row.children.map((mdastCell, colIndex) => {
@@ -4,7 +4,7 @@ import React__default from "react";
4
4
  import { IS_BOLD, IS_ITALIC, IS_UNDERLINE, IS_STRIKETHROUGH, IS_SUPERSCRIPT, IS_SUBSCRIPT } from "../../../FormatConstants.js";
5
5
  import { ToggleSingleGroupWithItem } from "../primitives/toolbar.js";
6
6
  import styles from "../../../styles/ui.module.css.js";
7
- const FormatButton = ({ format, addTitle, removeTitle, icon, style, formatName }) => {
7
+ const FormatButton = ({ format, addTitle, removeTitle, icon, formatName }) => {
8
8
  const [currentFormat, iconComponentFor] = useCellValues(currentFormat$, iconComponentFor$);
9
9
  const applyFormat = usePublisher(applyFormat$);
10
10
  const active = (currentFormat & format) !== 0;
@@ -17,7 +17,7 @@ const FormatButton = ({ format, addTitle, removeTitle, icon, style, formatName }
17
17
  applyFormat(formatName);
18
18
  }
19
19
  },
20
- /* @__PURE__ */ React__default.createElement("div", { style }, iconComponentFor(icon))
20
+ iconComponentFor(icon)
21
21
  );
22
22
  };
23
23
  const BoldItalicUnderlineToggles = () => {
@@ -47,8 +47,7 @@ const BoldItalicUnderlineToggles = () => {
47
47
  addTitle: t("toolbar.underline", "Underline"),
48
48
  removeTitle: t("toolbar.removeUnderline", "Remove underline"),
49
49
  icon: "format_underlined",
50
- formatName: "underline",
51
- style: { transform: "translateY(2px)" }
50
+ formatName: "underline"
52
51
  }
53
52
  ));
54
53
  };