@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
@@ -0,0 +1,245 @@
1
+ const cmdImport = "gjs-open-import-webpage";
2
+ const cmdDeviceDesktop = "set-device-desktop";
3
+ const cmdDeviceTablet = "set-device-tablet";
4
+ const cmdDeviceMobile = "set-device-mobile";
5
+ const exportTemplate = "export-template";
6
+ const cmdClear = "canvas-clear";
7
+ const cmdSave = "store-data";
8
+ const typedId = "typed";
9
+ const typedTraitStringId = "typed-strings";
10
+ const keyCustomCode = "custom-code-plugin__code";
11
+ const typeCustomCode = "custom-code";
12
+ const commandNameCustomCode = "custom-code:open-modal";
13
+ const typeForm = "form";
14
+ const typeInput = "input";
15
+ const typeTextarea = "textarea";
16
+ const typeSelect = "select";
17
+ const typeCheckbox = "checkbox";
18
+ const typeRadio = "radio";
19
+ const typeButton = "button";
20
+ const typeLabel = "label";
21
+ const typeOption = "option";
22
+ const resolveTemplate = (template, props) => {
23
+ if (!template) {
24
+ return void 0;
25
+ }
26
+ if (typeof template === "function") {
27
+ return template(props);
28
+ }
29
+ return template;
30
+ };
31
+ const mergeStyles = (userStyle) => {
32
+ return userStyle || defaultStyle;
33
+ };
34
+ const defaultStyle = (config) => `
35
+ .${config.classTab} {
36
+ padding: 7px 14px;
37
+ display: inline-block;
38
+ border-radius: 3px;
39
+ margin-right: 10px;
40
+ }
41
+
42
+ .${config.classTab}:focus {
43
+ outline: none;
44
+ }
45
+
46
+ .${config.classTab}.${config.classTabActive} {
47
+ background-color: #0d94e6;
48
+ color: white;
49
+ }
50
+
51
+ .${config.classTabContainer} {
52
+ display: inline-block;
53
+ }
54
+
55
+ .${config.classTabContent} {
56
+ animation: fadeEffect 1s;
57
+ }
58
+
59
+ .${config.classTabContents} {
60
+ min-height: 100px;
61
+ padding: 10px;
62
+ }
63
+
64
+ @keyframes fadeEffect {
65
+ from {opacity: 0;}
66
+ to {opacity: 1;}
67
+ }
68
+ `;
69
+ const defaultGrapesBlocksOptions = {
70
+ blocks: [
71
+ "link-block",
72
+ "quote",
73
+ "text-basic",
74
+ "tooltip",
75
+ "typed",
76
+ "column1",
77
+ "column2",
78
+ "column3",
79
+ "column3-7",
80
+ "text",
81
+ "link",
82
+ "image",
83
+ "video",
84
+ "map",
85
+ "countdown",
86
+ "custom-code",
87
+ "form",
88
+ "input",
89
+ "textarea",
90
+ "select",
91
+ "button",
92
+ "label",
93
+ "checkbox",
94
+ "radio",
95
+ "tabs"
96
+ ],
97
+ block: () => ({}),
98
+ modalImportTitle: "Import",
99
+ modalImportButton: "Import",
100
+ modalImportLabel: "",
101
+ modalImportContent: "",
102
+ importViewerOptions: {},
103
+ textCleanCanvas: "Are you sure you want to clear the canvas?",
104
+ showStylesOnChange: true,
105
+ flexGrid: true,
106
+ stylePrefix: "gjs-",
107
+ addBasicStyle: true,
108
+ labelColumn1: "1 Column",
109
+ labelColumn2: "2 Columns",
110
+ labelColumn3: "3 Columns",
111
+ labelColumn37: "2 Columns 3/7",
112
+ labelText: "Text",
113
+ labelLink: "Link",
114
+ labelImage: "Image",
115
+ labelVideo: "Video",
116
+ labelMap: "Map",
117
+ rowHeight: 75,
118
+ tooltip: {
119
+ id: "tooltip",
120
+ labelTooltip: "Tooltip",
121
+ blockTooltip: {},
122
+ propsTooltip: {},
123
+ extendTraits: (traits) => traits,
124
+ attrTooltip: "data-tooltip",
125
+ classTooltip: "tooltip-component",
126
+ style: "",
127
+ styleAdditional: "",
128
+ privateClasses: true,
129
+ stylableTooltip: [
130
+ "background-color",
131
+ "padding",
132
+ "padding-top",
133
+ "padding-right",
134
+ "padding-bottom",
135
+ "padding-left",
136
+ "font-family",
137
+ "font-size",
138
+ "font-weight",
139
+ "letter-spacing",
140
+ "color",
141
+ "line-height",
142
+ "text-align",
143
+ "border-radius",
144
+ "border-top-left-radius",
145
+ "border-top-right-radius",
146
+ "border-bottom-left-radius",
147
+ "border-bottom-right-radius",
148
+ "border",
149
+ "border-width",
150
+ "border-style",
151
+ "border-color"
152
+ ],
153
+ showTooltipOnStyle: true
154
+ },
155
+ typed: {
156
+ script: "https://cdn.jsdelivr.net/npm/typed.js@2.0.11",
157
+ block: {},
158
+ props: (p) => p
159
+ },
160
+ rteOpts: {},
161
+ countdown: {
162
+ id: "countdown",
163
+ label: "Countdown",
164
+ block: {},
165
+ props: {},
166
+ style: "",
167
+ styleAdditional: "",
168
+ startTime: "",
169
+ endText: "EXPIRED",
170
+ dateInputType: "date",
171
+ labelDays: "days",
172
+ labelHours: "hours",
173
+ labelMinutes: "minutes",
174
+ labelSeconds: "seconds",
175
+ classPrefix: "countdown"
176
+ },
177
+ customCode: {
178
+ blockCustomCode: {},
179
+ propsCustomCode: {},
180
+ toolbarBtnCustomCode: {},
181
+ placeholderScript: `<div style="pointer-events: none; padding: 10px;">
182
+ <svg viewBox="0 0 24 24" style="height: 30px; vertical-align: middle;">
183
+ <path d="M13 14h-2v-4h2m0 8h-2v-2h2M1 21h22L12 2 1 21z"></path>
184
+ </svg>
185
+ Custom code with <i>&lt;script&gt;</i> can't be rendered on the canvas
186
+ </div>`,
187
+ modalTitle: "Insert your code",
188
+ codeViewOptions: {},
189
+ buttonLabel: "Save",
190
+ commandCustomCode: {}
191
+ },
192
+ tabOptions: {
193
+ // Block settings
194
+ tabsBlock: {},
195
+ tabsProps: {},
196
+ tabContainerProps: {},
197
+ tabProps: {},
198
+ tabContentProps: {},
199
+ tabContentsProps: {},
200
+ // Class names
201
+ classTab: "tab",
202
+ classTabContainer: "tab-container",
203
+ classTabActive: "tab-active",
204
+ classTabContent: "tab-content",
205
+ classTabContents: "tab-contents",
206
+ // Selectors and types
207
+ selectorTab: "aria-controls",
208
+ typeTabs: "tabs",
209
+ typeTabContainer: "tab-container",
210
+ typeTab: "tab",
211
+ typeTabContent: "tab-content",
212
+ typeTabContents: "tab-contents",
213
+ // Templates
214
+ templateTab: ({ index }) => `<span data-gjs-highlightable="false">Tab ${index}</span>`,
215
+ templateTabContent: ({ index }) => `<div>Tab Content ${index}</div>`,
216
+ // Style
217
+ style: defaultStyle
218
+ }
219
+ };
220
+ export {
221
+ cmdClear,
222
+ cmdDeviceDesktop,
223
+ cmdDeviceMobile,
224
+ cmdDeviceTablet,
225
+ cmdImport,
226
+ cmdSave,
227
+ commandNameCustomCode,
228
+ defaultGrapesBlocksOptions,
229
+ exportTemplate,
230
+ keyCustomCode,
231
+ mergeStyles,
232
+ resolveTemplate,
233
+ typeButton,
234
+ typeCheckbox,
235
+ typeCustomCode,
236
+ typeForm,
237
+ typeInput,
238
+ typeLabel,
239
+ typeOption,
240
+ typeRadio,
241
+ typeSelect,
242
+ typeTextarea,
243
+ typedId,
244
+ typedTraitStringId
245
+ };
@@ -0,0 +1,3 @@
1
+ import type { Editor } from 'grapesjs';
2
+ export declare const loadI18n: (editor: Editor) => void;
3
+ export default loadI18n;
@@ -0,0 +1,19 @@
1
+ const loadI18n = (editor) => {
2
+ editor.I18n.addMessages({
3
+ en: {
4
+ styleManager: {
5
+ properties: {
6
+ "background-repeat": "Repeat",
7
+ "background-position": "Position",
8
+ "background-attachment": "Attachment",
9
+ "background-size": "Size"
10
+ }
11
+ }
12
+ }
13
+ });
14
+ };
15
+ var i18n_default = loadI18n;
16
+ export {
17
+ i18n_default as default,
18
+ loadI18n
19
+ };
@@ -0,0 +1,4 @@
1
+ import type { Editor } from 'grapesjs';
2
+ import type { RequiredGrapesBlocksOptions } from '../types.js';
3
+ export declare function loadPanels(editor: Editor, opts: RequiredGrapesBlocksOptions): void;
4
+ export default loadPanels;
@@ -0,0 +1,171 @@
1
+ import {
2
+ cmdClear,
3
+ cmdDeviceDesktop,
4
+ cmdDeviceMobile,
5
+ cmdDeviceTablet,
6
+ cmdImport,
7
+ exportTemplate
8
+ } from "../consts.js";
9
+ function loadPanels(editor, opts) {
10
+ const { Panels } = editor;
11
+ const config = editor.getConfig();
12
+ const osm = "open-sm";
13
+ const otm = "open-tm";
14
+ const ola = "open-layers";
15
+ const obl = "open-blocks";
16
+ const iconStyle = 'style="display: block; max-width:22px"';
17
+ config.showDevices = false;
18
+ Panels.getPanels().reset([
19
+ {
20
+ id: "commands",
21
+ buttons: [{}]
22
+ },
23
+ {
24
+ id: "devices-c",
25
+ buttons: [
26
+ {
27
+ id: cmdDeviceDesktop,
28
+ command: cmdDeviceDesktop,
29
+ active: true,
30
+ label: `<svg ${iconStyle} viewBox="0 0 24 24">
31
+ <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" />
32
+ </svg>`
33
+ },
34
+ {
35
+ id: cmdDeviceTablet,
36
+ command: cmdDeviceTablet,
37
+ label: `<svg ${iconStyle} viewBox="0 0 24 24">
38
+ <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" />
39
+ </svg>`
40
+ },
41
+ {
42
+ id: cmdDeviceMobile,
43
+ command: cmdDeviceMobile,
44
+ label: `<svg ${iconStyle} viewBox="0 0 24 24">
45
+ <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" />
46
+ </svg>`
47
+ }
48
+ ]
49
+ },
50
+ {
51
+ id: "options",
52
+ buttons: [
53
+ {
54
+ id: "undo",
55
+ command: () => editor.runCommand("core:undo"),
56
+ label: `<svg ${iconStyle} title="Undo" viewBox="0 0 24 24">
57
+ <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" />
58
+ </svg>`
59
+ },
60
+ {
61
+ id: "redo",
62
+ command: () => editor.runCommand("core:redo"),
63
+ label: `<svg ${iconStyle} viewBox="0 0 24 24">
64
+ <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" />
65
+ </svg>`
66
+ },
67
+ {
68
+ id: cmdImport,
69
+ command: () => editor.runCommand(cmdImport),
70
+ label: `<svg ${iconStyle} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="size-6"> <path fill-rule="evenodd" d="M9.75 6.75h-3a3 3 0 0 0-3 3v7.5a3 3 0 0 0 3 3h7.5a3 3 0 0 0 3-3v-7.5a3 3 0 0 0-3-3h-3V1.5a.75.75 0 0 0-1.5 0v5.25Zm0 0h1.5v5.69l1.72-1.72a.75.75 0 1 1 1.06 1.06l-3 3a.75.75 0 0 1-1.06 0l-3-3a.75.75 0 1 1 1.06-1.06l1.72 1.72V6.75Z" clip-rule="evenodd" /><path d="M7.151 21.75a2.999 2.999 0 0 0 2.599 1.5h7.5a3 3 0 0 0 3-3v-7.5c0-1.11-.603-2.08-1.5-2.599v7.099a4.5 4.5 0 0 1-4.5 4.5H7.151Z" /></svg>`
71
+ },
72
+ {
73
+ id: exportTemplate,
74
+ command: () => editor.runCommand(exportTemplate),
75
+ label: `<svg ${iconStyle} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="size-6"><path d="M9.97.97a.75.75 0 0 1 1.06 0l3 3a.75.75 0 0 1-1.06 1.06l-1.72-1.72v3.44h-1.5V3.31L8.03 5.03a.75.75 0 0 1-1.06-1.06l3-3ZM9.75 6.75v6a.75.75 0 0 0 1.5 0v-6h3a3 3 0 0 1 3 3v7.5a3 3 0 0 1-3 3h-7.5a3 3 0 0 1-3-3v-7.5a3 3 0 0 1 3-3h3Z" /><path d="M7.151 21.75a2.999 2.999 0 0 0 2.599 1.5h7.5a3 3 0 0 0 3-3v-7.5c0-1.11-.603-2.08-1.5-2.599v7.099a4.5 4.5 0 0 1-4.5 4.5H7.151Z" /></svg>`
76
+ },
77
+ {
78
+ id: cmdClear,
79
+ command: () => editor.runCommand(cmdClear),
80
+ label: `<svg ${iconStyle} viewBox="0 0 24 24">
81
+ <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" />
82
+ </svg>`
83
+ },
84
+ {
85
+ id: "fullscreen",
86
+ command: "core:fullscreen",
87
+ label: `<svg ${iconStyle} viewBox="0 0 24 24" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" ><path stroke-linecap="round" stroke-linejoin="round" d="M7.5 3.75H6A2.25 2.25 0 0 0 3.75 6v1.5M16.5 3.75H18A2.25 2.25 0 0 1 20.25 6v1.5m0 9V18A2.25 2.25 0 0 1 18 20.25h-1.5m-9 0H6A2.25 2.25 0 0 1 3.75 18v-1.5M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" /></svg>`
88
+ },
89
+ {
90
+ id: "save",
91
+ command: "save-page",
92
+ label: `<svg ${iconStyle} fill="none" viewBox="0 0 24 24" stroke-width="1.5" class="save-indicator"><path fill="none" stroke-linecap="round" stroke-linejoin="round" d="M21.75 17.25v-.228a4.5 4.5 0 0 0-.12-1.03l-2.268-9.64a3.375 3.375 0 0 0-3.285-2.602H7.923a3.375 3.375 0 0 0-3.285 2.602l-2.268 9.64a4.5 4.5 0 0 0-.12 1.03v.228m19.5 0a3 3 0 0 1-3 3H5.25a3 3 0 0 1-3-3m19.5 0a3 3 0 0 0-3-3H5.25a3 3 0 0 0-3 3m16.5 0h.008v.008h-.008v-.008Zm-3 0h.008v.008h-.008v-.008Z" /><circle cx="20" cy="18" r="4" fill="#ef4444" stroke="white" stroke-width="0.5" class="dirty-indicator" /></svg>`
93
+ }
94
+ ]
95
+ },
96
+ {
97
+ id: "views",
98
+ buttons: [
99
+ {
100
+ id: osm,
101
+ command: osm,
102
+ active: true,
103
+ label: `<svg ${iconStyle} viewBox="0 0 24 24">
104
+ <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" />
105
+ </svg>`
106
+ },
107
+ {
108
+ id: otm,
109
+ command: otm,
110
+ label: `<svg ${iconStyle} viewBox="0 0 24 24">
111
+ <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" />
112
+ </svg>`
113
+ },
114
+ {
115
+ id: ola,
116
+ command: ola,
117
+ label: `<svg ${iconStyle} viewBox="0 0 24 24">
118
+ <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" />
119
+ </svg>`
120
+ },
121
+ {
122
+ id: obl,
123
+ command: obl,
124
+ label: `<svg ${iconStyle} viewBox="0 0 24 24">
125
+ <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" />
126
+ </svg>`
127
+ }
128
+ ]
129
+ }
130
+ ]);
131
+ [
132
+ ["sw-visibility", "Show Borders"],
133
+ ["preview", "Preview"],
134
+ ["fullscreen", "Fullscreen"],
135
+ ["export-template", "Export"],
136
+ ["undo", "Undo"],
137
+ ["redo", "Redo"],
138
+ ["gjs-open-import-webpage", "Import"],
139
+ ["canvas-clear", "Clear canvas"],
140
+ ["save", "Save page"]
141
+ ].forEach((item) => {
142
+ Panels.getButton("options", item[0])?.set("attributes", {
143
+ title: item[1],
144
+ "data-tooltip-pos": "bottom"
145
+ });
146
+ });
147
+ [
148
+ ["open-sm", "Style Manager"],
149
+ ["open-layers", "Layers"],
150
+ ["open-blocks", "Blocks"]
151
+ ].forEach((item) => {
152
+ Panels.getButton("views", item[0])?.set("attributes", {
153
+ title: item[1],
154
+ "data-tooltip-pos": "bottom"
155
+ });
156
+ });
157
+ const openBl = Panels.getButton("views", obl);
158
+ editor.on("load", () => openBl?.set("active", true));
159
+ opts.showStylesOnChange && editor.on("component:selected", () => {
160
+ const openSmBtn = Panels.getButton("views", osm);
161
+ const openLayersBtn = Panels.getButton("views", ola);
162
+ if ((!openLayersBtn || !openLayersBtn.get("active")) && editor.getSelected()) {
163
+ openSmBtn?.set("active", true);
164
+ }
165
+ });
166
+ }
167
+ var panels_default = loadPanels;
168
+ export {
169
+ panels_default as default,
170
+ loadPanels
171
+ };
@@ -16,6 +16,7 @@ export default class ColorPicker {
16
16
  private isOpen;
17
17
  private colors;
18
18
  private options;
19
+ private windowClickHandler?;
19
20
  /**
20
21
  * ColorPicker
21
22
  * Creates a new `ColorPicker` instance.
@@ -38,6 +39,14 @@ export default class ColorPicker {
38
39
  * @return {ColorPicker} The `ColorPicker` instance.
39
40
  */
40
41
  constructor(sel: string | HTMLElement, colors?: string[], options?: ColorPickerOptions);
42
+ /**
43
+ * destroy
44
+ * Cleans up event listeners and resources.
45
+ *
46
+ * @name destroy
47
+ * @function
48
+ */
49
+ destroy(): void;
41
50
  /**
42
51
  * getElm
43
52
  * Finds the HTML element.
@@ -5,6 +5,7 @@ class ColorPicker {
5
5
  isOpen;
6
6
  colors;
7
7
  options;
8
+ windowClickHandler;
8
9
  /**
9
10
  * ColorPicker
10
11
  * Creates a new `ColorPicker` instance.
@@ -84,12 +85,25 @@ class ColorPicker {
84
85
  this.close();
85
86
  });
86
87
  if (this.options.closeOnBlur) {
87
- window.addEventListener("click", (ev) => {
88
+ this.windowClickHandler = (ev) => {
88
89
  const target = ev.target;
89
90
  if (target !== this.options.open && target !== this.elm && this.isOpen) {
90
91
  this.close();
91
92
  }
92
- });
93
+ };
94
+ window.addEventListener("click", this.windowClickHandler);
95
+ }
96
+ }
97
+ /**
98
+ * destroy
99
+ * Cleans up event listeners and resources.
100
+ *
101
+ * @name destroy
102
+ * @function
103
+ */
104
+ destroy() {
105
+ if (this.windowClickHandler) {
106
+ window.removeEventListener("click", this.windowClickHandler);
93
107
  }
94
108
  if (this.options.autoclose !== false) {
95
109
  this.close();
@@ -29,7 +29,7 @@ interface ActionOptions {
29
29
  paste?: boolean;
30
30
  delete?: boolean;
31
31
  }
32
- interface RichTextEditorOptions {
32
+ export interface RichTextEditorOptions {
33
33
  base?: BaseOptions | boolean;
34
34
  fonts?: FontOptions;
35
35
  format?: FormatOptions | boolean;
@@ -44,5 +44,5 @@ interface RichTextEditorOptions {
44
44
  darkColorPicker?: boolean;
45
45
  maxWidth?: string;
46
46
  }
47
- declare const plugin: Plugin<RichTextEditorOptions>;
48
- export default plugin;
47
+ declare const richTextEditor: Plugin<RichTextEditorOptions>;
48
+ export default richTextEditor;
@@ -1,5 +1,5 @@
1
1
  import ColorPicker from "./colorPicker.js";
2
- const plugin = (editor, opts = {}) => {
2
+ const richTextEditor = (editor, opts = {}) => {
3
3
  const options = {
4
4
  ...{
5
5
  // default options
@@ -63,7 +63,13 @@ const plugin = (editor, opts = {}) => {
63
63
  ${fontOptionsEl}
64
64
  </select>`;
65
65
  editor.onReady(() => {
66
- if (options.maxWidth) rte.getToolbarEl().firstChild.style.maxWidth = options.maxWidth;
66
+ if (options.maxWidth) {
67
+ const toolbar = rte.getToolbarEl();
68
+ const firstChild = toolbar.firstChild;
69
+ if (firstChild) {
70
+ firstChild.style.maxWidth = options.maxWidth;
71
+ }
72
+ }
67
73
  if (!options.base || typeof options.base === "object") {
68
74
  const baseOpts = options.base;
69
75
  !baseOpts.bold && rte.remove("bold");
@@ -80,10 +86,10 @@ const plugin = (editor, opts = {}) => {
80
86
  style: "padding: 0 4px 2px;",
81
87
  title: "Font Name"
82
88
  },
83
- // @ts-ignore
89
+ // @ts-expect-error
84
90
  result: (rte2, action) => rte2.exec("fontName", action.btn?.firstChild?.value),
85
91
  // Callback on any input change (mousedown, keydown, etc..)
86
- // @ts-ignore
92
+ // @ts-expect-error
87
93
  update: (rte2, action) => {
88
94
  const value = rte2.doc.queryCommandValue(action.name);
89
95
  if (value !== "false") {
@@ -107,10 +113,10 @@ const plugin = (editor, opts = {}) => {
107
113
  style: "padding: 0 4px 2px;",
108
114
  title: "Font Size"
109
115
  },
110
- // @ts-ignore
116
+ // @ts-expect-error
111
117
  result: (rte2, action) => rte2.exec("fontSize", action.btn?.firstChild?.value),
112
118
  // Callback on any input change (mousedown, keydown, etc..)
113
- // @ts-ignore
119
+ // @ts-expect-error
114
120
  update: (rte2, action) => {
115
121
  const value = rte2.doc.queryCommandValue(action.name);
116
122
  if (value !== "false") {
@@ -121,7 +127,7 @@ const plugin = (editor, opts = {}) => {
121
127
  const pk1 = {};
122
128
  options.fonts?.fontColor && rte.add("fontColor", {
123
129
  icon: `${icons?.fontColor || '<b style="pointer-events:none;border-bottom:2px solid">A</b>'}
124
- <div id="foreColor-picker-${// @ts-ignore
130
+ <div id="foreColor-picker-${// @ts-expect-error
125
131
  editor.Config.container?.replace("#", "")}"
126
132
  class="${options.darkColorPicker ? "rte-color-picker dark" : "rte-color-picker light"}">
127
133
  </div>`,
@@ -130,7 +136,7 @@ const plugin = (editor, opts = {}) => {
130
136
  title: "Font Color"
131
137
  },
132
138
  result: (rte2) => {
133
- const pikerEle = `#foreColor-picker-${// @ts-ignore
139
+ const pikerEle = `#foreColor-picker-${// @ts-expect-error
134
140
  editor.Config.container?.replace("#", "")}`;
135
141
  if (!pk1[pikerEle])
136
142
  pk1[pikerEle] = new ColorPicker(
@@ -147,7 +153,7 @@ const plugin = (editor, opts = {}) => {
147
153
  const pk2 = {};
148
154
  options.fonts?.hilite && rte.add("hiliteColor", {
149
155
  icon: `${icons?.hiliteColor || '<b style="pointer-events:none;" class="rte-hilite-btn">A</b>'}
150
- <div id="hilite-picker-${// @ts-ignore
156
+ <div id="hilite-picker-${// @ts-expect-error
151
157
  editor.Config.container?.replace("#", "")}"
152
158
  class="${options.darkColorPicker ? "rte-color-picker dark" : "rte-color-picker light"}">
153
159
  </div>`,
@@ -156,7 +162,7 @@ const plugin = (editor, opts = {}) => {
156
162
  title: "Font Highlight"
157
163
  },
158
164
  result: (rte2) => {
159
- const pikerEle = `#hilite-picker-${// @ts-ignore
165
+ const pikerEle = `#hilite-picker-${// @ts-expect-error
160
166
  editor.Config.container?.replace("#", "")}`;
161
167
  if (!pk2[pikerEle])
162
168
  pk2[pikerEle] = new ColorPicker(
@@ -284,7 +290,7 @@ const plugin = (editor, opts = {}) => {
284
290
  result: (rte2) => rte2.exec("justifyLeft")
285
291
  });
286
292
  options.align && rte.add("justifyCenter", {
287
- icon: icons?.justifyRight || '<i class="fa fa-align-center"></i>',
293
+ icon: icons?.justifyCenter || '<i class="fa fa-align-center"></i>',
288
294
  attributes: {
289
295
  title: "Align Center"
290
296
  },
@@ -363,7 +369,7 @@ const plugin = (editor, opts = {}) => {
363
369
  });
364
370
  });
365
371
  };
366
- var rte_default = plugin;
372
+ var rte_default = richTextEditor;
367
373
  export {
368
374
  rte_default as default
369
375
  };
@@ -0,0 +1,4 @@
1
+ import type { Editor } from 'grapesjs';
2
+ import type { RequiredGrapesBlocksOptions } from '../types.js';
3
+ export declare function loadSelectors(editor: Editor, opts: RequiredGrapesBlocksOptions): void;
4
+ export default loadSelectors;
@@ -0,0 +1,9 @@
1
+ import loadTooltip from "./tooltip.js";
2
+ function loadSelectors(editor, opts) {
3
+ loadTooltip(editor, opts.tooltip);
4
+ }
5
+ var selectors_default = loadSelectors;
6
+ export {
7
+ selectors_default as default,
8
+ loadSelectors
9
+ };
@@ -0,0 +1,4 @@
1
+ import type { Editor } from 'grapesjs';
2
+ import type { RequiredTooltipOptions } from '../types';
3
+ declare const _default: (editor: Editor, opts: RequiredTooltipOptions) => void;
4
+ export default _default;
@@ -0,0 +1,15 @@
1
+ var tooltip_default = (editor, opts) => {
2
+ const { classTooltip, privateClasses } = opts;
3
+ const classTooltipBody = `${classTooltip}__body`;
4
+ const classTooltipEmpty = `${classTooltip}--empty`;
5
+ if (privateClasses) {
6
+ editor.SelectorManager.getAll().add([
7
+ { private: 1, name: classTooltip },
8
+ { private: 1, name: classTooltipBody },
9
+ { private: 1, name: classTooltipEmpty }
10
+ ]);
11
+ }
12
+ };
13
+ export {
14
+ tooltip_default as default
15
+ };
@@ -0,0 +1,3 @@
1
+ import type { Editor } from 'grapesjs';
2
+ declare const _default: (editor: Editor) => void;
3
+ export default _default;