@beyondwork/docx-react-component 1.0.133 → 1.0.135

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.
Files changed (83) hide show
  1. package/dist/api/public-types.cjs +23 -3
  2. package/dist/api/public-types.d.cts +1 -1
  3. package/dist/api/public-types.d.ts +1 -1
  4. package/dist/api/public-types.js +2 -2
  5. package/dist/api/v3.cjs +708 -47
  6. package/dist/api/v3.d.cts +2 -2
  7. package/dist/api/v3.d.ts +2 -2
  8. package/dist/api/v3.js +4 -4
  9. package/dist/{chunk-REFHJ2FN.js → chunk-2BNXARVO.js} +3 -3
  10. package/dist/{chunk-INLRCC4N.js → chunk-4CIHTMCH.js} +2 -2
  11. package/dist/{chunk-224TSMEB.js → chunk-5CCYF333.js} +138 -42
  12. package/dist/{chunk-MQ5GAJ54.js → chunk-BJXSMPHD.js} +1 -1
  13. package/dist/{chunk-OTRVGNZQ.js → chunk-EPFVMUKF.js} +548 -3
  14. package/dist/{chunk-XBQFDBXE.js → chunk-EZFF6GKF.js} +9 -2
  15. package/dist/{chunk-S3PEKX6H.js → chunk-FGJTOFZY.js} +72 -554
  16. package/dist/{chunk-3JEE5RJU.js → chunk-GIFXKIM5.js} +612 -34
  17. package/dist/{chunk-57HTKX3P.js → chunk-H4HI6RUE.js} +1 -1
  18. package/dist/{chunk-KL4TZSZV.js → chunk-HWMPNLEF.js} +1 -1
  19. package/dist/{chunk-ZFCZ7XXH.js → chunk-NEMOQ4QR.js} +1 -1
  20. package/dist/{chunk-CVSD3UNK.js → chunk-P7XDEVS6.js} +15 -2
  21. package/dist/{chunk-QTRJLKR2.js → chunk-TSNK4ECL.js} +1 -1
  22. package/dist/{chunk-WDDFU2N2.js → chunk-UR2LW63N.js} +1 -1
  23. package/dist/core/commands/formatting-commands.d.cts +1 -1
  24. package/dist/core/commands/formatting-commands.d.ts +1 -1
  25. package/dist/core/commands/image-commands.cjs +9 -2
  26. package/dist/core/commands/image-commands.d.cts +1 -1
  27. package/dist/core/commands/image-commands.d.ts +1 -1
  28. package/dist/core/commands/image-commands.js +4 -4
  29. package/dist/core/commands/section-layout-commands.d.cts +1 -1
  30. package/dist/core/commands/section-layout-commands.d.ts +1 -1
  31. package/dist/core/commands/style-commands.d.cts +1 -1
  32. package/dist/core/commands/style-commands.d.ts +1 -1
  33. package/dist/core/commands/table-structure-commands.cjs +9 -2
  34. package/dist/core/commands/table-structure-commands.d.cts +1 -1
  35. package/dist/core/commands/table-structure-commands.d.ts +1 -1
  36. package/dist/core/commands/table-structure-commands.js +3 -3
  37. package/dist/core/commands/text-commands.cjs +9 -2
  38. package/dist/core/commands/text-commands.d.cts +1 -1
  39. package/dist/core/commands/text-commands.d.ts +1 -1
  40. package/dist/core/commands/text-commands.js +4 -4
  41. package/dist/core/selection/mapping.d.cts +1 -1
  42. package/dist/core/selection/mapping.d.ts +1 -1
  43. package/dist/core/state/editor-state.d.cts +1 -1
  44. package/dist/core/state/editor-state.d.ts +1 -1
  45. package/dist/index.cjs +1478 -636
  46. package/dist/index.d.cts +4 -4
  47. package/dist/index.d.ts +4 -4
  48. package/dist/index.js +113 -26
  49. package/dist/io/docx-session.d.cts +3 -3
  50. package/dist/io/docx-session.d.ts +3 -3
  51. package/dist/{loader-B2H99237.d.cts → loader-BQ7AB-0v.d.cts} +2 -2
  52. package/dist/{loader-DfTjqVwn.d.ts → loader-Cy6OYBfn.d.ts} +2 -2
  53. package/dist/{public-types-S8gTYwKo.d.cts → public-types-D31xKNGc.d.cts} +146 -3
  54. package/dist/{public-types-B5lOUIrP.d.ts → public-types-DqYt8GdP.d.ts} +146 -3
  55. package/dist/public-types.cjs +23 -3
  56. package/dist/public-types.d.cts +1 -1
  57. package/dist/public-types.d.ts +1 -1
  58. package/dist/public-types.js +2 -2
  59. package/dist/runtime/collab.d.cts +2 -2
  60. package/dist/runtime/collab.d.ts +2 -2
  61. package/dist/runtime/document-runtime.cjs +760 -68
  62. package/dist/runtime/document-runtime.d.cts +1 -1
  63. package/dist/runtime/document-runtime.d.ts +1 -1
  64. package/dist/runtime/document-runtime.js +10 -10
  65. package/dist/{session-CR2A1hGZ.d.cts → session-DA-F2fCw.d.cts} +2 -2
  66. package/dist/{session-CBDIOYXA.d.ts → session-DqL8H0oZ.d.ts} +2 -2
  67. package/dist/session.d.cts +4 -4
  68. package/dist/session.d.ts +4 -4
  69. package/dist/tailwind.cjs +81 -554
  70. package/dist/tailwind.d.cts +1 -1
  71. package/dist/tailwind.d.ts +1 -1
  72. package/dist/tailwind.js +5 -5
  73. package/dist/{types-yty2K-hk.d.cts → types-B2y94n5t.d.cts} +1 -1
  74. package/dist/{types-B-90ywjU.d.ts → types-SllbCtGs.d.ts} +1 -1
  75. package/dist/ui-tailwind/editor-surface/search-plugin.cjs +11 -0
  76. package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +2 -2
  77. package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +2 -2
  78. package/dist/ui-tailwind/editor-surface/search-plugin.js +3 -3
  79. package/dist/ui-tailwind.cjs +81 -554
  80. package/dist/ui-tailwind.d.cts +2 -2
  81. package/dist/ui-tailwind.d.ts +2 -2
  82. package/dist/ui-tailwind.js +5 -5
  83. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolvePageOverlayRectsFromGeometry
3
- } from "./chunk-57HTKX3P.js";
3
+ } from "./chunk-H4HI6RUE.js";
4
4
  import {
5
5
  buildPageAnchorAttributes,
6
6
  buildPageAnchorSelector,
@@ -20,13 +20,13 @@ import {
20
20
  incrementInvalidationCounter,
21
21
  recordPerfSample,
22
22
  sanitizeMarkdown
23
- } from "./chunk-CVSD3UNK.js";
23
+ } from "./chunk-P7XDEVS6.js";
24
24
  import {
25
25
  createCanvasBackend
26
26
  } from "./chunk-OVLZQ6FZ.js";
27
27
  import {
28
28
  storyTargetKey
29
- } from "./chunk-XBQFDBXE.js";
29
+ } from "./chunk-EZFF6GKF.js";
30
30
  import {
31
31
  EMU_PER_INCH,
32
32
  EMU_PER_PX,
@@ -7993,294 +7993,6 @@ function resolveSkeletalPageOverlayRectsFromLayout(facet) {
7993
7993
  }
7994
7994
  return rects;
7995
7995
  }
7996
- function pageOverlayLastBottom(rects) {
7997
- let bottom = 0;
7998
- for (const rect of rects) {
7999
- if (rect.bottomPx > bottom) bottom = rect.bottomPx;
8000
- }
8001
- return bottom;
8002
- }
8003
- function extendFinalPageOverlayRectToFlowHeight(rects, flowHeightPx) {
8004
- if (rects.length === 0 || !Number.isFinite(flowHeightPx)) return rects;
8005
- const last = rects[rects.length - 1];
8006
- if (flowHeightPx <= last.bottomPx + 1) return rects;
8007
- return [
8008
- ...rects.slice(0, -1),
8009
- {
8010
- ...last,
8011
- bottomPx: flowHeightPx,
8012
- heightPx: Math.max(0, flowHeightPx - last.topPx)
8013
- }
8014
- ];
8015
- }
8016
- function extendPageOverlayRectsAcrossTableBoundaryGaps(rects, tableBoundaryIndices) {
8017
- if (rects.length === 0 || tableBoundaryIndices.length === 0) return rects;
8018
- const tableBoundaries = new Set(tableBoundaryIndices);
8019
- const byPageIndex = /* @__PURE__ */ new Map();
8020
- for (const rect of rects) {
8021
- byPageIndex.set(rect.pageIndex, rect);
8022
- }
8023
- let changed = false;
8024
- const bridged = rects.map((rect) => {
8025
- if (!tableBoundaries.has(rect.pageIndex)) return rect;
8026
- const next = byPageIndex.get(rect.pageIndex + 1);
8027
- if (!next || next.topPx <= rect.bottomPx + 1) return rect;
8028
- changed = true;
8029
- return {
8030
- ...rect,
8031
- bottomPx: next.topPx,
8032
- heightPx: Math.max(0, next.topPx - rect.topPx)
8033
- };
8034
- });
8035
- return changed ? bridged : rects;
8036
- }
8037
- function mergePageOverlayRectsByPageIndex(baseRects, flowRects) {
8038
- if (baseRects.length === 0 || flowRects.length === 0) return baseRects;
8039
- const flowByIndex = /* @__PURE__ */ new Map();
8040
- for (const rect of flowRects) {
8041
- flowByIndex.set(rect.pageIndex, rect);
8042
- }
8043
- return baseRects.map((rect) => flowByIndex.get(rect.pageIndex) ?? rect);
8044
- }
8045
- function normalizeVisiblePageIndexRange(range, pageCount) {
8046
- if (!range || pageCount <= 0) return null;
8047
- const start = Math.max(0, Math.min(range.start, pageCount));
8048
- const end = Math.max(start, Math.min(range.end, pageCount));
8049
- if (start >= end) return null;
8050
- return { start, end };
8051
- }
8052
- function collectBoundaryIndicesForVisibleRange(range, pageCount) {
8053
- if (pageCount <= 1) return [];
8054
- const startBoundaryIndex = Math.max(0, range.start - 1);
8055
- const endBoundaryIndex = Math.min(pageCount - 2, range.end - 1);
8056
- if (startBoundaryIndex > endBoundaryIndex) return [];
8057
- const indices = [];
8058
- for (let index = startBoundaryIndex; index <= endBoundaryIndex; index += 1) {
8059
- indices.push(index);
8060
- }
8061
- return indices;
8062
- }
8063
- function parsePageBoundaryIndex(prevPageId) {
8064
- const match = /^page-(\d+)$/.exec(prevPageId);
8065
- if (!match) return void 0;
8066
- return Number.parseInt(match[1] ?? "", 10);
8067
- }
8068
- function collectTableEmbeddedBoundaryIndices(queryRoot) {
8069
- if (!queryRoot) return [];
8070
- const indices = [];
8071
- const widgets = Array.from(
8072
- queryRoot.querySelectorAll("[data-page-frame-end]")
8073
- );
8074
- for (const widget of widgets) {
8075
- const prevPageId = widget.getAttribute("data-page-frame-end");
8076
- if (!prevPageId) continue;
8077
- const boundaryIndex = parsePageBoundaryIndex(prevPageId);
8078
- if (boundaryIndex === void 0) continue;
8079
- if (widget.closest("[data-pm-table-root='true'], table")) {
8080
- indices.push(boundaryIndex);
8081
- }
8082
- }
8083
- return indices;
8084
- }
8085
- function containsTableBoundaryRisk(queryRoot) {
8086
- if (!queryRoot) return false;
8087
- if (queryRoot.getElementsByTagName("table").length > 0) return true;
8088
- const descendants = queryRoot.getElementsByTagName("*");
8089
- for (let i = 0; i < descendants.length; i += 1) {
8090
- const element = descendants[i];
8091
- if (element.getAttribute("data-pm-table-root") === "true") {
8092
- return true;
8093
- }
8094
- }
8095
- return false;
8096
- }
8097
- function resolvePageOverlayRects(input, legacyPageCount) {
8098
- let widgets;
8099
- let pageCount;
8100
- let scrollHeight;
8101
- if (Array.isArray(input)) {
8102
- const [scrollRoot, count] = input;
8103
- if (!scrollRoot || count <= 0) return [];
8104
- widgets = measureWidgetsViaOffsetChain(scrollRoot);
8105
- pageCount = count;
8106
- scrollHeight = scrollRoot.clientHeight;
8107
- } else if (input !== null && typeof input === "object" && "widgets" in input) {
8108
- widgets = input.widgets;
8109
- pageCount = input.pageCount;
8110
- scrollHeight = input.scrollHeight;
8111
- } else if (input && legacyPageCount !== void 0) {
8112
- const scrollRoot = input;
8113
- if (legacyPageCount <= 0) return [];
8114
- widgets = measureWidgetsViaOffsetChain(scrollRoot);
8115
- pageCount = legacyPageCount;
8116
- scrollHeight = scrollRoot.clientHeight;
8117
- } else {
8118
- return [];
8119
- }
8120
- if (pageCount <= 0) return [];
8121
- const boundaries = [...widgets].sort((a, b) => a.topPx - b.topPx);
8122
- const normalizedVisiblePageIndexRange = Array.isArray(input) ? null : normalizeVisiblePageIndexRange(input.visiblePageIndexRange, pageCount);
8123
- const boundaryByIndex = /* @__PURE__ */ new Map();
8124
- boundaries.forEach((boundary, index) => {
8125
- const boundaryIndex = boundary.boundaryIndex ?? parsePageBoundaryIndex(boundary.prevPageId) ?? index;
8126
- boundaryByIndex.set(boundaryIndex, boundary);
8127
- });
8128
- const pageStart = normalizedVisiblePageIndexRange?.start ?? 0;
8129
- const pageEnd = normalizedVisiblePageIndexRange?.end ?? pageCount;
8130
- const rects = [];
8131
- for (let pageIndex = pageStart; pageIndex < pageEnd; pageIndex += 1) {
8132
- const boundaryBefore = pageIndex === 0 ? null : boundaryByIndex.get(pageIndex - 1) ?? null;
8133
- const boundaryAfter = pageIndex === pageCount - 1 ? null : boundaryByIndex.get(pageIndex) ?? null;
8134
- let pageId = null;
8135
- if (boundaryBefore) pageId = boundaryBefore.nextPageId;
8136
- else if (boundaryAfter) pageId = boundaryAfter.prevPageId;
8137
- if (!pageId) pageId = `page-${pageIndex}`;
8138
- const topPx = boundaryBefore ? boundaryBefore.bottomPx : 0;
8139
- const bottomPx = boundaryAfter ? boundaryAfter.topPx : scrollHeight;
8140
- if (bottomPx <= topPx) continue;
8141
- rects.push({
8142
- pageId,
8143
- pageIndex,
8144
- topPx,
8145
- bottomPx,
8146
- heightPx: bottomPx - topPx
8147
- });
8148
- }
8149
- return rects;
8150
- }
8151
- function measureWidgetsViaBoundingRect(queryRoot, originElement, options) {
8152
- if (!queryRoot || !originElement) return [];
8153
- const originRect = originElement.getBoundingClientRect();
8154
- const normalizedVisiblePageIndexRange = normalizeVisiblePageIndexRange(
8155
- options?.visiblePageIndexRange,
8156
- options?.pageCount ?? 0
8157
- );
8158
- const queryOne = typeof queryRoot.querySelector === "function" ? queryRoot.querySelector.bind(queryRoot) : null;
8159
- const widgets = normalizedVisiblePageIndexRange && queryOne && options?.pageCount ? collectBoundaryIndicesForVisibleRange(
8160
- normalizedVisiblePageIndexRange,
8161
- options.pageCount
8162
- ).map(
8163
- (boundaryIndex) => queryOne(`[data-page-frame-end="page-${boundaryIndex}"]`)
8164
- ).filter((widget) => widget !== null) : Array.from(
8165
- queryRoot.querySelectorAll("[data-page-frame-end]")
8166
- );
8167
- const out = [];
8168
- for (const widget of widgets) {
8169
- const prevPageId = widget.getAttribute("data-page-frame-end");
8170
- const nextPageId = widget.getAttribute("data-page-frame-start");
8171
- if (!prevPageId || !nextPageId) continue;
8172
- const rect = widget.getBoundingClientRect();
8173
- out.push({
8174
- prevPageId,
8175
- nextPageId,
8176
- boundaryIndex: parsePageBoundaryIndex(prevPageId),
8177
- topPx: rect.top - originRect.top,
8178
- bottomPx: rect.bottom - originRect.top
8179
- });
8180
- }
8181
- return out;
8182
- }
8183
- function measureWidgetsViaOffsetChain(scrollRoot, options) {
8184
- const normalizedVisiblePageIndexRange = normalizeVisiblePageIndexRange(
8185
- options?.visiblePageIndexRange,
8186
- options?.pageCount ?? 0
8187
- );
8188
- const queryOne = typeof scrollRoot.querySelector === "function" ? scrollRoot.querySelector.bind(scrollRoot) : null;
8189
- const widgets = normalizedVisiblePageIndexRange && queryOne && options?.pageCount ? collectBoundaryIndicesForVisibleRange(
8190
- normalizedVisiblePageIndexRange,
8191
- options.pageCount
8192
- ).map(
8193
- (boundaryIndex) => queryOne(`[data-page-frame-end="page-${boundaryIndex}"]`)
8194
- ).filter((widget) => widget !== null) : Array.from(
8195
- scrollRoot.querySelectorAll("[data-page-frame-end]")
8196
- );
8197
- const out = [];
8198
- for (const widget of widgets) {
8199
- const prevPageId = widget.getAttribute("data-page-frame-end");
8200
- const nextPageId = widget.getAttribute("data-page-frame-start");
8201
- if (!prevPageId || !nextPageId) continue;
8202
- const topPx = resolveOffsetTop(widget, scrollRoot);
8203
- const bottomPx = topPx + resolveOffsetHeight(widget);
8204
- out.push({
8205
- prevPageId,
8206
- nextPageId,
8207
- boundaryIndex: parsePageBoundaryIndex(prevPageId),
8208
- topPx,
8209
- bottomPx
8210
- });
8211
- }
8212
- return out;
8213
- }
8214
- function resolveOffsetTop(widget, scrollRoot) {
8215
- let node = widget;
8216
- let top = 0;
8217
- while (node) {
8218
- top += node.offsetTop ?? 0;
8219
- const parent = node.offsetParent;
8220
- if (parent === scrollRoot || parent === null) break;
8221
- node = parent;
8222
- }
8223
- return top;
8224
- }
8225
- function resolveOffsetHeight(widget) {
8226
- return widget.offsetHeight ?? 0;
8227
- }
8228
- function readElementFlowHeight(element, options = {}) {
8229
- if (!element) return 0;
8230
- let height = 0;
8231
- height = Math.max(height, element.clientHeight || 0);
8232
- if (options.includeScrollHeight !== false) {
8233
- height = Math.max(height, element.scrollHeight || 0);
8234
- }
8235
- if (height <= 0) {
8236
- const rect = element.getBoundingClientRect();
8237
- height = Math.max(height, rect.height || 0);
8238
- }
8239
- return height;
8240
- }
8241
- function readOverlayFlowHeight(origin) {
8242
- if (!origin) return 0;
8243
- const parent = origin.parentElement instanceof HTMLElement ? origin.parentElement : null;
8244
- const parentHeight = readElementFlowHeight(parent);
8245
- if (parentHeight > 0) return parentHeight;
8246
- return readElementFlowHeight(origin, { includeScrollHeight: false });
8247
- }
8248
- function reconcilePageStackRectsWithFlow(input) {
8249
- const { baseRects, pageCount, scrollRoot, originElement } = input;
8250
- if (baseRects.length === 0 || pageCount <= 0) return baseRects;
8251
- const flowHeight = readOverlayFlowHeight(originElement);
8252
- if (flowHeight <= 0) return baseRects;
8253
- const geometryBottom = pageOverlayLastBottom(baseRects);
8254
- const tableBoundaryRisk = containsTableBoundaryRisk(scrollRoot);
8255
- if (!tableBoundaryRisk && flowHeight <= geometryBottom + 1) {
8256
- return extendFinalPageOverlayRectToFlowHeight(baseRects, flowHeight);
8257
- }
8258
- const bridgedBase = extendPageOverlayRectsAcrossTableBoundaryGaps(
8259
- baseRects,
8260
- tableBoundaryRisk ? collectTableEmbeddedBoundaryIndices(scrollRoot) : []
8261
- );
8262
- const extendedBase = extendFinalPageOverlayRectToFlowHeight(
8263
- bridgedBase,
8264
- flowHeight
8265
- );
8266
- if (!originElement || !scrollRoot) return extendedBase;
8267
- if (flowHeight <= pageOverlayLastBottom(bridgedBase) + 1) {
8268
- return extendedBase;
8269
- }
8270
- const widgets = measureWidgetsViaBoundingRect(scrollRoot, originElement, {
8271
- pageCount,
8272
- visiblePageIndexRange: null
8273
- });
8274
- if (widgets.length === 0) return extendedBase;
8275
- const flowRects = resolvePageOverlayRects({
8276
- widgets,
8277
- pageCount,
8278
- scrollHeight: flowHeight,
8279
- visiblePageIndexRange: null
8280
- });
8281
- const merged = mergePageOverlayRectsByPageIndex(extendedBase, flowRects);
8282
- return extendFinalPageOverlayRectToFlowHeight(merged, flowHeight);
8283
- }
8284
7996
  var resolvePageOverlayRectsFromGeometry2 = resolvePageOverlayRectsFromGeometry;
8285
7997
  function resolvePageOverlayRectsFromUiApi(ui, pageCount, visiblePageIndexRange, pageIds) {
8286
7998
  if (pageCount <= 0) return [];
@@ -8338,17 +8050,6 @@ var TwPageStackOverlayLayer = ({
8338
8050
  },
8339
8051
  []
8340
8052
  );
8341
- const reconcilePaperRectsWithFlow = React14.useCallback(
8342
- (baseRects, pageCount) => {
8343
- return reconcilePageStackRectsWithFlow({
8344
- baseRects,
8345
- pageCount,
8346
- scrollRoot,
8347
- originElement: overlayRootRef.current
8348
- });
8349
- },
8350
- [scrollRoot]
8351
- );
8352
8053
  const refreshRectsNow = React14.useCallback(() => {
8353
8054
  const pageCount = facet.getPageCount();
8354
8055
  const skeletalRects = resolveSkeletalPageOverlayRectsFromLayout(facet);
@@ -8389,51 +8090,11 @@ var TwPageStackOverlayLayer = ({
8389
8090
  setRectsIfChanged(skeletalRects);
8390
8091
  return;
8391
8092
  }
8392
- if (!scrollRoot) {
8393
- setRectsIfChanged(skeletalRects);
8394
- return;
8395
- }
8396
- const origin = overlayRootRef.current;
8397
- incrementInvalidationCounter("overlay.page.dom_fallback");
8398
- if (origin) {
8399
- incrementInvalidationCounter("overlay.page.dom.degraded");
8400
- const widgets = measureWidgetsViaBoundingRect(scrollRoot, origin, {
8401
- pageCount,
8402
- visiblePageIndexRange: null
8403
- });
8404
- const originRect = origin.getBoundingClientRect();
8405
- const domRects = resolvePageOverlayRects({
8406
- widgets,
8407
- pageCount,
8408
- scrollHeight: (
8409
- // geometry:allow-dom-fallback
8410
- origin.clientHeight > 0 ? origin.clientHeight : originRect.height
8411
- ),
8412
- visiblePageIndexRange: null
8413
- });
8414
- const reconciled = reconcilePaperRectsWithFlow(domRects, pageCount);
8415
- setRectsIfChanged(reconciled.length > 0 ? reconciled : skeletalRects);
8416
- } else {
8417
- incrementInvalidationCounter("overlay.page.dom.degraded");
8418
- const widgets = measureWidgetsViaOffsetChain(scrollRoot, {
8419
- pageCount,
8420
- visiblePageIndexRange: null
8421
- });
8422
- const domRects = resolvePageOverlayRects({
8423
- widgets,
8424
- pageCount,
8425
- // geometry:allow-dom-fallback
8426
- scrollHeight: scrollRoot.clientHeight,
8427
- visiblePageIndexRange: null
8428
- });
8429
- const reconciled = reconcilePaperRectsWithFlow(domRects, pageCount);
8430
- setRectsIfChanged(reconciled.length > 0 ? reconciled : skeletalRects);
8431
- }
8093
+ incrementInvalidationCounter("overlay.page.skeletal_fallback");
8094
+ setRectsIfChanged(skeletalRects);
8432
8095
  }, [
8433
8096
  facet,
8434
8097
  geometryFacet,
8435
- reconcilePaperRectsWithFlow,
8436
- scrollRoot,
8437
8098
  setRectsIfChanged,
8438
8099
  ui
8439
8100
  ]);
@@ -8464,33 +8125,6 @@ var TwPageStackOverlayLayer = ({
8464
8125
  }
8465
8126
  };
8466
8127
  }, [refreshRects, renderFrameRevision, scrollRoot]);
8467
- React14.useEffect(() => {
8468
- if (geometryFacet) return;
8469
- if (!scrollRoot) return;
8470
- const runtime = scrollRoot.ownerDocument?.defaultView;
8471
- if (!runtime?.ResizeObserver) return;
8472
- const observer = new runtime.ResizeObserver(() => refreshRects());
8473
- observer.observe(scrollRoot);
8474
- return () => observer.disconnect();
8475
- }, [geometryFacet, scrollRoot, refreshRects]);
8476
- React14.useEffect(() => {
8477
- if (geometryFacet) return;
8478
- if (!scrollRoot) return;
8479
- const runtime = scrollRoot.ownerDocument?.defaultView;
8480
- if (!runtime?.MutationObserver) return;
8481
- const observer = new runtime.MutationObserver((records) => {
8482
- const overlay = overlayRootRef.current;
8483
- if (overlay) {
8484
- const allSelf = records.every(
8485
- (r) => r.target instanceof Node && overlay.contains(r.target)
8486
- );
8487
- if (allSelf) return;
8488
- }
8489
- refreshRects();
8490
- });
8491
- observer.observe(scrollRoot, { childList: true, subtree: false });
8492
- return () => observer.disconnect();
8493
- }, [geometryFacet, scrollRoot, refreshRects]);
8494
8128
  if (rects.length === 0) {
8495
8129
  return /* @__PURE__ */ jsx28(
8496
8130
  "div",
@@ -9689,18 +9323,7 @@ function findScrollAnchor(root, options) {
9689
9323
  offsetWithinBlock: viewportTopFramePx - blockTop
9690
9324
  };
9691
9325
  }
9692
- }
9693
- const rootRect = root.getBoundingClientRect();
9694
- const rootTop = rootRect.top;
9695
- for (const block of blocks) {
9696
- const rect = block.getBoundingClientRect();
9697
- if (rect.bottom < rootTop) continue;
9698
- const blockId = block.getAttribute("data-block-id");
9699
- if (!blockId) continue;
9700
- return {
9701
- blockId,
9702
- offsetWithinBlock: rootTop - rect.top
9703
- };
9326
+ return null;
9704
9327
  }
9705
9328
  return null;
9706
9329
  }
@@ -9718,17 +9341,9 @@ function resolveScrollTopForAnchor(root, anchor, options) {
9718
9341
  const rect = geometry.rects[0];
9719
9342
  return rect.topPx + anchor.offsetWithinBlock;
9720
9343
  }
9344
+ return null;
9721
9345
  }
9722
- const selector = `[data-block-id="${cssEscape(anchor.blockId)}"]`;
9723
- const block = root.querySelector(selector);
9724
- if (!block) return null;
9725
- const rootRect = root.getBoundingClientRect();
9726
- const blockRect = block.getBoundingClientRect();
9727
- const delta = blockRect.top - rootRect.top + anchor.offsetWithinBlock;
9728
- return root.scrollTop + delta;
9729
- }
9730
- function cssEscape(value) {
9731
- return value.replace(/[^a-zA-Z0-9_-]/g, (ch) => `\\${ch}`);
9346
+ return null;
9732
9347
  }
9733
9348
 
9734
9349
  // src/ui-tailwind/chrome/collab-top-nav-container.tsx
@@ -12301,6 +11916,14 @@ var EDITOR_ACTION_REGISTRY = [
12301
11916
  targetKinds: ["generated-field"],
12302
11917
  callback: "onUpdateFields"
12303
11918
  }),
11919
+ mk({
11920
+ id: "toc-refresh",
11921
+ label: "Refresh table of contents",
11922
+ description: "Refresh TOC entries through the runtime table-of-contents updater.",
11923
+ group: "misc",
11924
+ targetKinds: ["toc-field"],
11925
+ callback: "onUpdateTableOfContents"
11926
+ }),
12304
11927
  // -------- Workflow scope --------
12305
11928
  mk({
12306
11929
  id: "scope-open-card",
@@ -12886,6 +12509,18 @@ function hasAncestorAttributeValue(el, attribute, expected, root) {
12886
12509
  }
12887
12510
  return false;
12888
12511
  }
12512
+ function hasAncestorAttributeValueInsensitive(el, attribute, expected, root) {
12513
+ const normalizedExpected = expected.toLowerCase();
12514
+ let cursor = el;
12515
+ while (cursor) {
12516
+ if (cursor.getAttribute?.(attribute)?.toLowerCase() === normalizedExpected) {
12517
+ return true;
12518
+ }
12519
+ if (cursor === root) return false;
12520
+ cursor = cursor.parentElement;
12521
+ }
12522
+ return false;
12523
+ }
12889
12524
  function resolveTargetKind(target, options = {}) {
12890
12525
  const kinds = [];
12891
12526
  const el = toElement(target);
@@ -12900,7 +12535,12 @@ function resolveTargetKind(target, options = {}) {
12900
12535
  const insideListItem = insideNumberingMarker || hasAncestorAttributeValue(el, "data-numbered", "true", root);
12901
12536
  const insideGeneratedField = hasAncestorAttributeValue(el, "data-generated-field", "true", root) || hasAncestorAttributeValue(el, "data-node-type", "field_ref_atom", root) || hasAncestorAttributeValue(el, "data-node-type", "field_ref", root);
12902
12537
  if (insideListItem) kinds.push("list-item");
12903
- if (insideGeneratedField) kinds.push("generated-field");
12538
+ if (insideGeneratedField) {
12539
+ kinds.push("generated-field");
12540
+ if (hasAncestorAttributeValueInsensitive(el, "data-field-family", "TOC", root)) {
12541
+ kinds.push("toc-field");
12542
+ }
12543
+ }
12904
12544
  if (hasAncestorTag(el, "a", root)) kinds.push("hyperlink");
12905
12545
  if (!insideNumberingMarker && hasAncestorTag(el, "img", root)) {
12906
12546
  kinds.push("image");
@@ -13206,45 +12846,17 @@ var TwFloatingImageLayer = ({
13206
12846
  const [pageRects, setPageRects] = React25.useState([]);
13207
12847
  const refreshPageRectsNow = React25.useCallback(() => {
13208
12848
  const pageCount = facet.getPageCount();
13209
- if (geometryFacet) {
13210
- const geometryRects = resolvePageOverlayRectsFromGeometry2(
13211
- geometryFacet,
13212
- pageCount,
13213
- visiblePageIndexRange
13214
- );
13215
- if (geometryRects !== null) {
13216
- setPageRects(geometryRects);
13217
- return;
13218
- }
12849
+ if (!geometryFacet) {
13219
12850
  setPageRects([]);
13220
12851
  return;
13221
12852
  }
13222
- if (!scrollRoot) {
13223
- setPageRects([]);
13224
- return;
13225
- }
13226
- const origin = overlayRootRef.current;
13227
- if (!origin) {
13228
- setPageRects([]);
13229
- return;
13230
- }
13231
- const widgets = measureWidgetsViaBoundingRect(scrollRoot, origin, {
12853
+ const geometryRects = resolvePageOverlayRectsFromGeometry2(
12854
+ geometryFacet,
13232
12855
  pageCount,
13233
12856
  visiblePageIndexRange
13234
- });
13235
- const originRect = origin.getBoundingClientRect();
13236
- setPageRects(
13237
- resolvePageOverlayRects({
13238
- widgets,
13239
- pageCount,
13240
- scrollHeight: (
13241
- // geometry:allow-dom-fallback
13242
- origin.clientHeight > 0 ? origin.clientHeight : originRect.height
13243
- ),
13244
- visiblePageIndexRange
13245
- })
13246
12857
  );
13247
- }, [facet, geometryFacet, scrollRoot, visiblePageIndexRange]);
12858
+ setPageRects(geometryRects ?? []);
12859
+ }, [facet, geometryFacet, visiblePageIndexRange]);
13248
12860
  const refreshPageRects = React25.useCallback(() => {
13249
12861
  if (!scrollRoot) {
13250
12862
  refreshPageRectsNow();
@@ -13274,47 +12886,6 @@ var TwFloatingImageLayer = ({
13274
12886
  }
13275
12887
  };
13276
12888
  }, [refreshPageRects, renderFrameRevision, scrollRoot]);
13277
- React25.useEffect(() => {
13278
- if (geometryFacet) {
13279
- return;
13280
- }
13281
- if (!scrollRoot) {
13282
- return;
13283
- }
13284
- const runtime = scrollRoot.ownerDocument?.defaultView;
13285
- if (!runtime?.ResizeObserver) {
13286
- return;
13287
- }
13288
- const observer = new runtime.ResizeObserver(() => refreshPageRects());
13289
- observer.observe(scrollRoot);
13290
- return () => observer.disconnect();
13291
- }, [geometryFacet, refreshPageRects, scrollRoot]);
13292
- React25.useEffect(() => {
13293
- if (geometryFacet) {
13294
- return;
13295
- }
13296
- if (!scrollRoot) {
13297
- return;
13298
- }
13299
- const runtime = scrollRoot.ownerDocument?.defaultView;
13300
- if (!runtime?.MutationObserver) {
13301
- return;
13302
- }
13303
- const observer = new runtime.MutationObserver((records) => {
13304
- const overlay = overlayRootRef.current;
13305
- if (overlay) {
13306
- const allSelf = records.every(
13307
- (record) => record.target instanceof Node && overlay.contains(record.target)
13308
- );
13309
- if (allSelf) {
13310
- return;
13311
- }
13312
- }
13313
- refreshPageRects();
13314
- });
13315
- observer.observe(scrollRoot, { childList: true, subtree: false });
13316
- return () => observer.disconnect();
13317
- }, [geometryFacet, refreshPageRects, scrollRoot]);
13318
12889
  const items = React25.useMemo(() => {
13319
12890
  const viewportScale = geometryFacet?.getViewport().pxPerTwip;
13320
12891
  const pxPerTwip = typeof viewportScale === "number" && viewportScale > 0 ? viewportScale : void 0;
@@ -17377,25 +16948,23 @@ var TwPageStackChromeLayerInner = ({
17377
16948
  const pageCount = facet.getPageCount();
17378
16949
  const uiRects = resolveUiPageRects(pageCount);
17379
16950
  if (uiRects !== null) return uiRects;
17380
- if (!geometryFacet) return [];
17381
- const warm = resolvePageOverlayRectsFromGeometry2(
17382
- geometryFacet,
17383
- pageCount,
17384
- visiblePageIndexRange
16951
+ if (geometryFacet) {
16952
+ const warm = resolvePageOverlayRectsFromGeometry2(
16953
+ geometryFacet,
16954
+ pageCount,
16955
+ visiblePageIndexRange
16956
+ );
16957
+ if (warm !== null) return warm;
16958
+ }
16959
+ return resolveSkeletalPageOverlayRectsFromLayout(facet).filter(
16960
+ (rect) => !visiblePageIndexRange || rect.pageIndex >= visiblePageIndexRange.start && rect.pageIndex < visiblePageIndexRange.end
17385
16961
  );
17386
- return warm ?? [];
17387
16962
  });
17388
16963
  const overlayRootRef = React34.useRef(null);
17389
16964
  const rafHandleRef = React34.useRef(null);
17390
16965
  const [activeStoryPageIndex, setActiveStoryPageIndex] = React34.useState(null);
17391
16966
  const refreshRectsNow = React34.useCallback(() => {
17392
16967
  const pageCount = facet.getPageCount();
17393
- const reconcileDomRects = (baseRects) => reconcilePageStackRectsWithFlow({
17394
- baseRects,
17395
- pageCount,
17396
- scrollRoot,
17397
- originElement: overlayRootRef.current
17398
- });
17399
16968
  const uiRects = resolveUiPageRects(pageCount);
17400
16969
  if (uiRects !== null) {
17401
16970
  setRects(uiRects);
@@ -17414,47 +16983,11 @@ var TwPageStackChromeLayerInner = ({
17414
16983
  setRects([]);
17415
16984
  return;
17416
16985
  }
17417
- if (!scrollRoot) {
17418
- setRects([]);
17419
- return;
17420
- }
17421
- const origin = overlayRootRef.current;
17422
- if (origin) {
17423
- const widgets = measureWidgetsViaBoundingRect(scrollRoot, origin, {
17424
- pageCount,
17425
- visiblePageIndexRange
17426
- });
17427
- const originRect = origin.getBoundingClientRect();
17428
- const scrollHeight = (
17429
- // geometry:allow-dom-fallback
17430
- origin.clientHeight > 0 ? origin.clientHeight : originRect.height > 0 ? originRect.height : scrollRoot.clientHeight
17431
- );
17432
- const domRects = resolvePageOverlayRects({
17433
- widgets,
17434
- pageCount,
17435
- scrollHeight,
17436
- visiblePageIndexRange
17437
- });
17438
- setRects(
17439
- reconcileDomRects(domRects)
17440
- );
17441
- } else {
17442
- const widgets = measureWidgetsViaOffsetChain(scrollRoot, {
17443
- pageCount,
17444
- visiblePageIndexRange
17445
- });
17446
- const domRects = resolvePageOverlayRects({
17447
- widgets,
17448
- pageCount,
17449
- // geometry:allow-dom-fallback
17450
- scrollHeight: scrollRoot.clientHeight,
17451
- visiblePageIndexRange
17452
- });
17453
- setRects(
17454
- reconcileDomRects(domRects)
17455
- );
17456
- }
17457
- }, [facet, geometryFacet, resolveUiPageRects, scrollRoot, visiblePageIndexRange]);
16986
+ const skeletalRects = resolveSkeletalPageOverlayRectsFromLayout(facet).filter(
16987
+ (rect) => !visiblePageIndexRange || rect.pageIndex >= visiblePageIndexRange.start && rect.pageIndex < visiblePageIndexRange.end
16988
+ );
16989
+ setRects(skeletalRects);
16990
+ }, [facet, geometryFacet, resolveUiPageRects, visiblePageIndexRange]);
17458
16991
  const refreshRects = React34.useCallback(() => {
17459
16992
  if (!scrollRoot) {
17460
16993
  refreshRectsNow();
@@ -17494,33 +17027,6 @@ var TwPageStackChromeLayerInner = ({
17494
17027
  },
17495
17028
  [onOpenStory]
17496
17029
  );
17497
- React34.useEffect(() => {
17498
- if (geometryFacet) return;
17499
- if (!scrollRoot) return;
17500
- const runtime = scrollRoot.ownerDocument?.defaultView;
17501
- if (!runtime?.ResizeObserver) return;
17502
- const observer = new runtime.ResizeObserver(() => refreshRects());
17503
- observer.observe(scrollRoot);
17504
- return () => observer.disconnect();
17505
- }, [geometryFacet, scrollRoot, refreshRects]);
17506
- React34.useEffect(() => {
17507
- if (geometryFacet) return;
17508
- if (!scrollRoot) return;
17509
- const runtime = scrollRoot.ownerDocument?.defaultView;
17510
- if (!runtime?.MutationObserver) return;
17511
- const observer = new runtime.MutationObserver((records) => {
17512
- const overlay = overlayRootRef.current;
17513
- if (overlay) {
17514
- const allSelf = records.every(
17515
- (r) => r.target instanceof Node && overlay.contains(r.target)
17516
- );
17517
- if (allSelf) return;
17518
- }
17519
- refreshRects();
17520
- });
17521
- observer.observe(scrollRoot, { childList: true, subtree: false });
17522
- return () => observer.disconnect();
17523
- }, [geometryFacet, scrollRoot, refreshRects]);
17524
17030
  React34.useLayoutEffect(() => {
17525
17031
  if (!pmSurfaceElement) return;
17526
17032
  const overlay = overlayRootRef.current;
@@ -17698,6 +17204,10 @@ function TwTableGripLayer({
17698
17204
  tableGeometry,
17699
17205
  plan.columnsTwips
17700
17206
  );
17207
+ const columnWidthCapability = tableContext.operations.setColumnWidth;
17208
+ const rowHeightCapability = tableContext.operations.setRowHeight;
17209
+ const columnResizeDisabled = !!disabled || !onSetColumnWidth || columnWidthCapability?.enabled === false;
17210
+ const rowResizeDisabled = !!disabled || !onSetRowHeight || rowHeightCapability?.enabled === false;
17701
17211
  return /* @__PURE__ */ jsxs50(Fragment13, { children: [
17702
17212
  plan.columnResizeHandles.map((handle) => {
17703
17213
  const rect = resolveColumnEdgeRect(
@@ -17712,7 +17222,8 @@ function TwTableGripLayer({
17712
17222
  colIndex: handle.columnIndex,
17713
17223
  originalTwips: plan.columnsTwips[handle.columnIndex] ?? 720,
17714
17224
  pxPerTwip,
17715
- disabled: !!disabled || !onSetColumnWidth,
17225
+ disabled: columnResizeDisabled,
17226
+ disabledReason: columnWidthCapability?.reason,
17716
17227
  onCommit: onSetColumnWidth
17717
17228
  },
17718
17229
  `col-${blockId}-${handle.columnIndex}`
@@ -17733,7 +17244,8 @@ function TwTableGripLayer({
17733
17244
  rowIndex,
17734
17245
  originalTwips,
17735
17246
  pxPerTwip,
17736
- disabled: !!disabled || !onSetRowHeight,
17247
+ disabled: rowResizeDisabled,
17248
+ disabledReason: rowHeightCapability?.reason,
17737
17249
  onCommit: onSetRowHeight
17738
17250
  },
17739
17251
  `row-${blockId}-${rowIndex}`
@@ -17823,6 +17335,7 @@ function ColResizeGrip({
17823
17335
  originalTwips,
17824
17336
  pxPerTwip,
17825
17337
  disabled,
17338
+ disabledReason,
17826
17339
  onCommit
17827
17340
  }) {
17828
17341
  const dragRef = useRef19(null);
@@ -17881,11 +17394,13 @@ function ColResizeGrip({
17881
17394
  role: "separator",
17882
17395
  "aria-orientation": "vertical",
17883
17396
  "aria-label": `Resize column ${colIndex + 1}`,
17397
+ "aria-disabled": disabled ? "true" : void 0,
17884
17398
  "data-testid": `col-resize-grip-${colIndex}`,
17885
17399
  "data-active": isActive ? "true" : "false",
17400
+ title: disabled ? disabledReason : void 0,
17886
17401
  className: [
17887
- "wre-table-grip-col pointer-events-auto absolute",
17888
- disabled ? "opacity-0 cursor-default" : ""
17402
+ "wre-table-grip-col absolute",
17403
+ disabled ? "pointer-events-none opacity-0 cursor-default" : "pointer-events-auto"
17889
17404
  ].filter(Boolean).join(" "),
17890
17405
  style: {
17891
17406
  left: `calc(${pos.left} - ${GRIP_HIT_PX / 2}px)`,
@@ -17903,6 +17418,7 @@ function RowResizeGrip({
17903
17418
  originalTwips,
17904
17419
  pxPerTwip,
17905
17420
  disabled,
17421
+ disabledReason,
17906
17422
  onCommit
17907
17423
  }) {
17908
17424
  const dragRef = useRef19(null);
@@ -17962,11 +17478,13 @@ function RowResizeGrip({
17962
17478
  role: "separator",
17963
17479
  "aria-orientation": "horizontal",
17964
17480
  "aria-label": `Resize row ${rowIndex + 1}`,
17481
+ "aria-disabled": disabled ? "true" : void 0,
17965
17482
  "data-testid": `row-resize-grip-${rowIndex}`,
17966
17483
  "data-active": isActive ? "true" : "false",
17484
+ title: disabled ? disabledReason : void 0,
17967
17485
  className: [
17968
- "wre-table-grip-row pointer-events-auto absolute",
17969
- disabled ? "opacity-0 cursor-default" : ""
17486
+ "wre-table-grip-row absolute",
17487
+ disabled ? "pointer-events-none opacity-0 cursor-default" : "pointer-events-auto"
17970
17488
  ].filter(Boolean).join(" "),
17971
17489
  style: {
17972
17490
  left: pos.left,