docxodus 9.1.0 → 9.2.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/README.md +39 -18
- package/dist/editor-reconcile.d.ts.map +1 -1
- package/dist/editor-reconcile.js +33 -5
- package/dist/editor-reconcile.js.map +1 -1
- package/dist/editor.bundle.js +1912 -24
- package/dist/editor.d.ts +52 -3
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +261 -18
- package/dist/editor.js.map +1 -1
- package/dist/embed.bundle.js +1955 -22
- package/dist/embed.d.ts +26 -1
- package/dist/embed.d.ts.map +1 -1
- package/dist/embed.iife.js +1955 -22
- package/dist/embed.js +70 -1
- package/dist/embed.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/ribbon-chrome.d.ts +45 -0
- package/dist/ribbon-chrome.d.ts.map +1 -0
- package/dist/ribbon-chrome.js +965 -0
- package/dist/ribbon-chrome.js.map +1 -0
- package/dist/ribbon.d.ts +153 -0
- package/dist/ribbon.d.ts.map +1 -0
- package/dist/ribbon.js +830 -0
- package/dist/ribbon.js.map +1 -0
- 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/dotnet.boot.js +3 -3
- package/dist/wasm/_framework/dotnet.boot.js.br +0 -0
- package/package.json +3 -3
package/dist/embed.bundle.js
CHANGED
|
@@ -3045,6 +3045,28 @@ function diffUnits(oldUnids, newUnits) {
|
|
|
3045
3045
|
}
|
|
3046
3046
|
while (i < n) removed.push(i++);
|
|
3047
3047
|
while (j < m) added.push(j++);
|
|
3048
|
+
const bareUnid = (token) => {
|
|
3049
|
+
const bar = token.indexOf("|");
|
|
3050
|
+
return bar < 0 ? token : token.slice(0, bar);
|
|
3051
|
+
};
|
|
3052
|
+
const substituted = [];
|
|
3053
|
+
const usedRemoved = /* @__PURE__ */ new Set();
|
|
3054
|
+
const removedByUnid = /* @__PURE__ */ new Map();
|
|
3055
|
+
for (const oi of removed) {
|
|
3056
|
+
const u = bareUnid(oldUnids[oi]);
|
|
3057
|
+
(removedByUnid.get(u) ?? removedByUnid.set(u, []).get(u)).push(oi);
|
|
3058
|
+
}
|
|
3059
|
+
const unmatchedAdded = [];
|
|
3060
|
+
for (const nj of added) {
|
|
3061
|
+
const candidates = removedByUnid.get(bareUnid(newUnids[nj]));
|
|
3062
|
+
const oi = candidates?.find((i2) => !usedRemoved.has(i2));
|
|
3063
|
+
if (oi !== void 0) {
|
|
3064
|
+
substituted.push({ oldIndex: oi, newIndex: nj });
|
|
3065
|
+
usedRemoved.add(oi);
|
|
3066
|
+
} else {
|
|
3067
|
+
unmatchedAdded.push(nj);
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3048
3070
|
const keptBeforeOld = (oi) => {
|
|
3049
3071
|
let c = 0;
|
|
3050
3072
|
for (const v of keep.values()) if (v < oi) c++;
|
|
@@ -3055,9 +3077,7 @@ function diffUnits(oldUnids, newUnits) {
|
|
|
3055
3077
|
for (const k of keep.keys()) if (k < nj) c++;
|
|
3056
3078
|
return c;
|
|
3057
3079
|
};
|
|
3058
|
-
const
|
|
3059
|
-
const usedRemoved = /* @__PURE__ */ new Set();
|
|
3060
|
-
for (const nj of added) {
|
|
3080
|
+
for (const nj of unmatchedAdded) {
|
|
3061
3081
|
const target = keptBeforeNew(nj);
|
|
3062
3082
|
for (const oi of removed) {
|
|
3063
3083
|
if (usedRemoved.has(oi)) continue;
|
|
@@ -3261,6 +3281,33 @@ function contentPositionIn(el, offset) {
|
|
|
3261
3281
|
if (lastText) return { node: lastText, offset: (lastText.textContent ?? "").length };
|
|
3262
3282
|
return { node: el, offset: el.childNodes.length };
|
|
3263
3283
|
}
|
|
3284
|
+
function caretPointFromClient(doc, clientX, clientY) {
|
|
3285
|
+
const caretDoc = doc;
|
|
3286
|
+
const position = caretDoc.caretPositionFromPoint?.(clientX, clientY);
|
|
3287
|
+
if (position) return { node: position.offsetNode, offset: position.offset };
|
|
3288
|
+
const range = caretDoc.caretRangeFromPoint?.(clientX, clientY);
|
|
3289
|
+
return range ? { node: range.startContainer, offset: range.startOffset } : null;
|
|
3290
|
+
}
|
|
3291
|
+
function setSelectionBetween(anchor, focus) {
|
|
3292
|
+
const sel = typeof window !== "undefined" ? window.getSelection() : null;
|
|
3293
|
+
if (!sel || !anchor.node.isConnected || !focus.node.isConnected) return false;
|
|
3294
|
+
try {
|
|
3295
|
+
const probe = document.createRange();
|
|
3296
|
+
probe.setStart(anchor.node, anchor.offset);
|
|
3297
|
+
probe.collapse(true);
|
|
3298
|
+
const focusIsBefore = probe.comparePoint(focus.node, focus.offset) < 0;
|
|
3299
|
+
const range = document.createRange();
|
|
3300
|
+
const start = focusIsBefore ? focus : anchor;
|
|
3301
|
+
const end = focusIsBefore ? anchor : focus;
|
|
3302
|
+
range.setStart(start.node, start.offset);
|
|
3303
|
+
range.setEnd(end.node, end.offset);
|
|
3304
|
+
sel.removeAllRanges();
|
|
3305
|
+
sel.addRange(range);
|
|
3306
|
+
return true;
|
|
3307
|
+
} catch {
|
|
3308
|
+
return false;
|
|
3309
|
+
}
|
|
3310
|
+
}
|
|
3264
3311
|
function placeCaretAtOffset(el, offset) {
|
|
3265
3312
|
const sel = typeof window !== "undefined" ? window.getSelection() : null;
|
|
3266
3313
|
if (!sel) return;
|
|
@@ -3426,6 +3473,15 @@ var DocxEditor = class _DocxEditor {
|
|
|
3426
3473
|
* block, and cleared when a caret is collapsed inside a block (so it never goes stale).
|
|
3427
3474
|
*/
|
|
3428
3475
|
this.lastSelection = null;
|
|
3476
|
+
/**
|
|
3477
|
+
* Stable bookmark for a selection spanning independent editable blocks. Native controls such as
|
|
3478
|
+
* a font-size combobox can take focus and collapse the live DOM selection; block ids + content
|
|
3479
|
+
* offsets let the command restore that same range before applying. This is the multi-block
|
|
3480
|
+
* counterpart to lastSelection above.
|
|
3481
|
+
*/
|
|
3482
|
+
this.lastCrossBlockSelection = null;
|
|
3483
|
+
/** State for the mouse-selection bridge between independent contenteditable block hosts. */
|
|
3484
|
+
this.dragSelection = null;
|
|
3429
3485
|
/** The docked header/footer bands, when `options.headerFooter` is on. */
|
|
3430
3486
|
this.region = null;
|
|
3431
3487
|
/** Why the last reconcile() fell back to a full remount (null = it patched). For
|
|
@@ -3437,24 +3493,128 @@ var DocxEditor = class _DocxEditor {
|
|
|
3437
3493
|
const sel = typeof window !== "undefined" ? window.getSelection() : null;
|
|
3438
3494
|
if (!sel || sel.rangeCount === 0) return;
|
|
3439
3495
|
const range = sel.getRangeAt(0);
|
|
3440
|
-
const
|
|
3496
|
+
const startBlock = this.editableBlockOf(range.startContainer);
|
|
3497
|
+
const endBlock = this.editableBlockOf(range.endContainer);
|
|
3498
|
+
const block = startBlock ?? endBlock;
|
|
3441
3499
|
if (!block) return;
|
|
3442
|
-
const unid = block.getAttribute("data-anchor");
|
|
3443
|
-
if (!unid) return;
|
|
3444
3500
|
if (range.collapsed) {
|
|
3445
3501
|
this.lastSelection = null;
|
|
3502
|
+
this.lastCrossBlockSelection = null;
|
|
3446
3503
|
return;
|
|
3447
3504
|
}
|
|
3505
|
+
if (startBlock && endBlock && startBlock !== endBlock && this.ownerRoot(startBlock) === this.ownerRoot(endBlock)) {
|
|
3506
|
+
const startUnid = startBlock.getAttribute("data-anchor");
|
|
3507
|
+
const endUnid = endBlock.getAttribute("data-anchor");
|
|
3508
|
+
if (startUnid && endUnid) {
|
|
3509
|
+
this.lastSelection = null;
|
|
3510
|
+
this.lastCrossBlockSelection = {
|
|
3511
|
+
startUnid,
|
|
3512
|
+
startOffset: contentOffsetOf(startBlock, range.startContainer, range.startOffset),
|
|
3513
|
+
endUnid,
|
|
3514
|
+
endOffset: contentOffsetOf(endBlock, range.endContainer, range.endOffset)
|
|
3515
|
+
};
|
|
3516
|
+
}
|
|
3517
|
+
return;
|
|
3518
|
+
}
|
|
3519
|
+
const unid = block.getAttribute("data-anchor");
|
|
3520
|
+
if (!unid) return;
|
|
3521
|
+
this.lastCrossBlockSelection = null;
|
|
3448
3522
|
const span = selectionSpanIn(block);
|
|
3449
3523
|
if (span) this.lastSelection = { unid, span };
|
|
3450
3524
|
};
|
|
3525
|
+
/** Start tracking a normal primary-button text drag inside one editable block. */
|
|
3526
|
+
this.onMouseDown = (event) => {
|
|
3527
|
+
if (this.closed || !this.options.editable || event.button !== 0) return;
|
|
3528
|
+
const target = event.target instanceof Node ? event.target : null;
|
|
3529
|
+
const origin = this.editableBlockOf(target);
|
|
3530
|
+
if (!origin || isInMarker(target)) return;
|
|
3531
|
+
const anchor = caretPointFromClient(document, event.clientX, event.clientY);
|
|
3532
|
+
if (!anchor || this.editableBlockOf(anchor.node) !== origin) return;
|
|
3533
|
+
this.clearDragSelection();
|
|
3534
|
+
this.dragSelection = {
|
|
3535
|
+
anchor,
|
|
3536
|
+
origin,
|
|
3537
|
+
crossedBlockBoundary: false,
|
|
3538
|
+
focus: null,
|
|
3539
|
+
frame: null
|
|
3540
|
+
};
|
|
3541
|
+
};
|
|
3542
|
+
/**
|
|
3543
|
+
* Browsers fence native mouse selection at a contenteditable host boundary. Once a drag reaches
|
|
3544
|
+
* another block in the same OOXML story, take over just that gesture and create the cross-block
|
|
3545
|
+
* Selection the editor's existing multi-block command path consumes. Intra-block selection stays
|
|
3546
|
+
* entirely native, and separate hosts remain intact for safe per-anchor commits.
|
|
3547
|
+
*/
|
|
3548
|
+
this.onMouseMove = (event) => {
|
|
3549
|
+
const drag = this.dragSelection;
|
|
3550
|
+
if (!drag) return;
|
|
3551
|
+
if ((event.buttons & 1) === 0) {
|
|
3552
|
+
this.clearDragSelection();
|
|
3553
|
+
return;
|
|
3554
|
+
}
|
|
3555
|
+
const focus = caretPointFromClient(document, event.clientX, event.clientY);
|
|
3556
|
+
if (!focus || isInMarker(focus.node)) return;
|
|
3557
|
+
const focusBlock = this.editableBlockOf(focus.node);
|
|
3558
|
+
if (!focusBlock || this.ownerRoot(focusBlock) !== this.ownerRoot(drag.origin)) return;
|
|
3559
|
+
if (focusBlock !== drag.origin) drag.crossedBlockBoundary = true;
|
|
3560
|
+
if (!drag.crossedBlockBoundary) return;
|
|
3561
|
+
event.preventDefault();
|
|
3562
|
+
this.queueDragSelection(drag, focus);
|
|
3563
|
+
};
|
|
3564
|
+
/** Commit the final cross-block endpoint before releasing the gesture state. */
|
|
3565
|
+
this.onMouseUp = (event) => {
|
|
3566
|
+
const drag = this.dragSelection;
|
|
3567
|
+
if (!drag) return;
|
|
3568
|
+
if (drag.crossedBlockBoundary) {
|
|
3569
|
+
const focus = caretPointFromClient(document, event.clientX, event.clientY);
|
|
3570
|
+
const focusBlock = focus ? this.editableBlockOf(focus.node) : null;
|
|
3571
|
+
if (focus && focusBlock && this.ownerRoot(focusBlock) === this.ownerRoot(drag.origin)) {
|
|
3572
|
+
event.preventDefault();
|
|
3573
|
+
setSelectionBetween(drag.anchor, focus);
|
|
3574
|
+
}
|
|
3575
|
+
}
|
|
3576
|
+
this.clearDragSelection();
|
|
3577
|
+
};
|
|
3451
3578
|
this.container = container;
|
|
3452
3579
|
this.exports = exports;
|
|
3453
3580
|
this.handle = handle;
|
|
3454
3581
|
this.options = options;
|
|
3455
3582
|
this.editRoot = container;
|
|
3456
|
-
if (typeof document !== "undefined")
|
|
3583
|
+
if (typeof document !== "undefined") {
|
|
3457
3584
|
document.addEventListener("selectionchange", this.onSelectionChange);
|
|
3585
|
+
document.addEventListener("mousedown", this.onMouseDown, true);
|
|
3586
|
+
document.addEventListener("mousemove", this.onMouseMove, true);
|
|
3587
|
+
document.addEventListener("mouseup", this.onMouseUp, true);
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
/**
|
|
3591
|
+
* Apply the latest cross-block endpoint after the browser finishes its native mousemove
|
|
3592
|
+
* selection update. Firefox rewrites Selection back into the originating contenteditable after
|
|
3593
|
+
* event dispatch even when mousemove is cancelled; writing in requestAnimationFrame wins that
|
|
3594
|
+
* race and happens before paint. Coalescing also avoids rebuilding a Range for every raw pointer
|
|
3595
|
+
* event when the mouse is moving faster than the display can refresh.
|
|
3596
|
+
*/
|
|
3597
|
+
queueDragSelection(drag, focus) {
|
|
3598
|
+
drag.focus = focus;
|
|
3599
|
+
if (drag.frame !== null) return;
|
|
3600
|
+
const view = this.container.ownerDocument.defaultView;
|
|
3601
|
+
if (!view) {
|
|
3602
|
+
setSelectionBetween(drag.anchor, focus);
|
|
3603
|
+
return;
|
|
3604
|
+
}
|
|
3605
|
+
drag.frame = view.requestAnimationFrame(() => {
|
|
3606
|
+
drag.frame = null;
|
|
3607
|
+
if (this.dragSelection !== drag || !drag.focus) return;
|
|
3608
|
+
setSelectionBetween(drag.anchor, drag.focus);
|
|
3609
|
+
});
|
|
3610
|
+
}
|
|
3611
|
+
/** Cancel a queued repaint and discard the current gesture. */
|
|
3612
|
+
clearDragSelection() {
|
|
3613
|
+
const drag = this.dragSelection;
|
|
3614
|
+
if (drag && drag.frame !== null) {
|
|
3615
|
+
this.container.ownerDocument.defaultView?.cancelAnimationFrame(drag.frame);
|
|
3616
|
+
}
|
|
3617
|
+
this.dragSelection = null;
|
|
3458
3618
|
}
|
|
3459
3619
|
/** The editable block (contenteditable [data-anchor]) containing `node`, if any, within this editor.
|
|
3460
3620
|
* Fenced by `container`, not `editRoot`, so header/footer band blocks — which live outside the
|
|
@@ -3534,8 +3694,13 @@ var DocxEditor = class _DocxEditor {
|
|
|
3534
3694
|
close() {
|
|
3535
3695
|
if (this.closed) return;
|
|
3536
3696
|
this.closed = true;
|
|
3537
|
-
if (typeof document !== "undefined")
|
|
3697
|
+
if (typeof document !== "undefined") {
|
|
3538
3698
|
document.removeEventListener("selectionchange", this.onSelectionChange);
|
|
3699
|
+
document.removeEventListener("mousedown", this.onMouseDown, true);
|
|
3700
|
+
document.removeEventListener("mousemove", this.onMouseMove, true);
|
|
3701
|
+
document.removeEventListener("mouseup", this.onMouseUp, true);
|
|
3702
|
+
}
|
|
3703
|
+
this.clearDragSelection();
|
|
3539
3704
|
this.exports.DocxSessionBridge.CloseSession(this.handle);
|
|
3540
3705
|
}
|
|
3541
3706
|
/**
|
|
@@ -3553,6 +3718,16 @@ var DocxEditor = class _DocxEditor {
|
|
|
3553
3718
|
get root() {
|
|
3554
3719
|
return this.container;
|
|
3555
3720
|
}
|
|
3721
|
+
/**
|
|
3722
|
+
* The live `DocxSession` handle backing this editor — the model of record.
|
|
3723
|
+
*
|
|
3724
|
+
* Surfaced because chrome around the editor (the anchor rail) reports it as engine
|
|
3725
|
+
* state, and reaching into the private field from a host page only worked because
|
|
3726
|
+
* the bundle erases TypeScript's visibility.
|
|
3727
|
+
*/
|
|
3728
|
+
get sessionHandle() {
|
|
3729
|
+
return this.handle;
|
|
3730
|
+
}
|
|
3556
3731
|
// ─── internals ───────────────────────────────────────────────────────
|
|
3557
3732
|
assertOpen() {
|
|
3558
3733
|
if (this.closed) throw new Error("DocxEditor is closed");
|
|
@@ -3843,8 +4018,7 @@ var DocxEditor = class _DocxEditor {
|
|
|
3843
4018
|
this.options.onEdit?.({ anchorId: second.id, unid: second.unid });
|
|
3844
4019
|
return;
|
|
3845
4020
|
}
|
|
3846
|
-
const firstEl = this.
|
|
3847
|
-
const secondEl = this.renderInto(second.id);
|
|
4021
|
+
const [firstEl, secondEl] = this.renderTwo(first.id, second.id);
|
|
3848
4022
|
if (!firstEl || !secondEl) return;
|
|
3849
4023
|
const inBand = this.isBandBlock(el);
|
|
3850
4024
|
if (!this.replaceNode(el, firstEl, secondEl)) return;
|
|
@@ -3957,6 +4131,34 @@ var DocxEditor = class _DocxEditor {
|
|
|
3957
4131
|
if (html.charCodeAt(0) === 123) return null;
|
|
3958
4132
|
return new DOMParser().parseFromString(html, "text/html").body.firstElementChild;
|
|
3959
4133
|
}
|
|
4134
|
+
/** Render two blocks in ONE batched bridge call when the bundle carries RenderBlocksHtml —
|
|
4135
|
+
* the per-render shell/converter setup is paid once instead of twice, which matters on the
|
|
4136
|
+
* Enter path (split renders both halves synchronously under the keystroke). Falls back to
|
|
4137
|
+
* two per-block renders on older bundles. Output is renderInto-identical per block (both
|
|
4138
|
+
* routes share the same extraction). */
|
|
4139
|
+
renderTwo(a, b) {
|
|
4140
|
+
const bridge = this.exports.DocxSessionBridge;
|
|
4141
|
+
if (typeof bridge.RenderBlocksHtml === "function") {
|
|
4142
|
+
try {
|
|
4143
|
+
const map = JSON.parse(
|
|
4144
|
+
bridge.RenderBlocksHtml(
|
|
4145
|
+
this.handle,
|
|
4146
|
+
JSON.stringify([a, b]),
|
|
4147
|
+
this.options.cssPrefix,
|
|
4148
|
+
this.options.fabricateClasses
|
|
4149
|
+
)
|
|
4150
|
+
);
|
|
4151
|
+
if (!map.error) {
|
|
4152
|
+
const parse = (h) => h ? new DOMParser().parseFromString(h, "text/html").body.firstElementChild : null;
|
|
4153
|
+
const fa = parse(map[a]);
|
|
4154
|
+
const fb = parse(map[b]);
|
|
4155
|
+
if (fa && fb) return [fa, fb];
|
|
4156
|
+
}
|
|
4157
|
+
} catch {
|
|
4158
|
+
}
|
|
4159
|
+
}
|
|
4160
|
+
return [this.renderInto(a), this.renderInto(b)];
|
|
4161
|
+
}
|
|
3960
4162
|
/** The editable block immediately before `el` within its own root, or null. */
|
|
3961
4163
|
previousEditable(el) {
|
|
3962
4164
|
const all = Array.from(
|
|
@@ -3974,12 +4176,34 @@ var DocxEditor = class _DocxEditor {
|
|
|
3974
4176
|
}
|
|
3975
4177
|
// ─── M5: formatting commands (ribbon) ────────────────────────────────
|
|
3976
4178
|
// ─── Multi-block selection helpers (format a whole stack of paragraphs at once) ──────
|
|
4179
|
+
/**
|
|
4180
|
+
* Restore a cross-block selection after a native toolbar control took focus. The bookmark uses
|
|
4181
|
+
* stable anchor ids and content offsets, so it also survives incremental block swaps.
|
|
4182
|
+
*/
|
|
4183
|
+
restoreCrossBlockSelection() {
|
|
4184
|
+
const bookmark = this.lastCrossBlockSelection;
|
|
4185
|
+
const active = this.activeBlock;
|
|
4186
|
+
if (!bookmark || !active) return false;
|
|
4187
|
+
const all = Array.from(
|
|
4188
|
+
this.ownerRoot(active).querySelectorAll('[data-anchor][contenteditable="true"]')
|
|
4189
|
+
);
|
|
4190
|
+
const first = all.find((block) => block.getAttribute("data-anchor") === bookmark.startUnid);
|
|
4191
|
+
const last = all.find((block) => block.getAttribute("data-anchor") === bookmark.endUnid);
|
|
4192
|
+
if (!first || !last || first === last || all.indexOf(first) > all.indexOf(last)) return false;
|
|
4193
|
+
const start = contentPositionIn(first, bookmark.startOffset);
|
|
4194
|
+
const end = contentPositionIn(last, bookmark.endOffset);
|
|
4195
|
+
return setSelectionBetween(start, end);
|
|
4196
|
+
}
|
|
3977
4197
|
/** Editable blocks the current selection covers, in document order. Uses Range.comparePoint
|
|
3978
4198
|
* (robust to a selection boundary that normalized onto a wrapper element rather than a block
|
|
3979
4199
|
* or text node — Range.intersectsNode misses the end block at a `(block, childCount)` boundary).
|
|
3980
4200
|
* A collapsed or single-block selection yields just the active block. */
|
|
3981
4201
|
selectedBlocks() {
|
|
3982
|
-
|
|
4202
|
+
let sel = typeof window !== "undefined" ? window.getSelection() : null;
|
|
4203
|
+
if ((!sel || sel.rangeCount === 0 || sel.isCollapsed) && this.lastCrossBlockSelection) {
|
|
4204
|
+
this.restoreCrossBlockSelection();
|
|
4205
|
+
sel = typeof window !== "undefined" ? window.getSelection() : null;
|
|
4206
|
+
}
|
|
3983
4207
|
const root = this.activeBlock ? this.ownerRoot(this.activeBlock) : this.editRoot;
|
|
3984
4208
|
const all = Array.from(
|
|
3985
4209
|
root.querySelectorAll('[data-anchor][contenteditable="true"]')
|
|
@@ -4758,7 +4982,8 @@ var DocxEditor = class _DocxEditor {
|
|
|
4758
4982
|
);
|
|
4759
4983
|
if (oldMarker !== newMarker) return this.bail("substituted li marker drift");
|
|
4760
4984
|
}
|
|
4761
|
-
|
|
4985
|
+
const bodyApply = this.applyBodyDiff(oldNodes, plan.body, bodyDiff, freshBody);
|
|
4986
|
+
if (bodyApply !== true) return this.bail(`applyBodyDiff bail: ${bodyApply}`);
|
|
4762
4987
|
this.applyNotesDiff("footnotes", plan.footnotes, fnState, rendered);
|
|
4763
4988
|
this.applyNotesDiff("endnotes", plan.endnotes, enState, rendered);
|
|
4764
4989
|
const freshHasMarker = [...freshBody.values()].some(
|
|
@@ -4790,15 +5015,15 @@ var DocxEditor = class _DocxEditor {
|
|
|
4790
5015
|
static anchorElOf(root) {
|
|
4791
5016
|
return root.hasAttribute("data-anchor") ? root : root.querySelector("[data-anchor]");
|
|
4792
5017
|
}
|
|
4793
|
-
/** Insert/remove/swap body unit nodes per the diff. Returns
|
|
4794
|
-
* ambiguity, order violation, wrapper semantics) — the
|
|
4795
|
-
* so bailing just means a full repaint. */
|
|
5018
|
+
/** Insert/remove/swap body unit nodes per the diff. Returns `true` on success or a
|
|
5019
|
+
* bail-reason string (parent ambiguity, order violation, wrapper semantics) — the
|
|
5020
|
+
* session is already correct, so bailing just means a full repaint. */
|
|
4796
5021
|
applyBodyDiff(oldNodes, units, diff, fresh) {
|
|
4797
5022
|
let lastOld = -1;
|
|
4798
5023
|
for (let j = 0; j < units.length; j++) {
|
|
4799
5024
|
const oi = diff.keep.get(j);
|
|
4800
5025
|
if (oi === void 0) continue;
|
|
4801
|
-
if (oi < lastOld) return
|
|
5026
|
+
if (oi < lastOld) return "kept order violation";
|
|
4802
5027
|
lastOld = oi;
|
|
4803
5028
|
}
|
|
4804
5029
|
const subOldByNew = new Map(diff.substituted.map((s) => [s.newIndex, s.oldIndex]));
|
|
@@ -4809,8 +5034,10 @@ var DocxEditor = class _DocxEditor {
|
|
|
4809
5034
|
oldWrapper.replaceWith(freshRoot);
|
|
4810
5035
|
} else if (oldWrapper === oldNodes[oi]) {
|
|
4811
5036
|
oldNodes[oi].replaceWith(freshRoot);
|
|
5037
|
+
} else if (!oldNodes[oi].hasAttribute("data-render-sig") && unidOf(units[nj].id) === oldNodes[oi].getAttribute("data-anchor")) {
|
|
5038
|
+
oldNodes[oi].replaceWith(freshRoot);
|
|
4812
5039
|
} else {
|
|
4813
|
-
return
|
|
5040
|
+
return `leaf render into wrapped slot (unit ${units[nj].id.slice(0, 24)})`;
|
|
4814
5041
|
}
|
|
4815
5042
|
this.wireUnit(freshRoot, units[nj]);
|
|
4816
5043
|
}
|
|
@@ -4837,10 +5064,11 @@ var DocxEditor = class _DocxEditor {
|
|
|
4837
5064
|
}
|
|
4838
5065
|
const prevW = prev ? this.unitWrapperOf(prev) : null;
|
|
4839
5066
|
const nextW = next ? this.unitWrapperOf(next) : null;
|
|
4840
|
-
if (prevW && nextW && prevW.parentElement !== nextW.parentElement)
|
|
5067
|
+
if (prevW && nextW && prevW.parentElement !== nextW.parentElement)
|
|
5068
|
+
return "insert neighbors in different parents";
|
|
4841
5069
|
if (prevW) prevW.after(el);
|
|
4842
5070
|
else if (nextW) nextW.before(el);
|
|
4843
|
-
else return
|
|
5071
|
+
else return "insert with no anchored neighbor";
|
|
4844
5072
|
this.wireUnit(el, units[j]);
|
|
4845
5073
|
}
|
|
4846
5074
|
for (const i of pureRemoved) {
|
|
@@ -5015,6 +5243,1666 @@ var DocxEditor = class _DocxEditor {
|
|
|
5015
5243
|
}
|
|
5016
5244
|
};
|
|
5017
5245
|
|
|
5246
|
+
// src/ribbon-chrome.ts
|
|
5247
|
+
var RIBBON_STYLE_VERSION = "5";
|
|
5248
|
+
var RIBBON_STYLE_ATTR = "data-docxodus-ribbon-styles";
|
|
5249
|
+
var RIBBON_CSS = `
|
|
5250
|
+
.dxr {
|
|
5251
|
+
--dxr-ink: #101418;
|
|
5252
|
+
--dxr-sheet: #ffffff;
|
|
5253
|
+
--dxr-chrome: #eef1f6;
|
|
5254
|
+
--dxr-chrome-sunk: #e3e8f0;
|
|
5255
|
+
--dxr-rule: #d3dae4;
|
|
5256
|
+
--dxr-accent: #1f5fd0;
|
|
5257
|
+
--dxr-wash: #dde8fb;
|
|
5258
|
+
--dxr-muted: #5d6975;
|
|
5259
|
+
--dxr-data: #0b6f6a;
|
|
5260
|
+
--dxr-danger: #a3341f;
|
|
5261
|
+
--dxr-desk: #dfe3ea;
|
|
5262
|
+
--dxr-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
|
5263
|
+
--dxr-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
|
|
5264
|
+
--dxr-tap: 30px;
|
|
5265
|
+
|
|
5266
|
+
position: relative;
|
|
5267
|
+
display: flex;
|
|
5268
|
+
flex-direction: column;
|
|
5269
|
+
height: 100%;
|
|
5270
|
+
min-height: 0;
|
|
5271
|
+
isolation: isolate;
|
|
5272
|
+
font-family: var(--dxr-ui);
|
|
5273
|
+
color: var(--dxr-ink);
|
|
5274
|
+
background: var(--dxr-desk);
|
|
5275
|
+
-webkit-text-size-adjust: 100%;
|
|
5276
|
+
}
|
|
5277
|
+
.dxr *, .dxr *::before, .dxr *::after { box-sizing: border-box; }
|
|
5278
|
+
|
|
5279
|
+
/* Touch devices get bigger hit targets everywhere the token is used. */
|
|
5280
|
+
@media (pointer: coarse) { .dxr { --dxr-tap: 40px; } }
|
|
5281
|
+
|
|
5282
|
+
/* \u2500\u2500 Chrome shell \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
5283
|
+
.dxr-chrome {
|
|
5284
|
+
position: sticky;
|
|
5285
|
+
top: 0;
|
|
5286
|
+
z-index: 10;
|
|
5287
|
+
flex: 0 0 auto;
|
|
5288
|
+
background: var(--dxr-chrome);
|
|
5289
|
+
border-bottom: 1px solid var(--dxr-rule);
|
|
5290
|
+
}
|
|
5291
|
+
|
|
5292
|
+
.dxr-titlebar {
|
|
5293
|
+
display: flex;
|
|
5294
|
+
align-items: center;
|
|
5295
|
+
gap: 10px;
|
|
5296
|
+
padding: 6px 10px 0;
|
|
5297
|
+
}
|
|
5298
|
+
.dxr-brand {
|
|
5299
|
+
display: flex;
|
|
5300
|
+
align-items: baseline;
|
|
5301
|
+
gap: 7px;
|
|
5302
|
+
min-width: 0;
|
|
5303
|
+
font-size: 13px;
|
|
5304
|
+
font-weight: 600;
|
|
5305
|
+
letter-spacing: -.01em;
|
|
5306
|
+
}
|
|
5307
|
+
.dxr-brand .dxr-mark {
|
|
5308
|
+
flex: 0 0 auto;
|
|
5309
|
+
width: 9px;
|
|
5310
|
+
height: 9px;
|
|
5311
|
+
background: var(--dxr-accent);
|
|
5312
|
+
clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
|
|
5313
|
+
}
|
|
5314
|
+
.dxr-brand .dxr-docname {
|
|
5315
|
+
overflow: hidden;
|
|
5316
|
+
max-width: 22ch;
|
|
5317
|
+
color: var(--dxr-muted);
|
|
5318
|
+
font-size: 12px;
|
|
5319
|
+
font-weight: 400;
|
|
5320
|
+
text-overflow: ellipsis;
|
|
5321
|
+
white-space: nowrap;
|
|
5322
|
+
}
|
|
5323
|
+
.dxr-quick { flex: 0 0 auto; display: flex; align-items: center; gap: 3px; }
|
|
5324
|
+
.dxr-titlebar .dxr-spacer { flex: 1; }
|
|
5325
|
+
.dxr-status {
|
|
5326
|
+
overflow: hidden;
|
|
5327
|
+
max-width: 42ch;
|
|
5328
|
+
color: var(--dxr-muted);
|
|
5329
|
+
font-family: var(--dxr-mono);
|
|
5330
|
+
font-size: 11.5px;
|
|
5331
|
+
text-overflow: ellipsis;
|
|
5332
|
+
white-space: nowrap;
|
|
5333
|
+
}
|
|
5334
|
+
|
|
5335
|
+
/* \u2500\u2500 Tab strip \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
5336
|
+
.dxr-tabs {
|
|
5337
|
+
display: flex;
|
|
5338
|
+
gap: 1px;
|
|
5339
|
+
padding: 6px 10px 0;
|
|
5340
|
+
overflow-x: auto;
|
|
5341
|
+
scrollbar-width: none;
|
|
5342
|
+
}
|
|
5343
|
+
.dxr-tabs::-webkit-scrollbar { display: none; }
|
|
5344
|
+
.dxr-tab {
|
|
5345
|
+
flex: 0 0 auto;
|
|
5346
|
+
padding: 6px 15px 7px;
|
|
5347
|
+
border: 1px solid transparent;
|
|
5348
|
+
border-bottom: none;
|
|
5349
|
+
border-radius: 5px 5px 0 0;
|
|
5350
|
+
background: none;
|
|
5351
|
+
color: var(--dxr-muted);
|
|
5352
|
+
font: inherit;
|
|
5353
|
+
font-size: 12.5px;
|
|
5354
|
+
cursor: pointer;
|
|
5355
|
+
}
|
|
5356
|
+
.dxr-tab:hover { color: var(--dxr-ink); background: #e6ebf3; }
|
|
5357
|
+
.dxr-tab[aria-selected="true"] {
|
|
5358
|
+
color: var(--dxr-ink);
|
|
5359
|
+
font-weight: 600;
|
|
5360
|
+
background: var(--dxr-chrome-sunk);
|
|
5361
|
+
border-color: var(--dxr-rule);
|
|
5362
|
+
box-shadow: inset 0 2px 0 var(--dxr-accent);
|
|
5363
|
+
}
|
|
5364
|
+
/* Contextual tab \u2014 present only while the caret is inside a table. */
|
|
5365
|
+
.dxr-tab[data-contextual] { color: var(--dxr-accent); }
|
|
5366
|
+
.dxr-tab[hidden] { display: none; }
|
|
5367
|
+
|
|
5368
|
+
/* \u2500\u2500 Ribbon panels \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
5369
|
+
.dxr-ribbon { background: var(--dxr-chrome-sunk); border-top: 1px solid var(--dxr-rule); }
|
|
5370
|
+
.dxr-ribbon[aria-disabled="true"] { opacity: .45; pointer-events: none; }
|
|
5371
|
+
.dxr-panel {
|
|
5372
|
+
display: none;
|
|
5373
|
+
align-items: stretch;
|
|
5374
|
+
padding: 7px 10px 8px;
|
|
5375
|
+
overflow-x: auto;
|
|
5376
|
+
overscroll-behavior-x: contain;
|
|
5377
|
+
}
|
|
5378
|
+
.dxr-panel[data-active] { display: flex; }
|
|
5379
|
+
/* Group label sits ABOVE its controls (a spec-sheet reading), with hairline
|
|
5380
|
+
dividers rather than boxes \u2014 lighter than the boxed, label-under convention. */
|
|
5381
|
+
.dxr-group {
|
|
5382
|
+
flex: 0 0 auto;
|
|
5383
|
+
display: flex;
|
|
5384
|
+
flex-direction: column;
|
|
5385
|
+
gap: 5px;
|
|
5386
|
+
padding: 0 13px;
|
|
5387
|
+
border-right: 1px solid var(--dxr-rule);
|
|
5388
|
+
}
|
|
5389
|
+
.dxr-group:last-child { border-right: none; }
|
|
5390
|
+
.dxr-group:first-child { padding-left: 0; }
|
|
5391
|
+
.dxr-glabel {
|
|
5392
|
+
color: var(--dxr-muted);
|
|
5393
|
+
font-size: 9.5px;
|
|
5394
|
+
font-weight: 600;
|
|
5395
|
+
letter-spacing: .11em;
|
|
5396
|
+
text-transform: uppercase;
|
|
5397
|
+
}
|
|
5398
|
+
.dxr-row { display: flex; gap: 3px; align-items: center; }
|
|
5399
|
+
|
|
5400
|
+
/* \u2500\u2500 Controls \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
5401
|
+
.dxr button, .dxr label.dxr-btn {
|
|
5402
|
+
min-height: var(--dxr-tap);
|
|
5403
|
+
padding: 5px 9px;
|
|
5404
|
+
border: 1px solid transparent;
|
|
5405
|
+
border-radius: 4px;
|
|
5406
|
+
background: none;
|
|
5407
|
+
color: var(--dxr-ink);
|
|
5408
|
+
font: inherit;
|
|
5409
|
+
font-size: 13px;
|
|
5410
|
+
line-height: 1.15;
|
|
5411
|
+
cursor: pointer;
|
|
5412
|
+
}
|
|
5413
|
+
.dxr label.dxr-btn { display: inline-flex; align-items: center; }
|
|
5414
|
+
.dxr button:hover, .dxr label.dxr-btn:hover { background: #d6deea; }
|
|
5415
|
+
.dxr button:active { background: #c8d3e3; }
|
|
5416
|
+
.dxr button:disabled { opacity: .38; cursor: default; background: none; }
|
|
5417
|
+
.dxr button.dxr-on { color: var(--dxr-accent); background: var(--dxr-wash); border-color: #b3ccf2; }
|
|
5418
|
+
.dxr-quick button, .dxr-quick label.dxr-btn {
|
|
5419
|
+
padding: 4px 10px;
|
|
5420
|
+
border-color: var(--dxr-rule);
|
|
5421
|
+
background: #f7f9fc;
|
|
5422
|
+
font-size: 12.5px;
|
|
5423
|
+
}
|
|
5424
|
+
.dxr-quick button:hover, .dxr-quick label.dxr-btn:hover { background: #fff; border-color: #b9c4d4; }
|
|
5425
|
+
.dxr-quick button:disabled:hover { background: #f7f9fc; border-color: var(--dxr-rule); }
|
|
5426
|
+
.dxr button.dxr-icon { min-width: var(--dxr-tap); text-align: center; }
|
|
5427
|
+
/* Icons are inline SVG drawn from the same shapes the control acts on (text lines,
|
|
5428
|
+
rules), so alignment and indent read at a glance instead of relying on arrow
|
|
5429
|
+
glyphs that collide with undo/redo. currentColor keeps them in step with state. */
|
|
5430
|
+
.dxr button svg { display: block; margin: 0 auto; fill: currentColor; }
|
|
5431
|
+
.dxr button.dxr-wide { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
|
|
5432
|
+
.dxr button.dxr-danger:hover { color: var(--dxr-danger); background: #f6dcd6; }
|
|
5433
|
+
.dxr select, .dxr input[type="number"], .dxr input[type="text"] {
|
|
5434
|
+
min-height: var(--dxr-tap);
|
|
5435
|
+
padding: 4px 6px;
|
|
5436
|
+
border: 1px solid var(--dxr-rule);
|
|
5437
|
+
border-radius: 4px;
|
|
5438
|
+
background: #f7f9fc;
|
|
5439
|
+
color: var(--dxr-ink);
|
|
5440
|
+
font: inherit;
|
|
5441
|
+
font-size: 12.5px;
|
|
5442
|
+
}
|
|
5443
|
+
.dxr select:focus-visible, .dxr input:focus-visible, .dxr button:focus-visible,
|
|
5444
|
+
.dxr .dxr-tab:focus-visible, .dxr label.dxr-btn:focus-within {
|
|
5445
|
+
outline: 2px solid var(--dxr-accent);
|
|
5446
|
+
outline-offset: 1px;
|
|
5447
|
+
}
|
|
5448
|
+
.dxr [data-dxr="fontsize"] { width: 62px; }
|
|
5449
|
+
.dxr [data-dxr="fontfamily"] { max-width: 132px; }
|
|
5450
|
+
.dxr [data-dxr="pgstart"] { width: 64px; }
|
|
5451
|
+
.dxr-toggle {
|
|
5452
|
+
display: inline-flex;
|
|
5453
|
+
gap: 5px;
|
|
5454
|
+
align-items: center;
|
|
5455
|
+
color: var(--dxr-ink);
|
|
5456
|
+
font-size: 12.5px;
|
|
5457
|
+
white-space: nowrap;
|
|
5458
|
+
cursor: pointer;
|
|
5459
|
+
}
|
|
5460
|
+
.dxr-note { color: var(--dxr-muted); font-size: 11.5px; }
|
|
5461
|
+
|
|
5462
|
+
/* \u2500\u2500 Anchor rail \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
5463
|
+
The addressing spine made permanent chrome. Every block in this editor is
|
|
5464
|
+
addressable as kind:scope:unid, and the model of record is a live WASM session \u2014
|
|
5465
|
+
so the surface states both, live, instead of hiding them behind devtools. It also
|
|
5466
|
+
reports each command's real cost, which is what a smoke test needs to see. */
|
|
5467
|
+
.dxr-rail {
|
|
5468
|
+
display: flex;
|
|
5469
|
+
align-items: center;
|
|
5470
|
+
height: 25px;
|
|
5471
|
+
padding: 0 10px;
|
|
5472
|
+
overflow-x: auto;
|
|
5473
|
+
background: #f7f9fc;
|
|
5474
|
+
border-top: 1px solid var(--dxr-rule);
|
|
5475
|
+
color: var(--dxr-muted);
|
|
5476
|
+
font-family: var(--dxr-mono);
|
|
5477
|
+
font-size: 11.5px;
|
|
5478
|
+
scrollbar-width: none;
|
|
5479
|
+
}
|
|
5480
|
+
.dxr-rail::-webkit-scrollbar { display: none; }
|
|
5481
|
+
.dxr-rail .dxr-cell {
|
|
5482
|
+
display: flex;
|
|
5483
|
+
align-items: baseline;
|
|
5484
|
+
gap: 6px;
|
|
5485
|
+
padding: 0 13px;
|
|
5486
|
+
border-right: 1px solid var(--dxr-rule);
|
|
5487
|
+
white-space: nowrap;
|
|
5488
|
+
}
|
|
5489
|
+
.dxr-rail .dxr-cell:first-child { padding-left: 0; }
|
|
5490
|
+
.dxr-rail .dxr-cell:last-child { border-right: none; }
|
|
5491
|
+
.dxr-rail .dxr-k {
|
|
5492
|
+
color: #8b96a3;
|
|
5493
|
+
font-family: var(--dxr-ui);
|
|
5494
|
+
font-size: 9.5px;
|
|
5495
|
+
letter-spacing: .1em;
|
|
5496
|
+
text-transform: uppercase;
|
|
5497
|
+
}
|
|
5498
|
+
.dxr-rail .dxr-v { color: var(--dxr-data); }
|
|
5499
|
+
.dxr-rail .dxr-v.dxr-flash { animation: dxr-railflash .45s ease-out; }
|
|
5500
|
+
@keyframes dxr-railflash { from { background: #b9ecdf; } to { background: transparent; } }
|
|
5501
|
+
|
|
5502
|
+
/* \u2500\u2500 Hint \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
5503
|
+
.dxr-hint {
|
|
5504
|
+
flex: 0 0 auto;
|
|
5505
|
+
max-width: 920px;
|
|
5506
|
+
margin: 0 auto;
|
|
5507
|
+
padding: 9px 16px 0;
|
|
5508
|
+
color: var(--dxr-muted);
|
|
5509
|
+
font-size: 12px;
|
|
5510
|
+
line-height: 1.5;
|
|
5511
|
+
}
|
|
5512
|
+
.dxr-hint kbd {
|
|
5513
|
+
padding: 0 4px;
|
|
5514
|
+
border: 1px solid var(--dxr-rule);
|
|
5515
|
+
border-radius: 3px;
|
|
5516
|
+
background: #e8ecf3;
|
|
5517
|
+
font-family: var(--dxr-mono);
|
|
5518
|
+
font-size: 11px;
|
|
5519
|
+
}
|
|
5520
|
+
|
|
5521
|
+
/* \u2500\u2500 Document surface \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
5522
|
+
The surface is also the element the converter's own stylesheet treats as the
|
|
5523
|
+
document body: in an embed, its "body { margin: 20px }" is rewritten to
|
|
5524
|
+
[data-docxodus-embed-root="dN"] [data-dxr-surface] \u2014 (0,2,0), and inserted AFTER
|
|
5525
|
+
this sheet, so it wins a tie. Rules that own the SHEET BOX (centering, page
|
|
5526
|
+
padding, the paper itself) therefore qualify with the root's data-chrome to reach
|
|
5527
|
+
(0,3,0). Rules that only style CONTENT stay unqualified \u2014 there the converter
|
|
5528
|
+
SHOULD win.
|
|
5529
|
+
(No backticks in this file's comments: the stylesheet is a template literal.) */
|
|
5530
|
+
.dxr-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; }
|
|
5531
|
+
.dxr[data-chrome] .dxr-surface { max-width: 920px; margin: 26px auto; padding: 0 16px 96px; }
|
|
5532
|
+
.dxr-surface[data-view="continuous"] > * { background: var(--dxr-sheet); }
|
|
5533
|
+
.dxr[data-chrome] .dxr-surface[data-view="continuous"] {
|
|
5534
|
+
padding: 56px 72px;
|
|
5535
|
+
border-radius: 3px;
|
|
5536
|
+
background: var(--dxr-sheet);
|
|
5537
|
+
box-shadow: 0 1px 3px rgba(16, 20, 24, .14), 0 8px 24px rgba(16, 20, 24, .05);
|
|
5538
|
+
}
|
|
5539
|
+
.dxr-surface [contenteditable="true"]:focus {
|
|
5540
|
+
outline: 2px solid var(--dxr-accent);
|
|
5541
|
+
outline-offset: 2px;
|
|
5542
|
+
border-radius: 2px;
|
|
5543
|
+
}
|
|
5544
|
+
@media (hover: hover) { .dxr-surface [contenteditable="true"]:hover { background: #f2f7ff; } }
|
|
5545
|
+
|
|
5546
|
+
/* Header/footer bands: stories live in their own OOXML parts outside the body,
|
|
5547
|
+
so they dock as their own regions. Styled from the same tokens as the ribbon
|
|
5548
|
+
so the surface reads as one instrument rather than two apps. */
|
|
5549
|
+
.dxr-surface .docx-hf-band {
|
|
5550
|
+
margin: 0 0 14px;
|
|
5551
|
+
padding: 9px 72px 13px;
|
|
5552
|
+
border: 1px solid var(--dxr-rule);
|
|
5553
|
+
border-left: 2px solid #c2ccd9;
|
|
5554
|
+
border-radius: 3px;
|
|
5555
|
+
background: var(--dxr-sheet);
|
|
5556
|
+
}
|
|
5557
|
+
.dxr-surface .docx-hf-band + .docx-body-flow { margin-top: 0; }
|
|
5558
|
+
.dxr-surface .docx-hf-band[data-hf-band="footer"] { margin: 14px 0 0; }
|
|
5559
|
+
.dxr-surface .docx-hf-chrome {
|
|
5560
|
+
display: flex;
|
|
5561
|
+
gap: 8px;
|
|
5562
|
+
align-items: center;
|
|
5563
|
+
flex-wrap: wrap;
|
|
5564
|
+
margin: 0 0 7px -60px;
|
|
5565
|
+
color: var(--dxr-muted);
|
|
5566
|
+
font-size: 9.5px;
|
|
5567
|
+
font-weight: 600;
|
|
5568
|
+
letter-spacing: .11em;
|
|
5569
|
+
text-transform: uppercase;
|
|
5570
|
+
}
|
|
5571
|
+
.dxr-surface .docx-hf-chrome select, .dxr-surface .docx-hf-chrome input {
|
|
5572
|
+
padding: 3px 5px;
|
|
5573
|
+
border: 1px solid var(--dxr-rule);
|
|
5574
|
+
border-radius: 4px;
|
|
5575
|
+
background: #f7f9fc;
|
|
5576
|
+
color: var(--dxr-ink);
|
|
5577
|
+
font: inherit;
|
|
5578
|
+
font-family: var(--dxr-ui);
|
|
5579
|
+
font-size: 12.5px;
|
|
5580
|
+
font-weight: 400;
|
|
5581
|
+
letter-spacing: normal;
|
|
5582
|
+
text-transform: none;
|
|
5583
|
+
}
|
|
5584
|
+
.dxr-surface .docx-hf-chrome input[data-hf-pagestart] { width: 64px; }
|
|
5585
|
+
.dxr-surface .docx-hf-label { font-weight: 600; }
|
|
5586
|
+
.dxr-surface .docx-hf-warning {
|
|
5587
|
+
margin: 0 0 8px -60px;
|
|
5588
|
+
padding: 7px 9px;
|
|
5589
|
+
border: 1px solid #e8d9a8;
|
|
5590
|
+
border-left: 2px solid #c9a227;
|
|
5591
|
+
border-radius: 3px;
|
|
5592
|
+
background: #fdf6e3;
|
|
5593
|
+
color: #6b5310;
|
|
5594
|
+
font-size: 12px;
|
|
5595
|
+
line-height: 1.45;
|
|
5596
|
+
}
|
|
5597
|
+
.dxr-surface .docx-hf-warning button {
|
|
5598
|
+
margin-left: 6px;
|
|
5599
|
+
padding: 2px 8px;
|
|
5600
|
+
border-color: #e8d9a8;
|
|
5601
|
+
background: #fff;
|
|
5602
|
+
font-size: 12px;
|
|
5603
|
+
}
|
|
5604
|
+
.dxr-surface .docx-hf-placeholder { color: #9aa4b1; font-style: italic; }
|
|
5605
|
+
.dxr-surface .docx-hf-inherited {
|
|
5606
|
+
color: var(--dxr-muted);
|
|
5607
|
+
font-style: italic;
|
|
5608
|
+
font-weight: 400;
|
|
5609
|
+
letter-spacing: normal;
|
|
5610
|
+
text-transform: none;
|
|
5611
|
+
}
|
|
5612
|
+
.dxr-surface .docx-hf-band[data-hf-inherited] { border-style: dashed; }
|
|
5613
|
+
.dxr[data-chrome] .dxr-surface[data-view="continuous"]:has(.docx-body-flow) {
|
|
5614
|
+
padding: 0;
|
|
5615
|
+
background: transparent;
|
|
5616
|
+
box-shadow: none;
|
|
5617
|
+
}
|
|
5618
|
+
.dxr[data-chrome] .dxr-surface[data-view="continuous"] .docx-body-flow {
|
|
5619
|
+
padding: 56px 72px;
|
|
5620
|
+
border-radius: 3px;
|
|
5621
|
+
background: var(--dxr-sheet);
|
|
5622
|
+
box-shadow: 0 1px 3px rgba(16, 20, 24, .14), 0 8px 24px rgba(16, 20, 24, .05);
|
|
5623
|
+
}
|
|
5624
|
+
|
|
5625
|
+
/* \u2500\u2500 Table size picker \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
5626
|
+
.dxr-pop {
|
|
5627
|
+
display: none;
|
|
5628
|
+
position: absolute;
|
|
5629
|
+
z-index: 30;
|
|
5630
|
+
padding: 9px;
|
|
5631
|
+
border: 1px solid var(--dxr-rule);
|
|
5632
|
+
border-radius: 6px;
|
|
5633
|
+
background: #fff;
|
|
5634
|
+
box-shadow: 0 4px 16px rgba(16, 20, 24, .18);
|
|
5635
|
+
}
|
|
5636
|
+
.dxr-pop[data-open] { display: block; }
|
|
5637
|
+
.dxr-gridcells { display: grid; grid-template-columns: repeat(10, 16px); gap: 2px; }
|
|
5638
|
+
.dxr-gridcells div {
|
|
5639
|
+
width: 16px;
|
|
5640
|
+
height: 16px;
|
|
5641
|
+
border: 1px solid var(--dxr-rule);
|
|
5642
|
+
border-radius: 2px;
|
|
5643
|
+
background: #f2f5f9;
|
|
5644
|
+
cursor: pointer;
|
|
5645
|
+
}
|
|
5646
|
+
.dxr-gridcells div[data-on] { background: var(--dxr-wash); border-color: var(--dxr-accent); }
|
|
5647
|
+
.dxr-popfoot {
|
|
5648
|
+
display: flex;
|
|
5649
|
+
justify-content: space-between;
|
|
5650
|
+
align-items: center;
|
|
5651
|
+
flex-wrap: wrap;
|
|
5652
|
+
gap: 10px;
|
|
5653
|
+
margin-top: 8px;
|
|
5654
|
+
font-size: 12px;
|
|
5655
|
+
}
|
|
5656
|
+
|
|
5657
|
+
/* \u2500\u2500 Compact chrome (the mobile-first base) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
5658
|
+
One scrolling strip per tab instead of a multi-row ribbon: group labels turn
|
|
5659
|
+
into inline dividers, the rail and hint step aside, and the picker becomes a
|
|
5660
|
+
bottom sheet because there is no room to hang a popover off a button. */
|
|
5661
|
+
/* A 320px phone cannot hold the product name AND the file actions, and the file
|
|
5662
|
+
actions are what a user came for. The strip also scrolls, so nothing is stranded. */
|
|
5663
|
+
.dxr[data-chrome="compact"] .dxr-titlebar {
|
|
5664
|
+
gap: 6px;
|
|
5665
|
+
padding: 5px 8px 0;
|
|
5666
|
+
overflow-x: auto;
|
|
5667
|
+
scrollbar-width: none;
|
|
5668
|
+
}
|
|
5669
|
+
.dxr[data-chrome="compact"] .dxr-titlebar::-webkit-scrollbar { display: none; }
|
|
5670
|
+
.dxr[data-chrome="compact"] .dxr-brandname { display: none; }
|
|
5671
|
+
.dxr[data-chrome="compact"] .dxr-brand { flex: 0 1 auto; }
|
|
5672
|
+
/* A filename clipped to "do..." tells you less than no filename at all, so it keeps a
|
|
5673
|
+
readable floor and the strip scrolls instead. The tighter file-action padding is what
|
|
5674
|
+
buys that floor back on a 390px screen. */
|
|
5675
|
+
.dxr[data-chrome="compact"] .dxr-brand .dxr-docname { min-width: 6ch; max-width: 14ch; }
|
|
5676
|
+
.dxr[data-chrome="compact"] .dxr-quick button,
|
|
5677
|
+
.dxr[data-chrome="compact"] .dxr-quick label.dxr-btn { padding: 4px 8px; }
|
|
5678
|
+
.dxr[data-chrome="compact"] .dxr-status { display: none; }
|
|
5679
|
+
.dxr[data-chrome="compact"] .dxr-tabs { padding: 5px 8px 0; }
|
|
5680
|
+
.dxr[data-chrome="compact"] .dxr-tab { padding: 6px 12px 7px; font-size: 12px; }
|
|
5681
|
+
.dxr[data-chrome="compact"] .dxr-panel {
|
|
5682
|
+
align-items: center;
|
|
5683
|
+
gap: 4px;
|
|
5684
|
+
padding: 5px 8px;
|
|
5685
|
+
scroll-snap-type: x proximity;
|
|
5686
|
+
}
|
|
5687
|
+
.dxr[data-chrome="compact"] .dxr-group {
|
|
5688
|
+
flex-direction: row;
|
|
5689
|
+
align-items: center;
|
|
5690
|
+
gap: 4px;
|
|
5691
|
+
padding: 0 8px;
|
|
5692
|
+
scroll-snap-align: start;
|
|
5693
|
+
}
|
|
5694
|
+
.dxr[data-chrome="compact"] .dxr-glabel { display: none; }
|
|
5695
|
+
.dxr[data-chrome="compact"] .dxr-note { display: none; }
|
|
5696
|
+
.dxr[data-chrome="compact"] .dxr-rail { display: none; }
|
|
5697
|
+
.dxr[data-chrome="compact"] .dxr-hint { display: none; }
|
|
5698
|
+
.dxr[data-chrome="compact"] .dxr-surface { margin: 12px auto; padding: 0 10px 64px; }
|
|
5699
|
+
.dxr[data-chrome="compact"] .dxr-surface[data-view="continuous"] { padding: 22px 18px; }
|
|
5700
|
+
.dxr[data-chrome="compact"] .dxr-surface[data-view="continuous"] .docx-body-flow { padding: 22px 18px; }
|
|
5701
|
+
.dxr[data-chrome="compact"] .dxr-surface .docx-hf-band { padding: 9px 18px 13px; }
|
|
5702
|
+
.dxr[data-chrome="compact"] .dxr-surface .docx-hf-chrome,
|
|
5703
|
+
.dxr[data-chrome="compact"] .dxr-surface .docx-hf-warning { margin-left: 0; }
|
|
5704
|
+
/* A popover anchored to a button has nowhere to go on a narrow surface, so the
|
|
5705
|
+
picker docks to the bottom edge where a thumb already is. */
|
|
5706
|
+
.dxr[data-chrome="compact"] .dxr-pop[data-open] {
|
|
5707
|
+
position: fixed;
|
|
5708
|
+
left: 50%;
|
|
5709
|
+
right: auto;
|
|
5710
|
+
bottom: 12px;
|
|
5711
|
+
top: auto !important;
|
|
5712
|
+
transform: translateX(-50%);
|
|
5713
|
+
max-width: calc(100vw - 20px);
|
|
5714
|
+
}
|
|
5715
|
+
|
|
5716
|
+
/* \u2500\u2500 Loading overlay \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
5717
|
+
Kept from the shipped demo: the wait is real (a .NET runtime is streaming), so
|
|
5718
|
+
the surface spends it explaining what is being built rather than showing a
|
|
5719
|
+
spinner. It covers the whole instrument so half-built chrome never flashes. */
|
|
5720
|
+
.dxr-loader {
|
|
5721
|
+
position: absolute;
|
|
5722
|
+
inset: 0;
|
|
5723
|
+
z-index: 40;
|
|
5724
|
+
display: grid;
|
|
5725
|
+
place-items: center;
|
|
5726
|
+
padding: 24px;
|
|
5727
|
+
color: #f4f9ff;
|
|
5728
|
+
background:
|
|
5729
|
+
radial-gradient(circle at 20% 20%, rgba(63, 128, 255, .24), transparent 22rem),
|
|
5730
|
+
radial-gradient(circle at 82% 80%, rgba(176, 91, 255, .22), transparent 24rem),
|
|
5731
|
+
linear-gradient(145deg, #071221 0%, #0b1930 52%, #101426 100%);
|
|
5732
|
+
transition: opacity .55s ease, visibility .55s ease;
|
|
5733
|
+
}
|
|
5734
|
+
.dxr-loader[hidden] { display: none; }
|
|
5735
|
+
/* pointer-events drops the instant the fade starts: the surface underneath is already
|
|
5736
|
+
live, so a click during the half-second fade should reach it rather than be eaten. */
|
|
5737
|
+
.dxr-loader[data-done] { opacity: 0; visibility: hidden; pointer-events: none; }
|
|
5738
|
+
.dxr-loader-grid {
|
|
5739
|
+
width: min(850px, 100%);
|
|
5740
|
+
display: grid;
|
|
5741
|
+
grid-template-columns: 1fr;
|
|
5742
|
+
align-items: center;
|
|
5743
|
+
gap: 22px;
|
|
5744
|
+
text-align: center;
|
|
5745
|
+
}
|
|
5746
|
+
.dxr-visual { position: relative; width: min(170px, 52vw); aspect-ratio: 1; margin: 0 auto; }
|
|
5747
|
+
.dxr-orbit {
|
|
5748
|
+
position: absolute;
|
|
5749
|
+
inset: 7%;
|
|
5750
|
+
border: 1px solid rgba(115, 204, 255, .22);
|
|
5751
|
+
border-radius: 50%;
|
|
5752
|
+
animation: dxr-spin 9s linear infinite;
|
|
5753
|
+
}
|
|
5754
|
+
.dxr-orbit.dxr-two {
|
|
5755
|
+
inset: 20%;
|
|
5756
|
+
border-style: dashed;
|
|
5757
|
+
border-color: rgba(196, 128, 255, .32);
|
|
5758
|
+
animation-duration: 6s;
|
|
5759
|
+
animation-direction: reverse;
|
|
5760
|
+
}
|
|
5761
|
+
.dxr-orbit::before, .dxr-orbit::after {
|
|
5762
|
+
position: absolute;
|
|
5763
|
+
width: 10px;
|
|
5764
|
+
height: 10px;
|
|
5765
|
+
border-radius: 50%;
|
|
5766
|
+
content: "";
|
|
5767
|
+
background: #52e5ff;
|
|
5768
|
+
box-shadow: 0 0 18px #52e5ff;
|
|
5769
|
+
}
|
|
5770
|
+
.dxr-orbit::before { top: -5px; left: 50%; }
|
|
5771
|
+
.dxr-orbit::after { right: 7%; bottom: 12%; background: #b26cff; box-shadow: 0 0 18px #b26cff; }
|
|
5772
|
+
.dxr-card {
|
|
5773
|
+
position: absolute;
|
|
5774
|
+
inset: 24% 28%;
|
|
5775
|
+
padding: 20px 15px;
|
|
5776
|
+
border: 1px solid rgba(255, 255, 255, .33);
|
|
5777
|
+
border-radius: 14px;
|
|
5778
|
+
background: linear-gradient(150deg, rgba(255, 255, 255, .18), rgba(255, 255, 255, .06));
|
|
5779
|
+
box-shadow: 0 22px 50px rgba(0, 0, 0, .35), 0 0 45px rgba(71, 150, 255, .13);
|
|
5780
|
+
backdrop-filter: blur(10px);
|
|
5781
|
+
animation: dxr-float 3.6s ease-in-out infinite;
|
|
5782
|
+
}
|
|
5783
|
+
.dxr-card::before {
|
|
5784
|
+
position: absolute;
|
|
5785
|
+
top: -9px;
|
|
5786
|
+
right: -9px;
|
|
5787
|
+
padding: 4px 7px;
|
|
5788
|
+
border-radius: 6px;
|
|
5789
|
+
background: #52e5ff;
|
|
5790
|
+
color: #06111d;
|
|
5791
|
+
content: "DOCX";
|
|
5792
|
+
font-size: 8px;
|
|
5793
|
+
font-weight: 900;
|
|
5794
|
+
letter-spacing: .12em;
|
|
5795
|
+
}
|
|
5796
|
+
.dxr-card i {
|
|
5797
|
+
display: block;
|
|
5798
|
+
height: 4px;
|
|
5799
|
+
margin-bottom: 10px;
|
|
5800
|
+
border-radius: 4px;
|
|
5801
|
+
background: rgba(255, 255, 255, .56);
|
|
5802
|
+
transform-origin: left;
|
|
5803
|
+
animation: dxr-pulse 2.2s ease-in-out infinite;
|
|
5804
|
+
}
|
|
5805
|
+
.dxr-card i:nth-child(2) { width: 76%; animation-delay: -.45s; }
|
|
5806
|
+
.dxr-card i:nth-child(3) { width: 88%; animation-delay: -.85s; }
|
|
5807
|
+
.dxr-card i:nth-child(4) { width: 58%; background: rgba(255, 111, 139, .75); animation-delay: -1.2s; }
|
|
5808
|
+
.dxr-chip {
|
|
5809
|
+
position: absolute;
|
|
5810
|
+
display: grid;
|
|
5811
|
+
width: 34px;
|
|
5812
|
+
height: 34px;
|
|
5813
|
+
place-items: center;
|
|
5814
|
+
border: 1px solid rgba(255, 255, 255, .17);
|
|
5815
|
+
border-radius: 11px;
|
|
5816
|
+
background: rgba(12, 28, 49, .88);
|
|
5817
|
+
box-shadow: 0 12px 30px rgba(0, 0, 0, .28);
|
|
5818
|
+
font-size: 11px;
|
|
5819
|
+
font-weight: 850;
|
|
5820
|
+
}
|
|
5821
|
+
.dxr-chip.dxr-b { left: 2%; top: 30%; color: #52e5ff; animation: dxr-chip 3s ease-in-out infinite; }
|
|
5822
|
+
.dxr-chip.dxr-r { right: -2%; bottom: 24%; color: #ff8da0; animation: dxr-chip 3s -1.4s ease-in-out infinite; }
|
|
5823
|
+
.dxr-chip.dxr-s { left: 20%; bottom: 0; color: #52e0a2; animation: dxr-chip 3s -.7s ease-in-out infinite; }
|
|
5824
|
+
.dxr-eyebrow { color: #52e5ff; font-size: 10px; font-weight: 850; letter-spacing: .16em; text-transform: uppercase; }
|
|
5825
|
+
.dxr-loader h2 {
|
|
5826
|
+
margin: 10px auto 10px;
|
|
5827
|
+
max-width: 520px;
|
|
5828
|
+
font-size: clamp(23px, 5vw, 40px);
|
|
5829
|
+
line-height: 1.05;
|
|
5830
|
+
letter-spacing: -.045em;
|
|
5831
|
+
}
|
|
5832
|
+
.dxr-loader-copy > p { margin: 0 auto; max-width: 46ch; color: #9eb2c9; font-size: 13.5px; line-height: 1.6; }
|
|
5833
|
+
.dxr-ad {
|
|
5834
|
+
display: flex;
|
|
5835
|
+
gap: 12px;
|
|
5836
|
+
margin: 20px auto 0;
|
|
5837
|
+
max-width: 420px;
|
|
5838
|
+
padding: 13px;
|
|
5839
|
+
border: 1px solid rgba(126, 160, 200, .16);
|
|
5840
|
+
border-radius: 13px;
|
|
5841
|
+
background: rgba(255, 255, 255, .04);
|
|
5842
|
+
text-align: left;
|
|
5843
|
+
}
|
|
5844
|
+
.dxr-ad .dxr-num { color: #b26cff; font: 800 10px/1.4 var(--dxr-mono); }
|
|
5845
|
+
.dxr-ad strong { display: block; font-size: 12.5px; }
|
|
5846
|
+
.dxr-ad .dxr-adcopy { display: block; margin-top: 4px; color: #849bb5; font-size: 11.5px; line-height: 1.45; }
|
|
5847
|
+
.dxr-ad[data-swap] { animation: dxr-swap .4s ease; }
|
|
5848
|
+
.dxr-track {
|
|
5849
|
+
height: 3px;
|
|
5850
|
+
margin: 22px auto 0;
|
|
5851
|
+
max-width: 420px;
|
|
5852
|
+
overflow: hidden;
|
|
5853
|
+
border-radius: 999px;
|
|
5854
|
+
background: rgba(255, 255, 255, .09);
|
|
5855
|
+
}
|
|
5856
|
+
.dxr-bar {
|
|
5857
|
+
width: 12%;
|
|
5858
|
+
height: 100%;
|
|
5859
|
+
border-radius: inherit;
|
|
5860
|
+
background: linear-gradient(90deg, #52e5ff, #5c7cff, #b26cff);
|
|
5861
|
+
box-shadow: 0 0 16px rgba(82, 229, 255, .55);
|
|
5862
|
+
transition: width .65s cubic-bezier(.22, .8, .28, 1);
|
|
5863
|
+
}
|
|
5864
|
+
.dxr-meta {
|
|
5865
|
+
display: flex;
|
|
5866
|
+
justify-content: space-between;
|
|
5867
|
+
gap: 14px;
|
|
5868
|
+
margin: 9px auto 0;
|
|
5869
|
+
max-width: 420px;
|
|
5870
|
+
color: #647e9c;
|
|
5871
|
+
font: 700 9px/1 var(--dxr-mono);
|
|
5872
|
+
letter-spacing: .09em;
|
|
5873
|
+
text-transform: uppercase;
|
|
5874
|
+
}
|
|
5875
|
+
.dxr-retry {
|
|
5876
|
+
display: none;
|
|
5877
|
+
margin-top: 18px;
|
|
5878
|
+
padding: 9px 14px;
|
|
5879
|
+
border: 1px solid rgba(255, 127, 145, .4);
|
|
5880
|
+
border-radius: 9px;
|
|
5881
|
+
background: rgba(255, 127, 145, .12);
|
|
5882
|
+
color: #fff;
|
|
5883
|
+
cursor: pointer;
|
|
5884
|
+
}
|
|
5885
|
+
.dxr-loader[data-error] .dxr-retry { display: inline-flex; }
|
|
5886
|
+
.dxr-loader[data-error] .dxr-visual { opacity: .35; }
|
|
5887
|
+
|
|
5888
|
+
/* Two columns once there is room \u2014 the visual earns its space beside the copy. */
|
|
5889
|
+
@media (min-width: 760px) {
|
|
5890
|
+
.dxr-loader-grid {
|
|
5891
|
+
grid-template-columns: minmax(220px, .8fr) minmax(300px, 1.2fr);
|
|
5892
|
+
gap: clamp(28px, 6vw, 72px);
|
|
5893
|
+
text-align: left;
|
|
5894
|
+
}
|
|
5895
|
+
.dxr-visual { width: min(280px, 30vw); }
|
|
5896
|
+
.dxr-loader h2 { margin-left: 0; }
|
|
5897
|
+
.dxr-loader-copy > p { margin-left: 0; min-height: 44px; }
|
|
5898
|
+
.dxr-ad, .dxr-track, .dxr-meta { margin-left: 0; }
|
|
5899
|
+
}
|
|
5900
|
+
|
|
5901
|
+
@keyframes dxr-spin { to { transform: rotate(360deg); } }
|
|
5902
|
+
@keyframes dxr-float { 0%, 100% { transform: translateY(-5px) rotate(-2deg); } 50% { transform: translateY(7px) rotate(1deg); } }
|
|
5903
|
+
@keyframes dxr-chip { 0%, 100% { transform: translateY(-4px); } 50% { transform: translateY(5px); } }
|
|
5904
|
+
@keyframes dxr-pulse { 0%, 100% { transform: scaleX(.65); opacity: .45; } 50% { transform: scaleX(1); opacity: .95; } }
|
|
5905
|
+
@keyframes dxr-swap { from { opacity: .1; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
|
|
5906
|
+
|
|
5907
|
+
@media (prefers-reduced-motion: reduce) {
|
|
5908
|
+
.dxr *, .dxr *::before, .dxr *::after {
|
|
5909
|
+
animation-duration: .01ms !important;
|
|
5910
|
+
animation-iteration-count: 1 !important;
|
|
5911
|
+
transition-duration: .01ms !important;
|
|
5912
|
+
}
|
|
5913
|
+
}
|
|
5914
|
+
`;
|
|
5915
|
+
var ICON_ALIGN = (bars) => `<svg width="15" height="13" viewBox="0 0 15 13" aria-hidden="true">${bars}</svg>`;
|
|
5916
|
+
var RIBBON_HTML = `
|
|
5917
|
+
<div class="dxr-chrome">
|
|
5918
|
+
<div class="dxr-titlebar">
|
|
5919
|
+
<span class="dxr-brand"><span class="dxr-mark"></span><span class="dxr-brandname">Docxodus</span>
|
|
5920
|
+
<span class="dxr-docname" data-dxr="docname">no document</span></span>
|
|
5921
|
+
<div class="dxr-quick" data-dxr-files>
|
|
5922
|
+
<button type="button" data-dxr="new" title="Start a new blank document">New</button>
|
|
5923
|
+
<label class="dxr-btn" tabindex="0">Open<input data-dxr="file" type="file" accept=".docx" hidden /></label>
|
|
5924
|
+
<button type="button" data-dxr="save" disabled>Save</button>
|
|
5925
|
+
</div>
|
|
5926
|
+
<div class="dxr-quick">
|
|
5927
|
+
<button type="button" class="dxr-icon" data-dxr="undo" title="Undo (Ctrl+Z)" aria-label="Undo">↶</button>
|
|
5928
|
+
<button type="button" class="dxr-icon" data-dxr="redo" title="Redo (Ctrl+Shift+Z)" aria-label="Redo">↷</button>
|
|
5929
|
+
</div>
|
|
5930
|
+
<span class="dxr-spacer"></span>
|
|
5931
|
+
<span class="dxr-status" data-dxr="status" role="status" aria-live="polite">Booting WASM…</span>
|
|
5932
|
+
</div>
|
|
5933
|
+
|
|
5934
|
+
<div class="dxr-tabs" role="tablist">
|
|
5935
|
+
<button type="button" class="dxr-tab" role="tab" data-tab="home" aria-selected="true">Home</button>
|
|
5936
|
+
<button type="button" class="dxr-tab" role="tab" data-tab="insert" aria-selected="false">Insert</button>
|
|
5937
|
+
<button type="button" class="dxr-tab" role="tab" data-tab="layout" aria-selected="false">Layout</button>
|
|
5938
|
+
<button type="button" class="dxr-tab" role="tab" data-tab="table" data-contextual aria-selected="false" hidden>Table</button>
|
|
5939
|
+
</div>
|
|
5940
|
+
|
|
5941
|
+
<div class="dxr-ribbon" data-dxr="ribbon" aria-disabled="true">
|
|
5942
|
+
<!-- HOME \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 -->
|
|
5943
|
+
<div class="dxr-panel" data-panel="home" data-active>
|
|
5944
|
+
<div class="dxr-group">
|
|
5945
|
+
<span class="dxr-glabel">Text</span>
|
|
5946
|
+
<div class="dxr-row">
|
|
5947
|
+
<button type="button" class="dxr-icon" data-cmd="bold" title="Bold (Ctrl+B)"><b>B</b></button>
|
|
5948
|
+
<button type="button" class="dxr-icon" data-cmd="italic" title="Italic (Ctrl+I)"><i>I</i></button>
|
|
5949
|
+
<button type="button" class="dxr-icon" data-cmd="underline" title="Underline (Ctrl+U)"><u>U</u></button>
|
|
5950
|
+
<button type="button" class="dxr-icon" data-cmd="strike" title="Strikethrough"><s>S</s></button>
|
|
5951
|
+
<button type="button" class="dxr-icon" data-cmd="code" title="Inline code"></></button>
|
|
5952
|
+
<button type="button" class="dxr-icon" data-cmd="superscript" title="Superscript">x²</button>
|
|
5953
|
+
<button type="button" class="dxr-icon" data-cmd="subscript" title="Subscript">x₂</button>
|
|
5954
|
+
</div>
|
|
5955
|
+
<div class="dxr-row">
|
|
5956
|
+
<input data-dxr="fontsize" data-dxr-list="fontsizes" type="number" min="1" max="1638" step="0.5"
|
|
5957
|
+
placeholder="pt" title="Font size in points \u2014 type any value or pick a preset" />
|
|
5958
|
+
<datalist data-dxr="fontsizes">
|
|
5959
|
+
<option>8</option><option>9</option><option>10</option><option>11</option>
|
|
5960
|
+
<option>12</option><option>14</option><option>16</option><option>18</option>
|
|
5961
|
+
<option>20</option><option>24</option><option>28</option><option>36</option>
|
|
5962
|
+
<option>48</option><option>72</option><option>96</option>
|
|
5963
|
+
</datalist>
|
|
5964
|
+
<select data-dxr="fontfamily" title="Font family \u2014 applies to the selection">
|
|
5965
|
+
<option value="">Font…</option>
|
|
5966
|
+
<option>Calibri</option><option>Times New Roman</option><option>Arial</option>
|
|
5967
|
+
<option>Georgia</option><option>Cambria</option><option>Courier New</option>
|
|
5968
|
+
<option>Verdana</option><option>Garamond</option>
|
|
5969
|
+
</select>
|
|
5970
|
+
</div>
|
|
5971
|
+
</div>
|
|
5972
|
+
|
|
5973
|
+
<div class="dxr-group">
|
|
5974
|
+
<span class="dxr-glabel">Paragraph</span>
|
|
5975
|
+
<div class="dxr-row">
|
|
5976
|
+
<button type="button" class="dxr-icon" data-align="left" title="Align left">${ICON_ALIGN(
|
|
5977
|
+
'<rect x="0" y="0" width="15" height="1.6"/><rect x="0" y="3.8" width="9" height="1.6"/><rect x="0" y="7.6" width="15" height="1.6"/><rect x="0" y="11.4" width="9" height="1.6"/>'
|
|
5978
|
+
)}</button>
|
|
5979
|
+
<button type="button" class="dxr-icon" data-align="center" title="Align center">${ICON_ALIGN(
|
|
5980
|
+
'<rect x="0" y="0" width="15" height="1.6"/><rect x="3" y="3.8" width="9" height="1.6"/><rect x="0" y="7.6" width="15" height="1.6"/><rect x="3" y="11.4" width="9" height="1.6"/>'
|
|
5981
|
+
)}</button>
|
|
5982
|
+
<button type="button" class="dxr-icon" data-align="right" title="Align right">${ICON_ALIGN(
|
|
5983
|
+
'<rect x="0" y="0" width="15" height="1.6"/><rect x="6" y="3.8" width="9" height="1.6"/><rect x="0" y="7.6" width="15" height="1.6"/><rect x="6" y="11.4" width="9" height="1.6"/>'
|
|
5984
|
+
)}</button>
|
|
5985
|
+
<button type="button" class="dxr-icon" data-align="justify" title="Justify">${ICON_ALIGN(
|
|
5986
|
+
'<rect x="0" y="0" width="15" height="1.6"/><rect x="0" y="3.8" width="15" height="1.6"/><rect x="0" y="7.6" width="15" height="1.6"/><rect x="0" y="11.4" width="15" height="1.6"/>'
|
|
5987
|
+
)}</button>
|
|
5988
|
+
<button type="button" class="dxr-icon" data-indent="-720" title="Decrease indent">${ICON_ALIGN(
|
|
5989
|
+
'<rect x="0" y="0" width="15" height="1.6"/><rect x="6" y="3.8" width="9" height="1.6"/><rect x="6" y="7.6" width="9" height="1.6"/><rect x="0" y="11.4" width="15" height="1.6"/><path d="M4.6 4.2v4.6L0.6 6.5z"/>'
|
|
5990
|
+
)}</button>
|
|
5991
|
+
<button type="button" class="dxr-icon" data-indent="720" title="Increase indent">${ICON_ALIGN(
|
|
5992
|
+
'<rect x="0" y="0" width="15" height="1.6"/><rect x="6" y="3.8" width="9" height="1.6"/><rect x="6" y="7.6" width="9" height="1.6"/><rect x="0" y="11.4" width="15" height="1.6"/><path d="M0.6 4.2v4.6l4-2.3z"/>'
|
|
5993
|
+
)}</button>
|
|
5994
|
+
</div>
|
|
5995
|
+
<div class="dxr-row">
|
|
5996
|
+
<button type="button" data-list="bullet" title="Bullet list">• List</button>
|
|
5997
|
+
<button type="button" data-list="decimal" title="Numbered list">1. List</button>
|
|
5998
|
+
<button type="button" data-pagebreak title="Start this block on a new page">Page break</button>
|
|
5999
|
+
</div>
|
|
6000
|
+
</div>
|
|
6001
|
+
|
|
6002
|
+
<div class="dxr-group">
|
|
6003
|
+
<span class="dxr-glabel">Block</span>
|
|
6004
|
+
<div class="dxr-row">
|
|
6005
|
+
<select data-dxr="style" title="Paragraph style">
|
|
6006
|
+
<option value="">Style…</option>
|
|
6007
|
+
<option value="Normal">Normal</option>
|
|
6008
|
+
<option value="Heading1">Heading 1</option>
|
|
6009
|
+
<option value="Heading2">Heading 2</option>
|
|
6010
|
+
<option value="Heading3">Heading 3</option>
|
|
6011
|
+
<option value="Title">Title</option>
|
|
6012
|
+
</select>
|
|
6013
|
+
</div>
|
|
6014
|
+
<div class="dxr-row">
|
|
6015
|
+
<button type="button" data-dxr="delblock" class="dxr-danger" title="Delete the block the caret is in">Delete block</button>
|
|
6016
|
+
</div>
|
|
6017
|
+
</div>
|
|
6018
|
+
</div>
|
|
6019
|
+
|
|
6020
|
+
<!-- INSERT \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 -->
|
|
6021
|
+
<div class="dxr-panel" data-panel="insert">
|
|
6022
|
+
<div class="dxr-group">
|
|
6023
|
+
<span class="dxr-glabel">Table</span>
|
|
6024
|
+
<div class="dxr-row">
|
|
6025
|
+
<button type="button" data-dxr="table" title="Insert a table \u2014 pick its size on the grid">▦ Table</button>
|
|
6026
|
+
</div>
|
|
6027
|
+
</div>
|
|
6028
|
+
|
|
6029
|
+
<div class="dxr-group">
|
|
6030
|
+
<span class="dxr-glabel">Rules</span>
|
|
6031
|
+
<div class="dxr-row">
|
|
6032
|
+
<button type="button" data-dxr="hr" class="dxr-wide" title="Insert a single rule"><svg width="22" height="8" viewBox="0 0 22 8" aria-hidden="true"><rect x="0" y="3.2" width="22" height="1.4"/></svg>Single</button>
|
|
6033
|
+
<button type="button" data-dxr="hrThick" class="dxr-wide" title="Insert a thick rule"><svg width="22" height="8" viewBox="0 0 22 8" aria-hidden="true"><rect x="0" y="2.4" width="22" height="3.2"/></svg>Thick</button>
|
|
6034
|
+
<button type="button" data-dxr="hrDouble" class="dxr-wide" title="Insert a double rule"><svg width="22" height="8" viewBox="0 0 22 8" aria-hidden="true"><rect x="0" y="1.6" width="22" height="1.3"/><rect x="0" y="5" width="22" height="1.3"/></svg>Double</button>
|
|
6035
|
+
</div>
|
|
6036
|
+
<div class="dxr-row">
|
|
6037
|
+
<select data-dxr="rulepos" title="Where the rule lands relative to the current block">
|
|
6038
|
+
<option value="below">Below block</option>
|
|
6039
|
+
<option value="above">Above block</option>
|
|
6040
|
+
</select>
|
|
6041
|
+
<button type="button" data-dxr="hrClear" title="Remove the rule or paragraph border">Clear</button>
|
|
6042
|
+
</div>
|
|
6043
|
+
</div>
|
|
6044
|
+
|
|
6045
|
+
<div class="dxr-group">
|
|
6046
|
+
<span class="dxr-glabel">References</span>
|
|
6047
|
+
<div class="dxr-row">
|
|
6048
|
+
<button type="button" data-dxr="footnote" title="Cite a new footnote at the caret">Footnote</button>
|
|
6049
|
+
<button type="button" data-dxr="endnote" title="Cite a new endnote at the caret">Endnote</button>
|
|
6050
|
+
</div>
|
|
6051
|
+
</div>
|
|
6052
|
+
</div>
|
|
6053
|
+
|
|
6054
|
+
<!-- LAYOUT \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 -->
|
|
6055
|
+
<div class="dxr-panel" data-panel="layout">
|
|
6056
|
+
<div class="dxr-group">
|
|
6057
|
+
<span class="dxr-glabel">View</span>
|
|
6058
|
+
<div class="dxr-row">
|
|
6059
|
+
<label class="dxr-toggle"><input data-dxr="paginated" type="checkbox" /> Page view</label>
|
|
6060
|
+
</div>
|
|
6061
|
+
<div class="dxr-row">
|
|
6062
|
+
<label class="dxr-toggle"><input data-dxr="headerfooter" type="checkbox" /> Header & footer bands</label>
|
|
6063
|
+
</div>
|
|
6064
|
+
</div>
|
|
6065
|
+
|
|
6066
|
+
<div class="dxr-group">
|
|
6067
|
+
<span class="dxr-glabel">Page numbers</span>
|
|
6068
|
+
<div class="dxr-row">
|
|
6069
|
+
<select data-dxr="pgfmt" title="Number format for this section">
|
|
6070
|
+
<option value="">Format…</option>
|
|
6071
|
+
<option value="decimal">1, 2, 3</option>
|
|
6072
|
+
<option value="lowerLetter">a, b, c</option>
|
|
6073
|
+
<option value="upperLetter">A, B, C</option>
|
|
6074
|
+
<option value="lowerRoman">i, ii, iii</option>
|
|
6075
|
+
<option value="upperRoman">I, II, III</option>
|
|
6076
|
+
</select>
|
|
6077
|
+
<label class="dxr-toggle">Start at
|
|
6078
|
+
<input data-dxr="pgstart" type="number" min="1" step="1"
|
|
6079
|
+
title="Restart this section's numbering at this value" />
|
|
6080
|
+
</label>
|
|
6081
|
+
<button type="button" data-dxr="pgclear" title="Continue the previous section's numbering">Clear</button>
|
|
6082
|
+
</div>
|
|
6083
|
+
<div class="dxr-row">
|
|
6084
|
+
<span class="dxr-note">Applies to the section holding the caret.</span>
|
|
6085
|
+
</div>
|
|
6086
|
+
</div>
|
|
6087
|
+
|
|
6088
|
+
<!-- The field lands in the running footer (Word's convention, and where the band
|
|
6089
|
+
puts it), so it belongs with the section's numbering rather than under Insert,
|
|
6090
|
+
whose controls all act at the caret. -->
|
|
6091
|
+
<div class="dxr-group">
|
|
6092
|
+
<span class="dxr-glabel">Footer fields</span>
|
|
6093
|
+
<div class="dxr-row">
|
|
6094
|
+
<button type="button" data-dxr="pagenum" title="Add a page-number field to the footer">Page number</button>
|
|
6095
|
+
<button type="button" data-dxr="totalpages" title="Add a total-pages field to the footer">Total pages</button>
|
|
6096
|
+
</div>
|
|
6097
|
+
<div class="dxr-row">
|
|
6098
|
+
<span class="dxr-note">Added to the footer story.</span>
|
|
6099
|
+
</div>
|
|
6100
|
+
</div>
|
|
6101
|
+
</div>
|
|
6102
|
+
|
|
6103
|
+
<!-- TABLE (contextual) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
6104
|
+
Row/column editing lives here rather than in a floating toolbar: a docked
|
|
6105
|
+
contextual tab cannot overlap the cell you are editing. -->
|
|
6106
|
+
<div class="dxr-panel" data-panel="table">
|
|
6107
|
+
<div class="dxr-group">
|
|
6108
|
+
<span class="dxr-glabel">Rows</span>
|
|
6109
|
+
<div class="dxr-row">
|
|
6110
|
+
<button type="button" data-tt="rowAbove" title="Insert a row above this one">Insert above</button>
|
|
6111
|
+
<button type="button" data-tt="rowBelow" title="Insert a row below this one">Insert below</button>
|
|
6112
|
+
<button type="button" data-tt="delRow" class="dxr-danger" title="Delete this row">Delete row</button>
|
|
6113
|
+
</div>
|
|
6114
|
+
</div>
|
|
6115
|
+
<div class="dxr-group">
|
|
6116
|
+
<span class="dxr-glabel">Columns</span>
|
|
6117
|
+
<div class="dxr-row">
|
|
6118
|
+
<button type="button" data-tt="colLeft" title="Insert a column to the left">Insert left</button>
|
|
6119
|
+
<button type="button" data-tt="colRight" title="Insert a column to the right">Insert right</button>
|
|
6120
|
+
<button type="button" data-tt="delCol" class="dxr-danger" title="Delete this column">Delete column</button>
|
|
6121
|
+
</div>
|
|
6122
|
+
</div>
|
|
6123
|
+
</div>
|
|
6124
|
+
</div>
|
|
6125
|
+
|
|
6126
|
+
<!-- Anchor rail \u2014 live engine state, not decoration. -->
|
|
6127
|
+
<div class="dxr-rail" data-dxr-rail>
|
|
6128
|
+
<span class="dxr-cell"><span class="dxr-k">anchor</span><span class="dxr-v" data-dxr="railAnchor">—</span></span>
|
|
6129
|
+
<span class="dxr-cell"><span class="dxr-k">blocks</span><span class="dxr-v" data-dxr="railBlocks">—</span></span>
|
|
6130
|
+
<span class="dxr-cell"><span class="dxr-k">session</span><span class="dxr-v" data-dxr="railSession">—</span></span>
|
|
6131
|
+
<span class="dxr-cell"><span class="dxr-k">last op</span><span class="dxr-v" data-dxr="railOp">—</span></span>
|
|
6132
|
+
</div>
|
|
6133
|
+
</div>
|
|
6134
|
+
|
|
6135
|
+
<div class="dxr-scroll" data-dxr-scroll>
|
|
6136
|
+
<p class="dxr-hint" data-dxr-hint></p>
|
|
6137
|
+
<div class="dxr-surface" data-dxr="editor" data-dxr-surface data-view="continuous"></div>
|
|
6138
|
+
</div>
|
|
6139
|
+
|
|
6140
|
+
<!-- Table size picker, anchored to the Insert tab's Table button. -->
|
|
6141
|
+
<div class="dxr-pop" data-dxr="gridpicker">
|
|
6142
|
+
<div class="dxr-gridcells" data-dxr="gridcells"></div>
|
|
6143
|
+
<div class="dxr-popfoot">
|
|
6144
|
+
<span data-dxr="gridlabel">0 × 0</span>
|
|
6145
|
+
<span style="display:inline-flex; align-items:center; gap:10px;">
|
|
6146
|
+
<label class="dxr-toggle">Align
|
|
6147
|
+
<select data-dxr="gridalign">
|
|
6148
|
+
<option value="left">Left</option>
|
|
6149
|
+
<option value="center">Center</option>
|
|
6150
|
+
<option value="right">Right</option>
|
|
6151
|
+
</select>
|
|
6152
|
+
</label>
|
|
6153
|
+
<label class="dxr-toggle"><input data-dxr="gridborderless" type="checkbox" checked /> Borderless</label>
|
|
6154
|
+
</span>
|
|
6155
|
+
</div>
|
|
6156
|
+
</div>
|
|
6157
|
+
|
|
6158
|
+
<div class="dxr-loader" data-dxr="loader" aria-live="polite" hidden>
|
|
6159
|
+
<div class="dxr-loader-grid">
|
|
6160
|
+
<div class="dxr-visual" aria-hidden="true">
|
|
6161
|
+
<div class="dxr-orbit"></div><div class="dxr-orbit dxr-two"></div>
|
|
6162
|
+
<div class="dxr-card"><i></i><i></i><i></i><i></i></div>
|
|
6163
|
+
<span class="dxr-chip dxr-b">B</span><span class="dxr-chip dxr-r">±</span><span class="dxr-chip dxr-s">↓</span>
|
|
6164
|
+
</div>
|
|
6165
|
+
<div class="dxr-loader-copy">
|
|
6166
|
+
<div class="dxr-eyebrow" data-dxr="loaderEyebrow">Running locally in this tab</div>
|
|
6167
|
+
<h2 data-dxr="loaderTitle">Booting .NET inside your browser</h2>
|
|
6168
|
+
<p data-dxr="loaderCopy">Streaming the trimmed WebAssembly runtime.</p>
|
|
6169
|
+
<div class="dxr-ad" data-dxr="loaderAd">
|
|
6170
|
+
<span class="dxr-num" data-dxr="loaderNumber">01</span>
|
|
6171
|
+
<div><strong data-dxr="loaderAdTitle"></strong><span class="dxr-adcopy" data-dxr="loaderAdCopy"></span></div>
|
|
6172
|
+
</div>
|
|
6173
|
+
<div class="dxr-track" aria-hidden="true"><div class="dxr-bar" data-dxr="loaderBar"></div></div>
|
|
6174
|
+
<div class="dxr-meta"><span data-dxr="loaderLabel">Loading engine</span><span data-dxr="loaderMeta">DOCX → WASM → DOCX</span></div>
|
|
6175
|
+
<button type="button" class="dxr-retry" data-dxr="loaderRetry">Retry loading</button>
|
|
6176
|
+
</div>
|
|
6177
|
+
</div>
|
|
6178
|
+
</div>
|
|
6179
|
+
`;
|
|
6180
|
+
var RIBBON_HINT_HTML = "Click any paragraph, heading, table cell, footnote or header/footer line to edit it. <kbd>Enter</kbd> splits a block, <kbd>Backspace</kbd> at the start merges it into the previous one, <kbd>Ctrl</kbd>+<kbd>Z</kbd> undoes. Only the block you changed re-renders \u2014 everything else keeps full fidelity, and <b>Save</b> writes a lossless .docx.";
|
|
6181
|
+
|
|
6182
|
+
// src/ribbon.ts
|
|
6183
|
+
var DEFAULT_STAGES = [
|
|
6184
|
+
{
|
|
6185
|
+
title: "Booting .NET inside your browser",
|
|
6186
|
+
copy: "Streaming the trimmed WebAssembly runtime. No document bytes are sent to a server.",
|
|
6187
|
+
progress: 16,
|
|
6188
|
+
label: "Loading engine"
|
|
6189
|
+
},
|
|
6190
|
+
{
|
|
6191
|
+
title: "Opening the document",
|
|
6192
|
+
copy: "Parsing OOXML parts, styles, numbering, tables, notes, and tracked revisions locally.",
|
|
6193
|
+
progress: 54,
|
|
6194
|
+
label: "Reading document"
|
|
6195
|
+
},
|
|
6196
|
+
{
|
|
6197
|
+
title: "Wiring lossless editing",
|
|
6198
|
+
copy: "Connecting every editable block to its native WordprocessingML anchor.",
|
|
6199
|
+
progress: 84,
|
|
6200
|
+
label: "Mounting editor"
|
|
6201
|
+
},
|
|
6202
|
+
{
|
|
6203
|
+
title: "Your local editor is ready",
|
|
6204
|
+
copy: "Select text, use the ribbon, switch page view, and save a real DOCX.",
|
|
6205
|
+
progress: 100,
|
|
6206
|
+
label: "Ready"
|
|
6207
|
+
}
|
|
6208
|
+
];
|
|
6209
|
+
var DEFAULT_FEATURES = [
|
|
6210
|
+
{ number: "01", title: "Zero-upload architecture", copy: "Your source file and edits never leave this browser session." },
|
|
6211
|
+
{ number: "02", title: "Word-grade OOXML fidelity", copy: "Tables, numbering, footnotes, redlines, comments, and styles stay native." },
|
|
6212
|
+
{ number: "03", title: "Surgical editing", copy: "Formatting and text edits target real document anchors instead of flattening the file." },
|
|
6213
|
+
{ number: "04", title: "Lossless DOCX out", copy: "Undo, redo, edit, and save a Word document that remains a Word document." }
|
|
6214
|
+
];
|
|
6215
|
+
var CONTROL_NAMES = [
|
|
6216
|
+
"docname",
|
|
6217
|
+
"new",
|
|
6218
|
+
"file",
|
|
6219
|
+
"save",
|
|
6220
|
+
"undo",
|
|
6221
|
+
"redo",
|
|
6222
|
+
"status",
|
|
6223
|
+
"ribbon",
|
|
6224
|
+
"fontsize",
|
|
6225
|
+
"fontsizes",
|
|
6226
|
+
"fontfamily",
|
|
6227
|
+
"style",
|
|
6228
|
+
"delblock",
|
|
6229
|
+
"table",
|
|
6230
|
+
"hr",
|
|
6231
|
+
"hrThick",
|
|
6232
|
+
"hrDouble",
|
|
6233
|
+
"rulepos",
|
|
6234
|
+
"hrClear",
|
|
6235
|
+
"footnote",
|
|
6236
|
+
"endnote",
|
|
6237
|
+
"paginated",
|
|
6238
|
+
"headerfooter",
|
|
6239
|
+
"pgfmt",
|
|
6240
|
+
"pgstart",
|
|
6241
|
+
"pgclear",
|
|
6242
|
+
"pagenum",
|
|
6243
|
+
"totalpages",
|
|
6244
|
+
"railAnchor",
|
|
6245
|
+
"railBlocks",
|
|
6246
|
+
"railSession",
|
|
6247
|
+
"railOp",
|
|
6248
|
+
"gridpicker",
|
|
6249
|
+
"gridcells",
|
|
6250
|
+
"gridlabel",
|
|
6251
|
+
"gridalign",
|
|
6252
|
+
"gridborderless",
|
|
6253
|
+
"editor",
|
|
6254
|
+
"loader",
|
|
6255
|
+
"loaderEyebrow",
|
|
6256
|
+
"loaderTitle",
|
|
6257
|
+
"loaderCopy",
|
|
6258
|
+
"loaderAd",
|
|
6259
|
+
"loaderNumber",
|
|
6260
|
+
"loaderAdTitle",
|
|
6261
|
+
"loaderAdCopy",
|
|
6262
|
+
"loaderBar",
|
|
6263
|
+
"loaderLabel",
|
|
6264
|
+
"loaderMeta",
|
|
6265
|
+
"loaderRetry"
|
|
6266
|
+
];
|
|
6267
|
+
var GRID_ROWS = 8;
|
|
6268
|
+
var GRID_COLS = 10;
|
|
6269
|
+
var nextIdPrefixSeed = 0;
|
|
6270
|
+
function ensureStyles(doc) {
|
|
6271
|
+
const existing = doc.querySelector(`style[${RIBBON_STYLE_ATTR}]`);
|
|
6272
|
+
if (existing?.getAttribute(RIBBON_STYLE_ATTR) === RIBBON_STYLE_VERSION) return;
|
|
6273
|
+
existing?.remove();
|
|
6274
|
+
const style = doc.createElement("style");
|
|
6275
|
+
style.setAttribute(RIBBON_STYLE_ATTR, RIBBON_STYLE_VERSION);
|
|
6276
|
+
style.textContent = RIBBON_CSS;
|
|
6277
|
+
(doc.head ?? doc.documentElement).appendChild(style);
|
|
6278
|
+
}
|
|
6279
|
+
function resolveIdPrefix(explicit, doc) {
|
|
6280
|
+
if (explicit !== void 0) return explicit;
|
|
6281
|
+
if (!CONTROL_NAMES.some((name) => doc.getElementById(name))) return "";
|
|
6282
|
+
for (; ; ) {
|
|
6283
|
+
const candidate = `dxr${++nextIdPrefixSeed}-`;
|
|
6284
|
+
if (!CONTROL_NAMES.some((name) => doc.getElementById(candidate + name))) return candidate;
|
|
6285
|
+
}
|
|
6286
|
+
}
|
|
6287
|
+
function resolveContainer(container) {
|
|
6288
|
+
if (typeof container !== "string") return container;
|
|
6289
|
+
const el = document.querySelector(container);
|
|
6290
|
+
if (!el) throw new Error(`Docxodus ribbon: no element matches "${container}"`);
|
|
6291
|
+
return el;
|
|
6292
|
+
}
|
|
6293
|
+
function mountRibbon(container, options = {}) {
|
|
6294
|
+
return new RibbonSurface(resolveContainer(container), options);
|
|
6295
|
+
}
|
|
6296
|
+
var RibbonSurface = class {
|
|
6297
|
+
constructor(container, options) {
|
|
6298
|
+
this.live = null;
|
|
6299
|
+
this.density = "full";
|
|
6300
|
+
this.destroyed = false;
|
|
6301
|
+
this.featureTimer = null;
|
|
6302
|
+
this.featureIndex = 0;
|
|
6303
|
+
this.resizeObserver = null;
|
|
6304
|
+
this.lastAnchorText = "";
|
|
6305
|
+
this.selectionFrame = null;
|
|
6306
|
+
this.options = options;
|
|
6307
|
+
this.exports = options.exports ?? null;
|
|
6308
|
+
this.documentName = options.documentName ?? "untitled.docx";
|
|
6309
|
+
this.chromeMode = options.chrome ?? "auto";
|
|
6310
|
+
this.headerFooter = options.headerFooter ?? false;
|
|
6311
|
+
this.loaderOptions = options.loader === false ? null : typeof options.loader === "object" ? options.loader : {};
|
|
6312
|
+
this.stages = this.loaderOptions?.stages ?? DEFAULT_STAGES;
|
|
6313
|
+
this.features = this.loaderOptions?.features ?? DEFAULT_FEATURES;
|
|
6314
|
+
const doc = container.ownerDocument ?? document;
|
|
6315
|
+
ensureStyles(doc);
|
|
6316
|
+
this.idPrefix = resolveIdPrefix(options.idPrefix, doc);
|
|
6317
|
+
const root = doc.createElement("div");
|
|
6318
|
+
root.className = "dxr";
|
|
6319
|
+
root.dataset.state = "idle";
|
|
6320
|
+
root.innerHTML = RIBBON_HTML;
|
|
6321
|
+
for (const el of Array.from(root.querySelectorAll("[data-dxr]"))) {
|
|
6322
|
+
el.id = this.idPrefix + el.dataset.dxr;
|
|
6323
|
+
}
|
|
6324
|
+
for (const el of Array.from(root.querySelectorAll("[data-dxr-list]"))) {
|
|
6325
|
+
el.setAttribute("list", this.idPrefix + el.dataset.dxrList);
|
|
6326
|
+
}
|
|
6327
|
+
container.replaceChildren(root);
|
|
6328
|
+
this.element = root;
|
|
6329
|
+
this.surface = this.require("editor");
|
|
6330
|
+
this.applyStaticOptions();
|
|
6331
|
+
this.buildGrid();
|
|
6332
|
+
this.wire();
|
|
6333
|
+
this.applyChrome();
|
|
6334
|
+
this.loader = this.createLoaderController();
|
|
6335
|
+
if (this.loaderOptions) this.loader.show();
|
|
6336
|
+
this.onSelectionChange = () => {
|
|
6337
|
+
if (this.selectionFrame != null) cancelAnimationFrame(this.selectionFrame);
|
|
6338
|
+
this.selectionFrame = requestAnimationFrame(() => {
|
|
6339
|
+
this.selectionFrame = null;
|
|
6340
|
+
this.syncSelection();
|
|
6341
|
+
});
|
|
6342
|
+
};
|
|
6343
|
+
doc.addEventListener("selectionchange", this.onSelectionChange);
|
|
6344
|
+
this.onDocumentMouseDown = (event) => this.maybeClosePicker(event);
|
|
6345
|
+
doc.addEventListener("mousedown", this.onDocumentMouseDown);
|
|
6346
|
+
if (this.chromeMode === "auto" && typeof ResizeObserver !== "undefined") {
|
|
6347
|
+
this.resizeObserver = new ResizeObserver(() => this.applyChrome());
|
|
6348
|
+
this.resizeObserver.observe(root);
|
|
6349
|
+
}
|
|
6350
|
+
}
|
|
6351
|
+
// ── element lookup ──────────────────────────────────────────────────────────
|
|
6352
|
+
control(name) {
|
|
6353
|
+
return this.element.querySelector(`[data-dxr="${name}"]`);
|
|
6354
|
+
}
|
|
6355
|
+
require(name) {
|
|
6356
|
+
const el = this.control(name);
|
|
6357
|
+
if (!el) throw new Error(`Docxodus ribbon: template is missing "${name}"`);
|
|
6358
|
+
return el;
|
|
6359
|
+
}
|
|
6360
|
+
// ── mount-time configuration ────────────────────────────────────────────────
|
|
6361
|
+
applyStaticOptions() {
|
|
6362
|
+
const hintEl = this.element.querySelector("[data-dxr-hint]");
|
|
6363
|
+
if (hintEl) {
|
|
6364
|
+
if (this.options.hint === false) hintEl.remove();
|
|
6365
|
+
else hintEl.innerHTML = typeof this.options.hint === "string" ? this.options.hint : RIBBON_HINT_HTML;
|
|
6366
|
+
}
|
|
6367
|
+
if (this.options.rail === false) {
|
|
6368
|
+
this.element.querySelector("[data-dxr-rail]")?.remove();
|
|
6369
|
+
}
|
|
6370
|
+
if (this.options.fileActions === false) {
|
|
6371
|
+
this.element.querySelector("[data-dxr-files]")?.remove();
|
|
6372
|
+
}
|
|
6373
|
+
if (!this.loaderOptions) this.control("loader")?.remove();
|
|
6374
|
+
this.require("docname").textContent = this.documentName;
|
|
6375
|
+
this.require("paginated").checked = this.options.paginated ?? false;
|
|
6376
|
+
this.require("headerfooter").checked = this.headerFooter;
|
|
6377
|
+
this.surface.dataset.view = this.options.paginated ? "paginated" : "continuous";
|
|
6378
|
+
}
|
|
6379
|
+
buildGrid() {
|
|
6380
|
+
const cells = this.require("gridcells");
|
|
6381
|
+
const fragment = document.createDocumentFragment();
|
|
6382
|
+
for (let r = 0; r < GRID_ROWS; r++) {
|
|
6383
|
+
for (let c = 0; c < GRID_COLS; c++) {
|
|
6384
|
+
const cell = document.createElement("div");
|
|
6385
|
+
cell.dataset.r = String(r);
|
|
6386
|
+
cell.dataset.c = String(c);
|
|
6387
|
+
fragment.appendChild(cell);
|
|
6388
|
+
}
|
|
6389
|
+
}
|
|
6390
|
+
cells.replaceChildren(fragment);
|
|
6391
|
+
}
|
|
6392
|
+
// ── chrome density ──────────────────────────────────────────────────────────
|
|
6393
|
+
get chrome() {
|
|
6394
|
+
return this.density;
|
|
6395
|
+
}
|
|
6396
|
+
setChrome(mode) {
|
|
6397
|
+
this.chromeMode = mode;
|
|
6398
|
+
if (mode === "auto" && !this.resizeObserver && typeof ResizeObserver !== "undefined") {
|
|
6399
|
+
this.resizeObserver = new ResizeObserver(() => this.applyChrome());
|
|
6400
|
+
this.resizeObserver.observe(this.element);
|
|
6401
|
+
}
|
|
6402
|
+
this.applyChrome();
|
|
6403
|
+
}
|
|
6404
|
+
applyChrome() {
|
|
6405
|
+
const breakpoint = this.options.compactBreakpoint ?? 720;
|
|
6406
|
+
const width = this.element.clientWidth || this.element.getBoundingClientRect().width;
|
|
6407
|
+
const next = this.chromeMode === "auto" ? width > 0 && width < breakpoint ? "compact" : "full" : this.chromeMode;
|
|
6408
|
+
if (next === this.density && this.element.dataset.chrome) return;
|
|
6409
|
+
this.density = next;
|
|
6410
|
+
this.element.dataset.chrome = next;
|
|
6411
|
+
this.closePicker();
|
|
6412
|
+
}
|
|
6413
|
+
// ── status ──────────────────────────────────────────────────────────────────
|
|
6414
|
+
/** Publish the lifecycle on the root, where CSS and host pages can key off it. */
|
|
6415
|
+
setState(state) {
|
|
6416
|
+
this.element.dataset.state = state;
|
|
6417
|
+
}
|
|
6418
|
+
setStatus(text) {
|
|
6419
|
+
const el = this.control("status");
|
|
6420
|
+
if (el) el.textContent = text;
|
|
6421
|
+
this.options.onStatus?.(text);
|
|
6422
|
+
}
|
|
6423
|
+
// ── document lifecycle ──────────────────────────────────────────────────────
|
|
6424
|
+
get editor() {
|
|
6425
|
+
return this.live;
|
|
6426
|
+
}
|
|
6427
|
+
setExports(exports) {
|
|
6428
|
+
this.exports = exports;
|
|
6429
|
+
}
|
|
6430
|
+
open(bytes, name) {
|
|
6431
|
+
if (!this.exports) throw new Error("Docxodus ribbon: WASM exports are not set yet");
|
|
6432
|
+
if (this.live) {
|
|
6433
|
+
try {
|
|
6434
|
+
this.live.close();
|
|
6435
|
+
} catch {
|
|
6436
|
+
}
|
|
6437
|
+
this.live = null;
|
|
6438
|
+
}
|
|
6439
|
+
if (name) this.documentName = name;
|
|
6440
|
+
this.require("docname").textContent = this.documentName;
|
|
6441
|
+
const paginated = this.require("paginated").checked;
|
|
6442
|
+
this.surface.dataset.view = paginated ? "paginated" : "continuous";
|
|
6443
|
+
this.surface.replaceChildren();
|
|
6444
|
+
const started = performance.now();
|
|
6445
|
+
this.live = DocxEditor.open(this.surface, bytes, this.exports, {
|
|
6446
|
+
cssPrefix: this.options.cssPrefix,
|
|
6447
|
+
fabricateClasses: this.options.fabricateClasses,
|
|
6448
|
+
editable: this.options.editable,
|
|
6449
|
+
scale: this.options.scale,
|
|
6450
|
+
onEdit: this.options.onEdit,
|
|
6451
|
+
paginated,
|
|
6452
|
+
headerFooter: this.headerFooter
|
|
6453
|
+
});
|
|
6454
|
+
this.require("save").disabled = false;
|
|
6455
|
+
this.require("ribbon").setAttribute("aria-disabled", "false");
|
|
6456
|
+
this.setState("ready");
|
|
6457
|
+
this.setStatus(`Rendered in ${Math.round(performance.now() - started)} ms`);
|
|
6458
|
+
this.syncPageNumbering();
|
|
6459
|
+
this.refreshRailCounts();
|
|
6460
|
+
this.refreshRailAnchor();
|
|
6461
|
+
this.options.onOpen?.(this.live);
|
|
6462
|
+
return this.live;
|
|
6463
|
+
}
|
|
6464
|
+
openBlank(name = "untitled.docx") {
|
|
6465
|
+
if (!this.exports) throw new Error("Docxodus ribbon: WASM exports are not set yet");
|
|
6466
|
+
return this.open(this.exports.DocxSessionBridge.CreateBlankDocx(), name);
|
|
6467
|
+
}
|
|
6468
|
+
save() {
|
|
6469
|
+
return this.live ? this.live.save() : null;
|
|
6470
|
+
}
|
|
6471
|
+
download(name) {
|
|
6472
|
+
const bytes = this.save();
|
|
6473
|
+
if (!bytes) return;
|
|
6474
|
+
const filename = name ?? this.documentName ?? "edited.docx";
|
|
6475
|
+
if (this.options.onSave) {
|
|
6476
|
+
this.options.onSave(bytes, filename);
|
|
6477
|
+
return;
|
|
6478
|
+
}
|
|
6479
|
+
const url = URL.createObjectURL(
|
|
6480
|
+
new Blob([bytes], {
|
|
6481
|
+
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
|
6482
|
+
})
|
|
6483
|
+
);
|
|
6484
|
+
const link = document.createElement("a");
|
|
6485
|
+
link.href = url;
|
|
6486
|
+
link.download = filename;
|
|
6487
|
+
link.click();
|
|
6488
|
+
setTimeout(() => URL.revokeObjectURL(url), 1e3);
|
|
6489
|
+
this.setStatus(`Saved ${filename}`);
|
|
6490
|
+
}
|
|
6491
|
+
destroy() {
|
|
6492
|
+
if (this.destroyed) return;
|
|
6493
|
+
this.destroyed = true;
|
|
6494
|
+
const doc = this.element.ownerDocument ?? document;
|
|
6495
|
+
doc.removeEventListener("selectionchange", this.onSelectionChange);
|
|
6496
|
+
doc.removeEventListener("mousedown", this.onDocumentMouseDown);
|
|
6497
|
+
this.resizeObserver?.disconnect();
|
|
6498
|
+
this.resizeObserver = null;
|
|
6499
|
+
if (this.selectionFrame != null) cancelAnimationFrame(this.selectionFrame);
|
|
6500
|
+
this.selectionFrame = null;
|
|
6501
|
+
this.stopRotation();
|
|
6502
|
+
try {
|
|
6503
|
+
this.live?.close();
|
|
6504
|
+
} catch {
|
|
6505
|
+
}
|
|
6506
|
+
this.live = null;
|
|
6507
|
+
this.element.remove();
|
|
6508
|
+
}
|
|
6509
|
+
// ── command plumbing ────────────────────────────────────────────────────────
|
|
6510
|
+
/**
|
|
6511
|
+
* Run one ribbon command and report its real cost on the rail.
|
|
6512
|
+
*
|
|
6513
|
+
* Every control routes through here, which is what makes the rail's "last op"
|
|
6514
|
+
* an honest measurement rather than a label the surface makes up.
|
|
6515
|
+
*/
|
|
6516
|
+
run(label, fn) {
|
|
6517
|
+
if (!this.live) return;
|
|
6518
|
+
const started = performance.now();
|
|
6519
|
+
try {
|
|
6520
|
+
fn();
|
|
6521
|
+
} finally {
|
|
6522
|
+
const ms = performance.now() - started;
|
|
6523
|
+
const el = this.control("railOp");
|
|
6524
|
+
if (el) el.textContent = `${label} ${ms >= 1e3 ? `${(ms / 1e3).toFixed(2)} s` : `${Math.round(ms)} ms`}`;
|
|
6525
|
+
this.options.onCommand?.(label, ms);
|
|
6526
|
+
this.refreshRailCounts();
|
|
6527
|
+
this.refreshRailAnchor();
|
|
6528
|
+
}
|
|
6529
|
+
}
|
|
6530
|
+
/** Format controls must not steal the document selection they are about to act on. */
|
|
6531
|
+
keepSelection(el) {
|
|
6532
|
+
el.addEventListener("mousedown", (event) => event.preventDefault());
|
|
6533
|
+
}
|
|
6534
|
+
wire() {
|
|
6535
|
+
const ribbon = this.require("ribbon");
|
|
6536
|
+
for (const tab of Array.from(this.element.querySelectorAll(".dxr-tab"))) {
|
|
6537
|
+
this.keepSelection(tab);
|
|
6538
|
+
tab.addEventListener("click", () => this.selectTab(tab.dataset.tab ?? "home"));
|
|
6539
|
+
}
|
|
6540
|
+
const delegate = (selector, label, fn) => {
|
|
6541
|
+
for (const el of Array.from(ribbon.querySelectorAll(selector))) {
|
|
6542
|
+
this.keepSelection(el);
|
|
6543
|
+
el.addEventListener("click", () => this.run(label(el), () => fn(el)));
|
|
6544
|
+
}
|
|
6545
|
+
};
|
|
6546
|
+
delegate("button[data-cmd]", (b) => b.dataset.cmd, (b) => this.live.format(b.dataset.cmd));
|
|
6547
|
+
delegate("button[data-align]", (b) => `align ${b.dataset.align}`, (b) => this.live.setAlignment(b.dataset.align));
|
|
6548
|
+
delegate("button[data-indent]", () => "indent", (b) => this.live.indent(parseInt(b.dataset.indent ?? "720", 10)));
|
|
6549
|
+
delegate("button[data-list]", (b) => `list ${b.dataset.list}`, (b) => this.live.toggleList(b.dataset.list));
|
|
6550
|
+
delegate("button[data-pagebreak]", () => "page break", () => this.live.pageBreakBefore(true));
|
|
6551
|
+
delegate('.dxr-panel[data-panel="table"] button[data-tt]', (b) => b.dataset.tt, (b) => {
|
|
6552
|
+
const ops = {
|
|
6553
|
+
rowAbove: () => this.live.insertTableRow("above"),
|
|
6554
|
+
rowBelow: () => this.live.insertTableRow("below"),
|
|
6555
|
+
colLeft: () => this.live.insertTableColumn("left"),
|
|
6556
|
+
colRight: () => this.live.insertTableColumn("right"),
|
|
6557
|
+
delRow: () => this.live.deleteTableRow(),
|
|
6558
|
+
delCol: () => this.live.deleteTableColumn()
|
|
6559
|
+
};
|
|
6560
|
+
ops[b.dataset.tt ?? ""]?.();
|
|
6561
|
+
});
|
|
6562
|
+
const rulepos = () => this.require("rulepos").value === "above" ? "above" : "below";
|
|
6563
|
+
const simple = [
|
|
6564
|
+
["undo", "undo", () => this.live.undo()],
|
|
6565
|
+
["redo", "redo", () => this.live.redo()],
|
|
6566
|
+
["hr", "rule", () => this.live.insertHorizontalRule(12, "single", rulepos())],
|
|
6567
|
+
["hrThick", "thick rule", () => this.live.insertHorizontalRule(24, "single", rulepos())],
|
|
6568
|
+
["hrDouble", "double rule", () => this.live.insertHorizontalRule(12, "double", rulepos())],
|
|
6569
|
+
["hrClear", "clear border", () => this.live.clearParagraphBorders()],
|
|
6570
|
+
["delblock", "delete block", () => this.live.deleteBlock()],
|
|
6571
|
+
["footnote", "footnote", () => this.live.insertFootnote()],
|
|
6572
|
+
["endnote", "endnote", () => this.live.insertEndnote()],
|
|
6573
|
+
["pagenum", "page number", () => this.live.insertPageNumber("currentPage")],
|
|
6574
|
+
["totalpages", "total pages", () => this.live.insertPageNumber("totalPages")]
|
|
6575
|
+
];
|
|
6576
|
+
for (const [name, label, fn] of simple) {
|
|
6577
|
+
const el = this.control(name);
|
|
6578
|
+
if (!el) continue;
|
|
6579
|
+
this.keepSelection(el);
|
|
6580
|
+
el.addEventListener("click", () => this.run(label, fn));
|
|
6581
|
+
}
|
|
6582
|
+
const fontsize = this.require("fontsize");
|
|
6583
|
+
fontsize.addEventListener("change", () => {
|
|
6584
|
+
const pts = parseFloat(fontsize.value);
|
|
6585
|
+
if (this.live && pts > 0) this.run("font size", () => this.live.setFontSize(pts));
|
|
6586
|
+
});
|
|
6587
|
+
fontsize.addEventListener("keydown", (event) => {
|
|
6588
|
+
if (event.key === "Enter") {
|
|
6589
|
+
event.preventDefault();
|
|
6590
|
+
fontsize.blur();
|
|
6591
|
+
}
|
|
6592
|
+
});
|
|
6593
|
+
const fontfamily = this.require("fontfamily");
|
|
6594
|
+
fontfamily.addEventListener("change", () => {
|
|
6595
|
+
if (this.live && fontfamily.value) this.run("font family", () => this.live.setFontFamily(fontfamily.value));
|
|
6596
|
+
fontfamily.value = "";
|
|
6597
|
+
});
|
|
6598
|
+
const style = this.require("style");
|
|
6599
|
+
style.addEventListener("change", () => {
|
|
6600
|
+
if (this.live && style.value) this.run("style", () => this.live.setParagraphStyle(style.value));
|
|
6601
|
+
style.value = "";
|
|
6602
|
+
});
|
|
6603
|
+
this.wireFileActions();
|
|
6604
|
+
this.wireLayout();
|
|
6605
|
+
this.wirePicker();
|
|
6606
|
+
}
|
|
6607
|
+
wireFileActions() {
|
|
6608
|
+
const file = this.control("file");
|
|
6609
|
+
file?.addEventListener("change", async () => {
|
|
6610
|
+
const chosen = file.files?.[0];
|
|
6611
|
+
if (!chosen) return;
|
|
6612
|
+
this.setStatus(`Loading ${chosen.name}\u2026`);
|
|
6613
|
+
this.open(new Uint8Array(await chosen.arrayBuffer()), chosen.name);
|
|
6614
|
+
file.value = "";
|
|
6615
|
+
});
|
|
6616
|
+
this.control("new")?.addEventListener("click", () => {
|
|
6617
|
+
if (this.exports) this.openBlank("untitled.docx");
|
|
6618
|
+
});
|
|
6619
|
+
this.control("save")?.addEventListener("click", () => this.download());
|
|
6620
|
+
}
|
|
6621
|
+
wireLayout() {
|
|
6622
|
+
const paginated = this.require("paginated");
|
|
6623
|
+
paginated.addEventListener("change", () => {
|
|
6624
|
+
this.surface.dataset.view = paginated.checked ? "paginated" : "continuous";
|
|
6625
|
+
if (!this.live) return;
|
|
6626
|
+
this.run(paginated.checked ? "page view" : "continuous view", () => this.live.setPaginated(paginated.checked));
|
|
6627
|
+
});
|
|
6628
|
+
const headerFooter = this.require("headerfooter");
|
|
6629
|
+
headerFooter.addEventListener("change", () => {
|
|
6630
|
+
this.headerFooter = headerFooter.checked;
|
|
6631
|
+
if (!this.live) return;
|
|
6632
|
+
this.open(this.live.save(), this.documentName);
|
|
6633
|
+
});
|
|
6634
|
+
const pgfmt = this.require("pgfmt");
|
|
6635
|
+
pgfmt.addEventListener("change", () => {
|
|
6636
|
+
if (!this.live || !pgfmt.value) return;
|
|
6637
|
+
this.run("page format", () => this.live.setPageNumbering({ format: pgfmt.value }));
|
|
6638
|
+
this.syncPageNumbering();
|
|
6639
|
+
});
|
|
6640
|
+
const pgstart = this.require("pgstart");
|
|
6641
|
+
pgstart.addEventListener("change", () => {
|
|
6642
|
+
const value = parseInt(pgstart.value, 10);
|
|
6643
|
+
if (!this.live || !(value > 0)) return;
|
|
6644
|
+
this.run("page start", () => this.live.setPageNumbering({ start: value }));
|
|
6645
|
+
this.syncPageNumbering();
|
|
6646
|
+
});
|
|
6647
|
+
this.control("pgclear")?.addEventListener("click", () => {
|
|
6648
|
+
this.run("clear numbering", () => this.live.clearPageNumbering());
|
|
6649
|
+
this.syncPageNumbering();
|
|
6650
|
+
});
|
|
6651
|
+
}
|
|
6652
|
+
/** The bands own the same setting and read the live session, so both stay in step. */
|
|
6653
|
+
syncPageNumbering() {
|
|
6654
|
+
if (!this.live) return;
|
|
6655
|
+
const numbering = this.live.pageNumbering() ?? {};
|
|
6656
|
+
this.require("pgfmt").value = numbering.format ?? "";
|
|
6657
|
+
this.require("pgstart").value = numbering.start != null ? String(numbering.start) : "";
|
|
6658
|
+
}
|
|
6659
|
+
// ── table size picker ───────────────────────────────────────────────────────
|
|
6660
|
+
wirePicker() {
|
|
6661
|
+
const button = this.require("table");
|
|
6662
|
+
const picker = this.require("gridpicker");
|
|
6663
|
+
const cells = this.require("gridcells");
|
|
6664
|
+
const highlight = (rows, cols) => {
|
|
6665
|
+
for (const cell of Array.from(cells.children)) {
|
|
6666
|
+
const on = Number(cell.dataset.r) < rows && Number(cell.dataset.c) < cols;
|
|
6667
|
+
if (on) cell.setAttribute("data-on", "");
|
|
6668
|
+
else cell.removeAttribute("data-on");
|
|
6669
|
+
}
|
|
6670
|
+
this.require("gridlabel").textContent = `${rows} \xD7 ${cols}`;
|
|
6671
|
+
};
|
|
6672
|
+
cells.addEventListener("pointerover", (event) => {
|
|
6673
|
+
const cell = event.target.closest("[data-r]");
|
|
6674
|
+
if (cell) highlight(Number(cell.dataset.r) + 1, Number(cell.dataset.c) + 1);
|
|
6675
|
+
});
|
|
6676
|
+
cells.addEventListener("mousedown", (event) => {
|
|
6677
|
+
const cell = event.target.closest("[data-r]");
|
|
6678
|
+
if (!cell || !this.live) return;
|
|
6679
|
+
event.preventDefault();
|
|
6680
|
+
const rows = Number(cell.dataset.r) + 1;
|
|
6681
|
+
const cols = Number(cell.dataset.c) + 1;
|
|
6682
|
+
this.closePicker();
|
|
6683
|
+
this.run(`table ${rows}\xD7${cols}`, () => this.live.insertTable(rows, cols, {
|
|
6684
|
+
borderless: this.require("gridborderless").checked,
|
|
6685
|
+
cellAlignment: this.require("gridalign").value
|
|
6686
|
+
}));
|
|
6687
|
+
});
|
|
6688
|
+
this.keepSelection(button);
|
|
6689
|
+
button.addEventListener("click", () => {
|
|
6690
|
+
if (!this.live) return;
|
|
6691
|
+
if (picker.hasAttribute("data-open")) {
|
|
6692
|
+
this.closePicker();
|
|
6693
|
+
return;
|
|
6694
|
+
}
|
|
6695
|
+
highlight(0, 0);
|
|
6696
|
+
picker.setAttribute("data-open", "");
|
|
6697
|
+
if (this.density === "full") {
|
|
6698
|
+
const rect = button.getBoundingClientRect();
|
|
6699
|
+
const host = this.element.getBoundingClientRect();
|
|
6700
|
+
picker.style.left = `${rect.left - host.left}px`;
|
|
6701
|
+
picker.style.top = `${rect.bottom - host.top + 5}px`;
|
|
6702
|
+
}
|
|
6703
|
+
});
|
|
6704
|
+
}
|
|
6705
|
+
closePicker() {
|
|
6706
|
+
this.control("gridpicker")?.removeAttribute("data-open");
|
|
6707
|
+
}
|
|
6708
|
+
maybeClosePicker(event) {
|
|
6709
|
+
const picker = this.control("gridpicker");
|
|
6710
|
+
if (!picker?.hasAttribute("data-open")) return;
|
|
6711
|
+
const target = event.target;
|
|
6712
|
+
if (picker.contains(target) || this.control("table")?.contains(target)) return;
|
|
6713
|
+
this.closePicker();
|
|
6714
|
+
}
|
|
6715
|
+
// ── tabs ────────────────────────────────────────────────────────────────────
|
|
6716
|
+
selectTab(name) {
|
|
6717
|
+
for (const tab of Array.from(this.element.querySelectorAll(".dxr-tab"))) {
|
|
6718
|
+
tab.setAttribute("aria-selected", String(tab.dataset.tab === name));
|
|
6719
|
+
}
|
|
6720
|
+
for (const panel of Array.from(this.element.querySelectorAll(".dxr-panel"))) {
|
|
6721
|
+
if (panel.dataset.panel === name) panel.setAttribute("data-active", "");
|
|
6722
|
+
else panel.removeAttribute("data-active");
|
|
6723
|
+
}
|
|
6724
|
+
if (name === "layout") this.syncPageNumbering();
|
|
6725
|
+
}
|
|
6726
|
+
// ── selection-driven state ──────────────────────────────────────────────────
|
|
6727
|
+
selectionElement() {
|
|
6728
|
+
const selection = (this.element.ownerDocument ?? document).getSelection();
|
|
6729
|
+
const node = selection?.anchorNode ?? null;
|
|
6730
|
+
if (!node) return null;
|
|
6731
|
+
const el = node.nodeType === Node.ELEMENT_NODE ? node : node.parentElement;
|
|
6732
|
+
return el && this.surface.contains(el) ? el : null;
|
|
6733
|
+
}
|
|
6734
|
+
syncSelection() {
|
|
6735
|
+
if (!this.live || this.destroyed) return;
|
|
6736
|
+
const el = this.selectionElement();
|
|
6737
|
+
const state = this.live.queryFormatState();
|
|
6738
|
+
for (const button of Array.from(this.element.querySelectorAll("button[data-cmd]"))) {
|
|
6739
|
+
button.classList.toggle("dxr-on", !!state[button.dataset.cmd]);
|
|
6740
|
+
}
|
|
6741
|
+
const fontsize = this.control("fontsize");
|
|
6742
|
+
if (el && fontsize && (this.element.ownerDocument ?? document).activeElement !== fontsize) {
|
|
6743
|
+
const px = parseFloat(getComputedStyle(el).fontSize);
|
|
6744
|
+
if (px) fontsize.value = String(Math.round(px * 0.75 * 2) / 2);
|
|
6745
|
+
}
|
|
6746
|
+
const inTable = !!el?.closest("table");
|
|
6747
|
+
const tableTab = this.element.querySelector('.dxr-tab[data-tab="table"]');
|
|
6748
|
+
if (tableTab) {
|
|
6749
|
+
tableTab.hidden = !inTable;
|
|
6750
|
+
if (!inTable && tableTab.getAttribute("aria-selected") === "true") this.selectTab("home");
|
|
6751
|
+
}
|
|
6752
|
+
this.refreshRailAnchor();
|
|
6753
|
+
}
|
|
6754
|
+
/** Scope is read from where the block lives, which is exactly what the anchor encodes. */
|
|
6755
|
+
scopeOf(el) {
|
|
6756
|
+
const band = el.closest(".docx-hf-band");
|
|
6757
|
+
if (band) return band.getAttribute("data-hf-band") === "header" ? "hdr" : "ftr";
|
|
6758
|
+
if (el.closest(".footnotes")) return "fn";
|
|
6759
|
+
if (el.closest(".endnotes")) return "en";
|
|
6760
|
+
return "body";
|
|
6761
|
+
}
|
|
6762
|
+
kindOf(el) {
|
|
6763
|
+
if (/^H[1-6]$/.test(el.tagName)) return "h";
|
|
6764
|
+
if (el.tagName === "LI" || el.hasAttribute("data-list-marker") || el.querySelector("[data-list-marker]")) {
|
|
6765
|
+
return "li";
|
|
6766
|
+
}
|
|
6767
|
+
return "p";
|
|
6768
|
+
}
|
|
6769
|
+
/**
|
|
6770
|
+
* Block count and session handle — an O(blocks) query, so it runs only when
|
|
6771
|
+
* something could have changed them (a command, or a document opening), never on
|
|
6772
|
+
* the selectionchange path that fires per keystroke.
|
|
6773
|
+
*/
|
|
6774
|
+
refreshRailCounts() {
|
|
6775
|
+
const blocks = this.control("railBlocks");
|
|
6776
|
+
if (!blocks) return;
|
|
6777
|
+
blocks.textContent = this.live ? String(this.surface.querySelectorAll("[data-anchor]").length) : "\u2014";
|
|
6778
|
+
const session = this.control("railSession");
|
|
6779
|
+
if (session) session.textContent = this.live ? `#${this.live.sessionHandle}` : "\u2014";
|
|
6780
|
+
}
|
|
6781
|
+
/** The focused anchor — cheap, and the only part the caret can change. */
|
|
6782
|
+
refreshRailAnchor() {
|
|
6783
|
+
const anchorEl = this.control("railAnchor");
|
|
6784
|
+
if (!anchorEl) return;
|
|
6785
|
+
const block = this.selectionElement()?.closest("[data-anchor]") ?? null;
|
|
6786
|
+
if (!block) {
|
|
6787
|
+
anchorEl.textContent = this.live ? "none" : "\u2014";
|
|
6788
|
+
this.lastAnchorText = "";
|
|
6789
|
+
return;
|
|
6790
|
+
}
|
|
6791
|
+
const unid = block.getAttribute("data-anchor") ?? "";
|
|
6792
|
+
const text = `${this.kindOf(block)}:${this.scopeOf(block)}:${unid.slice(0, 10)}\u2026`;
|
|
6793
|
+
if (text === this.lastAnchorText) return;
|
|
6794
|
+
anchorEl.textContent = text;
|
|
6795
|
+
this.lastAnchorText = text;
|
|
6796
|
+
anchorEl.classList.remove("dxr-flash");
|
|
6797
|
+
void anchorEl.offsetWidth;
|
|
6798
|
+
anchorEl.classList.add("dxr-flash");
|
|
6799
|
+
}
|
|
6800
|
+
// ── loading overlay ─────────────────────────────────────────────────────────
|
|
6801
|
+
createLoaderController() {
|
|
6802
|
+
const overlay = this.control("loader");
|
|
6803
|
+
if (!overlay) {
|
|
6804
|
+
const noop = () => {
|
|
6805
|
+
};
|
|
6806
|
+
return { show: noop, stage: noop, progress: noop, done: noop, fail: noop };
|
|
6807
|
+
}
|
|
6808
|
+
const options = this.loaderOptions ?? {};
|
|
6809
|
+
const eyebrow = this.control("loaderEyebrow");
|
|
6810
|
+
if (eyebrow && options.eyebrow) eyebrow.textContent = options.eyebrow;
|
|
6811
|
+
const meta = this.control("loaderMeta");
|
|
6812
|
+
if (meta && options.meta) meta.textContent = options.meta;
|
|
6813
|
+
this.control("loaderRetry")?.addEventListener("click", () => {
|
|
6814
|
+
if (options.onRetry) options.onRetry();
|
|
6815
|
+
else location.reload();
|
|
6816
|
+
});
|
|
6817
|
+
if (this.features.length === 0) this.control("loaderAd")?.remove();
|
|
6818
|
+
const setProgress = (percent, label) => {
|
|
6819
|
+
const bar = this.control("loaderBar");
|
|
6820
|
+
if (bar) bar.style.width = `${Math.max(0, Math.min(100, percent))}%`;
|
|
6821
|
+
if (label) {
|
|
6822
|
+
const el = this.control("loaderLabel");
|
|
6823
|
+
if (el) el.textContent = label;
|
|
6824
|
+
}
|
|
6825
|
+
};
|
|
6826
|
+
return {
|
|
6827
|
+
show: () => {
|
|
6828
|
+
overlay.hidden = false;
|
|
6829
|
+
overlay.removeAttribute("data-done");
|
|
6830
|
+
overlay.removeAttribute("data-error");
|
|
6831
|
+
this.setState("loading");
|
|
6832
|
+
this.showFeature(0);
|
|
6833
|
+
this.startRotation();
|
|
6834
|
+
this.loaderStage(0);
|
|
6835
|
+
},
|
|
6836
|
+
stage: (step) => this.loaderStage(step),
|
|
6837
|
+
progress: setProgress,
|
|
6838
|
+
done: () => {
|
|
6839
|
+
this.stopRotation();
|
|
6840
|
+
this.setState("ready");
|
|
6841
|
+
setTimeout(() => overlay.setAttribute("data-done", ""), 420);
|
|
6842
|
+
setTimeout(() => {
|
|
6843
|
+
overlay.hidden = true;
|
|
6844
|
+
}, 1050);
|
|
6845
|
+
},
|
|
6846
|
+
fail: (error) => {
|
|
6847
|
+
this.stopRotation();
|
|
6848
|
+
this.setState("error");
|
|
6849
|
+
overlay.hidden = false;
|
|
6850
|
+
overlay.setAttribute("data-error", "");
|
|
6851
|
+
overlay.removeAttribute("data-done");
|
|
6852
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
6853
|
+
const title = this.control("loaderTitle");
|
|
6854
|
+
if (title) title.textContent = "The local engine did not start";
|
|
6855
|
+
const copy = this.control("loaderCopy");
|
|
6856
|
+
if (copy) copy.textContent = message.slice(0, 220);
|
|
6857
|
+
setProgress(100, "Load failed");
|
|
6858
|
+
this.setStatus(message.slice(0, 180));
|
|
6859
|
+
}
|
|
6860
|
+
};
|
|
6861
|
+
}
|
|
6862
|
+
loaderStage(step) {
|
|
6863
|
+
const stage = typeof step === "number" ? this.stages[Math.max(0, Math.min(this.stages.length - 1, step))] : step;
|
|
6864
|
+
if (!stage) return;
|
|
6865
|
+
const title = this.control("loaderTitle");
|
|
6866
|
+
if (title && stage.title) title.textContent = stage.title;
|
|
6867
|
+
const copy = this.control("loaderCopy");
|
|
6868
|
+
if (copy && stage.copy) copy.textContent = stage.copy;
|
|
6869
|
+
const bar = this.control("loaderBar");
|
|
6870
|
+
if (bar && stage.progress != null) bar.style.width = `${stage.progress}%`;
|
|
6871
|
+
const label = this.control("loaderLabel");
|
|
6872
|
+
if (label && stage.label) label.textContent = stage.label;
|
|
6873
|
+
}
|
|
6874
|
+
showFeature(index) {
|
|
6875
|
+
const feature = this.features[index];
|
|
6876
|
+
if (!feature) return;
|
|
6877
|
+
const card = this.control("loaderAd");
|
|
6878
|
+
const number = this.control("loaderNumber");
|
|
6879
|
+
const title = this.control("loaderAdTitle");
|
|
6880
|
+
const copy = this.control("loaderAdCopy");
|
|
6881
|
+
if (number) number.textContent = feature.number;
|
|
6882
|
+
if (title) title.textContent = feature.title;
|
|
6883
|
+
if (copy) copy.textContent = feature.copy;
|
|
6884
|
+
if (card) {
|
|
6885
|
+
card.removeAttribute("data-swap");
|
|
6886
|
+
void card.offsetWidth;
|
|
6887
|
+
card.setAttribute("data-swap", "");
|
|
6888
|
+
}
|
|
6889
|
+
}
|
|
6890
|
+
startRotation() {
|
|
6891
|
+
this.stopRotation();
|
|
6892
|
+
if (this.features.length < 2) return;
|
|
6893
|
+
const every = this.loaderOptions?.rotateMs ?? 1750;
|
|
6894
|
+
this.featureTimer = setInterval(() => {
|
|
6895
|
+
this.featureIndex = (this.featureIndex + 1) % this.features.length;
|
|
6896
|
+
this.showFeature(this.featureIndex);
|
|
6897
|
+
}, every);
|
|
6898
|
+
}
|
|
6899
|
+
stopRotation() {
|
|
6900
|
+
if (this.featureTimer == null) return;
|
|
6901
|
+
clearInterval(this.featureTimer);
|
|
6902
|
+
this.featureTimer = null;
|
|
6903
|
+
}
|
|
6904
|
+
};
|
|
6905
|
+
|
|
5018
6906
|
// src/index.ts
|
|
5019
6907
|
function openDocxSession2(bytes, settings) {
|
|
5020
6908
|
const wasm = ensureInitialized();
|
|
@@ -6264,7 +8152,7 @@ async function ensureWasm(wasmBasePath2) {
|
|
|
6264
8152
|
await initialize(dir);
|
|
6265
8153
|
}
|
|
6266
8154
|
}
|
|
6267
|
-
function
|
|
8155
|
+
function resolveContainer2(container) {
|
|
6268
8156
|
if (typeof container !== "string") return container;
|
|
6269
8157
|
const el = document.querySelector(container);
|
|
6270
8158
|
if (!el) throw new Error(`Docxodus embed: no element matches "${container}"`);
|
|
@@ -6417,7 +8305,7 @@ async function toDocumentBytes(source) {
|
|
|
6417
8305
|
throw new Error("Docxodus embed: unsupported document source");
|
|
6418
8306
|
}
|
|
6419
8307
|
async function createViewer(container, source, options = {}) {
|
|
6420
|
-
const el =
|
|
8308
|
+
const el = resolveContainer2(container);
|
|
6421
8309
|
const { wasmBasePath: wasmBasePath2, ...conversion } = options;
|
|
6422
8310
|
await ensureWasm(wasmBasePath2);
|
|
6423
8311
|
const mount = createScopedMount(el);
|
|
@@ -6454,7 +8342,7 @@ async function createViewer(container, source, options = {}) {
|
|
|
6454
8342
|
};
|
|
6455
8343
|
}
|
|
6456
8344
|
async function createEditor(container, source, options = {}) {
|
|
6457
|
-
const el =
|
|
8345
|
+
const el = resolveContainer2(container);
|
|
6458
8346
|
const { wasmBasePath: wasmBasePath2, ...editorOptions } = options;
|
|
6459
8347
|
await ensureWasm(wasmBasePath2);
|
|
6460
8348
|
const mount = createScopedMount(el);
|
|
@@ -6469,6 +8357,49 @@ async function createEditor(container, source, options = {}) {
|
|
|
6469
8357
|
throw error;
|
|
6470
8358
|
}
|
|
6471
8359
|
}
|
|
8360
|
+
function nameFromSource(source) {
|
|
8361
|
+
if (typeof source !== "string") return void 0;
|
|
8362
|
+
try {
|
|
8363
|
+
const path = new URL(source, typeof location === "undefined" ? void 0 : location.href).pathname;
|
|
8364
|
+
return decodeURIComponent(path.split("/").pop() ?? "") || void 0;
|
|
8365
|
+
} catch {
|
|
8366
|
+
return source.split("/").pop() || void 0;
|
|
8367
|
+
}
|
|
8368
|
+
}
|
|
8369
|
+
async function createRibbonEditor(container, source, options = {}) {
|
|
8370
|
+
const el = resolveContainer2(container);
|
|
8371
|
+
const { wasmBasePath: wasmBasePath2, ...ribbonOptions } = options;
|
|
8372
|
+
const mount = createScopedMount(el);
|
|
8373
|
+
mount.root.style.height = "100%";
|
|
8374
|
+
mount.root.style.minHeight = "0";
|
|
8375
|
+
const ribbon = mountRibbon(mount.root, {
|
|
8376
|
+
documentName: ribbonOptions.documentName ?? nameFromSource(source),
|
|
8377
|
+
...ribbonOptions,
|
|
8378
|
+
// Exports arrive after the runtime boots; the loader covers that gap.
|
|
8379
|
+
exports: void 0
|
|
8380
|
+
});
|
|
8381
|
+
try {
|
|
8382
|
+
ribbon.loader.stage(0);
|
|
8383
|
+
await ensureWasm(wasmBasePath2);
|
|
8384
|
+
ribbon.setExports(
|
|
8385
|
+
createScopedEditorExports(
|
|
8386
|
+
getWasmExports(),
|
|
8387
|
+
`${mount.selector} [data-dxr-surface]`
|
|
8388
|
+
)
|
|
8389
|
+
);
|
|
8390
|
+
ribbon.loader.stage(1);
|
|
8391
|
+
const bytes = source == null ? null : await toDocumentBytes(source);
|
|
8392
|
+
ribbon.loader.stage(2);
|
|
8393
|
+
if (bytes == null) ribbon.openBlank(ribbonOptions.documentName);
|
|
8394
|
+
else ribbon.open(bytes, ribbonOptions.documentName ?? nameFromSource(source));
|
|
8395
|
+
ribbon.loader.stage(3);
|
|
8396
|
+
ribbon.loader.done();
|
|
8397
|
+
return ribbon;
|
|
8398
|
+
} catch (error) {
|
|
8399
|
+
ribbon.loader.fail(error);
|
|
8400
|
+
throw error;
|
|
8401
|
+
}
|
|
8402
|
+
}
|
|
6472
8403
|
export {
|
|
6473
8404
|
AnchorIdRendering,
|
|
6474
8405
|
AnchorRenderMode,
|
|
@@ -6510,6 +8441,7 @@ export {
|
|
|
6510
8441
|
createBlankDocx,
|
|
6511
8442
|
createEditor,
|
|
6512
8443
|
createExternalAnnotationSet,
|
|
8444
|
+
createRibbonEditor,
|
|
6513
8445
|
createViewer,
|
|
6514
8446
|
docxDiffAcceptRevisions,
|
|
6515
8447
|
docxDiffCompare,
|
|
@@ -6545,6 +8477,7 @@ export {
|
|
|
6545
8477
|
isMove,
|
|
6546
8478
|
isMoveDestination,
|
|
6547
8479
|
isMoveSource,
|
|
8480
|
+
mountRibbon,
|
|
6548
8481
|
openDocxSession2 as openDocxSession,
|
|
6549
8482
|
paginateHtml,
|
|
6550
8483
|
projectAnnotationsOntoHtml,
|