@studiocms/wysiwyg 0.1.0-experimental.2 → 0.1.0-experimental.4
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/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
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { cmpId, traitStringId } from "./utils.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 components_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: <explanation>
|
|
34
|
+
type: getTraitType(typedProps[name]),
|
|
35
|
+
min: 0,
|
|
36
|
+
name
|
|
37
|
+
}));
|
|
38
|
+
traits.unshift({
|
|
39
|
+
changeProp: true,
|
|
40
|
+
name: "strings",
|
|
41
|
+
type: traitStringId
|
|
42
|
+
});
|
|
43
|
+
domc.addType(cmpId, {
|
|
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: <explanation>
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
export {
|
|
108
|
+
components_default as default
|
|
109
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { BlockProperties, ComponentDefinition, Plugin } from 'grapesjs';
|
|
2
|
+
export interface PluginOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Library to load asynchronously in case `Typed` is not found.
|
|
5
|
+
* @default 'https://cdn.jsdelivr.net/npm/typed.js@2.0.11'
|
|
6
|
+
*/
|
|
7
|
+
script?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Object to extend the default block, eg. `{ label: 'Typed', ... }`.
|
|
10
|
+
* Pass a falsy value to avoid adding the block
|
|
11
|
+
* @default {}
|
|
12
|
+
*/
|
|
13
|
+
block?: Partial<BlockProperties>;
|
|
14
|
+
/**
|
|
15
|
+
* Customize the component props. The final object should be returned.
|
|
16
|
+
* @default (props) => props
|
|
17
|
+
* @example
|
|
18
|
+
* props: props => {
|
|
19
|
+
* props.traits = props.traits.map(trait => {
|
|
20
|
+
* if (trait.name == 'strings') {
|
|
21
|
+
* trait.label = 'Custom <b>trait<b/> label';
|
|
22
|
+
* }
|
|
23
|
+
* // this trait will be removed
|
|
24
|
+
* if (trait.name == 'fade-out-class') return;
|
|
25
|
+
* return trait;
|
|
26
|
+
* }).filter(Boolean);
|
|
27
|
+
*
|
|
28
|
+
* return props;
|
|
29
|
+
* }
|
|
30
|
+
*/
|
|
31
|
+
props?: (p: ComponentDefinition) => ComponentDefinition;
|
|
32
|
+
}
|
|
33
|
+
export type RequiredPluginOptions = Required<PluginOptions>;
|
|
34
|
+
declare const plugin: Plugin<PluginOptions>;
|
|
35
|
+
export default plugin;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import loadBlocks from "./blocks.js";
|
|
2
|
+
import loadComponents from "./components.js";
|
|
3
|
+
import loadTraits from "./traits.js";
|
|
4
|
+
const plugin = (editor, opts = {}) => {
|
|
5
|
+
const options = {
|
|
6
|
+
script: "https://cdn.jsdelivr.net/npm/typed.js@2.0.11",
|
|
7
|
+
block: {},
|
|
8
|
+
props: (p) => p,
|
|
9
|
+
...opts
|
|
10
|
+
};
|
|
11
|
+
loadComponents(editor, options);
|
|
12
|
+
loadBlocks(editor, options);
|
|
13
|
+
loadTraits(editor);
|
|
14
|
+
};
|
|
15
|
+
var typed_default = plugin;
|
|
16
|
+
export {
|
|
17
|
+
typed_default as default
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { traitStringId } from "./utils.js";
|
|
2
|
+
var traits_default = (editor) => {
|
|
3
|
+
editor.TraitManager.addType(traitStringId, {
|
|
4
|
+
createInput({ component }) {
|
|
5
|
+
return `<textarea>${component.get("strings").join("\n")}</textarea>`;
|
|
6
|
+
},
|
|
7
|
+
onUpdate({ component, elInput }) {
|
|
8
|
+
elInput.value = component.get("strings").join("\n");
|
|
9
|
+
},
|
|
10
|
+
onEvent({ component, elInput }) {
|
|
11
|
+
const value = (elInput.value || "").split("\n");
|
|
12
|
+
component.set("strings", value);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
traits_default as default
|
|
18
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studiocms/wysiwyg",
|
|
3
|
-
"version": "0.1.0-experimental.
|
|
3
|
+
"version": "0.1.0-experimental.4",
|
|
4
4
|
"description": "Add A WYSIWYG Editor to your StudioCMS project with ease!",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Adam Matthiesen | Jacob Jenkins | Paul Valladares",
|
|
@@ -62,29 +62,17 @@
|
|
|
62
62
|
"@studiocms/ui": "^0.4.16",
|
|
63
63
|
"astro-integration-kit": "^0.18",
|
|
64
64
|
"grapesjs": "^0.22.6",
|
|
65
|
-
"grapesjs-blocks-basic": "^1.0.2",
|
|
66
|
-
"grapesjs-plugin-forms": "^2.0.6",
|
|
67
|
-
"grapesjs-component-countdown": "1.0.2",
|
|
68
|
-
"grapesjs-plugin-export": "^1.0.12",
|
|
69
|
-
"grapesjs-tabs": "^1.0.6",
|
|
70
|
-
"grapesjs-custom-code": "^1.0.2",
|
|
71
|
-
"grapesjs-touch": "^0.1.1",
|
|
72
|
-
"grapesjs-parser-postcss": "^1.0.3",
|
|
73
|
-
"grapesjs-tooltip": "0.1.8",
|
|
74
|
-
"grapesjs-tui-image-editor": "^1.0.2",
|
|
75
|
-
"grapesjs-typed": "^2.0.1",
|
|
76
|
-
"grapesjs-style-bg": "^2.0.2",
|
|
77
|
-
"grapesjs-rte-extensions": "^1.0.10",
|
|
78
65
|
"ultrahtml": "^1.5.3",
|
|
66
|
+
"tui-image-editor": "^3.15.3",
|
|
79
67
|
"@studiocms/grapesjs-plugin": "0.1.0"
|
|
80
68
|
},
|
|
81
69
|
"devDependencies": {
|
|
82
70
|
"@types/node": "^22.0.0"
|
|
83
71
|
},
|
|
84
72
|
"peerDependencies": {
|
|
85
|
-
"astro": "^5.
|
|
86
|
-
"studiocms": "0.1.0-beta.
|
|
87
|
-
"vite": "^6.2.
|
|
73
|
+
"astro": "^5.7.1",
|
|
74
|
+
"studiocms": ">=0.1.0-beta.14",
|
|
75
|
+
"vite": "^6.2.5"
|
|
88
76
|
},
|
|
89
77
|
"scripts": {
|
|
90
78
|
"build": "build-scripts build 'src/**/*.{ts,astro,css,js}'",
|