@bitcobblers/wod-wiki-ui 0.56.2210 → 0.58.2220

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.
@@ -350,6 +350,33 @@ var lineIdsExtension = view.ViewPlugin.fromClass(
350
350
  decorations: (v) => v.decorations
351
351
  }
352
352
  );
353
+ var affiliateTagFacet = state.Facet.define({
354
+ combine(values2) {
355
+ for (let i = values2.length - 1; i >= 0; i--) {
356
+ const trimmed = values2[i]?.trim();
357
+ if (trimmed) return trimmed;
358
+ }
359
+ return null;
360
+ }
361
+ });
362
+ var AMAZON_RETAIL_HOST_RE = /^(?:www\.|smile\.|m\.)?amazon\.[a-z]{2,3}(?:\.[a-z]{2})?$/i;
363
+ function isAmazonRetailHost(hostname) {
364
+ return AMAZON_RETAIL_HOST_RE.test(hostname);
365
+ }
366
+ function applyAmazonAffiliateTag(url, associateTag) {
367
+ const tag = associateTag?.trim();
368
+ if (!tag || !/^https?:\/\//i.test(url)) return url;
369
+ try {
370
+ const parsed = new URL(url);
371
+ if (!isAmazonRetailHost(parsed.hostname)) return url;
372
+ parsed.searchParams.set("tag", tag);
373
+ return parsed.toString();
374
+ } catch {
375
+ return url;
376
+ }
377
+ }
378
+
379
+ // src/extensions/link-open.ts
353
380
  var navigationFacet = state.Facet.define({
354
381
  combine(values2) {
355
382
  return values2.length > 0 ? values2[values2.length - 1] : null;
@@ -440,12 +467,13 @@ var ctrlClickPlugin = view.ViewPlugin.fromClass(
440
467
  if (!url) return;
441
468
  e.preventDefault();
442
469
  e.stopPropagation();
470
+ const resolvedUrl = applyAmazonAffiliateTag(url, view.state.facet(affiliateTagFacet));
443
471
  const navHook = view.state.facet(navigationFacet);
444
472
  if (navHook) {
445
- navHook(url, view);
473
+ navHook(resolvedUrl, view);
446
474
  } else if (typeof window !== "undefined") {
447
- const isInternal = url.startsWith("/") || url.startsWith("#");
448
- window.open(url, isInternal ? "_self" : "_blank", isInternal ? void 0 : "noopener,noreferrer");
475
+ const isInternal = resolvedUrl.startsWith("/") || resolvedUrl.startsWith("#");
476
+ window.open(resolvedUrl, isInternal ? "_self" : "_blank", isInternal ? void 0 : "noopener,noreferrer");
449
477
  }
450
478
  };
451
479
  view.dom.addEventListener("mousedown", this.handler, true);
@@ -1155,17 +1183,25 @@ var SectionGeometryPlugin = class {
1155
1183
  constructor(view) {
1156
1184
  this.view = view;
1157
1185
  this.measure();
1186
+ if (typeof ResizeObserver !== "undefined" && this.view.contentDOM) {
1187
+ this.resizeObserver = new ResizeObserver(() => {
1188
+ this.view.requestMeasure();
1189
+ this.measure();
1190
+ });
1191
+ this.resizeObserver.observe(this.view.contentDOM);
1192
+ }
1158
1193
  }
1159
1194
  view;
1160
1195
  rects = [];
1161
1196
  docVersion = 0;
1162
1197
  listeners = /* @__PURE__ */ new Set();
1163
1198
  pendingNotify = null;
1199
+ resizeObserver = null;
1164
1200
  update(update) {
1165
1201
  if (update.docChanged) {
1166
1202
  this.docVersion++;
1167
1203
  }
1168
- if (update.docChanged || update.geometryChanged) {
1204
+ if (update.docChanged || update.geometryChanged || update.viewportChanged) {
1169
1205
  this.measure();
1170
1206
  }
1171
1207
  }
@@ -1229,6 +1265,8 @@ var SectionGeometryPlugin = class {
1229
1265
  if (this.pendingNotify !== null && typeof cancelAnimationFrame === "function") {
1230
1266
  cancelAnimationFrame(this.pendingNotify);
1231
1267
  }
1268
+ this.resizeObserver?.disconnect();
1269
+ this.resizeObserver = null;
1232
1270
  this.listeners.clear();
1233
1271
  }
1234
1272
  };
@@ -2187,6 +2225,7 @@ function createTagDraftRow(view, root, key, onCommit) {
2187
2225
  const discard = () => settle(false);
2188
2226
  attachSuggestions(input, view, root, "value", key, [], commit);
2189
2227
  input.addEventListener("keydown", (e) => {
2228
+ if (e.isComposing || e.keyCode === 229) return;
2190
2229
  if (e.key === "Escape") {
2191
2230
  e.preventDefault();
2192
2231
  discard();
@@ -2306,6 +2345,7 @@ function createMetricDraftRow(view, root, referenceProvider, commit) {
2306
2345
  customKeyInput.setAttribute("aria-label", "Metric key");
2307
2346
  customKeyInput.dataset.frontmatterField = "key";
2308
2347
  customKeyInput.addEventListener("keydown", (e) => {
2348
+ if (e.isComposing || e.keyCode === 229) return;
2309
2349
  if (e.key === "Escape") {
2310
2350
  e.preventDefault();
2311
2351
  settle(false);
@@ -2330,6 +2370,7 @@ function createMetricDraftRow(view, root, referenceProvider, commit) {
2330
2370
  attachFor();
2331
2371
  select.addEventListener("change", attachFor);
2332
2372
  input.addEventListener("keydown", (e) => {
2373
+ if (e.isComposing || e.keyCode === 229) return;
2333
2374
  if (e.defaultPrevented && e.key !== "Escape") return;
2334
2375
  if (e.key === "Escape") {
2335
2376
  e.preventDefault();
@@ -2400,6 +2441,7 @@ function createSummaryDraftRow(view, commit) {
2400
2441
  view.requestMeasure();
2401
2442
  };
2402
2443
  keyInput.addEventListener("keydown", (e) => {
2444
+ if (e.isComposing || e.keyCode === 229) return;
2403
2445
  if (e.key === "Escape") {
2404
2446
  e.preventDefault();
2405
2447
  settle(false);
@@ -2412,6 +2454,7 @@ function createSummaryDraftRow(view, commit) {
2412
2454
  }
2413
2455
  });
2414
2456
  valInput.addEventListener("keydown", (e) => {
2457
+ if (e.isComposing || e.keyCode === 229) return;
2415
2458
  if (e.key === "Escape") {
2416
2459
  e.preventDefault();
2417
2460
  settle(false);
@@ -4065,11 +4108,12 @@ function appendFormattedCellContent(container, rawText, view) {
4065
4108
  } else if (match[2] !== void 0 && match[3] !== void 0) {
4066
4109
  const label = match[2];
4067
4110
  const url = match[3];
4111
+ const isExternal = /^https?:\/\//i.test(url);
4112
+ const resolvedUrl = isExternal ? applyAmazonAffiliateTag(url, view.state.facet(affiliateTagFacet)) : url;
4068
4113
  const a = document.createElement("a");
4069
- a.href = url;
4114
+ a.href = resolvedUrl;
4070
4115
  a.textContent = label;
4071
4116
  a.className = "cm-table-cell-link underline underline-offset-2";
4072
- const isExternal = /^https?:\/\//i.test(url);
4073
4117
  if (isExternal) {
4074
4118
  a.target = "_blank";
4075
4119
  a.rel = "noopener noreferrer";
@@ -4184,6 +4228,7 @@ var MarkdownTableWidget = class extends view.WidgetType {
4184
4228
  input.addEventListener("click", (e) => e.stopPropagation());
4185
4229
  input.addEventListener("keydown", (e) => {
4186
4230
  e.stopPropagation();
4231
+ if (e.isComposing || e.keyCode === 229) return;
4187
4232
  if (e.key === "Tab") {
4188
4233
  e.preventDefault();
4189
4234
  const dir = e.shiftKey ? -1 : 1;
@@ -4527,7 +4572,8 @@ function openLinkEditPopover(anchorEl, view, match) {
4527
4572
  openBtn.addEventListener("click", (e) => {
4528
4573
  e.preventDefault();
4529
4574
  e.stopPropagation();
4530
- const targetUrl = urlInput.value.trim() || match.url;
4575
+ const rawUrl = urlInput.value.trim() || match.url;
4576
+ const targetUrl = applyAmazonAffiliateTag(rawUrl, view.state.facet(affiliateTagFacet));
4531
4577
  closeActiveLinkPopover();
4532
4578
  const navHook = view.state.facet(navigationFacet);
4533
4579
  if (!isExternalHttpUrl(targetUrl) && navHook) {
@@ -4578,6 +4624,7 @@ function openLinkEditPopover(anchorEl, view, match) {
4578
4624
  });
4579
4625
  const handleKeyDown = (e) => {
4580
4626
  e.stopPropagation();
4627
+ if (e.isComposing || e.keyCode === 229) return;
4581
4628
  if (e.key === "Enter") {
4582
4629
  e.preventDefault();
4583
4630
  applyChanges();
@@ -4614,21 +4661,23 @@ function openLinkEditPopover(anchorEl, view, match) {
4614
4661
  labelInput.select();
4615
4662
  }
4616
4663
  var LinkPillWidget = class extends view.WidgetType {
4617
- constructor(label, url, from, to, readOnly) {
4664
+ constructor(label, url, from, to, readOnly, affiliateTag) {
4618
4665
  super();
4619
4666
  this.label = label;
4620
4667
  this.url = url;
4621
4668
  this.from = from;
4622
4669
  this.to = to;
4623
4670
  this.readOnly = readOnly;
4671
+ this.affiliateTag = affiliateTag;
4624
4672
  }
4625
4673
  label;
4626
4674
  url;
4627
4675
  from;
4628
4676
  to;
4629
4677
  readOnly;
4678
+ affiliateTag;
4630
4679
  eq(other) {
4631
- return this.label === other.label && this.url === other.url && this.from === other.from && this.to === other.to && this.readOnly === other.readOnly;
4680
+ return this.label === other.label && this.url === other.url && this.from === other.from && this.to === other.to && this.readOnly === other.readOnly && this.affiliateTag === other.affiliateTag;
4632
4681
  }
4633
4682
  toDOM(view) {
4634
4683
  const isExternal = isExternalHttpUrl(this.url);
@@ -4655,9 +4704,10 @@ var LinkPillWidget = class extends view.WidgetType {
4655
4704
  });
4656
4705
  }
4657
4706
  pill.appendChild(label);
4707
+ const resolvedUrl = isExternal ? applyAmazonAffiliateTag(this.url, this.affiliateTag) : this.url;
4658
4708
  const open = document.createElement("a");
4659
4709
  open.className = "cm-link-pill-open";
4660
- open.href = this.url;
4710
+ open.href = resolvedUrl;
4661
4711
  if (isExternal) {
4662
4712
  open.target = "_blank";
4663
4713
  open.rel = "noopener noreferrer";
@@ -4669,11 +4719,11 @@ var LinkPillWidget = class extends view.WidgetType {
4669
4719
  if (navHook) {
4670
4720
  e.preventDefault();
4671
4721
  e.stopPropagation();
4672
- navHook(this.url, view);
4722
+ navHook(resolvedUrl, view);
4673
4723
  }
4674
4724
  });
4675
4725
  }
4676
- open.title = this.url;
4726
+ open.title = resolvedUrl;
4677
4727
  open.appendChild(createLinkArrowIcon(isExternal));
4678
4728
  pill.appendChild(open);
4679
4729
  return pill;
@@ -4807,7 +4857,8 @@ function buildLinkDecos(state$1) {
4807
4857
  link.url,
4808
4858
  link.from,
4809
4859
  link.to,
4810
- state$1.readOnly
4860
+ state$1.readOnly,
4861
+ state$1.facet(affiliateTagFacet)
4811
4862
  )
4812
4863
  })
4813
4864
  );
@@ -17452,6 +17503,8 @@ exports.DefaultFrontmatterWidget = DefaultFrontmatterWidget;
17452
17503
  exports.INTERNAL_FRONTMATTER_KEYS = INTERNAL_FRONTMATTER_KEYS;
17453
17504
  exports.activeCursorSection = activeCursorSection;
17454
17505
  exports.addRuntimePanel = addRuntimePanel;
17506
+ exports.affiliateTagFacet = affiliateTagFacet;
17507
+ exports.applyAmazonAffiliateTag = applyAmazonAffiliateTag;
17455
17508
  exports.attachmentUrlFacet = attachmentUrlFacet;
17456
17509
  exports.autocompleteTooltipTheme = autocompleteTooltipTheme;
17457
17510
  exports.configureOverlayActions = configureOverlayActions;
@@ -17490,6 +17543,7 @@ exports.handleFenceAutoWrap = handleFenceAutoWrap;
17490
17543
  exports.handleSmartUrlPaste = handleSmartUrlPaste;
17491
17544
  exports.inlineButtonDecoration = inlineButtonDecoration;
17492
17545
  exports.insertMarkdownLinkCommand = insertMarkdownLinkCommand;
17546
+ exports.isAmazonRetailHost = isAmazonRetailHost;
17493
17547
  exports.isEditorFocused = isEditorFocused;
17494
17548
  exports.isInternalFrontmatterKey = isInternalFrontmatterKey;
17495
17549
  exports.isNavigableUrl = isNavigableUrl;