@cloudcannon/editable-regions 0.0.2
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/LICENSE +5 -0
- package/README.md +5 -0
- package/components/editable-array-component.ts +26 -0
- package/components/editable-array-item-component.ts +26 -0
- package/components/editable-component-component.ts +26 -0
- package/components/editable-image-component.ts +26 -0
- package/components/editable-snippet-component.ts +30 -0
- package/components/editable-source-component.ts +26 -0
- package/components/editable-text-component.ts +26 -0
- package/components/index.ts +35 -0
- package/components/ui/editable-array-item-controls.ts +123 -0
- package/components/ui/editable-component-controls.ts +57 -0
- package/components/ui/editable-region-error-card.ts +77 -0
- package/helpers/checks.ts +126 -0
- package/helpers/cloudcannon.ts +67 -0
- package/helpers/hydrate-editable-regions.ts +71 -0
- package/integrations/astro/astro-integration.mjs +110 -0
- package/integrations/astro/index.mjs +193 -0
- package/integrations/astro/modules/actions.js +74 -0
- package/integrations/astro/modules/assets.js +38 -0
- package/integrations/astro/modules/client-router.astro +5 -0
- package/integrations/astro/modules/content.js +116 -0
- package/integrations/astro/modules/i18n.js +76 -0
- package/integrations/astro/modules/image.astro +33 -0
- package/integrations/astro/modules/middleware.js +27 -0
- package/integrations/astro/modules/picture.astro +7 -0
- package/integrations/astro/modules/transitions.js +63 -0
- package/integrations/astro/react-renderer.mjs +40 -0
- package/integrations/react.mjs +32 -0
- package/nodes/editable-array-item.ts +427 -0
- package/nodes/editable-array.ts +241 -0
- package/nodes/editable-component.ts +273 -0
- package/nodes/editable-image.ts +253 -0
- package/nodes/editable-snippet.ts +148 -0
- package/nodes/editable-source.ts +245 -0
- package/nodes/editable-text.ts +163 -0
- package/nodes/editable.ts +471 -0
- package/nodes/index.ts +8 -0
- package/package.json +64 -0
- package/styles/editable-array-item.css +8 -0
- package/styles/editable-component.css +8 -0
- package/styles/editable-image.css +4 -0
- package/styles/editable-snippet.css +12 -0
- package/styles/editable-source.css +3 -0
- package/styles/editable-text.css +3 -0
- package/styles/index.css +101 -0
- package/styles/index.ts +6 -0
- package/styles/ui/editable-component-controls.css +104 -0
- package/styles/ui/editable-region-error-card.css +25 -0
- package/types/astro.d.ts +19 -0
- package/types/cloudcannon.d.ts +11 -0
- package/types/modules.d.ts +12 -0
- package/types/react.d.ts +5 -0
- package/types/vite.d.ts +9 -0
package/styles/index.css
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
@import "./editable-array-item.css";
|
|
2
|
+
@import "./editable-text.css";
|
|
3
|
+
@import "./editable-component.css";
|
|
4
|
+
@import "./editable-image.css";
|
|
5
|
+
@import "./editable-source.css";
|
|
6
|
+
@import "./editable-snippet.css";
|
|
7
|
+
|
|
8
|
+
editable-array-item-controls,
|
|
9
|
+
editable-component-controls {
|
|
10
|
+
transition: opacity var(--ccve-transition-duration) ease;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
editable-array-item,
|
|
14
|
+
editable-text,
|
|
15
|
+
editable-component,
|
|
16
|
+
editable-image,
|
|
17
|
+
editable-source,
|
|
18
|
+
editable-snippet,
|
|
19
|
+
[data-editable="array-item"],
|
|
20
|
+
[data-editable="text"],
|
|
21
|
+
[data-editable="component"],
|
|
22
|
+
[data-editable="image"],
|
|
23
|
+
[data-editable="source"] {
|
|
24
|
+
transition: outline var(--ccve-transition-duration) ease;
|
|
25
|
+
|
|
26
|
+
outline-offset: calc(var(--ccve-editable-outline-width) * -1);
|
|
27
|
+
outline: var(--ccve-editable-outline-width) solid transparent;
|
|
28
|
+
|
|
29
|
+
& > editable-array-item-controls,
|
|
30
|
+
& > editable-component-controls {
|
|
31
|
+
opacity: 0;
|
|
32
|
+
pointer-events: none;
|
|
33
|
+
display: none;
|
|
34
|
+
|
|
35
|
+
&:hover,
|
|
36
|
+
&[open="true"] {
|
|
37
|
+
opacity: 1;
|
|
38
|
+
pointer-events: auto;
|
|
39
|
+
display: flex;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&.errored {
|
|
44
|
+
outline: none !important;
|
|
45
|
+
cursor: default !important;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&.dragover * {
|
|
49
|
+
opacity: 0.8;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.cms-region-highlighted {
|
|
54
|
+
editable-array-item,
|
|
55
|
+
editable-text,
|
|
56
|
+
editable-component,
|
|
57
|
+
editable-image,
|
|
58
|
+
editable-source,
|
|
59
|
+
editable-snippet,
|
|
60
|
+
[data-editable="array-item"],
|
|
61
|
+
[data-editable="text"],
|
|
62
|
+
[data-editable="component"],
|
|
63
|
+
[data-editable="image"],
|
|
64
|
+
[data-editable="source"] {
|
|
65
|
+
outline: var(--ccve-editable-outline-width) solid var(--ccve-color-sol);
|
|
66
|
+
|
|
67
|
+
&:hover {
|
|
68
|
+
outline: var(--ccve-editable-outline-width) solid
|
|
69
|
+
var(--ccve-color-emerald);
|
|
70
|
+
|
|
71
|
+
& > editable-array-item-controls,
|
|
72
|
+
& > editable-component-controls {
|
|
73
|
+
opacity: 1;
|
|
74
|
+
pointer-events: auto;
|
|
75
|
+
display: flex;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.dragging {
|
|
82
|
+
& editable-array-item,
|
|
83
|
+
& editable-text,
|
|
84
|
+
& editable-component,
|
|
85
|
+
& editable-image,
|
|
86
|
+
& editable-source,
|
|
87
|
+
& editable-snippet,
|
|
88
|
+
& [data-editable="array-item"],
|
|
89
|
+
& [data-editable="text"],
|
|
90
|
+
& [data-editable="component"],
|
|
91
|
+
& [data-editable="image"],
|
|
92
|
+
& [data-editable="source"] {
|
|
93
|
+
transition: none;
|
|
94
|
+
outline: none;
|
|
95
|
+
|
|
96
|
+
&:hover {
|
|
97
|
+
transition: none;
|
|
98
|
+
outline: none;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
package/styles/index.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
position: absolute;
|
|
3
|
+
z-index: 99999999999;
|
|
4
|
+
top: var(--ccve-editable-outline-width);
|
|
5
|
+
right: var(--ccve-editable-outline-width);
|
|
6
|
+
text-rendering: geometricprecision;
|
|
7
|
+
-webkit-font-smoothing: antialiased;
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
align-items: end;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.button-row {
|
|
14
|
+
display: flex;
|
|
15
|
+
background: #fff;
|
|
16
|
+
gap: 12px;
|
|
17
|
+
padding: 6px;
|
|
18
|
+
margin: 4px;
|
|
19
|
+
border-radius: var(--ccve-border-radius);
|
|
20
|
+
width: fit-content;
|
|
21
|
+
border: 1px solid #eee;
|
|
22
|
+
box-shadow: 0 0 16px rgba(0, 0, 0, 0.1);
|
|
23
|
+
|
|
24
|
+
& button {
|
|
25
|
+
width: 36px;
|
|
26
|
+
height: 36px;
|
|
27
|
+
|
|
28
|
+
&:hover {
|
|
29
|
+
background-color: var(--ccve-color-cc-blue);
|
|
30
|
+
--cc-icon-fill: var(--ccve-color-cloud);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.context-menu {
|
|
36
|
+
animation: fade-in-up ease 0.2s;
|
|
37
|
+
border-radius: var(--ccve-border-radius);
|
|
38
|
+
background: #fff;
|
|
39
|
+
gap: 12px;
|
|
40
|
+
padding: 10px 6px;
|
|
41
|
+
margin: 4px;
|
|
42
|
+
width: 154px;
|
|
43
|
+
border: 1px solid #eee;
|
|
44
|
+
box-shadow: 0 0 16px rgba(0, 0, 0, 0.1);
|
|
45
|
+
border: 2px solid #cfcfcf;
|
|
46
|
+
display: none;
|
|
47
|
+
pointer-events: none;
|
|
48
|
+
|
|
49
|
+
& li {
|
|
50
|
+
list-style: none;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
& button {
|
|
54
|
+
line-height: 24px;
|
|
55
|
+
padding: 10px;
|
|
56
|
+
gap: 10px;
|
|
57
|
+
max-width: 100%;
|
|
58
|
+
display: flex;
|
|
59
|
+
align-items: center;
|
|
60
|
+
font-family: "TT Norms Pro", helvetica, arial, sans-serif;
|
|
61
|
+
font-size: 16px;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&.open {
|
|
65
|
+
display: block;
|
|
66
|
+
pointer-events: auto;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
button {
|
|
71
|
+
background-color: transparent;
|
|
72
|
+
border: 0;
|
|
73
|
+
padding: 0;
|
|
74
|
+
|
|
75
|
+
border-radius: var(--ccve-border-radius);
|
|
76
|
+
cursor: pointer;
|
|
77
|
+
|
|
78
|
+
&[draggable="true"] {
|
|
79
|
+
cursor: grab;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&:disabled {
|
|
83
|
+
color: #979797;
|
|
84
|
+
--cc-icon-fill: #979797;
|
|
85
|
+
cursor: not-allowed;
|
|
86
|
+
|
|
87
|
+
&:hover {
|
|
88
|
+
background-color: transparent;
|
|
89
|
+
--cc-icon-fill: #979797;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@keyframes fade-in-up {
|
|
95
|
+
from {
|
|
96
|
+
opacity: 0.5;
|
|
97
|
+
transform: scale(0.9);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
to {
|
|
101
|
+
opacity: 1;
|
|
102
|
+
transform: scale(1);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
all: initial;
|
|
3
|
+
font-family: var(--ccrt-font-family);
|
|
4
|
+
|
|
5
|
+
display: flex;
|
|
6
|
+
background-color: #ffe7ea;
|
|
7
|
+
border-radius: var(--ccve-border-radius);
|
|
8
|
+
padding: var(--ccrt-gap);
|
|
9
|
+
margin: 2px;
|
|
10
|
+
border: 2px solid var(--ccve-color-ruby);
|
|
11
|
+
gap: var(--ccrt-gap);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.heading {
|
|
15
|
+
font-size: 1.15em;
|
|
16
|
+
margin-top: 0px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
pre {
|
|
20
|
+
margin-bottom: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
cc-icon {
|
|
24
|
+
--cc-icon-fill: var(--ccve-color-ruby);
|
|
25
|
+
}
|
package/types/astro.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference path="./cloudcannon.d.ts" />
|
|
2
|
+
|
|
3
|
+
declare module "@cloudcannon/editable-regions/astro-integration" {
|
|
4
|
+
import type { AstroIntegration } from "astro";
|
|
5
|
+
|
|
6
|
+
export default function (): AstroIntegration;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare module "@cloudcannon/editable-regions/astro" {
|
|
10
|
+
export function registerAstroComponent(key: string, component: unknown): void;
|
|
11
|
+
export function addFrameworkRenderer(renderer: any): void;
|
|
12
|
+
export function queueForClientSideRender(
|
|
13
|
+
renderFunction: (node: Element) => void,
|
|
14
|
+
): number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare module "@cloudcannon/editable-regions/astro-react-renderer" {
|
|
18
|
+
// Side-effect only module that registers React renderer
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare module "astro/runtime/server/index.js" {
|
|
2
|
+
export function renderSlotToString(result: any, slot: any): string;
|
|
3
|
+
export function renderToString(
|
|
4
|
+
result: any,
|
|
5
|
+
component: any,
|
|
6
|
+
props: any,
|
|
7
|
+
slots: any,
|
|
8
|
+
): Promise<string>;
|
|
9
|
+
}
|
|
10
|
+
declare module "react-dom/server.browser" {
|
|
11
|
+
export function renderToStaticMarkup(element: any): string;
|
|
12
|
+
}
|
package/types/react.d.ts
ADDED