@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.
- package/helpers/checks.ts +0 -22
- package/helpers/hydrate-editable-regions.ts +2 -1
- package/integrations/astro/react-renderer.mjs +94 -19
- package/integrations/astro/svelte-renderer.mjs +72 -15
- package/integrations/astro/vue-renderer.mjs +61 -0
- package/integrations/eleventy/browser/collect-config.mjs +69 -8
- package/integrations/eleventy/browser/inert.mjs +35 -0
- package/integrations/eleventy/browser/process-shim.mjs +32 -0
- package/integrations/eleventy/browser/stub-mode.mjs +61 -0
- package/integrations/eleventy/index.cjs +28 -1
- package/integrations/eleventy/index.mjs +82 -30
- package/integrations/liquid/README.md +92 -3
- package/integrations/liquid/errors.mjs +3 -1
- package/integrations/liquid/fs.mjs +11 -1
- package/integrations/liquid/globals.mjs +124 -25
- package/integrations/liquid/index.mjs +5 -2
- package/integrations/vue.mjs +28 -0
- package/nodes/editable-array-item.ts +6 -1
- package/nodes/editable-component.ts +2 -3
- package/nodes/editable-text.ts +6 -0
- package/nodes/editable.ts +6 -1
- package/package.json +120 -90
- package/types/astro.d.ts +4 -0
- package/types/eleventy.d.ts +11 -4
- package/types/liquid.d.ts +0 -1
- package/types/vue.d.ts +40 -0
package/nodes/editable-text.ts
CHANGED
|
@@ -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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
+
}
|
package/types/eleventy.d.ts
CHANGED
|
@@ -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).
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
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
|
+
}
|