@studiocms/wysiwyg 0.1.0-experimental.5 → 0.1.0

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,765 +0,0 @@
1
- ---
2
- import '@studiocms/ui/css/colors.css';
3
- import 'grapesjs/dist/css/grapes.min.css';
4
- import '../editorPlugins/rte/styles.css';
5
- import '../styles/main.css';
6
- import { importComponentsKeys } from 'studiocms/lib/renderer/runtime.js';
7
- import type { PluginPageTypeEditorProps } from 'studiocms/types';
8
- import { firstUpperCase } from '../../utils.js';
9
-
10
- const AstroSVG: string =
11
- '<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>';
12
-
13
- const componentKeys = Object.keys(await importComponentsKeys());
14
-
15
- const AstroComponentBlocks = componentKeys.map((key) => ({
16
- id: `astro-component-${key}`,
17
- label: firstUpperCase(key),
18
- category: 'Astro Components',
19
- media: AstroSVG,
20
- key,
21
- }));
22
-
23
- interface Props extends PluginPageTypeEditorProps {}
24
- ---
25
-
26
- <div
27
- class="editor-container"
28
- data-blocks={JSON.stringify(AstroComponentBlocks || [])}
29
- data-compkeys={JSON.stringify(componentKeys || [])}
30
- >
31
- <div class="editor">
32
- <div id="gjs" style=" overflow:hidden">
33
- <h1>Hello World Component!</h1>
34
- </div>
35
- </div>
36
- </div>
37
- <textarea id="page-content" name="page-content" style="display: none;"
38
- >{Astro.props.content}</textarea
39
- >
40
-
41
- <script>
42
- import { toast } from "@studiocms/ui/components/Toast/toast.js";
43
- import grapesjs, { type Editor, usePlugin } from "grapesjs";
44
- import { parse } from "../../utils.js";
45
- import {
46
- blocks,
47
- customCode,
48
- countdown,
49
- forms,
50
- rte,
51
- tabs,
52
- tooltip,
53
- tuiImageEditor,
54
- typed
55
- } from '../editorPlugins/index.js';
56
- import "@studiocms/grapesjs-plugin";
57
-
58
- /**
59
- * Represents an array of Astro component blocks, where each block contains metadata
60
- * about a specific component used in the system.
61
- */
62
- type AstroComponentBlocks = {
63
- id: string;
64
- label: string;
65
- category: string;
66
- media: string;
67
- key: string;
68
- }[];
69
-
70
- /**
71
- * Represents an array of editor blocks used in the Astro component editor.
72
- * Each block contains metadata and a function to generate its content.
73
- */
74
- type AstroComponentEditorBlocks = {
75
- id: string;
76
- label: string;
77
- category: string;
78
- media: string;
79
- content: () => string;
80
- }[];
81
-
82
- /**
83
- * Converts an array of `AstroComponentBlocks` into an array of `AstroComponentEditorBlocks`.
84
- *
85
- * Each block in the input array is transformed by extracting its `key` property
86
- * and using it to generate a `content` function that returns a string representation
87
- * of an HTML element with the given key as its tag name. The rest of the block's properties
88
- * are preserved in the output.
89
- *
90
- * @param blocks - An array of `AstroComponentBlocks` to be converted.
91
- * @returns An array of `AstroComponentEditorBlocks` with updated `content` functions.
92
- */
93
- function convertComponentBlocks(
94
- blocks: AstroComponentBlocks,
95
- ): AstroComponentEditorBlocks {
96
- return blocks.map(({ key, ...block }) => ({
97
- ...block,
98
- content: () => `<${key}></${key}>`,
99
- }));
100
- }
101
-
102
- const getPlugin = (componentKeys: string[]) => (editor: Editor) => {
103
- editor.DomComponents.addType("astro-component", {
104
- isComponent: (el) => componentKeys.includes(el.tagName?.toLowerCase()),
105
- view: {
106
- tagName: () => "div",
107
- onRender: async ({ el, model }) => {
108
- // Fetch from API endpoint that uses Astro Container API to render Component to html
109
- const getCompResponse = await fetch(
110
- "/studiocms_api/wysiwyg_editor/partial",
111
- {
112
- method: "POST",
113
- body: JSON.stringify({ componentKey: model.tagName }),
114
- headers: {
115
- "Content-Type": "application/json",
116
- },
117
- },
118
- );
119
-
120
- // If response is not valid, log error.
121
- if (!getCompResponse.ok)
122
- console.log(
123
- "[Error]: Could not fetch component HTML, please try again.",
124
- );
125
-
126
- // Get HTML from JSON response
127
- const html = await getCompResponse.text();
128
-
129
- // Set the HTML in the Editor View
130
- el.innerHTML = html;
131
- },
132
- },
133
- });
134
- };
135
-
136
- const pageContent = document.querySelector<HTMLTextAreaElement>(
137
- "#page-content",
138
- ) as HTMLTextAreaElement;
139
- const editorContainer = document.querySelector<HTMLDivElement>(
140
- ".editor-container",
141
- ) as HTMLDivElement;
142
-
143
- const rawBlocks = parse<AstroComponentBlocks>(
144
- editorContainer.dataset.blocks as string,
145
- );
146
- const componentKeys = parse<string[]>(
147
- editorContainer.dataset.compkeys as string,
148
- );
149
-
150
- const fallbackPages = {
151
- pages: [{ name: "page" }],
152
- };
153
-
154
- const projectData = JSON.parse(
155
- pageContent.innerText || JSON.stringify(fallbackPages),
156
- );
157
-
158
- const generateHTML = async (editor: Editor): Promise<string> => {
159
- const page = editor.Pages.getMain();
160
- const component = page.getMainComponent();
161
- const htmlData = component.toHTML({ tag: "div" });
162
- const styles = editor.getCss({ component })?.replaceAll("body", "div");
163
- const html = `${htmlData}${styles ? `<style>${styles}</style>` : ""}`;
164
- return html;
165
- };
166
-
167
- // Inline storage
168
- const inlineStorage = (editor: Editor) => {
169
- editor.Storage.add("inline", {
170
- load() {
171
- return projectData;
172
- },
173
- async store(data) {
174
- pageContent.innerText = JSON.stringify({
175
- ...data,
176
- __STUDIOCMS_HTML: await generateHTML(editor),
177
- });
178
- },
179
- });
180
- };
181
-
182
- const osm = 'open-sm';
183
- const otm = 'open-tm';
184
- const ola = 'open-layers';
185
- const obl = 'open-blocks';
186
- const iconStyle = 'style="display: block; max-width:22px"';
187
-
188
- const editor = grapesjs.init({
189
- container: "#gjs",
190
- height: "80dvh",
191
- width: "auto",
192
- // Disable the storage manager for the moment
193
- storageManager: { type: "inline" },
194
- panels: { defaults: [] },
195
- plugins: [
196
- usePlugin(getPlugin(componentKeys)),
197
- usePlugin(inlineStorage),
198
- usePlugin(blocks, {
199
- flexGrid: true
200
- }),
201
- usePlugin(tabs, {
202
- tabsBlock: {
203
- category: 'Extra'
204
- },
205
- }),
206
- usePlugin(countdown),
207
- usePlugin(customCode),
208
- usePlugin(tooltip),
209
- usePlugin(tuiImageEditor, {
210
- script: [
211
- "https://uicdn.toast.com/tui.code-snippet/v1.5.2/tui-code-snippet.min.js",
212
- "https://uicdn.toast.com/tui-color-picker/v2.2.7/tui-color-picker.min.js",
213
- "https://uicdn.toast.com/tui-image-editor/v3.15.2/tui-image-editor.min.js",
214
- ],
215
- style: [
216
- "https://uicdn.toast.com/tui-color-picker/v2.2.7/tui-color-picker.min.css",
217
- "https://uicdn.toast.com/tui-image-editor/v3.15.2/tui-image-editor.min.css",
218
- ],
219
- }),
220
- usePlugin(typed),
221
- usePlugin(forms),
222
- usePlugin(rte),
223
- '@studiocms/grapesjs-plugin',
224
- ],
225
- blockManager: {
226
- blocks: convertComponentBlocks(rawBlocks),
227
- },
228
- styleManager: {
229
- sectors: [
230
- {
231
- name: "General",
232
- properties: [
233
- {
234
- extend: "float",
235
- type: "radio",
236
- default: "none",
237
- options: [
238
- { value: "none", className: "fa fa-times", id: "" },
239
- { value: "left", className: "fa fa-align-left", id: "" },
240
- { value: "right", className: "fa fa-align-right", id: "" },
241
- ],
242
- },
243
- "display",
244
- { extend: "position", type: "select" },
245
- "top",
246
- "right",
247
- "left",
248
- "bottom",
249
- ],
250
- },
251
- {
252
- name: "Dimension",
253
- open: false,
254
- properties: [
255
- "width",
256
- {
257
- id: "flex-width",
258
- type: "integer",
259
- name: "Width",
260
- units: ["px", "%"],
261
- property: "flex-basis",
262
- toRequire: true,
263
- },
264
- "height",
265
- "max-width",
266
- "min-height",
267
- "margin",
268
- "padding",
269
- ],
270
- },
271
- {
272
- name: "Typography",
273
- open: false,
274
- properties: [
275
- "font-family",
276
- "font-size",
277
- "font-weight",
278
- "letter-spacing",
279
- "color",
280
- "line-height",
281
- {
282
- extend: "text-align",
283
- options: [
284
- { id: "left", label: "Left", className: "fa fa-align-left" },
285
- {
286
- id: "center",
287
- label: "Center",
288
- className: "fa fa-align-center",
289
- },
290
- { id: "right", label: "Right", className: "fa fa-align-right" },
291
- {
292
- id: "justify",
293
- label: "Justify",
294
- className: "fa fa-align-justify",
295
- },
296
- ],
297
- },
298
- {
299
- property: "text-decoration",
300
- type: "radio",
301
- default: "none",
302
- options: [
303
- { id: "none", label: "None", className: "fa fa-times" },
304
- {
305
- id: "underline",
306
- label: "underline",
307
- className: "fa fa-underline",
308
- },
309
- {
310
- id: "line-through",
311
- label: "Line-through",
312
- className: "fa fa-strikethrough",
313
- },
314
- ],
315
- },
316
- "text-shadow",
317
- ],
318
- },
319
- {
320
- name: "Decorations",
321
- open: false,
322
- properties: [
323
- "opacity",
324
- "border-radius",
325
- "border",
326
- "box-shadow",
327
- "background", // { id: 'background-bg', property: 'background', type: 'bg' }
328
- ],
329
- },
330
- {
331
- name: "Extra",
332
- open: false,
333
- buildProps: ["transition", "perspective", "transform"],
334
- },
335
- {
336
- name: "Flex",
337
- open: false,
338
- properties: [
339
- {
340
- name: "Flex Container",
341
- property: "display",
342
- type: "select",
343
- defaults: "block",
344
- list: [
345
- { value: "block", name: "Disable", id: "" },
346
- { value: "flex", name: "Enable", id: "" },
347
- ],
348
- },
349
- {
350
- name: "Flex Parent",
351
- property: "label-parent-flex",
352
- type: "integer",
353
- },
354
- {
355
- name: "Direction",
356
- property: "flex-direction",
357
- type: "radio",
358
- defaults: "row",
359
- list: [
360
- {
361
- value: "row",
362
- name: "Row",
363
- className: "icons-flex icon-dir-row",
364
- title: "Row",
365
- id: "",
366
- },
367
- {
368
- value: "row-reverse",
369
- name: "Row reverse",
370
- className: "icons-flex icon-dir-row-rev",
371
- title: "Row reverse",
372
- id: "",
373
- },
374
- {
375
- value: "column",
376
- name: "Column",
377
- title: "Column",
378
- className: "icons-flex icon-dir-col",
379
- id: "",
380
- },
381
- {
382
- value: "column-reverse",
383
- name: "Column reverse",
384
- title: "Column reverse",
385
- className: "icons-flex icon-dir-col-rev",
386
- id: "",
387
- },
388
- ],
389
- },
390
- {
391
- name: "Justify",
392
- property: "justify-content",
393
- type: "radio",
394
- defaults: "flex-start",
395
- list: [
396
- {
397
- value: "flex-start",
398
- className: "icons-flex icon-just-start",
399
- title: "Start",
400
- id: "",
401
- },
402
- {
403
- value: "flex-end",
404
- title: "End",
405
- className: "icons-flex icon-just-end",
406
- id: "",
407
- },
408
- {
409
- value: "space-between",
410
- title: "Space between",
411
- className: "icons-flex icon-just-sp-bet",
412
- id: "",
413
- },
414
- {
415
- value: "space-around",
416
- title: "Space around",
417
- className: "icons-flex icon-just-sp-ar",
418
- id: "",
419
- },
420
- {
421
- value: "center",
422
- title: "Center",
423
- className: "icons-flex icon-just-sp-cent",
424
- id: "",
425
- },
426
- ],
427
- },
428
- {
429
- name: "Align",
430
- property: "align-items",
431
- type: "radio",
432
- defaults: "center",
433
- list: [
434
- {
435
- value: "flex-start",
436
- title: "Start",
437
- className: "icons-flex icon-al-start",
438
- id: "",
439
- },
440
- {
441
- value: "flex-end",
442
- title: "End",
443
- className: "icons-flex icon-al-end",
444
- id: "",
445
- },
446
- {
447
- value: "stretch",
448
- title: "Stretch",
449
- className: "icons-flex icon-al-str",
450
- id: "",
451
- },
452
- {
453
- value: "center",
454
- title: "Center",
455
- className: "icons-flex icon-al-center",
456
- id: "",
457
- },
458
- ],
459
- },
460
- {
461
- name: "Flex Children",
462
- property: "label-parent-flex",
463
- type: "integer",
464
- },
465
- {
466
- name: "Order",
467
- property: "order",
468
- type: "integer",
469
- // @ts-ignore
470
- defaults: 0,
471
- min: 0,
472
- },
473
- {
474
- name: "Flex",
475
- property: "flex",
476
- type: "composite",
477
- properties: [
478
- {
479
- name: "Grow",
480
- property: "flex-grow",
481
- type: "integer",
482
- // @ts-ignore
483
- defaults: 0,
484
- min: 0,
485
- },
486
- {
487
- name: "Shrink",
488
- property: "flex-shrink",
489
- type: "integer",
490
- // @ts-ignore
491
- defaults: 0,
492
- min: 0,
493
- },
494
- {
495
- name: "Basis",
496
- property: "flex-basis",
497
- type: "integer",
498
- units: ["px", "%", ""],
499
- unit: "",
500
- defaults: "auto",
501
- },
502
- ],
503
- },
504
- {
505
- name: "Align",
506
- property: "align-self",
507
- type: "radio",
508
- defaults: "auto",
509
- list: [
510
- {
511
- value: "auto",
512
- name: "Auto",
513
- id: "",
514
- },
515
- {
516
- value: "flex-start",
517
- title: "Start",
518
- className: "icons-flex icon-al-start",
519
- id: "",
520
- },
521
- {
522
- value: "flex-end",
523
- title: "End",
524
- className: "icons-flex icon-al-end",
525
- id: "",
526
- },
527
- {
528
- value: "stretch",
529
- title: "Stretch",
530
- className: "icons-flex icon-al-str",
531
- id: "",
532
- },
533
- {
534
- value: "center",
535
- title: "Center",
536
- className: "icons-flex icon-al-center",
537
- id: "",
538
- },
539
- ],
540
- },
541
- ],
542
- },
543
- ],
544
- },
545
- });
546
-
547
- editor.I18n.addMessages({
548
- en: {
549
- styleManager: {
550
- properties: {
551
- "background-repeat": "Repeat",
552
- "background-position": "Position",
553
- "background-attachment": "Attachment",
554
- "background-size": "Size",
555
- },
556
- },
557
- },
558
- });
559
-
560
- var pn = editor.Panels;
561
- var modal = editor.Modal;
562
- var cmdm = editor.Commands;
563
-
564
- pn.getPanels().reset([
565
- {
566
- id: 'commands',
567
- buttons: [{}],
568
- },
569
- {
570
- id: 'devices-c',
571
- buttons: [
572
- {
573
- id: "set-device-desktop",
574
- command: "set-device-desktop",
575
- active: true,
576
- label: `<svg ${iconStyle} viewBox="0 0 24 24">
577
- <path fill="currentColor" d="M21,16H3V4H21M21,2H3C1.89,2 1,2.89 1,4V16A2,2 0 0,0 3,18H10V20H8V22H16V20H14V18H21A2,2 0 0,0 23,16V4C23,2.89 22.1,2 21,2Z" />
578
- </svg>`,
579
- },
580
- {
581
- id: "set-device-tablet",
582
- command: "set-device-tablet",
583
- label: `<svg ${iconStyle} viewBox="0 0 24 24">
584
- <path fill="currentColor" d="M19,18H5V6H19M21,4H3C1.89,4 1,4.89 1,6V18A2,2 0 0,0 3,20H21A2,2 0 0,0 23,18V6C23,4.89 22.1,4 21,4Z" />
585
- </svg>`,
586
- },
587
- {
588
- id: "set-device-mobile",
589
- command: "set-device-mobile",
590
- label: `<svg ${iconStyle} viewBox="0 0 24 24">
591
- <path fill="currentColor" d="M17,19H7V5H17M17,1H7C5.89,1 5,1.89 5,3V21A2,2 0 0,0 7,23H17A2,2 0 0,0 19,21V3C19,1.89 18.1,1 17,1Z" />
592
- </svg>`,
593
- },
594
- ],
595
- },
596
- {
597
- id: 'options',
598
- buttons: [
599
- {
600
- id: 'undo',
601
- command: () => editor.runCommand('core:undo'),
602
- label: `<svg ${iconStyle} viewBox="0 0 24 24">
603
- <path fill="currentColor" d="M20 13.5C20 17.09 17.09 20 13.5 20H6V18H13.5C16 18 18 16 18 13.5S16 9 13.5 9H7.83L10.91 12.09L9.5 13.5L4 8L9.5 2.5L10.92 3.91L7.83 7H13.5C17.09 7 20 9.91 20 13.5Z" />
604
- </svg>`,
605
- },
606
- {
607
- id: 'redo',
608
- command: () => editor.runCommand('core:redo'),
609
- label: `<svg ${iconStyle} viewBox="0 0 24 24">
610
- <path fill="currentColor" d="M10.5 18H18V20H10.5C6.91 20 4 17.09 4 13.5S6.91 7 10.5 7H16.17L13.08 3.91L14.5 2.5L20 8L14.5 13.5L13.09 12.09L16.17 9H10.5C8 9 6 11 6 13.5S8 18 10.5 18Z" />
611
- </svg>`,
612
- },
613
- {
614
- id: "canvas-clear",
615
- command: () => editor.runCommand("canvas-clear"),
616
- label: `<svg ${iconStyle} viewBox="0 0 24 24">
617
- <path fill="currentColor" d="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z" />
618
- </svg>`,
619
- },
620
- ],
621
- },
622
- {
623
- id: 'views',
624
- buttons: [
625
- {
626
- id: osm,
627
- command: osm,
628
- active: true,
629
- label: `<svg ${iconStyle} viewBox="0 0 24 24">
630
- <path fill="currentColor" d="M20.71,4.63L19.37,3.29C19,2.9 18.35,2.9 17.96,3.29L9,12.25L11.75,15L20.71,6.04C21.1,5.65 21.1,5 20.71,4.63M7,14A3,3 0 0,0 4,17C4,18.31 2.84,19 2,19C2.92,20.22 4.5,21 6,21A4,4 0 0,0 10,17A3,3 0 0,0 7,14Z" />
631
- </svg>`,
632
- },
633
- {
634
- id: otm,
635
- command: otm,
636
- label: `<svg ${iconStyle} viewBox="0 0 24 24">
637
- <path fill="currentColor" d="M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z" />
638
- </svg>`,
639
- },
640
- {
641
- id: ola,
642
- command: ola,
643
- label: `<svg ${iconStyle} viewBox="0 0 24 24">
644
- <path fill="currentColor" d="M12,16L19.36,10.27L21,9L12,2L3,9L4.63,10.27M12,18.54L4.62,12.81L3,14.07L12,21.07L21,14.07L19.37,12.8L12,18.54Z" />
645
- </svg>`,
646
- },
647
- {
648
- id: obl,
649
- command: obl,
650
- label: `<svg ${iconStyle} viewBox="0 0 24 24">
651
- <path fill="currentColor" d="M17,13H13V17H11V13H7V11H11V7H13V11H17M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3Z" />
652
- </svg>`,
653
- },
654
- ]
655
- },
656
- ])
657
-
658
- // Update canvas-clear command
659
- cmdm.add("canvas-clear", function () {
660
- if (confirm("Are you sure to clean the canvas?")) {
661
- editor.runCommand("core:canvas-clear");
662
- }
663
- });
664
-
665
- // Simple warn notifier
666
- var origWarn = console.warn;
667
- console.warn = function (msg) {
668
- if (msg.indexOf("[undefined]") == -1) {
669
- toast({
670
- title: "Warning",
671
- type: "warning",
672
- description: msg,
673
- });
674
- }
675
- origWarn(msg);
676
- };
677
-
678
- // Add and beautify tooltips
679
- [
680
- ["sw-visibility", "Show Borders"],
681
- ["preview", "Preview"],
682
- ["fullscreen", "Fullscreen"],
683
- ["export-template", "Export"],
684
- ["undo", "Undo"],
685
- ["redo", "Redo"],
686
- ["gjs-open-import-webpage", "Import"],
687
- ["canvas-clear", "Clear canvas"],
688
- ].forEach(function (item) {
689
- pn.getButton("options", item[0])?.set("attributes", {
690
- title: item[1],
691
- "data-tooltip-pos": "bottom",
692
- });
693
- });
694
- [
695
- ["open-sm", "Style Manager"],
696
- ["open-layers", "Layers"],
697
- ["open-blocks", "Blocks"],
698
- ].forEach(function (item) {
699
- pn.getButton("views", item[0])?.set("attributes", {
700
- title: item[1],
701
- "data-tooltip-pos": "bottom",
702
- });
703
- });
704
- var titles = document.querySelectorAll("*[title]");
705
-
706
- for (var i = 0; i < titles.length; i++) {
707
- var el = titles[i];
708
- var title = el.getAttribute("title");
709
- title = title ? title.trim() : "";
710
- if (!title) break;
711
- el.setAttribute("data-tooltip", title);
712
- el.setAttribute("title", "");
713
- }
714
-
715
- // Do stuff on load
716
- editor.on("load", function () {
717
- var $ = grapesjs.$;
718
-
719
- // Load and show settings and style manager
720
- var openTmBtn = pn.getButton("views", "open-tm");
721
- openTmBtn && openTmBtn.set("active", 1);
722
- var openSm = pn.getButton("views", "open-sm");
723
- openSm && openSm.set("active", 1);
724
-
725
- // Remove trait view
726
- pn.removeButton("views", "open-tm");
727
-
728
- // Add Settings Sector
729
- var traitsSector = $(
730
- '<div class="gjs-sm-sector no-select">' +
731
- '<div class="gjs-sm-sector-title"><span class="icon-settings fa fa-cog"></span> <span class="gjs-sm-sector-label">Settings</span></div>' +
732
- '<div class="gjs-sm-properties" style="display: none;"></div></div>',
733
- );
734
- var traitsProps = traitsSector.find(".gjs-sm-properties");
735
- traitsProps.append($(".gjs-traits-cs"));
736
- $(".gjs-sm-sectors").before(traitsSector);
737
- traitsSector.find(".gjs-sm-sector-title").on("click", function () {
738
- var traitStyle = traitsProps.get(0).style;
739
- var hidden = traitStyle.display == "none";
740
- if (hidden) {
741
- traitStyle.display = "block";
742
- } else {
743
- traitStyle.display = "none";
744
- }
745
- });
746
-
747
- // Open block manager
748
- var openBlocksBtn = editor.Panels.getButton("views", "open-blocks");
749
- openBlocksBtn && openBlocksBtn.set("active", 1);
750
- });
751
-
752
- </script>
753
-
754
- <style>
755
- :root {
756
- font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
757
- line-height: 1.5;
758
- font-weight: 400;
759
-
760
- font-synthesis: none;
761
- text-rendering: optimizeLegibility;
762
- -webkit-font-smoothing: antialiased;
763
- -moz-osx-font-smoothing: grayscale;
764
- }
765
- </style>