@preprio/toolkit 0.5.0-rc.10 → 0.5.0-rc.12
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/README.md +21 -0
- package/dist/astro/index.cjs +31 -2
- package/dist/astro/index.js +31 -2
- package/dist/{chunk-KD3GK6TO.js → chunk-CABGJW5X.js} +30 -1
- package/dist/{chunk-URXSDJOU.js → chunk-H3AFUPYD.js} +9 -0
- package/dist/{chunk-F46GJS6Y.js → chunk-HVTNUCF7.js} +1 -1
- package/dist/{chunk-IPMB32AZ.js → chunk-LWUSRWFE.js} +2 -2
- package/dist/{chunk-IDEC77LZ.js → chunk-M7FT7XXV.js} +93 -20
- package/dist/{chunk-TBBU3LDD.js → chunk-TJ7VALNA.js} +1 -1
- package/dist/index.cjs +131 -20
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +6 -6
- package/dist/{live-preview-DLXGXRE5.js → live-preview-SFBGATWC.js} +3 -3
- package/dist/nextjs/components.cjs +101 -19
- package/dist/nextjs/components.js +3 -3
- package/dist/nextjs/index.cjs +31 -2
- package/dist/nextjs/index.js +31 -2
- package/dist/nextjs/live-action.js +3 -3
- package/dist/nextjs/live.cjs +30 -1
- package/dist/nextjs/live.js +1 -1
- package/dist/nuxt/index.cjs +1 -1
- package/dist/nuxt/index.js +1 -1
- package/dist/nuxt/{live-preview-2RCU35W5.js → live-preview-XMQQZHMZ.js} +30 -1
- package/dist/nuxt/live.cjs +30 -1
- package/dist/nuxt/live.js +1 -1
- package/dist/react/components.cjs +101 -19
- package/dist/react/components.js +101 -19
- package/dist/sveltekit/index.cjs +1 -1
- package/dist/sveltekit/index.js +1 -1
- package/dist/sveltekit/{live-preview-2RCU35W5.js → live-preview-XMQQZHMZ.js} +30 -1
- package/dist/sveltekit/live.cjs +30 -1
- package/dist/sveltekit/live.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -51,7 +51,7 @@ __export(src_exports, {
|
|
|
51
51
|
module.exports = __toCommonJS(src_exports);
|
|
52
52
|
|
|
53
53
|
// src/version.ts
|
|
54
|
-
var VERSION = "0.5.0-rc.
|
|
54
|
+
var VERSION = "0.5.0-rc.12";
|
|
55
55
|
|
|
56
56
|
// src/core/features.ts
|
|
57
57
|
function isEnabled(config) {
|
|
@@ -427,6 +427,7 @@ function createIframeBridge(store, options = {}) {
|
|
|
427
427
|
const onReferences = options.onReferences;
|
|
428
428
|
const onAssets = options.onAssets;
|
|
429
429
|
const onAllowNavigation = options.onAllowNavigation;
|
|
430
|
+
const onItemChanged = options.onItemChanged;
|
|
430
431
|
let parentOrigin = null;
|
|
431
432
|
const onKeyDown = (event) => {
|
|
432
433
|
const key = event.key.toLowerCase();
|
|
@@ -517,6 +518,14 @@ function createIframeBridge(store, options = {}) {
|
|
|
517
518
|
debug.warn("allowNavigation handler failed", error);
|
|
518
519
|
}
|
|
519
520
|
}
|
|
521
|
+
if (data?.event === "prepr:itemChanged") {
|
|
522
|
+
if (typeof data.itemId !== "string" || !data.itemId) return;
|
|
523
|
+
try {
|
|
524
|
+
onItemChanged?.(data.itemId);
|
|
525
|
+
} catch (error) {
|
|
526
|
+
debug.warn("itemChanged handler failed", error);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
520
529
|
};
|
|
521
530
|
return {
|
|
522
531
|
start() {
|
|
@@ -2664,6 +2673,7 @@ var ABSOLUTE_HTTP = /^https?:\/\//i;
|
|
|
2664
2673
|
var SOURCE_URL_ATTRIBUTES = ["src", "data-src"];
|
|
2665
2674
|
var SOURCE_SET_ATTRIBUTES = ["srcset", "data-srcset"];
|
|
2666
2675
|
var ASSET_ATTR = "data-prepr-asset";
|
|
2676
|
+
var REMOVED_ATTR = "data-prepr-removed";
|
|
2667
2677
|
var ASSET_SOURCE_ATTRIBUTES = [
|
|
2668
2678
|
...SOURCE_URL_ATTRIBUTES,
|
|
2669
2679
|
...SOURCE_SET_ATTRIBUTES
|
|
@@ -2673,7 +2683,8 @@ var TAG_ATTRIBUTES = [
|
|
|
2673
2683
|
"data-prepr-id",
|
|
2674
2684
|
"data-prepr-field",
|
|
2675
2685
|
"data-prepr-entry-id",
|
|
2676
|
-
ASSET_ATTR
|
|
2686
|
+
ASSET_ATTR,
|
|
2687
|
+
REMOVED_ATTR
|
|
2677
2688
|
];
|
|
2678
2689
|
function decodeSegment(segment) {
|
|
2679
2690
|
try {
|
|
@@ -2792,11 +2803,22 @@ function besideOtherItem(img, isCurrentItem) {
|
|
|
2792
2803
|
return false;
|
|
2793
2804
|
}
|
|
2794
2805
|
function tagAssetImages(index, itemId, keys, options = {}) {
|
|
2795
|
-
const { isCurrentItem } = options;
|
|
2806
|
+
const { isCurrentItem, removed } = options;
|
|
2807
|
+
let showsRemoved = false;
|
|
2796
2808
|
for (const img of document.getElementsByTagName("img")) {
|
|
2797
2809
|
const ours = img.hasAttribute(ASSET_ATTR);
|
|
2798
|
-
|
|
2799
|
-
|
|
2810
|
+
let match = index.size ? matchAsset(img, index, keys) : void 0;
|
|
2811
|
+
let isRemoved = false;
|
|
2812
|
+
if (!match && removed?.size) {
|
|
2813
|
+
match = matchAsset(img, removed, keys);
|
|
2814
|
+
isRemoved = match !== void 0;
|
|
2815
|
+
}
|
|
2816
|
+
if (!ours && img.hasAttribute("data-prepr-encoded")) {
|
|
2817
|
+
const mark = isRemoved && (!isCurrentItem || isCurrentItem(img));
|
|
2818
|
+
setIfChanged(img, REMOVED_ATTR, mark ? "" : null);
|
|
2819
|
+
showsRemoved || (showsRemoved = mark);
|
|
2820
|
+
continue;
|
|
2821
|
+
}
|
|
2800
2822
|
const asset = match && isCurrentItem && besideOtherItem(img, isCurrentItem) ? void 0 : match;
|
|
2801
2823
|
if (!asset) {
|
|
2802
2824
|
if (ours) untagAssetImage(img);
|
|
@@ -2807,10 +2829,14 @@ function tagAssetImages(index, itemId, keys, options = {}) {
|
|
|
2807
2829
|
setIfChanged(img, "data-prepr-id", itemId);
|
|
2808
2830
|
setIfChanged(img, "data-prepr-field", asset.field);
|
|
2809
2831
|
setIfChanged(img, "data-prepr-entry-id", asset.entryId ?? null);
|
|
2832
|
+
setIfChanged(img, REMOVED_ATTR, isRemoved ? "" : null);
|
|
2833
|
+
showsRemoved || (showsRemoved = isRemoved);
|
|
2810
2834
|
}
|
|
2835
|
+
return showsRemoved;
|
|
2811
2836
|
}
|
|
2812
2837
|
function untagAssetImages() {
|
|
2813
2838
|
document.querySelectorAll(`img[${ASSET_ATTR}]`).forEach(untagAssetImage);
|
|
2839
|
+
document.querySelectorAll(`img[${REMOVED_ATTR}]`).forEach((img) => img.removeAttribute(REMOVED_ATTR));
|
|
2814
2840
|
}
|
|
2815
2841
|
|
|
2816
2842
|
// src/core/visual-editor/navigation-guard.ts
|
|
@@ -2980,12 +3006,19 @@ var debug8 = createScopedLogger("visual-editor");
|
|
|
2980
3006
|
var ENCODED_SELECTOR2 = "[data-prepr-encoded]";
|
|
2981
3007
|
var REFERENCE_ATTR = "data-prepr-reference";
|
|
2982
3008
|
var REFERENCE_SELECTOR = `[${REFERENCE_ATTR}]`;
|
|
3009
|
+
var OTHER_ITEM_ATTR = "data-prepr-other-item";
|
|
3010
|
+
var OTHER_ITEM_SELECTOR = `[${OTHER_ITEM_ATTR}="on"],[${OTHER_ITEM_ATTR}="off"]`;
|
|
3011
|
+
var CHROME_SELECTOR = "header, footer, nav, [role=banner], [role=contentinfo], [role=navigation]";
|
|
3012
|
+
var SECTIONING_SELECTOR = "article, aside, main, nav, section";
|
|
3013
|
+
var PLAIN_HEADER_FOOTER = "header:not([role]), footer:not([role])";
|
|
2983
3014
|
var CURSOR_STYLE_MARKER = "data-prepr-visual-editor";
|
|
2984
|
-
var
|
|
3015
|
+
var REMOVED_STYLES = `img[${REMOVED_ATTR}]{opacity:.2!important;transition:opacity .2s ease}@media (prefers-reduced-motion:reduce){img[${REMOVED_ATTR}]{transition:none}}`;
|
|
3016
|
+
var CURSOR_STYLES = `${ENCODED_SELECTOR2}{cursor:pointer}html[data-prepr-ve-suspended] ${ENCODED_SELECTOR2}{cursor:auto}${REMOVED_STYLES}`;
|
|
2985
3017
|
var SUSPENDED_ATTR = "data-prepr-ve-suspended";
|
|
2986
3018
|
var FIND_RETRY_MS = 150;
|
|
2987
3019
|
var FIND_RETRIES = 6;
|
|
2988
3020
|
var MAX_CACHED_KEYS = 2e3;
|
|
3021
|
+
var SAVED_FADE_MS = 1e4;
|
|
2989
3022
|
var LAYOUT_MUTATIONS = {
|
|
2990
3023
|
childList: true,
|
|
2991
3024
|
subtree: true,
|
|
@@ -3028,6 +3061,9 @@ function createVisualEditor(opts) {
|
|
|
3028
3061
|
let guardEnabled = false;
|
|
3029
3062
|
let assetIndex = /* @__PURE__ */ new Map();
|
|
3030
3063
|
const assetKeys = /* @__PURE__ */ new Map();
|
|
3064
|
+
const removedAssets = /* @__PURE__ */ new Map();
|
|
3065
|
+
let saved = false;
|
|
3066
|
+
let savedTimeout = null;
|
|
3031
3067
|
const guard = createNavigationGuard({
|
|
3032
3068
|
onBlocked: (href) => opts.onNavigationBlocked?.(href),
|
|
3033
3069
|
showsEditedContent: () => showsEditedContent()
|
|
@@ -3059,10 +3095,26 @@ function createVisualEditor(opts) {
|
|
|
3059
3095
|
}
|
|
3060
3096
|
return null;
|
|
3061
3097
|
};
|
|
3098
|
+
const inSiteChrome = (el) => {
|
|
3099
|
+
let chrome = el.closest(CHROME_SELECTOR);
|
|
3100
|
+
while (chrome) {
|
|
3101
|
+
if (!chrome.matches(PLAIN_HEADER_FOOTER) || !chrome.parentElement?.closest(SECTIONING_SELECTOR)) {
|
|
3102
|
+
return true;
|
|
3103
|
+
}
|
|
3104
|
+
chrome = chrome.parentElement?.closest(CHROME_SELECTOR) ?? null;
|
|
3105
|
+
}
|
|
3106
|
+
return false;
|
|
3107
|
+
};
|
|
3108
|
+
const showsOtherItem = (el) => {
|
|
3109
|
+
const choice = el.closest(OTHER_ITEM_SELECTOR);
|
|
3110
|
+
if (choice) return choice.getAttribute(OTHER_ITEM_ATTR) === "on";
|
|
3111
|
+
return !inSiteChrome(el);
|
|
3112
|
+
};
|
|
3062
3113
|
const itemKind = (el) => {
|
|
3063
3114
|
if (isCurrentItem(el)) return "current";
|
|
3064
3115
|
if (!references) return "other";
|
|
3065
|
-
|
|
3116
|
+
if (linkedIdOf(el)) return "referenced";
|
|
3117
|
+
return showsOtherItem(el) ? "other" : null;
|
|
3066
3118
|
};
|
|
3067
3119
|
const referenceFieldOf = (el) => {
|
|
3068
3120
|
const linked = linkedIdOf(el);
|
|
@@ -3135,6 +3187,7 @@ function createVisualEditor(opts) {
|
|
|
3135
3187
|
}
|
|
3136
3188
|
return;
|
|
3137
3189
|
}
|
|
3190
|
+
if (kind === "other" && (e2.ctrlKey || e2.metaKey || e2.shiftKey)) return;
|
|
3138
3191
|
e2.preventDefault();
|
|
3139
3192
|
e2.stopPropagation();
|
|
3140
3193
|
const item = listItemIn(encoded, e2.target);
|
|
@@ -3142,11 +3195,13 @@ function createVisualEditor(opts) {
|
|
|
3142
3195
|
select(item?.element ?? encoded, encoded, item?.index);
|
|
3143
3196
|
const referenceField = kind === "referenced" ? referenceFieldOf(encoded) : void 0;
|
|
3144
3197
|
const linkedId = kind === "referenced" ? linkedIdOf(encoded) : null;
|
|
3198
|
+
const linkHref = kind === "other" ? leavingLinkHref(e2.target) : null;
|
|
3145
3199
|
opts.onEdit({
|
|
3146
3200
|
...readEditPayload(encoded),
|
|
3147
3201
|
...linkedId && { id: linkedId },
|
|
3148
3202
|
...item && { block: item.index },
|
|
3149
|
-
...referenceField && { referenceField }
|
|
3203
|
+
...referenceField && { referenceField },
|
|
3204
|
+
...linkHref && { linkHref }
|
|
3150
3205
|
});
|
|
3151
3206
|
};
|
|
3152
3207
|
const handleKey = (e2) => {
|
|
@@ -3207,15 +3262,32 @@ function createVisualEditor(opts) {
|
|
|
3207
3262
|
const el = block !== void 0 ? nthListItem(found, block) ?? found : found;
|
|
3208
3263
|
select(el, found, block);
|
|
3209
3264
|
}
|
|
3265
|
+
const hasAssets = () => assetIndex.size > 0 || removedAssets.size > 0;
|
|
3210
3266
|
function tagAssets() {
|
|
3211
3267
|
if (assetKeys.size > MAX_CACHED_KEYS) assetKeys.clear();
|
|
3212
|
-
tagAssetImages(assetIndex, currentItemId, assetKeys, {
|
|
3213
|
-
isCurrentItem: (el) => isCurrentItem(el)
|
|
3268
|
+
const showsRemoved = tagAssetImages(assetIndex, currentItemId, assetKeys, {
|
|
3269
|
+
isCurrentItem: (el) => isCurrentItem(el),
|
|
3270
|
+
removed: removedAssets
|
|
3214
3271
|
});
|
|
3272
|
+
if (saved && !showsRemoved) forgetRemoved();
|
|
3273
|
+
}
|
|
3274
|
+
function forgetRemoved() {
|
|
3275
|
+
saved = false;
|
|
3276
|
+
if (savedTimeout) clearTimeout(savedTimeout);
|
|
3277
|
+
savedTimeout = null;
|
|
3278
|
+
if (!removedAssets.size) return;
|
|
3279
|
+
removedAssets.clear();
|
|
3280
|
+
if (running) tagAssets();
|
|
3281
|
+
}
|
|
3282
|
+
function itemSaved() {
|
|
3283
|
+
if (!removedAssets.size) return;
|
|
3284
|
+
saved = true;
|
|
3285
|
+
if (savedTimeout) clearTimeout(savedTimeout);
|
|
3286
|
+
savedTimeout = setTimeout(forgetRemoved, SAVED_FADE_MS);
|
|
3215
3287
|
}
|
|
3216
3288
|
const handleLayoutFrame = () => {
|
|
3217
3289
|
mutationFrame = null;
|
|
3218
|
-
if (
|
|
3290
|
+
if (hasAssets()) tagAssets();
|
|
3219
3291
|
reselect();
|
|
3220
3292
|
const hovered = overlay.getHoverTarget();
|
|
3221
3293
|
if (hovered && !hovered.isConnected) {
|
|
@@ -3227,7 +3299,7 @@ function createVisualEditor(opts) {
|
|
|
3227
3299
|
};
|
|
3228
3300
|
const handleMutations = () => {
|
|
3229
3301
|
if (mutationFrame !== null) return;
|
|
3230
|
-
if (!selection && !overlay.getHoverTarget() && !
|
|
3302
|
+
if (!selection && !overlay.getHoverTarget() && !hasAssets()) return;
|
|
3231
3303
|
mutationFrame = requestAnimationFrame(handleLayoutFrame);
|
|
3232
3304
|
};
|
|
3233
3305
|
function injectCursorStyles() {
|
|
@@ -3268,7 +3340,7 @@ function createVisualEditor(opts) {
|
|
|
3268
3340
|
});
|
|
3269
3341
|
mutationObserver = new MutationObserver(handleMutations);
|
|
3270
3342
|
mutationObserver.observe(document.body, LAYOUT_MUTATIONS);
|
|
3271
|
-
if (
|
|
3343
|
+
if (hasAssets()) tagAssets();
|
|
3272
3344
|
syncGuard();
|
|
3273
3345
|
debug8.log("visual editor started");
|
|
3274
3346
|
}
|
|
@@ -3344,18 +3416,24 @@ function createVisualEditor(opts) {
|
|
|
3344
3416
|
});
|
|
3345
3417
|
}
|
|
3346
3418
|
function setCurrentItem(itemId, referenceList, componentIds) {
|
|
3419
|
+
if (itemId !== currentItemId) forgetRemoved();
|
|
3347
3420
|
currentItemId = itemId;
|
|
3348
3421
|
if (referenceList) setReferences(referenceList, componentIds);
|
|
3349
3422
|
else if (componentIds) ownComponents = new Set(componentIds);
|
|
3350
|
-
if (running &&
|
|
3423
|
+
if (running && hasAssets()) tagAssets();
|
|
3351
3424
|
const selected = overlay.getSelectedTarget();
|
|
3352
3425
|
const owner = selected ? encodedFrom(selected) : null;
|
|
3353
3426
|
if (owner && !isCurrentItem(owner)) clearSelection();
|
|
3354
3427
|
}
|
|
3355
3428
|
function setAssets(assets) {
|
|
3356
|
-
const hadAssets =
|
|
3357
|
-
|
|
3358
|
-
|
|
3429
|
+
const hadAssets = hasAssets();
|
|
3430
|
+
const next = createAssetIndex(assets);
|
|
3431
|
+
for (const [key, asset] of assetIndex) {
|
|
3432
|
+
if (!next.has(key)) removedAssets.set(key, asset);
|
|
3433
|
+
}
|
|
3434
|
+
for (const key of next.keys()) removedAssets.delete(key);
|
|
3435
|
+
assetIndex = next;
|
|
3436
|
+
if (running && (hadAssets || hasAssets())) tagAssets();
|
|
3359
3437
|
}
|
|
3360
3438
|
function setReferences(referenceList, componentIds) {
|
|
3361
3439
|
if (componentIds) ownComponents = new Set(componentIds);
|
|
@@ -3381,6 +3459,7 @@ function createVisualEditor(opts) {
|
|
|
3381
3459
|
setCurrentItem,
|
|
3382
3460
|
setReferences,
|
|
3383
3461
|
setAssets,
|
|
3462
|
+
itemSaved,
|
|
3384
3463
|
setLocale,
|
|
3385
3464
|
focusField,
|
|
3386
3465
|
setNavigationGuard,
|
|
@@ -3467,7 +3546,8 @@ function createPreprPreview(opts = {}) {
|
|
|
3467
3546
|
locale: contentLocale,
|
|
3468
3547
|
block,
|
|
3469
3548
|
entryId,
|
|
3470
|
-
referenceField
|
|
3549
|
+
referenceField,
|
|
3550
|
+
linkHref
|
|
3471
3551
|
}) => {
|
|
3472
3552
|
const safeHref = href ? safeEditUrl(href) : null;
|
|
3473
3553
|
if (href && !safeHref) {
|
|
@@ -3481,7 +3561,8 @@ function createPreprPreview(opts = {}) {
|
|
|
3481
3561
|
locale: contentLocale,
|
|
3482
3562
|
...block !== void 0 && { block },
|
|
3483
3563
|
...entryId && { entryId },
|
|
3484
|
-
...referenceField && { referenceField }
|
|
3564
|
+
...referenceField && { referenceField },
|
|
3565
|
+
...linkHref && { linkHref }
|
|
3485
3566
|
});
|
|
3486
3567
|
} else if (safeHref) {
|
|
3487
3568
|
window.open(safeHref, "_blank", "noopener,noreferrer");
|
|
@@ -3536,6 +3617,7 @@ function createPreprPreview(opts = {}) {
|
|
|
3536
3617
|
},
|
|
3537
3618
|
onAssets: (assets) => visualEditor?.setAssets(assets),
|
|
3538
3619
|
onAllowNavigation: (href) => visualEditor?.allowNavigation(href),
|
|
3620
|
+
onItemChanged: () => visualEditor?.itemSaved(),
|
|
3539
3621
|
onReferences: (referencedIds, componentIds) => visualEditor?.setReferences(referencedIds, componentIds),
|
|
3540
3622
|
// The editor selecting a field scrolls the matching element into view. The
|
|
3541
3623
|
// lookup relies on the attributes the stega scan writes, so it finds
|
|
@@ -3702,8 +3784,32 @@ function shapeLike(template, incoming) {
|
|
|
3702
3784
|
}
|
|
3703
3785
|
return out;
|
|
3704
3786
|
}
|
|
3787
|
+
function isAsset(value) {
|
|
3788
|
+
return isPlainObject(value) && (typeof value.url === "string" || value.__typename === "Asset");
|
|
3789
|
+
}
|
|
3790
|
+
function hasId(list, entry) {
|
|
3791
|
+
return entry._id !== void 0 && list.some((c2) => isPlainObject(c2) && c2._id === entry._id);
|
|
3792
|
+
}
|
|
3793
|
+
function isAssetValue(value) {
|
|
3794
|
+
return Array.isArray(value) ? value.length > 0 && value.every(isAsset) : isAsset(value);
|
|
3795
|
+
}
|
|
3796
|
+
function keepRemovedAssets(current, next) {
|
|
3797
|
+
const listed = /* @__PURE__ */ new Set();
|
|
3798
|
+
for (const entry of next) {
|
|
3799
|
+
if (isPlainObject(entry) && entry._id !== void 0) listed.add(entry._id);
|
|
3800
|
+
}
|
|
3801
|
+
let out = next;
|
|
3802
|
+
current.forEach((entry, position) => {
|
|
3803
|
+
if (!isPlainObject(entry) || entry._id === void 0) return;
|
|
3804
|
+
if (listed.has(entry._id)) return;
|
|
3805
|
+
if (out === next) out = [...next];
|
|
3806
|
+
out.splice(Math.min(position, out.length), 0, entry);
|
|
3807
|
+
});
|
|
3808
|
+
return out;
|
|
3809
|
+
}
|
|
3705
3810
|
function mergeStructured(current, incoming) {
|
|
3706
3811
|
if (incoming === null || Array.isArray(incoming) && !incoming.length) {
|
|
3812
|
+
if (isAssetValue(current)) return current;
|
|
3707
3813
|
if (Array.isArray(current)) return current.length ? [] : current;
|
|
3708
3814
|
return null;
|
|
3709
3815
|
}
|
|
@@ -3711,13 +3817,18 @@ function mergeStructured(current, incoming) {
|
|
|
3711
3817
|
if (current === null || current === void 0) return incoming;
|
|
3712
3818
|
if (Array.isArray(current)) {
|
|
3713
3819
|
const template = current.find(isPlainObject);
|
|
3714
|
-
|
|
3820
|
+
const next = list.map((entry) => {
|
|
3715
3821
|
const match = current.find(
|
|
3716
3822
|
(c2) => isPlainObject(c2) && c2._id !== void 0 && c2._id === entry._id
|
|
3717
3823
|
);
|
|
3718
3824
|
if (isPlainObject(match)) return mergeObject(match, entry);
|
|
3719
3825
|
return isPlainObject(template) ? shapeLike(template, entry) : entry;
|
|
3720
3826
|
});
|
|
3827
|
+
if (!isAssetValue(current) || list.some((entry) => !hasId(current, entry))) {
|
|
3828
|
+
return next;
|
|
3829
|
+
}
|
|
3830
|
+
const kept = keepRemovedAssets(current, next);
|
|
3831
|
+
return kept.length === current.length && kept.every((entry, i2) => entry === current[i2]) ? current : kept;
|
|
3721
3832
|
}
|
|
3722
3833
|
if (isPlainObject(current)) return mergeObject(current, list[0]);
|
|
3723
3834
|
return current;
|
package/dist/index.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ export { g as PreprEnvironment, h as PreprEventType, i as PreprFeatureConfig, j
|
|
|
5
5
|
* Package version; must match package.json. Lives in its own leaf module so
|
|
6
6
|
* core can import it without cycling through the barrel.
|
|
7
7
|
*/
|
|
8
|
-
declare const VERSION = "0.5.0-rc.
|
|
8
|
+
declare const VERSION = "0.5.0-rc.12";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Resolve a `PreprFeatures` bag to plain booleans, defaulting every omitted key
|
|
@@ -233,6 +233,11 @@ interface IframeBridgeOptions {
|
|
|
233
233
|
* string; its scheme is not checked here.
|
|
234
234
|
*/
|
|
235
235
|
onAllowNavigation?: (href: string) => void;
|
|
236
|
+
/**
|
|
237
|
+
* The editor saved the open item (`prepr:itemChanged`), with that item's
|
|
238
|
+
* id. The page shows stored content from its next render on.
|
|
239
|
+
*/
|
|
240
|
+
onItemChanged?: (itemId: string) => void;
|
|
236
241
|
}
|
|
237
242
|
|
|
238
243
|
interface PreviewAttrsTarget {
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { g as PreprEnvironment, h as PreprEventType, i as PreprFeatureConfig, j
|
|
|
5
5
|
* Package version; must match package.json. Lives in its own leaf module so
|
|
6
6
|
* core can import it without cycling through the barrel.
|
|
7
7
|
*/
|
|
8
|
-
declare const VERSION = "0.5.0-rc.
|
|
8
|
+
declare const VERSION = "0.5.0-rc.12";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Resolve a `PreprFeatures` bag to plain booleans, defaulting every omitted key
|
|
@@ -233,6 +233,11 @@ interface IframeBridgeOptions {
|
|
|
233
233
|
* string; its scheme is not checked here.
|
|
234
234
|
*/
|
|
235
235
|
onAllowNavigation?: (href: string) => void;
|
|
236
|
+
/**
|
|
237
|
+
* The editor saved the open item (`prepr:itemChanged`), with that item's
|
|
238
|
+
* id. The page shows stored content from its next render on.
|
|
239
|
+
*/
|
|
240
|
+
onItemChanged?: (itemId: string) => void;
|
|
236
241
|
}
|
|
237
242
|
|
|
238
243
|
interface PreviewAttrsTarget {
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
setTrackingParam,
|
|
19
19
|
stegaClean,
|
|
20
20
|
trackEvent
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-M7FT7XXV.js";
|
|
22
22
|
import {
|
|
23
23
|
PreprError,
|
|
24
24
|
extractAccessToken,
|
|
@@ -29,22 +29,22 @@ import {
|
|
|
29
29
|
getPreprUUIDFromHeaders,
|
|
30
30
|
getToolbarPropsFromHeaders,
|
|
31
31
|
validatePreprToken
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-TJ7VALNA.js";
|
|
33
33
|
import {
|
|
34
34
|
VERSION,
|
|
35
35
|
resolveFeatures
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-HVTNUCF7.js";
|
|
37
37
|
import {
|
|
38
38
|
createLiveBridge,
|
|
39
39
|
createLiveStore
|
|
40
|
-
} from "./chunk-
|
|
41
|
-
import "./chunk-
|
|
40
|
+
} from "./chunk-LWUSRWFE.js";
|
|
41
|
+
import "./chunk-H3AFUPYD.js";
|
|
42
42
|
import {
|
|
43
43
|
collectFields,
|
|
44
44
|
normalizeQuery,
|
|
45
45
|
parsePatchLog,
|
|
46
46
|
readQueryDocument
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-CABGJW5X.js";
|
|
48
48
|
import {
|
|
49
49
|
createScopedLogger
|
|
50
50
|
} from "./chunk-S3VT4UWM.js";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createLiveBridge,
|
|
3
3
|
createLiveStore
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-LWUSRWFE.js";
|
|
5
|
+
import "./chunk-H3AFUPYD.js";
|
|
6
6
|
import {
|
|
7
7
|
applyPatchLog,
|
|
8
8
|
normalizeQuery,
|
|
9
9
|
parsePatchLog
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-CABGJW5X.js";
|
|
11
11
|
import "./chunk-S3VT4UWM.js";
|
|
12
12
|
export {
|
|
13
13
|
applyPatchLog,
|