docxodus 9.4.0 → 9.6.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
  *
@@ -267,6 +291,16 @@ export declare class DocxEditor {
267
291
  * the bundle erases TypeScript's visibility.
268
292
  */
269
293
  get sessionHandle(): number;
294
+ /**
295
+ * Repaint from the live session after it was mutated OUTSIDE the editor's own
296
+ * commands — a host driving {@link sessionHandle} directly (an agent pipeline,
297
+ * `raw.replaceXml`, a batch import). Continuous mode patches incrementally from
298
+ * the render plan (a Unid-preserving single-block mutation repaints just that
299
+ * block); paginated mode — or anything the reconciler cannot prove — remounts.
300
+ * The editor cannot observe external mutations, so the host owns calling this
301
+ * once per mutation batch.
302
+ */
303
+ refresh(): void;
270
304
  /** Move one top-level body block relative to another and repaint from the live session. */
271
305
  moveBlock(sourceAnchorId: string, targetAnchorId: string, position: "before" | "after"): boolean;
272
306
  /** Resolve any rendered descendant to its top-level body move unit (tables stay whole). */
@@ -276,7 +310,16 @@ export declare class DocxEditor {
276
310
  private showBlockHandle;
277
311
  private hideBlockHandle;
278
312
  private positionBlockHandle;
279
- private showDropIndicator;
313
+ /** Draw the drop line on `zone`'s requested edge, or take it away when there is no target. */
314
+ private paintDropIndicator;
315
+ /**
316
+ * Where to draw the line for an insertion on `position` of `zone` — the MIDDLE of the gap to
317
+ * the neighbour on that side, not the zone's own border-box edge. A paragraph's `w:spacing`
318
+ * becomes a CSS margin, which sits outside the box, so drawing on the edge underlines the
319
+ * block's last line instead of reading as a gap between two blocks. Falls back to the raw edge
320
+ * at the ends of the flow, and degrades to the same value when blocks are contiguous.
321
+ */
322
+ private dropEdgeY;
280
323
  private hideDropIndicator;
281
324
  private announceBlockMove;
282
325
  /**
@@ -305,14 +348,24 @@ export declare class DocxEditor {
305
348
  * legal and the other not, so "this target is reachable" is not enough to pick a position.
306
349
  */
307
350
  private isValidMoveTarget;
351
+ /** Measure every movable block once, at drag start. See `BlockDropZone`. */
352
+ private captureDropZones;
353
+ private scrollOffsetSum;
354
+ /** How far the measured boxes have travelled since capture, from scrolling (drag autoscroll). */
355
+ private dropZoneShift;
308
356
  /**
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;
357
+ * Where a drop at `clientY` lands, or null when nothing there is legal.
358
+ *
359
+ * Resolution is by VERTICAL GEOMETRY over the measured blocks, not by which element the pointer
360
+ * is over: the drag handle floats in the page margin, so a drag straight down the gutter — the
361
+ * natural gesture — never crosses a paragraph box, and element hit testing gave those drags no
362
+ * indicator and no drop at all. The nearest block by vertical distance is the target; the half
363
+ * the pointer is in picks the side, snapped to the other side when only that one is legal
364
+ * (a section break or a cross-block range usually makes exactly one side illegal). When neither
365
+ * side is legal — the pointer is in a region this block cannot reach — there is no drop, and
366
+ * nothing is drawn.
367
+ */
368
+ private resolveDropAt;
316
369
  private closeBlockMoveMenu;
317
370
  private openBlockMoveMenu;
318
371
  /**
@@ -362,7 +415,14 @@ export declare class DocxEditor {
362
415
  * indices, and band blocks in that list would shift every index.
363
416
  */
364
417
  private dockBands;
365
- /** Continuous (non-paginated) mount: inject the converter's styles + body, wire blocks. */
418
+ /**
419
+ * Continuous (non-paginated) mount: inject the converter's styles + body, wire blocks.
420
+ *
421
+ * The body always gets its own `.docx-body-flow` wrapper — not only when bands are docked.
422
+ * It is the sheet: the element the viewport gives page geometry to and zooms, and the one
423
+ * the bands dock around. Without it the container would have to be both the scrolling host
424
+ * and the scaled page, which are different boxes.
425
+ */
366
426
  private mountHtml;
367
427
  /** Paginated mount: flow blocks into page boxes via pagination.ts, wire the page clones. */
368
428
  private mountPaginated;
@@ -1 +1 @@
1
- {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAU1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAIjE,4FAA4F;AAC5F,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE;QACjB,WAAW,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,KAAK,MAAM,CAAC;QACjE,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;QACvC,eAAe,EAAE,MAAM,UAAU,CAAC;QAClC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;QACpC,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;QACpE,iBAAiB,EAAE,CACjB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,OAAO,EAA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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
  *
@@ -875,6 +923,19 @@ export class DocxEditor {
875
923
  get sessionHandle() {
876
924
  return this.handle;
877
925
  }
926
+ /**
927
+ * Repaint from the live session after it was mutated OUTSIDE the editor's own
928
+ * commands — a host driving {@link sessionHandle} directly (an agent pipeline,
929
+ * `raw.replaceXml`, a batch import). Continuous mode patches incrementally from
930
+ * the render plan (a Unid-preserving single-block mutation repaints just that
931
+ * block); paginated mode — or anything the reconciler cannot prove — remounts.
932
+ * The editor cannot observe external mutations, so the host owns calling this
933
+ * once per mutation batch.
934
+ */
935
+ refresh() {
936
+ this.assertOpen();
937
+ this.reconcile();
938
+ }
878
939
  /** Move one top-level body block relative to another and repaint from the live session. */
879
940
  moveBlock(sourceAnchorId, targetAnchorId, position) {
880
941
  this.assertOpen();
@@ -985,11 +1046,8 @@ export class DocxEditor {
985
1046
  handle.style.display = "flex";
986
1047
  handle.style.left = `${Math.max(4, rect.left - 32)}px`;
987
1048
  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);
1049
+ const preview = blockPreviewText(unit);
989
1050
  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
1051
  }
994
1052
  hideBlockHandle() {
995
1053
  if (this.blockDragging || this.blockMoveMenu?.style.display === "block")
@@ -1002,15 +1060,42 @@ export class DocxEditor {
1002
1060
  if (source && this.blockDragHandle?.style.display !== "none")
1003
1061
  this.showBlockHandle(source);
1004
1062
  }
1005
- showDropIndicator(target, position) {
1063
+ /** Draw the drop line on `zone`'s requested edge, or take it away when there is no target. */
1064
+ paintDropIndicator(data) {
1006
1065
  const indicator = this.blockDropIndicator;
1066
+ const zone = data.zone;
1007
1067
  if (!indicator)
1008
1068
  return;
1009
- const rect = this.unitWrapperOf(target).getBoundingClientRect();
1069
+ if (!zone) {
1070
+ this.hideDropIndicator();
1071
+ return;
1072
+ }
1073
+ const y = Math.round(this.dropEdgeY(zone, data.position === "after" ? "after" : "before")
1074
+ + this.dropZoneShift()) - 1;
1075
+ // Position before revealing, so the entry fade never plays at a stale spot.
1076
+ indicator.style.transform = `translate3d(${Math.round(zone.left)}px, ${y}px, 0)`;
1077
+ indicator.style.width = `${Math.max(24, Math.round(zone.width))}px`;
1010
1078
  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`;
1079
+ }
1080
+ /**
1081
+ * Where to draw the line for an insertion on `position` of `zone` — the MIDDLE of the gap to
1082
+ * the neighbour on that side, not the zone's own border-box edge. A paragraph's `w:spacing`
1083
+ * becomes a CSS margin, which sits outside the box, so drawing on the edge underlines the
1084
+ * block's last line instead of reading as a gap between two blocks. Falls back to the raw edge
1085
+ * at the ends of the flow, and degrades to the same value when blocks are contiguous.
1086
+ */
1087
+ dropEdgeY(zone, position) {
1088
+ const neighbour = this.dropZones[zone.index + (position === "after" ? 1 : -1)];
1089
+ // At the ends of the flow there is nothing to bisect against, so half the block's own
1090
+ // margin stands in for half the gap — the same position, one contributor instead of two.
1091
+ if (!neighbour) {
1092
+ return position === "after"
1093
+ ? zone.bottom + zone.marginAfter / 2
1094
+ : zone.top - zone.marginBefore / 2;
1095
+ }
1096
+ return position === "after"
1097
+ ? (zone.bottom + neighbour.top) / 2
1098
+ : (neighbour.bottom + zone.top) / 2;
1014
1099
  }
1015
1100
  hideDropIndicator() {
1016
1101
  if (this.blockDropIndicator)
@@ -1100,49 +1185,74 @@ export class DocxEditor {
1100
1185
  return false;
1101
1186
  return position ? sides[position] : sides.before || sides.after;
1102
1187
  }
1188
+ /** Measure every movable block once, at drag start. See `BlockDropZone`. */
1189
+ captureDropZones() {
1190
+ const view = this.container.ownerDocument.defaultView;
1191
+ this.dropZoneScroller = this.scrollContainer();
1192
+ this.dropZoneOrigin = this.scrollOffsetSum();
1193
+ this.dropZones = [];
1194
+ const boxes = [];
1195
+ for (const unit of this.bodyUnitNodes()) {
1196
+ const anchorId = this.isMovableBlockUnit(unit) ? this.anchorIdOf(unit) : null;
1197
+ if (!anchorId)
1198
+ continue;
1199
+ const box = this.unitWrapperOf(unit);
1200
+ const rect = box.getBoundingClientRect();
1201
+ boxes.push(box);
1202
+ this.dropZones.push({
1203
+ unit, anchorId, index: this.dropZones.length,
1204
+ top: rect.top, bottom: rect.bottom, left: rect.left, width: rect.width,
1205
+ marginBefore: 0, marginAfter: 0,
1206
+ });
1207
+ }
1208
+ // Only the flow's two ends ever consult a margin, so only they are worth a style read.
1209
+ const ends = new Set([0, this.dropZones.length - 1].filter((i) => i >= 0 && i < boxes.length));
1210
+ for (const i of ends) {
1211
+ const style = view?.getComputedStyle(boxes[i]);
1212
+ this.dropZones[i].marginBefore = parseFloat(style?.marginTop ?? "0") || 0;
1213
+ this.dropZones[i].marginAfter = parseFloat(style?.marginBottom ?? "0") || 0;
1214
+ }
1215
+ }
1216
+ scrollOffsetSum() {
1217
+ const view = this.container.ownerDocument.defaultView;
1218
+ return (view?.scrollY ?? 0) + (this.dropZoneScroller?.scrollTop ?? 0);
1219
+ }
1220
+ /** How far the measured boxes have travelled since capture, from scrolling (drag autoscroll). */
1221
+ dropZoneShift() {
1222
+ return this.dropZoneOrigin - this.scrollOffsetSum();
1223
+ }
1103
1224
  /**
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.
1225
+ * Where a drop at `clientY` lands, or null when nothing there is legal.
1226
+ *
1227
+ * Resolution is by VERTICAL GEOMETRY over the measured blocks, not by which element the pointer
1228
+ * is over: the drag handle floats in the page margin, so a drag straight down the gutter — the
1229
+ * natural gesture — never crosses a paragraph box, and element hit testing gave those drags no
1230
+ * indicator and no drop at all. The nearest block by vertical distance is the target; the half
1231
+ * the pointer is in picks the side, snapped to the other side when only that one is legal
1232
+ * (a section break or a cross-block range usually makes exactly one side illegal). When neither
1233
+ * side is legal — the pointer is in a region this block cannot reach — there is no drop, and
1234
+ * nothing is drawn.
1108
1235
  */
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
- }));
1236
+ resolveDropAt(clientY) {
1237
+ const y = clientY - this.dropZoneShift();
1238
+ let best = null;
1239
+ let bestGap = Infinity;
1240
+ for (const zone of this.dropZones) {
1241
+ const gap = y < zone.top ? zone.top - y : y > zone.bottom ? y - zone.bottom : 0;
1242
+ if (gap < bestGap) {
1243
+ best = zone;
1244
+ bestGap = gap;
1245
+ }
1246
+ if (gap === 0)
1247
+ break; // inside this block; zones are in document order and never overlap
1145
1248
  }
1249
+ if (!best || best.unit === this.blockDragSource)
1250
+ return null;
1251
+ const preferred = y < (best.top + best.bottom) / 2 ? "before" : "after";
1252
+ if (this.isValidMoveTarget(best.unit, preferred))
1253
+ return { zone: best, position: preferred };
1254
+ const other = preferred === "before" ? "after" : "before";
1255
+ return this.isValidMoveTarget(best.unit, other) ? { zone: best, position: other } : null;
1146
1256
  }
1147
1257
  closeBlockMoveMenu(restoreFocus = false) {
1148
1258
  if (!this.blockMoveMenu || !this.blockDragHandle)
@@ -1324,20 +1434,59 @@ export class DocxEditor {
1324
1434
  const source = this.currentBlockDragSource();
1325
1435
  return { type: BLOCK_DRAG_TYPE, sourceAnchorId: source ? this.anchorIdOf(source) : undefined };
1326
1436
  },
1437
+ // The browser would otherwise ghost the 26px grip, which says nothing about what is moving.
1438
+ onGenerateDragPreview: ({ nativeSetDragImage }) => {
1439
+ const source = this.currentBlockDragSource();
1440
+ setCustomNativeDragPreview({
1441
+ nativeSetDragImage,
1442
+ getOffset: pointerOutsideOfPreview({ x: "14px", y: "10px" }),
1443
+ render: ({ container }) => {
1444
+ const chip = doc.createElement("div");
1445
+ chip.className = "docx-block-drag-preview";
1446
+ chip.textContent = (source && blockPreviewText(source)) || "Move block";
1447
+ container.appendChild(chip);
1448
+ return () => chip.remove();
1449
+ },
1450
+ });
1451
+ },
1327
1452
  onDragStart: () => {
1453
+ const source = this.currentBlockDragSource();
1328
1454
  this.blockDragging = true;
1329
1455
  handle.classList.add("docx-block-dragging");
1456
+ // After the preview snapshot, so the chip is not dimmed too.
1457
+ source?.classList.add("docx-block-drag-source");
1330
1458
  this.closeBlockMoveMenu();
1331
- this.refreshBlockMoveTargets(this.currentBlockDragSource());
1332
- this.refreshBlockDropTargets();
1459
+ this.refreshBlockMoveTargets(source);
1460
+ this.captureDropZones();
1333
1461
  },
1334
1462
  onDrop: () => {
1335
1463
  this.blockDragging = false;
1336
1464
  this.blockDragPointerDown = false;
1465
+ this.dropZones = [];
1337
1466
  handle.classList.remove("docx-block-dragging");
1467
+ // Cleared by selector rather than from a captured reference: a completed move may have
1468
+ // re-rendered the block, and the node that carries the class outlives either handle on it.
1469
+ doc.querySelectorAll(".docx-block-drag-source")
1470
+ .forEach((el) => el.classList.remove("docx-block-drag-source"));
1338
1471
  this.hideDropIndicator();
1339
1472
  },
1340
1473
  }));
1474
+ // ONE drop target for the whole flow. Which block a drop belongs to is decided by
1475
+ // `resolveDropAt` from the pointer's vertical position, so the gutter the handle is dragged
1476
+ // down counts as being over the document — see that method.
1477
+ this.blockDragCleanup.push(dropTargetForElements({
1478
+ element: this.editRoot,
1479
+ canDrop: ({ source }) => source.data.type === BLOCK_DRAG_TYPE,
1480
+ getData: ({ input }) => {
1481
+ const hit = this.resolveDropAt(input.clientY);
1482
+ return hit
1483
+ ? { type: BLOCK_DRAG_TYPE, targetAnchorId: hit.zone.anchorId, position: hit.position, zone: hit.zone }
1484
+ : { type: BLOCK_DRAG_TYPE };
1485
+ },
1486
+ onDragEnter: ({ self }) => this.paintDropIndicator(self.data),
1487
+ onDrag: ({ self }) => this.paintDropIndicator(self.data),
1488
+ onDragLeave: () => this.hideDropIndicator(),
1489
+ }));
1341
1490
  this.blockDragCleanup.push(monitorForElements({
1342
1491
  canMonitor: ({ source }) => source.data.type === BLOCK_DRAG_TYPE,
1343
1492
  onDrop: ({ source, location }) => {
@@ -1369,14 +1518,13 @@ export class DocxEditor {
1369
1518
  canScroll: ({ source }) => source.data.type === BLOCK_DRAG_TYPE,
1370
1519
  getAllowedAxis: () => "vertical",
1371
1520
  }));
1372
- this.refreshBlockDropTargets();
1373
1521
  }
1374
1522
  teardownBlockDrag() {
1375
1523
  this.blockMoveTargetPrefetch?.();
1376
1524
  this.blockMoveTargetPrefetch = null;
1377
1525
  this.blockMoveTargetCache.clear();
1378
- for (const cleanup of this.blockDragTargetCleanup.splice(0))
1379
- cleanup();
1526
+ this.dropZones = [];
1527
+ this.dropZoneScroller = null;
1380
1528
  for (const cleanup of this.blockDragCleanup.splice(0))
1381
1529
  cleanup();
1382
1530
  this.blockDragHandle?.remove();
@@ -1472,21 +1620,19 @@ export class DocxEditor {
1472
1620
  bodyRoot.after(this.region.footerBand);
1473
1621
  this.region.refreshAll();
1474
1622
  }
1475
- /** Continuous (non-paginated) mount: inject the converter's styles + body, wire blocks. */
1623
+ /**
1624
+ * Continuous (non-paginated) mount: inject the converter's styles + body, wire blocks.
1625
+ *
1626
+ * The body always gets its own `.docx-body-flow` wrapper — not only when bands are docked.
1627
+ * It is the sheet: the element the viewport gives page geometry to and zooms, and the one
1628
+ * the bands dock around. Without it the container would have to be both the scrolling host
1629
+ * and the scaled page, which are different boxes.
1630
+ */
1476
1631
  mountHtml(fullHtml) {
1477
1632
  const parsed = new DOMParser().parseFromString(fullHtml, "text/html");
1478
1633
  const styles = Array.from(parsed.querySelectorAll("style"))
1479
1634
  .map((s) => s.outerHTML)
1480
1635
  .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
1636
  this.container.innerHTML = styles;
1491
1637
  const flow = document.createElement("div");
1492
1638
  flow.className = "docx-body-flow";
@@ -1496,7 +1642,9 @@ export class DocxEditor {
1496
1642
  if (this.options.editable)
1497
1643
  this.wireBlocks(flow);
1498
1644
  this.stampPlanState();
1499
- this.dockBands(flow);
1645
+ if (this.region)
1646
+ this.dockBands(flow);
1647
+ this.viewport.attach(flow, true);
1500
1648
  }
1501
1649
  /** Paginated mount: flow blocks into page boxes via pagination.ts, wire the page clones. */
1502
1650
  mountPaginated(fullHtml) {
@@ -1532,6 +1680,9 @@ export class DocxEditor {
1532
1680
  // around the page stack, so there is still exactly one addressable node per story paragraph.
1533
1681
  if (this.region)
1534
1682
  this.dockBands(target);
1683
+ // Page boxes already carry the section's dimensions, so the viewport contributes only the
1684
+ // fit zoom — a full page is far wider than a phone, and clipping it is not an option.
1685
+ this.viewport.attach(pageRoot, false);
1535
1686
  }
1536
1687
  wireBlocks(root) {
1537
1688
  root.querySelectorAll("[data-anchor]").forEach((el) => this.wireBlock(el));