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/editor.bundle.js
CHANGED
|
@@ -18,11 +18,11 @@ var DocxodusEditor = (() => {
|
|
|
18
18
|
};
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
20
|
|
|
21
|
-
// src/
|
|
22
|
-
var
|
|
23
|
-
__export(
|
|
21
|
+
// src/ribbon.ts
|
|
22
|
+
var ribbon_exports = {};
|
|
23
|
+
__export(ribbon_exports, {
|
|
24
24
|
DocxEditor: () => DocxEditor,
|
|
25
|
-
|
|
25
|
+
mountRibbon: () => mountRibbon
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
// src/page-number-format.ts
|
|
@@ -1921,6 +1921,28 @@ var DocxodusEditor = (() => {
|
|
|
1921
1921
|
}
|
|
1922
1922
|
while (i < n) removed.push(i++);
|
|
1923
1923
|
while (j < m) added.push(j++);
|
|
1924
|
+
const bareUnid = (token) => {
|
|
1925
|
+
const bar = token.indexOf("|");
|
|
1926
|
+
return bar < 0 ? token : token.slice(0, bar);
|
|
1927
|
+
};
|
|
1928
|
+
const substituted = [];
|
|
1929
|
+
const usedRemoved = /* @__PURE__ */ new Set();
|
|
1930
|
+
const removedByUnid = /* @__PURE__ */ new Map();
|
|
1931
|
+
for (const oi of removed) {
|
|
1932
|
+
const u = bareUnid(oldUnids[oi]);
|
|
1933
|
+
(removedByUnid.get(u) ?? removedByUnid.set(u, []).get(u)).push(oi);
|
|
1934
|
+
}
|
|
1935
|
+
const unmatchedAdded = [];
|
|
1936
|
+
for (const nj of added) {
|
|
1937
|
+
const candidates = removedByUnid.get(bareUnid(newUnids[nj]));
|
|
1938
|
+
const oi = candidates?.find((i2) => !usedRemoved.has(i2));
|
|
1939
|
+
if (oi !== void 0) {
|
|
1940
|
+
substituted.push({ oldIndex: oi, newIndex: nj });
|
|
1941
|
+
usedRemoved.add(oi);
|
|
1942
|
+
} else {
|
|
1943
|
+
unmatchedAdded.push(nj);
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1924
1946
|
const keptBeforeOld = (oi) => {
|
|
1925
1947
|
let c = 0;
|
|
1926
1948
|
for (const v of keep.values()) if (v < oi) c++;
|
|
@@ -1931,9 +1953,7 @@ var DocxodusEditor = (() => {
|
|
|
1931
1953
|
for (const k of keep.keys()) if (k < nj) c++;
|
|
1932
1954
|
return c;
|
|
1933
1955
|
};
|
|
1934
|
-
const
|
|
1935
|
-
const usedRemoved = /* @__PURE__ */ new Set();
|
|
1936
|
-
for (const nj of added) {
|
|
1956
|
+
for (const nj of unmatchedAdded) {
|
|
1937
1957
|
const target = keptBeforeNew(nj);
|
|
1938
1958
|
for (const oi of removed) {
|
|
1939
1959
|
if (usedRemoved.has(oi)) continue;
|
|
@@ -2137,6 +2157,33 @@ var DocxodusEditor = (() => {
|
|
|
2137
2157
|
if (lastText) return { node: lastText, offset: (lastText.textContent ?? "").length };
|
|
2138
2158
|
return { node: el, offset: el.childNodes.length };
|
|
2139
2159
|
}
|
|
2160
|
+
function caretPointFromClient(doc, clientX, clientY) {
|
|
2161
|
+
const caretDoc = doc;
|
|
2162
|
+
const position = caretDoc.caretPositionFromPoint?.(clientX, clientY);
|
|
2163
|
+
if (position) return { node: position.offsetNode, offset: position.offset };
|
|
2164
|
+
const range = caretDoc.caretRangeFromPoint?.(clientX, clientY);
|
|
2165
|
+
return range ? { node: range.startContainer, offset: range.startOffset } : null;
|
|
2166
|
+
}
|
|
2167
|
+
function setSelectionBetween(anchor, focus) {
|
|
2168
|
+
const sel = typeof window !== "undefined" ? window.getSelection() : null;
|
|
2169
|
+
if (!sel || !anchor.node.isConnected || !focus.node.isConnected) return false;
|
|
2170
|
+
try {
|
|
2171
|
+
const probe = document.createRange();
|
|
2172
|
+
probe.setStart(anchor.node, anchor.offset);
|
|
2173
|
+
probe.collapse(true);
|
|
2174
|
+
const focusIsBefore = probe.comparePoint(focus.node, focus.offset) < 0;
|
|
2175
|
+
const range = document.createRange();
|
|
2176
|
+
const start = focusIsBefore ? focus : anchor;
|
|
2177
|
+
const end = focusIsBefore ? anchor : focus;
|
|
2178
|
+
range.setStart(start.node, start.offset);
|
|
2179
|
+
range.setEnd(end.node, end.offset);
|
|
2180
|
+
sel.removeAllRanges();
|
|
2181
|
+
sel.addRange(range);
|
|
2182
|
+
return true;
|
|
2183
|
+
} catch {
|
|
2184
|
+
return false;
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2140
2187
|
function placeCaretAtOffset(el, offset) {
|
|
2141
2188
|
const sel = typeof window !== "undefined" ? window.getSelection() : null;
|
|
2142
2189
|
if (!sel) return;
|
|
@@ -2302,6 +2349,15 @@ var DocxodusEditor = (() => {
|
|
|
2302
2349
|
* block, and cleared when a caret is collapsed inside a block (so it never goes stale).
|
|
2303
2350
|
*/
|
|
2304
2351
|
this.lastSelection = null;
|
|
2352
|
+
/**
|
|
2353
|
+
* Stable bookmark for a selection spanning independent editable blocks. Native controls such as
|
|
2354
|
+
* a font-size combobox can take focus and collapse the live DOM selection; block ids + content
|
|
2355
|
+
* offsets let the command restore that same range before applying. This is the multi-block
|
|
2356
|
+
* counterpart to lastSelection above.
|
|
2357
|
+
*/
|
|
2358
|
+
this.lastCrossBlockSelection = null;
|
|
2359
|
+
/** State for the mouse-selection bridge between independent contenteditable block hosts. */
|
|
2360
|
+
this.dragSelection = null;
|
|
2305
2361
|
/** The docked header/footer bands, when `options.headerFooter` is on. */
|
|
2306
2362
|
this.region = null;
|
|
2307
2363
|
/** Why the last reconcile() fell back to a full remount (null = it patched). For
|
|
@@ -2313,24 +2369,128 @@ var DocxodusEditor = (() => {
|
|
|
2313
2369
|
const sel = typeof window !== "undefined" ? window.getSelection() : null;
|
|
2314
2370
|
if (!sel || sel.rangeCount === 0) return;
|
|
2315
2371
|
const range = sel.getRangeAt(0);
|
|
2316
|
-
const
|
|
2372
|
+
const startBlock = this.editableBlockOf(range.startContainer);
|
|
2373
|
+
const endBlock = this.editableBlockOf(range.endContainer);
|
|
2374
|
+
const block = startBlock ?? endBlock;
|
|
2317
2375
|
if (!block) return;
|
|
2318
|
-
const unid = block.getAttribute("data-anchor");
|
|
2319
|
-
if (!unid) return;
|
|
2320
2376
|
if (range.collapsed) {
|
|
2321
2377
|
this.lastSelection = null;
|
|
2378
|
+
this.lastCrossBlockSelection = null;
|
|
2322
2379
|
return;
|
|
2323
2380
|
}
|
|
2381
|
+
if (startBlock && endBlock && startBlock !== endBlock && this.ownerRoot(startBlock) === this.ownerRoot(endBlock)) {
|
|
2382
|
+
const startUnid = startBlock.getAttribute("data-anchor");
|
|
2383
|
+
const endUnid = endBlock.getAttribute("data-anchor");
|
|
2384
|
+
if (startUnid && endUnid) {
|
|
2385
|
+
this.lastSelection = null;
|
|
2386
|
+
this.lastCrossBlockSelection = {
|
|
2387
|
+
startUnid,
|
|
2388
|
+
startOffset: contentOffsetOf(startBlock, range.startContainer, range.startOffset),
|
|
2389
|
+
endUnid,
|
|
2390
|
+
endOffset: contentOffsetOf(endBlock, range.endContainer, range.endOffset)
|
|
2391
|
+
};
|
|
2392
|
+
}
|
|
2393
|
+
return;
|
|
2394
|
+
}
|
|
2395
|
+
const unid = block.getAttribute("data-anchor");
|
|
2396
|
+
if (!unid) return;
|
|
2397
|
+
this.lastCrossBlockSelection = null;
|
|
2324
2398
|
const span = selectionSpanIn(block);
|
|
2325
2399
|
if (span) this.lastSelection = { unid, span };
|
|
2326
2400
|
};
|
|
2401
|
+
/** Start tracking a normal primary-button text drag inside one editable block. */
|
|
2402
|
+
this.onMouseDown = (event) => {
|
|
2403
|
+
if (this.closed || !this.options.editable || event.button !== 0) return;
|
|
2404
|
+
const target = event.target instanceof Node ? event.target : null;
|
|
2405
|
+
const origin = this.editableBlockOf(target);
|
|
2406
|
+
if (!origin || isInMarker(target)) return;
|
|
2407
|
+
const anchor = caretPointFromClient(document, event.clientX, event.clientY);
|
|
2408
|
+
if (!anchor || this.editableBlockOf(anchor.node) !== origin) return;
|
|
2409
|
+
this.clearDragSelection();
|
|
2410
|
+
this.dragSelection = {
|
|
2411
|
+
anchor,
|
|
2412
|
+
origin,
|
|
2413
|
+
crossedBlockBoundary: false,
|
|
2414
|
+
focus: null,
|
|
2415
|
+
frame: null
|
|
2416
|
+
};
|
|
2417
|
+
};
|
|
2418
|
+
/**
|
|
2419
|
+
* Browsers fence native mouse selection at a contenteditable host boundary. Once a drag reaches
|
|
2420
|
+
* another block in the same OOXML story, take over just that gesture and create the cross-block
|
|
2421
|
+
* Selection the editor's existing multi-block command path consumes. Intra-block selection stays
|
|
2422
|
+
* entirely native, and separate hosts remain intact for safe per-anchor commits.
|
|
2423
|
+
*/
|
|
2424
|
+
this.onMouseMove = (event) => {
|
|
2425
|
+
const drag = this.dragSelection;
|
|
2426
|
+
if (!drag) return;
|
|
2427
|
+
if ((event.buttons & 1) === 0) {
|
|
2428
|
+
this.clearDragSelection();
|
|
2429
|
+
return;
|
|
2430
|
+
}
|
|
2431
|
+
const focus = caretPointFromClient(document, event.clientX, event.clientY);
|
|
2432
|
+
if (!focus || isInMarker(focus.node)) return;
|
|
2433
|
+
const focusBlock = this.editableBlockOf(focus.node);
|
|
2434
|
+
if (!focusBlock || this.ownerRoot(focusBlock) !== this.ownerRoot(drag.origin)) return;
|
|
2435
|
+
if (focusBlock !== drag.origin) drag.crossedBlockBoundary = true;
|
|
2436
|
+
if (!drag.crossedBlockBoundary) return;
|
|
2437
|
+
event.preventDefault();
|
|
2438
|
+
this.queueDragSelection(drag, focus);
|
|
2439
|
+
};
|
|
2440
|
+
/** Commit the final cross-block endpoint before releasing the gesture state. */
|
|
2441
|
+
this.onMouseUp = (event) => {
|
|
2442
|
+
const drag = this.dragSelection;
|
|
2443
|
+
if (!drag) return;
|
|
2444
|
+
if (drag.crossedBlockBoundary) {
|
|
2445
|
+
const focus = caretPointFromClient(document, event.clientX, event.clientY);
|
|
2446
|
+
const focusBlock = focus ? this.editableBlockOf(focus.node) : null;
|
|
2447
|
+
if (focus && focusBlock && this.ownerRoot(focusBlock) === this.ownerRoot(drag.origin)) {
|
|
2448
|
+
event.preventDefault();
|
|
2449
|
+
setSelectionBetween(drag.anchor, focus);
|
|
2450
|
+
}
|
|
2451
|
+
}
|
|
2452
|
+
this.clearDragSelection();
|
|
2453
|
+
};
|
|
2327
2454
|
this.container = container;
|
|
2328
2455
|
this.exports = exports;
|
|
2329
2456
|
this.handle = handle;
|
|
2330
2457
|
this.options = options;
|
|
2331
2458
|
this.editRoot = container;
|
|
2332
|
-
if (typeof document !== "undefined")
|
|
2459
|
+
if (typeof document !== "undefined") {
|
|
2333
2460
|
document.addEventListener("selectionchange", this.onSelectionChange);
|
|
2461
|
+
document.addEventListener("mousedown", this.onMouseDown, true);
|
|
2462
|
+
document.addEventListener("mousemove", this.onMouseMove, true);
|
|
2463
|
+
document.addEventListener("mouseup", this.onMouseUp, true);
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
/**
|
|
2467
|
+
* Apply the latest cross-block endpoint after the browser finishes its native mousemove
|
|
2468
|
+
* selection update. Firefox rewrites Selection back into the originating contenteditable after
|
|
2469
|
+
* event dispatch even when mousemove is cancelled; writing in requestAnimationFrame wins that
|
|
2470
|
+
* race and happens before paint. Coalescing also avoids rebuilding a Range for every raw pointer
|
|
2471
|
+
* event when the mouse is moving faster than the display can refresh.
|
|
2472
|
+
*/
|
|
2473
|
+
queueDragSelection(drag, focus) {
|
|
2474
|
+
drag.focus = focus;
|
|
2475
|
+
if (drag.frame !== null) return;
|
|
2476
|
+
const view = this.container.ownerDocument.defaultView;
|
|
2477
|
+
if (!view) {
|
|
2478
|
+
setSelectionBetween(drag.anchor, focus);
|
|
2479
|
+
return;
|
|
2480
|
+
}
|
|
2481
|
+
drag.frame = view.requestAnimationFrame(() => {
|
|
2482
|
+
drag.frame = null;
|
|
2483
|
+
if (this.dragSelection !== drag || !drag.focus) return;
|
|
2484
|
+
setSelectionBetween(drag.anchor, drag.focus);
|
|
2485
|
+
});
|
|
2486
|
+
}
|
|
2487
|
+
/** Cancel a queued repaint and discard the current gesture. */
|
|
2488
|
+
clearDragSelection() {
|
|
2489
|
+
const drag = this.dragSelection;
|
|
2490
|
+
if (drag && drag.frame !== null) {
|
|
2491
|
+
this.container.ownerDocument.defaultView?.cancelAnimationFrame(drag.frame);
|
|
2492
|
+
}
|
|
2493
|
+
this.dragSelection = null;
|
|
2334
2494
|
}
|
|
2335
2495
|
/** The editable block (contenteditable [data-anchor]) containing `node`, if any, within this editor.
|
|
2336
2496
|
* Fenced by `container`, not `editRoot`, so header/footer band blocks — which live outside the
|
|
@@ -2410,8 +2570,13 @@ var DocxodusEditor = (() => {
|
|
|
2410
2570
|
close() {
|
|
2411
2571
|
if (this.closed) return;
|
|
2412
2572
|
this.closed = true;
|
|
2413
|
-
if (typeof document !== "undefined")
|
|
2573
|
+
if (typeof document !== "undefined") {
|
|
2414
2574
|
document.removeEventListener("selectionchange", this.onSelectionChange);
|
|
2575
|
+
document.removeEventListener("mousedown", this.onMouseDown, true);
|
|
2576
|
+
document.removeEventListener("mousemove", this.onMouseMove, true);
|
|
2577
|
+
document.removeEventListener("mouseup", this.onMouseUp, true);
|
|
2578
|
+
}
|
|
2579
|
+
this.clearDragSelection();
|
|
2415
2580
|
this.exports.DocxSessionBridge.CloseSession(this.handle);
|
|
2416
2581
|
}
|
|
2417
2582
|
/**
|
|
@@ -2429,6 +2594,16 @@ var DocxodusEditor = (() => {
|
|
|
2429
2594
|
get root() {
|
|
2430
2595
|
return this.container;
|
|
2431
2596
|
}
|
|
2597
|
+
/**
|
|
2598
|
+
* The live `DocxSession` handle backing this editor — the model of record.
|
|
2599
|
+
*
|
|
2600
|
+
* Surfaced because chrome around the editor (the anchor rail) reports it as engine
|
|
2601
|
+
* state, and reaching into the private field from a host page only worked because
|
|
2602
|
+
* the bundle erases TypeScript's visibility.
|
|
2603
|
+
*/
|
|
2604
|
+
get sessionHandle() {
|
|
2605
|
+
return this.handle;
|
|
2606
|
+
}
|
|
2432
2607
|
// ─── internals ───────────────────────────────────────────────────────
|
|
2433
2608
|
assertOpen() {
|
|
2434
2609
|
if (this.closed) throw new Error("DocxEditor is closed");
|
|
@@ -2719,8 +2894,7 @@ var DocxodusEditor = (() => {
|
|
|
2719
2894
|
this.options.onEdit?.({ anchorId: second.id, unid: second.unid });
|
|
2720
2895
|
return;
|
|
2721
2896
|
}
|
|
2722
|
-
const firstEl = this.
|
|
2723
|
-
const secondEl = this.renderInto(second.id);
|
|
2897
|
+
const [firstEl, secondEl] = this.renderTwo(first.id, second.id);
|
|
2724
2898
|
if (!firstEl || !secondEl) return;
|
|
2725
2899
|
const inBand = this.isBandBlock(el);
|
|
2726
2900
|
if (!this.replaceNode(el, firstEl, secondEl)) return;
|
|
@@ -2833,6 +3007,34 @@ var DocxodusEditor = (() => {
|
|
|
2833
3007
|
if (html.charCodeAt(0) === 123) return null;
|
|
2834
3008
|
return new DOMParser().parseFromString(html, "text/html").body.firstElementChild;
|
|
2835
3009
|
}
|
|
3010
|
+
/** Render two blocks in ONE batched bridge call when the bundle carries RenderBlocksHtml —
|
|
3011
|
+
* the per-render shell/converter setup is paid once instead of twice, which matters on the
|
|
3012
|
+
* Enter path (split renders both halves synchronously under the keystroke). Falls back to
|
|
3013
|
+
* two per-block renders on older bundles. Output is renderInto-identical per block (both
|
|
3014
|
+
* routes share the same extraction). */
|
|
3015
|
+
renderTwo(a, b) {
|
|
3016
|
+
const bridge = this.exports.DocxSessionBridge;
|
|
3017
|
+
if (typeof bridge.RenderBlocksHtml === "function") {
|
|
3018
|
+
try {
|
|
3019
|
+
const map = JSON.parse(
|
|
3020
|
+
bridge.RenderBlocksHtml(
|
|
3021
|
+
this.handle,
|
|
3022
|
+
JSON.stringify([a, b]),
|
|
3023
|
+
this.options.cssPrefix,
|
|
3024
|
+
this.options.fabricateClasses
|
|
3025
|
+
)
|
|
3026
|
+
);
|
|
3027
|
+
if (!map.error) {
|
|
3028
|
+
const parse = (h) => h ? new DOMParser().parseFromString(h, "text/html").body.firstElementChild : null;
|
|
3029
|
+
const fa = parse(map[a]);
|
|
3030
|
+
const fb = parse(map[b]);
|
|
3031
|
+
if (fa && fb) return [fa, fb];
|
|
3032
|
+
}
|
|
3033
|
+
} catch {
|
|
3034
|
+
}
|
|
3035
|
+
}
|
|
3036
|
+
return [this.renderInto(a), this.renderInto(b)];
|
|
3037
|
+
}
|
|
2836
3038
|
/** The editable block immediately before `el` within its own root, or null. */
|
|
2837
3039
|
previousEditable(el) {
|
|
2838
3040
|
const all = Array.from(
|
|
@@ -2850,12 +3052,34 @@ var DocxodusEditor = (() => {
|
|
|
2850
3052
|
}
|
|
2851
3053
|
// ─── M5: formatting commands (ribbon) ────────────────────────────────
|
|
2852
3054
|
// ─── Multi-block selection helpers (format a whole stack of paragraphs at once) ──────
|
|
3055
|
+
/**
|
|
3056
|
+
* Restore a cross-block selection after a native toolbar control took focus. The bookmark uses
|
|
3057
|
+
* stable anchor ids and content offsets, so it also survives incremental block swaps.
|
|
3058
|
+
*/
|
|
3059
|
+
restoreCrossBlockSelection() {
|
|
3060
|
+
const bookmark = this.lastCrossBlockSelection;
|
|
3061
|
+
const active = this.activeBlock;
|
|
3062
|
+
if (!bookmark || !active) return false;
|
|
3063
|
+
const all = Array.from(
|
|
3064
|
+
this.ownerRoot(active).querySelectorAll('[data-anchor][contenteditable="true"]')
|
|
3065
|
+
);
|
|
3066
|
+
const first = all.find((block) => block.getAttribute("data-anchor") === bookmark.startUnid);
|
|
3067
|
+
const last = all.find((block) => block.getAttribute("data-anchor") === bookmark.endUnid);
|
|
3068
|
+
if (!first || !last || first === last || all.indexOf(first) > all.indexOf(last)) return false;
|
|
3069
|
+
const start = contentPositionIn(first, bookmark.startOffset);
|
|
3070
|
+
const end = contentPositionIn(last, bookmark.endOffset);
|
|
3071
|
+
return setSelectionBetween(start, end);
|
|
3072
|
+
}
|
|
2853
3073
|
/** Editable blocks the current selection covers, in document order. Uses Range.comparePoint
|
|
2854
3074
|
* (robust to a selection boundary that normalized onto a wrapper element rather than a block
|
|
2855
3075
|
* or text node — Range.intersectsNode misses the end block at a `(block, childCount)` boundary).
|
|
2856
3076
|
* A collapsed or single-block selection yields just the active block. */
|
|
2857
3077
|
selectedBlocks() {
|
|
2858
|
-
|
|
3078
|
+
let sel = typeof window !== "undefined" ? window.getSelection() : null;
|
|
3079
|
+
if ((!sel || sel.rangeCount === 0 || sel.isCollapsed) && this.lastCrossBlockSelection) {
|
|
3080
|
+
this.restoreCrossBlockSelection();
|
|
3081
|
+
sel = typeof window !== "undefined" ? window.getSelection() : null;
|
|
3082
|
+
}
|
|
2859
3083
|
const root = this.activeBlock ? this.ownerRoot(this.activeBlock) : this.editRoot;
|
|
2860
3084
|
const all = Array.from(
|
|
2861
3085
|
root.querySelectorAll('[data-anchor][contenteditable="true"]')
|
|
@@ -3634,7 +3858,8 @@ var DocxodusEditor = (() => {
|
|
|
3634
3858
|
);
|
|
3635
3859
|
if (oldMarker !== newMarker) return this.bail("substituted li marker drift");
|
|
3636
3860
|
}
|
|
3637
|
-
|
|
3861
|
+
const bodyApply = this.applyBodyDiff(oldNodes, plan.body, bodyDiff, freshBody);
|
|
3862
|
+
if (bodyApply !== true) return this.bail(`applyBodyDiff bail: ${bodyApply}`);
|
|
3638
3863
|
this.applyNotesDiff("footnotes", plan.footnotes, fnState, rendered);
|
|
3639
3864
|
this.applyNotesDiff("endnotes", plan.endnotes, enState, rendered);
|
|
3640
3865
|
const freshHasMarker = [...freshBody.values()].some(
|
|
@@ -3666,15 +3891,15 @@ var DocxodusEditor = (() => {
|
|
|
3666
3891
|
static anchorElOf(root) {
|
|
3667
3892
|
return root.hasAttribute("data-anchor") ? root : root.querySelector("[data-anchor]");
|
|
3668
3893
|
}
|
|
3669
|
-
/** Insert/remove/swap body unit nodes per the diff. Returns
|
|
3670
|
-
* ambiguity, order violation, wrapper semantics) — the
|
|
3671
|
-
* so bailing just means a full repaint. */
|
|
3894
|
+
/** Insert/remove/swap body unit nodes per the diff. Returns `true` on success or a
|
|
3895
|
+
* bail-reason string (parent ambiguity, order violation, wrapper semantics) — the
|
|
3896
|
+
* session is already correct, so bailing just means a full repaint. */
|
|
3672
3897
|
applyBodyDiff(oldNodes, units, diff, fresh) {
|
|
3673
3898
|
let lastOld = -1;
|
|
3674
3899
|
for (let j = 0; j < units.length; j++) {
|
|
3675
3900
|
const oi = diff.keep.get(j);
|
|
3676
3901
|
if (oi === void 0) continue;
|
|
3677
|
-
if (oi < lastOld) return
|
|
3902
|
+
if (oi < lastOld) return "kept order violation";
|
|
3678
3903
|
lastOld = oi;
|
|
3679
3904
|
}
|
|
3680
3905
|
const subOldByNew = new Map(diff.substituted.map((s) => [s.newIndex, s.oldIndex]));
|
|
@@ -3685,8 +3910,10 @@ var DocxodusEditor = (() => {
|
|
|
3685
3910
|
oldWrapper.replaceWith(freshRoot);
|
|
3686
3911
|
} else if (oldWrapper === oldNodes[oi]) {
|
|
3687
3912
|
oldNodes[oi].replaceWith(freshRoot);
|
|
3913
|
+
} else if (!oldNodes[oi].hasAttribute("data-render-sig") && unidOf(units[nj].id) === oldNodes[oi].getAttribute("data-anchor")) {
|
|
3914
|
+
oldNodes[oi].replaceWith(freshRoot);
|
|
3688
3915
|
} else {
|
|
3689
|
-
return
|
|
3916
|
+
return `leaf render into wrapped slot (unit ${units[nj].id.slice(0, 24)})`;
|
|
3690
3917
|
}
|
|
3691
3918
|
this.wireUnit(freshRoot, units[nj]);
|
|
3692
3919
|
}
|
|
@@ -3713,10 +3940,11 @@ var DocxodusEditor = (() => {
|
|
|
3713
3940
|
}
|
|
3714
3941
|
const prevW = prev ? this.unitWrapperOf(prev) : null;
|
|
3715
3942
|
const nextW = next ? this.unitWrapperOf(next) : null;
|
|
3716
|
-
if (prevW && nextW && prevW.parentElement !== nextW.parentElement)
|
|
3943
|
+
if (prevW && nextW && prevW.parentElement !== nextW.parentElement)
|
|
3944
|
+
return "insert neighbors in different parents";
|
|
3717
3945
|
if (prevW) prevW.after(el);
|
|
3718
3946
|
else if (nextW) nextW.before(el);
|
|
3719
|
-
else return
|
|
3947
|
+
else return "insert with no anchored neighbor";
|
|
3720
3948
|
this.wireUnit(el, units[j]);
|
|
3721
3949
|
}
|
|
3722
3950
|
for (const i of pureRemoved) {
|
|
@@ -3890,5 +4118,1665 @@ var DocxodusEditor = (() => {
|
|
|
3890
4118
|
this.syncRegionToBody(this.activeBlock ?? void 0);
|
|
3891
4119
|
}
|
|
3892
4120
|
};
|
|
3893
|
-
|
|
4121
|
+
|
|
4122
|
+
// src/ribbon-chrome.ts
|
|
4123
|
+
var RIBBON_STYLE_VERSION = "5";
|
|
4124
|
+
var RIBBON_STYLE_ATTR = "data-docxodus-ribbon-styles";
|
|
4125
|
+
var RIBBON_CSS = `
|
|
4126
|
+
.dxr {
|
|
4127
|
+
--dxr-ink: #101418;
|
|
4128
|
+
--dxr-sheet: #ffffff;
|
|
4129
|
+
--dxr-chrome: #eef1f6;
|
|
4130
|
+
--dxr-chrome-sunk: #e3e8f0;
|
|
4131
|
+
--dxr-rule: #d3dae4;
|
|
4132
|
+
--dxr-accent: #1f5fd0;
|
|
4133
|
+
--dxr-wash: #dde8fb;
|
|
4134
|
+
--dxr-muted: #5d6975;
|
|
4135
|
+
--dxr-data: #0b6f6a;
|
|
4136
|
+
--dxr-danger: #a3341f;
|
|
4137
|
+
--dxr-desk: #dfe3ea;
|
|
4138
|
+
--dxr-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
|
4139
|
+
--dxr-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
|
|
4140
|
+
--dxr-tap: 30px;
|
|
4141
|
+
|
|
4142
|
+
position: relative;
|
|
4143
|
+
display: flex;
|
|
4144
|
+
flex-direction: column;
|
|
4145
|
+
height: 100%;
|
|
4146
|
+
min-height: 0;
|
|
4147
|
+
isolation: isolate;
|
|
4148
|
+
font-family: var(--dxr-ui);
|
|
4149
|
+
color: var(--dxr-ink);
|
|
4150
|
+
background: var(--dxr-desk);
|
|
4151
|
+
-webkit-text-size-adjust: 100%;
|
|
4152
|
+
}
|
|
4153
|
+
.dxr *, .dxr *::before, .dxr *::after { box-sizing: border-box; }
|
|
4154
|
+
|
|
4155
|
+
/* Touch devices get bigger hit targets everywhere the token is used. */
|
|
4156
|
+
@media (pointer: coarse) { .dxr { --dxr-tap: 40px; } }
|
|
4157
|
+
|
|
4158
|
+
/* \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 */
|
|
4159
|
+
.dxr-chrome {
|
|
4160
|
+
position: sticky;
|
|
4161
|
+
top: 0;
|
|
4162
|
+
z-index: 10;
|
|
4163
|
+
flex: 0 0 auto;
|
|
4164
|
+
background: var(--dxr-chrome);
|
|
4165
|
+
border-bottom: 1px solid var(--dxr-rule);
|
|
4166
|
+
}
|
|
4167
|
+
|
|
4168
|
+
.dxr-titlebar {
|
|
4169
|
+
display: flex;
|
|
4170
|
+
align-items: center;
|
|
4171
|
+
gap: 10px;
|
|
4172
|
+
padding: 6px 10px 0;
|
|
4173
|
+
}
|
|
4174
|
+
.dxr-brand {
|
|
4175
|
+
display: flex;
|
|
4176
|
+
align-items: baseline;
|
|
4177
|
+
gap: 7px;
|
|
4178
|
+
min-width: 0;
|
|
4179
|
+
font-size: 13px;
|
|
4180
|
+
font-weight: 600;
|
|
4181
|
+
letter-spacing: -.01em;
|
|
4182
|
+
}
|
|
4183
|
+
.dxr-brand .dxr-mark {
|
|
4184
|
+
flex: 0 0 auto;
|
|
4185
|
+
width: 9px;
|
|
4186
|
+
height: 9px;
|
|
4187
|
+
background: var(--dxr-accent);
|
|
4188
|
+
clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
|
|
4189
|
+
}
|
|
4190
|
+
.dxr-brand .dxr-docname {
|
|
4191
|
+
overflow: hidden;
|
|
4192
|
+
max-width: 22ch;
|
|
4193
|
+
color: var(--dxr-muted);
|
|
4194
|
+
font-size: 12px;
|
|
4195
|
+
font-weight: 400;
|
|
4196
|
+
text-overflow: ellipsis;
|
|
4197
|
+
white-space: nowrap;
|
|
4198
|
+
}
|
|
4199
|
+
.dxr-quick { flex: 0 0 auto; display: flex; align-items: center; gap: 3px; }
|
|
4200
|
+
.dxr-titlebar .dxr-spacer { flex: 1; }
|
|
4201
|
+
.dxr-status {
|
|
4202
|
+
overflow: hidden;
|
|
4203
|
+
max-width: 42ch;
|
|
4204
|
+
color: var(--dxr-muted);
|
|
4205
|
+
font-family: var(--dxr-mono);
|
|
4206
|
+
font-size: 11.5px;
|
|
4207
|
+
text-overflow: ellipsis;
|
|
4208
|
+
white-space: nowrap;
|
|
4209
|
+
}
|
|
4210
|
+
|
|
4211
|
+
/* \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 */
|
|
4212
|
+
.dxr-tabs {
|
|
4213
|
+
display: flex;
|
|
4214
|
+
gap: 1px;
|
|
4215
|
+
padding: 6px 10px 0;
|
|
4216
|
+
overflow-x: auto;
|
|
4217
|
+
scrollbar-width: none;
|
|
4218
|
+
}
|
|
4219
|
+
.dxr-tabs::-webkit-scrollbar { display: none; }
|
|
4220
|
+
.dxr-tab {
|
|
4221
|
+
flex: 0 0 auto;
|
|
4222
|
+
padding: 6px 15px 7px;
|
|
4223
|
+
border: 1px solid transparent;
|
|
4224
|
+
border-bottom: none;
|
|
4225
|
+
border-radius: 5px 5px 0 0;
|
|
4226
|
+
background: none;
|
|
4227
|
+
color: var(--dxr-muted);
|
|
4228
|
+
font: inherit;
|
|
4229
|
+
font-size: 12.5px;
|
|
4230
|
+
cursor: pointer;
|
|
4231
|
+
}
|
|
4232
|
+
.dxr-tab:hover { color: var(--dxr-ink); background: #e6ebf3; }
|
|
4233
|
+
.dxr-tab[aria-selected="true"] {
|
|
4234
|
+
color: var(--dxr-ink);
|
|
4235
|
+
font-weight: 600;
|
|
4236
|
+
background: var(--dxr-chrome-sunk);
|
|
4237
|
+
border-color: var(--dxr-rule);
|
|
4238
|
+
box-shadow: inset 0 2px 0 var(--dxr-accent);
|
|
4239
|
+
}
|
|
4240
|
+
/* Contextual tab \u2014 present only while the caret is inside a table. */
|
|
4241
|
+
.dxr-tab[data-contextual] { color: var(--dxr-accent); }
|
|
4242
|
+
.dxr-tab[hidden] { display: none; }
|
|
4243
|
+
|
|
4244
|
+
/* \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 */
|
|
4245
|
+
.dxr-ribbon { background: var(--dxr-chrome-sunk); border-top: 1px solid var(--dxr-rule); }
|
|
4246
|
+
.dxr-ribbon[aria-disabled="true"] { opacity: .45; pointer-events: none; }
|
|
4247
|
+
.dxr-panel {
|
|
4248
|
+
display: none;
|
|
4249
|
+
align-items: stretch;
|
|
4250
|
+
padding: 7px 10px 8px;
|
|
4251
|
+
overflow-x: auto;
|
|
4252
|
+
overscroll-behavior-x: contain;
|
|
4253
|
+
}
|
|
4254
|
+
.dxr-panel[data-active] { display: flex; }
|
|
4255
|
+
/* Group label sits ABOVE its controls (a spec-sheet reading), with hairline
|
|
4256
|
+
dividers rather than boxes \u2014 lighter than the boxed, label-under convention. */
|
|
4257
|
+
.dxr-group {
|
|
4258
|
+
flex: 0 0 auto;
|
|
4259
|
+
display: flex;
|
|
4260
|
+
flex-direction: column;
|
|
4261
|
+
gap: 5px;
|
|
4262
|
+
padding: 0 13px;
|
|
4263
|
+
border-right: 1px solid var(--dxr-rule);
|
|
4264
|
+
}
|
|
4265
|
+
.dxr-group:last-child { border-right: none; }
|
|
4266
|
+
.dxr-group:first-child { padding-left: 0; }
|
|
4267
|
+
.dxr-glabel {
|
|
4268
|
+
color: var(--dxr-muted);
|
|
4269
|
+
font-size: 9.5px;
|
|
4270
|
+
font-weight: 600;
|
|
4271
|
+
letter-spacing: .11em;
|
|
4272
|
+
text-transform: uppercase;
|
|
4273
|
+
}
|
|
4274
|
+
.dxr-row { display: flex; gap: 3px; align-items: center; }
|
|
4275
|
+
|
|
4276
|
+
/* \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 */
|
|
4277
|
+
.dxr button, .dxr label.dxr-btn {
|
|
4278
|
+
min-height: var(--dxr-tap);
|
|
4279
|
+
padding: 5px 9px;
|
|
4280
|
+
border: 1px solid transparent;
|
|
4281
|
+
border-radius: 4px;
|
|
4282
|
+
background: none;
|
|
4283
|
+
color: var(--dxr-ink);
|
|
4284
|
+
font: inherit;
|
|
4285
|
+
font-size: 13px;
|
|
4286
|
+
line-height: 1.15;
|
|
4287
|
+
cursor: pointer;
|
|
4288
|
+
}
|
|
4289
|
+
.dxr label.dxr-btn { display: inline-flex; align-items: center; }
|
|
4290
|
+
.dxr button:hover, .dxr label.dxr-btn:hover { background: #d6deea; }
|
|
4291
|
+
.dxr button:active { background: #c8d3e3; }
|
|
4292
|
+
.dxr button:disabled { opacity: .38; cursor: default; background: none; }
|
|
4293
|
+
.dxr button.dxr-on { color: var(--dxr-accent); background: var(--dxr-wash); border-color: #b3ccf2; }
|
|
4294
|
+
.dxr-quick button, .dxr-quick label.dxr-btn {
|
|
4295
|
+
padding: 4px 10px;
|
|
4296
|
+
border-color: var(--dxr-rule);
|
|
4297
|
+
background: #f7f9fc;
|
|
4298
|
+
font-size: 12.5px;
|
|
4299
|
+
}
|
|
4300
|
+
.dxr-quick button:hover, .dxr-quick label.dxr-btn:hover { background: #fff; border-color: #b9c4d4; }
|
|
4301
|
+
.dxr-quick button:disabled:hover { background: #f7f9fc; border-color: var(--dxr-rule); }
|
|
4302
|
+
.dxr button.dxr-icon { min-width: var(--dxr-tap); text-align: center; }
|
|
4303
|
+
/* Icons are inline SVG drawn from the same shapes the control acts on (text lines,
|
|
4304
|
+
rules), so alignment and indent read at a glance instead of relying on arrow
|
|
4305
|
+
glyphs that collide with undo/redo. currentColor keeps them in step with state. */
|
|
4306
|
+
.dxr button svg { display: block; margin: 0 auto; fill: currentColor; }
|
|
4307
|
+
.dxr button.dxr-wide { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
|
|
4308
|
+
.dxr button.dxr-danger:hover { color: var(--dxr-danger); background: #f6dcd6; }
|
|
4309
|
+
.dxr select, .dxr input[type="number"], .dxr input[type="text"] {
|
|
4310
|
+
min-height: var(--dxr-tap);
|
|
4311
|
+
padding: 4px 6px;
|
|
4312
|
+
border: 1px solid var(--dxr-rule);
|
|
4313
|
+
border-radius: 4px;
|
|
4314
|
+
background: #f7f9fc;
|
|
4315
|
+
color: var(--dxr-ink);
|
|
4316
|
+
font: inherit;
|
|
4317
|
+
font-size: 12.5px;
|
|
4318
|
+
}
|
|
4319
|
+
.dxr select:focus-visible, .dxr input:focus-visible, .dxr button:focus-visible,
|
|
4320
|
+
.dxr .dxr-tab:focus-visible, .dxr label.dxr-btn:focus-within {
|
|
4321
|
+
outline: 2px solid var(--dxr-accent);
|
|
4322
|
+
outline-offset: 1px;
|
|
4323
|
+
}
|
|
4324
|
+
.dxr [data-dxr="fontsize"] { width: 62px; }
|
|
4325
|
+
.dxr [data-dxr="fontfamily"] { max-width: 132px; }
|
|
4326
|
+
.dxr [data-dxr="pgstart"] { width: 64px; }
|
|
4327
|
+
.dxr-toggle {
|
|
4328
|
+
display: inline-flex;
|
|
4329
|
+
gap: 5px;
|
|
4330
|
+
align-items: center;
|
|
4331
|
+
color: var(--dxr-ink);
|
|
4332
|
+
font-size: 12.5px;
|
|
4333
|
+
white-space: nowrap;
|
|
4334
|
+
cursor: pointer;
|
|
4335
|
+
}
|
|
4336
|
+
.dxr-note { color: var(--dxr-muted); font-size: 11.5px; }
|
|
4337
|
+
|
|
4338
|
+
/* \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
|
|
4339
|
+
The addressing spine made permanent chrome. Every block in this editor is
|
|
4340
|
+
addressable as kind:scope:unid, and the model of record is a live WASM session \u2014
|
|
4341
|
+
so the surface states both, live, instead of hiding them behind devtools. It also
|
|
4342
|
+
reports each command's real cost, which is what a smoke test needs to see. */
|
|
4343
|
+
.dxr-rail {
|
|
4344
|
+
display: flex;
|
|
4345
|
+
align-items: center;
|
|
4346
|
+
height: 25px;
|
|
4347
|
+
padding: 0 10px;
|
|
4348
|
+
overflow-x: auto;
|
|
4349
|
+
background: #f7f9fc;
|
|
4350
|
+
border-top: 1px solid var(--dxr-rule);
|
|
4351
|
+
color: var(--dxr-muted);
|
|
4352
|
+
font-family: var(--dxr-mono);
|
|
4353
|
+
font-size: 11.5px;
|
|
4354
|
+
scrollbar-width: none;
|
|
4355
|
+
}
|
|
4356
|
+
.dxr-rail::-webkit-scrollbar { display: none; }
|
|
4357
|
+
.dxr-rail .dxr-cell {
|
|
4358
|
+
display: flex;
|
|
4359
|
+
align-items: baseline;
|
|
4360
|
+
gap: 6px;
|
|
4361
|
+
padding: 0 13px;
|
|
4362
|
+
border-right: 1px solid var(--dxr-rule);
|
|
4363
|
+
white-space: nowrap;
|
|
4364
|
+
}
|
|
4365
|
+
.dxr-rail .dxr-cell:first-child { padding-left: 0; }
|
|
4366
|
+
.dxr-rail .dxr-cell:last-child { border-right: none; }
|
|
4367
|
+
.dxr-rail .dxr-k {
|
|
4368
|
+
color: #8b96a3;
|
|
4369
|
+
font-family: var(--dxr-ui);
|
|
4370
|
+
font-size: 9.5px;
|
|
4371
|
+
letter-spacing: .1em;
|
|
4372
|
+
text-transform: uppercase;
|
|
4373
|
+
}
|
|
4374
|
+
.dxr-rail .dxr-v { color: var(--dxr-data); }
|
|
4375
|
+
.dxr-rail .dxr-v.dxr-flash { animation: dxr-railflash .45s ease-out; }
|
|
4376
|
+
@keyframes dxr-railflash { from { background: #b9ecdf; } to { background: transparent; } }
|
|
4377
|
+
|
|
4378
|
+
/* \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 */
|
|
4379
|
+
.dxr-hint {
|
|
4380
|
+
flex: 0 0 auto;
|
|
4381
|
+
max-width: 920px;
|
|
4382
|
+
margin: 0 auto;
|
|
4383
|
+
padding: 9px 16px 0;
|
|
4384
|
+
color: var(--dxr-muted);
|
|
4385
|
+
font-size: 12px;
|
|
4386
|
+
line-height: 1.5;
|
|
4387
|
+
}
|
|
4388
|
+
.dxr-hint kbd {
|
|
4389
|
+
padding: 0 4px;
|
|
4390
|
+
border: 1px solid var(--dxr-rule);
|
|
4391
|
+
border-radius: 3px;
|
|
4392
|
+
background: #e8ecf3;
|
|
4393
|
+
font-family: var(--dxr-mono);
|
|
4394
|
+
font-size: 11px;
|
|
4395
|
+
}
|
|
4396
|
+
|
|
4397
|
+
/* \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
|
|
4398
|
+
The surface is also the element the converter's own stylesheet treats as the
|
|
4399
|
+
document body: in an embed, its "body { margin: 20px }" is rewritten to
|
|
4400
|
+
[data-docxodus-embed-root="dN"] [data-dxr-surface] \u2014 (0,2,0), and inserted AFTER
|
|
4401
|
+
this sheet, so it wins a tie. Rules that own the SHEET BOX (centering, page
|
|
4402
|
+
padding, the paper itself) therefore qualify with the root's data-chrome to reach
|
|
4403
|
+
(0,3,0). Rules that only style CONTENT stay unqualified \u2014 there the converter
|
|
4404
|
+
SHOULD win.
|
|
4405
|
+
(No backticks in this file's comments: the stylesheet is a template literal.) */
|
|
4406
|
+
.dxr-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; }
|
|
4407
|
+
.dxr[data-chrome] .dxr-surface { max-width: 920px; margin: 26px auto; padding: 0 16px 96px; }
|
|
4408
|
+
.dxr-surface[data-view="continuous"] > * { background: var(--dxr-sheet); }
|
|
4409
|
+
.dxr[data-chrome] .dxr-surface[data-view="continuous"] {
|
|
4410
|
+
padding: 56px 72px;
|
|
4411
|
+
border-radius: 3px;
|
|
4412
|
+
background: var(--dxr-sheet);
|
|
4413
|
+
box-shadow: 0 1px 3px rgba(16, 20, 24, .14), 0 8px 24px rgba(16, 20, 24, .05);
|
|
4414
|
+
}
|
|
4415
|
+
.dxr-surface [contenteditable="true"]:focus {
|
|
4416
|
+
outline: 2px solid var(--dxr-accent);
|
|
4417
|
+
outline-offset: 2px;
|
|
4418
|
+
border-radius: 2px;
|
|
4419
|
+
}
|
|
4420
|
+
@media (hover: hover) { .dxr-surface [contenteditable="true"]:hover { background: #f2f7ff; } }
|
|
4421
|
+
|
|
4422
|
+
/* Header/footer bands: stories live in their own OOXML parts outside the body,
|
|
4423
|
+
so they dock as their own regions. Styled from the same tokens as the ribbon
|
|
4424
|
+
so the surface reads as one instrument rather than two apps. */
|
|
4425
|
+
.dxr-surface .docx-hf-band {
|
|
4426
|
+
margin: 0 0 14px;
|
|
4427
|
+
padding: 9px 72px 13px;
|
|
4428
|
+
border: 1px solid var(--dxr-rule);
|
|
4429
|
+
border-left: 2px solid #c2ccd9;
|
|
4430
|
+
border-radius: 3px;
|
|
4431
|
+
background: var(--dxr-sheet);
|
|
4432
|
+
}
|
|
4433
|
+
.dxr-surface .docx-hf-band + .docx-body-flow { margin-top: 0; }
|
|
4434
|
+
.dxr-surface .docx-hf-band[data-hf-band="footer"] { margin: 14px 0 0; }
|
|
4435
|
+
.dxr-surface .docx-hf-chrome {
|
|
4436
|
+
display: flex;
|
|
4437
|
+
gap: 8px;
|
|
4438
|
+
align-items: center;
|
|
4439
|
+
flex-wrap: wrap;
|
|
4440
|
+
margin: 0 0 7px -60px;
|
|
4441
|
+
color: var(--dxr-muted);
|
|
4442
|
+
font-size: 9.5px;
|
|
4443
|
+
font-weight: 600;
|
|
4444
|
+
letter-spacing: .11em;
|
|
4445
|
+
text-transform: uppercase;
|
|
4446
|
+
}
|
|
4447
|
+
.dxr-surface .docx-hf-chrome select, .dxr-surface .docx-hf-chrome input {
|
|
4448
|
+
padding: 3px 5px;
|
|
4449
|
+
border: 1px solid var(--dxr-rule);
|
|
4450
|
+
border-radius: 4px;
|
|
4451
|
+
background: #f7f9fc;
|
|
4452
|
+
color: var(--dxr-ink);
|
|
4453
|
+
font: inherit;
|
|
4454
|
+
font-family: var(--dxr-ui);
|
|
4455
|
+
font-size: 12.5px;
|
|
4456
|
+
font-weight: 400;
|
|
4457
|
+
letter-spacing: normal;
|
|
4458
|
+
text-transform: none;
|
|
4459
|
+
}
|
|
4460
|
+
.dxr-surface .docx-hf-chrome input[data-hf-pagestart] { width: 64px; }
|
|
4461
|
+
.dxr-surface .docx-hf-label { font-weight: 600; }
|
|
4462
|
+
.dxr-surface .docx-hf-warning {
|
|
4463
|
+
margin: 0 0 8px -60px;
|
|
4464
|
+
padding: 7px 9px;
|
|
4465
|
+
border: 1px solid #e8d9a8;
|
|
4466
|
+
border-left: 2px solid #c9a227;
|
|
4467
|
+
border-radius: 3px;
|
|
4468
|
+
background: #fdf6e3;
|
|
4469
|
+
color: #6b5310;
|
|
4470
|
+
font-size: 12px;
|
|
4471
|
+
line-height: 1.45;
|
|
4472
|
+
}
|
|
4473
|
+
.dxr-surface .docx-hf-warning button {
|
|
4474
|
+
margin-left: 6px;
|
|
4475
|
+
padding: 2px 8px;
|
|
4476
|
+
border-color: #e8d9a8;
|
|
4477
|
+
background: #fff;
|
|
4478
|
+
font-size: 12px;
|
|
4479
|
+
}
|
|
4480
|
+
.dxr-surface .docx-hf-placeholder { color: #9aa4b1; font-style: italic; }
|
|
4481
|
+
.dxr-surface .docx-hf-inherited {
|
|
4482
|
+
color: var(--dxr-muted);
|
|
4483
|
+
font-style: italic;
|
|
4484
|
+
font-weight: 400;
|
|
4485
|
+
letter-spacing: normal;
|
|
4486
|
+
text-transform: none;
|
|
4487
|
+
}
|
|
4488
|
+
.dxr-surface .docx-hf-band[data-hf-inherited] { border-style: dashed; }
|
|
4489
|
+
.dxr[data-chrome] .dxr-surface[data-view="continuous"]:has(.docx-body-flow) {
|
|
4490
|
+
padding: 0;
|
|
4491
|
+
background: transparent;
|
|
4492
|
+
box-shadow: none;
|
|
4493
|
+
}
|
|
4494
|
+
.dxr[data-chrome] .dxr-surface[data-view="continuous"] .docx-body-flow {
|
|
4495
|
+
padding: 56px 72px;
|
|
4496
|
+
border-radius: 3px;
|
|
4497
|
+
background: var(--dxr-sheet);
|
|
4498
|
+
box-shadow: 0 1px 3px rgba(16, 20, 24, .14), 0 8px 24px rgba(16, 20, 24, .05);
|
|
4499
|
+
}
|
|
4500
|
+
|
|
4501
|
+
/* \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 */
|
|
4502
|
+
.dxr-pop {
|
|
4503
|
+
display: none;
|
|
4504
|
+
position: absolute;
|
|
4505
|
+
z-index: 30;
|
|
4506
|
+
padding: 9px;
|
|
4507
|
+
border: 1px solid var(--dxr-rule);
|
|
4508
|
+
border-radius: 6px;
|
|
4509
|
+
background: #fff;
|
|
4510
|
+
box-shadow: 0 4px 16px rgba(16, 20, 24, .18);
|
|
4511
|
+
}
|
|
4512
|
+
.dxr-pop[data-open] { display: block; }
|
|
4513
|
+
.dxr-gridcells { display: grid; grid-template-columns: repeat(10, 16px); gap: 2px; }
|
|
4514
|
+
.dxr-gridcells div {
|
|
4515
|
+
width: 16px;
|
|
4516
|
+
height: 16px;
|
|
4517
|
+
border: 1px solid var(--dxr-rule);
|
|
4518
|
+
border-radius: 2px;
|
|
4519
|
+
background: #f2f5f9;
|
|
4520
|
+
cursor: pointer;
|
|
4521
|
+
}
|
|
4522
|
+
.dxr-gridcells div[data-on] { background: var(--dxr-wash); border-color: var(--dxr-accent); }
|
|
4523
|
+
.dxr-popfoot {
|
|
4524
|
+
display: flex;
|
|
4525
|
+
justify-content: space-between;
|
|
4526
|
+
align-items: center;
|
|
4527
|
+
flex-wrap: wrap;
|
|
4528
|
+
gap: 10px;
|
|
4529
|
+
margin-top: 8px;
|
|
4530
|
+
font-size: 12px;
|
|
4531
|
+
}
|
|
4532
|
+
|
|
4533
|
+
/* \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
|
|
4534
|
+
One scrolling strip per tab instead of a multi-row ribbon: group labels turn
|
|
4535
|
+
into inline dividers, the rail and hint step aside, and the picker becomes a
|
|
4536
|
+
bottom sheet because there is no room to hang a popover off a button. */
|
|
4537
|
+
/* A 320px phone cannot hold the product name AND the file actions, and the file
|
|
4538
|
+
actions are what a user came for. The strip also scrolls, so nothing is stranded. */
|
|
4539
|
+
.dxr[data-chrome="compact"] .dxr-titlebar {
|
|
4540
|
+
gap: 6px;
|
|
4541
|
+
padding: 5px 8px 0;
|
|
4542
|
+
overflow-x: auto;
|
|
4543
|
+
scrollbar-width: none;
|
|
4544
|
+
}
|
|
4545
|
+
.dxr[data-chrome="compact"] .dxr-titlebar::-webkit-scrollbar { display: none; }
|
|
4546
|
+
.dxr[data-chrome="compact"] .dxr-brandname { display: none; }
|
|
4547
|
+
.dxr[data-chrome="compact"] .dxr-brand { flex: 0 1 auto; }
|
|
4548
|
+
/* A filename clipped to "do..." tells you less than no filename at all, so it keeps a
|
|
4549
|
+
readable floor and the strip scrolls instead. The tighter file-action padding is what
|
|
4550
|
+
buys that floor back on a 390px screen. */
|
|
4551
|
+
.dxr[data-chrome="compact"] .dxr-brand .dxr-docname { min-width: 6ch; max-width: 14ch; }
|
|
4552
|
+
.dxr[data-chrome="compact"] .dxr-quick button,
|
|
4553
|
+
.dxr[data-chrome="compact"] .dxr-quick label.dxr-btn { padding: 4px 8px; }
|
|
4554
|
+
.dxr[data-chrome="compact"] .dxr-status { display: none; }
|
|
4555
|
+
.dxr[data-chrome="compact"] .dxr-tabs { padding: 5px 8px 0; }
|
|
4556
|
+
.dxr[data-chrome="compact"] .dxr-tab { padding: 6px 12px 7px; font-size: 12px; }
|
|
4557
|
+
.dxr[data-chrome="compact"] .dxr-panel {
|
|
4558
|
+
align-items: center;
|
|
4559
|
+
gap: 4px;
|
|
4560
|
+
padding: 5px 8px;
|
|
4561
|
+
scroll-snap-type: x proximity;
|
|
4562
|
+
}
|
|
4563
|
+
.dxr[data-chrome="compact"] .dxr-group {
|
|
4564
|
+
flex-direction: row;
|
|
4565
|
+
align-items: center;
|
|
4566
|
+
gap: 4px;
|
|
4567
|
+
padding: 0 8px;
|
|
4568
|
+
scroll-snap-align: start;
|
|
4569
|
+
}
|
|
4570
|
+
.dxr[data-chrome="compact"] .dxr-glabel { display: none; }
|
|
4571
|
+
.dxr[data-chrome="compact"] .dxr-note { display: none; }
|
|
4572
|
+
.dxr[data-chrome="compact"] .dxr-rail { display: none; }
|
|
4573
|
+
.dxr[data-chrome="compact"] .dxr-hint { display: none; }
|
|
4574
|
+
.dxr[data-chrome="compact"] .dxr-surface { margin: 12px auto; padding: 0 10px 64px; }
|
|
4575
|
+
.dxr[data-chrome="compact"] .dxr-surface[data-view="continuous"] { padding: 22px 18px; }
|
|
4576
|
+
.dxr[data-chrome="compact"] .dxr-surface[data-view="continuous"] .docx-body-flow { padding: 22px 18px; }
|
|
4577
|
+
.dxr[data-chrome="compact"] .dxr-surface .docx-hf-band { padding: 9px 18px 13px; }
|
|
4578
|
+
.dxr[data-chrome="compact"] .dxr-surface .docx-hf-chrome,
|
|
4579
|
+
.dxr[data-chrome="compact"] .dxr-surface .docx-hf-warning { margin-left: 0; }
|
|
4580
|
+
/* A popover anchored to a button has nowhere to go on a narrow surface, so the
|
|
4581
|
+
picker docks to the bottom edge where a thumb already is. */
|
|
4582
|
+
.dxr[data-chrome="compact"] .dxr-pop[data-open] {
|
|
4583
|
+
position: fixed;
|
|
4584
|
+
left: 50%;
|
|
4585
|
+
right: auto;
|
|
4586
|
+
bottom: 12px;
|
|
4587
|
+
top: auto !important;
|
|
4588
|
+
transform: translateX(-50%);
|
|
4589
|
+
max-width: calc(100vw - 20px);
|
|
4590
|
+
}
|
|
4591
|
+
|
|
4592
|
+
/* \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
|
|
4593
|
+
Kept from the shipped demo: the wait is real (a .NET runtime is streaming), so
|
|
4594
|
+
the surface spends it explaining what is being built rather than showing a
|
|
4595
|
+
spinner. It covers the whole instrument so half-built chrome never flashes. */
|
|
4596
|
+
.dxr-loader {
|
|
4597
|
+
position: absolute;
|
|
4598
|
+
inset: 0;
|
|
4599
|
+
z-index: 40;
|
|
4600
|
+
display: grid;
|
|
4601
|
+
place-items: center;
|
|
4602
|
+
padding: 24px;
|
|
4603
|
+
color: #f4f9ff;
|
|
4604
|
+
background:
|
|
4605
|
+
radial-gradient(circle at 20% 20%, rgba(63, 128, 255, .24), transparent 22rem),
|
|
4606
|
+
radial-gradient(circle at 82% 80%, rgba(176, 91, 255, .22), transparent 24rem),
|
|
4607
|
+
linear-gradient(145deg, #071221 0%, #0b1930 52%, #101426 100%);
|
|
4608
|
+
transition: opacity .55s ease, visibility .55s ease;
|
|
4609
|
+
}
|
|
4610
|
+
.dxr-loader[hidden] { display: none; }
|
|
4611
|
+
/* pointer-events drops the instant the fade starts: the surface underneath is already
|
|
4612
|
+
live, so a click during the half-second fade should reach it rather than be eaten. */
|
|
4613
|
+
.dxr-loader[data-done] { opacity: 0; visibility: hidden; pointer-events: none; }
|
|
4614
|
+
.dxr-loader-grid {
|
|
4615
|
+
width: min(850px, 100%);
|
|
4616
|
+
display: grid;
|
|
4617
|
+
grid-template-columns: 1fr;
|
|
4618
|
+
align-items: center;
|
|
4619
|
+
gap: 22px;
|
|
4620
|
+
text-align: center;
|
|
4621
|
+
}
|
|
4622
|
+
.dxr-visual { position: relative; width: min(170px, 52vw); aspect-ratio: 1; margin: 0 auto; }
|
|
4623
|
+
.dxr-orbit {
|
|
4624
|
+
position: absolute;
|
|
4625
|
+
inset: 7%;
|
|
4626
|
+
border: 1px solid rgba(115, 204, 255, .22);
|
|
4627
|
+
border-radius: 50%;
|
|
4628
|
+
animation: dxr-spin 9s linear infinite;
|
|
4629
|
+
}
|
|
4630
|
+
.dxr-orbit.dxr-two {
|
|
4631
|
+
inset: 20%;
|
|
4632
|
+
border-style: dashed;
|
|
4633
|
+
border-color: rgba(196, 128, 255, .32);
|
|
4634
|
+
animation-duration: 6s;
|
|
4635
|
+
animation-direction: reverse;
|
|
4636
|
+
}
|
|
4637
|
+
.dxr-orbit::before, .dxr-orbit::after {
|
|
4638
|
+
position: absolute;
|
|
4639
|
+
width: 10px;
|
|
4640
|
+
height: 10px;
|
|
4641
|
+
border-radius: 50%;
|
|
4642
|
+
content: "";
|
|
4643
|
+
background: #52e5ff;
|
|
4644
|
+
box-shadow: 0 0 18px #52e5ff;
|
|
4645
|
+
}
|
|
4646
|
+
.dxr-orbit::before { top: -5px; left: 50%; }
|
|
4647
|
+
.dxr-orbit::after { right: 7%; bottom: 12%; background: #b26cff; box-shadow: 0 0 18px #b26cff; }
|
|
4648
|
+
.dxr-card {
|
|
4649
|
+
position: absolute;
|
|
4650
|
+
inset: 24% 28%;
|
|
4651
|
+
padding: 20px 15px;
|
|
4652
|
+
border: 1px solid rgba(255, 255, 255, .33);
|
|
4653
|
+
border-radius: 14px;
|
|
4654
|
+
background: linear-gradient(150deg, rgba(255, 255, 255, .18), rgba(255, 255, 255, .06));
|
|
4655
|
+
box-shadow: 0 22px 50px rgba(0, 0, 0, .35), 0 0 45px rgba(71, 150, 255, .13);
|
|
4656
|
+
backdrop-filter: blur(10px);
|
|
4657
|
+
animation: dxr-float 3.6s ease-in-out infinite;
|
|
4658
|
+
}
|
|
4659
|
+
.dxr-card::before {
|
|
4660
|
+
position: absolute;
|
|
4661
|
+
top: -9px;
|
|
4662
|
+
right: -9px;
|
|
4663
|
+
padding: 4px 7px;
|
|
4664
|
+
border-radius: 6px;
|
|
4665
|
+
background: #52e5ff;
|
|
4666
|
+
color: #06111d;
|
|
4667
|
+
content: "DOCX";
|
|
4668
|
+
font-size: 8px;
|
|
4669
|
+
font-weight: 900;
|
|
4670
|
+
letter-spacing: .12em;
|
|
4671
|
+
}
|
|
4672
|
+
.dxr-card i {
|
|
4673
|
+
display: block;
|
|
4674
|
+
height: 4px;
|
|
4675
|
+
margin-bottom: 10px;
|
|
4676
|
+
border-radius: 4px;
|
|
4677
|
+
background: rgba(255, 255, 255, .56);
|
|
4678
|
+
transform-origin: left;
|
|
4679
|
+
animation: dxr-pulse 2.2s ease-in-out infinite;
|
|
4680
|
+
}
|
|
4681
|
+
.dxr-card i:nth-child(2) { width: 76%; animation-delay: -.45s; }
|
|
4682
|
+
.dxr-card i:nth-child(3) { width: 88%; animation-delay: -.85s; }
|
|
4683
|
+
.dxr-card i:nth-child(4) { width: 58%; background: rgba(255, 111, 139, .75); animation-delay: -1.2s; }
|
|
4684
|
+
.dxr-chip {
|
|
4685
|
+
position: absolute;
|
|
4686
|
+
display: grid;
|
|
4687
|
+
width: 34px;
|
|
4688
|
+
height: 34px;
|
|
4689
|
+
place-items: center;
|
|
4690
|
+
border: 1px solid rgba(255, 255, 255, .17);
|
|
4691
|
+
border-radius: 11px;
|
|
4692
|
+
background: rgba(12, 28, 49, .88);
|
|
4693
|
+
box-shadow: 0 12px 30px rgba(0, 0, 0, .28);
|
|
4694
|
+
font-size: 11px;
|
|
4695
|
+
font-weight: 850;
|
|
4696
|
+
}
|
|
4697
|
+
.dxr-chip.dxr-b { left: 2%; top: 30%; color: #52e5ff; animation: dxr-chip 3s ease-in-out infinite; }
|
|
4698
|
+
.dxr-chip.dxr-r { right: -2%; bottom: 24%; color: #ff8da0; animation: dxr-chip 3s -1.4s ease-in-out infinite; }
|
|
4699
|
+
.dxr-chip.dxr-s { left: 20%; bottom: 0; color: #52e0a2; animation: dxr-chip 3s -.7s ease-in-out infinite; }
|
|
4700
|
+
.dxr-eyebrow { color: #52e5ff; font-size: 10px; font-weight: 850; letter-spacing: .16em; text-transform: uppercase; }
|
|
4701
|
+
.dxr-loader h2 {
|
|
4702
|
+
margin: 10px auto 10px;
|
|
4703
|
+
max-width: 520px;
|
|
4704
|
+
font-size: clamp(23px, 5vw, 40px);
|
|
4705
|
+
line-height: 1.05;
|
|
4706
|
+
letter-spacing: -.045em;
|
|
4707
|
+
}
|
|
4708
|
+
.dxr-loader-copy > p { margin: 0 auto; max-width: 46ch; color: #9eb2c9; font-size: 13.5px; line-height: 1.6; }
|
|
4709
|
+
.dxr-ad {
|
|
4710
|
+
display: flex;
|
|
4711
|
+
gap: 12px;
|
|
4712
|
+
margin: 20px auto 0;
|
|
4713
|
+
max-width: 420px;
|
|
4714
|
+
padding: 13px;
|
|
4715
|
+
border: 1px solid rgba(126, 160, 200, .16);
|
|
4716
|
+
border-radius: 13px;
|
|
4717
|
+
background: rgba(255, 255, 255, .04);
|
|
4718
|
+
text-align: left;
|
|
4719
|
+
}
|
|
4720
|
+
.dxr-ad .dxr-num { color: #b26cff; font: 800 10px/1.4 var(--dxr-mono); }
|
|
4721
|
+
.dxr-ad strong { display: block; font-size: 12.5px; }
|
|
4722
|
+
.dxr-ad .dxr-adcopy { display: block; margin-top: 4px; color: #849bb5; font-size: 11.5px; line-height: 1.45; }
|
|
4723
|
+
.dxr-ad[data-swap] { animation: dxr-swap .4s ease; }
|
|
4724
|
+
.dxr-track {
|
|
4725
|
+
height: 3px;
|
|
4726
|
+
margin: 22px auto 0;
|
|
4727
|
+
max-width: 420px;
|
|
4728
|
+
overflow: hidden;
|
|
4729
|
+
border-radius: 999px;
|
|
4730
|
+
background: rgba(255, 255, 255, .09);
|
|
4731
|
+
}
|
|
4732
|
+
.dxr-bar {
|
|
4733
|
+
width: 12%;
|
|
4734
|
+
height: 100%;
|
|
4735
|
+
border-radius: inherit;
|
|
4736
|
+
background: linear-gradient(90deg, #52e5ff, #5c7cff, #b26cff);
|
|
4737
|
+
box-shadow: 0 0 16px rgba(82, 229, 255, .55);
|
|
4738
|
+
transition: width .65s cubic-bezier(.22, .8, .28, 1);
|
|
4739
|
+
}
|
|
4740
|
+
.dxr-meta {
|
|
4741
|
+
display: flex;
|
|
4742
|
+
justify-content: space-between;
|
|
4743
|
+
gap: 14px;
|
|
4744
|
+
margin: 9px auto 0;
|
|
4745
|
+
max-width: 420px;
|
|
4746
|
+
color: #647e9c;
|
|
4747
|
+
font: 700 9px/1 var(--dxr-mono);
|
|
4748
|
+
letter-spacing: .09em;
|
|
4749
|
+
text-transform: uppercase;
|
|
4750
|
+
}
|
|
4751
|
+
.dxr-retry {
|
|
4752
|
+
display: none;
|
|
4753
|
+
margin-top: 18px;
|
|
4754
|
+
padding: 9px 14px;
|
|
4755
|
+
border: 1px solid rgba(255, 127, 145, .4);
|
|
4756
|
+
border-radius: 9px;
|
|
4757
|
+
background: rgba(255, 127, 145, .12);
|
|
4758
|
+
color: #fff;
|
|
4759
|
+
cursor: pointer;
|
|
4760
|
+
}
|
|
4761
|
+
.dxr-loader[data-error] .dxr-retry { display: inline-flex; }
|
|
4762
|
+
.dxr-loader[data-error] .dxr-visual { opacity: .35; }
|
|
4763
|
+
|
|
4764
|
+
/* Two columns once there is room \u2014 the visual earns its space beside the copy. */
|
|
4765
|
+
@media (min-width: 760px) {
|
|
4766
|
+
.dxr-loader-grid {
|
|
4767
|
+
grid-template-columns: minmax(220px, .8fr) minmax(300px, 1.2fr);
|
|
4768
|
+
gap: clamp(28px, 6vw, 72px);
|
|
4769
|
+
text-align: left;
|
|
4770
|
+
}
|
|
4771
|
+
.dxr-visual { width: min(280px, 30vw); }
|
|
4772
|
+
.dxr-loader h2 { margin-left: 0; }
|
|
4773
|
+
.dxr-loader-copy > p { margin-left: 0; min-height: 44px; }
|
|
4774
|
+
.dxr-ad, .dxr-track, .dxr-meta { margin-left: 0; }
|
|
4775
|
+
}
|
|
4776
|
+
|
|
4777
|
+
@keyframes dxr-spin { to { transform: rotate(360deg); } }
|
|
4778
|
+
@keyframes dxr-float { 0%, 100% { transform: translateY(-5px) rotate(-2deg); } 50% { transform: translateY(7px) rotate(1deg); } }
|
|
4779
|
+
@keyframes dxr-chip { 0%, 100% { transform: translateY(-4px); } 50% { transform: translateY(5px); } }
|
|
4780
|
+
@keyframes dxr-pulse { 0%, 100% { transform: scaleX(.65); opacity: .45; } 50% { transform: scaleX(1); opacity: .95; } }
|
|
4781
|
+
@keyframes dxr-swap { from { opacity: .1; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
|
|
4782
|
+
|
|
4783
|
+
@media (prefers-reduced-motion: reduce) {
|
|
4784
|
+
.dxr *, .dxr *::before, .dxr *::after {
|
|
4785
|
+
animation-duration: .01ms !important;
|
|
4786
|
+
animation-iteration-count: 1 !important;
|
|
4787
|
+
transition-duration: .01ms !important;
|
|
4788
|
+
}
|
|
4789
|
+
}
|
|
4790
|
+
`;
|
|
4791
|
+
var ICON_ALIGN = (bars) => `<svg width="15" height="13" viewBox="0 0 15 13" aria-hidden="true">${bars}</svg>`;
|
|
4792
|
+
var RIBBON_HTML = `
|
|
4793
|
+
<div class="dxr-chrome">
|
|
4794
|
+
<div class="dxr-titlebar">
|
|
4795
|
+
<span class="dxr-brand"><span class="dxr-mark"></span><span class="dxr-brandname">Docxodus</span>
|
|
4796
|
+
<span class="dxr-docname" data-dxr="docname">no document</span></span>
|
|
4797
|
+
<div class="dxr-quick" data-dxr-files>
|
|
4798
|
+
<button type="button" data-dxr="new" title="Start a new blank document">New</button>
|
|
4799
|
+
<label class="dxr-btn" tabindex="0">Open<input data-dxr="file" type="file" accept=".docx" hidden /></label>
|
|
4800
|
+
<button type="button" data-dxr="save" disabled>Save</button>
|
|
4801
|
+
</div>
|
|
4802
|
+
<div class="dxr-quick">
|
|
4803
|
+
<button type="button" class="dxr-icon" data-dxr="undo" title="Undo (Ctrl+Z)" aria-label="Undo">↶</button>
|
|
4804
|
+
<button type="button" class="dxr-icon" data-dxr="redo" title="Redo (Ctrl+Shift+Z)" aria-label="Redo">↷</button>
|
|
4805
|
+
</div>
|
|
4806
|
+
<span class="dxr-spacer"></span>
|
|
4807
|
+
<span class="dxr-status" data-dxr="status" role="status" aria-live="polite">Booting WASM…</span>
|
|
4808
|
+
</div>
|
|
4809
|
+
|
|
4810
|
+
<div class="dxr-tabs" role="tablist">
|
|
4811
|
+
<button type="button" class="dxr-tab" role="tab" data-tab="home" aria-selected="true">Home</button>
|
|
4812
|
+
<button type="button" class="dxr-tab" role="tab" data-tab="insert" aria-selected="false">Insert</button>
|
|
4813
|
+
<button type="button" class="dxr-tab" role="tab" data-tab="layout" aria-selected="false">Layout</button>
|
|
4814
|
+
<button type="button" class="dxr-tab" role="tab" data-tab="table" data-contextual aria-selected="false" hidden>Table</button>
|
|
4815
|
+
</div>
|
|
4816
|
+
|
|
4817
|
+
<div class="dxr-ribbon" data-dxr="ribbon" aria-disabled="true">
|
|
4818
|
+
<!-- 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 -->
|
|
4819
|
+
<div class="dxr-panel" data-panel="home" data-active>
|
|
4820
|
+
<div class="dxr-group">
|
|
4821
|
+
<span class="dxr-glabel">Text</span>
|
|
4822
|
+
<div class="dxr-row">
|
|
4823
|
+
<button type="button" class="dxr-icon" data-cmd="bold" title="Bold (Ctrl+B)"><b>B</b></button>
|
|
4824
|
+
<button type="button" class="dxr-icon" data-cmd="italic" title="Italic (Ctrl+I)"><i>I</i></button>
|
|
4825
|
+
<button type="button" class="dxr-icon" data-cmd="underline" title="Underline (Ctrl+U)"><u>U</u></button>
|
|
4826
|
+
<button type="button" class="dxr-icon" data-cmd="strike" title="Strikethrough"><s>S</s></button>
|
|
4827
|
+
<button type="button" class="dxr-icon" data-cmd="code" title="Inline code"></></button>
|
|
4828
|
+
<button type="button" class="dxr-icon" data-cmd="superscript" title="Superscript">x²</button>
|
|
4829
|
+
<button type="button" class="dxr-icon" data-cmd="subscript" title="Subscript">x₂</button>
|
|
4830
|
+
</div>
|
|
4831
|
+
<div class="dxr-row">
|
|
4832
|
+
<input data-dxr="fontsize" data-dxr-list="fontsizes" type="number" min="1" max="1638" step="0.5"
|
|
4833
|
+
placeholder="pt" title="Font size in points \u2014 type any value or pick a preset" />
|
|
4834
|
+
<datalist data-dxr="fontsizes">
|
|
4835
|
+
<option>8</option><option>9</option><option>10</option><option>11</option>
|
|
4836
|
+
<option>12</option><option>14</option><option>16</option><option>18</option>
|
|
4837
|
+
<option>20</option><option>24</option><option>28</option><option>36</option>
|
|
4838
|
+
<option>48</option><option>72</option><option>96</option>
|
|
4839
|
+
</datalist>
|
|
4840
|
+
<select data-dxr="fontfamily" title="Font family \u2014 applies to the selection">
|
|
4841
|
+
<option value="">Font…</option>
|
|
4842
|
+
<option>Calibri</option><option>Times New Roman</option><option>Arial</option>
|
|
4843
|
+
<option>Georgia</option><option>Cambria</option><option>Courier New</option>
|
|
4844
|
+
<option>Verdana</option><option>Garamond</option>
|
|
4845
|
+
</select>
|
|
4846
|
+
</div>
|
|
4847
|
+
</div>
|
|
4848
|
+
|
|
4849
|
+
<div class="dxr-group">
|
|
4850
|
+
<span class="dxr-glabel">Paragraph</span>
|
|
4851
|
+
<div class="dxr-row">
|
|
4852
|
+
<button type="button" class="dxr-icon" data-align="left" title="Align left">${ICON_ALIGN(
|
|
4853
|
+
'<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"/>'
|
|
4854
|
+
)}</button>
|
|
4855
|
+
<button type="button" class="dxr-icon" data-align="center" title="Align center">${ICON_ALIGN(
|
|
4856
|
+
'<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"/>'
|
|
4857
|
+
)}</button>
|
|
4858
|
+
<button type="button" class="dxr-icon" data-align="right" title="Align right">${ICON_ALIGN(
|
|
4859
|
+
'<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"/>'
|
|
4860
|
+
)}</button>
|
|
4861
|
+
<button type="button" class="dxr-icon" data-align="justify" title="Justify">${ICON_ALIGN(
|
|
4862
|
+
'<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"/>'
|
|
4863
|
+
)}</button>
|
|
4864
|
+
<button type="button" class="dxr-icon" data-indent="-720" title="Decrease indent">${ICON_ALIGN(
|
|
4865
|
+
'<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"/>'
|
|
4866
|
+
)}</button>
|
|
4867
|
+
<button type="button" class="dxr-icon" data-indent="720" title="Increase indent">${ICON_ALIGN(
|
|
4868
|
+
'<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"/>'
|
|
4869
|
+
)}</button>
|
|
4870
|
+
</div>
|
|
4871
|
+
<div class="dxr-row">
|
|
4872
|
+
<button type="button" data-list="bullet" title="Bullet list">• List</button>
|
|
4873
|
+
<button type="button" data-list="decimal" title="Numbered list">1. List</button>
|
|
4874
|
+
<button type="button" data-pagebreak title="Start this block on a new page">Page break</button>
|
|
4875
|
+
</div>
|
|
4876
|
+
</div>
|
|
4877
|
+
|
|
4878
|
+
<div class="dxr-group">
|
|
4879
|
+
<span class="dxr-glabel">Block</span>
|
|
4880
|
+
<div class="dxr-row">
|
|
4881
|
+
<select data-dxr="style" title="Paragraph style">
|
|
4882
|
+
<option value="">Style…</option>
|
|
4883
|
+
<option value="Normal">Normal</option>
|
|
4884
|
+
<option value="Heading1">Heading 1</option>
|
|
4885
|
+
<option value="Heading2">Heading 2</option>
|
|
4886
|
+
<option value="Heading3">Heading 3</option>
|
|
4887
|
+
<option value="Title">Title</option>
|
|
4888
|
+
</select>
|
|
4889
|
+
</div>
|
|
4890
|
+
<div class="dxr-row">
|
|
4891
|
+
<button type="button" data-dxr="delblock" class="dxr-danger" title="Delete the block the caret is in">Delete block</button>
|
|
4892
|
+
</div>
|
|
4893
|
+
</div>
|
|
4894
|
+
</div>
|
|
4895
|
+
|
|
4896
|
+
<!-- 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 -->
|
|
4897
|
+
<div class="dxr-panel" data-panel="insert">
|
|
4898
|
+
<div class="dxr-group">
|
|
4899
|
+
<span class="dxr-glabel">Table</span>
|
|
4900
|
+
<div class="dxr-row">
|
|
4901
|
+
<button type="button" data-dxr="table" title="Insert a table \u2014 pick its size on the grid">▦ Table</button>
|
|
4902
|
+
</div>
|
|
4903
|
+
</div>
|
|
4904
|
+
|
|
4905
|
+
<div class="dxr-group">
|
|
4906
|
+
<span class="dxr-glabel">Rules</span>
|
|
4907
|
+
<div class="dxr-row">
|
|
4908
|
+
<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>
|
|
4909
|
+
<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>
|
|
4910
|
+
<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>
|
|
4911
|
+
</div>
|
|
4912
|
+
<div class="dxr-row">
|
|
4913
|
+
<select data-dxr="rulepos" title="Where the rule lands relative to the current block">
|
|
4914
|
+
<option value="below">Below block</option>
|
|
4915
|
+
<option value="above">Above block</option>
|
|
4916
|
+
</select>
|
|
4917
|
+
<button type="button" data-dxr="hrClear" title="Remove the rule or paragraph border">Clear</button>
|
|
4918
|
+
</div>
|
|
4919
|
+
</div>
|
|
4920
|
+
|
|
4921
|
+
<div class="dxr-group">
|
|
4922
|
+
<span class="dxr-glabel">References</span>
|
|
4923
|
+
<div class="dxr-row">
|
|
4924
|
+
<button type="button" data-dxr="footnote" title="Cite a new footnote at the caret">Footnote</button>
|
|
4925
|
+
<button type="button" data-dxr="endnote" title="Cite a new endnote at the caret">Endnote</button>
|
|
4926
|
+
</div>
|
|
4927
|
+
</div>
|
|
4928
|
+
</div>
|
|
4929
|
+
|
|
4930
|
+
<!-- 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 -->
|
|
4931
|
+
<div class="dxr-panel" data-panel="layout">
|
|
4932
|
+
<div class="dxr-group">
|
|
4933
|
+
<span class="dxr-glabel">View</span>
|
|
4934
|
+
<div class="dxr-row">
|
|
4935
|
+
<label class="dxr-toggle"><input data-dxr="paginated" type="checkbox" /> Page view</label>
|
|
4936
|
+
</div>
|
|
4937
|
+
<div class="dxr-row">
|
|
4938
|
+
<label class="dxr-toggle"><input data-dxr="headerfooter" type="checkbox" /> Header & footer bands</label>
|
|
4939
|
+
</div>
|
|
4940
|
+
</div>
|
|
4941
|
+
|
|
4942
|
+
<div class="dxr-group">
|
|
4943
|
+
<span class="dxr-glabel">Page numbers</span>
|
|
4944
|
+
<div class="dxr-row">
|
|
4945
|
+
<select data-dxr="pgfmt" title="Number format for this section">
|
|
4946
|
+
<option value="">Format…</option>
|
|
4947
|
+
<option value="decimal">1, 2, 3</option>
|
|
4948
|
+
<option value="lowerLetter">a, b, c</option>
|
|
4949
|
+
<option value="upperLetter">A, B, C</option>
|
|
4950
|
+
<option value="lowerRoman">i, ii, iii</option>
|
|
4951
|
+
<option value="upperRoman">I, II, III</option>
|
|
4952
|
+
</select>
|
|
4953
|
+
<label class="dxr-toggle">Start at
|
|
4954
|
+
<input data-dxr="pgstart" type="number" min="1" step="1"
|
|
4955
|
+
title="Restart this section's numbering at this value" />
|
|
4956
|
+
</label>
|
|
4957
|
+
<button type="button" data-dxr="pgclear" title="Continue the previous section's numbering">Clear</button>
|
|
4958
|
+
</div>
|
|
4959
|
+
<div class="dxr-row">
|
|
4960
|
+
<span class="dxr-note">Applies to the section holding the caret.</span>
|
|
4961
|
+
</div>
|
|
4962
|
+
</div>
|
|
4963
|
+
|
|
4964
|
+
<!-- The field lands in the running footer (Word's convention, and where the band
|
|
4965
|
+
puts it), so it belongs with the section's numbering rather than under Insert,
|
|
4966
|
+
whose controls all act at the caret. -->
|
|
4967
|
+
<div class="dxr-group">
|
|
4968
|
+
<span class="dxr-glabel">Footer fields</span>
|
|
4969
|
+
<div class="dxr-row">
|
|
4970
|
+
<button type="button" data-dxr="pagenum" title="Add a page-number field to the footer">Page number</button>
|
|
4971
|
+
<button type="button" data-dxr="totalpages" title="Add a total-pages field to the footer">Total pages</button>
|
|
4972
|
+
</div>
|
|
4973
|
+
<div class="dxr-row">
|
|
4974
|
+
<span class="dxr-note">Added to the footer story.</span>
|
|
4975
|
+
</div>
|
|
4976
|
+
</div>
|
|
4977
|
+
</div>
|
|
4978
|
+
|
|
4979
|
+
<!-- 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
|
|
4980
|
+
Row/column editing lives here rather than in a floating toolbar: a docked
|
|
4981
|
+
contextual tab cannot overlap the cell you are editing. -->
|
|
4982
|
+
<div class="dxr-panel" data-panel="table">
|
|
4983
|
+
<div class="dxr-group">
|
|
4984
|
+
<span class="dxr-glabel">Rows</span>
|
|
4985
|
+
<div class="dxr-row">
|
|
4986
|
+
<button type="button" data-tt="rowAbove" title="Insert a row above this one">Insert above</button>
|
|
4987
|
+
<button type="button" data-tt="rowBelow" title="Insert a row below this one">Insert below</button>
|
|
4988
|
+
<button type="button" data-tt="delRow" class="dxr-danger" title="Delete this row">Delete row</button>
|
|
4989
|
+
</div>
|
|
4990
|
+
</div>
|
|
4991
|
+
<div class="dxr-group">
|
|
4992
|
+
<span class="dxr-glabel">Columns</span>
|
|
4993
|
+
<div class="dxr-row">
|
|
4994
|
+
<button type="button" data-tt="colLeft" title="Insert a column to the left">Insert left</button>
|
|
4995
|
+
<button type="button" data-tt="colRight" title="Insert a column to the right">Insert right</button>
|
|
4996
|
+
<button type="button" data-tt="delCol" class="dxr-danger" title="Delete this column">Delete column</button>
|
|
4997
|
+
</div>
|
|
4998
|
+
</div>
|
|
4999
|
+
</div>
|
|
5000
|
+
</div>
|
|
5001
|
+
|
|
5002
|
+
<!-- Anchor rail \u2014 live engine state, not decoration. -->
|
|
5003
|
+
<div class="dxr-rail" data-dxr-rail>
|
|
5004
|
+
<span class="dxr-cell"><span class="dxr-k">anchor</span><span class="dxr-v" data-dxr="railAnchor">—</span></span>
|
|
5005
|
+
<span class="dxr-cell"><span class="dxr-k">blocks</span><span class="dxr-v" data-dxr="railBlocks">—</span></span>
|
|
5006
|
+
<span class="dxr-cell"><span class="dxr-k">session</span><span class="dxr-v" data-dxr="railSession">—</span></span>
|
|
5007
|
+
<span class="dxr-cell"><span class="dxr-k">last op</span><span class="dxr-v" data-dxr="railOp">—</span></span>
|
|
5008
|
+
</div>
|
|
5009
|
+
</div>
|
|
5010
|
+
|
|
5011
|
+
<div class="dxr-scroll" data-dxr-scroll>
|
|
5012
|
+
<p class="dxr-hint" data-dxr-hint></p>
|
|
5013
|
+
<div class="dxr-surface" data-dxr="editor" data-dxr-surface data-view="continuous"></div>
|
|
5014
|
+
</div>
|
|
5015
|
+
|
|
5016
|
+
<!-- Table size picker, anchored to the Insert tab's Table button. -->
|
|
5017
|
+
<div class="dxr-pop" data-dxr="gridpicker">
|
|
5018
|
+
<div class="dxr-gridcells" data-dxr="gridcells"></div>
|
|
5019
|
+
<div class="dxr-popfoot">
|
|
5020
|
+
<span data-dxr="gridlabel">0 × 0</span>
|
|
5021
|
+
<span style="display:inline-flex; align-items:center; gap:10px;">
|
|
5022
|
+
<label class="dxr-toggle">Align
|
|
5023
|
+
<select data-dxr="gridalign">
|
|
5024
|
+
<option value="left">Left</option>
|
|
5025
|
+
<option value="center">Center</option>
|
|
5026
|
+
<option value="right">Right</option>
|
|
5027
|
+
</select>
|
|
5028
|
+
</label>
|
|
5029
|
+
<label class="dxr-toggle"><input data-dxr="gridborderless" type="checkbox" checked /> Borderless</label>
|
|
5030
|
+
</span>
|
|
5031
|
+
</div>
|
|
5032
|
+
</div>
|
|
5033
|
+
|
|
5034
|
+
<div class="dxr-loader" data-dxr="loader" aria-live="polite" hidden>
|
|
5035
|
+
<div class="dxr-loader-grid">
|
|
5036
|
+
<div class="dxr-visual" aria-hidden="true">
|
|
5037
|
+
<div class="dxr-orbit"></div><div class="dxr-orbit dxr-two"></div>
|
|
5038
|
+
<div class="dxr-card"><i></i><i></i><i></i><i></i></div>
|
|
5039
|
+
<span class="dxr-chip dxr-b">B</span><span class="dxr-chip dxr-r">±</span><span class="dxr-chip dxr-s">↓</span>
|
|
5040
|
+
</div>
|
|
5041
|
+
<div class="dxr-loader-copy">
|
|
5042
|
+
<div class="dxr-eyebrow" data-dxr="loaderEyebrow">Running locally in this tab</div>
|
|
5043
|
+
<h2 data-dxr="loaderTitle">Booting .NET inside your browser</h2>
|
|
5044
|
+
<p data-dxr="loaderCopy">Streaming the trimmed WebAssembly runtime.</p>
|
|
5045
|
+
<div class="dxr-ad" data-dxr="loaderAd">
|
|
5046
|
+
<span class="dxr-num" data-dxr="loaderNumber">01</span>
|
|
5047
|
+
<div><strong data-dxr="loaderAdTitle"></strong><span class="dxr-adcopy" data-dxr="loaderAdCopy"></span></div>
|
|
5048
|
+
</div>
|
|
5049
|
+
<div class="dxr-track" aria-hidden="true"><div class="dxr-bar" data-dxr="loaderBar"></div></div>
|
|
5050
|
+
<div class="dxr-meta"><span data-dxr="loaderLabel">Loading engine</span><span data-dxr="loaderMeta">DOCX → WASM → DOCX</span></div>
|
|
5051
|
+
<button type="button" class="dxr-retry" data-dxr="loaderRetry">Retry loading</button>
|
|
5052
|
+
</div>
|
|
5053
|
+
</div>
|
|
5054
|
+
</div>
|
|
5055
|
+
`;
|
|
5056
|
+
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.";
|
|
5057
|
+
|
|
5058
|
+
// src/ribbon.ts
|
|
5059
|
+
var DEFAULT_STAGES = [
|
|
5060
|
+
{
|
|
5061
|
+
title: "Booting .NET inside your browser",
|
|
5062
|
+
copy: "Streaming the trimmed WebAssembly runtime. No document bytes are sent to a server.",
|
|
5063
|
+
progress: 16,
|
|
5064
|
+
label: "Loading engine"
|
|
5065
|
+
},
|
|
5066
|
+
{
|
|
5067
|
+
title: "Opening the document",
|
|
5068
|
+
copy: "Parsing OOXML parts, styles, numbering, tables, notes, and tracked revisions locally.",
|
|
5069
|
+
progress: 54,
|
|
5070
|
+
label: "Reading document"
|
|
5071
|
+
},
|
|
5072
|
+
{
|
|
5073
|
+
title: "Wiring lossless editing",
|
|
5074
|
+
copy: "Connecting every editable block to its native WordprocessingML anchor.",
|
|
5075
|
+
progress: 84,
|
|
5076
|
+
label: "Mounting editor"
|
|
5077
|
+
},
|
|
5078
|
+
{
|
|
5079
|
+
title: "Your local editor is ready",
|
|
5080
|
+
copy: "Select text, use the ribbon, switch page view, and save a real DOCX.",
|
|
5081
|
+
progress: 100,
|
|
5082
|
+
label: "Ready"
|
|
5083
|
+
}
|
|
5084
|
+
];
|
|
5085
|
+
var DEFAULT_FEATURES = [
|
|
5086
|
+
{ number: "01", title: "Zero-upload architecture", copy: "Your source file and edits never leave this browser session." },
|
|
5087
|
+
{ number: "02", title: "Word-grade OOXML fidelity", copy: "Tables, numbering, footnotes, redlines, comments, and styles stay native." },
|
|
5088
|
+
{ number: "03", title: "Surgical editing", copy: "Formatting and text edits target real document anchors instead of flattening the file." },
|
|
5089
|
+
{ number: "04", title: "Lossless DOCX out", copy: "Undo, redo, edit, and save a Word document that remains a Word document." }
|
|
5090
|
+
];
|
|
5091
|
+
var CONTROL_NAMES = [
|
|
5092
|
+
"docname",
|
|
5093
|
+
"new",
|
|
5094
|
+
"file",
|
|
5095
|
+
"save",
|
|
5096
|
+
"undo",
|
|
5097
|
+
"redo",
|
|
5098
|
+
"status",
|
|
5099
|
+
"ribbon",
|
|
5100
|
+
"fontsize",
|
|
5101
|
+
"fontsizes",
|
|
5102
|
+
"fontfamily",
|
|
5103
|
+
"style",
|
|
5104
|
+
"delblock",
|
|
5105
|
+
"table",
|
|
5106
|
+
"hr",
|
|
5107
|
+
"hrThick",
|
|
5108
|
+
"hrDouble",
|
|
5109
|
+
"rulepos",
|
|
5110
|
+
"hrClear",
|
|
5111
|
+
"footnote",
|
|
5112
|
+
"endnote",
|
|
5113
|
+
"paginated",
|
|
5114
|
+
"headerfooter",
|
|
5115
|
+
"pgfmt",
|
|
5116
|
+
"pgstart",
|
|
5117
|
+
"pgclear",
|
|
5118
|
+
"pagenum",
|
|
5119
|
+
"totalpages",
|
|
5120
|
+
"railAnchor",
|
|
5121
|
+
"railBlocks",
|
|
5122
|
+
"railSession",
|
|
5123
|
+
"railOp",
|
|
5124
|
+
"gridpicker",
|
|
5125
|
+
"gridcells",
|
|
5126
|
+
"gridlabel",
|
|
5127
|
+
"gridalign",
|
|
5128
|
+
"gridborderless",
|
|
5129
|
+
"editor",
|
|
5130
|
+
"loader",
|
|
5131
|
+
"loaderEyebrow",
|
|
5132
|
+
"loaderTitle",
|
|
5133
|
+
"loaderCopy",
|
|
5134
|
+
"loaderAd",
|
|
5135
|
+
"loaderNumber",
|
|
5136
|
+
"loaderAdTitle",
|
|
5137
|
+
"loaderAdCopy",
|
|
5138
|
+
"loaderBar",
|
|
5139
|
+
"loaderLabel",
|
|
5140
|
+
"loaderMeta",
|
|
5141
|
+
"loaderRetry"
|
|
5142
|
+
];
|
|
5143
|
+
var GRID_ROWS = 8;
|
|
5144
|
+
var GRID_COLS = 10;
|
|
5145
|
+
var nextIdPrefixSeed = 0;
|
|
5146
|
+
function ensureStyles(doc) {
|
|
5147
|
+
const existing = doc.querySelector(`style[${RIBBON_STYLE_ATTR}]`);
|
|
5148
|
+
if (existing?.getAttribute(RIBBON_STYLE_ATTR) === RIBBON_STYLE_VERSION) return;
|
|
5149
|
+
existing?.remove();
|
|
5150
|
+
const style = doc.createElement("style");
|
|
5151
|
+
style.setAttribute(RIBBON_STYLE_ATTR, RIBBON_STYLE_VERSION);
|
|
5152
|
+
style.textContent = RIBBON_CSS;
|
|
5153
|
+
(doc.head ?? doc.documentElement).appendChild(style);
|
|
5154
|
+
}
|
|
5155
|
+
function resolveIdPrefix(explicit, doc) {
|
|
5156
|
+
if (explicit !== void 0) return explicit;
|
|
5157
|
+
if (!CONTROL_NAMES.some((name) => doc.getElementById(name))) return "";
|
|
5158
|
+
for (; ; ) {
|
|
5159
|
+
const candidate = `dxr${++nextIdPrefixSeed}-`;
|
|
5160
|
+
if (!CONTROL_NAMES.some((name) => doc.getElementById(candidate + name))) return candidate;
|
|
5161
|
+
}
|
|
5162
|
+
}
|
|
5163
|
+
function resolveContainer(container) {
|
|
5164
|
+
if (typeof container !== "string") return container;
|
|
5165
|
+
const el = document.querySelector(container);
|
|
5166
|
+
if (!el) throw new Error(`Docxodus ribbon: no element matches "${container}"`);
|
|
5167
|
+
return el;
|
|
5168
|
+
}
|
|
5169
|
+
function mountRibbon(container, options = {}) {
|
|
5170
|
+
return new RibbonSurface(resolveContainer(container), options);
|
|
5171
|
+
}
|
|
5172
|
+
var RibbonSurface = class {
|
|
5173
|
+
constructor(container, options) {
|
|
5174
|
+
this.live = null;
|
|
5175
|
+
this.density = "full";
|
|
5176
|
+
this.destroyed = false;
|
|
5177
|
+
this.featureTimer = null;
|
|
5178
|
+
this.featureIndex = 0;
|
|
5179
|
+
this.resizeObserver = null;
|
|
5180
|
+
this.lastAnchorText = "";
|
|
5181
|
+
this.selectionFrame = null;
|
|
5182
|
+
this.options = options;
|
|
5183
|
+
this.exports = options.exports ?? null;
|
|
5184
|
+
this.documentName = options.documentName ?? "untitled.docx";
|
|
5185
|
+
this.chromeMode = options.chrome ?? "auto";
|
|
5186
|
+
this.headerFooter = options.headerFooter ?? false;
|
|
5187
|
+
this.loaderOptions = options.loader === false ? null : typeof options.loader === "object" ? options.loader : {};
|
|
5188
|
+
this.stages = this.loaderOptions?.stages ?? DEFAULT_STAGES;
|
|
5189
|
+
this.features = this.loaderOptions?.features ?? DEFAULT_FEATURES;
|
|
5190
|
+
const doc = container.ownerDocument ?? document;
|
|
5191
|
+
ensureStyles(doc);
|
|
5192
|
+
this.idPrefix = resolveIdPrefix(options.idPrefix, doc);
|
|
5193
|
+
const root = doc.createElement("div");
|
|
5194
|
+
root.className = "dxr";
|
|
5195
|
+
root.dataset.state = "idle";
|
|
5196
|
+
root.innerHTML = RIBBON_HTML;
|
|
5197
|
+
for (const el of Array.from(root.querySelectorAll("[data-dxr]"))) {
|
|
5198
|
+
el.id = this.idPrefix + el.dataset.dxr;
|
|
5199
|
+
}
|
|
5200
|
+
for (const el of Array.from(root.querySelectorAll("[data-dxr-list]"))) {
|
|
5201
|
+
el.setAttribute("list", this.idPrefix + el.dataset.dxrList);
|
|
5202
|
+
}
|
|
5203
|
+
container.replaceChildren(root);
|
|
5204
|
+
this.element = root;
|
|
5205
|
+
this.surface = this.require("editor");
|
|
5206
|
+
this.applyStaticOptions();
|
|
5207
|
+
this.buildGrid();
|
|
5208
|
+
this.wire();
|
|
5209
|
+
this.applyChrome();
|
|
5210
|
+
this.loader = this.createLoaderController();
|
|
5211
|
+
if (this.loaderOptions) this.loader.show();
|
|
5212
|
+
this.onSelectionChange = () => {
|
|
5213
|
+
if (this.selectionFrame != null) cancelAnimationFrame(this.selectionFrame);
|
|
5214
|
+
this.selectionFrame = requestAnimationFrame(() => {
|
|
5215
|
+
this.selectionFrame = null;
|
|
5216
|
+
this.syncSelection();
|
|
5217
|
+
});
|
|
5218
|
+
};
|
|
5219
|
+
doc.addEventListener("selectionchange", this.onSelectionChange);
|
|
5220
|
+
this.onDocumentMouseDown = (event) => this.maybeClosePicker(event);
|
|
5221
|
+
doc.addEventListener("mousedown", this.onDocumentMouseDown);
|
|
5222
|
+
if (this.chromeMode === "auto" && typeof ResizeObserver !== "undefined") {
|
|
5223
|
+
this.resizeObserver = new ResizeObserver(() => this.applyChrome());
|
|
5224
|
+
this.resizeObserver.observe(root);
|
|
5225
|
+
}
|
|
5226
|
+
}
|
|
5227
|
+
// ── element lookup ──────────────────────────────────────────────────────────
|
|
5228
|
+
control(name) {
|
|
5229
|
+
return this.element.querySelector(`[data-dxr="${name}"]`);
|
|
5230
|
+
}
|
|
5231
|
+
require(name) {
|
|
5232
|
+
const el = this.control(name);
|
|
5233
|
+
if (!el) throw new Error(`Docxodus ribbon: template is missing "${name}"`);
|
|
5234
|
+
return el;
|
|
5235
|
+
}
|
|
5236
|
+
// ── mount-time configuration ────────────────────────────────────────────────
|
|
5237
|
+
applyStaticOptions() {
|
|
5238
|
+
const hintEl = this.element.querySelector("[data-dxr-hint]");
|
|
5239
|
+
if (hintEl) {
|
|
5240
|
+
if (this.options.hint === false) hintEl.remove();
|
|
5241
|
+
else hintEl.innerHTML = typeof this.options.hint === "string" ? this.options.hint : RIBBON_HINT_HTML;
|
|
5242
|
+
}
|
|
5243
|
+
if (this.options.rail === false) {
|
|
5244
|
+
this.element.querySelector("[data-dxr-rail]")?.remove();
|
|
5245
|
+
}
|
|
5246
|
+
if (this.options.fileActions === false) {
|
|
5247
|
+
this.element.querySelector("[data-dxr-files]")?.remove();
|
|
5248
|
+
}
|
|
5249
|
+
if (!this.loaderOptions) this.control("loader")?.remove();
|
|
5250
|
+
this.require("docname").textContent = this.documentName;
|
|
5251
|
+
this.require("paginated").checked = this.options.paginated ?? false;
|
|
5252
|
+
this.require("headerfooter").checked = this.headerFooter;
|
|
5253
|
+
this.surface.dataset.view = this.options.paginated ? "paginated" : "continuous";
|
|
5254
|
+
}
|
|
5255
|
+
buildGrid() {
|
|
5256
|
+
const cells = this.require("gridcells");
|
|
5257
|
+
const fragment = document.createDocumentFragment();
|
|
5258
|
+
for (let r = 0; r < GRID_ROWS; r++) {
|
|
5259
|
+
for (let c = 0; c < GRID_COLS; c++) {
|
|
5260
|
+
const cell = document.createElement("div");
|
|
5261
|
+
cell.dataset.r = String(r);
|
|
5262
|
+
cell.dataset.c = String(c);
|
|
5263
|
+
fragment.appendChild(cell);
|
|
5264
|
+
}
|
|
5265
|
+
}
|
|
5266
|
+
cells.replaceChildren(fragment);
|
|
5267
|
+
}
|
|
5268
|
+
// ── chrome density ──────────────────────────────────────────────────────────
|
|
5269
|
+
get chrome() {
|
|
5270
|
+
return this.density;
|
|
5271
|
+
}
|
|
5272
|
+
setChrome(mode) {
|
|
5273
|
+
this.chromeMode = mode;
|
|
5274
|
+
if (mode === "auto" && !this.resizeObserver && typeof ResizeObserver !== "undefined") {
|
|
5275
|
+
this.resizeObserver = new ResizeObserver(() => this.applyChrome());
|
|
5276
|
+
this.resizeObserver.observe(this.element);
|
|
5277
|
+
}
|
|
5278
|
+
this.applyChrome();
|
|
5279
|
+
}
|
|
5280
|
+
applyChrome() {
|
|
5281
|
+
const breakpoint = this.options.compactBreakpoint ?? 720;
|
|
5282
|
+
const width = this.element.clientWidth || this.element.getBoundingClientRect().width;
|
|
5283
|
+
const next = this.chromeMode === "auto" ? width > 0 && width < breakpoint ? "compact" : "full" : this.chromeMode;
|
|
5284
|
+
if (next === this.density && this.element.dataset.chrome) return;
|
|
5285
|
+
this.density = next;
|
|
5286
|
+
this.element.dataset.chrome = next;
|
|
5287
|
+
this.closePicker();
|
|
5288
|
+
}
|
|
5289
|
+
// ── status ──────────────────────────────────────────────────────────────────
|
|
5290
|
+
/** Publish the lifecycle on the root, where CSS and host pages can key off it. */
|
|
5291
|
+
setState(state) {
|
|
5292
|
+
this.element.dataset.state = state;
|
|
5293
|
+
}
|
|
5294
|
+
setStatus(text) {
|
|
5295
|
+
const el = this.control("status");
|
|
5296
|
+
if (el) el.textContent = text;
|
|
5297
|
+
this.options.onStatus?.(text);
|
|
5298
|
+
}
|
|
5299
|
+
// ── document lifecycle ──────────────────────────────────────────────────────
|
|
5300
|
+
get editor() {
|
|
5301
|
+
return this.live;
|
|
5302
|
+
}
|
|
5303
|
+
setExports(exports) {
|
|
5304
|
+
this.exports = exports;
|
|
5305
|
+
}
|
|
5306
|
+
open(bytes, name) {
|
|
5307
|
+
if (!this.exports) throw new Error("Docxodus ribbon: WASM exports are not set yet");
|
|
5308
|
+
if (this.live) {
|
|
5309
|
+
try {
|
|
5310
|
+
this.live.close();
|
|
5311
|
+
} catch {
|
|
5312
|
+
}
|
|
5313
|
+
this.live = null;
|
|
5314
|
+
}
|
|
5315
|
+
if (name) this.documentName = name;
|
|
5316
|
+
this.require("docname").textContent = this.documentName;
|
|
5317
|
+
const paginated = this.require("paginated").checked;
|
|
5318
|
+
this.surface.dataset.view = paginated ? "paginated" : "continuous";
|
|
5319
|
+
this.surface.replaceChildren();
|
|
5320
|
+
const started = performance.now();
|
|
5321
|
+
this.live = DocxEditor.open(this.surface, bytes, this.exports, {
|
|
5322
|
+
cssPrefix: this.options.cssPrefix,
|
|
5323
|
+
fabricateClasses: this.options.fabricateClasses,
|
|
5324
|
+
editable: this.options.editable,
|
|
5325
|
+
scale: this.options.scale,
|
|
5326
|
+
onEdit: this.options.onEdit,
|
|
5327
|
+
paginated,
|
|
5328
|
+
headerFooter: this.headerFooter
|
|
5329
|
+
});
|
|
5330
|
+
this.require("save").disabled = false;
|
|
5331
|
+
this.require("ribbon").setAttribute("aria-disabled", "false");
|
|
5332
|
+
this.setState("ready");
|
|
5333
|
+
this.setStatus(`Rendered in ${Math.round(performance.now() - started)} ms`);
|
|
5334
|
+
this.syncPageNumbering();
|
|
5335
|
+
this.refreshRailCounts();
|
|
5336
|
+
this.refreshRailAnchor();
|
|
5337
|
+
this.options.onOpen?.(this.live);
|
|
5338
|
+
return this.live;
|
|
5339
|
+
}
|
|
5340
|
+
openBlank(name = "untitled.docx") {
|
|
5341
|
+
if (!this.exports) throw new Error("Docxodus ribbon: WASM exports are not set yet");
|
|
5342
|
+
return this.open(this.exports.DocxSessionBridge.CreateBlankDocx(), name);
|
|
5343
|
+
}
|
|
5344
|
+
save() {
|
|
5345
|
+
return this.live ? this.live.save() : null;
|
|
5346
|
+
}
|
|
5347
|
+
download(name) {
|
|
5348
|
+
const bytes = this.save();
|
|
5349
|
+
if (!bytes) return;
|
|
5350
|
+
const filename = name ?? this.documentName ?? "edited.docx";
|
|
5351
|
+
if (this.options.onSave) {
|
|
5352
|
+
this.options.onSave(bytes, filename);
|
|
5353
|
+
return;
|
|
5354
|
+
}
|
|
5355
|
+
const url = URL.createObjectURL(
|
|
5356
|
+
new Blob([bytes], {
|
|
5357
|
+
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
|
5358
|
+
})
|
|
5359
|
+
);
|
|
5360
|
+
const link = document.createElement("a");
|
|
5361
|
+
link.href = url;
|
|
5362
|
+
link.download = filename;
|
|
5363
|
+
link.click();
|
|
5364
|
+
setTimeout(() => URL.revokeObjectURL(url), 1e3);
|
|
5365
|
+
this.setStatus(`Saved ${filename}`);
|
|
5366
|
+
}
|
|
5367
|
+
destroy() {
|
|
5368
|
+
if (this.destroyed) return;
|
|
5369
|
+
this.destroyed = true;
|
|
5370
|
+
const doc = this.element.ownerDocument ?? document;
|
|
5371
|
+
doc.removeEventListener("selectionchange", this.onSelectionChange);
|
|
5372
|
+
doc.removeEventListener("mousedown", this.onDocumentMouseDown);
|
|
5373
|
+
this.resizeObserver?.disconnect();
|
|
5374
|
+
this.resizeObserver = null;
|
|
5375
|
+
if (this.selectionFrame != null) cancelAnimationFrame(this.selectionFrame);
|
|
5376
|
+
this.selectionFrame = null;
|
|
5377
|
+
this.stopRotation();
|
|
5378
|
+
try {
|
|
5379
|
+
this.live?.close();
|
|
5380
|
+
} catch {
|
|
5381
|
+
}
|
|
5382
|
+
this.live = null;
|
|
5383
|
+
this.element.remove();
|
|
5384
|
+
}
|
|
5385
|
+
// ── command plumbing ────────────────────────────────────────────────────────
|
|
5386
|
+
/**
|
|
5387
|
+
* Run one ribbon command and report its real cost on the rail.
|
|
5388
|
+
*
|
|
5389
|
+
* Every control routes through here, which is what makes the rail's "last op"
|
|
5390
|
+
* an honest measurement rather than a label the surface makes up.
|
|
5391
|
+
*/
|
|
5392
|
+
run(label, fn) {
|
|
5393
|
+
if (!this.live) return;
|
|
5394
|
+
const started = performance.now();
|
|
5395
|
+
try {
|
|
5396
|
+
fn();
|
|
5397
|
+
} finally {
|
|
5398
|
+
const ms = performance.now() - started;
|
|
5399
|
+
const el = this.control("railOp");
|
|
5400
|
+
if (el) el.textContent = `${label} ${ms >= 1e3 ? `${(ms / 1e3).toFixed(2)} s` : `${Math.round(ms)} ms`}`;
|
|
5401
|
+
this.options.onCommand?.(label, ms);
|
|
5402
|
+
this.refreshRailCounts();
|
|
5403
|
+
this.refreshRailAnchor();
|
|
5404
|
+
}
|
|
5405
|
+
}
|
|
5406
|
+
/** Format controls must not steal the document selection they are about to act on. */
|
|
5407
|
+
keepSelection(el) {
|
|
5408
|
+
el.addEventListener("mousedown", (event) => event.preventDefault());
|
|
5409
|
+
}
|
|
5410
|
+
wire() {
|
|
5411
|
+
const ribbon = this.require("ribbon");
|
|
5412
|
+
for (const tab of Array.from(this.element.querySelectorAll(".dxr-tab"))) {
|
|
5413
|
+
this.keepSelection(tab);
|
|
5414
|
+
tab.addEventListener("click", () => this.selectTab(tab.dataset.tab ?? "home"));
|
|
5415
|
+
}
|
|
5416
|
+
const delegate = (selector, label, fn) => {
|
|
5417
|
+
for (const el of Array.from(ribbon.querySelectorAll(selector))) {
|
|
5418
|
+
this.keepSelection(el);
|
|
5419
|
+
el.addEventListener("click", () => this.run(label(el), () => fn(el)));
|
|
5420
|
+
}
|
|
5421
|
+
};
|
|
5422
|
+
delegate("button[data-cmd]", (b) => b.dataset.cmd, (b) => this.live.format(b.dataset.cmd));
|
|
5423
|
+
delegate("button[data-align]", (b) => `align ${b.dataset.align}`, (b) => this.live.setAlignment(b.dataset.align));
|
|
5424
|
+
delegate("button[data-indent]", () => "indent", (b) => this.live.indent(parseInt(b.dataset.indent ?? "720", 10)));
|
|
5425
|
+
delegate("button[data-list]", (b) => `list ${b.dataset.list}`, (b) => this.live.toggleList(b.dataset.list));
|
|
5426
|
+
delegate("button[data-pagebreak]", () => "page break", () => this.live.pageBreakBefore(true));
|
|
5427
|
+
delegate('.dxr-panel[data-panel="table"] button[data-tt]', (b) => b.dataset.tt, (b) => {
|
|
5428
|
+
const ops = {
|
|
5429
|
+
rowAbove: () => this.live.insertTableRow("above"),
|
|
5430
|
+
rowBelow: () => this.live.insertTableRow("below"),
|
|
5431
|
+
colLeft: () => this.live.insertTableColumn("left"),
|
|
5432
|
+
colRight: () => this.live.insertTableColumn("right"),
|
|
5433
|
+
delRow: () => this.live.deleteTableRow(),
|
|
5434
|
+
delCol: () => this.live.deleteTableColumn()
|
|
5435
|
+
};
|
|
5436
|
+
ops[b.dataset.tt ?? ""]?.();
|
|
5437
|
+
});
|
|
5438
|
+
const rulepos = () => this.require("rulepos").value === "above" ? "above" : "below";
|
|
5439
|
+
const simple = [
|
|
5440
|
+
["undo", "undo", () => this.live.undo()],
|
|
5441
|
+
["redo", "redo", () => this.live.redo()],
|
|
5442
|
+
["hr", "rule", () => this.live.insertHorizontalRule(12, "single", rulepos())],
|
|
5443
|
+
["hrThick", "thick rule", () => this.live.insertHorizontalRule(24, "single", rulepos())],
|
|
5444
|
+
["hrDouble", "double rule", () => this.live.insertHorizontalRule(12, "double", rulepos())],
|
|
5445
|
+
["hrClear", "clear border", () => this.live.clearParagraphBorders()],
|
|
5446
|
+
["delblock", "delete block", () => this.live.deleteBlock()],
|
|
5447
|
+
["footnote", "footnote", () => this.live.insertFootnote()],
|
|
5448
|
+
["endnote", "endnote", () => this.live.insertEndnote()],
|
|
5449
|
+
["pagenum", "page number", () => this.live.insertPageNumber("currentPage")],
|
|
5450
|
+
["totalpages", "total pages", () => this.live.insertPageNumber("totalPages")]
|
|
5451
|
+
];
|
|
5452
|
+
for (const [name, label, fn] of simple) {
|
|
5453
|
+
const el = this.control(name);
|
|
5454
|
+
if (!el) continue;
|
|
5455
|
+
this.keepSelection(el);
|
|
5456
|
+
el.addEventListener("click", () => this.run(label, fn));
|
|
5457
|
+
}
|
|
5458
|
+
const fontsize = this.require("fontsize");
|
|
5459
|
+
fontsize.addEventListener("change", () => {
|
|
5460
|
+
const pts = parseFloat(fontsize.value);
|
|
5461
|
+
if (this.live && pts > 0) this.run("font size", () => this.live.setFontSize(pts));
|
|
5462
|
+
});
|
|
5463
|
+
fontsize.addEventListener("keydown", (event) => {
|
|
5464
|
+
if (event.key === "Enter") {
|
|
5465
|
+
event.preventDefault();
|
|
5466
|
+
fontsize.blur();
|
|
5467
|
+
}
|
|
5468
|
+
});
|
|
5469
|
+
const fontfamily = this.require("fontfamily");
|
|
5470
|
+
fontfamily.addEventListener("change", () => {
|
|
5471
|
+
if (this.live && fontfamily.value) this.run("font family", () => this.live.setFontFamily(fontfamily.value));
|
|
5472
|
+
fontfamily.value = "";
|
|
5473
|
+
});
|
|
5474
|
+
const style = this.require("style");
|
|
5475
|
+
style.addEventListener("change", () => {
|
|
5476
|
+
if (this.live && style.value) this.run("style", () => this.live.setParagraphStyle(style.value));
|
|
5477
|
+
style.value = "";
|
|
5478
|
+
});
|
|
5479
|
+
this.wireFileActions();
|
|
5480
|
+
this.wireLayout();
|
|
5481
|
+
this.wirePicker();
|
|
5482
|
+
}
|
|
5483
|
+
wireFileActions() {
|
|
5484
|
+
const file = this.control("file");
|
|
5485
|
+
file?.addEventListener("change", async () => {
|
|
5486
|
+
const chosen = file.files?.[0];
|
|
5487
|
+
if (!chosen) return;
|
|
5488
|
+
this.setStatus(`Loading ${chosen.name}\u2026`);
|
|
5489
|
+
this.open(new Uint8Array(await chosen.arrayBuffer()), chosen.name);
|
|
5490
|
+
file.value = "";
|
|
5491
|
+
});
|
|
5492
|
+
this.control("new")?.addEventListener("click", () => {
|
|
5493
|
+
if (this.exports) this.openBlank("untitled.docx");
|
|
5494
|
+
});
|
|
5495
|
+
this.control("save")?.addEventListener("click", () => this.download());
|
|
5496
|
+
}
|
|
5497
|
+
wireLayout() {
|
|
5498
|
+
const paginated = this.require("paginated");
|
|
5499
|
+
paginated.addEventListener("change", () => {
|
|
5500
|
+
this.surface.dataset.view = paginated.checked ? "paginated" : "continuous";
|
|
5501
|
+
if (!this.live) return;
|
|
5502
|
+
this.run(paginated.checked ? "page view" : "continuous view", () => this.live.setPaginated(paginated.checked));
|
|
5503
|
+
});
|
|
5504
|
+
const headerFooter = this.require("headerfooter");
|
|
5505
|
+
headerFooter.addEventListener("change", () => {
|
|
5506
|
+
this.headerFooter = headerFooter.checked;
|
|
5507
|
+
if (!this.live) return;
|
|
5508
|
+
this.open(this.live.save(), this.documentName);
|
|
5509
|
+
});
|
|
5510
|
+
const pgfmt = this.require("pgfmt");
|
|
5511
|
+
pgfmt.addEventListener("change", () => {
|
|
5512
|
+
if (!this.live || !pgfmt.value) return;
|
|
5513
|
+
this.run("page format", () => this.live.setPageNumbering({ format: pgfmt.value }));
|
|
5514
|
+
this.syncPageNumbering();
|
|
5515
|
+
});
|
|
5516
|
+
const pgstart = this.require("pgstart");
|
|
5517
|
+
pgstart.addEventListener("change", () => {
|
|
5518
|
+
const value = parseInt(pgstart.value, 10);
|
|
5519
|
+
if (!this.live || !(value > 0)) return;
|
|
5520
|
+
this.run("page start", () => this.live.setPageNumbering({ start: value }));
|
|
5521
|
+
this.syncPageNumbering();
|
|
5522
|
+
});
|
|
5523
|
+
this.control("pgclear")?.addEventListener("click", () => {
|
|
5524
|
+
this.run("clear numbering", () => this.live.clearPageNumbering());
|
|
5525
|
+
this.syncPageNumbering();
|
|
5526
|
+
});
|
|
5527
|
+
}
|
|
5528
|
+
/** The bands own the same setting and read the live session, so both stay in step. */
|
|
5529
|
+
syncPageNumbering() {
|
|
5530
|
+
if (!this.live) return;
|
|
5531
|
+
const numbering = this.live.pageNumbering() ?? {};
|
|
5532
|
+
this.require("pgfmt").value = numbering.format ?? "";
|
|
5533
|
+
this.require("pgstart").value = numbering.start != null ? String(numbering.start) : "";
|
|
5534
|
+
}
|
|
5535
|
+
// ── table size picker ───────────────────────────────────────────────────────
|
|
5536
|
+
wirePicker() {
|
|
5537
|
+
const button = this.require("table");
|
|
5538
|
+
const picker = this.require("gridpicker");
|
|
5539
|
+
const cells = this.require("gridcells");
|
|
5540
|
+
const highlight = (rows, cols) => {
|
|
5541
|
+
for (const cell of Array.from(cells.children)) {
|
|
5542
|
+
const on = Number(cell.dataset.r) < rows && Number(cell.dataset.c) < cols;
|
|
5543
|
+
if (on) cell.setAttribute("data-on", "");
|
|
5544
|
+
else cell.removeAttribute("data-on");
|
|
5545
|
+
}
|
|
5546
|
+
this.require("gridlabel").textContent = `${rows} \xD7 ${cols}`;
|
|
5547
|
+
};
|
|
5548
|
+
cells.addEventListener("pointerover", (event) => {
|
|
5549
|
+
const cell = event.target.closest("[data-r]");
|
|
5550
|
+
if (cell) highlight(Number(cell.dataset.r) + 1, Number(cell.dataset.c) + 1);
|
|
5551
|
+
});
|
|
5552
|
+
cells.addEventListener("mousedown", (event) => {
|
|
5553
|
+
const cell = event.target.closest("[data-r]");
|
|
5554
|
+
if (!cell || !this.live) return;
|
|
5555
|
+
event.preventDefault();
|
|
5556
|
+
const rows = Number(cell.dataset.r) + 1;
|
|
5557
|
+
const cols = Number(cell.dataset.c) + 1;
|
|
5558
|
+
this.closePicker();
|
|
5559
|
+
this.run(`table ${rows}\xD7${cols}`, () => this.live.insertTable(rows, cols, {
|
|
5560
|
+
borderless: this.require("gridborderless").checked,
|
|
5561
|
+
cellAlignment: this.require("gridalign").value
|
|
5562
|
+
}));
|
|
5563
|
+
});
|
|
5564
|
+
this.keepSelection(button);
|
|
5565
|
+
button.addEventListener("click", () => {
|
|
5566
|
+
if (!this.live) return;
|
|
5567
|
+
if (picker.hasAttribute("data-open")) {
|
|
5568
|
+
this.closePicker();
|
|
5569
|
+
return;
|
|
5570
|
+
}
|
|
5571
|
+
highlight(0, 0);
|
|
5572
|
+
picker.setAttribute("data-open", "");
|
|
5573
|
+
if (this.density === "full") {
|
|
5574
|
+
const rect = button.getBoundingClientRect();
|
|
5575
|
+
const host = this.element.getBoundingClientRect();
|
|
5576
|
+
picker.style.left = `${rect.left - host.left}px`;
|
|
5577
|
+
picker.style.top = `${rect.bottom - host.top + 5}px`;
|
|
5578
|
+
}
|
|
5579
|
+
});
|
|
5580
|
+
}
|
|
5581
|
+
closePicker() {
|
|
5582
|
+
this.control("gridpicker")?.removeAttribute("data-open");
|
|
5583
|
+
}
|
|
5584
|
+
maybeClosePicker(event) {
|
|
5585
|
+
const picker = this.control("gridpicker");
|
|
5586
|
+
if (!picker?.hasAttribute("data-open")) return;
|
|
5587
|
+
const target = event.target;
|
|
5588
|
+
if (picker.contains(target) || this.control("table")?.contains(target)) return;
|
|
5589
|
+
this.closePicker();
|
|
5590
|
+
}
|
|
5591
|
+
// ── tabs ────────────────────────────────────────────────────────────────────
|
|
5592
|
+
selectTab(name) {
|
|
5593
|
+
for (const tab of Array.from(this.element.querySelectorAll(".dxr-tab"))) {
|
|
5594
|
+
tab.setAttribute("aria-selected", String(tab.dataset.tab === name));
|
|
5595
|
+
}
|
|
5596
|
+
for (const panel of Array.from(this.element.querySelectorAll(".dxr-panel"))) {
|
|
5597
|
+
if (panel.dataset.panel === name) panel.setAttribute("data-active", "");
|
|
5598
|
+
else panel.removeAttribute("data-active");
|
|
5599
|
+
}
|
|
5600
|
+
if (name === "layout") this.syncPageNumbering();
|
|
5601
|
+
}
|
|
5602
|
+
// ── selection-driven state ──────────────────────────────────────────────────
|
|
5603
|
+
selectionElement() {
|
|
5604
|
+
const selection = (this.element.ownerDocument ?? document).getSelection();
|
|
5605
|
+
const node = selection?.anchorNode ?? null;
|
|
5606
|
+
if (!node) return null;
|
|
5607
|
+
const el = node.nodeType === Node.ELEMENT_NODE ? node : node.parentElement;
|
|
5608
|
+
return el && this.surface.contains(el) ? el : null;
|
|
5609
|
+
}
|
|
5610
|
+
syncSelection() {
|
|
5611
|
+
if (!this.live || this.destroyed) return;
|
|
5612
|
+
const el = this.selectionElement();
|
|
5613
|
+
const state = this.live.queryFormatState();
|
|
5614
|
+
for (const button of Array.from(this.element.querySelectorAll("button[data-cmd]"))) {
|
|
5615
|
+
button.classList.toggle("dxr-on", !!state[button.dataset.cmd]);
|
|
5616
|
+
}
|
|
5617
|
+
const fontsize = this.control("fontsize");
|
|
5618
|
+
if (el && fontsize && (this.element.ownerDocument ?? document).activeElement !== fontsize) {
|
|
5619
|
+
const px = parseFloat(getComputedStyle(el).fontSize);
|
|
5620
|
+
if (px) fontsize.value = String(Math.round(px * 0.75 * 2) / 2);
|
|
5621
|
+
}
|
|
5622
|
+
const inTable = !!el?.closest("table");
|
|
5623
|
+
const tableTab = this.element.querySelector('.dxr-tab[data-tab="table"]');
|
|
5624
|
+
if (tableTab) {
|
|
5625
|
+
tableTab.hidden = !inTable;
|
|
5626
|
+
if (!inTable && tableTab.getAttribute("aria-selected") === "true") this.selectTab("home");
|
|
5627
|
+
}
|
|
5628
|
+
this.refreshRailAnchor();
|
|
5629
|
+
}
|
|
5630
|
+
/** Scope is read from where the block lives, which is exactly what the anchor encodes. */
|
|
5631
|
+
scopeOf(el) {
|
|
5632
|
+
const band = el.closest(".docx-hf-band");
|
|
5633
|
+
if (band) return band.getAttribute("data-hf-band") === "header" ? "hdr" : "ftr";
|
|
5634
|
+
if (el.closest(".footnotes")) return "fn";
|
|
5635
|
+
if (el.closest(".endnotes")) return "en";
|
|
5636
|
+
return "body";
|
|
5637
|
+
}
|
|
5638
|
+
kindOf(el) {
|
|
5639
|
+
if (/^H[1-6]$/.test(el.tagName)) return "h";
|
|
5640
|
+
if (el.tagName === "LI" || el.hasAttribute("data-list-marker") || el.querySelector("[data-list-marker]")) {
|
|
5641
|
+
return "li";
|
|
5642
|
+
}
|
|
5643
|
+
return "p";
|
|
5644
|
+
}
|
|
5645
|
+
/**
|
|
5646
|
+
* Block count and session handle — an O(blocks) query, so it runs only when
|
|
5647
|
+
* something could have changed them (a command, or a document opening), never on
|
|
5648
|
+
* the selectionchange path that fires per keystroke.
|
|
5649
|
+
*/
|
|
5650
|
+
refreshRailCounts() {
|
|
5651
|
+
const blocks = this.control("railBlocks");
|
|
5652
|
+
if (!blocks) return;
|
|
5653
|
+
blocks.textContent = this.live ? String(this.surface.querySelectorAll("[data-anchor]").length) : "\u2014";
|
|
5654
|
+
const session = this.control("railSession");
|
|
5655
|
+
if (session) session.textContent = this.live ? `#${this.live.sessionHandle}` : "\u2014";
|
|
5656
|
+
}
|
|
5657
|
+
/** The focused anchor — cheap, and the only part the caret can change. */
|
|
5658
|
+
refreshRailAnchor() {
|
|
5659
|
+
const anchorEl = this.control("railAnchor");
|
|
5660
|
+
if (!anchorEl) return;
|
|
5661
|
+
const block = this.selectionElement()?.closest("[data-anchor]") ?? null;
|
|
5662
|
+
if (!block) {
|
|
5663
|
+
anchorEl.textContent = this.live ? "none" : "\u2014";
|
|
5664
|
+
this.lastAnchorText = "";
|
|
5665
|
+
return;
|
|
5666
|
+
}
|
|
5667
|
+
const unid = block.getAttribute("data-anchor") ?? "";
|
|
5668
|
+
const text = `${this.kindOf(block)}:${this.scopeOf(block)}:${unid.slice(0, 10)}\u2026`;
|
|
5669
|
+
if (text === this.lastAnchorText) return;
|
|
5670
|
+
anchorEl.textContent = text;
|
|
5671
|
+
this.lastAnchorText = text;
|
|
5672
|
+
anchorEl.classList.remove("dxr-flash");
|
|
5673
|
+
void anchorEl.offsetWidth;
|
|
5674
|
+
anchorEl.classList.add("dxr-flash");
|
|
5675
|
+
}
|
|
5676
|
+
// ── loading overlay ─────────────────────────────────────────────────────────
|
|
5677
|
+
createLoaderController() {
|
|
5678
|
+
const overlay = this.control("loader");
|
|
5679
|
+
if (!overlay) {
|
|
5680
|
+
const noop = () => {
|
|
5681
|
+
};
|
|
5682
|
+
return { show: noop, stage: noop, progress: noop, done: noop, fail: noop };
|
|
5683
|
+
}
|
|
5684
|
+
const options = this.loaderOptions ?? {};
|
|
5685
|
+
const eyebrow = this.control("loaderEyebrow");
|
|
5686
|
+
if (eyebrow && options.eyebrow) eyebrow.textContent = options.eyebrow;
|
|
5687
|
+
const meta = this.control("loaderMeta");
|
|
5688
|
+
if (meta && options.meta) meta.textContent = options.meta;
|
|
5689
|
+
this.control("loaderRetry")?.addEventListener("click", () => {
|
|
5690
|
+
if (options.onRetry) options.onRetry();
|
|
5691
|
+
else location.reload();
|
|
5692
|
+
});
|
|
5693
|
+
if (this.features.length === 0) this.control("loaderAd")?.remove();
|
|
5694
|
+
const setProgress = (percent, label) => {
|
|
5695
|
+
const bar = this.control("loaderBar");
|
|
5696
|
+
if (bar) bar.style.width = `${Math.max(0, Math.min(100, percent))}%`;
|
|
5697
|
+
if (label) {
|
|
5698
|
+
const el = this.control("loaderLabel");
|
|
5699
|
+
if (el) el.textContent = label;
|
|
5700
|
+
}
|
|
5701
|
+
};
|
|
5702
|
+
return {
|
|
5703
|
+
show: () => {
|
|
5704
|
+
overlay.hidden = false;
|
|
5705
|
+
overlay.removeAttribute("data-done");
|
|
5706
|
+
overlay.removeAttribute("data-error");
|
|
5707
|
+
this.setState("loading");
|
|
5708
|
+
this.showFeature(0);
|
|
5709
|
+
this.startRotation();
|
|
5710
|
+
this.loaderStage(0);
|
|
5711
|
+
},
|
|
5712
|
+
stage: (step) => this.loaderStage(step),
|
|
5713
|
+
progress: setProgress,
|
|
5714
|
+
done: () => {
|
|
5715
|
+
this.stopRotation();
|
|
5716
|
+
this.setState("ready");
|
|
5717
|
+
setTimeout(() => overlay.setAttribute("data-done", ""), 420);
|
|
5718
|
+
setTimeout(() => {
|
|
5719
|
+
overlay.hidden = true;
|
|
5720
|
+
}, 1050);
|
|
5721
|
+
},
|
|
5722
|
+
fail: (error) => {
|
|
5723
|
+
this.stopRotation();
|
|
5724
|
+
this.setState("error");
|
|
5725
|
+
overlay.hidden = false;
|
|
5726
|
+
overlay.setAttribute("data-error", "");
|
|
5727
|
+
overlay.removeAttribute("data-done");
|
|
5728
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
5729
|
+
const title = this.control("loaderTitle");
|
|
5730
|
+
if (title) title.textContent = "The local engine did not start";
|
|
5731
|
+
const copy = this.control("loaderCopy");
|
|
5732
|
+
if (copy) copy.textContent = message.slice(0, 220);
|
|
5733
|
+
setProgress(100, "Load failed");
|
|
5734
|
+
this.setStatus(message.slice(0, 180));
|
|
5735
|
+
}
|
|
5736
|
+
};
|
|
5737
|
+
}
|
|
5738
|
+
loaderStage(step) {
|
|
5739
|
+
const stage = typeof step === "number" ? this.stages[Math.max(0, Math.min(this.stages.length - 1, step))] : step;
|
|
5740
|
+
if (!stage) return;
|
|
5741
|
+
const title = this.control("loaderTitle");
|
|
5742
|
+
if (title && stage.title) title.textContent = stage.title;
|
|
5743
|
+
const copy = this.control("loaderCopy");
|
|
5744
|
+
if (copy && stage.copy) copy.textContent = stage.copy;
|
|
5745
|
+
const bar = this.control("loaderBar");
|
|
5746
|
+
if (bar && stage.progress != null) bar.style.width = `${stage.progress}%`;
|
|
5747
|
+
const label = this.control("loaderLabel");
|
|
5748
|
+
if (label && stage.label) label.textContent = stage.label;
|
|
5749
|
+
}
|
|
5750
|
+
showFeature(index) {
|
|
5751
|
+
const feature = this.features[index];
|
|
5752
|
+
if (!feature) return;
|
|
5753
|
+
const card = this.control("loaderAd");
|
|
5754
|
+
const number = this.control("loaderNumber");
|
|
5755
|
+
const title = this.control("loaderAdTitle");
|
|
5756
|
+
const copy = this.control("loaderAdCopy");
|
|
5757
|
+
if (number) number.textContent = feature.number;
|
|
5758
|
+
if (title) title.textContent = feature.title;
|
|
5759
|
+
if (copy) copy.textContent = feature.copy;
|
|
5760
|
+
if (card) {
|
|
5761
|
+
card.removeAttribute("data-swap");
|
|
5762
|
+
void card.offsetWidth;
|
|
5763
|
+
card.setAttribute("data-swap", "");
|
|
5764
|
+
}
|
|
5765
|
+
}
|
|
5766
|
+
startRotation() {
|
|
5767
|
+
this.stopRotation();
|
|
5768
|
+
if (this.features.length < 2) return;
|
|
5769
|
+
const every = this.loaderOptions?.rotateMs ?? 1750;
|
|
5770
|
+
this.featureTimer = setInterval(() => {
|
|
5771
|
+
this.featureIndex = (this.featureIndex + 1) % this.features.length;
|
|
5772
|
+
this.showFeature(this.featureIndex);
|
|
5773
|
+
}, every);
|
|
5774
|
+
}
|
|
5775
|
+
stopRotation() {
|
|
5776
|
+
if (this.featureTimer == null) return;
|
|
5777
|
+
clearInterval(this.featureTimer);
|
|
5778
|
+
this.featureTimer = null;
|
|
5779
|
+
}
|
|
5780
|
+
};
|
|
5781
|
+
return __toCommonJS(ribbon_exports);
|
|
3894
5782
|
})();
|