@studiocms/html 0.2.1 → 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.
@@ -9,15 +9,6 @@
9
9
  */
10
10
  declare const renderer: {
11
11
  name: string;
12
- sanitizeOpts: {
13
- allowElements?: string[] | undefined;
14
- blockElements?: string[] | undefined;
15
- dropElements?: string[] | undefined;
16
- allowAttributes?: Record<string, string[]> | undefined;
17
- dropAttributes?: Record<string, string[]> | undefined;
18
- allowComponents?: boolean | undefined;
19
- allowCustomElements?: boolean | undefined;
20
- allowComments?: boolean | undefined;
21
- } | undefined;
12
+ sanitizeOpts: import("ultrahtml/transformers/sanitize").SanitizeOptions | undefined;
22
13
  };
23
14
  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
  /// <reference types="./virtual.d.ts" preserve="true" />
7
- import { type StudioCMSPlugin } from 'studiocms/plugins';
7
+ import type { StudioCMSPluginDef } from 'studiocms/schemas';
8
8
  import { type HTMLSchemaOptions } from './types.js';
9
9
  /**
10
10
  * Creates the StudioCMS HTML plugin.
@@ -15,5 +15,5 @@ import { type HTMLSchemaOptions } from './types.js';
15
15
  * @param options - Optional configuration for the HTML schema.
16
16
  * @returns The StudioCMS plugin configuration object.
17
17
  */
18
- export declare function studiocmsHTML(options?: HTMLSchemaOptions): StudioCMSPlugin;
18
+ export declare function studiocmsHTML(options?: HTMLSchemaOptions): StudioCMSPluginDef;
19
19
  export default studiocmsHTML;
package/dist/index.js CHANGED
@@ -1,21 +1,21 @@
1
1
  import { createResolver } from "astro-integration-kit";
2
+ import { Schema } from "effect";
2
3
  import { definePlugin } from "studiocms/plugins";
3
4
  import { shared } from "./lib/shared.js";
4
5
  import { HTMLSchema } from "./types.js";
5
- function studiocmsHTML(options) {
6
+ function studiocmsHTML(options = {}) {
6
7
  const { resolve } = createResolver(import.meta.url);
7
8
  const packageIdentifier = "@studiocms/html";
8
- const parseResult = HTMLSchema.safeParse(options);
9
- if (!parseResult.success) {
10
- throw new Error(`Invalid HTML options: ${parseResult.error.message}`);
9
+ const parseResult = Schema.decodeEither(HTMLSchema)(options);
10
+ if (parseResult._tag === "Left") {
11
+ throw new Error(`Invalid HTML options: ${parseResult.left.message}`);
11
12
  }
12
- const resolvedOptions = parseResult.data;
13
+ const resolvedOptions = parseResult.right;
13
14
  return definePlugin({
14
15
  identifier: packageIdentifier,
15
16
  name: "StudioCMS HTML",
16
- studiocmsMinimumVersion: "0.1.0-beta.21",
17
17
  hooks: {
18
- "studiocms:astro-config": ({ addIntegrations }) => {
18
+ "studiocms:astro-config": async ({ addIntegrations }) => {
19
19
  addIntegrations({
20
20
  name: packageIdentifier,
21
21
  hooks: {
@@ -25,7 +25,7 @@ function studiocmsHTML(options) {
25
25
  }
26
26
  });
27
27
  },
28
- "studiocms:rendering": ({ setRendering }) => {
28
+ "studiocms:rendering": async ({ setRendering }) => {
29
29
  setRendering({
30
30
  pageTypes: [
31
31
  // Define the HTML page type
package/dist/types.d.ts CHANGED
@@ -1,62 +1,14 @@
1
- import { z } from 'astro/zod';
1
+ import { Schema } from 'studiocms/effect';
2
2
  /**
3
- * Defines the schema for HTML configuration options.
4
- *
5
- * The schema includes an optional `sanitize` property, which is validated
6
- * using the `StudioCMSSanitizeOptionsSchema`. If no value is provided,
7
- * the default is an empty object.
3
+ * Schema definition for HTML configuration in StudioCMS.
8
4
  */
9
- export declare const HTMLSchema: z.ZodDefault<z.ZodOptional<z.ZodObject<{
10
- /** Sanitization options for HTML content. See {@link StudioCMSSanitizeOptionsSchema} for details. */
11
- sanitize: z.ZodOptional<z.ZodObject<{
12
- allowElements: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
13
- blockElements: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
14
- dropElements: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
15
- allowAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
16
- dropAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
17
- allowComponents: z.ZodOptional<z.ZodBoolean>;
18
- allowCustomElements: z.ZodOptional<z.ZodBoolean>;
19
- allowComments: z.ZodOptional<z.ZodBoolean>;
20
- }, "strip", z.ZodTypeAny, {
21
- allowElements?: string[] | undefined;
22
- blockElements?: string[] | undefined;
23
- dropElements?: string[] | undefined;
24
- allowAttributes?: Record<string, string[]> | undefined;
25
- dropAttributes?: Record<string, string[]> | undefined;
26
- allowComponents?: boolean | undefined;
27
- allowCustomElements?: boolean | undefined;
28
- allowComments?: boolean | undefined;
29
- }, {
30
- allowElements?: string[] | undefined;
31
- blockElements?: string[] | undefined;
32
- dropElements?: string[] | undefined;
33
- allowAttributes?: Record<string, string[]> | undefined;
34
- dropAttributes?: Record<string, string[]> | undefined;
35
- allowComponents?: boolean | undefined;
36
- allowCustomElements?: boolean | undefined;
37
- allowComments?: boolean | undefined;
38
- }>>;
39
- }, "strip", z.ZodTypeAny, {
40
- sanitize?: {
41
- allowElements?: string[] | undefined;
42
- blockElements?: string[] | undefined;
43
- dropElements?: string[] | undefined;
44
- allowAttributes?: Record<string, string[]> | undefined;
45
- dropAttributes?: Record<string, string[]> | undefined;
46
- allowComponents?: boolean | undefined;
47
- allowCustomElements?: boolean | undefined;
48
- allowComments?: boolean | undefined;
49
- } | undefined;
50
- }, {
51
- sanitize?: {
52
- allowElements?: string[] | undefined;
53
- blockElements?: string[] | undefined;
54
- dropElements?: string[] | undefined;
55
- allowAttributes?: Record<string, string[]> | undefined;
56
- dropAttributes?: Record<string, string[]> | undefined;
57
- allowComponents?: boolean | undefined;
58
- allowCustomElements?: boolean | undefined;
59
- allowComments?: boolean | undefined;
60
- } | undefined;
61
- }>>>;
62
- export type HTMLSchemaOptions = z.infer<typeof HTMLSchema>;
5
+ export declare const HTMLSchema: Schema.Struct<{
6
+ sanitize: Schema.optionalWith<Schema.declare<import("ultrahtml/transformers/sanitize").SanitizeOptions, import("ultrahtml/transformers/sanitize").SanitizeOptions, readonly [], never>, {
7
+ default: () => {};
8
+ exact: true;
9
+ }>;
10
+ }>;
11
+ /**
12
+ * Type definition for the HTML configuration options in StudioCMS.
13
+ */
14
+ export type HTMLSchemaOptions = typeof HTMLSchema.Encoded;
package/dist/types.js CHANGED
@@ -1,9 +1,20 @@
1
- import { z } from "astro/zod";
2
- import { StudioCMSSanitizeOptionsSchema } from "studiocms/schemas";
3
- const HTMLSchema = z.object({
4
- /** Sanitization options for HTML 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 HTMLSchema = Schema.Struct({
4
+ sanitize: Schema.optionalWith(
5
+ SanitizeOptionsSchema.annotations({
6
+ description: "Sanitization options for HTML content. See StudioCMSSanitizeOptionsSchema for details."
7
+ }),
8
+ {
9
+ default: () => ({}),
10
+ exact: true
11
+ }
12
+ )
13
+ }).annotations({
14
+ description: "The configuration for HTML content in StudioCMS.",
15
+ title: "HTML Configuration",
16
+ identifier: "HTMLSchemaBase"
17
+ });
7
18
  export {
8
19
  HTMLSchema
9
20
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@studiocms/html",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Add HTML Support to your StudioCMS project with ease!",
5
5
  "author": {
6
6
  "name": "withstudiocms",
@@ -62,7 +62,7 @@
62
62
  "dependencies": {
63
63
  "astro-integration-kit": "^0.19.1",
64
64
  "codemirror": "5.65.19",
65
- "katex": "^0.16.28",
65
+ "katex": "^0.16.35",
66
66
  "suneditor": "^2.47.8"
67
67
  },
68
68
  "devDependencies": {
@@ -70,10 +70,10 @@
70
70
  "@types/node": "^22.0.0",
71
71
  "astro": "^5.12.9",
72
72
  "vite": "^6.3.4",
73
- "studiocms": "^0.3.0"
73
+ "studiocms": "^0.4.0"
74
74
  },
75
75
  "peerDependencies": {
76
- "effect": "^3.19.15"
76
+ "effect": "^3.19.19"
77
77
  },
78
78
  "scripts": {
79
79
  "build": "buildkit build 'src/**/*.{ts,astro,css,json,png,d.ts}'",