docxodus 9.2.0 → 9.4.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-reconcile.d.ts +5 -0
- package/dist/editor-reconcile.d.ts.map +1 -1
- package/dist/editor-reconcile.js +23 -2
- package/dist/editor-reconcile.js.map +1 -1
- package/dist/editor.bundle.js +3338 -162
- package/dist/editor.d.ts +120 -0
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +775 -57
- package/dist/editor.js.map +1 -1
- package/dist/embed.bundle.js +3401 -178
- package/dist/embed.d.ts.map +1 -1
- package/dist/embed.iife.js +3388 -178
- package/dist/embed.js +8 -0
- package/dist/embed.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/ribbon.js +4 -0
- package/dist/ribbon.js.map +1 -1
- package/dist/session.bundle.js +31 -1
- package/dist/session.d.ts +22 -2
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +27 -1
- package/dist/session.js.map +1 -1
- package/dist/types.d.ts +18 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/wasm/_framework/Docxodus.wasm +0 -0
- package/dist/wasm/_framework/Docxodus.wasm.br +0 -0
- package/dist/wasm/_framework/DocxodusWasm.wasm +0 -0
- package/dist/wasm/_framework/DocxodusWasm.wasm.br +0 -0
- package/dist/wasm/_framework/System.Private.CoreLib.wasm +0 -0
- package/dist/wasm/_framework/System.Private.CoreLib.wasm.br +0 -0
- package/dist/wasm/_framework/dotnet.boot.js +5 -5
- package/dist/wasm/_framework/dotnet.boot.js.br +0 -0
- package/dist/wasm/_framework/dotnet.native.wasm +0 -0
- package/dist/wasm/_framework/dotnet.native.wasm.br +0 -0
- package/package.json +5 -1
package/dist/embed.bundle.js
CHANGED
|
@@ -1,3 +1,118 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
try {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
} catch (e) {
|
|
11
|
+
throw mod = 0, e;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
30
|
+
|
|
31
|
+
// node_modules/bind-event-listener/dist/bind.js
|
|
32
|
+
var require_bind = __commonJS({
|
|
33
|
+
"node_modules/bind-event-listener/dist/bind.js"(exports) {
|
|
34
|
+
"use strict";
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.bind = void 0;
|
|
37
|
+
function bind3(target, _a) {
|
|
38
|
+
var type = _a.type, listener = _a.listener, options = _a.options;
|
|
39
|
+
target.addEventListener(type, listener, options);
|
|
40
|
+
return function unbind() {
|
|
41
|
+
target.removeEventListener(type, listener, options);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
exports.bind = bind3;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// node_modules/bind-event-listener/dist/bind-all.js
|
|
49
|
+
var require_bind_all = __commonJS({
|
|
50
|
+
"node_modules/bind-event-listener/dist/bind-all.js"(exports) {
|
|
51
|
+
"use strict";
|
|
52
|
+
var __assign = exports && exports.__assign || function() {
|
|
53
|
+
__assign = Object.assign || function(t) {
|
|
54
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
55
|
+
s = arguments[i];
|
|
56
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
57
|
+
t[p] = s[p];
|
|
58
|
+
}
|
|
59
|
+
return t;
|
|
60
|
+
};
|
|
61
|
+
return __assign.apply(this, arguments);
|
|
62
|
+
};
|
|
63
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
|
+
exports.bindAll = void 0;
|
|
65
|
+
var bind_1 = require_bind();
|
|
66
|
+
function toOptions(value) {
|
|
67
|
+
if (typeof value === "undefined") {
|
|
68
|
+
return void 0;
|
|
69
|
+
}
|
|
70
|
+
if (typeof value === "boolean") {
|
|
71
|
+
return {
|
|
72
|
+
capture: value
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
function getBinding(original, sharedOptions) {
|
|
78
|
+
if (sharedOptions == null) {
|
|
79
|
+
return original;
|
|
80
|
+
}
|
|
81
|
+
var binding = __assign(__assign({}, original), { options: __assign(__assign({}, toOptions(sharedOptions)), toOptions(original.options)) });
|
|
82
|
+
return binding;
|
|
83
|
+
}
|
|
84
|
+
function bindAll4(target, bindings, sharedOptions) {
|
|
85
|
+
var unbinds = bindings.map(function(original) {
|
|
86
|
+
var binding = getBinding(original, sharedOptions);
|
|
87
|
+
return (0, bind_1.bind)(target, binding);
|
|
88
|
+
});
|
|
89
|
+
return function unbindAll() {
|
|
90
|
+
unbinds.forEach(function(unbind) {
|
|
91
|
+
return unbind();
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
exports.bindAll = bindAll4;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// node_modules/bind-event-listener/dist/index.js
|
|
100
|
+
var require_dist = __commonJS({
|
|
101
|
+
"node_modules/bind-event-listener/dist/index.js"(exports) {
|
|
102
|
+
"use strict";
|
|
103
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
104
|
+
exports.bindAll = exports.bind = void 0;
|
|
105
|
+
var bind_1 = require_bind();
|
|
106
|
+
Object.defineProperty(exports, "bind", { enumerable: true, get: function() {
|
|
107
|
+
return bind_1.bind;
|
|
108
|
+
} });
|
|
109
|
+
var bind_all_1 = require_bind_all();
|
|
110
|
+
Object.defineProperty(exports, "bindAll", { enumerable: true, get: function() {
|
|
111
|
+
return bind_all_1.bindAll;
|
|
112
|
+
} });
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
1
116
|
// src/types.ts
|
|
2
117
|
var ProjectionScopes = /* @__PURE__ */ ((ProjectionScopes2) => {
|
|
3
118
|
ProjectionScopes2[ProjectionScopes2["Body"] = 1] = "Body";
|
|
@@ -310,6 +425,12 @@ var DocxSession = class {
|
|
|
310
425
|
deleteBlock(anchorId) {
|
|
311
426
|
return JSON.parse(this.wasm.DeleteBlock(this.handle, anchorId));
|
|
312
427
|
}
|
|
428
|
+
/** Reorder one top-level paragraph/heading/list/table block relative to another. */
|
|
429
|
+
moveBlock(sourceAnchorId, targetAnchorId, position) {
|
|
430
|
+
return JSON.parse(
|
|
431
|
+
this.wasm.MoveBlock(this.handle, sourceAnchorId, targetAnchorId, position)
|
|
432
|
+
);
|
|
433
|
+
}
|
|
313
434
|
/**
|
|
314
435
|
* Delete every top-level block-level sibling between `fromAnchorId` (inclusive)
|
|
315
436
|
* and `toAnchorIdExclusive` (exclusive). Both anchors must share a direct
|
|
@@ -370,7 +491,9 @@ var DocxSession = class {
|
|
|
370
491
|
* Table row/column editing, addressed by a cell-paragraph anchor (e.g. one returned from
|
|
371
492
|
* {@link insertTable}'s `created`). Insert clones the reference row/column's widths and starts
|
|
372
493
|
* empty (`created` lists the new cell-paragraph anchors); delete of the last row/column removes
|
|
373
|
-
* the whole table.
|
|
494
|
+
* the whole table. All four are grid-aware: inserting across a merge extends it, deleting
|
|
495
|
+
* through one narrows it, and deleting a vertical merge's lead row promotes the next row to
|
|
496
|
+
* carry it — the grid is never left ragged.
|
|
374
497
|
*/
|
|
375
498
|
insertTableRow(cellAnchorId, position) {
|
|
376
499
|
return JSON.parse(this.wasm.InsertTableRow(this.handle, cellAnchorId, position));
|
|
@@ -384,6 +507,28 @@ var DocxSession = class {
|
|
|
384
507
|
deleteTableColumn(cellAnchorId) {
|
|
385
508
|
return JSON.parse(this.wasm.DeleteTableColumn(this.handle, cellAnchorId));
|
|
386
509
|
}
|
|
510
|
+
/**
|
|
511
|
+
* Merge the rectangle of cells anchored at `cellAnchorId` running `rowSpan` rows down ×
|
|
512
|
+
* `colSpan` cells right (Word's *Merge Cells*): `w:gridSpan` for the horizontal extent,
|
|
513
|
+
* `w:vMerge` restart/continue for the vertical one. The rectangle must tile the same whole grid
|
|
514
|
+
* columns in every row it covers and must not clip a vertical merge entering from above or
|
|
515
|
+
* continuing below — a partial overlap fails with `invalid_table_merge` instead of tearing the
|
|
516
|
+
* grid. `content` decides what happens to the absorbed cells' content (default `"append"`).
|
|
517
|
+
*/
|
|
518
|
+
mergeCells(cellAnchorId, rowSpan, colSpan, content = "append") {
|
|
519
|
+
return JSON.parse(
|
|
520
|
+
this.wasm.MergeCells(this.handle, cellAnchorId, rowSpan, colSpan, content)
|
|
521
|
+
);
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Split the merged cell at `cellAnchorId` back into unit cells, dropping its `w:gridSpan` and
|
|
525
|
+
* `w:vMerge` markup and restoring one cell per grid column (each taking its `w:tblGrid` width).
|
|
526
|
+
* Addressing a vertical-merge continuation unmerges the whole run. A cell with no merge markup
|
|
527
|
+
* fails with `invalid_table_merge`.
|
|
528
|
+
*/
|
|
529
|
+
unmergeCells(cellAnchorId) {
|
|
530
|
+
return JSON.parse(this.wasm.UnmergeCells(this.handle, cellAnchorId));
|
|
531
|
+
}
|
|
387
532
|
/**
|
|
388
533
|
* Table styling, addressed by a cell-paragraph anchor — the post-insert counterpart of
|
|
389
534
|
* {@link insertTable}'s options (issue #315 Stage A). `setColumnWidths` retunes `w:tblGrid` +
|
|
@@ -1286,9 +1431,9 @@ var PaginationEngine = class {
|
|
|
1286
1431
|
for (const section of Array.from(sections)) {
|
|
1287
1432
|
const index = parseInt(section.dataset.sectionIndex || "0", 10);
|
|
1288
1433
|
const rawStart = section.dataset.pageNumStart;
|
|
1289
|
-
const
|
|
1434
|
+
const start2 = rawStart === void 0 ? void 0 : parseInt(rawStart, 10);
|
|
1290
1435
|
map.set(index, {
|
|
1291
|
-
start:
|
|
1436
|
+
start: start2 !== void 0 && Number.isFinite(start2) ? start2 : void 0,
|
|
1292
1437
|
format: section.dataset.pageNumFmt
|
|
1293
1438
|
});
|
|
1294
1439
|
}
|
|
@@ -1513,16 +1658,16 @@ var PaginationEngine = class {
|
|
|
1513
1658
|
return null;
|
|
1514
1659
|
}
|
|
1515
1660
|
const groups = [];
|
|
1516
|
-
let
|
|
1517
|
-
while (
|
|
1518
|
-
let end =
|
|
1661
|
+
let start2 = 0;
|
|
1662
|
+
while (start2 < rows.length) {
|
|
1663
|
+
let end = start2;
|
|
1519
1664
|
while (end < rows.length) {
|
|
1520
1665
|
const candidate = this.createSimpleTableFragment(
|
|
1521
1666
|
wrapper,
|
|
1522
1667
|
table,
|
|
1523
1668
|
body,
|
|
1524
|
-
rows.slice(
|
|
1525
|
-
|
|
1669
|
+
rows.slice(start2, end + 1),
|
|
1670
|
+
start2 === 0
|
|
1526
1671
|
);
|
|
1527
1672
|
const measured = this.measureElement(candidate, dims);
|
|
1528
1673
|
if (measured.heightPt > maximumFragmentHeight) {
|
|
@@ -1530,11 +1675,11 @@ var PaginationEngine = class {
|
|
|
1530
1675
|
}
|
|
1531
1676
|
end++;
|
|
1532
1677
|
}
|
|
1533
|
-
if (end ===
|
|
1678
|
+
if (end === start2) {
|
|
1534
1679
|
return null;
|
|
1535
1680
|
}
|
|
1536
|
-
groups.push(rows.slice(
|
|
1537
|
-
|
|
1681
|
+
groups.push(rows.slice(start2, end));
|
|
1682
|
+
start2 = end;
|
|
1538
1683
|
}
|
|
1539
1684
|
if (groups.length < 2) {
|
|
1540
1685
|
return null;
|
|
@@ -2849,9 +2994,9 @@ var HeaderFooterRegion = class {
|
|
|
2849
2994
|
const commitStart = () => {
|
|
2850
2995
|
const raw = pageStart.value.trim();
|
|
2851
2996
|
if (raw === "") return;
|
|
2852
|
-
const
|
|
2853
|
-
if (!Number.isInteger(
|
|
2854
|
-
this.setPageNumbering({ start });
|
|
2997
|
+
const start2 = Number(raw);
|
|
2998
|
+
if (!Number.isInteger(start2) || start2 < 0) return;
|
|
2999
|
+
this.setPageNumbering({ start: start2 });
|
|
2855
3000
|
};
|
|
2856
3001
|
pageStart.addEventListener("blur", commitStart);
|
|
2857
3002
|
pageStart.addEventListener("keydown", (e) => {
|
|
@@ -2902,8 +3047,8 @@ var HeaderFooterRegion = class {
|
|
|
2902
3047
|
if (pageFmt) pageFmt.value = this.sectionInfo?.pageNumberFormat ?? "";
|
|
2903
3048
|
const pageStart = band.querySelector("[data-hf-pagestart]");
|
|
2904
3049
|
if (pageStart && document.activeElement !== pageStart) {
|
|
2905
|
-
const
|
|
2906
|
-
pageStart.value =
|
|
3050
|
+
const start2 = this.sectionInfo?.pageNumberStart;
|
|
3051
|
+
pageStart.value = start2 === void 0 ? "" : String(start2);
|
|
2907
3052
|
}
|
|
2908
3053
|
const inherited = this.refFor(which, kind)?.inherited === true;
|
|
2909
3054
|
band.toggleAttribute("data-hf-inherited", inherited);
|
|
@@ -2951,65 +3096,2466 @@ var HeaderFooterRegion = class {
|
|
|
2951
3096
|
el.setAttribute("data-hf-focused", "true");
|
|
2952
3097
|
});
|
|
2953
3098
|
}
|
|
2954
|
-
renderStoryBlock(anchorId) {
|
|
2955
|
-
const html = this.bridge.RenderBlockHtml(
|
|
2956
|
-
this.handle,
|
|
2957
|
-
anchorId,
|
|
2958
|
-
this.options.cssPrefix,
|
|
2959
|
-
this.options.fabricateClasses
|
|
2960
|
-
);
|
|
2961
|
-
if (html.charCodeAt(0) === 123) return null;
|
|
2962
|
-
return new DOMParser().parseFromString(html, "text/html").body.firstElementChild;
|
|
3099
|
+
renderStoryBlock(anchorId) {
|
|
3100
|
+
const html = this.bridge.RenderBlockHtml(
|
|
3101
|
+
this.handle,
|
|
3102
|
+
anchorId,
|
|
3103
|
+
this.options.cssPrefix,
|
|
3104
|
+
this.options.fabricateClasses
|
|
3105
|
+
);
|
|
3106
|
+
if (html.charCodeAt(0) === 123) return null;
|
|
3107
|
+
return new DOMParser().parseFromString(html, "text/html").body.firstElementChild;
|
|
3108
|
+
}
|
|
3109
|
+
placeholder(which, kind) {
|
|
3110
|
+
const el = document.createElement("div");
|
|
3111
|
+
el.className = "docx-hf-placeholder";
|
|
3112
|
+
el.setAttribute("data-hf-placeholder", "");
|
|
3113
|
+
const label = KIND_LABELS.find((k) => k.value === kind)?.label ?? kind;
|
|
3114
|
+
el.textContent = `No ${label.toLowerCase()} ${which} \u2014 pick a kind to create one.`;
|
|
3115
|
+
return el;
|
|
3116
|
+
}
|
|
3117
|
+
/**
|
|
3118
|
+
* Surface the caveat that comes with the selected kind. Turning on first/even means those pages
|
|
3119
|
+
* stop using the Default stories entirely, which bites hardest on the OTHER band: enabling an
|
|
3120
|
+
* even header with no even footer leaves even pages footer-less, and enabling a first-page
|
|
3121
|
+
* header with an empty first-page footer leaves page 1 footer-less. The note is shown whenever
|
|
3122
|
+
* first/even is selected (the behavior change is real either way); the fix button appears only
|
|
3123
|
+
* when the counterpart story is missing entirely, which is what a user almost always wants next.
|
|
3124
|
+
*/
|
|
3125
|
+
renderKindWarning(which) {
|
|
3126
|
+
const band = this.bandFor(which);
|
|
3127
|
+
const warning = band.querySelector("[data-hf-warning]");
|
|
3128
|
+
if (!warning) return;
|
|
3129
|
+
const kind = this.kinds[which];
|
|
3130
|
+
if (kind === "default") {
|
|
3131
|
+
warning.hidden = true;
|
|
3132
|
+
warning.textContent = "";
|
|
3133
|
+
return;
|
|
3134
|
+
}
|
|
3135
|
+
const other = which === "header" ? "footer" : "header";
|
|
3136
|
+
warning.hidden = false;
|
|
3137
|
+
warning.textContent = `${kind === "even" ? EVEN_WARNING : FIRST_WARNING} `;
|
|
3138
|
+
if (this.partUriFor(other, kind)) return;
|
|
3139
|
+
const fix = document.createElement("button");
|
|
3140
|
+
fix.type = "button";
|
|
3141
|
+
fix.setAttribute("data-hf-fix-counterpart", "");
|
|
3142
|
+
fix.textContent = `Also create a ${kind === "even" ? "matching even" : "first-page"} ${other}`;
|
|
3143
|
+
fix.addEventListener("click", () => {
|
|
3144
|
+
this.setKind(other, kind);
|
|
3145
|
+
this.renderKindWarning(which);
|
|
3146
|
+
});
|
|
3147
|
+
warning.appendChild(fix);
|
|
3148
|
+
}
|
|
3149
|
+
};
|
|
3150
|
+
function parseResult(json) {
|
|
3151
|
+
try {
|
|
3152
|
+
return JSON.parse(json);
|
|
3153
|
+
} catch {
|
|
3154
|
+
return { success: false };
|
|
3155
|
+
}
|
|
3156
|
+
}
|
|
3157
|
+
|
|
3158
|
+
// node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
|
|
3159
|
+
function _arrayWithHoles(r) {
|
|
3160
|
+
if (Array.isArray(r)) return r;
|
|
3161
|
+
}
|
|
3162
|
+
|
|
3163
|
+
// node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
|
|
3164
|
+
function _iterableToArrayLimit(r, l) {
|
|
3165
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
3166
|
+
if (null != t) {
|
|
3167
|
+
var e, n, i, u, a = [], f = true, o = false;
|
|
3168
|
+
try {
|
|
3169
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
3170
|
+
if (Object(t) !== t) return;
|
|
3171
|
+
f = false;
|
|
3172
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ;
|
|
3173
|
+
} catch (r2) {
|
|
3174
|
+
o = true, n = r2;
|
|
3175
|
+
} finally {
|
|
3176
|
+
try {
|
|
3177
|
+
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
|
|
3178
|
+
} finally {
|
|
3179
|
+
if (o) throw n;
|
|
3180
|
+
}
|
|
3181
|
+
}
|
|
3182
|
+
return a;
|
|
3183
|
+
}
|
|
3184
|
+
}
|
|
3185
|
+
|
|
3186
|
+
// node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
|
|
3187
|
+
function _arrayLikeToArray(r, a) {
|
|
3188
|
+
(null == a || a > r.length) && (a = r.length);
|
|
3189
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
3190
|
+
return n;
|
|
3191
|
+
}
|
|
3192
|
+
|
|
3193
|
+
// node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
|
|
3194
|
+
function _unsupportedIterableToArray(r, a) {
|
|
3195
|
+
if (r) {
|
|
3196
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
3197
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
3198
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
3199
|
+
}
|
|
3200
|
+
}
|
|
3201
|
+
|
|
3202
|
+
// node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
|
|
3203
|
+
function _nonIterableRest() {
|
|
3204
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
3205
|
+
}
|
|
3206
|
+
|
|
3207
|
+
// node_modules/@babel/runtime/helpers/esm/slicedToArray.js
|
|
3208
|
+
function _slicedToArray(r, e) {
|
|
3209
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
3210
|
+
}
|
|
3211
|
+
|
|
3212
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/adapter/element-adapter.js
|
|
3213
|
+
var import_bind_event_listener4 = __toESM(require_dist());
|
|
3214
|
+
|
|
3215
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/honey-pot-fix/honey-pot-data-attribute.js
|
|
3216
|
+
var honeyPotDataAttribute = "data-pdnd-honey-pot";
|
|
3217
|
+
|
|
3218
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/honey-pot-fix/is-honey-pot-element.js
|
|
3219
|
+
function isHoneyPotElement(target) {
|
|
3220
|
+
return target instanceof Element && target.hasAttribute(honeyPotDataAttribute);
|
|
3221
|
+
}
|
|
3222
|
+
|
|
3223
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/honey-pot-fix/get-element-from-point-without-honey-pot.js
|
|
3224
|
+
function getElementFromPointWithoutHoneypot(client) {
|
|
3225
|
+
var _document$elementsFro = document.elementsFromPoint(client.x, client.y), _document$elementsFro2 = _slicedToArray(_document$elementsFro, 2), top2 = _document$elementsFro2[0], second = _document$elementsFro2[1];
|
|
3226
|
+
if (!top2) {
|
|
3227
|
+
return null;
|
|
3228
|
+
}
|
|
3229
|
+
if (isHoneyPotElement(top2)) {
|
|
3230
|
+
return second !== null && second !== void 0 ? second : null;
|
|
3231
|
+
}
|
|
3232
|
+
return top2;
|
|
3233
|
+
}
|
|
3234
|
+
|
|
3235
|
+
// node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
3236
|
+
function _typeof(o) {
|
|
3237
|
+
"@babel/helpers - typeof";
|
|
3238
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
3239
|
+
return typeof o2;
|
|
3240
|
+
} : function(o2) {
|
|
3241
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
3242
|
+
}, _typeof(o);
|
|
3243
|
+
}
|
|
3244
|
+
|
|
3245
|
+
// node_modules/@babel/runtime/helpers/esm/toPrimitive.js
|
|
3246
|
+
function toPrimitive(t, r) {
|
|
3247
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
3248
|
+
var e = t[Symbol.toPrimitive];
|
|
3249
|
+
if (void 0 !== e) {
|
|
3250
|
+
var i = e.call(t, r || "default");
|
|
3251
|
+
if ("object" != _typeof(i)) return i;
|
|
3252
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
3253
|
+
}
|
|
3254
|
+
return ("string" === r ? String : Number)(t);
|
|
3255
|
+
}
|
|
3256
|
+
|
|
3257
|
+
// node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
|
|
3258
|
+
function toPropertyKey(t) {
|
|
3259
|
+
var i = toPrimitive(t, "string");
|
|
3260
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
3261
|
+
}
|
|
3262
|
+
|
|
3263
|
+
// node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
3264
|
+
function _defineProperty(e, r, t) {
|
|
3265
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
3266
|
+
value: t,
|
|
3267
|
+
enumerable: true,
|
|
3268
|
+
configurable: true,
|
|
3269
|
+
writable: true
|
|
3270
|
+
}) : e[r] = t, e;
|
|
3271
|
+
}
|
|
3272
|
+
|
|
3273
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/honey-pot-fix/make-honey-pot-fix.js
|
|
3274
|
+
var import_bind_event_listener = __toESM(require_dist());
|
|
3275
|
+
|
|
3276
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/max-z-index.js
|
|
3277
|
+
var maxZIndex = 2147483647;
|
|
3278
|
+
|
|
3279
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/popover-reset-styles.js
|
|
3280
|
+
var popoverResetUserAgentStyles = {
|
|
3281
|
+
inset: "unset",
|
|
3282
|
+
border: "none",
|
|
3283
|
+
padding: 0,
|
|
3284
|
+
margin: 0,
|
|
3285
|
+
overflow: "visible",
|
|
3286
|
+
color: "inherit",
|
|
3287
|
+
background: "transparent",
|
|
3288
|
+
width: "auto",
|
|
3289
|
+
height: "auto"
|
|
3290
|
+
};
|
|
3291
|
+
|
|
3292
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/public-utils/once.js
|
|
3293
|
+
function once(fn) {
|
|
3294
|
+
var cache = null;
|
|
3295
|
+
return function wrapped() {
|
|
3296
|
+
if (!cache) {
|
|
3297
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3298
|
+
args[_key] = arguments[_key];
|
|
3299
|
+
}
|
|
3300
|
+
var result = fn.apply(this, args);
|
|
3301
|
+
cache = {
|
|
3302
|
+
result
|
|
3303
|
+
};
|
|
3304
|
+
}
|
|
3305
|
+
return cache.result;
|
|
3306
|
+
};
|
|
3307
|
+
}
|
|
3308
|
+
|
|
3309
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/supports-popover.js
|
|
3310
|
+
var supportsPopover = once(function supportsPopover2() {
|
|
3311
|
+
return typeof HTMLElement !== "undefined" && typeof HTMLElement.prototype.showPopover === "function";
|
|
3312
|
+
});
|
|
3313
|
+
|
|
3314
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/honey-pot-fix/make-honey-pot-fix.js
|
|
3315
|
+
function ownKeys(e, r) {
|
|
3316
|
+
var t = Object.keys(e);
|
|
3317
|
+
if (Object.getOwnPropertySymbols) {
|
|
3318
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
3319
|
+
r && (o = o.filter(function(r2) {
|
|
3320
|
+
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
3321
|
+
})), t.push.apply(t, o);
|
|
3322
|
+
}
|
|
3323
|
+
return t;
|
|
3324
|
+
}
|
|
3325
|
+
function _objectSpread(e) {
|
|
3326
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
3327
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
3328
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
|
|
3329
|
+
_defineProperty(e, r2, t[r2]);
|
|
3330
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
|
|
3331
|
+
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
3332
|
+
});
|
|
3333
|
+
}
|
|
3334
|
+
return e;
|
|
3335
|
+
}
|
|
3336
|
+
var honeyPotSize = 2;
|
|
3337
|
+
var halfHoneyPotSize = honeyPotSize / 2;
|
|
3338
|
+
function floorToClosestPixel(point) {
|
|
3339
|
+
return {
|
|
3340
|
+
x: Math.floor(point.x),
|
|
3341
|
+
y: Math.floor(point.y)
|
|
3342
|
+
};
|
|
3343
|
+
}
|
|
3344
|
+
function pullBackByHalfHoneyPotSize(point) {
|
|
3345
|
+
return {
|
|
3346
|
+
x: point.x - halfHoneyPotSize,
|
|
3347
|
+
y: point.y - halfHoneyPotSize
|
|
3348
|
+
};
|
|
3349
|
+
}
|
|
3350
|
+
function preventGoingBackwardsOffScreen(point) {
|
|
3351
|
+
return {
|
|
3352
|
+
x: Math.max(point.x, 0),
|
|
3353
|
+
y: Math.max(point.y, 0)
|
|
3354
|
+
};
|
|
3355
|
+
}
|
|
3356
|
+
function preventGoingForwardsOffScreen(point) {
|
|
3357
|
+
return {
|
|
3358
|
+
x: Math.min(point.x, window.innerWidth - honeyPotSize),
|
|
3359
|
+
y: Math.min(point.y, window.innerHeight - honeyPotSize)
|
|
3360
|
+
};
|
|
3361
|
+
}
|
|
3362
|
+
function getHoneyPotRectFor(_ref) {
|
|
3363
|
+
var client = _ref.client;
|
|
3364
|
+
var point = preventGoingForwardsOffScreen(preventGoingBackwardsOffScreen(pullBackByHalfHoneyPotSize(floorToClosestPixel(client))));
|
|
3365
|
+
return DOMRect.fromRect({
|
|
3366
|
+
x: point.x,
|
|
3367
|
+
y: point.y,
|
|
3368
|
+
width: honeyPotSize,
|
|
3369
|
+
height: honeyPotSize
|
|
3370
|
+
});
|
|
3371
|
+
}
|
|
3372
|
+
function getRectStyles(_ref2) {
|
|
3373
|
+
var clientRect = _ref2.clientRect;
|
|
3374
|
+
return {
|
|
3375
|
+
left: "".concat(clientRect.left, "px"),
|
|
3376
|
+
top: "".concat(clientRect.top, "px"),
|
|
3377
|
+
width: "".concat(clientRect.width, "px"),
|
|
3378
|
+
height: "".concat(clientRect.height, "px")
|
|
3379
|
+
};
|
|
3380
|
+
}
|
|
3381
|
+
function isWithin(_ref3) {
|
|
3382
|
+
var client = _ref3.client, clientRect = _ref3.clientRect;
|
|
3383
|
+
return (
|
|
3384
|
+
// is within horizontal bounds
|
|
3385
|
+
client.x >= clientRect.x && client.x <= clientRect.x + clientRect.width && // is within vertical bounds
|
|
3386
|
+
client.y >= clientRect.y && client.y <= clientRect.y + clientRect.height
|
|
3387
|
+
);
|
|
3388
|
+
}
|
|
3389
|
+
function mountHoneyPot(_ref4) {
|
|
3390
|
+
var initial = _ref4.initial;
|
|
3391
|
+
var element = document.createElement("div");
|
|
3392
|
+
element.setAttribute(honeyPotDataAttribute, "true");
|
|
3393
|
+
if (supportsPopover()) {
|
|
3394
|
+
element.setAttribute("popover", "manual");
|
|
3395
|
+
}
|
|
3396
|
+
var clientRect = getHoneyPotRectFor({
|
|
3397
|
+
client: initial
|
|
3398
|
+
});
|
|
3399
|
+
Object.assign(element.style, _objectSpread(_objectSpread({
|
|
3400
|
+
position: "fixed"
|
|
3401
|
+
}, supportsPopover() ? (
|
|
3402
|
+
// needs to come first as it has 'inset: unset' which
|
|
3403
|
+
// needs to be overridden by our top / left values
|
|
3404
|
+
popoverResetUserAgentStyles
|
|
3405
|
+
) : {
|
|
3406
|
+
// Fallback: using maximum possible z-index so that this element
|
|
3407
|
+
// will always be on top of other positioned content.
|
|
3408
|
+
zIndex: maxZIndex
|
|
3409
|
+
}), {}, {
|
|
3410
|
+
// Setting a background color explicitly to avoid any inherited styles.
|
|
3411
|
+
// Looks like this could be `opacity: 0`, but worried that _might_
|
|
3412
|
+
// cause the element to be ignored on some platforms.
|
|
3413
|
+
// When debugging, set backgroundColor to something like "red".
|
|
3414
|
+
backgroundColor: "transparent",
|
|
3415
|
+
// Being explicit to avoid inheriting styles
|
|
3416
|
+
padding: 0,
|
|
3417
|
+
margin: 0,
|
|
3418
|
+
boxSizing: "border-box",
|
|
3419
|
+
// We want this element to absorb pointer events,
|
|
3420
|
+
// it's kind of the whole point 😉
|
|
3421
|
+
pointerEvents: "auto"
|
|
3422
|
+
}, getRectStyles({
|
|
3423
|
+
clientRect
|
|
3424
|
+
})));
|
|
3425
|
+
document.body.appendChild(element);
|
|
3426
|
+
if (supportsPopover()) {
|
|
3427
|
+
element.showPopover();
|
|
3428
|
+
}
|
|
3429
|
+
var unbindPointerMove = (0, import_bind_event_listener.bind)(window, {
|
|
3430
|
+
type: "pointermove",
|
|
3431
|
+
listener: function listener(event) {
|
|
3432
|
+
var client = {
|
|
3433
|
+
x: event.clientX,
|
|
3434
|
+
y: event.clientY
|
|
3435
|
+
};
|
|
3436
|
+
clientRect = getHoneyPotRectFor({
|
|
3437
|
+
client
|
|
3438
|
+
});
|
|
3439
|
+
Object.assign(element.style, getRectStyles({
|
|
3440
|
+
clientRect
|
|
3441
|
+
}));
|
|
3442
|
+
},
|
|
3443
|
+
// using capture so we are less likely to be impacted by event stopping
|
|
3444
|
+
options: {
|
|
3445
|
+
capture: true
|
|
3446
|
+
}
|
|
3447
|
+
});
|
|
3448
|
+
return function finish(_ref5) {
|
|
3449
|
+
var current = _ref5.current;
|
|
3450
|
+
unbindPointerMove();
|
|
3451
|
+
if (isWithin({
|
|
3452
|
+
client: current,
|
|
3453
|
+
clientRect
|
|
3454
|
+
})) {
|
|
3455
|
+
element.remove();
|
|
3456
|
+
return;
|
|
3457
|
+
}
|
|
3458
|
+
function cleanup() {
|
|
3459
|
+
unbindPostDragEvents();
|
|
3460
|
+
element.remove();
|
|
3461
|
+
}
|
|
3462
|
+
var unbindPostDragEvents = (0, import_bind_event_listener.bindAll)(window, [
|
|
3463
|
+
{
|
|
3464
|
+
type: "pointerdown",
|
|
3465
|
+
listener: cleanup
|
|
3466
|
+
},
|
|
3467
|
+
{
|
|
3468
|
+
type: "pointermove",
|
|
3469
|
+
listener: cleanup
|
|
3470
|
+
},
|
|
3471
|
+
{
|
|
3472
|
+
type: "focusin",
|
|
3473
|
+
listener: cleanup
|
|
3474
|
+
},
|
|
3475
|
+
{
|
|
3476
|
+
type: "focusout",
|
|
3477
|
+
listener: cleanup
|
|
3478
|
+
},
|
|
3479
|
+
// a 'pointerdown' should happen before 'dragstart', but just being super safe
|
|
3480
|
+
{
|
|
3481
|
+
type: "dragstart",
|
|
3482
|
+
listener: cleanup
|
|
3483
|
+
},
|
|
3484
|
+
// if the user has dragged something out of the window
|
|
3485
|
+
// and then is dragging something back into the window
|
|
3486
|
+
// the first events we will see are "dragenter" (and then "dragover").
|
|
3487
|
+
// So if we see any of these we need to clear the post drag fix.
|
|
3488
|
+
{
|
|
3489
|
+
type: "dragenter",
|
|
3490
|
+
listener: cleanup
|
|
3491
|
+
},
|
|
3492
|
+
{
|
|
3493
|
+
type: "dragover",
|
|
3494
|
+
listener: cleanup
|
|
3495
|
+
}
|
|
3496
|
+
// Not adding a "wheel" event listener, as "wheel" by itself does not
|
|
3497
|
+
// resolve the bug.
|
|
3498
|
+
], {
|
|
3499
|
+
// Using `capture` so less likely to be impacted by other code stopping events
|
|
3500
|
+
capture: true
|
|
3501
|
+
});
|
|
3502
|
+
};
|
|
3503
|
+
}
|
|
3504
|
+
function makeHoneyPotFix() {
|
|
3505
|
+
var latestPointerMove = null;
|
|
3506
|
+
function bindEvents() {
|
|
3507
|
+
latestPointerMove = null;
|
|
3508
|
+
return (0, import_bind_event_listener.bind)(window, {
|
|
3509
|
+
type: "pointermove",
|
|
3510
|
+
listener: function listener(event) {
|
|
3511
|
+
latestPointerMove = {
|
|
3512
|
+
x: event.clientX,
|
|
3513
|
+
y: event.clientY
|
|
3514
|
+
};
|
|
3515
|
+
},
|
|
3516
|
+
// listening for pointer move in capture phase
|
|
3517
|
+
// so we are less likely to be impacted by events being stopped.
|
|
3518
|
+
options: {
|
|
3519
|
+
capture: true
|
|
3520
|
+
}
|
|
3521
|
+
});
|
|
3522
|
+
}
|
|
3523
|
+
function getOnPostDispatch() {
|
|
3524
|
+
var finish = null;
|
|
3525
|
+
return function onPostEvent(_ref6) {
|
|
3526
|
+
var eventName = _ref6.eventName, payload = _ref6.payload;
|
|
3527
|
+
if (eventName === "onDragStart") {
|
|
3528
|
+
var input = payload.location.initial.input;
|
|
3529
|
+
var initial = latestPointerMove !== null && latestPointerMove !== void 0 ? latestPointerMove : {
|
|
3530
|
+
x: input.clientX,
|
|
3531
|
+
y: input.clientY
|
|
3532
|
+
};
|
|
3533
|
+
finish = mountHoneyPot({
|
|
3534
|
+
initial
|
|
3535
|
+
});
|
|
3536
|
+
}
|
|
3537
|
+
if (eventName === "onDrop") {
|
|
3538
|
+
var _finish;
|
|
3539
|
+
var _input = payload.location.current.input;
|
|
3540
|
+
(_finish = finish) === null || _finish === void 0 || _finish({
|
|
3541
|
+
current: {
|
|
3542
|
+
x: _input.clientX,
|
|
3543
|
+
y: _input.clientY
|
|
3544
|
+
}
|
|
3545
|
+
});
|
|
3546
|
+
finish = null;
|
|
3547
|
+
latestPointerMove = null;
|
|
3548
|
+
}
|
|
3549
|
+
};
|
|
3550
|
+
}
|
|
3551
|
+
return {
|
|
3552
|
+
bindEvents,
|
|
3553
|
+
getOnPostDispatch
|
|
3554
|
+
};
|
|
3555
|
+
}
|
|
3556
|
+
|
|
3557
|
+
// node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
|
|
3558
|
+
function _arrayWithoutHoles(r) {
|
|
3559
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
3560
|
+
}
|
|
3561
|
+
|
|
3562
|
+
// node_modules/@babel/runtime/helpers/esm/iterableToArray.js
|
|
3563
|
+
function _iterableToArray(r) {
|
|
3564
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
3565
|
+
}
|
|
3566
|
+
|
|
3567
|
+
// node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
|
|
3568
|
+
function _nonIterableSpread() {
|
|
3569
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
3570
|
+
}
|
|
3571
|
+
|
|
3572
|
+
// node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
|
|
3573
|
+
function _toConsumableArray(r) {
|
|
3574
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
3575
|
+
}
|
|
3576
|
+
|
|
3577
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/ledger/lifecycle-manager.js
|
|
3578
|
+
var import_bind_event_listener3 = __toESM(require_dist());
|
|
3579
|
+
|
|
3580
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/is-firefox.js
|
|
3581
|
+
var isFirefox = once(function isFirefox2() {
|
|
3582
|
+
if (false) {
|
|
3583
|
+
return false;
|
|
3584
|
+
}
|
|
3585
|
+
return navigator.userAgent.includes("Firefox");
|
|
3586
|
+
});
|
|
3587
|
+
|
|
3588
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/is-safari.js
|
|
3589
|
+
var isSafari = once(function isSafari2() {
|
|
3590
|
+
if (false) {
|
|
3591
|
+
return false;
|
|
3592
|
+
}
|
|
3593
|
+
var _navigator = navigator, userAgent = _navigator.userAgent;
|
|
3594
|
+
return userAgent.includes("AppleWebKit") && !userAgent.includes("Chrome");
|
|
3595
|
+
});
|
|
3596
|
+
|
|
3597
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/changing-window/count-events-for-safari.js
|
|
3598
|
+
var import_bind_event_listener2 = __toESM(require_dist());
|
|
3599
|
+
var symbols = {
|
|
3600
|
+
isLeavingWindow: /* @__PURE__ */ Symbol("leaving"),
|
|
3601
|
+
isEnteringWindow: /* @__PURE__ */ Symbol("entering")
|
|
3602
|
+
};
|
|
3603
|
+
function isLeavingWindowInSafari(_ref2) {
|
|
3604
|
+
var dragLeave = _ref2.dragLeave;
|
|
3605
|
+
if (!isSafari()) {
|
|
3606
|
+
return false;
|
|
3607
|
+
}
|
|
3608
|
+
return dragLeave.hasOwnProperty(symbols.isLeavingWindow);
|
|
3609
|
+
}
|
|
3610
|
+
(function fixSafari() {
|
|
3611
|
+
if (typeof window === "undefined") {
|
|
3612
|
+
return;
|
|
3613
|
+
}
|
|
3614
|
+
if (false) {
|
|
3615
|
+
return;
|
|
3616
|
+
}
|
|
3617
|
+
if (!isSafari()) {
|
|
3618
|
+
return;
|
|
3619
|
+
}
|
|
3620
|
+
function getInitialState() {
|
|
3621
|
+
return {
|
|
3622
|
+
enterCount: 0,
|
|
3623
|
+
isOverWindow: false
|
|
3624
|
+
};
|
|
3625
|
+
}
|
|
3626
|
+
var state = getInitialState();
|
|
3627
|
+
function resetState() {
|
|
3628
|
+
state = getInitialState();
|
|
3629
|
+
}
|
|
3630
|
+
(0, import_bind_event_listener2.bindAll)(
|
|
3631
|
+
window,
|
|
3632
|
+
[{
|
|
3633
|
+
type: "dragstart",
|
|
3634
|
+
listener: function listener() {
|
|
3635
|
+
state.enterCount = 0;
|
|
3636
|
+
state.isOverWindow = true;
|
|
3637
|
+
}
|
|
3638
|
+
}, {
|
|
3639
|
+
type: "drop",
|
|
3640
|
+
listener: resetState
|
|
3641
|
+
}, {
|
|
3642
|
+
type: "dragend",
|
|
3643
|
+
listener: resetState
|
|
3644
|
+
}, {
|
|
3645
|
+
type: "dragenter",
|
|
3646
|
+
listener: function listener(event) {
|
|
3647
|
+
if (!state.isOverWindow && state.enterCount === 0) {
|
|
3648
|
+
event[symbols.isEnteringWindow] = true;
|
|
3649
|
+
}
|
|
3650
|
+
state.isOverWindow = true;
|
|
3651
|
+
state.enterCount++;
|
|
3652
|
+
}
|
|
3653
|
+
}, {
|
|
3654
|
+
type: "dragleave",
|
|
3655
|
+
listener: function listener(event) {
|
|
3656
|
+
state.enterCount--;
|
|
3657
|
+
if (state.isOverWindow && state.enterCount === 0) {
|
|
3658
|
+
event[symbols.isLeavingWindow] = true;
|
|
3659
|
+
state.isOverWindow = false;
|
|
3660
|
+
}
|
|
3661
|
+
}
|
|
3662
|
+
}],
|
|
3663
|
+
// using `capture: true` so that adding event listeners
|
|
3664
|
+
// in bubble phase will have the correct symbols
|
|
3665
|
+
{
|
|
3666
|
+
capture: true
|
|
3667
|
+
}
|
|
3668
|
+
);
|
|
3669
|
+
})();
|
|
3670
|
+
|
|
3671
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/changing-window/is-from-another-window.js
|
|
3672
|
+
function isNodeLike(target) {
|
|
3673
|
+
return "nodeName" in target;
|
|
3674
|
+
}
|
|
3675
|
+
function isFromAnotherWindow(eventTarget) {
|
|
3676
|
+
return isNodeLike(eventTarget) && eventTarget.ownerDocument !== document;
|
|
3677
|
+
}
|
|
3678
|
+
|
|
3679
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/changing-window/is-leaving-window.js
|
|
3680
|
+
function isLeavingWindow(_ref) {
|
|
3681
|
+
var dragLeave = _ref.dragLeave;
|
|
3682
|
+
var type = dragLeave.type, relatedTarget = dragLeave.relatedTarget;
|
|
3683
|
+
if (type !== "dragleave") {
|
|
3684
|
+
return false;
|
|
3685
|
+
}
|
|
3686
|
+
if (isSafari()) {
|
|
3687
|
+
return isLeavingWindowInSafari({
|
|
3688
|
+
dragLeave
|
|
3689
|
+
});
|
|
3690
|
+
}
|
|
3691
|
+
if (relatedTarget == null) {
|
|
3692
|
+
return true;
|
|
3693
|
+
}
|
|
3694
|
+
if (isFirefox()) {
|
|
3695
|
+
return isFromAnotherWindow(relatedTarget);
|
|
3696
|
+
}
|
|
3697
|
+
return relatedTarget instanceof HTMLIFrameElement;
|
|
3698
|
+
}
|
|
3699
|
+
|
|
3700
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/detect-broken-drag.js
|
|
3701
|
+
function getBindingsForBrokenDrags(_ref) {
|
|
3702
|
+
var onDragEnd = _ref.onDragEnd;
|
|
3703
|
+
return [
|
|
3704
|
+
// ## Detecting drag ending for removed draggables
|
|
3705
|
+
//
|
|
3706
|
+
// If a draggable element is removed during a drag and the user drops:
|
|
3707
|
+
// 1. if over a valid drop target: we get a "drop" event to know the drag is finished
|
|
3708
|
+
// 2. if not over a valid drop target (or cancelled): we get nothing
|
|
3709
|
+
// The "dragend" event will not fire on the source draggable if it has been
|
|
3710
|
+
// removed from the DOM.
|
|
3711
|
+
// So we need to figure out if a drag operation has finished by looking at other events
|
|
3712
|
+
// We can do this by looking at other events
|
|
3713
|
+
// ### First detection: "pointermove" events
|
|
3714
|
+
// 1. "pointermove" events cannot fire during a drag and drop operation
|
|
3715
|
+
// according to the spec. So if we get a "pointermove" it means that
|
|
3716
|
+
// the drag and drop operations has finished. So if we get a "pointermove"
|
|
3717
|
+
// we know that the drag is over
|
|
3718
|
+
// 2. 🦊😤 Drag and drop operations are _supposed_ to suppress
|
|
3719
|
+
// other pointer events. However, firefox will allow a few
|
|
3720
|
+
// pointer event to get through after a drag starts.
|
|
3721
|
+
// The most I've seen is 3
|
|
3722
|
+
{
|
|
3723
|
+
type: "pointermove",
|
|
3724
|
+
listener: /* @__PURE__ */ (function() {
|
|
3725
|
+
var callCount = 0;
|
|
3726
|
+
return function listener() {
|
|
3727
|
+
if (callCount < 20) {
|
|
3728
|
+
callCount++;
|
|
3729
|
+
return;
|
|
3730
|
+
}
|
|
3731
|
+
onDragEnd();
|
|
3732
|
+
};
|
|
3733
|
+
})()
|
|
3734
|
+
},
|
|
3735
|
+
// ### Second detection: "pointerdown" events
|
|
3736
|
+
// If we receive this event then we know that a drag operation has finished
|
|
3737
|
+
// and potentially another one is about to start.
|
|
3738
|
+
// Note: `pointerdown` fires on all browsers / platforms before "dragstart"
|
|
3739
|
+
{
|
|
3740
|
+
type: "pointerdown",
|
|
3741
|
+
listener: onDragEnd
|
|
3742
|
+
}
|
|
3743
|
+
];
|
|
3744
|
+
}
|
|
3745
|
+
|
|
3746
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/get-input.js
|
|
3747
|
+
function getInput(event) {
|
|
3748
|
+
return {
|
|
3749
|
+
altKey: event.altKey,
|
|
3750
|
+
button: event.button,
|
|
3751
|
+
buttons: event.buttons,
|
|
3752
|
+
ctrlKey: event.ctrlKey,
|
|
3753
|
+
metaKey: event.metaKey,
|
|
3754
|
+
shiftKey: event.shiftKey,
|
|
3755
|
+
clientX: event.clientX,
|
|
3756
|
+
clientY: event.clientY,
|
|
3757
|
+
pageX: event.pageX,
|
|
3758
|
+
pageY: event.pageY
|
|
3759
|
+
};
|
|
3760
|
+
}
|
|
3761
|
+
|
|
3762
|
+
// node_modules/raf-schd/dist/raf-schd.esm.js
|
|
3763
|
+
var rafSchd = function rafSchd2(fn) {
|
|
3764
|
+
var lastArgs = [];
|
|
3765
|
+
var frameId = null;
|
|
3766
|
+
var wrapperFn = function wrapperFn2() {
|
|
3767
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3768
|
+
args[_key] = arguments[_key];
|
|
3769
|
+
}
|
|
3770
|
+
lastArgs = args;
|
|
3771
|
+
if (frameId) {
|
|
3772
|
+
return;
|
|
3773
|
+
}
|
|
3774
|
+
frameId = requestAnimationFrame(function() {
|
|
3775
|
+
frameId = null;
|
|
3776
|
+
fn.apply(void 0, lastArgs);
|
|
3777
|
+
});
|
|
3778
|
+
};
|
|
3779
|
+
wrapperFn.cancel = function() {
|
|
3780
|
+
if (!frameId) {
|
|
3781
|
+
return;
|
|
3782
|
+
}
|
|
3783
|
+
cancelAnimationFrame(frameId);
|
|
3784
|
+
frameId = null;
|
|
3785
|
+
};
|
|
3786
|
+
return wrapperFn;
|
|
3787
|
+
};
|
|
3788
|
+
var raf_schd_esm_default = rafSchd;
|
|
3789
|
+
|
|
3790
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/ledger/dispatch-consumer-event.js
|
|
3791
|
+
var scheduleOnDrag = raf_schd_esm_default(function(fn) {
|
|
3792
|
+
return fn();
|
|
3793
|
+
});
|
|
3794
|
+
var dragStart = /* @__PURE__ */ (function() {
|
|
3795
|
+
var scheduled = null;
|
|
3796
|
+
function schedule(fn) {
|
|
3797
|
+
var frameId = requestAnimationFrame(function() {
|
|
3798
|
+
scheduled = null;
|
|
3799
|
+
fn();
|
|
3800
|
+
});
|
|
3801
|
+
scheduled = {
|
|
3802
|
+
frameId,
|
|
3803
|
+
fn
|
|
3804
|
+
};
|
|
3805
|
+
}
|
|
3806
|
+
function flush() {
|
|
3807
|
+
if (scheduled) {
|
|
3808
|
+
cancelAnimationFrame(scheduled.frameId);
|
|
3809
|
+
scheduled.fn();
|
|
3810
|
+
scheduled = null;
|
|
3811
|
+
}
|
|
3812
|
+
}
|
|
3813
|
+
return {
|
|
3814
|
+
schedule,
|
|
3815
|
+
flush
|
|
3816
|
+
};
|
|
3817
|
+
})();
|
|
3818
|
+
function makeDispatch(_ref) {
|
|
3819
|
+
var source = _ref.source, initial = _ref.initial, dispatchEvent = _ref.dispatchEvent;
|
|
3820
|
+
var previous = {
|
|
3821
|
+
dropTargets: []
|
|
3822
|
+
};
|
|
3823
|
+
function safeDispatch(args) {
|
|
3824
|
+
dispatchEvent(args);
|
|
3825
|
+
previous = {
|
|
3826
|
+
dropTargets: args.payload.location.current.dropTargets
|
|
3827
|
+
};
|
|
3828
|
+
}
|
|
3829
|
+
var dispatch = {
|
|
3830
|
+
start: function start2(_ref2) {
|
|
3831
|
+
var nativeSetDragImage = _ref2.nativeSetDragImage;
|
|
3832
|
+
var location2 = {
|
|
3833
|
+
current: initial,
|
|
3834
|
+
previous,
|
|
3835
|
+
initial
|
|
3836
|
+
};
|
|
3837
|
+
safeDispatch({
|
|
3838
|
+
eventName: "onGenerateDragPreview",
|
|
3839
|
+
payload: {
|
|
3840
|
+
source,
|
|
3841
|
+
location: location2,
|
|
3842
|
+
nativeSetDragImage
|
|
3843
|
+
}
|
|
3844
|
+
});
|
|
3845
|
+
dragStart.schedule(function() {
|
|
3846
|
+
safeDispatch({
|
|
3847
|
+
eventName: "onDragStart",
|
|
3848
|
+
payload: {
|
|
3849
|
+
source,
|
|
3850
|
+
location: location2
|
|
3851
|
+
}
|
|
3852
|
+
});
|
|
3853
|
+
});
|
|
3854
|
+
},
|
|
3855
|
+
dragUpdate: function dragUpdate(_ref3) {
|
|
3856
|
+
var current = _ref3.current;
|
|
3857
|
+
dragStart.flush();
|
|
3858
|
+
scheduleOnDrag.cancel();
|
|
3859
|
+
safeDispatch({
|
|
3860
|
+
eventName: "onDropTargetChange",
|
|
3861
|
+
payload: {
|
|
3862
|
+
source,
|
|
3863
|
+
location: {
|
|
3864
|
+
initial,
|
|
3865
|
+
previous,
|
|
3866
|
+
current
|
|
3867
|
+
}
|
|
3868
|
+
}
|
|
3869
|
+
});
|
|
3870
|
+
},
|
|
3871
|
+
drag: function drag(_ref4) {
|
|
3872
|
+
var current = _ref4.current;
|
|
3873
|
+
scheduleOnDrag(function() {
|
|
3874
|
+
dragStart.flush();
|
|
3875
|
+
var location2 = {
|
|
3876
|
+
initial,
|
|
3877
|
+
previous,
|
|
3878
|
+
current
|
|
3879
|
+
};
|
|
3880
|
+
safeDispatch({
|
|
3881
|
+
eventName: "onDrag",
|
|
3882
|
+
payload: {
|
|
3883
|
+
source,
|
|
3884
|
+
location: location2
|
|
3885
|
+
}
|
|
3886
|
+
});
|
|
3887
|
+
});
|
|
3888
|
+
},
|
|
3889
|
+
drop: function drop(_ref5) {
|
|
3890
|
+
var current = _ref5.current, updatedSourcePayload = _ref5.updatedSourcePayload;
|
|
3891
|
+
dragStart.flush();
|
|
3892
|
+
scheduleOnDrag.cancel();
|
|
3893
|
+
safeDispatch({
|
|
3894
|
+
eventName: "onDrop",
|
|
3895
|
+
payload: {
|
|
3896
|
+
source: updatedSourcePayload !== null && updatedSourcePayload !== void 0 ? updatedSourcePayload : source,
|
|
3897
|
+
location: {
|
|
3898
|
+
current,
|
|
3899
|
+
previous,
|
|
3900
|
+
initial
|
|
3901
|
+
}
|
|
3902
|
+
}
|
|
3903
|
+
});
|
|
3904
|
+
}
|
|
3905
|
+
};
|
|
3906
|
+
return dispatch;
|
|
3907
|
+
}
|
|
3908
|
+
|
|
3909
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/ledger/lifecycle-manager.js
|
|
3910
|
+
var globalState = {
|
|
3911
|
+
isActive: false
|
|
3912
|
+
};
|
|
3913
|
+
function canStart() {
|
|
3914
|
+
return !globalState.isActive;
|
|
3915
|
+
}
|
|
3916
|
+
function getNativeSetDragImage(event) {
|
|
3917
|
+
if (event.dataTransfer) {
|
|
3918
|
+
return event.dataTransfer.setDragImage.bind(event.dataTransfer);
|
|
3919
|
+
}
|
|
3920
|
+
return null;
|
|
3921
|
+
}
|
|
3922
|
+
function hasHierarchyChanged(_ref) {
|
|
3923
|
+
var current = _ref.current, next = _ref.next;
|
|
3924
|
+
if (current.length !== next.length) {
|
|
3925
|
+
return true;
|
|
3926
|
+
}
|
|
3927
|
+
for (var i = 0; i < current.length; i++) {
|
|
3928
|
+
if (current[i].element !== next[i].element) {
|
|
3929
|
+
return true;
|
|
3930
|
+
}
|
|
3931
|
+
}
|
|
3932
|
+
return false;
|
|
3933
|
+
}
|
|
3934
|
+
function start(_ref2) {
|
|
3935
|
+
var event = _ref2.event, dragType = _ref2.dragType, getDropTargetsOver = _ref2.getDropTargetsOver, dispatchEvent = _ref2.dispatchEvent;
|
|
3936
|
+
if (!canStart()) {
|
|
3937
|
+
return;
|
|
3938
|
+
}
|
|
3939
|
+
var initial = getStartLocation({
|
|
3940
|
+
event,
|
|
3941
|
+
dragType,
|
|
3942
|
+
getDropTargetsOver
|
|
3943
|
+
});
|
|
3944
|
+
globalState.isActive = true;
|
|
3945
|
+
var state = {
|
|
3946
|
+
current: initial
|
|
3947
|
+
};
|
|
3948
|
+
setDropEffectOnEvent({
|
|
3949
|
+
event,
|
|
3950
|
+
current: initial.dropTargets
|
|
3951
|
+
});
|
|
3952
|
+
var dispatch = makeDispatch({
|
|
3953
|
+
source: dragType.payload,
|
|
3954
|
+
dispatchEvent,
|
|
3955
|
+
initial
|
|
3956
|
+
});
|
|
3957
|
+
function updateState(next) {
|
|
3958
|
+
var hasChanged = hasHierarchyChanged({
|
|
3959
|
+
current: state.current.dropTargets,
|
|
3960
|
+
next: next.dropTargets
|
|
3961
|
+
});
|
|
3962
|
+
state.current = next;
|
|
3963
|
+
if (hasChanged) {
|
|
3964
|
+
dispatch.dragUpdate({
|
|
3965
|
+
current: state.current
|
|
3966
|
+
});
|
|
3967
|
+
}
|
|
3968
|
+
}
|
|
3969
|
+
function onUpdateEvent(event2) {
|
|
3970
|
+
var input = getInput(event2);
|
|
3971
|
+
var target = isHoneyPotElement(event2.target) ? getElementFromPointWithoutHoneypot({
|
|
3972
|
+
x: input.clientX,
|
|
3973
|
+
y: input.clientY
|
|
3974
|
+
}) : event2.target;
|
|
3975
|
+
var nextDropTargets = getDropTargetsOver({
|
|
3976
|
+
target,
|
|
3977
|
+
input,
|
|
3978
|
+
source: dragType.payload,
|
|
3979
|
+
current: state.current.dropTargets
|
|
3980
|
+
});
|
|
3981
|
+
if (nextDropTargets.length) {
|
|
3982
|
+
event2.preventDefault();
|
|
3983
|
+
setDropEffectOnEvent({
|
|
3984
|
+
event: event2,
|
|
3985
|
+
current: nextDropTargets
|
|
3986
|
+
});
|
|
3987
|
+
}
|
|
3988
|
+
updateState({
|
|
3989
|
+
dropTargets: nextDropTargets,
|
|
3990
|
+
input
|
|
3991
|
+
});
|
|
3992
|
+
}
|
|
3993
|
+
function cancel() {
|
|
3994
|
+
if (state.current.dropTargets.length) {
|
|
3995
|
+
updateState({
|
|
3996
|
+
dropTargets: [],
|
|
3997
|
+
input: state.current.input
|
|
3998
|
+
});
|
|
3999
|
+
}
|
|
4000
|
+
dispatch.drop({
|
|
4001
|
+
current: state.current,
|
|
4002
|
+
updatedSourcePayload: null
|
|
4003
|
+
});
|
|
4004
|
+
finish();
|
|
4005
|
+
}
|
|
4006
|
+
function finish() {
|
|
4007
|
+
globalState.isActive = false;
|
|
4008
|
+
unbindEvents();
|
|
4009
|
+
}
|
|
4010
|
+
var unbindEvents = (0, import_bind_event_listener3.bindAll)(
|
|
4011
|
+
window,
|
|
4012
|
+
[{
|
|
4013
|
+
// 👋 Note: we are repurposing the `dragover` event as our `drag` event
|
|
4014
|
+
// this is because firefox does not publish pointer coordinates during
|
|
4015
|
+
// a `drag` event, but does for every other type of drag event
|
|
4016
|
+
// `dragover` fires on all elements that are being dragged over
|
|
4017
|
+
// Because we are binding to `window` - our `dragover` is effectively the same as a `drag`
|
|
4018
|
+
// 🦊😤
|
|
4019
|
+
type: "dragover",
|
|
4020
|
+
listener: function listener(event2) {
|
|
4021
|
+
onUpdateEvent(event2);
|
|
4022
|
+
dispatch.drag({
|
|
4023
|
+
current: state.current
|
|
4024
|
+
});
|
|
4025
|
+
}
|
|
4026
|
+
}, {
|
|
4027
|
+
type: "dragenter",
|
|
4028
|
+
listener: onUpdateEvent
|
|
4029
|
+
}, {
|
|
4030
|
+
type: "dragleave",
|
|
4031
|
+
listener: function listener(event2) {
|
|
4032
|
+
if (!isLeavingWindow({
|
|
4033
|
+
dragLeave: event2
|
|
4034
|
+
})) {
|
|
4035
|
+
return;
|
|
4036
|
+
}
|
|
4037
|
+
updateState({
|
|
4038
|
+
input: state.current.input,
|
|
4039
|
+
dropTargets: []
|
|
4040
|
+
});
|
|
4041
|
+
if (dragType.startedFrom === "external") {
|
|
4042
|
+
cancel();
|
|
4043
|
+
}
|
|
4044
|
+
}
|
|
4045
|
+
}, {
|
|
4046
|
+
// A "drop" can only happen if the browser allowed the drop
|
|
4047
|
+
type: "drop",
|
|
4048
|
+
listener: function listener(event2) {
|
|
4049
|
+
state.current = {
|
|
4050
|
+
dropTargets: state.current.dropTargets,
|
|
4051
|
+
input: getInput(event2)
|
|
4052
|
+
};
|
|
4053
|
+
if (!state.current.dropTargets.length) {
|
|
4054
|
+
cancel();
|
|
4055
|
+
return;
|
|
4056
|
+
}
|
|
4057
|
+
event2.preventDefault();
|
|
4058
|
+
setDropEffectOnEvent({
|
|
4059
|
+
event: event2,
|
|
4060
|
+
current: state.current.dropTargets
|
|
4061
|
+
});
|
|
4062
|
+
dispatch.drop({
|
|
4063
|
+
current: state.current,
|
|
4064
|
+
// When dropping something native, we need to extract the latest
|
|
4065
|
+
// `.items` from the "drop" event as it is now accessible
|
|
4066
|
+
updatedSourcePayload: dragType.type === "external" ? dragType.getDropPayload(event2) : null
|
|
4067
|
+
});
|
|
4068
|
+
finish();
|
|
4069
|
+
}
|
|
4070
|
+
}, {
|
|
4071
|
+
// "dragend" fires when on the drag source (eg a draggable element)
|
|
4072
|
+
// when the drag is finished.
|
|
4073
|
+
// "dragend" will fire after "drop" (if there was a successful drop)
|
|
4074
|
+
// "dragend" does not fire if the draggable source has been removed during the drag
|
|
4075
|
+
// or for external drag sources (eg files)
|
|
4076
|
+
// This "dragend" listener will not fire if there was a successful drop
|
|
4077
|
+
// as we will have already removed the event listener
|
|
4078
|
+
type: "dragend",
|
|
4079
|
+
listener: function listener(event2) {
|
|
4080
|
+
state.current = {
|
|
4081
|
+
dropTargets: state.current.dropTargets,
|
|
4082
|
+
input: getInput(event2)
|
|
4083
|
+
};
|
|
4084
|
+
cancel();
|
|
4085
|
+
}
|
|
4086
|
+
}].concat(_toConsumableArray(getBindingsForBrokenDrags({
|
|
4087
|
+
onDragEnd: cancel
|
|
4088
|
+
}))),
|
|
4089
|
+
// Once we have started a managed drag operation it is important that we see / own all drag events
|
|
4090
|
+
// We got one adoption bug pop up where some code was stopping (`event.stopPropagation()`)
|
|
4091
|
+
// all "drop" events in the bubble phase on the `document.body`.
|
|
4092
|
+
// This meant that we never saw the "drop" event.
|
|
4093
|
+
{
|
|
4094
|
+
capture: true
|
|
4095
|
+
}
|
|
4096
|
+
);
|
|
4097
|
+
dispatch.start({
|
|
4098
|
+
nativeSetDragImage: getNativeSetDragImage(event)
|
|
4099
|
+
});
|
|
4100
|
+
}
|
|
4101
|
+
function setDropEffectOnEvent(_ref3) {
|
|
4102
|
+
var _current$;
|
|
4103
|
+
var event = _ref3.event, current = _ref3.current;
|
|
4104
|
+
var innerMost = (_current$ = current[0]) === null || _current$ === void 0 ? void 0 : _current$.dropEffect;
|
|
4105
|
+
if (innerMost != null && event.dataTransfer) {
|
|
4106
|
+
event.dataTransfer.dropEffect = innerMost;
|
|
4107
|
+
}
|
|
4108
|
+
}
|
|
4109
|
+
function getStartLocation(_ref4) {
|
|
4110
|
+
var event = _ref4.event, dragType = _ref4.dragType, getDropTargetsOver = _ref4.getDropTargetsOver;
|
|
4111
|
+
var input = getInput(event);
|
|
4112
|
+
if (dragType.startedFrom === "external") {
|
|
4113
|
+
return {
|
|
4114
|
+
input,
|
|
4115
|
+
dropTargets: []
|
|
4116
|
+
};
|
|
4117
|
+
}
|
|
4118
|
+
var dropTargets = getDropTargetsOver({
|
|
4119
|
+
input,
|
|
4120
|
+
source: dragType.payload,
|
|
4121
|
+
target: event.target,
|
|
4122
|
+
current: []
|
|
4123
|
+
});
|
|
4124
|
+
return {
|
|
4125
|
+
input,
|
|
4126
|
+
dropTargets
|
|
4127
|
+
};
|
|
4128
|
+
}
|
|
4129
|
+
var lifecycle = {
|
|
4130
|
+
canStart,
|
|
4131
|
+
start
|
|
4132
|
+
};
|
|
4133
|
+
|
|
4134
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/ledger/usage-ledger.js
|
|
4135
|
+
var ledger = /* @__PURE__ */ new Map();
|
|
4136
|
+
function registerUsage(_ref) {
|
|
4137
|
+
var typeKey = _ref.typeKey, mount2 = _ref.mount;
|
|
4138
|
+
var entry = ledger.get(typeKey);
|
|
4139
|
+
if (entry) {
|
|
4140
|
+
entry.usageCount++;
|
|
4141
|
+
return entry;
|
|
4142
|
+
}
|
|
4143
|
+
var initial = {
|
|
4144
|
+
typeKey,
|
|
4145
|
+
unmount: mount2(),
|
|
4146
|
+
usageCount: 1
|
|
4147
|
+
};
|
|
4148
|
+
ledger.set(typeKey, initial);
|
|
4149
|
+
return initial;
|
|
4150
|
+
}
|
|
4151
|
+
function register(args) {
|
|
4152
|
+
var entry = registerUsage(args);
|
|
4153
|
+
return function unregister() {
|
|
4154
|
+
entry.usageCount--;
|
|
4155
|
+
if (entry.usageCount > 0) {
|
|
4156
|
+
return;
|
|
4157
|
+
}
|
|
4158
|
+
entry.unmount();
|
|
4159
|
+
ledger.delete(args.typeKey);
|
|
4160
|
+
};
|
|
4161
|
+
}
|
|
4162
|
+
|
|
4163
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/public-utils/combine.js
|
|
4164
|
+
function combine() {
|
|
4165
|
+
for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
4166
|
+
fns[_key] = arguments[_key];
|
|
4167
|
+
}
|
|
4168
|
+
return function cleanup() {
|
|
4169
|
+
fns.forEach(function(fn) {
|
|
4170
|
+
return fn();
|
|
4171
|
+
});
|
|
4172
|
+
};
|
|
4173
|
+
}
|
|
4174
|
+
|
|
4175
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/add-attribute.js
|
|
4176
|
+
function addAttribute(element, _ref) {
|
|
4177
|
+
var attribute = _ref.attribute, value = _ref.value;
|
|
4178
|
+
element.setAttribute(attribute, value);
|
|
4179
|
+
return function() {
|
|
4180
|
+
return element.removeAttribute(attribute);
|
|
4181
|
+
};
|
|
4182
|
+
}
|
|
4183
|
+
|
|
4184
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/make-adapter/make-drop-target.js
|
|
4185
|
+
function ownKeys2(e, r) {
|
|
4186
|
+
var t = Object.keys(e);
|
|
4187
|
+
if (Object.getOwnPropertySymbols) {
|
|
4188
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
4189
|
+
r && (o = o.filter(function(r2) {
|
|
4190
|
+
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
4191
|
+
})), t.push.apply(t, o);
|
|
4192
|
+
}
|
|
4193
|
+
return t;
|
|
4194
|
+
}
|
|
4195
|
+
function _objectSpread2(e) {
|
|
4196
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
4197
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
4198
|
+
r % 2 ? ownKeys2(Object(t), true).forEach(function(r2) {
|
|
4199
|
+
_defineProperty(e, r2, t[r2]);
|
|
4200
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys2(Object(t)).forEach(function(r2) {
|
|
4201
|
+
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
4202
|
+
});
|
|
4203
|
+
}
|
|
4204
|
+
return e;
|
|
4205
|
+
}
|
|
4206
|
+
function _createForOfIteratorHelper(r, e) {
|
|
4207
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
4208
|
+
if (!t) {
|
|
4209
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray2(r)) || e && r && "number" == typeof r.length) {
|
|
4210
|
+
t && (r = t);
|
|
4211
|
+
var _n = 0, F = function F2() {
|
|
4212
|
+
};
|
|
4213
|
+
return { s: F, n: function n() {
|
|
4214
|
+
return _n >= r.length ? { done: true } : { done: false, value: r[_n++] };
|
|
4215
|
+
}, e: function e2(r2) {
|
|
4216
|
+
throw r2;
|
|
4217
|
+
}, f: F };
|
|
4218
|
+
}
|
|
4219
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4220
|
+
}
|
|
4221
|
+
var o, a = true, u = false;
|
|
4222
|
+
return { s: function s() {
|
|
4223
|
+
t = t.call(r);
|
|
4224
|
+
}, n: function n() {
|
|
4225
|
+
var r2 = t.next();
|
|
4226
|
+
return a = r2.done, r2;
|
|
4227
|
+
}, e: function e2(r2) {
|
|
4228
|
+
u = true, o = r2;
|
|
4229
|
+
}, f: function f() {
|
|
4230
|
+
try {
|
|
4231
|
+
a || null == t.return || t.return();
|
|
4232
|
+
} finally {
|
|
4233
|
+
if (u) throw o;
|
|
4234
|
+
}
|
|
4235
|
+
} };
|
|
4236
|
+
}
|
|
4237
|
+
function _unsupportedIterableToArray2(r, a) {
|
|
4238
|
+
if (r) {
|
|
4239
|
+
if ("string" == typeof r) return _arrayLikeToArray2(r, a);
|
|
4240
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
4241
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray2(r, a) : void 0;
|
|
4242
|
+
}
|
|
4243
|
+
}
|
|
4244
|
+
function _arrayLikeToArray2(r, a) {
|
|
4245
|
+
(null == a || a > r.length) && (a = r.length);
|
|
4246
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
4247
|
+
return n;
|
|
4248
|
+
}
|
|
4249
|
+
function copyReverse(array) {
|
|
4250
|
+
return array.slice(0).reverse();
|
|
4251
|
+
}
|
|
4252
|
+
function makeDropTarget(_ref) {
|
|
4253
|
+
var typeKey = _ref.typeKey, defaultDropEffect = _ref.defaultDropEffect;
|
|
4254
|
+
var registry = /* @__PURE__ */ new WeakMap();
|
|
4255
|
+
var dropTargetDataAtt = "data-drop-target-for-".concat(typeKey);
|
|
4256
|
+
var dropTargetSelector = "[".concat(dropTargetDataAtt, "]");
|
|
4257
|
+
function addToRegistry2(args) {
|
|
4258
|
+
registry.set(args.element, args);
|
|
4259
|
+
return function() {
|
|
4260
|
+
return registry.delete(args.element);
|
|
4261
|
+
};
|
|
4262
|
+
}
|
|
4263
|
+
function dropTargetForConsumers(args) {
|
|
4264
|
+
if (true) {
|
|
4265
|
+
var existing = registry.get(args.element);
|
|
4266
|
+
if (existing) {
|
|
4267
|
+
console.warn("You have already registered a [".concat(typeKey, "] dropTarget on the same element"), {
|
|
4268
|
+
existing,
|
|
4269
|
+
proposed: args
|
|
4270
|
+
});
|
|
4271
|
+
}
|
|
4272
|
+
if (args.element instanceof HTMLIFrameElement) {
|
|
4273
|
+
console.warn("\n We recommend not registering <iframe> elements as drop targets\n as it can result in some strange browser event ordering.\n ".replace(/\s{2,}/g, " ").trim());
|
|
4274
|
+
}
|
|
4275
|
+
}
|
|
4276
|
+
var cleanup = combine(addAttribute(args.element, {
|
|
4277
|
+
attribute: dropTargetDataAtt,
|
|
4278
|
+
value: "true"
|
|
4279
|
+
}), addToRegistry2(args));
|
|
4280
|
+
return once(cleanup);
|
|
4281
|
+
}
|
|
4282
|
+
function getActualDropTargets(_ref2) {
|
|
4283
|
+
var _args$getData, _args$getData2, _args$getDropEffect, _args$getDropEffect2;
|
|
4284
|
+
var source = _ref2.source, target = _ref2.target, input = _ref2.input, _ref2$result = _ref2.result, result = _ref2$result === void 0 ? [] : _ref2$result;
|
|
4285
|
+
if (target == null) {
|
|
4286
|
+
return result;
|
|
4287
|
+
}
|
|
4288
|
+
if (!(target instanceof Element)) {
|
|
4289
|
+
if (target instanceof Node) {
|
|
4290
|
+
return getActualDropTargets({
|
|
4291
|
+
source,
|
|
4292
|
+
target: target.parentElement,
|
|
4293
|
+
input,
|
|
4294
|
+
result
|
|
4295
|
+
});
|
|
4296
|
+
}
|
|
4297
|
+
return result;
|
|
4298
|
+
}
|
|
4299
|
+
var closest = target.closest(dropTargetSelector);
|
|
4300
|
+
if (closest == null) {
|
|
4301
|
+
return result;
|
|
4302
|
+
}
|
|
4303
|
+
var args = registry.get(closest);
|
|
4304
|
+
if (args == null) {
|
|
4305
|
+
return result;
|
|
4306
|
+
}
|
|
4307
|
+
var feedback = {
|
|
4308
|
+
input,
|
|
4309
|
+
source,
|
|
4310
|
+
element: args.element
|
|
4311
|
+
};
|
|
4312
|
+
if (args.canDrop && !args.canDrop(feedback)) {
|
|
4313
|
+
return getActualDropTargets({
|
|
4314
|
+
source,
|
|
4315
|
+
target: args.element.parentElement,
|
|
4316
|
+
input,
|
|
4317
|
+
result
|
|
4318
|
+
});
|
|
4319
|
+
}
|
|
4320
|
+
var data = (_args$getData = (_args$getData2 = args.getData) === null || _args$getData2 === void 0 ? void 0 : _args$getData2.call(args, feedback)) !== null && _args$getData !== void 0 ? _args$getData : {};
|
|
4321
|
+
var dropEffect = (_args$getDropEffect = (_args$getDropEffect2 = args.getDropEffect) === null || _args$getDropEffect2 === void 0 ? void 0 : _args$getDropEffect2.call(args, feedback)) !== null && _args$getDropEffect !== void 0 ? _args$getDropEffect : defaultDropEffect;
|
|
4322
|
+
var record = {
|
|
4323
|
+
data,
|
|
4324
|
+
element: args.element,
|
|
4325
|
+
dropEffect,
|
|
4326
|
+
// we are collecting _actual_ drop targets, so these are
|
|
4327
|
+
// being applied _not_ due to stickiness
|
|
4328
|
+
isActiveDueToStickiness: false
|
|
4329
|
+
};
|
|
4330
|
+
return getActualDropTargets({
|
|
4331
|
+
source,
|
|
4332
|
+
target: args.element.parentElement,
|
|
4333
|
+
input,
|
|
4334
|
+
// Using bubble ordering. Same ordering as `event.getPath()`
|
|
4335
|
+
result: [].concat(_toConsumableArray(result), [record])
|
|
4336
|
+
});
|
|
4337
|
+
}
|
|
4338
|
+
function notifyCurrent(_ref3) {
|
|
4339
|
+
var eventName = _ref3.eventName, payload = _ref3.payload;
|
|
4340
|
+
var _iterator = _createForOfIteratorHelper(payload.location.current.dropTargets), _step;
|
|
4341
|
+
try {
|
|
4342
|
+
for (_iterator.s(); !(_step = _iterator.n()).done; ) {
|
|
4343
|
+
var _entry$eventName;
|
|
4344
|
+
var record = _step.value;
|
|
4345
|
+
var entry = registry.get(record.element);
|
|
4346
|
+
var args = _objectSpread2(_objectSpread2({}, payload), {}, {
|
|
4347
|
+
self: record
|
|
4348
|
+
});
|
|
4349
|
+
entry === null || entry === void 0 || (_entry$eventName = entry[eventName]) === null || _entry$eventName === void 0 || _entry$eventName.call(
|
|
4350
|
+
entry,
|
|
4351
|
+
// I cannot seem to get the types right here.
|
|
4352
|
+
// TS doesn't seem to like that one event can need `nativeSetDragImage`
|
|
4353
|
+
// @ts-expect-error
|
|
4354
|
+
args
|
|
4355
|
+
);
|
|
4356
|
+
}
|
|
4357
|
+
} catch (err) {
|
|
4358
|
+
_iterator.e(err);
|
|
4359
|
+
} finally {
|
|
4360
|
+
_iterator.f();
|
|
4361
|
+
}
|
|
4362
|
+
}
|
|
4363
|
+
var actions = {
|
|
4364
|
+
onGenerateDragPreview: notifyCurrent,
|
|
4365
|
+
onDrag: notifyCurrent,
|
|
4366
|
+
onDragStart: notifyCurrent,
|
|
4367
|
+
onDrop: notifyCurrent,
|
|
4368
|
+
onDropTargetChange: function onDropTargetChange(_ref4) {
|
|
4369
|
+
var payload = _ref4.payload;
|
|
4370
|
+
var isCurrent = new Set(payload.location.current.dropTargets.map(function(record2) {
|
|
4371
|
+
return record2.element;
|
|
4372
|
+
}));
|
|
4373
|
+
var visited = /* @__PURE__ */ new Set();
|
|
4374
|
+
var _iterator2 = _createForOfIteratorHelper(payload.location.previous.dropTargets), _step2;
|
|
4375
|
+
try {
|
|
4376
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) {
|
|
4377
|
+
var _entry$onDropTargetCh;
|
|
4378
|
+
var record = _step2.value;
|
|
4379
|
+
visited.add(record.element);
|
|
4380
|
+
var entry = registry.get(record.element);
|
|
4381
|
+
var isOver = isCurrent.has(record.element);
|
|
4382
|
+
var args = _objectSpread2(_objectSpread2({}, payload), {}, {
|
|
4383
|
+
self: record
|
|
4384
|
+
});
|
|
4385
|
+
entry === null || entry === void 0 || (_entry$onDropTargetCh = entry.onDropTargetChange) === null || _entry$onDropTargetCh === void 0 || _entry$onDropTargetCh.call(entry, args);
|
|
4386
|
+
if (!isOver) {
|
|
4387
|
+
var _entry$onDragLeave;
|
|
4388
|
+
entry === null || entry === void 0 || (_entry$onDragLeave = entry.onDragLeave) === null || _entry$onDragLeave === void 0 || _entry$onDragLeave.call(entry, args);
|
|
4389
|
+
}
|
|
4390
|
+
}
|
|
4391
|
+
} catch (err) {
|
|
4392
|
+
_iterator2.e(err);
|
|
4393
|
+
} finally {
|
|
4394
|
+
_iterator2.f();
|
|
4395
|
+
}
|
|
4396
|
+
var _iterator3 = _createForOfIteratorHelper(payload.location.current.dropTargets), _step3;
|
|
4397
|
+
try {
|
|
4398
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done; ) {
|
|
4399
|
+
var _entry$onDropTargetCh2, _entry$onDragEnter;
|
|
4400
|
+
var _record = _step3.value;
|
|
4401
|
+
if (visited.has(_record.element)) {
|
|
4402
|
+
continue;
|
|
4403
|
+
}
|
|
4404
|
+
var _args = _objectSpread2(_objectSpread2({}, payload), {}, {
|
|
4405
|
+
self: _record
|
|
4406
|
+
});
|
|
4407
|
+
var _entry = registry.get(_record.element);
|
|
4408
|
+
_entry === null || _entry === void 0 || (_entry$onDropTargetCh2 = _entry.onDropTargetChange) === null || _entry$onDropTargetCh2 === void 0 || _entry$onDropTargetCh2.call(_entry, _args);
|
|
4409
|
+
_entry === null || _entry === void 0 || (_entry$onDragEnter = _entry.onDragEnter) === null || _entry$onDragEnter === void 0 || _entry$onDragEnter.call(_entry, _args);
|
|
4410
|
+
}
|
|
4411
|
+
} catch (err) {
|
|
4412
|
+
_iterator3.e(err);
|
|
4413
|
+
} finally {
|
|
4414
|
+
_iterator3.f();
|
|
4415
|
+
}
|
|
4416
|
+
}
|
|
4417
|
+
};
|
|
4418
|
+
function dispatchEvent(args) {
|
|
4419
|
+
actions[args.eventName](args);
|
|
4420
|
+
}
|
|
4421
|
+
function getIsOver(_ref5) {
|
|
4422
|
+
var source = _ref5.source, target = _ref5.target, input = _ref5.input, current = _ref5.current;
|
|
4423
|
+
var actual = getActualDropTargets({
|
|
4424
|
+
source,
|
|
4425
|
+
target,
|
|
4426
|
+
input
|
|
4427
|
+
});
|
|
4428
|
+
if (actual.length >= current.length) {
|
|
4429
|
+
return actual;
|
|
4430
|
+
}
|
|
4431
|
+
var lastCaptureOrdered = copyReverse(current);
|
|
4432
|
+
var actualCaptureOrdered = copyReverse(actual);
|
|
4433
|
+
var resultCaptureOrdered = [];
|
|
4434
|
+
for (var index = 0; index < lastCaptureOrdered.length; index++) {
|
|
4435
|
+
var _argsForLast$getIsSti;
|
|
4436
|
+
var last = lastCaptureOrdered[index];
|
|
4437
|
+
var fresh = actualCaptureOrdered[index];
|
|
4438
|
+
if (fresh != null) {
|
|
4439
|
+
resultCaptureOrdered.push(fresh);
|
|
4440
|
+
continue;
|
|
4441
|
+
}
|
|
4442
|
+
var parent = resultCaptureOrdered[index - 1];
|
|
4443
|
+
var lastParent = lastCaptureOrdered[index - 1];
|
|
4444
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.element) !== (lastParent === null || lastParent === void 0 ? void 0 : lastParent.element)) {
|
|
4445
|
+
break;
|
|
4446
|
+
}
|
|
4447
|
+
var argsForLast = registry.get(last.element);
|
|
4448
|
+
if (!argsForLast) {
|
|
4449
|
+
break;
|
|
4450
|
+
}
|
|
4451
|
+
var feedback = {
|
|
4452
|
+
input,
|
|
4453
|
+
source,
|
|
4454
|
+
element: argsForLast.element
|
|
4455
|
+
};
|
|
4456
|
+
if (argsForLast.canDrop && !argsForLast.canDrop(feedback)) {
|
|
4457
|
+
break;
|
|
4458
|
+
}
|
|
4459
|
+
if (!((_argsForLast$getIsSti = argsForLast.getIsSticky) !== null && _argsForLast$getIsSti !== void 0 && _argsForLast$getIsSti.call(argsForLast, feedback))) {
|
|
4460
|
+
break;
|
|
4461
|
+
}
|
|
4462
|
+
resultCaptureOrdered.push(_objectSpread2(_objectSpread2({}, last), {}, {
|
|
4463
|
+
// making it clear to consumers this drop target is active due to stickiness
|
|
4464
|
+
isActiveDueToStickiness: true
|
|
4465
|
+
}));
|
|
4466
|
+
}
|
|
4467
|
+
return copyReverse(resultCaptureOrdered);
|
|
4468
|
+
}
|
|
4469
|
+
return {
|
|
4470
|
+
dropTargetForConsumers,
|
|
4471
|
+
getIsOver,
|
|
4472
|
+
dispatchEvent
|
|
4473
|
+
};
|
|
4474
|
+
}
|
|
4475
|
+
|
|
4476
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/make-adapter/make-monitor.js
|
|
4477
|
+
function _createForOfIteratorHelper2(r, e) {
|
|
4478
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
4479
|
+
if (!t) {
|
|
4480
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray3(r)) || e && r && "number" == typeof r.length) {
|
|
4481
|
+
t && (r = t);
|
|
4482
|
+
var _n = 0, F = function F2() {
|
|
4483
|
+
};
|
|
4484
|
+
return { s: F, n: function n() {
|
|
4485
|
+
return _n >= r.length ? { done: true } : { done: false, value: r[_n++] };
|
|
4486
|
+
}, e: function e2(r2) {
|
|
4487
|
+
throw r2;
|
|
4488
|
+
}, f: F };
|
|
4489
|
+
}
|
|
4490
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4491
|
+
}
|
|
4492
|
+
var o, a = true, u = false;
|
|
4493
|
+
return { s: function s() {
|
|
4494
|
+
t = t.call(r);
|
|
4495
|
+
}, n: function n() {
|
|
4496
|
+
var r2 = t.next();
|
|
4497
|
+
return a = r2.done, r2;
|
|
4498
|
+
}, e: function e2(r2) {
|
|
4499
|
+
u = true, o = r2;
|
|
4500
|
+
}, f: function f() {
|
|
4501
|
+
try {
|
|
4502
|
+
a || null == t.return || t.return();
|
|
4503
|
+
} finally {
|
|
4504
|
+
if (u) throw o;
|
|
4505
|
+
}
|
|
4506
|
+
} };
|
|
4507
|
+
}
|
|
4508
|
+
function _unsupportedIterableToArray3(r, a) {
|
|
4509
|
+
if (r) {
|
|
4510
|
+
if ("string" == typeof r) return _arrayLikeToArray3(r, a);
|
|
4511
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
4512
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray3(r, a) : void 0;
|
|
4513
|
+
}
|
|
4514
|
+
}
|
|
4515
|
+
function _arrayLikeToArray3(r, a) {
|
|
4516
|
+
(null == a || a > r.length) && (a = r.length);
|
|
4517
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
4518
|
+
return n;
|
|
4519
|
+
}
|
|
4520
|
+
function ownKeys3(e, r) {
|
|
4521
|
+
var t = Object.keys(e);
|
|
4522
|
+
if (Object.getOwnPropertySymbols) {
|
|
4523
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
4524
|
+
r && (o = o.filter(function(r2) {
|
|
4525
|
+
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
4526
|
+
})), t.push.apply(t, o);
|
|
4527
|
+
}
|
|
4528
|
+
return t;
|
|
4529
|
+
}
|
|
4530
|
+
function _objectSpread3(e) {
|
|
4531
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
4532
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
4533
|
+
r % 2 ? ownKeys3(Object(t), true).forEach(function(r2) {
|
|
4534
|
+
_defineProperty(e, r2, t[r2]);
|
|
4535
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys3(Object(t)).forEach(function(r2) {
|
|
4536
|
+
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
4537
|
+
});
|
|
4538
|
+
}
|
|
4539
|
+
return e;
|
|
4540
|
+
}
|
|
4541
|
+
function makeMonitor() {
|
|
4542
|
+
var registry = /* @__PURE__ */ new Set();
|
|
4543
|
+
var dragging = null;
|
|
4544
|
+
function tryAddToActive(monitor) {
|
|
4545
|
+
if (!dragging) {
|
|
4546
|
+
return;
|
|
4547
|
+
}
|
|
4548
|
+
if (!monitor.canMonitor || monitor.canMonitor(dragging.canMonitorArgs)) {
|
|
4549
|
+
dragging.active.add(monitor);
|
|
4550
|
+
}
|
|
4551
|
+
}
|
|
4552
|
+
function monitorForConsumers(args) {
|
|
4553
|
+
var entry = _objectSpread3({}, args);
|
|
4554
|
+
registry.add(entry);
|
|
4555
|
+
tryAddToActive(entry);
|
|
4556
|
+
function cleanup() {
|
|
4557
|
+
registry.delete(entry);
|
|
4558
|
+
if (dragging) {
|
|
4559
|
+
dragging.active.delete(entry);
|
|
4560
|
+
}
|
|
4561
|
+
}
|
|
4562
|
+
return once(cleanup);
|
|
4563
|
+
}
|
|
4564
|
+
function dispatchEvent(_ref) {
|
|
4565
|
+
var eventName = _ref.eventName, payload = _ref.payload;
|
|
4566
|
+
if (eventName === "onGenerateDragPreview") {
|
|
4567
|
+
dragging = {
|
|
4568
|
+
canMonitorArgs: {
|
|
4569
|
+
initial: payload.location.initial,
|
|
4570
|
+
source: payload.source
|
|
4571
|
+
},
|
|
4572
|
+
active: /* @__PURE__ */ new Set()
|
|
4573
|
+
};
|
|
4574
|
+
var _iterator = _createForOfIteratorHelper2(registry), _step;
|
|
4575
|
+
try {
|
|
4576
|
+
for (_iterator.s(); !(_step = _iterator.n()).done; ) {
|
|
4577
|
+
var monitor = _step.value;
|
|
4578
|
+
tryAddToActive(monitor);
|
|
4579
|
+
}
|
|
4580
|
+
} catch (err) {
|
|
4581
|
+
_iterator.e(err);
|
|
4582
|
+
} finally {
|
|
4583
|
+
_iterator.f();
|
|
4584
|
+
}
|
|
4585
|
+
}
|
|
4586
|
+
if (!dragging) {
|
|
4587
|
+
return;
|
|
4588
|
+
}
|
|
4589
|
+
var active = Array.from(dragging.active);
|
|
4590
|
+
for (var _i = 0, _active = active; _i < _active.length; _i++) {
|
|
4591
|
+
var _monitor = _active[_i];
|
|
4592
|
+
if (dragging.active.has(_monitor)) {
|
|
4593
|
+
var _monitor$eventName;
|
|
4594
|
+
(_monitor$eventName = _monitor[eventName]) === null || _monitor$eventName === void 0 || _monitor$eventName.call(_monitor, payload);
|
|
4595
|
+
}
|
|
4596
|
+
}
|
|
4597
|
+
if (eventName === "onDrop") {
|
|
4598
|
+
dragging.active.clear();
|
|
4599
|
+
dragging = null;
|
|
4600
|
+
}
|
|
4601
|
+
}
|
|
4602
|
+
return {
|
|
4603
|
+
dispatchEvent,
|
|
4604
|
+
monitorForConsumers
|
|
4605
|
+
};
|
|
4606
|
+
}
|
|
4607
|
+
|
|
4608
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/make-adapter/make-adapter.js
|
|
4609
|
+
function makeAdapter(_ref) {
|
|
4610
|
+
var typeKey = _ref.typeKey, mount2 = _ref.mount, dispatchEventToSource2 = _ref.dispatchEventToSource, onPostDispatch = _ref.onPostDispatch, defaultDropEffect = _ref.defaultDropEffect;
|
|
4611
|
+
var monitorAPI = makeMonitor();
|
|
4612
|
+
var dropTargetAPI = makeDropTarget({
|
|
4613
|
+
typeKey,
|
|
4614
|
+
defaultDropEffect
|
|
4615
|
+
});
|
|
4616
|
+
function dispatchEvent(args) {
|
|
4617
|
+
dispatchEventToSource2 === null || dispatchEventToSource2 === void 0 || dispatchEventToSource2(args);
|
|
4618
|
+
dropTargetAPI.dispatchEvent(args);
|
|
4619
|
+
monitorAPI.dispatchEvent(args);
|
|
4620
|
+
onPostDispatch === null || onPostDispatch === void 0 || onPostDispatch(args);
|
|
4621
|
+
}
|
|
4622
|
+
function start2(_ref2) {
|
|
4623
|
+
var event = _ref2.event, dragType = _ref2.dragType;
|
|
4624
|
+
lifecycle.start({
|
|
4625
|
+
event,
|
|
4626
|
+
dragType,
|
|
4627
|
+
getDropTargetsOver: dropTargetAPI.getIsOver,
|
|
4628
|
+
dispatchEvent
|
|
4629
|
+
});
|
|
4630
|
+
}
|
|
4631
|
+
function registerUsage2() {
|
|
4632
|
+
function mountAdapter() {
|
|
4633
|
+
var api2 = {
|
|
4634
|
+
canStart: lifecycle.canStart,
|
|
4635
|
+
start: start2
|
|
4636
|
+
};
|
|
4637
|
+
return mount2(api2);
|
|
4638
|
+
}
|
|
4639
|
+
return register({
|
|
4640
|
+
typeKey,
|
|
4641
|
+
mount: mountAdapter
|
|
4642
|
+
});
|
|
4643
|
+
}
|
|
4644
|
+
return {
|
|
4645
|
+
registerUsage: registerUsage2,
|
|
4646
|
+
dropTarget: dropTargetAPI.dropTargetForConsumers,
|
|
4647
|
+
monitor: monitorAPI.monitorForConsumers
|
|
4648
|
+
};
|
|
4649
|
+
}
|
|
4650
|
+
|
|
4651
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/android.js
|
|
4652
|
+
var isAndroid = once(function isAndroid2() {
|
|
4653
|
+
return navigator.userAgent.toLocaleLowerCase().includes("android");
|
|
4654
|
+
});
|
|
4655
|
+
var androidFallbackText = "pdnd:android-fallback";
|
|
4656
|
+
|
|
4657
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/media-types/text-media-type.js
|
|
4658
|
+
var textMediaType = "text/plain";
|
|
4659
|
+
|
|
4660
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/util/media-types/url-media-type.js
|
|
4661
|
+
var URLMediaType = "text/uri-list";
|
|
4662
|
+
|
|
4663
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/adapter/element-adapter-native-data-key.js
|
|
4664
|
+
var elementAdapterNativeDataKey = "application/vnd.pdnd";
|
|
4665
|
+
|
|
4666
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop/dist/esm/adapter/element-adapter.js
|
|
4667
|
+
var draggableRegistry = /* @__PURE__ */ new WeakMap();
|
|
4668
|
+
function addToRegistry(args) {
|
|
4669
|
+
draggableRegistry.set(args.element, args);
|
|
4670
|
+
return function cleanup() {
|
|
4671
|
+
draggableRegistry.delete(args.element);
|
|
4672
|
+
};
|
|
4673
|
+
}
|
|
4674
|
+
var honeyPotFix = makeHoneyPotFix();
|
|
4675
|
+
var adapter = makeAdapter({
|
|
4676
|
+
typeKey: "element",
|
|
4677
|
+
defaultDropEffect: "move",
|
|
4678
|
+
mount: function mount(api2) {
|
|
4679
|
+
return combine(honeyPotFix.bindEvents(), (0, import_bind_event_listener4.bind)(document, {
|
|
4680
|
+
type: "dragstart",
|
|
4681
|
+
listener: function listener(event) {
|
|
4682
|
+
var _entry$dragHandle, _entry$getInitialData, _entry$getInitialData2, _entry$dragHandle2, _entry$getInitialData3, _entry$getInitialData4;
|
|
4683
|
+
if (!api2.canStart(event)) {
|
|
4684
|
+
return;
|
|
4685
|
+
}
|
|
4686
|
+
if (event.defaultPrevented) {
|
|
4687
|
+
return;
|
|
4688
|
+
}
|
|
4689
|
+
if (!event.dataTransfer) {
|
|
4690
|
+
if (true) {
|
|
4691
|
+
console.warn("\n It appears as though you have are not testing DragEvents correctly.\n\n - If you are unit testing, ensure you have polyfilled DragEvent.\n - If you are browser testing, ensure you are dispatching drag events correctly.\n\n Please see our testing guides for more information:\n https://atlassian.design/components/pragmatic-drag-and-drop/core-package/testing\n ".replace(/ {2}/g, ""));
|
|
4692
|
+
}
|
|
4693
|
+
return;
|
|
4694
|
+
}
|
|
4695
|
+
var target = event.target;
|
|
4696
|
+
if (!(target instanceof HTMLElement)) {
|
|
4697
|
+
return;
|
|
4698
|
+
}
|
|
4699
|
+
var entry = draggableRegistry.get(target);
|
|
4700
|
+
if (!entry) {
|
|
4701
|
+
return;
|
|
4702
|
+
}
|
|
4703
|
+
var input = getInput(event);
|
|
4704
|
+
var feedback = {
|
|
4705
|
+
element: entry.element,
|
|
4706
|
+
dragHandle: (_entry$dragHandle = entry.dragHandle) !== null && _entry$dragHandle !== void 0 ? _entry$dragHandle : null,
|
|
4707
|
+
input
|
|
4708
|
+
};
|
|
4709
|
+
if (entry.canDrag && !entry.canDrag(feedback)) {
|
|
4710
|
+
event.preventDefault();
|
|
4711
|
+
return;
|
|
4712
|
+
}
|
|
4713
|
+
if (entry.dragHandle) {
|
|
4714
|
+
var over = getElementFromPointWithoutHoneypot({
|
|
4715
|
+
x: input.clientX,
|
|
4716
|
+
y: input.clientY
|
|
4717
|
+
});
|
|
4718
|
+
if (!entry.dragHandle.contains(over)) {
|
|
4719
|
+
event.preventDefault();
|
|
4720
|
+
return;
|
|
4721
|
+
}
|
|
4722
|
+
}
|
|
4723
|
+
var nativeData = (_entry$getInitialData = (_entry$getInitialData2 = entry.getInitialDataForExternal) === null || _entry$getInitialData2 === void 0 ? void 0 : _entry$getInitialData2.call(entry, feedback)) !== null && _entry$getInitialData !== void 0 ? _entry$getInitialData : null;
|
|
4724
|
+
if (nativeData) {
|
|
4725
|
+
for (var _i = 0, _Object$entries = Object.entries(nativeData); _i < _Object$entries.length; _i++) {
|
|
4726
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), key = _Object$entries$_i[0], data = _Object$entries$_i[1];
|
|
4727
|
+
event.dataTransfer.setData(key, data !== null && data !== void 0 ? data : "");
|
|
4728
|
+
}
|
|
4729
|
+
}
|
|
4730
|
+
if (isAndroid() && !event.dataTransfer.types.includes(textMediaType) && !event.dataTransfer.types.includes(URLMediaType)) {
|
|
4731
|
+
event.dataTransfer.setData(textMediaType, androidFallbackText);
|
|
4732
|
+
}
|
|
4733
|
+
event.dataTransfer.setData(elementAdapterNativeDataKey, "");
|
|
4734
|
+
var payload = {
|
|
4735
|
+
element: entry.element,
|
|
4736
|
+
dragHandle: (_entry$dragHandle2 = entry.dragHandle) !== null && _entry$dragHandle2 !== void 0 ? _entry$dragHandle2 : null,
|
|
4737
|
+
data: (_entry$getInitialData3 = (_entry$getInitialData4 = entry.getInitialData) === null || _entry$getInitialData4 === void 0 ? void 0 : _entry$getInitialData4.call(entry, feedback)) !== null && _entry$getInitialData3 !== void 0 ? _entry$getInitialData3 : {}
|
|
4738
|
+
};
|
|
4739
|
+
var dragType = {
|
|
4740
|
+
type: "element",
|
|
4741
|
+
payload,
|
|
4742
|
+
startedFrom: "internal"
|
|
4743
|
+
};
|
|
4744
|
+
api2.start({
|
|
4745
|
+
event,
|
|
4746
|
+
dragType
|
|
4747
|
+
});
|
|
4748
|
+
}
|
|
4749
|
+
}));
|
|
4750
|
+
},
|
|
4751
|
+
dispatchEventToSource: function dispatchEventToSource(_ref) {
|
|
4752
|
+
var _draggableRegistry$ge, _draggableRegistry$ge2;
|
|
4753
|
+
var eventName = _ref.eventName, payload = _ref.payload;
|
|
4754
|
+
(_draggableRegistry$ge = draggableRegistry.get(payload.source.element)) === null || _draggableRegistry$ge === void 0 || (_draggableRegistry$ge2 = _draggableRegistry$ge[eventName]) === null || _draggableRegistry$ge2 === void 0 || _draggableRegistry$ge2.call(
|
|
4755
|
+
_draggableRegistry$ge,
|
|
4756
|
+
// I cannot seem to get the types right here.
|
|
4757
|
+
// TS doesn't seem to like that one event can need `nativeSetDragImage`
|
|
4758
|
+
// @ts-expect-error
|
|
4759
|
+
payload
|
|
4760
|
+
);
|
|
4761
|
+
},
|
|
4762
|
+
onPostDispatch: honeyPotFix.getOnPostDispatch()
|
|
4763
|
+
});
|
|
4764
|
+
var dropTargetForElements = adapter.dropTarget;
|
|
4765
|
+
var monitorForElements = adapter.monitor;
|
|
4766
|
+
function draggable(args) {
|
|
4767
|
+
if (true) {
|
|
4768
|
+
if (args.dragHandle && !args.element.contains(args.dragHandle)) {
|
|
4769
|
+
console.warn("Drag handle element must be contained in draggable element", {
|
|
4770
|
+
element: args.element,
|
|
4771
|
+
dragHandle: args.dragHandle
|
|
4772
|
+
});
|
|
4773
|
+
}
|
|
4774
|
+
}
|
|
4775
|
+
if (true) {
|
|
4776
|
+
var existing = draggableRegistry.get(args.element);
|
|
4777
|
+
if (existing) {
|
|
4778
|
+
console.warn("You have already registered a `draggable` on the same element", {
|
|
4779
|
+
existing,
|
|
4780
|
+
proposed: args
|
|
4781
|
+
});
|
|
4782
|
+
}
|
|
4783
|
+
}
|
|
4784
|
+
var cleanup = combine(
|
|
4785
|
+
// making the draggable register the adapter rather than drop targets
|
|
4786
|
+
// this is because you *must* have a draggable element to start a drag
|
|
4787
|
+
// but you _might_ not have any drop targets immediately
|
|
4788
|
+
// (You might create drop targets async)
|
|
4789
|
+
adapter.registerUsage(),
|
|
4790
|
+
addToRegistry(args),
|
|
4791
|
+
addAttribute(args.element, {
|
|
4792
|
+
attribute: "draggable",
|
|
4793
|
+
value: "true"
|
|
4794
|
+
})
|
|
4795
|
+
);
|
|
4796
|
+
return once(cleanup);
|
|
4797
|
+
}
|
|
4798
|
+
|
|
4799
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/engagement-history.js
|
|
4800
|
+
var ledger2 = /* @__PURE__ */ new Map();
|
|
4801
|
+
var requested = /* @__PURE__ */ new Set();
|
|
4802
|
+
function markAndGetEngagement(element) {
|
|
4803
|
+
markEngagement(element);
|
|
4804
|
+
var entry = ledger2.get(element);
|
|
4805
|
+
if (entry) {
|
|
4806
|
+
return entry;
|
|
4807
|
+
}
|
|
4808
|
+
var fresh = {
|
|
4809
|
+
timeOfEngagementStart: Date.now()
|
|
4810
|
+
};
|
|
4811
|
+
ledger2.set(element, fresh);
|
|
4812
|
+
return fresh;
|
|
4813
|
+
}
|
|
4814
|
+
function markEngagement(element) {
|
|
4815
|
+
requested.add(element);
|
|
4816
|
+
}
|
|
4817
|
+
function clearUnusedEngagements(fn) {
|
|
4818
|
+
requested.clear();
|
|
4819
|
+
fn();
|
|
4820
|
+
ledger2.forEach(function(_, element) {
|
|
4821
|
+
if (!requested.has(element)) {
|
|
4822
|
+
ledger2.delete(element);
|
|
4823
|
+
}
|
|
4824
|
+
});
|
|
4825
|
+
requested.clear();
|
|
4826
|
+
}
|
|
4827
|
+
function clearEngagementHistory() {
|
|
4828
|
+
ledger2.clear();
|
|
4829
|
+
}
|
|
4830
|
+
|
|
4831
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/scheduler.js
|
|
4832
|
+
var schedulers = /* @__PURE__ */ new Map();
|
|
4833
|
+
function getScheduler(monitor) {
|
|
4834
|
+
var scheduler = schedulers.get(monitor);
|
|
4835
|
+
if (scheduler) {
|
|
4836
|
+
return scheduler;
|
|
4837
|
+
}
|
|
4838
|
+
var created = makeScheduler(monitor);
|
|
4839
|
+
schedulers.set(monitor, created);
|
|
4840
|
+
return created;
|
|
4841
|
+
}
|
|
4842
|
+
function makeScheduler(monitor) {
|
|
4843
|
+
var state = {
|
|
4844
|
+
type: "idle"
|
|
4845
|
+
};
|
|
4846
|
+
var callbacks = [];
|
|
4847
|
+
function loop(timeLastFrameFinished) {
|
|
4848
|
+
if (state.type !== "running") {
|
|
4849
|
+
return;
|
|
4850
|
+
}
|
|
4851
|
+
var timeSinceLastFrame = timeLastFrameFinished - state.timeLastFrameFinished;
|
|
4852
|
+
var _state = state, latestArgs = _state.latestArgs;
|
|
4853
|
+
var underUsersPointer = getElementFromPointWithoutHoneypot({
|
|
4854
|
+
x: latestArgs.location.current.input.clientX,
|
|
4855
|
+
y: latestArgs.location.current.input.clientY
|
|
4856
|
+
});
|
|
4857
|
+
clearUnusedEngagements(function() {
|
|
4858
|
+
callbacks.forEach(function(onFrame) {
|
|
4859
|
+
return onFrame({
|
|
4860
|
+
underUsersPointer,
|
|
4861
|
+
latestArgs,
|
|
4862
|
+
timeSinceLastFrame
|
|
4863
|
+
});
|
|
4864
|
+
});
|
|
4865
|
+
});
|
|
4866
|
+
state.timeLastFrameFinished = timeLastFrameFinished;
|
|
4867
|
+
state.frameId = requestAnimationFrame(loop);
|
|
4868
|
+
}
|
|
4869
|
+
function reset() {
|
|
4870
|
+
if (state.type === "idle") {
|
|
4871
|
+
return;
|
|
4872
|
+
}
|
|
4873
|
+
cancelAnimationFrame(state.frameId);
|
|
4874
|
+
clearEngagementHistory();
|
|
4875
|
+
state = {
|
|
4876
|
+
type: "idle"
|
|
4877
|
+
};
|
|
4878
|
+
}
|
|
4879
|
+
function start2(args) {
|
|
4880
|
+
if (state.type !== "idle") {
|
|
4881
|
+
return;
|
|
4882
|
+
}
|
|
4883
|
+
state = {
|
|
4884
|
+
// Waiting a frame so we can accurately determine `timeSinceLastFrame`.
|
|
4885
|
+
type: "initializing",
|
|
4886
|
+
latestArgs: args,
|
|
4887
|
+
frameId: requestAnimationFrame(function(timeLastFrameFinished) {
|
|
4888
|
+
if (state.type !== "initializing") {
|
|
4889
|
+
return;
|
|
4890
|
+
}
|
|
4891
|
+
state = {
|
|
4892
|
+
type: "running",
|
|
4893
|
+
timeLastFrameFinished,
|
|
4894
|
+
latestArgs: state.latestArgs,
|
|
4895
|
+
frameId: requestAnimationFrame(loop)
|
|
4896
|
+
};
|
|
4897
|
+
})
|
|
4898
|
+
};
|
|
4899
|
+
}
|
|
4900
|
+
function update(args) {
|
|
4901
|
+
if (state.type === "idle") {
|
|
4902
|
+
start2(args);
|
|
4903
|
+
return;
|
|
4904
|
+
}
|
|
4905
|
+
state.latestArgs = args;
|
|
4906
|
+
}
|
|
4907
|
+
monitor({
|
|
4908
|
+
onDragStart: start2,
|
|
4909
|
+
onDropTargetChange: update,
|
|
4910
|
+
onDrag: update,
|
|
4911
|
+
onDrop: reset
|
|
4912
|
+
});
|
|
4913
|
+
var api2 = {
|
|
4914
|
+
onFrame: function onFrame(fn) {
|
|
4915
|
+
callbacks.push(fn);
|
|
4916
|
+
}
|
|
4917
|
+
};
|
|
4918
|
+
return api2;
|
|
4919
|
+
}
|
|
4920
|
+
|
|
4921
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/over-element/data-attributes.js
|
|
4922
|
+
var dataAttribute = "data-auto-scrollable";
|
|
4923
|
+
var selector = "[".concat(dataAttribute, '="true"]');
|
|
4924
|
+
function addScrollableAttribute(element) {
|
|
4925
|
+
element.setAttribute(dataAttribute, "true");
|
|
4926
|
+
return function() {
|
|
4927
|
+
return element.removeAttribute(dataAttribute);
|
|
4928
|
+
};
|
|
4929
|
+
}
|
|
4930
|
+
|
|
4931
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/configuration.js
|
|
4932
|
+
function ownKeys4(e, r) {
|
|
4933
|
+
var t = Object.keys(e);
|
|
4934
|
+
if (Object.getOwnPropertySymbols) {
|
|
4935
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
4936
|
+
r && (o = o.filter(function(r2) {
|
|
4937
|
+
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
4938
|
+
})), t.push.apply(t, o);
|
|
4939
|
+
}
|
|
4940
|
+
return t;
|
|
4941
|
+
}
|
|
4942
|
+
function _objectSpread4(e) {
|
|
4943
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
4944
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
4945
|
+
r % 2 ? ownKeys4(Object(t), true).forEach(function(r2) {
|
|
4946
|
+
_defineProperty(e, r2, t[r2]);
|
|
4947
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys4(Object(t)).forEach(function(r2) {
|
|
4948
|
+
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
4949
|
+
});
|
|
4950
|
+
}
|
|
4951
|
+
return e;
|
|
4952
|
+
}
|
|
4953
|
+
var baseConfig = {
|
|
4954
|
+
startHitboxAtPercentageRemainingOfElement: {
|
|
4955
|
+
top: 0.25,
|
|
4956
|
+
right: 0.25,
|
|
4957
|
+
bottom: 0.25,
|
|
4958
|
+
left: 0.25
|
|
4959
|
+
},
|
|
4960
|
+
maxScrollAtPercentageRemainingOfHitbox: {
|
|
4961
|
+
top: 0.5,
|
|
4962
|
+
right: 0.5,
|
|
4963
|
+
bottom: 0.5,
|
|
4964
|
+
left: 0.5
|
|
4965
|
+
},
|
|
4966
|
+
timeDampeningDurationMs: 400,
|
|
4967
|
+
// Too big and it's too easy to trigger auto scrolling
|
|
4968
|
+
// Too small and it's too hard 😅
|
|
4969
|
+
maxMainAxisHitboxSize: 180
|
|
4970
|
+
};
|
|
4971
|
+
var maxPixelScrollPerSecond = {
|
|
4972
|
+
// What the value would be if we were scrolling at 15px per frame at 60fps.
|
|
4973
|
+
// This is the default as it works well for most experiences.
|
|
4974
|
+
// In certain scenarios though it can feel a bit slow.
|
|
4975
|
+
standard: 15 * 60,
|
|
4976
|
+
// What the value would be if we were scrolling at 25px per frame at 60fps.
|
|
4977
|
+
// This is not the default as it feels too fast for a lot of experiences.
|
|
4978
|
+
fast: 25 * 60
|
|
4979
|
+
};
|
|
4980
|
+
function getInternalConfig(provided) {
|
|
4981
|
+
var _provided$maxScrollSp;
|
|
4982
|
+
return _objectSpread4(_objectSpread4({}, baseConfig), {}, {
|
|
4983
|
+
// only allowing limited control over the config at this stage
|
|
4984
|
+
maxPixelScrollPerSecond: maxPixelScrollPerSecond[(_provided$maxScrollSp = provided === null || provided === void 0 ? void 0 : provided.maxScrollSpeed) !== null && _provided$maxScrollSp !== void 0 ? _provided$maxScrollSp : "standard"]
|
|
4985
|
+
});
|
|
4986
|
+
}
|
|
4987
|
+
|
|
4988
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/can-scroll-on-edge.js
|
|
4989
|
+
var canScrollOnEdge = {
|
|
4990
|
+
// Notes:
|
|
4991
|
+
//
|
|
4992
|
+
// 🌏 Chrome 115.0: uses fractional units for `scrollLeft` and `scrollTop`
|
|
4993
|
+
// (and fractional units don't reach true integer maximum when zoomed in / out)
|
|
4994
|
+
// 🍎 Safari 16.5.2: no fractional units
|
|
4995
|
+
// 🦊 Firefox 115.0: no fractional units
|
|
4996
|
+
// we have some scroll we can move backwards into
|
|
4997
|
+
top: function top(element) {
|
|
4998
|
+
return element.scrollTop > 0;
|
|
4999
|
+
},
|
|
5000
|
+
// We have some scroll we can move forward into
|
|
5001
|
+
right: function right(element) {
|
|
5002
|
+
return Math.ceil(element.scrollLeft) + element.clientWidth < element.scrollWidth;
|
|
5003
|
+
},
|
|
5004
|
+
// We have some scroll we can move forwards into
|
|
5005
|
+
bottom: function bottom(element) {
|
|
5006
|
+
return Math.ceil(element.scrollTop) + element.clientHeight < element.scrollHeight;
|
|
5007
|
+
},
|
|
5008
|
+
// we have some scroll we can move back into.
|
|
5009
|
+
left: function left(element) {
|
|
5010
|
+
return element.scrollLeft > 0;
|
|
5011
|
+
}
|
|
5012
|
+
};
|
|
5013
|
+
|
|
5014
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/edges.js
|
|
5015
|
+
var edges = ["top", "right", "bottom", "left"];
|
|
5016
|
+
var edgeAxisLookup = {
|
|
5017
|
+
top: "vertical",
|
|
5018
|
+
right: "horizontal",
|
|
5019
|
+
bottom: "vertical",
|
|
5020
|
+
left: "horizontal"
|
|
5021
|
+
};
|
|
5022
|
+
|
|
5023
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/axis.js
|
|
5024
|
+
var vertical = {
|
|
5025
|
+
start: "top",
|
|
5026
|
+
end: "bottom",
|
|
5027
|
+
point: "y",
|
|
5028
|
+
size: "height"
|
|
5029
|
+
};
|
|
5030
|
+
var horizontal = {
|
|
5031
|
+
start: "left",
|
|
5032
|
+
end: "right",
|
|
5033
|
+
point: "x",
|
|
5034
|
+
size: "width"
|
|
5035
|
+
};
|
|
5036
|
+
var axisLookup = {
|
|
5037
|
+
vertical: {
|
|
5038
|
+
mainAxis: vertical,
|
|
5039
|
+
crossAxis: horizontal
|
|
5040
|
+
},
|
|
5041
|
+
horizontal: {
|
|
5042
|
+
mainAxis: horizontal,
|
|
5043
|
+
crossAxis: vertical
|
|
5044
|
+
}
|
|
5045
|
+
};
|
|
5046
|
+
|
|
5047
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/side.js
|
|
5048
|
+
var mainAxisSideLookup = {
|
|
5049
|
+
top: "start",
|
|
5050
|
+
right: "end",
|
|
5051
|
+
bottom: "end",
|
|
5052
|
+
left: "start"
|
|
5053
|
+
};
|
|
5054
|
+
|
|
5055
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/get-over-element-hitbox.js
|
|
5056
|
+
function makeGetHitbox(_ref) {
|
|
5057
|
+
var edge = _ref.edge, axis = _ref.axis;
|
|
5058
|
+
return function hitbox(_ref2) {
|
|
5059
|
+
var clientRect = _ref2.clientRect, config = _ref2.config;
|
|
5060
|
+
var _axisLookup$axis = axisLookup[axis], mainAxis = _axisLookup$axis.mainAxis, crossAxis = _axisLookup$axis.crossAxis;
|
|
5061
|
+
var side = mainAxisSideLookup[edge];
|
|
5062
|
+
var mainAxisHitboxSize = Math.min(
|
|
5063
|
+
// scale the size of the hitbox down for smaller elements
|
|
5064
|
+
config.startHitboxAtPercentageRemainingOfElement[edge] * clientRect[mainAxis.size],
|
|
5065
|
+
// Don't let the hitbox grow too big for big elements
|
|
5066
|
+
config.maxMainAxisHitboxSize
|
|
5067
|
+
);
|
|
5068
|
+
return DOMRect.fromRect(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, mainAxis.point, side === "start" ? (
|
|
5069
|
+
// begin from the start edge and grow inwards
|
|
5070
|
+
clientRect[mainAxis.point]
|
|
5071
|
+
) : (
|
|
5072
|
+
// begin from inside the end edge and grow towards the end edge
|
|
5073
|
+
clientRect[mainAxis.point] + clientRect[mainAxis.size] - mainAxisHitboxSize
|
|
5074
|
+
)), crossAxis.point, clientRect[crossAxis.point]), mainAxis.size, mainAxisHitboxSize), crossAxis.size, clientRect[crossAxis.size]));
|
|
5075
|
+
};
|
|
5076
|
+
}
|
|
5077
|
+
var getOverElementHitbox = {
|
|
5078
|
+
top: makeGetHitbox({
|
|
5079
|
+
axis: "vertical",
|
|
5080
|
+
edge: "top"
|
|
5081
|
+
}),
|
|
5082
|
+
right: makeGetHitbox({
|
|
5083
|
+
axis: "horizontal",
|
|
5084
|
+
edge: "right"
|
|
5085
|
+
}),
|
|
5086
|
+
bottom: makeGetHitbox({
|
|
5087
|
+
axis: "vertical",
|
|
5088
|
+
edge: "bottom"
|
|
5089
|
+
}),
|
|
5090
|
+
left: makeGetHitbox({
|
|
5091
|
+
axis: "horizontal",
|
|
5092
|
+
edge: "left"
|
|
5093
|
+
})
|
|
5094
|
+
};
|
|
5095
|
+
|
|
5096
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/get-percentage-in-range.js
|
|
5097
|
+
function getPercentageInRange(_ref) {
|
|
5098
|
+
var startOfRange = _ref.startOfRange, endOfRange = _ref.endOfRange, value = _ref.value;
|
|
5099
|
+
var isValid = startOfRange < endOfRange;
|
|
5100
|
+
if (!isValid) {
|
|
5101
|
+
return 0;
|
|
5102
|
+
}
|
|
5103
|
+
if (value < startOfRange) {
|
|
5104
|
+
return 0;
|
|
5105
|
+
}
|
|
5106
|
+
if (value > endOfRange) {
|
|
5107
|
+
return 1;
|
|
5108
|
+
}
|
|
5109
|
+
var range = endOfRange - startOfRange;
|
|
5110
|
+
return (value - startOfRange) / range;
|
|
5111
|
+
}
|
|
5112
|
+
|
|
5113
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/get-scroll-change.js
|
|
5114
|
+
function getMaxScrollChange(_ref) {
|
|
5115
|
+
var timeSinceLastFrame = _ref.timeSinceLastFrame, config = _ref.config;
|
|
5116
|
+
var targetScrollPerMs = config.maxPixelScrollPerSecond / 1e3;
|
|
5117
|
+
var proposed = Math.ceil(targetScrollPerMs * timeSinceLastFrame);
|
|
5118
|
+
var maximum = config.maxPixelScrollPerSecond / 60;
|
|
5119
|
+
return Math.min(proposed, maximum);
|
|
5120
|
+
}
|
|
5121
|
+
function getDistanceDampening(_ref2) {
|
|
5122
|
+
var client = _ref2.client, axis = _ref2.axis, edge = _ref2.edge, hitbox = _ref2.hitbox, config = _ref2.config;
|
|
5123
|
+
var mainAxis = axisLookup[axis].mainAxis;
|
|
5124
|
+
var side = mainAxisSideLookup[edge];
|
|
5125
|
+
var maxSpeedBuffer = hitbox[mainAxis.size] * config.maxScrollAtPercentageRemainingOfHitbox[edge];
|
|
5126
|
+
if (side === "end") {
|
|
5127
|
+
return getPercentageInRange({
|
|
5128
|
+
startOfRange: hitbox[mainAxis.start],
|
|
5129
|
+
endOfRange: hitbox[mainAxis.end] - maxSpeedBuffer,
|
|
5130
|
+
value: client[mainAxis.point]
|
|
5131
|
+
});
|
|
5132
|
+
}
|
|
5133
|
+
var raw = getPercentageInRange({
|
|
5134
|
+
startOfRange: hitbox[mainAxis.start] + maxSpeedBuffer,
|
|
5135
|
+
endOfRange: hitbox[mainAxis.end],
|
|
5136
|
+
value: client[mainAxis.point]
|
|
5137
|
+
});
|
|
5138
|
+
return 1 - raw;
|
|
5139
|
+
}
|
|
5140
|
+
function getScrollChange(_ref3) {
|
|
5141
|
+
var client = _ref3.client, timeSinceLastFrame = _ref3.timeSinceLastFrame, engagement = _ref3.engagement, axis = _ref3.axis, hitbox = _ref3.hitbox, edge = _ref3.edge, isDistanceDampeningEnabled = _ref3.isDistanceDampeningEnabled, config = _ref3.config;
|
|
5142
|
+
var maxScroll = getMaxScrollChange({
|
|
5143
|
+
timeSinceLastFrame,
|
|
5144
|
+
config
|
|
5145
|
+
});
|
|
5146
|
+
var percentageDistanceDampening = isDistanceDampeningEnabled ? getDistanceDampening({
|
|
5147
|
+
client,
|
|
5148
|
+
edge,
|
|
5149
|
+
hitbox,
|
|
5150
|
+
axis,
|
|
5151
|
+
config
|
|
5152
|
+
}) : 1;
|
|
5153
|
+
var percentageThroughTimeDampening = getPercentageInRange({
|
|
5154
|
+
startOfRange: engagement.timeOfEngagementStart,
|
|
5155
|
+
endOfRange: engagement.timeOfEngagementStart + config.timeDampeningDurationMs,
|
|
5156
|
+
value: Date.now()
|
|
5157
|
+
});
|
|
5158
|
+
var percentageOfMaxScroll = percentageDistanceDampening * percentageThroughTimeDampening;
|
|
5159
|
+
var scroll = Math.max(maxScroll * percentageOfMaxScroll, 1);
|
|
5160
|
+
var side = mainAxisSideLookup[edge];
|
|
5161
|
+
return side === "end" ? scroll : -1 * scroll;
|
|
5162
|
+
}
|
|
5163
|
+
|
|
5164
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/is-axis-allowed.js
|
|
5165
|
+
function isAxisAllowed(axis, allowedAxis) {
|
|
5166
|
+
return allowedAxis === "all" || axis === allowedAxis;
|
|
5167
|
+
}
|
|
5168
|
+
|
|
5169
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/shared/is-within.js
|
|
5170
|
+
function isWithin2(_ref) {
|
|
5171
|
+
var client = _ref.client, clientRect = _ref.clientRect;
|
|
5172
|
+
return (
|
|
5173
|
+
// is within horizontal bounds
|
|
5174
|
+
client.x >= clientRect.x && client.x <= clientRect.x + clientRect.width && // is within vertical bounds
|
|
5175
|
+
client.y >= clientRect.y && client.y <= clientRect.y + clientRect.height
|
|
5176
|
+
);
|
|
5177
|
+
}
|
|
5178
|
+
|
|
5179
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/over-element/get-scroll-by.js
|
|
5180
|
+
function getRectDefault(element) {
|
|
5181
|
+
return element.getBoundingClientRect();
|
|
5182
|
+
}
|
|
5183
|
+
function getScrollBy(_ref) {
|
|
5184
|
+
var element = _ref.element, input = _ref.input, timeSinceLastFrame = _ref.timeSinceLastFrame, engagement = _ref.engagement, config = _ref.config, allowedAxis = _ref.allowedAxis, _ref$getRect = _ref.getRect, getRect = _ref$getRect === void 0 ? getRectDefault : _ref$getRect;
|
|
5185
|
+
var client = {
|
|
5186
|
+
x: input.clientX,
|
|
5187
|
+
y: input.clientY
|
|
5188
|
+
};
|
|
5189
|
+
var clientRect = getRect(element);
|
|
5190
|
+
var scrollableEdges = edges.reduce(function(map, edge) {
|
|
5191
|
+
var hitbox = getOverElementHitbox[edge]({
|
|
5192
|
+
clientRect,
|
|
5193
|
+
config
|
|
5194
|
+
});
|
|
5195
|
+
var axis = edgeAxisLookup[edge];
|
|
5196
|
+
if (!isAxisAllowed(axis, allowedAxis)) {
|
|
5197
|
+
return map;
|
|
5198
|
+
}
|
|
5199
|
+
if (!isWithin2({
|
|
5200
|
+
client,
|
|
5201
|
+
clientRect: hitbox
|
|
5202
|
+
})) {
|
|
5203
|
+
return map;
|
|
5204
|
+
}
|
|
5205
|
+
if (!canScrollOnEdge[edge](element)) {
|
|
5206
|
+
return map;
|
|
5207
|
+
}
|
|
5208
|
+
map.set(edge, {
|
|
5209
|
+
edge,
|
|
5210
|
+
hitbox
|
|
5211
|
+
});
|
|
5212
|
+
return map;
|
|
5213
|
+
}, /* @__PURE__ */ new Map());
|
|
5214
|
+
var left2 = (function() {
|
|
5215
|
+
var axis = "horizontal";
|
|
5216
|
+
var leftEdge = scrollableEdges.get("left");
|
|
5217
|
+
if (leftEdge) {
|
|
5218
|
+
return getScrollChange({
|
|
5219
|
+
client,
|
|
5220
|
+
edge: leftEdge.edge,
|
|
5221
|
+
hitbox: leftEdge.hitbox,
|
|
5222
|
+
axis,
|
|
5223
|
+
timeSinceLastFrame,
|
|
5224
|
+
engagement,
|
|
5225
|
+
isDistanceDampeningEnabled: true,
|
|
5226
|
+
config
|
|
5227
|
+
});
|
|
5228
|
+
}
|
|
5229
|
+
var rightEdge = scrollableEdges.get("right");
|
|
5230
|
+
if (rightEdge) {
|
|
5231
|
+
return getScrollChange({
|
|
5232
|
+
client,
|
|
5233
|
+
edge: rightEdge.edge,
|
|
5234
|
+
hitbox: rightEdge.hitbox,
|
|
5235
|
+
axis,
|
|
5236
|
+
timeSinceLastFrame,
|
|
5237
|
+
engagement,
|
|
5238
|
+
isDistanceDampeningEnabled: true,
|
|
5239
|
+
config
|
|
5240
|
+
});
|
|
5241
|
+
}
|
|
5242
|
+
return 0;
|
|
5243
|
+
})();
|
|
5244
|
+
var top2 = (function() {
|
|
5245
|
+
var axis = "vertical";
|
|
5246
|
+
var bottomEdge = scrollableEdges.get("bottom");
|
|
5247
|
+
if (bottomEdge) {
|
|
5248
|
+
return getScrollChange({
|
|
5249
|
+
client,
|
|
5250
|
+
edge: bottomEdge.edge,
|
|
5251
|
+
hitbox: bottomEdge.hitbox,
|
|
5252
|
+
axis,
|
|
5253
|
+
timeSinceLastFrame,
|
|
5254
|
+
engagement,
|
|
5255
|
+
isDistanceDampeningEnabled: true,
|
|
5256
|
+
config
|
|
5257
|
+
});
|
|
5258
|
+
}
|
|
5259
|
+
var topEdge = scrollableEdges.get("top");
|
|
5260
|
+
if (topEdge) {
|
|
5261
|
+
return getScrollChange({
|
|
5262
|
+
client,
|
|
5263
|
+
edge: topEdge.edge,
|
|
5264
|
+
hitbox: topEdge.hitbox,
|
|
5265
|
+
axis,
|
|
5266
|
+
timeSinceLastFrame,
|
|
5267
|
+
engagement,
|
|
5268
|
+
isDistanceDampeningEnabled: true,
|
|
5269
|
+
config
|
|
5270
|
+
});
|
|
5271
|
+
}
|
|
5272
|
+
return 0;
|
|
5273
|
+
})();
|
|
5274
|
+
return {
|
|
5275
|
+
left: left2,
|
|
5276
|
+
top: top2
|
|
5277
|
+
};
|
|
5278
|
+
}
|
|
5279
|
+
|
|
5280
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/over-element/try-scroll.js
|
|
5281
|
+
function _createForOfIteratorHelper3(r, e) {
|
|
5282
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
5283
|
+
if (!t) {
|
|
5284
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray4(r)) || e && r && "number" == typeof r.length) {
|
|
5285
|
+
t && (r = t);
|
|
5286
|
+
var _n = 0, F = function F2() {
|
|
5287
|
+
};
|
|
5288
|
+
return { s: F, n: function n() {
|
|
5289
|
+
return _n >= r.length ? { done: true } : { done: false, value: r[_n++] };
|
|
5290
|
+
}, e: function e2(r2) {
|
|
5291
|
+
throw r2;
|
|
5292
|
+
}, f: F };
|
|
5293
|
+
}
|
|
5294
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
5295
|
+
}
|
|
5296
|
+
var o, a = true, u = false;
|
|
5297
|
+
return { s: function s() {
|
|
5298
|
+
t = t.call(r);
|
|
5299
|
+
}, n: function n() {
|
|
5300
|
+
var r2 = t.next();
|
|
5301
|
+
return a = r2.done, r2;
|
|
5302
|
+
}, e: function e2(r2) {
|
|
5303
|
+
u = true, o = r2;
|
|
5304
|
+
}, f: function f() {
|
|
5305
|
+
try {
|
|
5306
|
+
a || null == t.return || t.return();
|
|
5307
|
+
} finally {
|
|
5308
|
+
if (u) throw o;
|
|
5309
|
+
}
|
|
5310
|
+
} };
|
|
5311
|
+
}
|
|
5312
|
+
function _unsupportedIterableToArray4(r, a) {
|
|
5313
|
+
if (r) {
|
|
5314
|
+
if ("string" == typeof r) return _arrayLikeToArray4(r, a);
|
|
5315
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
5316
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray4(r, a) : void 0;
|
|
5317
|
+
}
|
|
5318
|
+
}
|
|
5319
|
+
function _arrayLikeToArray4(r, a) {
|
|
5320
|
+
(null == a || a > r.length) && (a = r.length);
|
|
5321
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
5322
|
+
return n;
|
|
5323
|
+
}
|
|
5324
|
+
function isScrollingAvailable(value) {
|
|
5325
|
+
return Boolean(value.top || value.left);
|
|
5326
|
+
}
|
|
5327
|
+
function tryScrollElements(_ref) {
|
|
5328
|
+
var _container$getConfigu, _container$getAllowed, _container$getAllowed2;
|
|
5329
|
+
var target = _ref.target, input = _ref.input, source = _ref.source, findEntry = _ref.findEntry, timeSinceLastFrame = _ref.timeSinceLastFrame, _ref$available = _ref.available, available = _ref$available === void 0 ? {
|
|
5330
|
+
top: true,
|
|
5331
|
+
left: true
|
|
5332
|
+
} : _ref$available;
|
|
5333
|
+
if (!isScrollingAvailable(available)) {
|
|
5334
|
+
return available;
|
|
5335
|
+
}
|
|
5336
|
+
if (!target) {
|
|
5337
|
+
return available;
|
|
5338
|
+
}
|
|
5339
|
+
var element = target.closest(selector);
|
|
5340
|
+
if (!element) {
|
|
5341
|
+
return available;
|
|
5342
|
+
}
|
|
5343
|
+
var container = findEntry(element);
|
|
5344
|
+
if (!container) {
|
|
5345
|
+
return available;
|
|
5346
|
+
}
|
|
5347
|
+
function continueSearchUp() {
|
|
5348
|
+
var _element$parentElemen;
|
|
5349
|
+
return tryScrollElements({
|
|
5350
|
+
target: (_element$parentElemen = element === null || element === void 0 ? void 0 : element.parentElement) !== null && _element$parentElemen !== void 0 ? _element$parentElemen : null,
|
|
5351
|
+
findEntry,
|
|
5352
|
+
source,
|
|
5353
|
+
timeSinceLastFrame,
|
|
5354
|
+
input,
|
|
5355
|
+
available
|
|
5356
|
+
});
|
|
5357
|
+
}
|
|
5358
|
+
var feedback = {
|
|
5359
|
+
input,
|
|
5360
|
+
source,
|
|
5361
|
+
element
|
|
5362
|
+
};
|
|
5363
|
+
if (container.canScroll && !container.canScroll(feedback)) {
|
|
5364
|
+
return continueSearchUp();
|
|
5365
|
+
}
|
|
5366
|
+
var engagement = markAndGetEngagement(element);
|
|
5367
|
+
var config = getInternalConfig((_container$getConfigu = container.getConfiguration) === null || _container$getConfigu === void 0 ? void 0 : _container$getConfigu.call(container, feedback));
|
|
5368
|
+
var allowedAxis = (_container$getAllowed = (_container$getAllowed2 = container.getAllowedAxis) === null || _container$getAllowed2 === void 0 ? void 0 : _container$getAllowed2.call(container, feedback)) !== null && _container$getAllowed !== void 0 ? _container$getAllowed : "all";
|
|
5369
|
+
var scrollBy = getScrollBy({
|
|
5370
|
+
element,
|
|
5371
|
+
engagement,
|
|
5372
|
+
input,
|
|
5373
|
+
timeSinceLastFrame,
|
|
5374
|
+
allowedAxis,
|
|
5375
|
+
config
|
|
5376
|
+
});
|
|
5377
|
+
var scroll = {
|
|
5378
|
+
top: 0,
|
|
5379
|
+
left: 0
|
|
5380
|
+
};
|
|
5381
|
+
if (available.top && scrollBy.top !== 0) {
|
|
5382
|
+
scroll.top = scrollBy.top;
|
|
5383
|
+
available.top = false;
|
|
5384
|
+
}
|
|
5385
|
+
if (available.left && scrollBy.left !== 0) {
|
|
5386
|
+
scroll.left = scrollBy.left;
|
|
5387
|
+
available.left = false;
|
|
5388
|
+
}
|
|
5389
|
+
if (scroll.top !== 0 || scroll.left !== 0) {
|
|
5390
|
+
element.scrollBy(scroll);
|
|
5391
|
+
}
|
|
5392
|
+
return continueSearchUp();
|
|
5393
|
+
}
|
|
5394
|
+
function tryScrollWindow(_ref2) {
|
|
5395
|
+
var input = _ref2.input, timeSinceLastFrame = _ref2.timeSinceLastFrame, available = _ref2.available, source = _ref2.source, entries = _ref2.entries;
|
|
5396
|
+
var element = document.documentElement;
|
|
5397
|
+
var feedback = {
|
|
5398
|
+
input,
|
|
5399
|
+
source,
|
|
5400
|
+
element
|
|
5401
|
+
};
|
|
5402
|
+
var _iterator = _createForOfIteratorHelper3(entries), _step;
|
|
5403
|
+
try {
|
|
5404
|
+
for (_iterator.s(); !(_step = _iterator.n()).done; ) {
|
|
5405
|
+
var _entry$getConfigurati, _entry$getAllowedAxis, _entry$getAllowedAxis2;
|
|
5406
|
+
var entry = _step.value;
|
|
5407
|
+
if (entry.canScroll && !entry.canScroll(feedback)) {
|
|
5408
|
+
continue;
|
|
5409
|
+
}
|
|
5410
|
+
var engagement = markAndGetEngagement(element);
|
|
5411
|
+
var config = getInternalConfig((_entry$getConfigurati = entry.getConfiguration) === null || _entry$getConfigurati === void 0 ? void 0 : _entry$getConfigurati.call(entry, feedback));
|
|
5412
|
+
var allowedAxis = (_entry$getAllowedAxis = (_entry$getAllowedAxis2 = entry.getAllowedAxis) === null || _entry$getAllowedAxis2 === void 0 ? void 0 : _entry$getAllowedAxis2.call(entry, feedback)) !== null && _entry$getAllowedAxis !== void 0 ? _entry$getAllowedAxis : "all";
|
|
5413
|
+
var scrollBy = getScrollBy({
|
|
5414
|
+
element,
|
|
5415
|
+
engagement,
|
|
5416
|
+
input,
|
|
5417
|
+
config,
|
|
5418
|
+
allowedAxis,
|
|
5419
|
+
getRect: function getRect(element2) {
|
|
5420
|
+
return DOMRect.fromRect({
|
|
5421
|
+
y: 0,
|
|
5422
|
+
x: 0,
|
|
5423
|
+
width: element2.clientWidth,
|
|
5424
|
+
height: element2.clientHeight
|
|
5425
|
+
});
|
|
5426
|
+
},
|
|
5427
|
+
timeSinceLastFrame
|
|
5428
|
+
});
|
|
5429
|
+
var scroll = {
|
|
5430
|
+
top: available.top ? scrollBy.top : 0,
|
|
5431
|
+
left: available.left ? scrollBy.left : 0
|
|
5432
|
+
};
|
|
5433
|
+
if (scroll.top !== 0 || scroll.left !== 0) {
|
|
5434
|
+
element.scrollBy(scroll);
|
|
5435
|
+
}
|
|
5436
|
+
break;
|
|
5437
|
+
}
|
|
5438
|
+
} catch (err) {
|
|
5439
|
+
_iterator.e(err);
|
|
5440
|
+
} finally {
|
|
5441
|
+
_iterator.f();
|
|
2963
5442
|
}
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
5443
|
+
}
|
|
5444
|
+
function tryScroll(_ref3) {
|
|
5445
|
+
var input = _ref3.input, findEntry = _ref3.findEntry, timeSinceLastFrame = _ref3.timeSinceLastFrame, source = _ref3.source, getWindowScrollEntries = _ref3.getWindowScrollEntries, underUsersPointer = _ref3.underUsersPointer;
|
|
5446
|
+
var remainder = tryScrollElements({
|
|
5447
|
+
target: underUsersPointer,
|
|
5448
|
+
timeSinceLastFrame,
|
|
5449
|
+
input,
|
|
5450
|
+
source,
|
|
5451
|
+
findEntry
|
|
5452
|
+
});
|
|
5453
|
+
if (!isScrollingAvailable(remainder)) {
|
|
5454
|
+
return;
|
|
2971
5455
|
}
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
this.setKind(other, kind);
|
|
3000
|
-
this.renderKindWarning(which);
|
|
5456
|
+
tryScrollWindow({
|
|
5457
|
+
input,
|
|
5458
|
+
source,
|
|
5459
|
+
entries: getWindowScrollEntries(),
|
|
5460
|
+
timeSinceLastFrame,
|
|
5461
|
+
available: remainder
|
|
5462
|
+
});
|
|
5463
|
+
}
|
|
5464
|
+
|
|
5465
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/over-element/make-api.js
|
|
5466
|
+
function ownKeys5(e, r) {
|
|
5467
|
+
var t = Object.keys(e);
|
|
5468
|
+
if (Object.getOwnPropertySymbols) {
|
|
5469
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
5470
|
+
r && (o = o.filter(function(r2) {
|
|
5471
|
+
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
5472
|
+
})), t.push.apply(t, o);
|
|
5473
|
+
}
|
|
5474
|
+
return t;
|
|
5475
|
+
}
|
|
5476
|
+
function _objectSpread5(e) {
|
|
5477
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
5478
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
5479
|
+
r % 2 ? ownKeys5(Object(t), true).forEach(function(r2) {
|
|
5480
|
+
_defineProperty(e, r2, t[r2]);
|
|
5481
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys5(Object(t)).forEach(function(r2) {
|
|
5482
|
+
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
3001
5483
|
});
|
|
3002
|
-
warning.appendChild(fix);
|
|
3003
5484
|
}
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
5485
|
+
return e;
|
|
5486
|
+
}
|
|
5487
|
+
function makeApi(_ref) {
|
|
5488
|
+
var monitor = _ref.monitor;
|
|
5489
|
+
var elementRegistry = /* @__PURE__ */ new Map();
|
|
5490
|
+
var windowRegistry = /* @__PURE__ */ new Set();
|
|
5491
|
+
function autoScroll(args) {
|
|
5492
|
+
if (true) {
|
|
5493
|
+
var _window$getComputedSt = window.getComputedStyle(args.element), overflowX = _window$getComputedSt.overflowX, overflowY = _window$getComputedSt.overflowY;
|
|
5494
|
+
var isScrollable = overflowX === "auto" || overflowX === "scroll" || overflowY === "auto" || overflowY === "scroll";
|
|
5495
|
+
if (!isScrollable) {
|
|
5496
|
+
console.warn("Auto scrolling has been attached to an element that appears not to be scrollable", {
|
|
5497
|
+
element: args.element,
|
|
5498
|
+
overflowX,
|
|
5499
|
+
overflowY
|
|
5500
|
+
});
|
|
5501
|
+
}
|
|
5502
|
+
}
|
|
5503
|
+
if (true) {
|
|
5504
|
+
var existing = elementRegistry.get(args.element);
|
|
5505
|
+
if (existing) {
|
|
5506
|
+
console.warn("You have already registered autoScrolling on the same element", {
|
|
5507
|
+
existing,
|
|
5508
|
+
proposed: args
|
|
5509
|
+
});
|
|
5510
|
+
}
|
|
5511
|
+
}
|
|
5512
|
+
elementRegistry.set(args.element, args);
|
|
5513
|
+
var cleanup = combine(addScrollableAttribute(args.element), function() {
|
|
5514
|
+
return elementRegistry.delete(args.element);
|
|
5515
|
+
});
|
|
5516
|
+
return once(cleanup);
|
|
5517
|
+
}
|
|
5518
|
+
function autoScrollWindow() {
|
|
5519
|
+
var args = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
5520
|
+
var unique = _objectSpread5({}, args);
|
|
5521
|
+
windowRegistry.add(unique);
|
|
5522
|
+
function cleanup() {
|
|
5523
|
+
windowRegistry.delete(unique);
|
|
5524
|
+
}
|
|
5525
|
+
return once(cleanup);
|
|
5526
|
+
}
|
|
5527
|
+
function findEntry(element) {
|
|
5528
|
+
var _elementRegistry$get;
|
|
5529
|
+
return (_elementRegistry$get = elementRegistry.get(element)) !== null && _elementRegistry$get !== void 0 ? _elementRegistry$get : null;
|
|
5530
|
+
}
|
|
5531
|
+
function getWindowScrollEntries() {
|
|
5532
|
+
return Array.from(windowRegistry);
|
|
5533
|
+
}
|
|
5534
|
+
function onFrame(_ref2) {
|
|
5535
|
+
var latestArgs = _ref2.latestArgs, underUsersPointer = _ref2.underUsersPointer, timeSinceLastFrame = _ref2.timeSinceLastFrame;
|
|
5536
|
+
tryScroll({
|
|
5537
|
+
input: latestArgs.location.current.input,
|
|
5538
|
+
source: latestArgs.source,
|
|
5539
|
+
findEntry,
|
|
5540
|
+
underUsersPointer,
|
|
5541
|
+
timeSinceLastFrame,
|
|
5542
|
+
getWindowScrollEntries
|
|
5543
|
+
});
|
|
3010
5544
|
}
|
|
5545
|
+
getScheduler(monitor).onFrame(onFrame);
|
|
5546
|
+
return {
|
|
5547
|
+
autoScroll,
|
|
5548
|
+
autoScrollWindow
|
|
5549
|
+
};
|
|
3011
5550
|
}
|
|
3012
5551
|
|
|
5552
|
+
// node_modules/@atlaskit/pragmatic-drag-and-drop-auto-scroll/dist/esm/entry-point/element.js
|
|
5553
|
+
var api = makeApi({
|
|
5554
|
+
monitor: monitorForElements
|
|
5555
|
+
});
|
|
5556
|
+
var autoScrollForElements = api.autoScroll;
|
|
5557
|
+
var autoScrollWindowForElements = api.autoScrollWindow;
|
|
5558
|
+
|
|
3013
5559
|
// src/editor-reconcile.ts
|
|
3014
5560
|
function tokenOf(unit) {
|
|
3015
5561
|
return unidOf(unit.id) + (unit.sig ? "|" + unit.sig : "");
|
|
@@ -3049,15 +5595,32 @@ function diffUnits(oldUnids, newUnits) {
|
|
|
3049
5595
|
const bar = token.indexOf("|");
|
|
3050
5596
|
return bar < 0 ? token : token.slice(0, bar);
|
|
3051
5597
|
};
|
|
3052
|
-
const
|
|
5598
|
+
const moved = [];
|
|
3053
5599
|
const usedRemoved = /* @__PURE__ */ new Set();
|
|
5600
|
+
const usedAdded = /* @__PURE__ */ new Set();
|
|
5601
|
+
const removedByToken = /* @__PURE__ */ new Map();
|
|
5602
|
+
for (const oi of removed) {
|
|
5603
|
+
(removedByToken.get(oldUnids[oi]) ?? removedByToken.set(oldUnids[oi], []).get(oldUnids[oi])).push(oi);
|
|
5604
|
+
}
|
|
5605
|
+
for (const nj of added) {
|
|
5606
|
+
const candidates = removedByToken.get(newUnids[nj]);
|
|
5607
|
+
const oi = candidates?.find((i2) => !usedRemoved.has(i2));
|
|
5608
|
+
if (oi !== void 0) {
|
|
5609
|
+
moved.push({ oldIndex: oi, newIndex: nj });
|
|
5610
|
+
usedRemoved.add(oi);
|
|
5611
|
+
usedAdded.add(nj);
|
|
5612
|
+
}
|
|
5613
|
+
}
|
|
5614
|
+
const substituted = [];
|
|
3054
5615
|
const removedByUnid = /* @__PURE__ */ new Map();
|
|
3055
5616
|
for (const oi of removed) {
|
|
5617
|
+
if (usedRemoved.has(oi)) continue;
|
|
3056
5618
|
const u = bareUnid(oldUnids[oi]);
|
|
3057
5619
|
(removedByUnid.get(u) ?? removedByUnid.set(u, []).get(u)).push(oi);
|
|
3058
5620
|
}
|
|
3059
5621
|
const unmatchedAdded = [];
|
|
3060
5622
|
for (const nj of added) {
|
|
5623
|
+
if (usedAdded.has(nj)) continue;
|
|
3061
5624
|
const candidates = removedByUnid.get(bareUnid(newUnids[nj]));
|
|
3062
5625
|
const oi = candidates?.find((i2) => !usedRemoved.has(i2));
|
|
3063
5626
|
if (oi !== void 0) {
|
|
@@ -3088,7 +5651,7 @@ function diffUnits(oldUnids, newUnits) {
|
|
|
3088
5651
|
}
|
|
3089
5652
|
}
|
|
3090
5653
|
}
|
|
3091
|
-
return { keep, removed, added, substituted };
|
|
5654
|
+
return { keep, removed, added, substituted, moved };
|
|
3092
5655
|
}
|
|
3093
5656
|
function needsRemount(diff, newUnits, oldKinds, threshold = 40) {
|
|
3094
5657
|
if (diff.added.length + diff.removed.length > threshold) return true;
|
|
@@ -3105,6 +5668,46 @@ function needsRemount(diff, newUnits, oldKinds, threshold = 40) {
|
|
|
3105
5668
|
|
|
3106
5669
|
// src/editor.ts
|
|
3107
5670
|
var EDITABLE_TAGS = /* @__PURE__ */ new Set(["P", "H1", "H2", "H3", "H4", "H5", "H6"]);
|
|
5671
|
+
var BLOCK_DRAG_TYPE = "docxodus-block";
|
|
5672
|
+
var blockDragStyledDocuments = /* @__PURE__ */ new WeakSet();
|
|
5673
|
+
function ensureBlockDragStyles(doc) {
|
|
5674
|
+
if (blockDragStyledDocuments.has(doc)) return;
|
|
5675
|
+
blockDragStyledDocuments.add(doc);
|
|
5676
|
+
const style = doc.createElement("style");
|
|
5677
|
+
style.dataset.docxodusBlockDrag = "true";
|
|
5678
|
+
style.textContent = `
|
|
5679
|
+
.docx-block-handle {
|
|
5680
|
+
position: fixed; z-index: 2147483000; display: none; width: 26px; height: 28px;
|
|
5681
|
+
align-items: center; justify-content: center; padding: 0; border: 1px solid #d0d5dd;
|
|
5682
|
+
border-radius: 6px; background: #fff; color: #667085; box-shadow: 0 1px 3px rgba(16,24,40,.12);
|
|
5683
|
+
cursor: grab; font: 700 17px/1 system-ui, sans-serif; user-select: none; touch-action: none;
|
|
5684
|
+
}
|
|
5685
|
+
.docx-block-handle:hover, .docx-block-handle:focus-visible { color: #344054; border-color: #98a2b3; outline: none; }
|
|
5686
|
+
.docx-block-handle[aria-pressed="true"] { color: #175cd3; border-color: #84adff; background: #eff8ff; }
|
|
5687
|
+
.docx-block-handle.docx-block-dragging { cursor: grabbing; opacity: .78; }
|
|
5688
|
+
.docx-block-drop-indicator {
|
|
5689
|
+
position: fixed; z-index: 2147482999; display: none; height: 3px; pointer-events: none;
|
|
5690
|
+
border-radius: 999px; background: #2e90fa; box-shadow: 0 0 0 1px rgba(255,255,255,.85);
|
|
5691
|
+
}
|
|
5692
|
+
.docx-block-move-menu {
|
|
5693
|
+
position: fixed; z-index: 2147483001; display: none; min-width: 150px; padding: 5px;
|
|
5694
|
+
border: 1px solid #d0d5dd; border-radius: 8px; background: #fff;
|
|
5695
|
+
box-shadow: 0 8px 24px rgba(16,24,40,.18); font: 13px/1.35 system-ui, sans-serif;
|
|
5696
|
+
}
|
|
5697
|
+
.docx-block-move-menu button { display: block; width: 100%; padding: 7px 9px; border: 0; border-radius: 5px; background: transparent; color: #344054; text-align: left; }
|
|
5698
|
+
.docx-block-move-menu button:hover, .docx-block-move-menu button:focus-visible { background: #f2f4f7; outline: none; }
|
|
5699
|
+
.docx-block-move-menu button:disabled { color: #98a2b3; background: transparent; }
|
|
5700
|
+
.docx-block-move-flash { animation: docx-block-move-flash 800ms ease-out; }
|
|
5701
|
+
@keyframes docx-block-move-flash { from { box-shadow: 0 0 0 3px rgba(46,144,250,.55); } to { box-shadow: none; } }
|
|
5702
|
+
.docx-block-live-region { position: fixed; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
5703
|
+
`;
|
|
5704
|
+
(doc.head ?? doc.documentElement).appendChild(style);
|
|
5705
|
+
}
|
|
5706
|
+
function trackedChangeWireName(mode) {
|
|
5707
|
+
if (mode === 1 /* RenderInline */) return "render_inline";
|
|
5708
|
+
if (mode === 2 /* StripDeletions */) return "strip_deletions";
|
|
5709
|
+
return "accept";
|
|
5710
|
+
}
|
|
3108
5711
|
function fontWeightIsBold(w) {
|
|
3109
5712
|
if (w === "bold" || w === "bolder") return true;
|
|
3110
5713
|
const n = parseInt(w, 10);
|
|
@@ -3252,9 +5855,9 @@ function trimBounds(block) {
|
|
|
3252
5855
|
}
|
|
3253
5856
|
function trimmedSpan(block, span) {
|
|
3254
5857
|
const { leading, trimmedLen } = trimBounds(block);
|
|
3255
|
-
const
|
|
3256
|
-
const end = Math.max(
|
|
3257
|
-
return { start, length: end -
|
|
5858
|
+
const start2 = Math.max(0, Math.min(span.start - Math.min(span.start, leading), trimmedLen));
|
|
5859
|
+
const end = Math.max(start2, Math.min(span.start + span.length - leading, trimmedLen));
|
|
5860
|
+
return { start: start2, length: end - start2 };
|
|
3258
5861
|
}
|
|
3259
5862
|
function contentPositionIn(el, offset) {
|
|
3260
5863
|
let remaining = offset;
|
|
@@ -3297,9 +5900,9 @@ function setSelectionBetween(anchor, focus) {
|
|
|
3297
5900
|
probe.collapse(true);
|
|
3298
5901
|
const focusIsBefore = probe.comparePoint(focus.node, focus.offset) < 0;
|
|
3299
5902
|
const range = document.createRange();
|
|
3300
|
-
const
|
|
5903
|
+
const start2 = focusIsBefore ? focus : anchor;
|
|
3301
5904
|
const end = focusIsBefore ? anchor : focus;
|
|
3302
|
-
range.setStart(
|
|
5905
|
+
range.setStart(start2.node, start2.offset);
|
|
3303
5906
|
range.setEnd(end.node, end.offset);
|
|
3304
5907
|
sel.removeAllRanges();
|
|
3305
5908
|
sel.addRange(range);
|
|
@@ -3347,17 +5950,17 @@ function selectionSpanIn(block) {
|
|
|
3347
5950
|
const range = sel.getRangeAt(0);
|
|
3348
5951
|
if (range.collapsed) return null;
|
|
3349
5952
|
if (!block.contains(range.startContainer) || !block.contains(range.endContainer)) return null;
|
|
3350
|
-
const
|
|
5953
|
+
const start2 = contentOffsetOf(block, range.startContainer, range.startOffset);
|
|
3351
5954
|
const end = contentOffsetOf(block, range.endContainer, range.endOffset);
|
|
3352
|
-
const span = trimmedSpan(block, { start: Math.min(
|
|
5955
|
+
const span = trimmedSpan(block, { start: Math.min(start2, end), length: Math.abs(end - start2) });
|
|
3353
5956
|
return span.length > 0 ? span : null;
|
|
3354
5957
|
}
|
|
3355
|
-
function selectRange(el,
|
|
5958
|
+
function selectRange(el, start2, length) {
|
|
3356
5959
|
const sel = typeof window !== "undefined" ? window.getSelection() : null;
|
|
3357
5960
|
if (!sel || !el.isConnected) return;
|
|
3358
5961
|
el.focus();
|
|
3359
5962
|
const range = document.createRange();
|
|
3360
|
-
const end =
|
|
5963
|
+
const end = start2 + length;
|
|
3361
5964
|
let pos = 0;
|
|
3362
5965
|
let startSet = false;
|
|
3363
5966
|
const walk = (node) => {
|
|
@@ -3366,8 +5969,8 @@ function selectRange(el, start, length) {
|
|
|
3366
5969
|
if (isInMarker(child)) continue;
|
|
3367
5970
|
const raw = child.textContent ?? "";
|
|
3368
5971
|
const len = stripBidi(raw).length;
|
|
3369
|
-
if (!startSet && pos + len >=
|
|
3370
|
-
range.setStart(child, domOffsetForContentOffset(raw,
|
|
5972
|
+
if (!startSet && pos + len >= start2) {
|
|
5973
|
+
range.setStart(child, domOffsetForContentOffset(raw, start2 - pos));
|
|
3371
5974
|
startSet = true;
|
|
3372
5975
|
}
|
|
3373
5976
|
if (startSet && pos + len >= end) {
|
|
@@ -3418,7 +6021,7 @@ function selectionHasFormat(key, fallback) {
|
|
|
3418
6021
|
return false;
|
|
3419
6022
|
}
|
|
3420
6023
|
}
|
|
3421
|
-
function completeArgs(bytes, cssPrefix, fabricate, paginated, scale) {
|
|
6024
|
+
function completeArgs(bytes, cssPrefix, fabricate, paginated, scale, renderTrackedChanges) {
|
|
3422
6025
|
return [
|
|
3423
6026
|
bytes,
|
|
3424
6027
|
"Document",
|
|
@@ -3442,7 +6045,7 @@ function completeArgs(bytes, cssPrefix, fabricate, paginated, scale) {
|
|
|
3442
6045
|
true,
|
|
3443
6046
|
/* renderHeadersAndFooters */
|
|
3444
6047
|
paginated,
|
|
3445
|
-
|
|
6048
|
+
renderTrackedChanges,
|
|
3446
6049
|
true,
|
|
3447
6050
|
true,
|
|
3448
6051
|
false,
|
|
@@ -3465,6 +6068,27 @@ var DocxEditor = class _DocxEditor {
|
|
|
3465
6068
|
* structural edit (split/merge/format) is lost. While this flag is set, commitBlock no-ops.
|
|
3466
6069
|
*/
|
|
3467
6070
|
this.replacing = false;
|
|
6071
|
+
/** Editor-owned block-move chrome. It is deliberately outside the rendered unit tree. */
|
|
6072
|
+
this.blockDragHandle = null;
|
|
6073
|
+
this.blockDropIndicator = null;
|
|
6074
|
+
this.blockMoveMenu = null;
|
|
6075
|
+
this.blockMoveLive = null;
|
|
6076
|
+
this.blockDragSource = null;
|
|
6077
|
+
this.blockDragCleanup = [];
|
|
6078
|
+
this.blockDragTargetCleanup = [];
|
|
6079
|
+
this.blockDragging = false;
|
|
6080
|
+
this.blockDragPointerDown = false;
|
|
6081
|
+
/** Anchors the current drag source may legally move next to, per the engine's own rules.
|
|
6082
|
+
* Null when the bridge predates ValidMoveTargets — then every block is offered, as before. */
|
|
6083
|
+
this.blockMoveTargets = null;
|
|
6084
|
+
/** Memoized `ValidMoveTargets` answers, keyed by source anchor and dropped whenever an edit
|
|
6085
|
+
* lands. The legal-target set is a property of the document, so hovering back and forth over
|
|
6086
|
+
* the same blocks between edits must not re-ask the engine. */
|
|
6087
|
+
this.blockMoveTargetCache = /* @__PURE__ */ new Map();
|
|
6088
|
+
/** Cancels the pending idle prefetch of the hovered block's targets — see `showBlockHandle`. */
|
|
6089
|
+
this.blockMoveTargetPrefetch = null;
|
|
6090
|
+
/** Why the last move was refused, verbatim from the engine — diagnostics, not announcement copy. */
|
|
6091
|
+
this.lastMoveError = null;
|
|
3468
6092
|
/**
|
|
3469
6093
|
* The last real (non-collapsed) text selection inside an editable block. A toolbar control that
|
|
3470
6094
|
* must take focus to be used — the font-size combobox — blurs the block and collapses the live
|
|
@@ -3621,8 +6245,8 @@ var DocxEditor = class _DocxEditor {
|
|
|
3621
6245
|
* body edit root by design — also register. The fence still rejects other editors on the page. */
|
|
3622
6246
|
editableBlockOf(node) {
|
|
3623
6247
|
if (!node) return null;
|
|
3624
|
-
const
|
|
3625
|
-
const block =
|
|
6248
|
+
const start2 = node.nodeType === 1 ? node : node.parentElement;
|
|
6249
|
+
const block = start2?.closest('[data-anchor][contenteditable="true"]') ?? null;
|
|
3626
6250
|
return block && this.container.contains(block) ? block : null;
|
|
3627
6251
|
}
|
|
3628
6252
|
/**
|
|
@@ -3663,18 +6287,34 @@ var DocxEditor = class _DocxEditor {
|
|
|
3663
6287
|
paginated: options.paginated ?? false,
|
|
3664
6288
|
scale: options.scale ?? 1,
|
|
3665
6289
|
headerFooter: options.headerFooter ?? false,
|
|
3666
|
-
|
|
6290
|
+
blockDrag: options.blockDrag ?? false,
|
|
6291
|
+
trackedChanges: options.trackedChanges ?? 0 /* Accept */,
|
|
6292
|
+
revisionAuthor: options.revisionAuthor ?? "docxodus",
|
|
6293
|
+
onEdit: options.onEdit,
|
|
6294
|
+
onMove: options.onMove
|
|
3667
6295
|
};
|
|
3668
|
-
const handle = exports.DocxSessionBridge.OpenSession(bytes,
|
|
6296
|
+
const handle = exports.DocxSessionBridge.OpenSession(bytes, JSON.stringify({
|
|
6297
|
+
emitMarkdownPatch: false,
|
|
6298
|
+
trackedChanges: trackedChangeWireName(opts.trackedChanges),
|
|
6299
|
+
revisionAuthor: opts.revisionAuthor
|
|
6300
|
+
}));
|
|
3669
6301
|
const editor = new _DocxEditor(container, exports, handle, opts);
|
|
3670
6302
|
editor.refreshAnchorMap();
|
|
3671
6303
|
if (opts.headerFooter) editor.createRegion();
|
|
3672
6304
|
const fullHtml = exports.DocumentConverter.ConvertDocxToHtmlComplete(
|
|
3673
|
-
...completeArgs(
|
|
6305
|
+
...completeArgs(
|
|
6306
|
+
bytes,
|
|
6307
|
+
opts.cssPrefix,
|
|
6308
|
+
opts.fabricateClasses,
|
|
6309
|
+
opts.paginated,
|
|
6310
|
+
opts.scale,
|
|
6311
|
+
opts.trackedChanges === 1 /* RenderInline */
|
|
6312
|
+
)
|
|
3674
6313
|
);
|
|
3675
6314
|
if (opts.paginated) editor.mountPaginated(fullHtml);
|
|
3676
6315
|
else editor.mountHtml(fullHtml);
|
|
3677
6316
|
editor.syncRegionToBody();
|
|
6317
|
+
editor.setupBlockDrag();
|
|
3678
6318
|
return editor;
|
|
3679
6319
|
}
|
|
3680
6320
|
/**
|
|
@@ -3701,6 +6341,7 @@ var DocxEditor = class _DocxEditor {
|
|
|
3701
6341
|
document.removeEventListener("mouseup", this.onMouseUp, true);
|
|
3702
6342
|
}
|
|
3703
6343
|
this.clearDragSelection();
|
|
6344
|
+
this.teardownBlockDrag();
|
|
3704
6345
|
this.exports.DocxSessionBridge.CloseSession(this.handle);
|
|
3705
6346
|
}
|
|
3706
6347
|
/**
|
|
@@ -3728,6 +6369,457 @@ var DocxEditor = class _DocxEditor {
|
|
|
3728
6369
|
get sessionHandle() {
|
|
3729
6370
|
return this.handle;
|
|
3730
6371
|
}
|
|
6372
|
+
/** Move one top-level body block relative to another and repaint from the live session. */
|
|
6373
|
+
moveBlock(sourceAnchorId, targetAnchorId, position) {
|
|
6374
|
+
this.assertOpen();
|
|
6375
|
+
const bridge = this.exports.DocxSessionBridge;
|
|
6376
|
+
if (typeof bridge.MoveBlock !== "function") return false;
|
|
6377
|
+
const res = this.parseEdit(
|
|
6378
|
+
bridge.MoveBlock(this.handle, sourceAnchorId, targetAnchorId, position)
|
|
6379
|
+
);
|
|
6380
|
+
if (!res.success) {
|
|
6381
|
+
this.lastMoveError = res.error?.message ?? null;
|
|
6382
|
+
this.announceBlockMove("This block cannot be moved there.");
|
|
6383
|
+
return false;
|
|
6384
|
+
}
|
|
6385
|
+
if ((res.created?.length ?? 0) === 0 && (res.modified?.length ?? 0) === 0 && (res.removed?.length ?? 0) === 0) {
|
|
6386
|
+
this.announceBlockMove("The block is already in that position.");
|
|
6387
|
+
return true;
|
|
6388
|
+
}
|
|
6389
|
+
const destination = res.created?.[0] ?? res.modified?.[0];
|
|
6390
|
+
this.reconcile();
|
|
6391
|
+
const moved = destination ? this.bodyUnitNodes().find((el) => el.getAttribute("data-anchor") === destination.unid) : null;
|
|
6392
|
+
if (moved) {
|
|
6393
|
+
moved.classList.add("docx-block-move-flash");
|
|
6394
|
+
moved.addEventListener("animationend", () => moved.classList.remove("docx-block-move-flash"), {
|
|
6395
|
+
once: true
|
|
6396
|
+
});
|
|
6397
|
+
const focusTarget = EDITABLE_TAGS.has(moved.tagName) ? moved : moved.querySelector('[data-anchor][contenteditable="true"]');
|
|
6398
|
+
if (focusTarget) {
|
|
6399
|
+
this.activeBlock = focusTarget;
|
|
6400
|
+
focusTarget.focus({ preventScroll: true });
|
|
6401
|
+
}
|
|
6402
|
+
}
|
|
6403
|
+
this.options.onMove?.({
|
|
6404
|
+
sourceAnchorId,
|
|
6405
|
+
destinationAnchorId: destination?.id ?? sourceAnchorId
|
|
6406
|
+
});
|
|
6407
|
+
this.announceBlockMove("Block moved.");
|
|
6408
|
+
return true;
|
|
6409
|
+
}
|
|
6410
|
+
/** Resolve any rendered descendant to its top-level body move unit (tables stay whole). */
|
|
6411
|
+
blockUnitOf(target) {
|
|
6412
|
+
const node = target instanceof Node ? target : null;
|
|
6413
|
+
const el = node?.nodeType === Node.ELEMENT_NODE ? node : node?.parentElement;
|
|
6414
|
+
if (!el || !this.editRoot.contains(el)) return null;
|
|
6415
|
+
let unit = null;
|
|
6416
|
+
for (let candidate = el.closest("[data-anchor]"); candidate && this.editRoot.contains(candidate); candidate = candidate.parentElement?.closest("[data-anchor]") ?? null) {
|
|
6417
|
+
unit = candidate;
|
|
6418
|
+
}
|
|
6419
|
+
if (!unit || unit.closest("section.footnotes, section.endnotes")) return null;
|
|
6420
|
+
return unit;
|
|
6421
|
+
}
|
|
6422
|
+
isMovableBlockUnit(unit) {
|
|
6423
|
+
if (!unit || !this.anchorIdOf(unit)) return false;
|
|
6424
|
+
if (unit.matches("[class$='row-del'], [class*='row-del ']") || unit.querySelector("tr[class$='row-del'], tr[class*='row-del '], del[class$='move-from'], del[class*='move-from ']")) return false;
|
|
6425
|
+
return unit.tagName === "TABLE" || EDITABLE_TAGS.has(unit.tagName);
|
|
6426
|
+
}
|
|
6427
|
+
currentBlockDragSource() {
|
|
6428
|
+
if (this.isMovableBlockUnit(this.blockDragSource) && this.blockDragSource.isConnected)
|
|
6429
|
+
return this.blockDragSource;
|
|
6430
|
+
const fromActive = this.blockUnitOf(this.activeBlock);
|
|
6431
|
+
if (this.isMovableBlockUnit(fromActive)) {
|
|
6432
|
+
this.blockDragSource = fromActive;
|
|
6433
|
+
return fromActive;
|
|
6434
|
+
}
|
|
6435
|
+
return null;
|
|
6436
|
+
}
|
|
6437
|
+
showBlockHandle(unit) {
|
|
6438
|
+
const handle = this.blockDragHandle;
|
|
6439
|
+
if (!handle || !this.isMovableBlockUnit(unit)) return;
|
|
6440
|
+
const changed = unit !== this.blockDragSource;
|
|
6441
|
+
this.blockDragSource = unit;
|
|
6442
|
+
const known = this.blockMoveTargetsFor(unit, { cachedOnly: true });
|
|
6443
|
+
if (known?.size === 0) {
|
|
6444
|
+
handle.style.display = "none";
|
|
6445
|
+
return;
|
|
6446
|
+
}
|
|
6447
|
+
if (changed && known === void 0) this.prefetchBlockMoveTargets(unit);
|
|
6448
|
+
const rect = unit.getBoundingClientRect();
|
|
6449
|
+
handle.style.display = "flex";
|
|
6450
|
+
handle.style.left = `${Math.max(4, rect.left - 32)}px`;
|
|
6451
|
+
handle.style.top = `${Math.max(4, rect.top + (unit.tagName === "TABLE" ? 6 : Math.max(0, (rect.height - 28) / 2)))}px`;
|
|
6452
|
+
const preview = (unit.textContent ?? "").trim().replace(/\s+/g, " ").slice(0, 48);
|
|
6453
|
+
handle.setAttribute("aria-label", preview ? `Move block: ${preview}` : "Move block");
|
|
6454
|
+
}
|
|
6455
|
+
hideBlockHandle() {
|
|
6456
|
+
if (this.blockDragging || this.blockMoveMenu?.style.display === "block") return;
|
|
6457
|
+
if (this.blockDragHandle) this.blockDragHandle.style.display = "none";
|
|
6458
|
+
}
|
|
6459
|
+
positionBlockHandle() {
|
|
6460
|
+
const source = this.currentBlockDragSource();
|
|
6461
|
+
if (source && this.blockDragHandle?.style.display !== "none") this.showBlockHandle(source);
|
|
6462
|
+
}
|
|
6463
|
+
showDropIndicator(target, position) {
|
|
6464
|
+
const indicator = this.blockDropIndicator;
|
|
6465
|
+
if (!indicator) return;
|
|
6466
|
+
const rect = this.unitWrapperOf(target).getBoundingClientRect();
|
|
6467
|
+
indicator.style.display = "block";
|
|
6468
|
+
indicator.style.left = `${rect.left}px`;
|
|
6469
|
+
indicator.style.top = `${position === "before" ? rect.top - 1 : rect.bottom - 1}px`;
|
|
6470
|
+
indicator.style.width = `${Math.max(24, rect.width)}px`;
|
|
6471
|
+
}
|
|
6472
|
+
hideDropIndicator() {
|
|
6473
|
+
if (this.blockDropIndicator) this.blockDropIndicator.style.display = "none";
|
|
6474
|
+
}
|
|
6475
|
+
announceBlockMove(message) {
|
|
6476
|
+
const live = this.blockMoveLive;
|
|
6477
|
+
if (!live) return;
|
|
6478
|
+
live.textContent = "";
|
|
6479
|
+
this.container.ownerDocument.defaultView?.setTimeout(() => {
|
|
6480
|
+
live.textContent = message;
|
|
6481
|
+
}, 0);
|
|
6482
|
+
}
|
|
6483
|
+
/**
|
|
6484
|
+
* Ask the engine which anchors the current source may move next to. One call per drag source,
|
|
6485
|
+
* so the UI offers only drops MoveBlock will accept — a document with section breaks is
|
|
6486
|
+
* partitioned into regions, and drawing an indicator across one only to fail the drop was the
|
|
6487
|
+
* behaviour this replaces. Null (no bridge support) keeps the previous offer-everything path.
|
|
6488
|
+
*/
|
|
6489
|
+
refreshBlockMoveTargets(source) {
|
|
6490
|
+
this.blockMoveTargets = source ? this.blockMoveTargetsFor(source) ?? null : null;
|
|
6491
|
+
}
|
|
6492
|
+
/**
|
|
6493
|
+
* This block's legal destinations, from the memo when it is there. Returns `undefined` — not
|
|
6494
|
+
* `null` — for "not asked yet", so a caller can tell an unknown answer from the engine's
|
|
6495
|
+
* "no bridge support, offer everything" one.
|
|
6496
|
+
*/
|
|
6497
|
+
blockMoveTargetsFor(source, options = {}) {
|
|
6498
|
+
const bridge = this.exports.DocxSessionBridge;
|
|
6499
|
+
const sourceId = this.anchorIdOf(source);
|
|
6500
|
+
if (!sourceId || typeof bridge.ValidMoveTargets !== "function") return null;
|
|
6501
|
+
if (this.blockMoveTargetCache.has(sourceId)) return this.blockMoveTargetCache.get(sourceId);
|
|
6502
|
+
if (options.cachedOnly) return void 0;
|
|
6503
|
+
let targets;
|
|
6504
|
+
try {
|
|
6505
|
+
const parsed = JSON.parse(bridge.ValidMoveTargets(this.handle, sourceId));
|
|
6506
|
+
targets = new Map(parsed.map((t) => [t.anchorId, { before: t.before, after: t.after }]));
|
|
6507
|
+
} catch {
|
|
6508
|
+
targets = null;
|
|
6509
|
+
}
|
|
6510
|
+
this.blockMoveTargetCache.set(sourceId, targets);
|
|
6511
|
+
return targets;
|
|
6512
|
+
}
|
|
6513
|
+
/**
|
|
6514
|
+
* Ask for the hovered block's destinations off the interaction path, and hide the handle if
|
|
6515
|
+
* the answer comes back empty and that block is still the one under the pointer. The handle
|
|
6516
|
+
* therefore appears immediately on hover and withdraws a beat later on the rare immovable
|
|
6517
|
+
* block, instead of every hover paying for the query up front.
|
|
6518
|
+
*/
|
|
6519
|
+
prefetchBlockMoveTargets(source) {
|
|
6520
|
+
const view = this.container.ownerDocument.defaultView;
|
|
6521
|
+
if (!view) return;
|
|
6522
|
+
this.blockMoveTargetPrefetch?.();
|
|
6523
|
+
const run = () => {
|
|
6524
|
+
this.blockMoveTargetPrefetch = null;
|
|
6525
|
+
if (this.closed || !source.isConnected || this.blockDragSource !== source) return;
|
|
6526
|
+
if (this.blockMoveTargetsFor(source)?.size === 0 && this.blockDragHandle)
|
|
6527
|
+
this.blockDragHandle.style.display = "none";
|
|
6528
|
+
};
|
|
6529
|
+
const idle = view;
|
|
6530
|
+
if (idle.requestIdleCallback && idle.cancelIdleCallback) {
|
|
6531
|
+
const id = idle.requestIdleCallback(run, { timeout: 500 });
|
|
6532
|
+
this.blockMoveTargetPrefetch = () => idle.cancelIdleCallback(id);
|
|
6533
|
+
} else {
|
|
6534
|
+
const id = view.setTimeout(run, 0);
|
|
6535
|
+
this.blockMoveTargetPrefetch = () => view.clearTimeout(id);
|
|
6536
|
+
}
|
|
6537
|
+
}
|
|
6538
|
+
/**
|
|
6539
|
+
* Whether `unit` is a legal destination for the current drag source — for a SPECIFIC side when
|
|
6540
|
+
* one is given. A cross-block range or a section break between the blocks can make one side
|
|
6541
|
+
* legal and the other not, so "this target is reachable" is not enough to pick a position.
|
|
6542
|
+
*/
|
|
6543
|
+
isValidMoveTarget(unit, position) {
|
|
6544
|
+
if (!this.blockMoveTargets) return true;
|
|
6545
|
+
const id = this.anchorIdOf(unit);
|
|
6546
|
+
const sides = id ? this.blockMoveTargets.get(id) : void 0;
|
|
6547
|
+
if (!sides) return false;
|
|
6548
|
+
return position ? sides[position] : sides.before || sides.after;
|
|
6549
|
+
}
|
|
6550
|
+
/**
|
|
6551
|
+
* The side of `unit` a drop at `clientY` should land on: the half the pointer is in, snapped to
|
|
6552
|
+
* the other side when only that one is legal. Snapping rather than refusing keeps a reachable
|
|
6553
|
+
* target usable — the illegal side is usually illegal only because a section break or a
|
|
6554
|
+
* cross-block range sits between the two blocks on that side.
|
|
6555
|
+
*/
|
|
6556
|
+
dropPositionFor(unit, clientY) {
|
|
6557
|
+
const rect = unit.getBoundingClientRect();
|
|
6558
|
+
const preferred = clientY < rect.top + rect.height / 2 ? "before" : "after";
|
|
6559
|
+
if (this.isValidMoveTarget(unit, preferred)) return preferred;
|
|
6560
|
+
const other = preferred === "before" ? "after" : "before";
|
|
6561
|
+
return this.isValidMoveTarget(unit, other) ? other : preferred;
|
|
6562
|
+
}
|
|
6563
|
+
refreshBlockDropTargets() {
|
|
6564
|
+
for (const cleanup of this.blockDragTargetCleanup.splice(0)) cleanup();
|
|
6565
|
+
if (!this.blockDragHandle || this.options.paginated) return;
|
|
6566
|
+
for (const unit of this.bodyUnitNodes().filter((el) => this.isMovableBlockUnit(el))) {
|
|
6567
|
+
this.blockDragTargetCleanup.push(dropTargetForElements({
|
|
6568
|
+
element: unit,
|
|
6569
|
+
// A target the engine would refuse is not a drop target at all, so Pragmatic never
|
|
6570
|
+
// fires onDragEnter for it and no indicator is drawn over it.
|
|
6571
|
+
canDrop: ({ source }) => source.data.type === BLOCK_DRAG_TYPE && source.data.sourceAnchorId !== this.anchorIdOf(unit) && this.isValidMoveTarget(unit),
|
|
6572
|
+
getData: ({ input }) => ({
|
|
6573
|
+
type: BLOCK_DRAG_TYPE,
|
|
6574
|
+
targetAnchorId: this.anchorIdOf(unit),
|
|
6575
|
+
position: this.dropPositionFor(unit, input.clientY),
|
|
6576
|
+
targetElement: unit
|
|
6577
|
+
}),
|
|
6578
|
+
onDragEnter: ({ self }) => {
|
|
6579
|
+
const pos = self.data.position === "after" ? "after" : "before";
|
|
6580
|
+
this.showDropIndicator(unit, pos);
|
|
6581
|
+
},
|
|
6582
|
+
onDrag: ({ self }) => {
|
|
6583
|
+
const pos = self.data.position === "after" ? "after" : "before";
|
|
6584
|
+
this.showDropIndicator(unit, pos);
|
|
6585
|
+
},
|
|
6586
|
+
onDragLeave: () => this.hideDropIndicator()
|
|
6587
|
+
}));
|
|
6588
|
+
}
|
|
6589
|
+
}
|
|
6590
|
+
closeBlockMoveMenu(restoreFocus = false) {
|
|
6591
|
+
if (!this.blockMoveMenu || !this.blockDragHandle) return;
|
|
6592
|
+
this.blockMoveMenu.style.display = "none";
|
|
6593
|
+
this.blockDragHandle.setAttribute("aria-expanded", "false");
|
|
6594
|
+
this.blockDragHandle.setAttribute("aria-pressed", "false");
|
|
6595
|
+
if (restoreFocus) this.blockDragHandle.focus({ preventScroll: true });
|
|
6596
|
+
}
|
|
6597
|
+
openBlockMoveMenu() {
|
|
6598
|
+
const menu = this.blockMoveMenu;
|
|
6599
|
+
const handle = this.blockDragHandle;
|
|
6600
|
+
const source = this.currentBlockDragSource();
|
|
6601
|
+
if (!menu || !handle || !source) return;
|
|
6602
|
+
this.refreshBlockMoveTargets(source);
|
|
6603
|
+
menu.querySelectorAll("button[data-move]").forEach((button) => {
|
|
6604
|
+
button.disabled = !this.blockMoveDestination(source, button.dataset.move ?? "");
|
|
6605
|
+
});
|
|
6606
|
+
const rect = handle.getBoundingClientRect();
|
|
6607
|
+
menu.style.display = "block";
|
|
6608
|
+
menu.style.left = `${Math.max(4, rect.right + 6)}px`;
|
|
6609
|
+
menu.style.top = `${Math.max(4, rect.top)}px`;
|
|
6610
|
+
handle.setAttribute("aria-expanded", "true");
|
|
6611
|
+
handle.setAttribute("aria-pressed", "true");
|
|
6612
|
+
menu.querySelector("button:not(:disabled)")?.focus({ preventScroll: true });
|
|
6613
|
+
}
|
|
6614
|
+
/**
|
|
6615
|
+
* Resolve a move-menu action to the block it should land against, considering only destinations
|
|
6616
|
+
* the engine accepts. "Top"/"bottom" therefore mean the ends of the source's own movable region
|
|
6617
|
+
* — on a document with section breaks that is the section, not the document, which is what makes
|
|
6618
|
+
* the commands work at all there instead of always failing.
|
|
6619
|
+
*/
|
|
6620
|
+
blockMoveDestination(source, action) {
|
|
6621
|
+
const units = this.bodyUnitNodes().filter((el) => this.isMovableBlockUnit(el));
|
|
6622
|
+
const index = units.indexOf(source);
|
|
6623
|
+
if (index < 0) return null;
|
|
6624
|
+
const position = action === "up" || action === "top" ? "before" : "after";
|
|
6625
|
+
const side = position === "before" ? units.slice(0, index) : units.slice(index + 1);
|
|
6626
|
+
const candidates = side.filter((el) => this.isValidMoveTarget(el, position));
|
|
6627
|
+
if (candidates.length === 0) return null;
|
|
6628
|
+
if (action === "up") return { target: candidates[candidates.length - 1], position };
|
|
6629
|
+
if (action === "down") return { target: candidates[0], position };
|
|
6630
|
+
if (action === "top") return { target: candidates[0], position };
|
|
6631
|
+
if (action === "bottom") return { target: candidates[candidates.length - 1], position };
|
|
6632
|
+
return null;
|
|
6633
|
+
}
|
|
6634
|
+
runBlockMoveMenuAction(action) {
|
|
6635
|
+
const source = this.currentBlockDragSource();
|
|
6636
|
+
if (!source) return;
|
|
6637
|
+
const destination = this.blockMoveDestination(source, action);
|
|
6638
|
+
this.closeBlockMoveMenu();
|
|
6639
|
+
if (!destination) return;
|
|
6640
|
+
const sourceId = this.anchorIdOf(source);
|
|
6641
|
+
const targetId = this.anchorIdOf(destination.target);
|
|
6642
|
+
if (sourceId && targetId) this.moveBlock(sourceId, targetId, destination.position);
|
|
6643
|
+
}
|
|
6644
|
+
/** The nearest ancestor that actually scrolls the document flow, for drag autoscroll. */
|
|
6645
|
+
scrollContainer() {
|
|
6646
|
+
const view = this.container.ownerDocument.defaultView;
|
|
6647
|
+
for (let el = this.editRoot; el; el = el.parentElement) {
|
|
6648
|
+
const overflowY = view?.getComputedStyle(el).overflowY ?? "visible";
|
|
6649
|
+
if ((overflowY === "auto" || overflowY === "scroll") && el.scrollHeight > el.clientHeight)
|
|
6650
|
+
return el;
|
|
6651
|
+
}
|
|
6652
|
+
return null;
|
|
6653
|
+
}
|
|
6654
|
+
/** Mount one floating handle; PDD owns pointer dragging while the menu owns keyboard moves. */
|
|
6655
|
+
setupBlockDrag() {
|
|
6656
|
+
if (!this.options.blockDrag || this.options.paginated || this.closed || this.blockDragHandle)
|
|
6657
|
+
return;
|
|
6658
|
+
const doc = this.container.ownerDocument;
|
|
6659
|
+
ensureBlockDragStyles(doc);
|
|
6660
|
+
const handle = doc.createElement("div");
|
|
6661
|
+
handle.className = "docx-block-handle";
|
|
6662
|
+
handle.textContent = "\u283F";
|
|
6663
|
+
handle.tabIndex = 0;
|
|
6664
|
+
handle.setAttribute("role", "button");
|
|
6665
|
+
handle.setAttribute("contenteditable", "false");
|
|
6666
|
+
handle.setAttribute("aria-haspopup", "menu");
|
|
6667
|
+
handle.setAttribute("aria-expanded", "false");
|
|
6668
|
+
handle.setAttribute("aria-pressed", "false");
|
|
6669
|
+
const indicator = doc.createElement("div");
|
|
6670
|
+
indicator.className = "docx-block-drop-indicator";
|
|
6671
|
+
const menu = doc.createElement("div");
|
|
6672
|
+
menu.className = "docx-block-move-menu";
|
|
6673
|
+
menu.setAttribute("role", "menu");
|
|
6674
|
+
menu.innerHTML = `
|
|
6675
|
+
<button type="button" role="menuitem" data-move="up">Move up</button>
|
|
6676
|
+
<button type="button" role="menuitem" data-move="down">Move down</button>
|
|
6677
|
+
<button type="button" role="menuitem" data-move="top">Move to top</button>
|
|
6678
|
+
<button type="button" role="menuitem" data-move="bottom">Move to bottom</button>`;
|
|
6679
|
+
const live = doc.createElement("div");
|
|
6680
|
+
live.className = "docx-block-live-region";
|
|
6681
|
+
live.setAttribute("role", "status");
|
|
6682
|
+
live.setAttribute("aria-live", "polite");
|
|
6683
|
+
this.container.append(handle, indicator, menu, live);
|
|
6684
|
+
this.blockDragHandle = handle;
|
|
6685
|
+
this.blockDropIndicator = indicator;
|
|
6686
|
+
this.blockMoveMenu = menu;
|
|
6687
|
+
this.blockMoveLive = live;
|
|
6688
|
+
const onPointerMove = (event) => {
|
|
6689
|
+
if (this.blockDragging || this.blockDragPointerDown) return;
|
|
6690
|
+
const unit = this.blockUnitOf(event.target);
|
|
6691
|
+
if (this.isMovableBlockUnit(unit)) this.showBlockHandle(unit);
|
|
6692
|
+
};
|
|
6693
|
+
const onFocusIn = (event) => {
|
|
6694
|
+
const unit = this.blockUnitOf(event.target);
|
|
6695
|
+
if (this.isMovableBlockUnit(unit)) this.showBlockHandle(unit);
|
|
6696
|
+
};
|
|
6697
|
+
const onPointerLeave = (event) => {
|
|
6698
|
+
const next = event.relatedTarget instanceof Node ? event.relatedTarget : null;
|
|
6699
|
+
if (next && (handle.contains(next) || menu.contains(next))) return;
|
|
6700
|
+
this.hideBlockHandle();
|
|
6701
|
+
};
|
|
6702
|
+
const onViewportChange = () => this.positionBlockHandle();
|
|
6703
|
+
this.container.addEventListener("pointermove", onPointerMove);
|
|
6704
|
+
this.container.addEventListener("focusin", onFocusIn);
|
|
6705
|
+
this.container.addEventListener("pointerleave", onPointerLeave);
|
|
6706
|
+
doc.addEventListener("scroll", onViewportChange, true);
|
|
6707
|
+
doc.defaultView?.addEventListener("resize", onViewportChange);
|
|
6708
|
+
this.blockDragCleanup.push(
|
|
6709
|
+
() => this.container.removeEventListener("pointermove", onPointerMove),
|
|
6710
|
+
() => this.container.removeEventListener("focusin", onFocusIn),
|
|
6711
|
+
() => this.container.removeEventListener("pointerleave", onPointerLeave),
|
|
6712
|
+
() => doc.removeEventListener("scroll", onViewportChange, true),
|
|
6713
|
+
() => doc.defaultView?.removeEventListener("resize", onViewportChange)
|
|
6714
|
+
);
|
|
6715
|
+
const onHandleClick = () => {
|
|
6716
|
+
if (menu.style.display === "block") this.closeBlockMoveMenu();
|
|
6717
|
+
else this.openBlockMoveMenu();
|
|
6718
|
+
};
|
|
6719
|
+
const onHandlePointerDown = () => {
|
|
6720
|
+
this.blockDragPointerDown = true;
|
|
6721
|
+
};
|
|
6722
|
+
const onPointerUp = () => {
|
|
6723
|
+
this.blockDragPointerDown = false;
|
|
6724
|
+
};
|
|
6725
|
+
const onHandleKeydown = (event) => {
|
|
6726
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
6727
|
+
event.preventDefault();
|
|
6728
|
+
onHandleClick();
|
|
6729
|
+
};
|
|
6730
|
+
const onMenuClick = (event) => {
|
|
6731
|
+
const button = event.target?.closest("button[data-move]");
|
|
6732
|
+
if (button && !button.disabled) this.runBlockMoveMenuAction(button.dataset.move ?? "");
|
|
6733
|
+
};
|
|
6734
|
+
const onMenuKeydown = (event) => {
|
|
6735
|
+
if (event.key === "Escape") {
|
|
6736
|
+
event.preventDefault();
|
|
6737
|
+
this.closeBlockMoveMenu(true);
|
|
6738
|
+
}
|
|
6739
|
+
};
|
|
6740
|
+
handle.addEventListener("click", onHandleClick);
|
|
6741
|
+
handle.addEventListener("pointerdown", onHandlePointerDown);
|
|
6742
|
+
handle.addEventListener("keydown", onHandleKeydown);
|
|
6743
|
+
menu.addEventListener("click", onMenuClick);
|
|
6744
|
+
menu.addEventListener("keydown", onMenuKeydown);
|
|
6745
|
+
doc.addEventListener("pointerup", onPointerUp, true);
|
|
6746
|
+
doc.addEventListener("pointercancel", onPointerUp, true);
|
|
6747
|
+
this.blockDragCleanup.push(
|
|
6748
|
+
() => handle.removeEventListener("click", onHandleClick),
|
|
6749
|
+
() => handle.removeEventListener("pointerdown", onHandlePointerDown),
|
|
6750
|
+
() => handle.removeEventListener("keydown", onHandleKeydown),
|
|
6751
|
+
() => menu.removeEventListener("click", onMenuClick),
|
|
6752
|
+
() => menu.removeEventListener("keydown", onMenuKeydown),
|
|
6753
|
+
() => doc.removeEventListener("pointerup", onPointerUp, true),
|
|
6754
|
+
() => doc.removeEventListener("pointercancel", onPointerUp, true)
|
|
6755
|
+
);
|
|
6756
|
+
this.blockDragCleanup.push(draggable({
|
|
6757
|
+
element: handle,
|
|
6758
|
+
canDrag: () => !!this.currentBlockDragSource(),
|
|
6759
|
+
getInitialData: () => {
|
|
6760
|
+
const source = this.currentBlockDragSource();
|
|
6761
|
+
return { type: BLOCK_DRAG_TYPE, sourceAnchorId: source ? this.anchorIdOf(source) : void 0 };
|
|
6762
|
+
},
|
|
6763
|
+
onDragStart: () => {
|
|
6764
|
+
this.blockDragging = true;
|
|
6765
|
+
handle.classList.add("docx-block-dragging");
|
|
6766
|
+
this.closeBlockMoveMenu();
|
|
6767
|
+
this.refreshBlockMoveTargets(this.currentBlockDragSource());
|
|
6768
|
+
this.refreshBlockDropTargets();
|
|
6769
|
+
},
|
|
6770
|
+
onDrop: () => {
|
|
6771
|
+
this.blockDragging = false;
|
|
6772
|
+
this.blockDragPointerDown = false;
|
|
6773
|
+
handle.classList.remove("docx-block-dragging");
|
|
6774
|
+
this.hideDropIndicator();
|
|
6775
|
+
}
|
|
6776
|
+
}));
|
|
6777
|
+
this.blockDragCleanup.push(monitorForElements({
|
|
6778
|
+
canMonitor: ({ source }) => source.data.type === BLOCK_DRAG_TYPE,
|
|
6779
|
+
onDrop: ({ source, location: location2 }) => {
|
|
6780
|
+
this.hideDropIndicator();
|
|
6781
|
+
const drop = location2.current.dropTargets[0]?.data;
|
|
6782
|
+
const sourceId = source.data.sourceAnchorId;
|
|
6783
|
+
const targetId = drop?.targetAnchorId;
|
|
6784
|
+
const position = drop?.position === "after" ? "after" : "before";
|
|
6785
|
+
if (typeof sourceId === "string" && typeof targetId === "string")
|
|
6786
|
+
this.moveBlock(sourceId, targetId, position);
|
|
6787
|
+
else
|
|
6788
|
+
this.announceBlockMove("Move cancelled \u2014 the block was not dropped on a valid position.");
|
|
6789
|
+
}
|
|
6790
|
+
}));
|
|
6791
|
+
const scroller = this.scrollContainer();
|
|
6792
|
+
if (scroller) {
|
|
6793
|
+
this.blockDragCleanup.push(autoScrollForElements({
|
|
6794
|
+
element: scroller,
|
|
6795
|
+
canScroll: ({ source }) => source.data.type === BLOCK_DRAG_TYPE,
|
|
6796
|
+
getAllowedAxis: () => "vertical"
|
|
6797
|
+
}));
|
|
6798
|
+
}
|
|
6799
|
+
this.blockDragCleanup.push(autoScrollWindowForElements({
|
|
6800
|
+
canScroll: ({ source }) => source.data.type === BLOCK_DRAG_TYPE,
|
|
6801
|
+
getAllowedAxis: () => "vertical"
|
|
6802
|
+
}));
|
|
6803
|
+
this.refreshBlockDropTargets();
|
|
6804
|
+
}
|
|
6805
|
+
teardownBlockDrag() {
|
|
6806
|
+
this.blockMoveTargetPrefetch?.();
|
|
6807
|
+
this.blockMoveTargetPrefetch = null;
|
|
6808
|
+
this.blockMoveTargetCache.clear();
|
|
6809
|
+
for (const cleanup of this.blockDragTargetCleanup.splice(0)) cleanup();
|
|
6810
|
+
for (const cleanup of this.blockDragCleanup.splice(0)) cleanup();
|
|
6811
|
+
this.blockDragHandle?.remove();
|
|
6812
|
+
this.blockDropIndicator?.remove();
|
|
6813
|
+
this.blockMoveMenu?.remove();
|
|
6814
|
+
this.blockMoveLive?.remove();
|
|
6815
|
+
this.blockDragHandle = null;
|
|
6816
|
+
this.blockDropIndicator = null;
|
|
6817
|
+
this.blockMoveMenu = null;
|
|
6818
|
+
this.blockMoveLive = null;
|
|
6819
|
+
this.blockDragSource = null;
|
|
6820
|
+
this.blockDragging = false;
|
|
6821
|
+
this.blockDragPointerDown = false;
|
|
6822
|
+
}
|
|
3731
6823
|
// ─── internals ───────────────────────────────────────────────────────
|
|
3732
6824
|
assertOpen() {
|
|
3733
6825
|
if (this.closed) throw new Error("DocxEditor is closed");
|
|
@@ -3849,6 +6941,10 @@ var DocxEditor = class _DocxEditor {
|
|
|
3849
6941
|
}
|
|
3850
6942
|
wireBlock(el) {
|
|
3851
6943
|
if (!EDITABLE_TAGS.has(el.tagName)) return;
|
|
6944
|
+
if (el.closest("tr[class$='row-del'], tr[class*='row-del ']") || el.querySelector(":scope > del[class$='move-from'], :scope > del[class*='move-from ']")) {
|
|
6945
|
+
el.setAttribute("contenteditable", "false");
|
|
6946
|
+
return;
|
|
6947
|
+
}
|
|
3852
6948
|
const unid = el.getAttribute("data-anchor");
|
|
3853
6949
|
if (!unid || !this.anchorIdOf(el)) return;
|
|
3854
6950
|
el.setAttribute("contenteditable", "true");
|
|
@@ -3910,12 +7006,7 @@ var DocxEditor = class _DocxEditor {
|
|
|
3910
7006
|
this.options.onEdit?.({ anchorId: newAnchor, unid: newUnid });
|
|
3911
7007
|
return;
|
|
3912
7008
|
}
|
|
3913
|
-
const html = this.
|
|
3914
|
-
this.handle,
|
|
3915
|
-
newAnchor,
|
|
3916
|
-
this.options.cssPrefix,
|
|
3917
|
-
this.options.fabricateClasses
|
|
3918
|
-
);
|
|
7009
|
+
const html = this.renderBlockHtml(newAnchor);
|
|
3919
7010
|
if (html.charCodeAt(0) !== 123) {
|
|
3920
7011
|
const fresh = new DOMParser().parseFromString(html, "text/html").body.firstElementChild;
|
|
3921
7012
|
const inBand = this.isBandBlock(el);
|
|
@@ -3956,9 +7047,10 @@ var DocxEditor = class _DocxEditor {
|
|
|
3956
7047
|
}
|
|
3957
7048
|
}
|
|
3958
7049
|
const inTableCell = !!el.closest("table");
|
|
3959
|
-
if (ev.key === "Tab") {
|
|
7050
|
+
if (ev.key === "Tab" && !ev.ctrlKey && !ev.metaKey && !ev.altKey && !ev.isComposing) {
|
|
3960
7051
|
if (inTableCell) {
|
|
3961
7052
|
ev.preventDefault();
|
|
7053
|
+
this.navigateTableCell(el, ev.shiftKey);
|
|
3962
7054
|
return;
|
|
3963
7055
|
}
|
|
3964
7056
|
if (isListBlock(el)) {
|
|
@@ -3987,6 +7079,42 @@ var DocxEditor = class _DocxEditor {
|
|
|
3987
7079
|
}
|
|
3988
7080
|
}
|
|
3989
7081
|
}
|
|
7082
|
+
/** Editable cells in visual document order, excluding cells from any nested table. */
|
|
7083
|
+
tableCellsFor(el) {
|
|
7084
|
+
const cell = el.closest("td, th");
|
|
7085
|
+
const table = cell?.closest("table");
|
|
7086
|
+
if (!cell || !table) return null;
|
|
7087
|
+
const cells = Array.from(table.querySelectorAll("td, th")).filter((candidate) => candidate.closest("table") === table);
|
|
7088
|
+
const index = cells.indexOf(cell);
|
|
7089
|
+
return index >= 0 ? { cells, index } : null;
|
|
7090
|
+
}
|
|
7091
|
+
/** First addressable paragraph in a cell, fenced against nested-table descendants. */
|
|
7092
|
+
editableInCell(cell) {
|
|
7093
|
+
return Array.from(
|
|
7094
|
+
cell.querySelectorAll('[data-anchor][contenteditable="true"]')
|
|
7095
|
+
).find((block) => block.closest("td, th") === cell) ?? null;
|
|
7096
|
+
}
|
|
7097
|
+
/** Word-style cell navigation: Shift+Tab goes back, Tab goes forward, and Tab at the
|
|
7098
|
+
* final cell appends a row before entering its first cell. The first cell is a hard
|
|
7099
|
+
* boundary for Shift+Tab so focus never leaks out of the editor table. */
|
|
7100
|
+
navigateTableCell(el, backwards) {
|
|
7101
|
+
const state = this.tableCellsFor(el);
|
|
7102
|
+
if (!state) return;
|
|
7103
|
+
const adjacent = state.cells[state.index + (backwards ? -1 : 1)];
|
|
7104
|
+
if (adjacent) {
|
|
7105
|
+
const target2 = this.editableInCell(adjacent);
|
|
7106
|
+
if (target2) placeCaretAtOffset(target2, 0);
|
|
7107
|
+
return;
|
|
7108
|
+
}
|
|
7109
|
+
if (backwards) return;
|
|
7110
|
+
this.activeBlock = el;
|
|
7111
|
+
this.insertTableRow("below");
|
|
7112
|
+
const fresh = this.activeBlock ? this.tableCellsFor(this.activeBlock) : null;
|
|
7113
|
+
if (!fresh) return;
|
|
7114
|
+
const target = fresh.cells[fresh.index + 1];
|
|
7115
|
+
const block = target ? this.editableInCell(target) : null;
|
|
7116
|
+
if (block) placeCaretAtOffset(block, 0);
|
|
7117
|
+
}
|
|
3990
7118
|
/** Shift+Enter: insert an intra-paragraph line break at the caret. Delegates to the
|
|
3991
7119
|
* native `insertLineBreak` command, which inserts a <br> AND positions the caret
|
|
3992
7120
|
* after it correctly (handling the browser's bogus trailing-<br> rule) so typing
|
|
@@ -4096,21 +7224,21 @@ var DocxEditor = class _DocxEditor {
|
|
|
4096
7224
|
while (p < minLen && old[p] === next[p]) p++;
|
|
4097
7225
|
let s = 0;
|
|
4098
7226
|
while (s < minLen - p && old[old.length - 1 - s] === next[next.length - 1 - s]) s++;
|
|
4099
|
-
let
|
|
7227
|
+
let start2 = p;
|
|
4100
7228
|
let len = old.length - p - s;
|
|
4101
7229
|
let middle = next.slice(p, next.length - s);
|
|
4102
7230
|
if (len === 0) {
|
|
4103
|
-
if (
|
|
4104
|
-
|
|
7231
|
+
if (start2 > 0) {
|
|
7232
|
+
start2 -= 1;
|
|
4105
7233
|
len = 1;
|
|
4106
|
-
middle = old[
|
|
7234
|
+
middle = old[start2] + middle;
|
|
4107
7235
|
} else {
|
|
4108
7236
|
len = 1;
|
|
4109
7237
|
middle = middle + old[0];
|
|
4110
7238
|
}
|
|
4111
7239
|
}
|
|
4112
7240
|
return this.parseEdit(
|
|
4113
|
-
this.exports.DocxSessionBridge.ReplaceTextAtSpan(this.handle, fullId,
|
|
7241
|
+
this.exports.DocxSessionBridge.ReplaceTextAtSpan(this.handle, fullId, start2, len, middle)
|
|
4114
7242
|
);
|
|
4115
7243
|
}
|
|
4116
7244
|
/** Flush a block's current (uncommitted) text to the session; returns the live full id. */
|
|
@@ -4122,14 +7250,34 @@ var DocxEditor = class _DocxEditor {
|
|
|
4122
7250
|
}
|
|
4123
7251
|
/** Render a block by anchor and parse it into a detached element (null on error). */
|
|
4124
7252
|
renderInto(anchorId) {
|
|
4125
|
-
const html = this.
|
|
7253
|
+
const html = this.renderBlockHtml(anchorId);
|
|
7254
|
+
if (html.charCodeAt(0) === 123) return null;
|
|
7255
|
+
return new DOMParser().parseFromString(html, "text/html").body.firstElementChild;
|
|
7256
|
+
}
|
|
7257
|
+
get renderTrackedChanges() {
|
|
7258
|
+
return this.options.trackedChanges === 1 /* RenderInline */;
|
|
7259
|
+
}
|
|
7260
|
+
renderBlockHtml(anchorId) {
|
|
7261
|
+
const bridge = this.exports.DocxSessionBridge;
|
|
7262
|
+
if (typeof bridge.RenderBlockHtmlForReview === "function") {
|
|
7263
|
+
return bridge.RenderBlockHtmlForReview(
|
|
7264
|
+
this.handle,
|
|
7265
|
+
anchorId,
|
|
7266
|
+
this.options.cssPrefix,
|
|
7267
|
+
this.options.fabricateClasses,
|
|
7268
|
+
this.renderTrackedChanges
|
|
7269
|
+
);
|
|
7270
|
+
}
|
|
7271
|
+
return bridge.RenderBlockHtml(
|
|
4126
7272
|
this.handle,
|
|
4127
7273
|
anchorId,
|
|
4128
7274
|
this.options.cssPrefix,
|
|
4129
7275
|
this.options.fabricateClasses
|
|
4130
7276
|
);
|
|
4131
|
-
|
|
4132
|
-
|
|
7277
|
+
}
|
|
7278
|
+
renderPlanJson() {
|
|
7279
|
+
const bridge = this.exports.DocxSessionBridge;
|
|
7280
|
+
return typeof bridge.ListRenderedBlocks === "function" ? bridge.ListRenderedBlocks(this.handle, this.renderTrackedChanges) : bridge.ListBlocks(this.handle);
|
|
4133
7281
|
}
|
|
4134
7282
|
/** Render two blocks in ONE batched bridge call when the bundle carries RenderBlocksHtml —
|
|
4135
7283
|
* the per-render shell/converter setup is paid once instead of twice, which matters on the
|
|
@@ -4140,14 +7288,20 @@ var DocxEditor = class _DocxEditor {
|
|
|
4140
7288
|
const bridge = this.exports.DocxSessionBridge;
|
|
4141
7289
|
if (typeof bridge.RenderBlocksHtml === "function") {
|
|
4142
7290
|
try {
|
|
4143
|
-
const
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
7291
|
+
const idsJson = JSON.stringify([a, b]);
|
|
7292
|
+
const json = typeof bridge.RenderBlocksHtmlForReview === "function" ? bridge.RenderBlocksHtmlForReview(
|
|
7293
|
+
this.handle,
|
|
7294
|
+
idsJson,
|
|
7295
|
+
this.options.cssPrefix,
|
|
7296
|
+
this.options.fabricateClasses,
|
|
7297
|
+
this.renderTrackedChanges
|
|
7298
|
+
) : bridge.RenderBlocksHtml(
|
|
7299
|
+
this.handle,
|
|
7300
|
+
idsJson,
|
|
7301
|
+
this.options.cssPrefix,
|
|
7302
|
+
this.options.fabricateClasses
|
|
4150
7303
|
);
|
|
7304
|
+
const map = JSON.parse(json);
|
|
4151
7305
|
if (!map.error) {
|
|
4152
7306
|
const parse = (h) => h ? new DOMParser().parseFromString(h, "text/html").body.firstElementChild : null;
|
|
4153
7307
|
const fa = parse(map[a]);
|
|
@@ -4169,11 +7323,22 @@ var DocxEditor = class _DocxEditor {
|
|
|
4169
7323
|
}
|
|
4170
7324
|
parseEdit(json) {
|
|
4171
7325
|
try {
|
|
4172
|
-
|
|
7326
|
+
const result = JSON.parse(json);
|
|
7327
|
+
if (result.success) this.invalidateBlockMoveTargets();
|
|
7328
|
+
return result;
|
|
4173
7329
|
} catch {
|
|
4174
7330
|
return { success: false };
|
|
4175
7331
|
}
|
|
4176
7332
|
}
|
|
7333
|
+
/**
|
|
7334
|
+
* Drop the memoized `ValidMoveTargets` answers. Which blocks a block may move next to is a
|
|
7335
|
+
* fact about the DOCUMENT, so it survives hovering but not editing — and the two places a
|
|
7336
|
+
* document changes are `parseEdit` (every mutation that returns an `EditResult`) and
|
|
7337
|
+
* undo/redo, which return a bare boolean and so cannot go through it.
|
|
7338
|
+
*/
|
|
7339
|
+
invalidateBlockMoveTargets() {
|
|
7340
|
+
this.blockMoveTargetCache.clear();
|
|
7341
|
+
}
|
|
4177
7342
|
// ─── M5: formatting commands (ribbon) ────────────────────────────────
|
|
4178
7343
|
// ─── Multi-block selection helpers (format a whole stack of paragraphs at once) ──────
|
|
4179
7344
|
/**
|
|
@@ -4190,9 +7355,9 @@ var DocxEditor = class _DocxEditor {
|
|
|
4190
7355
|
const first = all.find((block) => block.getAttribute("data-anchor") === bookmark.startUnid);
|
|
4191
7356
|
const last = all.find((block) => block.getAttribute("data-anchor") === bookmark.endUnid);
|
|
4192
7357
|
if (!first || !last || first === last || all.indexOf(first) > all.indexOf(last)) return false;
|
|
4193
|
-
const
|
|
7358
|
+
const start2 = contentPositionIn(first, bookmark.startOffset);
|
|
4194
7359
|
const end = contentPositionIn(last, bookmark.endOffset);
|
|
4195
|
-
return setSelectionBetween(
|
|
7360
|
+
return setSelectionBetween(start2, end);
|
|
4196
7361
|
}
|
|
4197
7362
|
/** Editable blocks the current selection covers, in document order. Uses Range.comparePoint
|
|
4198
7363
|
* (robust to a selection boundary that normalized onto a wrapper element rather than a block
|
|
@@ -4235,8 +7400,8 @@ var DocxEditor = class _DocxEditor {
|
|
|
4235
7400
|
if (hasStart && hasEnd) return selectionSpanIn(block);
|
|
4236
7401
|
const contentLen = blockContentText(block).length;
|
|
4237
7402
|
if (hasStart) {
|
|
4238
|
-
const
|
|
4239
|
-
return trimmedSpan(block, { start, length: Math.max(0, contentLen -
|
|
7403
|
+
const start2 = contentOffsetOf(block, range.startContainer, range.startOffset);
|
|
7404
|
+
return trimmedSpan(block, { start: start2, length: Math.max(0, contentLen - start2) });
|
|
4240
7405
|
}
|
|
4241
7406
|
if (hasEnd) {
|
|
4242
7407
|
const end = contentOffsetOf(block, range.endContainer, range.endOffset);
|
|
@@ -4727,12 +7892,16 @@ var DocxEditor = class _DocxEditor {
|
|
|
4727
7892
|
/** Undo the last edit (incremental repaint; falls back to a full re-render). */
|
|
4728
7893
|
undo() {
|
|
4729
7894
|
if (this.closed) return;
|
|
4730
|
-
if (this.exports.DocxSessionBridge.Undo(this.handle))
|
|
7895
|
+
if (!this.exports.DocxSessionBridge.Undo(this.handle)) return;
|
|
7896
|
+
this.invalidateBlockMoveTargets();
|
|
7897
|
+
this.reconcile();
|
|
4731
7898
|
}
|
|
4732
7899
|
/** Redo the last undone edit (incremental repaint; falls back to a full re-render). */
|
|
4733
7900
|
redo() {
|
|
4734
7901
|
if (this.closed) return;
|
|
4735
|
-
if (this.exports.DocxSessionBridge.Redo(this.handle))
|
|
7902
|
+
if (!this.exports.DocxSessionBridge.Redo(this.handle)) return;
|
|
7903
|
+
this.invalidateBlockMoveTargets();
|
|
7904
|
+
this.reconcile();
|
|
4736
7905
|
}
|
|
4737
7906
|
// ─── Header/footer region commands (no-ops unless `headerFooter` is on) ───────────────
|
|
4738
7907
|
/**
|
|
@@ -4831,6 +8000,17 @@ var DocxEditor = class _DocxEditor {
|
|
|
4831
8000
|
*/
|
|
4832
8001
|
renderFullHtml() {
|
|
4833
8002
|
const bridge = this.exports.DocxSessionBridge;
|
|
8003
|
+
if (typeof bridge.RenderHtmlForReview === "function") {
|
|
8004
|
+
const html = bridge.RenderHtmlForReview(
|
|
8005
|
+
this.handle,
|
|
8006
|
+
this.options.cssPrefix,
|
|
8007
|
+
this.options.fabricateClasses,
|
|
8008
|
+
this.options.paginated,
|
|
8009
|
+
this.options.scale,
|
|
8010
|
+
this.renderTrackedChanges
|
|
8011
|
+
);
|
|
8012
|
+
if (html.charCodeAt(0) !== 123) return html;
|
|
8013
|
+
}
|
|
4834
8014
|
if (typeof bridge.RenderHtml === "function") {
|
|
4835
8015
|
const html = bridge.RenderHtml(
|
|
4836
8016
|
this.handle,
|
|
@@ -4843,7 +8023,14 @@ var DocxEditor = class _DocxEditor {
|
|
|
4843
8023
|
}
|
|
4844
8024
|
const bytes = typeof bridge.SaveWithAnchorIds === "function" ? bridge.SaveWithAnchorIds(this.handle) : bridge.Save(this.handle);
|
|
4845
8025
|
return this.exports.DocumentConverter.ConvertDocxToHtmlComplete(
|
|
4846
|
-
...completeArgs(
|
|
8026
|
+
...completeArgs(
|
|
8027
|
+
bytes,
|
|
8028
|
+
this.options.cssPrefix,
|
|
8029
|
+
this.options.fabricateClasses,
|
|
8030
|
+
this.options.paginated,
|
|
8031
|
+
this.options.scale,
|
|
8032
|
+
this.renderTrackedChanges
|
|
8033
|
+
)
|
|
4847
8034
|
);
|
|
4848
8035
|
}
|
|
4849
8036
|
/** Editable BODY blocks in document order (band blocks are enumerated by `ownerRoot`). */
|
|
@@ -4937,29 +8124,40 @@ var DocxEditor = class _DocxEditor {
|
|
|
4937
8124
|
reconcileCore() {
|
|
4938
8125
|
const bridge = this.exports.DocxSessionBridge;
|
|
4939
8126
|
this.refreshAnchorMap();
|
|
4940
|
-
const plan = JSON.parse(
|
|
8127
|
+
const plan = JSON.parse(this.renderPlanJson());
|
|
4941
8128
|
if (plan.error) return this.bail(`plan error: ${plan.error}`);
|
|
4942
8129
|
const oldNodes = this.bodyUnitNodes();
|
|
4943
8130
|
const oldTokens = oldNodes.map(_DocxEditor.domTokenOf);
|
|
4944
8131
|
const oldKinds = oldNodes.map(_DocxEditor.domKindOf);
|
|
4945
8132
|
const bodyDiff = diffUnits(oldTokens, plan.body);
|
|
4946
|
-
if (needsRemount(bodyDiff, plan.body, oldKinds))
|
|
8133
|
+
if (needsRemount(bodyDiff, plan.body, oldKinds)) {
|
|
8134
|
+
return this.bail(
|
|
8135
|
+
`needsRemount (li change or churn): +${bodyDiff.added.length} -${bodyDiff.removed.length} ~${bodyDiff.substituted.length} moved=${bodyDiff.moved.length} of ${plan.body.length}`
|
|
8136
|
+
);
|
|
8137
|
+
}
|
|
4947
8138
|
const fnState = this.notesDiff("footnotes", plan.footnotes);
|
|
4948
8139
|
const enState = this.notesDiff("endnotes", plan.endnotes);
|
|
4949
8140
|
if (fnState === null || enState === null) return this.bail("notes container unstampable/missing");
|
|
4950
|
-
const
|
|
8141
|
+
const movedBodyNew = new Set(bodyDiff.moved.map((m) => m.newIndex));
|
|
8142
|
+
const addedBodyIds = bodyDiff.added.filter((j) => !movedBodyNew.has(j)).map((j) => plan.body[j].id);
|
|
4951
8143
|
const addedNoteIds = fnState.diff.added.map((j) => plan.footnotes[j].id).concat(enState.diff.added.map((j) => plan.endnotes[j].id));
|
|
4952
8144
|
const allIds = addedBodyIds.concat(addedNoteIds);
|
|
4953
8145
|
let rendered = {};
|
|
4954
8146
|
if (allIds.length > 0) {
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
8147
|
+
const idsJson = JSON.stringify(allIds);
|
|
8148
|
+
const renderedJson = typeof bridge.RenderBlocksHtmlForReview === "function" ? bridge.RenderBlocksHtmlForReview(
|
|
8149
|
+
this.handle,
|
|
8150
|
+
idsJson,
|
|
8151
|
+
this.options.cssPrefix,
|
|
8152
|
+
this.options.fabricateClasses,
|
|
8153
|
+
this.renderTrackedChanges
|
|
8154
|
+
) : bridge.RenderBlocksHtml(
|
|
8155
|
+
this.handle,
|
|
8156
|
+
idsJson,
|
|
8157
|
+
this.options.cssPrefix,
|
|
8158
|
+
this.options.fabricateClasses
|
|
4962
8159
|
);
|
|
8160
|
+
rendered = JSON.parse(renderedJson);
|
|
4963
8161
|
if (rendered.error) return this.bail(`render error: ${rendered.error}`);
|
|
4964
8162
|
for (const id of allIds) if (!rendered[id]) return this.bail(`unrenderable: ${id}`);
|
|
4965
8163
|
}
|
|
@@ -4969,7 +8167,7 @@ var DocxEditor = class _DocxEditor {
|
|
|
4969
8167
|
return el;
|
|
4970
8168
|
};
|
|
4971
8169
|
const freshBody = /* @__PURE__ */ new Map();
|
|
4972
|
-
for (const j of bodyDiff.added) {
|
|
8170
|
+
for (const j of bodyDiff.added.filter((j2) => !movedBodyNew.has(j2))) {
|
|
4973
8171
|
const el = parse(rendered[plan.body[j].id]);
|
|
4974
8172
|
if (!el) return this.bail(`unparseable render: ${plan.body[j].id}`);
|
|
4975
8173
|
freshBody.set(j, el);
|
|
@@ -5019,13 +8217,6 @@ var DocxEditor = class _DocxEditor {
|
|
|
5019
8217
|
* bail-reason string (parent ambiguity, order violation, wrapper semantics) — the
|
|
5020
8218
|
* session is already correct, so bailing just means a full repaint. */
|
|
5021
8219
|
applyBodyDiff(oldNodes, units, diff, fresh) {
|
|
5022
|
-
let lastOld = -1;
|
|
5023
|
-
for (let j = 0; j < units.length; j++) {
|
|
5024
|
-
const oi = diff.keep.get(j);
|
|
5025
|
-
if (oi === void 0) continue;
|
|
5026
|
-
if (oi < lastOld) return "kept order violation";
|
|
5027
|
-
lastOld = oi;
|
|
5028
|
-
}
|
|
5029
8220
|
const subOldByNew = new Map(diff.substituted.map((s) => [s.newIndex, s.oldIndex]));
|
|
5030
8221
|
for (const [nj, oi] of subOldByNew) {
|
|
5031
8222
|
const freshRoot = fresh.get(nj);
|
|
@@ -5041,13 +8232,18 @@ var DocxEditor = class _DocxEditor {
|
|
|
5041
8232
|
}
|
|
5042
8233
|
this.wireUnit(freshRoot, units[nj]);
|
|
5043
8234
|
}
|
|
5044
|
-
const
|
|
8235
|
+
const movedOldByNew = new Map(diff.moved.map((m) => [m.newIndex, m.oldIndex]));
|
|
8236
|
+
const movedNew = new Set(diff.moved.map((m) => m.newIndex));
|
|
8237
|
+
const movedOld = new Set(diff.moved.map((m) => m.oldIndex));
|
|
8238
|
+
const pureAdded = diff.added.filter((j) => !subOldByNew.has(j) && !movedNew.has(j));
|
|
5045
8239
|
const pureRemoved = diff.removed.filter(
|
|
5046
|
-
(i) => !diff.substituted.some((s) => s.oldIndex === i)
|
|
8240
|
+
(i) => !diff.substituted.some((s) => s.oldIndex === i) && !movedOld.has(i)
|
|
5047
8241
|
);
|
|
5048
8242
|
const nodeAt = (j) => {
|
|
5049
8243
|
const oi = diff.keep.get(j);
|
|
5050
8244
|
if (oi !== void 0) return oldNodes[oi];
|
|
8245
|
+
const movedOi = movedOldByNew.get(j);
|
|
8246
|
+
if (movedOi !== void 0) return oldNodes[movedOi];
|
|
5051
8247
|
if (subOldByNew.has(j)) return fresh.get(j);
|
|
5052
8248
|
const f = fresh.get(j);
|
|
5053
8249
|
return f && f.isConnected ? f : null;
|
|
@@ -5057,11 +8253,7 @@ var DocxEditor = class _DocxEditor {
|
|
|
5057
8253
|
let prev = null;
|
|
5058
8254
|
for (let k = j - 1; k >= 0 && !prev; k--) prev = nodeAt(k);
|
|
5059
8255
|
let next = null;
|
|
5060
|
-
for (let k = j + 1; k < units.length && !next; k++)
|
|
5061
|
-
const oi = diff.keep.get(k);
|
|
5062
|
-
if (oi !== void 0) next = oldNodes[oi];
|
|
5063
|
-
else if (subOldByNew.has(k)) next = fresh.get(k);
|
|
5064
|
-
}
|
|
8256
|
+
for (let k = j + 1; k < units.length && !next; k++) next = nodeAt(k);
|
|
5065
8257
|
const prevW = prev ? this.unitWrapperOf(prev) : null;
|
|
5066
8258
|
const nextW = next ? this.unitWrapperOf(next) : null;
|
|
5067
8259
|
if (prevW && nextW && prevW.parentElement !== nextW.parentElement)
|
|
@@ -5072,8 +8264,29 @@ var DocxEditor = class _DocxEditor {
|
|
|
5072
8264
|
this.wireUnit(el, units[j]);
|
|
5073
8265
|
}
|
|
5074
8266
|
for (const i of pureRemoved) {
|
|
5075
|
-
|
|
5076
|
-
|
|
8267
|
+
this.unitWrapperOf(oldNodes[i]).remove();
|
|
8268
|
+
}
|
|
8269
|
+
for (const { newIndex } of [...diff.moved].sort((a, b) => a.newIndex - b.newIndex)) {
|
|
8270
|
+
const moving = nodeAt(newIndex);
|
|
8271
|
+
if (!moving?.isConnected) return "move source is not connected";
|
|
8272
|
+
const movingW = this.unitWrapperOf(moving);
|
|
8273
|
+
let prevW = null;
|
|
8274
|
+
for (let k = newIndex - 1; k >= 0 && !prevW; k--) {
|
|
8275
|
+
const n = nodeAt(k);
|
|
8276
|
+
if (n?.isConnected) prevW = this.unitWrapperOf(n);
|
|
8277
|
+
}
|
|
8278
|
+
let nextW = null;
|
|
8279
|
+
for (let k = newIndex + 1; k < units.length && !nextW; k++) {
|
|
8280
|
+
const n = nodeAt(k);
|
|
8281
|
+
if (n?.isConnected) nextW = this.unitWrapperOf(n);
|
|
8282
|
+
}
|
|
8283
|
+
if (prevW && prevW !== movingW && prevW.parentElement === movingW.parentElement) {
|
|
8284
|
+
prevW.after(movingW);
|
|
8285
|
+
} else if (nextW && nextW !== movingW && nextW.parentElement === movingW.parentElement) {
|
|
8286
|
+
nextW.before(movingW);
|
|
8287
|
+
} else {
|
|
8288
|
+
return "move neighbors in different parents";
|
|
8289
|
+
}
|
|
5077
8290
|
}
|
|
5078
8291
|
return true;
|
|
5079
8292
|
}
|
|
@@ -5197,7 +8410,7 @@ var DocxEditor = class _DocxEditor {
|
|
|
5197
8410
|
const bridge = this.exports.DocxSessionBridge;
|
|
5198
8411
|
if (typeof bridge.ListBlocks !== "function") return;
|
|
5199
8412
|
try {
|
|
5200
|
-
const plan = JSON.parse(
|
|
8413
|
+
const plan = JSON.parse(this.renderPlanJson());
|
|
5201
8414
|
if (plan.error) return;
|
|
5202
8415
|
const nodes = this.bodyUnitNodes();
|
|
5203
8416
|
if (nodes.length === plan.body.length) {
|
|
@@ -5226,6 +8439,7 @@ var DocxEditor = class _DocxEditor {
|
|
|
5226
8439
|
* block's content-hashed unid changes across the save/reproject a remount performs.
|
|
5227
8440
|
*/
|
|
5228
8441
|
remount(focusIndex = -1, caretAtEnd = false) {
|
|
8442
|
+
this.teardownBlockDrag();
|
|
5229
8443
|
this.refreshAnchorMap();
|
|
5230
8444
|
const fullHtml = this.renderFullHtml();
|
|
5231
8445
|
this.activeBlock = null;
|
|
@@ -5240,6 +8454,7 @@ var DocxEditor = class _DocxEditor {
|
|
|
5240
8454
|
}
|
|
5241
8455
|
}
|
|
5242
8456
|
this.syncRegionToBody(this.activeBlock ?? void 0);
|
|
8457
|
+
this.setupBlockDrag();
|
|
5243
8458
|
}
|
|
5244
8459
|
};
|
|
5245
8460
|
|
|
@@ -6448,8 +9663,12 @@ var RibbonSurface = class {
|
|
|
6448
9663
|
editable: this.options.editable,
|
|
6449
9664
|
scale: this.options.scale,
|
|
6450
9665
|
onEdit: this.options.onEdit,
|
|
9666
|
+
onMove: this.options.onMove,
|
|
6451
9667
|
paginated,
|
|
6452
|
-
headerFooter: this.headerFooter
|
|
9668
|
+
headerFooter: this.headerFooter,
|
|
9669
|
+
blockDrag: this.options.blockDrag ?? true,
|
|
9670
|
+
trackedChanges: this.options.trackedChanges,
|
|
9671
|
+
revisionAuthor: this.options.revisionAuthor
|
|
6453
9672
|
});
|
|
6454
9673
|
this.require("save").disabled = false;
|
|
6455
9674
|
this.require("ribbon").setAttribute("aria-disabled", "false");
|
|
@@ -6537,8 +9756,8 @@ var RibbonSurface = class {
|
|
|
6537
9756
|
this.keepSelection(tab);
|
|
6538
9757
|
tab.addEventListener("click", () => this.selectTab(tab.dataset.tab ?? "home"));
|
|
6539
9758
|
}
|
|
6540
|
-
const delegate = (
|
|
6541
|
-
for (const el of Array.from(ribbon.querySelectorAll(
|
|
9759
|
+
const delegate = (selector2, label, fn) => {
|
|
9760
|
+
for (const el of Array.from(ribbon.querySelectorAll(selector2))) {
|
|
6542
9761
|
this.keepSelection(el);
|
|
6543
9762
|
el.addEventListener("click", () => this.run(label(el), () => fn(el)));
|
|
6544
9763
|
}
|
|
@@ -7253,10 +10472,10 @@ async function getRevisions(document2, options) {
|
|
|
7253
10472
|
function docxDiffSettingsJson(settings) {
|
|
7254
10473
|
return settings ? JSON.stringify(settings) : "";
|
|
7255
10474
|
}
|
|
7256
|
-
async function docxDiffCompare(
|
|
10475
|
+
async function docxDiffCompare(left2, right2, settings) {
|
|
7257
10476
|
const exports = ensureInitialized();
|
|
7258
|
-
const leftBytes = await toBytes(
|
|
7259
|
-
const rightBytes = await toBytes(
|
|
10477
|
+
const leftBytes = await toBytes(left2);
|
|
10478
|
+
const rightBytes = await toBytes(right2);
|
|
7260
10479
|
await yieldToMain();
|
|
7261
10480
|
const result = exports.DocxDiffBridge.Compare(
|
|
7262
10481
|
leftBytes,
|
|
@@ -7268,10 +10487,10 @@ async function docxDiffCompare(left, right, settings) {
|
|
|
7268
10487
|
}
|
|
7269
10488
|
return result;
|
|
7270
10489
|
}
|
|
7271
|
-
async function docxDiffGetRevisions(
|
|
10490
|
+
async function docxDiffGetRevisions(left2, right2, settings) {
|
|
7272
10491
|
const exports = ensureInitialized();
|
|
7273
|
-
const leftBytes = await toBytes(
|
|
7274
|
-
const rightBytes = await toBytes(
|
|
10492
|
+
const leftBytes = await toBytes(left2);
|
|
10493
|
+
const rightBytes = await toBytes(right2);
|
|
7275
10494
|
await yieldToMain();
|
|
7276
10495
|
const result = exports.DocxDiffBridge.GetRevisionsJson(
|
|
7277
10496
|
leftBytes,
|
|
@@ -7299,10 +10518,10 @@ async function docxDiffGetRevisions(left, right, settings) {
|
|
|
7299
10518
|
rightAnchor: r.rightAnchor ?? r.RightAnchor ?? void 0
|
|
7300
10519
|
}));
|
|
7301
10520
|
}
|
|
7302
|
-
async function docxDiffGetEditScript(
|
|
10521
|
+
async function docxDiffGetEditScript(left2, right2, settings) {
|
|
7303
10522
|
const exports = ensureInitialized();
|
|
7304
|
-
const leftBytes = await toBytes(
|
|
7305
|
-
const rightBytes = await toBytes(
|
|
10523
|
+
const leftBytes = await toBytes(left2);
|
|
10524
|
+
const rightBytes = await toBytes(right2);
|
|
7306
10525
|
await yieldToMain();
|
|
7307
10526
|
const result = exports.DocxDiffBridge.GetEditScriptJson(
|
|
7308
10527
|
leftBytes,
|
|
@@ -7930,8 +11149,8 @@ function createAnnotationFromSearch(id, labelId, documentText, searchText, occur
|
|
|
7930
11149
|
if (occurrence > offsets.length) {
|
|
7931
11150
|
return null;
|
|
7932
11151
|
}
|
|
7933
|
-
const { start, end } = offsets[occurrence - 1];
|
|
7934
|
-
return createAnnotation(id, labelId, documentText,
|
|
11152
|
+
const { start: start2, end } = offsets[occurrence - 1];
|
|
11153
|
+
return createAnnotation(id, labelId, documentText, start2, end);
|
|
7935
11154
|
}
|
|
7936
11155
|
function findTextOccurrences(documentText, searchText, maxResults = 100) {
|
|
7937
11156
|
if (!searchText) return [];
|
|
@@ -8173,7 +11392,7 @@ function createScopedMount(container) {
|
|
|
8173
11392
|
}
|
|
8174
11393
|
function splitSelectorList(selectorText) {
|
|
8175
11394
|
const selectors = [];
|
|
8176
|
-
let
|
|
11395
|
+
let start2 = 0;
|
|
8177
11396
|
let parentheses = 0;
|
|
8178
11397
|
let brackets = 0;
|
|
8179
11398
|
let quote = "";
|
|
@@ -8201,15 +11420,15 @@ function splitSelectorList(selectorText) {
|
|
|
8201
11420
|
else if (ch === "[") brackets++;
|
|
8202
11421
|
else if (ch === "]") brackets--;
|
|
8203
11422
|
else if (ch === "," && parentheses === 0 && brackets === 0) {
|
|
8204
|
-
selectors.push(selectorText.slice(
|
|
8205
|
-
|
|
11423
|
+
selectors.push(selectorText.slice(start2, i).trim());
|
|
11424
|
+
start2 = i + 1;
|
|
8206
11425
|
}
|
|
8207
11426
|
}
|
|
8208
|
-
selectors.push(selectorText.slice(
|
|
11427
|
+
selectors.push(selectorText.slice(start2).trim());
|
|
8209
11428
|
return selectors.filter(Boolean);
|
|
8210
11429
|
}
|
|
8211
|
-
function scopeSelector(
|
|
8212
|
-
let remaining =
|
|
11430
|
+
function scopeSelector(selector2, rootSelector) {
|
|
11431
|
+
let remaining = selector2.trim();
|
|
8213
11432
|
let consumedRoot = false;
|
|
8214
11433
|
let separated = false;
|
|
8215
11434
|
for (; ; ) {
|
|
@@ -8240,7 +11459,7 @@ function scopeCssRules(container, rootSelector) {
|
|
|
8240
11459
|
}
|
|
8241
11460
|
if (rule.type === CSSRule.STYLE_RULE) {
|
|
8242
11461
|
const styleRule = rule;
|
|
8243
|
-
styleRule.selectorText = splitSelectorList(styleRule.selectorText).map((
|
|
11462
|
+
styleRule.selectorText = splitSelectorList(styleRule.selectorText).map((selector2) => scopeSelector(selector2, rootSelector)).join(", ");
|
|
8244
11463
|
continue;
|
|
8245
11464
|
}
|
|
8246
11465
|
const grouping = rule;
|
|
@@ -8280,6 +11499,10 @@ function createScopedEditorExports(exports, rootSelector) {
|
|
|
8280
11499
|
if (renderHtml) {
|
|
8281
11500
|
bridge.RenderHtml = (...args) => scopeDocumentStyles(renderHtml(...args), rootSelector);
|
|
8282
11501
|
}
|
|
11502
|
+
const renderHtmlForReview = bridge.RenderHtmlForReview;
|
|
11503
|
+
if (renderHtmlForReview) {
|
|
11504
|
+
bridge.RenderHtmlForReview = (...args) => scopeDocumentStyles(renderHtmlForReview(...args), rootSelector);
|
|
11505
|
+
}
|
|
8283
11506
|
return {
|
|
8284
11507
|
DocxSessionBridge: bridge,
|
|
8285
11508
|
DocumentConverter: {
|
|
@@ -8308,7 +11531,7 @@ async function createViewer(container, source, options = {}) {
|
|
|
8308
11531
|
const el = resolveContainer2(container);
|
|
8309
11532
|
const { wasmBasePath: wasmBasePath2, ...conversion } = options;
|
|
8310
11533
|
await ensureWasm(wasmBasePath2);
|
|
8311
|
-
const
|
|
11534
|
+
const mount2 = createScopedMount(el);
|
|
8312
11535
|
let lastHtml = "";
|
|
8313
11536
|
const render = async (src, opts) => {
|
|
8314
11537
|
const bytes = await toDocumentBytes(src);
|
|
@@ -8321,13 +11544,13 @@ async function createViewer(container, source, options = {}) {
|
|
|
8321
11544
|
parsed.querySelectorAll("style").forEach((sourceStyle) => {
|
|
8322
11545
|
const style = document.createElement("style");
|
|
8323
11546
|
style.textContent = sourceStyle.textContent;
|
|
8324
|
-
scopeStyleElement(style,
|
|
11547
|
+
scopeStyleElement(style, mount2.selector);
|
|
8325
11548
|
fragment.appendChild(style);
|
|
8326
11549
|
});
|
|
8327
11550
|
const body = document.createElement("template");
|
|
8328
11551
|
body.innerHTML = parsed.body.innerHTML;
|
|
8329
11552
|
fragment.appendChild(body.content);
|
|
8330
|
-
|
|
11553
|
+
mount2.root.replaceChildren(fragment);
|
|
8331
11554
|
};
|
|
8332
11555
|
await render(source, conversion);
|
|
8333
11556
|
return {
|
|
@@ -8345,13 +11568,13 @@ async function createEditor(container, source, options = {}) {
|
|
|
8345
11568
|
const el = resolveContainer2(container);
|
|
8346
11569
|
const { wasmBasePath: wasmBasePath2, ...editorOptions } = options;
|
|
8347
11570
|
await ensureWasm(wasmBasePath2);
|
|
8348
|
-
const
|
|
11571
|
+
const mount2 = createScopedMount(el);
|
|
8349
11572
|
const exports = createScopedEditorExports(
|
|
8350
11573
|
getWasmExports(),
|
|
8351
|
-
|
|
11574
|
+
mount2.selector
|
|
8352
11575
|
);
|
|
8353
11576
|
try {
|
|
8354
|
-
return source == null ? DocxEditor.openBlank(
|
|
11577
|
+
return source == null ? DocxEditor.openBlank(mount2.root, exports, editorOptions) : DocxEditor.open(mount2.root, await toDocumentBytes(source), exports, editorOptions);
|
|
8355
11578
|
} catch (error) {
|
|
8356
11579
|
el.replaceChildren();
|
|
8357
11580
|
throw error;
|
|
@@ -8369,10 +11592,10 @@ function nameFromSource(source) {
|
|
|
8369
11592
|
async function createRibbonEditor(container, source, options = {}) {
|
|
8370
11593
|
const el = resolveContainer2(container);
|
|
8371
11594
|
const { wasmBasePath: wasmBasePath2, ...ribbonOptions } = options;
|
|
8372
|
-
const
|
|
8373
|
-
|
|
8374
|
-
|
|
8375
|
-
const ribbon = mountRibbon(
|
|
11595
|
+
const mount2 = createScopedMount(el);
|
|
11596
|
+
mount2.root.style.height = "100%";
|
|
11597
|
+
mount2.root.style.minHeight = "0";
|
|
11598
|
+
const ribbon = mountRibbon(mount2.root, {
|
|
8376
11599
|
documentName: ribbonOptions.documentName ?? nameFromSource(source),
|
|
8377
11600
|
...ribbonOptions,
|
|
8378
11601
|
// Exports arrive after the runtime boots; the loader covers that gap.
|
|
@@ -8384,7 +11607,7 @@ async function createRibbonEditor(container, source, options = {}) {
|
|
|
8384
11607
|
ribbon.setExports(
|
|
8385
11608
|
createScopedEditorExports(
|
|
8386
11609
|
getWasmExports(),
|
|
8387
|
-
`${
|
|
11610
|
+
`${mount2.selector} [data-dxr-surface]`
|
|
8388
11611
|
)
|
|
8389
11612
|
);
|
|
8390
11613
|
ribbon.loader.stage(1);
|