@groupher/rich-editor 0.0.1

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 (49) hide show
  1. package/README.md +69 -0
  2. package/components.json +21 -0
  3. package/dist/rich-editor.css +1 -0
  4. package/dist/rich-editor.es.js +60825 -0
  5. package/dist/rich-editor.umd.js +361 -0
  6. package/dist/vite.svg +1 -0
  7. package/eslint.config.js +26 -0
  8. package/index.html +13 -0
  9. package/package.json +54 -0
  10. package/public/vite.svg +1 -0
  11. package/src/RichEditor.tsx +102 -0
  12. package/src/assets/react.svg +1 -0
  13. package/src/components/editor/plate-editor.tsx +54 -0
  14. package/src/components/editor/plugins/basic-blocks-base-kit.tsx +35 -0
  15. package/src/components/editor/plugins/basic-blocks-kit.tsx +88 -0
  16. package/src/components/editor/plugins/basic-marks-base-kit.tsx +27 -0
  17. package/src/components/editor/plugins/basic-marks-kit.tsx +41 -0
  18. package/src/components/editor/plugins/basic-nodes-kit.tsx +6 -0
  19. package/src/components/ui/blockquote-node-static.tsx +11 -0
  20. package/src/components/ui/blockquote-node.tsx +13 -0
  21. package/src/components/ui/button.tsx +59 -0
  22. package/src/components/ui/code-node-static.tsx +15 -0
  23. package/src/components/ui/code-node.tsx +17 -0
  24. package/src/components/ui/dropdown-menu.tsx +255 -0
  25. package/src/components/ui/editor-static.tsx +53 -0
  26. package/src/components/ui/editor.tsx +129 -0
  27. package/src/components/ui/fixed-toolbar.tsx +17 -0
  28. package/src/components/ui/heading-node-static.tsx +66 -0
  29. package/src/components/ui/heading-node.tsx +58 -0
  30. package/src/components/ui/highlight-node-static.tsx +11 -0
  31. package/src/components/ui/highlight-node.tsx +13 -0
  32. package/src/components/ui/hr-node-static.tsx +20 -0
  33. package/src/components/ui/hr-node.tsx +33 -0
  34. package/src/components/ui/kbd-node-static.tsx +15 -0
  35. package/src/components/ui/kbd-node.tsx +17 -0
  36. package/src/components/ui/mark-toolbar-button.tsx +19 -0
  37. package/src/components/ui/paragraph-node-static.tsx +13 -0
  38. package/src/components/ui/paragraph-node.tsx +15 -0
  39. package/src/components/ui/separator.tsx +28 -0
  40. package/src/components/ui/toolbar.tsx +389 -0
  41. package/src/components/ui/tooltip.tsx +59 -0
  42. package/src/global.css +235 -0
  43. package/src/lib/utils.ts +6 -0
  44. package/src/main.tsx +11 -0
  45. package/src/vite-env.d.ts +1 -0
  46. package/tsconfig.app.json +31 -0
  47. package/tsconfig.json +10 -0
  48. package/tsconfig.node.json +25 -0
  49. package/vite.config.ts +40 -0
package/src/global.css ADDED
@@ -0,0 +1,235 @@
1
+ @import "tailwindcss";
2
+
3
+ @plugin "tailwind-scrollbar-hide";
4
+ @import "tw-animate-css";
5
+
6
+ @custom-variant dark (&:is(.dark *));
7
+
8
+ @theme inline {
9
+ --radius-sm: calc(var(--radius) - 4px);
10
+ --radius-md: calc(var(--radius) - 2px);
11
+ --radius-lg: var(--radius);
12
+ --radius-xl: calc(var(--radius) + 4px);
13
+ --color-background: var(--background);
14
+ --color-foreground: var(--foreground);
15
+ --color-card: var(--card);
16
+ --color-card-foreground: var(--card-foreground);
17
+ --color-popover: var(--popover);
18
+ --color-popover-foreground: var(--popover-foreground);
19
+ --color-primary: var(--primary);
20
+ --color-primary-foreground: var(--primary-foreground);
21
+ --color-secondary: var(--secondary);
22
+ --color-secondary-foreground: var(--secondary-foreground);
23
+ --color-muted: var(--muted);
24
+ --color-muted-foreground: var(--muted-foreground);
25
+ --color-accent: var(--accent);
26
+ --color-accent-foreground: var(--accent-foreground);
27
+ --color-destructive: var(--destructive);
28
+ --color-border: var(--border);
29
+ --color-input: var(--input);
30
+ --color-ring: var(--ring);
31
+ --color-chart-1: var(--chart-1);
32
+ --color-chart-2: var(--chart-2);
33
+ --color-chart-3: var(--chart-3);
34
+ --color-chart-4: var(--chart-4);
35
+ --color-chart-5: var(--chart-5);
36
+ --color-sidebar: var(--sidebar);
37
+ --color-sidebar-foreground: var(--sidebar-foreground);
38
+ --color-sidebar-primary: var(--sidebar-primary);
39
+ --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
40
+ --color-sidebar-accent: var(--sidebar-accent);
41
+ --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
42
+ --color-sidebar-border: var(--sidebar-border);
43
+ --color-sidebar-ring: var(--sidebar-ring);
44
+ --color-brand: var(--brand);
45
+ --color-highlight: var(--highlight);
46
+ }
47
+
48
+ :root {
49
+ --radius: 0.625rem;
50
+ --background: oklch(1 0 0);
51
+ --foreground: oklch(0.145 0 0);
52
+ --card: oklch(1 0 0);
53
+ --card-foreground: oklch(0.145 0 0);
54
+ --popover: oklch(1 0 0);
55
+ --popover-foreground: oklch(0.145 0 0);
56
+ --primary: oklch(0.205 0 0);
57
+ --primary-foreground: oklch(0.985 0 0);
58
+ --secondary: oklch(0.97 0 0);
59
+ --secondary-foreground: oklch(0.205 0 0);
60
+ --muted: oklch(0.97 0 0);
61
+ --muted-foreground: oklch(0.556 0 0);
62
+ --accent: oklch(0.97 0 0);
63
+ --accent-foreground: oklch(0.205 0 0);
64
+ --destructive: oklch(0.577 0.245 27.325);
65
+ --border: oklch(0.922 0 0);
66
+ --input: oklch(0.922 0 0);
67
+ --ring: oklch(0.708 0 0);
68
+ --chart-1: oklch(0.646 0.222 41.116);
69
+ --chart-2: oklch(0.6 0.118 184.704);
70
+ --chart-3: oklch(0.398 0.07 227.392);
71
+ --chart-4: oklch(0.828 0.189 84.429);
72
+ --chart-5: oklch(0.769 0.188 70.08);
73
+ --sidebar: oklch(0.985 0 0);
74
+ --sidebar-foreground: oklch(0.145 0 0);
75
+ --sidebar-primary: oklch(0.205 0 0);
76
+ --sidebar-primary-foreground: oklch(0.985 0 0);
77
+ --sidebar-accent: oklch(0.97 0 0);
78
+ --sidebar-accent-foreground: oklch(0.205 0 0);
79
+ --sidebar-border: oklch(0.922 0 0);
80
+ --sidebar-ring: oklch(0.708 0 0);
81
+ --brand: oklch(0.623 0.214 259.815);
82
+ --highlight: oklch(0.852 0.199 91.936);
83
+ }
84
+
85
+ .dark {
86
+ --background: oklch(0.145 0 0);
87
+ --foreground: oklch(0.985 0 0);
88
+ --card: oklch(0.205 0 0);
89
+ --card-foreground: oklch(0.985 0 0);
90
+ --popover: oklch(0.205 0 0);
91
+ --popover-foreground: oklch(0.985 0 0);
92
+ --primary: oklch(0.922 0 0);
93
+ --primary-foreground: oklch(0.205 0 0);
94
+ --secondary: oklch(0.269 0 0);
95
+ --secondary-foreground: oklch(0.985 0 0);
96
+ --muted: oklch(0.269 0 0);
97
+ --muted-foreground: oklch(0.708 0 0);
98
+ --accent: oklch(0.269 0 0);
99
+ --accent-foreground: oklch(0.985 0 0);
100
+ --destructive: oklch(0.704 0.191 22.216);
101
+ --border: oklch(1 0 0 / 10%);
102
+ --input: oklch(1 0 0 / 15%);
103
+ --ring: oklch(0.556 0 0);
104
+ --chart-1: oklch(0.488 0.243 264.376);
105
+ --chart-2: oklch(0.696 0.17 162.48);
106
+ --chart-3: oklch(0.769 0.188 70.08);
107
+ --chart-4: oklch(0.627 0.265 303.9);
108
+ --chart-5: oklch(0.645 0.246 16.439);
109
+ --sidebar: oklch(0.205 0 0);
110
+ --sidebar-foreground: oklch(0.985 0 0);
111
+ --sidebar-primary: oklch(0.488 0.243 264.376);
112
+ --sidebar-primary-foreground: oklch(0.985 0 0);
113
+ --sidebar-accent: oklch(0.269 0 0);
114
+ --sidebar-accent-foreground: oklch(0.985 0 0);
115
+ --sidebar-border: oklch(1 0 0 / 10%);
116
+ --sidebar-ring: oklch(0.556 0 0);
117
+ --brand: oklch(0.707 0.165 254.624);
118
+ --highlight: oklch(0.852 0.199 91.936);
119
+ }
120
+
121
+ @layer base {
122
+ * {
123
+ @apply border-border outline-ring/50;
124
+ }
125
+ body {
126
+ @apply bg-background text-foreground;
127
+ }
128
+ }
129
+
130
+ @layer utilities {
131
+ .row {
132
+ @apply flex flex-row;
133
+ }
134
+
135
+ .row-center {
136
+ @apply flex flex-row items-center;
137
+ }
138
+
139
+ .align-both {
140
+ @apply flex flex-row items-center justify-center;
141
+ }
142
+
143
+ .row-center-between {
144
+ @apply flex flex-row items-center justify-between;
145
+ }
146
+
147
+ .column {
148
+ @apply flex flex-col;
149
+ }
150
+
151
+ .column-center {
152
+ @apply flex flex-col items-center;
153
+ }
154
+
155
+ .column-align-both {
156
+ @apply flex flex-col items-center justify-center;
157
+ }
158
+
159
+ .wrap {
160
+ @apply flex-wrap;
161
+ }
162
+
163
+ .pointer {
164
+ @apply hover:cursor-pointer;
165
+ }
166
+
167
+ .bold-none {
168
+ @apply font-normal;
169
+ }
170
+
171
+ .bold {
172
+ @apply font-semibold;
173
+ }
174
+
175
+ .bold-sm {
176
+ @apply font-medium;
177
+ }
178
+
179
+ .bold-lg {
180
+ @apply font-bold;
181
+ }
182
+
183
+ .circle {
184
+ @apply rounded-full;
185
+ }
186
+
187
+ .trans-all-200 {
188
+ @apply transition-all duration-200;
189
+ }
190
+
191
+ .trans-all-100 {
192
+ @apply transition-all duration-100;
193
+ }
194
+
195
+ .smoky-40 {
196
+ @apply opacity-40 hover:opacity-100 cursor-pointer;
197
+ }
198
+
199
+ .smoky-65 {
200
+ @apply opacity-65 hover:opacity-100 cursor-pointer;
201
+ }
202
+
203
+ .smoky-80 {
204
+ @apply opacity-80 hover:opacity-100 cursor-pointer;
205
+ }
206
+
207
+ .smoky-90 {
208
+ @apply opacity-90 hover:opacity-100 cursor-pointer;
209
+ }
210
+
211
+ .group-smoky-0 {
212
+ @apply opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer;
213
+ }
214
+
215
+ .group-smoky-65 {
216
+ @apply opacity-65 group-hover:opacity-100 transition-opacity cursor-pointer;
217
+ }
218
+
219
+ .group-smoky-80 {
220
+ @apply opacity-80 group-hover:opacity-100 transition-opacity cursor-pointer;
221
+ }
222
+
223
+ .debug {
224
+ @apply border border-dashed;
225
+ border-color: red;
226
+ }
227
+ .debug-g {
228
+ @apply border border-dashed;
229
+ border-color: #4d7c0f;
230
+ }
231
+ .debug-b {
232
+ @apply border border-dashed;
233
+ border-color: blue;
234
+ }
235
+ }
@@ -0,0 +1,6 @@
1
+ import { clsx, type ClassValue } from "clsx"
2
+ import { twMerge } from "tailwind-merge"
3
+
4
+ export function cn(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs))
6
+ }
package/src/main.tsx ADDED
@@ -0,0 +1,11 @@
1
+ import { StrictMode } from 'react'
2
+ import { createRoot } from 'react-dom/client'
3
+
4
+ import './global.css'
5
+ import RichEditor from './RichEditor.tsx'
6
+
7
+ createRoot(document.getElementById('root')!).render(
8
+ <StrictMode>
9
+ <RichEditor />
10
+ </StrictMode>,
11
+ )
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
@@ -0,0 +1,31 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": ".",
4
+ "paths": {
5
+ "@/*": ["./src/*"]
6
+ },
7
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
8
+ "target": "ES2022",
9
+ "useDefineForClassFields": true,
10
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
11
+ "module": "ESNext",
12
+ "skipLibCheck": true,
13
+
14
+ /* Bundler mode */
15
+ "moduleResolution": "bundler",
16
+ "allowImportingTsExtensions": true,
17
+ "verbatimModuleSyntax": true,
18
+ "moduleDetection": "force",
19
+ "noEmit": true,
20
+ "jsx": "react-jsx",
21
+
22
+ /* Linting */
23
+ "strict": true,
24
+ "noUnusedLocals": true,
25
+ "noUnusedParameters": true,
26
+ "erasableSyntaxOnly": true,
27
+ "noFallthroughCasesInSwitch": true,
28
+ "noUncheckedSideEffectImports": true
29
+ },
30
+ "include": ["src"]
31
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "files": [],
3
+ "references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" }],
4
+ "compilerOptions": {
5
+ "baseUrl": ".",
6
+ "paths": {
7
+ "@/*": ["./src/*"]
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "compilerOptions": {
3
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
4
+ "target": "ES2023",
5
+ "lib": ["ES2023"],
6
+ "module": "ESNext",
7
+ "skipLibCheck": true,
8
+
9
+ /* Bundler mode */
10
+ "moduleResolution": "bundler",
11
+ "allowImportingTsExtensions": true,
12
+ "verbatimModuleSyntax": true,
13
+ "moduleDetection": "force",
14
+ "noEmit": true,
15
+
16
+ /* Linting */
17
+ "strict": true,
18
+ "noUnusedLocals": true,
19
+ "noUnusedParameters": true,
20
+ "erasableSyntaxOnly": true,
21
+ "noFallthroughCasesInSwitch": true,
22
+ "noUncheckedSideEffectImports": true
23
+ },
24
+ "include": ["vite.config.ts"]
25
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,40 @@
1
+ // vite.config.js
2
+ import path from 'path'
3
+ import tailwindcss from '@tailwindcss/vite'
4
+ import react from '@vitejs/plugin-react'
5
+ import { defineConfig } from 'vite'
6
+
7
+ export default defineConfig({
8
+ plugins: [
9
+ react(),
10
+ tailwindcss()
11
+ ],
12
+ resolve: {
13
+ alias: {
14
+ '@': path.resolve(__dirname, './src'),
15
+ },
16
+ },
17
+ build: {
18
+ lib: {
19
+ entry: path.resolve(__dirname, 'src/main.tsx'), // targeting export file
20
+ name: 'RichEditor',
21
+ formats: ['es', 'umd'], // two export format
22
+ fileName: (format) => `rich-editor.${format}.js`
23
+ },
24
+ rollupOptions: {
25
+ external: ['react', 'react-dom'],
26
+ output: {
27
+ globals: {
28
+ react: 'React',
29
+ 'react-dom': 'ReactDOM'
30
+ },
31
+ // disable hash name
32
+ entryFileNames: `rich-editor.[format].js`,
33
+ chunkFileNames: `[name].js`,
34
+ assetFileNames: `[name].[ext]`
35
+ }
36
+ },
37
+ // warning size
38
+ chunkSizeWarningLimit: 2000
39
+ }
40
+ })