doclific 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +2 -0
- package/.prettierignore +5 -0
- package/.prettierrc +9 -0
- package/.vscode/settings.json +13 -0
- package/dist/bin/doclific.d.ts +3 -0
- package/dist/bin/doclific.d.ts.map +1 -0
- package/dist/bin/doclific.js +11 -0
- package/dist/core/codebase.js +31 -0
- package/dist/core/docs.js +75 -0
- package/dist/core/git.js +47 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +46 -0
- package/dist/server/router.d.ts +9 -0
- package/dist/server/router.d.ts.map +1 -0
- package/dist/server/router.js +55 -0
- package/frontend/README.md +73 -0
- package/frontend/components.json +24 -0
- package/frontend/eslint.config.js +23 -0
- package/frontend/index.html +25 -0
- package/frontend/package-lock.json +15754 -0
- package/frontend/package.json +122 -0
- package/frontend/public/logo.svg +1 -0
- package/frontend/src/App.tsx +21 -0
- package/frontend/src/components/app-sidebar.tsx +393 -0
- package/frontend/src/components/editor/editor-base-kit.tsx +43 -0
- package/frontend/src/components/editor/editor-kit.tsx +93 -0
- package/frontend/src/components/editor/plugins/align-base-kit.tsx +16 -0
- package/frontend/src/components/editor/plugins/align-kit.tsx +18 -0
- package/frontend/src/components/editor/plugins/autoformat-kit.tsx +236 -0
- package/frontend/src/components/editor/plugins/basic-blocks-base-kit.tsx +35 -0
- package/frontend/src/components/editor/plugins/basic-blocks-kit.tsx +88 -0
- package/frontend/src/components/editor/plugins/basic-marks-base-kit.tsx +27 -0
- package/frontend/src/components/editor/plugins/basic-marks-kit.tsx +41 -0
- package/frontend/src/components/editor/plugins/basic-nodes-kit.tsx +6 -0
- package/frontend/src/components/editor/plugins/block-menu-kit.tsx +14 -0
- package/frontend/src/components/editor/plugins/block-placeholder-kit.tsx +17 -0
- package/frontend/src/components/editor/plugins/block-selection-kit.tsx +32 -0
- package/frontend/src/components/editor/plugins/callout-base-kit.tsx +7 -0
- package/frontend/src/components/editor/plugins/callout-kit.tsx +7 -0
- package/frontend/src/components/editor/plugins/code-block-base-kit.tsx +23 -0
- package/frontend/src/components/editor/plugins/code-block-kit.tsx +26 -0
- package/frontend/src/components/editor/plugins/codebase-kit.tsx +23 -0
- package/frontend/src/components/editor/plugins/column-base-kit.tsx +11 -0
- package/frontend/src/components/editor/plugins/column-kit.tsx +10 -0
- package/frontend/src/components/editor/plugins/comment-base-kit.tsx +7 -0
- package/frontend/src/components/editor/plugins/comment-kit.tsx +97 -0
- package/frontend/src/components/editor/plugins/cursor-overlay-kit.tsx +13 -0
- package/frontend/src/components/editor/plugins/date-base-kit.tsx +5 -0
- package/frontend/src/components/editor/plugins/date-kit.tsx +7 -0
- package/frontend/src/components/editor/plugins/discussion-kit.tsx +148 -0
- package/frontend/src/components/editor/plugins/dnd-kit.tsx +28 -0
- package/frontend/src/components/editor/plugins/docx-kit.tsx +6 -0
- package/frontend/src/components/editor/plugins/emoji-kit.tsx +13 -0
- package/frontend/src/components/editor/plugins/excalidraw-kit.tsx +9 -0
- package/frontend/src/components/editor/plugins/exit-break-kit.tsx +12 -0
- package/frontend/src/components/editor/plugins/floating-toolbar-kit.tsx +19 -0
- package/frontend/src/components/editor/plugins/font-base-kit.tsx +20 -0
- package/frontend/src/components/editor/plugins/font-kit.tsx +29 -0
- package/frontend/src/components/editor/plugins/indent-base-kit.tsx +19 -0
- package/frontend/src/components/editor/plugins/indent-kit.tsx +22 -0
- package/frontend/src/components/editor/plugins/line-height-base-kit.tsx +14 -0
- package/frontend/src/components/editor/plugins/line-height-kit.tsx +16 -0
- package/frontend/src/components/editor/plugins/link-base-kit.tsx +5 -0
- package/frontend/src/components/editor/plugins/link-kit.tsx +15 -0
- package/frontend/src/components/editor/plugins/list-base-kit.tsx +23 -0
- package/frontend/src/components/editor/plugins/list-kit.tsx +26 -0
- package/frontend/src/components/editor/plugins/markdown-kit.tsx +46 -0
- package/frontend/src/components/editor/plugins/math-base-kit.tsx +11 -0
- package/frontend/src/components/editor/plugins/math-kit.tsx +13 -0
- package/frontend/src/components/editor/plugins/media-base-kit.tsx +31 -0
- package/frontend/src/components/editor/plugins/media-kit.tsx +43 -0
- package/frontend/src/components/editor/plugins/mention-base-kit.tsx +7 -0
- package/frontend/src/components/editor/plugins/mention-kit.tsx +15 -0
- package/frontend/src/components/editor/plugins/slash-kit.tsx +18 -0
- package/frontend/src/components/editor/plugins/suggestion-base-kit.tsx +7 -0
- package/frontend/src/components/editor/plugins/suggestion-kit.tsx +90 -0
- package/frontend/src/components/editor/plugins/table-base-kit.tsx +20 -0
- package/frontend/src/components/editor/plugins/table-kit.tsx +22 -0
- package/frontend/src/components/editor/plugins/toc-base-kit.tsx +5 -0
- package/frontend/src/components/editor/plugins/toc-kit.tsx +14 -0
- package/frontend/src/components/editor/plugins/toggle-base-kit.tsx +7 -0
- package/frontend/src/components/editor/plugins/toggle-kit.tsx +11 -0
- package/frontend/src/components/editor/transforms.ts +194 -0
- package/frontend/src/components/markdown-to-slate-demo.tsx +50 -0
- package/frontend/src/components/mode-toggle.tsx +15 -0
- package/frontend/src/components/theme-provider.tsx +73 -0
- package/frontend/src/components/ui/alert-dialog.tsx +155 -0
- package/frontend/src/components/ui/align-toolbar-button.tsx +84 -0
- package/frontend/src/components/ui/avatar.tsx +51 -0
- package/frontend/src/components/ui/block-context-menu.tsx +199 -0
- package/frontend/src/components/ui/block-discussion.tsx +365 -0
- package/frontend/src/components/ui/block-draggable.tsx +512 -0
- package/frontend/src/components/ui/block-list-static.tsx +80 -0
- package/frontend/src/components/ui/block-list.tsx +87 -0
- package/frontend/src/components/ui/block-selection.tsx +42 -0
- package/frontend/src/components/ui/block-suggestion.tsx +473 -0
- package/frontend/src/components/ui/blockquote-node-static.tsx +11 -0
- package/frontend/src/components/ui/blockquote-node.tsx +13 -0
- package/frontend/src/components/ui/button.tsx +62 -0
- package/frontend/src/components/ui/calendar.tsx +218 -0
- package/frontend/src/components/ui/callout-node-static.tsx +36 -0
- package/frontend/src/components/ui/callout-node.tsx +63 -0
- package/frontend/src/components/ui/caption.tsx +63 -0
- package/frontend/src/components/ui/checkbox.tsx +30 -0
- package/frontend/src/components/ui/code-block-node-static.tsx +35 -0
- package/frontend/src/components/ui/code-block-node.tsx +287 -0
- package/frontend/src/components/ui/code-node-static.tsx +15 -0
- package/frontend/src/components/ui/code-node.tsx +17 -0
- package/frontend/src/components/ui/codebase-snippet-node.tsx +237 -0
- package/frontend/src/components/ui/column-node-static.tsx +29 -0
- package/frontend/src/components/ui/column-node.tsx +317 -0
- package/frontend/src/components/ui/command.tsx +182 -0
- package/frontend/src/components/ui/comment-node-static.tsx +15 -0
- package/frontend/src/components/ui/comment-node.tsx +45 -0
- package/frontend/src/components/ui/comment-toolbar-button.tsx +24 -0
- package/frontend/src/components/ui/comment.tsx +618 -0
- package/frontend/src/components/ui/context-menu.tsx +250 -0
- package/frontend/src/components/ui/cursor-overlay.tsx +66 -0
- package/frontend/src/components/ui/date-node-static.tsx +45 -0
- package/frontend/src/components/ui/date-node.tsx +93 -0
- package/frontend/src/components/ui/dialog.tsx +143 -0
- package/frontend/src/components/ui/dropdown-menu.tsx +255 -0
- package/frontend/src/components/ui/dynamic-icon.tsx +12 -0
- package/frontend/src/components/ui/editor-static.tsx +53 -0
- package/frontend/src/components/ui/editor.tsx +130 -0
- package/frontend/src/components/ui/emoji-node.tsx +69 -0
- package/frontend/src/components/ui/emoji-toolbar-button.tsx +628 -0
- package/frontend/src/components/ui/equation-node-static.tsx +98 -0
- package/frontend/src/components/ui/equation-node.tsx +235 -0
- package/frontend/src/components/ui/equation-toolbar-button.tsx +25 -0
- package/frontend/src/components/ui/excalidraw-node.tsx +36 -0
- package/frontend/src/components/ui/export-toolbar-button.tsx +174 -0
- package/frontend/src/components/ui/file-selector.tsx +339 -0
- package/frontend/src/components/ui/floating-toolbar-buttons.tsx +73 -0
- package/frontend/src/components/ui/floating-toolbar.tsx +85 -0
- package/frontend/src/components/ui/font-color-toolbar-button.tsx +831 -0
- package/frontend/src/components/ui/font-size-toolbar-button.tsx +152 -0
- package/frontend/src/components/ui/heading-node-static.tsx +68 -0
- package/frontend/src/components/ui/heading-node.tsx +58 -0
- package/frontend/src/components/ui/highlight-node-static.tsx +11 -0
- package/frontend/src/components/ui/highlight-node.tsx +13 -0
- package/frontend/src/components/ui/history-toolbar-button.tsx +50 -0
- package/frontend/src/components/ui/hr-node-static.tsx +20 -0
- package/frontend/src/components/ui/hr-node.tsx +33 -0
- package/frontend/src/components/ui/import-toolbar-button.tsx +97 -0
- package/frontend/src/components/ui/indent-toolbar-button.tsx +30 -0
- package/frontend/src/components/ui/inline-combobox.tsx +414 -0
- package/frontend/src/components/ui/input.tsx +21 -0
- package/frontend/src/components/ui/insert-toolbar-button.tsx +254 -0
- package/frontend/src/components/ui/kbd-node-static.tsx +15 -0
- package/frontend/src/components/ui/kbd-node.tsx +17 -0
- package/frontend/src/components/ui/layout-header.tsx +35 -0
- package/frontend/src/components/ui/line-height-toolbar-button.tsx +68 -0
- package/frontend/src/components/ui/link-node-static.tsx +21 -0
- package/frontend/src/components/ui/link-node.tsx +39 -0
- package/frontend/src/components/ui/link-toolbar-button.tsx +22 -0
- package/frontend/src/components/ui/link-toolbar.tsx +206 -0
- package/frontend/src/components/ui/list-toolbar-button.tsx +204 -0
- package/frontend/src/components/ui/mark-toolbar-button.tsx +19 -0
- package/frontend/src/components/ui/media-audio-node-static.tsx +17 -0
- package/frontend/src/components/ui/media-audio-node.tsx +39 -0
- package/frontend/src/components/ui/media-embed-node.tsx +136 -0
- package/frontend/src/components/ui/media-file-node-static.tsx +29 -0
- package/frontend/src/components/ui/media-file-node.tsx +47 -0
- package/frontend/src/components/ui/media-image-node-static.tsx +39 -0
- package/frontend/src/components/ui/media-image-node.tsx +80 -0
- package/frontend/src/components/ui/media-placeholder-node.tsx +249 -0
- package/frontend/src/components/ui/media-preview-dialog.tsx +152 -0
- package/frontend/src/components/ui/media-toolbar-button.tsx +225 -0
- package/frontend/src/components/ui/media-toolbar.tsx +115 -0
- package/frontend/src/components/ui/media-upload-toast.tsx +66 -0
- package/frontend/src/components/ui/media-video-node-static.tsx +30 -0
- package/frontend/src/components/ui/media-video-node.tsx +121 -0
- package/frontend/src/components/ui/mention-node-static.tsx +36 -0
- package/frontend/src/components/ui/mention-node.tsx +194 -0
- package/frontend/src/components/ui/mode-toolbar-button.tsx +123 -0
- package/frontend/src/components/ui/more-toolbar-button.tsx +80 -0
- package/frontend/src/components/ui/paragraph-node-static.tsx +13 -0
- package/frontend/src/components/ui/paragraph-node.tsx +15 -0
- package/frontend/src/components/ui/popover.tsx +46 -0
- package/frontend/src/components/ui/resize-handle.tsx +87 -0
- package/frontend/src/components/ui/separator.tsx +28 -0
- package/frontend/src/components/ui/sheet.tsx +139 -0
- package/frontend/src/components/ui/sidebar.tsx +726 -0
- package/frontend/src/components/ui/skeleton.tsx +13 -0
- package/frontend/src/components/ui/slash-node.tsx +233 -0
- package/frontend/src/components/ui/sonner.tsx +38 -0
- package/frontend/src/components/ui/suggestion-node-static.tsx +35 -0
- package/frontend/src/components/ui/suggestion-node.tsx +162 -0
- package/frontend/src/components/ui/suggestion-toolbar-button.tsx +25 -0
- package/frontend/src/components/ui/table-icons.tsx +862 -0
- package/frontend/src/components/ui/table-node-static.tsx +98 -0
- package/frontend/src/components/ui/table-node.tsx +656 -0
- package/frontend/src/components/ui/table-toolbar-button.tsx +264 -0
- package/frontend/src/components/ui/toc-node-static.tsx +92 -0
- package/frontend/src/components/ui/toc-node.tsx +55 -0
- package/frontend/src/components/ui/toggle-node-static.tsx +18 -0
- package/frontend/src/components/ui/toggle-node.tsx +36 -0
- package/frontend/src/components/ui/toggle-toolbar-button.tsx +22 -0
- package/frontend/src/components/ui/toolbar.tsx +387 -0
- package/frontend/src/components/ui/tooltip.tsx +59 -0
- package/frontend/src/components/ui/turn-into-toolbar-button.tsx +188 -0
- package/frontend/src/hooks/use-debounce.ts +18 -0
- package/frontend/src/hooks/use-is-touch-device.ts +24 -0
- package/frontend/src/hooks/use-mobile.ts +19 -0
- package/frontend/src/hooks/use-mounted.ts +11 -0
- package/frontend/src/hooks/use-upload-file.ts +128 -0
- package/frontend/src/index.css +128 -0
- package/frontend/src/layout.tsx +42 -0
- package/frontend/src/lib/markdown-joiner-transform.ts +239 -0
- package/frontend/src/lib/orpc.ts +13 -0
- package/frontend/src/lib/uploadthing.ts +19 -0
- package/frontend/src/lib/utils.ts +6 -0
- package/frontend/src/main.tsx +13 -0
- package/frontend/src/pages/editor.tsx +44 -0
- package/frontend/src/types/docs.d.ts +6 -0
- package/frontend/src/types/global.d.ts +9 -0
- package/frontend/src/types/router.d.ts +4 -0
- package/frontend/tsconfig.app.json +33 -0
- package/frontend/tsconfig.json +10 -0
- package/frontend/tsconfig.node.json +26 -0
- package/frontend/vite.config.ts +14 -0
- package/package.json +30 -0
- package/src/bin/doclific.ts +17 -0
- package/src/core/codebase.ts +39 -0
- package/src/core/docs.ts +90 -0
- package/src/core/git.ts +48 -0
- package/src/server/index.ts +55 -0
- package/src/server/router.ts +65 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { ExtendConfig, Path } from 'platejs';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
type BaseCommentConfig,
|
|
7
|
+
BaseCommentPlugin,
|
|
8
|
+
getDraftCommentKey,
|
|
9
|
+
} from '@platejs/comment';
|
|
10
|
+
import { isSlateString } from 'platejs';
|
|
11
|
+
import { toTPlatePlugin } from 'platejs/react';
|
|
12
|
+
|
|
13
|
+
import { CommentLeaf } from '@/components/ui/comment-node';
|
|
14
|
+
|
|
15
|
+
type CommentConfig = ExtendConfig<
|
|
16
|
+
BaseCommentConfig,
|
|
17
|
+
{
|
|
18
|
+
activeId: string | null;
|
|
19
|
+
commentingBlock: Path | null;
|
|
20
|
+
hoverId: string | null;
|
|
21
|
+
uniquePathMap: Map<string, Path>;
|
|
22
|
+
}
|
|
23
|
+
>;
|
|
24
|
+
|
|
25
|
+
export const commentPlugin = toTPlatePlugin<CommentConfig>(BaseCommentPlugin, {
|
|
26
|
+
handlers: {
|
|
27
|
+
onClick: ({ api, event, setOption, type }) => {
|
|
28
|
+
let leaf = event.target as HTMLElement;
|
|
29
|
+
let isSet = false;
|
|
30
|
+
|
|
31
|
+
const unsetActiveSuggestion = () => {
|
|
32
|
+
setOption('activeId', null);
|
|
33
|
+
isSet = true;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
if (!isSlateString(leaf)) unsetActiveSuggestion();
|
|
37
|
+
|
|
38
|
+
while (leaf.parentElement) {
|
|
39
|
+
if (leaf.classList.contains(`slate-${type}`)) {
|
|
40
|
+
const commentsEntry = api.comment!.node();
|
|
41
|
+
|
|
42
|
+
if (!commentsEntry) {
|
|
43
|
+
unsetActiveSuggestion();
|
|
44
|
+
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const id = api.comment!.nodeId(commentsEntry[0]);
|
|
49
|
+
|
|
50
|
+
setOption('activeId', id ?? null);
|
|
51
|
+
isSet = true;
|
|
52
|
+
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
leaf = leaf.parentElement;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (!isSet) unsetActiveSuggestion();
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
options: {
|
|
63
|
+
activeId: null,
|
|
64
|
+
commentingBlock: null,
|
|
65
|
+
hoverId: null,
|
|
66
|
+
uniquePathMap: new Map(),
|
|
67
|
+
},
|
|
68
|
+
})
|
|
69
|
+
.extendTransforms(
|
|
70
|
+
({
|
|
71
|
+
editor,
|
|
72
|
+
setOption,
|
|
73
|
+
tf: {
|
|
74
|
+
comment: { setDraft },
|
|
75
|
+
},
|
|
76
|
+
}) => ({
|
|
77
|
+
setDraft: () => {
|
|
78
|
+
if (editor.api.isCollapsed()) {
|
|
79
|
+
editor.tf.select(editor.api.block()![1]);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
setDraft();
|
|
83
|
+
|
|
84
|
+
editor.tf.collapse();
|
|
85
|
+
setOption('activeId', getDraftCommentKey());
|
|
86
|
+
setOption('commentingBlock', editor.selection!.focus.path.slice(0, 1));
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
)
|
|
90
|
+
.configure({
|
|
91
|
+
node: { component: CommentLeaf },
|
|
92
|
+
shortcuts: {
|
|
93
|
+
setDraft: { keys: 'mod+shift+m' },
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
export const CommentKit = [commentPlugin];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { CursorOverlayPlugin } from '@platejs/selection/react';
|
|
4
|
+
|
|
5
|
+
import { CursorOverlay } from '@/components/ui/cursor-overlay';
|
|
6
|
+
|
|
7
|
+
export const CursorOverlayKit = [
|
|
8
|
+
CursorOverlayPlugin.configure({
|
|
9
|
+
render: {
|
|
10
|
+
afterEditable: () => <CursorOverlay />,
|
|
11
|
+
},
|
|
12
|
+
}),
|
|
13
|
+
];
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { TComment } from '@/components/ui/comment';
|
|
4
|
+
|
|
5
|
+
import { createPlatePlugin } from 'platejs/react';
|
|
6
|
+
|
|
7
|
+
import { BlockDiscussion } from '@/components/ui/block-discussion';
|
|
8
|
+
|
|
9
|
+
export type TDiscussion = {
|
|
10
|
+
id: string;
|
|
11
|
+
comments: TComment[];
|
|
12
|
+
createdAt: Date;
|
|
13
|
+
isResolved: boolean;
|
|
14
|
+
userId: string;
|
|
15
|
+
documentContent?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const discussionsData: TDiscussion[] = [
|
|
19
|
+
{
|
|
20
|
+
id: 'discussion1',
|
|
21
|
+
comments: [
|
|
22
|
+
{
|
|
23
|
+
id: 'comment1',
|
|
24
|
+
contentRich: [
|
|
25
|
+
{
|
|
26
|
+
children: [
|
|
27
|
+
{
|
|
28
|
+
text: 'Comments are a great way to provide feedback and discuss changes.',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
type: 'p',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
createdAt: new Date(Date.now() - 600_000),
|
|
35
|
+
discussionId: 'discussion1',
|
|
36
|
+
isEdited: false,
|
|
37
|
+
userId: 'charlie',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: 'comment2',
|
|
41
|
+
contentRich: [
|
|
42
|
+
{
|
|
43
|
+
children: [
|
|
44
|
+
{
|
|
45
|
+
text: 'Agreed! The link to the docs makes it easy to learn more.',
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
type: 'p',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
createdAt: new Date(Date.now() - 500_000),
|
|
52
|
+
discussionId: 'discussion1',
|
|
53
|
+
isEdited: false,
|
|
54
|
+
userId: 'bob',
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
createdAt: new Date(),
|
|
58
|
+
documentContent: 'comments',
|
|
59
|
+
isResolved: false,
|
|
60
|
+
userId: 'charlie',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: 'discussion2',
|
|
64
|
+
comments: [
|
|
65
|
+
{
|
|
66
|
+
id: 'comment1',
|
|
67
|
+
contentRich: [
|
|
68
|
+
{
|
|
69
|
+
children: [
|
|
70
|
+
{
|
|
71
|
+
text: 'Nice demonstration of overlapping annotations with both comments and suggestions!',
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
type: 'p',
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
createdAt: new Date(Date.now() - 300_000),
|
|
78
|
+
discussionId: 'discussion2',
|
|
79
|
+
isEdited: false,
|
|
80
|
+
userId: 'bob',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
id: 'comment2',
|
|
84
|
+
contentRich: [
|
|
85
|
+
{
|
|
86
|
+
children: [
|
|
87
|
+
{
|
|
88
|
+
text: 'This helps users understand how powerful the editor can be.',
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
type: 'p',
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
createdAt: new Date(Date.now() - 200_000),
|
|
95
|
+
discussionId: 'discussion2',
|
|
96
|
+
isEdited: false,
|
|
97
|
+
userId: 'charlie',
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
createdAt: new Date(),
|
|
101
|
+
documentContent: 'overlapping',
|
|
102
|
+
isResolved: false,
|
|
103
|
+
userId: 'bob',
|
|
104
|
+
},
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
const avatarUrl = (seed: string) =>
|
|
108
|
+
`https://api.dicebear.com/9.x/glass/svg?seed=${seed}`;
|
|
109
|
+
|
|
110
|
+
const usersData: Record<
|
|
111
|
+
string,
|
|
112
|
+
{ id: string; avatarUrl: string; name: string; hue?: number }
|
|
113
|
+
> = {
|
|
114
|
+
alice: {
|
|
115
|
+
id: 'alice',
|
|
116
|
+
avatarUrl: avatarUrl('alice6'),
|
|
117
|
+
name: 'Alice',
|
|
118
|
+
},
|
|
119
|
+
bob: {
|
|
120
|
+
id: 'bob',
|
|
121
|
+
avatarUrl: avatarUrl('bob4'),
|
|
122
|
+
name: 'Bob',
|
|
123
|
+
},
|
|
124
|
+
charlie: {
|
|
125
|
+
id: 'charlie',
|
|
126
|
+
avatarUrl: avatarUrl('charlie2'),
|
|
127
|
+
name: 'Charlie',
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// This plugin is purely UI. It's only used to store the discussions and users data
|
|
132
|
+
export const discussionPlugin = createPlatePlugin({
|
|
133
|
+
key: 'discussion',
|
|
134
|
+
options: {
|
|
135
|
+
currentUserId: 'alice',
|
|
136
|
+
discussions: discussionsData,
|
|
137
|
+
users: usersData,
|
|
138
|
+
},
|
|
139
|
+
})
|
|
140
|
+
.configure({
|
|
141
|
+
render: { aboveNodes: BlockDiscussion },
|
|
142
|
+
})
|
|
143
|
+
.extendSelectors(({ getOption }) => ({
|
|
144
|
+
currentUser: () => getOption('users')[getOption('currentUserId')],
|
|
145
|
+
user: (id: string) => getOption('users')[id],
|
|
146
|
+
}));
|
|
147
|
+
|
|
148
|
+
export const DiscussionKit = [discussionPlugin];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { DndProvider } from 'react-dnd';
|
|
4
|
+
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
5
|
+
|
|
6
|
+
import { DndPlugin } from '@platejs/dnd';
|
|
7
|
+
import { PlaceholderPlugin } from '@platejs/media/react';
|
|
8
|
+
|
|
9
|
+
import { BlockDraggable } from '@/components/ui/block-draggable';
|
|
10
|
+
|
|
11
|
+
export const DndKit = [
|
|
12
|
+
DndPlugin.configure({
|
|
13
|
+
options: {
|
|
14
|
+
enableScroller: true,
|
|
15
|
+
onDropFiles: ({ dragItem, editor, target }) => {
|
|
16
|
+
editor
|
|
17
|
+
.getTransforms(PlaceholderPlugin)
|
|
18
|
+
.insert.media(dragItem.files, { at: target, nextBlock: false });
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
render: {
|
|
22
|
+
aboveNodes: BlockDraggable,
|
|
23
|
+
aboveSlate: ({ children }) => (
|
|
24
|
+
<DndProvider backend={HTML5Backend}>{children}</DndProvider>
|
|
25
|
+
),
|
|
26
|
+
},
|
|
27
|
+
}),
|
|
28
|
+
];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import emojiMartData from '@emoji-mart/data';
|
|
4
|
+
import { EmojiInputPlugin, EmojiPlugin } from '@platejs/emoji/react';
|
|
5
|
+
|
|
6
|
+
import { EmojiInputElement } from '@/components/ui/emoji-node';
|
|
7
|
+
|
|
8
|
+
export const EmojiKit = [
|
|
9
|
+
EmojiPlugin.configure({
|
|
10
|
+
options: { data: emojiMartData as any },
|
|
11
|
+
}),
|
|
12
|
+
EmojiInputPlugin.withComponent(EmojiInputElement),
|
|
13
|
+
];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { createPlatePlugin } from 'platejs/react';
|
|
4
|
+
|
|
5
|
+
import { FloatingToolbar } from '@/components/ui/floating-toolbar';
|
|
6
|
+
import { FloatingToolbarButtons } from '@/components/ui/floating-toolbar-buttons';
|
|
7
|
+
|
|
8
|
+
export const FloatingToolbarKit = [
|
|
9
|
+
createPlatePlugin({
|
|
10
|
+
key: 'floating-toolbar',
|
|
11
|
+
render: {
|
|
12
|
+
afterEditable: () => (
|
|
13
|
+
<FloatingToolbar>
|
|
14
|
+
<FloatingToolbarButtons />
|
|
15
|
+
</FloatingToolbar>
|
|
16
|
+
),
|
|
17
|
+
},
|
|
18
|
+
}),
|
|
19
|
+
];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SlatePluginConfig } from 'platejs';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
BaseFontBackgroundColorPlugin,
|
|
5
|
+
BaseFontColorPlugin,
|
|
6
|
+
BaseFontFamilyPlugin,
|
|
7
|
+
BaseFontSizePlugin,
|
|
8
|
+
} from '@platejs/basic-styles';
|
|
9
|
+
import { KEYS } from 'platejs';
|
|
10
|
+
|
|
11
|
+
const options = {
|
|
12
|
+
inject: { targetPlugins: [KEYS.p] },
|
|
13
|
+
} satisfies SlatePluginConfig;
|
|
14
|
+
|
|
15
|
+
export const BaseFontKit = [
|
|
16
|
+
BaseFontColorPlugin.configure(options),
|
|
17
|
+
BaseFontBackgroundColorPlugin.configure(options),
|
|
18
|
+
BaseFontSizePlugin.configure(options),
|
|
19
|
+
BaseFontFamilyPlugin.configure(options),
|
|
20
|
+
];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { PlatePluginConfig } from 'platejs/react';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
FontBackgroundColorPlugin,
|
|
7
|
+
FontColorPlugin,
|
|
8
|
+
FontFamilyPlugin,
|
|
9
|
+
FontSizePlugin,
|
|
10
|
+
} from '@platejs/basic-styles/react';
|
|
11
|
+
import { KEYS } from 'platejs';
|
|
12
|
+
|
|
13
|
+
const options = {
|
|
14
|
+
inject: { targetPlugins: [KEYS.p] },
|
|
15
|
+
} satisfies PlatePluginConfig;
|
|
16
|
+
|
|
17
|
+
export const FontKit = [
|
|
18
|
+
FontColorPlugin.configure({
|
|
19
|
+
inject: {
|
|
20
|
+
...options.inject,
|
|
21
|
+
nodeProps: {
|
|
22
|
+
defaultNodeValue: 'black',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
26
|
+
FontBackgroundColorPlugin.configure(options),
|
|
27
|
+
FontSizePlugin.configure(options),
|
|
28
|
+
FontFamilyPlugin.configure(options),
|
|
29
|
+
];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseIndentPlugin } from '@platejs/indent';
|
|
2
|
+
import { KEYS } from 'platejs';
|
|
3
|
+
|
|
4
|
+
export const BaseIndentKit = [
|
|
5
|
+
BaseIndentPlugin.configure({
|
|
6
|
+
inject: {
|
|
7
|
+
targetPlugins: [
|
|
8
|
+
...KEYS.heading,
|
|
9
|
+
KEYS.p,
|
|
10
|
+
KEYS.blockquote,
|
|
11
|
+
KEYS.codeBlock,
|
|
12
|
+
KEYS.toggle,
|
|
13
|
+
],
|
|
14
|
+
},
|
|
15
|
+
options: {
|
|
16
|
+
offset: 24,
|
|
17
|
+
},
|
|
18
|
+
}),
|
|
19
|
+
];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { IndentPlugin } from '@platejs/indent/react';
|
|
4
|
+
import { KEYS } from 'platejs';
|
|
5
|
+
|
|
6
|
+
export const IndentKit = [
|
|
7
|
+
IndentPlugin.configure({
|
|
8
|
+
inject: {
|
|
9
|
+
targetPlugins: [
|
|
10
|
+
...KEYS.heading,
|
|
11
|
+
KEYS.p,
|
|
12
|
+
KEYS.blockquote,
|
|
13
|
+
KEYS.codeBlock,
|
|
14
|
+
KEYS.toggle,
|
|
15
|
+
KEYS.img,
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
options: {
|
|
19
|
+
offset: 24,
|
|
20
|
+
},
|
|
21
|
+
}),
|
|
22
|
+
];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseLineHeightPlugin } from '@platejs/basic-styles';
|
|
2
|
+
import { KEYS } from 'platejs';
|
|
3
|
+
|
|
4
|
+
export const BaseLineHeightKit = [
|
|
5
|
+
BaseLineHeightPlugin.configure({
|
|
6
|
+
inject: {
|
|
7
|
+
nodeProps: {
|
|
8
|
+
defaultNodeValue: 1.5,
|
|
9
|
+
validNodeValues: [1, 1.2, 1.5, 2, 3],
|
|
10
|
+
},
|
|
11
|
+
targetPlugins: [...KEYS.heading, KEYS.p],
|
|
12
|
+
},
|
|
13
|
+
}),
|
|
14
|
+
];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { LineHeightPlugin } from '@platejs/basic-styles/react';
|
|
4
|
+
import { KEYS } from 'platejs';
|
|
5
|
+
|
|
6
|
+
export const LineHeightKit = [
|
|
7
|
+
LineHeightPlugin.configure({
|
|
8
|
+
inject: {
|
|
9
|
+
nodeProps: {
|
|
10
|
+
defaultNodeValue: 1.5,
|
|
11
|
+
validNodeValues: [1, 1.2, 1.5, 2, 3],
|
|
12
|
+
},
|
|
13
|
+
targetPlugins: [...KEYS.heading, KEYS.p],
|
|
14
|
+
},
|
|
15
|
+
}),
|
|
16
|
+
];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { LinkPlugin } from '@platejs/link/react';
|
|
4
|
+
|
|
5
|
+
import { LinkElement } from '@/components/ui/link-node';
|
|
6
|
+
import { LinkFloatingToolbar } from '@/components/ui/link-toolbar';
|
|
7
|
+
|
|
8
|
+
export const LinkKit = [
|
|
9
|
+
LinkPlugin.configure({
|
|
10
|
+
render: {
|
|
11
|
+
node: LinkElement,
|
|
12
|
+
afterEditable: () => <LinkFloatingToolbar />,
|
|
13
|
+
},
|
|
14
|
+
}),
|
|
15
|
+
];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BaseListPlugin } from '@platejs/list';
|
|
2
|
+
import { KEYS } from 'platejs';
|
|
3
|
+
|
|
4
|
+
import { BaseIndentKit } from '@/components/editor/plugins/indent-base-kit';
|
|
5
|
+
import { BlockListStatic } from '@/components/ui/block-list-static';
|
|
6
|
+
|
|
7
|
+
export const BaseListKit = [
|
|
8
|
+
...BaseIndentKit,
|
|
9
|
+
BaseListPlugin.configure({
|
|
10
|
+
inject: {
|
|
11
|
+
targetPlugins: [
|
|
12
|
+
...KEYS.heading,
|
|
13
|
+
KEYS.p,
|
|
14
|
+
KEYS.blockquote,
|
|
15
|
+
KEYS.codeBlock,
|
|
16
|
+
KEYS.toggle,
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
render: {
|
|
20
|
+
belowNodes: BlockListStatic,
|
|
21
|
+
},
|
|
22
|
+
}),
|
|
23
|
+
];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { ListPlugin } from '@platejs/list/react';
|
|
4
|
+
import { KEYS } from 'platejs';
|
|
5
|
+
|
|
6
|
+
import { IndentKit } from '@/components/editor/plugins/indent-kit';
|
|
7
|
+
import { BlockList } from '@/components/ui/block-list';
|
|
8
|
+
|
|
9
|
+
export const ListKit = [
|
|
10
|
+
...IndentKit,
|
|
11
|
+
ListPlugin.configure({
|
|
12
|
+
inject: {
|
|
13
|
+
targetPlugins: [
|
|
14
|
+
...KEYS.heading,
|
|
15
|
+
KEYS.p,
|
|
16
|
+
KEYS.blockquote,
|
|
17
|
+
KEYS.codeBlock,
|
|
18
|
+
KEYS.toggle,
|
|
19
|
+
KEYS.img,
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
render: {
|
|
23
|
+
belowNodes: BlockList,
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
26
|
+
];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { MarkdownPlugin, remarkMdx, remarkMention } from '@platejs/markdown';
|
|
2
|
+
import { KEYS } from 'platejs';
|
|
3
|
+
import remarkGfm from 'remark-gfm';
|
|
4
|
+
import remarkMath from 'remark-math';
|
|
5
|
+
import { CodebaseSnippetType } from './codebase-kit';
|
|
6
|
+
|
|
7
|
+
export const MarkdownKit = [
|
|
8
|
+
MarkdownPlugin.configure({
|
|
9
|
+
options: {
|
|
10
|
+
plainMarks: [KEYS.suggestion, KEYS.comment],
|
|
11
|
+
remarkPlugins: [remarkMath, remarkGfm, remarkMdx, remarkMention],
|
|
12
|
+
rules: {
|
|
13
|
+
[CodebaseSnippetType]: {
|
|
14
|
+
serialize: (slateNode) => {
|
|
15
|
+
return {
|
|
16
|
+
type: 'mdxJsxFlowElement',
|
|
17
|
+
name: 'CodebaseSnippet', // MDX tag name
|
|
18
|
+
attributes: [
|
|
19
|
+
{ type: 'mdxJsxAttribute', name: 'filePath', value: slateNode.filePath || '' },
|
|
20
|
+
{ type: 'mdxJsxAttribute', name: 'lineStart', value: slateNode.lineStart || '' },
|
|
21
|
+
{ type: 'mdxJsxAttribute', name: 'lineEnd', value: slateNode.lineEnd || '' },
|
|
22
|
+
],
|
|
23
|
+
children: [{ type: 'text', value: '' }],
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
deserialize: (mdastNode) => {
|
|
27
|
+
// Extract attributes from the mdast node
|
|
28
|
+
const getAttr = (name: string) => {
|
|
29
|
+
const attr = mdastNode.attributes?.find((a: { name: string }) => a.name === name);
|
|
30
|
+
return attr?.value || '';
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// Return a Slate node structure
|
|
34
|
+
return {
|
|
35
|
+
type: CodebaseSnippetType,
|
|
36
|
+
filePath: getAttr('filePath'),
|
|
37
|
+
lineStart: getAttr('lineStart'),
|
|
38
|
+
lineEnd: getAttr('lineEnd'),
|
|
39
|
+
children: [{ text: '' }], // Required for void elements
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseEquationPlugin, BaseInlineEquationPlugin } from '@platejs/math';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
EquationElementStatic,
|
|
5
|
+
InlineEquationElementStatic,
|
|
6
|
+
} from '@/components/ui/equation-node-static';
|
|
7
|
+
|
|
8
|
+
export const BaseMathKit = [
|
|
9
|
+
BaseInlineEquationPlugin.withComponent(InlineEquationElementStatic),
|
|
10
|
+
BaseEquationPlugin.withComponent(EquationElementStatic),
|
|
11
|
+
];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { EquationPlugin, InlineEquationPlugin } from '@platejs/math/react';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
EquationElement,
|
|
7
|
+
InlineEquationElement,
|
|
8
|
+
} from '@/components/ui/equation-node';
|
|
9
|
+
|
|
10
|
+
export const MathKit = [
|
|
11
|
+
InlineEquationPlugin.withComponent(InlineEquationElement),
|
|
12
|
+
EquationPlugin.withComponent(EquationElement),
|
|
13
|
+
];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BaseCaptionPlugin } from '@platejs/caption';
|
|
2
|
+
import {
|
|
3
|
+
BaseAudioPlugin,
|
|
4
|
+
BaseFilePlugin,
|
|
5
|
+
BaseImagePlugin,
|
|
6
|
+
BaseMediaEmbedPlugin,
|
|
7
|
+
BasePlaceholderPlugin,
|
|
8
|
+
BaseVideoPlugin,
|
|
9
|
+
} from '@platejs/media';
|
|
10
|
+
import { KEYS } from 'platejs';
|
|
11
|
+
|
|
12
|
+
import { AudioElementStatic } from '@/components/ui/media-audio-node-static';
|
|
13
|
+
import { FileElementStatic } from '@/components/ui/media-file-node-static';
|
|
14
|
+
import { ImageElementStatic } from '@/components/ui/media-image-node-static';
|
|
15
|
+
import { VideoElementStatic } from '@/components/ui/media-video-node-static';
|
|
16
|
+
|
|
17
|
+
export const BaseMediaKit = [
|
|
18
|
+
BaseImagePlugin.withComponent(ImageElementStatic),
|
|
19
|
+
BaseVideoPlugin.withComponent(VideoElementStatic),
|
|
20
|
+
BaseAudioPlugin.withComponent(AudioElementStatic),
|
|
21
|
+
BaseFilePlugin.withComponent(FileElementStatic),
|
|
22
|
+
BaseCaptionPlugin.configure({
|
|
23
|
+
options: {
|
|
24
|
+
query: {
|
|
25
|
+
allow: [KEYS.img, KEYS.video, KEYS.audio, KEYS.file, KEYS.mediaEmbed],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
BaseMediaEmbedPlugin,
|
|
30
|
+
BasePlaceholderPlugin,
|
|
31
|
+
];
|