@open-cloud-initiative/editor-x 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 (190) hide show
  1. package/.devcontainer/Dockerfile +13 -0
  2. package/.devcontainer/devcontainer.json +52 -0
  3. package/.github/dependabot.yml +10 -0
  4. package/.github/workflows/pages.yml +42 -0
  5. package/.github/workflows/publish.yml +41 -0
  6. package/.vscode/settings.json +7 -0
  7. package/LICENSE +9 -0
  8. package/README.md +9 -0
  9. package/app/_component/editor.tsx +383 -0
  10. package/app/layout.tsx +46 -0
  11. package/app/page.tsx +11 -0
  12. package/app/r/registry.json/route.ts +22 -0
  13. package/components/editorx/editor.tsx +1794 -0
  14. package/components/editorx/extensions/floating-menu.tsx +376 -0
  15. package/components/editorx/extensions/floating-toolbar.tsx +97 -0
  16. package/components/editorx/extensions/image-placeholder.tsx +316 -0
  17. package/components/editorx/extensions/image.tsx +462 -0
  18. package/components/editorx/extensions/search-and-replace.tsx +438 -0
  19. package/components/editorx/rich-text-editor.tsx +383 -0
  20. package/components/editorx/tiptap.css +421 -0
  21. package/components/editorx/toolbars/alignment.tsx +126 -0
  22. package/components/editorx/toolbars/blockquote.tsx +47 -0
  23. package/components/editorx/toolbars/bold.tsx +48 -0
  24. package/components/editorx/toolbars/bullet-list.tsx +48 -0
  25. package/components/editorx/toolbars/code-block.tsx +47 -0
  26. package/components/editorx/toolbars/code.tsx +43 -0
  27. package/components/editorx/toolbars/color-and-highlight.tsx +215 -0
  28. package/components/editorx/toolbars/editor-toolbar.tsx +77 -0
  29. package/components/editorx/toolbars/hard-break.tsx +46 -0
  30. package/components/editorx/toolbars/headings.tsx +97 -0
  31. package/components/editorx/toolbars/horizontal-rule.tsx +42 -0
  32. package/components/editorx/toolbars/image-placeholder-toolbar.tsx +47 -0
  33. package/components/editorx/toolbars/italic.tsx +48 -0
  34. package/components/editorx/toolbars/link.tsx +130 -0
  35. package/components/editorx/toolbars/mobile-toolbar-group.tsx +76 -0
  36. package/components/editorx/toolbars/ordered-list.tsx +47 -0
  37. package/components/editorx/toolbars/redo.tsx +44 -0
  38. package/components/editorx/toolbars/strikethrough.tsx +48 -0
  39. package/components/editorx/toolbars/toolbar-provider.tsx +29 -0
  40. package/components/editorx/toolbars/underline.tsx +48 -0
  41. package/components/editorx/toolbars/undo.tsx +43 -0
  42. package/components/layout/theme-switcher.tsx +26 -0
  43. package/components/main-nav.tsx +24 -0
  44. package/components/mobile-nav.tsx +46 -0
  45. package/components/open-in-v0-button.tsx +38 -0
  46. package/components/page-header.tsx +30 -0
  47. package/components/site-footer.tsx +41 -0
  48. package/components/site-header.tsx +32 -0
  49. package/components/theme-provider.tsx +8 -0
  50. package/components/ui/button.tsx +57 -0
  51. package/components/ui/checkbox.tsx +30 -0
  52. package/components/ui/collapsible.tsx +11 -0
  53. package/components/ui/command.tsx +148 -0
  54. package/components/ui/dialog.tsx +122 -0
  55. package/components/ui/drawer.tsx +118 -0
  56. package/components/ui/dropdown-menu.tsx +201 -0
  57. package/components/ui/input.tsx +22 -0
  58. package/components/ui/label.tsx +26 -0
  59. package/components/ui/popover.tsx +33 -0
  60. package/components/ui/resizable.tsx +40 -0
  61. package/components/ui/scroll-area.tsx +42 -0
  62. package/components/ui/separator.tsx +31 -0
  63. package/components/ui/sheet.tsx +140 -0
  64. package/components/ui/sidebar.tsx +763 -0
  65. package/components/ui/skeleton.tsx +15 -0
  66. package/components/ui/spinner.tsx +29 -0
  67. package/components/ui/tabs.tsx +55 -0
  68. package/components/ui/toggle-group.tsx +61 -0
  69. package/components/ui/toggle.tsx +45 -0
  70. package/components/ui/tooltip.tsx +32 -0
  71. package/components.json +21 -0
  72. package/config/site.ts +15 -0
  73. package/eslint.config.mjs +20 -0
  74. package/hooks/use-character-limit.ts +28 -0
  75. package/hooks/use-copy-to-clipboard.ts +16 -0
  76. package/hooks/use-debounce.ts +17 -0
  77. package/hooks/use-image-upload.ts +97 -0
  78. package/hooks/use-media-querry.ts +18 -0
  79. package/hooks/use-mobile.tsx +19 -0
  80. package/images/editor.png +0 -0
  81. package/lib/content.ts +39 -0
  82. package/lib/cookie-client.ts +19 -0
  83. package/lib/localstorage-client.ts +19 -0
  84. package/lib/package.ts +144 -0
  85. package/lib/preferences-config.ts +72 -0
  86. package/lib/preferences-storage.ts +20 -0
  87. package/lib/theme-utils.ts +12 -0
  88. package/lib/theme.ts +50 -0
  89. package/lib/tiptap-utils.ts +45 -0
  90. package/lib/utils.ts +11 -0
  91. package/next-env.d.ts +6 -0
  92. package/next.config.mjs +11 -0
  93. package/package.json +92 -0
  94. package/postcss.config.mjs +8 -0
  95. package/prettier.config.mjs +15 -0
  96. package/public/android-chrome-192x192.png +0 -0
  97. package/public/android-chrome-512x512.png +0 -0
  98. package/public/apple-touch-icon.png +0 -0
  99. package/public/favicon-16x16.png +0 -0
  100. package/public/favicon-32x32.png +0 -0
  101. package/public/favicon.ico +0 -0
  102. package/public/file.svg +1 -0
  103. package/public/globe.svg +1 -0
  104. package/public/next.svg +1 -0
  105. package/public/og.webp +0 -0
  106. package/public/r/editor-x.json +85 -0
  107. package/public/r/registry.json +93 -0
  108. package/public/site.webmanifest +19 -0
  109. package/public/vercel.svg +1 -0
  110. package/public/window.svg +1 -0
  111. package/registry/editor/components/editor.tsx +1794 -0
  112. package/registry/editor/components/extensions/floating-menu.tsx +376 -0
  113. package/registry/editor/components/extensions/floating-toolbar.tsx +97 -0
  114. package/registry/editor/components/extensions/image-placeholder.tsx +316 -0
  115. package/registry/editor/components/extensions/image.tsx +462 -0
  116. package/registry/editor/components/extensions/search-and-replace.tsx +438 -0
  117. package/registry/editor/components/rich-text-editor.tsx +383 -0
  118. package/registry/editor/components/tiptap.css +421 -0
  119. package/registry/editor/components/toolbars/alignment.tsx +126 -0
  120. package/registry/editor/components/toolbars/blockquote.tsx +47 -0
  121. package/registry/editor/components/toolbars/bold.tsx +48 -0
  122. package/registry/editor/components/toolbars/bullet-list.tsx +48 -0
  123. package/registry/editor/components/toolbars/code-block.tsx +47 -0
  124. package/registry/editor/components/toolbars/code.tsx +43 -0
  125. package/registry/editor/components/toolbars/color-and-highlight.tsx +215 -0
  126. package/registry/editor/components/toolbars/editor-toolbar.tsx +77 -0
  127. package/registry/editor/components/toolbars/hard-break.tsx +46 -0
  128. package/registry/editor/components/toolbars/headings.tsx +97 -0
  129. package/registry/editor/components/toolbars/horizontal-rule.tsx +42 -0
  130. package/registry/editor/components/toolbars/image-placeholder-toolbar.tsx +47 -0
  131. package/registry/editor/components/toolbars/italic.tsx +48 -0
  132. package/registry/editor/components/toolbars/link.tsx +130 -0
  133. package/registry/editor/components/toolbars/mobile-toolbar-group.tsx +76 -0
  134. package/registry/editor/components/toolbars/ordered-list.tsx +47 -0
  135. package/registry/editor/components/toolbars/redo.tsx +44 -0
  136. package/registry/editor/components/toolbars/strikethrough.tsx +48 -0
  137. package/registry/editor/components/toolbars/toolbar-provider.tsx +29 -0
  138. package/registry/editor/components/toolbars/underline.tsx +48 -0
  139. package/registry/editor/components/toolbars/undo.tsx +43 -0
  140. package/registry/editor/components/ui/button.tsx +57 -0
  141. package/registry/editor/components/ui/checkbox.tsx +30 -0
  142. package/registry/editor/components/ui/collapsible.tsx +11 -0
  143. package/registry/editor/components/ui/command.tsx +148 -0
  144. package/registry/editor/components/ui/dialog.tsx +122 -0
  145. package/registry/editor/components/ui/drawer.tsx +118 -0
  146. package/registry/editor/components/ui/dropdown-menu.tsx +201 -0
  147. package/registry/editor/components/ui/input.tsx +22 -0
  148. package/registry/editor/components/ui/label.tsx +26 -0
  149. package/registry/editor/components/ui/popover.tsx +33 -0
  150. package/registry/editor/components/ui/resizable.tsx +40 -0
  151. package/registry/editor/components/ui/scroll-area.tsx +42 -0
  152. package/registry/editor/components/ui/separator.tsx +31 -0
  153. package/registry/editor/components/ui/sheet.tsx +140 -0
  154. package/registry/editor/components/ui/sidebar.tsx +763 -0
  155. package/registry/editor/components/ui/skeleton.tsx +15 -0
  156. package/registry/editor/components/ui/spinner.tsx +29 -0
  157. package/registry/editor/components/ui/tabs.tsx +55 -0
  158. package/registry/editor/components/ui/toggle-group.tsx +61 -0
  159. package/registry/editor/components/ui/toggle.tsx +45 -0
  160. package/registry/editor/components/ui/tooltip.tsx +32 -0
  161. package/registry/editor/hooks/use-character-limit.ts +28 -0
  162. package/registry/editor/hooks/use-copy-to-clipboard.ts +16 -0
  163. package/registry/editor/hooks/use-debounce.ts +17 -0
  164. package/registry/editor/hooks/use-image-upload.ts +97 -0
  165. package/registry/editor/hooks/use-media-querry.ts +18 -0
  166. package/registry/editor/hooks/use-mobile.tsx +19 -0
  167. package/registry/editor/lib/content.ts +39 -0
  168. package/registry/editor/lib/cookie-client.ts +19 -0
  169. package/registry/editor/lib/localstorage-client.ts +19 -0
  170. package/registry/editor/lib/package.ts +144 -0
  171. package/registry/editor/lib/preferences-config.ts +72 -0
  172. package/registry/editor/lib/preferences-storage.ts +20 -0
  173. package/registry/editor/lib/theme-utils.ts +12 -0
  174. package/registry/editor/lib/theme.ts +50 -0
  175. package/registry/editor/lib/tiptap-utils.ts +45 -0
  176. package/registry/editor/lib/utils.ts +11 -0
  177. package/registry/editor/page.tsx +9 -0
  178. package/registry.json +93 -0
  179. package/reset.d.ts +1 -0
  180. package/scripts/generate-theme-presets.ts +128 -0
  181. package/scripts/postCreateCommand.sh +0 -0
  182. package/scripts/theme-boot.tsx +105 -0
  183. package/server/server-actions.ts +27 -0
  184. package/stores/preferences/preferences-provider.tsx +55 -0
  185. package/stores/preferences/preferences-store.ts +23 -0
  186. package/styles/globals.css +288 -0
  187. package/styles/presets/brutalist.css +89 -0
  188. package/styles/presets/soft-pop.css +89 -0
  189. package/styles/presets/tangerine.css +89 -0
  190. package/tsconfig.json +50 -0
@@ -0,0 +1,383 @@
1
+ 'use client'
2
+
3
+ import type { Editor, JSONContent } from '@/components/editorx/editor'
4
+ import {
5
+ EditorBubbleMenu,
6
+ EditorCharacterCount,
7
+ EditorClearFormatting,
8
+ EditorFormatBold,
9
+ EditorFormatCode,
10
+ EditorFormatItalic,
11
+ EditorFormatStrike,
12
+ EditorFormatSubscript,
13
+ EditorFormatSuperscript,
14
+ EditorFormatUnderline,
15
+ EditorLinkSelector,
16
+ EditorNodeBulletList,
17
+ EditorNodeCode,
18
+ EditorNodeHeading1,
19
+ EditorNodeHeading2,
20
+ EditorNodeHeading3,
21
+ EditorNodeOrderedList,
22
+ EditorNodeQuote,
23
+ EditorNodeTaskList,
24
+ EditorNodeText,
25
+ EditorProvider,
26
+ EditorSelector,
27
+ EditorTableColumnAfter,
28
+ EditorTableColumnBefore,
29
+ EditorTableColumnDelete,
30
+ EditorTableColumnMenu,
31
+ EditorTableDelete,
32
+ EditorTableFix,
33
+ EditorTableGlobalMenu,
34
+ EditorTableHeaderColumnToggle,
35
+ EditorTableHeaderRowToggle,
36
+ EditorTableMenu,
37
+ EditorTableMergeCells,
38
+ EditorTableRowAfter,
39
+ EditorTableRowBefore,
40
+ EditorTableRowDelete,
41
+ EditorTableRowMenu,
42
+ EditorTableSplitCell,
43
+ } from '@/components/editorx/editor'
44
+ import { EditorToolbar } from '@/components/editorx/toolbars/editor-toolbar'
45
+ import Highlight from '@tiptap/extension-highlight'
46
+ import { useState } from 'react'
47
+
48
+ export default function ExampleEditor() {
49
+ const [content, setContent] = useState<JSONContent>({
50
+ type: 'doc',
51
+ content: [
52
+ {
53
+ type: 'heading',
54
+ attrs: { level: 1 },
55
+ content: [{ type: 'text', text: 'Heading 1' }],
56
+ },
57
+ {
58
+ type: 'heading',
59
+ attrs: { level: 2 },
60
+ content: [{ type: 'text', text: 'Heading 2' }],
61
+ },
62
+ {
63
+ type: 'heading',
64
+ attrs: { level: 3 },
65
+ content: [{ type: 'text', text: 'Heading 3' }],
66
+ },
67
+ {
68
+ type: 'heading',
69
+ attrs: { level: 4 },
70
+ content: [{ type: 'text', text: 'Heading 4' }],
71
+ },
72
+ {
73
+ type: 'heading',
74
+ attrs: { level: 5 },
75
+ content: [{ type: 'text', text: 'Heading 5' }],
76
+ },
77
+ {
78
+ type: 'heading',
79
+ attrs: { level: 6 },
80
+ content: [{ type: 'text', text: 'Heading 6' }],
81
+ },
82
+ { type: 'paragraph' },
83
+ { type: 'paragraph', content: [{ type: 'text', text: 'Hello, world.' }] },
84
+ { type: 'paragraph' },
85
+ {
86
+ type: 'taskList',
87
+ content: [
88
+ {
89
+ type: 'taskItem',
90
+ attrs: { checked: false },
91
+ content: [
92
+ {
93
+ type: 'paragraph',
94
+ content: [{ type: 'text', text: 'This is a todo list' }],
95
+ },
96
+ ],
97
+ },
98
+ {
99
+ type: 'taskItem',
100
+ attrs: { checked: false },
101
+ content: [
102
+ {
103
+ type: 'paragraph',
104
+ content: [{ type: 'text', text: 'With two items' }],
105
+ },
106
+ ],
107
+ },
108
+ ],
109
+ },
110
+ { type: 'paragraph' },
111
+ {
112
+ type: 'bulletList',
113
+ content: [
114
+ {
115
+ type: 'listItem',
116
+ content: [
117
+ {
118
+ type: 'paragraph',
119
+ content: [{ type: 'text', text: 'This is an unordered list' }],
120
+ },
121
+ {
122
+ type: 'bulletList',
123
+ content: [
124
+ {
125
+ type: 'listItem',
126
+ content: [
127
+ {
128
+ type: 'paragraph',
129
+ content: [{ type: 'text', text: 'With a nested item' }],
130
+ },
131
+ ],
132
+ },
133
+ ],
134
+ },
135
+ ],
136
+ },
137
+ ],
138
+ },
139
+ { type: 'paragraph' },
140
+ {
141
+ type: 'orderedList',
142
+ attrs: { start: 1 },
143
+ content: [
144
+ {
145
+ type: 'listItem',
146
+ content: [
147
+ {
148
+ type: 'paragraph',
149
+ content: [{ type: 'text', text: 'This is an ordered list' }],
150
+ },
151
+ ],
152
+ },
153
+ {
154
+ type: 'listItem',
155
+ content: [
156
+ {
157
+ type: 'paragraph',
158
+ content: [{ type: 'text', text: 'With two items' }],
159
+ },
160
+ ],
161
+ },
162
+ ],
163
+ },
164
+ { type: 'paragraph' },
165
+ {
166
+ type: 'blockquote',
167
+ content: [
168
+ {
169
+ type: 'paragraph',
170
+ content: [
171
+ {
172
+ type: 'text',
173
+ text: 'This is a quote, probably by someone famous.',
174
+ },
175
+ ],
176
+ },
177
+ ],
178
+ },
179
+ { type: 'paragraph' },
180
+ {
181
+ type: 'paragraph',
182
+ content: [
183
+ { type: 'text', text: 'This is some ' },
184
+ { type: 'text', marks: [{ type: 'code' }], text: 'inline code' },
185
+ { type: 'text', text: ', while this is a code block:' },
186
+ ],
187
+ },
188
+ { type: 'paragraph' },
189
+ {
190
+ type: 'codeBlock',
191
+ attrs: { language: null },
192
+ content: [
193
+ {
194
+ type: 'text',
195
+ text: "function x () {\\n console.log('hello, world.');\\n}",
196
+ },
197
+ ],
198
+ },
199
+ { type: 'paragraph' },
200
+ {
201
+ type: 'paragraph',
202
+ content: [
203
+ {
204
+ type: 'text',
205
+ text: 'You can also create complex tables, like so:',
206
+ },
207
+ ],
208
+ },
209
+ {
210
+ type: 'table',
211
+ content: [
212
+ {
213
+ type: 'tableRow',
214
+ content: [
215
+ {
216
+ type: 'tableHeader',
217
+ attrs: { colspan: 1, rowspan: 1, colwidth: null },
218
+ content: [
219
+ {
220
+ type: 'paragraph',
221
+ content: [{ type: 'text', text: 'Here’s a column' }],
222
+ },
223
+ ],
224
+ },
225
+ {
226
+ type: 'tableHeader',
227
+ attrs: { colspan: 1, rowspan: 1, colwidth: null },
228
+ content: [
229
+ {
230
+ type: 'paragraph',
231
+ content: [{ type: 'text', text: 'Another column' }],
232
+ },
233
+ ],
234
+ },
235
+ {
236
+ type: 'tableHeader',
237
+ attrs: { colspan: 1, rowspan: 1, colwidth: null },
238
+ content: [
239
+ {
240
+ type: 'paragraph',
241
+ content: [{ type: 'text', text: 'Yet another' }],
242
+ },
243
+ ],
244
+ },
245
+ ],
246
+ },
247
+ {
248
+ type: 'tableRow',
249
+ content: [
250
+ {
251
+ type: 'tableCell',
252
+ attrs: { colspan: 1, rowspan: 1, colwidth: null },
253
+ content: [
254
+ {
255
+ type: 'paragraph',
256
+ content: [{ type: 'text', text: 'Cell 1A' }],
257
+ },
258
+ ],
259
+ },
260
+ {
261
+ type: 'tableCell',
262
+ attrs: { colspan: 1, rowspan: 1, colwidth: null },
263
+ content: [
264
+ {
265
+ type: 'paragraph',
266
+ content: [{ type: 'text', text: 'Cell 2A' }],
267
+ },
268
+ ],
269
+ },
270
+ {
271
+ type: 'tableCell',
272
+ attrs: { colspan: 1, rowspan: 1, colwidth: null },
273
+ content: [
274
+ {
275
+ type: 'paragraph',
276
+ content: [{ type: 'text', text: 'Cell 3A' }],
277
+ },
278
+ ],
279
+ },
280
+ ],
281
+ },
282
+ {
283
+ type: 'tableRow',
284
+ content: [
285
+ {
286
+ type: 'tableCell',
287
+ attrs: { colspan: 1, rowspan: 1, colwidth: null },
288
+ content: [
289
+ {
290
+ type: 'paragraph',
291
+ content: [{ type: 'text', text: 'Cell 1B' }],
292
+ },
293
+ ],
294
+ },
295
+ {
296
+ type: 'tableCell',
297
+ attrs: { colspan: 1, rowspan: 1, colwidth: null },
298
+ content: [
299
+ {
300
+ type: 'paragraph',
301
+ content: [{ type: 'text', text: 'Cell 2B' }],
302
+ },
303
+ ],
304
+ },
305
+ {
306
+ type: 'tableCell',
307
+ attrs: { colspan: 1, rowspan: 1, colwidth: null },
308
+ content: [
309
+ {
310
+ type: 'paragraph',
311
+ content: [{ type: 'text', text: 'Cell 3B' }],
312
+ },
313
+ ],
314
+ },
315
+ ],
316
+ },
317
+ ],
318
+ },
319
+ ],
320
+ })
321
+ const handleUpdate = ({ editor }: { editor: Editor }) => {
322
+ const json = editor.getJSON()
323
+ setContent(json)
324
+ console.log(JSON.stringify(json))
325
+ }
326
+
327
+ return (
328
+ <EditorProvider
329
+ className="h-full w-full overflow-y-auto rounded-lg border bg-background p-4"
330
+ content={content}
331
+ onUpdate={handleUpdate}
332
+ placeholder="Start typing..."
333
+ extensions={[Highlight]}
334
+ slotBefore={<EditorToolbar />}
335
+ >
336
+ <EditorBubbleMenu>
337
+ <EditorSelector title="Text">
338
+ <EditorNodeText />
339
+ <EditorNodeHeading1 />
340
+ <EditorNodeHeading2 />
341
+ <EditorNodeHeading3 />
342
+ <EditorNodeBulletList />
343
+ <EditorNodeOrderedList />
344
+ <EditorNodeTaskList />
345
+ <EditorNodeQuote />
346
+ <EditorNodeCode />
347
+ </EditorSelector>
348
+ <EditorSelector title="Format">
349
+ <EditorFormatBold />
350
+ <EditorFormatItalic />
351
+ <EditorFormatUnderline />
352
+ <EditorFormatStrike />
353
+ <EditorFormatCode />
354
+ <EditorFormatSuperscript />
355
+ <EditorFormatSubscript />
356
+ </EditorSelector>
357
+ <EditorLinkSelector />
358
+ <EditorClearFormatting />
359
+ </EditorBubbleMenu>
360
+ <EditorTableMenu>
361
+ <EditorTableColumnMenu>
362
+ <EditorTableColumnBefore />
363
+ <EditorTableColumnAfter />
364
+ <EditorTableColumnDelete />
365
+ </EditorTableColumnMenu>
366
+ <EditorTableRowMenu>
367
+ <EditorTableRowBefore />
368
+ <EditorTableRowAfter />
369
+ <EditorTableRowDelete />
370
+ </EditorTableRowMenu>
371
+ <EditorTableGlobalMenu>
372
+ <EditorTableHeaderColumnToggle />
373
+ <EditorTableHeaderRowToggle />
374
+ <EditorTableDelete />
375
+ <EditorTableMergeCells />
376
+ <EditorTableSplitCell />
377
+ <EditorTableFix />
378
+ </EditorTableGlobalMenu>
379
+ </EditorTableMenu>
380
+ <EditorCharacterCount.Words>Words: </EditorCharacterCount.Words>
381
+ </EditorProvider>
382
+ )
383
+ }