@studiocms/wysiwyg 0.1.0-beta.26 → 0.1.0-beta.28
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/README.md +2 -0
- package/dist/common/grapesBlocks/components/countdown.js +0 -1
- package/dist/common/grapesBlocks/components/tabs/Tabs.js +1 -1
- package/dist/common/grapesBlocks/rte/index.js +8 -8
- package/dist/common/grapesBlocks/tuiImageEditor/index.js +1 -1
- package/dist/components/Editor.astro +1 -1
- package/dist/components/render.d.ts +15 -0
- package/dist/components/render.js +11 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +28 -22
- package/dist/lib/db.d.ts +3 -3
- package/dist/lib/shared.js +1 -2
- package/package.json +9 -7
- package/dist/components/Render.astro +0 -24
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @studiocms/wysiwyg
|
|
2
2
|
|
|
3
|
+
[](https://codecov.io/github/withstudiocms/studiocms)
|
|
4
|
+
|
|
3
5
|
Add a WYSIWYG editor to your StudioCMS dashboard.
|
|
4
6
|
|
|
5
7
|
## Overview
|
|
@@ -28,7 +28,7 @@ var Tabs_default = (editor, config) => {
|
|
|
28
28
|
const getAllTabs = () => el.querySelectorAll(roleTab);
|
|
29
29
|
const upTabIdx = (item, val) => {
|
|
30
30
|
if (!_isEditor) {
|
|
31
|
-
item.tabIndex = Number.parseInt(val);
|
|
31
|
+
item.tabIndex = Number.parseInt(val, 10);
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
const activeTab = (tabEl) => {
|
|
@@ -86,10 +86,10 @@ const richTextEditor = (editor, opts = {}) => {
|
|
|
86
86
|
style: "padding: 0 4px 2px;",
|
|
87
87
|
title: "Font Name"
|
|
88
88
|
},
|
|
89
|
-
// @ts-
|
|
89
|
+
// @ts-expect-error
|
|
90
90
|
result: (rte2, action) => rte2.exec("fontName", action.btn?.firstChild?.value),
|
|
91
91
|
// Callback on any input change (mousedown, keydown, etc..)
|
|
92
|
-
// @ts-
|
|
92
|
+
// @ts-expect-error
|
|
93
93
|
update: (rte2, action) => {
|
|
94
94
|
const value = rte2.doc.queryCommandValue(action.name);
|
|
95
95
|
if (value !== "false") {
|
|
@@ -113,10 +113,10 @@ const richTextEditor = (editor, opts = {}) => {
|
|
|
113
113
|
style: "padding: 0 4px 2px;",
|
|
114
114
|
title: "Font Size"
|
|
115
115
|
},
|
|
116
|
-
// @ts-
|
|
116
|
+
// @ts-expect-error
|
|
117
117
|
result: (rte2, action) => rte2.exec("fontSize", action.btn?.firstChild?.value),
|
|
118
118
|
// Callback on any input change (mousedown, keydown, etc..)
|
|
119
|
-
// @ts-
|
|
119
|
+
// @ts-expect-error
|
|
120
120
|
update: (rte2, action) => {
|
|
121
121
|
const value = rte2.doc.queryCommandValue(action.name);
|
|
122
122
|
if (value !== "false") {
|
|
@@ -127,7 +127,7 @@ const richTextEditor = (editor, opts = {}) => {
|
|
|
127
127
|
const pk1 = {};
|
|
128
128
|
options.fonts?.fontColor && rte.add("fontColor", {
|
|
129
129
|
icon: `${icons?.fontColor || '<b style="pointer-events:none;border-bottom:2px solid">A</b>'}
|
|
130
|
-
<div id="foreColor-picker-${// @ts-
|
|
130
|
+
<div id="foreColor-picker-${// @ts-expect-error
|
|
131
131
|
editor.Config.container?.replace("#", "")}"
|
|
132
132
|
class="${options.darkColorPicker ? "rte-color-picker dark" : "rte-color-picker light"}">
|
|
133
133
|
</div>`,
|
|
@@ -136,7 +136,7 @@ const richTextEditor = (editor, opts = {}) => {
|
|
|
136
136
|
title: "Font Color"
|
|
137
137
|
},
|
|
138
138
|
result: (rte2) => {
|
|
139
|
-
const pikerEle = `#foreColor-picker-${// @ts-
|
|
139
|
+
const pikerEle = `#foreColor-picker-${// @ts-expect-error
|
|
140
140
|
editor.Config.container?.replace("#", "")}`;
|
|
141
141
|
if (!pk1[pikerEle])
|
|
142
142
|
pk1[pikerEle] = new ColorPicker(
|
|
@@ -153,7 +153,7 @@ const richTextEditor = (editor, opts = {}) => {
|
|
|
153
153
|
const pk2 = {};
|
|
154
154
|
options.fonts?.hilite && rte.add("hiliteColor", {
|
|
155
155
|
icon: `${icons?.hiliteColor || '<b style="pointer-events:none;" class="rte-hilite-btn">A</b>'}
|
|
156
|
-
<div id="hilite-picker-${// @ts-
|
|
156
|
+
<div id="hilite-picker-${// @ts-expect-error
|
|
157
157
|
editor.Config.container?.replace("#", "")}"
|
|
158
158
|
class="${options.darkColorPicker ? "rte-color-picker dark" : "rte-color-picker light"}">
|
|
159
159
|
</div>`,
|
|
@@ -162,7 +162,7 @@ const richTextEditor = (editor, opts = {}) => {
|
|
|
162
162
|
title: "Font Highlight"
|
|
163
163
|
},
|
|
164
164
|
result: (rte2) => {
|
|
165
|
-
const pikerEle = `#hilite-picker-${// @ts-
|
|
165
|
+
const pikerEle = `#hilite-picker-${// @ts-expect-error
|
|
166
166
|
editor.Config.container?.replace("#", "")}`;
|
|
167
167
|
if (!pk2[pikerEle])
|
|
168
168
|
pk2[pikerEle] = new ColorPicker(
|
|
@@ -13,7 +13,7 @@ interface Props extends PluginPageTypeEditorProps {}
|
|
|
13
13
|
// Extract the content from Astro props
|
|
14
14
|
const { content, id = '' } = Astro.props as Props;
|
|
15
15
|
|
|
16
|
-
const token = Astro.locals
|
|
16
|
+
const token = Astro.locals?.StudioCMS?.plugins?.editorCSRFToken;
|
|
17
17
|
---
|
|
18
18
|
|
|
19
19
|
<div
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const renderer: {
|
|
2
|
+
name: string;
|
|
3
|
+
renderer: (content: string) => Promise<string>;
|
|
4
|
+
sanitizeOpts: {
|
|
5
|
+
allowElements?: string[] | undefined;
|
|
6
|
+
blockElements?: string[] | undefined;
|
|
7
|
+
dropElements?: string[] | undefined;
|
|
8
|
+
allowAttributes?: Record<string, string[]> | undefined;
|
|
9
|
+
dropAttributes?: Record<string, string[]> | undefined;
|
|
10
|
+
allowComponents?: boolean | undefined;
|
|
11
|
+
allowCustomElements?: boolean | undefined;
|
|
12
|
+
allowComments?: boolean | undefined;
|
|
13
|
+
} | undefined;
|
|
14
|
+
};
|
|
15
|
+
export default renderer;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { preRenderer } from "../lib/prerender.js";
|
|
2
|
+
import { shared } from "../lib/shared.js";
|
|
3
|
+
const renderer = {
|
|
4
|
+
name: "@studiocms/wysiwyg",
|
|
5
|
+
renderer: preRenderer,
|
|
6
|
+
sanitizeOpts: shared?.sanitize
|
|
7
|
+
};
|
|
8
|
+
var render_default = renderer;
|
|
9
|
+
export {
|
|
10
|
+
render_default as default
|
|
11
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,18 @@
|
|
|
3
3
|
* loaded when a user imports the StudioCMS plugin in their Astro configuration file. These
|
|
4
4
|
* directives must be first at the top of the file and can only be preceded by this comment.
|
|
5
5
|
*/
|
|
6
|
+
import type { AstroIntegration } from 'astro';
|
|
6
7
|
import { type StudioCMSPlugin } from 'studiocms/plugins';
|
|
7
8
|
import { type WYSIWYGSchemaOptions } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Creates an internal Astro integration for WYSIWYG rendering.
|
|
11
|
+
* This is used for testing and internal purposes.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} packageIdentifier - The package identifier for the integration.
|
|
14
|
+
* @param {WYSIWYGSchemaOptions} [options] - Optional configuration options for the WYSIWYG plugin.
|
|
15
|
+
* @returns {AstroIntegration} The configured Astro integration.
|
|
16
|
+
*/
|
|
17
|
+
export declare function internalWysiwygIntegration(packageIdentifier: string, options?: WYSIWYGSchemaOptions): AstroIntegration;
|
|
8
18
|
/**
|
|
9
19
|
* Creates and configures the StudioCMS WYSIWYG Editor plugin.
|
|
10
20
|
*
|
package/dist/index.js
CHANGED
|
@@ -3,46 +3,51 @@ import { definePlugin } from "studiocms/plugins";
|
|
|
3
3
|
import { GRAPES_CSS_PATH, PARTIAL_PATH, STORE_ENDPOINT_PATH } from "./consts.js";
|
|
4
4
|
import { shared } from "./lib/shared.js";
|
|
5
5
|
import { WYSIWYGSchema } from "./types.js";
|
|
6
|
-
function
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const packageIdentifier = "@studiocms/wysiwyg";
|
|
6
|
+
function internalWysiwygIntegration(packageIdentifier, options) {
|
|
7
|
+
const resolvedOptions = WYSIWYGSchema.parse(options);
|
|
8
|
+
const resEntrypoint = (path) => `@studiocms/wysiwyg/routes/${path}`;
|
|
10
9
|
const routes = [
|
|
11
10
|
{
|
|
12
|
-
entrypoint:
|
|
11
|
+
entrypoint: resEntrypoint("partial.astro"),
|
|
13
12
|
pattern: PARTIAL_PATH,
|
|
14
13
|
prerender: false
|
|
15
14
|
},
|
|
16
15
|
{
|
|
17
|
-
entrypoint:
|
|
16
|
+
entrypoint: resEntrypoint("grapes.css.js"),
|
|
18
17
|
pattern: GRAPES_CSS_PATH,
|
|
19
18
|
prerender: false
|
|
20
19
|
},
|
|
21
20
|
{
|
|
22
|
-
entrypoint:
|
|
21
|
+
entrypoint: resEntrypoint("store.js"),
|
|
23
22
|
pattern: STORE_ENDPOINT_PATH,
|
|
24
23
|
prerender: false
|
|
25
24
|
}
|
|
26
25
|
];
|
|
26
|
+
return {
|
|
27
|
+
name: packageIdentifier,
|
|
28
|
+
hooks: {
|
|
29
|
+
"astro:config:setup": ({ injectRoute }) => {
|
|
30
|
+
for (const route of routes) {
|
|
31
|
+
injectRoute(route);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"astro:config:done": () => {
|
|
35
|
+
shared.sanitize = resolvedOptions?.sanitize;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function wysiwyg(opts) {
|
|
41
|
+
const { resolve } = createResolver(import.meta.url);
|
|
42
|
+
const options = WYSIWYGSchema.parse(opts);
|
|
43
|
+
const packageIdentifier = "@studiocms/wysiwyg";
|
|
27
44
|
return definePlugin({
|
|
28
45
|
identifier: packageIdentifier,
|
|
29
46
|
name: "StudioCMS WYSIWYG Editor",
|
|
30
47
|
studiocmsMinimumVersion: "0.1.0-beta.23",
|
|
31
48
|
hooks: {
|
|
32
49
|
"studiocms:astro:config": ({ addIntegrations }) => {
|
|
33
|
-
addIntegrations(
|
|
34
|
-
name: packageIdentifier,
|
|
35
|
-
hooks: {
|
|
36
|
-
"astro:config:setup": ({ injectRoute }) => {
|
|
37
|
-
for (const route of routes) {
|
|
38
|
-
injectRoute(route);
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
"astro:config:done": () => {
|
|
42
|
-
shared.sanitize = options?.sanitize;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
});
|
|
50
|
+
addIntegrations(internalWysiwygIntegration(packageIdentifier, options));
|
|
46
51
|
},
|
|
47
52
|
"studiocms:config:setup": ({ setRendering }) => {
|
|
48
53
|
setRendering({
|
|
@@ -50,7 +55,7 @@ function wysiwyg(opts) {
|
|
|
50
55
|
{
|
|
51
56
|
identifier: "studiocms/wysiwyg",
|
|
52
57
|
label: "WYSIWYG",
|
|
53
|
-
rendererComponent: resolve("./components/
|
|
58
|
+
rendererComponent: resolve("./components/render.js"),
|
|
54
59
|
pageContentComponent: resolve("./components/Editor.astro")
|
|
55
60
|
}
|
|
56
61
|
]
|
|
@@ -61,5 +66,6 @@ function wysiwyg(opts) {
|
|
|
61
66
|
}
|
|
62
67
|
var index_default = wysiwyg;
|
|
63
68
|
export {
|
|
64
|
-
index_default as default
|
|
69
|
+
index_default as default,
|
|
70
|
+
internalWysiwygIntegration
|
|
65
71
|
};
|
package/dist/lib/db.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export declare const UseSDK: Effect.Effect<{
|
|
|
35
35
|
symbols: unknown[];
|
|
36
36
|
pages: unknown[];
|
|
37
37
|
__STUDIOCMS_HTML?: string | undefined;
|
|
38
|
-
}>[], Error | import("
|
|
38
|
+
}>[], Error | import("@withstudiocms/effect/drizzle").LibSQLClientError, never>;
|
|
39
39
|
/**
|
|
40
40
|
* Retrieves a specific entry of the plugin data by its ID.
|
|
41
41
|
*
|
|
@@ -49,7 +49,7 @@ export declare const UseSDK: Effect.Effect<{
|
|
|
49
49
|
symbols: unknown[];
|
|
50
50
|
pages: unknown[];
|
|
51
51
|
__STUDIOCMS_HTML?: string | undefined;
|
|
52
|
-
}> | undefined, Error | import("
|
|
52
|
+
}> | undefined, Error | import("@withstudiocms/effect/drizzle").LibSQLClientError, never>;
|
|
53
53
|
/**
|
|
54
54
|
* Inserts or updates a plugin data entry with the specified ID and data.
|
|
55
55
|
*
|
|
@@ -71,7 +71,7 @@ export declare const UseSDK: Effect.Effect<{
|
|
|
71
71
|
symbols: unknown[];
|
|
72
72
|
pages: unknown[];
|
|
73
73
|
__STUDIOCMS_HTML?: string | undefined;
|
|
74
|
-
}>, Error | import("
|
|
74
|
+
}>, Error | import("@withstudiocms/effect/drizzle").LibSQLClientError, never>;
|
|
75
75
|
/**
|
|
76
76
|
* Returns the inferred type for the plugin data schema.
|
|
77
77
|
*/
|
package/dist/lib/shared.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
const shared = globalThis.studiocmsWYSIWYG ||
|
|
2
|
-
(globalThis.studiocmsWYSIWYG = {
|
|
1
|
+
const shared = globalThis.studiocmsWYSIWYG || (globalThis.studiocmsWYSIWYG = {
|
|
3
2
|
sanitize: void 0
|
|
4
3
|
});
|
|
5
4
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studiocms/wysiwyg",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.28",
|
|
4
4
|
"description": "Add A WYSIWYG Editor to your StudioCMS project with ease!",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "withstudiocms",
|
|
@@ -52,28 +52,30 @@
|
|
|
52
52
|
"types": "./dist/types.d.ts",
|
|
53
53
|
"default": "./dist/types.js"
|
|
54
54
|
},
|
|
55
|
-
"./components/*": "./dist/components/*"
|
|
55
|
+
"./components/*": "./dist/components/*",
|
|
56
|
+
"./routes/*": "./dist/routes/*"
|
|
56
57
|
},
|
|
57
58
|
"type": "module",
|
|
58
59
|
"dependencies": {
|
|
59
|
-
"astro-integration-kit": "^0.19.
|
|
60
|
+
"astro-integration-kit": "^0.19.1",
|
|
60
61
|
"deepmerge-ts": "^7.1.5",
|
|
61
|
-
"grapesjs": "^0.22.
|
|
62
|
+
"grapesjs": "^0.22.13",
|
|
62
63
|
"tui-image-editor": "^3.15.3"
|
|
63
64
|
},
|
|
64
65
|
"devDependencies": {
|
|
65
66
|
"@types/node": "^22.0.0"
|
|
66
67
|
},
|
|
67
68
|
"peerDependencies": {
|
|
68
|
-
"@studiocms/ui": "^1.0.0-beta.
|
|
69
|
+
"@studiocms/ui": "^1.0.0-beta.3",
|
|
69
70
|
"astro": "^5.12.9",
|
|
70
71
|
"vite": "^6.3.4",
|
|
71
|
-
"@withstudiocms/component-registry": "0.1.0-beta.
|
|
72
|
-
"studiocms": "0.1.0-beta.
|
|
72
|
+
"@withstudiocms/component-registry": "0.1.0-beta.4",
|
|
73
|
+
"studiocms": "0.1.0-beta.28"
|
|
73
74
|
},
|
|
74
75
|
"scripts": {
|
|
75
76
|
"build": "buildkit build 'src/**/*.{ts,astro,css,js}'",
|
|
76
77
|
"dev": "buildkit dev 'src/**/*.{ts,astro,css,js}'",
|
|
78
|
+
"test": "vitest",
|
|
77
79
|
"typecheck": "tspc -p tsconfig.tspc.json"
|
|
78
80
|
}
|
|
79
81
|
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import { createRenderer } from 'studiocms:component-registry/runtime';
|
|
3
|
-
import type { PluginPageTypeRendererProps } from 'studiocms/types';
|
|
4
|
-
import { preRenderer } from '../lib/prerender.js';
|
|
5
|
-
import { shared } from '../lib/shared.js';
|
|
6
|
-
|
|
7
|
-
// @ts-expect-error - $$result is a global variable injected by Astro during compilation and not a editor-known variable
|
|
8
|
-
const ssrResult: SSRResult = $$result;
|
|
9
|
-
|
|
10
|
-
// Define render function
|
|
11
|
-
const render = await createRenderer(ssrResult, shared?.sanitize, preRenderer);
|
|
12
|
-
|
|
13
|
-
interface Props extends PluginPageTypeRendererProps {}
|
|
14
|
-
|
|
15
|
-
// Get default content
|
|
16
|
-
const { defaultContent } = Astro.props.data;
|
|
17
|
-
|
|
18
|
-
// Get content to render
|
|
19
|
-
const contentToRender = defaultContent?.content || '<h1>Error: No content found</h1>';
|
|
20
|
-
|
|
21
|
-
// Render content
|
|
22
|
-
const renderedContent = await render(contentToRender);
|
|
23
|
-
---
|
|
24
|
-
<Fragment set:html={renderedContent} />
|