@cloudcannon/editable-regions 0.0.18 → 0.0.19

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.
@@ -3,6 +3,12 @@ import Editable from "./editable.js";
3
3
 
4
4
  type EditableFocusEvent = CustomEvent<number>;
5
5
 
6
+ export const hasEditableText = <T extends object>(
7
+ el: T,
8
+ ): el is T & { editable: EditableText } => {
9
+ return "editable" in el && el.editable instanceof EditableText;
10
+ };
11
+
6
12
  export default class EditableText extends Editable {
7
13
  editor?: any;
8
14
  focused = false;
package/nodes/editable.ts CHANGED
@@ -3,9 +3,14 @@ import type {
3
3
  CloudCannonVisualEditorAPIV1Dataset,
4
4
  CloudCannonVisualEditorAPIV1File,
5
5
  } from "@cloudcannon/visual-editor-api";
6
- import { hasEditable } from "../helpers/checks";
7
6
  import { apiLoadedPromise, CloudCannon } from "../helpers/cloudcannon.mjs";
8
7
 
8
+ export const hasEditable = <T extends object>(
9
+ el: T,
10
+ ): el is T & { editable: Editable } => {
11
+ return "editable" in el && el.editable instanceof Editable;
12
+ };
13
+
9
14
  declare global {
10
15
  interface HTMLElement {
11
16
  __pendingEditableListeners?: EditableListener[];
package/package.json CHANGED
@@ -1,92 +1,122 @@
1
1
  {
2
- "name": "@cloudcannon/editable-regions",
3
- "version": "0.0.18",
4
- "type": "module",
5
- "description": "Visual Editing for the CloudCannon CMS.",
6
- "keywords": [
7
- "cloudcannon"
8
- ],
9
- "license": "MIT",
10
- "author": "CloudCannon <support@cloudcannon.com>",
11
- "homepage": "https://github.com/CloudCannon/editable-regions#readme",
12
- "repository": {
13
- "type": "git",
14
- "url": "https://github.com/CloudCannon/editable-regions.git"
15
- },
16
- "bugs": {
17
- "url": "https://github.com/CloudCannon/editable-regions/issues",
18
- "email": "support@cloudcannon.com"
19
- },
20
- "scripts": {
21
- "typecheck": "tsc --noEmit",
22
- "typecheck:watch": "tsc --noEmit --watch",
23
- "lint-autofix": "biome check --fix",
24
- "lint": "biome check"
25
- },
26
- "files": [
27
- "components",
28
- "helpers",
29
- "integrations",
30
- "nodes",
31
- "styles",
32
- "types"
33
- ],
34
- "exports": {
35
- "./*": null,
36
- "./astro": {
37
- "types": "./types/astro.d.ts",
38
- "default": "./integrations/astro/index.mjs"
39
- },
40
- "./astro-react-renderer": {
41
- "types": "./types/astro.d.ts",
42
- "default": "./integrations/astro/react-renderer.mjs"
43
- },
44
- "./astro-integration": {
45
- "types": "./types/astro.d.ts",
46
- "default": "./integrations/astro/astro-integration.mjs"
47
- },
48
- "./react": {
49
- "types": "./types/react.d.ts",
50
- "default": "./integrations/react.mjs"
51
- },
52
- "./svelte": {
53
- "types": "./types/svelte.d.ts",
54
- "default": "./integrations/svelte.mjs"
55
- },
56
- "./astro-svelte-renderer": {
57
- "types": "./types/astro.d.ts",
58
- "default": "./integrations/astro/svelte-renderer.mjs"
59
- },
60
- "./liquid": "./integrations/liquid/index.mjs",
61
- "./eleventy": {
62
- "require": {
63
- "types": "./types/eleventy.d.cts",
64
- "default": "./integrations/eleventy/index.cjs"
65
- },
66
- "import": {
67
- "types": "./types/eleventy.d.ts",
68
- "default": "./integrations/eleventy/index.mjs"
69
- }
70
- },
71
- "./eleventy/browser": "./integrations/eleventy/browser/index.mjs",
72
- "./internal/components": "./components/index.js",
73
- "./internal/styles": "./styles/index.js"
74
- },
75
- "devDependencies": {
76
- "@biomejs/biome": "2.5.3",
77
- "@cloudcannon/visual-editor-api": "0.0.19",
78
- "@sindresorhus/slugify": "3.0.0",
79
- "@types/js-beautify": "1.14.3",
80
- "@types/node": "26.1.1",
81
- "@types/react": "19.2.17",
82
- "@types/react-dom": "19.2.3",
83
- "astro": "7.0.7",
84
- "js-beautify": "2.0.3",
85
- "liquidjs": "10.27.2",
86
- "slugify": "1.6.9",
87
- "typescript": "6.0.3"
88
- },
89
- "dependencies": {
90
- "esbuild": "0.28.1"
91
- }
2
+ "name": "@cloudcannon/editable-regions",
3
+ "version": "0.0.19",
4
+ "type": "module",
5
+ "description": "Visual Editing for the CloudCannon CMS.",
6
+ "keywords": [
7
+ "cloudcannon"
8
+ ],
9
+ "license": "MIT",
10
+ "author": "CloudCannon <support@cloudcannon.com>",
11
+ "engines": {
12
+ "node": ">=20.19.0"
13
+ },
14
+ "homepage": "https://github.com/CloudCannon/editable-regions#readme",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/CloudCannon/editable-regions.git"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/CloudCannon/editable-regions/issues",
21
+ "email": "support@cloudcannon.com"
22
+ },
23
+ "scripts": {
24
+ "typecheck": "tsc --noEmit",
25
+ "typecheck:watch": "tsc --noEmit --watch",
26
+ "lint-autofix": "biome check --fix",
27
+ "lint": "biome check",
28
+ "test": "vitest run",
29
+ "test:watch": "vitest",
30
+ "test:update-snapshots": "vitest run -u",
31
+ "test:build-fixtures": "npm run test:build-astro-fixture && npm run test:build-eleventy-fixture && npm run test:build-eleventy-plugin-config",
32
+ "test:build-astro-fixture": "npm --prefix test/unit/_fixtures/astro install --silent && npm --prefix test/unit/_fixtures/astro run build",
33
+ "test:build-eleventy-fixture": "npm --prefix test/unit/_fixtures/eleventy install --silent && npm --prefix test/unit/_fixtures/eleventy run build",
34
+ "test:build-eleventy-plugin-config": "npm --prefix test/unit/_fixtures/eleventy-plugin-config install --silent && npm --prefix test/unit/_fixtures/eleventy-plugin-config run build"
35
+ },
36
+ "files": [
37
+ "components",
38
+ "helpers",
39
+ "integrations",
40
+ "nodes",
41
+ "styles",
42
+ "types"
43
+ ],
44
+ "exports": {
45
+ "./*": null,
46
+ "./astro": {
47
+ "types": "./types/astro.d.ts",
48
+ "default": "./integrations/astro/index.mjs"
49
+ },
50
+ "./astro-react-renderer": {
51
+ "types": "./types/astro.d.ts",
52
+ "default": "./integrations/astro/react-renderer.mjs"
53
+ },
54
+ "./astro-svelte-renderer": {
55
+ "types": "./types/astro.d.ts",
56
+ "default": "./integrations/astro/svelte-renderer.mjs"
57
+ },
58
+ "./astro-vue-renderer": {
59
+ "types": "./types/astro.d.ts",
60
+ "default": "./integrations/astro/vue-renderer.mjs"
61
+ },
62
+ "./astro-integration": {
63
+ "types": "./types/astro.d.ts",
64
+ "default": "./integrations/astro/astro-integration.mjs"
65
+ },
66
+ "./react": {
67
+ "types": "./types/react.d.ts",
68
+ "default": "./integrations/react.mjs"
69
+ },
70
+ "./svelte": {
71
+ "types": "./types/svelte.d.ts",
72
+ "default": "./integrations/svelte.mjs"
73
+ },
74
+ "./vue": {
75
+ "types": "./types/vue.d.ts",
76
+ "default": "./integrations/vue.mjs"
77
+ },
78
+ "./liquid": "./integrations/liquid/index.mjs",
79
+ "./eleventy": {
80
+ "require": {
81
+ "types": "./types/eleventy.d.cts",
82
+ "default": "./integrations/eleventy/index.cjs"
83
+ },
84
+ "import": {
85
+ "types": "./types/eleventy.d.ts",
86
+ "default": "./integrations/eleventy/index.mjs"
87
+ }
88
+ },
89
+ "./eleventy/browser": "./integrations/eleventy/browser/index.mjs",
90
+ "./internal/components": "./components/index.js",
91
+ "./internal/styles": "./styles/index.js"
92
+ },
93
+ "devDependencies": {
94
+ "@astrojs/react": "6.0.1",
95
+ "@astrojs/svelte": "9.0.1",
96
+ "@astrojs/vue": "7.0.1",
97
+ "@biomejs/biome": "2.5.5",
98
+ "@cloudcannon/visual-editor-api": "0.0.19",
99
+ "@sindresorhus/slugify": "3.0.0",
100
+ "@sveltejs/vite-plugin-svelte": "7.2.0",
101
+ "@types/js-beautify": "1.14.3",
102
+ "@types/node": "26.1.2",
103
+ "@types/react": "19.2.17",
104
+ "@types/react-dom": "19.2.3",
105
+ "@vitejs/plugin-vue": "6.0.8",
106
+ "astro": "7.1.4",
107
+ "happy-dom": "20.11.1",
108
+ "js-beautify": "2.0.3",
109
+ "liquidjs": "10.27.2",
110
+ "react": "19.2.8",
111
+ "react-dom": "19.2.8",
112
+ "slugify": "1.6.9",
113
+ "svelte": "5.56.8",
114
+ "typescript": "6.0.3",
115
+ "vitest": "4.1.10",
116
+ "vue": "3.5.40",
117
+ "vue-tsc": "3.3.8"
118
+ },
119
+ "dependencies": {
120
+ "esbuild": "0.28.1"
121
+ }
92
122
  }
package/types/astro.d.ts CHANGED
@@ -21,3 +21,7 @@ declare module "@cloudcannon/editable-regions/astro-react-renderer" {
21
21
  declare module "@cloudcannon/editable-regions/astro-svelte-renderer" {
22
22
  // Side-effect only module that registers Svelte renderer
23
23
  }
24
+
25
+ declare module "@cloudcannon/editable-regions/astro-vue-renderer" {
26
+ // Side-effect only module that registers Vue renderer
27
+ }
@@ -17,10 +17,17 @@ export interface LiquidOptions {
17
17
  configPath?: string;
18
18
  /**
19
19
  * Extra bare module specifiers to stub out of the browser bundle, on top of
20
- * the 11ty toolchain and Node built-ins (always stubbed). Use this when the
21
- * config imports a native/Node-only package (e.g. `sharp`) that no
22
- * browser-bound helper actually calls at render time but that would
23
- * otherwise break bundling.
20
+ * the 11ty toolchain and Node built-ins (always stubbed). Two uses:
21
+ *
22
+ * - a native/Node-only package (e.g. `sharp`) that would otherwise break
23
+ * bundling;
24
+ * - a Node-only package the config *calls* at config time, such as a
25
+ * plugin factory in `addPlugin(pluginFoo({ … }))`. The argument is
26
+ * evaluated before `addPlugin` is reached, so stubbing the module is the
27
+ * only way to stop it aborting the auto-mirror replay.
28
+ *
29
+ * A stubbed module called during the replay is skipped with a warning; the
30
+ * same call from a rendered helper still throws.
24
31
  */
25
32
  browserStub?: string[];
26
33
  /**
package/types/liquid.d.ts CHANGED
@@ -31,7 +31,6 @@ declare module "@cloudcannon/editable-regions/liquid" {
31
31
  name: string,
32
32
  factory: (liquidEngine: Liquid) => any,
33
33
  ): void;
34
- export function registerProcessEnv(env: Record<string, string>): void;
35
34
  export function registerEleventyData(data: {
36
35
  version: string;
37
36
  generator: string;
package/types/vue.d.ts ADDED
@@ -0,0 +1,40 @@
1
+ /// <reference path="./cloudcannon.d.ts" />
2
+
3
+ import type { HTMLAttributes } from "vue";
4
+
5
+ export function registerVueComponent(key: string, component: unknown): void;
6
+
7
+ declare global {
8
+ namespace JSX {
9
+ interface IntrinsicElements {
10
+ "editable-component": HTMLAttributes & {
11
+ class?: string;
12
+ "data-prop": string;
13
+ "data-component": string;
14
+ };
15
+ "editable-text": HTMLAttributes & {
16
+ class?: string;
17
+ "data-prop": string;
18
+ "data-type"?: "block" | "text" | "span";
19
+ };
20
+ "editable-source": HTMLAttributes & {
21
+ class?: string;
22
+ "data-path": string;
23
+ "data-key": string;
24
+ };
25
+ "editable-array": HTMLAttributes & {
26
+ class?: string;
27
+ "data-prop": string;
28
+ "data-id-key"?: string;
29
+ "data-component-key"?: string;
30
+ "data-component"?: string;
31
+ "data-direction"?: "column" | "row" | "column-reverse" | "row-reverse";
32
+ };
33
+ "editable-array-item": HTMLAttributes & {
34
+ class?: string;
35
+ "data-id"?: string;
36
+ "data-component"?: string;
37
+ };
38
+ }
39
+ }
40
+ }