@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,244 +0,0 @@
1
- import { firstUpperCase, parse } from "../utils.js";
2
- const AstroSVG = '<svg xmlns="http://www.w3.org/2000/svg" style="width:48px;height:48px" viewBox="0 0 24 24"><path fill="currentColor" d="M9.24 19.035c-.901-.826-1.164-2.561-.789-3.819c.65.793 1.552 1.044 2.486 1.186c1.44.218 2.856.137 4.195-.524c.153-.076.295-.177.462-.278c.126.365.159.734.115 1.11c-.107.915-.56 1.622-1.283 2.158c-.289.215-.594.406-.892.608c-.916.622-1.164 1.35-.82 2.41l.034.114a2.4 2.4 0 0 1-1.07-.918a2.6 2.6 0 0 1-.412-1.401c-.003-.248-.003-.497-.036-.74c-.081-.595-.36-.86-.883-.876a1.034 1.034 0 0 0-1.075.843q-.013.058-.033.126M4.1 15.007s2.666-1.303 5.34-1.303l2.016-6.26c.075-.304.296-.51.544-.51c.25 0 .47.206.545.51l2.016 6.26c3.167 0 5.34 1.303 5.34 1.303L15.363 2.602c-.13-.366-.35-.602-.645-.602H9.283c-.296 0-.506.236-.645.602c-.01.024-4.538 12.405-4.538 12.405"/></svg>';
3
- const fallbackPages = {
4
- pages: [{ name: "page" }]
5
- };
6
- const fallbackProject = {
7
- default: fallbackPages
8
- };
9
- function convertComponentBlocks(blocks) {
10
- return blocks.map(({ key, ...block }) => ({
11
- ...block,
12
- content: () => `<${key}></${key}>`
13
- }));
14
- }
15
- const generateHTML = async (editor) => {
16
- const page = editor.Pages.getMain();
17
- const component = page.getMainComponent();
18
- const htmlData = component.toHTML({ tag: "div" });
19
- const styles = editor.getCss({ component })?.replaceAll("body", "div");
20
- const html = `${htmlData}${styles ? `<style>${styles}</style>` : ""}`;
21
- return html;
22
- };
23
- const getPlugin = (componentKeys) => (editor) => {
24
- editor.DomComponents.addType("astro-component", {
25
- isComponent: (el) => componentKeys.includes(el.tagName?.toLowerCase()),
26
- view: {
27
- tagName: () => "div",
28
- onRender: async ({ el, model }) => {
29
- const getCompResponse = await fetch("/studiocms_api/wysiwyg_editor/studiosdk/partial", {
30
- method: "POST",
31
- body: JSON.stringify({ componentKey: model.tagName }),
32
- headers: {
33
- "Content-Type": "application/json"
34
- }
35
- });
36
- if (!getCompResponse.ok)
37
- console.log("[Error]: Could not fetch component HTML, please try again.");
38
- const html = await getCompResponse.text();
39
- el.innerHTML = html;
40
- }
41
- }
42
- });
43
- };
44
- function getEditorSettings(licenseKey, root, pageContent, plugins) {
45
- const projectData = JSON.parse(pageContent.innerText || JSON.stringify(fallbackPages));
46
- const rawBlocks = parse(root.dataset.blocks);
47
- const componentKeys = parse(root.dataset.compkeys);
48
- const pluginList = [getPlugin(componentKeys)];
49
- if (typeof plugins === "function") {
50
- pluginList.push(...plugins({ plugins: pluginList }));
51
- } else if (Array.isArray(plugins)) {
52
- pluginList.push(...plugins);
53
- }
54
- return {
55
- licenseKey,
56
- plugins: pluginList,
57
- pages: false,
58
- root,
59
- project: fallbackProject,
60
- blocks: {
61
- default: convertComponentBlocks(rawBlocks)
62
- },
63
- assets: {
64
- storageType: "self"
65
- },
66
- storage: {
67
- type: "self",
68
- // Provide a custom handler for saving the project data.
69
- onSave: async ({ project, editor }) => {
70
- pageContent.innerText = JSON.stringify({
71
- ...project,
72
- __STUDIOCMS_HTML: await generateHTML(editor)
73
- });
74
- },
75
- onLoad: async () => ({ project: projectData }),
76
- autosaveChanges: 50,
77
- autosaveIntervalMs: 1e4
78
- },
79
- layout: {
80
- default: {
81
- type: "row",
82
- style: { height: "100%" },
83
- children: [
84
- {
85
- type: "column",
86
- style: { padding: 5, gap: 5, borderRightWidth: 1, zIndex: 20, alignItems: "center" },
87
- children: [
88
- {
89
- type: "button",
90
- icon: "layers",
91
- editorEvents: {
92
- "studio:layoutToggle:layoutId1": ({ fromEvent, setState }) => setState({ active: fromEvent.isOpen })
93
- },
94
- onClick: ({ editor }) => {
95
- editor.runCommand("studio:layoutRemove", { id: "layoutId2" });
96
- editor.runCommand("studio:layoutRemove", { id: "layoutId3" });
97
- editor.runCommand("studio:layoutRemove", { id: "layoutId4" });
98
- editor.runCommand("studio:layoutRemove", { id: "layoutId5" });
99
- editor.runCommand("studio:layoutToggle", {
100
- id: "layoutId1",
101
- layout: { type: "panelPagesLayers" },
102
- header: { label: "Layers" },
103
- placer: { type: "absolute", position: "left" },
104
- style: { marginLeft: 42 }
105
- });
106
- }
107
- },
108
- {
109
- type: "button",
110
- icon: "viewGridPlus",
111
- editorEvents: {
112
- "studio:layoutToggle:layoutId2": ({ fromEvent, setState }) => setState({ active: fromEvent.isOpen })
113
- },
114
- onClick: ({ editor }) => {
115
- editor.runCommand("studio:layoutRemove", { id: "layoutId1" });
116
- editor.runCommand("studio:layoutRemove", { id: "layoutId3" });
117
- editor.runCommand("studio:layoutRemove", { id: "layoutId4" });
118
- editor.runCommand("studio:layoutRemove", { id: "layoutId5" });
119
- editor.runCommand("studio:layoutToggle", {
120
- id: "layoutId2",
121
- layout: { type: "panelBlocks" },
122
- header: { label: "Blocks" },
123
- placer: { type: "absolute", position: "left" },
124
- style: { marginLeft: 42 }
125
- });
126
- }
127
- },
128
- {
129
- type: "button",
130
- icon: "target",
131
- editorEvents: {
132
- "studio:layoutToggle:layoutId3": ({ fromEvent, setState }) => setState({ active: fromEvent.isOpen })
133
- },
134
- onClick: ({ editor }) => {
135
- editor.runCommand("studio:layoutRemove", { id: "layoutId1" });
136
- editor.runCommand("studio:layoutRemove", { id: "layoutId2" });
137
- editor.runCommand("studio:layoutRemove", { id: "layoutId4" });
138
- editor.runCommand("studio:layoutRemove", { id: "layoutId5" });
139
- editor.runCommand("studio:layoutToggle", {
140
- id: "layoutId3",
141
- layout: { type: "panelSelectors" },
142
- header: { label: "Selectors" },
143
- placer: { type: "absolute", position: "left" },
144
- style: { marginLeft: 42, padding: 6 }
145
- });
146
- }
147
- },
148
- {
149
- type: "button",
150
- icon: "paletteSwatch",
151
- editorEvents: {
152
- "studio:layoutToggle:layoutId4": ({ fromEvent, setState }) => setState({ active: fromEvent.isOpen })
153
- },
154
- onClick: ({ editor }) => {
155
- editor.runCommand("studio:layoutRemove", { id: "layoutId1" });
156
- editor.runCommand("studio:layoutRemove", { id: "layoutId2" });
157
- editor.runCommand("studio:layoutRemove", { id: "layoutId3" });
158
- editor.runCommand("studio:layoutRemove", { id: "layoutId5" });
159
- editor.runCommand("studio:layoutToggle", {
160
- id: "layoutId4",
161
- layout: { type: "panelStyles" },
162
- header: { label: "Styles" },
163
- placer: { type: "absolute", position: "left" },
164
- style: { marginLeft: 42, padding: 6 }
165
- });
166
- }
167
- },
168
- {
169
- type: "button",
170
- icon: "cog",
171
- editorEvents: {
172
- "studio:layoutToggle:layoutId5": ({ fromEvent, setState }) => setState({ active: fromEvent.isOpen })
173
- },
174
- onClick: ({ editor }) => {
175
- editor.runCommand("studio:layoutRemove", { id: "layoutId1" });
176
- editor.runCommand("studio:layoutRemove", { id: "layoutId2" });
177
- editor.runCommand("studio:layoutRemove", { id: "layoutId3" });
178
- editor.runCommand("studio:layoutRemove", { id: "layoutId4" });
179
- editor.runCommand("studio:layoutToggle", {
180
- id: "layoutId5",
181
- layout: { type: "panelProperties" },
182
- header: { label: "Properties" },
183
- placer: { type: "absolute", position: "left" },
184
- style: { marginLeft: 42, padding: 6 }
185
- });
186
- }
187
- }
188
- ]
189
- },
190
- {
191
- type: "column",
192
- style: { height: "100%", width: "100%" },
193
- children: [
194
- {
195
- type: "sidebarTop",
196
- leftContainer: false,
197
- rightContainer: {
198
- buttons: [
199
- {
200
- id: "undo",
201
- icon: "arrowULeftTop",
202
- disabled: true,
203
- onClick: ({ editor }) => editor.runCommand("core:undo"),
204
- editorEvents: {
205
- "change:changesCount": ({ setState, editor }) => setState({ disabled: !editor.UndoManager.hasUndo() })
206
- }
207
- },
208
- {
209
- id: "redo",
210
- icon: "arrowURightTop",
211
- disabled: true,
212
- onClick: ({ editor }) => editor.runCommand("core:redo"),
213
- editorEvents: {
214
- "change:changesCount": ({ setState, editor }) => setState({ disabled: !editor.UndoManager.hasRedo() })
215
- }
216
- },
217
- {
218
- id: "store",
219
- icon: "floppy",
220
- tooltip: "Save Changes",
221
- onClick: async ({ editor }) => editor.store()
222
- }
223
- ]
224
- }
225
- },
226
- { type: "canvas", grow: true }
227
- ]
228
- }
229
- ]
230
- }
231
- }
232
- };
233
- }
234
- export {
235
- AstroSVG,
236
- convertComponentBlocks,
237
- fallbackPages,
238
- fallbackProject,
239
- firstUpperCase,
240
- generateHTML,
241
- getEditorSettings,
242
- getPlugin,
243
- parse
244
- };
@@ -1,114 +0,0 @@
1
- declare module 'virtual:studiocms/plugins/renderers' {
2
- export const studiocms_wysiwyg_studio: typeof import('./components/Render.astro').default;
3
- }
4
-
5
- declare module 'studiocms:wysiwyg/studio/client' {
6
- /**
7
- * Represents an array of Astro component blocks, where each block contains metadata
8
- * about a specific component used in the system.
9
- */
10
- export type AstroComponentBlocks = import('./utils').AstroComponentBlocks;
11
- /**
12
- * Represents an array of editor blocks used in the Astro component editor.
13
- * Each block contains metadata and a function to generate its content.
14
- */
15
- export type AstroComponentEditorBlocks = import('./utils').AstroComponentEditorBlocks;
16
- /**
17
- * Converts the first character of a given string to uppercase while keeping the rest of the string unchanged.
18
- *
19
- * @param text - The input string to be transformed.
20
- * @returns A new string with the first character converted to uppercase. If the input string has a length of 1 or less, it is returned unchanged.
21
- */
22
- export const firstUpperCase: typeof import('./utils').firstUpperCase;
23
- /**
24
- * Parses a JSON string into a strongly-typed object.
25
- *
26
- * @template T - The type of the object to parse the JSON string into.
27
- * @param data - The JSON string to be parsed.
28
- * @returns The parsed object of type `T`.
29
- * @throws {SyntaxError} If the input string is not valid JSON.
30
- */
31
- export const parse: typeof import('./utils').parse;
32
- /**
33
- * A fallback project object used as a default value when a project fails to load.
34
- *
35
- * @constant
36
- * @property {Object} default - The default project structure.
37
- * @property {Array<Object>} default.pages - An array of page objects for the fallback project.
38
- * @property {string} default.pages[].component - The HTML content to display as a fallback message.
39
- */
40
- export const fallbackProject: typeof import('./utils').fallbackProject;
41
- /** License Key for GrapesJS StudioSDK */
42
- export const licenseKey: string;
43
- /**
44
- * YouTube API Key
45
- *
46
- * 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).
47
- */
48
- export const youtubeAPIKey: string | undefined;
49
- /**
50
- * Google Data API v3 Key, Get yours at https://console.cloud.google.com/
51
- */
52
- export const googleFontsAPIKey: string | undefined;
53
- /** Astro Logo SVG */
54
- export const AstroSVG: string;
55
- /**
56
- * Converts an array of `AstroComponentBlocks` into an array of `AstroComponentEditorBlocks`.
57
- *
58
- * Each block in the input array is transformed by extracting its `key` property
59
- * and using it to generate a `content` function that returns a string representation
60
- * of an HTML element with the given key as its tag name. The rest of the block's properties
61
- * are preserved in the output.
62
- *
63
- * @param blocks - An array of `AstroComponentBlocks` to be converted.
64
- * @returns An array of `AstroComponentEditorBlocks` with updated `content` functions.
65
- */
66
- export const convertComponentBlocks: typeof import('./utils').convertComponentBlocks;
67
- /**
68
- * Generates the HTML content of the first page from the editor's project files.
69
- *
70
- * @param editor - The editor instance implementing the `WithEditorProps['editor']` interface.
71
- * @returns A promise that resolves to a string containing the HTML content of the first page.
72
- *
73
- * @remarks
74
- * - This function uses the `studio:projectFiles` command to retrieve the project files
75
- * with inline styles.
76
- * - It assumes that the first page is identified by the MIME type `text/html`.
77
- * - The `content` property of the first page is cast to a string and returned as the result.
78
- *
79
- * @throws Will throw an error if the `studio:projectFiles` command fails or if no HTML file is found.
80
- */
81
- export const generateHTML: typeof import('./utils').generateHTML;
82
- /**
83
- * Creates a plugin for the editor to handle custom Astro components.
84
- *
85
- * @param componentKeys - An array of strings representing the tag names of the Astro components to be recognized.
86
- * @returns A function that takes an editor instance and registers a custom component type (`astro-component`) with the editor.
87
- *
88
- * The custom component type includes:
89
- * - A `isComponent` method to determine if an element matches one of the specified `componentKeys`.
90
- * - A `view` object that defines how the component is rendered in the editor, including:
91
- * - A placeholder HTML structure with a styled card layout.
92
- * - A loading animation for the placeholder.
93
- *
94
- * The placeholder displays the name of the Astro component in a styled card format.
95
- */
96
- export const getPlugin: typeof import('./utils').getPlugin;
97
- /**
98
- * Generates the editor settings for the GrapesJS StudioSDK WYSIWYG editor.
99
- *
100
- * @param licenseKey - The license key required to initialize the editor.
101
- * @param root - The root HTML element containing dataset attributes for blocks and component keys.
102
- * @param pageContent - The HTML element containing the serialized project data as inner text.
103
- * @returns An object of type `CreateEditorOptions` containing the configuration for the editor.
104
- *
105
- * The returned configuration includes:
106
- * - License key validation.
107
- * - Plugins setup based on component keys.
108
- * - Project and block data initialization.
109
- * - Asset storage configuration.
110
- * - Custom storage handlers for saving and loading project data.
111
- * - Autosave settings for periodic saving of changes.
112
- */
113
- export const getEditorSettings: typeof import('./utils').getEditorSettings;
114
- }
package/dist/utils.js DELETED
@@ -1,15 +0,0 @@
1
- function firstUpperCase(text) {
2
- if (text.length > 1) {
3
- const p1 = text.slice(0, 1);
4
- const p2 = text.slice(1);
5
- return `${p1.toUpperCase()}${p2}`;
6
- }
7
- return text;
8
- }
9
- function parse(data) {
10
- return JSON.parse(data);
11
- }
12
- export {
13
- firstUpperCase,
14
- parse
15
- };