mirror of
https://github.com/docmost/docmost.git
synced 2026-08-30 18:36:26 +08:00
init multi-tab-node
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { mergeAttributes, Node } from "@tiptap/core";
|
||||
|
||||
export interface TabLabelOptions {
|
||||
HTMLAttributes: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export const TabLabel = Node.create<TabLabelOptions>({
|
||||
name: "tabLabel",
|
||||
content: "inline*",
|
||||
defining: true,
|
||||
selectable: false,
|
||||
|
||||
addOptions() {
|
||||
return {
|
||||
HTMLAttributes: {},
|
||||
};
|
||||
},
|
||||
|
||||
parseHTML() {
|
||||
return [
|
||||
{
|
||||
tag: `div[data-type="${this.name}"]`,
|
||||
},
|
||||
];
|
||||
},
|
||||
|
||||
renderHTML({ HTMLAttributes }) {
|
||||
return [
|
||||
"div",
|
||||
mergeAttributes(
|
||||
{
|
||||
"data-type": this.name,
|
||||
hidden: "hidden",
|
||||
"aria-hidden": "true",
|
||||
},
|
||||
this.options.HTMLAttributes,
|
||||
HTMLAttributes,
|
||||
),
|
||||
0,
|
||||
];
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user