@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,13 @@
1
+ # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.238.1/containers/ubuntu/.devcontainer/base.Dockerfile
2
+
3
+ # [Choice] Ubuntu version (use ubuntu-24.04 or ubuntu-18.04 on local arm64/Apple Silicon): ubuntu-24.04, ubuntu-20.04, ubuntu-18.04
4
+ ARG VARIANT="jammy"
5
+ FROM mcr.microsoft.com/vscode/devcontainers/base:1-${VARIANT}
6
+
7
+ # Install additional OS packages, if needed.
8
+ RUN apt-get update \
9
+ && apt-get install -y --no-install-recommends ca-certificates
10
+
11
+ # [Optional] Uncomment this section to install additional OS packages.
12
+ # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
13
+ # && apt-get -y install protobuf-compiler
@@ -0,0 +1,52 @@
1
+ {
2
+ "build": {
3
+ "dockerfile": "Dockerfile",
4
+ // Update 'VARIANT' to pick an Ubuntu version: jammy / ubuntu-22.04, focal / ubuntu-20.04, bionic /ubuntu-18.04
5
+ // Use ubuntu-24.04 or ubuntu-18.04 on local arm64/Apple Silicon.
6
+ "args": {
7
+ "VARIANT": "ubuntu-24.04"
8
+ }
9
+ },
10
+ "postStartCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",
11
+ "postCreateCommand": "bash scripts/postCreateCommand.sh",
12
+ "features": {
13
+ "ghcr.io/devcontainers/features/docker-in-docker:2": {},
14
+ "ghcr.io/devcontainers/features/node:1": {},
15
+ "ghcr.io/devcontainers/features/github-cli:1": {},
16
+ "ghcr.io/devcontainers/features/git-lfs:1": {}
17
+ },
18
+ "containerEnv": {
19
+ "SHELL": "/usr/bin/zsh"
20
+ },
21
+ "appPort": 3000,
22
+ "forwardPorts": [
23
+ 3000,
24
+ 5432
25
+ ],
26
+ "portsAttributes": {
27
+ "3000": {
28
+ "label": "Application",
29
+ "onAutoForward": "notify"
30
+ },
31
+ "5432": {
32
+ "label": "PostgreSQL",
33
+ "onAutoForward": "notify"
34
+ }
35
+ },
36
+ "hostRequirements": {
37
+ "cpus": 8,
38
+ "memory": "16gb",
39
+ "storage": "32gb"
40
+ },
41
+ "customizations": {
42
+ "vscode": {
43
+ "extensions": [
44
+ "ms-ossdata.vscode-pgsql",
45
+ "dbaeumer.vscode-eslint",
46
+ "GitHub.copilot",
47
+ "GitHub.copilot-chat",
48
+ "eamodio.gitlens"
49
+ ]
50
+ }
51
+ }
52
+ }
@@ -0,0 +1,10 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: npm
4
+ directory: '/'
5
+ schedule:
6
+ interval: 'daily'
7
+ - package-ecosystem: 'github-actions'
8
+ directory: '/'
9
+ schedule:
10
+ interval: 'weekly'
@@ -0,0 +1,42 @@
1
+ name: Pages
2
+
3
+ on:
4
+ push:
5
+ branches: ['main']
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: read
10
+ pages: write
11
+ id-token: write
12
+
13
+ concurrency:
14
+ group: 'pages'
15
+ cancel-in-progress: false
16
+
17
+ jobs:
18
+ build:
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@v6
22
+ - uses: actions/setup-node@v6
23
+ with:
24
+ node-version: '20'
25
+ - run: npm ci
26
+ - run: npm run build
27
+ env:
28
+ BASE_PATH: /editor-x
29
+ - uses: actions/upload-pages-artifact@v4
30
+ with:
31
+ path: ./out
32
+
33
+ deploy:
34
+ environment:
35
+ name: github-pages
36
+ url: ${{ steps.deployment.outputs.page_url }}
37
+ runs-on: ubuntu-latest
38
+ needs: build
39
+ steps:
40
+ - name: Deploy to GitHub Pages
41
+ id: deployment
42
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,41 @@
1
+ name: Publish
2
+
3
+ on:
4
+ release:
5
+ types: [created]
6
+
7
+ jobs:
8
+ publish-npm:
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ id-token: write
12
+ contents: read
13
+ steps:
14
+ - uses: actions/checkout@v6
15
+ - uses: actions/setup-node@v6
16
+ with:
17
+ node-version: 24
18
+ registry-url: 'https://registry.npmjs.org'
19
+ cache: npm
20
+ - run: npm ci
21
+ - run: npm version ${TAG_NAME} --git-tag-version=false
22
+ env:
23
+ TAG_NAME: ${{ github.event.release.tag_name }}
24
+ - run: npm --ignore-scripts publish --access public
25
+ env:
26
+ NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27
+ - uses: actions/upload-pages-artifact@v4
28
+ with:
29
+ path: ./examples
30
+ publish-page:
31
+ runs-on: ubuntu-latest
32
+ needs: publish-npm
33
+ permissions:
34
+ pages: write
35
+ id-token: write
36
+ environment:
37
+ name: github-pages
38
+ url: ${{ steps.deployment.outputs.page_url }}
39
+ steps:
40
+ - id: deployment
41
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,7 @@
1
+ {
2
+ "editor.codeActionsOnSave": {
3
+ "source.fixAll": "explicit",
4
+ "source.organizeImports": "explicit",
5
+ "source.sortMembers": "explicit"
6
+ }
7
+ }
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright 2026 Sebastian Doell (@katallaxie)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # Editor X
2
+
3
+ ![Editor X](images/editor.png "Editor X")
4
+
5
+ An advanced editor built on [shadcn/ui](https://ui.shadcn.com/) und [Tiptap](https://tiptap.dev/).
6
+
7
+ ## License
8
+
9
+ [MIT](/LICENSE)
@@ -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
+ }
package/app/layout.tsx ADDED
@@ -0,0 +1,46 @@
1
+ import { siteConfig } from '@/config/site'
2
+ import { PREFERENCE_DEFAULTS } from '@/lib/preferences-config'
3
+ import { ThemeBootScript } from '@/scripts/theme-boot'
4
+ import { PreferencesStoreProvider } from '@/stores/preferences/preferences-provider'
5
+ import '@/styles/globals.css'
6
+ import { SiteFooter } from 'components/site-footer'
7
+ import { SiteHeader } from 'components/site-header'
8
+ import type { Metadata } from 'next'
9
+ import { Inter } from 'next/font/google'
10
+
11
+ const inter = Inter({ subsets: ['latin'] })
12
+
13
+ export const metadata: Metadata = {
14
+ title: 'Editor X - Build Your Rich Text Editor',
15
+ keywords: [],
16
+ authors: [
17
+ {
18
+ name: siteConfig.author,
19
+ },
20
+ ],
21
+ creator: siteConfig.author,
22
+ }
23
+
24
+ export default function RootLayout({
25
+ children,
26
+ }: Readonly<{
27
+ children: React.ReactNode
28
+ }>) {
29
+ const { theme_mode, theme_preset } = PREFERENCE_DEFAULTS
30
+
31
+ return (
32
+ <html lang="en" className={theme_mode} data-theme-preset={theme_preset} suppressHydrationWarning>
33
+ <head>
34
+ {/* Applies theme and layout preferences on load to avoid flicker and unnecessary server rerenders. */}
35
+ <ThemeBootScript />
36
+ </head>
37
+ <body className={`${inter.className} min-h-screen antialiased`}>
38
+ <PreferencesStoreProvider themeMode={theme_mode} themePreset={theme_preset}>
39
+ <SiteHeader />
40
+ {children}
41
+ <SiteFooter />
42
+ </PreferencesStoreProvider>
43
+ </body>
44
+ </html>
45
+ )
46
+ }
package/app/page.tsx ADDED
@@ -0,0 +1,11 @@
1
+ import ExampleEditor from '@/app/_component/editor'
2
+
3
+ export default function Home() {
4
+ return (
5
+ <main className="flex min-h-screen flex-col w-full items-center ">
6
+ <section id="basic-editor" className="w-full container py-12 scroll-mt-10">
7
+ <ExampleEditor />
8
+ </section>
9
+ </main>
10
+ )
11
+ }
@@ -0,0 +1,22 @@
1
+ import { getPackage } from '@/lib/package'
2
+ import { type NextRequest, NextResponse } from 'next/server'
3
+ import type { Registry } from 'shadcn/schema'
4
+
5
+ export const dynamic = 'force-static'
6
+
7
+ export const GET = async (_: NextRequest) => {
8
+ const response: Registry = {
9
+ name: 'Editor X',
10
+ homepage: 'https://open-cloud-initiative.github.io/editor-x',
11
+ items: [],
12
+ }
13
+
14
+ try {
15
+ const pkg = await getPackage('editor-x')
16
+ response.items.push(pkg)
17
+ } catch (err) {
18
+ // skip packages that fail
19
+ }
20
+
21
+ return NextResponse.json(response)
22
+ }