mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
76 lines
2.2 KiB
TypeScript
76 lines
2.2 KiB
TypeScript
import { StarterKit } from "@tiptap/starter-kit";
|
|
import { Placeholder } from "@tiptap/extension-placeholder";
|
|
import { TextAlign } from "@tiptap/extension-text-align";
|
|
import { TaskList } from "@tiptap/extension-task-list";
|
|
import { TaskItem } from "@tiptap/extension-task-item";
|
|
import { Underline } from "@tiptap/extension-underline";
|
|
import { Link } from "@tiptap/extension-link";
|
|
import { Superscript } from "@tiptap/extension-superscript";
|
|
import SubScript from "@tiptap/extension-subscript";
|
|
import { Highlight } from "@tiptap/extension-highlight";
|
|
import { Typography } from "@tiptap/extension-typography";
|
|
import { TextStyle } from "@tiptap/extension-text-style";
|
|
import { Color } from "@tiptap/extension-color";
|
|
import SlashCommand from "@/features/editor/extensions/slash-command";
|
|
import { Collaboration } from "@tiptap/extension-collaboration";
|
|
import { CollaborationCursor } from "@tiptap/extension-collaboration-cursor";
|
|
import { HocuspocusProvider } from "@hocuspocus/provider";
|
|
import { Comment, TrailingNode } from "@docmost/editor-ext";
|
|
import GlobalDragHandle from "tiptap-extension-global-drag-handle";
|
|
import {
|
|
randomElement,
|
|
userColors,
|
|
} from "@/features/editor/extensions/utils.ts";
|
|
import { IUser } from "@/features/user/types/user.types.ts";
|
|
|
|
export const mainExtensions = [
|
|
StarterKit.configure({
|
|
history: false,
|
|
dropcursor: {
|
|
width: 3,
|
|
color: "#70CFF8",
|
|
},
|
|
}),
|
|
Placeholder.configure({
|
|
placeholder: 'Enter "/" for commands',
|
|
}),
|
|
TextAlign.configure({ types: ["heading", "paragraph"] }),
|
|
TaskList,
|
|
TaskItem.configure({
|
|
nested: true,
|
|
}),
|
|
Underline,
|
|
Link,
|
|
Superscript,
|
|
SubScript,
|
|
Highlight.configure({
|
|
multicolor: true,
|
|
}),
|
|
Typography,
|
|
TrailingNode,
|
|
GlobalDragHandle,
|
|
TextStyle,
|
|
Color,
|
|
SlashCommand,
|
|
Comment.configure({
|
|
HTMLAttributes: {
|
|
class: "comment-mark",
|
|
},
|
|
}),
|
|
] as any;
|
|
|
|
type CollabExtensions = (provider: HocuspocusProvider, user: IUser) => any[];
|
|
|
|
export const collabExtensions: CollabExtensions = (provider, user) => [
|
|
Collaboration.configure({
|
|
document: provider.document,
|
|
}),
|
|
CollaborationCursor.configure({
|
|
provider,
|
|
user: {
|
|
name: user.name,
|
|
color: randomElement(userColors),
|
|
},
|
|
}),
|
|
];
|