@mdxeditor/editor 0.10.0-alpha.1 → 0.10.0-alpha.2

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.
@@ -77,18 +77,26 @@ const TableEditor = ({ mdastNode, parentEditor, lexicalTable }) => {
77
77
  React__default.useEffect(() => {
78
78
  lexicalTable.focusEmitter.subscribe(setActiveCellWithBoundaries);
79
79
  }, [lexicalTable, setActiveCellWithBoundaries]);
80
- const addRowToBottom = React__default.useCallback(() => {
81
- parentEditor.update(() => {
82
- lexicalTable.addRowToBottom();
83
- setActiveCell([0, lexicalTable.getRowCount()]);
84
- });
85
- }, [parentEditor, lexicalTable]);
86
- const addColumnToRight = React__default.useCallback(() => {
87
- parentEditor.update(() => {
88
- lexicalTable.addColumnToRight();
89
- setActiveCell([lexicalTable.getColCount(), 0]);
90
- });
91
- }, [parentEditor, lexicalTable]);
80
+ const addRowToBottom = React__default.useCallback(
81
+ (e) => {
82
+ e.preventDefault();
83
+ parentEditor.update(() => {
84
+ lexicalTable.addRowToBottom();
85
+ setActiveCell([0, lexicalTable.getRowCount()]);
86
+ });
87
+ },
88
+ [parentEditor, lexicalTable]
89
+ );
90
+ const addColumnToRight = React__default.useCallback(
91
+ (e) => {
92
+ e.preventDefault();
93
+ parentEditor.update(() => {
94
+ lexicalTable.addColumnToRight();
95
+ setActiveCell([lexicalTable.getColCount(), 0]);
96
+ });
97
+ },
98
+ [parentEditor, lexicalTable]
99
+ );
92
100
  const [highlightedCoordinates, setHighlightedCoordinates] = React__default.useState([-1, -1]);
93
101
  const onTableMouseOver = React__default.useCallback((e) => {
94
102
  let tableCell = e.target;
@@ -116,8 +124,10 @@ const TableEditor = ({ mdastNode, parentEditor, lexicalTable }) => {
116
124
  "button",
117
125
  {
118
126
  className: styles.iconButton,
127
+ type: "button",
119
128
  title: "Delete table",
120
- onClick: () => {
129
+ onClick: (e) => {
130
+ e.preventDefault();
121
131
  parentEditor.update(() => {
122
132
  lexicalTable.selectNext();
123
133
  lexicalTable.remove();
@@ -158,8 +168,8 @@ const TableEditor = ({ mdastNode, parentEditor, lexicalTable }) => {
158
168
  }
159
169
  }
160
170
  );
161
- }), rowIndex === 0 && /* @__PURE__ */ React__default.createElement("th", { rowSpan: lexicalTable.getRowCount(), "data-tool-cell": true }, /* @__PURE__ */ React__default.createElement("button", { className: styles.addColumnButton, onClick: addColumnToRight }, /* @__PURE__ */ React__default.createElement(AddColumnIcon, null))));
162
- })), /* @__PURE__ */ React__default.createElement("tfoot", null, /* @__PURE__ */ React__default.createElement("tr", null, /* @__PURE__ */ React__default.createElement("th", null), /* @__PURE__ */ React__default.createElement("th", { colSpan: lexicalTable.getColCount() }, /* @__PURE__ */ React__default.createElement("button", { className: styles.addRowButton, onClick: addRowToBottom }, /* @__PURE__ */ React__default.createElement(AddRowIcon, null))), /* @__PURE__ */ React__default.createElement("th", null))));
171
+ }), rowIndex === 0 && /* @__PURE__ */ React__default.createElement("th", { rowSpan: lexicalTable.getRowCount(), "data-tool-cell": true }, /* @__PURE__ */ React__default.createElement("button", { type: "button", className: styles.addColumnButton, onClick: addColumnToRight }, /* @__PURE__ */ React__default.createElement(AddColumnIcon, null))));
172
+ })), /* @__PURE__ */ React__default.createElement("tfoot", null, /* @__PURE__ */ React__default.createElement("tr", null, /* @__PURE__ */ React__default.createElement("th", null), /* @__PURE__ */ React__default.createElement("th", { colSpan: lexicalTable.getColCount() }, /* @__PURE__ */ React__default.createElement("button", { type: "button", className: styles.addRowButton, onClick: addRowToBottom }, /* @__PURE__ */ React__default.createElement(AddRowIcon, null))), /* @__PURE__ */ React__default.createElement("th", null))));
163
173
  };
164
174
  const Cell = ({ align, ...props }) => {
165
175
  const { activeCell, setActiveCell } = props;