@studiocms/wysiwyg 0.1.0-experimental.1 → 0.1.0-experimental.3
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.
- package/dist/common/prepareRender.js +1 -1
- package/dist/wysiwyg/components/Editor.astro +24 -38
- package/dist/wysiwyg/editorPlugins/blocks/blocks.d.ts +3 -0
- package/dist/wysiwyg/editorPlugins/blocks/blocks.js +239 -0
- package/dist/wysiwyg/editorPlugins/blocks/index.d.ts +80 -0
- package/dist/wysiwyg/editorPlugins/blocks/index.js +26 -0
- package/dist/wysiwyg/editorPlugins/code/blocks.d.ts +4 -0
- package/dist/wysiwyg/editorPlugins/code/blocks.js +20 -0
- package/dist/wysiwyg/editorPlugins/code/commands.d.ts +4 -0
- package/dist/wysiwyg/editorPlugins/code/commands.js +109 -0
- package/dist/wysiwyg/editorPlugins/code/components.d.ts +4 -0
- package/dist/wysiwyg/editorPlugins/code/components.js +88 -0
- package/dist/wysiwyg/editorPlugins/code/index.d.ts +47 -0
- package/dist/wysiwyg/editorPlugins/code/index.js +28 -0
- package/dist/wysiwyg/editorPlugins/code/utils.d.ts +3 -0
- package/dist/wysiwyg/editorPlugins/code/utils.js +8 -0
- package/dist/wysiwyg/editorPlugins/countdown.d.ts +86 -0
- package/dist/wysiwyg/editorPlugins/countdown.js +163 -0
- package/dist/wysiwyg/editorPlugins/forms/blocks.d.ts +3 -0
- package/dist/wysiwyg/editorPlugins/forms/blocks.js +93 -0
- package/dist/wysiwyg/editorPlugins/forms/components.d.ts +11 -0
- package/dist/wysiwyg/editorPlugins/forms/components.js +284 -0
- package/dist/wysiwyg/editorPlugins/forms/index.d.ts +21 -0
- package/dist/wysiwyg/editorPlugins/forms/index.js +18 -0
- package/dist/wysiwyg/editorPlugins/forms/traits.d.ts +2 -0
- package/dist/wysiwyg/editorPlugins/forms/traits.js +47 -0
- package/dist/wysiwyg/editorPlugins/index.d.ts +9 -0
- package/dist/wysiwyg/editorPlugins/index.js +20 -0
- package/dist/wysiwyg/editorPlugins/rte/colorPicker.d.ts +95 -0
- package/dist/wysiwyg/editorPlugins/rte/colorPicker.js +185 -0
- package/dist/wysiwyg/editorPlugins/rte/index.d.ts +48 -0
- package/dist/wysiwyg/editorPlugins/rte/index.js +369 -0
- package/dist/wysiwyg/editorPlugins/rte/styles.css +63 -0
- package/dist/wysiwyg/editorPlugins/tabs/blocks.d.ts +3 -0
- package/dist/wysiwyg/editorPlugins/tabs/blocks.js +19 -0
- package/dist/wysiwyg/editorPlugins/tabs/components/Tab.d.ts +10 -0
- package/dist/wysiwyg/editorPlugins/tabs/components/Tab.js +100 -0
- package/dist/wysiwyg/editorPlugins/tabs/components/TabContainer.d.ts +5 -0
- package/dist/wysiwyg/editorPlugins/tabs/components/TabContainer.js +23 -0
- package/dist/wysiwyg/editorPlugins/tabs/components/TabContent.d.ts +5 -0
- package/dist/wysiwyg/editorPlugins/tabs/components/TabContent.js +23 -0
- package/dist/wysiwyg/editorPlugins/tabs/components/TabContents.d.ts +4 -0
- package/dist/wysiwyg/editorPlugins/tabs/components/TabContents.js +19 -0
- package/dist/wysiwyg/editorPlugins/tabs/components/Tabs.d.ts +4 -0
- package/dist/wysiwyg/editorPlugins/tabs/components/Tabs.js +169 -0
- package/dist/wysiwyg/editorPlugins/tabs/components/index.d.ts +4 -0
- package/dist/wysiwyg/editorPlugins/tabs/components/index.js +29 -0
- package/dist/wysiwyg/editorPlugins/tabs/index.d.ts +5 -0
- package/dist/wysiwyg/editorPlugins/tabs/index.js +15 -0
- package/dist/wysiwyg/editorPlugins/tabs/options.d.ts +5 -0
- package/dist/wysiwyg/editorPlugins/tabs/options.js +80 -0
- package/dist/wysiwyg/editorPlugins/tabs/types.d.ts +81 -0
- package/dist/wysiwyg/editorPlugins/tabs/types.js +0 -0
- package/dist/wysiwyg/editorPlugins/tooltip.d.ts +68 -0
- package/dist/wysiwyg/editorPlugins/tooltip.js +318 -0
- package/dist/wysiwyg/editorPlugins/tuiImageEditor.d.ts +86 -0
- package/dist/wysiwyg/editorPlugins/tuiImageEditor.js +204 -0
- package/dist/wysiwyg/editorPlugins/typed/blocks.d.ts +4 -0
- package/dist/wysiwyg/editorPlugins/typed/blocks.js +15 -0
- package/dist/wysiwyg/editorPlugins/typed/components.d.ts +9 -0
- package/dist/wysiwyg/editorPlugins/typed/components.js +109 -0
- package/dist/wysiwyg/editorPlugins/typed/index.d.ts +35 -0
- package/dist/wysiwyg/editorPlugins/typed/index.js +18 -0
- package/dist/wysiwyg/editorPlugins/typed/traits.d.ts +3 -0
- package/dist/wysiwyg/editorPlugins/typed/traits.js +18 -0
- package/dist/wysiwyg/editorPlugins/typed/utils.d.ts +2 -0
- package/dist/wysiwyg/editorPlugins/typed/utils.js +6 -0
- package/package.json +5 -17
- package/dist/runtime/AstroComponentProxy.d.ts +0 -29
- package/dist/runtime/AstroComponentProxy.js +0 -47
- package/dist/runtime/decoder/decode-codepoint.d.ts +0 -18
- package/dist/runtime/decoder/decode-codepoint.js +0 -58
- package/dist/runtime/decoder/decode-data-html.d.ts +0 -1
- package/dist/runtime/decoder/decode-data-html.js +0 -7
- package/dist/runtime/decoder/decode-data-xml.d.ts +0 -1
- package/dist/runtime/decoder/decode-data-xml.js +0 -7
- package/dist/runtime/decoder/index.d.ts +0 -34
- package/dist/runtime/decoder/index.js +0 -18
- package/dist/runtime/decoder/util.d.ts +0 -208
- package/dist/runtime/decoder/util.js +0 -415
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { BlockProperties, ComponentDefinition, Plugin } from 'grapesjs';
|
|
2
|
+
export type PluginOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* Object to extend the default custom code block. Pass a falsy value to avoid adding the block
|
|
5
|
+
* @example
|
|
6
|
+
* { label: 'Custom Code', category: 'Extra', ... }
|
|
7
|
+
*/
|
|
8
|
+
blockCustomCode?: Partial<BlockProperties>;
|
|
9
|
+
/**
|
|
10
|
+
* Object to extend the default custom code properties.
|
|
11
|
+
* @example
|
|
12
|
+
* { name: 'Custom Code', droppable: false, ... }
|
|
13
|
+
*/
|
|
14
|
+
propsCustomCode?: ComponentDefinition;
|
|
15
|
+
/**
|
|
16
|
+
* Object to extend the default component's toolbar button for the code. Pass a falsy value to avoid adding the button
|
|
17
|
+
* @example
|
|
18
|
+
* { label: '</>', attributes: { title: 'Open custom code' } }
|
|
19
|
+
*/
|
|
20
|
+
toolbarBtnCustomCode?: Record<string, any>;
|
|
21
|
+
/**
|
|
22
|
+
* Content to show when the custom code contains `<script>`
|
|
23
|
+
*/
|
|
24
|
+
placeholderScript?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Title for the custom code modal
|
|
27
|
+
* @default 'Insert your code'
|
|
28
|
+
*/
|
|
29
|
+
modalTitle?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Additional options for the code viewer.
|
|
32
|
+
* @example
|
|
33
|
+
* { theme: 'hopscotch', readOnly: 0 }
|
|
34
|
+
*/
|
|
35
|
+
codeViewOptions?: Record<string, any>;
|
|
36
|
+
/**
|
|
37
|
+
* Label for the default save button
|
|
38
|
+
* @default 'Save'
|
|
39
|
+
*/
|
|
40
|
+
buttonLabel?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Object to extend the default custom code command.
|
|
43
|
+
*/
|
|
44
|
+
commandCustomCode?: Record<string, any>;
|
|
45
|
+
};
|
|
46
|
+
declare const plugin: Plugin<PluginOptions>;
|
|
47
|
+
export default plugin;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import loadBlocks from "./blocks.js";
|
|
2
|
+
import loadCommands from "./commands.js";
|
|
3
|
+
import loadComponents from "./components.js";
|
|
4
|
+
const plugin = (editor, opts = {}) => {
|
|
5
|
+
const options = {
|
|
6
|
+
blockCustomCode: {},
|
|
7
|
+
propsCustomCode: {},
|
|
8
|
+
toolbarBtnCustomCode: {},
|
|
9
|
+
placeholderScript: `<div style="pointer-events: none; padding: 10px;">
|
|
10
|
+
<svg viewBox="0 0 24 24" style="height: 30px; vertical-align: middle;">
|
|
11
|
+
<path d="M13 14h-2v-4h2m0 8h-2v-2h2M1 21h22L12 2 1 21z"></path>
|
|
12
|
+
</svg>
|
|
13
|
+
Custom code with <i><script></i> can't be rendered on the canvas
|
|
14
|
+
</div>`,
|
|
15
|
+
modalTitle: "Insert your code",
|
|
16
|
+
codeViewOptions: {},
|
|
17
|
+
buttonLabel: "Save",
|
|
18
|
+
commandCustomCode: {},
|
|
19
|
+
...opts
|
|
20
|
+
};
|
|
21
|
+
loadComponents(editor, options);
|
|
22
|
+
loadBlocks(editor, options);
|
|
23
|
+
loadCommands(editor, options);
|
|
24
|
+
};
|
|
25
|
+
var code_default = plugin;
|
|
26
|
+
export {
|
|
27
|
+
code_default as default
|
|
28
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { BlockProperties, ComponentDefinition, Plugin } from 'grapesjs';
|
|
2
|
+
export type PluginOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* The ID used to create the block and component
|
|
5
|
+
* @default 'countdown'
|
|
6
|
+
*/
|
|
7
|
+
id?: string;
|
|
8
|
+
/**
|
|
9
|
+
* The label used for the block and the component.
|
|
10
|
+
* @default 'Countdown'
|
|
11
|
+
*/
|
|
12
|
+
label?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Object to extend the default block. Pass a falsy value to avoid adding the block.
|
|
15
|
+
* @example
|
|
16
|
+
* { label: 'Countdown', category: 'Extra', ... }
|
|
17
|
+
*/
|
|
18
|
+
block?: Partial<BlockProperties>;
|
|
19
|
+
/**
|
|
20
|
+
* Object to extend the default component properties.
|
|
21
|
+
* @example
|
|
22
|
+
* { name: 'Countdown', droppable: false, ... }
|
|
23
|
+
*/
|
|
24
|
+
props?: ComponentDefinition;
|
|
25
|
+
/**
|
|
26
|
+
* Custom CSS styles for the component. This will replace the default one.
|
|
27
|
+
* @default ''
|
|
28
|
+
*/
|
|
29
|
+
style?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Additional CSS styles for the component. These will be appended to the default one.
|
|
32
|
+
* @default ''
|
|
33
|
+
*/
|
|
34
|
+
styleAdditional?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Default start time.
|
|
37
|
+
* @default ''
|
|
38
|
+
* @example '2018-01-25 00:00'
|
|
39
|
+
*/
|
|
40
|
+
startTime?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Text to show when the countdown is ended.
|
|
43
|
+
* @default 'EXPIRED'
|
|
44
|
+
*/
|
|
45
|
+
endText?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Date input type, eg. `date`, `datetime-local`
|
|
48
|
+
* @default 'date'
|
|
49
|
+
*/
|
|
50
|
+
dateInputType?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Days label text used in component.
|
|
53
|
+
* @default 'days'
|
|
54
|
+
*/
|
|
55
|
+
labelDays?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Hours label text used in component.
|
|
58
|
+
* @default 'hours'
|
|
59
|
+
*/
|
|
60
|
+
labelHours?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Minutes label text used in component.
|
|
63
|
+
* @default 'minutes'
|
|
64
|
+
*/
|
|
65
|
+
labelMinutes?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Seconds label text used in component.
|
|
68
|
+
* @default 'seconds'
|
|
69
|
+
*/
|
|
70
|
+
labelSeconds?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Countdown component class prefix.
|
|
73
|
+
* @default 'countdown'
|
|
74
|
+
*/
|
|
75
|
+
classPrefix?: string;
|
|
76
|
+
};
|
|
77
|
+
type TElement = HTMLElement & {
|
|
78
|
+
__gjsCountdownInterval: NodeJS.Timer;
|
|
79
|
+
};
|
|
80
|
+
declare global {
|
|
81
|
+
interface Window {
|
|
82
|
+
__gjsCountdownIntervals: TElement[];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
declare const plugin: Plugin<PluginOptions>;
|
|
86
|
+
export default plugin;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
const plugin = (editor, opts = {}) => {
|
|
2
|
+
const options = {
|
|
3
|
+
id: "countdown",
|
|
4
|
+
label: "Countdown",
|
|
5
|
+
block: {},
|
|
6
|
+
props: {},
|
|
7
|
+
style: "",
|
|
8
|
+
styleAdditional: "",
|
|
9
|
+
startTime: "",
|
|
10
|
+
endText: "EXPIRED",
|
|
11
|
+
dateInputType: "date",
|
|
12
|
+
labelDays: "days",
|
|
13
|
+
labelHours: "hours",
|
|
14
|
+
labelMinutes: "minutes",
|
|
15
|
+
labelSeconds: "seconds",
|
|
16
|
+
classPrefix: "countdown",
|
|
17
|
+
...opts
|
|
18
|
+
};
|
|
19
|
+
const { block, props, style } = options;
|
|
20
|
+
const id = options.id;
|
|
21
|
+
const label = options.label;
|
|
22
|
+
const pfx = options.classPrefix;
|
|
23
|
+
if (block) {
|
|
24
|
+
editor.Blocks.add(id, {
|
|
25
|
+
media: `<svg viewBox="0 0 24 24">
|
|
26
|
+
<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" />
|
|
27
|
+
</svg>`,
|
|
28
|
+
label,
|
|
29
|
+
category: "Extra",
|
|
30
|
+
select: true,
|
|
31
|
+
content: { type: id },
|
|
32
|
+
...block
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const countdownScript = function(props2) {
|
|
36
|
+
const startfrom = props2.startfrom;
|
|
37
|
+
const endTxt = props2.endText;
|
|
38
|
+
const el = this;
|
|
39
|
+
const countDownDate = new Date(startfrom).getTime();
|
|
40
|
+
const countdownEl = el.querySelector("[data-js=countdown]");
|
|
41
|
+
const endTextEl = el.querySelector("[data-js=countdown-endtext]");
|
|
42
|
+
const dayEl = el.querySelector("[data-js=countdown-day]");
|
|
43
|
+
const hourEl = el.querySelector("[data-js=countdown-hour]");
|
|
44
|
+
const minuteEl = el.querySelector("[data-js=countdown-minute]");
|
|
45
|
+
const secondEl = el.querySelector("[data-js=countdown-second]");
|
|
46
|
+
const oldInterval = el.__gjsCountdownInterval;
|
|
47
|
+
oldInterval && clearInterval(oldInterval);
|
|
48
|
+
const connected = window.__gjsCountdownIntervals || [];
|
|
49
|
+
const toClean = [];
|
|
50
|
+
connected.forEach((item) => {
|
|
51
|
+
if (!item.isConnected) {
|
|
52
|
+
clearInterval(item.__gjsCountdownInterval);
|
|
53
|
+
toClean.push(item);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
connected.indexOf(el) < 0 && connected.push(el);
|
|
57
|
+
window.__gjsCountdownIntervals = connected.filter((item) => toClean.indexOf(item) < 0);
|
|
58
|
+
const setTimer = (days, hours, minutes, seconds) => {
|
|
59
|
+
dayEl.innerHTML = `${days < 10 ? `0${days}` : days}`;
|
|
60
|
+
hourEl.innerHTML = `${hours < 10 ? `0${hours}` : hours}`;
|
|
61
|
+
minuteEl.innerHTML = `${minutes < 10 ? `0${minutes}` : minutes}`;
|
|
62
|
+
secondEl.innerHTML = `${seconds < 10 ? `0${seconds}` : seconds}`;
|
|
63
|
+
};
|
|
64
|
+
const moveTimer = () => {
|
|
65
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
66
|
+
const distance = countDownDate - now;
|
|
67
|
+
const days = Math.floor(distance / 864e5);
|
|
68
|
+
const hours = Math.floor(distance % 864e5 / 36e5);
|
|
69
|
+
const minutes = Math.floor(distance % 36e5 / 6e4);
|
|
70
|
+
const seconds = Math.floor(distance % 6e4 / 1e3);
|
|
71
|
+
setTimer(days, hours, minutes, seconds);
|
|
72
|
+
if (distance < 0) {
|
|
73
|
+
clearInterval(el.__gjsCountdownInterval);
|
|
74
|
+
endTextEl.innerHTML = endTxt;
|
|
75
|
+
countdownEl.style.display = "none";
|
|
76
|
+
endTextEl.style.display = "";
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
if (countDownDate) {
|
|
80
|
+
el.__gjsCountdownInterval = setInterval(moveTimer, 1e3);
|
|
81
|
+
endTextEl.style.display = "none";
|
|
82
|
+
countdownEl.style.display = "";
|
|
83
|
+
moveTimer();
|
|
84
|
+
} else {
|
|
85
|
+
setTimer(0, 0, 0, 0);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
editor.Components.addType(id, {
|
|
89
|
+
model: {
|
|
90
|
+
defaults: {
|
|
91
|
+
startfrom: options.startTime,
|
|
92
|
+
classes: [pfx],
|
|
93
|
+
endText: options.endText,
|
|
94
|
+
droppable: false,
|
|
95
|
+
script: countdownScript,
|
|
96
|
+
"script-props": ["startfrom", "endText"],
|
|
97
|
+
traits: [
|
|
98
|
+
{
|
|
99
|
+
label: "Start",
|
|
100
|
+
name: "startfrom",
|
|
101
|
+
changeProp: true,
|
|
102
|
+
type: options.dateInputType
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
label: "End text",
|
|
106
|
+
name: "endText",
|
|
107
|
+
changeProp: true
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
// @ts-ignore
|
|
111
|
+
components: `
|
|
112
|
+
<span data-js="countdown" class="${pfx}-cont">
|
|
113
|
+
<div class="${pfx}-block">
|
|
114
|
+
<div data-js="countdown-day" class="${pfx}-digit"></div>
|
|
115
|
+
<div class="${pfx}-label">${options.labelDays}</div>
|
|
116
|
+
</div>
|
|
117
|
+
<div class="${pfx}-block">
|
|
118
|
+
<div data-js="countdown-hour" class="${pfx}-digit"></div>
|
|
119
|
+
<div class="${pfx}-label">${options.labelHours}</div>
|
|
120
|
+
</div>
|
|
121
|
+
<div class="${pfx}-block">
|
|
122
|
+
<div data-js="countdown-minute" class="${pfx}-digit"></div>
|
|
123
|
+
<div class="${pfx}-label">${options.labelMinutes}</div>
|
|
124
|
+
</div>
|
|
125
|
+
<div class="${pfx}-block">
|
|
126
|
+
<div data-js="countdown-second" class="${pfx}-digit"></div>
|
|
127
|
+
<div class="${pfx}-label">${options.labelSeconds}</div>
|
|
128
|
+
</div>
|
|
129
|
+
</span>
|
|
130
|
+
<span data-js="countdown-endtext" class="${pfx}-endtext"></span>
|
|
131
|
+
`,
|
|
132
|
+
styles: (style || `
|
|
133
|
+
.${pfx} {
|
|
134
|
+
text-align: center;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.${pfx}-block {
|
|
138
|
+
display: inline-block;
|
|
139
|
+
margin: 0 10px;
|
|
140
|
+
padding: 10px;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.${pfx}-digit {
|
|
144
|
+
font-size: 5rem;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.${pfx}-endtext {
|
|
148
|
+
font-size: 5rem;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.${pfx}-cont {
|
|
152
|
+
display: inline-block;
|
|
153
|
+
}
|
|
154
|
+
`) + options.styleAdditional,
|
|
155
|
+
...props
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
var countdown_default = plugin;
|
|
161
|
+
export {
|
|
162
|
+
countdown_default as default
|
|
163
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import {
|
|
2
|
+
typeButton,
|
|
3
|
+
typeCheckbox,
|
|
4
|
+
typeForm,
|
|
5
|
+
typeInput,
|
|
6
|
+
typeLabel,
|
|
7
|
+
typeRadio,
|
|
8
|
+
typeSelect,
|
|
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
|
+
};
|
|
22
|
+
addBlock(typeForm, {
|
|
23
|
+
label: "Form",
|
|
24
|
+
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
|
+
content: {
|
|
26
|
+
type: typeForm,
|
|
27
|
+
components: [
|
|
28
|
+
{
|
|
29
|
+
components: [{ type: typeLabel, components: "Name" }, { type: typeInput }]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
components: [
|
|
33
|
+
{ type: typeLabel, components: "Email" },
|
|
34
|
+
{ type: typeInput, attributes: { type: "email" } }
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
components: [
|
|
39
|
+
{ type: typeLabel, components: "Gender" },
|
|
40
|
+
{ type: typeCheckbox, attributes: { value: "M" } },
|
|
41
|
+
{ type: typeLabel, components: "M" },
|
|
42
|
+
{ type: typeCheckbox, attributes: { value: "F" } },
|
|
43
|
+
{ type: typeLabel, components: "F" }
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
components: [{ type: typeLabel, components: "Message" }, { type: typeTextarea }]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
components: [{ type: typeButton }]
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
addBlock(typeInput, {
|
|
56
|
+
label: "Input",
|
|
57
|
+
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
|
+
content: { type: typeInput }
|
|
59
|
+
});
|
|
60
|
+
addBlock(typeTextarea, {
|
|
61
|
+
label: "Textarea",
|
|
62
|
+
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
|
+
content: { type: typeTextarea }
|
|
64
|
+
});
|
|
65
|
+
addBlock(typeSelect, {
|
|
66
|
+
label: "Select",
|
|
67
|
+
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
|
+
content: { type: typeSelect }
|
|
69
|
+
});
|
|
70
|
+
addBlock(typeButton, {
|
|
71
|
+
label: "Button",
|
|
72
|
+
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
|
+
content: { type: typeButton }
|
|
74
|
+
});
|
|
75
|
+
addBlock(typeLabel, {
|
|
76
|
+
label: "Label",
|
|
77
|
+
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
|
+
content: { type: typeLabel }
|
|
79
|
+
});
|
|
80
|
+
addBlock(typeCheckbox, {
|
|
81
|
+
label: "Checkbox",
|
|
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
|
+
content: { type: typeCheckbox }
|
|
84
|
+
});
|
|
85
|
+
addBlock(typeRadio, {
|
|
86
|
+
label: "Radio",
|
|
87
|
+
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
|
+
content: { type: typeRadio }
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
export {
|
|
92
|
+
blocks_default as default
|
|
93
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Editor } from 'grapesjs';
|
|
2
|
+
export declare const typeForm = "form";
|
|
3
|
+
export declare const typeInput = "input";
|
|
4
|
+
export declare const typeTextarea = "textarea";
|
|
5
|
+
export declare const typeSelect = "select";
|
|
6
|
+
export declare const typeCheckbox = "checkbox";
|
|
7
|
+
export declare const typeRadio = "radio";
|
|
8
|
+
export declare const typeButton = "button";
|
|
9
|
+
export declare const typeLabel = "label";
|
|
10
|
+
export declare const typeOption = "option";
|
|
11
|
+
export default function (editor: Editor): void;
|