@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/432.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Suspense, lazy } from "react";
|
|
2
|
+
import { Suspense, createContext, lazy, useCallback, useContext, useEffect, useMemo, useRef } from "react";
|
|
3
3
|
import { LoaderCircle } from "lucide-react";
|
|
4
|
+
import { OfficeCollaborationError as WorkOfficeCollaborationError } from "./9787.js";
|
|
4
5
|
function StateView({ icon, title, description, descriptionTitle, actions, children, tone = 'neutral', size = 'standard', role, className = '' }) {
|
|
5
6
|
return /*#__PURE__*/ jsxs("div", {
|
|
6
7
|
className: `ds-state-view ${tone} ${size}${className ? ` ${className}` : ''}`,
|
|
@@ -40,6 +41,136 @@ function WorkEditorLoadingState({ title }) {
|
|
|
40
41
|
title: title
|
|
41
42
|
});
|
|
42
43
|
}
|
|
44
|
+
const OfficeCollaborationPresenceContext = /*#__PURE__*/ createContext(null);
|
|
45
|
+
function OfficeCollaborationPresenceProvider({ children, presence }) {
|
|
46
|
+
const navigatorRef = useRef(null);
|
|
47
|
+
const registerLocationNavigator = useCallback((navigator)=>{
|
|
48
|
+
navigatorRef.current = navigator;
|
|
49
|
+
return ()=>{
|
|
50
|
+
if (navigatorRef.current === navigator) navigatorRef.current = null;
|
|
51
|
+
};
|
|
52
|
+
}, []);
|
|
53
|
+
const navigateToParticipant = useCallback((participant)=>navigatorRef.current?.(participant) ?? false, []);
|
|
54
|
+
const value = useMemo(()=>({
|
|
55
|
+
navigateToParticipant,
|
|
56
|
+
presence,
|
|
57
|
+
registerLocationNavigator
|
|
58
|
+
}), [
|
|
59
|
+
navigateToParticipant,
|
|
60
|
+
presence,
|
|
61
|
+
registerLocationNavigator
|
|
62
|
+
]);
|
|
63
|
+
return /*#__PURE__*/ jsx(OfficeCollaborationPresenceContext.Provider, {
|
|
64
|
+
value: value,
|
|
65
|
+
children: children
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function useOfficeCollaborationPresence() {
|
|
69
|
+
return useContext(OfficeCollaborationPresenceContext)?.presence;
|
|
70
|
+
}
|
|
71
|
+
function useOfficeCollaborationLocationNavigator(navigator) {
|
|
72
|
+
const context = useContext(OfficeCollaborationPresenceContext);
|
|
73
|
+
useEffect(()=>{
|
|
74
|
+
if (!context?.presence) return;
|
|
75
|
+
return context.registerLocationNavigator(navigator);
|
|
76
|
+
}, [
|
|
77
|
+
context,
|
|
78
|
+
navigator
|
|
79
|
+
]);
|
|
80
|
+
}
|
|
81
|
+
function useOfficeCollaborationParticipantNavigation() {
|
|
82
|
+
const context = useContext(OfficeCollaborationPresenceContext);
|
|
83
|
+
return context?.presence ? context.navigateToParticipant : void 0;
|
|
84
|
+
}
|
|
85
|
+
function assertOfficeCollaborationPresencePairing({ expectedKind, presence, session }) {
|
|
86
|
+
if (!presence) return;
|
|
87
|
+
if (!session) throw new WorkOfficeCollaborationError('office.collaboration.presence_invalid', 'Office editor presence must be paired with its collaboration session.');
|
|
88
|
+
const local = presence.local();
|
|
89
|
+
if (session.kind !== expectedKind || local.artifactKind !== expectedKind) throw new WorkOfficeCollaborationError('office.collaboration.kind_mismatch', `Office editor presence and collaboration must both target '${expectedKind}'.`);
|
|
90
|
+
if (local.artifactId !== session.artifactId) throw new WorkOfficeCollaborationError('office.collaboration.artifact_mismatch', 'Office editor presence belongs to another collaboration artifact.');
|
|
91
|
+
const snapshot = presence.snapshot();
|
|
92
|
+
const actor = session.actor;
|
|
93
|
+
if (local.namespace !== session.namespace || snapshot.localClientId !== session.document.clientID || !actor || local.actor.id !== actor.id || local.actor.kind !== (actor.kind ?? 'human') || local.mode !== session.mode) throw new WorkOfficeCollaborationError('office.collaboration.presence_invalid', 'Office editor presence does not belong to the supplied collaboration session.');
|
|
94
|
+
}
|
|
95
|
+
const OFFICE_EDITOR_INITIAL_FOCUS_MAX_FRAMES = 120;
|
|
96
|
+
const OfficeEditorFocusOriginContext = /*#__PURE__*/ createContext(void 0);
|
|
97
|
+
function OfficeEditorFocusHandoff({ children }) {
|
|
98
|
+
const originRef = useRef(void 0);
|
|
99
|
+
if (void 0 === originRef.current) originRef.current = activeFocusOrigin();
|
|
100
|
+
return /*#__PURE__*/ jsx(OfficeEditorFocusOriginContext.Provider, {
|
|
101
|
+
value: originRef.current,
|
|
102
|
+
children: children
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function useOfficeEditorFocusOrigin() {
|
|
106
|
+
const handedOffOrigin = useContext(OfficeEditorFocusOriginContext);
|
|
107
|
+
const localOriginRef = useRef(void 0);
|
|
108
|
+
if (void 0 === localOriginRef.current) localOriginRef.current = activeFocusOrigin();
|
|
109
|
+
return void 0 === handedOffOrigin ? localOriginRef.current : handedOffOrigin;
|
|
110
|
+
}
|
|
111
|
+
function useOfficeEditorInitialFocus({ enabled, getTarget, isTargetReady }) {
|
|
112
|
+
const focusOrigin = useOfficeEditorFocusOrigin();
|
|
113
|
+
const getTargetRef = useRef(getTarget);
|
|
114
|
+
const isTargetReadyRef = useRef(isTargetReady);
|
|
115
|
+
getTargetRef.current = getTarget;
|
|
116
|
+
isTargetReadyRef.current = isTargetReady;
|
|
117
|
+
useEffect(()=>{
|
|
118
|
+
if (!enabled) return;
|
|
119
|
+
return stabilizeOfficeEditorInitialFocus(()=>getTargetRef.current(), focusOrigin, (target)=>isTargetReadyRef.current?.(target) ?? true);
|
|
120
|
+
}, [
|
|
121
|
+
enabled,
|
|
122
|
+
focusOrigin
|
|
123
|
+
]);
|
|
124
|
+
}
|
|
125
|
+
function stabilizeOfficeEditorInitialFocus(getTarget, focusOrigin = activeFocusOrigin(), isTargetReady = ()=>true) {
|
|
126
|
+
if ("u" < typeof document || 'function' != typeof requestAnimationFrame || 'function' != typeof cancelAnimationFrame) return ()=>void 0;
|
|
127
|
+
let frame = 0;
|
|
128
|
+
let remainingFrames = OFFICE_EDITOR_INITIAL_FOCUS_MAX_FRAMES;
|
|
129
|
+
let lastTarget = null;
|
|
130
|
+
let stopped = false;
|
|
131
|
+
const stop = ()=>{
|
|
132
|
+
if (stopped) return;
|
|
133
|
+
stopped = true;
|
|
134
|
+
if (frame) cancelAnimationFrame(frame);
|
|
135
|
+
document.removeEventListener('pointerdown', handleOutsideInteraction, true);
|
|
136
|
+
document.removeEventListener('click', handleOutsideInteraction, true);
|
|
137
|
+
document.removeEventListener('keydown', handleKeyDown, true);
|
|
138
|
+
};
|
|
139
|
+
const handleOutsideInteraction = (event)=>{
|
|
140
|
+
const target = getTarget();
|
|
141
|
+
if (event.target instanceof Node && target?.isConnected && target.contains(event.target)) return;
|
|
142
|
+
stop();
|
|
143
|
+
};
|
|
144
|
+
const handleKeyDown = (event)=>{
|
|
145
|
+
if ('Tab' === event.key) stop();
|
|
146
|
+
};
|
|
147
|
+
const canClaimFocus = (activeElement, target)=>activeElement === focusOrigin || activeElement === document.body || activeElement === document.documentElement || !activeElement?.isConnected || Boolean(target?.contains(activeElement)) || Boolean(lastTarget?.contains(activeElement));
|
|
148
|
+
const stabilize = ()=>{
|
|
149
|
+
frame = 0;
|
|
150
|
+
if (stopped || remainingFrames <= 0) return void stop();
|
|
151
|
+
remainingFrames -= 1;
|
|
152
|
+
const target = getTarget();
|
|
153
|
+
const activeElement = document.activeElement;
|
|
154
|
+
if (!canClaimFocus(activeElement, target)) return void stop();
|
|
155
|
+
if (target?.isConnected && isTargetReady(target)) {
|
|
156
|
+
const targetAlreadyFocused = target.contains(activeElement);
|
|
157
|
+
if (!targetAlreadyFocused) target.focus({
|
|
158
|
+
preventScroll: true
|
|
159
|
+
});
|
|
160
|
+
if (target.contains(document.activeElement)) lastTarget = target;
|
|
161
|
+
}
|
|
162
|
+
frame = requestAnimationFrame(stabilize);
|
|
163
|
+
};
|
|
164
|
+
document.addEventListener('pointerdown', handleOutsideInteraction, true);
|
|
165
|
+
document.addEventListener('click', handleOutsideInteraction, true);
|
|
166
|
+
document.addEventListener('keydown', handleKeyDown, true);
|
|
167
|
+
frame = requestAnimationFrame(stabilize);
|
|
168
|
+
return stop;
|
|
169
|
+
}
|
|
170
|
+
function activeFocusOrigin() {
|
|
171
|
+
return "u" < typeof document ? null : document.activeElement;
|
|
172
|
+
}
|
|
173
|
+
const PDF_EVIDENCE_COORDINATE_BASIS = 1000000;
|
|
43
174
|
const OFFICE_DOCUMENT_LAYOUT_FONT_ID = 'noto-sans-hans-regular';
|
|
44
175
|
const OFFICE_DOCUMENT_LAYOUT_FONT_FAMILY = 'A3S Office Noto Sans Hans';
|
|
45
176
|
const OFFICE_DOCUMENT_LAYOUT_LATIN_FONT_ID = 'noto-sans-regular';
|
|
@@ -126,36 +257,53 @@ const defaultDocumentLayoutFonts = [
|
|
|
126
257
|
style: 'normal'
|
|
127
258
|
}
|
|
128
259
|
];
|
|
129
|
-
function OfficeEditorLoader({ children, title }) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
260
|
+
function OfficeEditorLoader({ children, collaboration, kind, presence, title }) {
|
|
261
|
+
assertOfficeCollaborationPresencePairing({
|
|
262
|
+
expectedKind: kind,
|
|
263
|
+
presence,
|
|
264
|
+
session: collaboration
|
|
265
|
+
});
|
|
266
|
+
return /*#__PURE__*/ jsx(OfficeCollaborationPresenceProvider, {
|
|
267
|
+
presence: presence,
|
|
268
|
+
children: /*#__PURE__*/ jsx(OfficeEditorFocusHandoff, {
|
|
269
|
+
children: /*#__PURE__*/ jsx(Suspense, {
|
|
270
|
+
fallback: /*#__PURE__*/ jsx(WorkEditorLoadingState, {
|
|
271
|
+
title: title
|
|
272
|
+
}),
|
|
273
|
+
children: children
|
|
274
|
+
})
|
|
275
|
+
})
|
|
135
276
|
});
|
|
136
277
|
}
|
|
137
|
-
function DocumentEditor({ className, kernelWasmUrl = defaultOfficeKernelWasmUrl, layoutFonts = defaultDocumentLayoutFonts, preview = false, style, theme, ...editorProps }) {
|
|
278
|
+
function DocumentEditor({ className, defaultRibbonCollapsed = false, kernelWasmUrl = defaultOfficeKernelWasmUrl, layoutFonts = defaultDocumentLayoutFonts, presence, preview = false, style, theme, ...editorProps }) {
|
|
138
279
|
return /*#__PURE__*/ jsx(OfficeSurface, {
|
|
139
280
|
className: className,
|
|
140
281
|
style: style,
|
|
141
282
|
theme: theme,
|
|
142
283
|
children: /*#__PURE__*/ jsx(OfficeEditorLoader, {
|
|
284
|
+
collaboration: editorProps.collaboration,
|
|
285
|
+
kind: "document",
|
|
286
|
+
presence: presence,
|
|
143
287
|
title: "正在打开文字编辑器",
|
|
144
288
|
children: /*#__PURE__*/ jsx(LazyDocumentEditor, {
|
|
145
289
|
...editorProps,
|
|
146
290
|
kernelWasmUrl: kernelWasmUrl,
|
|
147
291
|
layoutFonts: layoutFonts,
|
|
148
|
-
preview: preview
|
|
292
|
+
preview: preview,
|
|
293
|
+
defaultRibbonCollapsed: defaultRibbonCollapsed
|
|
149
294
|
})
|
|
150
295
|
})
|
|
151
296
|
});
|
|
152
297
|
}
|
|
153
|
-
function MarkdownEditor({ className, preview = false, style, theme, ...editorProps }) {
|
|
298
|
+
function MarkdownEditor({ className, presence, preview = false, style, theme, ...editorProps }) {
|
|
154
299
|
return /*#__PURE__*/ jsx(OfficeSurface, {
|
|
155
300
|
className: className,
|
|
156
301
|
style: style,
|
|
157
302
|
theme: theme,
|
|
158
303
|
children: /*#__PURE__*/ jsx(OfficeEditorLoader, {
|
|
304
|
+
collaboration: editorProps.collaboration,
|
|
305
|
+
kind: "markdown",
|
|
306
|
+
presence: presence,
|
|
159
307
|
title: "正在打开 Markdown 编辑器",
|
|
160
308
|
children: /*#__PURE__*/ jsx(LazyMarkdownEditor, {
|
|
161
309
|
...editorProps,
|
|
@@ -164,12 +312,15 @@ function MarkdownEditor({ className, preview = false, style, theme, ...editorPro
|
|
|
164
312
|
})
|
|
165
313
|
});
|
|
166
314
|
}
|
|
167
|
-
function SpreadsheetEditor({ className, kernelWasmUrl = defaultOfficeKernelWasmUrl, preview = false, style, theme, ...editorProps }) {
|
|
315
|
+
function SpreadsheetEditor({ className, kernelWasmUrl = defaultOfficeKernelWasmUrl, presence, preview = false, style, theme, ...editorProps }) {
|
|
168
316
|
return /*#__PURE__*/ jsx(OfficeSurface, {
|
|
169
317
|
className: className,
|
|
170
318
|
style: style,
|
|
171
319
|
theme: theme,
|
|
172
320
|
children: /*#__PURE__*/ jsx(OfficeEditorLoader, {
|
|
321
|
+
collaboration: editorProps.collaboration,
|
|
322
|
+
kind: "spreadsheet",
|
|
323
|
+
presence: presence,
|
|
173
324
|
title: "正在打开表格编辑器",
|
|
174
325
|
children: /*#__PURE__*/ jsx(LazySpreadsheetEditor, {
|
|
175
326
|
...editorProps,
|
|
@@ -179,12 +330,15 @@ function SpreadsheetEditor({ className, kernelWasmUrl = defaultOfficeKernelWasmU
|
|
|
179
330
|
})
|
|
180
331
|
});
|
|
181
332
|
}
|
|
182
|
-
function PresentationEditor({ className, kernelWasmUrl = defaultOfficeKernelWasmUrl, preview = false, style, theme, ...editorProps }) {
|
|
333
|
+
function PresentationEditor({ className, kernelWasmUrl = defaultOfficeKernelWasmUrl, presence, preview = false, style, theme, ...editorProps }) {
|
|
183
334
|
return /*#__PURE__*/ jsx(OfficeSurface, {
|
|
184
335
|
className: className,
|
|
185
336
|
style: style,
|
|
186
337
|
theme: theme,
|
|
187
338
|
children: /*#__PURE__*/ jsx(OfficeEditorLoader, {
|
|
339
|
+
collaboration: editorProps.collaboration,
|
|
340
|
+
kind: "presentation",
|
|
341
|
+
presence: presence,
|
|
188
342
|
title: "正在打开演示编辑器",
|
|
189
343
|
children: /*#__PURE__*/ jsx(LazyPresentationEditor, {
|
|
190
344
|
...editorProps,
|
|
@@ -194,12 +348,15 @@ function PresentationEditor({ className, kernelWasmUrl = defaultOfficeKernelWasm
|
|
|
194
348
|
})
|
|
195
349
|
});
|
|
196
350
|
}
|
|
197
|
-
function PdfViewer({ className, style, theme, wasmUrl = defaultPdfiumWasmUrl, ...viewerProps }) {
|
|
351
|
+
function PdfViewer({ className, presence, style, theme, wasmUrl = defaultPdfiumWasmUrl, ...viewerProps }) {
|
|
198
352
|
return /*#__PURE__*/ jsx(OfficeSurface, {
|
|
199
353
|
className: className,
|
|
200
354
|
style: style,
|
|
201
355
|
theme: theme,
|
|
202
356
|
children: /*#__PURE__*/ jsx(OfficeEditorLoader, {
|
|
357
|
+
collaboration: viewerProps.collaboration,
|
|
358
|
+
kind: "pdf",
|
|
359
|
+
presence: presence,
|
|
203
360
|
title: "正在打开 PDF",
|
|
204
361
|
children: /*#__PURE__*/ jsx(LazyPdfViewer, {
|
|
205
362
|
...viewerProps,
|
|
@@ -208,4 +365,4 @@ function PdfViewer({ className, style, theme, wasmUrl = defaultPdfiumWasmUrl, ..
|
|
|
208
365
|
})
|
|
209
366
|
});
|
|
210
367
|
}
|
|
211
|
-
export { DocumentEditor, MarkdownEditor, OFFICE_DOCUMENT_LAYOUT_ARABIC_FONT_ID, OFFICE_DOCUMENT_LAYOUT_FONT_ID, OFFICE_DOCUMENT_LAYOUT_HEBREW_FONT_ID, OFFICE_DOCUMENT_LAYOUT_LATIN_FONT_ID, PdfViewer, PresentationEditor, SpreadsheetEditor, StateView, WorkEditorLoadingState, defaultDocumentArabicLayoutFontUrl, defaultDocumentHebrewLayoutFontUrl, defaultDocumentLatinLayoutFontUrl, defaultDocumentLayoutFontUrl, defaultDocumentLayoutFonts, defaultOfficeKernelWasmUrl, defaultPdfiumWasmUrl, documentLayoutFontKey, preloadOfficeEditor };
|
|
368
|
+
export { DocumentEditor, MarkdownEditor, OFFICE_DOCUMENT_LAYOUT_ARABIC_FONT_ID, OFFICE_DOCUMENT_LAYOUT_FONT_ID, OFFICE_DOCUMENT_LAYOUT_HEBREW_FONT_ID, OFFICE_DOCUMENT_LAYOUT_LATIN_FONT_ID, PDF_EVIDENCE_COORDINATE_BASIS, PdfViewer, PresentationEditor, SpreadsheetEditor, StateView, WorkEditorLoadingState, defaultDocumentArabicLayoutFontUrl, defaultDocumentHebrewLayoutFontUrl, defaultDocumentLatinLayoutFontUrl, defaultDocumentLayoutFontUrl, defaultDocumentLayoutFonts, defaultOfficeKernelWasmUrl, defaultPdfiumWasmUrl, documentLayoutFontKey, preloadOfficeEditor, useOfficeCollaborationLocationNavigator, useOfficeCollaborationParticipantNavigation, useOfficeCollaborationPresence, useOfficeEditorFocusOrigin, useOfficeEditorInitialFocus };
|