editor: prevent table column size reset in readonly mode (#2586)

This commit is contained in:
Muhammad Ali
2023-05-25 12:11:57 +05:00
committed by GitHub
parent b3b1b7470e
commit 283efa6e41

View File

@@ -18,8 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Table as TiptapTable, TableOptions } from "@tiptap/extension-table";
import { columnResizing, tableEditing } from "@tiptap/pm/tables";
import { tableEditing, columnResizing, TableView } from "@tiptap/pm/tables";
import { TableNodeView } from "./component";
import { Plugin, PluginKey } from "prosemirror-state";
export const Table = TiptapTable.extend<TableOptions>({
addProseMirrorPlugins() {
@@ -35,10 +36,20 @@ export const Table = TiptapTable.extend<TableOptions>({
lastColumnResizable: this.options.lastColumnResizable
})
]
: []),
: [tiptapTableView(this.options.cellMinWidth)]),
tableEditing({
allowTableNodeSelection: this.options.allowTableNodeSelection
})
];
}
});
const TiptapTableViewPluginKey = new PluginKey("TiptapTableView");
function tiptapTableView(cellMinWidth: number): Plugin {
return new Plugin({
key: TiptapTableViewPluginKey,
props: {
nodeViews: { [Table.name]: (node) => new TableView(node, cellMinWidth) }
}
});
}