@datocms/astro 0.6.5 → 0.6.7
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/package.json
CHANGED
|
@@ -34,7 +34,7 @@ export interface Props {
|
|
|
34
34
|
*
|
|
35
35
|
* - `true`: Enable click-to-edit mode immediately
|
|
36
36
|
* - `{ scrollToNearestTarget: true }`: Enable and scroll to nearest editable if none visible
|
|
37
|
-
* - `undefined`: Don't enable automatically (use Alt/Option key to toggle)
|
|
37
|
+
* - `false` or `undefined`: Don't enable automatically (use Alt/Option key to toggle)
|
|
38
38
|
*
|
|
39
39
|
* @example
|
|
40
40
|
* ```astro
|
|
@@ -145,8 +145,8 @@ const enableClickToEditValue =
|
|
|
145
145
|
document.addEventListener('astro:page-load', this.pageLoadHandler);
|
|
146
146
|
|
|
147
147
|
// Enable click-to-edit mode if requested via prop
|
|
148
|
-
if (enableClickToEdit
|
|
149
|
-
if (
|
|
148
|
+
if (enableClickToEdit) {
|
|
149
|
+
if (enableClickToEdit === true) {
|
|
150
150
|
this.controller.enableClickToEdit();
|
|
151
151
|
} else {
|
|
152
152
|
this.controller.enableClickToEdit(enableClickToEdit);
|
|
@@ -34,8 +34,11 @@ Visual Editing transforms how editors interact with your content by letting them
|
|
|
34
34
|
- [StructuredText integration](#structuredtext-integration)
|
|
35
35
|
- [Edit groups with `data-datocms-content-link-group`](#edit-groups-with-data-datocms-content-link-group)
|
|
36
36
|
- [Edit boundaries with `data-datocms-content-link-boundary`](#edit-boundaries-with-data-datocms-content-link-boundary)
|
|
37
|
-
- [Manual overlays
|
|
37
|
+
- [Manual overlays](#manual-overlays)
|
|
38
|
+
- [Using `data-datocms-content-link-url`](#using-data-datocms-content-link-url)
|
|
39
|
+
- [Using `data-datocms-content-link-source`](#using-data-datocms-content-link-source)
|
|
38
40
|
- [Low-level utilities](#low-level-utilities)
|
|
41
|
+
- [`stripStega()` works with any data type](#stripstega-works-with-any-data-type)
|
|
39
42
|
- [Troubleshooting](#troubleshooting)
|
|
40
43
|
- [Click-to-edit overlays not appearing](#click-to-edit-overlays-not-appearing)
|
|
41
44
|
- [Navigation not syncing in Web Previews plugin](#navigation-not-syncing-in-web-previews-plugin)
|
|
@@ -78,7 +81,7 @@ const result = await executeQuery(query, {
|
|
|
78
81
|
---
|
|
79
82
|
```
|
|
80
83
|
|
|
81
|
-
The `contentLink: 'v1'` option enables stega encoding, which embeds invisible metadata into text fields. The `baseEditingUrl` tells DatoCMS where your project is located so edit URLs can be generated correctly.
|
|
84
|
+
The `contentLink: 'v1'` option enables stega encoding, which embeds invisible metadata into text fields. The `baseEditingUrl` tells DatoCMS where your project is located so edit URLs can be generated correctly. Both options are required.
|
|
82
85
|
|
|
83
86
|
### Step 2: Add the ContentLink component
|
|
84
87
|
|
|
@@ -202,13 +205,13 @@ This ensures:
|
|
|
202
205
|
- Clicking the main text opens the Structured Text field editor
|
|
203
206
|
- Clicking an embedded block opens that specific block's editor
|
|
204
207
|
|
|
205
|
-
## Manual overlays
|
|
208
|
+
## Manual overlays
|
|
206
209
|
|
|
207
|
-
|
|
210
|
+
In some cases, you may want to manually create click-to-edit overlays for content that doesn't have stega encoding.
|
|
208
211
|
|
|
209
|
-
|
|
212
|
+
### Using `data-datocms-content-link-url`
|
|
210
213
|
|
|
211
|
-
|
|
214
|
+
You can add the `data-datocms-content-link-url` attribute with a DatoCMS editing URL:
|
|
212
215
|
|
|
213
216
|
```graphql
|
|
214
217
|
query {
|
|
@@ -222,17 +225,7 @@ query {
|
|
|
222
225
|
}
|
|
223
226
|
```
|
|
224
227
|
|
|
225
|
-
**2. Add the attribute to your HTML element:**
|
|
226
|
-
|
|
227
228
|
```astro
|
|
228
|
-
---
|
|
229
|
-
const { product } = await executeQuery(query, {
|
|
230
|
-
token: import.meta.env.DATOCMS_API_TOKEN,
|
|
231
|
-
contentLink: 'v1',
|
|
232
|
-
baseEditingUrl: 'https://your-project.admin.datocms.com',
|
|
233
|
-
});
|
|
234
|
-
---
|
|
235
|
-
|
|
236
229
|
<div>
|
|
237
230
|
<span data-datocms-content-link-url={product._editingUrl}>
|
|
238
231
|
${product.price}
|
|
@@ -244,7 +237,19 @@ const { product } = await executeQuery(query, {
|
|
|
244
237
|
</div>
|
|
245
238
|
```
|
|
246
239
|
|
|
247
|
-
|
|
240
|
+
### Using `data-datocms-content-link-source`
|
|
241
|
+
|
|
242
|
+
For elements without visible stega-encoded content, use the [`data-datocms-content-link-source`](https://github.com/datocms/content-link?tab=readme-ov-file#stamping-elements-via-data-datocms-content-link-source) attribute to attach stega metadata directly:
|
|
243
|
+
|
|
244
|
+
```astro
|
|
245
|
+
<!-- product.asset.video.alt contains stega-encoded info -->
|
|
246
|
+
<video
|
|
247
|
+
src={product.asset.video.url}
|
|
248
|
+
data-datocms-content-link-source={product.asset.video.alt}
|
|
249
|
+
controls></video>
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
This is useful for structural elements like `<video>`, `<audio>`, or `<iframe>` where stega encoding in visible text would be problematic.
|
|
248
253
|
|
|
249
254
|
## Low-level utilities
|
|
250
255
|
|
|
@@ -272,6 +277,29 @@ const cleanText = stripStega(text);
|
|
|
272
277
|
- **Programmatic text processing**: Remove invisible characters before string operations
|
|
273
278
|
- **Debugging**: Use `decodeStega()` to inspect what editing URLs are embedded in content
|
|
274
279
|
|
|
280
|
+
### `stripStega()` works with any data type
|
|
281
|
+
|
|
282
|
+
The `stripStega()` function handles strings, objects, arrays, and primitives:
|
|
283
|
+
|
|
284
|
+
```js
|
|
285
|
+
// Works with strings
|
|
286
|
+
stripStega('HelloWorld'); // "HelloWorld"
|
|
287
|
+
|
|
288
|
+
// Works with objects
|
|
289
|
+
stripStega({ name: 'John', age: 30 });
|
|
290
|
+
|
|
291
|
+
// Works with nested structures - removes ALL stega encodings
|
|
292
|
+
stripStega({
|
|
293
|
+
users: [
|
|
294
|
+
{ name: 'Alice', email: 'alice.com' },
|
|
295
|
+
{ name: 'Bob', email: 'bob.co' },
|
|
296
|
+
],
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
// Works with arrays
|
|
300
|
+
stripStega(['First', 'Second', 'Third']);
|
|
301
|
+
```
|
|
302
|
+
|
|
275
303
|
## Troubleshooting
|
|
276
304
|
|
|
277
305
|
### Click-to-edit overlays not appearing
|