@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
@@ -0,0 +1,63 @@
1
+ import { typeCustomCode, typedId } from "../consts.js";
2
+ import { AddBlocks } from "./index.js";
3
+ var extras_default = (editor, opts) => {
4
+ const addBlock = AddBlocks(editor, opts);
5
+ const extrasCategory = "Extra";
6
+ const sharedExtraBlockProps = {
7
+ select: true,
8
+ category: extrasCategory
9
+ };
10
+ const { id: tooltipId, labelTooltip, blockTooltip } = opts.tooltip;
11
+ if (blockTooltip) {
12
+ addBlock(tooltipId, {
13
+ label: labelTooltip,
14
+ content: { type: tooltipId },
15
+ media: `<svg viewBox="0 0 24 24">
16
+ <path d="M4 2h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2h-4l-4 4-4-4H4c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2m0 2v12h4.83L12 19.17 15.17 16H20V4H4z"></path>
17
+ </svg>`,
18
+ ...sharedExtraBlockProps,
19
+ ...blockTooltip
20
+ });
21
+ }
22
+ addBlock(typedId, {
23
+ label: "Typed",
24
+ media: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300"><path d="M212.3 44l2.3 49.6h-6A60 60 0 00204 75c-3.2-6-7.5-10.5-12.9-13.3a44.9 44.9 0 00-21.1-4.3h-29.8V219c0 13 1.4 21 4.2 24.3 4 4.4 10 6.6 18.2 6.6h7.4v5.7H80.2V250h7.5c9 0 15.3-2.7 19-8.2 2.4-3.3 3.5-10.9 3.5-22.7V57.3H84.8a71 71 0 00-21.1 2.2 29 29 0 00-13.9 11.3 46.1 46.1 0 00-6.9 22.8H37L39.5 44h172.8zM245 22h18v256h-18z"/></svg>',
25
+ content: { type: typedId },
26
+ ...sharedExtraBlockProps,
27
+ ...opts.typed.block
28
+ });
29
+ const {
30
+ block: countdownBlock,
31
+ id: countdownId,
32
+ label: countdownLabel
33
+ } = opts.countdown;
34
+ if (countdownBlock) {
35
+ addBlock(countdownId, {
36
+ media: `<svg viewBox="0 0 24 24">
37
+ <path fill="currentColor" d="M12 20C16.4 20 20 16.4 20 12S16.4 4 12 4 4 7.6 4 12 7.6 20 12 20M12 2C17.5 2 22 6.5 22 12S17.5 22 12 22C6.5 22 2 17.5 2 12C2 6.5 6.5 2 12 2M17 11.5V13H11V7H12.5V11.5H17Z" />
38
+ </svg>`,
39
+ label: countdownLabel,
40
+ content: { type: countdownId },
41
+ ...sharedExtraBlockProps,
42
+ ...countdownBlock
43
+ });
44
+ }
45
+ const { blockCustomCode } = opts.customCode;
46
+ if (blockCustomCode) {
47
+ addBlock(typeCustomCode, {
48
+ label: "Custom Code",
49
+ media: `
50
+ <svg viewBox="0 0 24 24">
51
+ <path d="M14.6 16.6l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4m-5.2 0L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4z"></path>
52
+ </svg>
53
+ `,
54
+ activate: true,
55
+ ...sharedExtraBlockProps,
56
+ content: { type: typeCustomCode },
57
+ ...blockCustomCode
58
+ });
59
+ }
60
+ };
61
+ export {
62
+ extras_default as default
63
+ };
@@ -0,0 +1,4 @@
1
+ import type { Editor } from 'grapesjs';
2
+ import type { RequiredGrapesBlocksOptions } from '../types.js';
3
+ declare const _default: (editor: Editor, opts: RequiredGrapesBlocksOptions) => void;
4
+ export default _default;
@@ -7,20 +7,14 @@ import {
7
7
  typeRadio,
8
8
  typeSelect,
9
9
  typeTextarea
10
- } from "./components.js";
11
- function blocks_default(editor, opt) {
12
- const opts = opt;
13
- const bm = editor.BlockManager;
14
- const addBlock = (id, def) => {
15
- opts.blocks?.indexOf(id) >= 0 && bm.add(id, {
16
- ...def,
17
- category: opts.category,
18
- select: true,
19
- ...opt.block(id)
20
- });
21
- };
10
+ } from "../consts.js";
11
+ import { AddBlocks } from "./index.js";
12
+ var forms_default = (editor, opts) => {
13
+ const addBlock = AddBlocks(editor, opts);
14
+ const formsCategory = "Forms";
22
15
  addBlock(typeForm, {
23
16
  label: "Form",
17
+ category: formsCategory,
24
18
  media: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M22 5.5c0-.3-.5-.5-1.3-.5H3.4c-.8 0-1.3.2-1.3.5v3c0 .3.5.5 1.3.5h17.4c.8 0 1.3-.2 1.3-.5v-3zM21 8H3V6h18v2zM22 10.5c0-.3-.5-.5-1.3-.5H3.4c-.8 0-1.3.2-1.3.5v3c0 .3.5.5 1.3.5h17.4c.8 0 1.3-.2 1.3-.5v-3zM21 13H3v-2h18v2z"/><rect width="10" height="3" x="2" y="15" rx=".5"/></svg>',
25
19
  content: {
26
20
  type: typeForm,
@@ -54,40 +48,47 @@ function blocks_default(editor, opt) {
54
48
  });
55
49
  addBlock(typeInput, {
56
50
  label: "Input",
51
+ category: formsCategory,
57
52
  media: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M22 9c0-.6-.5-1-1.3-1H3.4C2.5 8 2 8.4 2 9v6c0 .6.5 1 1.3 1h17.4c.8 0 1.3-.4 1.3-1V9zm-1 6H3V9h18v6z"/><path d="M4 10h1v4H4z"/></svg>',
58
53
  content: { type: typeInput }
59
54
  });
60
55
  addBlock(typeTextarea, {
61
56
  label: "Textarea",
57
+ category: formsCategory,
62
58
  media: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M22 7.5c0-.9-.5-1.5-1.3-1.5H3.4C2.5 6 2 6.6 2 7.5v9c0 .9.5 1.5 1.3 1.5h17.4c.8 0 1.3-.6 1.3-1.5v-9zM21 17H3V7h18v10z"/><path d="M4 8h1v4H4zM19 7h1v10h-1zM20 8h1v1h-1zM20 15h1v1h-1z"/></svg>',
63
59
  content: { type: typeTextarea }
64
60
  });
65
61
  addBlock(typeSelect, {
66
62
  label: "Select",
63
+ category: formsCategory,
67
64
  media: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M22 9c0-.6-.5-1-1.3-1H3.4C2.5 8 2 8.4 2 9v6c0 .6.5 1 1.3 1h17.4c.8 0 1.3-.4 1.3-1V9zm-1 6H3V9h18v6z"/><path d="M18.5 13l1.5-2h-3zM4 11.5h11v1H4z"/></svg>',
68
65
  content: { type: typeSelect }
69
66
  });
70
67
  addBlock(typeButton, {
71
68
  label: "Button",
69
+ category: formsCategory,
72
70
  media: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M22 9c0-.6-.5-1-1.3-1H3.4C2.5 8 2 8.4 2 9v6c0 .6.5 1 1.3 1h17.4c.8 0 1.3-.4 1.3-1V9zm-1 6H3V9h18v6z"/><path d="M4 11.5h16v1H4z"/></svg>',
73
71
  content: { type: typeButton }
74
72
  });
75
73
  addBlock(typeLabel, {
76
74
  label: "Label",
75
+ category: formsCategory,
77
76
  media: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M22 11.9c0-.6-.5-.9-1.3-.9H3.4c-.8 0-1.3.3-1.3.9V17c0 .5.5.9 1.3.9h17.4c.8 0 1.3-.4 1.3-.9V12zM21 17H3v-5h18v5z"/><rect width="14" height="5" x="2" y="5" rx=".5"/><path d="M4 13h1v3H4z"/></svg>',
78
77
  content: { type: typeLabel }
79
78
  });
80
79
  addBlock(typeCheckbox, {
81
80
  label: "Checkbox",
81
+ category: formsCategory,
82
82
  media: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M10 17l-5-5 1.41-1.42L10 14.17l7.59-7.59L19 8m0-5H5c-1.11 0-2 .89-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5a2 2 0 0 0-2-2z"></path></svg>',
83
83
  content: { type: typeCheckbox }
84
84
  });
85
85
  addBlock(typeRadio, {
86
86
  label: "Radio",
87
+ category: formsCategory,
87
88
  media: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8m0-18C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 5c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5z"></path></svg>',
88
89
  content: { type: typeRadio }
89
90
  });
90
- }
91
+ };
91
92
  export {
92
- blocks_default as default
93
+ forms_default as default
93
94
  };
@@ -0,0 +1,5 @@
1
+ import type { BlockProperties, Editor } from 'grapesjs';
2
+ import type { RequiredGrapesBlocksOptions } from '../types.js';
3
+ export declare const AddBlocks: (editor: Editor, opts: RequiredGrapesBlocksOptions) => (id: string, def: BlockProperties) => void;
4
+ export declare function loadBlocks(editor: Editor, opts: RequiredGrapesBlocksOptions): void;
5
+ export default loadBlocks;
@@ -0,0 +1,23 @@
1
+ import basics from "./basics.js";
2
+ import extras from "./extras.js";
3
+ import forms from "./forms.js";
4
+ import tabs from "./tabs.js";
5
+ const AddBlocks = (editor, opts) => (id, def) => {
6
+ opts.blocks.indexOf(id) >= 0 && editor.Blocks.add(id, {
7
+ select: true,
8
+ ...def,
9
+ ...opts.block(id)
10
+ });
11
+ };
12
+ function loadBlocks(editor, opts) {
13
+ basics(editor, opts);
14
+ extras(editor, opts);
15
+ forms(editor, opts);
16
+ tabs(editor, opts);
17
+ }
18
+ var blocks_default = loadBlocks;
19
+ export {
20
+ AddBlocks,
21
+ blocks_default as default,
22
+ loadBlocks
23
+ };
@@ -0,0 +1,4 @@
1
+ import type { Editor } from 'grapesjs';
2
+ import type { RequiredGrapesBlocksOptions } from '../types.js';
3
+ declare const _default: (editor: Editor, opts: RequiredGrapesBlocksOptions) => void;
4
+ export default _default;
@@ -1,7 +1,9 @@
1
- function loadBlocks(editor, { tabsBlock, typeTabs }) {
2
- const { Blocks } = editor;
1
+ import { AddBlocks } from "./index.js";
2
+ var tabs_default = (editor, opts) => {
3
+ const addBlock = AddBlocks(editor, opts);
4
+ const { tabsBlock, typeTabs } = opts.tabOptions;
3
5
  if (tabsBlock) {
4
- const blockConfig = {
6
+ addBlock(typeTabs, {
5
7
  media: `
6
8
  <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
7
9
  <path d="M22 9.3c0-.8-.5-1.3-1.3-1.3H3.4C2.5 8 2 8.5 2 9.3v7.4c0 .8.5 1.3 1.3 1.3h17.4c.8 0 1.3-.5 1.3-1.3V9.3zM21 17H3V9h18v8z" fill-rule="nonzero"/><rect x="3" y="5" width="4" height="2" rx=".5"/><rect x="8" y="5" width="4" height="2" rx=".5"/><rect x="13" y="5" width="4" height="2" rx=".5"/>
@@ -9,11 +11,10 @@ function loadBlocks(editor, { tabsBlock, typeTabs }) {
9
11
  `,
10
12
  label: "Tabs",
11
13
  content: { type: typeTabs },
12
- ...tabsBlock
13
- };
14
- Blocks.add(typeTabs, blockConfig);
14
+ category: "Extra"
15
+ });
15
16
  }
16
- }
17
+ };
17
18
  export {
18
- loadBlocks as default
19
+ tabs_default as default
19
20
  };
@@ -0,0 +1,4 @@
1
+ import type { Editor } from 'grapesjs';
2
+ import type { RequiredGrapesBlocksOptions } from '../types.js';
3
+ declare const _default: (editor: Editor, opts: RequiredGrapesBlocksOptions) => void;
4
+ export default _default;
@@ -0,0 +1,21 @@
1
+ import { toast } from "@studiocms/ui/components/Toast/toast.js";
2
+ import { cmdClear } from "../consts.js";
3
+ import { AddCmd } from "./index.js";
4
+ var clear_default = (editor, opts) => {
5
+ const addCmd = AddCmd(editor);
6
+ const txtConfirm = opts.textCleanCanvas;
7
+ addCmd(cmdClear, (e) => {
8
+ if (confirm(txtConfirm)) {
9
+ e.runCommand("core:canvas-clear");
10
+ toast({
11
+ title: "Canvas Cleared",
12
+ type: "success",
13
+ description: "The canvas has been cleared successfully.",
14
+ duration: 5e3
15
+ });
16
+ }
17
+ });
18
+ };
19
+ export {
20
+ clear_default as default
21
+ };
@@ -0,0 +1,4 @@
1
+ import type { Editor } from 'grapesjs';
2
+ import type { RequiredCustomCodeOptions } from '../types';
3
+ declare const _default: (editor: Editor, opts: RequiredCustomCodeOptions) => void;
4
+ export default _default;
@@ -1,6 +1,8 @@
1
- import { commandNameCustomCode, keyCustomCode } from "./utils.js";
2
- var commands_default = (editor, opts = {}) => {
3
- const { modalTitle, codeViewOptions, commandCustomCode } = opts;
1
+ import { commandNameCustomCode, keyCustomCode } from "../consts";
2
+ import { AddCmd } from "./index.js";
3
+ var customCodeCommands_default = (editor, opts) => {
4
+ const addCmd = AddCmd(editor);
5
+ const { modalTitle, codeViewOptions, commandCustomCode, buttonLabel } = opts;
4
6
  const appendToContent = (target, content) => {
5
7
  if (content instanceof HTMLElement) {
6
8
  target.appendChild(content);
@@ -8,12 +10,12 @@ var commands_default = (editor, opts = {}) => {
8
10
  target.insertAdjacentHTML("beforeend", content);
9
11
  }
10
12
  };
11
- editor.Commands.add(commandNameCustomCode, {
13
+ addCmd(commandNameCustomCode, {
12
14
  keyCustomCode,
13
15
  target: null,
14
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
16
+ // biome-ignore lint/suspicious/noExplicitAny: This is the type that was already used in the original code
15
17
  codeViewer: null,
16
- run(editor2, s, opts2 = {}) {
18
+ run(editor2, _s, opts2 = {}) {
17
19
  const target = opts2.target || editor2.getSelected();
18
20
  this.target = target;
19
21
  if (target?.get("editable")) {
@@ -27,7 +29,7 @@ var commands_default = (editor, opts = {}) => {
27
29
  * Method which tells how to show the custom code
28
30
  * @param {Component} target
29
31
  */
30
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
32
+ // biome-ignore lint/suspicious/noExplicitAny: This is the type that was already used in the original code
31
33
  showCustomCode(target, options) {
32
34
  const title = options.title || modalTitle;
33
35
  const code = target.get(keyCustomCode) || "";
@@ -72,7 +74,7 @@ var commands_default = (editor, opts = {}) => {
72
74
  const btn = document.createElement("button");
73
75
  btn.setAttribute("type", "button");
74
76
  const pfx = editor.getConfig("stylePrefix");
75
- btn.innerHTML = opts.buttonLabel;
77
+ btn.innerHTML = buttonLabel;
76
78
  btn.className = `${pfx}btn-prim ${pfx}btn-import__custom-code`;
77
79
  btn.onclick = () => this.handleSave();
78
80
  return btn;
@@ -105,5 +107,5 @@ var commands_default = (editor, opts = {}) => {
105
107
  });
106
108
  };
107
109
  export {
108
- commands_default as default
110
+ customCodeCommands_default as default
109
111
  };
@@ -0,0 +1,23 @@
1
+ import { cmdDeviceDesktop, cmdDeviceMobile, cmdDeviceTablet } from "../consts";
2
+ import { AddCmd } from "./index.js";
3
+ var deviceCommands_default = (editor) => {
4
+ const addCmd = AddCmd(editor);
5
+ addCmd(cmdDeviceDesktop, {
6
+ run: (ed) => ed.setDevice("Desktop"),
7
+ stop: () => {
8
+ }
9
+ });
10
+ addCmd(cmdDeviceTablet, {
11
+ run: (ed) => ed.setDevice("Tablet"),
12
+ stop: () => {
13
+ }
14
+ });
15
+ addCmd(cmdDeviceMobile, {
16
+ run: (ed) => ed.setDevice("Mobile portrait"),
17
+ stop: () => {
18
+ }
19
+ });
20
+ };
21
+ export {
22
+ deviceCommands_default as default
23
+ };
@@ -0,0 +1,5 @@
1
+ import type { CommandFunction, CommandObject, Editor, ObjectAny } from 'grapesjs';
2
+ import type { RequiredGrapesBlocksOptions } from '../types.js';
3
+ export declare const AddCmd: (editor: Editor) => <T extends ObjectAny>(id: string, command: CommandFunction | CommandObject<any, T>) => void;
4
+ export declare function loadCommands(editor: Editor, opts: RequiredGrapesBlocksOptions): void;
5
+ export default loadCommands;
@@ -0,0 +1,40 @@
1
+ import { toast } from "@studiocms/ui/components/Toast/toast.js";
2
+ import clear from "./clear.js";
3
+ import customCodeCommands from "./customCodeCommands.js";
4
+ import deviceCommands from "./deviceCommands.js";
5
+ import openImport from "./openImport.js";
6
+ const AddCmd = (editor) => (id, command) => {
7
+ editor.Commands.add(id, command);
8
+ };
9
+ function loadCommands(editor, opts) {
10
+ clear(editor, opts);
11
+ openImport(editor, opts);
12
+ deviceCommands(editor);
13
+ customCodeCommands(editor, opts.customCode);
14
+ AddCmd(editor)("save-page", {
15
+ run: async (editor2, sender) => {
16
+ sender?.set("active", 0);
17
+ try {
18
+ await editor2.store();
19
+ toast({
20
+ title: "WYSIWYG: Manually Saved Page",
21
+ description: "Your editor changes have been saved. Don't forget to save your changes in StudioCMS!",
22
+ type: "info",
23
+ duration: 3e3
24
+ });
25
+ } catch (e) {
26
+ toast({
27
+ title: "WYSIWYG: Save failed",
28
+ description: String(e),
29
+ type: "danger"
30
+ });
31
+ }
32
+ }
33
+ });
34
+ }
35
+ var commands_default = loadCommands;
36
+ export {
37
+ AddCmd,
38
+ commands_default as default,
39
+ loadCommands
40
+ };
@@ -0,0 +1,4 @@
1
+ import type { Editor } from 'grapesjs';
2
+ import type { RequiredGrapesBlocksOptions } from '../types.js';
3
+ declare const _default: (editor: Editor, config: RequiredGrapesBlocksOptions) => void;
4
+ export default _default;
@@ -0,0 +1,71 @@
1
+ import { cmdImport } from "../consts.js";
2
+ import { AddCmd } from "./index.js";
3
+ var openImport_default = (editor, config) => {
4
+ const addCmd = AddCmd(editor);
5
+ const pfx = editor.getConfig("stylePrefix");
6
+ const importLabel = config.modalImportLabel;
7
+ const importCnt = config.modalImportContent;
8
+ addCmd(cmdImport, {
9
+ // biome-ignore lint/suspicious/noExplicitAny: This is the type that was already used in the original code
10
+ codeViewer: null,
11
+ container: null,
12
+ run(editor2) {
13
+ const codeContent = typeof importCnt === "function" ? importCnt(editor2) : importCnt;
14
+ const codeViewer = this.getCodeViewer();
15
+ editor2.Modal.open({
16
+ title: config.modalImportTitle,
17
+ content: this.getContainer()
18
+ }).onceClose(() => editor2.stopCommand(cmdImport));
19
+ codeViewer.setContent(codeContent ?? "");
20
+ codeViewer.refresh();
21
+ setTimeout(() => codeViewer.focus(), 0);
22
+ },
23
+ stop() {
24
+ editor.Modal.close();
25
+ },
26
+ getContainer() {
27
+ if (!this.container) {
28
+ const codeViewer = this.getCodeViewer();
29
+ const container = document.createElement("div");
30
+ container.className = `${pfx}import-container`;
31
+ if (importLabel) {
32
+ const labelEl = document.createElement("div");
33
+ labelEl.className = `${pfx}import-label`;
34
+ labelEl.innerHTML = importLabel;
35
+ container.appendChild(labelEl);
36
+ }
37
+ container.appendChild(codeViewer.getElement());
38
+ const btnImp = document.createElement("button");
39
+ btnImp.type = "button";
40
+ btnImp.innerHTML = config.modalImportButton;
41
+ btnImp.className = `${pfx}btn-prim ${pfx}btn-import`;
42
+ btnImp.onclick = () => {
43
+ editor.Css.clear();
44
+ editor.setComponents(codeViewer.getContent().trim());
45
+ editor.Modal.close();
46
+ };
47
+ container.appendChild(btnImp);
48
+ this.container = container;
49
+ }
50
+ return this.container;
51
+ },
52
+ /**
53
+ * Return the code viewer instance
54
+ * @returns {CodeViewer}
55
+ */
56
+ getCodeViewer() {
57
+ if (!this.codeViewer) {
58
+ this.codeViewer = editor.CodeManager.createViewer({
59
+ codeName: "htmlmixed",
60
+ theme: "hopscotch",
61
+ readOnly: false,
62
+ ...config.importViewerOptions
63
+ });
64
+ }
65
+ return this.codeViewer;
66
+ }
67
+ });
68
+ };
69
+ export {
70
+ openImport_default as default
71
+ };
@@ -0,0 +1,12 @@
1
+ import type { Editor } from 'grapesjs';
2
+ import type { RequiredCountdownOptions } from '../types.js';
3
+ type TElement = HTMLElement & {
4
+ __gjsCountdownInterval: ReturnType<typeof setTimeout | typeof setInterval>;
5
+ };
6
+ declare global {
7
+ interface Window {
8
+ __gjsCountdownIntervals: TElement[];
9
+ }
10
+ }
11
+ declare const _default: (editor: Editor, opts: RequiredCountdownOptions) => void;
12
+ export default _default;
@@ -0,0 +1,147 @@
1
+ import { AddComponent } from "./index.js";
2
+ var countdown_default = (editor, opts) => {
3
+ const addComponent = AddComponent(editor);
4
+ const {
5
+ props: countdownProps,
6
+ style: countdownStyle,
7
+ id: countdownId,
8
+ classPrefix: countdownPfx,
9
+ startTime: countdownStartTime,
10
+ endText: countdownEndText,
11
+ dateInputType: countdownDateInputType,
12
+ labelDays: countdownLabelDays,
13
+ labelHours: countdownLabelHours,
14
+ labelMinutes: countdownLabelMinutes,
15
+ labelSeconds: countdownLabelSeconds,
16
+ styleAdditional: countdownStyleAdditional
17
+ } = opts;
18
+ addComponent(countdownId, {
19
+ model: {
20
+ defaults: {
21
+ startfrom: countdownStartTime,
22
+ classes: [countdownPfx],
23
+ endText: countdownEndText,
24
+ droppable: false,
25
+ // biome-ignore lint/suspicious/noExplicitAny: grapesjs types
26
+ script(props) {
27
+ const startfrom = props.startfrom;
28
+ const endTxt = props.endText;
29
+ const countDownDate = new Date(startfrom).getTime();
30
+ const countdownEl = this.querySelector("[data-js=countdown]");
31
+ const endTextEl = this.querySelector("[data-js=countdown-endtext]");
32
+ const dayEl = this.querySelector("[data-js=countdown-day]");
33
+ const hourEl = this.querySelector("[data-js=countdown-hour]");
34
+ const minuteEl = this.querySelector("[data-js=countdown-minute]");
35
+ const secondEl = this.querySelector("[data-js=countdown-second]");
36
+ const oldInterval = this.__gjsCountdownInterval;
37
+ if (oldInterval) clearInterval(oldInterval);
38
+ const connected = window.__gjsCountdownIntervals || [];
39
+ const toClean = [];
40
+ connected.forEach((item) => {
41
+ if (!item.isConnected) {
42
+ clearInterval(item.__gjsCountdownInterval);
43
+ toClean.push(item);
44
+ }
45
+ });
46
+ connected.indexOf(this) < 0 && connected.push(this);
47
+ window.__gjsCountdownIntervals = connected.filter((item) => toClean.indexOf(item) < 0);
48
+ const setTimer = (days, hours, minutes, seconds) => {
49
+ dayEl.innerHTML = `${days < 10 ? `0${days}` : days}`;
50
+ hourEl.innerHTML = `${hours < 10 ? `0${hours}` : hours}`;
51
+ minuteEl.innerHTML = `${minutes < 10 ? `0${minutes}` : minutes}`;
52
+ secondEl.innerHTML = `${seconds < 10 ? `0${seconds}` : seconds}`;
53
+ };
54
+ const MS_PER_DAY = 864e5;
55
+ const MS_PER_HOUR = 36e5;
56
+ const MS_PER_MINUTE = 6e4;
57
+ const MS_PER_SECOND = 1e3;
58
+ const moveTimer = () => {
59
+ const now = (/* @__PURE__ */ new Date()).getTime();
60
+ const distance = countDownDate - now;
61
+ const days = Math.floor(distance / MS_PER_DAY);
62
+ const hours = Math.floor(distance % MS_PER_DAY / MS_PER_HOUR);
63
+ const minutes = Math.floor(distance % MS_PER_HOUR / MS_PER_MINUTE);
64
+ const seconds = Math.floor(distance % MS_PER_MINUTE / MS_PER_SECOND);
65
+ setTimer(days, hours, minutes, seconds);
66
+ if (distance < 0) {
67
+ clearInterval(this.__gjsCountdownInterval);
68
+ endTextEl.innerHTML = endTxt;
69
+ countdownEl.style.display = "none";
70
+ endTextEl.style.display = "";
71
+ }
72
+ };
73
+ if (countDownDate) {
74
+ this.__gjsCountdownInterval = setInterval(moveTimer, 1e3);
75
+ endTextEl.style.display = "none";
76
+ countdownEl.style.display = "";
77
+ moveTimer();
78
+ } else {
79
+ setTimer(0, 0, 0, 0);
80
+ }
81
+ },
82
+ "script-props": ["startfrom", "endText"],
83
+ traits: [
84
+ {
85
+ label: "Start",
86
+ name: "startfrom",
87
+ changeProp: true,
88
+ type: countdownDateInputType
89
+ },
90
+ {
91
+ label: "End text",
92
+ name: "endText",
93
+ changeProp: true
94
+ }
95
+ ],
96
+ components: `
97
+ <span data-js="countdown" class="${countdownPfx}-cont">
98
+ <div class="${countdownPfx}-block">
99
+ <div data-js="countdown-day" class="${countdownPfx}-digit"></div>
100
+ <div class="${countdownPfx}-label">${countdownLabelDays}</div>
101
+ </div>
102
+ <div class="${countdownPfx}-block">
103
+ <div data-js="countdown-hour" class="${countdownPfx}-digit"></div>
104
+ <div class="${countdownPfx}-label">${countdownLabelHours}</div>
105
+ </div>
106
+ <div class="${countdownPfx}-block">
107
+ <div data-js="countdown-minute" class="${countdownPfx}-digit"></div>
108
+ <div class="${countdownPfx}-label">${countdownLabelMinutes}</div>
109
+ </div>
110
+ <div class="${countdownPfx}-block">
111
+ <div data-js="countdown-second" class="${countdownPfx}-digit"></div>
112
+ <div class="${countdownPfx}-label">${countdownLabelSeconds}</div>
113
+ </div>
114
+ </span>
115
+ <span data-js="countdown-endtext" class="${countdownPfx}-endtext"></span>
116
+ `,
117
+ styles: (countdownStyle || `
118
+ .${countdownPfx} {
119
+ text-align: center;
120
+ }
121
+
122
+ .${countdownPfx}-block {
123
+ display: inline-block;
124
+ margin: 0 10px;
125
+ padding: 10px;
126
+ }
127
+
128
+ .${countdownPfx}-digit {
129
+ font-size: 5rem;
130
+ }
131
+
132
+ .${countdownPfx}-endtext {
133
+ font-size: 5rem;
134
+ }
135
+
136
+ .${countdownPfx}-cont {
137
+ display: inline-block;
138
+ }
139
+ `) + countdownStyleAdditional,
140
+ ...countdownProps
141
+ }
142
+ }
143
+ });
144
+ };
145
+ export {
146
+ countdown_default as default
147
+ };
@@ -0,0 +1,4 @@
1
+ import type { Editor } from 'grapesjs';
2
+ import type { RequiredCustomCodeOptions } from '../types.js';
3
+ declare const _default: (editor: Editor, opts: RequiredCustomCodeOptions) => void;
4
+ export default _default;