@a3s-lab/office 0.1.0 → 0.2.2
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 +101 -24
- package/dist/0~2582.js +485 -0
- package/dist/0~4595.js +14 -7
- package/dist/0~4750.js +939 -0
- package/dist/{0~work-document-paragraph-formatting.js → 0~5861.js} +174 -3
- package/dist/0~7048.js +8 -6
- package/dist/0~9512.js +7 -4
- package/dist/0~document-editor.js +3147 -531
- package/dist/0~markdown-editor.js +26 -1
- package/dist/0~presentation-editor.js +68 -12
- package/dist/0~spreadsheet-editor.js +37 -17
- package/dist/0~work-document-extensions.js +588 -13
- package/dist/0~work-document-model-codec.js +1 -1
- package/dist/0~work-docx-bibliography.js +1 -1
- package/dist/0~work-docx-export.js +116 -55
- package/dist/0~work-docx-import.js +766 -107
- package/dist/0~work-office-diagnostics.js +2 -2
- package/dist/{4704.js → 2881.js} +162 -71
- package/dist/4104.js +2 -62
- package/dist/internal/features/work/editors/document-comment-window.d.ts +37 -0
- package/dist/internal/features/work/editors/document-navigation-panel.d.ts +3 -1
- package/dist/internal/features/work/editors/document-navigation-window.d.ts +64 -0
- package/dist/internal/features/work/editors/document-outline-navigation.d.ts +11 -0
- package/dist/internal/features/work/editors/document-page-navigation.d.ts +11 -1
- package/dist/internal/features/work/editors/document-page-thumbnail.d.ts +31 -0
- package/dist/internal/features/work/editors/document-picture-properties-dialog-model.d.ts +28 -0
- package/dist/internal/features/work/editors/document-picture-properties-dialog.d.ts +4 -0
- package/dist/internal/features/work/editors/document-search-navigation.d.ts +12 -0
- package/dist/internal/features/work/editors/document-table-margins-popover.d.ts +4 -0
- package/dist/internal/features/work/editors/document-table-properties-dialog-model.d.ts +51 -0
- package/dist/internal/features/work/editors/document-table-properties-dialog-sections.d.ts +19 -0
- package/dist/internal/features/work/editors/document-table-properties-dialog.d.ts +8 -0
- package/dist/internal/features/work/editors/office-task-pane.d.ts +1 -1
- package/dist/internal/features/work/editors/presentation-chart-panel.d.ts +2 -1
- package/dist/internal/features/work/editors/presentation-comments-panel.d.ts +2 -1
- package/dist/internal/features/work/editors/spreadsheet-workbook-panel.d.ts +2 -1
- package/dist/internal/features/work/editors/use-document-pagination.d.ts +6 -0
- package/dist/internal/features/work/editors/use-presentation-review-commands.d.ts +1 -1
- package/dist/internal/features/work/work-document-image-layout.d.ts +11 -0
- package/dist/internal/features/work/work-document-page-capture.d.ts +15 -0
- package/dist/internal/features/work/work-document-paragraph-formatting.d.ts +4 -0
- package/dist/internal/features/work/work-document-section.d.ts +3 -1
- package/dist/internal/features/work/work-document-table-borders.d.ts +20 -0
- package/dist/internal/features/work/work-document-table-cell-formatting.d.ts +8 -5
- package/dist/internal/features/work/work-document-table-geometry.d.ts +41 -0
- package/dist/internal/features/work/work-document-table-property-changes.d.ts +25 -0
- package/dist/internal/features/work/work-document-table-sizing.d.ts +15 -2
- package/dist/internal/features/work/work-document-word-line-metrics.d.ts +11 -0
- package/dist/internal/features/work/work-docx-document-layout.d.ts +2 -0
- package/dist/internal/features/work/work-docx-paragraph-alignment-import.d.ts +2 -1
- package/dist/internal/features/work/work-docx-paragraph-direction-import.d.ts +2 -1
- package/dist/internal/features/work/work-docx-paragraph-indent-import.d.ts +2 -1
- package/dist/internal/features/work/work-docx-paragraph-pagination-import.d.ts +2 -1
- package/dist/internal/features/work/work-docx-paragraph-spacing-import.d.ts +3 -2
- package/dist/internal/features/work/work-docx-paragraph-styles.d.ts +2 -2
- package/dist/internal/features/work/work-docx-run-formatting-import.d.ts +8 -1
- package/dist/internal/features/work/work-docx-tab-stop-import.d.ts +2 -1
- package/dist/internal/features/work/work-docx-table-cell-export.d.ts +1 -1
- package/dist/internal/features/work/work-docx-table-cell-import.d.ts +14 -4
- package/dist/internal/features/work/work-docx-table-sizing-export.d.ts +1 -1
- package/dist/internal/features/work/work-docx-table-sizing-import.d.ts +4 -3
- package/dist/internal/features/work/work-docx-table-styles.d.ts +22 -0
- package/dist/internal/features/work/work-types.d.ts +6 -0
- package/dist/office-kernel.wasm +0 -0
- package/dist/styles.css +1288 -233
- package/docs/{browser-editor-architecture.md → latest/en/browser-editor-architecture.md} +144 -35
- package/package.json +9 -5
- package/dist/0~6552.js +0 -787
- package/dist/0~8155.js +0 -299
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { docxCaptionSequenceKind, docxFieldOccurrences, docxCaptionBookmark, docxCaptionReferenceTarget, docxFieldInstructions } from "./0~152.js";
|
|
2
|
-
import { documentCitationTagsFromInstruction, docxDocumentFieldKind } from "./
|
|
2
|
+
import { documentCitationTagsFromInstruction, docxDocumentFieldKind } from "./2881.js";
|
|
3
3
|
import { contentTypeForPart, directChildren, formulaHasStructuredReference, OoxmlPackage, formulaHasExternalReference, firstDescendant, parseSpreadsheetPrintTitles, stripSpreadsheetSheetQualifier, descendants, directChild, attribute, volatileSpreadsheetFormulaFunctions } from "./8715.js";
|
|
4
4
|
import { readDocxBibliography } from "./0~work-docx-bibliography.js";
|
|
5
5
|
import { isSupportedXlsxCombinationChartNodes, MAX_XLSX_WORKSHEET_IMAGE_BYTES, inspectXlsxPivotTables, isSupportedXlsxWorksheetImageContentType, isSupportedXlsxChartLegend, isSupportedXlsxChartPlotLayout, xlsxChartNodeUsesStackedGrouping, isSupportedXlsxChartSeriesFormatting, readXlsxFormulaFeaturesFromPackage, inspectXlsxHeaderFooterText, isEditableXlsxPaperSizeCode, diagnoseXlsxProtection, xlsxChartSeriesFormattingShapeProperties } from "./4104.js";
|
|
@@ -1190,7 +1190,7 @@ async function analyzeDocxCompatibility(file, messages) {
|
|
|
1190
1190
|
issues.push(...await diagnoseDocxCitations(archive, document));
|
|
1191
1191
|
const captionDiagnostics = diagnoseDocxCaptions(document);
|
|
1192
1192
|
issues.push(...captionDiagnostics.issues);
|
|
1193
|
-
if (descendants(document, 'tbl').length) issues.push(work_office_diagnostics_issue('docx.tables', 'Tables', 'Table rows, non-splitting rows, repeated headers,
|
|
1193
|
+
if (descendants(document, 'tbl').length) issues.push(work_office_diagnostics_issue('docx.tables', 'Tables', 'Table rows, non-splitting rows, repeated headers, cell shading, vertical alignment, per-edge borders, and paragraph-boundary row continuation remain editable. Layout algorithm, preferred auto, percentage, or pixel width, alignment, indent, table-level cell margins, and cell-level margin overrides are preserved independently across edit, preview, and DOCX export. Common inherited Word table styles apply whole-table, banded row or column, first or last row or column, corner-cell, border, fill, text-emphasis, paragraph alignment, direction, indents, spacing, line, pagination, and tab-stop rules before direct table, cell, paragraph, and run formatting. Theme tint and shade values resolve to stable RGB for edit, preview, and export; less-common conditional paragraph properties, semantic theme references after export, nested tables, and complex merged-cell flow may be normalized.'));
|
|
1194
1194
|
if (descendants(document, 'drawing').length || descendants(document, 'pict').length) issues.push(work_office_diagnostics_issue('docx.images', 'Images', 'Inline images and supported square or top-and-bottom floating images remain embedded with editable size, alternative text, alignment, and wrap distance. Precise offsets, crop, contour wrapping, layering, and unsupported drawing types may be normalized.'));
|
|
1195
1195
|
const textRevisions = [
|
|
1196
1196
|
...descendants(document, 'ins'),
|
package/dist/{4704.js → 2881.js}
RENAMED
|
@@ -24,13 +24,13 @@ function validMargin(value, fallback) {
|
|
|
24
24
|
const CAPTION_SELECTOR = 'figcaption[data-document-caption]';
|
|
25
25
|
const REFERENCE_SELECTOR = 'span[data-document-cross-reference]';
|
|
26
26
|
function normalizeDocumentCaptionsHtml(source) {
|
|
27
|
-
const
|
|
28
|
-
const targets = normalizeCaptions(
|
|
29
|
-
normalizeReferences(
|
|
27
|
+
const document1 = new DOMParser().parseFromString(source, 'text/html');
|
|
28
|
+
const targets = normalizeCaptions(document1);
|
|
29
|
+
normalizeReferences(document1, new Map(targets.map((target)=>[
|
|
30
30
|
target.id,
|
|
31
31
|
target
|
|
32
32
|
])));
|
|
33
|
-
return
|
|
33
|
+
return document1.body.innerHTML;
|
|
34
34
|
}
|
|
35
35
|
function documentCaptionKind(value) {
|
|
36
36
|
return 'figure' === value || 'table' === value ? value : null;
|
|
@@ -41,13 +41,13 @@ function documentCaptionLabel(kind) {
|
|
|
41
41
|
function documentCaptionDisplay(kind, number) {
|
|
42
42
|
return `${documentCaptionLabel(kind)} ${positiveInteger(number)}`;
|
|
43
43
|
}
|
|
44
|
-
function normalizeCaptions(
|
|
44
|
+
function normalizeCaptions(document1) {
|
|
45
45
|
const counters = {
|
|
46
46
|
figure: 0,
|
|
47
47
|
table: 0
|
|
48
48
|
};
|
|
49
49
|
const usedIds = new Set();
|
|
50
|
-
return Array.from(
|
|
50
|
+
return Array.from(document1.body.querySelectorAll(CAPTION_SELECTOR)).map((element, index)=>{
|
|
51
51
|
const kind = documentCaptionKind(element.dataset.captionKind) ?? 'figure';
|
|
52
52
|
counters[kind] += 1;
|
|
53
53
|
const number = counters[kind];
|
|
@@ -72,8 +72,8 @@ function normalizeCaptions(document) {
|
|
|
72
72
|
};
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
|
-
function normalizeReferences(
|
|
76
|
-
for (const element of Array.from(
|
|
75
|
+
function normalizeReferences(document1, targets) {
|
|
76
|
+
for (const element of Array.from(document1.body.querySelectorAll(REFERENCE_SELECTOR))){
|
|
77
77
|
const id = element.dataset.referenceTargetId?.trim() ?? '';
|
|
78
78
|
const target = targets.get(id);
|
|
79
79
|
element.dataset.documentCrossReference = 'true';
|
|
@@ -211,14 +211,14 @@ function resolveDocumentCitation(tags, bibliography, instruction = '', cachedVal
|
|
|
211
211
|
};
|
|
212
212
|
}
|
|
213
213
|
function normalizeDocumentCitationsHtml(source, bibliography) {
|
|
214
|
-
const
|
|
214
|
+
const document1 = new DOMParser().parseFromString(source, 'text/html');
|
|
215
215
|
const usedIds = new Set();
|
|
216
|
-
for (const [index, element] of Array.from(
|
|
216
|
+
for (const [index, element] of Array.from(document1.body.querySelectorAll(CITATION_SELECTOR)).entries()){
|
|
217
217
|
const instruction = element.dataset.citationInstruction?.trim() ?? '';
|
|
218
218
|
const tags = documentCitationTags(element.dataset.citationTags);
|
|
219
219
|
const normalizedTags = tags.length ? tags : documentCitationTagsFromInstruction(instruction);
|
|
220
220
|
if (!normalizedTags.length) {
|
|
221
|
-
element.replaceWith(
|
|
221
|
+
element.replaceWith(document1.createTextNode(element.textContent ?? ''));
|
|
222
222
|
continue;
|
|
223
223
|
}
|
|
224
224
|
const cached = element.dataset.citationDisplay?.trim() || element.textContent?.trim() || '';
|
|
@@ -233,17 +233,17 @@ function normalizeDocumentCitationsHtml(source, bibliography) {
|
|
|
233
233
|
element.classList.add('work-document-citation');
|
|
234
234
|
element.textContent = resolved.text;
|
|
235
235
|
}
|
|
236
|
-
for (const [index, element] of Array.from(
|
|
236
|
+
for (const [index, element] of Array.from(document1.body.querySelectorAll(BIBLIOGRAPHY_SELECTOR)).entries()){
|
|
237
237
|
if (!bibliography) continue;
|
|
238
|
-
const replacement = createBibliographyElement(
|
|
238
|
+
const replacement = createBibliographyElement(document1, bibliography, element.dataset.bibliographyId || `document-bibliography-${index + 1}`);
|
|
239
239
|
element.replaceWith(replacement);
|
|
240
240
|
}
|
|
241
|
-
return
|
|
241
|
+
return document1.body.innerHTML;
|
|
242
242
|
}
|
|
243
243
|
function renderDocumentBibliographyHtml(bibliography, id = 'document-bibliography-1') {
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
return
|
|
244
|
+
const document1 = new DOMParser().parseFromString('', 'text/html');
|
|
245
|
+
document1.body.append(createBibliographyElement(document1, bibliography, id));
|
|
246
|
+
return document1.body.innerHTML;
|
|
247
247
|
}
|
|
248
248
|
function documentBibliographyEntry(source, bibliography, index) {
|
|
249
249
|
const people = primaryCitationContributor(source);
|
|
@@ -283,24 +283,24 @@ function documentBibliographyEntry(source, bibliography, index) {
|
|
|
283
283
|
function primaryCitationContributor(source) {
|
|
284
284
|
return source.contributors?.Author ?? Object.values(source.contributors ?? {})[0];
|
|
285
285
|
}
|
|
286
|
-
function createBibliographyElement(
|
|
287
|
-
const section =
|
|
286
|
+
function createBibliographyElement(document1, bibliography, id) {
|
|
287
|
+
const section = document1.createElement('section');
|
|
288
288
|
section.dataset.documentBibliography = 'true';
|
|
289
289
|
section.dataset.bibliographyId = id;
|
|
290
290
|
section.dataset.bibliographyStyle = bibliography.style;
|
|
291
291
|
section.className = 'work-document-bibliography';
|
|
292
|
-
const heading =
|
|
292
|
+
const heading = document1.createElement('h2');
|
|
293
293
|
heading.textContent = '参考文献';
|
|
294
294
|
section.append(heading);
|
|
295
295
|
if (!bibliography.sources.length) {
|
|
296
|
-
const empty =
|
|
296
|
+
const empty = document1.createElement('p');
|
|
297
297
|
empty.dataset.bibliographyEmpty = 'true';
|
|
298
298
|
empty.textContent = '尚无文献源';
|
|
299
299
|
section.append(empty);
|
|
300
300
|
return section;
|
|
301
301
|
}
|
|
302
302
|
bibliography.sources.forEach((source, index)=>{
|
|
303
|
-
const paragraph =
|
|
303
|
+
const paragraph = document1.createElement('p');
|
|
304
304
|
paragraph.dataset.bibliographyEntry = source.tag;
|
|
305
305
|
paragraph.textContent = documentBibliographyEntry(source, bibliography, index);
|
|
306
306
|
section.append(paragraph);
|
|
@@ -445,13 +445,13 @@ function documentFieldDisplay(kind, context, instruction = documentFieldInstruct
|
|
|
445
445
|
return display || cachedValue || documentFieldLabel(kind);
|
|
446
446
|
}
|
|
447
447
|
function normalizeDocumentFieldsHtml(source) {
|
|
448
|
-
const
|
|
448
|
+
const document1 = new DOMParser().parseFromString(source, 'text/html');
|
|
449
449
|
const usedIds = new Set();
|
|
450
|
-
for (const [index, element] of Array.from(
|
|
450
|
+
for (const [index, element] of Array.from(document1.body.querySelectorAll(FIELD_SELECTOR)).entries()){
|
|
451
451
|
const instruction = element.dataset.fieldInstruction?.trim() ?? '';
|
|
452
452
|
const kind = documentFieldKind(element.dataset.fieldKind) ?? docxDocumentFieldKind(instruction);
|
|
453
453
|
if (!kind) {
|
|
454
|
-
element.replaceWith(
|
|
454
|
+
element.replaceWith(document1.createTextNode(element.textContent ?? ''));
|
|
455
455
|
continue;
|
|
456
456
|
}
|
|
457
457
|
const display = element.dataset.fieldDisplay?.trim() || element.textContent?.trim() || documentFieldLabel(kind);
|
|
@@ -463,18 +463,18 @@ function normalizeDocumentFieldsHtml(source) {
|
|
|
463
463
|
element.classList.add('work-document-field');
|
|
464
464
|
element.textContent = display;
|
|
465
465
|
}
|
|
466
|
-
return
|
|
466
|
+
return document1.body.innerHTML;
|
|
467
467
|
}
|
|
468
468
|
function resolveDocumentFieldsHtml(source, context) {
|
|
469
|
-
const
|
|
470
|
-
for (const element of Array.from(
|
|
469
|
+
const document1 = new DOMParser().parseFromString(normalizeDocumentFieldsHtml(source), 'text/html');
|
|
470
|
+
for (const element of Array.from(document1.body.querySelectorAll(FIELD_SELECTOR))){
|
|
471
471
|
const kind = documentFieldKind(element.dataset.fieldKind);
|
|
472
472
|
if (!kind) continue;
|
|
473
473
|
const display = documentFieldDisplay(kind, context, element.dataset.fieldInstruction, element.dataset.fieldDisplay);
|
|
474
474
|
element.dataset.fieldDisplay = display;
|
|
475
475
|
element.textContent = display;
|
|
476
476
|
}
|
|
477
|
-
return
|
|
477
|
+
return document1.body.innerHTML;
|
|
478
478
|
}
|
|
479
479
|
function uniqueFieldId(source, index, usedIds) {
|
|
480
480
|
const candidate = source?.trim();
|
|
@@ -534,9 +534,9 @@ function validDate(value) {
|
|
|
534
534
|
const NOTE_REFERENCE_SELECTOR = 'sup[data-document-note-reference]';
|
|
535
535
|
const NOTE_DEFINITION_SELECTOR = 'aside[data-document-note]';
|
|
536
536
|
function normalizeDocumentNotesHtml(source) {
|
|
537
|
-
const
|
|
537
|
+
const document1 = new DOMParser().parseFromString(source, 'text/html');
|
|
538
538
|
const definitions = new Map();
|
|
539
|
-
for (const element of Array.from(
|
|
539
|
+
for (const element of Array.from(document1.body.querySelectorAll(NOTE_DEFINITION_SELECTOR))){
|
|
540
540
|
const kind = documentNoteKind(element.dataset.noteKind);
|
|
541
541
|
const id = element.dataset.noteId?.trim();
|
|
542
542
|
if (!kind || !id) {
|
|
@@ -556,7 +556,7 @@ function normalizeDocumentNotesHtml(source) {
|
|
|
556
556
|
};
|
|
557
557
|
const numbers = new Map();
|
|
558
558
|
const references = new Map();
|
|
559
|
-
for (const element of Array.from(
|
|
559
|
+
for (const element of Array.from(document1.body.querySelectorAll(NOTE_REFERENCE_SELECTOR))){
|
|
560
560
|
const kind = documentNoteKind(element.dataset.noteKind) ?? 'footnote';
|
|
561
561
|
const id = element.dataset.noteId?.trim() || nextDocumentNoteId(kind, counters[kind] + 1, numbers);
|
|
562
562
|
const key = documentNoteKey(kind, id);
|
|
@@ -583,30 +583,30 @@ function normalizeDocumentNotesHtml(source) {
|
|
|
583
583
|
for (const [key, number] of numbers){
|
|
584
584
|
if (definitions.has(key)) continue;
|
|
585
585
|
const { kind, id } = splitDocumentNoteKey(key);
|
|
586
|
-
const note = createDocumentNoteElement(
|
|
586
|
+
const note = createDocumentNoteElement(document1, {
|
|
587
587
|
id,
|
|
588
588
|
kind,
|
|
589
589
|
number,
|
|
590
590
|
html: '<p></p>'
|
|
591
591
|
});
|
|
592
592
|
const reference = references.get(key);
|
|
593
|
-
const target = 'footnote' === kind ? reference?.closest('section[data-document-section]') :
|
|
594
|
-
(target ??
|
|
593
|
+
const target = 'footnote' === kind ? reference?.closest('section[data-document-section]') : document1.body.querySelector('section[data-document-section]:last-of-type');
|
|
594
|
+
(target ?? document1.body).append(note);
|
|
595
595
|
}
|
|
596
|
-
return
|
|
596
|
+
return document1.body.innerHTML;
|
|
597
597
|
}
|
|
598
598
|
function collectDocumentNotes(source) {
|
|
599
599
|
const html = normalizeDocumentNotesHtml(source);
|
|
600
|
-
const
|
|
600
|
+
const document1 = new DOMParser().parseFromString(html, 'text/html');
|
|
601
601
|
const definitions = new Map();
|
|
602
|
-
for (const element of Array.from(
|
|
602
|
+
for (const element of Array.from(document1.body.querySelectorAll(NOTE_DEFINITION_SELECTOR))){
|
|
603
603
|
const kind = documentNoteKind(element.dataset.noteKind);
|
|
604
604
|
const id = element.dataset.noteId?.trim();
|
|
605
605
|
if (kind && id) definitions.set(documentNoteKey(kind, id), element);
|
|
606
606
|
}
|
|
607
607
|
const seen = new Set();
|
|
608
608
|
const notes = [];
|
|
609
|
-
for (const reference of Array.from(
|
|
609
|
+
for (const reference of Array.from(document1.body.querySelectorAll(NOTE_REFERENCE_SELECTOR))){
|
|
610
610
|
const kind = documentNoteKind(reference.dataset.noteKind);
|
|
611
611
|
const id = reference.dataset.noteId?.trim();
|
|
612
612
|
if (!kind || !id) continue;
|
|
@@ -629,9 +629,9 @@ function collectDocumentNotes(source) {
|
|
|
629
629
|
};
|
|
630
630
|
}
|
|
631
631
|
function documentNoteReferenceKeys(source) {
|
|
632
|
-
const
|
|
632
|
+
const document1 = new DOMParser().parseFromString(source, 'text/html');
|
|
633
633
|
const keys = [];
|
|
634
|
-
for (const reference of Array.from(
|
|
634
|
+
for (const reference of Array.from(document1.body.querySelectorAll(NOTE_REFERENCE_SELECTOR))){
|
|
635
635
|
const kind = documentNoteKind(reference.dataset.noteKind);
|
|
636
636
|
const id = reference.dataset.noteId?.trim();
|
|
637
637
|
if (kind && id) keys.push(documentNoteKey(kind, id));
|
|
@@ -639,12 +639,12 @@ function documentNoteReferenceKeys(source) {
|
|
|
639
639
|
return keys;
|
|
640
640
|
}
|
|
641
641
|
function removeDocumentNoteDefinitions(source) {
|
|
642
|
-
const
|
|
643
|
-
for (const note of Array.from(
|
|
644
|
-
return
|
|
642
|
+
const document1 = new DOMParser().parseFromString(source, 'text/html');
|
|
643
|
+
for (const note of Array.from(document1.body.querySelectorAll(NOTE_DEFINITION_SELECTOR)))note.remove();
|
|
644
|
+
return document1.body.innerHTML;
|
|
645
645
|
}
|
|
646
|
-
function createDocumentNoteElement(
|
|
647
|
-
const element =
|
|
646
|
+
function createDocumentNoteElement(document1, note) {
|
|
647
|
+
const element = document1.createElement('aside');
|
|
648
648
|
applyDocumentNoteAttributes(element, note.kind, note.id, note.number, false);
|
|
649
649
|
element.innerHTML = note.html || '<p></p>';
|
|
650
650
|
ensureDocumentNoteBlocks(element);
|
|
@@ -882,23 +882,23 @@ function updateDocumentPageChromeVariant(chrome, variant, patch) {
|
|
|
882
882
|
}
|
|
883
883
|
function pageChromePlainText(source) {
|
|
884
884
|
if (!source.trim()) return '';
|
|
885
|
-
const
|
|
886
|
-
const blocks = Array.from(
|
|
887
|
-
return (blocks.length ? blocks.join('\n') :
|
|
885
|
+
const document1 = new DOMParser().parseFromString(source, 'text/html');
|
|
886
|
+
const blocks = Array.from(document1.body.querySelectorAll('p, div, li')).map((element)=>element.textContent?.replace(/\s+/g, ' ').trim() ?? '').filter(Boolean);
|
|
887
|
+
return (blocks.length ? blocks.join('\n') : document1.body.textContent ?? '').trim();
|
|
888
888
|
}
|
|
889
889
|
function sanitizeDocumentPageChromeHtml(source) {
|
|
890
890
|
if (!source?.trim()) return '';
|
|
891
|
-
const
|
|
892
|
-
for (const element of Array.from(
|
|
893
|
-
for (const font of Array.from(
|
|
894
|
-
const span =
|
|
891
|
+
const document1 = new DOMParser().parseFromString(source, 'text/html');
|
|
892
|
+
for (const element of Array.from(document1.body.querySelectorAll("script, iframe, object, embed, link, meta")))element.remove();
|
|
893
|
+
for (const font of Array.from(document1.body.querySelectorAll('font'))){
|
|
894
|
+
const span = document1.createElement('span');
|
|
895
895
|
const color = font.getAttribute('color')?.trim();
|
|
896
896
|
if (font.getAttribute('style')) span.setAttribute('style', font.getAttribute('style') ?? '');
|
|
897
897
|
if (color && !span.style.color) span.style.color = color;
|
|
898
898
|
span.append(...Array.from(font.childNodes));
|
|
899
899
|
font.replaceWith(span);
|
|
900
900
|
}
|
|
901
|
-
for (const element of Array.from(
|
|
901
|
+
for (const element of Array.from(document1.body.querySelectorAll('*'))){
|
|
902
902
|
const tag = element.tagName.toLowerCase();
|
|
903
903
|
if (!ALLOWED_TAGS.has(tag)) {
|
|
904
904
|
element.replaceWith(...Array.from(element.childNodes));
|
|
@@ -906,8 +906,8 @@ function sanitizeDocumentPageChromeHtml(source) {
|
|
|
906
906
|
}
|
|
907
907
|
sanitizeAttributes(element, tag);
|
|
908
908
|
}
|
|
909
|
-
if (!(
|
|
910
|
-
return
|
|
909
|
+
if (!(document1.body.textContent ?? '').trim() && !document1.body.querySelector('img, table')) return '';
|
|
910
|
+
return document1.body.innerHTML;
|
|
911
911
|
}
|
|
912
912
|
function plainTextToPageChromeHtml(source) {
|
|
913
913
|
const lines = source?.split(/\r?\n/).map((line)=>line.trim()).filter(Boolean);
|
|
@@ -1150,18 +1150,18 @@ function documentInitialSectionLayout(content) {
|
|
|
1150
1150
|
};
|
|
1151
1151
|
}
|
|
1152
1152
|
function normalizeDocumentHtml(content) {
|
|
1153
|
-
const
|
|
1154
|
-
const directSections = Array.from(
|
|
1153
|
+
const document1 = new DOMParser().parseFromString(content.html, 'text/html');
|
|
1154
|
+
const directSections = Array.from(document1.body.children).filter((element)=>element.matches(SECTION_SELECTOR));
|
|
1155
1155
|
if (!directSections.length) {
|
|
1156
|
-
const section =
|
|
1156
|
+
const section = document1.createElement('section');
|
|
1157
1157
|
applyDocumentSectionDomAttributes(section, documentInitialSectionLayout(content), 'document-section-1');
|
|
1158
|
-
while(
|
|
1158
|
+
while(document1.body.firstChild)section.append(document1.body.firstChild);
|
|
1159
1159
|
if (!section.childNodes.length) section.innerHTML = '<p></p>';
|
|
1160
|
-
|
|
1161
|
-
return normalizeDocumentSemanticHtml(
|
|
1160
|
+
document1.body.append(section);
|
|
1161
|
+
return normalizeDocumentSemanticHtml(document1.body.innerHTML, content.bibliography);
|
|
1162
1162
|
}
|
|
1163
1163
|
let activeSection = directSections[0];
|
|
1164
|
-
for (const node of Array.from(
|
|
1164
|
+
for (const node of Array.from(document1.body.childNodes)){
|
|
1165
1165
|
if (node instanceof HTMLElement && node.matches(SECTION_SELECTOR)) {
|
|
1166
1166
|
activeSection = node;
|
|
1167
1167
|
continue;
|
|
@@ -1175,12 +1175,12 @@ function normalizeDocumentHtml(content) {
|
|
|
1175
1175
|
if (!element.childNodes.length) element.innerHTML = '<p></p>';
|
|
1176
1176
|
fallback = layout;
|
|
1177
1177
|
});
|
|
1178
|
-
return normalizeDocumentSemanticHtml(
|
|
1178
|
+
return normalizeDocumentSemanticHtml(document1.body.innerHTML, content.bibliography);
|
|
1179
1179
|
}
|
|
1180
1180
|
function documentSections(content) {
|
|
1181
|
-
const
|
|
1181
|
+
const document1 = new DOMParser().parseFromString(normalizeDocumentHtml(content), 'text/html');
|
|
1182
1182
|
let fallback = documentInitialSectionLayout(content);
|
|
1183
|
-
return Array.from(
|
|
1183
|
+
return Array.from(document1.body.querySelectorAll(`:scope > ${SECTION_SELECTOR}`)).map((element, index)=>{
|
|
1184
1184
|
const layout = documentSectionLayoutFromElement(element, fallback);
|
|
1185
1185
|
fallback = layout;
|
|
1186
1186
|
return {
|
|
@@ -1211,7 +1211,9 @@ function documentSectionNodeAttributes(layout, id) {
|
|
|
1211
1211
|
footerText: legacy.footerText ?? '',
|
|
1212
1212
|
showPageNumbers: Boolean(legacy.showPageNumbers),
|
|
1213
1213
|
pageNumberStart: validPageNumber(layout.pageNumberStart) ?? null,
|
|
1214
|
-
pageChrome: serializeDocumentPageChrome(pageChrome)
|
|
1214
|
+
pageChrome: serializeDocumentPageChrome(pageChrome),
|
|
1215
|
+
documentGridType: layout.documentGrid?.type ?? '',
|
|
1216
|
+
documentGridLinePitch: normalizedDocumentGrid(layout.documentGrid)?.linePitch ?? null
|
|
1215
1217
|
};
|
|
1216
1218
|
}
|
|
1217
1219
|
function documentSectionLayoutFromNodeAttributes(attributes, fallback) {
|
|
@@ -1233,6 +1235,7 @@ function documentSectionLayoutFromNodeAttributes(attributes, fallback) {
|
|
|
1233
1235
|
showPageNumbers: attributes.showPageNumbers
|
|
1234
1236
|
}, base.pageChrome);
|
|
1235
1237
|
const legacy = documentPageChromeLegacyFields(pageChrome);
|
|
1238
|
+
const documentGrid = documentGridFromNodeAttributes(attributes, base);
|
|
1236
1239
|
return {
|
|
1237
1240
|
pageSize: 'letter' === attributes.pageSize ? 'letter' : 'a4' === attributes.pageSize ? 'a4' : base.pageSize,
|
|
1238
1241
|
orientation: 'landscape' === attributes.orientation ? 'landscape' : 'portrait' === attributes.orientation ? 'portrait' : base.orientation,
|
|
@@ -1252,7 +1255,10 @@ function documentSectionLayoutFromNodeAttributes(attributes, fallback) {
|
|
|
1252
1255
|
footerText: legacy.footerText,
|
|
1253
1256
|
showPageNumbers: legacy.showPageNumbers,
|
|
1254
1257
|
pageNumberStart: validPageNumber(attributes.pageNumberStart ?? void 0),
|
|
1255
|
-
pageChrome
|
|
1258
|
+
pageChrome,
|
|
1259
|
+
...documentGrid ? {
|
|
1260
|
+
documentGrid
|
|
1261
|
+
} : {}
|
|
1256
1262
|
};
|
|
1257
1263
|
}
|
|
1258
1264
|
function documentSectionDomAttributes(layout, id) {
|
|
@@ -1275,7 +1281,9 @@ function documentSectionDomAttributes(layout, id) {
|
|
|
1275
1281
|
'data-section-footer-text': attributes.footerText,
|
|
1276
1282
|
'data-section-show-page-numbers': String(attributes.showPageNumbers),
|
|
1277
1283
|
'data-section-page-number-start': null === attributes.pageNumberStart ? '' : String(attributes.pageNumberStart),
|
|
1278
|
-
'data-section-page-chrome': attributes.pageChrome
|
|
1284
|
+
'data-section-page-chrome': attributes.pageChrome,
|
|
1285
|
+
'data-section-document-grid-type': attributes.documentGridType,
|
|
1286
|
+
'data-section-document-grid-line-pitch': null === attributes.documentGridLinePitch ? '' : String(attributes.documentGridLinePitch)
|
|
1279
1287
|
};
|
|
1280
1288
|
}
|
|
1281
1289
|
function documentSectionLayoutFromElement(element, fallback) {
|
|
@@ -1295,7 +1303,9 @@ function documentSectionLayoutFromElement(element, fallback) {
|
|
|
1295
1303
|
footerText: element.dataset.sectionFooterText ?? '',
|
|
1296
1304
|
showPageNumbers: 'true' === element.dataset.sectionShowPageNumbers,
|
|
1297
1305
|
pageNumberStart: numberValue(element.dataset.sectionPageNumberStart) ?? null,
|
|
1298
|
-
pageChrome: element.dataset.sectionPageChrome ?? ''
|
|
1306
|
+
pageChrome: element.dataset.sectionPageChrome ?? '',
|
|
1307
|
+
documentGridType: element.dataset.sectionDocumentGridType,
|
|
1308
|
+
documentGridLinePitch: numberValue(element.dataset.sectionDocumentGridLinePitch) ?? null
|
|
1299
1309
|
}, fallback);
|
|
1300
1310
|
}
|
|
1301
1311
|
function syncDocumentContentFromHtml(content, html) {
|
|
@@ -1361,4 +1371,85 @@ function numberValue(value) {
|
|
|
1361
1371
|
const parsed = Number(value);
|
|
1362
1372
|
return Number.isFinite(parsed) ? parsed : void 0;
|
|
1363
1373
|
}
|
|
1364
|
-
|
|
1374
|
+
function documentGridFromNodeAttributes(attributes, base) {
|
|
1375
|
+
if (void 0 === attributes.documentGridType && void 0 === attributes.documentGridLinePitch) return normalizedDocumentGrid(base.documentGrid);
|
|
1376
|
+
return normalizedDocumentGrid({
|
|
1377
|
+
type: attributes.documentGridType,
|
|
1378
|
+
linePitch: Number(attributes.documentGridLinePitch)
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
function normalizedDocumentGrid(value) {
|
|
1382
|
+
if (!value || !validDocumentGridType(value.type)) return;
|
|
1383
|
+
const linePitch = Number(value.linePitch);
|
|
1384
|
+
if (!Number.isFinite(linePitch) || linePitch <= 0) return;
|
|
1385
|
+
return {
|
|
1386
|
+
type: value.type,
|
|
1387
|
+
linePitch: Math.min(720, Number(linePitch.toFixed(2)))
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
function validDocumentGridType(value) {
|
|
1391
|
+
return 'default' === value || 'lines' === value || 'linesAndChars' === value || 'snapToChars' === value;
|
|
1392
|
+
}
|
|
1393
|
+
function mountWorkLiveDocumentCapture(surface, firstPageIndex = 0, captureHeight = surface.pageHeight) {
|
|
1394
|
+
const host = document.createElement('div');
|
|
1395
|
+
host.className = 'work-pdf-export-surface';
|
|
1396
|
+
host.setAttribute('aria-hidden', 'true');
|
|
1397
|
+
const viewport = document.createElement('div');
|
|
1398
|
+
viewport.className = 'work-document-live-pdf-viewport';
|
|
1399
|
+
const backgroundColor = getComputedStyle(surface.element).backgroundColor || '#ffffff';
|
|
1400
|
+
Object.assign(viewport.style, {
|
|
1401
|
+
backgroundColor,
|
|
1402
|
+
height: `${captureHeight}px`,
|
|
1403
|
+
overflow: 'hidden',
|
|
1404
|
+
position: 'relative',
|
|
1405
|
+
width: `${surface.pageWidth}px`
|
|
1406
|
+
});
|
|
1407
|
+
const snapshot = surface.element.cloneNode(true);
|
|
1408
|
+
snapshot.removeAttribute('data-work-pdf-live-document');
|
|
1409
|
+
snapshot.removeAttribute('aria-label');
|
|
1410
|
+
snapshot.classList.remove('page-chrome-editing', 'work-document-preview-page');
|
|
1411
|
+
snapshot.classList.add('document', 'work-document-live-pdf-snapshot', 'work-pdf-export-page');
|
|
1412
|
+
snapshot.dataset.documentCommentAppearance = 'plain';
|
|
1413
|
+
snapshot.setAttribute('aria-hidden', 'true');
|
|
1414
|
+
const surfaceHeight = surface.pageCount * surface.pageHeight + Math.max(0, surface.pageCount - 1) * surface.pageGap;
|
|
1415
|
+
Object.assign(snapshot.style, {
|
|
1416
|
+
borderColor: 'transparent',
|
|
1417
|
+
boxShadow: 'none',
|
|
1418
|
+
height: `${surfaceHeight}px`,
|
|
1419
|
+
left: '0',
|
|
1420
|
+
margin: '0',
|
|
1421
|
+
minHeight: `${surfaceHeight}px`,
|
|
1422
|
+
position: 'absolute',
|
|
1423
|
+
top: `-${firstPageIndex * (surface.pageHeight + surface.pageGap)}px`,
|
|
1424
|
+
width: `${surface.pageWidth}px`
|
|
1425
|
+
});
|
|
1426
|
+
normalizeWorkLiveDocumentSnapshot(snapshot);
|
|
1427
|
+
viewport.append(snapshot);
|
|
1428
|
+
host.append(viewport);
|
|
1429
|
+
document.body.append(host);
|
|
1430
|
+
return {
|
|
1431
|
+
backgroundColor,
|
|
1432
|
+
host,
|
|
1433
|
+
snapshot,
|
|
1434
|
+
viewport
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
function normalizeWorkLiveDocumentSnapshot(snapshot) {
|
|
1438
|
+
snapshot.querySelectorAll('.work-document-selection-toolbar').forEach((element)=>{
|
|
1439
|
+
element.remove();
|
|
1440
|
+
});
|
|
1441
|
+
for (const editor of snapshot.querySelectorAll('.work-document-page-chrome-inline-editor')){
|
|
1442
|
+
const content = editor.querySelector('[data-document-page-chrome-engine="tiptap"]');
|
|
1443
|
+
const replacement = document.createElement('div');
|
|
1444
|
+
replacement.className = 'work-document-page-chrome-html';
|
|
1445
|
+
replacement.innerHTML = content?.innerHTML ?? '';
|
|
1446
|
+
editor.replaceWith(replacement);
|
|
1447
|
+
}
|
|
1448
|
+
for (const element of snapshot.querySelectorAll('*')){
|
|
1449
|
+
element.removeAttribute('contenteditable');
|
|
1450
|
+
element.removeAttribute('id');
|
|
1451
|
+
element.removeAttribute('tabindex');
|
|
1452
|
+
element.classList.remove('ProseMirror-focused', 'ProseMirror-selectednode', 'is-editor-empty', 'selectedCell');
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
export { clampDocumentMargin, collectDocumentNotes, createDocumentBibliography, createDocumentNoteElement, createWorkDocumentModel, documentCaptionDisplay, documentCaptionKind, documentCaptionLabel, documentCitationInstruction, documentCitationStyle, documentCitationStyleDetails, documentCitationTags, documentCitationTagsFromInstruction, documentContentLayoutProperties, documentFieldDisplay, documentFieldInstruction, documentFieldKind, documentFieldLabel, documentHtmlFingerprint, documentInitialSectionLayout, documentMargins, documentModelForContent, documentNoteKey, documentNoteKind, documentNoteReferenceKeys, documentPageChromeLegacyFields, documentSectionDomAttributes, documentSectionLayoutFromNodeAttributes, documentSectionNodeAttributes, documentSections, docxDocumentFieldKind, isValidDocumentCitationTag, millimetersToPixels, mountWorkLiveDocumentCapture, normalizeDocumentCaptionsHtml, normalizeDocumentCitationsHtml, normalizeDocumentColumns, normalizeDocumentFieldsHtml, normalizeDocumentHtml, normalizeDocumentNotesHtml, normalizeDocumentPageChrome, removeDocumentNoteDefinitions, renameDocumentCitationTagInInstruction, renderDocumentBibliographyHtml, resolveDocumentCitation, resolveDocumentFieldsHtml, resolveDocumentPageChrome, resolveWorkDocumentEditorInput, sanitizeDocumentPageChromeHtml, setCustomDocumentColumns, syncDocumentContentFromHtml, updateDocumentColumnWidth, updateDocumentPageChromeVariant };
|
package/dist/4104.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import jszip from "jszip";
|
|
2
|
-
import { documentContentLayoutProperties } from "./
|
|
2
|
+
import { documentContentLayoutProperties, mountWorkLiveDocumentCapture } from "./2881.js";
|
|
3
3
|
import { createOfficeId as createWorkId, createArtifact as createWorkArtifact } from "./1134.js";
|
|
4
4
|
import { workSpreadsheetChartSupportsGrouping, parseXml, attribute, normalizeSpreadsheetPrintTitleColumns, normalizeSpreadsheetPrintTitleRows, normalizeWorkSpreadsheetErrorBars, directChildren, workSpreadsheetChartSupportsBarSpacing, xlsxTwoCellAnchorMarkers, normalizeWorkSpreadsheetChartGrouping, xlsxDrawingAnchorToBounds, normalizeWorkSpreadsheetChartAxisGroup, normalizeWorkSpreadsheetScatterStyle, firstDescendant, descendants, workSpreadsheetChartAxisIsCategoryAxis, normalizeWorkSpreadsheetDoughnutHoleSize, normalizeWorkSpreadsheetChartAxes, parseSpreadsheetPrintTitles, editableSpreadsheetFormula, normalizeWorkSpreadsheetChartLegendPosition, effectiveSpreadsheetCalculationSettings, normalizeWorkSpreadsheetTrendline, normalizeWorkSpreadsheetDataLabels, normalizeSpreadsheetPrintArea, bytesToDataUrl, OoxmlPackage, formatSpreadsheetCellRanges, normalizeWorkSpreadsheetChartSmoothLines, spreadsheetCellAddress, spreadsheetFormulaRangeForCell, spreadsheetPivotFilterValueKey, normalizeWorkSpreadsheetBubbleScale, normalizeWorkSpreadsheetChartSeriesStyle, qualifySpreadsheetRange, normalizeWorkSpreadsheetBubbleSizeRepresents, workSpreadsheetChartSupportsTrendlines, normalizeWorkSpreadsheetChartLegendOverlay, normalizeWorkSpreadsheetChartGapWidth, workSpreadsheetChartGroupingIsStacked, stripSpreadsheetSheetQualifier, workSpreadsheetChartSupportsSmoothLines, refreshSpreadsheetPivotTables, workSpreadsheetChartSupportsErrorBars, contentTypeForPart, workSpreadsheetChartAxisDefaultLabelPosition, isValidSpreadsheetDefinedName, spreadsheetPivotValidation, resolveSpreadsheetChart, parseSpreadsheetCellRanges, spreadsheetPivotFields, xmlNamespacePrefix, normalizeWorkSpreadsheetChartOverlap, spreadsheetFormulaRangeConflict, spreadsheetFormulaForXlsx, workSpreadsheetChartUsesNumericXAxis, normalizeWorkSpreadsheetChartColor, readXlsxDrawingAnchor, directChild, workSpreadsheetChartSupportsAxes, workSpreadsheetChartAxisShowsMajorGridlinesByDefault, normalizeWorkSpreadsheetRadarStyle, normalizeWorkSpreadsheetCombinationSeriesType } from "./8715.js";
|
|
5
5
|
import { editableRangeRequiresCredentials, normalizeSpreadsheetConditionalIconSetFormat, defaultSpreadsheetDataBarOptions, normalizeSpreadsheetConditionalVisualOptions, normalizeSheetProtectionAuthority, applySpreadsheetCellProtectionRanges, normalizeSpreadsheetPaperSize, defaultSpreadsheetColorScaleThresholds, applyPasswordlessEditableRanges, sheetHasProtectionState, spreadsheetConditionalComparisonNeedsUpperValue, isSpreadsheetConditionalComparisonOperator, defaultSpreadsheetConditionalIconThresholds, DEFAULT_PROTECTION_HINT, isSpreadsheetConditionalIconSetName, spreadsheetConditionalThresholdsEqual, spreadsheetConditionalIconSetCount } from "./8728.js";
|
|
@@ -5537,7 +5537,7 @@ async function exportWorkArtifactPdf(artifact, options = {}) {
|
|
|
5537
5537
|
]);
|
|
5538
5538
|
let pdf = null;
|
|
5539
5539
|
if (liveDocument) {
|
|
5540
|
-
const capture =
|
|
5540
|
+
const capture = mountWorkLiveDocumentCapture(liveDocument);
|
|
5541
5541
|
try {
|
|
5542
5542
|
const batches = workLiveDocumentPdfCaptureBatches(livePageIndexes, liveDocument);
|
|
5543
5543
|
for (const batch of batches){
|
|
@@ -5647,66 +5647,6 @@ function workLiveDocumentPdfCaptureBatches(pageIndexes, page) {
|
|
|
5647
5647
|
}
|
|
5648
5648
|
return batches;
|
|
5649
5649
|
}
|
|
5650
|
-
function mountLiveDocumentPdfCapture(surface) {
|
|
5651
|
-
const host = document.createElement('div');
|
|
5652
|
-
host.className = 'work-pdf-export-surface';
|
|
5653
|
-
host.setAttribute('aria-hidden', 'true');
|
|
5654
|
-
const viewport = document.createElement('div');
|
|
5655
|
-
viewport.className = 'work-document-live-pdf-viewport';
|
|
5656
|
-
const backgroundColor = getComputedStyle(surface.element).backgroundColor || '#ffffff';
|
|
5657
|
-
Object.assign(viewport.style, {
|
|
5658
|
-
backgroundColor,
|
|
5659
|
-
height: `${surface.pageHeight}px`,
|
|
5660
|
-
overflow: 'hidden',
|
|
5661
|
-
position: 'relative',
|
|
5662
|
-
width: `${surface.pageWidth}px`
|
|
5663
|
-
});
|
|
5664
|
-
const snapshot = surface.element.cloneNode(true);
|
|
5665
|
-
snapshot.removeAttribute('data-work-pdf-live-document');
|
|
5666
|
-
snapshot.removeAttribute('aria-label');
|
|
5667
|
-
snapshot.classList.remove('page-chrome-editing', 'work-document-preview-page');
|
|
5668
|
-
snapshot.classList.add('document', 'work-document-live-pdf-snapshot', 'work-pdf-export-page');
|
|
5669
|
-
snapshot.dataset.documentCommentAppearance = 'plain';
|
|
5670
|
-
snapshot.setAttribute('aria-hidden', 'true');
|
|
5671
|
-
const surfaceHeight = surface.pageCount * surface.pageHeight + (surface.pageCount - 1) * surface.pageGap;
|
|
5672
|
-
Object.assign(snapshot.style, {
|
|
5673
|
-
borderColor: 'transparent',
|
|
5674
|
-
boxShadow: 'none',
|
|
5675
|
-
height: `${surfaceHeight}px`,
|
|
5676
|
-
left: '0',
|
|
5677
|
-
margin: '0',
|
|
5678
|
-
minHeight: `${surfaceHeight}px`,
|
|
5679
|
-
position: 'absolute',
|
|
5680
|
-
top: '0',
|
|
5681
|
-
width: `${surface.pageWidth}px`
|
|
5682
|
-
});
|
|
5683
|
-
normalizeLiveDocumentPdfSnapshot(snapshot);
|
|
5684
|
-
viewport.append(snapshot);
|
|
5685
|
-
host.append(viewport);
|
|
5686
|
-
document.body.append(host);
|
|
5687
|
-
return {
|
|
5688
|
-
backgroundColor,
|
|
5689
|
-
host,
|
|
5690
|
-
snapshot,
|
|
5691
|
-
viewport
|
|
5692
|
-
};
|
|
5693
|
-
}
|
|
5694
|
-
function normalizeLiveDocumentPdfSnapshot(snapshot) {
|
|
5695
|
-
snapshot.querySelectorAll('.work-document-selection-toolbar').forEach((element)=>{
|
|
5696
|
-
element.remove();
|
|
5697
|
-
});
|
|
5698
|
-
for (const editor of snapshot.querySelectorAll('.work-document-page-chrome-inline-editor')){
|
|
5699
|
-
const content = editor.querySelector('[data-document-page-chrome-engine="tiptap"]');
|
|
5700
|
-
const replacement = document.createElement('div');
|
|
5701
|
-
replacement.className = 'work-document-page-chrome-html';
|
|
5702
|
-
replacement.innerHTML = content?.innerHTML ?? '';
|
|
5703
|
-
editor.replaceWith(replacement);
|
|
5704
|
-
}
|
|
5705
|
-
for (const element of snapshot.querySelectorAll('*')){
|
|
5706
|
-
element.removeAttribute('contenteditable');
|
|
5707
|
-
element.classList.remove('ProseMirror-focused', 'ProseMirror-selectednode', 'is-editor-empty', 'selectedCell');
|
|
5708
|
-
}
|
|
5709
|
-
}
|
|
5710
5650
|
function finiteDatasetNumber(value, minimum) {
|
|
5711
5651
|
if (void 0 === value || '' === value.trim()) return null;
|
|
5712
5652
|
const parsed = Number(value);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const DOCUMENT_COMMENT_WINDOW_THRESHOLD = 48;
|
|
2
|
+
export declare const DOCUMENT_COMMENT_WINDOW_LIMIT = 32;
|
|
3
|
+
export declare const DOCUMENT_COMMENT_WINDOW_OVERSCAN = 4;
|
|
4
|
+
export interface DocumentCommentWindowRange {
|
|
5
|
+
end: number;
|
|
6
|
+
start: number;
|
|
7
|
+
windowed: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function useDocumentCommentWindow({ keys, onRovingKeyChange, pinnedKeys, rovingKey, }: {
|
|
10
|
+
keys: readonly string[];
|
|
11
|
+
onRovingKeyChange: (key: string) => void;
|
|
12
|
+
pinnedKeys?: readonly (string | null | undefined)[];
|
|
13
|
+
rovingKey: string | null;
|
|
14
|
+
}): {
|
|
15
|
+
focusAt: (requestedIndex: number) => void;
|
|
16
|
+
mountedIndices: number[];
|
|
17
|
+
onItemFocus: (index: number) => void;
|
|
18
|
+
onViewportAnchorChange: (index: number) => void;
|
|
19
|
+
range: DocumentCommentWindowRange;
|
|
20
|
+
registerItem: (key: string, element: HTMLElement | null) => void;
|
|
21
|
+
rovingIndex: number;
|
|
22
|
+
};
|
|
23
|
+
export declare function calculateDocumentCommentWindowRange({ anchorIndex, itemCount, limit, overscan, threshold, }: {
|
|
24
|
+
anchorIndex: number;
|
|
25
|
+
itemCount: number;
|
|
26
|
+
limit?: number;
|
|
27
|
+
overscan?: number;
|
|
28
|
+
threshold?: number;
|
|
29
|
+
}): DocumentCommentWindowRange;
|
|
30
|
+
export declare function documentCommentWindowIndices({ itemCount, pinnedIndices, range, }: {
|
|
31
|
+
itemCount: number;
|
|
32
|
+
pinnedIndices: readonly number[];
|
|
33
|
+
range: DocumentCommentWindowRange;
|
|
34
|
+
}): number[];
|
|
35
|
+
export declare function documentCommentKeyboardDestination(key: string, index: number, itemCount: number): number | null;
|
|
36
|
+
export declare function focusDocumentCommentItem(element: HTMLElement): void;
|
|
37
|
+
export declare function scrollDocumentCommentItemIntoView(element: HTMLElement): void;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { Editor } from '@tiptap/core';
|
|
2
2
|
import { type DocumentNavigationPage } from './document-page-navigation';
|
|
3
|
-
|
|
3
|
+
import type { WorkDocumentPageThumbnailSource } from './document-page-thumbnail';
|
|
4
|
+
export declare function DocumentNavigationPanel({ currentPage, editor, modal, pages, pageThumbnailSource, onClose, }: {
|
|
4
5
|
currentPage?: number;
|
|
5
6
|
editor: Editor;
|
|
6
7
|
modal?: boolean;
|
|
7
8
|
pages?: readonly DocumentNavigationPage[];
|
|
9
|
+
pageThumbnailSource?: WorkDocumentPageThumbnailSource;
|
|
8
10
|
onClose: () => void | Promise<void>;
|
|
9
11
|
}): import("react").JSX.Element;
|