@mdxeditor/editor 0.22.2 → 0.22.3
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.
|
@@ -2,7 +2,7 @@ import { createEmptyHistoryState } from "@lexical/react/LexicalHistoryPlugin.js"
|
|
|
2
2
|
import { $isHeadingNode } from "@lexical/rich-text";
|
|
3
3
|
import { $setBlocksType } from "@lexical/selection";
|
|
4
4
|
import { $findMatchingParent, $wrapNodeInElement, $insertNodeToNearestRoot } from "@lexical/utils";
|
|
5
|
-
import { createCommand, SELECTION_CHANGE_COMMAND, $getRoot, COMMAND_PRIORITY_CRITICAL, BLUR_COMMAND, KEY_DOWN_COMMAND, FORMAT_TEXT_COMMAND, $isRootOrShadowRoot, $getSelection, $isRangeSelection, $insertNodes, $createParagraphNode, ParagraphNode, TextNode } from "lexical";
|
|
5
|
+
import { createCommand, SELECTION_CHANGE_COMMAND, $getRoot, COMMAND_PRIORITY_CRITICAL, BLUR_COMMAND, KEY_DOWN_COMMAND, $isDecoratorNode, FORMAT_TEXT_COMMAND, $isRootOrShadowRoot, $getSelection, $isRangeSelection, $insertNodes, $createParagraphNode, ParagraphNode, TextNode } from "lexical";
|
|
6
6
|
import { exportMarkdownFromLexical } from "../../exportMarkdownFromLexical.js";
|
|
7
7
|
import { importMarkdownToLexical } from "../../importMarkdownToLexical.js";
|
|
8
8
|
import { LexicalLinebreakVisitor } from "./LexicalLinebreakVisitor.js";
|
|
@@ -198,23 +198,24 @@ const coreSystem = system((r) => {
|
|
|
198
198
|
KEY_DOWN_COMMAND,
|
|
199
199
|
(event) => {
|
|
200
200
|
const { keyCode, ctrlKey, metaKey } = event;
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
});
|
|
206
|
-
if (keyCode === 65 && controlOrMeta(metaKey, ctrlKey) && shouldOverride) {
|
|
207
|
-
event.preventDefault();
|
|
208
|
-
event.stopImmediatePropagation();
|
|
209
|
-
theRootEditor.update(() => {
|
|
210
|
-
var _a;
|
|
211
|
-
const rootElement = theRootEditor.getRootElement();
|
|
212
|
-
(_a = window.getSelection()) == null ? void 0 : _a.selectAllChildren(rootElement);
|
|
213
|
-
rootElement.focus({
|
|
214
|
-
preventScroll: true
|
|
215
|
-
});
|
|
201
|
+
if (keyCode === 65 && controlOrMeta(metaKey, ctrlKey)) {
|
|
202
|
+
let shouldOverride = false;
|
|
203
|
+
theRootEditor.getEditorState().read(() => {
|
|
204
|
+
shouldOverride = $isDecoratorNode($getRoot().getFirstChild()) || $isDecoratorNode($getRoot().getLastChild());
|
|
216
205
|
});
|
|
217
|
-
|
|
206
|
+
if (shouldOverride) {
|
|
207
|
+
event.preventDefault();
|
|
208
|
+
event.stopImmediatePropagation();
|
|
209
|
+
theRootEditor.update(() => {
|
|
210
|
+
var _a;
|
|
211
|
+
const rootElement = theRootEditor.getRootElement();
|
|
212
|
+
(_a = window.getSelection()) == null ? void 0 : _a.selectAllChildren(rootElement);
|
|
213
|
+
rootElement.focus({
|
|
214
|
+
preventScroll: true
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
218
219
|
}
|
|
219
220
|
return false;
|
|
220
221
|
},
|
|
@@ -26,6 +26,7 @@ import { corePluginHooks } from "../core/index.js";
|
|
|
26
26
|
import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin.js";
|
|
27
27
|
import { mergeRegister } from "@lexical/utils";
|
|
28
28
|
import { isPartOftheEditorUI } from "../../utils/isPartOftheEditorUI.js";
|
|
29
|
+
import { uuidv4 } from "../../utils/uuid4.js";
|
|
29
30
|
const AlignToTailwindClassMap = {
|
|
30
31
|
center: styles.centeredCell,
|
|
31
32
|
left: styles.leftAlignedCell,
|
|
@@ -33,6 +34,15 @@ const AlignToTailwindClassMap = {
|
|
|
33
34
|
};
|
|
34
35
|
const TableEditor = ({ mdastNode, parentEditor, lexicalTable }) => {
|
|
35
36
|
const [activeCell, setActiveCell] = React__default.useState(null);
|
|
37
|
+
const getCellKey = React__default.useMemo(() => {
|
|
38
|
+
const cellKeyMap = /* @__PURE__ */ new WeakMap();
|
|
39
|
+
return (cell) => {
|
|
40
|
+
if (!cellKeyMap.has(cell)) {
|
|
41
|
+
cellKeyMap.set(cell, uuidv4());
|
|
42
|
+
}
|
|
43
|
+
return cellKeyMap.get(cell);
|
|
44
|
+
};
|
|
45
|
+
}, []);
|
|
36
46
|
const setActiveCellWithBoundaries = React__default.useCallback(
|
|
37
47
|
(cell) => {
|
|
38
48
|
const colCount = lexicalTable.getColCount();
|
|
@@ -156,7 +166,7 @@ const TableEditor = ({ mdastNode, parentEditor, lexicalTable }) => {
|
|
|
156
166
|
Cell,
|
|
157
167
|
{
|
|
158
168
|
align: (_a = mdastNode.align) == null ? void 0 : _a[colIndex],
|
|
159
|
-
key:
|
|
169
|
+
key: getCellKey(mdastCell),
|
|
160
170
|
contents: mdastCell.children,
|
|
161
171
|
setActiveCell: setActiveCellWithBoundaries,
|
|
162
172
|
...{
|