docxodus 9.4.0 → 9.5.0

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/dist/editor.d.ts CHANGED
@@ -16,6 +16,7 @@
16
16
  * edited block is not preserved — a documented MVP limit); UNTOUCHED blocks keep
17
17
  * full fidelity, and save() is lossless for them.
18
18
  */
19
+ import type { ColumnWidth } from "./viewport.js";
19
20
  import type { BandWhich } from "./editor-headerfooter.js";
20
21
  import { TrackedChangeMode } from "./types.js";
21
22
  import type { HeaderFooterKind, NumberFormat } from "./types.js";
@@ -96,8 +97,19 @@ export interface DocxEditorOptions {
96
97
  editable?: boolean;
97
98
  /** Render block-flow pages (page boxes via pagination.ts) vs a continuous view. Default false. */
98
99
  paginated?: boolean;
99
- /** Page render scale for paginated mode (1.0 = 100%). Default 1. */
100
+ /** Author-pinned page render scale (1.0 = 100%). Default 1. */
100
101
  scale?: number;
102
+ /**
103
+ * How the continuous view sizes its text column. `"section"` (default) uses the width the
104
+ * document's `w:sectPr` defines, so line breaking matches Word on every screen; `"fluid"`
105
+ * lets the column follow the host, the pre-geometry behavior.
106
+ */
107
+ columnWidth?: ColumnWidth;
108
+ /**
109
+ * Zoom the page down to fit a host narrower than it, the way a word processor's
110
+ * fit-to-width does, instead of letting it overflow. Default true.
111
+ */
112
+ fitToWidth?: boolean;
101
113
  /**
102
114
  * Render docked Header/Footer editing bands around the body flow. Default FALSE — with it off
103
115
  * the editor's DOM is unchanged, so existing consumers are unaffected. When on, the body flow
@@ -158,7 +170,11 @@ export declare class DocxEditor {
158
170
  private blockMoveLive;
159
171
  private blockDragSource;
160
172
  private blockDragCleanup;
161
- private blockDragTargetCleanup;
173
+ /** Block boxes measured at drag start — see `BlockDropZone`. Empty when no drag is in flight. */
174
+ private dropZones;
175
+ /** Combined scroll offset when `dropZones` was measured, and the scroller measured against. */
176
+ private dropZoneOrigin;
177
+ private dropZoneScroller;
162
178
  private blockDragging;
163
179
  private blockDragPointerDown;
164
180
  /** Anchors the current drag source may legally move next to, per the engine's own rules.
@@ -191,6 +207,8 @@ export declare class DocxEditor {
191
207
  private dragSelection;
192
208
  /** The docked header/footer bands, when `options.headerFooter` is on. */
193
209
  private region;
210
+ /** Page geometry + fit-to-width zoom for the mounted document. Re-attached on every mount. */
211
+ private readonly viewport;
194
212
  /** Why the last reconcile() fell back to a full remount (null = it patched). For
195
213
  * diagnostics/specs; not part of the public API. */
196
214
  private lastReconcileFallback;
@@ -259,6 +277,12 @@ export declare class DocxEditor {
259
277
  setPaginated(value: boolean): void;
260
278
  /** The editor's current DOM (for inspection/tests). */
261
279
  get root(): HTMLElement;
280
+ /**
281
+ * The zoom the viewport is currently applying (1 = 100%). Below 1 the page is wider than the
282
+ * host and has been scaled to fit rather than reflowed — the honest thing to show a user who
283
+ * is wondering why a phone shows the whole page.
284
+ */
285
+ get zoom(): number;
262
286
  /**
263
287
  * The live `DocxSession` handle backing this editor — the model of record.
264
288
  *
@@ -276,7 +300,16 @@ export declare class DocxEditor {
276
300
  private showBlockHandle;
277
301
  private hideBlockHandle;
278
302
  private positionBlockHandle;
279
- private showDropIndicator;
303
+ /** Draw the drop line on `zone`'s requested edge, or take it away when there is no target. */
304
+ private paintDropIndicator;
305
+ /**
306
+ * Where to draw the line for an insertion on `position` of `zone` — the MIDDLE of the gap to
307
+ * the neighbour on that side, not the zone's own border-box edge. A paragraph's `w:spacing`
308
+ * becomes a CSS margin, which sits outside the box, so drawing on the edge underlines the
309
+ * block's last line instead of reading as a gap between two blocks. Falls back to the raw edge
310
+ * at the ends of the flow, and degrades to the same value when blocks are contiguous.
311
+ */
312
+ private dropEdgeY;
280
313
  private hideDropIndicator;
281
314
  private announceBlockMove;
282
315
  /**
@@ -305,14 +338,24 @@ export declare class DocxEditor {
305
338
  * legal and the other not, so "this target is reachable" is not enough to pick a position.
306
339
  */
307
340
  private isValidMoveTarget;
341
+ /** Measure every movable block once, at drag start. See `BlockDropZone`. */
342
+ private captureDropZones;
343
+ private scrollOffsetSum;
344
+ /** How far the measured boxes have travelled since capture, from scrolling (drag autoscroll). */
345
+ private dropZoneShift;
308
346
  /**
309
- * The side of `unit` a drop at `clientY` should land on: the half the pointer is in, snapped to
310
- * the other side when only that one is legal. Snapping rather than refusing keeps a reachable
311
- * target usable the illegal side is usually illegal only because a section break or a
312
- * cross-block range sits between the two blocks on that side.
313
- */
314
- private dropPositionFor;
315
- private refreshBlockDropTargets;
347
+ * Where a drop at `clientY` lands, or null when nothing there is legal.
348
+ *
349
+ * Resolution is by VERTICAL GEOMETRY over the measured blocks, not by which element the pointer
350
+ * is over: the drag handle floats in the page margin, so a drag straight down the gutter — the
351
+ * natural gesture — never crosses a paragraph box, and element hit testing gave those drags no
352
+ * indicator and no drop at all. The nearest block by vertical distance is the target; the half
353
+ * the pointer is in picks the side, snapped to the other side when only that one is legal
354
+ * (a section break or a cross-block range usually makes exactly one side illegal). When neither
355
+ * side is legal — the pointer is in a region this block cannot reach — there is no drop, and
356
+ * nothing is drawn.
357
+ */
358
+ private resolveDropAt;
316
359
  private closeBlockMoveMenu;
317
360
  private openBlockMoveMenu;
318
361
  /**
@@ -362,7 +405,14 @@ export declare class DocxEditor {
362
405
  * indices, and band blocks in that list would shift every index.
363
406
  */
364
407
  private dockBands;
365
- /** Continuous (non-paginated) mount: inject the converter's styles + body, wire blocks. */
408
+ /**
409
+ * Continuous (non-paginated) mount: inject the converter's styles + body, wire blocks.
410
+ *
411
+ * The body always gets its own `.docx-body-flow` wrapper — not only when bands are docked.
412
+ * It is the sheet: the element the viewport gives page geometry to and zooms, and the one
413
+ * the bands dock around. Without it the container would have to be both the scrolling host
414
+ * and the scaled page, which are different boxes.
415
+ */
366
416
  private mountHtml;
367
417
  /** Paginated mount: flow blocks into page boxes via pagination.ts, wire the page clones. */
368
418
  private mountPaginated;
@@ -1 +1 @@
1
- {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;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AAC,YAAY;IAIpB,OAAO,CAAC,UAAU;IAMlB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAanB,oFAAoF;IACpF,OAAO,CAAC,YAAY;IAUpB;;0BAEsB;IACtB,OAAO,CAAC,aAAa;IASrB,8EAA8E;IAC9E,OAAO,CAAC,MAAM,CAAC,UAAU;IAMzB;0BACsB;IACtB,OAAO,CAAC,MAAM,CAAC,SAAS;IAKxB,OAAO,CAAC,MAAM,CAAC,cAAc;IAK7B;;;;OAIG;IACH,OAAO,CAAC,SAAS;IA0BjB,uEAAuE;IACvE,OAAO,CAAC,aAAa;IA+FrB,OAAO,CAAC,IAAI;IAKZ;;iFAE6E;IAC7E,OAAO,CAAC,aAAa;IAcrB;uFACmF;IACnF,OAAO,CAAC,MAAM,CAAC,UAAU;IAMzB;;4EAEwE;IACxE,OAAO,CAAC,aAAa;IA0GrB;;kDAE8C;IAC9C,OAAO,CAAC,QAAQ;IAOhB;iCAC6B;IAC7B,OAAO,CAAC,SAAS;IAmBjB,uFAAuF;IACvF,OAAO,CAAC,cAAc;IA2BtB;;wEAEoE;IACpE,OAAO,CAAC,WAAW;IAkBnB;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAwC1B;2EACuE;IACvE,OAAO,CAAC,kBAAkB;IAK1B;;iEAE6D;IAC7D,OAAO,CAAC,cAAc;IA+BtB;;;;;OAKG;IACH,OAAO,CAAC,OAAO;CAoBhB"}
package/dist/editor.js CHANGED
@@ -17,14 +17,24 @@
17
17
  * full fidelity, and save() is lossless for them.
18
18
  */
19
19
  import { paginateHtml } from "./pagination.js";
20
+ import { DocumentViewport } from "./viewport.js";
20
21
  import { HeaderFooterRegion } from "./editor-headerfooter.js";
21
22
  import { draggable, dropTargetForElements, monitorForElements, } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
23
+ import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
24
+ import { pointerOutsideOfPreview } from "@atlaskit/pragmatic-drag-and-drop/element/pointer-outside-of-preview";
22
25
  import { autoScrollForElements, autoScrollWindowForElements, } from "@atlaskit/pragmatic-drag-and-drop-auto-scroll/element";
23
26
  import { TrackedChangeMode } from "./types.js";
24
27
  import { diffUnits, needsRemount, unidOf } from "./editor-reconcile.js";
25
28
  const EDITABLE_TAGS = new Set(["P", "H1", "H2", "H3", "H4", "H5", "H6"]);
26
29
  const BLOCK_DRAG_TYPE = "docxodus-block";
27
30
  const blockDragStyledDocuments = new WeakSet();
31
+ /** One-line description of a block, for the handle's label and the drag preview chip. */
32
+ function blockPreviewText(unit) {
33
+ if (unit.tagName === "TABLE")
34
+ return "Table";
35
+ const text = (unit.textContent ?? "").trim().replace(/\s+/g, " ");
36
+ return text.length > 48 ? `${text.slice(0, 48)}…` : text;
37
+ }
28
38
  function ensureBlockDragStyles(doc) {
29
39
  if (blockDragStyledDocuments.has(doc))
30
40
  return;
@@ -40,10 +50,28 @@ function ensureBlockDragStyles(doc) {
40
50
  }
41
51
  .docx-block-handle:hover, .docx-block-handle:focus-visible { color: #344054; border-color: #98a2b3; outline: none; }
42
52
  .docx-block-handle[aria-pressed="true"] { color: #175cd3; border-color: #84adff; background: #eff8ff; }
43
- .docx-block-handle.docx-block-dragging { cursor: grabbing; opacity: .78; }
53
+ .docx-block-handle.docx-block-dragging { cursor: grabbing; opacity: .35; }
54
+ /* The block being carried. Dimming it is the "a drag is happening" signal that survives the
55
+ pointer being anywhere on screen — the drop line only says where, not what. */
56
+ .docx-block-drag-source { opacity: .38; transition: opacity 120ms ease-out; }
57
+ /* Positioned by transform so tracking the pointer costs no layout. Flipping display none→block
58
+ restarts the fade — one cheap entry animation per appearance, none while it tracks. */
44
59
  .docx-block-drop-indicator {
45
- position: fixed; z-index: 2147482999; display: none; height: 3px; pointer-events: none;
46
- border-radius: 999px; background: #2e90fa; box-shadow: 0 0 0 1px rgba(255,255,255,.85);
60
+ position: fixed; top: 0; left: 0; z-index: 2147482999; display: none; height: 0;
61
+ pointer-events: none; border-top: 2px solid #2e90fa;
62
+ filter: drop-shadow(0 1px 2px rgba(46,144,250,.5));
63
+ animation: docx-block-drop-in 110ms ease-out;
64
+ }
65
+ .docx-block-drop-indicator::before {
66
+ content: ""; position: absolute; top: -5px; left: -2px; width: 8px; height: 8px;
67
+ border-radius: 50%; background: #2e90fa;
68
+ }
69
+ @keyframes docx-block-drop-in { from { opacity: 0; } to { opacity: 1; } }
70
+ .docx-block-drag-preview {
71
+ max-width: 320px; padding: 6px 10px; border: 1px solid #b2ddff; border-radius: 6px;
72
+ background: #eff8ff; color: #175cd3; box-shadow: 0 6px 16px rgba(16,24,40,.18);
73
+ font: 500 13px/1.35 system-ui, sans-serif; white-space: nowrap; overflow: hidden;
74
+ text-overflow: ellipsis;
47
75
  }
48
76
  .docx-block-move-menu {
49
77
  position: fixed; z-index: 2147483001; display: none; min-width: 150px; padding: 5px;
@@ -559,7 +587,11 @@ export class DocxEditor {
559
587
  this.blockMoveLive = null;
560
588
  this.blockDragSource = null;
561
589
  this.blockDragCleanup = [];
562
- this.blockDragTargetCleanup = [];
590
+ /** Block boxes measured at drag start — see `BlockDropZone`. Empty when no drag is in flight. */
591
+ this.dropZones = [];
592
+ /** Combined scroll offset when `dropZones` was measured, and the scroller measured against. */
593
+ this.dropZoneOrigin = 0;
594
+ this.dropZoneScroller = null;
563
595
  this.blockDragging = false;
564
596
  this.blockDragPointerDown = false;
565
597
  /** Anchors the current drag source may legally move next to, per the engine's own rules.
@@ -703,6 +735,11 @@ export class DocxEditor {
703
735
  this.handle = handle;
704
736
  this.options = options;
705
737
  this.editRoot = container;
738
+ this.viewport = new DocumentViewport(container, {
739
+ columnWidth: options.columnWidth,
740
+ fitToWidth: options.fitToWidth,
741
+ scale: options.scale,
742
+ });
706
743
  if (typeof document !== "undefined") {
707
744
  document.addEventListener("selectionchange", this.onSelectionChange);
708
745
  document.addEventListener("mousedown", this.onMouseDown, true);
@@ -790,6 +827,8 @@ export class DocxEditor {
790
827
  editable: options.editable ?? true,
791
828
  paginated: options.paginated ?? false,
792
829
  scale: options.scale ?? 1,
830
+ columnWidth: options.columnWidth ?? "section",
831
+ fitToWidth: options.fitToWidth ?? true,
793
832
  headerFooter: options.headerFooter ?? false,
794
833
  blockDrag: options.blockDrag ?? false,
795
834
  trackedChanges: options.trackedChanges ?? TrackedChangeMode.Accept,
@@ -847,6 +886,7 @@ export class DocxEditor {
847
886
  }
848
887
  this.clearDragSelection();
849
888
  this.teardownBlockDrag();
889
+ this.viewport.dispose();
850
890
  this.exports.DocxSessionBridge.CloseSession(this.handle);
851
891
  }
852
892
  /**
@@ -865,6 +905,14 @@ export class DocxEditor {
865
905
  get root() {
866
906
  return this.container;
867
907
  }
908
+ /**
909
+ * The zoom the viewport is currently applying (1 = 100%). Below 1 the page is wider than the
910
+ * host and has been scaled to fit rather than reflowed — the honest thing to show a user who
911
+ * is wondering why a phone shows the whole page.
912
+ */
913
+ get zoom() {
914
+ return this.viewport.scale;
915
+ }
868
916
  /**
869
917
  * The live `DocxSession` handle backing this editor — the model of record.
870
918
  *
@@ -985,11 +1033,8 @@ export class DocxEditor {
985
1033
  handle.style.display = "flex";
986
1034
  handle.style.left = `${Math.max(4, rect.left - 32)}px`;
987
1035
  handle.style.top = `${Math.max(4, rect.top + (unit.tagName === "TABLE" ? 6 : Math.max(0, (rect.height - 28) / 2)))}px`;
988
- const preview = (unit.textContent ?? "").trim().replace(/\s+/g, " ").slice(0, 48);
1036
+ const preview = blockPreviewText(unit);
989
1037
  handle.setAttribute("aria-label", preview ? `Move block: ${preview}` : "Move block");
990
- // Drop targets are registered when a drag actually begins (and once at mount), not on
991
- // hover: re-registering one listener per body block every time the pointer crosses a
992
- // paragraph boundary is work no drop can use.
993
1038
  }
994
1039
  hideBlockHandle() {
995
1040
  if (this.blockDragging || this.blockMoveMenu?.style.display === "block")
@@ -1002,15 +1047,42 @@ export class DocxEditor {
1002
1047
  if (source && this.blockDragHandle?.style.display !== "none")
1003
1048
  this.showBlockHandle(source);
1004
1049
  }
1005
- showDropIndicator(target, position) {
1050
+ /** Draw the drop line on `zone`'s requested edge, or take it away when there is no target. */
1051
+ paintDropIndicator(data) {
1006
1052
  const indicator = this.blockDropIndicator;
1053
+ const zone = data.zone;
1007
1054
  if (!indicator)
1008
1055
  return;
1009
- const rect = this.unitWrapperOf(target).getBoundingClientRect();
1056
+ if (!zone) {
1057
+ this.hideDropIndicator();
1058
+ return;
1059
+ }
1060
+ const y = Math.round(this.dropEdgeY(zone, data.position === "after" ? "after" : "before")
1061
+ + this.dropZoneShift()) - 1;
1062
+ // Position before revealing, so the entry fade never plays at a stale spot.
1063
+ indicator.style.transform = `translate3d(${Math.round(zone.left)}px, ${y}px, 0)`;
1064
+ indicator.style.width = `${Math.max(24, Math.round(zone.width))}px`;
1010
1065
  indicator.style.display = "block";
1011
- indicator.style.left = `${rect.left}px`;
1012
- indicator.style.top = `${position === "before" ? rect.top - 1 : rect.bottom - 1}px`;
1013
- indicator.style.width = `${Math.max(24, rect.width)}px`;
1066
+ }
1067
+ /**
1068
+ * Where to draw the line for an insertion on `position` of `zone` — the MIDDLE of the gap to
1069
+ * the neighbour on that side, not the zone's own border-box edge. A paragraph's `w:spacing`
1070
+ * becomes a CSS margin, which sits outside the box, so drawing on the edge underlines the
1071
+ * block's last line instead of reading as a gap between two blocks. Falls back to the raw edge
1072
+ * at the ends of the flow, and degrades to the same value when blocks are contiguous.
1073
+ */
1074
+ dropEdgeY(zone, position) {
1075
+ const neighbour = this.dropZones[zone.index + (position === "after" ? 1 : -1)];
1076
+ // At the ends of the flow there is nothing to bisect against, so half the block's own
1077
+ // margin stands in for half the gap — the same position, one contributor instead of two.
1078
+ if (!neighbour) {
1079
+ return position === "after"
1080
+ ? zone.bottom + zone.marginAfter / 2
1081
+ : zone.top - zone.marginBefore / 2;
1082
+ }
1083
+ return position === "after"
1084
+ ? (zone.bottom + neighbour.top) / 2
1085
+ : (neighbour.bottom + zone.top) / 2;
1014
1086
  }
1015
1087
  hideDropIndicator() {
1016
1088
  if (this.blockDropIndicator)
@@ -1100,49 +1172,74 @@ export class DocxEditor {
1100
1172
  return false;
1101
1173
  return position ? sides[position] : sides.before || sides.after;
1102
1174
  }
1175
+ /** Measure every movable block once, at drag start. See `BlockDropZone`. */
1176
+ captureDropZones() {
1177
+ const view = this.container.ownerDocument.defaultView;
1178
+ this.dropZoneScroller = this.scrollContainer();
1179
+ this.dropZoneOrigin = this.scrollOffsetSum();
1180
+ this.dropZones = [];
1181
+ const boxes = [];
1182
+ for (const unit of this.bodyUnitNodes()) {
1183
+ const anchorId = this.isMovableBlockUnit(unit) ? this.anchorIdOf(unit) : null;
1184
+ if (!anchorId)
1185
+ continue;
1186
+ const box = this.unitWrapperOf(unit);
1187
+ const rect = box.getBoundingClientRect();
1188
+ boxes.push(box);
1189
+ this.dropZones.push({
1190
+ unit, anchorId, index: this.dropZones.length,
1191
+ top: rect.top, bottom: rect.bottom, left: rect.left, width: rect.width,
1192
+ marginBefore: 0, marginAfter: 0,
1193
+ });
1194
+ }
1195
+ // Only the flow's two ends ever consult a margin, so only they are worth a style read.
1196
+ const ends = new Set([0, this.dropZones.length - 1].filter((i) => i >= 0 && i < boxes.length));
1197
+ for (const i of ends) {
1198
+ const style = view?.getComputedStyle(boxes[i]);
1199
+ this.dropZones[i].marginBefore = parseFloat(style?.marginTop ?? "0") || 0;
1200
+ this.dropZones[i].marginAfter = parseFloat(style?.marginBottom ?? "0") || 0;
1201
+ }
1202
+ }
1203
+ scrollOffsetSum() {
1204
+ const view = this.container.ownerDocument.defaultView;
1205
+ return (view?.scrollY ?? 0) + (this.dropZoneScroller?.scrollTop ?? 0);
1206
+ }
1207
+ /** How far the measured boxes have travelled since capture, from scrolling (drag autoscroll). */
1208
+ dropZoneShift() {
1209
+ return this.dropZoneOrigin - this.scrollOffsetSum();
1210
+ }
1103
1211
  /**
1104
- * The side of `unit` a drop at `clientY` should land on: the half the pointer is in, snapped to
1105
- * the other side when only that one is legal. Snapping rather than refusing keeps a reachable
1106
- * target usable the illegal side is usually illegal only because a section break or a
1107
- * cross-block range sits between the two blocks on that side.
1212
+ * Where a drop at `clientY` lands, or null when nothing there is legal.
1213
+ *
1214
+ * Resolution is by VERTICAL GEOMETRY over the measured blocks, not by which element the pointer
1215
+ * is over: the drag handle floats in the page margin, so a drag straight down the gutter — the
1216
+ * natural gesture — never crosses a paragraph box, and element hit testing gave those drags no
1217
+ * indicator and no drop at all. The nearest block by vertical distance is the target; the half
1218
+ * the pointer is in picks the side, snapped to the other side when only that one is legal
1219
+ * (a section break or a cross-block range usually makes exactly one side illegal). When neither
1220
+ * side is legal — the pointer is in a region this block cannot reach — there is no drop, and
1221
+ * nothing is drawn.
1108
1222
  */
1109
- dropPositionFor(unit, clientY) {
1110
- const rect = unit.getBoundingClientRect();
1111
- const preferred = clientY < rect.top + rect.height / 2 ? "before" : "after";
1112
- if (this.isValidMoveTarget(unit, preferred))
1113
- return preferred;
1114
- const other = preferred === "before" ? "after" : "before";
1115
- return this.isValidMoveTarget(unit, other) ? other : preferred;
1116
- }
1117
- refreshBlockDropTargets() {
1118
- for (const cleanup of this.blockDragTargetCleanup.splice(0))
1119
- cleanup();
1120
- if (!this.blockDragHandle || this.options.paginated)
1121
- return;
1122
- for (const unit of this.bodyUnitNodes().filter((el) => this.isMovableBlockUnit(el))) {
1123
- this.blockDragTargetCleanup.push(dropTargetForElements({
1124
- element: unit,
1125
- // A target the engine would refuse is not a drop target at all, so Pragmatic never
1126
- // fires onDragEnter for it and no indicator is drawn over it.
1127
- canDrop: ({ source }) => source.data.type === BLOCK_DRAG_TYPE && source.data.sourceAnchorId !== this.anchorIdOf(unit) &&
1128
- this.isValidMoveTarget(unit),
1129
- getData: ({ input }) => ({
1130
- type: BLOCK_DRAG_TYPE,
1131
- targetAnchorId: this.anchorIdOf(unit),
1132
- position: this.dropPositionFor(unit, input.clientY),
1133
- targetElement: unit,
1134
- }),
1135
- onDragEnter: ({ self }) => {
1136
- const pos = self.data.position === "after" ? "after" : "before";
1137
- this.showDropIndicator(unit, pos);
1138
- },
1139
- onDrag: ({ self }) => {
1140
- const pos = self.data.position === "after" ? "after" : "before";
1141
- this.showDropIndicator(unit, pos);
1142
- },
1143
- onDragLeave: () => this.hideDropIndicator(),
1144
- }));
1223
+ resolveDropAt(clientY) {
1224
+ const y = clientY - this.dropZoneShift();
1225
+ let best = null;
1226
+ let bestGap = Infinity;
1227
+ for (const zone of this.dropZones) {
1228
+ const gap = y < zone.top ? zone.top - y : y > zone.bottom ? y - zone.bottom : 0;
1229
+ if (gap < bestGap) {
1230
+ best = zone;
1231
+ bestGap = gap;
1232
+ }
1233
+ if (gap === 0)
1234
+ break; // inside this block; zones are in document order and never overlap
1145
1235
  }
1236
+ if (!best || best.unit === this.blockDragSource)
1237
+ return null;
1238
+ const preferred = y < (best.top + best.bottom) / 2 ? "before" : "after";
1239
+ if (this.isValidMoveTarget(best.unit, preferred))
1240
+ return { zone: best, position: preferred };
1241
+ const other = preferred === "before" ? "after" : "before";
1242
+ return this.isValidMoveTarget(best.unit, other) ? { zone: best, position: other } : null;
1146
1243
  }
1147
1244
  closeBlockMoveMenu(restoreFocus = false) {
1148
1245
  if (!this.blockMoveMenu || !this.blockDragHandle)
@@ -1324,20 +1421,59 @@ export class DocxEditor {
1324
1421
  const source = this.currentBlockDragSource();
1325
1422
  return { type: BLOCK_DRAG_TYPE, sourceAnchorId: source ? this.anchorIdOf(source) : undefined };
1326
1423
  },
1424
+ // The browser would otherwise ghost the 26px grip, which says nothing about what is moving.
1425
+ onGenerateDragPreview: ({ nativeSetDragImage }) => {
1426
+ const source = this.currentBlockDragSource();
1427
+ setCustomNativeDragPreview({
1428
+ nativeSetDragImage,
1429
+ getOffset: pointerOutsideOfPreview({ x: "14px", y: "10px" }),
1430
+ render: ({ container }) => {
1431
+ const chip = doc.createElement("div");
1432
+ chip.className = "docx-block-drag-preview";
1433
+ chip.textContent = (source && blockPreviewText(source)) || "Move block";
1434
+ container.appendChild(chip);
1435
+ return () => chip.remove();
1436
+ },
1437
+ });
1438
+ },
1327
1439
  onDragStart: () => {
1440
+ const source = this.currentBlockDragSource();
1328
1441
  this.blockDragging = true;
1329
1442
  handle.classList.add("docx-block-dragging");
1443
+ // After the preview snapshot, so the chip is not dimmed too.
1444
+ source?.classList.add("docx-block-drag-source");
1330
1445
  this.closeBlockMoveMenu();
1331
- this.refreshBlockMoveTargets(this.currentBlockDragSource());
1332
- this.refreshBlockDropTargets();
1446
+ this.refreshBlockMoveTargets(source);
1447
+ this.captureDropZones();
1333
1448
  },
1334
1449
  onDrop: () => {
1335
1450
  this.blockDragging = false;
1336
1451
  this.blockDragPointerDown = false;
1452
+ this.dropZones = [];
1337
1453
  handle.classList.remove("docx-block-dragging");
1454
+ // Cleared by selector rather than from a captured reference: a completed move may have
1455
+ // re-rendered the block, and the node that carries the class outlives either handle on it.
1456
+ doc.querySelectorAll(".docx-block-drag-source")
1457
+ .forEach((el) => el.classList.remove("docx-block-drag-source"));
1338
1458
  this.hideDropIndicator();
1339
1459
  },
1340
1460
  }));
1461
+ // ONE drop target for the whole flow. Which block a drop belongs to is decided by
1462
+ // `resolveDropAt` from the pointer's vertical position, so the gutter the handle is dragged
1463
+ // down counts as being over the document — see that method.
1464
+ this.blockDragCleanup.push(dropTargetForElements({
1465
+ element: this.editRoot,
1466
+ canDrop: ({ source }) => source.data.type === BLOCK_DRAG_TYPE,
1467
+ getData: ({ input }) => {
1468
+ const hit = this.resolveDropAt(input.clientY);
1469
+ return hit
1470
+ ? { type: BLOCK_DRAG_TYPE, targetAnchorId: hit.zone.anchorId, position: hit.position, zone: hit.zone }
1471
+ : { type: BLOCK_DRAG_TYPE };
1472
+ },
1473
+ onDragEnter: ({ self }) => this.paintDropIndicator(self.data),
1474
+ onDrag: ({ self }) => this.paintDropIndicator(self.data),
1475
+ onDragLeave: () => this.hideDropIndicator(),
1476
+ }));
1341
1477
  this.blockDragCleanup.push(monitorForElements({
1342
1478
  canMonitor: ({ source }) => source.data.type === BLOCK_DRAG_TYPE,
1343
1479
  onDrop: ({ source, location }) => {
@@ -1369,14 +1505,13 @@ export class DocxEditor {
1369
1505
  canScroll: ({ source }) => source.data.type === BLOCK_DRAG_TYPE,
1370
1506
  getAllowedAxis: () => "vertical",
1371
1507
  }));
1372
- this.refreshBlockDropTargets();
1373
1508
  }
1374
1509
  teardownBlockDrag() {
1375
1510
  this.blockMoveTargetPrefetch?.();
1376
1511
  this.blockMoveTargetPrefetch = null;
1377
1512
  this.blockMoveTargetCache.clear();
1378
- for (const cleanup of this.blockDragTargetCleanup.splice(0))
1379
- cleanup();
1513
+ this.dropZones = [];
1514
+ this.dropZoneScroller = null;
1380
1515
  for (const cleanup of this.blockDragCleanup.splice(0))
1381
1516
  cleanup();
1382
1517
  this.blockDragHandle?.remove();
@@ -1472,21 +1607,19 @@ export class DocxEditor {
1472
1607
  bodyRoot.after(this.region.footerBand);
1473
1608
  this.region.refreshAll();
1474
1609
  }
1475
- /** Continuous (non-paginated) mount: inject the converter's styles + body, wire blocks. */
1610
+ /**
1611
+ * Continuous (non-paginated) mount: inject the converter's styles + body, wire blocks.
1612
+ *
1613
+ * The body always gets its own `.docx-body-flow` wrapper — not only when bands are docked.
1614
+ * It is the sheet: the element the viewport gives page geometry to and zooms, and the one
1615
+ * the bands dock around. Without it the container would have to be both the scrolling host
1616
+ * and the scaled page, which are different boxes.
1617
+ */
1476
1618
  mountHtml(fullHtml) {
1477
1619
  const parsed = new DOMParser().parseFromString(fullHtml, "text/html");
1478
1620
  const styles = Array.from(parsed.querySelectorAll("style"))
1479
1621
  .map((s) => s.outerHTML)
1480
1622
  .join("");
1481
- if (!this.region) {
1482
- this.container.innerHTML = styles + parsed.body.innerHTML;
1483
- this.editRoot = this.container;
1484
- if (this.options.editable)
1485
- this.wireBlocks(this.container);
1486
- this.stampPlanState();
1487
- return;
1488
- }
1489
- // With bands docked, the body flow needs its own wrapper to be the edit root.
1490
1623
  this.container.innerHTML = styles;
1491
1624
  const flow = document.createElement("div");
1492
1625
  flow.className = "docx-body-flow";
@@ -1496,7 +1629,9 @@ export class DocxEditor {
1496
1629
  if (this.options.editable)
1497
1630
  this.wireBlocks(flow);
1498
1631
  this.stampPlanState();
1499
- this.dockBands(flow);
1632
+ if (this.region)
1633
+ this.dockBands(flow);
1634
+ this.viewport.attach(flow, true);
1500
1635
  }
1501
1636
  /** Paginated mount: flow blocks into page boxes via pagination.ts, wire the page clones. */
1502
1637
  mountPaginated(fullHtml) {
@@ -1532,6 +1667,9 @@ export class DocxEditor {
1532
1667
  // around the page stack, so there is still exactly one addressable node per story paragraph.
1533
1668
  if (this.region)
1534
1669
  this.dockBands(target);
1670
+ // Page boxes already carry the section's dimensions, so the viewport contributes only the
1671
+ // fit zoom — a full page is far wider than a phone, and clipping it is not an option.
1672
+ this.viewport.attach(pageRoot, false);
1535
1673
  }
1536
1674
  wireBlocks(root) {
1537
1675
  root.querySelectorAll("[data-anchor]").forEach((el) => this.wireBlock(el));