@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.
@@ -331,6 +331,33 @@ var lineIdsExtension = ViewPlugin.fromClass(
331
331
  decorations: (v) => v.decorations
332
332
  }
333
333
  );
334
+ var affiliateTagFacet = Facet.define({
335
+ combine(values2) {
336
+ for (let i = values2.length - 1; i >= 0; i--) {
337
+ const trimmed = values2[i]?.trim();
338
+ if (trimmed) return trimmed;
339
+ }
340
+ return null;
341
+ }
342
+ });
343
+ var AMAZON_RETAIL_HOST_RE = /^(?:www\.|smile\.|m\.)?amazon\.[a-z]{2,3}(?:\.[a-z]{2})?$/i;
344
+ function isAmazonRetailHost(hostname) {
345
+ return AMAZON_RETAIL_HOST_RE.test(hostname);
346
+ }
347
+ function applyAmazonAffiliateTag(url, associateTag) {
348
+ const tag = associateTag?.trim();
349
+ if (!tag || !/^https?:\/\//i.test(url)) return url;
350
+ try {
351
+ const parsed = new URL(url);
352
+ if (!isAmazonRetailHost(parsed.hostname)) return url;
353
+ parsed.searchParams.set("tag", tag);
354
+ return parsed.toString();
355
+ } catch {
356
+ return url;
357
+ }
358
+ }
359
+
360
+ // src/extensions/link-open.ts
334
361
  var navigationFacet = Facet.define({
335
362
  combine(values2) {
336
363
  return values2.length > 0 ? values2[values2.length - 1] : null;
@@ -421,12 +448,13 @@ var ctrlClickPlugin = ViewPlugin.fromClass(
421
448
  if (!url) return;
422
449
  e.preventDefault();
423
450
  e.stopPropagation();
451
+ const resolvedUrl = applyAmazonAffiliateTag(url, view.state.facet(affiliateTagFacet));
424
452
  const navHook = view.state.facet(navigationFacet);
425
453
  if (navHook) {
426
- navHook(url, view);
454
+ navHook(resolvedUrl, view);
427
455
  } else if (typeof window !== "undefined") {
428
- const isInternal = url.startsWith("/") || url.startsWith("#");
429
- window.open(url, isInternal ? "_self" : "_blank", isInternal ? void 0 : "noopener,noreferrer");
456
+ const isInternal = resolvedUrl.startsWith("/") || resolvedUrl.startsWith("#");
457
+ window.open(resolvedUrl, isInternal ? "_self" : "_blank", isInternal ? void 0 : "noopener,noreferrer");
430
458
  }
431
459
  };
432
460
  view.dom.addEventListener("mousedown", this.handler, true);
@@ -1136,17 +1164,25 @@ var SectionGeometryPlugin = class {
1136
1164
  constructor(view) {
1137
1165
  this.view = view;
1138
1166
  this.measure();
1167
+ if (typeof ResizeObserver !== "undefined" && this.view.contentDOM) {
1168
+ this.resizeObserver = new ResizeObserver(() => {
1169
+ this.view.requestMeasure();
1170
+ this.measure();
1171
+ });
1172
+ this.resizeObserver.observe(this.view.contentDOM);
1173
+ }
1139
1174
  }
1140
1175
  view;
1141
1176
  rects = [];
1142
1177
  docVersion = 0;
1143
1178
  listeners = /* @__PURE__ */ new Set();
1144
1179
  pendingNotify = null;
1180
+ resizeObserver = null;
1145
1181
  update(update) {
1146
1182
  if (update.docChanged) {
1147
1183
  this.docVersion++;
1148
1184
  }
1149
- if (update.docChanged || update.geometryChanged) {
1185
+ if (update.docChanged || update.geometryChanged || update.viewportChanged) {
1150
1186
  this.measure();
1151
1187
  }
1152
1188
  }
@@ -1210,6 +1246,8 @@ var SectionGeometryPlugin = class {
1210
1246
  if (this.pendingNotify !== null && typeof cancelAnimationFrame === "function") {
1211
1247
  cancelAnimationFrame(this.pendingNotify);
1212
1248
  }
1249
+ this.resizeObserver?.disconnect();
1250
+ this.resizeObserver = null;
1213
1251
  this.listeners.clear();
1214
1252
  }
1215
1253
  };
@@ -2168,6 +2206,7 @@ function createTagDraftRow(view, root, key, onCommit) {
2168
2206
  const discard = () => settle(false);
2169
2207
  attachSuggestions(input, view, root, "value", key, [], commit);
2170
2208
  input.addEventListener("keydown", (e) => {
2209
+ if (e.isComposing || e.keyCode === 229) return;
2171
2210
  if (e.key === "Escape") {
2172
2211
  e.preventDefault();
2173
2212
  discard();
@@ -2287,6 +2326,7 @@ function createMetricDraftRow(view, root, referenceProvider, commit) {
2287
2326
  customKeyInput.setAttribute("aria-label", "Metric key");
2288
2327
  customKeyInput.dataset.frontmatterField = "key";
2289
2328
  customKeyInput.addEventListener("keydown", (e) => {
2329
+ if (e.isComposing || e.keyCode === 229) return;
2290
2330
  if (e.key === "Escape") {
2291
2331
  e.preventDefault();
2292
2332
  settle(false);
@@ -2311,6 +2351,7 @@ function createMetricDraftRow(view, root, referenceProvider, commit) {
2311
2351
  attachFor();
2312
2352
  select.addEventListener("change", attachFor);
2313
2353
  input.addEventListener("keydown", (e) => {
2354
+ if (e.isComposing || e.keyCode === 229) return;
2314
2355
  if (e.defaultPrevented && e.key !== "Escape") return;
2315
2356
  if (e.key === "Escape") {
2316
2357
  e.preventDefault();
@@ -2381,6 +2422,7 @@ function createSummaryDraftRow(view, commit) {
2381
2422
  view.requestMeasure();
2382
2423
  };
2383
2424
  keyInput.addEventListener("keydown", (e) => {
2425
+ if (e.isComposing || e.keyCode === 229) return;
2384
2426
  if (e.key === "Escape") {
2385
2427
  e.preventDefault();
2386
2428
  settle(false);
@@ -2393,6 +2435,7 @@ function createSummaryDraftRow(view, commit) {
2393
2435
  }
2394
2436
  });
2395
2437
  valInput.addEventListener("keydown", (e) => {
2438
+ if (e.isComposing || e.keyCode === 229) return;
2396
2439
  if (e.key === "Escape") {
2397
2440
  e.preventDefault();
2398
2441
  settle(false);
@@ -4046,11 +4089,12 @@ function appendFormattedCellContent(container, rawText, view) {
4046
4089
  } else if (match[2] !== void 0 && match[3] !== void 0) {
4047
4090
  const label = match[2];
4048
4091
  const url = match[3];
4092
+ const isExternal = /^https?:\/\//i.test(url);
4093
+ const resolvedUrl = isExternal ? applyAmazonAffiliateTag(url, view.state.facet(affiliateTagFacet)) : url;
4049
4094
  const a = document.createElement("a");
4050
- a.href = url;
4095
+ a.href = resolvedUrl;
4051
4096
  a.textContent = label;
4052
4097
  a.className = "cm-table-cell-link underline underline-offset-2";
4053
- const isExternal = /^https?:\/\//i.test(url);
4054
4098
  if (isExternal) {
4055
4099
  a.target = "_blank";
4056
4100
  a.rel = "noopener noreferrer";
@@ -4165,6 +4209,7 @@ var MarkdownTableWidget = class extends WidgetType {
4165
4209
  input.addEventListener("click", (e) => e.stopPropagation());
4166
4210
  input.addEventListener("keydown", (e) => {
4167
4211
  e.stopPropagation();
4212
+ if (e.isComposing || e.keyCode === 229) return;
4168
4213
  if (e.key === "Tab") {
4169
4214
  e.preventDefault();
4170
4215
  const dir = e.shiftKey ? -1 : 1;
@@ -4508,7 +4553,8 @@ function openLinkEditPopover(anchorEl, view, match) {
4508
4553
  openBtn.addEventListener("click", (e) => {
4509
4554
  e.preventDefault();
4510
4555
  e.stopPropagation();
4511
- const targetUrl = urlInput.value.trim() || match.url;
4556
+ const rawUrl = urlInput.value.trim() || match.url;
4557
+ const targetUrl = applyAmazonAffiliateTag(rawUrl, view.state.facet(affiliateTagFacet));
4512
4558
  closeActiveLinkPopover();
4513
4559
  const navHook = view.state.facet(navigationFacet);
4514
4560
  if (!isExternalHttpUrl(targetUrl) && navHook) {
@@ -4559,6 +4605,7 @@ function openLinkEditPopover(anchorEl, view, match) {
4559
4605
  });
4560
4606
  const handleKeyDown = (e) => {
4561
4607
  e.stopPropagation();
4608
+ if (e.isComposing || e.keyCode === 229) return;
4562
4609
  if (e.key === "Enter") {
4563
4610
  e.preventDefault();
4564
4611
  applyChanges();
@@ -4595,21 +4642,23 @@ function openLinkEditPopover(anchorEl, view, match) {
4595
4642
  labelInput.select();
4596
4643
  }
4597
4644
  var LinkPillWidget = class extends WidgetType {
4598
- constructor(label, url, from, to, readOnly) {
4645
+ constructor(label, url, from, to, readOnly, affiliateTag) {
4599
4646
  super();
4600
4647
  this.label = label;
4601
4648
  this.url = url;
4602
4649
  this.from = from;
4603
4650
  this.to = to;
4604
4651
  this.readOnly = readOnly;
4652
+ this.affiliateTag = affiliateTag;
4605
4653
  }
4606
4654
  label;
4607
4655
  url;
4608
4656
  from;
4609
4657
  to;
4610
4658
  readOnly;
4659
+ affiliateTag;
4611
4660
  eq(other) {
4612
- return this.label === other.label && this.url === other.url && this.from === other.from && this.to === other.to && this.readOnly === other.readOnly;
4661
+ 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;
4613
4662
  }
4614
4663
  toDOM(view) {
4615
4664
  const isExternal = isExternalHttpUrl(this.url);
@@ -4636,9 +4685,10 @@ var LinkPillWidget = class extends WidgetType {
4636
4685
  });
4637
4686
  }
4638
4687
  pill.appendChild(label);
4688
+ const resolvedUrl = isExternal ? applyAmazonAffiliateTag(this.url, this.affiliateTag) : this.url;
4639
4689
  const open = document.createElement("a");
4640
4690
  open.className = "cm-link-pill-open";
4641
- open.href = this.url;
4691
+ open.href = resolvedUrl;
4642
4692
  if (isExternal) {
4643
4693
  open.target = "_blank";
4644
4694
  open.rel = "noopener noreferrer";
@@ -4650,11 +4700,11 @@ var LinkPillWidget = class extends WidgetType {
4650
4700
  if (navHook) {
4651
4701
  e.preventDefault();
4652
4702
  e.stopPropagation();
4653
- navHook(this.url, view);
4703
+ navHook(resolvedUrl, view);
4654
4704
  }
4655
4705
  });
4656
4706
  }
4657
- open.title = this.url;
4707
+ open.title = resolvedUrl;
4658
4708
  open.appendChild(createLinkArrowIcon(isExternal));
4659
4709
  pill.appendChild(open);
4660
4710
  return pill;
@@ -4788,7 +4838,8 @@ function buildLinkDecos(state) {
4788
4838
  link.url,
4789
4839
  link.from,
4790
4840
  link.to,
4791
- state.readOnly
4841
+ state.readOnly,
4842
+ state.facet(affiliateTagFacet)
4792
4843
  )
4793
4844
  })
4794
4845
  );
@@ -17624,6 +17675,6 @@ function editorPreset(optionsOrDialect = "markdown") {
17624
17675
  return extensions;
17625
17676
  }
17626
17677
 
17627
- export { AGG_OPTIONS, CANONICAL_BLOCK_TYPES, CLAUSE_META, ComposerRegistry, DEFAULT_DIAGNOSTICS_DEBOUNCE_MS, DEFAULT_OUTPUT_FILTERS, DEFAULT_PRIMARY_FILTER, DefaultFrontmatterWidget, EditorDialog, GROUPBY_OPTIONS, GoalRings, INTERNAL_FRONTMATTER_KEYS, KIND_OPTIONS, METRIC_OPTIONS, MULTI_VALUE_TYPES, MetricBadge, OUTPUT_TYPE_CLASS, OUTPUT_TYPE_DOT, OutputFilterPills, OutputStatementsTable, PLANE_OPTIONS, PRBadge, ProposedMetricBadge, QueryBlockView, QueryObjectBuilder, QueryValue, ROLLUP_OPTIONS, RowsResultsChrome, RowsTable, SERIES_COLORS, SOURCE_OPTIONS, SUGGESTION_BINDINGS, StackedBar, TARGET_OPTIONS, TIME_OPTIONS, TONE_CLASS, TokenSlotPill, TopList, UNIT_OPTIONS, WHERE_AGGREGATORS, WHERE_METRICS, WidgetChart, WidgetProblemBadge, WqlBars, WqlComposer, WqlDiagnosticsStrip, WqlEmptyState, WqlQueryInspectorModal, WqlTable, WqlTimeseries, ZoneDistribution, activeCursorSection, addRuntimePanel, attachmentUrlFacet, autocompleteTooltipTheme, bindTokenParamIntoWql, bindTokenToQueryObject, blockTypesFromBlocks, canonicalSuggestionItems, cn, compactNumber, composerRegistry, computeSessionPrHighlights, configureOverlayActions, createExecutorDocumentHost, cursorFocusExtension, customCompletionSources, cycleBaselineLayer, dateRangeSlot, dispatchAddRuntimePanel, dispatchExpandRuntimePanel, dispatchGutterHighlights, dispatchRemoveRuntimePanel, editQueryClause, editingQuerySectionsField, editingWidgetsField, editorFocusField, editorFocusTracker, editorPreset, editorTheme, embedPreviewDecorations, expandRuntimePanel, extractBlockQueries, extractMetricsByCategory, fenceCompletion, findQueryBlockSection, findWorkoutErrors, forceSectionParse, formatClockTime, formatMMSS, formatTimeseriesTick, formatTimeseriesTooltipValue, formatTimestamp, frontmatterDebugMode, frontmatterDetailed, frontmatterKeymap, frontmatterPreview, frontmatterPreviewField, frontmatterReferenceIndex, frontmatterSource, frontmatterSuggestions, frontmatterVisibility, getClauseMeta, getCursorFocusState, getOverlayActions, getSuggestionBinding, gutterHighlightsField, gutterUnified, handleFenceAutoWrap, handleSmartUrlPaste, hashCode, inlineButtonDecoration, insertMarkdownLinkCommand, invalidateSuggestions, isEditorFocused, isInternalFrontmatterKey, isNavigableUrl, lineIdsExtension, linkOpen, linkPreview, loadSuggestions, markdownSyntaxHiding, markdownTablePreview, matchFilterTypeahead, mergeSeries, mergeSuggestionItems, mergeTagSuggestions, navigationFacet, nestedCompletion, nestedCompletionOptions, normalizeOutputFilter, normalizeSimplePipelineToAggregate, notebookSlugsFromBlocks, outputToRunResult, outputsToRunResult, patchBlockQuery, presentBadges, previewDecorations, primaryQueryOf, promoteFindToChartObject, queryBlockPreview, readSessionRpe, referenceIndexReload, registeredSectionWidgets, removeRuntimePanel, removeSeriesLayer, resolveCodeLanguage, resolveQueryDraft, runtimePanelField, saveBlockQuerySource, sectionAtPos, sectionField, sectionGeometry, sectionIdentity, sectionIdentityHistory, sectionMove, sectionRestore, sectionSaved, sessionQueryFence, sessionQueryInsert, sessionQueryWql, setEditorFocused, setFrontmatterDetailed, setFrontmatterSource, setGutterHighlights, setPrimaryQueryOnObject, setQuerySourceEditing, setSuggestionBinding, slashBlockCompletion, smartIncrement, summarizeAggregate, summarizeFind, summarizePipeline, tagsFromStaticBlocks, toChartResult, toggleCompareLayer, toggleGoalLayer, toggleInlineMarkdown, toggleWidgetEdit, tooltipTimestamp, urlAtPos, useChartShape, useComposerSlots, useSuggestions, useVisualViewportRect, useWqlStageCounts, widgetBlockPreview, wodAutoWrap, wodAutocompletion, wodCompletionSource, wodEditorKeymap, wodLinter, wodOverlayPanel, workoutLintSource, wqlToPills, wrapInTimeFence };
17628
- //# sourceMappingURL=chunk-VYFKXF46.mjs.map
17629
- //# sourceMappingURL=chunk-VYFKXF46.mjs.map
17678
+ export { AGG_OPTIONS, CANONICAL_BLOCK_TYPES, CLAUSE_META, ComposerRegistry, DEFAULT_DIAGNOSTICS_DEBOUNCE_MS, DEFAULT_OUTPUT_FILTERS, DEFAULT_PRIMARY_FILTER, DefaultFrontmatterWidget, EditorDialog, GROUPBY_OPTIONS, GoalRings, INTERNAL_FRONTMATTER_KEYS, KIND_OPTIONS, METRIC_OPTIONS, MULTI_VALUE_TYPES, MetricBadge, OUTPUT_TYPE_CLASS, OUTPUT_TYPE_DOT, OutputFilterPills, OutputStatementsTable, PLANE_OPTIONS, PRBadge, ProposedMetricBadge, QueryBlockView, QueryObjectBuilder, QueryValue, ROLLUP_OPTIONS, RowsResultsChrome, RowsTable, SERIES_COLORS, SOURCE_OPTIONS, SUGGESTION_BINDINGS, StackedBar, TARGET_OPTIONS, TIME_OPTIONS, TONE_CLASS, TokenSlotPill, TopList, UNIT_OPTIONS, WHERE_AGGREGATORS, WHERE_METRICS, WidgetChart, WidgetProblemBadge, WqlBars, WqlComposer, WqlDiagnosticsStrip, WqlEmptyState, WqlQueryInspectorModal, WqlTable, WqlTimeseries, ZoneDistribution, activeCursorSection, addRuntimePanel, affiliateTagFacet, applyAmazonAffiliateTag, attachmentUrlFacet, autocompleteTooltipTheme, bindTokenParamIntoWql, bindTokenToQueryObject, blockTypesFromBlocks, canonicalSuggestionItems, cn, compactNumber, composerRegistry, computeSessionPrHighlights, configureOverlayActions, createExecutorDocumentHost, cursorFocusExtension, customCompletionSources, cycleBaselineLayer, dateRangeSlot, dispatchAddRuntimePanel, dispatchExpandRuntimePanel, dispatchGutterHighlights, dispatchRemoveRuntimePanel, editQueryClause, editingQuerySectionsField, editingWidgetsField, editorFocusField, editorFocusTracker, editorPreset, editorTheme, embedPreviewDecorations, expandRuntimePanel, extractBlockQueries, extractMetricsByCategory, fenceCompletion, findQueryBlockSection, findWorkoutErrors, forceSectionParse, formatClockTime, formatMMSS, formatTimeseriesTick, formatTimeseriesTooltipValue, formatTimestamp, frontmatterDebugMode, frontmatterDetailed, frontmatterKeymap, frontmatterPreview, frontmatterPreviewField, frontmatterReferenceIndex, frontmatterSource, frontmatterSuggestions, frontmatterVisibility, getClauseMeta, getCursorFocusState, getOverlayActions, getSuggestionBinding, gutterHighlightsField, gutterUnified, handleFenceAutoWrap, handleSmartUrlPaste, hashCode, inlineButtonDecoration, insertMarkdownLinkCommand, invalidateSuggestions, isAmazonRetailHost, isEditorFocused, isInternalFrontmatterKey, isNavigableUrl, lineIdsExtension, linkOpen, linkPreview, loadSuggestions, markdownSyntaxHiding, markdownTablePreview, matchFilterTypeahead, mergeSeries, mergeSuggestionItems, mergeTagSuggestions, navigationFacet, nestedCompletion, nestedCompletionOptions, normalizeOutputFilter, normalizeSimplePipelineToAggregate, notebookSlugsFromBlocks, outputToRunResult, outputsToRunResult, patchBlockQuery, presentBadges, previewDecorations, primaryQueryOf, promoteFindToChartObject, queryBlockPreview, readSessionRpe, referenceIndexReload, registeredSectionWidgets, removeRuntimePanel, removeSeriesLayer, resolveCodeLanguage, resolveQueryDraft, runtimePanelField, saveBlockQuerySource, sectionAtPos, sectionField, sectionGeometry, sectionIdentity, sectionIdentityHistory, sectionMove, sectionRestore, sectionSaved, sessionQueryFence, sessionQueryInsert, sessionQueryWql, setEditorFocused, setFrontmatterDetailed, setFrontmatterSource, setGutterHighlights, setPrimaryQueryOnObject, setQuerySourceEditing, setSuggestionBinding, slashBlockCompletion, smartIncrement, summarizeAggregate, summarizeFind, summarizePipeline, tagsFromStaticBlocks, toChartResult, toggleCompareLayer, toggleGoalLayer, toggleInlineMarkdown, toggleWidgetEdit, tooltipTimestamp, urlAtPos, useChartShape, useComposerSlots, useSuggestions, useVisualViewportRect, useWqlStageCounts, widgetBlockPreview, wodAutoWrap, wodAutocompletion, wodCompletionSource, wodEditorKeymap, wodLinter, wodOverlayPanel, workoutLintSource, wqlToPills, wrapInTimeFence };
17679
+ //# sourceMappingURL=chunk-Y7FAKA4S.mjs.map
17680
+ //# sourceMappingURL=chunk-Y7FAKA4S.mjs.map