@studiocms/wysiwyg 0.2.0 → 0.3.0

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.
@@ -66,7 +66,7 @@ export declare const getSlotData: (model: Component) => string | undefined;
66
66
  * @param type - The trait type to filter (e.g., "number", "string", etc.).
67
67
  * @returns The corresponding input type as a string. Returns "number" if the type is "number", otherwise returns "text".
68
68
  */
69
- export declare const traitTypeFilter: (type: string) => "text" | "number";
69
+ export declare const traitTypeFilter: (type: string) => "number" | "text";
70
70
  /**
71
71
  * Maps an `AstroComponentProp` to a new object with filtered type, name, and default value.
72
72
  *
@@ -1,15 +1,6 @@
1
1
  declare const renderer: {
2
2
  name: string;
3
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;
4
+ sanitizeOpts: import("ultrahtml/transformers/sanitize").SanitizeOptions | undefined;
14
5
  };
15
6
  export default renderer;
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * directives must be first at the top of the file and can only be preceded by this comment.
5
5
  */
6
6
  import type { AstroIntegration } from 'astro';
7
- import { type StudioCMSPlugin } from 'studiocms/plugins';
7
+ import type { StudioCMSPluginDef } from 'studiocms/schemas';
8
8
  import { type WYSIWYGSchemaOptions } from './types.js';
9
9
  /**
10
10
  * Creates an internal Astro integration for WYSIWYG rendering.
@@ -35,5 +35,5 @@ export declare function internalWysiwygIntegration(packageIdentifier: string, op
35
35
  * ]
36
36
  * ```
37
37
  */
38
- declare function wysiwyg(opts?: WYSIWYGSchemaOptions): StudioCMSPlugin;
38
+ declare function wysiwyg(opts?: WYSIWYGSchemaOptions): StudioCMSPluginDef;
39
39
  export default wysiwyg;
package/dist/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { createResolver } from "astro-integration-kit";
2
+ import { Schema } from "studiocms/effect";
2
3
  import { definePlugin } from "studiocms/plugins";
3
4
  import { GRAPES_CSS_PATH, PARTIAL_PATH, STORE_ENDPOINT_PATH } from "./consts.js";
4
5
  import { shared } from "./lib/shared.js";
5
6
  import { WYSIWYGSchema } from "./types.js";
6
- function internalWysiwygIntegration(packageIdentifier, options) {
7
- const resolvedOptions = WYSIWYGSchema.parse(options);
7
+ function internalWysiwygIntegration(packageIdentifier, options = {}) {
8
+ const resolvedOptions = Schema.decodeSync(WYSIWYGSchema)(options);
8
9
  const resEntrypoint = (path) => `@studiocms/wysiwyg/routes/${path}`;
9
10
  const routes = [
10
11
  {
@@ -37,19 +38,18 @@ function internalWysiwygIntegration(packageIdentifier, options) {
37
38
  }
38
39
  };
39
40
  }
40
- function wysiwyg(opts) {
41
+ function wysiwyg(opts = {}) {
41
42
  const { resolve } = createResolver(import.meta.url);
42
- const options = WYSIWYGSchema.parse(opts);
43
+ const options = Schema.decodeSync(WYSIWYGSchema)(opts);
43
44
  const packageIdentifier = "@studiocms/wysiwyg";
44
45
  return definePlugin({
45
46
  identifier: packageIdentifier,
46
47
  name: "StudioCMS WYSIWYG Editor",
47
- studiocmsMinimumVersion: "0.1.0-beta.23",
48
48
  hooks: {
49
- "studiocms:astro-config": ({ addIntegrations }) => {
49
+ "studiocms:astro-config": async ({ addIntegrations }) => {
50
50
  addIntegrations(internalWysiwygIntegration(packageIdentifier, options));
51
51
  },
52
- "studiocms:rendering": ({ setRendering }) => {
52
+ "studiocms:rendering": async ({ setRendering }) => {
53
53
  setRendering({
54
54
  pageTypes: [
55
55
  {
package/dist/lib/db.d.ts CHANGED
@@ -28,14 +28,28 @@ export declare const UseSDK: Effect.Effect<{
28
28
  *
29
29
  * @returns An array of all plugin data entries.
30
30
  */
31
- getAll: () => Effect.Effect<import("@withstudiocms/sdk/types").PluginDataEntry<any>[], import("@withstudiocms/sdk/errors.js").StudioCMSSDKError, never>;
31
+ getAll: () => Effect.Effect<import("@withstudiocms/sdk/types").PluginDataEntry<{
32
+ dataSources: unknown[];
33
+ assets: unknown[];
34
+ styles: unknown[];
35
+ symbols: unknown[];
36
+ pages: unknown[];
37
+ __STUDIOCMS_HTML?: string | undefined;
38
+ }>[], import("@withstudiocms/sdk/errors.js").StudioCMSSDKError, never>;
32
39
  /**
33
40
  * Retrieves a specific entry of the plugin data by its ID.
34
41
  *
35
42
  * @param id - The unique identifier for the plugin data entry.
36
43
  * @returns An Effect that resolves to the plugin data entry with the specified ID.
37
44
  */
38
- load: (id: string) => Effect.Effect<import("@withstudiocms/sdk/types").PluginDataEntry<any> | undefined, import("@withstudiocms/sdk/errors.js").StudioCMSSDKError, never>;
45
+ load: (id: string) => Effect.Effect<import("@withstudiocms/sdk/types").PluginDataEntry<{
46
+ dataSources: unknown[];
47
+ assets: unknown[];
48
+ styles: unknown[];
49
+ symbols: unknown[];
50
+ pages: unknown[];
51
+ __STUDIOCMS_HTML?: string | undefined;
52
+ }> | undefined, import("@withstudiocms/sdk/errors.js").StudioCMSSDKError, never>;
39
53
  /**
40
54
  * Inserts or updates a plugin data entry with the specified ID and data.
41
55
  *
@@ -50,7 +64,14 @@ export declare const UseSDK: Effect.Effect<{
50
64
  symbols: unknown[];
51
65
  pages: unknown[];
52
66
  __STUDIOCMS_HTML?: string | undefined;
53
- }) => Effect.Effect<import("@withstudiocms/sdk/types").PluginDataEntry<any>, import("@withstudiocms/sdk/errors.js").StudioCMSSDKError, never>;
67
+ }) => Effect.Effect<import("@withstudiocms/sdk/types").PluginDataEntry<{
68
+ dataSources: unknown[];
69
+ assets: unknown[];
70
+ styles: unknown[];
71
+ symbols: unknown[];
72
+ pages: unknown[];
73
+ __STUDIOCMS_HTML?: string | undefined;
74
+ }>, import("@withstudiocms/sdk/errors.js").StudioCMSSDKError, never>;
54
75
  /**
55
76
  * Returns the inferred type for the plugin data schema.
56
77
  */
package/dist/types.d.ts CHANGED
@@ -1,66 +1,16 @@
1
- import { z } from 'astro/zod';
2
- import type { Schema } from 'studiocms/effect';
1
+ import { Schema } from 'studiocms/effect';
3
2
  import type { studioCMSProjectDataSchema } from './schema.js';
4
3
  export interface WysiwygDBContent extends Schema.SimplifyMutable<typeof studioCMSProjectDataSchema.Type> {
5
4
  }
6
5
  /**
7
- * Defines the schema for HTML configuration options.
8
- *
9
- * The schema includes an optional `sanitize` property, which is validated
10
- * using the `StudioCMSSanitizeOptionsSchema`. If no value is provided,
11
- * the default is an empty object.
6
+ * Schema for WYSIWYG configuration options.
12
7
  */
13
- export declare const WYSIWYGSchema: z.ZodDefault<z.ZodOptional<z.ZodObject<{
14
- /** Sanitization options for WYSIWYG content. See {@link StudioCMSSanitizeOptionsSchema} for details. */
15
- sanitize: z.ZodOptional<z.ZodObject<{
16
- allowElements: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
17
- blockElements: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
18
- dropElements: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
19
- allowAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
20
- dropAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
21
- allowComponents: z.ZodOptional<z.ZodBoolean>;
22
- allowCustomElements: z.ZodOptional<z.ZodBoolean>;
23
- allowComments: z.ZodOptional<z.ZodBoolean>;
24
- }, "strip", z.ZodTypeAny, {
25
- allowElements?: string[] | undefined;
26
- blockElements?: string[] | undefined;
27
- dropElements?: string[] | undefined;
28
- allowAttributes?: Record<string, string[]> | undefined;
29
- dropAttributes?: Record<string, string[]> | undefined;
30
- allowComponents?: boolean | undefined;
31
- allowCustomElements?: boolean | undefined;
32
- allowComments?: boolean | undefined;
33
- }, {
34
- allowElements?: string[] | undefined;
35
- blockElements?: string[] | undefined;
36
- dropElements?: string[] | undefined;
37
- allowAttributes?: Record<string, string[]> | undefined;
38
- dropAttributes?: Record<string, string[]> | undefined;
39
- allowComponents?: boolean | undefined;
40
- allowCustomElements?: boolean | undefined;
41
- allowComments?: boolean | undefined;
42
- }>>;
43
- }, "strip", z.ZodTypeAny, {
44
- sanitize?: {
45
- allowElements?: string[] | undefined;
46
- blockElements?: string[] | undefined;
47
- dropElements?: string[] | undefined;
48
- allowAttributes?: Record<string, string[]> | undefined;
49
- dropAttributes?: Record<string, string[]> | undefined;
50
- allowComponents?: boolean | undefined;
51
- allowCustomElements?: boolean | undefined;
52
- allowComments?: boolean | undefined;
53
- } | undefined;
54
- }, {
55
- sanitize?: {
56
- allowElements?: string[] | undefined;
57
- blockElements?: string[] | undefined;
58
- dropElements?: string[] | undefined;
59
- allowAttributes?: Record<string, string[]> | undefined;
60
- dropAttributes?: Record<string, string[]> | undefined;
61
- allowComponents?: boolean | undefined;
62
- allowCustomElements?: boolean | undefined;
63
- allowComments?: boolean | undefined;
64
- } | undefined;
65
- }>>>;
66
- export type WYSIWYGSchemaOptions = z.infer<typeof WYSIWYGSchema>;
8
+ export declare const WYSIWYGSchema: Schema.mutable<Schema.Struct<{
9
+ sanitize: Schema.optionalWith<Schema.declare<import("ultrahtml/transformers/sanitize").SanitizeOptions, import("ultrahtml/transformers/sanitize").SanitizeOptions, readonly [], never>, {
10
+ default: () => {};
11
+ }>;
12
+ }>>;
13
+ /**
14
+ * Type representing the WYSIWYG schema options.
15
+ */
16
+ export type WYSIWYGSchemaOptions = typeof WYSIWYGSchema.Encoded;
package/dist/types.js CHANGED
@@ -1,9 +1,18 @@
1
- import { z } from "astro/zod";
2
- import { StudioCMSSanitizeOptionsSchema } from "studiocms/schemas";
3
- const WYSIWYGSchema = z.object({
4
- /** Sanitization options for WYSIWYG content. See {@link StudioCMSSanitizeOptionsSchema} for details. */
5
- sanitize: StudioCMSSanitizeOptionsSchema
6
- }).optional().default({});
1
+ import { Schema } from "studiocms/effect";
2
+ import { SanitizeOptionsSchema } from "studiocms/schemas";
3
+ const WYSIWYGSchema = Schema.mutable(
4
+ Schema.Struct({
5
+ sanitize: Schema.optionalWith(SanitizeOptionsSchema, {
6
+ default: () => ({})
7
+ }).annotations({
8
+ description: "Sanitization options for WYSIWYG content. See {@link SanitizeOptionsSchema} for details."
9
+ })
10
+ })
11
+ ).annotations({
12
+ title: "WYSIWYG Configuration Options",
13
+ identifier: "WYSIWYGSchema",
14
+ description: "Defines the schema for HTML configuration options."
15
+ });
7
16
  export {
8
17
  WYSIWYGSchema
9
18
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@studiocms/wysiwyg",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Add A WYSIWYG Editor to your StudioCMS project with ease!",
5
5
  "author": {
6
6
  "name": "withstudiocms",
@@ -63,12 +63,12 @@
63
63
  "tui-image-editor": "^3.15.3"
64
64
  },
65
65
  "devDependencies": {
66
- "@studiocms/ui": "^1.0.1",
66
+ "@studiocms/ui": "^1.1.2",
67
67
  "@types/node": "^22.0.0",
68
68
  "astro": "^5.12.9",
69
69
  "vite": "^6.3.4",
70
- "@withstudiocms/component-registry": "^0.1.2",
71
- "studiocms": "^0.2.0"
70
+ "@withstudiocms/component-registry": "^0.1.4",
71
+ "studiocms": "^0.4.0"
72
72
  },
73
73
  "scripts": {
74
74
  "build": "buildkit build 'src/**/*.{ts,astro,css,js}'",