@studiocms/wysiwyg 0.1.0-experimental.5 → 0.1.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 (164) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +7 -28
  3. package/dist/common/gjs-blocks.d.ts +4 -0
  4. package/dist/common/gjs-blocks.js +27 -0
  5. package/dist/common/gjs-componentRegistry.d.ts +31 -0
  6. package/dist/common/gjs-componentRegistry.js +59 -0
  7. package/dist/common/gjs-editor-settings.d.ts +23 -0
  8. package/dist/common/gjs-editor-settings.js +357 -0
  9. package/dist/common/gjs-editor-utils.d.ts +165 -0
  10. package/dist/common/gjs-editor-utils.js +217 -0
  11. package/dist/common/grapesBlocks/blocks/basics.d.ts +4 -0
  12. package/dist/common/grapesBlocks/blocks/basics.js +279 -0
  13. package/dist/common/grapesBlocks/blocks/extras.d.ts +4 -0
  14. package/dist/common/grapesBlocks/blocks/extras.js +63 -0
  15. package/dist/common/grapesBlocks/blocks/forms.d.ts +4 -0
  16. package/dist/{wysiwyg/editorPlugins/forms/blocks.js → common/grapesBlocks/blocks/forms.js} +15 -14
  17. package/dist/common/grapesBlocks/blocks/index.d.ts +5 -0
  18. package/dist/common/grapesBlocks/blocks/index.js +23 -0
  19. package/dist/common/grapesBlocks/blocks/tabs.d.ts +4 -0
  20. package/dist/{wysiwyg/editorPlugins/tabs/blocks.js → common/grapesBlocks/blocks/tabs.js} +9 -8
  21. package/dist/common/grapesBlocks/commands/clear.d.ts +4 -0
  22. package/dist/common/grapesBlocks/commands/clear.js +21 -0
  23. package/dist/common/grapesBlocks/commands/customCodeCommands.d.ts +4 -0
  24. package/dist/{wysiwyg/editorPlugins/code/commands.js → common/grapesBlocks/commands/customCodeCommands.js} +11 -9
  25. package/dist/common/grapesBlocks/commands/deviceCommands.js +23 -0
  26. package/dist/common/grapesBlocks/commands/index.d.ts +5 -0
  27. package/dist/common/grapesBlocks/commands/index.js +40 -0
  28. package/dist/common/grapesBlocks/commands/openImport.d.ts +4 -0
  29. package/dist/common/grapesBlocks/commands/openImport.js +71 -0
  30. package/dist/common/grapesBlocks/components/countdown.d.ts +12 -0
  31. package/dist/common/grapesBlocks/components/countdown.js +147 -0
  32. package/dist/common/grapesBlocks/components/customCode.d.ts +4 -0
  33. package/dist/{wysiwyg/editorPlugins/code/components.js → common/grapesBlocks/components/customCode.js} +16 -15
  34. package/dist/common/grapesBlocks/components/forms.d.ts +3 -0
  35. package/dist/{wysiwyg/editorPlugins/forms/components.js → common/grapesBlocks/components/forms.js} +30 -36
  36. package/dist/common/grapesBlocks/components/index.d.ts +5 -0
  37. package/dist/common/grapesBlocks/components/index.js +23 -0
  38. package/dist/common/grapesBlocks/components/tabLoader.d.ts +4 -0
  39. package/dist/{wysiwyg/editorPlugins/tabs/components/index.js → common/grapesBlocks/components/tabLoader.js} +7 -7
  40. package/dist/{wysiwyg/editorPlugins/tabs/components → common/grapesBlocks/components/tabs}/Tab.d.ts +1 -1
  41. package/dist/{wysiwyg/editorPlugins/tabs/components → common/grapesBlocks/components/tabs}/Tab.js +2 -2
  42. package/dist/{wysiwyg/editorPlugins/tabs/components → common/grapesBlocks/components/tabs}/TabContainer.d.ts +1 -1
  43. package/dist/{wysiwyg/editorPlugins/tabs/components → common/grapesBlocks/components/tabs}/TabContent.d.ts +1 -1
  44. package/dist/{wysiwyg/editorPlugins/tabs/components → common/grapesBlocks/components/tabs}/TabContents.d.ts +1 -1
  45. package/dist/{wysiwyg/editorPlugins/tabs/components → common/grapesBlocks/components/tabs}/Tabs.d.ts +1 -1
  46. package/dist/{wysiwyg/editorPlugins/tabs/components → common/grapesBlocks/components/tabs}/Tabs.js +8 -8
  47. package/dist/common/grapesBlocks/components/tooltip.d.ts +4 -0
  48. package/dist/{wysiwyg/editorPlugins → common/grapesBlocks/components}/tooltip.js +15 -87
  49. package/dist/common/grapesBlocks/components/typed.d.ts +9 -0
  50. package/dist/{wysiwyg/editorPlugins/typed/components.js → common/grapesBlocks/components/typed.js} +7 -7
  51. package/dist/common/grapesBlocks/consts.d.ts +25 -0
  52. package/dist/common/grapesBlocks/consts.js +245 -0
  53. package/dist/common/grapesBlocks/i18n/index.d.ts +3 -0
  54. package/dist/common/grapesBlocks/i18n/index.js +19 -0
  55. package/dist/common/grapesBlocks/panels/index.d.ts +4 -0
  56. package/dist/common/grapesBlocks/panels/index.js +171 -0
  57. package/dist/{wysiwyg/editorPlugins → common/grapesBlocks}/rte/colorPicker.d.ts +9 -0
  58. package/dist/{wysiwyg/editorPlugins → common/grapesBlocks}/rte/colorPicker.js +16 -2
  59. package/dist/{wysiwyg/editorPlugins → common/grapesBlocks}/rte/index.d.ts +3 -3
  60. package/dist/{wysiwyg/editorPlugins → common/grapesBlocks}/rte/index.js +18 -12
  61. package/dist/common/grapesBlocks/selectors/index.d.ts +4 -0
  62. package/dist/common/grapesBlocks/selectors/index.js +9 -0
  63. package/dist/common/grapesBlocks/selectors/tooltip.d.ts +4 -0
  64. package/dist/common/grapesBlocks/selectors/tooltip.js +15 -0
  65. package/dist/common/grapesBlocks/traits/formTraits.d.ts +3 -0
  66. package/dist/{wysiwyg/editorPlugins/forms/traits.js → common/grapesBlocks/traits/formTraits.js} +12 -8
  67. package/dist/common/grapesBlocks/traits/index.d.ts +4 -0
  68. package/dist/common/grapesBlocks/traits/index.js +15 -0
  69. package/dist/common/grapesBlocks/traits/typedTraits.d.ts +3 -0
  70. package/dist/common/grapesBlocks/traits/typedTraits.js +24 -0
  71. package/dist/{wysiwyg/editorPlugins/tuiImageEditor.d.ts → common/grapesBlocks/tuiImageEditor/index.d.ts} +2 -2
  72. package/dist/{wysiwyg/editorPlugins/tuiImageEditor.js → common/grapesBlocks/tuiImageEditor/index.js} +6 -7
  73. package/dist/common/grapesBlocks/types.d.ts +446 -0
  74. package/dist/components/Editor.astro +153 -0
  75. package/dist/components/render.d.ts +15 -0
  76. package/dist/components/render.js +11 -0
  77. package/dist/consts.d.ts +31 -0
  78. package/dist/consts.js +15 -0
  79. package/dist/index.d.ts +39 -0
  80. package/dist/index.js +71 -0
  81. package/dist/lib/db.d.ts +83 -0
  82. package/dist/lib/db.js +50 -0
  83. package/dist/lib/prerender.d.ts +10 -0
  84. package/dist/lib/prerender.js +22 -0
  85. package/dist/{wysiwyg → lib}/shared.d.ts +3 -6
  86. package/dist/lib/shared.js +6 -0
  87. package/dist/{utils.d.ts → lib/utils.d.ts} +1 -1
  88. package/dist/lib/utils.js +10 -0
  89. package/dist/routes/grapes.css.d.ts +7 -0
  90. package/dist/routes/grapes.css.js +13 -0
  91. package/dist/routes/partial.astro +44 -0
  92. package/dist/routes/store.d.ts +1 -0
  93. package/dist/routes/store.js +121 -0
  94. package/dist/schema.d.ts +60 -0
  95. package/dist/schema.js +24 -0
  96. package/dist/styles/editor.css +150 -0
  97. package/dist/styles/grapes.css +71 -0
  98. package/dist/types.d.ts +66 -0
  99. package/dist/types.js +9 -0
  100. package/package.json +30 -28
  101. package/dist/common/prepareRender.d.ts +0 -11
  102. package/dist/common/prepareRender.js +0 -24
  103. package/dist/studio/components/Render.astro +0 -11
  104. package/dist/studio/components/StudioSDKEditor.astro +0 -334
  105. package/dist/studio/index.d.ts +0 -38
  106. package/dist/studio/index.js +0 -58
  107. package/dist/studio/routes/partial.astro +0 -27
  108. package/dist/studio/shared.d.ts +0 -17
  109. package/dist/studio/shared.js +0 -7
  110. package/dist/studio/utils.d.ts +0 -105
  111. package/dist/studio/utils.js +0 -244
  112. package/dist/studio/virtual.d.ts +0 -114
  113. package/dist/utils.js +0 -15
  114. package/dist/wysiwyg/components/Editor.astro +0 -765
  115. package/dist/wysiwyg/components/Render.astro +0 -11
  116. package/dist/wysiwyg/editorPlugins/blocks/blocks.d.ts +0 -3
  117. package/dist/wysiwyg/editorPlugins/blocks/blocks.js +0 -239
  118. package/dist/wysiwyg/editorPlugins/blocks/index.d.ts +0 -80
  119. package/dist/wysiwyg/editorPlugins/blocks/index.js +0 -26
  120. package/dist/wysiwyg/editorPlugins/code/blocks.d.ts +0 -4
  121. package/dist/wysiwyg/editorPlugins/code/blocks.js +0 -20
  122. package/dist/wysiwyg/editorPlugins/code/commands.d.ts +0 -4
  123. package/dist/wysiwyg/editorPlugins/code/components.d.ts +0 -4
  124. package/dist/wysiwyg/editorPlugins/code/index.d.ts +0 -47
  125. package/dist/wysiwyg/editorPlugins/code/index.js +0 -28
  126. package/dist/wysiwyg/editorPlugins/code/utils.d.ts +0 -3
  127. package/dist/wysiwyg/editorPlugins/code/utils.js +0 -8
  128. package/dist/wysiwyg/editorPlugins/countdown.d.ts +0 -86
  129. package/dist/wysiwyg/editorPlugins/countdown.js +0 -163
  130. package/dist/wysiwyg/editorPlugins/forms/blocks.d.ts +0 -3
  131. package/dist/wysiwyg/editorPlugins/forms/components.d.ts +0 -11
  132. package/dist/wysiwyg/editorPlugins/forms/index.d.ts +0 -21
  133. package/dist/wysiwyg/editorPlugins/forms/index.js +0 -18
  134. package/dist/wysiwyg/editorPlugins/forms/traits.d.ts +0 -2
  135. package/dist/wysiwyg/editorPlugins/index.d.ts +0 -9
  136. package/dist/wysiwyg/editorPlugins/index.js +0 -20
  137. package/dist/wysiwyg/editorPlugins/rte/styles.css +0 -63
  138. package/dist/wysiwyg/editorPlugins/tabs/blocks.d.ts +0 -3
  139. package/dist/wysiwyg/editorPlugins/tabs/components/index.d.ts +0 -4
  140. package/dist/wysiwyg/editorPlugins/tabs/index.d.ts +0 -5
  141. package/dist/wysiwyg/editorPlugins/tabs/index.js +0 -15
  142. package/dist/wysiwyg/editorPlugins/tabs/options.d.ts +0 -5
  143. package/dist/wysiwyg/editorPlugins/tabs/options.js +0 -80
  144. package/dist/wysiwyg/editorPlugins/tabs/types.d.ts +0 -81
  145. package/dist/wysiwyg/editorPlugins/tooltip.d.ts +0 -68
  146. package/dist/wysiwyg/editorPlugins/typed/blocks.d.ts +0 -4
  147. package/dist/wysiwyg/editorPlugins/typed/blocks.js +0 -15
  148. package/dist/wysiwyg/editorPlugins/typed/components.d.ts +0 -9
  149. package/dist/wysiwyg/editorPlugins/typed/index.d.ts +0 -35
  150. package/dist/wysiwyg/editorPlugins/typed/index.js +0 -18
  151. package/dist/wysiwyg/editorPlugins/typed/traits.js +0 -18
  152. package/dist/wysiwyg/editorPlugins/typed/utils.d.ts +0 -2
  153. package/dist/wysiwyg/editorPlugins/typed/utils.js +0 -6
  154. package/dist/wysiwyg/index.d.ts +0 -20
  155. package/dist/wysiwyg/index.js +0 -47
  156. package/dist/wysiwyg/routes/partial.astro +0 -27
  157. package/dist/wysiwyg/shared.js +0 -7
  158. package/dist/wysiwyg/styles/main.css +0 -52
  159. package/dist/wysiwyg/virtual.d.ts +0 -3
  160. /package/dist/{wysiwyg/editorPlugins/typed/traits.d.ts → common/grapesBlocks/commands/deviceCommands.d.ts} +0 -0
  161. /package/dist/{wysiwyg/editorPlugins/tabs/components → common/grapesBlocks/components/tabs}/TabContainer.js +0 -0
  162. /package/dist/{wysiwyg/editorPlugins/tabs/components → common/grapesBlocks/components/tabs}/TabContent.js +0 -0
  163. /package/dist/{wysiwyg/editorPlugins/tabs/components → common/grapesBlocks/components/tabs}/TabContents.js +0 -0
  164. /package/dist/{wysiwyg/editorPlugins/tabs → common/grapesBlocks}/types.js +0 -0
@@ -1,334 +0,0 @@
1
- ---
2
- import '@grapesjs/studio-sdk/style';
3
- import { AstroSVG, firstUpperCase } from 'studiocms:wysiwyg/studio/client';
4
- import { importComponentsKeys } from 'studiocms/lib/renderer/runtime.js';
5
- import type { PluginPageTypeEditorProps } from 'studiocms/types';
6
-
7
- const componentKeys = Object.keys(await importComponentsKeys());
8
-
9
- const AstroComponentBlocks = componentKeys.map((key) => ({
10
- id: `astro-component-${key}`,
11
- label: firstUpperCase(key),
12
- category: 'Astro Components',
13
- media: AstroSVG,
14
- key,
15
- }));
16
-
17
- interface Props extends PluginPageTypeEditorProps {}
18
- ---
19
- <div class="grapes-studio-container">
20
- <div class="editor"
21
- data-blocks={JSON.stringify(AstroComponentBlocks || [])}
22
- data-compkeys={JSON.stringify(componentKeys || [])}
23
- ></div>
24
- <textarea id="page-content" name="page-content" style="display: none;">{Astro.props.content}</textarea>
25
- </div>
26
-
27
- <script>
28
- import {
29
- licenseKey, youtubeAPIKey,
30
- googleFontsAPIKey, getEditorSettings
31
- } from 'studiocms:wysiwyg/studio/client';
32
- import {
33
- tableComponent, fsLightboxComponent,
34
- lightGalleryComponent, swiperComponent,
35
- iconifyComponent, accordionComponent,
36
- flexComponent, rteTinyMce,
37
- canvasEmptyState, youtubeAssetProvider,
38
- googleFontsAssetProvider
39
- } from "@grapesjs/studio-sdk-plugins";
40
- import {
41
- createStudioEditor, StudioCommands,
42
- type CreateEditorOptions, type WithEditorProps
43
- } from '@grapesjs/studio-sdk';
44
-
45
- const editor = document.querySelector<HTMLDivElement>('.editor') as HTMLDivElement;
46
- const pageContent = document.querySelector<HTMLTextAreaElement>('#page-content') as HTMLTextAreaElement;
47
-
48
- const plugins: CreateEditorOptions["plugins"] = [
49
- tableComponent.init({
50
- block: { category: 'Extra', label: 'My Table' }
51
- }),
52
- fsLightboxComponent?.init({
53
- block: false // Skip default block
54
- }),
55
- // Add custom blocks for the lightbox
56
- (editor: WithEditorProps['editor']) => {
57
- editor.Blocks.add('lightbox-image', {
58
- label: 'Image',
59
- category: 'Lightbox',
60
- media: '<svg viewBox="0 0 24 24"><path d="M5,14L8.5,9.5L11,12.5L14.5,8L19,14M20,2H4A2,2 0 0,0 2,4V22L6,18H20A2,2 0 0,0 22,16V4C22,2.89 21.1,2 20,2Z" /></svg>',
61
- content: {
62
- type: 'fslightbox',
63
- attributes: { href: 'https://placehold.co/300/777/white.png?text=Image+LB+(Open)' },
64
- components: `<h2>Image</h2><img src="https://placehold.co/300/777/white.png?text=Image+LB">`
65
- }
66
- });
67
- editor.Blocks.add('lightbox-video', {
68
- label: 'Video',
69
- category: 'Lightbox',
70
- media: '<svg viewBox="0 0 24 24"><path d="M18,14L14,10.8V14H6V6H14V9.2L18,6M20,2H4A2,2 0 0,0 2,4V22L6,18H20A2,2 0 0,0 22,16V4C22,2.89 21.1,2 20,2Z" /></svg>',
71
- content: {
72
- type: 'fslightbox',
73
- 'source-type': 'video',
74
- attributes: { href: 'https://videos.pexels.com/video-files/15462514/15462514-uhd_2560_1440_30fps.mp4' },
75
- components: `<h2>Video</h2><img src="https://images.pexels.com/videos/15462514/pexels-photo-15462514.jpeg?auto=compress&cs=tinysrgb&dpr=1&h=300">`
76
- }
77
- });
78
- editor.Blocks.add('lightbox-el', {
79
- label: 'Element',
80
- category: 'Lightbox',
81
- media: '<svg viewBox="0 0 24 24"><path d="M20,2H4A2,2 0 0,0 2,4V22L6,18H20A2,2 0 0,0 22,16V4A2,2 0 0,0 20,2M8,14H6V12H8V14M8,11H6V9H8V11M8,8H6V6H8V8M15,14H10V12H15V14M18,11H10V9H18V11M18,8H10V6H18V8Z" /></svg>',
82
- content: () => { // Generate block with dynamic IDs
83
- const randomId = Math.random().toString(36).substring(9);
84
- const id = `el-id-${randomId}`;
85
- return [
86
- {
87
- type: 'fslightbox',
88
- 'source-type': 'el',
89
- attributes: { href: `#${id}`, 'data-fslightbox': 'custom-elements' },
90
- components: `<h2>Custom element #${randomId}</h2>`
91
- },
92
- `<div style="display: none">
93
- <div id="${id}" class="custom-element">Custom content #${randomId}</div>
94
- </div>`
95
- ];
96
- }
97
- });
98
- },
99
- lightGalleryComponent?.init({
100
- block: false // Skip default block
101
- }),
102
- // Add custom gallery blocks
103
- (editor: WithEditorProps['editor']) => {
104
- editor.Blocks.add('gallery-images', {
105
- label: 'Gallery Images',
106
- category: 'LightGallery',
107
- media: '<svg viewBox="0 0 24 24"><path d="M5,14L8.5,9.5L11,12.5L14.5,8L19,14M20,2H4A2,2 0 0,0 2,4V22L6,18H20A2,2 0 0,0 22,16V4C22,2.89 21.1,2 20,2Z" /></svg>',
108
- content: {
109
- type: 'lightGallery',
110
- components: [
111
- {
112
- type: 'lightGallery-item',
113
- attributes: { href: 'https://placehold.co/1500/777/white.png?text=Image+1+(Open)' },
114
- components: { type: 'image', src: 'https://placehold.co/100/777/white.png?text=Image+1' }
115
- },
116
- {
117
- type: 'lightGallery-item',
118
- attributes: { href: 'https://placehold.co/1500/777/white.png?text=Image+2+(Open)' },
119
- components: { type: 'image', src: 'https://placehold.co/100/777/white.png?text=Image+2' }
120
- }
121
- ]
122
- }
123
- });
124
- editor.Blocks.add('gallery-videos', {
125
- label: 'Gallery Video',
126
- category: 'LightGallery',
127
- media: '<svg viewBox="0 0 24 24"><path d="M18,14L14,10.8V14H6V6H14V9.2L18,6M20,2H4A2,2 0 0,0 2,4V22L6,18H20A2,2 0 0,0 22,16V4C22,2.89 21.1,2 20,2Z" /></svg>',
128
- content: {
129
- type: 'lightGallery',
130
- components: [
131
- {
132
- type: 'lightGallery-item',
133
- attributes: { 'data-src': 'https://www.youtube.com/watch?v=EIUJfXk3_3w', 'data-sub-html': 'Video Caption 1' },
134
- components: { type: 'image', src: 'https://img.youtube.com/vi/EIUJfXk3_3w/maxresdefault.jpg', style: { width: '200px' } }
135
- },
136
- {
137
- type: 'lightGallery-item',
138
- attributes: { 'data-src': 'https://vimeo.com/112836958', 'data-sub-html': 'Video Caption 2' },
139
- components: { type: 'image', src: 'https://i.vimeocdn.com/video/506427660-2e93a42675715090a52de8e6645d592c5f58c1a7e388231d801072c9b2d9843d-d?mw=300', style: { width: '200px' } }
140
- }
141
- ]
142
- }
143
- });
144
- },
145
- swiperComponent?.init({
146
- block: false // Skip default block
147
- }),
148
- // Add custom blocks for the swiper
149
- (editor: WithEditorProps['editor']) => {
150
- editor.Blocks.add('swiper', {
151
- label: 'Swiper Slider',
152
- category: 'Swiper example',
153
- media: '<svg viewBox="0 0 24 24"><path d="M22 7.6c0-1-.5-1.6-1.3-1.6H3.4C2.5 6 2 6.7 2 7.6v9.8c0 1 .5 1.6 1.3 1.6h17.4c.8 0 1.3-.6 1.3-1.6V7.6zM21 18H3V7h18v11z" fill-rule="nonzero"/><path d="M4 12.5L6 14v-3zM20 12.5L18 14v-3z"/></svg>',
154
- content: `<div class="swiper" style="height: 200px">
155
- <div class="swiper-wrapper">
156
- <div class="swiper-slide"><div>Slide 1</div></div>
157
- <div class="swiper-slide"><div>Slide 2</div></div>
158
- <div class="swiper-slide"><div>Slide 3</div></div>
159
- </div>
160
- <div class="swiper-button-next"></div>
161
- <div class="swiper-button-prev"></div>
162
- </div>`
163
- });
164
- },
165
- iconifyComponent.init({
166
- block: { category: 'Extra', label: 'Iconify' }
167
- }),
168
- accordionComponent.init({
169
- block: { category: 'Extra' },
170
- blockGroup: { category: 'Extra' },
171
- }),
172
- flexComponent.init({}),
173
- rteTinyMce.init({
174
- loadConfig: ({ editor }) => {
175
- const { theme } = editor.runCommand(StudioCommands.getStateTheme);
176
-
177
- return {
178
- toolbar: "bold italic underline strikethrough forecolor backcolor alignleft aligncenter alignright alignjustify link image | fontfamily fontsize bullist numlist outdent indent table",
179
- skin: (theme === 'auto' ? (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme) === 'dark' ? 'oxide-dark' : 'oxide',
180
- }
181
- }
182
- }),
183
- canvasEmptyState?.init({
184
- emptyStates: [
185
- {
186
- isValid: ['wrapper'],
187
- render: ({ editor, mount, unmount }) => {
188
- const container = document.createElement('div');
189
- container.className = 'empty-state-wrapper';
190
- container.innerHTML = `
191
- <div class="empty-state-wrapper__card">
192
- <div class="empty-state-wrapper__content">
193
- <h1>This is the empty state element of the body!</h1>
194
- <p>Drop the column block to see another component with a custom empty state!</p>
195
- </div>
196
- <button class="empty-state-wrapper__btn">Add Block</button>
197
- </div>
198
-
199
- <style>
200
- .empty-state-wrapper {
201
- font-family: system-ui, sans-serif;
202
- background-color: #f5f5f5;
203
- display: flex;
204
- justify-content: center;
205
- align-items: center;
206
- height: 100dvh;
207
- }
208
- .empty-state-wrapper__card {
209
- text-align: center;
210
- display: flex;
211
- flex-direction: column;
212
- align-items: center;
213
- justify-content: center;
214
- padding: 24px;
215
- border-radius: 4px;
216
- background-color: white;
217
- color: #333;
218
- gap: 16px;
219
- }
220
- .empty-state-wrapper__btn {
221
- background-color: #8b5cf6;
222
- padding: 8px 16px;
223
- margin: 0;
224
- color: white;
225
- border: none;
226
- cursor: pointer;
227
- border-radius: 4px;
228
- }
229
- </style>
230
- `;
231
-
232
- const btn = container.querySelector('button') as HTMLButtonElement;
233
- btn.addEventListener('click', () => {
234
- editor.runCommand('studio:layoutToggle', {
235
- id: 'emptyStateWrapperBlocks',
236
- layout: { type: 'panelBlocks' },
237
- header: { label: 'Blocks' },
238
- placer: { type: 'absolute', position: 'left' }
239
- });
240
- });
241
-
242
- // Mount the empty state container
243
- mount(container);
244
- return () => unmount(container);
245
- }
246
- },
247
- {
248
- isValid: ({ component }) => component.is('gridColumn'),
249
- render: ({ editor, component, mount }) => {
250
- const container = document.createElement('div');
251
- container.className = 'empty-state-wrapper';
252
- container.innerHTML = `
253
- <button class="empty-state-column__btn">Add text to column</button>
254
- <style>
255
- .empty-state-wrapper {
256
- display: flex;
257
- justify-content: center;
258
- align-items: center;
259
- }
260
- .empty-state-column__btn {
261
- background-color: #8b5cf6;
262
- padding: 8px 16px;
263
- margin: 0;
264
- color: white;
265
- border: none;
266
- cursor: pointer;
267
- border-radius: 4px;
268
- }
269
- </style>
270
- `;
271
- const btn = container.querySelector('button') as HTMLButtonElement;
272
- btn.addEventListener('click', () => {
273
- const textCmp = component.append('<div>New Text</div>')[0];
274
- editor.select(textCmp);
275
- textCmp.trigger('active');
276
- });
277
- mount(container);
278
- }
279
- }
280
- ]
281
- }),
282
- ];
283
-
284
- if (youtubeAPIKey) {
285
- plugins.push(
286
- youtubeAssetProvider.init({
287
- apiKey: youtubeAPIKey,
288
- searchParams: ({ searchValue }) => ({
289
- q: searchValue || 'Default search query',
290
- })
291
- }),
292
- (editor: WithEditorProps['editor']) => {
293
- editor.onReady(() => {
294
- const videoCmp = editor.getWrapper()?.findType('video')[0];
295
- editor.select(videoCmp);
296
- });
297
- },
298
- )
299
- }
300
-
301
- if (googleFontsAPIKey) {
302
- plugins.push(googleFontsAssetProvider.init({
303
- apiKey: googleFontsAPIKey,
304
- }))
305
- }
306
-
307
- createStudioEditor(getEditorSettings(licenseKey, editor, pageContent, plugins));
308
- </script>
309
-
310
- <style>
311
- :root {
312
- font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
313
- line-height: 1.5;
314
- font-weight: 400;
315
-
316
- color-scheme: light dark;
317
- color: rgba(255, 255, 255, 0.87);
318
- background-color: #242424;
319
-
320
- font-synthesis: none;
321
- text-rendering: optimizeLegibility;
322
- -webkit-font-smoothing: antialiased;
323
- -moz-osx-font-smoothing: grayscale;
324
- }
325
-
326
- .grapes-studio-container {
327
- display: flex;
328
- flex-direction: column;
329
- height: 80dvh;
330
- }
331
- .editor {
332
- height: 100%;
333
- }
334
- </style>
@@ -1,38 +0,0 @@
1
- /**
2
- * These triple-slash directives defines dependencies to various declaration files that will be
3
- * loaded when a user imports the StudioCMS plugin in their Astro configuration file. These
4
- * directives must be first at the top of the file and can only be preceded by this comment.
5
- */
6
- /// <reference types="./virtual.d.ts" preserve="true" />
7
- import { type StudioCMSPlugin } from 'studiocms/plugins';
8
- import type { SanitizeOptions } from 'ultrahtml/transformers/sanitize';
9
- /**
10
- * Represents the configuration options for the StudioCMS WYSIWYG Plugin.
11
- */
12
- export type StudioCMSWYSIWYGStudioOptions = {
13
- /** The license key required for the GrapesJS StudioSDK. */
14
- licenseKey: string;
15
- /**
16
- * YouTube API Key
17
- *
18
- * You must provide your own apiKey in the plugin options when using this in your project. Get a YouTube Data API v3 key from the [Google Cloud Console](https://console.cloud.google.com/apis/library/browse?q=youtube).
19
- */
20
- youtubeAPIKey?: string;
21
- /**
22
- * Google Data API v3 Key, Get yours at [Google Cloud Console](https://console.cloud.google.com/)
23
- */
24
- googleFontsAPIKey?: string;
25
- /** Options passed to the HTML Transformer during rendering */
26
- sanitize?: SanitizeOptions;
27
- };
28
- /**
29
- * Creates a StudioCMS plugin for integrating the GrapesJS StudioSDK WYSIWYG editor into the StudioCMS environment.
30
- *
31
- * > **Important:** GrapesJS StudioSDK License is required. If you would like a WYSIWYG Editor that does not require
32
- * > a license please try the `@studiocms/wysiwyg` default export instead.
33
- *
34
- * @returns A `StudioCMSPlugin` object that defines the plugin configuration, including page types,
35
- * integration hooks, and other metadata.
36
- */
37
- declare function studiocmsWYSIWYGStudio(options: StudioCMSWYSIWYGStudioOptions): StudioCMSPlugin;
38
- export default studiocmsWYSIWYGStudio;
@@ -1,58 +0,0 @@
1
- import { addVirtualImports, createResolver } from "astro-integration-kit";
2
- import { definePlugin } from "studiocms/plugins";
3
- import { shared } from "./shared.js";
4
- function studiocmsWYSIWYGStudio(options) {
5
- const { resolve } = createResolver(import.meta.url);
6
- const packageIdentifier = "@studiocms/wysiwyg/studio";
7
- return definePlugin({
8
- identifier: packageIdentifier,
9
- name: "StudioCMS WYSIWYG (GrapesJS StudioSDK)",
10
- studiocmsMinimumVersion: "0.1.0-beta.18",
11
- hooks: {
12
- "studiocms:astro:config": ({ addIntegrations }) => {
13
- addIntegrations({
14
- name: packageIdentifier,
15
- hooks: {
16
- "astro:config:setup": (params) => {
17
- addVirtualImports(params, {
18
- name: packageIdentifier,
19
- imports: {
20
- "studiocms:wysiwyg/studio/client": `
21
- export const licenseKey = ${JSON.stringify(options.licenseKey)};
22
- export const youtubeAPIKey = ${JSON.stringify(options.youtubeAPIKey)};
23
- export const googleFontsAPIKey = ${JSON.stringify(options.googleFontsAPIKey)};
24
- export * from '${resolve("./utils.js")}';
25
- `
26
- }
27
- });
28
- params.injectRoute({
29
- entrypoint: resolve("./routes/partial.astro"),
30
- pattern: "/studiocms_api/wysiwyg_editor/studiosdk/partial",
31
- prerender: false
32
- });
33
- },
34
- "astro:config:done": () => {
35
- shared.sanitize = options.sanitize || {};
36
- }
37
- }
38
- });
39
- },
40
- "studiocms:config:setup": ({ setRendering }) => {
41
- setRendering({
42
- pageTypes: [
43
- {
44
- identifier: "studiocms/wysiwyg/studio",
45
- label: "GrapesJS StudioSDK",
46
- rendererComponent: resolve("./components/Render.astro"),
47
- pageContentComponent: resolve("./components/StudioSDKEditor.astro")
48
- }
49
- ]
50
- });
51
- }
52
- }
53
- });
54
- }
55
- var studio_default = studiocmsWYSIWYGStudio;
56
- export {
57
- studio_default as default
58
- };
@@ -1,27 +0,0 @@
1
- ---
2
- export const partial = true;
3
- import { importComponentsKeys } from 'studiocms/lib/renderer/runtime.js';
4
-
5
- // Import components
6
- const components = await importComponentsKeys();
7
-
8
- const data = await Astro.request.json();
9
- if (!data || typeof data.componentKey !== 'string') {
10
- return new Response(JSON.stringify({ error: 'Missing or invalid componentKey' }), {
11
- status: 400,
12
- headers: { 'Content-Type': 'application/json' },
13
- });
14
- }
15
- const { componentKey } = data;
16
-
17
- const Component = components[componentKey];
18
-
19
- // Handle case where component doesn't exist
20
- if (!Component) {
21
- return new Response(JSON.stringify({ error: `Component "${componentKey}" not found` }), {
22
- status: 404,
23
- headers: { 'Content-Type': 'application/json' },
24
- });
25
- }
26
- ---
27
- <Component />
@@ -1,17 +0,0 @@
1
- type Shared = {
2
- sanitize: import('ultrahtml/transformers/sanitize').SanitizeOptions;
3
- };
4
- declare global {
5
- var studiocmsWYSIWYGStudio: Shared;
6
- }
7
- /**
8
- * A shared object used across the WYSIWYG Studio module. This object is either retrieved
9
- * from the global `studiocmsWYSIWYGStudio` property or initialized as a new object with
10
- * default properties if it does not already exist.
11
- *
12
- * @remarks
13
- * The `sanitize` property is initialized as an empty object and can be used to store
14
- * sanitization-related configurations or utilities.
15
- */
16
- export declare const shared: Shared;
17
- export {};
@@ -1,7 +0,0 @@
1
- const shared = globalThis.studiocmsWYSIWYGStudio || // biome-ignore lint/suspicious/noAssignInExpressions: <explanation>
2
- (globalThis.studiocmsWYSIWYGStudio = {
3
- sanitize: {}
4
- });
5
- export {
6
- shared
7
- };
@@ -1,105 +0,0 @@
1
- import type { CreateEditorOptions, WithEditorProps } from '@grapesjs/studio-sdk';
2
- import { firstUpperCase, parse } from '../utils.js';
3
- export { firstUpperCase, parse };
4
- export declare const AstroSVG: string;
5
- export declare const fallbackPages: {
6
- pages: {
7
- name: string;
8
- }[];
9
- };
10
- /**
11
- * A fallback project object used as a default value when a project fails to load.
12
- *
13
- * @constant
14
- * @property {Object} default - The default project structure.
15
- * @property {Array<Object>} default.pages - An array of page objects for the fallback project.
16
- * @property {string} default.pages[].component - The HTML content to display as a fallback message.
17
- */
18
- export declare const fallbackProject: {
19
- default: {
20
- pages: {
21
- name: string;
22
- }[];
23
- };
24
- };
25
- /**
26
- * Represents an array of Astro component blocks, where each block contains metadata
27
- * about a specific component used in the system.
28
- */
29
- export type AstroComponentBlocks = {
30
- id: string;
31
- label: string;
32
- category: string;
33
- media: string;
34
- key: string;
35
- }[];
36
- /**
37
- * Represents an array of editor blocks used in the Astro component editor.
38
- * Each block contains metadata and a function to generate its content.
39
- */
40
- export type AstroComponentEditorBlocks = {
41
- id: string;
42
- label: string;
43
- category: string;
44
- media: string;
45
- content: () => string;
46
- }[];
47
- /**
48
- * Converts an array of `AstroComponentBlocks` into an array of `AstroComponentEditorBlocks`.
49
- *
50
- * Each block in the input array is transformed by extracting its `key` property
51
- * and using it to generate a `content` function that returns a string representation
52
- * of an HTML element with the given key as its tag name. The rest of the block's properties
53
- * are preserved in the output.
54
- *
55
- * @param blocks - An array of `AstroComponentBlocks` to be converted.
56
- * @returns An array of `AstroComponentEditorBlocks` with updated `content` functions.
57
- */
58
- export declare function convertComponentBlocks(blocks: AstroComponentBlocks): AstroComponentEditorBlocks;
59
- /**
60
- * Generates the HTML content of the first page from the editor's project files.
61
- *
62
- * @param editor - The editor instance implementing the `WithEditorProps['editor']` interface.
63
- * @returns A promise that resolves to a string containing the HTML content of the first page.
64
- *
65
- * @remarks
66
- * - This function uses the `studio:projectFiles` command to retrieve the project files
67
- * with inline styles.
68
- * - It assumes that the first page is identified by the MIME type `text/html`.
69
- * - The `content` property of the first page is cast to a string and returned as the result.
70
- *
71
- * @throws Will throw an error if the `studio:projectFiles` command fails or if no HTML file is found.
72
- */
73
- export declare const generateHTML: (editor: WithEditorProps["editor"]) => Promise<string>;
74
- /**
75
- * Creates a plugin for the editor to handle custom Astro components.
76
- *
77
- * @param componentKeys - An array of strings representing the tag names of the Astro components to be recognized.
78
- * @returns A function that takes an editor instance and registers a custom component type (`astro-component`) with the editor.
79
- *
80
- * The custom component type includes:
81
- * - A `isComponent` method to determine if an element matches one of the specified `componentKeys`.
82
- * - A `view` object that defines how the component is rendered in the editor, including:
83
- * - A placeholder HTML structure with a styled card layout.
84
- * - A loading animation for the placeholder.
85
- *
86
- * The placeholder displays the name of the Astro component in a styled card format.
87
- */
88
- export declare const getPlugin: (componentKeys: string[]) => (editor: WithEditorProps["editor"]) => void;
89
- /**
90
- * Generates the editor settings for the GrapesJS StudioSDK WYSIWYG editor.
91
- *
92
- * @param licenseKey - The license key required to initialize the editor.
93
- * @param root - The root HTML element containing dataset attributes for blocks and component keys.
94
- * @param pageContent - The HTML element containing the serialized project data as inner text.
95
- * @returns An object of type `CreateEditorOptions` containing the configuration for the editor.
96
- *
97
- * The returned configuration includes:
98
- * - License key validation.
99
- * - Plugins setup based on component keys.
100
- * - Project and block data initialization.
101
- * - Asset storage configuration.
102
- * - Custom storage handlers for saving and loading project data.
103
- * - Autosave settings for periodic saving of changes.
104
- */
105
- export declare function getEditorSettings(licenseKey: string, root: HTMLElement, pageContent: HTMLElement, plugins?: CreateEditorOptions['plugins']): CreateEditorOptions;