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,236 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { AutoformatRule } from '@platejs/autoformat';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
autoformatArrow,
|
|
7
|
+
autoformatLegal,
|
|
8
|
+
autoformatLegalHtml,
|
|
9
|
+
autoformatMath,
|
|
10
|
+
AutoformatPlugin,
|
|
11
|
+
autoformatPunctuation,
|
|
12
|
+
autoformatSmartQuotes,
|
|
13
|
+
} from '@platejs/autoformat';
|
|
14
|
+
import { insertEmptyCodeBlock } from '@platejs/code-block';
|
|
15
|
+
import { toggleList } from '@platejs/list';
|
|
16
|
+
import { KEYS } from 'platejs';
|
|
17
|
+
|
|
18
|
+
const autoformatMarks: AutoformatRule[] = [
|
|
19
|
+
{
|
|
20
|
+
match: '***',
|
|
21
|
+
mode: 'mark',
|
|
22
|
+
type: [KEYS.bold, KEYS.italic],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
match: '__*',
|
|
26
|
+
mode: 'mark',
|
|
27
|
+
type: [KEYS.underline, KEYS.italic],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
match: '__**',
|
|
31
|
+
mode: 'mark',
|
|
32
|
+
type: [KEYS.underline, KEYS.bold],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
match: '___***',
|
|
36
|
+
mode: 'mark',
|
|
37
|
+
type: [KEYS.underline, KEYS.bold, KEYS.italic],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
match: '**',
|
|
41
|
+
mode: 'mark',
|
|
42
|
+
type: KEYS.bold,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
match: '__',
|
|
46
|
+
mode: 'mark',
|
|
47
|
+
type: KEYS.underline,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
match: '*',
|
|
51
|
+
mode: 'mark',
|
|
52
|
+
type: KEYS.italic,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
match: '_',
|
|
56
|
+
mode: 'mark',
|
|
57
|
+
type: KEYS.italic,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
match: '~~',
|
|
61
|
+
mode: 'mark',
|
|
62
|
+
type: KEYS.strikethrough,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
match: '^',
|
|
66
|
+
mode: 'mark',
|
|
67
|
+
type: KEYS.sup,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
match: '~',
|
|
71
|
+
mode: 'mark',
|
|
72
|
+
type: KEYS.sub,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
match: '==',
|
|
76
|
+
mode: 'mark',
|
|
77
|
+
type: KEYS.highlight,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
match: '≡',
|
|
81
|
+
mode: 'mark',
|
|
82
|
+
type: KEYS.highlight,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
match: '`',
|
|
86
|
+
mode: 'mark',
|
|
87
|
+
type: KEYS.code,
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
const autoformatBlocks: AutoformatRule[] = [
|
|
92
|
+
{
|
|
93
|
+
match: '# ',
|
|
94
|
+
mode: 'block',
|
|
95
|
+
type: KEYS.h1,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
match: '## ',
|
|
99
|
+
mode: 'block',
|
|
100
|
+
type: KEYS.h2,
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
match: '### ',
|
|
104
|
+
mode: 'block',
|
|
105
|
+
type: KEYS.h3,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
match: '#### ',
|
|
109
|
+
mode: 'block',
|
|
110
|
+
type: KEYS.h4,
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
match: '##### ',
|
|
114
|
+
mode: 'block',
|
|
115
|
+
type: KEYS.h5,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
match: '###### ',
|
|
119
|
+
mode: 'block',
|
|
120
|
+
type: KEYS.h6,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
match: '> ',
|
|
124
|
+
mode: 'block',
|
|
125
|
+
type: KEYS.blockquote,
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
match: '```',
|
|
129
|
+
mode: 'block',
|
|
130
|
+
type: KEYS.codeBlock,
|
|
131
|
+
format: (editor) => {
|
|
132
|
+
insertEmptyCodeBlock(editor, {
|
|
133
|
+
defaultType: KEYS.p,
|
|
134
|
+
insertNodesOptions: { select: true },
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
// {
|
|
139
|
+
// match: '+ ',
|
|
140
|
+
// mode: 'block',
|
|
141
|
+
// preFormat: openNextToggles,
|
|
142
|
+
// type: KEYS.toggle,
|
|
143
|
+
// },
|
|
144
|
+
{
|
|
145
|
+
match: ['---', '—-', '___ '],
|
|
146
|
+
mode: 'block',
|
|
147
|
+
type: KEYS.hr,
|
|
148
|
+
format: (editor) => {
|
|
149
|
+
editor.tf.setNodes({ type: KEYS.hr });
|
|
150
|
+
editor.tf.insertNodes({
|
|
151
|
+
children: [{ text: '' }],
|
|
152
|
+
type: KEYS.p,
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
];
|
|
157
|
+
|
|
158
|
+
const autoformatLists: AutoformatRule[] = [
|
|
159
|
+
{
|
|
160
|
+
match: ['* ', '- '],
|
|
161
|
+
mode: 'block',
|
|
162
|
+
type: 'list',
|
|
163
|
+
format: (editor) => {
|
|
164
|
+
toggleList(editor, {
|
|
165
|
+
listStyleType: KEYS.ul,
|
|
166
|
+
});
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
match: [String.raw`^\d+\.$ `, String.raw`^\d+\)$ `],
|
|
171
|
+
matchByRegex: true,
|
|
172
|
+
mode: 'block',
|
|
173
|
+
type: 'list',
|
|
174
|
+
format: (editor, { matchString }) => {
|
|
175
|
+
toggleList(editor, {
|
|
176
|
+
listRestartPolite: Number(matchString) || 1,
|
|
177
|
+
listStyleType: KEYS.ol,
|
|
178
|
+
});
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
match: ['[] '],
|
|
183
|
+
mode: 'block',
|
|
184
|
+
type: 'list',
|
|
185
|
+
format: (editor) => {
|
|
186
|
+
toggleList(editor, {
|
|
187
|
+
listStyleType: KEYS.listTodo,
|
|
188
|
+
});
|
|
189
|
+
editor.tf.setNodes({
|
|
190
|
+
checked: false,
|
|
191
|
+
listStyleType: KEYS.listTodo,
|
|
192
|
+
});
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
match: ['[x] '],
|
|
197
|
+
mode: 'block',
|
|
198
|
+
type: 'list',
|
|
199
|
+
format: (editor) => {
|
|
200
|
+
toggleList(editor, {
|
|
201
|
+
listStyleType: KEYS.listTodo,
|
|
202
|
+
});
|
|
203
|
+
editor.tf.setNodes({
|
|
204
|
+
checked: true,
|
|
205
|
+
listStyleType: KEYS.listTodo,
|
|
206
|
+
});
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
];
|
|
210
|
+
|
|
211
|
+
export const AutoformatKit = [
|
|
212
|
+
AutoformatPlugin.configure({
|
|
213
|
+
options: {
|
|
214
|
+
enableUndoOnDelete: true,
|
|
215
|
+
rules: [
|
|
216
|
+
...autoformatBlocks,
|
|
217
|
+
...autoformatMarks,
|
|
218
|
+
...autoformatSmartQuotes,
|
|
219
|
+
...autoformatPunctuation,
|
|
220
|
+
...autoformatLegal,
|
|
221
|
+
...autoformatLegalHtml,
|
|
222
|
+
...autoformatArrow,
|
|
223
|
+
...autoformatMath,
|
|
224
|
+
...autoformatLists,
|
|
225
|
+
].map(
|
|
226
|
+
(rule): AutoformatRule => ({
|
|
227
|
+
...rule,
|
|
228
|
+
query: (editor) =>
|
|
229
|
+
!editor.api.some({
|
|
230
|
+
match: { type: editor.getType(KEYS.codeBlock) },
|
|
231
|
+
}),
|
|
232
|
+
})
|
|
233
|
+
),
|
|
234
|
+
},
|
|
235
|
+
}),
|
|
236
|
+
];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseBlockquotePlugin,
|
|
3
|
+
BaseH1Plugin,
|
|
4
|
+
BaseH2Plugin,
|
|
5
|
+
BaseH3Plugin,
|
|
6
|
+
BaseH4Plugin,
|
|
7
|
+
BaseH5Plugin,
|
|
8
|
+
BaseH6Plugin,
|
|
9
|
+
BaseHorizontalRulePlugin,
|
|
10
|
+
} from '@platejs/basic-nodes';
|
|
11
|
+
import { BaseParagraphPlugin } from 'platejs';
|
|
12
|
+
|
|
13
|
+
import { BlockquoteElementStatic } from '@/components/ui/blockquote-node-static';
|
|
14
|
+
import {
|
|
15
|
+
H1ElementStatic,
|
|
16
|
+
H2ElementStatic,
|
|
17
|
+
H3ElementStatic,
|
|
18
|
+
H4ElementStatic,
|
|
19
|
+
H5ElementStatic,
|
|
20
|
+
H6ElementStatic,
|
|
21
|
+
} from '@/components/ui/heading-node-static';
|
|
22
|
+
import { HrElementStatic } from '@/components/ui/hr-node-static';
|
|
23
|
+
import { ParagraphElementStatic } from '@/components/ui/paragraph-node-static';
|
|
24
|
+
|
|
25
|
+
export const BaseBasicBlocksKit = [
|
|
26
|
+
BaseParagraphPlugin.withComponent(ParagraphElementStatic),
|
|
27
|
+
BaseH1Plugin.withComponent(H1ElementStatic),
|
|
28
|
+
BaseH2Plugin.withComponent(H2ElementStatic),
|
|
29
|
+
BaseH3Plugin.withComponent(H3ElementStatic),
|
|
30
|
+
BaseH4Plugin.withComponent(H4ElementStatic),
|
|
31
|
+
BaseH5Plugin.withComponent(H5ElementStatic),
|
|
32
|
+
BaseH6Plugin.withComponent(H6ElementStatic),
|
|
33
|
+
BaseBlockquotePlugin.withComponent(BlockquoteElementStatic),
|
|
34
|
+
BaseHorizontalRulePlugin.withComponent(HrElementStatic),
|
|
35
|
+
];
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
BlockquotePlugin,
|
|
5
|
+
H1Plugin,
|
|
6
|
+
H2Plugin,
|
|
7
|
+
H3Plugin,
|
|
8
|
+
H4Plugin,
|
|
9
|
+
H5Plugin,
|
|
10
|
+
H6Plugin,
|
|
11
|
+
HorizontalRulePlugin,
|
|
12
|
+
} from '@platejs/basic-nodes/react';
|
|
13
|
+
import { ParagraphPlugin } from 'platejs/react';
|
|
14
|
+
|
|
15
|
+
import { BlockquoteElement } from '@/components/ui/blockquote-node';
|
|
16
|
+
import {
|
|
17
|
+
H1Element,
|
|
18
|
+
H2Element,
|
|
19
|
+
H3Element,
|
|
20
|
+
H4Element,
|
|
21
|
+
H5Element,
|
|
22
|
+
H6Element,
|
|
23
|
+
} from '@/components/ui/heading-node';
|
|
24
|
+
import { HrElement } from '@/components/ui/hr-node';
|
|
25
|
+
import { ParagraphElement } from '@/components/ui/paragraph-node';
|
|
26
|
+
|
|
27
|
+
export const BasicBlocksKit = [
|
|
28
|
+
ParagraphPlugin.withComponent(ParagraphElement),
|
|
29
|
+
H1Plugin.configure({
|
|
30
|
+
node: {
|
|
31
|
+
component: H1Element,
|
|
32
|
+
},
|
|
33
|
+
rules: {
|
|
34
|
+
break: { empty: 'reset' },
|
|
35
|
+
},
|
|
36
|
+
shortcuts: { toggle: { keys: 'mod+alt+1' } },
|
|
37
|
+
}),
|
|
38
|
+
H2Plugin.configure({
|
|
39
|
+
node: {
|
|
40
|
+
component: H2Element,
|
|
41
|
+
},
|
|
42
|
+
rules: {
|
|
43
|
+
break: { empty: 'reset' },
|
|
44
|
+
},
|
|
45
|
+
shortcuts: { toggle: { keys: 'mod+alt+2' } },
|
|
46
|
+
}),
|
|
47
|
+
H3Plugin.configure({
|
|
48
|
+
node: {
|
|
49
|
+
component: H3Element,
|
|
50
|
+
},
|
|
51
|
+
rules: {
|
|
52
|
+
break: { empty: 'reset' },
|
|
53
|
+
},
|
|
54
|
+
shortcuts: { toggle: { keys: 'mod+alt+3' } },
|
|
55
|
+
}),
|
|
56
|
+
H4Plugin.configure({
|
|
57
|
+
node: {
|
|
58
|
+
component: H4Element,
|
|
59
|
+
},
|
|
60
|
+
rules: {
|
|
61
|
+
break: { empty: 'reset' },
|
|
62
|
+
},
|
|
63
|
+
shortcuts: { toggle: { keys: 'mod+alt+4' } },
|
|
64
|
+
}),
|
|
65
|
+
H5Plugin.configure({
|
|
66
|
+
node: {
|
|
67
|
+
component: H5Element,
|
|
68
|
+
},
|
|
69
|
+
rules: {
|
|
70
|
+
break: { empty: 'reset' },
|
|
71
|
+
},
|
|
72
|
+
shortcuts: { toggle: { keys: 'mod+alt+5' } },
|
|
73
|
+
}),
|
|
74
|
+
H6Plugin.configure({
|
|
75
|
+
node: {
|
|
76
|
+
component: H6Element,
|
|
77
|
+
},
|
|
78
|
+
rules: {
|
|
79
|
+
break: { empty: 'reset' },
|
|
80
|
+
},
|
|
81
|
+
shortcuts: { toggle: { keys: 'mod+alt+6' } },
|
|
82
|
+
}),
|
|
83
|
+
BlockquotePlugin.configure({
|
|
84
|
+
node: { component: BlockquoteElement },
|
|
85
|
+
shortcuts: { toggle: { keys: 'mod+shift+period' } },
|
|
86
|
+
}),
|
|
87
|
+
HorizontalRulePlugin.withComponent(HrElement),
|
|
88
|
+
];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseBoldPlugin,
|
|
3
|
+
BaseCodePlugin,
|
|
4
|
+
BaseHighlightPlugin,
|
|
5
|
+
BaseItalicPlugin,
|
|
6
|
+
BaseKbdPlugin,
|
|
7
|
+
BaseStrikethroughPlugin,
|
|
8
|
+
BaseSubscriptPlugin,
|
|
9
|
+
BaseSuperscriptPlugin,
|
|
10
|
+
BaseUnderlinePlugin,
|
|
11
|
+
} from '@platejs/basic-nodes';
|
|
12
|
+
|
|
13
|
+
import { CodeLeafStatic } from '@/components/ui/code-node-static';
|
|
14
|
+
import { HighlightLeafStatic } from '@/components/ui/highlight-node-static';
|
|
15
|
+
import { KbdLeafStatic } from '@/components/ui/kbd-node-static';
|
|
16
|
+
|
|
17
|
+
export const BaseBasicMarksKit = [
|
|
18
|
+
BaseBoldPlugin,
|
|
19
|
+
BaseItalicPlugin,
|
|
20
|
+
BaseUnderlinePlugin,
|
|
21
|
+
BaseCodePlugin.withComponent(CodeLeafStatic),
|
|
22
|
+
BaseStrikethroughPlugin,
|
|
23
|
+
BaseSubscriptPlugin,
|
|
24
|
+
BaseSuperscriptPlugin,
|
|
25
|
+
BaseHighlightPlugin.withComponent(HighlightLeafStatic),
|
|
26
|
+
BaseKbdPlugin.withComponent(KbdLeafStatic),
|
|
27
|
+
];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
BoldPlugin,
|
|
5
|
+
CodePlugin,
|
|
6
|
+
HighlightPlugin,
|
|
7
|
+
ItalicPlugin,
|
|
8
|
+
KbdPlugin,
|
|
9
|
+
StrikethroughPlugin,
|
|
10
|
+
SubscriptPlugin,
|
|
11
|
+
SuperscriptPlugin,
|
|
12
|
+
UnderlinePlugin,
|
|
13
|
+
} from '@platejs/basic-nodes/react';
|
|
14
|
+
|
|
15
|
+
import { CodeLeaf } from '@/components/ui/code-node';
|
|
16
|
+
import { HighlightLeaf } from '@/components/ui/highlight-node';
|
|
17
|
+
import { KbdLeaf } from '@/components/ui/kbd-node';
|
|
18
|
+
|
|
19
|
+
export const BasicMarksKit = [
|
|
20
|
+
BoldPlugin,
|
|
21
|
+
ItalicPlugin,
|
|
22
|
+
UnderlinePlugin,
|
|
23
|
+
CodePlugin.configure({
|
|
24
|
+
node: { component: CodeLeaf },
|
|
25
|
+
shortcuts: { toggle: { keys: 'mod+e' } },
|
|
26
|
+
}),
|
|
27
|
+
StrikethroughPlugin.configure({
|
|
28
|
+
shortcuts: { toggle: { keys: 'mod+shift+x' } },
|
|
29
|
+
}),
|
|
30
|
+
SubscriptPlugin.configure({
|
|
31
|
+
shortcuts: { toggle: { keys: 'mod+comma' } },
|
|
32
|
+
}),
|
|
33
|
+
SuperscriptPlugin.configure({
|
|
34
|
+
shortcuts: { toggle: { keys: 'mod+period' } },
|
|
35
|
+
}),
|
|
36
|
+
HighlightPlugin.configure({
|
|
37
|
+
node: { component: HighlightLeaf },
|
|
38
|
+
shortcuts: { toggle: { keys: 'mod+shift+h' } },
|
|
39
|
+
}),
|
|
40
|
+
KbdPlugin.withComponent(KbdLeaf),
|
|
41
|
+
];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { BlockMenuPlugin } from '@platejs/selection/react';
|
|
4
|
+
|
|
5
|
+
import { BlockContextMenu } from '@/components/ui/block-context-menu';
|
|
6
|
+
|
|
7
|
+
import { BlockSelectionKit } from './block-selection-kit';
|
|
8
|
+
|
|
9
|
+
export const BlockMenuKit = [
|
|
10
|
+
...BlockSelectionKit,
|
|
11
|
+
BlockMenuPlugin.configure({
|
|
12
|
+
render: { aboveEditable: BlockContextMenu },
|
|
13
|
+
}),
|
|
14
|
+
];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { KEYS } from 'platejs';
|
|
4
|
+
import { BlockPlaceholderPlugin } from 'platejs/react';
|
|
5
|
+
|
|
6
|
+
export const BlockPlaceholderKit = [
|
|
7
|
+
BlockPlaceholderPlugin.configure({
|
|
8
|
+
options: {
|
|
9
|
+
className:
|
|
10
|
+
'before:absolute before:cursor-text before:text-muted-foreground/80 before:content-[attr(placeholder)]',
|
|
11
|
+
placeholders: {
|
|
12
|
+
[KEYS.p]: 'Type something...',
|
|
13
|
+
},
|
|
14
|
+
query: ({ path }) => path.length === 1,
|
|
15
|
+
},
|
|
16
|
+
}),
|
|
17
|
+
];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { AIChatPlugin } from '@platejs/ai/react';
|
|
4
|
+
import { BlockSelectionPlugin } from '@platejs/selection/react';
|
|
5
|
+
import { getPluginTypes, isHotkey, KEYS } from 'platejs';
|
|
6
|
+
|
|
7
|
+
import { BlockSelection } from '@/components/ui/block-selection';
|
|
8
|
+
|
|
9
|
+
export const BlockSelectionKit = [
|
|
10
|
+
BlockSelectionPlugin.configure(({ editor }) => ({
|
|
11
|
+
options: {
|
|
12
|
+
enableContextMenu: true,
|
|
13
|
+
isSelectable: (element) =>
|
|
14
|
+
!getPluginTypes(editor, [KEYS.column, KEYS.codeLine, KEYS.td]).includes(
|
|
15
|
+
element.type
|
|
16
|
+
),
|
|
17
|
+
onKeyDownSelecting: (editor, e) => {
|
|
18
|
+
if (isHotkey('mod+j')(e)) {
|
|
19
|
+
editor.getApi(AIChatPlugin).aiChat.show();
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
render: {
|
|
24
|
+
belowRootNodes: (props) => {
|
|
25
|
+
if (!props.attributes.className?.includes('slate-selectable'))
|
|
26
|
+
return null;
|
|
27
|
+
|
|
28
|
+
return <BlockSelection {...(props as any)} />;
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
})),
|
|
32
|
+
];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseCodeBlockPlugin,
|
|
3
|
+
BaseCodeLinePlugin,
|
|
4
|
+
BaseCodeSyntaxPlugin,
|
|
5
|
+
} from '@platejs/code-block';
|
|
6
|
+
import { all, createLowlight } from 'lowlight';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
CodeBlockElementStatic,
|
|
10
|
+
CodeLineElementStatic,
|
|
11
|
+
CodeSyntaxLeafStatic,
|
|
12
|
+
} from '@/components/ui/code-block-node-static';
|
|
13
|
+
|
|
14
|
+
const lowlight = createLowlight(all);
|
|
15
|
+
|
|
16
|
+
export const BaseCodeBlockKit = [
|
|
17
|
+
BaseCodeBlockPlugin.configure({
|
|
18
|
+
node: { component: CodeBlockElementStatic },
|
|
19
|
+
options: { lowlight },
|
|
20
|
+
}),
|
|
21
|
+
BaseCodeLinePlugin.withComponent(CodeLineElementStatic),
|
|
22
|
+
BaseCodeSyntaxPlugin.withComponent(CodeSyntaxLeafStatic),
|
|
23
|
+
];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
CodeBlockPlugin,
|
|
5
|
+
CodeLinePlugin,
|
|
6
|
+
CodeSyntaxPlugin,
|
|
7
|
+
} from '@platejs/code-block/react';
|
|
8
|
+
import { all, createLowlight } from 'lowlight';
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
CodeBlockElement,
|
|
12
|
+
CodeLineElement,
|
|
13
|
+
CodeSyntaxLeaf,
|
|
14
|
+
} from '@/components/ui/code-block-node';
|
|
15
|
+
|
|
16
|
+
const lowlight = createLowlight(all);
|
|
17
|
+
|
|
18
|
+
export const CodeBlockKit = [
|
|
19
|
+
CodeBlockPlugin.configure({
|
|
20
|
+
node: { component: CodeBlockElement },
|
|
21
|
+
options: { lowlight },
|
|
22
|
+
shortcuts: { toggle: { keys: 'mod+alt+8' } },
|
|
23
|
+
}),
|
|
24
|
+
CodeLinePlugin.withComponent(CodeLineElement),
|
|
25
|
+
CodeSyntaxPlugin.withComponent(CodeSyntaxLeaf),
|
|
26
|
+
];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createPlatePlugin } from "platejs/react";
|
|
2
|
+
import { CodebaseSnippetElement } from "@/components/ui/codebase-snippet-node";
|
|
3
|
+
|
|
4
|
+
export const CodebaseSnippetType = 'CodebaseSnippet';
|
|
5
|
+
|
|
6
|
+
export interface CodebaseSnippetElementType {
|
|
7
|
+
type: typeof CodebaseSnippetType;
|
|
8
|
+
filePath?: string;
|
|
9
|
+
lineStart?: string;
|
|
10
|
+
lineEnd?: string;
|
|
11
|
+
children: [{ text: '' }];
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export const CodebaseSnippetPlugin = createPlatePlugin({
|
|
17
|
+
key: CodebaseSnippetType,
|
|
18
|
+
node: {
|
|
19
|
+
isElement: true,
|
|
20
|
+
isVoid: true,
|
|
21
|
+
component: CodebaseSnippetElement
|
|
22
|
+
}
|
|
23
|
+
})
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseColumnItemPlugin, BaseColumnPlugin } from '@platejs/layout';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ColumnElementStatic,
|
|
5
|
+
ColumnGroupElementStatic,
|
|
6
|
+
} from '@/components/ui/column-node-static';
|
|
7
|
+
|
|
8
|
+
export const BaseColumnKit = [
|
|
9
|
+
BaseColumnPlugin.withComponent(ColumnGroupElementStatic),
|
|
10
|
+
BaseColumnItemPlugin.withComponent(ColumnElementStatic),
|
|
11
|
+
];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { ColumnItemPlugin, ColumnPlugin } from '@platejs/layout/react';
|
|
4
|
+
|
|
5
|
+
import { ColumnElement, ColumnGroupElement } from '@/components/ui/column-node';
|
|
6
|
+
|
|
7
|
+
export const ColumnKit = [
|
|
8
|
+
ColumnPlugin.withComponent(ColumnGroupElement),
|
|
9
|
+
ColumnItemPlugin.withComponent(ColumnElement),
|
|
10
|
+
];
|