doclific 0.2.0 → 0.2.2

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.
Files changed (220) hide show
  1. package/LICENSE +17 -0
  2. package/dist/bin/doclific.js +36 -8
  3. package/package.json +11 -4
  4. package/readme.md +77 -0
  5. package/.gitattributes +0 -2
  6. package/.prettierignore +0 -5
  7. package/.prettierrc +0 -9
  8. package/.vscode/settings.json +0 -13
  9. package/frontend/components.json +0 -24
  10. package/frontend/eslint.config.js +0 -23
  11. package/frontend/index.html +0 -25
  12. package/frontend/package-lock.json +0 -15754
  13. package/frontend/public/logo.svg +0 -1
  14. package/frontend/src/App.tsx +0 -21
  15. package/frontend/src/components/app-sidebar.tsx +0 -393
  16. package/frontend/src/components/editor/editor-base-kit.tsx +0 -43
  17. package/frontend/src/components/editor/editor-kit.tsx +0 -93
  18. package/frontend/src/components/editor/plugins/align-base-kit.tsx +0 -16
  19. package/frontend/src/components/editor/plugins/align-kit.tsx +0 -18
  20. package/frontend/src/components/editor/plugins/autoformat-kit.tsx +0 -236
  21. package/frontend/src/components/editor/plugins/basic-blocks-base-kit.tsx +0 -35
  22. package/frontend/src/components/editor/plugins/basic-blocks-kit.tsx +0 -88
  23. package/frontend/src/components/editor/plugins/basic-marks-base-kit.tsx +0 -27
  24. package/frontend/src/components/editor/plugins/basic-marks-kit.tsx +0 -41
  25. package/frontend/src/components/editor/plugins/basic-nodes-kit.tsx +0 -6
  26. package/frontend/src/components/editor/plugins/block-menu-kit.tsx +0 -14
  27. package/frontend/src/components/editor/plugins/block-placeholder-kit.tsx +0 -17
  28. package/frontend/src/components/editor/plugins/block-selection-kit.tsx +0 -32
  29. package/frontend/src/components/editor/plugins/callout-base-kit.tsx +0 -7
  30. package/frontend/src/components/editor/plugins/callout-kit.tsx +0 -7
  31. package/frontend/src/components/editor/plugins/code-block-base-kit.tsx +0 -23
  32. package/frontend/src/components/editor/plugins/code-block-kit.tsx +0 -26
  33. package/frontend/src/components/editor/plugins/codebase-kit.tsx +0 -23
  34. package/frontend/src/components/editor/plugins/column-base-kit.tsx +0 -11
  35. package/frontend/src/components/editor/plugins/column-kit.tsx +0 -10
  36. package/frontend/src/components/editor/plugins/comment-base-kit.tsx +0 -7
  37. package/frontend/src/components/editor/plugins/comment-kit.tsx +0 -97
  38. package/frontend/src/components/editor/plugins/cursor-overlay-kit.tsx +0 -13
  39. package/frontend/src/components/editor/plugins/date-base-kit.tsx +0 -5
  40. package/frontend/src/components/editor/plugins/date-kit.tsx +0 -7
  41. package/frontend/src/components/editor/plugins/discussion-kit.tsx +0 -148
  42. package/frontend/src/components/editor/plugins/dnd-kit.tsx +0 -28
  43. package/frontend/src/components/editor/plugins/docx-kit.tsx +0 -6
  44. package/frontend/src/components/editor/plugins/emoji-kit.tsx +0 -13
  45. package/frontend/src/components/editor/plugins/excalidraw-kit.tsx +0 -9
  46. package/frontend/src/components/editor/plugins/exit-break-kit.tsx +0 -12
  47. package/frontend/src/components/editor/plugins/floating-toolbar-kit.tsx +0 -19
  48. package/frontend/src/components/editor/plugins/font-base-kit.tsx +0 -20
  49. package/frontend/src/components/editor/plugins/font-kit.tsx +0 -29
  50. package/frontend/src/components/editor/plugins/indent-base-kit.tsx +0 -19
  51. package/frontend/src/components/editor/plugins/indent-kit.tsx +0 -22
  52. package/frontend/src/components/editor/plugins/line-height-base-kit.tsx +0 -14
  53. package/frontend/src/components/editor/plugins/line-height-kit.tsx +0 -16
  54. package/frontend/src/components/editor/plugins/link-base-kit.tsx +0 -5
  55. package/frontend/src/components/editor/plugins/link-kit.tsx +0 -15
  56. package/frontend/src/components/editor/plugins/list-base-kit.tsx +0 -23
  57. package/frontend/src/components/editor/plugins/list-kit.tsx +0 -26
  58. package/frontend/src/components/editor/plugins/markdown-kit.tsx +0 -46
  59. package/frontend/src/components/editor/plugins/math-base-kit.tsx +0 -11
  60. package/frontend/src/components/editor/plugins/math-kit.tsx +0 -13
  61. package/frontend/src/components/editor/plugins/media-base-kit.tsx +0 -31
  62. package/frontend/src/components/editor/plugins/media-kit.tsx +0 -43
  63. package/frontend/src/components/editor/plugins/mention-base-kit.tsx +0 -7
  64. package/frontend/src/components/editor/plugins/mention-kit.tsx +0 -15
  65. package/frontend/src/components/editor/plugins/slash-kit.tsx +0 -18
  66. package/frontend/src/components/editor/plugins/suggestion-base-kit.tsx +0 -7
  67. package/frontend/src/components/editor/plugins/suggestion-kit.tsx +0 -90
  68. package/frontend/src/components/editor/plugins/table-base-kit.tsx +0 -20
  69. package/frontend/src/components/editor/plugins/table-kit.tsx +0 -22
  70. package/frontend/src/components/editor/plugins/toc-base-kit.tsx +0 -5
  71. package/frontend/src/components/editor/plugins/toc-kit.tsx +0 -14
  72. package/frontend/src/components/editor/plugins/toggle-base-kit.tsx +0 -7
  73. package/frontend/src/components/editor/plugins/toggle-kit.tsx +0 -11
  74. package/frontend/src/components/editor/transforms.ts +0 -194
  75. package/frontend/src/components/markdown-to-slate-demo.tsx +0 -50
  76. package/frontend/src/components/mode-toggle.tsx +0 -15
  77. package/frontend/src/components/theme-provider.tsx +0 -73
  78. package/frontend/src/components/ui/alert-dialog.tsx +0 -155
  79. package/frontend/src/components/ui/align-toolbar-button.tsx +0 -84
  80. package/frontend/src/components/ui/avatar.tsx +0 -51
  81. package/frontend/src/components/ui/block-context-menu.tsx +0 -199
  82. package/frontend/src/components/ui/block-discussion.tsx +0 -365
  83. package/frontend/src/components/ui/block-draggable.tsx +0 -512
  84. package/frontend/src/components/ui/block-list-static.tsx +0 -80
  85. package/frontend/src/components/ui/block-list.tsx +0 -87
  86. package/frontend/src/components/ui/block-selection.tsx +0 -42
  87. package/frontend/src/components/ui/block-suggestion.tsx +0 -473
  88. package/frontend/src/components/ui/blockquote-node-static.tsx +0 -11
  89. package/frontend/src/components/ui/blockquote-node.tsx +0 -13
  90. package/frontend/src/components/ui/button.tsx +0 -62
  91. package/frontend/src/components/ui/calendar.tsx +0 -218
  92. package/frontend/src/components/ui/callout-node-static.tsx +0 -36
  93. package/frontend/src/components/ui/callout-node.tsx +0 -63
  94. package/frontend/src/components/ui/caption.tsx +0 -63
  95. package/frontend/src/components/ui/checkbox.tsx +0 -30
  96. package/frontend/src/components/ui/code-block-node-static.tsx +0 -35
  97. package/frontend/src/components/ui/code-block-node.tsx +0 -287
  98. package/frontend/src/components/ui/code-node-static.tsx +0 -15
  99. package/frontend/src/components/ui/code-node.tsx +0 -17
  100. package/frontend/src/components/ui/codebase-snippet-node.tsx +0 -237
  101. package/frontend/src/components/ui/column-node-static.tsx +0 -29
  102. package/frontend/src/components/ui/column-node.tsx +0 -317
  103. package/frontend/src/components/ui/command.tsx +0 -182
  104. package/frontend/src/components/ui/comment-node-static.tsx +0 -15
  105. package/frontend/src/components/ui/comment-node.tsx +0 -45
  106. package/frontend/src/components/ui/comment-toolbar-button.tsx +0 -24
  107. package/frontend/src/components/ui/comment.tsx +0 -618
  108. package/frontend/src/components/ui/context-menu.tsx +0 -250
  109. package/frontend/src/components/ui/cursor-overlay.tsx +0 -66
  110. package/frontend/src/components/ui/date-node-static.tsx +0 -45
  111. package/frontend/src/components/ui/date-node.tsx +0 -93
  112. package/frontend/src/components/ui/dialog.tsx +0 -143
  113. package/frontend/src/components/ui/dropdown-menu.tsx +0 -255
  114. package/frontend/src/components/ui/dynamic-icon.tsx +0 -12
  115. package/frontend/src/components/ui/editor-static.tsx +0 -53
  116. package/frontend/src/components/ui/editor.tsx +0 -130
  117. package/frontend/src/components/ui/emoji-node.tsx +0 -69
  118. package/frontend/src/components/ui/emoji-toolbar-button.tsx +0 -628
  119. package/frontend/src/components/ui/equation-node-static.tsx +0 -98
  120. package/frontend/src/components/ui/equation-node.tsx +0 -235
  121. package/frontend/src/components/ui/equation-toolbar-button.tsx +0 -25
  122. package/frontend/src/components/ui/excalidraw-node.tsx +0 -36
  123. package/frontend/src/components/ui/export-toolbar-button.tsx +0 -174
  124. package/frontend/src/components/ui/file-selector.tsx +0 -339
  125. package/frontend/src/components/ui/floating-toolbar-buttons.tsx +0 -73
  126. package/frontend/src/components/ui/floating-toolbar.tsx +0 -85
  127. package/frontend/src/components/ui/font-color-toolbar-button.tsx +0 -831
  128. package/frontend/src/components/ui/font-size-toolbar-button.tsx +0 -152
  129. package/frontend/src/components/ui/heading-node-static.tsx +0 -68
  130. package/frontend/src/components/ui/heading-node.tsx +0 -58
  131. package/frontend/src/components/ui/highlight-node-static.tsx +0 -11
  132. package/frontend/src/components/ui/highlight-node.tsx +0 -13
  133. package/frontend/src/components/ui/history-toolbar-button.tsx +0 -50
  134. package/frontend/src/components/ui/hr-node-static.tsx +0 -20
  135. package/frontend/src/components/ui/hr-node.tsx +0 -33
  136. package/frontend/src/components/ui/import-toolbar-button.tsx +0 -97
  137. package/frontend/src/components/ui/indent-toolbar-button.tsx +0 -30
  138. package/frontend/src/components/ui/inline-combobox.tsx +0 -414
  139. package/frontend/src/components/ui/input.tsx +0 -21
  140. package/frontend/src/components/ui/insert-toolbar-button.tsx +0 -254
  141. package/frontend/src/components/ui/kbd-node-static.tsx +0 -15
  142. package/frontend/src/components/ui/kbd-node.tsx +0 -17
  143. package/frontend/src/components/ui/layout-header.tsx +0 -35
  144. package/frontend/src/components/ui/line-height-toolbar-button.tsx +0 -68
  145. package/frontend/src/components/ui/link-node-static.tsx +0 -21
  146. package/frontend/src/components/ui/link-node.tsx +0 -39
  147. package/frontend/src/components/ui/link-toolbar-button.tsx +0 -22
  148. package/frontend/src/components/ui/link-toolbar.tsx +0 -206
  149. package/frontend/src/components/ui/list-toolbar-button.tsx +0 -204
  150. package/frontend/src/components/ui/mark-toolbar-button.tsx +0 -19
  151. package/frontend/src/components/ui/media-audio-node-static.tsx +0 -17
  152. package/frontend/src/components/ui/media-audio-node.tsx +0 -39
  153. package/frontend/src/components/ui/media-embed-node.tsx +0 -136
  154. package/frontend/src/components/ui/media-file-node-static.tsx +0 -29
  155. package/frontend/src/components/ui/media-file-node.tsx +0 -47
  156. package/frontend/src/components/ui/media-image-node-static.tsx +0 -39
  157. package/frontend/src/components/ui/media-image-node.tsx +0 -80
  158. package/frontend/src/components/ui/media-placeholder-node.tsx +0 -249
  159. package/frontend/src/components/ui/media-preview-dialog.tsx +0 -152
  160. package/frontend/src/components/ui/media-toolbar-button.tsx +0 -225
  161. package/frontend/src/components/ui/media-toolbar.tsx +0 -115
  162. package/frontend/src/components/ui/media-upload-toast.tsx +0 -66
  163. package/frontend/src/components/ui/media-video-node-static.tsx +0 -30
  164. package/frontend/src/components/ui/media-video-node.tsx +0 -121
  165. package/frontend/src/components/ui/mention-node-static.tsx +0 -36
  166. package/frontend/src/components/ui/mention-node.tsx +0 -194
  167. package/frontend/src/components/ui/mode-toolbar-button.tsx +0 -123
  168. package/frontend/src/components/ui/more-toolbar-button.tsx +0 -80
  169. package/frontend/src/components/ui/paragraph-node-static.tsx +0 -13
  170. package/frontend/src/components/ui/paragraph-node.tsx +0 -15
  171. package/frontend/src/components/ui/popover.tsx +0 -46
  172. package/frontend/src/components/ui/resize-handle.tsx +0 -87
  173. package/frontend/src/components/ui/separator.tsx +0 -28
  174. package/frontend/src/components/ui/sheet.tsx +0 -139
  175. package/frontend/src/components/ui/sidebar.tsx +0 -726
  176. package/frontend/src/components/ui/skeleton.tsx +0 -13
  177. package/frontend/src/components/ui/slash-node.tsx +0 -233
  178. package/frontend/src/components/ui/sonner.tsx +0 -38
  179. package/frontend/src/components/ui/suggestion-node-static.tsx +0 -35
  180. package/frontend/src/components/ui/suggestion-node.tsx +0 -162
  181. package/frontend/src/components/ui/suggestion-toolbar-button.tsx +0 -25
  182. package/frontend/src/components/ui/table-icons.tsx +0 -862
  183. package/frontend/src/components/ui/table-node-static.tsx +0 -98
  184. package/frontend/src/components/ui/table-node.tsx +0 -656
  185. package/frontend/src/components/ui/table-toolbar-button.tsx +0 -264
  186. package/frontend/src/components/ui/toc-node-static.tsx +0 -92
  187. package/frontend/src/components/ui/toc-node.tsx +0 -55
  188. package/frontend/src/components/ui/toggle-node-static.tsx +0 -18
  189. package/frontend/src/components/ui/toggle-node.tsx +0 -36
  190. package/frontend/src/components/ui/toggle-toolbar-button.tsx +0 -22
  191. package/frontend/src/components/ui/toolbar.tsx +0 -387
  192. package/frontend/src/components/ui/tooltip.tsx +0 -59
  193. package/frontend/src/components/ui/turn-into-toolbar-button.tsx +0 -188
  194. package/frontend/src/hooks/use-debounce.ts +0 -18
  195. package/frontend/src/hooks/use-is-touch-device.ts +0 -24
  196. package/frontend/src/hooks/use-mobile.ts +0 -19
  197. package/frontend/src/hooks/use-mounted.ts +0 -11
  198. package/frontend/src/hooks/use-upload-file.ts +0 -128
  199. package/frontend/src/index.css +0 -128
  200. package/frontend/src/layout.tsx +0 -42
  201. package/frontend/src/lib/markdown-joiner-transform.ts +0 -239
  202. package/frontend/src/lib/orpc.ts +0 -13
  203. package/frontend/src/lib/uploadthing.ts +0 -19
  204. package/frontend/src/lib/utils.ts +0 -6
  205. package/frontend/src/main.tsx +0 -13
  206. package/frontend/src/pages/editor.tsx +0 -44
  207. package/frontend/src/types/docs.d.ts +0 -6
  208. package/frontend/src/types/global.d.ts +0 -9
  209. package/frontend/src/types/router.d.ts +0 -4
  210. package/frontend/tsconfig.app.json +0 -33
  211. package/frontend/tsconfig.json +0 -10
  212. package/frontend/tsconfig.node.json +0 -26
  213. package/frontend/vite.config.ts +0 -14
  214. package/src/bin/doclific.ts +0 -47
  215. package/src/core/codebase.ts +0 -39
  216. package/src/core/docs.ts +0 -90
  217. package/src/core/git.ts +0 -48
  218. package/src/server/index.ts +0 -55
  219. package/src/server/router.ts +0 -65
  220. package/tsconfig.json +0 -15
@@ -1,46 +0,0 @@
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
- ];
@@ -1,11 +0,0 @@
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
- ];
@@ -1,13 +0,0 @@
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
- ];
@@ -1,31 +0,0 @@
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
- ];
@@ -1,43 +0,0 @@
1
- 'use client';
2
-
3
- import { CaptionPlugin } from '@platejs/caption/react';
4
- import {
5
- AudioPlugin,
6
- FilePlugin,
7
- ImagePlugin,
8
- MediaEmbedPlugin,
9
- PlaceholderPlugin,
10
- VideoPlugin,
11
- } from '@platejs/media/react';
12
- import { KEYS } from 'platejs';
13
-
14
- import { AudioElement } from '@/components/ui/media-audio-node';
15
- import { MediaEmbedElement } from '@/components/ui/media-embed-node';
16
- import { FileElement } from '@/components/ui/media-file-node';
17
- import { ImageElement } from '@/components/ui/media-image-node';
18
- import { PlaceholderElement } from '@/components/ui/media-placeholder-node';
19
- import { MediaPreviewDialog } from '@/components/ui/media-preview-dialog';
20
- import { MediaUploadToast } from '@/components/ui/media-upload-toast';
21
- import { VideoElement } from '@/components/ui/media-video-node';
22
-
23
- export const MediaKit = [
24
- ImagePlugin.configure({
25
- options: { disableUploadInsert: true },
26
- render: { afterEditable: MediaPreviewDialog, node: ImageElement },
27
- }),
28
- MediaEmbedPlugin.withComponent(MediaEmbedElement),
29
- VideoPlugin.withComponent(VideoElement),
30
- AudioPlugin.withComponent(AudioElement),
31
- FilePlugin.withComponent(FileElement),
32
- PlaceholderPlugin.configure({
33
- options: { disableEmptyPlaceholder: true },
34
- render: { afterEditable: MediaUploadToast, node: PlaceholderElement },
35
- }),
36
- CaptionPlugin.configure({
37
- options: {
38
- query: {
39
- allow: [KEYS.img, KEYS.video, KEYS.audio, KEYS.file, KEYS.mediaEmbed],
40
- },
41
- },
42
- }),
43
- ];
@@ -1,7 +0,0 @@
1
- import { BaseMentionPlugin } from '@platejs/mention';
2
-
3
- import { MentionElementStatic } from '@/components/ui/mention-node-static';
4
-
5
- export const BaseMentionKit = [
6
- BaseMentionPlugin.withComponent(MentionElementStatic),
7
- ];
@@ -1,15 +0,0 @@
1
- 'use client';
2
-
3
- import { MentionInputPlugin, MentionPlugin } from '@platejs/mention/react';
4
-
5
- import {
6
- MentionElement,
7
- MentionInputElement,
8
- } from '@/components/ui/mention-node';
9
-
10
- export const MentionKit = [
11
- MentionPlugin.configure({
12
- options: { triggerPreviousCharPattern: /^$|^[\s"']$/ },
13
- }).withComponent(MentionElement),
14
- MentionInputPlugin.withComponent(MentionInputElement),
15
- ];
@@ -1,18 +0,0 @@
1
- 'use client';
2
-
3
- import { SlashInputPlugin, SlashPlugin } from '@platejs/slash-command/react';
4
- import { KEYS } from 'platejs';
5
-
6
- import { SlashInputElement } from '@/components/ui/slash-node';
7
-
8
- export const SlashKit = [
9
- SlashPlugin.configure({
10
- options: {
11
- triggerQuery: (editor) =>
12
- !editor.api.some({
13
- match: { type: editor.getType(KEYS.codeBlock) },
14
- }),
15
- },
16
- }),
17
- SlashInputPlugin.withComponent(SlashInputElement),
18
- ];
@@ -1,7 +0,0 @@
1
- import { BaseSuggestionPlugin } from '@platejs/suggestion';
2
-
3
- import { SuggestionLeafStatic } from '@/components/ui/suggestion-node-static';
4
-
5
- export const BaseSuggestionKit = [
6
- BaseSuggestionPlugin.withComponent(SuggestionLeafStatic),
7
- ];
@@ -1,90 +0,0 @@
1
- 'use client';
2
-
3
- import type { ExtendConfig, Path } from 'platejs';
4
-
5
- import {
6
- type BaseSuggestionConfig,
7
- BaseSuggestionPlugin,
8
- } from '@platejs/suggestion';
9
- import { isSlateEditor, isSlateString } from 'platejs';
10
- import { toTPlatePlugin } from 'platejs/react';
11
-
12
- import {
13
- SuggestionLeaf,
14
- SuggestionLineBreak,
15
- } from '@/components/ui/suggestion-node';
16
-
17
- import { discussionPlugin } from './discussion-kit';
18
-
19
- export type SuggestionConfig = ExtendConfig<
20
- BaseSuggestionConfig,
21
- {
22
- activeId: string | null;
23
- hoverId: string | null;
24
- uniquePathMap: Map<string, Path>;
25
- }
26
- >;
27
-
28
- export const suggestionPlugin = toTPlatePlugin<SuggestionConfig>(
29
- BaseSuggestionPlugin,
30
- ({ editor }) => ({
31
- options: {
32
- activeId: null,
33
- currentUserId: editor.getOption(discussionPlugin, 'currentUserId'),
34
- hoverId: null,
35
- uniquePathMap: new Map(),
36
- },
37
- })
38
- ).configure({
39
- handlers: {
40
- // unset active suggestion when clicking outside of suggestion
41
- onClick: ({ api, event, setOption, type }) => {
42
- let leaf = event.target as HTMLElement;
43
- let isSet = false;
44
-
45
- const isBlockLeaf = leaf.dataset.blockSuggestion === 'true';
46
-
47
- const unsetActiveSuggestion = () => {
48
- setOption('activeId', null);
49
- isSet = true;
50
- };
51
-
52
- if (!isSlateString(leaf) && !isBlockLeaf) {
53
- unsetActiveSuggestion();
54
- }
55
-
56
- while (leaf.parentElement && !isSlateEditor(leaf.parentElement)) {
57
- const isBlockSuggestion = leaf.dataset.blockSuggestion === 'true';
58
-
59
- if (leaf.classList.contains(`slate-${type}`) || isBlockSuggestion) {
60
- const suggestionEntry = api.suggestion!.node({
61
- isText: !isBlockSuggestion,
62
- });
63
-
64
- if (!suggestionEntry) {
65
- unsetActiveSuggestion();
66
-
67
- break;
68
- }
69
-
70
- const id = api.suggestion!.nodeId(suggestionEntry[0]);
71
- setOption('activeId', id ?? null);
72
-
73
- isSet = true;
74
-
75
- break;
76
- }
77
-
78
- leaf = leaf.parentElement;
79
- }
80
-
81
- if (!isSet) unsetActiveSuggestion();
82
- },
83
- },
84
- render: {
85
- belowNodes: SuggestionLineBreak as any,
86
- node: SuggestionLeaf,
87
- },
88
- });
89
-
90
- export const SuggestionKit = [suggestionPlugin];
@@ -1,20 +0,0 @@
1
- import {
2
- BaseTableCellHeaderPlugin,
3
- BaseTableCellPlugin,
4
- BaseTablePlugin,
5
- BaseTableRowPlugin,
6
- } from '@platejs/table';
7
-
8
- import {
9
- TableCellElementStatic,
10
- TableCellHeaderElementStatic,
11
- TableElementStatic,
12
- TableRowElementStatic,
13
- } from '@/components/ui/table-node-static';
14
-
15
- export const BaseTableKit = [
16
- BaseTablePlugin.withComponent(TableElementStatic),
17
- BaseTableRowPlugin.withComponent(TableRowElementStatic),
18
- BaseTableCellPlugin.withComponent(TableCellElementStatic),
19
- BaseTableCellHeaderPlugin.withComponent(TableCellHeaderElementStatic),
20
- ];
@@ -1,22 +0,0 @@
1
- 'use client';
2
-
3
- import {
4
- TableCellHeaderPlugin,
5
- TableCellPlugin,
6
- TablePlugin,
7
- TableRowPlugin,
8
- } from '@platejs/table/react';
9
-
10
- import {
11
- TableCellElement,
12
- TableCellHeaderElement,
13
- TableElement,
14
- TableRowElement,
15
- } from '@/components/ui/table-node';
16
-
17
- export const TableKit = [
18
- TablePlugin.withComponent(TableElement),
19
- TableRowPlugin.withComponent(TableRowElement),
20
- TableCellPlugin.withComponent(TableCellElement),
21
- TableCellHeaderPlugin.withComponent(TableCellHeaderElement),
22
- ];
@@ -1,5 +0,0 @@
1
- import { BaseTocPlugin } from '@platejs/toc';
2
-
3
- import { TocElementStatic } from '@/components/ui/toc-node-static';
4
-
5
- export const BaseTocKit = [BaseTocPlugin.withComponent(TocElementStatic)];
@@ -1,14 +0,0 @@
1
- 'use client';
2
-
3
- import { TocPlugin } from '@platejs/toc/react';
4
-
5
- import { TocElement } from '@/components/ui/toc-node';
6
-
7
- export const TocKit = [
8
- TocPlugin.configure({
9
- options: {
10
- // isScroll: true,
11
- topOffset: 80,
12
- },
13
- }).withComponent(TocElement),
14
- ];
@@ -1,7 +0,0 @@
1
- import { BaseTogglePlugin } from '@platejs/toggle';
2
-
3
- import { ToggleElementStatic } from '@/components/ui/toggle-node-static';
4
-
5
- export const BaseToggleKit = [
6
- BaseTogglePlugin.withComponent(ToggleElementStatic),
7
- ];
@@ -1,11 +0,0 @@
1
- 'use client';
2
-
3
- import { TogglePlugin } from '@platejs/toggle/react';
4
-
5
- import { IndentKit } from '@/components/editor/plugins/indent-kit';
6
- import { ToggleElement } from '@/components/ui/toggle-node';
7
-
8
- export const ToggleKit = [
9
- ...IndentKit,
10
- TogglePlugin.withComponent(ToggleElement),
11
- ];
@@ -1,194 +0,0 @@
1
- 'use client';
2
-
3
- import type { PlateEditor } from 'platejs/react';
4
-
5
- import { insertCallout } from '@platejs/callout';
6
- import { insertCodeBlock, toggleCodeBlock } from '@platejs/code-block';
7
- import { insertDate } from '@platejs/date';
8
- import { insertExcalidraw } from '@platejs/excalidraw';
9
- import { insertColumnGroup, toggleColumnGroup } from '@platejs/layout';
10
- import { triggerFloatingLink } from '@platejs/link/react';
11
- import { insertEquation, insertInlineEquation } from '@platejs/math';
12
- import {
13
- insertAudioPlaceholder,
14
- insertFilePlaceholder,
15
- insertMedia,
16
- insertVideoPlaceholder,
17
- } from '@platejs/media';
18
- import { SuggestionPlugin } from '@platejs/suggestion/react';
19
- import { TablePlugin } from '@platejs/table/react';
20
- import { insertToc } from '@platejs/toc';
21
- import { type NodeEntry, type Path, type TElement, KEYS, PathApi } from 'platejs';
22
- import { CodebaseSnippetType } from './plugins/codebase-kit';
23
-
24
- const ACTION_THREE_COLUMNS = 'action_three_columns';
25
-
26
- const insertList = (editor: PlateEditor, type: string) => {
27
- editor.tf.insertNodes(
28
- editor.api.create.block({
29
- indent: 1,
30
- listStyleType: type,
31
- }),
32
- { select: true }
33
- );
34
- };
35
-
36
- const insertBlockMap: Record<string, (editor: PlateEditor, type: string) => void> = {
37
- [KEYS.listTodo]: insertList,
38
- [KEYS.ol]: insertList,
39
- [KEYS.ul]: insertList,
40
- [ACTION_THREE_COLUMNS]: (editor) => insertColumnGroup(editor, { columns: 3, select: true }),
41
- [KEYS.audio]: (editor) => insertAudioPlaceholder(editor, { select: true }),
42
- [KEYS.callout]: (editor) => insertCallout(editor, { select: true }),
43
- [KEYS.codeBlock]: (editor) => insertCodeBlock(editor, { select: true }),
44
- [KEYS.equation]: (editor) => insertEquation(editor, { select: true }),
45
- [KEYS.excalidraw]: (editor) => insertExcalidraw(editor, {}, { select: true }),
46
- [KEYS.file]: (editor) => insertFilePlaceholder(editor, { select: true }),
47
- [KEYS.img]: (editor) =>
48
- insertMedia(editor, {
49
- select: true,
50
- type: KEYS.img,
51
- }),
52
- [KEYS.mediaEmbed]: (editor) =>
53
- insertMedia(editor, {
54
- select: true,
55
- type: KEYS.mediaEmbed,
56
- }),
57
- [KEYS.table]: (editor) => editor.getTransforms(TablePlugin).insert.table({}, { select: true }),
58
- [KEYS.toc]: (editor) => insertToc(editor, { select: true }),
59
- [KEYS.video]: (editor) => insertVideoPlaceholder(editor, { select: true }),
60
- };
61
-
62
- const insertInlineMap: Record<string, (editor: PlateEditor, type: string) => void> = {
63
- [KEYS.date]: (editor) => insertDate(editor, { select: true }),
64
- [KEYS.inlineEquation]: (editor) => insertInlineEquation(editor, '', { select: true }),
65
- [KEYS.link]: (editor) => triggerFloatingLink(editor, { focused: true }),
66
- };
67
-
68
- type InsertBlockOptions = {
69
- upsert?: boolean;
70
- };
71
-
72
- export const insertBlock = (
73
- editor: PlateEditor,
74
- type: string,
75
- options: InsertBlockOptions = {}
76
- ) => {
77
- const { upsert = false } = options;
78
-
79
- editor.tf.withoutNormalizing(() => {
80
- const block = editor.api.block();
81
-
82
- if (!block) return;
83
-
84
- const [currentNode, path] = block;
85
- const isCurrentBlockEmpty = editor.api.isEmpty(currentNode);
86
- const currentBlockType = getBlockType(currentNode);
87
-
88
- const isSameBlockType = type === currentBlockType;
89
-
90
- if (upsert && isCurrentBlockEmpty && isSameBlockType) {
91
- return;
92
- }
93
-
94
- if (type in insertBlockMap) {
95
- insertBlockMap[type](editor, type);
96
- } else if (type === CodebaseSnippetType) {
97
- editor.tf.insertNodes({
98
- type: CodebaseSnippetType,
99
- filePath: '',
100
- lineStart: '',
101
- lineEnd: '',
102
- children: [{ text: '' }],
103
- });
104
- } else {
105
- editor.tf.insertNodes(editor.api.create.block({ type }), {
106
- at: PathApi.next(path),
107
- select: true,
108
- });
109
- }
110
-
111
- if (!isSameBlockType) {
112
- editor.getApi(SuggestionPlugin).suggestion.withoutSuggestions(() => {
113
- editor.tf.removeNodes({ previousEmptyBlock: true });
114
- });
115
- }
116
- });
117
- };
118
-
119
- export const insertInlineElement = (editor: PlateEditor, type: string) => {
120
- if (insertInlineMap[type]) {
121
- insertInlineMap[type](editor, type);
122
- }
123
- };
124
-
125
- const setList = (editor: PlateEditor, type: string, entry: NodeEntry<TElement>) => {
126
- editor.tf.setNodes(
127
- editor.api.create.block({
128
- indent: 1,
129
- listStyleType: type,
130
- }),
131
- {
132
- at: entry[1],
133
- }
134
- );
135
- };
136
-
137
- const setBlockMap: Record<
138
- string,
139
- (editor: PlateEditor, type: string, entry: NodeEntry<TElement>) => void
140
- > = {
141
- [KEYS.listTodo]: setList,
142
- [KEYS.ol]: setList,
143
- [KEYS.ul]: setList,
144
- [ACTION_THREE_COLUMNS]: (editor) => toggleColumnGroup(editor, { columns: 3 }),
145
- [KEYS.codeBlock]: (editor) => toggleCodeBlock(editor),
146
- };
147
-
148
- export const setBlockType = (editor: PlateEditor, type: string, { at }: { at?: Path } = {}) => {
149
- editor.tf.withoutNormalizing(() => {
150
- const setEntry = (entry: NodeEntry<TElement>) => {
151
- const [node, path] = entry;
152
-
153
- if (node[KEYS.listType]) {
154
- editor.tf.unsetNodes([KEYS.listType, 'indent'], { at: path });
155
- }
156
- if (type in setBlockMap) {
157
- return setBlockMap[type](editor, type, entry);
158
- }
159
- if (node.type !== type) {
160
- editor.tf.setNodes({ type }, { at: path });
161
- }
162
- };
163
-
164
- if (at) {
165
- const entry = editor.api.node<TElement>(at);
166
-
167
- if (entry) {
168
- setEntry(entry);
169
-
170
- return;
171
- }
172
- }
173
-
174
- const entries = editor.api.blocks({ mode: 'lowest' });
175
-
176
- entries.forEach((entry) => {
177
- setEntry(entry);
178
- });
179
- });
180
- };
181
-
182
- export const getBlockType = (block: TElement) => {
183
- if (block[KEYS.listType]) {
184
- if (block[KEYS.listType] === KEYS.ol) {
185
- return KEYS.ol;
186
- }
187
- if (block[KEYS.listType] === KEYS.listTodo) {
188
- return KEYS.listTodo;
189
- }
190
- return KEYS.ul;
191
- }
192
-
193
- return block.type;
194
- };
@@ -1,50 +0,0 @@
1
- import { MarkdownPlugin, remarkMdx, remarkMention } from '@platejs/markdown';
2
- import { Plate, usePlateEditor } from 'platejs/react';
3
- import remarkEmoji from 'remark-emoji';
4
- import remarkGfm from 'remark-gfm';
5
- import remarkMath from 'remark-math';
6
- import { useEffect, useRef } from 'react';
7
-
8
- import { EditorKit } from '@/components/editor/editor-kit';
9
- import { Editor, EditorContainer } from '@/components/ui/editor';
10
-
11
- export default function MarkdownDemo(
12
- { initialMarkdown, onUpdate }: { initialMarkdown: string, onUpdate: (content: string) => void }
13
- ) {
14
- const previousMarkdown = useRef<string>('');
15
- const editor = usePlateEditor(
16
- {
17
- plugins: EditorKit,
18
- value: (editor) => editor.getApi(MarkdownPlugin).markdown.deserialize(initialMarkdown, {
19
- remarkPlugins: [
20
- remarkMath,
21
- remarkGfm,
22
- remarkMdx,
23
- remarkMention,
24
- remarkEmoji as any,
25
- ],
26
- })
27
- },
28
- []
29
- );
30
-
31
- // useEffect that runs every 250ms and logs the serialized markdown to the console
32
- useEffect(() => {
33
- const interval = setInterval(() => {
34
- const serialized = editor.getApi(MarkdownPlugin).markdown.serialize();
35
- if (serialized !== previousMarkdown.current) {
36
- previousMarkdown.current = serialized;
37
- onUpdate(serialized);
38
- }
39
- }, 500);
40
- return () => clearInterval(interval);
41
- }, [editor, onUpdate]);
42
-
43
- return (
44
- <Plate editor={editor}>
45
- <EditorContainer>
46
- <Editor variant="none" className="px-8 py-2" />
47
- </EditorContainer>
48
- </Plate>
49
- );
50
- }
@@ -1,15 +0,0 @@
1
- import { Moon, Sun } from "lucide-react"
2
- import { Button } from "@/components/ui/button"
3
- import { useTheme } from "@/components/theme-provider"
4
-
5
- export function ModeToggle() {
6
- const { setTheme, theme } = useTheme()
7
-
8
- return (
9
- <Button variant="outline" size="icon" onClick={() => setTheme(theme === "dark" ? "light" : "dark")}>
10
- <Sun className="h-[1.2rem] w-[1.2rem] scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90" />
11
- <Moon className="absolute h-[1.2rem] w-[1.2rem] scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0" />
12
- <span className="sr-only">Toggle theme</span>
13
- </Button>
14
- )
15
- }