@a3s-lab/office 0.2.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COLLABORATION_ROADMAP.md +426 -0
- package/README.md +649 -10
- package/dist/0~1403.js +1 -1
- package/dist/0~2805.js +1279 -0
- package/dist/{0~use-office-draft.js → 0~345.js} +30 -1
- package/dist/0~3539.js +1 -1
- package/dist/0~3557.js +1 -1
- package/dist/0~3635.js +1 -1
- package/dist/0~4595.js +123 -12
- package/dist/0~4980.js +154 -0
- package/dist/0~5050.js +124 -113
- package/dist/{0~9512.js → 0~6090.js} +540 -3
- package/dist/0~7048.js +92 -66
- package/dist/0~7614.js +2 -1
- package/dist/0~7754.js +5653 -0
- package/dist/0~9445.js +1 -1
- package/dist/0~document-editor.js +4992 -3323
- package/dist/0~markdown-editor.js +250 -44
- package/dist/0~pdf-viewer.js +1016 -24
- package/dist/0~presentation-editor.js +179 -8
- package/dist/0~spreadsheet-editor.js +3371 -578
- package/dist/0~work-docx-export.js +6801 -658
- package/dist/0~work-docx-import.js +1388 -795
- package/dist/0~work-office-diagnostics.js +524 -30
- package/dist/0~work-pptx-export.js +2 -1
- package/dist/0~work-pptx-import.js +1 -2
- package/dist/0~work-presentation-charts.js +1 -1
- package/dist/2591.js +197 -0
- package/dist/3818.js +1090 -0
- package/dist/4104.js +970 -60
- package/dist/432.js +171 -14
- package/dist/4476.js +2008 -0
- package/dist/4560.js +674 -0
- package/dist/4650.js +70 -0
- package/dist/{1134.js → 5184.js} +183 -1
- package/dist/6489.js +18 -18
- package/dist/7060.js +132 -0
- package/dist/8715.js +2 -136
- package/dist/8928.js +16778 -0
- package/dist/9787.js +209 -0
- package/dist/core.d.ts +29 -9
- package/dist/core.js +10 -2
- package/dist/index.js +13 -3
- package/dist/internal/collaboration/office-collaboration-flat-json.d.ts +13 -0
- package/dist/internal/collaboration/office-collaboration-json.d.ts +4 -0
- package/dist/internal/collaboration/office-collaboration-presence.d.ts +86 -0
- package/dist/internal/collaboration/office-collaboration-transport.d.ts +42 -0
- package/dist/internal/collaboration/office-collaboration.d.ts +85 -0
- package/dist/internal/collaboration/office-document-collaboration-bibliography.d.ts +7 -0
- package/dist/internal/collaboration/office-document-collaboration-claims.d.ts +9 -0
- package/dist/internal/collaboration/office-document-collaboration-comments.d.ts +7 -0
- package/dist/internal/collaboration/office-document-collaboration-sidecar-utils.d.ts +27 -0
- package/dist/internal/collaboration/office-document-collaboration-sidecars.d.ts +16 -0
- package/dist/internal/collaboration/office-document-collaboration.d.ts +45 -0
- package/dist/internal/collaboration/office-markdown-collaboration.d.ts +31 -0
- package/dist/internal/collaboration/office-pdf-collaboration-claims.d.ts +4 -0
- package/dist/internal/collaboration/office-pdf-collaboration-conflicts.d.ts +2 -0
- package/dist/internal/collaboration/office-pdf-collaboration-model.d.ts +26 -0
- package/dist/internal/collaboration/office-pdf-collaboration-records.d.ts +21 -0
- package/dist/internal/collaboration/office-pdf-collaboration-types.d.ts +91 -0
- package/dist/internal/collaboration/office-pdf-collaboration-validation.d.ts +4 -0
- package/dist/internal/collaboration/office-pdf-collaboration.d.ts +35 -0
- package/dist/internal/collaboration/office-presentation-collaboration-model.d.ts +25 -0
- package/dist/internal/collaboration/office-presentation-collaboration-records.d.ts +22 -0
- package/dist/internal/collaboration/office-presentation-collaboration-validation.d.ts +4 -0
- package/dist/internal/collaboration/office-presentation-collaboration.d.ts +32 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration-cells.d.ts +13 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration-claims.d.ts +4 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration-conflicts.d.ts +2 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration-flat-json.d.ts +10 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration-model.d.ts +31 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration-records.d.ts +17 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration-validation.d.ts +4 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration.d.ts +32 -0
- package/dist/internal/design-system/primitives/navigation/tabs.d.ts +3 -1
- package/dist/internal/features/work/components/work-document-page-border.d.ts +6 -0
- package/dist/internal/features/work/editors/document-command-catalog.d.ts +536 -0
- package/dist/internal/features/work/editors/document-editor-focus.d.ts +1 -1
- package/dist/internal/features/work/editors/document-editor-support.d.ts +7 -3
- package/dist/internal/features/work/editors/document-editor.d.ts +8 -2
- package/dist/internal/features/work/editors/document-external-content.d.ts +14 -0
- package/dist/internal/features/work/editors/document-format-clipboard.d.ts +6 -0
- package/dist/internal/features/work/editors/document-format-tools.d.ts +4 -0
- package/dist/internal/features/work/editors/document-layout-panel.d.ts +4 -1
- package/dist/internal/features/work/editors/document-page-chrome-wps-shortcuts.d.ts +2 -0
- package/dist/internal/features/work/editors/document-page-layout-ribbon.d.ts +14 -0
- package/dist/internal/features/work/editors/document-page-stack.d.ts +10 -1
- package/dist/internal/features/work/editors/document-page-thumbnail.d.ts +2 -0
- package/dist/internal/features/work/editors/document-pagination-run-coordinator.d.ts +26 -0
- package/dist/internal/features/work/editors/document-picture-properties-dialog-model.d.ts +20 -1
- package/dist/internal/features/work/editors/document-review-navigation.d.ts +9 -0
- package/dist/internal/features/work/editors/document-statistics-dialog.d.ts +7 -0
- package/dist/internal/features/work/editors/document-status-bar.d.ts +2 -1
- package/dist/internal/features/work/editors/document-table-properties-dialog-model.d.ts +4 -1
- package/dist/internal/features/work/editors/document-toolbar.d.ts +19 -42
- package/dist/internal/features/work/editors/document-wps-shortcuts.d.ts +12 -0
- package/dist/internal/features/work/editors/document-zoom.d.ts +17 -0
- package/dist/internal/features/work/editors/markdown-editor-focus.d.ts +1 -1
- package/dist/internal/features/work/editors/markdown-editor.d.ts +5 -1
- package/dist/internal/features/work/editors/markdown-toolbar.d.ts +2 -1
- package/dist/internal/features/work/editors/office-collaboration-participants.d.ts +3 -0
- package/dist/internal/features/work/editors/office-collaboration-presence-context.d.ts +17 -0
- package/dist/internal/features/work/editors/office-collaboration-presence-ui.d.ts +25 -0
- package/dist/internal/features/work/editors/office-editor-focus-handoff.d.ts +27 -0
- package/dist/internal/features/work/editors/pdf-annotation-controller.d.ts +5 -0
- package/dist/internal/features/work/editors/pdf-collaboration-presence.d.ts +3 -0
- package/dist/internal/features/work/editors/pdf-collaboration-projection.d.ts +10 -0
- package/dist/internal/features/work/editors/pdf-evidence-contract.d.ts +36 -0
- package/dist/internal/features/work/editors/pdf-evidence-overlay.d.ts +37 -0
- package/dist/internal/features/work/editors/pdf-toolbar.d.ts +2 -1
- package/dist/internal/features/work/editors/pdf-viewer-controller.d.ts +7 -1
- package/dist/internal/features/work/editors/pdf-viewer.d.ts +11 -1
- package/dist/internal/features/work/editors/presentation-collaboration-presence.d.ts +5 -0
- package/dist/internal/features/work/editors/presentation-editor-focus.d.ts +3 -2
- package/dist/internal/features/work/editors/presentation-editor-types.d.ts +3 -0
- package/dist/internal/features/work/editors/presentation-editor.d.ts +1 -1
- package/dist/internal/features/work/editors/spreadsheet-auto-filter.d.ts +9 -0
- package/dist/internal/features/work/editors/spreadsheet-cell-clear.d.ts +3 -0
- package/dist/internal/features/work/editors/spreadsheet-cell-merge.d.ts +12 -0
- package/dist/internal/features/work/editors/spreadsheet-clipboard-shortcuts.d.ts +3 -7
- package/dist/internal/features/work/editors/spreadsheet-collaboration-presence.d.ts +9 -0
- package/dist/internal/features/work/editors/spreadsheet-command-catalog.d.ts +464 -0
- package/dist/internal/features/work/editors/spreadsheet-command-controller.d.ts +45 -9
- package/dist/internal/features/work/editors/spreadsheet-context-menu.d.ts +2 -0
- package/dist/internal/features/work/editors/spreadsheet-editor-ribbon.d.ts +9 -28
- package/dist/internal/features/work/editors/spreadsheet-editor.d.ts +8 -2
- package/dist/internal/features/work/editors/spreadsheet-format-painter.d.ts +27 -0
- package/dist/internal/features/work/editors/spreadsheet-freeze-panes.d.ts +14 -0
- package/dist/internal/features/work/editors/use-document-insert-commands.d.ts +3 -2
- package/dist/internal/features/work/editors/use-document-pagination.d.ts +6 -1
- package/dist/internal/features/work/editors/use-document-review-conflicts.d.ts +28 -0
- package/dist/internal/features/work/editors/use-spreadsheet-auto-filter.d.ts +21 -0
- package/dist/internal/features/work/editors/use-spreadsheet-collaboration.d.ts +27 -0
- package/dist/internal/features/work/editors/use-spreadsheet-format-painter.d.ts +18 -0
- package/dist/internal/features/work/editors/work-office-chrome.d.ts +22 -3
- package/dist/internal/features/work/editors/work-office-ribbon-overflow.d.ts +2 -0
- package/dist/internal/features/work/work-document-bookmark-references.d.ts +37 -0
- package/dist/internal/features/work/work-document-bookmarks.d.ts +29 -0
- package/dist/internal/features/work/work-document-caption-nodes.d.ts +4 -1
- package/dist/internal/features/work/work-document-comments.d.ts +1 -1
- package/dist/internal/features/work/work-document-equations.d.ts +513 -0
- package/dist/internal/features/work/work-document-extensions.d.ts +1 -0
- package/dist/internal/features/work/work-document-field-identity.d.ts +2 -0
- package/dist/internal/features/work/work-document-field-node.d.ts +2 -2
- package/dist/internal/features/work/work-document-fields.d.ts +7 -0
- package/dist/internal/features/work/work-document-image-identity.d.ts +30 -0
- package/dist/internal/features/work/work-document-image-layout.d.ts +46 -1
- package/dist/internal/features/work/work-document-image-wrap-contour.d.ts +16 -0
- package/dist/internal/features/work/work-document-incremental-layout.d.ts +2 -2
- package/dist/internal/features/work/work-document-model-codec.d.ts +4 -1
- package/dist/internal/features/work/work-document-note-integrity.d.ts +2 -0
- package/dist/internal/features/work/work-document-page-borders.d.ts +25 -0
- package/dist/internal/features/work/work-document-page-capture.d.ts +8 -0
- package/dist/internal/features/work/work-document-page-frames.d.ts +15 -0
- package/dist/internal/features/work/work-document-page-margins.d.ts +56 -0
- package/dist/internal/features/work/work-document-page-size.d.ts +47 -0
- package/dist/internal/features/work/work-document-pagination-measurement.d.ts +1 -2
- package/dist/internal/features/work/work-document-pagination-types.d.ts +7 -2
- package/dist/internal/features/work/work-document-pagination.d.ts +2 -2
- package/dist/internal/features/work/work-document-paragraph-borders.d.ts +32 -0
- package/dist/internal/features/work/work-document-paragraph-identity.d.ts +26 -0
- package/dist/internal/features/work/work-document-paragraph-shading.d.ts +18 -0
- package/dist/internal/features/work/work-document-review-conflicts.d.ts +35 -0
- package/dist/internal/features/work/work-document-section.d.ts +4 -0
- package/dist/internal/features/work/work-document-snapshot.d.ts +19 -0
- package/dist/internal/features/work/work-document-source.d.ts +23 -0
- package/dist/internal/features/work/work-document-table-column-widths.d.ts +7 -0
- package/dist/internal/features/work/work-document-table-property-changes.d.ts +3 -0
- package/dist/internal/features/work/work-document-table-row-identity.d.ts +15 -0
- package/dist/internal/features/work/work-document-table-sizing.d.ts +3 -0
- package/dist/internal/features/work/work-document-text-layout.d.ts +3 -1
- package/dist/internal/features/work/work-document-word-line-metrics.d.ts +2 -0
- package/dist/internal/features/work/work-docx-bookmark-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-bookmark-import.d.ts +24 -0
- package/dist/internal/features/work/work-docx-bookmarks.d.ts +17 -0
- package/dist/internal/features/work/work-docx-comment-durable-id-preservation.d.ts +2 -0
- package/dist/internal/features/work/work-docx-comment-export.d.ts +3 -0
- package/dist/internal/features/work/work-docx-comment-metadata.d.ts +2 -0
- package/dist/internal/features/work/work-docx-drawing-extension-preservation.d.ts +4 -0
- package/dist/internal/features/work/work-docx-equation-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-equation-export.d.ts +14 -0
- package/dist/internal/features/work/work-docx-equation-import.d.ts +30 -0
- package/dist/internal/features/work/work-docx-equation-story.d.ts +9 -0
- package/dist/internal/features/work/work-docx-export-formatting.d.ts +3 -1
- package/dist/internal/features/work/work-docx-export-image.d.ts +5 -1
- package/dist/internal/features/work/work-docx-export.d.ts +1 -1
- package/dist/internal/features/work/work-docx-field-instructions.d.ts +8 -0
- package/dist/internal/features/work/work-docx-font-table-preservation.d.ts +3 -0
- package/dist/internal/features/work/work-docx-ignorable-extension-preservation.d.ts +15 -0
- package/dist/internal/features/work/work-docx-image-crop.d.ts +12 -0
- package/dist/internal/features/work/work-docx-image-identity.d.ts +17 -0
- package/dist/internal/features/work/work-docx-image-layer.d.ts +12 -0
- package/dist/internal/features/work/work-docx-image-layout-import.d.ts +14 -2
- package/dist/internal/features/work/work-docx-image-wrap.d.ts +15 -0
- package/dist/internal/features/work/work-docx-import.d.ts +13 -3
- package/dist/internal/features/work/work-docx-list-export.d.ts +18 -0
- package/dist/internal/features/work/work-docx-list-import.d.ts +14 -0
- package/dist/internal/features/work/work-docx-note-comment-content-control-block-preservation.d.ts +18 -0
- package/dist/internal/features/work/work-docx-note-comment-content-control-model.d.ts +47 -0
- package/dist/internal/features/work/work-docx-note-comment-content-control-preservation.d.ts +4 -0
- package/dist/internal/features/work/work-docx-note-comment-content-control-properties.d.ts +17 -0
- package/dist/internal/features/work/work-docx-note-comment-content-control-table-model.d.ts +17 -0
- package/dist/internal/features/work/work-docx-note-comment-content-control-xml.d.ts +14 -0
- package/dist/internal/features/work/work-docx-note-comment-extension-preservation.d.ts +2 -0
- package/dist/internal/features/work/work-docx-note-comment-hyperlink-content.d.ts +40 -0
- package/dist/internal/features/work/work-docx-note-comment-hyperlink-preservation.d.ts +5 -0
- package/dist/internal/features/work/work-docx-note-comment-hyperlink-relationships.d.ts +35 -0
- package/dist/internal/features/work/work-docx-note-comment-identity.d.ts +15 -0
- package/dist/internal/features/work/work-docx-note-comment-run-preservation.d.ts +4 -0
- package/dist/internal/features/work/work-docx-note-comment-run-properties.d.ts +2 -0
- package/dist/internal/features/work/work-docx-note-image-import.d.ts +12 -0
- package/dist/internal/features/work/work-docx-note-image-relationships.d.ts +1 -0
- package/dist/internal/features/work/work-docx-numbering-extension-preservation.d.ts +6 -0
- package/dist/internal/features/work/work-docx-numbering.d.ts +1 -0
- package/dist/internal/features/work/work-docx-page-borders-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-page-borders-import.d.ts +10 -0
- package/dist/internal/features/work/work-docx-page-margins-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-page-margins-import.d.ts +18 -0
- package/dist/internal/features/work/work-docx-page-size-diagnostics.d.ts +2 -0
- package/dist/internal/features/work/work-docx-page-size-import.d.ts +17 -0
- package/dist/internal/features/work/work-docx-paragraph-borders-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-paragraph-borders-export.d.ts +18 -0
- package/dist/internal/features/work/work-docx-paragraph-borders-import.d.ts +24 -0
- package/dist/internal/features/work/work-docx-paragraph-default-collapsed.d.ts +19 -0
- package/dist/internal/features/work/work-docx-paragraph-extension-preservation.d.ts +2 -0
- package/dist/internal/features/work/work-docx-paragraph-identity-import.d.ts +10 -0
- package/dist/internal/features/work/work-docx-paragraph-identity.d.ts +18 -0
- package/dist/internal/features/work/work-docx-paragraph-pagination-import.d.ts +6 -1
- package/dist/internal/features/work/work-docx-paragraph-shading-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-paragraph-shading-export.d.ts +5 -0
- package/dist/internal/features/work/work-docx-paragraph-shading-import.d.ts +18 -0
- package/dist/internal/features/work/work-docx-run-formatting-import.d.ts +3 -0
- package/dist/internal/features/work/work-docx-settings-preservation.d.ts +10 -0
- package/dist/internal/features/work/work-docx-settings-xml.d.ts +16 -0
- package/dist/internal/features/work/work-docx-style-extension-preservation.d.ts +2 -0
- package/dist/internal/features/work/work-docx-table-cell-export.d.ts +2 -1
- package/dist/internal/features/work/work-docx-table-cell-import.d.ts +3 -0
- package/dist/internal/features/work/work-docx-table-extension-preservation.d.ts +2 -0
- package/dist/internal/features/work/work-docx-table-row-import.d.ts +2 -0
- package/dist/internal/features/work/work-docx-table-sizing-import.d.ts +1 -0
- package/dist/internal/features/work/work-docx-theme-reference.d.ts +23 -0
- package/dist/internal/features/work/work-docx-theme.d.ts +4 -1
- package/dist/internal/features/work/work-docx-twips.d.ts +12 -0
- package/dist/internal/features/work/work-file-contract.d.ts +1 -0
- package/dist/internal/features/work/work-file-io.d.ts +1 -1
- package/dist/internal/features/work/work-markdown-extensions.d.ts +4 -1
- package/dist/internal/features/work/work-ooxml-package-preservation.d.ts +12 -0
- package/dist/internal/features/work/work-ooxml-package-security.d.ts +6 -0
- package/dist/internal/features/work/work-ooxml-relationship-preservation.d.ts +10 -0
- package/dist/internal/features/work/work-ooxml-xml.d.ts +2 -0
- package/dist/internal/features/work/work-pdf-export.d.ts +10 -0
- package/dist/internal/features/work/work-repository.d.ts +2 -0
- package/dist/internal/features/work/work-types.d.ts +15 -2
- package/dist/internal/kernel/office-kernel-client-types.d.ts +1 -0
- package/dist/internal/kernel/office-kernel-protocol.d.ts +7 -0
- package/dist/internal/kernel/office-kernel-version.d.ts +1 -1
- package/dist/office-kernel.wasm +0 -0
- package/dist/office-kernel.worker.js +93 -41
- package/dist/react.d.ts +18 -12
- package/dist/react.js +1 -1
- package/dist/styles.css +1367 -16
- package/dist/vue.d.ts +48 -5
- package/dist/vue.js +42 -3
- package/dist/web-component.d.ts +24 -2
- package/dist/web-component.js +101 -2
- package/docs/latest/en/browser-editor-architecture.md +262 -47
- package/package.json +29 -4
- package/dist/0~152.js +0 -94
- package/dist/0~2582.js +0 -485
- package/dist/0~4750.js +0 -939
- package/dist/0~5861.js +0 -596
- package/dist/0~work-document-extensions.js +0 -3045
- package/dist/0~work-document-model-codec.js +0 -42
- package/dist/0~work-docx-bibliography.js +0 -347
- package/dist/0~work-docx-page-color.js +0 -42
- package/dist/2881.js +0 -1455
- package/dist/8728.js +0 -723
package/dist/4104.js
CHANGED
|
@@ -1,10 +1,460 @@
|
|
|
1
1
|
import jszip from "jszip";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { MarkdownManager } from "@tiptap/markdown";
|
|
3
|
+
import { getSchema } from "@tiptap/core";
|
|
4
|
+
import { OFFICE_COLLABORATION_PROTOCOL as WORK_OFFICE_COLLABORATION_PROTOCOL, OfficeCollaborationError as WorkOfficeCollaborationError, assertWorkOfficeCollaborationOrigin } from "./9787.js";
|
|
5
|
+
import { createWorkDocumentModel, documentContentLayoutProperties, documentModelForContent, mountWorkLiveDocumentCapture, materializeWorkDocumentContent as work_document_model_codec_materializeWorkDocumentContent, createWorkDocumentExtensions, positionWorkLiveDocumentCapture } from "./8928.js";
|
|
6
|
+
import { contentTypeForPart, directChildren, bytesToDataUrl, OoxmlPackage, parseXml, firstDescendant, xmlNamespacePrefix, directChild, descendants, createArtifact as createWorkArtifact, createOfficeId as createWorkId, attribute } from "./5184.js";
|
|
7
|
+
import { spreadsheetFormulaForXlsx, workSpreadsheetChartSupportsGrouping, normalizeSpreadsheetPrintArea, spreadsheetFormulaRangeConflict, formatSpreadsheetCellRanges, effectiveSpreadsheetCalculationSettings, normalizeWorkSpreadsheetChartSmoothLines, editableSpreadsheetFormula, spreadsheetCellAddress, spreadsheetFormulaRangeForCell, spreadsheetPivotFilterValueKey, normalizeWorkSpreadsheetBubbleScale, normalizeWorkSpreadsheetChartSeriesStyle, qualifySpreadsheetRange, normalizeSpreadsheetPrintTitleColumns, normalizeSpreadsheetPrintTitleRows, normalizeWorkSpreadsheetErrorBars, normalizeWorkSpreadsheetBubbleSizeRepresents, workSpreadsheetChartSupportsBarSpacing, workSpreadsheetChartSupportsTrendlines, workSpreadsheetChartGroupingIsStacked, normalizeWorkSpreadsheetChartGrouping, normalizeWorkSpreadsheetChartLegendOverlay, workSpreadsheetChartSupportsSmoothLines, normalizeWorkSpreadsheetChartGapWidth, xlsxTwoCellAnchorMarkers, xlsxDrawingAnchorToBounds, stripSpreadsheetSheetQualifier, workSpreadsheetChartSupportsErrorBars, refreshSpreadsheetPivotTables, normalizeWorkSpreadsheetChartAxisGroup, normalizeWorkSpreadsheetScatterStyle, workSpreadsheetChartAxisDefaultLabelPosition, isValidSpreadsheetDefinedName, spreadsheetPivotValidation, resolveSpreadsheetChart, workSpreadsheetChartAxisIsCategoryAxis, parseSpreadsheetCellRanges, spreadsheetPivotFields, normalizeWorkSpreadsheetDoughnutHoleSize, normalizeWorkSpreadsheetChartAxes, normalizeWorkSpreadsheetChartOverlap, workSpreadsheetChartUsesNumericXAxis, readXlsxDrawingAnchor, parseSpreadsheetPrintTitles, normalizeWorkSpreadsheetChartLegendPosition, normalizeWorkSpreadsheetChartColor, workSpreadsheetChartSupportsAxes, workSpreadsheetChartAxisShowsMajorGridlinesByDefault, normalizeWorkSpreadsheetTrendline, normalizeWorkSpreadsheetRadarStyle, normalizeWorkSpreadsheetCombinationSeriesType, normalizeWorkSpreadsheetDataLabels } from "./8715.js";
|
|
8
|
+
import { editableRangeRequiresCredentials, normalizeSpreadsheetConditionalIconSetFormat, defaultSpreadsheetDataBarOptions, normalizeSpreadsheetConditionalVisualOptions, normalizeSheetProtectionAuthority, applySpreadsheetCellProtectionRanges, normalizeSpreadsheetPaperSize, defaultSpreadsheetColorScaleThresholds, applyPasswordlessEditableRanges, sheetHasProtectionState, spreadsheetConditionalComparisonNeedsUpperValue, isSpreadsheetConditionalComparisonOperator, defaultSpreadsheetConditionalIconThresholds, DEFAULT_PROTECTION_HINT, isSpreadsheetConditionalIconSetName, spreadsheetConditionalThresholdsEqual, spreadsheetConditionalIconSetCount } from "./4476.js";
|
|
6
9
|
import { materializeWorkFile } from "./9356.js";
|
|
10
|
+
import "./2591.js";
|
|
11
|
+
import "./3818.js";
|
|
12
|
+
import "./4560.js";
|
|
7
13
|
import "./6489.js";
|
|
14
|
+
import * as __rspack_external_yjs from "yjs";
|
|
15
|
+
const WORK_OFFICE_COLLABORATION_PRESENCE_FIELD = 'a3sOffice';
|
|
16
|
+
const MAX_PRESENCE_RANGES = 64;
|
|
17
|
+
const MAX_PRESENCE_ELEMENT_IDS = 128;
|
|
18
|
+
function createWorkOfficeCollaborationPresence(session, initial = {}) {
|
|
19
|
+
return new WorkOfficeCollaborationPresenceImpl(session, initial);
|
|
20
|
+
}
|
|
21
|
+
let nextPresenceSequence = 0;
|
|
22
|
+
class WorkOfficeCollaborationPresenceImpl {
|
|
23
|
+
#session;
|
|
24
|
+
#awareness;
|
|
25
|
+
#actor;
|
|
26
|
+
#presenceId;
|
|
27
|
+
#listeners = new Set();
|
|
28
|
+
#activity;
|
|
29
|
+
#location;
|
|
30
|
+
#destroyed = false;
|
|
31
|
+
constructor(session, initial){
|
|
32
|
+
session.metadata();
|
|
33
|
+
if (!session.awareness) throw new WorkOfficeCollaborationError('office.collaboration.presence_unavailable', 'Office collaboration presence requires host-provided Yjs Awareness.');
|
|
34
|
+
if (!session.actor) throw new WorkOfficeCollaborationError('office.collaboration.presence_unavailable', 'Office collaboration presence requires a typed local actor.');
|
|
35
|
+
if (!isClientId(session.awareness.clientID) || session.awareness.clientID !== session.document.clientID) throw new WorkOfficeCollaborationError('office.collaboration.presence_unavailable', 'Office collaboration Awareness must belong to the session Y.Doc.');
|
|
36
|
+
const existing = session.awareness.getLocalState()?.[WORK_OFFICE_COLLABORATION_PRESENCE_FIELD];
|
|
37
|
+
if (null != existing) throw new WorkOfficeCollaborationError('office.collaboration.presence_conflict', 'The local Awareness state already has an A3S Office presence owner.');
|
|
38
|
+
this.#session = session;
|
|
39
|
+
this.#awareness = session.awareness;
|
|
40
|
+
this.#actor = copiedActor(session.actor);
|
|
41
|
+
this.#presenceId = createPresenceId(session.document.clientID);
|
|
42
|
+
this.#activity = normalizedActivity(initial.activity ?? 'active');
|
|
43
|
+
this.#location = void 0 === initial.location || null === initial.location ? void 0 : normalizedLocalLocation(initial.location, session.kind);
|
|
44
|
+
this.#awareness.on('change', this.#onAwarenessChange);
|
|
45
|
+
try {
|
|
46
|
+
this.publish();
|
|
47
|
+
} catch (error) {
|
|
48
|
+
this.#awareness.off('change', this.#onAwarenessChange);
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
local() {
|
|
53
|
+
this.ensureActive();
|
|
54
|
+
this.ensureOwnership();
|
|
55
|
+
return this.state();
|
|
56
|
+
}
|
|
57
|
+
snapshot() {
|
|
58
|
+
this.ensureActive();
|
|
59
|
+
const participants = [];
|
|
60
|
+
for (const [clientId, awarenessState] of this.#awareness.getStates()){
|
|
61
|
+
if (!isClientId(clientId) || !isRecord(awarenessState)) continue;
|
|
62
|
+
const state = validatedPresenceState(awarenessState[WORK_OFFICE_COLLABORATION_PRESENCE_FIELD], this.#session);
|
|
63
|
+
if (state) participants.push(Object.freeze({
|
|
64
|
+
...state,
|
|
65
|
+
clientId,
|
|
66
|
+
local: clientId === this.#awareness.clientID
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
participants.sort((left, right)=>left.clientId - right.clientId);
|
|
70
|
+
return Object.freeze({
|
|
71
|
+
localClientId: this.#awareness.clientID,
|
|
72
|
+
participants: Object.freeze(participants)
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
update(update) {
|
|
76
|
+
this.ensureActive();
|
|
77
|
+
this.ensureOwnership();
|
|
78
|
+
if (!isRecord(update)) throw invalidPresence('Presence updates must be plain objects.');
|
|
79
|
+
const nextActivity = void 0 === update.activity ? this.#activity : normalizedActivity(update.activity);
|
|
80
|
+
const nextLocation = Object.hasOwn(update, 'location') ? null === update.location ? void 0 : normalizedLocalLocation(update.location, this.#session.kind) : this.#location;
|
|
81
|
+
this.#activity = nextActivity;
|
|
82
|
+
this.#location = nextLocation;
|
|
83
|
+
this.publish();
|
|
84
|
+
return this.state();
|
|
85
|
+
}
|
|
86
|
+
subscribe(listener) {
|
|
87
|
+
this.ensureActive();
|
|
88
|
+
if ('function' != typeof listener) throw invalidPresence('Presence listeners must be functions.');
|
|
89
|
+
this.#listeners.add(listener);
|
|
90
|
+
return ()=>this.#listeners.delete(listener);
|
|
91
|
+
}
|
|
92
|
+
destroy() {
|
|
93
|
+
if (this.#destroyed) return;
|
|
94
|
+
this.#destroyed = true;
|
|
95
|
+
this.#awareness.off('change', this.#onAwarenessChange);
|
|
96
|
+
this.#listeners.clear();
|
|
97
|
+
const current = this.#awareness.getLocalState()?.[WORK_OFFICE_COLLABORATION_PRESENCE_FIELD];
|
|
98
|
+
if (isRecord(current) && current.presenceId === this.#presenceId) this.#awareness.setLocalStateField(WORK_OFFICE_COLLABORATION_PRESENCE_FIELD, null);
|
|
99
|
+
}
|
|
100
|
+
#onAwarenessChange = ()=>{
|
|
101
|
+
if (this.#destroyed) return;
|
|
102
|
+
const snapshot = this.snapshot();
|
|
103
|
+
for (const listener of this.#listeners)listener(snapshot);
|
|
104
|
+
};
|
|
105
|
+
publish() {
|
|
106
|
+
this.#awareness.setLocalStateField(WORK_OFFICE_COLLABORATION_PRESENCE_FIELD, this.state());
|
|
107
|
+
}
|
|
108
|
+
state() {
|
|
109
|
+
return Object.freeze({
|
|
110
|
+
protocol: WORK_OFFICE_COLLABORATION_PROTOCOL,
|
|
111
|
+
version: 1,
|
|
112
|
+
artifactId: this.#session.artifactId,
|
|
113
|
+
artifactKind: this.#session.kind,
|
|
114
|
+
namespace: this.#session.namespace,
|
|
115
|
+
presenceId: this.#presenceId,
|
|
116
|
+
actor: this.#actor,
|
|
117
|
+
mode: this.#session.mode,
|
|
118
|
+
activity: this.#activity,
|
|
119
|
+
location: this.#location
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
ensureOwnership() {
|
|
123
|
+
const current = this.#awareness.getLocalState()?.[WORK_OFFICE_COLLABORATION_PRESENCE_FIELD];
|
|
124
|
+
if (!isRecord(current) || current.presenceId !== this.#presenceId) throw new WorkOfficeCollaborationError('office.collaboration.presence_conflict', 'The local A3S Office presence field was replaced by another owner.');
|
|
125
|
+
}
|
|
126
|
+
ensureActive() {
|
|
127
|
+
if (!this.#destroyed) return;
|
|
128
|
+
throw new WorkOfficeCollaborationError('office.collaboration.binding_destroyed', 'The Office collaboration presence controller has been destroyed.');
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function validatedPresenceState(value, session) {
|
|
132
|
+
if (!isRecord(value) || value.protocol !== WORK_OFFICE_COLLABORATION_PROTOCOL || 1 !== value.version || value.artifactId !== session.artifactId || value.artifactKind !== session.kind || value.namespace !== session.namespace || !isIdentifier(value.presenceId) || !isMode(value.mode) || !isActivity(value.activity)) return null;
|
|
133
|
+
const actor = validatedActor(value.actor);
|
|
134
|
+
if (!actor) return null;
|
|
135
|
+
const location = void 0 === value.location ? void 0 : validatedLocation(value.location, session.kind);
|
|
136
|
+
if (void 0 !== value.location && null === location) return null;
|
|
137
|
+
return Object.freeze({
|
|
138
|
+
protocol: WORK_OFFICE_COLLABORATION_PROTOCOL,
|
|
139
|
+
version: 1,
|
|
140
|
+
artifactId: session.artifactId,
|
|
141
|
+
artifactKind: session.kind,
|
|
142
|
+
namespace: session.namespace,
|
|
143
|
+
presenceId: value.presenceId,
|
|
144
|
+
actor,
|
|
145
|
+
mode: value.mode,
|
|
146
|
+
activity: value.activity,
|
|
147
|
+
location: location ?? void 0
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function normalizedLocalLocation(value, kind) {
|
|
151
|
+
const location = validatedLocation(value, kind);
|
|
152
|
+
if (!location) throw invalidPresence(`The Office collaboration presence location is invalid for '${kind}'.`);
|
|
153
|
+
return location;
|
|
154
|
+
}
|
|
155
|
+
function validatedLocation(value, kind) {
|
|
156
|
+
if (!isRecord(value) || value.kind !== kind) return null;
|
|
157
|
+
if ('document' === kind || 'markdown' === kind) {
|
|
158
|
+
if (!isPosition(value.anchor) || !isPosition(value.head)) return null;
|
|
159
|
+
if ('document' === kind) return Object.freeze({
|
|
160
|
+
kind,
|
|
161
|
+
anchor: value.anchor,
|
|
162
|
+
head: value.head
|
|
163
|
+
});
|
|
164
|
+
if (void 0 !== value.surface && 'source' !== value.surface && 'visual' !== value.surface) return null;
|
|
165
|
+
return Object.freeze({
|
|
166
|
+
kind,
|
|
167
|
+
anchor: value.anchor,
|
|
168
|
+
head: value.head,
|
|
169
|
+
...void 0 === value.surface ? {} : {
|
|
170
|
+
surface: value.surface
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
if ('spreadsheet' === kind) {
|
|
175
|
+
if (!isIdentifier(value.sheetId) || !Array.isArray(value.ranges) || value.ranges.length < 1 || value.ranges.length > MAX_PRESENCE_RANGES) return null;
|
|
176
|
+
const ranges = [];
|
|
177
|
+
for (const candidate of value.ranges){
|
|
178
|
+
const range = validatedSpreadsheetRange(candidate);
|
|
179
|
+
if (!range) return null;
|
|
180
|
+
ranges.push(range);
|
|
181
|
+
}
|
|
182
|
+
const activeCell = void 0 === value.activeCell ? void 0 : validatedSpreadsheetCell(value.activeCell);
|
|
183
|
+
if (void 0 !== value.activeCell && !activeCell) return null;
|
|
184
|
+
return Object.freeze({
|
|
185
|
+
kind,
|
|
186
|
+
sheetId: value.sheetId,
|
|
187
|
+
ranges: Object.freeze(ranges),
|
|
188
|
+
activeCell: activeCell ?? void 0
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
if ('presentation' === kind) {
|
|
192
|
+
if (!isIdentifier(value.slideId) || !Array.isArray(value.elementIds) || value.elementIds.length > MAX_PRESENCE_ELEMENT_IDS) return null;
|
|
193
|
+
const elementIds = [];
|
|
194
|
+
const seen = new Set();
|
|
195
|
+
for (const candidate of value.elementIds){
|
|
196
|
+
if (!isIdentifier(candidate) || seen.has(candidate)) return null;
|
|
197
|
+
seen.add(candidate);
|
|
198
|
+
elementIds.push(candidate);
|
|
199
|
+
}
|
|
200
|
+
return Object.freeze({
|
|
201
|
+
kind,
|
|
202
|
+
slideId: value.slideId,
|
|
203
|
+
elementIds: Object.freeze(elementIds)
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
if (!isPosition(value.pageIndex)) return null;
|
|
207
|
+
if (void 0 !== value.annotationId && !isIdentifier(value.annotationId)) return null;
|
|
208
|
+
return Object.freeze({
|
|
209
|
+
kind: 'pdf',
|
|
210
|
+
pageIndex: value.pageIndex,
|
|
211
|
+
annotationId: value.annotationId
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
function validatedSpreadsheetRange(value) {
|
|
215
|
+
if (!isRecord(value) || !isPosition(value.startRow) || !isPosition(value.startColumn) || !isPosition(value.endRow) || !isPosition(value.endColumn) || value.startRow > value.endRow || value.startColumn > value.endColumn) return null;
|
|
216
|
+
return Object.freeze({
|
|
217
|
+
startRow: value.startRow,
|
|
218
|
+
startColumn: value.startColumn,
|
|
219
|
+
endRow: value.endRow,
|
|
220
|
+
endColumn: value.endColumn
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
function validatedSpreadsheetCell(value) {
|
|
224
|
+
if (!isRecord(value) || !isPosition(value.row) || !isPosition(value.column)) return null;
|
|
225
|
+
return Object.freeze({
|
|
226
|
+
row: value.row,
|
|
227
|
+
column: value.column
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
function validatedActor(value) {
|
|
231
|
+
if (!isRecord(value) || !isIdentifier(value.id) || !isIdentifier(value.name) || !isActorKind(value.kind) || !isOptionalBoundedString(value.color, 64) || !isOptionalBoundedString(value.avatarUrl, 2048)) return null;
|
|
232
|
+
return Object.freeze({
|
|
233
|
+
id: value.id,
|
|
234
|
+
name: value.name,
|
|
235
|
+
kind: value.kind,
|
|
236
|
+
color: value.color,
|
|
237
|
+
avatarUrl: value.avatarUrl
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
function copiedActor(actor) {
|
|
241
|
+
return Object.freeze({
|
|
242
|
+
id: actor.id,
|
|
243
|
+
name: actor.name,
|
|
244
|
+
kind: actor.kind ?? 'human',
|
|
245
|
+
color: actor.color,
|
|
246
|
+
avatarUrl: actor.avatarUrl
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
function normalizedActivity(value) {
|
|
250
|
+
if (isActivity(value)) return value;
|
|
251
|
+
throw invalidPresence(`The Office collaboration presence activity '${String(value)}' is invalid.`);
|
|
252
|
+
}
|
|
253
|
+
function createPresenceId(clientId) {
|
|
254
|
+
nextPresenceSequence = nextPresenceSequence >= Number.MAX_SAFE_INTEGER ? 1 : nextPresenceSequence + 1;
|
|
255
|
+
return `${clientId}:${nextPresenceSequence.toString(36)}`;
|
|
256
|
+
}
|
|
257
|
+
function invalidPresence(message) {
|
|
258
|
+
return new WorkOfficeCollaborationError('office.collaboration.presence_invalid', message);
|
|
259
|
+
}
|
|
260
|
+
function isRecord(value) {
|
|
261
|
+
return 'object' == typeof value && null !== value && !Array.isArray(value);
|
|
262
|
+
}
|
|
263
|
+
function isIdentifier(value) {
|
|
264
|
+
return 'string' == typeof value && value.length >= 1 && value.length <= 256 && value.trim() === value;
|
|
265
|
+
}
|
|
266
|
+
function isOptionalBoundedString(value, maximumLength) {
|
|
267
|
+
return void 0 === value || 'string' == typeof value && value.length >= 1 && value.length <= maximumLength && value.trim() === value;
|
|
268
|
+
}
|
|
269
|
+
function isPosition(value) {
|
|
270
|
+
return Number.isSafeInteger(value) && value >= 0;
|
|
271
|
+
}
|
|
272
|
+
function isClientId(value) {
|
|
273
|
+
return isPosition(value);
|
|
274
|
+
}
|
|
275
|
+
function isActivity(value) {
|
|
276
|
+
return 'active' === value || 'idle' === value || 'away' === value;
|
|
277
|
+
}
|
|
278
|
+
function isMode(value) {
|
|
279
|
+
return 'view' === value || 'comment' === value || 'suggest' === value || 'edit' === value;
|
|
280
|
+
}
|
|
281
|
+
function isActorKind(value) {
|
|
282
|
+
return 'human' === value || 'agent' === value || 'system' === value;
|
|
283
|
+
}
|
|
284
|
+
const WORK_OFFICE_COLLABORATION_DEFAULT_MAX_TRANSPORT_PAYLOAD_BYTES = 67108864;
|
|
285
|
+
const WORK_OFFICE_COLLABORATION_MAX_TRANSPORT_PAYLOAD_BYTES = 268435456;
|
|
286
|
+
function createWorkOfficeCollaborationTransportBinding(session, transport, options = {}) {
|
|
287
|
+
return new WorkOfficeCollaborationTransportBindingImpl(session, transport, options);
|
|
288
|
+
}
|
|
289
|
+
class WorkOfficeCollaborationTransportBindingImpl {
|
|
290
|
+
#session;
|
|
291
|
+
#transport;
|
|
292
|
+
#maxPayloadBytes;
|
|
293
|
+
#remoteOrigins = new WeakSet();
|
|
294
|
+
#unsubscribe;
|
|
295
|
+
#destroyed = false;
|
|
296
|
+
constructor(session, transport, options){
|
|
297
|
+
session.metadata();
|
|
298
|
+
assertTransport(transport);
|
|
299
|
+
this.#session = session;
|
|
300
|
+
this.#transport = transport;
|
|
301
|
+
this.#maxPayloadBytes = normalizedMaximumPayloadBytes(options.maxPayloadBytes ?? WORK_OFFICE_COLLABORATION_DEFAULT_MAX_TRANSPORT_PAYLOAD_BYTES);
|
|
302
|
+
session.document.on('update', this.#onDocumentUpdate);
|
|
303
|
+
try {
|
|
304
|
+
const unsubscribe = transport.subscribe(this.#onTransportMessage);
|
|
305
|
+
if ('function' != typeof unsubscribe) throw new WorkOfficeCollaborationError('office.collaboration.transport_invalid', 'The Office collaboration transport subscribe function must return an unsubscribe function.');
|
|
306
|
+
this.#unsubscribe = unsubscribe;
|
|
307
|
+
if (false !== options.autoSynchronize) this.synchronize();
|
|
308
|
+
} catch (error) {
|
|
309
|
+
session.document.off('update', this.#onDocumentUpdate);
|
|
310
|
+
this.#unsubscribe?.();
|
|
311
|
+
this.#unsubscribe = void 0;
|
|
312
|
+
this.#destroyed = true;
|
|
313
|
+
throw error;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
synchronize() {
|
|
317
|
+
this.ensureActive();
|
|
318
|
+
this.publish('sync-step-1', __rspack_external_yjs.encodeStateVector(this.#session.document));
|
|
319
|
+
}
|
|
320
|
+
destroy() {
|
|
321
|
+
if (this.#destroyed) return;
|
|
322
|
+
this.#destroyed = true;
|
|
323
|
+
this.#session.document.off('update', this.#onDocumentUpdate);
|
|
324
|
+
const unsubscribe = this.#unsubscribe;
|
|
325
|
+
this.#unsubscribe = void 0;
|
|
326
|
+
unsubscribe?.();
|
|
327
|
+
}
|
|
328
|
+
#onDocumentUpdate = (update, origin)=>{
|
|
329
|
+
if (this.#destroyed || isRemoteOrigin(this.#remoteOrigins, origin)) return;
|
|
330
|
+
this.publish('update', update, copiedLocalOrigin(origin));
|
|
331
|
+
};
|
|
332
|
+
#onTransportMessage = (value)=>{
|
|
333
|
+
if (this.#destroyed) return;
|
|
334
|
+
const message = validatedTransportMessage(value, this.#session, this.#maxPayloadBytes);
|
|
335
|
+
if (message.senderClientId === this.#session.document.clientID) return;
|
|
336
|
+
try {
|
|
337
|
+
if ('sync-step-1' === message.type) return void this.publish('sync-step-2', __rspack_external_yjs.encodeStateAsUpdate(this.#session.document, message.payload));
|
|
338
|
+
const remoteOrigin = message.origin ?? remoteSystemOrigin();
|
|
339
|
+
this.#remoteOrigins.add(remoteOrigin);
|
|
340
|
+
__rspack_external_yjs.applyUpdate(this.#session.document, message.payload, remoteOrigin);
|
|
341
|
+
this.#session.metadata();
|
|
342
|
+
} catch (error) {
|
|
343
|
+
if (error instanceof WorkOfficeCollaborationError) throw error;
|
|
344
|
+
throw invalidTransportMessage(`The '${message.type}' payload is not a valid Yjs v1 message: ${errorMessage(error)}`);
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
publish(type, payload, origin) {
|
|
348
|
+
assertPayloadSize(payload, this.#maxPayloadBytes);
|
|
349
|
+
const message = Object.freeze({
|
|
350
|
+
protocol: WORK_OFFICE_COLLABORATION_PROTOCOL,
|
|
351
|
+
version: 1,
|
|
352
|
+
artifactId: this.#session.artifactId,
|
|
353
|
+
artifactKind: this.#session.kind,
|
|
354
|
+
namespace: this.#session.namespace,
|
|
355
|
+
senderClientId: this.#session.document.clientID,
|
|
356
|
+
type,
|
|
357
|
+
payload: payload.slice(),
|
|
358
|
+
origin
|
|
359
|
+
});
|
|
360
|
+
this.#transport.publish(message);
|
|
361
|
+
}
|
|
362
|
+
ensureActive() {
|
|
363
|
+
if (!this.#destroyed) return;
|
|
364
|
+
throw new WorkOfficeCollaborationError('office.collaboration.binding_destroyed', 'The Office collaboration transport binding has been destroyed.');
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
function validatedTransportMessage(value, session, maximumPayloadBytes) {
|
|
368
|
+
if (!office_collaboration_transport_isRecord(value)) throw invalidTransportMessage('Office collaboration transport messages must be plain objects.');
|
|
369
|
+
if (value.protocol !== WORK_OFFICE_COLLABORATION_PROTOCOL || 1 !== value.version) throw invalidTransportMessage('The Office collaboration transport protocol or version is unsupported.');
|
|
370
|
+
if (value.artifactId !== session.artifactId || value.artifactKind !== session.kind || value.namespace !== session.namespace) throw new WorkOfficeCollaborationError('office.collaboration.transport_identity_mismatch', 'The Office collaboration transport message belongs to another artifact, kind, or namespace.');
|
|
371
|
+
if (!office_collaboration_transport_isClientId(value.senderClientId)) throw invalidTransportMessage('The Office collaboration transport sender client ID is invalid.');
|
|
372
|
+
if (!isTransportMessageType(value.type)) throw invalidTransportMessage(`The Office collaboration transport message type '${String(value.type)}' is invalid.`);
|
|
373
|
+
if (!(value.payload instanceof Uint8Array)) throw invalidTransportMessage('The Office collaboration transport payload must be a Uint8Array.');
|
|
374
|
+
assertPayloadSize(value.payload, maximumPayloadBytes);
|
|
375
|
+
const origin = copiedTransportOrigin(value.origin);
|
|
376
|
+
if ('update' !== value.type && void 0 !== origin) throw invalidTransportMessage('Only incremental Office collaboration update messages may carry a transaction origin.');
|
|
377
|
+
return Object.freeze({
|
|
378
|
+
protocol: WORK_OFFICE_COLLABORATION_PROTOCOL,
|
|
379
|
+
version: 1,
|
|
380
|
+
artifactId: session.artifactId,
|
|
381
|
+
artifactKind: session.kind,
|
|
382
|
+
namespace: session.namespace,
|
|
383
|
+
senderClientId: value.senderClientId,
|
|
384
|
+
type: value.type,
|
|
385
|
+
payload: value.payload.slice(),
|
|
386
|
+
origin
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
function copiedLocalOrigin(value) {
|
|
390
|
+
try {
|
|
391
|
+
return copiedTransportOrigin(value);
|
|
392
|
+
} catch {
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
function copiedTransportOrigin(value) {
|
|
397
|
+
if (void 0 === value) return;
|
|
398
|
+
if (!office_collaboration_transport_isRecord(value)) throw invalidTransportMessage('The Office collaboration transport origin must be a typed origin object.');
|
|
399
|
+
try {
|
|
400
|
+
assertWorkOfficeCollaborationOrigin(value);
|
|
401
|
+
} catch {
|
|
402
|
+
throw invalidTransportMessage('The Office collaboration transport origin is invalid.');
|
|
403
|
+
}
|
|
404
|
+
return Object.freeze({
|
|
405
|
+
protocol: WORK_OFFICE_COLLABORATION_PROTOCOL,
|
|
406
|
+
kind: value.kind,
|
|
407
|
+
actorId: value.actorId,
|
|
408
|
+
operationId: value.operationId
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
function remoteSystemOrigin() {
|
|
412
|
+
return Object.freeze({
|
|
413
|
+
protocol: WORK_OFFICE_COLLABORATION_PROTOCOL,
|
|
414
|
+
kind: 'system'
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
function isRemoteOrigin(origins, value) {
|
|
418
|
+
return 'object' == typeof value && null !== value && origins.has(value);
|
|
419
|
+
}
|
|
420
|
+
function assertTransport(value) {
|
|
421
|
+
if (!value || 'function' != typeof value.publish || 'function' != typeof value.subscribe) throw new WorkOfficeCollaborationError('office.collaboration.transport_invalid', 'An Office collaboration transport must provide publish and subscribe functions.');
|
|
422
|
+
}
|
|
423
|
+
function normalizedMaximumPayloadBytes(value) {
|
|
424
|
+
if (!Number.isSafeInteger(value) || value < 1 || value > WORK_OFFICE_COLLABORATION_MAX_TRANSPORT_PAYLOAD_BYTES) throw new WorkOfficeCollaborationError('office.collaboration.transport_invalid', `The Office collaboration transport payload limit must be an integer between 1 and ${WORK_OFFICE_COLLABORATION_MAX_TRANSPORT_PAYLOAD_BYTES} bytes.`);
|
|
425
|
+
return value;
|
|
426
|
+
}
|
|
427
|
+
function assertPayloadSize(payload, maximumPayloadBytes) {
|
|
428
|
+
if (payload.byteLength <= maximumPayloadBytes) return;
|
|
429
|
+
throw new WorkOfficeCollaborationError('office.collaboration.transport_message_too_large', `The Office collaboration transport payload is ${payload.byteLength} bytes; the configured limit is ${maximumPayloadBytes} bytes.`);
|
|
430
|
+
}
|
|
431
|
+
function invalidTransportMessage(message) {
|
|
432
|
+
return new WorkOfficeCollaborationError('office.collaboration.transport_message_invalid', message);
|
|
433
|
+
}
|
|
434
|
+
function office_collaboration_transport_isRecord(value) {
|
|
435
|
+
return 'object' == typeof value && null !== value && !Array.isArray(value);
|
|
436
|
+
}
|
|
437
|
+
function office_collaboration_transport_isClientId(value) {
|
|
438
|
+
return Number.isSafeInteger(value) && value >= 0;
|
|
439
|
+
}
|
|
440
|
+
function isTransportMessageType(value) {
|
|
441
|
+
return 'sync-step-1' === value || 'sync-step-2' === value || 'update' === value;
|
|
442
|
+
}
|
|
443
|
+
function errorMessage(error) {
|
|
444
|
+
return error instanceof Error ? error.message : String(error);
|
|
445
|
+
}
|
|
446
|
+
function createWorkPdfCollaborationContent(source) {
|
|
447
|
+
return {
|
|
448
|
+
type: 'pdf',
|
|
449
|
+
source,
|
|
450
|
+
annotations: [],
|
|
451
|
+
formValues: [],
|
|
452
|
+
signaturePlacements: [],
|
|
453
|
+
redactionProposals: [],
|
|
454
|
+
pageOperations: [],
|
|
455
|
+
reviewDecisions: []
|
|
456
|
+
};
|
|
457
|
+
}
|
|
8
458
|
function fileNameWithoutExtension(value) {
|
|
9
459
|
return value.replace(/\.[^.]+$/, '').trim() || '导入的文件';
|
|
10
460
|
}
|
|
@@ -19,6 +469,32 @@ function work_file_download_downloadBlob(blob, name) {
|
|
|
19
469
|
anchor.click();
|
|
20
470
|
window.setTimeout(()=>URL.revokeObjectURL(url), 0);
|
|
21
471
|
}
|
|
472
|
+
const sourceBlobs = new Map();
|
|
473
|
+
function rememberWorkSourceBlob(artifactId, source) {
|
|
474
|
+
sourceBlobs.set(artifactId, source);
|
|
475
|
+
}
|
|
476
|
+
function forgetWorkSourceBlob(artifactId) {
|
|
477
|
+
sourceBlobs.delete(artifactId);
|
|
478
|
+
}
|
|
479
|
+
async function readWorkSourceBlob(artifact) {
|
|
480
|
+
const source = sourceBlobs.get(artifact.id);
|
|
481
|
+
if (source) return source;
|
|
482
|
+
throw new Error(artifact.source ? 'The original file is not available in this browser session. Register it again before opening or exporting this source-backed artifact.' : 'This document has no original source file.');
|
|
483
|
+
}
|
|
484
|
+
async function readVerifiedWorkSourceBytes(artifact) {
|
|
485
|
+
const source = await readWorkSourceBlob(artifact);
|
|
486
|
+
const bytes = await source.arrayBuffer();
|
|
487
|
+
const expected = artifact.source?.fingerprint;
|
|
488
|
+
if (expected && await workSourceFingerprint(bytes) !== expected) throw new Error('The registered source file does not match the imported source fingerprint.');
|
|
489
|
+
return bytes;
|
|
490
|
+
}
|
|
491
|
+
async function workSourceFingerprint(bytes) {
|
|
492
|
+
const subtle = globalThis.crypto?.subtle;
|
|
493
|
+
if (!subtle) throw new Error('SHA-256 source fingerprinting is unavailable.');
|
|
494
|
+
const digest = new Uint8Array(await subtle.digest('SHA-256', bytes));
|
|
495
|
+
return `sha256:${Array.from(digest, (value)=>value.toString(16).padStart(2, '0')).join('')}`;
|
|
496
|
+
}
|
|
497
|
+
const DOCX_CONTENT_TYPE = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
|
|
22
498
|
async function importWorkDocumentFile(file, extension) {
|
|
23
499
|
let html;
|
|
24
500
|
if ('docx' === extension) {
|
|
@@ -36,7 +512,7 @@ async function importWorkDocumentFile(file, extension) {
|
|
|
36
512
|
"br[type='page'] => hr.work-page-break[data-page-break='true']:fresh"
|
|
37
513
|
]
|
|
38
514
|
});
|
|
39
|
-
html = prepared ? applyDocxSectionsToHtml(result.value, prepared.sections, prepared.captionMarkers, prepared.changeMarkers, prepared.commentMarkers, prepared.fieldMarkers, prepared.citationMarkers, prepared.listMarkers, prepared.imageLayoutMarkers, prepared.paragraphAlignmentMarkers, prepared.runFormattingMarkers, prepared.paragraphDirectionMarkers, prepared.paragraphIndentMarkers, prepared.paragraphSpacingMarkers, prepared.paragraphPaginationMarkers, prepared.bibliography, prepared.tabStopMarkers, prepared.tableCellMarkers, prepared.tableRowMarkers, prepared.tableSizingMarkers) : result.value;
|
|
515
|
+
html = prepared ? applyDocxSectionsToHtml(result.value, prepared.sections, prepared.captionMarkers, prepared.bookmarkMarkers, prepared.changeMarkers, prepared.commentMarkers, prepared.fieldMarkers, prepared.equationMarkers, prepared.citationMarkers, prepared.listMarkers, prepared.imageLayoutMarkers, prepared.paragraphIdentityMarkers, prepared.paragraphAlignmentMarkers, prepared.runFormattingMarkers, prepared.paragraphDirectionMarkers, prepared.paragraphIndentMarkers, prepared.paragraphSpacingMarkers, prepared.paragraphBorderMarkers, prepared.paragraphShadingMarkers, prepared.paragraphPaginationMarkers, prepared.bibliography, prepared.tabStopMarkers, prepared.tableCellMarkers, prepared.tableRowMarkers, prepared.tableSizingMarkers) : result.value;
|
|
40
516
|
const layout = prepared ? {
|
|
41
517
|
...documentContentLayoutProperties(prepared.sections[0].layout),
|
|
42
518
|
...prepared.pageColor ? {
|
|
@@ -63,6 +539,14 @@ async function importWorkDocumentFile(file, extension) {
|
|
|
63
539
|
} : {}
|
|
64
540
|
});
|
|
65
541
|
artifact.compatibility = await analyzeDocxCompatibility(file, result.messages);
|
|
542
|
+
artifact.source = {
|
|
543
|
+
name: file.name,
|
|
544
|
+
contentType: file.type || DOCX_CONTENT_TYPE,
|
|
545
|
+
size: file.size,
|
|
546
|
+
updatedAt: file.lastModified || Date.now(),
|
|
547
|
+
fingerprint: await workSourceFingerprint(arrayBuffer)
|
|
548
|
+
};
|
|
549
|
+
rememberWorkSourceBlob(artifact.id, file);
|
|
66
550
|
return artifact;
|
|
67
551
|
}
|
|
68
552
|
const source = await file.text();
|
|
@@ -78,9 +562,10 @@ async function importWorkDocumentFile(file, extension) {
|
|
|
78
562
|
}
|
|
79
563
|
async function createWorkDocumentBlob(artifact) {
|
|
80
564
|
if ('document' !== artifact.content.type) throw new Error('当前文件不是文档。');
|
|
81
|
-
const { materializeWorkDocumentContent } = await import("./
|
|
565
|
+
const { materializeWorkDocumentContent } = await import("./8928.js");
|
|
82
566
|
const { createDocxBlob } = await import("./0~work-docx-export.js");
|
|
83
|
-
|
|
567
|
+
const sourcePackage = artifact.source ? await readVerifiedWorkSourceBytes(artifact) : void 0;
|
|
568
|
+
return createDocxBlob(materializeWorkDocumentContent(artifact.content), sourcePackage);
|
|
84
569
|
}
|
|
85
570
|
function textToHtml(source) {
|
|
86
571
|
const blocks = source.replace(/\r\n?/g, '\n').split(/\n{2,}/).map((block)=>block.trim()).filter(Boolean);
|
|
@@ -91,7 +576,7 @@ function textToHtml(source) {
|
|
|
91
576
|
}).join('');
|
|
92
577
|
}
|
|
93
578
|
async function withStructuredDocumentModel(content) {
|
|
94
|
-
const { createWorkDocumentModelFromContent } = await import("./
|
|
579
|
+
const { createWorkDocumentModelFromContent } = await import("./8928.js");
|
|
95
580
|
return createWorkDocumentModelFromContent(content);
|
|
96
581
|
}
|
|
97
582
|
function escapeHtml(value) {
|
|
@@ -163,18 +648,6 @@ function loadPresentationRuntime(runtimeUrl) {
|
|
|
163
648
|
presentationRuntimePromises.set(resolvedUrl, runtime);
|
|
164
649
|
return runtime;
|
|
165
650
|
}
|
|
166
|
-
const sourceBlobs = new Map();
|
|
167
|
-
function rememberWorkSourceBlob(artifactId, source) {
|
|
168
|
-
sourceBlobs.set(artifactId, source);
|
|
169
|
-
}
|
|
170
|
-
function forgetWorkSourceBlob(artifactId) {
|
|
171
|
-
sourceBlobs.delete(artifactId);
|
|
172
|
-
}
|
|
173
|
-
async function readWorkSourceBlob(artifact) {
|
|
174
|
-
const source = sourceBlobs.get(artifact.id);
|
|
175
|
-
if (source) return source;
|
|
176
|
-
throw new Error(artifact.source ? 'The original file is not available in this browser session. Register it again before opening the PDF.' : 'This document has no original source file.');
|
|
177
|
-
}
|
|
178
651
|
function workArtifactExtension(kind) {
|
|
179
652
|
if ('document' === kind) return 'docx';
|
|
180
653
|
if ('markdown' === kind) return 'md';
|
|
@@ -5060,7 +5533,6 @@ const PRESENTATION_EXTENSIONS = new Set([
|
|
|
5060
5533
|
const PDF_EXTENSIONS = new Set([
|
|
5061
5534
|
'pdf'
|
|
5062
5535
|
]);
|
|
5063
|
-
const WORK_IMPORT_ACCEPT = ".docx,.xlsx,.xls,.csv,.ods,.pptx,.pdf,.html,.htm,.txt,.md,.markdown";
|
|
5064
5536
|
async function importWorkFile(file) {
|
|
5065
5537
|
const extension = file.name.split('.').pop()?.toLowerCase() ?? '';
|
|
5066
5538
|
if (!MARKDOWN_EXTENSIONS.has(extension) && !DOCUMENT_EXTENSIONS.has(extension) && !SPREADSHEET_EXTENSIONS.has(extension) && !PRESENTATION_EXTENSIONS.has(extension) && !PDF_EXTENSIONS.has(extension)) throw new Error('目前可导入 DOCX、XLSX、XLS、ODS、CSV、PPTX、PDF、HTML、Markdown 和文本文件。');
|
|
@@ -5495,6 +5967,343 @@ function workKindForFile(file) {
|
|
|
5495
5967
|
if (PDF_EXTENSIONS.has(extension)) return 'pdf';
|
|
5496
5968
|
return null;
|
|
5497
5969
|
}
|
|
5970
|
+
const WORK_IMPORT_ACCEPT = ".docx,.xlsx,.xls,.csv,.ods,.pptx,.pdf,.html,.htm,.txt,.md,.markdown";
|
|
5971
|
+
const WORK_DOCUMENT_SNAPSHOT_SCHEMA = 'a3s.office.document.snapshot';
|
|
5972
|
+
const WORK_DOCUMENT_SNAPSHOT_VERSION = 1;
|
|
5973
|
+
const WORK_DOCUMENT_SNAPSHOT_MEDIA_TYPE = 'application/vnd.a3s.office.document-snapshot+json;version=1';
|
|
5974
|
+
const MAX_DOCUMENT_SNAPSHOT_BYTES = 16777216;
|
|
5975
|
+
const MAX_DOCUMENT_SNAPSHOT_DEPTH = 512;
|
|
5976
|
+
const MAX_DOCUMENT_SNAPSHOT_VALUES = 2000000;
|
|
5977
|
+
function encodeWorkDocumentSnapshot(content) {
|
|
5978
|
+
assertStructuredDocumentContent(content);
|
|
5979
|
+
let encoded;
|
|
5980
|
+
try {
|
|
5981
|
+
encoded = canonicalJson({
|
|
5982
|
+
schema: WORK_DOCUMENT_SNAPSHOT_SCHEMA,
|
|
5983
|
+
version: WORK_DOCUMENT_SNAPSHOT_VERSION,
|
|
5984
|
+
content
|
|
5985
|
+
});
|
|
5986
|
+
} catch (error) {
|
|
5987
|
+
throw new Error('A3S Office document snapshots must contain only JSON-compatible values.', {
|
|
5988
|
+
cause: error
|
|
5989
|
+
});
|
|
5990
|
+
}
|
|
5991
|
+
assertSnapshotSize(encoded);
|
|
5992
|
+
return encoded;
|
|
5993
|
+
}
|
|
5994
|
+
function decodeWorkDocumentSnapshot(encoded) {
|
|
5995
|
+
if ('string' != typeof encoded) throw new TypeError('An A3S Office document snapshot must be a string.');
|
|
5996
|
+
assertSnapshotSize(encoded);
|
|
5997
|
+
let candidate;
|
|
5998
|
+
try {
|
|
5999
|
+
candidate = JSON.parse(encoded);
|
|
6000
|
+
} catch (error) {
|
|
6001
|
+
throw new Error('The A3S Office document snapshot is not valid JSON.', {
|
|
6002
|
+
cause: error
|
|
6003
|
+
});
|
|
6004
|
+
}
|
|
6005
|
+
if (!work_document_snapshot_isRecord(candidate)) throw new Error('The A3S Office document snapshot envelope is invalid.');
|
|
6006
|
+
if (candidate.schema !== WORK_DOCUMENT_SNAPSHOT_SCHEMA) throw new Error('The A3S Office document snapshot schema is unsupported.');
|
|
6007
|
+
if (candidate.version !== WORK_DOCUMENT_SNAPSHOT_VERSION) throw new Error(`A3S Office document snapshot version ${String(candidate.version)} is unsupported.`);
|
|
6008
|
+
const envelopeKeys = Object.keys(candidate);
|
|
6009
|
+
if (3 !== envelopeKeys.length || !envelopeKeys.includes('schema') || !envelopeKeys.includes('version') || !envelopeKeys.includes('content')) throw new Error('The A3S Office document snapshot envelope is invalid.');
|
|
6010
|
+
assertStructuredDocumentContent(candidate.content);
|
|
6011
|
+
return candidate.content;
|
|
6012
|
+
}
|
|
6013
|
+
function assertStructuredDocumentContent(candidate) {
|
|
6014
|
+
if (!work_document_snapshot_isRecord(candidate) || 'document' !== candidate.type || 'string' != typeof candidate.html || 'a4' !== candidate.pageSize && 'letter' !== candidate.pageSize) throw new Error('An A3S Office document snapshot must contain a valid document value.');
|
|
6015
|
+
if (!candidate.model || !documentModelForContent(candidate)) throw new Error('An A3S Office document snapshot requires a synchronized structured model.');
|
|
6016
|
+
}
|
|
6017
|
+
function assertSnapshotSize(encoded) {
|
|
6018
|
+
if (new TextEncoder().encode(encoded).byteLength > MAX_DOCUMENT_SNAPSHOT_BYTES) throw new Error(`The A3S Office document snapshot exceeds ${MAX_DOCUMENT_SNAPSHOT_BYTES} bytes.`);
|
|
6019
|
+
}
|
|
6020
|
+
function canonicalJson(value) {
|
|
6021
|
+
const ancestors = new Set();
|
|
6022
|
+
const budget = {
|
|
6023
|
+
values: 0
|
|
6024
|
+
};
|
|
6025
|
+
return encodeCanonicalValue(value, ancestors, budget, 0);
|
|
6026
|
+
}
|
|
6027
|
+
function encodeCanonicalValue(value, ancestors, budget, depth) {
|
|
6028
|
+
budget.values += 1;
|
|
6029
|
+
if (budget.values > MAX_DOCUMENT_SNAPSHOT_VALUES || depth > MAX_DOCUMENT_SNAPSHOT_DEPTH) throw new TypeError('The JSON value graph exceeds the snapshot limits.');
|
|
6030
|
+
if (null === value || 'string' == typeof value || 'boolean' == typeof value) return JSON.stringify(value);
|
|
6031
|
+
if ('number' == typeof value) {
|
|
6032
|
+
if (!Number.isFinite(value)) throw new TypeError('Non-finite numbers are not JSON-compatible.');
|
|
6033
|
+
return JSON.stringify(value);
|
|
6034
|
+
}
|
|
6035
|
+
if ('object' != typeof value || ancestors.has(value)) throw new TypeError('The value is not an acyclic JSON value.');
|
|
6036
|
+
ancestors.add(value);
|
|
6037
|
+
try {
|
|
6038
|
+
if (Array.isArray(value)) return `[${value.map((item)=>{
|
|
6039
|
+
if (void 0 === item) throw new TypeError('Undefined array entries are not supported.');
|
|
6040
|
+
return encodeCanonicalValue(item, ancestors, budget, depth + 1);
|
|
6041
|
+
}).join(',')}]`;
|
|
6042
|
+
const prototype = Object.getPrototypeOf(value);
|
|
6043
|
+
if (prototype !== Object.prototype && null !== prototype) throw new TypeError('Only plain JSON objects are supported.');
|
|
6044
|
+
const symbols = Object.getOwnPropertySymbols(value);
|
|
6045
|
+
if (symbols.length) throw new TypeError('Symbol properties are not JSON-compatible.');
|
|
6046
|
+
const entries = [];
|
|
6047
|
+
for (const key of Object.keys(value).sort()){
|
|
6048
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
6049
|
+
if (!descriptor || descriptor.get || descriptor.set) throw new TypeError('Accessor properties are not JSON-compatible.');
|
|
6050
|
+
if (void 0 !== descriptor.value) entries.push(`${JSON.stringify(key)}:${encodeCanonicalValue(descriptor.value, ancestors, budget, depth + 1)}`);
|
|
6051
|
+
}
|
|
6052
|
+
return `{${entries.join(',')}}`;
|
|
6053
|
+
} finally{
|
|
6054
|
+
ancestors.delete(value);
|
|
6055
|
+
}
|
|
6056
|
+
}
|
|
6057
|
+
function work_document_snapshot_isRecord(value) {
|
|
6058
|
+
return 'object' == typeof value && null !== value && !Array.isArray(value);
|
|
6059
|
+
}
|
|
6060
|
+
const WORK_DOCUMENT_SOURCE_SCHEMA = 'a3s.office.document.source';
|
|
6061
|
+
const WORK_DOCUMENT_SOURCE_VERSION = 1;
|
|
6062
|
+
const WORK_DOCUMENT_SOURCE_MEDIA_TYPE = 'text/markdown; charset=utf-8';
|
|
6063
|
+
let markdownManager = null;
|
|
6064
|
+
let documentSchema = null;
|
|
6065
|
+
function projectWorkDocumentSource(content) {
|
|
6066
|
+
const section = singleDocumentSection(content);
|
|
6067
|
+
let source;
|
|
6068
|
+
try {
|
|
6069
|
+
source = documentMarkdownManager().serialize({
|
|
6070
|
+
type: 'doc',
|
|
6071
|
+
content: section.content ?? []
|
|
6072
|
+
});
|
|
6073
|
+
} catch (error) {
|
|
6074
|
+
throw new Error('The structured document cannot be projected into the version 1 Markdown source contract.', {
|
|
6075
|
+
cause: error
|
|
6076
|
+
});
|
|
6077
|
+
}
|
|
6078
|
+
return {
|
|
6079
|
+
schema: WORK_DOCUMENT_SOURCE_SCHEMA,
|
|
6080
|
+
version: WORK_DOCUMENT_SOURCE_VERSION,
|
|
6081
|
+
mediaType: WORK_DOCUMENT_SOURCE_MEDIA_TYPE,
|
|
6082
|
+
content: source
|
|
6083
|
+
};
|
|
6084
|
+
}
|
|
6085
|
+
function applyWorkDocumentSource(content, source) {
|
|
6086
|
+
assertDocumentSource(source);
|
|
6087
|
+
const model = documentModelForContent(content);
|
|
6088
|
+
if (!model) throw new Error('Applying a document source requires a synchronized structured snapshot.');
|
|
6089
|
+
const section = singleDocumentSection(content);
|
|
6090
|
+
let parsed;
|
|
6091
|
+
try {
|
|
6092
|
+
parsed = documentMarkdownManager().parse(source.content);
|
|
6093
|
+
} catch (error) {
|
|
6094
|
+
throw new Error('The version 1 document source is not valid supported Markdown.', {
|
|
6095
|
+
cause: error
|
|
6096
|
+
});
|
|
6097
|
+
}
|
|
6098
|
+
const parsedBody = parsed.content?.length ? parsed.content : [
|
|
6099
|
+
{
|
|
6100
|
+
type: 'paragraph'
|
|
6101
|
+
}
|
|
6102
|
+
];
|
|
6103
|
+
const body = retainSurvivingDocumentCommentAnchors(section.content ?? [], parsedBody);
|
|
6104
|
+
const root = normalizeDocumentRoot({
|
|
6105
|
+
...model.root,
|
|
6106
|
+
content: [
|
|
6107
|
+
{
|
|
6108
|
+
...section,
|
|
6109
|
+
...section.attrs ? {
|
|
6110
|
+
attrs: structuredClone(section.attrs)
|
|
6111
|
+
} : {},
|
|
6112
|
+
content: body
|
|
6113
|
+
}
|
|
6114
|
+
]
|
|
6115
|
+
});
|
|
6116
|
+
const staged = {
|
|
6117
|
+
...content,
|
|
6118
|
+
model: createWorkDocumentModel(content.html, root, model)
|
|
6119
|
+
};
|
|
6120
|
+
return work_document_model_codec_materializeWorkDocumentContent(staged);
|
|
6121
|
+
}
|
|
6122
|
+
function normalizeDocumentRoot(root) {
|
|
6123
|
+
try {
|
|
6124
|
+
documentSchema ??= getSchema(createWorkDocumentExtensions());
|
|
6125
|
+
return documentSchema.nodeFromJSON(root).toJSON();
|
|
6126
|
+
} catch (error) {
|
|
6127
|
+
throw new Error('The version 1 document source cannot be represented by the Office document schema.', {
|
|
6128
|
+
cause: error
|
|
6129
|
+
});
|
|
6130
|
+
}
|
|
6131
|
+
}
|
|
6132
|
+
function singleDocumentSection(content) {
|
|
6133
|
+
const model = documentModelForContent(content);
|
|
6134
|
+
if (!model) throw new Error('The document source contract requires a synchronized structured snapshot.');
|
|
6135
|
+
const sections = (model.root.content ?? []).filter((node)=>'documentSection' === node.type);
|
|
6136
|
+
if (1 !== sections.length || model.root.content?.length !== 1) throw new Error('The version 1 document source contract requires exactly one structured section.');
|
|
6137
|
+
return sections[0];
|
|
6138
|
+
}
|
|
6139
|
+
function assertDocumentSource(source) {
|
|
6140
|
+
if (!source || source.schema !== WORK_DOCUMENT_SOURCE_SCHEMA || source.version !== WORK_DOCUMENT_SOURCE_VERSION || source.mediaType !== WORK_DOCUMENT_SOURCE_MEDIA_TYPE || 'string' != typeof source.content) throw new Error('The A3S Office document source envelope is invalid.');
|
|
6141
|
+
}
|
|
6142
|
+
function documentMarkdownManager() {
|
|
6143
|
+
markdownManager ??= new MarkdownManager({
|
|
6144
|
+
extensions: createWorkDocumentExtensions(),
|
|
6145
|
+
indentation: {
|
|
6146
|
+
style: 'space',
|
|
6147
|
+
size: 2
|
|
6148
|
+
},
|
|
6149
|
+
markedOptions: {
|
|
6150
|
+
gfm: true,
|
|
6151
|
+
breaks: false,
|
|
6152
|
+
pedantic: false
|
|
6153
|
+
}
|
|
6154
|
+
});
|
|
6155
|
+
return markdownManager;
|
|
6156
|
+
}
|
|
6157
|
+
const DOCUMENT_COMMENT_MARK = 'documentComment';
|
|
6158
|
+
const DOCUMENT_COMMENT_CONTEXT_LENGTH = 64;
|
|
6159
|
+
function retainSurvivingDocumentCommentAnchors(previousBody, nextBody) {
|
|
6160
|
+
const previous = indexDocumentText(previousBody);
|
|
6161
|
+
const next = indexDocumentText(nextBody);
|
|
6162
|
+
const ranges = collectDocumentCommentAnchors(previous).flatMap((anchor)=>{
|
|
6163
|
+
const anchorText = previous.content.slice(anchor.from, anchor.to);
|
|
6164
|
+
if (!anchor.valid || !anchorText) return [];
|
|
6165
|
+
const candidates = exactTextOccurrences(next.content, anchorText);
|
|
6166
|
+
const destination = uniqueCommentDestination(next.content, anchor, candidates);
|
|
6167
|
+
return null === destination ? [] : [
|
|
6168
|
+
{
|
|
6169
|
+
id: anchor.id,
|
|
6170
|
+
from: destination,
|
|
6171
|
+
to: destination + anchorText.length
|
|
6172
|
+
}
|
|
6173
|
+
];
|
|
6174
|
+
});
|
|
6175
|
+
return applyDocumentCommentRanges(nextBody, ranges);
|
|
6176
|
+
}
|
|
6177
|
+
function indexDocumentText(nodes) {
|
|
6178
|
+
const spans = [];
|
|
6179
|
+
let content = '';
|
|
6180
|
+
const visit = (node)=>{
|
|
6181
|
+
if ('text' === node.type && 'string' == typeof node.text) {
|
|
6182
|
+
const from = content.length;
|
|
6183
|
+
content += node.text;
|
|
6184
|
+
spans.push({
|
|
6185
|
+
from,
|
|
6186
|
+
to: content.length,
|
|
6187
|
+
node
|
|
6188
|
+
});
|
|
6189
|
+
}
|
|
6190
|
+
for (const child of node.content ?? [])visit(child);
|
|
6191
|
+
};
|
|
6192
|
+
for (const node of nodes)visit(node);
|
|
6193
|
+
return {
|
|
6194
|
+
content,
|
|
6195
|
+
spans
|
|
6196
|
+
};
|
|
6197
|
+
}
|
|
6198
|
+
function collectDocumentCommentAnchors(index) {
|
|
6199
|
+
const anchors = new Map();
|
|
6200
|
+
for (const span of index.spans)for (const mark of span.node.marks ?? []){
|
|
6201
|
+
const id = documentCommentId(mark);
|
|
6202
|
+
if (!id) continue;
|
|
6203
|
+
const current = anchors.get(id);
|
|
6204
|
+
if (current) {
|
|
6205
|
+
current.valid = current.valid && current.to === span.from;
|
|
6206
|
+
current.to = span.to;
|
|
6207
|
+
continue;
|
|
6208
|
+
}
|
|
6209
|
+
anchors.set(id, {
|
|
6210
|
+
id,
|
|
6211
|
+
from: span.from,
|
|
6212
|
+
to: span.to,
|
|
6213
|
+
prefix: '',
|
|
6214
|
+
suffix: '',
|
|
6215
|
+
valid: true
|
|
6216
|
+
});
|
|
6217
|
+
}
|
|
6218
|
+
for (const anchor of anchors.values()){
|
|
6219
|
+
anchor.prefix = index.content.slice(Math.max(0, anchor.from - DOCUMENT_COMMENT_CONTEXT_LENGTH), anchor.from);
|
|
6220
|
+
anchor.suffix = index.content.slice(anchor.to, anchor.to + DOCUMENT_COMMENT_CONTEXT_LENGTH);
|
|
6221
|
+
}
|
|
6222
|
+
return Array.from(anchors.values()).sort((left, right)=>left.from - right.from || left.id.localeCompare(right.id));
|
|
6223
|
+
}
|
|
6224
|
+
function documentCommentId(mark) {
|
|
6225
|
+
if (mark.type !== DOCUMENT_COMMENT_MARK) return '';
|
|
6226
|
+
const id = mark.attrs?.id;
|
|
6227
|
+
return 'string' == typeof id ? id.trim() : '';
|
|
6228
|
+
}
|
|
6229
|
+
function exactTextOccurrences(content, value) {
|
|
6230
|
+
const occurrences = [];
|
|
6231
|
+
let cursor = 0;
|
|
6232
|
+
while(cursor <= content.length - value.length){
|
|
6233
|
+
const position = content.indexOf(value, cursor);
|
|
6234
|
+
if (position < 0) break;
|
|
6235
|
+
occurrences.push(position);
|
|
6236
|
+
cursor = position + 1;
|
|
6237
|
+
}
|
|
6238
|
+
return occurrences;
|
|
6239
|
+
}
|
|
6240
|
+
function uniqueCommentDestination(content, anchor, candidates) {
|
|
6241
|
+
if (1 === candidates.length) return candidates[0] ?? null;
|
|
6242
|
+
const contextual = candidates.filter((candidate)=>{
|
|
6243
|
+
const preceding = content.slice(Math.max(0, candidate - anchor.prefix.length), candidate);
|
|
6244
|
+
const following = content.slice(candidate + (anchor.to - anchor.from), candidate + (anchor.to - anchor.from) + anchor.suffix.length);
|
|
6245
|
+
return preceding === anchor.prefix && following === anchor.suffix;
|
|
6246
|
+
});
|
|
6247
|
+
return 1 === contextual.length ? contextual[0] ?? null : null;
|
|
6248
|
+
}
|
|
6249
|
+
function applyDocumentCommentRanges(nodes, ranges) {
|
|
6250
|
+
let offset = 0;
|
|
6251
|
+
const rewrite = (node)=>{
|
|
6252
|
+
const marks = (node.marks ?? []).filter((mark)=>mark.type !== DOCUMENT_COMMENT_MARK);
|
|
6253
|
+
const { content: _content, marks: _marks, ...properties } = node;
|
|
6254
|
+
if ('text' === node.type && 'string' == typeof node.text) {
|
|
6255
|
+
const from = offset;
|
|
6256
|
+
const to = from + node.text.length;
|
|
6257
|
+
offset = to;
|
|
6258
|
+
const boundaries = new Set([
|
|
6259
|
+
from,
|
|
6260
|
+
to
|
|
6261
|
+
]);
|
|
6262
|
+
for (const range of ranges){
|
|
6263
|
+
if (range.from > from && range.from < to) boundaries.add(range.from);
|
|
6264
|
+
if (range.to > from && range.to < to) boundaries.add(range.to);
|
|
6265
|
+
}
|
|
6266
|
+
const ordered = Array.from(boundaries).sort((left, right)=>left - right);
|
|
6267
|
+
const rewritten = [];
|
|
6268
|
+
for(let index = 0; index < ordered.length - 1; index += 1){
|
|
6269
|
+
const chunkFrom = ordered[index];
|
|
6270
|
+
const chunkTo = ordered[index + 1];
|
|
6271
|
+
if (void 0 === chunkFrom || void 0 === chunkTo || chunkFrom === chunkTo) continue;
|
|
6272
|
+
const commentMarks = ranges.filter((range)=>range.from <= chunkFrom && range.to >= chunkTo).map((range)=>({
|
|
6273
|
+
type: DOCUMENT_COMMENT_MARK,
|
|
6274
|
+
attrs: {
|
|
6275
|
+
id: range.id
|
|
6276
|
+
}
|
|
6277
|
+
}));
|
|
6278
|
+
const nextMarks = [
|
|
6279
|
+
...marks,
|
|
6280
|
+
...commentMarks
|
|
6281
|
+
];
|
|
6282
|
+
rewritten.push({
|
|
6283
|
+
...properties,
|
|
6284
|
+
text: node.text.slice(chunkFrom - from, chunkTo - from),
|
|
6285
|
+
...nextMarks.length ? {
|
|
6286
|
+
marks: nextMarks
|
|
6287
|
+
} : {}
|
|
6288
|
+
});
|
|
6289
|
+
}
|
|
6290
|
+
return rewritten;
|
|
6291
|
+
}
|
|
6292
|
+
const content = (node.content ?? []).flatMap(rewrite);
|
|
6293
|
+
return [
|
|
6294
|
+
{
|
|
6295
|
+
...properties,
|
|
6296
|
+
...content.length ? {
|
|
6297
|
+
content
|
|
6298
|
+
} : {},
|
|
6299
|
+
...marks.length ? {
|
|
6300
|
+
marks
|
|
6301
|
+
} : {}
|
|
6302
|
+
}
|
|
6303
|
+
];
|
|
6304
|
+
};
|
|
6305
|
+
return nodes.flatMap(rewrite);
|
|
6306
|
+
}
|
|
5498
6307
|
const PDF_PAGE_DIMENSIONS = {
|
|
5499
6308
|
a3: {
|
|
5500
6309
|
width: 841.89,
|
|
@@ -5537,31 +6346,51 @@ async function exportWorkArtifactPdf(artifact, options = {}) {
|
|
|
5537
6346
|
]);
|
|
5538
6347
|
let pdf = null;
|
|
5539
6348
|
if (liveDocument) {
|
|
5540
|
-
const
|
|
6349
|
+
const firstSelectedPage = livePageIndexes[0] ?? 0;
|
|
6350
|
+
const capture = mountWorkLiveDocumentCapture(liveDocument, firstSelectedPage);
|
|
5541
6351
|
try {
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
6352
|
+
if (uniformLiveDocumentPages(liveDocument.pages)) {
|
|
6353
|
+
const batches = workLiveDocumentPdfCaptureBatches(livePageIndexes, liveDocument);
|
|
6354
|
+
for (const batch of batches){
|
|
6355
|
+
const firstPage = positionWorkLiveDocumentCapture(capture, liveDocument, batch.firstPageIndex, batch.captureHeight);
|
|
6356
|
+
await nextPaint();
|
|
6357
|
+
const batchCanvas = await html2canvas(capture.viewport, {
|
|
6358
|
+
backgroundColor: capture.backgroundColor,
|
|
6359
|
+
height: batch.captureHeight,
|
|
6360
|
+
logging: false,
|
|
6361
|
+
scale: 2,
|
|
6362
|
+
useCORS: true,
|
|
6363
|
+
width: firstPage.width,
|
|
6364
|
+
windowHeight: Math.ceil(batch.captureHeight),
|
|
6365
|
+
windowWidth: Math.ceil(firstPage.width)
|
|
6366
|
+
});
|
|
6367
|
+
const scaleY = batchCanvas.height / batch.captureHeight;
|
|
6368
|
+
for (const pageIndex of batch.pageIndexes){
|
|
6369
|
+
const page = liveDocument.pages[pageIndex];
|
|
6370
|
+
if (!page) continue;
|
|
6371
|
+
const pageOffset = page.top - firstPage.top;
|
|
6372
|
+
const sourceTop = Math.round(pageOffset * scaleY);
|
|
6373
|
+
const sourceBottom = Math.round((pageOffset + page.height) * scaleY);
|
|
6374
|
+
const pageCanvas = cropDocumentCanvas(batchCanvas, sourceTop, Math.max(1, sourceBottom - sourceTop), capture.backgroundColor);
|
|
6375
|
+
pdf = appendLiveDocumentCanvasPage(pdf, pageCanvas, page, jsPDF);
|
|
6376
|
+
}
|
|
6377
|
+
}
|
|
6378
|
+
} else for (const pageIndex of livePageIndexes){
|
|
6379
|
+
const page = liveDocument.pages[pageIndex];
|
|
6380
|
+
if (!page) continue;
|
|
6381
|
+
positionWorkLiveDocumentCapture(capture, liveDocument, pageIndex);
|
|
5546
6382
|
await nextPaint();
|
|
5547
|
-
const
|
|
6383
|
+
const pageCanvas = await html2canvas(capture.viewport, {
|
|
5548
6384
|
backgroundColor: capture.backgroundColor,
|
|
5549
|
-
height:
|
|
6385
|
+
height: page.height,
|
|
5550
6386
|
logging: false,
|
|
5551
6387
|
scale: 2,
|
|
5552
6388
|
useCORS: true,
|
|
5553
|
-
width:
|
|
5554
|
-
windowHeight: Math.ceil(
|
|
5555
|
-
windowWidth: Math.ceil(
|
|
6389
|
+
width: page.width,
|
|
6390
|
+
windowHeight: Math.ceil(page.height),
|
|
6391
|
+
windowWidth: Math.ceil(page.width)
|
|
5556
6392
|
});
|
|
5557
|
-
|
|
5558
|
-
for (const pageIndex of batch.pageIndexes){
|
|
5559
|
-
const pageOffset = (pageIndex - batch.firstPageIndex) * (liveDocument.pageHeight + liveDocument.pageGap);
|
|
5560
|
-
const sourceTop = Math.round(pageOffset * scaleY);
|
|
5561
|
-
const sourceBottom = Math.round((pageOffset + liveDocument.pageHeight) * scaleY);
|
|
5562
|
-
const pageCanvas = cropDocumentCanvas(batchCanvas, sourceTop, Math.max(1, sourceBottom - sourceTop), capture.backgroundColor);
|
|
5563
|
-
pdf = appendExactCanvasPage(pdf, pageCanvas, liveDocument.orientation, liveDocument.pageSize, jsPDF);
|
|
5564
|
-
}
|
|
6393
|
+
pdf = appendLiveDocumentCanvasPage(pdf, pageCanvas, page, jsPDF);
|
|
5565
6394
|
}
|
|
5566
6395
|
} finally{
|
|
5567
6396
|
capture.host.remove();
|
|
@@ -5569,6 +6398,7 @@ async function exportWorkArtifactPdf(artifact, options = {}) {
|
|
|
5569
6398
|
} else for (const page of pages){
|
|
5570
6399
|
const orientation = 'portrait' === page.dataset.pdfOrientation ? 'portrait' : 'landscape';
|
|
5571
6400
|
const pageSize = pdfPageSize(page.dataset.pdfPageSize);
|
|
6401
|
+
const pageDefinition = pdfPageDefinition(pageSize, orientation, finiteDatasetNumber(page.dataset.pdfPageWidthPoints, 1), finiteDatasetNumber(page.dataset.pdfPageHeightPoints, 1));
|
|
5572
6402
|
const backgroundColor = getComputedStyle(page).backgroundColor || '#ffffff';
|
|
5573
6403
|
const canvas = await html2canvas(page, {
|
|
5574
6404
|
backgroundColor,
|
|
@@ -5578,7 +6408,7 @@ async function exportWorkArtifactPdf(artifact, options = {}) {
|
|
|
5578
6408
|
windowWidth: Math.max(page.scrollWidth, page.clientWidth),
|
|
5579
6409
|
windowHeight: Math.max(page.scrollHeight, page.clientHeight)
|
|
5580
6410
|
});
|
|
5581
|
-
pdf = appendCanvas(pdf, canvas, orientation,
|
|
6411
|
+
pdf = appendCanvas(pdf, canvas, orientation, pageDefinition, backgroundColor, jsPDF);
|
|
5582
6412
|
}
|
|
5583
6413
|
if (!pdf) throw new Error('PDF export did not produce any pages.');
|
|
5584
6414
|
pdf.setProperties({
|
|
@@ -5597,15 +6427,61 @@ function workLiveDocumentPdfSurfaceForExport(artifactId) {
|
|
|
5597
6427
|
const pageGap = finiteDatasetNumber(element.dataset.pdfPageGap, 0);
|
|
5598
6428
|
const pageHeight = finiteDatasetNumber(element.dataset.pdfPageHeight, 1);
|
|
5599
6429
|
const pageWidth = finiteDatasetNumber(element.dataset.pdfPageWidth, 1);
|
|
6430
|
+
const fallback = pdfPageDefinition(pdfPageSize(element.dataset.pdfPageSize), 'landscape' === element.dataset.pdfOrientation ? 'landscape' : 'portrait');
|
|
6431
|
+
const pageHeightPoints = finiteDatasetNumber(element.dataset.pdfPageHeightPoints, 1) ?? fallback.height;
|
|
6432
|
+
const pageWidthPoints = finiteDatasetNumber(element.dataset.pdfPageWidthPoints, 1) ?? fallback.width;
|
|
5600
6433
|
if (null === pageCount || null === pageGap || null === pageHeight || null === pageWidth || !Number.isSafeInteger(pageCount) || pageCount > 10000 || Number(editor.dataset.paginationPages) !== pageCount) return null;
|
|
6434
|
+
const sheets = Array.from(element.querySelectorAll('.work-document-page-stack > [data-work-document-page-sheet]'));
|
|
6435
|
+
if (sheets.length > 0 && sheets.length !== pageCount) return null;
|
|
6436
|
+
const pages = sheets.length ? sheets.map((sheet, pageIndex)=>liveDocumentPdfPageFromSheet(sheet, pageIndex)) : Array.from({
|
|
6437
|
+
length: pageCount
|
|
6438
|
+
}, (_, pageIndex)=>({
|
|
6439
|
+
height: pageHeight,
|
|
6440
|
+
left: 0,
|
|
6441
|
+
orientation: 'landscape' === element.dataset.pdfOrientation ? 'landscape' : 'portrait',
|
|
6442
|
+
pageHeightPoints,
|
|
6443
|
+
pageSize: pdfPageSize(element.dataset.pdfPageSize),
|
|
6444
|
+
pageWidthPoints,
|
|
6445
|
+
top: pageIndex * (pageHeight + pageGap),
|
|
6446
|
+
width: pageWidth
|
|
6447
|
+
}));
|
|
6448
|
+
if (pages.some((page)=>null === page)) return null;
|
|
6449
|
+
const resolvedPages = pages;
|
|
6450
|
+
const firstPage = resolvedPages[0];
|
|
6451
|
+
if (!firstPage) return null;
|
|
6452
|
+
const resolvedPageGap = resolvedPages.length > 1 ? Math.max(0, resolvedPages[1].top - firstPage.top - firstPage.height) : pageGap;
|
|
6453
|
+
const surfaceWidth = Math.max(1, ...resolvedPages.map((page)=>page.left + page.width));
|
|
5601
6454
|
return {
|
|
5602
6455
|
element,
|
|
5603
|
-
orientation:
|
|
6456
|
+
orientation: firstPage.orientation,
|
|
5604
6457
|
pageCount,
|
|
5605
|
-
pageGap,
|
|
5606
|
-
pageHeight,
|
|
5607
|
-
|
|
5608
|
-
|
|
6458
|
+
pageGap: resolvedPageGap,
|
|
6459
|
+
pageHeight: firstPage.height,
|
|
6460
|
+
pageHeightPoints: firstPage.pageHeightPoints,
|
|
6461
|
+
pageSize: firstPage.pageSize,
|
|
6462
|
+
pageWidth: surfaceWidth,
|
|
6463
|
+
pageWidthPoints: firstPage.pageWidthPoints,
|
|
6464
|
+
pages: resolvedPages
|
|
6465
|
+
};
|
|
6466
|
+
}
|
|
6467
|
+
function liveDocumentPdfPageFromSheet(sheet, pageIndex) {
|
|
6468
|
+
if (Number(sheet.dataset.pageIndex) !== pageIndex + 1) return null;
|
|
6469
|
+
const height = finiteDatasetNumber(sheet.dataset.pageHeight, 1);
|
|
6470
|
+
const left = finiteDatasetNumber(sheet.dataset.pageLeft, 0);
|
|
6471
|
+
const pageHeightPoints = finiteDatasetNumber(sheet.dataset.pdfPageHeightPoints, 1);
|
|
6472
|
+
const pageWidthPoints = finiteDatasetNumber(sheet.dataset.pdfPageWidthPoints, 1);
|
|
6473
|
+
const top = finiteDatasetNumber(sheet.dataset.pageTop, 0);
|
|
6474
|
+
const width = finiteDatasetNumber(sheet.dataset.pageWidth, 1);
|
|
6475
|
+
if (null === height || null === left || null === pageHeightPoints || null === pageWidthPoints || null === top || null === width) return null;
|
|
6476
|
+
return {
|
|
6477
|
+
height,
|
|
6478
|
+
left,
|
|
6479
|
+
orientation: 'landscape' === sheet.dataset.pdfOrientation ? 'landscape' : 'portrait',
|
|
6480
|
+
pageHeightPoints,
|
|
6481
|
+
pageSize: pdfPageSize(sheet.dataset.pdfPageSize),
|
|
6482
|
+
pageWidthPoints,
|
|
6483
|
+
top,
|
|
6484
|
+
width
|
|
5609
6485
|
};
|
|
5610
6486
|
}
|
|
5611
6487
|
function workPdfPagesForExport(artifactId, options = {}) {
|
|
@@ -5647,6 +6523,17 @@ function workLiveDocumentPdfCaptureBatches(pageIndexes, page) {
|
|
|
5647
6523
|
}
|
|
5648
6524
|
return batches;
|
|
5649
6525
|
}
|
|
6526
|
+
function uniformLiveDocumentPages(pages) {
|
|
6527
|
+
const first = pages[0];
|
|
6528
|
+
if (!first) return false;
|
|
6529
|
+
const firstGap = pages[1] ? pages[1].top - first.top - first.height : 0;
|
|
6530
|
+
return pages.every((page, pageIndex)=>{
|
|
6531
|
+
if (page.width !== first.width || page.height !== first.height || page.left !== first.left) return false;
|
|
6532
|
+
if (0 === pageIndex) return true;
|
|
6533
|
+
const previous = pages[pageIndex - 1];
|
|
6534
|
+
return Boolean(previous && page.top - previous.top - previous.height === firstGap);
|
|
6535
|
+
});
|
|
6536
|
+
}
|
|
5650
6537
|
function finiteDatasetNumber(value, minimum) {
|
|
5651
6538
|
if (void 0 === value || '' === value.trim()) return null;
|
|
5652
6539
|
const parsed = Number(value);
|
|
@@ -5656,20 +6543,20 @@ function finiteDatasetNumber(value, minimum) {
|
|
|
5656
6543
|
function pdfSurfaceForArtifact(mode, artifactId) {
|
|
5657
6544
|
return Array.from(document.querySelectorAll(`[data-work-pdf-surface="${mode}"][data-work-pdf-artifact]`)).find((surface)=>surface.dataset.workPdfArtifact === artifactId);
|
|
5658
6545
|
}
|
|
5659
|
-
function appendCanvas(pdf, source, orientation,
|
|
6546
|
+
function appendCanvas(pdf, source, orientation, page, backgroundColor, Pdf) {
|
|
5660
6547
|
let document1 = pdf;
|
|
6548
|
+
const pageOrientation = Array.isArray(page.format) ? page.width > page.height ? 'landscape' : 'portrait' : orientation;
|
|
5661
6549
|
const ensurePage = ()=>{
|
|
5662
|
-
if (document1) document1.addPage(
|
|
6550
|
+
if (document1) document1.addPage(page.format, pageOrientation);
|
|
5663
6551
|
else document1 = new Pdf({
|
|
5664
|
-
orientation,
|
|
6552
|
+
orientation: pageOrientation,
|
|
5665
6553
|
unit: 'pt',
|
|
5666
|
-
format:
|
|
6554
|
+
format: page.format,
|
|
5667
6555
|
compress: true
|
|
5668
6556
|
});
|
|
5669
6557
|
};
|
|
5670
|
-
const
|
|
5671
|
-
const
|
|
5672
|
-
const standardHeight = 'portrait' === orientation ? dimensions.height : dimensions.width;
|
|
6558
|
+
const standardWidth = page.width;
|
|
6559
|
+
const standardHeight = page.height;
|
|
5673
6560
|
const sliceHeight = Math.max(1, Math.floor(source.width * standardHeight / standardWidth));
|
|
5674
6561
|
for(let offset = 0; offset < source.height; offset += sliceHeight){
|
|
5675
6562
|
ensurePage();
|
|
@@ -5685,23 +6572,46 @@ function appendCanvas(pdf, source, orientation, pageSize, backgroundColor, Pdf)
|
|
|
5685
6572
|
}
|
|
5686
6573
|
return document1;
|
|
5687
6574
|
}
|
|
5688
|
-
function appendExactCanvasPage(pdf, source, orientation,
|
|
6575
|
+
function appendExactCanvasPage(pdf, source, orientation, page, Pdf) {
|
|
6576
|
+
const pageOrientation = Array.isArray(page.format) ? page.width > page.height ? 'landscape' : 'portrait' : orientation;
|
|
5689
6577
|
const document1 = pdf ?? new Pdf({
|
|
5690
|
-
orientation,
|
|
6578
|
+
orientation: pageOrientation,
|
|
5691
6579
|
unit: 'pt',
|
|
5692
|
-
format:
|
|
6580
|
+
format: page.format,
|
|
5693
6581
|
compress: true
|
|
5694
6582
|
});
|
|
5695
|
-
if (pdf) document1.addPage(
|
|
5696
|
-
const
|
|
5697
|
-
const
|
|
5698
|
-
const height = 'portrait' === orientation ? dimensions.height : dimensions.width;
|
|
6583
|
+
if (pdf) document1.addPage(page.format, pageOrientation);
|
|
6584
|
+
const width = page.width;
|
|
6585
|
+
const height = page.height;
|
|
5699
6586
|
document1.addImage(source.toDataURL('image/jpeg', 0.92), 'JPEG', 0, 0, width, height, void 0, 'FAST');
|
|
5700
6587
|
return document1;
|
|
5701
6588
|
}
|
|
6589
|
+
function appendLiveDocumentCanvasPage(pdf, source, page, Pdf) {
|
|
6590
|
+
return appendExactCanvasPage(pdf, source, page.orientation, pdfPageDefinition(page.pageSize, page.orientation, page.pageWidthPoints, page.pageHeightPoints), Pdf);
|
|
6591
|
+
}
|
|
5702
6592
|
function pdfPageSize(value) {
|
|
5703
6593
|
return value && Object.hasOwn(PDF_PAGE_DIMENSIONS, value) ? value : 'a4';
|
|
5704
6594
|
}
|
|
6595
|
+
function pdfPageDefinition(pageSize, orientation, exactWidth, exactHeight) {
|
|
6596
|
+
if (null != exactWidth && null != exactHeight) return {
|
|
6597
|
+
format: [
|
|
6598
|
+
exactWidth,
|
|
6599
|
+
exactHeight
|
|
6600
|
+
],
|
|
6601
|
+
width: exactWidth,
|
|
6602
|
+
height: exactHeight
|
|
6603
|
+
};
|
|
6604
|
+
const dimensions = PDF_PAGE_DIMENSIONS[pageSize];
|
|
6605
|
+
return 'portrait' === orientation ? {
|
|
6606
|
+
format: pageSize,
|
|
6607
|
+
width: dimensions.width,
|
|
6608
|
+
height: dimensions.height
|
|
6609
|
+
} : {
|
|
6610
|
+
format: pageSize,
|
|
6611
|
+
width: dimensions.height,
|
|
6612
|
+
height: dimensions.width
|
|
6613
|
+
};
|
|
6614
|
+
}
|
|
5705
6615
|
function documentCanvas(width, height) {
|
|
5706
6616
|
const canvas = document.createElement('canvas');
|
|
5707
6617
|
canvas.width = width;
|
|
@@ -5723,4 +6633,4 @@ function nextPaint() {
|
|
|
5723
6633
|
function work_pdf_export_safeFileName(value) {
|
|
5724
6634
|
return value.replace(/[<>:"/\\|?*\u0000-\u001f]/g, '_').trim() || 'A3S Work file';
|
|
5725
6635
|
}
|
|
5726
|
-
export { MAX_XLSX_WORKSHEET_IMAGE_BYTES, WORK_IMPORT_ACCEPT as OFFICE_FILE_ACCEPT, createWorkArtifactBlob as createArtifactBlob, defaultPptxRuntimeUrl, diagnoseXlsxProtection, exportWorkArtifact as downloadArtifact, exportWorkArtifactPdf as downloadArtifactPdf, forgetWorkSourceBlob as forgetSourceBlob, importWorkFile as importOfficeFile, inspectXlsxHeaderFooterText, inspectXlsxPivotTables, isEditableXlsxPaperSizeCode, isSupportedXlsxChartLegend, isSupportedXlsxChartPlotLayout, isSupportedXlsxChartSeriesFormatting, isSupportedXlsxCombinationChartNodes, isSupportedXlsxWorksheetImageContentType, parseXlsxChartAxes, parseXlsxChartLegend, parseXlsxChartPlotLayout, parseXlsxChartSeriesStyle, parseXlsxErrorBars, parseXlsxTrendline, readWorkSourceBlob as readSourceBlob, readXlsxFormulaFeaturesFromPackage, rememberWorkSourceBlob as registerSourceBlob, workArtifactExtension as artifactExtension, workArtifactKindLabel as artifactKindLabel, workKindForFile as officeKindForFile, workPdfPagesForExport as pdfPagesForExport, xlsxChartNodeUsesStackedGrouping, xlsxChartSeriesFormattingShapeProperties, xlsxChartSeriesMarkerXml, xlsxChartSeriesShapePropertiesXml };
|
|
6636
|
+
export { MAX_XLSX_WORKSHEET_IMAGE_BYTES, WORK_DOCUMENT_SNAPSHOT_MEDIA_TYPE as DOCUMENT_SNAPSHOT_MEDIA_TYPE, WORK_DOCUMENT_SNAPSHOT_SCHEMA as DOCUMENT_SNAPSHOT_SCHEMA, WORK_DOCUMENT_SNAPSHOT_VERSION as DOCUMENT_SNAPSHOT_VERSION, WORK_DOCUMENT_SOURCE_MEDIA_TYPE as DOCUMENT_SOURCE_MEDIA_TYPE, WORK_DOCUMENT_SOURCE_SCHEMA as DOCUMENT_SOURCE_SCHEMA, WORK_DOCUMENT_SOURCE_VERSION as DOCUMENT_SOURCE_VERSION, WORK_IMPORT_ACCEPT as OFFICE_FILE_ACCEPT, WORK_OFFICE_COLLABORATION_DEFAULT_MAX_TRANSPORT_PAYLOAD_BYTES as OFFICE_COLLABORATION_DEFAULT_MAX_TRANSPORT_PAYLOAD_BYTES, WORK_OFFICE_COLLABORATION_MAX_TRANSPORT_PAYLOAD_BYTES as OFFICE_COLLABORATION_MAX_TRANSPORT_PAYLOAD_BYTES, WORK_OFFICE_COLLABORATION_PRESENCE_FIELD as OFFICE_COLLABORATION_PRESENCE_FIELD, applyWorkDocumentSource as applyDocumentSource, createWorkArtifactBlob as createArtifactBlob, createWorkOfficeCollaborationPresence as createOfficeCollaborationPresence, createWorkOfficeCollaborationTransportBinding as createOfficeCollaborationTransportBinding, createWorkPdfCollaborationContent as createPdfCollaborationContent, decodeWorkDocumentSnapshot as decodeDocumentSnapshot, defaultPptxRuntimeUrl, diagnoseXlsxProtection, encodeWorkDocumentSnapshot as encodeDocumentSnapshot, exportWorkArtifact as downloadArtifact, exportWorkArtifactPdf as downloadArtifactPdf, forgetWorkSourceBlob as forgetSourceBlob, importWorkFile as importOfficeFile, inspectXlsxHeaderFooterText, inspectXlsxPivotTables, isEditableXlsxPaperSizeCode, isSupportedXlsxChartLegend, isSupportedXlsxChartPlotLayout, isSupportedXlsxChartSeriesFormatting, isSupportedXlsxCombinationChartNodes, isSupportedXlsxWorksheetImageContentType, parseXlsxChartAxes, parseXlsxChartLegend, parseXlsxChartPlotLayout, parseXlsxChartSeriesStyle, parseXlsxErrorBars, parseXlsxTrendline, projectWorkDocumentSource as projectDocumentSource, readWorkSourceBlob as readSourceBlob, readXlsxFormulaFeaturesFromPackage, rememberWorkSourceBlob as registerSourceBlob, workArtifactExtension as artifactExtension, workArtifactKindLabel as artifactKindLabel, workKindForFile as officeKindForFile, workPdfPagesForExport as pdfPagesForExport, xlsxChartNodeUsesStackedGrouping, xlsxChartSeriesFormattingShapeProperties, xlsxChartSeriesMarkerXml, xlsxChartSeriesShapePropertiesXml };
|