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,152 +0,0 @@
1
- import React from 'react';
2
-
3
- import type { TElement } from 'platejs';
4
-
5
- import { toUnitLess } from '@platejs/basic-styles';
6
- import { FontSizePlugin } from '@platejs/basic-styles/react';
7
- import { Minus, Plus } from 'lucide-react';
8
- import { KEYS } from 'platejs';
9
- import { useEditorPlugin, useEditorSelector } from 'platejs/react';
10
-
11
- import {
12
- Popover,
13
- PopoverContent,
14
- PopoverTrigger,
15
- } from '@/components/ui/popover';
16
- import { cn } from '@/lib/utils';
17
-
18
- import { ToolbarButton } from './toolbar';
19
-
20
- const DEFAULT_FONT_SIZE = '16';
21
-
22
- const FONT_SIZE_MAP = {
23
- h1: '36',
24
- h2: '24',
25
- h3: '20',
26
- } as const;
27
-
28
- const FONT_SIZES = [
29
- '8',
30
- '9',
31
- '10',
32
- '12',
33
- '14',
34
- '16',
35
- '18',
36
- '24',
37
- '30',
38
- '36',
39
- '48',
40
- '60',
41
- '72',
42
- '96',
43
- ] as const;
44
-
45
- export function FontSizeToolbarButton() {
46
- const [inputValue, setInputValue] = React.useState(DEFAULT_FONT_SIZE);
47
- const [isFocused, setIsFocused] = React.useState(false);
48
- const { editor, tf } = useEditorPlugin(FontSizePlugin);
49
-
50
- const cursorFontSize = useEditorSelector((editor) => {
51
- const fontSize = editor.api.marks()?.[KEYS.fontSize];
52
-
53
- if (fontSize) {
54
- return toUnitLess(fontSize as string);
55
- }
56
-
57
- const [block] = editor.api.block<TElement>() || [];
58
-
59
- if (!block?.type) return DEFAULT_FONT_SIZE;
60
-
61
- return block.type in FONT_SIZE_MAP
62
- ? FONT_SIZE_MAP[block.type as keyof typeof FONT_SIZE_MAP]
63
- : DEFAULT_FONT_SIZE;
64
- }, []);
65
-
66
- const handleInputChange = () => {
67
- const newSize = toUnitLess(inputValue);
68
-
69
- if (
70
- Number.parseInt(newSize, 10) < 1 ||
71
- Number.parseInt(newSize, 10) > 100
72
- ) {
73
- editor.tf.focus();
74
-
75
- return;
76
- }
77
- if (newSize !== toUnitLess(cursorFontSize)) {
78
- tf.fontSize.addMark(`${newSize}px`);
79
- }
80
-
81
- editor.tf.focus();
82
- };
83
-
84
- const handleFontSizeChange = (delta: number) => {
85
- const newSize = Number(displayValue) + delta;
86
- tf.fontSize.addMark(`${newSize}px`);
87
- editor.tf.focus();
88
- };
89
-
90
- const displayValue = isFocused ? inputValue : cursorFontSize;
91
-
92
- return (
93
- <div className="flex h-7 items-center gap-1 rounded-md bg-muted/60 p-0">
94
- <ToolbarButton onClick={() => handleFontSizeChange(-1)}>
95
- <Minus />
96
- </ToolbarButton>
97
-
98
- <Popover open={isFocused} modal={false}>
99
- <PopoverTrigger asChild>
100
- <input
101
- className={cn(
102
- 'h-full w-10 shrink-0 bg-transparent px-1 text-center text-sm hover:bg-muted'
103
- )}
104
- value={displayValue}
105
- onBlur={() => {
106
- setIsFocused(false);
107
- handleInputChange();
108
- }}
109
- onChange={(e) => setInputValue(e.target.value)}
110
- onFocus={() => {
111
- setIsFocused(true);
112
- setInputValue(toUnitLess(cursorFontSize));
113
- }}
114
- onKeyDown={(e) => {
115
- if (e.key === 'Enter') {
116
- e.preventDefault();
117
- handleInputChange();
118
- }
119
- }}
120
- data-plate-focus="true"
121
- type="text"
122
- />
123
- </PopoverTrigger>
124
- <PopoverContent
125
- className="w-10 px-px py-1"
126
- onOpenAutoFocus={(e) => e.preventDefault()}
127
- >
128
- {FONT_SIZES.map((size) => (
129
- <button
130
- key={size}
131
- className={cn(
132
- 'flex h-8 w-full items-center justify-center text-sm hover:bg-accent data-[highlighted=true]:bg-accent'
133
- )}
134
- onClick={() => {
135
- tf.fontSize.addMark(`${size}px`);
136
- setIsFocused(false);
137
- }}
138
- data-highlighted={size === displayValue}
139
- type="button"
140
- >
141
- {size}
142
- </button>
143
- ))}
144
- </PopoverContent>
145
- </Popover>
146
-
147
- <ToolbarButton onClick={() => handleFontSizeChange(1)}>
148
- <Plus />
149
- </ToolbarButton>
150
- </div>
151
- );
152
- }
@@ -1,68 +0,0 @@
1
- import * as React from 'react';
2
-
3
- import type { SlateElementProps } from 'platejs/static';
4
-
5
- import { type VariantProps, cva } from 'class-variance-authority';
6
- import { SlateElement } from 'platejs/static';
7
-
8
- const headingVariants = cva('relative mb-1', {
9
- variants: {
10
- variant: {
11
- h1: 'mt-[1.6em] pb-1 font-bold font-heading text-4xl',
12
- h2: 'mt-[1.4em] pb-px font-heading font-semibold text-2xl tracking-tight',
13
- h3: 'mt-[1em] pb-px font-heading font-semibold text-xl tracking-tight',
14
- h4: 'mt-[0.75em] font-heading font-semibold text-lg tracking-tight',
15
- h5: 'mt-[0.75em] font-semibold text-lg tracking-tight',
16
- h6: 'mt-[0.75em] font-semibold text-base tracking-tight',
17
- },
18
- },
19
- });
20
-
21
- export function HeadingElementStatic({
22
- variant = 'h1',
23
- ...props
24
- }: SlateElementProps & VariantProps<typeof headingVariants>) {
25
- return (
26
- <SlateElement
27
- as={variant!}
28
- className={headingVariants({ variant })}
29
- {...props}
30
- >
31
- {props.children}
32
- </SlateElement>
33
- );
34
- }
35
-
36
- export function H1ElementStatic(props: SlateElementProps) {
37
- return <HeadingElementStatic variant="h1" {...props} />;
38
- }
39
-
40
- export function H2ElementStatic(
41
- props: React.ComponentProps<typeof HeadingElementStatic>
42
- ) {
43
- return <HeadingElementStatic variant="h2" {...props} />;
44
- }
45
-
46
- export function H3ElementStatic(
47
- props: React.ComponentProps<typeof HeadingElementStatic>
48
- ) {
49
- return <HeadingElementStatic variant="h3" {...props} />;
50
- }
51
-
52
- export function H4ElementStatic(
53
- props: React.ComponentProps<typeof HeadingElementStatic>
54
- ) {
55
- return <HeadingElementStatic variant="h4" {...props} />;
56
- }
57
-
58
- export function H5ElementStatic(
59
- props: React.ComponentProps<typeof HeadingElementStatic>
60
- ) {
61
- return <HeadingElementStatic variant="h5" {...props} />;
62
- }
63
-
64
- export function H6ElementStatic(
65
- props: React.ComponentProps<typeof HeadingElementStatic>
66
- ) {
67
- return <HeadingElementStatic variant="h6" {...props} />;
68
- }
@@ -1,58 +0,0 @@
1
-
2
-
3
- import type { PlateElementProps } from 'platejs/react';
4
-
5
- import { type VariantProps, cva } from 'class-variance-authority';
6
- import { PlateElement } from 'platejs/react';
7
-
8
- const headingVariants = cva('relative mb-1', {
9
- variants: {
10
- variant: {
11
- h1: 'mt-[1.6em] pb-1 font-bold font-heading text-4xl',
12
- h2: 'mt-[1.4em] pb-px font-heading font-semibold text-2xl tracking-tight',
13
- h3: 'mt-[1em] pb-px font-heading font-semibold text-xl tracking-tight',
14
- h4: 'mt-[0.75em] font-heading font-semibold text-lg tracking-tight',
15
- h5: 'mt-[0.75em] font-semibold text-lg tracking-tight',
16
- h6: 'mt-[0.75em] font-semibold text-base tracking-tight',
17
- },
18
- },
19
- });
20
-
21
- export function HeadingElement({
22
- variant = 'h1',
23
- ...props
24
- }: PlateElementProps & VariantProps<typeof headingVariants>) {
25
- return (
26
- <PlateElement
27
- as={variant!}
28
- className={headingVariants({ variant })}
29
- {...props}
30
- >
31
- {props.children}
32
- </PlateElement>
33
- );
34
- }
35
-
36
- export function H1Element(props: PlateElementProps) {
37
- return <HeadingElement variant="h1" {...props} />;
38
- }
39
-
40
- export function H2Element(props: PlateElementProps) {
41
- return <HeadingElement variant="h2" {...props} />;
42
- }
43
-
44
- export function H3Element(props: PlateElementProps) {
45
- return <HeadingElement variant="h3" {...props} />;
46
- }
47
-
48
- export function H4Element(props: PlateElementProps) {
49
- return <HeadingElement variant="h4" {...props} />;
50
- }
51
-
52
- export function H5Element(props: PlateElementProps) {
53
- return <HeadingElement variant="h5" {...props} />;
54
- }
55
-
56
- export function H6Element(props: PlateElementProps) {
57
- return <HeadingElement variant="h6" {...props} />;
58
- }
@@ -1,11 +0,0 @@
1
- import type { SlateLeafProps } from 'platejs/static';
2
-
3
- import { SlateLeaf } from 'platejs/static';
4
-
5
- export function HighlightLeafStatic(props: SlateLeafProps) {
6
- return (
7
- <SlateLeaf {...props} as="mark" className="bg-highlight/30 text-inherit">
8
- {props.children}
9
- </SlateLeaf>
10
- );
11
- }
@@ -1,13 +0,0 @@
1
-
2
-
3
- import type { PlateLeafProps } from 'platejs/react';
4
-
5
- import { PlateLeaf } from 'platejs/react';
6
-
7
- export function HighlightLeaf(props: PlateLeafProps) {
8
- return (
9
- <PlateLeaf {...props} as="mark" className="bg-highlight/30 text-inherit">
10
- {props.children}
11
- </PlateLeaf>
12
- );
13
- }
@@ -1,50 +0,0 @@
1
-
2
-
3
- import { Redo2Icon, Undo2Icon } from 'lucide-react';
4
- import { useEditorRef, useEditorSelector } from 'platejs/react';
5
-
6
- import { ToolbarButton } from './toolbar';
7
-
8
- export function RedoToolbarButton(
9
- props: React.ComponentProps<typeof ToolbarButton>
10
- ) {
11
- const editor = useEditorRef();
12
- const disabled = useEditorSelector(
13
- (editor) => editor.history.redos.length === 0,
14
- []
15
- );
16
-
17
- return (
18
- <ToolbarButton
19
- {...props}
20
- disabled={disabled}
21
- onClick={() => editor.redo()}
22
- onMouseDown={(e) => e.preventDefault()}
23
- tooltip="Redo"
24
- >
25
- <Redo2Icon />
26
- </ToolbarButton>
27
- );
28
- }
29
-
30
- export function UndoToolbarButton(
31
- props: React.ComponentProps<typeof ToolbarButton>
32
- ) {
33
- const editor = useEditorRef();
34
- const disabled = useEditorSelector(
35
- (editor) => editor.history.undos.length === 0,
36
- []
37
- );
38
-
39
- return (
40
- <ToolbarButton
41
- {...props}
42
- disabled={disabled}
43
- onClick={() => editor.undo()}
44
- onMouseDown={(e) => e.preventDefault()}
45
- tooltip="Undo"
46
- >
47
- <Undo2Icon />
48
- </ToolbarButton>
49
- );
50
- }
@@ -1,20 +0,0 @@
1
- import type { SlateElementProps } from 'platejs/static';
2
-
3
- import { SlateElement } from 'platejs/static';
4
-
5
- import { cn } from '@/lib/utils';
6
-
7
- export function HrElementStatic(props: SlateElementProps) {
8
- return (
9
- <SlateElement {...props}>
10
- <div className="cursor-text py-6" contentEditable={false}>
11
- <hr
12
- className={cn(
13
- 'h-0.5 rounded-sm border-none bg-muted bg-clip-content'
14
- )}
15
- />
16
- </div>
17
- {props.children}
18
- </SlateElement>
19
- );
20
- }
@@ -1,33 +0,0 @@
1
-
2
-
3
- import type { PlateElementProps } from 'platejs/react';
4
-
5
- import {
6
- PlateElement,
7
- useFocused,
8
- useReadOnly,
9
- useSelected,
10
- } from 'platejs/react';
11
-
12
- import { cn } from '@/lib/utils';
13
-
14
- export function HrElement(props: PlateElementProps) {
15
- const readOnly = useReadOnly();
16
- const selected = useSelected();
17
- const focused = useFocused();
18
-
19
- return (
20
- <PlateElement {...props}>
21
- <div className="py-6" contentEditable={false}>
22
- <hr
23
- className={cn(
24
- 'h-0.5 rounded-sm border-none bg-muted bg-clip-content',
25
- selected && focused && 'ring-2 ring-ring ring-offset-2',
26
- !readOnly && 'cursor-pointer'
27
- )}
28
- />
29
- </div>
30
- {props.children}
31
- </PlateElement>
32
- );
33
- }
@@ -1,97 +0,0 @@
1
- import React from 'react';
2
-
3
- import type { DropdownMenuProps } from '@radix-ui/react-dropdown-menu';
4
-
5
- import { MarkdownPlugin } from '@platejs/markdown';
6
- import { ArrowUpToLineIcon } from 'lucide-react';
7
- import { useEditorRef } from 'platejs/react';
8
- import { getEditorDOMFromHtmlString } from 'platejs/static';
9
- import { useFilePicker } from 'use-file-picker';
10
-
11
- import {
12
- DropdownMenu,
13
- DropdownMenuContent,
14
- DropdownMenuGroup,
15
- DropdownMenuItem,
16
- DropdownMenuTrigger,
17
- } from '@/components/ui/dropdown-menu';
18
-
19
- import { ToolbarButton } from './toolbar';
20
-
21
- type ImportType = 'html' | 'markdown';
22
-
23
- export function ImportToolbarButton(props: DropdownMenuProps) {
24
- const editor = useEditorRef();
25
- const [open, setOpen] = React.useState(false);
26
-
27
- const getFileNodes = (text: string, type: ImportType) => {
28
- if (type === 'html') {
29
- const editorNode = getEditorDOMFromHtmlString(text);
30
- const nodes = editor.api.html.deserialize({
31
- element: editorNode,
32
- });
33
-
34
- return nodes;
35
- }
36
-
37
- if (type === 'markdown') {
38
- return editor.getApi(MarkdownPlugin).markdown.deserialize(text);
39
- }
40
-
41
- return [];
42
- };
43
-
44
- const { openFilePicker: openMdFilePicker } = useFilePicker({
45
- accept: ['.md', '.mdx'],
46
- multiple: false,
47
- onFilesSelected: async ({ plainFiles }) => {
48
- const text = await plainFiles[0].text();
49
-
50
- const nodes = getFileNodes(text, 'markdown');
51
-
52
- editor.tf.insertNodes(nodes);
53
- },
54
- });
55
-
56
- const { openFilePicker: openHtmlFilePicker } = useFilePicker({
57
- accept: ['text/html'],
58
- multiple: false,
59
- onFilesSelected: async ({ plainFiles }) => {
60
- const text = await plainFiles[0].text();
61
-
62
- const nodes = getFileNodes(text, 'html');
63
-
64
- editor.tf.insertNodes(nodes);
65
- },
66
- });
67
-
68
- return (
69
- <DropdownMenu open={open} onOpenChange={setOpen} modal={false} {...props}>
70
- <DropdownMenuTrigger asChild>
71
- <ToolbarButton pressed={open} tooltip="Import" isDropdown>
72
- <ArrowUpToLineIcon className="size-4" />
73
- </ToolbarButton>
74
- </DropdownMenuTrigger>
75
-
76
- <DropdownMenuContent align="start">
77
- <DropdownMenuGroup>
78
- <DropdownMenuItem
79
- onSelect={() => {
80
- openHtmlFilePicker();
81
- }}
82
- >
83
- Import from HTML
84
- </DropdownMenuItem>
85
-
86
- <DropdownMenuItem
87
- onSelect={() => {
88
- openMdFilePicker();
89
- }}
90
- >
91
- Import from Markdown
92
- </DropdownMenuItem>
93
- </DropdownMenuGroup>
94
- </DropdownMenuContent>
95
- </DropdownMenu>
96
- );
97
- }
@@ -1,30 +0,0 @@
1
-
2
-
3
- import { useIndentButton, useOutdentButton } from '@platejs/indent/react';
4
- import { IndentIcon, OutdentIcon } from 'lucide-react';
5
-
6
- import { ToolbarButton } from './toolbar';
7
-
8
- export function IndentToolbarButton(
9
- props: React.ComponentProps<typeof ToolbarButton>
10
- ) {
11
- const { props: buttonProps } = useIndentButton();
12
-
13
- return (
14
- <ToolbarButton {...props} {...buttonProps} tooltip="Indent">
15
- <IndentIcon />
16
- </ToolbarButton>
17
- );
18
- }
19
-
20
- export function OutdentToolbarButton(
21
- props: React.ComponentProps<typeof ToolbarButton>
22
- ) {
23
- const { props: buttonProps } = useOutdentButton();
24
-
25
- return (
26
- <ToolbarButton {...props} {...buttonProps} tooltip="Outdent">
27
- <OutdentIcon />
28
- </ToolbarButton>
29
- );
30
- }