From 4991bdf689e876e8b7b5f7886c09c07724781d89 Mon Sep 17 00:00:00 2001 From: 01zulfi <85733202+01zulfi@users.noreply.github.com> Date: Tue, 25 Nov 2025 13:34:11 +0500 Subject: [PATCH] editor: readonly table fixes * fix tables not hiding under collapsed headings in readonly view * allow column resizing in readonly view * fix scrollbar not showing in readonly view Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com> --- .../editor/src/extensions/table/component.tsx | 24 +++++++++++-------- .../prosemirror-tables/columnresizing.ts | 2 -- packages/editor/src/extensions/table/table.ts | 15 ++++++++---- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/packages/editor/src/extensions/table/component.tsx b/packages/editor/src/extensions/table/component.tsx index d9ee1f43a..5ee339fae 100644 --- a/packages/editor/src/extensions/table/component.tsx +++ b/packages/editor/src/extensions/table/component.tsx @@ -90,16 +90,20 @@ export function TableComponent( return ( <> - - + {editor.isEditable ? ( + <> + + + + ) : null}
. import { callOrReturn, + Editor, getExtensionField, mergeAttributes, Node, @@ -30,7 +31,6 @@ import { EditorView, NodeView } from "@tiptap/pm/view"; import { createColGroup } from "./utilities/createColGroup.js"; import { createTable } from "./utilities/createTable.js"; import { deleteTableWhenAllCellsSelected } from "./utilities/deleteTableWhenAllCellsSelected.js"; -import { TableView } from "./TableView.js"; import { TableNodeView } from "./component.js"; import { addColumnAfter, @@ -477,7 +477,7 @@ export const Table = Node.create({ }, addProseMirrorPlugins() { - const isResizable = this.options.resizable && this.editor.isEditable; + const isResizable = this.options.resizable; return [ ...(isResizable @@ -489,7 +489,7 @@ export const Table = Node.create({ this.options.showResizeHandleOnSelection }) ] - : [tiptapTableView(this.options.cellMinWidth)]), + : [tiptapTableView(this.editor, this.options.cellMinWidth)]), tableEditing({ allowTableNodeSelection: this.options.allowTableNodeSelection }) @@ -512,11 +512,16 @@ export const Table = Node.create({ }); const TiptapTableViewPluginKey = new PluginKey("TiptapTableView"); -function tiptapTableView(cellMinWidth: number): Plugin { +function tiptapTableView(editor: Editor, cellMinWidth: number): Plugin { return new Plugin({ key: TiptapTableViewPluginKey, props: { - nodeViews: { [Table.name]: (node) => new TableView(node, cellMinWidth) } + nodeViews: { + [Table.name]: (node, view) => { + const View = TableNodeView(editor); + return new View(node, cellMinWidth, view); + } + } } }); }