@aphexcms/visual-editing 0.3.1 → 0.4.0-next.20261115053338
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/core.d.ts.map +1 -1
- package/dist/core.js +18 -4
- package/dist/preview.d.ts +1 -1
- package/dist/preview.js +1 -1
- package/dist/use-preview.svelte.d.ts +7 -0
- package/dist/use-preview.svelte.d.ts.map +1 -1
- package/dist/use-preview.svelte.js +2 -0
- package/package.json +1 -1
package/dist/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/lib/core.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IACnC;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,CACR,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,IAAI,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,KACjD,IAAI,CAAC;IACV;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/lib/core.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IACnC;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,CACR,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,IAAI,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,KACjD,IAAI,CAAC;IACV;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAwED,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,MAAM,IAAI,CA+OhF"}
|
package/dist/core.js
CHANGED
|
@@ -51,6 +51,23 @@ function navigatesAway(target) {
|
|
|
51
51
|
}
|
|
52
52
|
return false;
|
|
53
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* What the hover label calls an element. Inside an item, the field the path ends
|
|
56
|
+
* on (`heading`, `image`), or the item it ends on (`columns[0]`): naming the
|
|
57
|
+
* top-level field would label every part of a page builder `blocks`. Otherwise
|
|
58
|
+
* the field, with the row number for a list entry — several rows of one list
|
|
59
|
+
* would all hover as the same bare name, with nothing to say which is which.
|
|
60
|
+
*/
|
|
61
|
+
function labelFor(d) {
|
|
62
|
+
const path = d.aphexObjectPath;
|
|
63
|
+
if (path) {
|
|
64
|
+
const last = path.match(/(?:^|\.)([^.]+)$/)?.[1];
|
|
65
|
+
if (last && !last.startsWith('['))
|
|
66
|
+
return last;
|
|
67
|
+
}
|
|
68
|
+
const idx = d.aphexArrayIndex;
|
|
69
|
+
return (d.aphexField ?? '') + (idx != null ? `[${idx}]` : '');
|
|
70
|
+
}
|
|
54
71
|
export function enableAphexPreview(options = {}) {
|
|
55
72
|
const { stega = true, onData, onRefresh } = options;
|
|
56
73
|
if (typeof window === 'undefined' || window.parent === window)
|
|
@@ -161,10 +178,7 @@ export function enableAphexPreview(options = {}) {
|
|
|
161
178
|
}
|
|
162
179
|
function showOn(el) {
|
|
163
180
|
activeEl = el;
|
|
164
|
-
|
|
165
|
-
// hover as the same bare field name, with nothing to say which slot is which.
|
|
166
|
-
const idx = el.dataset.aphexArrayIndex;
|
|
167
|
-
label.textContent = (el.dataset.aphexField ?? '') + (idx != null ? `[${idx}]` : '');
|
|
181
|
+
label.textContent = labelFor(el.dataset);
|
|
168
182
|
positionOn(el);
|
|
169
183
|
overlay.style.display = 'block';
|
|
170
184
|
}
|
package/dist/preview.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* grant access to draft content.
|
|
5
5
|
*
|
|
6
6
|
* To resolve the actual content perspective (draft vs published) use
|
|
7
|
-
* `getPreviewPerspective(locals.
|
|
7
|
+
* `getPreviewPerspective(locals.aphexAuth, url)` from `@aphexcms/cms-core/server`
|
|
8
8
|
* inside a load function — draft access is gated on an authenticated session,
|
|
9
9
|
* so appending `?aphex-preview` alone never exposes drafts.
|
|
10
10
|
*/
|
package/dist/preview.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* grant access to draft content.
|
|
5
5
|
*
|
|
6
6
|
* To resolve the actual content perspective (draft vs published) use
|
|
7
|
-
* `getPreviewPerspective(locals.
|
|
7
|
+
* `getPreviewPerspective(locals.aphexAuth, url)` from `@aphexcms/cms-core/server`
|
|
8
8
|
* inside a load function — draft access is gated on an authenticated session,
|
|
9
9
|
* so appending `?aphex-preview` alone never exposes drafts.
|
|
10
10
|
*/
|
|
@@ -66,16 +66,23 @@ export interface PreviewApi {
|
|
|
66
66
|
* field, and with `arrayIndex` the specific row, in the form pane. Use this for a
|
|
67
67
|
* list whose entries are references: revealing the row is what lets the author
|
|
68
68
|
* reorder or remove it, which opening the referenced document does not.
|
|
69
|
+
* - **Something inside a row** (`{ field, objectPath }`) — the path from the field down,
|
|
70
|
+
* as `[2].image` or `[2].columns[0].parts[1]`: clicking opens each item on the way
|
|
71
|
+
* and lands on the field it ends at (or on the last item, when it ends on one). The
|
|
72
|
+
* stega the CMS adds to text carries the same path, so an image, a button or a
|
|
73
|
+
* card's padding can lead where the text beside it does.
|
|
69
74
|
*
|
|
70
75
|
* @example
|
|
71
76
|
* // {...ve.edit({ id: post.id, type: 'blog_post' })} → opens that post
|
|
72
77
|
* // {...ve.edit({ field: 'items', arrayIndex: i })} → reveals row i of `items`
|
|
78
|
+
* // {...ve.edit({ field: 'blocks', objectPath: `[${i}].image` })} → opens block i at its image
|
|
73
79
|
*/
|
|
74
80
|
edit(target: {
|
|
75
81
|
id?: string;
|
|
76
82
|
type?: string;
|
|
77
83
|
field?: string;
|
|
78
84
|
arrayIndex?: number;
|
|
85
|
+
objectPath?: string;
|
|
79
86
|
}): Record<string, string>;
|
|
80
87
|
/**
|
|
81
88
|
* Resolve an image field to `{ src, alt }` in one call — destructure it:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-preview.svelte.d.ts","sourceRoot":"","sources":["../src/lib/use-preview.svelte.ts"],"names":[],"mappings":"AAEA,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAK5D;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,IAAI,CAEzE;AAED;gEACgE;AAChE,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAElD,KAAK,SAAS,GACX;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GACvE,IAAI,GACJ,SAAS,CAAC;AAEb,6CAA6C;AAC7C,MAAM,WAAW,aAAa;IAC7B,yDAAyD;IACzD,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,yEAAyE;IACzE,GAAG,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,UAAU;IAC1B,6FAA6F;IAC7F,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAClD;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC;;;;;;;OAOG;IACH,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE;QAA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