Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
ruibaby committed Jan 19, 2024
2 parents 7a2a6e9 + b42e046 commit 5bf2eb7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 10 deletions.
2 changes: 1 addition & 1 deletion console/packages/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@tiptap/extension-strike": "^2.1.15",
"@tiptap/extension-subscript": "^2.1.15",
"@tiptap/extension-superscript": "^2.1.15",
"@tiptap/extension-table": "^2.1.15",
"@tiptap/extension-table": "2.2.0-rc.8",
"@tiptap/extension-table-row": "^2.1.15",
"@tiptap/extension-task-item": "^2.1.15",
"@tiptap/extension-task-list": "^2.1.15",
Expand Down
39 changes: 34 additions & 5 deletions console/packages/editor/src/extensions/table/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import TiptapTable, { type TableOptions } from "@tiptap/extension-table";
import TiptapTable, {
type TableOptions,
createColGroup,
} from "@tiptap/extension-table";
import {
isActive,
type Editor,
type Range,
mergeAttributes,
isNodeActive,
} from "@/tiptap/vue-3";
import type {
Node as ProseMirrorNode,
NodeView,
EditorState,
import {
type Node as ProseMirrorNode,
type NodeView,
type EditorState,
type DOMOutputSpec,
} from "@/tiptap/pm";
import TableCell from "./table-cell";
import TableRow from "./table-row";
Expand Down Expand Up @@ -419,6 +424,30 @@ const Table = TiptapTable.extend<ExtensionOptions & TableOptions>({
"Mod-Backspace": () => handleBackspace(),
};
},

renderHTML({ node, HTMLAttributes }) {
const { colgroup, tableWidth, tableMinWidth } = createColGroup(
node,
this.options.cellMinWidth
);

const table: DOMOutputSpec = [
"div",
{ style: "overflow-x: auto; overflow-y: hidden;" },
[
"table",
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
style: tableWidth
? `width: ${tableWidth}`
: `minWidth: ${tableMinWidth}`,
}),
colgroup,
["tbody", 0],
],
];

return table;
},
}).configure({ resizable: true });

export default Table;
8 changes: 4 additions & 4 deletions console/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5bf2eb7

Please sign in to comment.