@preprio/toolkit 0.5.0-rc.10 → 0.5.0-rc.11

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 CHANGED
@@ -872,6 +872,20 @@ The rest is about rendering:
872
872
  `data-prepr-reference="<linked item _id>"`. The editor only knows the items
873
873
  the open item links to directly; content inside the wrapper is outlined as
874
874
  that linked item, and clicking it opens the link in the editor.
875
+ - Content of items the open item does not link to (for example news cards
876
+ filled by a query) is outlined muted as "other item". Clicking it does not
877
+ follow its link: the editor offers to open that item, or to go to the
878
+ linked page. Ctrl/Cmd/Shift-click still opens the link in a new tab, and
879
+ Alt-click follows it. Inside the site's header, footer and navigation
880
+ (`header`, `footer`, `nav` and the `banner`, `contentinfo` and
881
+ `navigation` roles) such content stays unmarked and its links behave as
882
+ any other page link (a `header` or `footer` inside an `article`, `section`,
883
+ `aside` or `main` belongs to that content and is not site chrome). Change
884
+ that per part of the page with an attribute on
885
+ an ancestor; the nearest one wins:
886
+ - `data-prepr-other-item="off"` keeps other items inside it unmarked.
887
+ - `data-prepr-other-item="on"` marks them, also inside a header, footer or
888
+ navigation.
875
889
 
876
890
  Typed text and changed fields show immediately. Structural changes, such as
877
891
  adding or reordering components, appear after save.
@@ -31,7 +31,7 @@ __export(astro_exports, {
31
31
  module.exports = __toCommonJS(astro_exports);
32
32
 
33
33
  // src/version.ts
34
- var VERSION = "0.5.0-rc.10";
34
+ var VERSION = "0.5.0-rc.11";
35
35
 
36
36
  // src/core/features.ts
37
37
  function isEnabled(config) {
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "0.5.0-rc.10";
2
+ var VERSION = "0.5.0-rc.11";
3
3
 
4
4
  // src/core/features.ts
5
5
  function isEnabled(config) {
@@ -2,7 +2,7 @@ import {
2
2
  ALL_FEATURES_ENABLED,
3
3
  VERSION,
4
4
  resolveFeatures
5
- } from "./chunk-F46GJS6Y.js";
5
+ } from "./chunk-AOHA5INA.js";
6
6
  import {
7
7
  createIframeBridge,
8
8
  isLocale,
@@ -2509,6 +2509,11 @@ var debug7 = createScopedLogger("visual-editor");
2509
2509
  var ENCODED_SELECTOR2 = "[data-prepr-encoded]";
2510
2510
  var REFERENCE_ATTR = "data-prepr-reference";
2511
2511
  var REFERENCE_SELECTOR = `[${REFERENCE_ATTR}]`;
2512
+ var OTHER_ITEM_ATTR = "data-prepr-other-item";
2513
+ var OTHER_ITEM_SELECTOR = `[${OTHER_ITEM_ATTR}="on"],[${OTHER_ITEM_ATTR}="off"]`;
2514
+ var CHROME_SELECTOR = "header, footer, nav, [role=banner], [role=contentinfo], [role=navigation]";
2515
+ var SECTIONING_SELECTOR = "article, aside, main, nav, section";
2516
+ var PLAIN_HEADER_FOOTER = "header:not([role]), footer:not([role])";
2512
2517
  var CURSOR_STYLE_MARKER = "data-prepr-visual-editor";
2513
2518
  var CURSOR_STYLES = `${ENCODED_SELECTOR2}{cursor:pointer}html[data-prepr-ve-suspended] ${ENCODED_SELECTOR2}{cursor:auto}`;
2514
2519
  var SUSPENDED_ATTR = "data-prepr-ve-suspended";
@@ -2588,10 +2593,26 @@ function createVisualEditor(opts) {
2588
2593
  }
2589
2594
  return null;
2590
2595
  };
2596
+ const inSiteChrome = (el) => {
2597
+ let chrome = el.closest(CHROME_SELECTOR);
2598
+ while (chrome) {
2599
+ if (!chrome.matches(PLAIN_HEADER_FOOTER) || !chrome.parentElement?.closest(SECTIONING_SELECTOR)) {
2600
+ return true;
2601
+ }
2602
+ chrome = chrome.parentElement?.closest(CHROME_SELECTOR) ?? null;
2603
+ }
2604
+ return false;
2605
+ };
2606
+ const showsOtherItem = (el) => {
2607
+ const choice = el.closest(OTHER_ITEM_SELECTOR);
2608
+ if (choice) return choice.getAttribute(OTHER_ITEM_ATTR) === "on";
2609
+ return !inSiteChrome(el);
2610
+ };
2591
2611
  const itemKind = (el) => {
2592
2612
  if (isCurrentItem(el)) return "current";
2593
2613
  if (!references) return "other";
2594
- return linkedIdOf(el) ? "referenced" : null;
2614
+ if (linkedIdOf(el)) return "referenced";
2615
+ return showsOtherItem(el) ? "other" : null;
2595
2616
  };
2596
2617
  const referenceFieldOf = (el) => {
2597
2618
  const linked = linkedIdOf(el);
@@ -2664,6 +2685,7 @@ function createVisualEditor(opts) {
2664
2685
  }
2665
2686
  return;
2666
2687
  }
2688
+ if (kind === "other" && (e2.ctrlKey || e2.metaKey || e2.shiftKey)) return;
2667
2689
  e2.preventDefault();
2668
2690
  e2.stopPropagation();
2669
2691
  const item = listItemIn(encoded, e2.target);
@@ -2671,11 +2693,13 @@ function createVisualEditor(opts) {
2671
2693
  select(item?.element ?? encoded, encoded, item?.index);
2672
2694
  const referenceField = kind === "referenced" ? referenceFieldOf(encoded) : void 0;
2673
2695
  const linkedId = kind === "referenced" ? linkedIdOf(encoded) : null;
2696
+ const linkHref = kind === "other" ? leavingLinkHref(e2.target) : null;
2674
2697
  opts.onEdit({
2675
2698
  ...readEditPayload(encoded),
2676
2699
  ...linkedId && { id: linkedId },
2677
2700
  ...item && { block: item.index },
2678
- ...referenceField && { referenceField }
2701
+ ...referenceField && { referenceField },
2702
+ ...linkHref && { linkHref }
2679
2703
  });
2680
2704
  };
2681
2705
  const handleKey = (e2) => {
@@ -2996,7 +3020,8 @@ function createPreprPreview(opts = {}) {
2996
3020
  locale: contentLocale,
2997
3021
  block,
2998
3022
  entryId,
2999
- referenceField
3023
+ referenceField,
3024
+ linkHref
3000
3025
  }) => {
3001
3026
  const safeHref = href ? safeEditUrl(href) : null;
3002
3027
  if (href && !safeHref) {
@@ -3010,7 +3035,8 @@ function createPreprPreview(opts = {}) {
3010
3035
  locale: contentLocale,
3011
3036
  ...block !== void 0 && { block },
3012
3037
  ...entryId && { entryId },
3013
- ...referenceField && { referenceField }
3038
+ ...referenceField && { referenceField },
3039
+ ...linkHref && { linkHref }
3014
3040
  });
3015
3041
  } else if (safeHref) {
3016
3042
  window.open(safeHref, "_blank", "noopener,noreferrer");
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "0.5.0-rc.10";
2
+ var VERSION = "0.5.0-rc.11";
3
3
 
4
4
  // src/core/features.ts
5
5
  function isEnabled(config) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  VERSION,
3
3
  resolveFeatures
4
- } from "./chunk-F46GJS6Y.js";
4
+ } from "./chunk-AOHA5INA.js";
5
5
 
6
6
  // src/core/server.ts
7
7
  var PreprError = class extends Error {
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.10";
54
+ var VERSION = "0.5.0-rc.11";
55
55
 
56
56
  // src/core/features.ts
57
57
  function isEnabled(config) {
@@ -2980,6 +2980,11 @@ var debug8 = createScopedLogger("visual-editor");
2980
2980
  var ENCODED_SELECTOR2 = "[data-prepr-encoded]";
2981
2981
  var REFERENCE_ATTR = "data-prepr-reference";
2982
2982
  var REFERENCE_SELECTOR = `[${REFERENCE_ATTR}]`;
2983
+ var OTHER_ITEM_ATTR = "data-prepr-other-item";
2984
+ var OTHER_ITEM_SELECTOR = `[${OTHER_ITEM_ATTR}="on"],[${OTHER_ITEM_ATTR}="off"]`;
2985
+ var CHROME_SELECTOR = "header, footer, nav, [role=banner], [role=contentinfo], [role=navigation]";
2986
+ var SECTIONING_SELECTOR = "article, aside, main, nav, section";
2987
+ var PLAIN_HEADER_FOOTER = "header:not([role]), footer:not([role])";
2983
2988
  var CURSOR_STYLE_MARKER = "data-prepr-visual-editor";
2984
2989
  var CURSOR_STYLES = `${ENCODED_SELECTOR2}{cursor:pointer}html[data-prepr-ve-suspended] ${ENCODED_SELECTOR2}{cursor:auto}`;
2985
2990
  var SUSPENDED_ATTR = "data-prepr-ve-suspended";
@@ -3059,10 +3064,26 @@ function createVisualEditor(opts) {
3059
3064
  }
3060
3065
  return null;
3061
3066
  };
3067
+ const inSiteChrome = (el) => {
3068
+ let chrome = el.closest(CHROME_SELECTOR);
3069
+ while (chrome) {
3070
+ if (!chrome.matches(PLAIN_HEADER_FOOTER) || !chrome.parentElement?.closest(SECTIONING_SELECTOR)) {
3071
+ return true;
3072
+ }
3073
+ chrome = chrome.parentElement?.closest(CHROME_SELECTOR) ?? null;
3074
+ }
3075
+ return false;
3076
+ };
3077
+ const showsOtherItem = (el) => {
3078
+ const choice = el.closest(OTHER_ITEM_SELECTOR);
3079
+ if (choice) return choice.getAttribute(OTHER_ITEM_ATTR) === "on";
3080
+ return !inSiteChrome(el);
3081
+ };
3062
3082
  const itemKind = (el) => {
3063
3083
  if (isCurrentItem(el)) return "current";
3064
3084
  if (!references) return "other";
3065
- return linkedIdOf(el) ? "referenced" : null;
3085
+ if (linkedIdOf(el)) return "referenced";
3086
+ return showsOtherItem(el) ? "other" : null;
3066
3087
  };
3067
3088
  const referenceFieldOf = (el) => {
3068
3089
  const linked = linkedIdOf(el);
@@ -3135,6 +3156,7 @@ function createVisualEditor(opts) {
3135
3156
  }
3136
3157
  return;
3137
3158
  }
3159
+ if (kind === "other" && (e2.ctrlKey || e2.metaKey || e2.shiftKey)) return;
3138
3160
  e2.preventDefault();
3139
3161
  e2.stopPropagation();
3140
3162
  const item = listItemIn(encoded, e2.target);
@@ -3142,11 +3164,13 @@ function createVisualEditor(opts) {
3142
3164
  select(item?.element ?? encoded, encoded, item?.index);
3143
3165
  const referenceField = kind === "referenced" ? referenceFieldOf(encoded) : void 0;
3144
3166
  const linkedId = kind === "referenced" ? linkedIdOf(encoded) : null;
3167
+ const linkHref = kind === "other" ? leavingLinkHref(e2.target) : null;
3145
3168
  opts.onEdit({
3146
3169
  ...readEditPayload(encoded),
3147
3170
  ...linkedId && { id: linkedId },
3148
3171
  ...item && { block: item.index },
3149
- ...referenceField && { referenceField }
3172
+ ...referenceField && { referenceField },
3173
+ ...linkHref && { linkHref }
3150
3174
  });
3151
3175
  };
3152
3176
  const handleKey = (e2) => {
@@ -3467,7 +3491,8 @@ function createPreprPreview(opts = {}) {
3467
3491
  locale: contentLocale,
3468
3492
  block,
3469
3493
  entryId,
3470
- referenceField
3494
+ referenceField,
3495
+ linkHref
3471
3496
  }) => {
3472
3497
  const safeHref = href ? safeEditUrl(href) : null;
3473
3498
  if (href && !safeHref) {
@@ -3481,7 +3506,8 @@ function createPreprPreview(opts = {}) {
3481
3506
  locale: contentLocale,
3482
3507
  ...block !== void 0 && { block },
3483
3508
  ...entryId && { entryId },
3484
- ...referenceField && { referenceField }
3509
+ ...referenceField && { referenceField },
3510
+ ...linkHref && { linkHref }
3485
3511
  });
3486
3512
  } else if (safeHref) {
3487
3513
  window.open(safeHref, "_blank", "noopener,noreferrer");
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.10";
8
+ declare const VERSION = "0.5.0-rc.11";
9
9
 
10
10
  /**
11
11
  * Resolve a `PreprFeatures` bag to plain booleans, defaulting every omitted key
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.10";
8
+ declare const VERSION = "0.5.0-rc.11";
9
9
 
10
10
  /**
11
11
  * Resolve a `PreprFeatures` bag to plain booleans, defaulting every omitted key
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  setTrackingParam,
19
19
  stegaClean,
20
20
  trackEvent
21
- } from "./chunk-IDEC77LZ.js";
21
+ } from "./chunk-6423Q744.js";
22
22
  import {
23
23
  PreprError,
24
24
  extractAccessToken,
@@ -29,11 +29,11 @@ import {
29
29
  getPreprUUIDFromHeaders,
30
30
  getToolbarPropsFromHeaders,
31
31
  validatePreprToken
32
- } from "./chunk-TBBU3LDD.js";
32
+ } from "./chunk-QSXIHRH4.js";
33
33
  import {
34
34
  VERSION,
35
35
  resolveFeatures
36
- } from "./chunk-F46GJS6Y.js";
36
+ } from "./chunk-AOHA5INA.js";
37
37
  import {
38
38
  createLiveBridge,
39
39
  createLiveStore
@@ -2945,6 +2945,11 @@ var debug8 = createScopedLogger("visual-editor");
2945
2945
  var ENCODED_SELECTOR2 = "[data-prepr-encoded]";
2946
2946
  var REFERENCE_ATTR = "data-prepr-reference";
2947
2947
  var REFERENCE_SELECTOR = `[${REFERENCE_ATTR}]`;
2948
+ var OTHER_ITEM_ATTR = "data-prepr-other-item";
2949
+ var OTHER_ITEM_SELECTOR = `[${OTHER_ITEM_ATTR}="on"],[${OTHER_ITEM_ATTR}="off"]`;
2950
+ var CHROME_SELECTOR = "header, footer, nav, [role=banner], [role=contentinfo], [role=navigation]";
2951
+ var SECTIONING_SELECTOR = "article, aside, main, nav, section";
2952
+ var PLAIN_HEADER_FOOTER = "header:not([role]), footer:not([role])";
2948
2953
  var CURSOR_STYLE_MARKER = "data-prepr-visual-editor";
2949
2954
  var CURSOR_STYLES = `${ENCODED_SELECTOR2}{cursor:pointer}html[data-prepr-ve-suspended] ${ENCODED_SELECTOR2}{cursor:auto}`;
2950
2955
  var SUSPENDED_ATTR = "data-prepr-ve-suspended";
@@ -3024,10 +3029,26 @@ function createVisualEditor(opts) {
3024
3029
  }
3025
3030
  return null;
3026
3031
  };
3032
+ const inSiteChrome = (el) => {
3033
+ let chrome = el.closest(CHROME_SELECTOR);
3034
+ while (chrome) {
3035
+ if (!chrome.matches(PLAIN_HEADER_FOOTER) || !chrome.parentElement?.closest(SECTIONING_SELECTOR)) {
3036
+ return true;
3037
+ }
3038
+ chrome = chrome.parentElement?.closest(CHROME_SELECTOR) ?? null;
3039
+ }
3040
+ return false;
3041
+ };
3042
+ const showsOtherItem = (el) => {
3043
+ const choice = el.closest(OTHER_ITEM_SELECTOR);
3044
+ if (choice) return choice.getAttribute(OTHER_ITEM_ATTR) === "on";
3045
+ return !inSiteChrome(el);
3046
+ };
3027
3047
  const itemKind = (el) => {
3028
3048
  if (isCurrentItem(el)) return "current";
3029
3049
  if (!references) return "other";
3030
- return linkedIdOf(el) ? "referenced" : null;
3050
+ if (linkedIdOf(el)) return "referenced";
3051
+ return showsOtherItem(el) ? "other" : null;
3031
3052
  };
3032
3053
  const referenceFieldOf = (el) => {
3033
3054
  const linked = linkedIdOf(el);
@@ -3100,6 +3121,7 @@ function createVisualEditor(opts) {
3100
3121
  }
3101
3122
  return;
3102
3123
  }
3124
+ if (kind === "other" && (e2.ctrlKey || e2.metaKey || e2.shiftKey)) return;
3103
3125
  e2.preventDefault();
3104
3126
  e2.stopPropagation();
3105
3127
  const item = listItemIn(encoded, e2.target);
@@ -3107,11 +3129,13 @@ function createVisualEditor(opts) {
3107
3129
  select(item?.element ?? encoded, encoded, item?.index);
3108
3130
  const referenceField = kind === "referenced" ? referenceFieldOf(encoded) : void 0;
3109
3131
  const linkedId = kind === "referenced" ? linkedIdOf(encoded) : null;
3132
+ const linkHref = kind === "other" ? leavingLinkHref(e2.target) : null;
3110
3133
  opts.onEdit({
3111
3134
  ...readEditPayload(encoded),
3112
3135
  ...linkedId && { id: linkedId },
3113
3136
  ...item && { block: item.index },
3114
- ...referenceField && { referenceField }
3137
+ ...referenceField && { referenceField },
3138
+ ...linkHref && { linkHref }
3115
3139
  });
3116
3140
  };
3117
3141
  const handleKey = (e2) => {
@@ -3432,7 +3456,8 @@ function createPreprPreview(opts = {}) {
3432
3456
  locale: contentLocale,
3433
3457
  block,
3434
3458
  entryId,
3435
- referenceField
3459
+ referenceField,
3460
+ linkHref
3436
3461
  }) => {
3437
3462
  const safeHref = href ? safeEditUrl(href) : null;
3438
3463
  if (href && !safeHref) {
@@ -3446,7 +3471,8 @@ function createPreprPreview(opts = {}) {
3446
3471
  locale: contentLocale,
3447
3472
  ...block !== void 0 && { block },
3448
3473
  ...entryId && { entryId },
3449
- ...referenceField && { referenceField }
3474
+ ...referenceField && { referenceField },
3475
+ ...linkHref && { linkHref }
3450
3476
  });
3451
3477
  } else if (safeHref) {
3452
3478
  window.open(safeHref, "_blank", "noopener,noreferrer");
@@ -3544,7 +3570,7 @@ function createPreprPreview(opts = {}) {
3544
3570
  var import_react = require("react");
3545
3571
 
3546
3572
  // src/version.ts
3547
- var VERSION = "0.5.0-rc.10";
3573
+ var VERSION = "0.5.0-rc.11";
3548
3574
 
3549
3575
  // src/core/pixel.ts
3550
3576
  var PIXEL_SCRIPT_URL = "https://cdn.tracking.prepr.io/js/prepr.min.js";
@@ -2,8 +2,8 @@
2
2
  import {
3
3
  createPreprPreview,
4
4
  loadTrackingPixel
5
- } from "../chunk-IDEC77LZ.js";
6
- import "../chunk-F46GJS6Y.js";
5
+ } from "../chunk-6423Q744.js";
6
+ import "../chunk-AOHA5INA.js";
7
7
  import "../chunk-URXSDJOU.js";
8
8
  import "../chunk-S3VT4UWM.js";
9
9
 
@@ -49,7 +49,7 @@ module.exports = __toCommonJS(nextjs_exports);
49
49
  var import_server = require("next/server");
50
50
 
51
51
  // src/version.ts
52
- var VERSION = "0.5.0-rc.10";
52
+ var VERSION = "0.5.0-rc.11";
53
53
 
54
54
  // src/core/constants.ts
55
55
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
@@ -2,7 +2,7 @@
2
2
  import { NextResponse } from "next/server";
3
3
 
4
4
  // src/version.ts
5
- var VERSION = "0.5.0-rc.10";
5
+ var VERSION = "0.5.0-rc.11";
6
6
 
7
7
  // src/core/constants.ts
8
8
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
@@ -1,8 +1,8 @@
1
1
  "use server";
2
2
  import {
3
3
  isPreviewFromHeaders
4
- } from "../chunk-TBBU3LDD.js";
5
- import "../chunk-F46GJS6Y.js";
4
+ } from "../chunk-QSXIHRH4.js";
5
+ import "../chunk-AOHA5INA.js";
6
6
  import {
7
7
  parsePatchLog
8
8
  } from "../chunk-KD3GK6TO.js";
@@ -35,7 +35,7 @@ __export(nuxt_exports, {
35
35
  module.exports = __toCommonJS(nuxt_exports);
36
36
 
37
37
  // src/version.ts
38
- var VERSION = "0.5.0-rc.10";
38
+ var VERSION = "0.5.0-rc.11";
39
39
 
40
40
  // src/core/constants.ts
41
41
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "0.5.0-rc.10";
2
+ var VERSION = "0.5.0-rc.11";
3
3
 
4
4
  // src/core/constants.ts
5
5
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
@@ -2944,6 +2944,11 @@ var debug8 = createScopedLogger("visual-editor");
2944
2944
  var ENCODED_SELECTOR2 = "[data-prepr-encoded]";
2945
2945
  var REFERENCE_ATTR = "data-prepr-reference";
2946
2946
  var REFERENCE_SELECTOR = `[${REFERENCE_ATTR}]`;
2947
+ var OTHER_ITEM_ATTR = "data-prepr-other-item";
2948
+ var OTHER_ITEM_SELECTOR = `[${OTHER_ITEM_ATTR}="on"],[${OTHER_ITEM_ATTR}="off"]`;
2949
+ var CHROME_SELECTOR = "header, footer, nav, [role=banner], [role=contentinfo], [role=navigation]";
2950
+ var SECTIONING_SELECTOR = "article, aside, main, nav, section";
2951
+ var PLAIN_HEADER_FOOTER = "header:not([role]), footer:not([role])";
2947
2952
  var CURSOR_STYLE_MARKER = "data-prepr-visual-editor";
2948
2953
  var CURSOR_STYLES = `${ENCODED_SELECTOR2}{cursor:pointer}html[data-prepr-ve-suspended] ${ENCODED_SELECTOR2}{cursor:auto}`;
2949
2954
  var SUSPENDED_ATTR = "data-prepr-ve-suspended";
@@ -3023,10 +3028,26 @@ function createVisualEditor(opts) {
3023
3028
  }
3024
3029
  return null;
3025
3030
  };
3031
+ const inSiteChrome = (el) => {
3032
+ let chrome = el.closest(CHROME_SELECTOR);
3033
+ while (chrome) {
3034
+ if (!chrome.matches(PLAIN_HEADER_FOOTER) || !chrome.parentElement?.closest(SECTIONING_SELECTOR)) {
3035
+ return true;
3036
+ }
3037
+ chrome = chrome.parentElement?.closest(CHROME_SELECTOR) ?? null;
3038
+ }
3039
+ return false;
3040
+ };
3041
+ const showsOtherItem = (el) => {
3042
+ const choice = el.closest(OTHER_ITEM_SELECTOR);
3043
+ if (choice) return choice.getAttribute(OTHER_ITEM_ATTR) === "on";
3044
+ return !inSiteChrome(el);
3045
+ };
3026
3046
  const itemKind = (el) => {
3027
3047
  if (isCurrentItem(el)) return "current";
3028
3048
  if (!references) return "other";
3029
- return linkedIdOf(el) ? "referenced" : null;
3049
+ if (linkedIdOf(el)) return "referenced";
3050
+ return showsOtherItem(el) ? "other" : null;
3030
3051
  };
3031
3052
  const referenceFieldOf = (el) => {
3032
3053
  const linked = linkedIdOf(el);
@@ -3099,6 +3120,7 @@ function createVisualEditor(opts) {
3099
3120
  }
3100
3121
  return;
3101
3122
  }
3123
+ if (kind === "other" && (e2.ctrlKey || e2.metaKey || e2.shiftKey)) return;
3102
3124
  e2.preventDefault();
3103
3125
  e2.stopPropagation();
3104
3126
  const item = listItemIn(encoded, e2.target);
@@ -3106,11 +3128,13 @@ function createVisualEditor(opts) {
3106
3128
  select(item?.element ?? encoded, encoded, item?.index);
3107
3129
  const referenceField = kind === "referenced" ? referenceFieldOf(encoded) : void 0;
3108
3130
  const linkedId = kind === "referenced" ? linkedIdOf(encoded) : null;
3131
+ const linkHref = kind === "other" ? leavingLinkHref(e2.target) : null;
3109
3132
  opts.onEdit({
3110
3133
  ...readEditPayload(encoded),
3111
3134
  ...linkedId && { id: linkedId },
3112
3135
  ...item && { block: item.index },
3113
- ...referenceField && { referenceField }
3136
+ ...referenceField && { referenceField },
3137
+ ...linkHref && { linkHref }
3114
3138
  });
3115
3139
  };
3116
3140
  const handleKey = (e2) => {
@@ -3431,7 +3455,8 @@ function createPreprPreview(opts = {}) {
3431
3455
  locale: contentLocale,
3432
3456
  block,
3433
3457
  entryId,
3434
- referenceField
3458
+ referenceField,
3459
+ linkHref
3435
3460
  }) => {
3436
3461
  const safeHref = href ? safeEditUrl(href) : null;
3437
3462
  if (href && !safeHref) {
@@ -3445,7 +3470,8 @@ function createPreprPreview(opts = {}) {
3445
3470
  locale: contentLocale,
3446
3471
  ...block !== void 0 && { block },
3447
3472
  ...entryId && { entryId },
3448
- ...referenceField && { referenceField }
3473
+ ...referenceField && { referenceField },
3474
+ ...linkHref && { linkHref }
3449
3475
  });
3450
3476
  } else if (safeHref) {
3451
3477
  window.open(safeHref, "_blank", "noopener,noreferrer");
@@ -3540,7 +3566,7 @@ function createPreprPreview(opts = {}) {
3540
3566
  }
3541
3567
 
3542
3568
  // src/version.ts
3543
- var VERSION = "0.5.0-rc.10";
3569
+ var VERSION = "0.5.0-rc.11";
3544
3570
 
3545
3571
  // src/core/pixel.ts
3546
3572
  var PIXEL_SCRIPT_URL = "https://cdn.tracking.prepr.io/js/prepr.min.js";
@@ -2920,6 +2920,11 @@ var debug8 = createScopedLogger("visual-editor");
2920
2920
  var ENCODED_SELECTOR2 = "[data-prepr-encoded]";
2921
2921
  var REFERENCE_ATTR = "data-prepr-reference";
2922
2922
  var REFERENCE_SELECTOR = `[${REFERENCE_ATTR}]`;
2923
+ var OTHER_ITEM_ATTR = "data-prepr-other-item";
2924
+ var OTHER_ITEM_SELECTOR = `[${OTHER_ITEM_ATTR}="on"],[${OTHER_ITEM_ATTR}="off"]`;
2925
+ var CHROME_SELECTOR = "header, footer, nav, [role=banner], [role=contentinfo], [role=navigation]";
2926
+ var SECTIONING_SELECTOR = "article, aside, main, nav, section";
2927
+ var PLAIN_HEADER_FOOTER = "header:not([role]), footer:not([role])";
2923
2928
  var CURSOR_STYLE_MARKER = "data-prepr-visual-editor";
2924
2929
  var CURSOR_STYLES = `${ENCODED_SELECTOR2}{cursor:pointer}html[data-prepr-ve-suspended] ${ENCODED_SELECTOR2}{cursor:auto}`;
2925
2930
  var SUSPENDED_ATTR = "data-prepr-ve-suspended";
@@ -2999,10 +3004,26 @@ function createVisualEditor(opts) {
2999
3004
  }
3000
3005
  return null;
3001
3006
  };
3007
+ const inSiteChrome = (el) => {
3008
+ let chrome = el.closest(CHROME_SELECTOR);
3009
+ while (chrome) {
3010
+ if (!chrome.matches(PLAIN_HEADER_FOOTER) || !chrome.parentElement?.closest(SECTIONING_SELECTOR)) {
3011
+ return true;
3012
+ }
3013
+ chrome = chrome.parentElement?.closest(CHROME_SELECTOR) ?? null;
3014
+ }
3015
+ return false;
3016
+ };
3017
+ const showsOtherItem = (el) => {
3018
+ const choice = el.closest(OTHER_ITEM_SELECTOR);
3019
+ if (choice) return choice.getAttribute(OTHER_ITEM_ATTR) === "on";
3020
+ return !inSiteChrome(el);
3021
+ };
3002
3022
  const itemKind = (el) => {
3003
3023
  if (isCurrentItem(el)) return "current";
3004
3024
  if (!references) return "other";
3005
- return linkedIdOf(el) ? "referenced" : null;
3025
+ if (linkedIdOf(el)) return "referenced";
3026
+ return showsOtherItem(el) ? "other" : null;
3006
3027
  };
3007
3028
  const referenceFieldOf = (el) => {
3008
3029
  const linked = linkedIdOf(el);
@@ -3075,6 +3096,7 @@ function createVisualEditor(opts) {
3075
3096
  }
3076
3097
  return;
3077
3098
  }
3099
+ if (kind === "other" && (e2.ctrlKey || e2.metaKey || e2.shiftKey)) return;
3078
3100
  e2.preventDefault();
3079
3101
  e2.stopPropagation();
3080
3102
  const item = listItemIn(encoded, e2.target);
@@ -3082,11 +3104,13 @@ function createVisualEditor(opts) {
3082
3104
  select(item?.element ?? encoded, encoded, item?.index);
3083
3105
  const referenceField = kind === "referenced" ? referenceFieldOf(encoded) : void 0;
3084
3106
  const linkedId = kind === "referenced" ? linkedIdOf(encoded) : null;
3107
+ const linkHref = kind === "other" ? leavingLinkHref(e2.target) : null;
3085
3108
  opts.onEdit({
3086
3109
  ...readEditPayload(encoded),
3087
3110
  ...linkedId && { id: linkedId },
3088
3111
  ...item && { block: item.index },
3089
- ...referenceField && { referenceField }
3112
+ ...referenceField && { referenceField },
3113
+ ...linkHref && { linkHref }
3090
3114
  });
3091
3115
  };
3092
3116
  const handleKey = (e2) => {
@@ -3407,7 +3431,8 @@ function createPreprPreview(opts = {}) {
3407
3431
  locale: contentLocale,
3408
3432
  block,
3409
3433
  entryId,
3410
- referenceField
3434
+ referenceField,
3435
+ linkHref
3411
3436
  }) => {
3412
3437
  const safeHref = href ? safeEditUrl(href) : null;
3413
3438
  if (href && !safeHref) {
@@ -3421,7 +3446,8 @@ function createPreprPreview(opts = {}) {
3421
3446
  locale: contentLocale,
3422
3447
  ...block !== void 0 && { block },
3423
3448
  ...entryId && { entryId },
3424
- ...referenceField && { referenceField }
3449
+ ...referenceField && { referenceField },
3450
+ ...linkHref && { linkHref }
3425
3451
  });
3426
3452
  } else if (safeHref) {
3427
3453
  window.open(safeHref, "_blank", "noopener,noreferrer");
@@ -3516,7 +3542,7 @@ function createPreprPreview(opts = {}) {
3516
3542
  }
3517
3543
 
3518
3544
  // src/version.ts
3519
- var VERSION = "0.5.0-rc.10";
3545
+ var VERSION = "0.5.0-rc.11";
3520
3546
 
3521
3547
  // src/core/pixel.ts
3522
3548
  var PIXEL_SCRIPT_URL = "https://cdn.tracking.prepr.io/js/prepr.min.js";
@@ -35,7 +35,7 @@ __export(sveltekit_exports, {
35
35
  module.exports = __toCommonJS(sveltekit_exports);
36
36
 
37
37
  // src/version.ts
38
- var VERSION = "0.5.0-rc.10";
38
+ var VERSION = "0.5.0-rc.11";
39
39
 
40
40
  // src/core/constants.ts
41
41
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "0.5.0-rc.10";
2
+ var VERSION = "0.5.0-rc.11";
3
3
 
4
4
  // src/core/constants.ts
5
5
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@preprio/toolkit",
3
- "version": "0.5.0-rc.10",
3
+ "version": "0.5.0-rc.11",
4
4
  "description": "Prepr personalization, A/B testing and preview toolkit for React, Next.js, Nuxt, Astro, SvelteKit and Express",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Prepr B.V. (https://prepr.io)",