@studiocms/wysiwyg 0.1.0-beta.24

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 (104) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +20 -0
  3. package/dist/common/componentRegistry.d.ts +31 -0
  4. package/dist/common/componentRegistry.js +59 -0
  5. package/dist/common/editor-settings.d.ts +23 -0
  6. package/dist/common/editor-settings.js +357 -0
  7. package/dist/common/editor-utils.d.ts +165 -0
  8. package/dist/common/editor-utils.js +217 -0
  9. package/dist/common/grapesBlocks/blocks/basics.d.ts +4 -0
  10. package/dist/common/grapesBlocks/blocks/basics.js +279 -0
  11. package/dist/common/grapesBlocks/blocks/extras.d.ts +4 -0
  12. package/dist/common/grapesBlocks/blocks/extras.js +63 -0
  13. package/dist/common/grapesBlocks/blocks/forms.d.ts +4 -0
  14. package/dist/common/grapesBlocks/blocks/forms.js +94 -0
  15. package/dist/common/grapesBlocks/blocks/index.d.ts +5 -0
  16. package/dist/common/grapesBlocks/blocks/index.js +23 -0
  17. package/dist/common/grapesBlocks/blocks/tabs.d.ts +4 -0
  18. package/dist/common/grapesBlocks/blocks/tabs.js +20 -0
  19. package/dist/common/grapesBlocks/commands/clear.d.ts +4 -0
  20. package/dist/common/grapesBlocks/commands/clear.js +21 -0
  21. package/dist/common/grapesBlocks/commands/customCodeCommands.d.ts +4 -0
  22. package/dist/common/grapesBlocks/commands/customCodeCommands.js +111 -0
  23. package/dist/common/grapesBlocks/commands/deviceCommands.d.ts +3 -0
  24. package/dist/common/grapesBlocks/commands/deviceCommands.js +23 -0
  25. package/dist/common/grapesBlocks/commands/index.d.ts +5 -0
  26. package/dist/common/grapesBlocks/commands/index.js +40 -0
  27. package/dist/common/grapesBlocks/commands/openImport.d.ts +4 -0
  28. package/dist/common/grapesBlocks/commands/openImport.js +71 -0
  29. package/dist/common/grapesBlocks/components/countdown.d.ts +12 -0
  30. package/dist/common/grapesBlocks/components/countdown.js +148 -0
  31. package/dist/common/grapesBlocks/components/customCode.d.ts +4 -0
  32. package/dist/common/grapesBlocks/components/customCode.js +89 -0
  33. package/dist/common/grapesBlocks/components/forms.d.ts +3 -0
  34. package/dist/common/grapesBlocks/components/forms.js +278 -0
  35. package/dist/common/grapesBlocks/components/index.d.ts +5 -0
  36. package/dist/common/grapesBlocks/components/index.js +23 -0
  37. package/dist/common/grapesBlocks/components/tabLoader.d.ts +4 -0
  38. package/dist/common/grapesBlocks/components/tabLoader.js +29 -0
  39. package/dist/common/grapesBlocks/components/tabs/Tab.d.ts +10 -0
  40. package/dist/common/grapesBlocks/components/tabs/Tab.js +100 -0
  41. package/dist/common/grapesBlocks/components/tabs/TabContainer.d.ts +5 -0
  42. package/dist/common/grapesBlocks/components/tabs/TabContainer.js +23 -0
  43. package/dist/common/grapesBlocks/components/tabs/TabContent.d.ts +5 -0
  44. package/dist/common/grapesBlocks/components/tabs/TabContent.js +23 -0
  45. package/dist/common/grapesBlocks/components/tabs/TabContents.d.ts +4 -0
  46. package/dist/common/grapesBlocks/components/tabs/TabContents.js +19 -0
  47. package/dist/common/grapesBlocks/components/tabs/Tabs.d.ts +4 -0
  48. package/dist/common/grapesBlocks/components/tabs/Tabs.js +169 -0
  49. package/dist/common/grapesBlocks/components/tooltip.d.ts +4 -0
  50. package/dist/common/grapesBlocks/components/tooltip.js +246 -0
  51. package/dist/common/grapesBlocks/components/typed.d.ts +9 -0
  52. package/dist/common/grapesBlocks/components/typed.js +109 -0
  53. package/dist/common/grapesBlocks/consts.d.ts +25 -0
  54. package/dist/common/grapesBlocks/consts.js +245 -0
  55. package/dist/common/grapesBlocks/i18n/index.d.ts +3 -0
  56. package/dist/common/grapesBlocks/i18n/index.js +19 -0
  57. package/dist/common/grapesBlocks/index.d.ts +4 -0
  58. package/dist/common/grapesBlocks/index.js +27 -0
  59. package/dist/common/grapesBlocks/panels/index.d.ts +4 -0
  60. package/dist/common/grapesBlocks/panels/index.js +171 -0
  61. package/dist/common/grapesBlocks/rte/colorPicker.d.ts +104 -0
  62. package/dist/common/grapesBlocks/rte/colorPicker.js +199 -0
  63. package/dist/common/grapesBlocks/rte/index.d.ts +48 -0
  64. package/dist/common/grapesBlocks/rte/index.js +375 -0
  65. package/dist/common/grapesBlocks/selectors/index.d.ts +4 -0
  66. package/dist/common/grapesBlocks/selectors/index.js +9 -0
  67. package/dist/common/grapesBlocks/selectors/tooltip.d.ts +4 -0
  68. package/dist/common/grapesBlocks/selectors/tooltip.js +15 -0
  69. package/dist/common/grapesBlocks/traits/formTraits.d.ts +3 -0
  70. package/dist/common/grapesBlocks/traits/formTraits.js +51 -0
  71. package/dist/common/grapesBlocks/traits/index.d.ts +4 -0
  72. package/dist/common/grapesBlocks/traits/index.js +15 -0
  73. package/dist/common/grapesBlocks/traits/typedTraits.d.ts +3 -0
  74. package/dist/common/grapesBlocks/traits/typedTraits.js +24 -0
  75. package/dist/common/grapesBlocks/tuiImageEditor/index.d.ts +86 -0
  76. package/dist/common/grapesBlocks/tuiImageEditor/index.js +203 -0
  77. package/dist/common/grapesBlocks/types.d.ts +446 -0
  78. package/dist/common/grapesBlocks/types.js +0 -0
  79. package/dist/components/Editor.astro +147 -0
  80. package/dist/components/Render.astro +24 -0
  81. package/dist/consts.d.ts +31 -0
  82. package/dist/consts.js +15 -0
  83. package/dist/index.d.ts +29 -0
  84. package/dist/index.js +65 -0
  85. package/dist/lib/db.d.ts +104 -0
  86. package/dist/lib/db.js +50 -0
  87. package/dist/lib/prerender.d.ts +10 -0
  88. package/dist/lib/prerender.js +22 -0
  89. package/dist/lib/shared.d.ts +14 -0
  90. package/dist/lib/shared.js +7 -0
  91. package/dist/lib/utils.d.ts +16 -0
  92. package/dist/lib/utils.js +10 -0
  93. package/dist/routes/grapes.css.d.ts +7 -0
  94. package/dist/routes/grapes.css.js +13 -0
  95. package/dist/routes/partial.astro +44 -0
  96. package/dist/routes/store.d.ts +32 -0
  97. package/dist/routes/store.js +100 -0
  98. package/dist/schema.d.ts +60 -0
  99. package/dist/schema.js +24 -0
  100. package/dist/styles/editor.css +150 -0
  101. package/dist/styles/grapes.css +71 -0
  102. package/dist/types.d.ts +66 -0
  103. package/dist/types.js +9 -0
  104. package/package.json +78 -0
@@ -0,0 +1,169 @@
1
+ import { resolveTemplate } from "../../consts.js";
2
+ var Tabs_default = (editor, config) => {
3
+ const { Components } = editor;
4
+ const script = function(props) {
5
+ const el = this;
6
+ const classTabActive = props.classactive;
7
+ const selectorTab = props.selectortab;
8
+ const { history } = window;
9
+ const _isEditor = window._isEditor;
10
+ const attrSelected = "ariaSelected";
11
+ const roleTab = "[role=tab]";
12
+ const roleTabContent = "[role=tabpanel]";
13
+ const { body, location } = document;
14
+ const matches = body.matches || // biome-ignore lint/suspicious/noExplicitAny: This is the type that was already used in the original code
15
+ body.webkitMatchesSelector || // biome-ignore lint/suspicious/noExplicitAny: This is the type that was already used in the original code
16
+ body.mozMatchesSelector || // biome-ignore lint/suspicious/noExplicitAny: This is the type that was already used in the original code
17
+ body.msMatchesSelector;
18
+ const each = (items, clb) => {
19
+ Array.from(items).forEach(clb);
20
+ };
21
+ const hideContents = () => {
22
+ each(el.querySelectorAll(roleTabContent), (i) => {
23
+ i.hidden = true;
24
+ });
25
+ };
26
+ const getTabId = (item) => item.getAttribute(selectorTab) || "";
27
+ const qS = (elem, qs) => elem.querySelector(qs);
28
+ const getAllTabs = () => el.querySelectorAll(roleTab);
29
+ const upTabIdx = (item, val) => {
30
+ if (!_isEditor) {
31
+ item.tabIndex = Number.parseInt(val);
32
+ }
33
+ };
34
+ const activeTab = (tabEl) => {
35
+ each(getAllTabs(), (item) => {
36
+ item.className = item.className.replace(classTabActive, "").trim();
37
+ item.setAttribute(attrSelected, "false");
38
+ upTabIdx(item, "-1");
39
+ });
40
+ hideContents();
41
+ tabEl.className += ` ${classTabActive}`;
42
+ tabEl.setAttribute(attrSelected, "true");
43
+ upTabIdx(tabEl, "0");
44
+ const tabContentId = getTabId(tabEl);
45
+ const tabContent = tabContentId && qS(el, `#${tabContentId}`);
46
+ if (tabContent) {
47
+ tabContent.hidden = false;
48
+ }
49
+ };
50
+ const getTabByHash = () => {
51
+ const hashId = (location.hash || "").replace("#", "");
52
+ const qrStr = (att) => `${roleTab}[${att}=${hashId}]`;
53
+ return hashId ? qS(el, qrStr(selectorTab)) : null;
54
+ };
55
+ const getSelectedTab = (target) => {
56
+ return Array.from(getAllTabs()).find((item) => item.contains(target));
57
+ };
58
+ let tabToActive = qS(el, `.${classTabActive}${roleTab}`);
59
+ tabToActive = tabToActive || getTabByHash() || qS(el, roleTab);
60
+ if (tabToActive) activeTab(tabToActive);
61
+ el.addEventListener("click", (ev) => {
62
+ let target = ev.target;
63
+ if (!target) return;
64
+ let found = matches.call(target, roleTab);
65
+ if (!found) {
66
+ const selectedTab = getSelectedTab(target);
67
+ if (selectedTab) {
68
+ target = selectedTab;
69
+ found = true;
70
+ }
71
+ }
72
+ if (found && !ev.__trg && target.className.indexOf(classTabActive) < 0) {
73
+ ev.preventDefault();
74
+ ev.__trg = 1;
75
+ activeTab(target);
76
+ const id = getTabId(target);
77
+ try {
78
+ history?.pushState(null, "", `#${id}`);
79
+ } catch (e) {
80
+ console.error("History API is not supported", e);
81
+ }
82
+ }
83
+ });
84
+ };
85
+ const styleText = config.style ? config.style(config) : "";
86
+ const defTabs = [1, 2, 3].map((i) => ({
87
+ type: config.typeTab,
88
+ components: resolveTemplate(config.templateTab, { index: i })
89
+ }));
90
+ Components.addType(config.typeTabs, {
91
+ model: {
92
+ defaults: {
93
+ name: "Tabs",
94
+ classactive: config.classTabActive,
95
+ selectortab: config.selectorTab,
96
+ "script-props": ["classactive", "selectortab"],
97
+ script,
98
+ traits: [
99
+ {
100
+ type: "button",
101
+ label: "Add Tab",
102
+ text: "Add Tab",
103
+ full: true,
104
+ command: (editor2) => {
105
+ const selected = editor2.getSelected();
106
+ selected?.addTab();
107
+ }
108
+ }
109
+ ],
110
+ components: [
111
+ { type: config.typeTabContainer, components: defTabs },
112
+ { type: config.typeTabContents }
113
+ ],
114
+ styles: styleText,
115
+ ...config.tabsProps
116
+ },
117
+ // biome-ignore lint/suspicious/noExplicitAny: This is the type that was already used in the original code
118
+ isTabsComponent(comp) {
119
+ return comp.findTabs !== void 0;
120
+ },
121
+ init() {
122
+ const component = this;
123
+ component.findTabs().forEach((tab, index) => {
124
+ this.__onTab(tab, index + 1, {});
125
+ });
126
+ const container = component.getTabContainerType();
127
+ let tabCount = component.findTabs().length;
128
+ this.listenTo(container?.components(), "add", (tab) => {
129
+ tabCount++;
130
+ tab.__initTab?.(tabCount);
131
+ });
132
+ },
133
+ // biome-ignore lint/suspicious/noExplicitAny: This is the type that was already used in the original code
134
+ __onTab(tab, index, _v, opts = {}) {
135
+ if (!opts.avoidStore && !opts.temporary) {
136
+ tab.__initTab(index);
137
+ }
138
+ },
139
+ getTabContainerType() {
140
+ return this.findType(config.typeTabContainer)[0];
141
+ },
142
+ getContentsType() {
143
+ return this.findType(config.typeTabContents)[0] || this;
144
+ },
145
+ findTabs() {
146
+ return this.findType(config.typeTab);
147
+ },
148
+ findContents() {
149
+ return this.findType(config.typeTabContent);
150
+ },
151
+ addTab(content) {
152
+ const component = this;
153
+ const container = component.getTabContainerType();
154
+ const currentTabs = component.findTabs();
155
+ const templateProps = {
156
+ index: currentTabs.length + 1
157
+ };
158
+ const finalContent = content ? typeof content === "function" ? content(templateProps) : content : resolveTemplate(config.templateTab, templateProps);
159
+ container?.append({
160
+ type: config.typeTab,
161
+ components: finalContent
162
+ });
163
+ }
164
+ }
165
+ });
166
+ };
167
+ export {
168
+ Tabs_default as default
169
+ };
@@ -0,0 +1,4 @@
1
+ import type { Editor } from 'grapesjs';
2
+ import type { RequiredTooltipOptions } from '../types';
3
+ export declare const tooltipComponent: (editor: Editor, opts: RequiredTooltipOptions) => void;
4
+ export default tooltipComponent;
@@ -0,0 +1,246 @@
1
+ const tooltipComponent = (editor, opts) => {
2
+ const {
3
+ id: tooltipId,
4
+ labelTooltip,
5
+ classTooltip,
6
+ attrTooltip,
7
+ style,
8
+ styleAdditional,
9
+ extendTraits,
10
+ showTooltipOnStyle,
11
+ propsTooltip,
12
+ stylableTooltip
13
+ } = opts;
14
+ const classTooltipBody = `${classTooltip}__body`;
15
+ const classTooltipEmpty = `${classTooltip}--empty`;
16
+ const attrTooltipVis = `${attrTooltip}-visible`;
17
+ const attrTooltipPos = `${attrTooltip}-pos`;
18
+ const attrTooltipLen = `${attrTooltip}-length`;
19
+ const traitIdStyleTooltip = "style-tooltip";
20
+ editor.Components.addType(tooltipId, {
21
+ isComponent: (el) => el.hasAttribute?.(attrTooltip),
22
+ model: {
23
+ defaults: {
24
+ name: labelTooltip,
25
+ classes: [classTooltip],
26
+ attributes: { [attrTooltip]: labelTooltip },
27
+ styles: (style || `
28
+ .${classTooltip} {
29
+ position: relative;
30
+ display: inline-block;
31
+ vertical-align: top;
32
+ }
33
+
34
+ .${classTooltipEmpty} {
35
+ width: 50px;
36
+ height: 50px;
37
+ }
38
+
39
+ .${classTooltipBody},
40
+ [${attrTooltip}]::after {
41
+ font-family: Helvetica, sans-serif;
42
+ background: rgba(55, 61, 73, 0.95);
43
+ border-radius: 3px;
44
+ bottom: 100%;
45
+ color: #fff;
46
+ content: attr(${attrTooltip});
47
+ display: block;
48
+ font-size: 12px;
49
+ left: 50%;
50
+ line-height: normal;
51
+ max-width: 32rem;
52
+ opacity: 0;
53
+ overflow: hidden;
54
+ padding: 8px 16px;
55
+ pointer-events: none;
56
+ position: absolute;
57
+ text-overflow: ellipsis;
58
+ transform: translate(-50%, 0);
59
+ transition: opacity 0.25s, transform 0.25s;
60
+ white-space: nowrap;
61
+ box-sizing: border-box;
62
+ z-index: 10;
63
+ }
64
+
65
+ [${attrTooltipVis}=true]::after,
66
+ [${attrTooltip}]:focus::after,
67
+ [${attrTooltip}]:hover::after {
68
+ opacity: 1;
69
+ transform: translate(-50%, -0.5rem);
70
+ }
71
+
72
+ [${attrTooltipPos}=right]::after {
73
+ bottom: 50%;
74
+ left: 100%;
75
+ transform: translate(0, 50%);
76
+ }
77
+
78
+ [${attrTooltipPos}=right]:focus::after,
79
+ [${attrTooltipPos}=right]:hover::after,
80
+ [${attrTooltipVis}=true][${attrTooltipPos}=right]::after {
81
+ transform: translate(0.5rem, 50%);
82
+ }
83
+
84
+ [${attrTooltipPos}=bottom]::after {
85
+ bottom: auto;
86
+ top: 100%;
87
+ transform: translate(-50%, 0);
88
+ }
89
+
90
+ [${attrTooltipPos}=bottom]:focus::after,
91
+ [${attrTooltipPos}=bottom]:hover::after,
92
+ [${attrTooltipVis}=true][${attrTooltipPos}=bottom]::after {
93
+ transform: translate(-50%, 0.5rem);
94
+ }
95
+
96
+ [${attrTooltipPos}=left]::after {
97
+ bottom: 50%;
98
+ left: auto;
99
+ right: 100%;
100
+ transform: translate(0, 50%);
101
+ }
102
+
103
+ [${attrTooltipPos}=left]:focus::after,
104
+ [${attrTooltipPos}=left]:hover::after,
105
+ [${attrTooltipVis}=true][${attrTooltipPos}=left]::after {
106
+ transform: translate(-0.5rem, 50%);
107
+ }
108
+
109
+ [${attrTooltipLen}=small]::after {
110
+ white-space: normal;
111
+ width: 80px;
112
+ }
113
+
114
+ [${attrTooltipLen}=medium]::after {
115
+ white-space: normal;
116
+ width: 150px;
117
+ }
118
+
119
+ [${attrTooltipLen}=large]::after {
120
+ white-space: normal;
121
+ width: 300px;
122
+ }
123
+
124
+ [${attrTooltipLen}=fit]::after {
125
+ white-space: normal;
126
+ width: 100%;
127
+ }
128
+
129
+ // IE 11 bugfix
130
+ button[${attrTooltip}] {
131
+ overflow: visible;
132
+ }
133
+ `) + styleAdditional,
134
+ // biome-ignore lint/style/noNonNullAssertion: This is the type that was already used in the original code
135
+ traits: extendTraits([
136
+ {
137
+ name: attrTooltip,
138
+ label: "Text"
139
+ },
140
+ {
141
+ name: attrTooltipPos,
142
+ label: "Position",
143
+ type: "select",
144
+ options: [
145
+ {
146
+ value: "top",
147
+ name: "Top",
148
+ id: ""
149
+ },
150
+ {
151
+ value: "right",
152
+ name: "Right",
153
+ id: ""
154
+ },
155
+ {
156
+ value: "bottom",
157
+ name: "Bottom",
158
+ id: ""
159
+ },
160
+ {
161
+ value: "left",
162
+ name: "Left",
163
+ id: ""
164
+ }
165
+ ]
166
+ },
167
+ {
168
+ name: attrTooltipLen,
169
+ label: "Length",
170
+ type: "select",
171
+ options: [
172
+ {
173
+ value: "",
174
+ name: "One line",
175
+ id: ""
176
+ },
177
+ {
178
+ value: "small",
179
+ name: "Small",
180
+ id: ""
181
+ },
182
+ {
183
+ value: "medium",
184
+ name: "Medium",
185
+ id: ""
186
+ },
187
+ {
188
+ value: "large",
189
+ name: "Large",
190
+ id: ""
191
+ },
192
+ {
193
+ value: "fit",
194
+ name: "Fit",
195
+ id: ""
196
+ }
197
+ ]
198
+ },
199
+ {
200
+ name: attrTooltipVis,
201
+ label: "Visible",
202
+ type: "checkbox",
203
+ valueTrue: "true"
204
+ },
205
+ {
206
+ name: traitIdStyleTooltip,
207
+ labelButton: "Style tooltip",
208
+ type: "button",
209
+ full: true,
210
+ command: (editor2) => {
211
+ const openSm = editor2.Panels.getButton("views", "open-sm");
212
+ openSm?.set("active", true);
213
+ const ruleTooltip = editor2.Css.getRules(`.${classTooltipBody}`)[0];
214
+ ruleTooltip.set("stylable", stylableTooltip);
215
+ editor2.StyleManager.select(ruleTooltip);
216
+ if (showTooltipOnStyle) {
217
+ const selected = editor2.getSelected();
218
+ if (selected?.is(tooltipId)) {
219
+ selected.addAttributes({ [attrTooltipVis]: "true" });
220
+ editor2.once("style:target", () => {
221
+ selected.addAttributes({ [attrTooltipVis]: "false" });
222
+ });
223
+ }
224
+ }
225
+ }
226
+ }
227
+ ]),
228
+ // biome-ignore lint/suspicious/noExplicitAny: This is the type that was already used in the original code
229
+ ...propsTooltip
230
+ },
231
+ init() {
232
+ this.listenTo(this.components(), "add remove", this.checkEmpty);
233
+ this.checkEmpty();
234
+ },
235
+ checkEmpty() {
236
+ const empty = !this.components().length;
237
+ this[empty ? "addClass" : "removeClass"](`${classTooltipEmpty}`);
238
+ }
239
+ }
240
+ });
241
+ };
242
+ var tooltip_default = tooltipComponent;
243
+ export {
244
+ tooltip_default as default,
245
+ tooltipComponent
246
+ };
@@ -0,0 +1,9 @@
1
+ import type { Editor } from 'grapesjs';
2
+ import type { RequiredTypedOptions } from '../types.js';
3
+ declare global {
4
+ interface Window {
5
+ Typed: any;
6
+ }
7
+ }
8
+ declare const _default: (editor: Editor, opts: RequiredTypedOptions) => void;
9
+ export default _default;
@@ -0,0 +1,109 @@
1
+ import { typedId, typedTraitStringId } from "../consts.js";
2
+ const getTraitType = (value) => {
3
+ if (typeof value === "number") return "number";
4
+ if (typeof value === "boolean") return "checkbox";
5
+ return "text";
6
+ };
7
+ var typed_default = (editor, opts) => {
8
+ const domc = editor.DomComponents;
9
+ const { keys } = Object;
10
+ const typedProps = {
11
+ strings: [],
12
+ "type-speed": 0,
13
+ "start-delay": 0,
14
+ "back-speed": 0,
15
+ "smart-backspace": true,
16
+ "back-delay": 700,
17
+ "fade-out": false,
18
+ "fade-out-class": "typed-fade-out",
19
+ "fade-out-delay": 500,
20
+ "show-cursor": true,
21
+ "cursor-char": "|",
22
+ "auto-insert-css": true,
23
+ "bind-input-focus-events": false,
24
+ "content-type": "html",
25
+ loop: false,
26
+ "loop-count": Number.POSITIVE_INFINITY,
27
+ shuffle: false,
28
+ attr: ""
29
+ };
30
+ const typedPropsKeys = keys(typedProps);
31
+ const traits = typedPropsKeys.filter((item) => ["strings"].indexOf(item) < 0).map((name) => ({
32
+ changeProp: true,
33
+ // biome-ignore lint/suspicious/noExplicitAny: This is the type that was already used in the original code
34
+ type: getTraitType(typedProps[name]),
35
+ min: 0,
36
+ name
37
+ }));
38
+ traits.unshift({
39
+ changeProp: true,
40
+ name: "strings",
41
+ type: typedTraitStringId
42
+ });
43
+ domc.addType(typedId, {
44
+ model: {
45
+ defaults: opts.props({
46
+ ...typedProps,
47
+ typedsrc: opts.script,
48
+ droppable: 0,
49
+ traits,
50
+ "script-props": [...typedPropsKeys, "typedsrc"],
51
+ script(props) {
52
+ const getStrings = (value) => {
53
+ if (Array.isArray(value)) {
54
+ return value;
55
+ }
56
+ if (value.indexOf("\n") >= 0) {
57
+ return value.split("\n");
58
+ }
59
+ return [];
60
+ };
61
+ const strings = getStrings(props.strings);
62
+ const int = (num) => Number.parseInt(num, 10) || 0;
63
+ const bool = (val) => !!val;
64
+ const init = () => {
65
+ const el = this;
66
+ el.innerHTML = "<span></span>";
67
+ const loopCount = Number.parseInt(`${props["loop-count"]}`, 10);
68
+ `${props["type-speed"]}`;
69
+ const config = {
70
+ typeSpeed: int(props["type-speed"]),
71
+ startDelay: int(props["start-delay"]),
72
+ backDelay: int(props["back-delay"]),
73
+ backSpeed: int(props["back-speed"]),
74
+ smartBackspace: bool(props["smart-backspace"]),
75
+ fadeOut: bool(props["fade-out"]),
76
+ fadeOutClass: props["fade-out-class"],
77
+ fadeOutDelay: int(props["fade-out-delay"]),
78
+ shuffle: bool(props.shuffle),
79
+ loop: bool(props.loop),
80
+ loopCount: Number.isNaN(loopCount) ? Number.POSITIVE_INFINITY : loopCount,
81
+ showCursor: bool(props["show-cursor"]),
82
+ cursorChar: props["cursor-char"],
83
+ autoInsertCss: bool(props["auto-insert-css"]),
84
+ bindInputFocusEvents: bool(props["bind-input-focus-events"]),
85
+ attr: props.attr,
86
+ contentType: props["content-type"]
87
+ };
88
+ if (strings?.length) {
89
+ config.strings = strings;
90
+ }
91
+ new window.Typed(el.children[0], config);
92
+ };
93
+ if (!window.Typed) {
94
+ const scr = document.createElement("script");
95
+ scr.src = props.typedsrc;
96
+ scr.onload = init;
97
+ document.head.appendChild(scr);
98
+ } else {
99
+ init();
100
+ }
101
+ }
102
+ // biome-ignore lint/suspicious/noExplicitAny: This is the type that was already used in the original code
103
+ })
104
+ }
105
+ });
106
+ };
107
+ export {
108
+ typed_default as default
109
+ };
@@ -0,0 +1,25 @@
1
+ import type { RequiredGrapesBlocksOptions, TabsOptions, TabTemplate, TabTemplateProps } from './types.js';
2
+ export declare const cmdImport = "gjs-open-import-webpage";
3
+ export declare const cmdDeviceDesktop = "set-device-desktop";
4
+ export declare const cmdDeviceTablet = "set-device-tablet";
5
+ export declare const cmdDeviceMobile = "set-device-mobile";
6
+ export declare const exportTemplate = "export-template";
7
+ export declare const cmdClear = "canvas-clear";
8
+ export declare const cmdSave = "store-data";
9
+ export declare const typedId = "typed";
10
+ export declare const typedTraitStringId = "typed-strings";
11
+ export declare const keyCustomCode = "custom-code-plugin__code";
12
+ export declare const typeCustomCode = "custom-code";
13
+ export declare const commandNameCustomCode = "custom-code:open-modal";
14
+ export declare const typeForm = "form";
15
+ export declare const typeInput = "input";
16
+ export declare const typeTextarea = "textarea";
17
+ export declare const typeSelect = "select";
18
+ export declare const typeCheckbox = "checkbox";
19
+ export declare const typeRadio = "radio";
20
+ export declare const typeButton = "button";
21
+ export declare const typeLabel = "label";
22
+ export declare const typeOption = "option";
23
+ export declare const resolveTemplate: (template: TabTemplate | undefined, props: TabTemplateProps) => string | undefined;
24
+ export declare const mergeStyles: (userStyle?: (config: TabsOptions) => string) => (config: TabsOptions) => string;
25
+ export declare const defaultGrapesBlocksOptions: RequiredGrapesBlocksOptions;