ooxml-ui 1.49.1 → 1.50.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 +10 -2
- package/dist/{chunk-3WJUMM5D.js → chunk-63ELC26U.js} +1 -1
- package/dist/docx/building-blocks-read-aloud.d.ts +24 -0
- package/dist/docx/building-blocks.d.ts +5 -0
- package/dist/docx/editor-core.d.ts +3 -0
- package/dist/docx/element-api.d.ts +7 -0
- package/dist/docx/index.d.ts +2 -0
- package/dist/docx/read-aloud-session.d.ts +39 -0
- package/dist/docx/read-aloud.d.ts +14 -1
- package/dist/docx/view-options.d.ts +3 -0
- package/dist/docx.js +272 -154
- package/dist/image-native-size.d.ts +1 -0
- package/dist/index.js +2 -2
- package/dist/pptx/{chunk-WBGU7BWD.cjs → chunk-2JR2CHTG.cjs} +31 -1
- package/dist/pptx/{chunk-UFJBHFSD.cjs → chunk-3JGYWDMR.cjs} +5 -0
- package/dist/pptx/{chunk-URAPHGDB.cjs → chunk-3YKUOEZ5.cjs} +42 -42
- package/dist/pptx/{chunk-ZFZNX62I.mjs → chunk-74ESWHDZ.mjs} +1 -1
- package/dist/pptx/{chunk-PJQNDNOH.cjs → chunk-N7RS46HM.cjs} +2412 -483
- package/dist/pptx/{chunk-ZZJ7KTSD.mjs → chunk-OWXWCDNG.mjs} +2320 -483
- package/dist/pptx/{chunk-PTIGQSTY.mjs → chunk-QYBBLVGY.mjs} +31 -1
- package/dist/pptx/{chunk-2P6TH4ZE.mjs → chunk-VOBKKF45.mjs} +5 -0
- package/dist/pptx/dom/index.cjs +375 -375
- package/dist/pptx/dom/index.mjs +7 -7
- package/dist/pptx/i18n/index.cjs +6 -6
- package/dist/pptx/i18n/index.mjs +1 -1
- package/dist/pptx/i18n/translations-en.d.ts.map +1 -1
- package/dist/pptx/index.cjs +3443 -3075
- package/dist/pptx/index.mjs +3 -3
- package/dist/pptx/render/building-block-actions.d.ts +106 -0
- package/dist/pptx/render/building-block-actions.d.ts.map +1 -0
- package/dist/pptx/render/building-block-custom-shows.d.ts +74 -0
- package/dist/pptx/render/building-block-custom-shows.d.ts.map +1 -0
- package/dist/pptx/render/building-block-document-properties.d.ts +78 -0
- package/dist/pptx/render/building-block-document-properties.d.ts.map +1 -0
- package/dist/pptx/render/building-block-font-embedding.d.ts +42 -0
- package/dist/pptx/render/building-block-font-embedding.d.ts.map +1 -0
- package/dist/pptx/render/building-block-password.d.ts +71 -0
- package/dist/pptx/render/building-block-password.d.ts.map +1 -0
- package/dist/pptx/render/building-block-show-dialogs.d.ts +61 -0
- package/dist/pptx/render/building-block-show-dialogs.d.ts.map +1 -0
- package/dist/pptx/render/building-block-show-settings.d.ts +61 -0
- package/dist/pptx/render/building-block-show-settings.d.ts.map +1 -0
- package/dist/pptx/render/building-block-signatures.d.ts +68 -0
- package/dist/pptx/render/building-block-signatures.d.ts.map +1 -0
- package/dist/pptx/render/building-blocks/action-groups.d.ts +61 -0
- package/dist/pptx/render/building-blocks/action-groups.d.ts.map +1 -0
- package/dist/pptx/render/building-blocks/actions-types.d.ts +110 -0
- package/dist/pptx/render/building-blocks/actions-types.d.ts.map +1 -0
- package/dist/pptx/render/building-blocks/find-bar-controller.d.ts +18 -0
- package/dist/pptx/render/building-blocks/find-bar-controller.d.ts.map +1 -0
- package/dist/pptx/render/building-blocks/find-highlight-dom.d.ts +20 -0
- package/dist/pptx/render/building-blocks/find-highlight-dom.d.ts.map +1 -0
- package/dist/pptx/render/building-blocks/find-layout.d.ts +62 -0
- package/dist/pptx/render/building-blocks/find-layout.d.ts.map +1 -0
- package/dist/pptx/render/building-blocks/groups/file-dialog-groups.d.ts +45 -0
- package/dist/pptx/render/building-blocks/groups/file-dialog-groups.d.ts.map +1 -0
- package/dist/pptx/render/building-blocks/groups/index.d.ts +25 -0
- package/dist/pptx/render/building-blocks/groups/index.d.ts.map +1 -0
- package/dist/pptx/render/building-blocks/groups/show-dialog-groups.d.ts +79 -0
- package/dist/pptx/render/building-blocks/groups/show-dialog-groups.d.ts.map +1 -0
- package/dist/pptx/render/building-blocks/hyperlink-edit-data.d.ts +57 -0
- package/dist/pptx/render/building-blocks/hyperlink-edit-data.d.ts.map +1 -0
- package/dist/pptx/render/building-blocks/index.d.ts +19 -0
- package/dist/pptx/render/building-blocks/index.d.ts.map +1 -0
- package/dist/pptx/render/building-blocks/media-element-from-file.d.ts +23 -0
- package/dist/pptx/render/building-blocks/media-element-from-file.d.ts.map +1 -0
- package/dist/pptx/render/building-blocks/mode.d.ts +11 -0
- package/dist/pptx/render/building-blocks/mode.d.ts.map +1 -0
- package/dist/pptx/render/building-blocks/requests.d.ts +96 -0
- package/dist/pptx/render/building-blocks/requests.d.ts.map +1 -0
- package/dist/pptx/render/building-blocks/session.d.ts +84 -0
- package/dist/pptx/render/building-blocks/session.d.ts.map +1 -0
- package/dist/pptx/render/building-blocks/toolbar.d.ts +56 -0
- package/dist/pptx/render/building-blocks/toolbar.d.ts.map +1 -0
- package/dist/pptx/render/controller/index.d.ts +4 -0
- package/dist/pptx/render/controller/index.d.ts.map +1 -1
- package/dist/pptx/render/controller/ribbon-display-controller.d.ts +80 -0
- package/dist/pptx/render/controller/ribbon-display-controller.d.ts.map +1 -0
- package/dist/pptx/render/controller/save-revision.d.ts +83 -0
- package/dist/pptx/render/controller/save-revision.d.ts.map +1 -0
- package/dist/pptx/render/editor-chrome/ribbon-css.d.ts +1 -1
- package/dist/pptx/render/editor-chrome/ribbon-css.d.ts.map +1 -1
- package/dist/pptx/render/font-catalog.cjs +3 -3
- package/dist/pptx/render/font-catalog.d.ts +27 -3
- package/dist/pptx/render/font-catalog.d.ts.map +1 -1
- package/dist/pptx/render/font-catalog.mjs +1 -1
- package/dist/pptx/render/index.d.ts +12 -0
- package/dist/pptx/render/index.d.ts.map +1 -1
- package/dist/pptx/render/insert-chart.d.ts +12 -0
- package/dist/pptx/render/insert-chart.d.ts.map +1 -1
- package/dist/pptx/render/read-only-recommendation.d.ts +2 -0
- package/dist/pptx/render/read-only-recommendation.d.ts.map +1 -1
- package/dist/pptx/render/ribbon-display.d.ts +50 -0
- package/dist/pptx/render/ribbon-display.d.ts.map +1 -0
- package/dist/pptx/render/ribbon-home-state-extras.d.ts.map +1 -1
- package/dist/pptx/render/stage-element-ids.d.ts +9 -0
- package/dist/pptx/render/stage-element-ids.d.ts.map +1 -1
- package/dist/pptx/render/viewer-props-manifest.d.ts.map +1 -1
- package/dist/pptx/render/viewer-zoom-store.d.ts.map +1 -1
- package/dist/pptx/render/viewport-navigation.d.ts +93 -0
- package/dist/pptx/render/viewport-navigation.d.ts.map +1 -0
- package/dist/pptx/render/zoom-step.d.ts +9 -2
- package/dist/pptx/render/zoom-step.d.ts.map +1 -1
- package/dist/pptx/{smartart-insert-preview-WYVZOCHF.cjs → smartart-insert-preview-WPIGM6UQ.cjs} +5 -5
- package/dist/pptx/{smartart-insert-preview-WXVMLDH4.mjs → smartart-insert-preview-ZHDQ5QDD.mjs} +4 -4
- package/dist/pptx/types.d.ts +20 -0
- package/dist/pptx/types.d.ts.map +1 -1
- package/dist/ribbon/color-preview.d.ts +0 -1
- package/dist/teams.js +1 -1
- package/dist/theme.d.ts +1 -0
- package/dist/visio/controller.d.ts +11 -0
- package/dist/visio/index.d.ts +1 -0
- package/dist/visio/text-edit-outcome.d.ts +41 -0
- package/dist/visio/viewer-inline-text.d.ts +7 -0
- package/dist/visio.js +133 -10
- package/dist/xlsx/building-blocks.d.ts +24 -0
- package/dist/xlsx/commands/test-support.d.ts +1 -0
- package/dist/xlsx/component.d.ts +7 -0
- package/dist/xlsx/context-menu/host-api.d.ts +55 -0
- package/dist/xlsx/context-menu/menu.d.ts +9 -0
- package/dist/xlsx/dialogs/find-replace.d.ts +2 -4
- package/dist/xlsx/editor-core.d.ts +2 -0
- package/dist/xlsx/host-find.d.ts +3 -0
- package/dist/xlsx/host-function.d.ts +3 -0
- package/dist/xlsx/host-open.d.ts +10 -0
- package/dist/xlsx/host-workflows.d.ts +9 -0
- package/dist/xlsx/index.d.ts +1 -0
- package/dist/xlsx/surface-actions.d.ts +20 -4
- package/dist/xlsx/surface-workflows.d.ts +132 -0
- package/dist/xlsx.js +539 -201
- package/package.json +2 -2
- /package/dist/{chunk-XWGWPYG5.js → chunk-BY7X2LNM.js} +0 -0
package/dist/docx.js
CHANGED
|
@@ -5642,8 +5642,8 @@ function formatWordCount(locale, count) {
|
|
|
5642
5642
|
new Intl.NumberFormat(locale).format(count)
|
|
5643
5643
|
);
|
|
5644
5644
|
}
|
|
5645
|
-
function formatPageStatus(locale,
|
|
5646
|
-
return translate(locale, "status.page").replace("{current}", String(
|
|
5645
|
+
function formatPageStatus(locale, current3, total) {
|
|
5646
|
+
return translate(locale, "status.page").replace("{current}", String(current3)).replace("{total}", String(total));
|
|
5647
5647
|
}
|
|
5648
5648
|
function languageName(locale, tag, english) {
|
|
5649
5649
|
if (locale === "en") return english;
|
|
@@ -6002,7 +6002,7 @@ function openSwatchPopover(anchor, choices, choose) {
|
|
|
6002
6002
|
mountPopover(anchor, pop, anchor);
|
|
6003
6003
|
pop.style.left = `${Math.max(4, box2.left - 60)}px`;
|
|
6004
6004
|
}
|
|
6005
|
-
function openListPopover(anchor, items,
|
|
6005
|
+
function openListPopover(anchor, items, current3, preview, choose) {
|
|
6006
6006
|
const pop = document.createElement("div");
|
|
6007
6007
|
pop.className = "ribbon-popover ribbon-list";
|
|
6008
6008
|
pop.setAttribute("role", "listbox");
|
|
@@ -6013,7 +6013,7 @@ function openListPopover(anchor, items, current2, preview, choose) {
|
|
|
6013
6013
|
item.textContent = value;
|
|
6014
6014
|
item.setAttribute(
|
|
6015
6015
|
"aria-selected",
|
|
6016
|
-
String(typeof
|
|
6016
|
+
String(typeof current3 === "number" ? index === current3 : value === current3)
|
|
6017
6017
|
);
|
|
6018
6018
|
if (preview) item.style.fontFamily = `"${value}", sans-serif`;
|
|
6019
6019
|
item.addEventListener("mousedown", (event) => event.preventDefault());
|
|
@@ -10038,13 +10038,13 @@ function insertSectionBreak(view, model, type) {
|
|
|
10038
10038
|
const sections = sectionsOf(model);
|
|
10039
10039
|
if (sections.some((section3) => section3.endsAtBlockId === block.id)) return model;
|
|
10040
10040
|
const index = currentSectionIndex(view, model);
|
|
10041
|
-
const
|
|
10041
|
+
const current3 = expectDefined(sections[index], "current section");
|
|
10042
10042
|
const next = [...sections];
|
|
10043
10043
|
next.splice(
|
|
10044
10044
|
index,
|
|
10045
10045
|
1,
|
|
10046
|
-
{ ...structuredClone(
|
|
10047
|
-
{ ...
|
|
10046
|
+
{ ...structuredClone(current3), endsAtBlockId: block.id },
|
|
10047
|
+
{ ...current3, type }
|
|
10048
10048
|
);
|
|
10049
10049
|
return { ...model, sections: next };
|
|
10050
10050
|
}
|
|
@@ -10657,9 +10657,9 @@ function runStylesPlugin(getModel, getMode = () => "all") {
|
|
|
10657
10657
|
let hasScale = false;
|
|
10658
10658
|
paragraph2.forEach((child, offset) => {
|
|
10659
10659
|
if (!child.isInline || child.type.name === "equation") return;
|
|
10660
|
-
const
|
|
10661
|
-
if (!
|
|
10662
|
-
const projected = reviewRunFormatting(
|
|
10660
|
+
const current3 = runOf(child);
|
|
10661
|
+
if (!current3) return;
|
|
10662
|
+
const projected = reviewRunFormatting(current3, mode);
|
|
10663
10663
|
const run = projected.value;
|
|
10664
10664
|
const resolved = resolveRunFormatting(run, {
|
|
10665
10665
|
runCatalog: model.characterStyles,
|
|
@@ -10990,8 +10990,8 @@ function updateParagraphs(view, key3, value) {
|
|
|
10990
10990
|
if (key3 === "indent") {
|
|
10991
10991
|
const logical = node.attrs.indentStartTwips != null;
|
|
10992
10992
|
const attr = logical ? "indentStartTwips" : "indentLeftTwips";
|
|
10993
|
-
const
|
|
10994
|
-
const next = Math.max(0,
|
|
10993
|
+
const current3 = Number(node.attrs[attr] ?? 0);
|
|
10994
|
+
const next = Math.max(0, current3 + (value === "increase" ? 360 : -360));
|
|
10995
10995
|
transaction = transaction.setNodeMarkup(pos, void 0, {
|
|
10996
10996
|
...node.attrs,
|
|
10997
10997
|
[attr]: next
|
|
@@ -11972,12 +11972,12 @@ function applyEdits(view, ctx, edits, shading) {
|
|
|
11972
11972
|
const add = (edit) => all.set(`${edit.row}:${edit.column}:${edit.side}`, edit);
|
|
11973
11973
|
for (const edit of edits) {
|
|
11974
11974
|
add(edit);
|
|
11975
|
-
const
|
|
11975
|
+
const shared2 = {
|
|
11976
11976
|
row: edit.row + (edit.side === "bottom" ? 1 : edit.side === "top" ? -1 : 0),
|
|
11977
11977
|
column: edit.column + (edit.side === "right" ? 1 : edit.side === "left" ? -1 : 0)
|
|
11978
11978
|
};
|
|
11979
|
-
if (
|
|
11980
|
-
add({ ...
|
|
11979
|
+
if (shared2.row >= 0 && shared2.row < ctx.rows && shared2.column >= 0 && shared2.column < ctx.columns)
|
|
11980
|
+
add({ ...shared2, side: OPPOSITE[edit.side], pen: edit.pen });
|
|
11981
11981
|
}
|
|
11982
11982
|
const tr = view.state.tr;
|
|
11983
11983
|
const table = view.state.doc.nodeAt(ctx.tablePos);
|
|
@@ -12536,8 +12536,8 @@ function decorations(state, boxes) {
|
|
|
12536
12536
|
);
|
|
12537
12537
|
}
|
|
12538
12538
|
function sameBoxes(set, boxes, state) {
|
|
12539
|
-
const
|
|
12540
|
-
return
|
|
12539
|
+
const current3 = set.find(0, state.doc.content.size);
|
|
12540
|
+
return current3.length === boxes.length && current3.every((decoration, index) => {
|
|
12541
12541
|
const box2 = boxes[index];
|
|
12542
12542
|
if (!box2) return false;
|
|
12543
12543
|
const spec = decoration.spec;
|
|
@@ -14370,11 +14370,11 @@ function createChartTypeDialog(host, change) {
|
|
|
14370
14370
|
const cancel = dialogButton("Cancel");
|
|
14371
14371
|
const ok = dialogButton("OK", true);
|
|
14372
14372
|
let locale = "en";
|
|
14373
|
-
let
|
|
14373
|
+
let current3;
|
|
14374
14374
|
const hide = () => {
|
|
14375
14375
|
setDialogOpen(element, false);
|
|
14376
14376
|
element.replaceChildren();
|
|
14377
|
-
|
|
14377
|
+
current3 = void 0;
|
|
14378
14378
|
focusView(host.view());
|
|
14379
14379
|
};
|
|
14380
14380
|
extendedClose.addEventListener("click", hide);
|
|
@@ -14415,7 +14415,7 @@ function createChartTypeDialog(host, change) {
|
|
|
14415
14415
|
});
|
|
14416
14416
|
picker.drawPreview = (value, size, tile) => {
|
|
14417
14417
|
try {
|
|
14418
|
-
const chart = previewChart(value, tile,
|
|
14418
|
+
const chart = previewChart(value, tile, current3);
|
|
14419
14419
|
return docxChartPaint(chart, size.width, size.height, host.theme()).svg ?? "";
|
|
14420
14420
|
} catch {
|
|
14421
14421
|
return "";
|
|
@@ -14448,7 +14448,7 @@ function createChartTypeDialog(host, change) {
|
|
|
14448
14448
|
message.textContent = translate(locale, "chart.readOnly");
|
|
14449
14449
|
element.replaceChildren(message, dialogActions(cancel));
|
|
14450
14450
|
} else {
|
|
14451
|
-
|
|
14451
|
+
current3 = selected?.chart;
|
|
14452
14452
|
picker.types = DOCX_CHART_TYPES.map(([id, label2]) => ({
|
|
14453
14453
|
id,
|
|
14454
14454
|
label: translate(locale, label2)
|
|
@@ -14459,12 +14459,12 @@ function createChartTypeDialog(host, change) {
|
|
|
14459
14459
|
}));
|
|
14460
14460
|
picker.groupedTypes = [...DOCX_GROUPED_CHART_TYPES];
|
|
14461
14461
|
picker.labels = pickerLabels(locale);
|
|
14462
|
-
picker.value =
|
|
14462
|
+
picker.value = current3 ? { ...chartPickerChoice(current3), title: current3.title ?? "" } : { type: "column", grouping: "clustered", title: translate(locale, "Chart title") };
|
|
14463
14463
|
element.replaceChildren(picker, dialogActions(cancel, ok));
|
|
14464
14464
|
}
|
|
14465
14465
|
localizeDialog(element, locale);
|
|
14466
14466
|
setDialogOpen(element, true);
|
|
14467
|
-
(change && !
|
|
14467
|
+
(change && !current3 ? cancel : ok).focus();
|
|
14468
14468
|
}
|
|
14469
14469
|
};
|
|
14470
14470
|
}
|
|
@@ -14701,8 +14701,8 @@ function applyFontFields(view, changes) {
|
|
|
14701
14701
|
});
|
|
14702
14702
|
}
|
|
14703
14703
|
if (changes.script !== void 0) {
|
|
14704
|
-
const
|
|
14705
|
-
if (
|
|
14704
|
+
const current3 = readFontFormat(view.state).script;
|
|
14705
|
+
if (current3 !== changes.script) {
|
|
14706
14706
|
applyVerticalAlign(view, changes.script === "none" ? "baseline" : changes.script);
|
|
14707
14707
|
}
|
|
14708
14708
|
}
|
|
@@ -15359,15 +15359,15 @@ function createWatermarkDialog(host) {
|
|
|
15359
15359
|
},
|
|
15360
15360
|
open() {
|
|
15361
15361
|
if (!host.canEdit()) return;
|
|
15362
|
-
const
|
|
15362
|
+
const current3 = host.current();
|
|
15363
15363
|
element.replaceChildren(...content);
|
|
15364
15364
|
localizeDialog(element, locale);
|
|
15365
|
-
setting.value =
|
|
15366
|
-
text.value =
|
|
15367
|
-
font.value =
|
|
15368
|
-
color.value =
|
|
15369
|
-
layout.value =
|
|
15370
|
-
semi.input.checked =
|
|
15365
|
+
setting.value = current3 ? "text" : "none";
|
|
15366
|
+
text.value = current3?.text ?? "";
|
|
15367
|
+
font.value = current3?.fontFamily ?? "Calibri";
|
|
15368
|
+
color.value = current3?.color ?? DEFAULT_COLOR;
|
|
15369
|
+
layout.value = current3?.layout ?? "diagonal";
|
|
15370
|
+
semi.input.checked = current3?.semitransparent ?? true;
|
|
15371
15371
|
validate();
|
|
15372
15372
|
setDialogOpen(element, true);
|
|
15373
15373
|
setting.focus();
|
|
@@ -15988,15 +15988,15 @@ function createBordersDialog(getView) {
|
|
|
15988
15988
|
const content = [...element.childNodes];
|
|
15989
15989
|
element.replaceChildren();
|
|
15990
15990
|
const loadParagraph = (view) => {
|
|
15991
|
-
const
|
|
15991
|
+
const current3 = readBordersAndShading(view.state);
|
|
15992
15992
|
for (const [name, box2] of Object.entries(sides2))
|
|
15993
|
-
box2.input.checked = Boolean(
|
|
15994
|
-
style.value =
|
|
15995
|
-
width.value = WIDTHS2.some(([value]) => value === String(
|
|
15996
|
-
automatic.input.checked =
|
|
15997
|
-
color.value =
|
|
15998
|
-
noFill.input.checked =
|
|
15999
|
-
fill.value =
|
|
15993
|
+
box2.input.checked = Boolean(current3.sides[name]);
|
|
15994
|
+
style.value = current3.style;
|
|
15995
|
+
width.value = WIDTHS2.some(([value]) => value === String(current3.sizeEighthPoints)) ? String(current3.sizeEighthPoints) : "4";
|
|
15996
|
+
automatic.input.checked = current3.color === null;
|
|
15997
|
+
color.value = current3.color ?? "#000000";
|
|
15998
|
+
noFill.input.checked = current3.fill === null;
|
|
15999
|
+
fill.value = current3.fill ?? "#ffff00";
|
|
16000
16000
|
};
|
|
16001
16001
|
const inTable = () => {
|
|
16002
16002
|
const view = getView();
|
|
@@ -16012,14 +16012,14 @@ function createBordersDialog(getView) {
|
|
|
16012
16012
|
fillChanged = false;
|
|
16013
16013
|
noFill.input.indeterminate = false;
|
|
16014
16014
|
if (cells) {
|
|
16015
|
-
const
|
|
16015
|
+
const current3 = readCellFill(
|
|
16016
16016
|
tableBorderContext(view.state),
|
|
16017
16017
|
view.state,
|
|
16018
16018
|
scope.value
|
|
16019
16019
|
);
|
|
16020
|
-
noFill.input.checked =
|
|
16021
|
-
noFill.input.indeterminate =
|
|
16022
|
-
fill.value =
|
|
16020
|
+
noFill.input.checked = current3 === null;
|
|
16021
|
+
noFill.input.indeterminate = current3 === void 0;
|
|
16022
|
+
fill.value = current3 ?? "#ffff00";
|
|
16023
16023
|
const read = readCellBorderSettings(view.state, scope.value);
|
|
16024
16024
|
if (!read) return;
|
|
16025
16025
|
for (const [name, box2] of Object.entries(sides2))
|
|
@@ -16306,8 +16306,8 @@ function refreshFieldResults(tr, pageOf, captionsOnly = false, model) {
|
|
|
16306
16306
|
}
|
|
16307
16307
|
function refreshPass(tr, pageOf, captionsOnly, model) {
|
|
16308
16308
|
const targets = bookmarkTargets(tr.doc);
|
|
16309
|
-
const
|
|
16310
|
-
const source =
|
|
16309
|
+
const current3 = model && !captionsOnly && tr.docChanged ? docToModel(tr.doc, model, tr.before) : model;
|
|
16310
|
+
const source = current3 && !captionsOnly ? styleRefSource(current3) : void 0;
|
|
16311
16311
|
const changes = [];
|
|
16312
16312
|
for (const run of fieldResults(tr.doc)) {
|
|
16313
16313
|
if (isFieldLocked(inlineNodeRun(schema.text("x", run.marks)))) continue;
|
|
@@ -16889,8 +16889,8 @@ var figuresFilter = (label2) => label2 ? (instruction) => tocCaptionLabel(instru
|
|
|
16889
16889
|
function insertTableOfContents(view, model, measurer, levels = 3, captionLabel2) {
|
|
16890
16890
|
const { $from } = view.state.selection;
|
|
16891
16891
|
const index = $from.index(0);
|
|
16892
|
-
const
|
|
16893
|
-
const replace =
|
|
16892
|
+
const current3 = view.state.doc.maybeChild(index);
|
|
16893
|
+
const replace = current3?.type.name === "paragraph" && current3.content.size === 0;
|
|
16894
16894
|
const end2 = replace ? index : index - 1;
|
|
16895
16895
|
const depth = Math.min(9, Math.max(1, Math.floor(levels)));
|
|
16896
16896
|
const instruction = captionLabel2 ? tableOfFiguresInstruction(captionLabel2) : ` TOC \\o "1-${depth}" \\h \\z \\u `;
|
|
@@ -17037,19 +17037,19 @@ function createPageSetupDialog(host) {
|
|
|
17037
17037
|
open() {
|
|
17038
17038
|
const section3 = host.section();
|
|
17039
17039
|
if (!section3 || !host.canEdit()) return;
|
|
17040
|
-
const
|
|
17040
|
+
const current3 = readPageSetup(section3);
|
|
17041
17041
|
element.replaceChildren(...content);
|
|
17042
17042
|
localizeDialog(element, locale);
|
|
17043
|
-
top.value = String(
|
|
17044
|
-
bottom.value = String(
|
|
17045
|
-
left.value = String(
|
|
17046
|
-
right.value = String(
|
|
17047
|
-
gutter.value = String(
|
|
17048
|
-
header.value = String(
|
|
17049
|
-
footer.value = String(
|
|
17050
|
-
orientation.value =
|
|
17051
|
-
width.value = String(
|
|
17052
|
-
height.value = String(
|
|
17043
|
+
top.value = String(current3.topIn);
|
|
17044
|
+
bottom.value = String(current3.bottomIn);
|
|
17045
|
+
left.value = String(current3.leftIn);
|
|
17046
|
+
right.value = String(current3.rightIn);
|
|
17047
|
+
gutter.value = String(current3.gutterIn);
|
|
17048
|
+
header.value = String(current3.headerIn);
|
|
17049
|
+
footer.value = String(current3.footerIn);
|
|
17050
|
+
orientation.value = current3.orientation;
|
|
17051
|
+
width.value = String(current3.widthIn);
|
|
17052
|
+
height.value = String(current3.heightIn);
|
|
17053
17053
|
syncPreset();
|
|
17054
17054
|
setDialogOpen(element, true);
|
|
17055
17055
|
top.focus();
|
|
@@ -17480,9 +17480,9 @@ function createZoomDialog(host) {
|
|
|
17480
17480
|
session?.dispose();
|
|
17481
17481
|
element.replaceChildren(...content);
|
|
17482
17482
|
localizeDialog(element, locale);
|
|
17483
|
-
const
|
|
17484
|
-
const preset = ["200", "100", "75"].find((value) => Number(value) ===
|
|
17485
|
-
percent.value = String(
|
|
17483
|
+
const current3 = host.percent();
|
|
17484
|
+
const preset = ["200", "100", "75"].find((value) => Number(value) === current3);
|
|
17485
|
+
percent.value = String(current3);
|
|
17486
17486
|
const radio = radios.get(preset ?? "custom");
|
|
17487
17487
|
if (radio) radio.checked = true;
|
|
17488
17488
|
showPreview();
|
|
@@ -18714,10 +18714,10 @@ function createRestrictEditingPane(host) {
|
|
|
18714
18714
|
const render = () => {
|
|
18715
18715
|
say("");
|
|
18716
18716
|
const protection = host.protection();
|
|
18717
|
-
const
|
|
18718
|
-
body.replaceChildren(...
|
|
18717
|
+
const current3 = enforced();
|
|
18718
|
+
body.replaceChildren(...current3 ? enforcedView : settingsView);
|
|
18719
18719
|
for (const input of highlights) input.checked = host.highlight();
|
|
18720
|
-
if (
|
|
18720
|
+
if (current3) {
|
|
18721
18721
|
secret.value = "";
|
|
18722
18722
|
secret.parentElement.hidden = !protection?.password && !protection?.unverifiablePassword;
|
|
18723
18723
|
say("The document is protected");
|
|
@@ -19797,10 +19797,10 @@ function stylePreviewRuns(element, block, model, serializer, mode = "all") {
|
|
|
19797
19797
|
const measurer = scaleMeasurer();
|
|
19798
19798
|
const paragraphs = block.type === "paragraph" ? [block] : block.rows.flatMap((row3) => row3.flatMap((cell) => cell.paragraphs));
|
|
19799
19799
|
const elements = block.type === "paragraph" ? [element] : [...element.querySelectorAll("p")];
|
|
19800
|
-
paragraphs.forEach((
|
|
19800
|
+
paragraphs.forEach((current3, index) => {
|
|
19801
19801
|
const target = elements[index];
|
|
19802
19802
|
if (!target) return;
|
|
19803
|
-
const projected = reviewParagraphFormatting(
|
|
19803
|
+
const projected = reviewParagraphFormatting(current3, mode);
|
|
19804
19804
|
const paragraph2 = projected.value;
|
|
19805
19805
|
const effective = model.paragraphStyles ? resolveParagraphFormatting(paragraph2, model.paragraphStyles) : paragraph2;
|
|
19806
19806
|
target.style.cssText = paragraphStyle({ ...paragraph2, ...effective });
|
|
@@ -20424,8 +20424,8 @@ var PartsController = class {
|
|
|
20424
20424
|
if (this.notesEl)
|
|
20425
20425
|
attachNoteEditing(this.notesEl, {
|
|
20426
20426
|
note: (kind, id) => {
|
|
20427
|
-
const
|
|
20428
|
-
return
|
|
20427
|
+
const current3 = this.host.model();
|
|
20428
|
+
return current3[kind === "footnote" ? "footnotes" : "endnotes"]?.find(
|
|
20429
20429
|
(note) => note.id === id
|
|
20430
20430
|
);
|
|
20431
20431
|
},
|
|
@@ -21582,12 +21582,12 @@ function createSmartArtDialog(restoreFocus) {
|
|
|
21582
21582
|
get isOpen() {
|
|
21583
21583
|
return isDialogOpen(element);
|
|
21584
21584
|
},
|
|
21585
|
-
open(choose,
|
|
21585
|
+
open(choose, current3) {
|
|
21586
21586
|
onChoose = choose;
|
|
21587
21587
|
fill();
|
|
21588
21588
|
localizeDialog(element, locale);
|
|
21589
21589
|
const first = DIAGRAM_INSERT_PRESETS[0]?.layout ?? "";
|
|
21590
|
-
picker.value = { layout:
|
|
21590
|
+
picker.value = { layout: current3 ?? first, items: [] };
|
|
21591
21591
|
setDialogOpen(element, true);
|
|
21592
21592
|
picker.shadowRoot?.querySelector('[role="option"][tabindex="0"]')?.focus();
|
|
21593
21593
|
},
|
|
@@ -22091,9 +22091,9 @@ function reflectAttribute(element, name, value) {
|
|
|
22091
22091
|
if (element.hasAttribute(name) !== value) element.toggleAttribute(name, value);
|
|
22092
22092
|
return;
|
|
22093
22093
|
}
|
|
22094
|
-
const
|
|
22095
|
-
if (
|
|
22096
|
-
if (name === "locale" &&
|
|
22094
|
+
const current3 = element.getAttribute(name);
|
|
22095
|
+
if (current3 === value) return;
|
|
22096
|
+
if (name === "locale" && current3 !== null && normalizeEditorLocale(current3) === value) return;
|
|
22097
22097
|
element.setAttribute(name, value);
|
|
22098
22098
|
}
|
|
22099
22099
|
|
|
@@ -22172,6 +22172,8 @@ var EMPTY_WORD_CUSTOMIZATION = resolveWordCustomization();
|
|
|
22172
22172
|
var ViewOptions = class {
|
|
22173
22173
|
showThumbnails = false;
|
|
22174
22174
|
showToolbar = true;
|
|
22175
|
+
/** The host's Read Aloud options (`readAloud`); none keeps the defaults. */
|
|
22176
|
+
readAloud = null;
|
|
22175
22177
|
hiddenActions = [];
|
|
22176
22178
|
/** The host's `customization` object, as given. */
|
|
22177
22179
|
customizationInput = null;
|
|
@@ -22194,6 +22196,124 @@ function applyViewOptions(core) {
|
|
|
22194
22196
|
);
|
|
22195
22197
|
}
|
|
22196
22198
|
|
|
22199
|
+
// src/docx/read-aloud.ts
|
|
22200
|
+
function readAloudAvailable() {
|
|
22201
|
+
return typeof speechSynthesis !== "undefined" && typeof SpeechSynthesisUtterance !== "undefined";
|
|
22202
|
+
}
|
|
22203
|
+
function textToRead(view) {
|
|
22204
|
+
const { doc, selection } = view.state;
|
|
22205
|
+
const from2 = selection.from;
|
|
22206
|
+
const to = selection.empty ? doc.content.size : selection.to;
|
|
22207
|
+
return doc.textBetween(from2, to, "\n", " ").trim();
|
|
22208
|
+
}
|
|
22209
|
+
var current2;
|
|
22210
|
+
var shared = {};
|
|
22211
|
+
function isReadingAloud(owner) {
|
|
22212
|
+
return current2 !== void 0 && (owner === void 0 || current2.owner === owner);
|
|
22213
|
+
}
|
|
22214
|
+
function stopReadAloud(owner = shared) {
|
|
22215
|
+
const playback = current2;
|
|
22216
|
+
if (!playback || playback.owner !== owner) return false;
|
|
22217
|
+
current2 = void 0;
|
|
22218
|
+
try {
|
|
22219
|
+
speechSynthesis.cancel();
|
|
22220
|
+
} catch {
|
|
22221
|
+
}
|
|
22222
|
+
playback.onChange(false);
|
|
22223
|
+
return true;
|
|
22224
|
+
}
|
|
22225
|
+
function startReadAloud(owner, text, onChange, onError) {
|
|
22226
|
+
if (!readAloudAvailable()) return "unsupported";
|
|
22227
|
+
if (!text) return "empty";
|
|
22228
|
+
if (current2) stopReadAloud(current2.owner);
|
|
22229
|
+
const utterance = new SpeechSynthesisUtterance(text);
|
|
22230
|
+
const playback = { owner, onChange };
|
|
22231
|
+
const finish = (failure) => {
|
|
22232
|
+
if (current2 !== playback) return;
|
|
22233
|
+
current2 = void 0;
|
|
22234
|
+
onChange(false);
|
|
22235
|
+
const reason = failure?.error;
|
|
22236
|
+
if (failure && reason !== "canceled" && reason !== "interrupted") onError?.("error");
|
|
22237
|
+
};
|
|
22238
|
+
utterance.addEventListener("end", () => finish(void 0));
|
|
22239
|
+
utterance.addEventListener("error", (event) => finish(event ?? {}));
|
|
22240
|
+
current2 = playback;
|
|
22241
|
+
try {
|
|
22242
|
+
speechSynthesis.speak(utterance);
|
|
22243
|
+
} catch {
|
|
22244
|
+
current2 = void 0;
|
|
22245
|
+
onError?.("error");
|
|
22246
|
+
return "error";
|
|
22247
|
+
}
|
|
22248
|
+
onChange(true);
|
|
22249
|
+
return "started";
|
|
22250
|
+
}
|
|
22251
|
+
|
|
22252
|
+
// src/docx/read-aloud-session.ts
|
|
22253
|
+
var ReadAloudSession = class {
|
|
22254
|
+
constructor(core) {
|
|
22255
|
+
this.core = core;
|
|
22256
|
+
}
|
|
22257
|
+
core;
|
|
22258
|
+
lastIssue = null;
|
|
22259
|
+
get playing() {
|
|
22260
|
+
return isReadingAloud(this);
|
|
22261
|
+
}
|
|
22262
|
+
/** The last problem, or `unsupported` while the browser has no speech synthesis. */
|
|
22263
|
+
get issue() {
|
|
22264
|
+
return this.lastIssue ?? (readAloudAvailable() ? null : "unsupported");
|
|
22265
|
+
}
|
|
22266
|
+
/** True when a request can play now: speech exists and a document is on screen. */
|
|
22267
|
+
get available() {
|
|
22268
|
+
return readAloudAvailable() && Boolean(this.core.targetView()) && !this.core.loading;
|
|
22269
|
+
}
|
|
22270
|
+
/** Reads the selection, or the caret to the end, restarting if it is already reading. */
|
|
22271
|
+
start() {
|
|
22272
|
+
const view = this.core.targetView();
|
|
22273
|
+
stopReadAloud(this);
|
|
22274
|
+
const result = !view || this.core.loading ? "empty" : startReadAloud(
|
|
22275
|
+
this,
|
|
22276
|
+
textToRead(view),
|
|
22277
|
+
() => this.changed(),
|
|
22278
|
+
(issue) => this.report(issue)
|
|
22279
|
+
);
|
|
22280
|
+
this.lastIssue = result === "started" ? null : result;
|
|
22281
|
+
this.changed();
|
|
22282
|
+
return result;
|
|
22283
|
+
}
|
|
22284
|
+
/** Stops this editor's playback and clears its problem. Returns whether it was playing. */
|
|
22285
|
+
stop() {
|
|
22286
|
+
const was = stopReadAloud(this);
|
|
22287
|
+
if (this.lastIssue !== null) {
|
|
22288
|
+
this.lastIssue = null;
|
|
22289
|
+
this.changed();
|
|
22290
|
+
}
|
|
22291
|
+
return was;
|
|
22292
|
+
}
|
|
22293
|
+
/** The document was edited: stops only when the host chose `readAloud.stopOnEdit`. */
|
|
22294
|
+
documentEdited() {
|
|
22295
|
+
if (this.core.viewOptions.readAloud?.stopOnEdit === true) this.stop();
|
|
22296
|
+
}
|
|
22297
|
+
/** Starts, or stops when already playing. Returns whether it is playing now. */
|
|
22298
|
+
toggle() {
|
|
22299
|
+
if (this.stop()) return false;
|
|
22300
|
+
return this.start() === "started";
|
|
22301
|
+
}
|
|
22302
|
+
report(issue) {
|
|
22303
|
+
this.lastIssue = issue;
|
|
22304
|
+
this.changed();
|
|
22305
|
+
}
|
|
22306
|
+
changed() {
|
|
22307
|
+
const { toolbar } = this.core.shell;
|
|
22308
|
+
if (toolbar)
|
|
22309
|
+
findLocalizedControl(toolbar, "Read aloud")?.setAttribute(
|
|
22310
|
+
"aria-pressed",
|
|
22311
|
+
String(this.playing)
|
|
22312
|
+
);
|
|
22313
|
+
this.core.element.dispatchEvent(new CustomEvent("editor-state-change"));
|
|
22314
|
+
}
|
|
22315
|
+
};
|
|
22316
|
+
|
|
22197
22317
|
// src/docx/font-downloads.ts
|
|
22198
22318
|
var FONT_DOWNLOADS_KEY = "ooxml.docx.allowFontDownloads";
|
|
22199
22319
|
var memory;
|
|
@@ -22507,6 +22627,8 @@ var EditorCore = class {
|
|
|
22507
22627
|
parts;
|
|
22508
22628
|
pages;
|
|
22509
22629
|
viewOptions = new ViewOptions();
|
|
22630
|
+
/** This editor's Read Aloud playback; the browser's one voice is shared with other editors. */
|
|
22631
|
+
readAloud = new ReadAloudSession(this);
|
|
22510
22632
|
/** The `googleFonts` option and this editor's webfont `<link>`. */
|
|
22511
22633
|
webfonts = new DocxWebfonts();
|
|
22512
22634
|
dirtyState;
|
|
@@ -22580,6 +22702,7 @@ var EditorCore = class {
|
|
|
22580
22702
|
) : assignMissingParagraphIds(applied);
|
|
22581
22703
|
view.updateState(repaired ? applied.apply(repaired) : applied);
|
|
22582
22704
|
if (docChanged) {
|
|
22705
|
+
this.readAloud.documentEdited();
|
|
22583
22706
|
this.model = docToModel(view.state.doc, this.model, previousDoc);
|
|
22584
22707
|
if (previousComments !== view.state.doc.attrs.commentThreads)
|
|
22585
22708
|
this.shell.review?.commentsPanel.refresh();
|
|
@@ -25363,12 +25486,12 @@ function attachPrintFloatSelection(host) {
|
|
|
25363
25486
|
function commit(located, box2, origin) {
|
|
25364
25487
|
const view = host.view();
|
|
25365
25488
|
if (!view || view.isDestroyed || !view.editable) return;
|
|
25366
|
-
const
|
|
25367
|
-
if (!
|
|
25368
|
-
if (isShapeFloat(
|
|
25369
|
-
const placement = placementAt(parsePlacement(
|
|
25489
|
+
const current3 = view.state.doc.nodeAt(located.pos);
|
|
25490
|
+
if (!current3 || !isFloat(current3)) return;
|
|
25491
|
+
if (isShapeFloat(current3) && !shapeSpecOf(current3)?.editable) return;
|
|
25492
|
+
const placement = placementAt(parsePlacement(current3.attrs.placement), box2, origin);
|
|
25370
25493
|
const tr = view.state.tr.setNodeMarkup(located.pos, void 0, {
|
|
25371
|
-
...
|
|
25494
|
+
...current3.attrs,
|
|
25372
25495
|
widthPx: Math.round(box2.width),
|
|
25373
25496
|
heightPx: Math.round(box2.height),
|
|
25374
25497
|
placement: JSON.stringify(placement)
|
|
@@ -25382,8 +25505,8 @@ function attachPrintFloatSelection(host) {
|
|
|
25382
25505
|
if (!view || !blockId) return void 0;
|
|
25383
25506
|
const located = locateFloat(view.state.doc, blockId, Number(element.dataset.floatIndex));
|
|
25384
25507
|
if (!located) return void 0;
|
|
25385
|
-
const
|
|
25386
|
-
if (
|
|
25508
|
+
const current3 = selectedFloat(view.state);
|
|
25509
|
+
if (current3?.pos !== located.pos)
|
|
25387
25510
|
view.dispatch(view.state.tr.setSelection(NodeSelection.create(view.state.doc, located.pos)));
|
|
25388
25511
|
view.focus();
|
|
25389
25512
|
return located;
|
|
@@ -26345,9 +26468,9 @@ var BOOLEAN_KEYS = [
|
|
|
26345
26468
|
"allowFontDownloads"
|
|
26346
26469
|
];
|
|
26347
26470
|
var KEYS = ["locale", "theme", "author", ...BOOLEAN_KEYS];
|
|
26348
|
-
function wordCategories(context2,
|
|
26471
|
+
function wordCategories(context2, current3) {
|
|
26349
26472
|
const { t } = context2;
|
|
26350
|
-
const toggle = (key3, label2) =>
|
|
26473
|
+
const toggle = (key3, label2) => current3[key3] === void 0 ? [] : [{ kind: "toggle", key: key3, label: t(label2) }];
|
|
26351
26474
|
const display = [
|
|
26352
26475
|
{
|
|
26353
26476
|
id: "page",
|
|
@@ -26432,20 +26555,20 @@ function wordCategories(context2, current2) {
|
|
|
26432
26555
|
},
|
|
26433
26556
|
unavailableCategory(context2, "qat"),
|
|
26434
26557
|
unavailableCategory(context2, "addins"),
|
|
26435
|
-
|
|
26558
|
+
current3.allowFontDownloads === void 0 ? unavailableCategory(context2, "trust") : trustCategory(
|
|
26436
26559
|
context2,
|
|
26437
|
-
|
|
26560
|
+
current3.fontDownloadsLocked ? current3.allowFontDownloads : void 0
|
|
26438
26561
|
)
|
|
26439
26562
|
];
|
|
26440
26563
|
}
|
|
26441
|
-
function dialogValues(
|
|
26564
|
+
function dialogValues(current3) {
|
|
26442
26565
|
const values2 = {
|
|
26443
|
-
locale:
|
|
26444
|
-
theme:
|
|
26445
|
-
author:
|
|
26566
|
+
locale: current3.locale,
|
|
26567
|
+
theme: current3.theme === "light" || current3.theme === "dark" ? current3.theme : "auto",
|
|
26568
|
+
author: current3.author
|
|
26446
26569
|
};
|
|
26447
26570
|
for (const key3 of BOOLEAN_KEYS) {
|
|
26448
|
-
const value =
|
|
26571
|
+
const value = current3[key3];
|
|
26449
26572
|
if (value !== void 0) values2[key3] = value;
|
|
26450
26573
|
}
|
|
26451
26574
|
return values2;
|
|
@@ -26461,16 +26584,16 @@ function createWordOptions(handlers, t) {
|
|
|
26461
26584
|
const context2 = { product: "Word", t };
|
|
26462
26585
|
let hiddenOnOpen = [];
|
|
26463
26586
|
const build2 = () => {
|
|
26464
|
-
const
|
|
26587
|
+
const current3 = handlers.options();
|
|
26465
26588
|
element.setAttribute("heading", t("Options"));
|
|
26466
26589
|
element.labels = optionsLabels(context2);
|
|
26467
|
-
element.categories = wordCategories(context2,
|
|
26468
|
-
element.values = dialogValues(
|
|
26590
|
+
element.categories = wordCategories(context2, current3);
|
|
26591
|
+
element.values = dialogValues(current3);
|
|
26469
26592
|
element.defaults = {
|
|
26470
26593
|
theme: "auto",
|
|
26471
26594
|
...Object.fromEntries(
|
|
26472
26595
|
BOOLEAN_KEYS.filter(
|
|
26473
|
-
(key3) =>
|
|
26596
|
+
(key3) => current3[key3] !== void 0 && !(key3 === "allowFontDownloads" && current3.fontDownloadsLocked)
|
|
26474
26597
|
).map((key3) => [key3, key3 === "spellCheck"])
|
|
26475
26598
|
)
|
|
26476
26599
|
};
|
|
@@ -26544,10 +26667,10 @@ function createBackstage(handlers) {
|
|
|
26544
26667
|
label: "[docx-editor]"
|
|
26545
26668
|
});
|
|
26546
26669
|
const hidden = (id) => id === "account" && !handlers.fileProviders().length || handlers.customization().backstagePages.has(id);
|
|
26547
|
-
let
|
|
26670
|
+
let current3 = "info";
|
|
26548
26671
|
const options = createWordOptions(handlers, t);
|
|
26549
26672
|
const draw = (page2) => {
|
|
26550
|
-
|
|
26673
|
+
current3 = page2;
|
|
26551
26674
|
RENDERERS[page2]({ handlers, t, content: pages.get(page2) });
|
|
26552
26675
|
};
|
|
26553
26676
|
const showOptions = (category) => {
|
|
@@ -26612,7 +26735,7 @@ function createBackstage(handlers) {
|
|
|
26612
26735
|
relocalize() {
|
|
26613
26736
|
localize();
|
|
26614
26737
|
options.relocalize();
|
|
26615
|
-
if (element.open) draw(
|
|
26738
|
+
if (element.open) draw(current3);
|
|
26616
26739
|
},
|
|
26617
26740
|
refresh() {
|
|
26618
26741
|
localize();
|
|
@@ -26739,6 +26862,7 @@ function createTitleBar(handlers) {
|
|
|
26739
26862
|
defineTitleBar();
|
|
26740
26863
|
const element = document.createElement("office-ui-title-bar");
|
|
26741
26864
|
element.className = "dve-titlebar";
|
|
26865
|
+
element.setAttribute("part", "title-bar");
|
|
26742
26866
|
const model = {
|
|
26743
26867
|
fileName: "",
|
|
26744
26868
|
saveState: "saved",
|
|
@@ -27453,40 +27577,6 @@ function setHeadingLevel(view, model, level) {
|
|
|
27453
27577
|
view.dispatch(closeHistory(tr));
|
|
27454
27578
|
return true;
|
|
27455
27579
|
}
|
|
27456
|
-
|
|
27457
|
-
// src/docx/read-aloud.ts
|
|
27458
|
-
function readAloudAvailable() {
|
|
27459
|
-
return typeof speechSynthesis !== "undefined" && typeof SpeechSynthesisUtterance !== "undefined";
|
|
27460
|
-
}
|
|
27461
|
-
function textToRead(view) {
|
|
27462
|
-
const { doc, selection } = view.state;
|
|
27463
|
-
const from2 = selection.from;
|
|
27464
|
-
const to = selection.empty ? doc.content.size : selection.to;
|
|
27465
|
-
return doc.textBetween(from2, to, "\n", " ").trim();
|
|
27466
|
-
}
|
|
27467
|
-
var speaking = false;
|
|
27468
|
-
function toggleReadAloud(text, onChange) {
|
|
27469
|
-
if (!readAloudAvailable()) return false;
|
|
27470
|
-
if (speaking) {
|
|
27471
|
-
speechSynthesis.cancel();
|
|
27472
|
-
speaking = false;
|
|
27473
|
-
onChange(false);
|
|
27474
|
-
return false;
|
|
27475
|
-
}
|
|
27476
|
-
if (!text) return false;
|
|
27477
|
-
const utterance = new SpeechSynthesisUtterance(text);
|
|
27478
|
-
const finish = () => {
|
|
27479
|
-
if (!speaking) return;
|
|
27480
|
-
speaking = false;
|
|
27481
|
-
onChange(false);
|
|
27482
|
-
};
|
|
27483
|
-
utterance.addEventListener("end", finish);
|
|
27484
|
-
utterance.addEventListener("error", finish);
|
|
27485
|
-
speaking = true;
|
|
27486
|
-
speechSynthesis.speak(utterance);
|
|
27487
|
-
onChange(true);
|
|
27488
|
-
return true;
|
|
27489
|
-
}
|
|
27490
27580
|
function documentCounts(view, language) {
|
|
27491
27581
|
const { from: from2, to, empty } = view.state.selection;
|
|
27492
27582
|
const text = empty ? view.state.doc.textBetween(0, view.state.doc.content.size, "\n", " ") : view.state.doc.textBetween(from2, to, "\n", " ");
|
|
@@ -27730,16 +27820,9 @@ function routeRibbonAction(core, action) {
|
|
|
27730
27820
|
emit(core.element, "document-warning", "This document has no heading styles to apply.");
|
|
27731
27821
|
focusView(target);
|
|
27732
27822
|
} else if (action.type === "readAloud" && target) {
|
|
27733
|
-
const button3 = () => shell.toolbar?.querySelector(
|
|
27734
|
-
'[aria-label="Read aloud"], [data-localearialabel="Read aloud"]'
|
|
27735
|
-
);
|
|
27736
27823
|
if (!readAloudAvailable())
|
|
27737
27824
|
emit(core.element, "document-warning", "This browser cannot read text aloud.");
|
|
27738
|
-
else
|
|
27739
|
-
toggleReadAloud(
|
|
27740
|
-
textToRead(target),
|
|
27741
|
-
(on2) => button3()?.setAttribute("aria-pressed", String(on2))
|
|
27742
|
-
);
|
|
27825
|
+
else core.readAloud.toggle();
|
|
27743
27826
|
} else if (action.type === "zoomFit") pages.zoomTo(action.mode);
|
|
27744
27827
|
else if (action.type === "wordCount") {
|
|
27745
27828
|
const anchor = shell.toolbar?.querySelector(
|
|
@@ -28528,10 +28611,10 @@ function createContextMenu(host) {
|
|
|
28528
28611
|
return;
|
|
28529
28612
|
}
|
|
28530
28613
|
const item = items.find((candidate) => candidate.id === id);
|
|
28531
|
-
const
|
|
28532
|
-
if (!item || !
|
|
28614
|
+
const current3 = host.view();
|
|
28615
|
+
if (!item || !current3) return;
|
|
28533
28616
|
close3();
|
|
28534
|
-
void execute(item,
|
|
28617
|
+
void execute(item, current3);
|
|
28535
28618
|
});
|
|
28536
28619
|
element.addEventListener(
|
|
28537
28620
|
"office-menu-close",
|
|
@@ -28843,7 +28926,7 @@ function createChartFormatPane(host) {
|
|
|
28843
28926
|
try {
|
|
28844
28927
|
editSelectedChart(
|
|
28845
28928
|
view,
|
|
28846
|
-
(chart) => chart.chartExSpace ? editDocxChartEx(chart, (
|
|
28929
|
+
(chart) => chart.chartExSpace ? editDocxChartEx(chart, (current3) => applyChartExEditIntent(current3, intent)) : editDocxChart(chart, (current3) => applyChartEditIntent(current3, intent))
|
|
28847
28930
|
);
|
|
28848
28931
|
} catch {
|
|
28849
28932
|
}
|
|
@@ -28939,8 +29022,8 @@ function createChrome(core, api) {
|
|
|
28939
29022
|
} else if (key3 === "showThumbnails")
|
|
28940
29023
|
element.toggleAttribute("show-thumbnails", value === "true");
|
|
28941
29024
|
else if (key3 === "showRuler" || key3 === "showMarks") {
|
|
28942
|
-
const
|
|
28943
|
-
if (
|
|
29025
|
+
const current3 = key3 === "showRuler" ? Boolean(shell.canvas?.querySelector(".dve-ruler")) : shell.paper?.hasAttribute("data-show-marks") ?? false;
|
|
29026
|
+
if (current3 !== (value === "true"))
|
|
28944
29027
|
core.inserts.handle({ type: key3 === "showRuler" ? "ruler" : "showMarks" });
|
|
28945
29028
|
} else element.setAttribute(key3 === "author" ? "review-author" : key3, value);
|
|
28946
29029
|
},
|
|
@@ -29217,6 +29300,26 @@ function wordHostActionProps(core) {
|
|
|
29217
29300
|
};
|
|
29218
29301
|
}
|
|
29219
29302
|
|
|
29303
|
+
// src/docx/building-blocks-read-aloud.ts
|
|
29304
|
+
function wordReadAloudProps(core) {
|
|
29305
|
+
const session = core.readAloud;
|
|
29306
|
+
return {
|
|
29307
|
+
/** A document is on screen and the browser can speak. */
|
|
29308
|
+
canReadAloud: session.available,
|
|
29309
|
+
/** This editor is reading now. Another editor reading leaves it false. */
|
|
29310
|
+
readingAloud: session.playing,
|
|
29311
|
+
/**
|
|
29312
|
+
* Why Read Aloud is not or no longer playing: `unsupported` (no speech synthesis),
|
|
29313
|
+
* `empty` (nothing to read) or `error` (the voice failed). Null otherwise. The host words it.
|
|
29314
|
+
*/
|
|
29315
|
+
readAloudIssue: session.issue,
|
|
29316
|
+
/** Starts reading, taking the voice over from another editor. Says why nothing started. */
|
|
29317
|
+
onReadAloud: () => core.readAloud.start(),
|
|
29318
|
+
/** Stops this editor's playback. Returns whether it was playing. */
|
|
29319
|
+
onStopReadAloud: () => core.readAloud.stop()
|
|
29320
|
+
};
|
|
29321
|
+
}
|
|
29322
|
+
|
|
29220
29323
|
// src/docx/building-blocks.ts
|
|
29221
29324
|
var ALIGNMENTS2 = {
|
|
29222
29325
|
left: "left",
|
|
@@ -29243,7 +29346,8 @@ var TOOLBAR_LABELS = [
|
|
|
29243
29346
|
"Numbered list",
|
|
29244
29347
|
"Insert link",
|
|
29245
29348
|
"Find",
|
|
29246
|
-
"Insert picture"
|
|
29349
|
+
"Insert picture",
|
|
29350
|
+
"Read aloud"
|
|
29247
29351
|
];
|
|
29248
29352
|
function listState(kind) {
|
|
29249
29353
|
return kind === "decimal" ? "number" : kind;
|
|
@@ -29289,7 +29393,7 @@ function wordToolbarProps(core) {
|
|
|
29289
29393
|
core.refreshControls();
|
|
29290
29394
|
return true;
|
|
29291
29395
|
};
|
|
29292
|
-
const
|
|
29396
|
+
const shared2 = state && wordYjsPluginKey.getState(state);
|
|
29293
29397
|
return {
|
|
29294
29398
|
labels: Object.fromEntries(
|
|
29295
29399
|
TOOLBAR_LABELS.map((label2) => [label2, translate(core.locale, label2)])
|
|
@@ -29305,8 +29409,8 @@ function wordToolbarProps(core) {
|
|
|
29305
29409
|
fontFamily: value("fontFamily", "Calibri"),
|
|
29306
29410
|
fontSize: value("fontSize", 11),
|
|
29307
29411
|
alignment: value("alignment", "left"),
|
|
29308
|
-
canUndo: Boolean(canEdit && state && (
|
|
29309
|
-
canRedo: Boolean(canEdit && state && (
|
|
29412
|
+
canUndo: Boolean(canEdit && state && (shared2 ? wordYjsUndo : undo)(state)),
|
|
29413
|
+
canRedo: Boolean(canEdit && state && (shared2 ? wordYjsRedo : redo)(state)),
|
|
29310
29414
|
onBold: () => run({ type: "format", key: "bold" }),
|
|
29311
29415
|
onItalic: () => run({ type: "format", key: "italic" }),
|
|
29312
29416
|
onUnderline: () => run({ type: "format", key: "underline" }),
|
|
@@ -29316,7 +29420,8 @@ function wordToolbarProps(core) {
|
|
|
29316
29420
|
onListChange: (kind) => run({ type: "list", key: kind }),
|
|
29317
29421
|
onUndo: () => run({ type: "history", key: "undo" }),
|
|
29318
29422
|
onRedo: () => run({ type: "history", key: "redo" }),
|
|
29319
|
-
...wordHostActionProps(core)
|
|
29423
|
+
...wordHostActionProps(core),
|
|
29424
|
+
...wordReadAloudProps(core)
|
|
29320
29425
|
};
|
|
29321
29426
|
}
|
|
29322
29427
|
var ZOOM_STEP = 10;
|
|
@@ -29450,8 +29555,8 @@ var DocxEditorApi = class extends HTMLElementBase {
|
|
|
29450
29555
|
}
|
|
29451
29556
|
set fileProviders(value) {
|
|
29452
29557
|
const next = value ?? [];
|
|
29453
|
-
const
|
|
29454
|
-
if (next.length ===
|
|
29558
|
+
const current3 = this.core.fileProviders;
|
|
29559
|
+
if (next.length === current3.length && next.every((p, i) => p === current3[i])) return;
|
|
29455
29560
|
this.core.fileProviders = [...next];
|
|
29456
29561
|
this.core.shell.chrome?.backstage.relocalize();
|
|
29457
29562
|
}
|
|
@@ -29531,6 +29636,16 @@ var DocxEditorApi = class extends HTMLElementBase {
|
|
|
29531
29636
|
}
|
|
29532
29637
|
reflectAttribute(this, "show-thumbnails", this.showThumbnails);
|
|
29533
29638
|
}
|
|
29639
|
+
/**
|
|
29640
|
+
* Read Aloud options. `stopOnEdit` (default false) also stops playback when the document is
|
|
29641
|
+
* edited; replacing or reloading the document and unmounting always stop it.
|
|
29642
|
+
*/
|
|
29643
|
+
get readAloud() {
|
|
29644
|
+
return this.core.viewOptions.readAloud;
|
|
29645
|
+
}
|
|
29646
|
+
set readAloud(value) {
|
|
29647
|
+
this.core.viewOptions.readAloud = value ? { ...value } : null;
|
|
29648
|
+
}
|
|
29534
29649
|
/**
|
|
29535
29650
|
* Tabs a host adds after Word's own, as an Office add-in does. Each command runs its `run`
|
|
29536
29651
|
* callback and dispatches `office-ribbon-add-in` (`{ tab, command }`) from the editor.
|
|
@@ -29570,8 +29685,8 @@ var DocxEditorApi = class extends HTMLElementBase {
|
|
|
29570
29685
|
"document-warning",
|
|
29571
29686
|
`hiddenActions: English labels (${legacy.map((label2) => `'${label2}'`).join(", ")}) are deprecated and will be removed in the next release; use the stable ids from RIBBON_ACTION_IDS.`
|
|
29572
29687
|
);
|
|
29573
|
-
const
|
|
29574
|
-
if (next.length ===
|
|
29688
|
+
const current3 = this.core.viewOptions.hiddenActions;
|
|
29689
|
+
if (next.length === current3.length && next.every((id, index) => id === current3[index])) return;
|
|
29575
29690
|
this.core.viewOptions.hiddenActions = next;
|
|
29576
29691
|
applyViewOptions(this.core);
|
|
29577
29692
|
}
|
|
@@ -29768,6 +29883,7 @@ var DocxEditorElement = class extends DocxEditorApi {
|
|
|
29768
29883
|
}
|
|
29769
29884
|
disconnectedCallback() {
|
|
29770
29885
|
const { core } = this;
|
|
29886
|
+
core.readAloud.stop();
|
|
29771
29887
|
core.shell.surfaceNavigation?.();
|
|
29772
29888
|
delete core.shell.surfaceNavigation;
|
|
29773
29889
|
core.shell.printStoryEditing?.();
|
|
@@ -29789,6 +29905,7 @@ var DocxEditorElement = class extends DocxEditorApi {
|
|
|
29789
29905
|
this.assertDocumentReplaceable();
|
|
29790
29906
|
const generation = ++core.loadGeneration;
|
|
29791
29907
|
core.loading = true;
|
|
29908
|
+
core.readAloud.stop();
|
|
29792
29909
|
core.refreshControls();
|
|
29793
29910
|
try {
|
|
29794
29911
|
core.webfonts.prefetch(this.ownerDocument, input);
|
|
@@ -29858,6 +29975,7 @@ var DocxEditorElement = class extends DocxEditorApi {
|
|
|
29858
29975
|
/** Swaps in a new model (and the session that produced it) and invalidates in-flight loads. */
|
|
29859
29976
|
replaceDocument(model, session, bumpGeneration = true) {
|
|
29860
29977
|
const { core } = this;
|
|
29978
|
+
core.readAloud.stop();
|
|
29861
29979
|
core.detachedState = void 0;
|
|
29862
29980
|
if (bumpGeneration) core.loadGeneration++;
|
|
29863
29981
|
if (bumpGeneration) core.loading = false;
|