@bitcobblers/wod-wiki-ui 0.5.30 → 0.6.31

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.
@@ -779,11 +779,12 @@ var SectionGeometryPlugin = class {
779
779
  rects = [];
780
780
  docVersion = 0;
781
781
  listeners = /* @__PURE__ */ new Set();
782
+ pendingNotify = null;
782
783
  update(update) {
783
784
  if (update.docChanged) {
784
785
  this.docVersion++;
785
786
  }
786
- if (update.docChanged || update.viewportChanged || update.geometryChanged) {
787
+ if (update.docChanged || update.geometryChanged) {
787
788
  this.measure();
788
789
  }
789
790
  }
@@ -798,18 +799,19 @@ var SectionGeometryPlugin = class {
798
799
  try {
799
800
  const sectionState = this.view.state.field(sectionField, false);
800
801
  const sections = sectionState?.sections ?? [];
801
- const scrollRect = this.view.scrollDOM?.getBoundingClientRect ? this.view.scrollDOM.getBoundingClientRect() : { top: 0, left: 0, bottom: 0, right: 0 };
802
- const scrollTop = this.view.scrollDOM?.scrollTop ?? 0;
802
+ const docLength = this.view.state.doc.length;
803
803
  this.rects = sections.map((sec) => {
804
- let fromCoords = null;
805
- let toCoords = null;
804
+ const from = Math.max(0, Math.min(sec.from, docLength));
805
+ const to = Math.max(0, Math.min(sec.to, docLength));
806
+ let top = 0;
807
+ let bottom = 20;
806
808
  try {
807
- fromCoords = this.view.coordsAtPos ? this.view.coordsAtPos(sec.from) : null;
808
- toCoords = this.view.coordsAtPos ? this.view.coordsAtPos(sec.to) : null;
809
+ const topBlock = this.view.lineBlockAt(from);
810
+ const bottomBlock = this.view.lineBlockAt(to);
811
+ top = topBlock.top;
812
+ bottom = bottomBlock.top + bottomBlock.height;
809
813
  } catch {
810
814
  }
811
- const top = fromCoords ? fromCoords.top - (scrollRect?.top ?? 0) + scrollTop : 0;
812
- const bottom = toCoords ? toCoords.bottom - (scrollRect?.top ?? 0) + scrollTop : top;
813
815
  const height = Math.max(bottom - top, 20);
814
816
  return {
815
817
  sectionId: sec.id,
@@ -825,11 +827,24 @@ var SectionGeometryPlugin = class {
825
827
  }
826
828
  }
827
829
  notify() {
828
- for (const listener of this.listeners) {
829
- listener(this.rects, this.docVersion);
830
+ if (typeof requestAnimationFrame === "function") {
831
+ if (this.pendingNotify !== null) return;
832
+ this.pendingNotify = requestAnimationFrame(() => {
833
+ this.pendingNotify = null;
834
+ for (const listener of this.listeners) {
835
+ listener(this.rects, this.docVersion);
836
+ }
837
+ });
838
+ } else {
839
+ for (const listener of this.listeners) {
840
+ listener(this.rects, this.docVersion);
841
+ }
830
842
  }
831
843
  }
832
844
  destroy() {
845
+ if (this.pendingNotify !== null && typeof cancelAnimationFrame === "function") {
846
+ cancelAnimationFrame(this.pendingNotify);
847
+ }
833
848
  this.listeners.clear();
834
849
  }
835
850
  };
@@ -10355,5 +10370,5 @@ function editorPreset(optionsOrDialect = "markdown") {
10355
10370
  }
10356
10371
 
10357
10372
  export { AGG_OPTIONS, AddCalcDropdown, AddFilterDropdown, CLAUSE_META, CONTENT_SOURCES, ClausePopover, ComposerRegistry, CustomSlotPopover, DEFAULT_DIAGNOSTICS_DEBOUNCE_MS, DefaultFrontmatterWidget, GROUPBY_OPTIONS, GoalRings, METRIC_OPTIONS, MULTI_VALUE_TYPES, ProposedMetricBadge, QueryBlockView, QueryValue, ROLLUP_OPTIONS, RowsResultsChrome, RowsTable, SERIES_COLORS, SOURCE_OPTIONS, SUGGESTION_BINDINGS, StackedBar, TIME_OPTIONS, TokenSlotPill, TopList, UNIT_OPTIONS, WHERE_AGGREGATORS, WHERE_METRICS, WHERE_OPERATORS, WidgetChart, WidgetProblemBadge, WqlBars, WqlComposer, WqlDiagnosticsStrip, WqlEmptyState, WqlQueryInspectorModal, WqlTable, WqlTimeseries, ZoneDistribution, activeCursorSection, addRuntimePanel, blockContentId, blockTypesFromBlocks, catalogIdsFromBlocks, clauseToWql, clauseValue, clausesToWql, cn, compactNumber, composerRegistry, configureOverlayActions, cursorFocusExtension, dateRangeSlot, defaultClauses, defaultMetricsClauses, diagnoseClauses, dispatchAddRuntimePanel, dispatchExpandRuntimePanel, dispatchGutterHighlights, dispatchRemoveRuntimePanel, editingWidgetsField, editorPreset, editorTheme, embedPreviewDecorations, expandRuntimePanel, extractBlockQueries, fenceCompletion, findQueryBlockSection, findWorkoutErrors, forceSectionParse, formatTimestamp, frontmatterPreview, frontmatterPreviewField, getClauseMeta, getCursorFocusState, getOverlayActions, getSuggestionBinding, gutterHighlightsField, gutterUnified, handleFenceAutoWrap, hashCode, inlineButtonDecoration, invalidateSuggestions, lineIdsExtension, linkOpen, loadSuggestions, markdownSyntaxHiding, markdownTablePreview, mergeSeries, mergeTagSuggestions, navigationFacet, patchBlockQuery, pivotClauses, previewDecorations, queryBlockPreview, readSessionRpe, removeRuntimePanel, runtimePanelField, saveBlockQuerySource, sectionAtPos, sectionField, sectionGeometry, sessionQueryInsert, sessionQueryWql, setGutterHighlights, setMetricClause, setSuggestionBinding, smartIncrement, sourcePlane, summarizeAggregate, summarizeFind, tagsFromStaticBlocks, toggleWidgetEdit, tooltipTimestamp, urlAtPos, useChartShape, useComposerSlots, useSuggestions, useWqlStageCounts, widgetBlockPreview, wodAutoWrap, wodAutocompletion, wodEditorKeymap, wodLinter, wodOverlayPanel, workoutLintSource, wqlToClauses, wrapInTimeFence };
10358
- //# sourceMappingURL=chunk-HRROD36H.mjs.map
10359
- //# sourceMappingURL=chunk-HRROD36H.mjs.map
10373
+ //# sourceMappingURL=chunk-V2JNLN54.mjs.map
10374
+ //# sourceMappingURL=chunk-V2JNLN54.mjs.map