@astro-live-cms/core 0.2.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.
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +122 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/auth/session.d.ts +14 -0
- package/dist/runtime/auth/session.d.ts.map +1 -0
- package/dist/runtime/auth/session.js +77 -0
- package/dist/runtime/auth/session.js.map +1 -0
- package/dist/runtime/bind.d.ts +14 -0
- package/dist/runtime/bind.d.ts.map +1 -0
- package/dist/runtime/bind.js +11 -0
- package/dist/runtime/bind.js.map +1 -0
- package/dist/runtime/config.d.ts +6 -0
- package/dist/runtime/config.d.ts.map +1 -0
- package/dist/runtime/config.js +18 -0
- package/dist/runtime/config.js.map +1 -0
- package/dist/runtime/content.d.ts +30 -0
- package/dist/runtime/content.d.ts.map +1 -0
- package/dist/runtime/content.js +48 -0
- package/dist/runtime/content.js.map +1 -0
- package/dist/runtime/index.d.ts +10 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +12 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/markers.d.ts +17 -0
- package/dist/runtime/markers.d.ts.map +1 -0
- package/dist/runtime/markers.js +17 -0
- package/dist/runtime/markers.js.map +1 -0
- package/dist/runtime/middleware.d.ts +12 -0
- package/dist/runtime/middleware.d.ts.map +1 -0
- package/dist/runtime/middleware.js +37 -0
- package/dist/runtime/middleware.js.map +1 -0
- package/dist/runtime/mutations/contracts.d.ts +57 -0
- package/dist/runtime/mutations/contracts.d.ts.map +1 -0
- package/dist/runtime/mutations/contracts.js +242 -0
- package/dist/runtime/mutations/contracts.js.map +1 -0
- package/dist/runtime/mutations/engine.d.ts +23 -0
- package/dist/runtime/mutations/engine.d.ts.map +1 -0
- package/dist/runtime/mutations/engine.js +161 -0
- package/dist/runtime/mutations/engine.js.map +1 -0
- package/dist/runtime/routes/_helpers.d.ts +6 -0
- package/dist/runtime/routes/_helpers.d.ts.map +1 -0
- package/dist/runtime/routes/_helpers.js +23 -0
- package/dist/runtime/routes/_helpers.js.map +1 -0
- package/dist/runtime/routes/admin.d.ts +3 -0
- package/dist/runtime/routes/admin.d.ts.map +1 -0
- package/dist/runtime/routes/admin.js +110 -0
- package/dist/runtime/routes/admin.js.map +1 -0
- package/dist/runtime/routes/auth-login.d.ts +4 -0
- package/dist/runtime/routes/auth-login.d.ts.map +1 -0
- package/dist/runtime/routes/auth-login.js +66 -0
- package/dist/runtime/routes/auth-login.js.map +1 -0
- package/dist/runtime/routes/auth-logout.d.ts +4 -0
- package/dist/runtime/routes/auth-logout.d.ts.map +1 -0
- package/dist/runtime/routes/auth-logout.js +51 -0
- package/dist/runtime/routes/auth-logout.js.map +1 -0
- package/dist/runtime/routes/editor-assets.d.ts +3 -0
- package/dist/runtime/routes/editor-assets.d.ts.map +1 -0
- package/dist/runtime/routes/editor-assets.js +47 -0
- package/dist/runtime/routes/editor-assets.js.map +1 -0
- package/dist/runtime/routes/entries.d.ts +3 -0
- package/dist/runtime/routes/entries.d.ts.map +1 -0
- package/dist/runtime/routes/entries.js +89 -0
- package/dist/runtime/routes/entries.js.map +1 -0
- package/dist/runtime/routes/history.d.ts +4 -0
- package/dist/runtime/routes/history.d.ts.map +1 -0
- package/dist/runtime/routes/history.js +56 -0
- package/dist/runtime/routes/history.js.map +1 -0
- package/dist/runtime/routes/mutate.d.ts +4 -0
- package/dist/runtime/routes/mutate.d.ts.map +1 -0
- package/dist/runtime/routes/mutate.js +35 -0
- package/dist/runtime/routes/mutate.js.map +1 -0
- package/dist/runtime/routes/schema.d.ts +3 -0
- package/dist/runtime/routes/schema.d.ts.map +1 -0
- package/dist/runtime/routes/schema.js +27 -0
- package/dist/runtime/routes/schema.js.map +1 -0
- package/dist/runtime/routes/studio-home.d.ts +3 -0
- package/dist/runtime/routes/studio-home.d.ts.map +1 -0
- package/dist/runtime/routes/studio-home.js +174 -0
- package/dist/runtime/routes/studio-home.js.map +1 -0
- package/dist/runtime/routes/theme-bootstrap.d.ts +4 -0
- package/dist/runtime/routes/theme-bootstrap.d.ts.map +1 -0
- package/dist/runtime/routes/theme-bootstrap.js +65 -0
- package/dist/runtime/routes/theme-bootstrap.js.map +1 -0
- package/dist/runtime/routes/theme-factory.d.ts +3 -0
- package/dist/runtime/routes/theme-factory.d.ts.map +1 -0
- package/dist/runtime/routes/theme-factory.js +142 -0
- package/dist/runtime/routes/theme-factory.js.map +1 -0
- package/dist/runtime/routes/upload.d.ts +3 -0
- package/dist/runtime/routes/upload.d.ts.map +1 -0
- package/dist/runtime/routes/upload.js +29 -0
- package/dist/runtime/routes/upload.js.map +1 -0
- package/dist/runtime/schema/infer-json-schema.d.ts +12 -0
- package/dist/runtime/schema/infer-json-schema.d.ts.map +1 -0
- package/dist/runtime/schema/infer-json-schema.js +75 -0
- package/dist/runtime/schema/infer-json-schema.js.map +1 -0
- package/dist/runtime/storage/filesystem-adapter.d.ts +29 -0
- package/dist/runtime/storage/filesystem-adapter.d.ts.map +1 -0
- package/dist/runtime/storage/filesystem-adapter.js +182 -0
- package/dist/runtime/storage/filesystem-adapter.js.map +1 -0
- package/dist/runtime/storage/filesystem-upload-handler.d.ts +11 -0
- package/dist/runtime/storage/filesystem-upload-handler.d.ts.map +1 -0
- package/dist/runtime/storage/filesystem-upload-handler.js +37 -0
- package/dist/runtime/storage/filesystem-upload-handler.js.map +1 -0
- package/dist/runtime/storage/in-memory-adapter.d.ts +24 -0
- package/dist/runtime/storage/in-memory-adapter.d.ts.map +1 -0
- package/dist/runtime/storage/in-memory-adapter.js +78 -0
- package/dist/runtime/storage/in-memory-adapter.js.map +1 -0
- package/dist/runtime/themes/preset-catalog.d.ts +9 -0
- package/dist/runtime/themes/preset-catalog.d.ts.map +1 -0
- package/dist/runtime/themes/preset-catalog.js +47 -0
- package/dist/runtime/themes/preset-catalog.js.map +1 -0
- package/dist/runtime/utils.d.ts +6 -0
- package/dist/runtime/utils.d.ts.map +1 -0
- package/dist/runtime/utils.js +29 -0
- package/dist/runtime/utils.js.map +1 -0
- package/dist/types.d.ts +28 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/vite/virtual-config-plugin.d.ts +7 -0
- package/dist/vite/virtual-config-plugin.d.ts.map +1 -0
- package/dist/vite/virtual-config-plugin.js +25 -0
- package/dist/vite/virtual-config-plugin.js.map +1 -0
- package/package.json +35 -0
- package/static/cms/editor/config.js +6 -0
- package/static/cms/editor/guards.js +68 -0
- package/static/cms/editor/helpers.js +16 -0
- package/static/cms/editor/image-edit.js +148 -0
- package/static/cms/editor/image-utils.js +84 -0
- package/static/cms/editor/image.css +133 -0
- package/static/cms/editor/link-ui.css +143 -0
- package/static/cms/editor/linkify.js +55 -0
- package/static/cms/editor/panel.css +91 -0
- package/static/cms/editor/panel.js +64 -0
- package/static/cms/editor/save-queue.js +167 -0
- package/static/cms/editor/section-controls/activation.js +10 -0
- package/static/cms/editor/section-controls/api.js +88 -0
- package/static/cms/editor/section-controls/constants.js +24 -0
- package/static/cms/editor/section-controls/index.js +622 -0
- package/static/cms/editor/section-controls/model.js +76 -0
- package/static/cms/editor/section-controls/mutations.js +112 -0
- package/static/cms/editor/section-controls/page-context.js +34 -0
- package/static/cms/editor/section-controls/pickers.js +196 -0
- package/static/cms/editor/section-controls/reorder.js +92 -0
- package/static/cms/editor/section-controls/selection.js +54 -0
- package/static/cms/editor/section-controls/spacing-drag.js +83 -0
- package/static/cms/editor/section-controls/ui-elements.js +54 -0
- package/static/cms/editor/section-controls/utils.js +35 -0
- package/static/cms/editor/section-controls.css +349 -0
- package/static/cms/editor/section-controls.js +1 -0
- package/static/cms/editor/security.js +23 -0
- package/static/cms/editor/sync.js +64 -0
- package/static/cms/editor/text-edit.js +129 -0
- package/static/cms/editor/text-link-interactions.js +191 -0
- package/static/cms/editor/toast.css +50 -0
- package/static/cms/editor/toast.js +29 -0
- package/static/cms/editor/tokens-and-text.css +94 -0
- package/static/cms/editor/toolbar.css +261 -0
- package/static/cms/editor/toolbar.js +110 -0
- package/static/cms/editor.css +10 -0
- package/static/cms/editor.js +101 -0
- package/static/cms/studio.css +312 -0
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/* ---------------------------------------------------------------------------
|
|
2
|
+
Section controls (on-canvas layout actions)
|
|
3
|
+
--------------------------------------------------------------------------- */
|
|
4
|
+
|
|
5
|
+
.cms-section-editable {
|
|
6
|
+
outline: 2px dashed transparent;
|
|
7
|
+
outline-offset: 2px;
|
|
8
|
+
transition: outline-color 0.2s ease, box-shadow 0.2s ease;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.cms-section-editable:hover {
|
|
12
|
+
outline-color: rgba(212, 175, 55, 0.45);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.cms-section-editable.cms-section-active {
|
|
16
|
+
outline-color: rgba(212, 175, 55, 0.85);
|
|
17
|
+
box-shadow: inset 0 0 0 1px rgba(212, 175, 55, 0.28);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.cms-section-editable.cms-section-disabled-preview {
|
|
21
|
+
opacity: 0.58;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.cms-section-editable.cms-section-disabled-preview .cms-section-controls,
|
|
25
|
+
.cms-section-editable.cms-section-disabled-preview .cms-section-chip {
|
|
26
|
+
opacity: 1;
|
|
27
|
+
transform: translateY(0);
|
|
28
|
+
pointer-events: auto;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.cms-highlight-all .cms-section-editable {
|
|
32
|
+
outline-color: rgba(212, 175, 55, 0.35);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.cms-section-controls {
|
|
36
|
+
position: absolute;
|
|
37
|
+
top: 12px;
|
|
38
|
+
right: 12px;
|
|
39
|
+
z-index: 1200;
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
gap: 10px;
|
|
43
|
+
padding: 6px 8px;
|
|
44
|
+
border-radius: 6px;
|
|
45
|
+
background: rgba(15, 26, 51, 0.9);
|
|
46
|
+
border: 1px solid rgba(212, 175, 55, 0.22);
|
|
47
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
|
|
48
|
+
backdrop-filter: blur(4px);
|
|
49
|
+
opacity: 0;
|
|
50
|
+
transform: translateY(-4px);
|
|
51
|
+
transition: opacity 0.18s ease, transform 0.18s ease;
|
|
52
|
+
pointer-events: none;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.cms-section-editable:hover .cms-section-controls,
|
|
56
|
+
.cms-section-editable.cms-section-active .cms-section-controls,
|
|
57
|
+
.cms-section-controls:focus-within {
|
|
58
|
+
opacity: 1;
|
|
59
|
+
transform: translateY(0);
|
|
60
|
+
pointer-events: auto;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.cms-section-chip {
|
|
64
|
+
position: absolute;
|
|
65
|
+
top: 12px;
|
|
66
|
+
left: 12px;
|
|
67
|
+
z-index: 1198;
|
|
68
|
+
padding: 4px 8px;
|
|
69
|
+
border-radius: 999px;
|
|
70
|
+
font-family: var(--cms-font);
|
|
71
|
+
font-size: 9px;
|
|
72
|
+
font-weight: 700;
|
|
73
|
+
letter-spacing: 0.08em;
|
|
74
|
+
text-transform: uppercase;
|
|
75
|
+
border: 1px solid rgba(212, 175, 55, 0.28);
|
|
76
|
+
background: rgba(10, 17, 40, 0.88);
|
|
77
|
+
color: rgba(255, 255, 255, 0.75);
|
|
78
|
+
opacity: 0;
|
|
79
|
+
transform: translateY(-4px);
|
|
80
|
+
transition: opacity 0.16s ease, transform 0.16s ease, border-color 0.16s ease;
|
|
81
|
+
pointer-events: none;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.cms-section-editable:hover .cms-section-chip,
|
|
85
|
+
.cms-section-editable.cms-section-active .cms-section-chip,
|
|
86
|
+
.cms-highlight-all .cms-section-chip {
|
|
87
|
+
opacity: 1;
|
|
88
|
+
transform: translateY(0);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.cms-section-editable.cms-section-active .cms-section-chip {
|
|
92
|
+
border-color: rgba(212, 175, 55, 0.65);
|
|
93
|
+
color: var(--cms-gold);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.cms-section-controls-actions {
|
|
97
|
+
display: flex;
|
|
98
|
+
align-items: center;
|
|
99
|
+
gap: 4px;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.cms-section-btn {
|
|
103
|
+
border: 1px solid rgba(255, 255, 255, 0.15);
|
|
104
|
+
background: rgba(255, 255, 255, 0.03);
|
|
105
|
+
color: rgba(255, 255, 255, 0.76);
|
|
106
|
+
font-family: var(--cms-font);
|
|
107
|
+
font-size: 9px;
|
|
108
|
+
font-weight: 600;
|
|
109
|
+
letter-spacing: 0.08em;
|
|
110
|
+
text-transform: uppercase;
|
|
111
|
+
border-radius: 4px;
|
|
112
|
+
padding: 5px 7px;
|
|
113
|
+
cursor: pointer;
|
|
114
|
+
transition: all 0.16s ease;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.cms-section-btn:hover {
|
|
118
|
+
border-color: rgba(212, 175, 55, 0.55);
|
|
119
|
+
color: var(--cms-gold);
|
|
120
|
+
background: rgba(212, 175, 55, 0.1);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.cms-section-btn-drag {
|
|
124
|
+
cursor: grab;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.cms-section-btn-drag:active {
|
|
128
|
+
cursor: grabbing;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.cms-section-btn:disabled {
|
|
132
|
+
opacity: 0.4;
|
|
133
|
+
cursor: wait;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.cms-section-drag-source {
|
|
137
|
+
outline-color: rgba(59, 130, 246, 0.6) !important;
|
|
138
|
+
box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.25);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.cms-section-drop-target {
|
|
142
|
+
outline-color: rgba(212, 175, 55, 0.75) !important;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.cms-section-drop-before {
|
|
146
|
+
box-shadow: inset 0 4px 0 0 rgba(212, 175, 55, 0.8);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.cms-section-drop-after {
|
|
150
|
+
box-shadow: inset 0 -4px 0 0 rgba(212, 175, 55, 0.8);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
body.cms-section-dragging .cms-section-controls {
|
|
154
|
+
opacity: 1;
|
|
155
|
+
pointer-events: none;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.cms-section-boundary-actions {
|
|
159
|
+
position: absolute;
|
|
160
|
+
left: 50%;
|
|
161
|
+
bottom: -15px;
|
|
162
|
+
transform: translateX(-50%);
|
|
163
|
+
z-index: 1190;
|
|
164
|
+
display: flex;
|
|
165
|
+
align-items: center;
|
|
166
|
+
gap: 6px;
|
|
167
|
+
opacity: 0;
|
|
168
|
+
pointer-events: none;
|
|
169
|
+
transition: opacity 0.16s ease;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.cms-section-editable:hover .cms-section-boundary-actions,
|
|
173
|
+
.cms-section-editable.cms-section-active .cms-section-boundary-actions,
|
|
174
|
+
body.cms-spacing-dragging .cms-section-boundary-actions {
|
|
175
|
+
opacity: 1;
|
|
176
|
+
pointer-events: auto;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.cms-section-insert-handle {
|
|
180
|
+
width: 28px;
|
|
181
|
+
height: 28px;
|
|
182
|
+
border-radius: 999px;
|
|
183
|
+
border: 1px solid rgba(212, 175, 55, 0.5);
|
|
184
|
+
background: rgba(10, 17, 40, 0.96);
|
|
185
|
+
color: var(--cms-gold);
|
|
186
|
+
display: inline-flex;
|
|
187
|
+
align-items: center;
|
|
188
|
+
justify-content: center;
|
|
189
|
+
cursor: pointer;
|
|
190
|
+
box-shadow: 0 8px 18px rgba(0, 0, 0, 0.26);
|
|
191
|
+
transition: border-color 0.16s ease, transform 0.16s ease, background 0.16s ease;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.cms-section-insert-plus {
|
|
195
|
+
font-family: var(--cms-font);
|
|
196
|
+
font-size: 18px;
|
|
197
|
+
font-weight: 700;
|
|
198
|
+
line-height: 1;
|
|
199
|
+
transform: translateY(-1px);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.cms-section-insert-handle:hover {
|
|
203
|
+
border-color: rgba(212, 175, 55, 0.9);
|
|
204
|
+
background: rgba(212, 175, 55, 0.15);
|
|
205
|
+
transform: translateY(-1px);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.cms-section-gap-handle {
|
|
209
|
+
height: 22px;
|
|
210
|
+
min-width: 64px;
|
|
211
|
+
padding: 0 8px;
|
|
212
|
+
border: 1px solid rgba(212, 175, 55, 0.38);
|
|
213
|
+
border-radius: 999px;
|
|
214
|
+
background: rgba(10, 17, 40, 0.92);
|
|
215
|
+
color: rgba(255, 255, 255, 0.82);
|
|
216
|
+
display: inline-flex;
|
|
217
|
+
align-items: center;
|
|
218
|
+
justify-content: center;
|
|
219
|
+
gap: 6px;
|
|
220
|
+
font-family: var(--cms-font);
|
|
221
|
+
font-size: 9px;
|
|
222
|
+
letter-spacing: 0.08em;
|
|
223
|
+
text-transform: uppercase;
|
|
224
|
+
cursor: ns-resize;
|
|
225
|
+
box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
|
|
226
|
+
transition: border-color 0.16s ease, color 0.16s ease, background 0.16s ease;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.cms-section-gap-grip {
|
|
230
|
+
width: 10px;
|
|
231
|
+
height: 10px;
|
|
232
|
+
border-radius: 999px;
|
|
233
|
+
background:
|
|
234
|
+
radial-gradient(circle at 2px 2px, rgba(212, 175, 55, 0.9) 1.5px, transparent 1.7px),
|
|
235
|
+
radial-gradient(circle at 8px 2px, rgba(212, 175, 55, 0.9) 1.5px, transparent 1.7px),
|
|
236
|
+
radial-gradient(circle at 2px 8px, rgba(212, 175, 55, 0.9) 1.5px, transparent 1.7px),
|
|
237
|
+
radial-gradient(circle at 8px 8px, rgba(212, 175, 55, 0.9) 1.5px, transparent 1.7px);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.cms-section-gap-handle:hover,
|
|
241
|
+
.cms-section-gap-handle.is-dragging {
|
|
242
|
+
border-color: rgba(212, 175, 55, 0.75);
|
|
243
|
+
color: var(--cms-gold);
|
|
244
|
+
background: rgba(212, 175, 55, 0.1);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
body.cms-spacing-dragging {
|
|
248
|
+
cursor: ns-resize;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
body.cms-spacing-dragging * {
|
|
252
|
+
user-select: none !important;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.cms-section-add-picker {
|
|
256
|
+
position: fixed;
|
|
257
|
+
z-index: 1400;
|
|
258
|
+
width: 220px;
|
|
259
|
+
border-radius: 8px;
|
|
260
|
+
background: rgba(10, 17, 40, 0.97);
|
|
261
|
+
border: 1px solid rgba(212, 175, 55, 0.26);
|
|
262
|
+
box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
|
|
263
|
+
backdrop-filter: blur(6px);
|
|
264
|
+
transform: translateY(-4px);
|
|
265
|
+
opacity: 0;
|
|
266
|
+
pointer-events: none;
|
|
267
|
+
transition: opacity 0.16s ease, transform 0.16s ease;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.cms-section-add-picker.open {
|
|
271
|
+
opacity: 1;
|
|
272
|
+
transform: translateY(0);
|
|
273
|
+
pointer-events: auto;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.cms-section-add-picker-head {
|
|
277
|
+
padding: 10px 10px 8px;
|
|
278
|
+
font-size: 10px;
|
|
279
|
+
letter-spacing: 0.1em;
|
|
280
|
+
text-transform: uppercase;
|
|
281
|
+
color: rgba(255, 255, 255, 0.62);
|
|
282
|
+
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.cms-section-add-picker-list {
|
|
286
|
+
padding: 6px;
|
|
287
|
+
display: flex;
|
|
288
|
+
flex-direction: column;
|
|
289
|
+
gap: 4px;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.cms-section-add-option {
|
|
293
|
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
294
|
+
background: rgba(255, 255, 255, 0.02);
|
|
295
|
+
color: rgba(255, 255, 255, 0.83);
|
|
296
|
+
font-family: var(--cms-font);
|
|
297
|
+
font-size: 10px;
|
|
298
|
+
text-align: left;
|
|
299
|
+
padding: 7px 8px;
|
|
300
|
+
border-radius: 5px;
|
|
301
|
+
cursor: pointer;
|
|
302
|
+
transition: all 0.15s ease;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.cms-section-add-option:hover {
|
|
306
|
+
border-color: rgba(212, 175, 55, 0.45);
|
|
307
|
+
color: var(--cms-gold);
|
|
308
|
+
background: rgba(212, 175, 55, 0.08);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.cms-section-add-option.active {
|
|
312
|
+
border-color: rgba(212, 175, 55, 0.55);
|
|
313
|
+
color: var(--cms-gold);
|
|
314
|
+
background: rgba(212, 175, 55, 0.14);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
.cms-section-add-option:disabled {
|
|
318
|
+
opacity: 0.45;
|
|
319
|
+
cursor: wait;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
@media (max-width: 960px) {
|
|
323
|
+
.cms-section-controls {
|
|
324
|
+
left: 10px;
|
|
325
|
+
right: 10px;
|
|
326
|
+
top: 10px;
|
|
327
|
+
flex-direction: column;
|
|
328
|
+
align-items: stretch;
|
|
329
|
+
gap: 6px;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.cms-section-controls-actions {
|
|
333
|
+
flex-wrap: wrap;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
.cms-section-chip {
|
|
337
|
+
top: 8px;
|
|
338
|
+
left: 8px;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
.cms-section-boundary-actions {
|
|
342
|
+
bottom: -18px;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.cms-section-add-picker {
|
|
346
|
+
width: calc(100vw - 24px);
|
|
347
|
+
max-width: 360px;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { mountSectionControls } from './section-controls/index.js';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
async function getTurnstileToken(action) {
|
|
2
|
+
if (typeof window.cmsGetTurnstileToken !== 'function') return null;
|
|
3
|
+
try {
|
|
4
|
+
return await window.cmsGetTurnstileToken(action);
|
|
5
|
+
} catch {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export async function mutateHeaders() {
|
|
11
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
12
|
+
const token = await getTurnstileToken('cms_mutate');
|
|
13
|
+
if (token) {
|
|
14
|
+
headers['x-cms-turnstile-token'] = token;
|
|
15
|
+
}
|
|
16
|
+
return headers;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function uploadHeaders() {
|
|
20
|
+
const token = await getTurnstileToken('cms_upload');
|
|
21
|
+
if (!token) return undefined;
|
|
22
|
+
return { 'x-cms-turnstile-token': token };
|
|
23
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export function mountStudioSync({ studioIframe, state, showToast, clientLinkify }) {
|
|
2
|
+
window.addEventListener('message', (e) => {
|
|
3
|
+
// Only accept messages from our iframe
|
|
4
|
+
if (e.source !== studioIframe.contentWindow) return;
|
|
5
|
+
const msg = e.data;
|
|
6
|
+
if (!msg || typeof msg.type !== 'string') return;
|
|
7
|
+
|
|
8
|
+
if (msg.type === 'cms:saved') {
|
|
9
|
+
const { collection, id, data } = msg;
|
|
10
|
+
if (!data || typeof data !== 'object') return;
|
|
11
|
+
|
|
12
|
+
let updated = 0;
|
|
13
|
+
|
|
14
|
+
function walkData(obj, prefix) {
|
|
15
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
16
|
+
const path = prefix ? `${prefix}.${key}` : key;
|
|
17
|
+
const selector = `${collection}.${id}.${path}`;
|
|
18
|
+
|
|
19
|
+
if (typeof value === 'string') {
|
|
20
|
+
// Text fields
|
|
21
|
+
const els = document.querySelectorAll(`[data-cms="${selector}"]`);
|
|
22
|
+
els.forEach((el) => {
|
|
23
|
+
// Skip elements being actively edited to prevent overwriting unsaved work
|
|
24
|
+
if (el === state.dirtyEl || el === document.activeElement) return;
|
|
25
|
+
if (el.hasAttribute('data-cms-raw')) {
|
|
26
|
+
if (el.getAttribute('data-cms-raw') !== value) {
|
|
27
|
+
el.setAttribute('data-cms-raw', value);
|
|
28
|
+
el.innerHTML = clientLinkify(value);
|
|
29
|
+
updated++;
|
|
30
|
+
}
|
|
31
|
+
} else if (el.textContent !== value) {
|
|
32
|
+
el.textContent = value;
|
|
33
|
+
updated++;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Image fields
|
|
38
|
+
const imgs = document.querySelectorAll(`[data-cms-img="${selector}"]`);
|
|
39
|
+
imgs.forEach((img) => {
|
|
40
|
+
if (img.src !== value && img.getAttribute('src') !== value) {
|
|
41
|
+
img.src = value;
|
|
42
|
+
updated++;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
} else if (typeof value === 'object' && value !== null) {
|
|
46
|
+
walkData(value, path);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
walkData(data, '');
|
|
52
|
+
|
|
53
|
+
if (updated > 0) {
|
|
54
|
+
showToast(`Updated ${updated} element${updated > 1 ? 's' : ''} on page`, 'success');
|
|
55
|
+
} else {
|
|
56
|
+
showToast('Saved — refresh to see changes', 'success');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (msg.type === 'cms:created') {
|
|
61
|
+
showToast('New entry created — refresh to see changes', 'success');
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { createTextLinkInteractions } from './text-link-interactions.js';
|
|
2
|
+
|
|
3
|
+
const snapshots = new WeakMap();
|
|
4
|
+
let keydownBound = false;
|
|
5
|
+
|
|
6
|
+
export function mountTextEditors({
|
|
7
|
+
state,
|
|
8
|
+
parseCmsAttr,
|
|
9
|
+
clientLinkify,
|
|
10
|
+
saveField,
|
|
11
|
+
flash,
|
|
12
|
+
showToast,
|
|
13
|
+
}) {
|
|
14
|
+
const applyTextValue = (target, value) => {
|
|
15
|
+
if (target.hasAttribute('data-cms-raw')) {
|
|
16
|
+
target.setAttribute('data-cms-raw', value);
|
|
17
|
+
target.innerHTML = clientLinkify(value);
|
|
18
|
+
} else {
|
|
19
|
+
target.textContent = value;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const syncBoundText = (attr, value) => {
|
|
23
|
+
document.querySelectorAll('[data-cms]').forEach((node) => {
|
|
24
|
+
if (!(node instanceof HTMLElement)) return;
|
|
25
|
+
if (node.getAttribute('data-cms') !== attr) return;
|
|
26
|
+
applyTextValue(node, value);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
const { onKeydown, showLinkHint, removeLinkHint } = createTextLinkInteractions({
|
|
30
|
+
state,
|
|
31
|
+
clientLinkify,
|
|
32
|
+
showToast,
|
|
33
|
+
snapshots,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
if (!keydownBound) {
|
|
37
|
+
document.addEventListener('keydown', onKeydown);
|
|
38
|
+
keydownBound = true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
document.querySelectorAll('[data-cms]').forEach((el) => {
|
|
42
|
+
if (el.dataset.cmsTextMounted === 'true') return;
|
|
43
|
+
el.dataset.cmsTextMounted = 'true';
|
|
44
|
+
|
|
45
|
+
const attr = el.getAttribute('data-cms');
|
|
46
|
+
const isLinkable = el.hasAttribute('data-cms-raw');
|
|
47
|
+
|
|
48
|
+
el.setAttribute('contenteditable', 'plaintext-only');
|
|
49
|
+
el.classList.add('cms-editable');
|
|
50
|
+
if (isLinkable) el.classList.add('cms-linkable');
|
|
51
|
+
|
|
52
|
+
el.addEventListener('focus', () => {
|
|
53
|
+
if (isLinkable) {
|
|
54
|
+
const raw = el.getAttribute('data-cms-raw') || '';
|
|
55
|
+
snapshots.set(el, raw);
|
|
56
|
+
el.textContent = raw;
|
|
57
|
+
showLinkHint(el);
|
|
58
|
+
} else {
|
|
59
|
+
snapshots.set(el, el.textContent || '');
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
el.addEventListener('input', () => {
|
|
64
|
+
const snapshot = snapshots.get(el);
|
|
65
|
+
const current = el.textContent || '';
|
|
66
|
+
state.dirtyEl = current !== snapshot ? el : null;
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
el.addEventListener('blur', async () => {
|
|
70
|
+
removeLinkHint();
|
|
71
|
+
|
|
72
|
+
// If link popup is active for this element, defer the save
|
|
73
|
+
if (state.linkPopupEl === el) return;
|
|
74
|
+
|
|
75
|
+
// Skip save if Escape was pressed
|
|
76
|
+
if (el._cmsSkipSave) {
|
|
77
|
+
el._cmsSkipSave = false;
|
|
78
|
+
state.dirtyEl = null;
|
|
79
|
+
if (isLinkable) {
|
|
80
|
+
const raw = el.getAttribute('data-cms-raw') || '';
|
|
81
|
+
el.innerHTML = clientLinkify(raw);
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const snapshot = snapshots.get(el) ?? '';
|
|
87
|
+
const current = el.textContent || '';
|
|
88
|
+
if (current === snapshot) {
|
|
89
|
+
if (isLinkable) {
|
|
90
|
+
el.innerHTML = clientLinkify(current);
|
|
91
|
+
}
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const parsed = parseCmsAttr(el.getAttribute('data-cms') || '');
|
|
96
|
+
if (!parsed) return;
|
|
97
|
+
|
|
98
|
+
// Update raw attribute and re-render before saving
|
|
99
|
+
if (isLinkable) {
|
|
100
|
+
el.setAttribute('data-cms-raw', current);
|
|
101
|
+
el.innerHTML = clientLinkify(current);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
el.classList.add('cms-saving');
|
|
105
|
+
const result = await saveField(parsed.collection, parsed.id, parsed.field, current);
|
|
106
|
+
el.classList.remove('cms-saving');
|
|
107
|
+
flash(el, result.ok);
|
|
108
|
+
state.dirtyEl = null;
|
|
109
|
+
|
|
110
|
+
// Sync all duplicated text bindings
|
|
111
|
+
if (result.ok) {
|
|
112
|
+
syncBoundText(attr, current);
|
|
113
|
+
showToast('Content saved', 'success');
|
|
114
|
+
} else {
|
|
115
|
+
const rollbackValue =
|
|
116
|
+
result.reason === 'conflict' && typeof result.latestValue === 'string'
|
|
117
|
+
? result.latestValue
|
|
118
|
+
: snapshot;
|
|
119
|
+
syncBoundText(attr, rollbackValue);
|
|
120
|
+
|
|
121
|
+
if (result.reason === 'conflict') {
|
|
122
|
+
showToast('Content changed elsewhere. Loaded latest value.', 'error');
|
|
123
|
+
} else if (result.reason !== 'unauthorized') {
|
|
124
|
+
showToast('Failed to save. Changes reverted.', 'error');
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|