mirror of
https://github.com/docmost/docmost.git
synced 2025-11-13 12:02:38 +10:00
fix: readonly editor table responsiveness
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
import Table from "@tiptap/extension-table";
|
import Table from "@tiptap/extension-table";
|
||||||
import { Editor } from "@tiptap/core";
|
import { Editor } from "@tiptap/core";
|
||||||
|
import { DOMOutputSpec } from "@tiptap/pm/model";
|
||||||
|
|
||||||
const LIST_TYPES = ["bulletList", "orderedList", "taskList"];
|
const LIST_TYPES = ["bulletList", "orderedList", "taskList"];
|
||||||
|
|
||||||
@ -17,13 +18,17 @@ function isInList(editor: Editor): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleListIndent(editor: Editor): boolean {
|
function handleListIndent(editor: Editor): boolean {
|
||||||
return editor.commands.sinkListItem("listItem") ||
|
return (
|
||||||
editor.commands.sinkListItem("taskItem");
|
editor.commands.sinkListItem("listItem") ||
|
||||||
|
editor.commands.sinkListItem("taskItem")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleListOutdent(editor: Editor): boolean {
|
function handleListOutdent(editor: Editor): boolean {
|
||||||
return editor.commands.liftListItem("listItem") ||
|
return (
|
||||||
editor.commands.liftListItem("taskItem");
|
editor.commands.liftListItem("listItem") ||
|
||||||
|
editor.commands.liftListItem("taskItem")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CustomTable = Table.extend({
|
export const CustomTable = Table.extend({
|
||||||
@ -62,4 +67,15 @@ export const CustomTable = Table.extend({
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
renderHTML({ node, HTMLAttributes }) {
|
||||||
|
// https://github.com/ueberdosis/tiptap/issues/4872#issuecomment-2717554498
|
||||||
|
const originalRender = this.parent?.({ node, HTMLAttributes });
|
||||||
|
const wrapper: DOMOutputSpec = [
|
||||||
|
"div",
|
||||||
|
{ class: "tableWrapper" },
|
||||||
|
originalRender,
|
||||||
|
];
|
||||||
|
return wrapper;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user