@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
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { forwardRef, useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { forwardRef, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { createPortal } from "react-dom";
|
|
4
|
+
import { Bot, LocateFixed, UsersRound } from "lucide-react";
|
|
5
|
+
import { useOfficeCollaborationPresence, useOfficeCollaborationParticipantNavigation } from "./432.js";
|
|
4
6
|
const focusableSelector = 'button:not(:disabled), input:not(:disabled):not([type="hidden"]), textarea:not(:disabled), select:not(:disabled), a[href], [contenteditable="true"], [tabindex]:not([tabindex="-1"])';
|
|
5
7
|
const activeFocusScopes = [];
|
|
6
8
|
const inertCounts = new WeakMap();
|
|
@@ -42,6 +44,7 @@ function useDialogFocusScope({ active = true, onEscape, escapeDisabled = false,
|
|
|
42
44
|
if (!isTopScope(activeScope)) return;
|
|
43
45
|
const currentScope = optionsRef.current.getActiveScope?.() ?? scopeRef.current;
|
|
44
46
|
if (!currentScope) return;
|
|
47
|
+
if (event.target instanceof Node && currentScope.contains(event.target) && 'Escape' !== event.key && 'Tab' !== event.key) return;
|
|
45
48
|
handleScopedKeyDown(event, currentScope, optionsRef.current);
|
|
46
49
|
};
|
|
47
50
|
const handleDocumentFocus = (event)=>{
|
|
@@ -692,6 +695,540 @@ function adjacentDocumentTabStop(current, direction, excludedRoot) {
|
|
|
692
695
|
const index = tabStops.indexOf(current);
|
|
693
696
|
return index < 0 ? null : tabStops[index + direction] ?? null;
|
|
694
697
|
}
|
|
698
|
+
const PRESENCE_COLORS = [
|
|
699
|
+
'#1d4ed8',
|
|
700
|
+
'#6d28d9',
|
|
701
|
+
'#be123c',
|
|
702
|
+
'#047857',
|
|
703
|
+
'#a16207',
|
|
704
|
+
'#0369a1',
|
|
705
|
+
'#9d174d',
|
|
706
|
+
'#4338ca'
|
|
707
|
+
];
|
|
708
|
+
const MAX_PROJECTED_PARTICIPANTS = 24;
|
|
709
|
+
const MAX_TEXT_SELECTION_RECTS = 64;
|
|
710
|
+
function useOfficePresenceSnapshot() {
|
|
711
|
+
const presence = useOfficeCollaborationPresence();
|
|
712
|
+
const [state, setState] = useState(()=>({
|
|
713
|
+
owner: presence,
|
|
714
|
+
snapshot: presence?.snapshot()
|
|
715
|
+
}));
|
|
716
|
+
useEffect(()=>{
|
|
717
|
+
if (!presence) return void setState({
|
|
718
|
+
owner: void 0,
|
|
719
|
+
snapshot: void 0
|
|
720
|
+
});
|
|
721
|
+
setState({
|
|
722
|
+
owner: presence,
|
|
723
|
+
snapshot: presence.snapshot()
|
|
724
|
+
});
|
|
725
|
+
return presence.subscribe((snapshot)=>setState({
|
|
726
|
+
owner: presence,
|
|
727
|
+
snapshot
|
|
728
|
+
}));
|
|
729
|
+
}, [
|
|
730
|
+
presence
|
|
731
|
+
]);
|
|
732
|
+
return state.owner === presence ? state.snapshot : presence?.snapshot();
|
|
733
|
+
}
|
|
734
|
+
function useOfficeRemoteParticipants() {
|
|
735
|
+
const snapshot = useOfficePresenceSnapshot();
|
|
736
|
+
return useMemo(()=>(snapshot?.participants ?? []).filter((participant)=>!participant.local && participant.location).slice(0, MAX_PROJECTED_PARTICIPANTS), [
|
|
737
|
+
snapshot
|
|
738
|
+
]);
|
|
739
|
+
}
|
|
740
|
+
function useOfficePublishPresenceLocation(location) {
|
|
741
|
+
const presence = useOfficeCollaborationPresence();
|
|
742
|
+
const locationRef = useRef(location);
|
|
743
|
+
const publishedKeyRef = useRef(null);
|
|
744
|
+
locationRef.current = location;
|
|
745
|
+
const locationKey = presenceLocationKey(location);
|
|
746
|
+
useEffect(()=>{
|
|
747
|
+
if (!presence) return;
|
|
748
|
+
const next = locationRef.current;
|
|
749
|
+
const current = presence.local().location ?? null;
|
|
750
|
+
if (presenceLocationKey(current) !== locationKey) presence.update({
|
|
751
|
+
location: next
|
|
752
|
+
});
|
|
753
|
+
publishedKeyRef.current = locationKey;
|
|
754
|
+
}, [
|
|
755
|
+
locationKey,
|
|
756
|
+
presence
|
|
757
|
+
]);
|
|
758
|
+
useEffect(()=>()=>{
|
|
759
|
+
if (!presence || null === publishedKeyRef.current) return;
|
|
760
|
+
try {
|
|
761
|
+
const current = presence.local().location ?? null;
|
|
762
|
+
if (presenceLocationKey(current) === publishedKeyRef.current) presence.update({
|
|
763
|
+
location: null
|
|
764
|
+
});
|
|
765
|
+
} catch {}
|
|
766
|
+
}, [
|
|
767
|
+
presence
|
|
768
|
+
]);
|
|
769
|
+
}
|
|
770
|
+
function OfficePresenceAvatar({ compact = false, participant }) {
|
|
771
|
+
const avatarUrl = safeAvatarUrl(participant.actor.avatarUrl);
|
|
772
|
+
return /*#__PURE__*/ jsxs("span", {
|
|
773
|
+
className: "work-office-collaboration-avatar",
|
|
774
|
+
"data-activity": participant.activity,
|
|
775
|
+
"data-compact": compact ? 'true' : void 0,
|
|
776
|
+
style: officePresenceColorStyle(participant),
|
|
777
|
+
"aria-hidden": "true",
|
|
778
|
+
children: [
|
|
779
|
+
'agent' === participant.actor.kind ? /*#__PURE__*/ jsx(Bot, {
|
|
780
|
+
size: compact ? 10 : 12
|
|
781
|
+
}) : /*#__PURE__*/ jsx("span", {
|
|
782
|
+
children: participantInitial(participant.actor.name)
|
|
783
|
+
}),
|
|
784
|
+
avatarUrl && /*#__PURE__*/ jsx("img", {
|
|
785
|
+
src: avatarUrl,
|
|
786
|
+
alt: "",
|
|
787
|
+
loading: "lazy",
|
|
788
|
+
referrerPolicy: "no-referrer",
|
|
789
|
+
onError: (event)=>{
|
|
790
|
+
event.currentTarget.hidden = true;
|
|
791
|
+
}
|
|
792
|
+
})
|
|
793
|
+
]
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
function officePresenceColorStyle(participant) {
|
|
797
|
+
return {
|
|
798
|
+
'--work-office-presence-color': officePresenceColor(participant)
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
function officePresenceColor(participant) {
|
|
802
|
+
const requested = participant.actor.color;
|
|
803
|
+
if (requested && safeCssColor(requested)) return requested;
|
|
804
|
+
let hash = 0;
|
|
805
|
+
for (const character of participant.actor.id)hash = 31 * hash + (character.codePointAt(0) ?? 0) >>> 0;
|
|
806
|
+
return PRESENCE_COLORS[hash % PRESENCE_COLORS.length] ?? PRESENCE_COLORS[0];
|
|
807
|
+
}
|
|
808
|
+
function OfficeTiptapPresenceLayer({ containerRef, editor, kind, markdownSurface }) {
|
|
809
|
+
const remoteParticipants = useOfficeRemoteParticipants();
|
|
810
|
+
const [geometry, setGeometry] = useState([]);
|
|
811
|
+
useLayoutEffect(()=>{
|
|
812
|
+
if (!editor || editor.isDestroyed) return void setGeometry([]);
|
|
813
|
+
let frame = null;
|
|
814
|
+
const measure = ()=>{
|
|
815
|
+
frame = null;
|
|
816
|
+
setGeometry(measureTiptapPresence(editor, containerRef.current, remoteParticipants, kind, markdownSurface));
|
|
817
|
+
};
|
|
818
|
+
const schedule = ()=>{
|
|
819
|
+
if (null !== frame) cancelAnimationFrame(frame);
|
|
820
|
+
frame = requestAnimationFrame(measure);
|
|
821
|
+
};
|
|
822
|
+
measure();
|
|
823
|
+
editor.on('transaction', schedule);
|
|
824
|
+
window.addEventListener('resize', schedule);
|
|
825
|
+
window.addEventListener('scroll', schedule, true);
|
|
826
|
+
const observer = "u" < typeof ResizeObserver ? null : new ResizeObserver(schedule);
|
|
827
|
+
if (containerRef.current) observer?.observe(containerRef.current);
|
|
828
|
+
observer?.observe(editor.view.dom);
|
|
829
|
+
return ()=>{
|
|
830
|
+
if (null !== frame) cancelAnimationFrame(frame);
|
|
831
|
+
editor.off('transaction', schedule);
|
|
832
|
+
window.removeEventListener('resize', schedule);
|
|
833
|
+
window.removeEventListener('scroll', schedule, true);
|
|
834
|
+
observer?.disconnect();
|
|
835
|
+
};
|
|
836
|
+
}, [
|
|
837
|
+
containerRef,
|
|
838
|
+
editor,
|
|
839
|
+
kind,
|
|
840
|
+
markdownSurface,
|
|
841
|
+
remoteParticipants
|
|
842
|
+
]);
|
|
843
|
+
if (!geometry.length) return null;
|
|
844
|
+
return /*#__PURE__*/ jsx("div", {
|
|
845
|
+
className: "work-office-remote-presence-layer",
|
|
846
|
+
"data-presence-surface": kind,
|
|
847
|
+
"aria-hidden": "true",
|
|
848
|
+
children: geometry.flatMap(({ caret, participant, ranges })=>{
|
|
849
|
+
const style = officePresenceColorStyle(participant);
|
|
850
|
+
return [
|
|
851
|
+
...ranges.map((range, index)=>/*#__PURE__*/ jsx("span", {
|
|
852
|
+
className: "work-office-remote-selection",
|
|
853
|
+
"data-activity": participant.activity,
|
|
854
|
+
"data-participant-id": participant.actor.id,
|
|
855
|
+
style: {
|
|
856
|
+
...style,
|
|
857
|
+
...range
|
|
858
|
+
}
|
|
859
|
+
}, `${participant.presenceId}:range:${index}`)),
|
|
860
|
+
/*#__PURE__*/ jsx("span", {
|
|
861
|
+
className: "work-office-remote-caret",
|
|
862
|
+
"data-activity": participant.activity,
|
|
863
|
+
"data-participant-id": participant.actor.id,
|
|
864
|
+
style: {
|
|
865
|
+
...style,
|
|
866
|
+
...caret
|
|
867
|
+
},
|
|
868
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
869
|
+
children: participant.actor.name
|
|
870
|
+
})
|
|
871
|
+
}, `${participant.presenceId}:caret`)
|
|
872
|
+
];
|
|
873
|
+
})
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
function MarkdownSourcePresenceLayer({ markdown, sourceRef }) {
|
|
877
|
+
const remoteParticipants = useOfficeRemoteParticipants();
|
|
878
|
+
const [viewport, setViewport] = useState(null);
|
|
879
|
+
const sourceParticipants = remoteParticipants.filter((participant)=>{
|
|
880
|
+
const location = participant.location;
|
|
881
|
+
return location?.kind === 'markdown' && (location.surface ?? 'source') === 'source';
|
|
882
|
+
});
|
|
883
|
+
useLayoutEffect(()=>{
|
|
884
|
+
const source = sourceRef.current;
|
|
885
|
+
if (!source) return void setViewport(null);
|
|
886
|
+
let frame = null;
|
|
887
|
+
const measure = ()=>{
|
|
888
|
+
frame = null;
|
|
889
|
+
setViewport({
|
|
890
|
+
height: source.clientHeight,
|
|
891
|
+
left: source.offsetLeft,
|
|
892
|
+
scrollLeft: source.scrollLeft,
|
|
893
|
+
scrollTop: source.scrollTop,
|
|
894
|
+
scrollWidth: Math.max(source.clientWidth, source.scrollWidth),
|
|
895
|
+
top: source.offsetTop,
|
|
896
|
+
width: source.clientWidth
|
|
897
|
+
});
|
|
898
|
+
};
|
|
899
|
+
const schedule = ()=>{
|
|
900
|
+
if (null !== frame) cancelAnimationFrame(frame);
|
|
901
|
+
frame = requestAnimationFrame(measure);
|
|
902
|
+
};
|
|
903
|
+
measure();
|
|
904
|
+
source.addEventListener('scroll', schedule);
|
|
905
|
+
window.addEventListener('resize', schedule);
|
|
906
|
+
const observer = "u" < typeof ResizeObserver ? null : new ResizeObserver(schedule);
|
|
907
|
+
observer?.observe(source);
|
|
908
|
+
return ()=>{
|
|
909
|
+
if (null !== frame) cancelAnimationFrame(frame);
|
|
910
|
+
source.removeEventListener('scroll', schedule);
|
|
911
|
+
window.removeEventListener('resize', schedule);
|
|
912
|
+
observer?.disconnect();
|
|
913
|
+
};
|
|
914
|
+
}, [
|
|
915
|
+
markdown,
|
|
916
|
+
sourceRef
|
|
917
|
+
]);
|
|
918
|
+
if (!viewport || !sourceParticipants.length) return null;
|
|
919
|
+
return /*#__PURE__*/ jsx("div", {
|
|
920
|
+
className: "work-markdown-source-presence-layer",
|
|
921
|
+
"aria-hidden": "true",
|
|
922
|
+
style: {
|
|
923
|
+
height: viewport.height,
|
|
924
|
+
left: viewport.left,
|
|
925
|
+
top: viewport.top,
|
|
926
|
+
width: viewport.width
|
|
927
|
+
},
|
|
928
|
+
children: sourceParticipants.map((participant)=>{
|
|
929
|
+
const location = participant.location;
|
|
930
|
+
if (location?.kind !== 'markdown') return null;
|
|
931
|
+
if (!textPositionExists(location.anchor, markdown.length) || !textPositionExists(location.head, markdown.length)) return null;
|
|
932
|
+
const { anchor, head } = location;
|
|
933
|
+
const from = Math.min(anchor, head);
|
|
934
|
+
const to = Math.max(anchor, head);
|
|
935
|
+
const collapsed = from === to;
|
|
936
|
+
return /*#__PURE__*/ jsxs("pre", {
|
|
937
|
+
className: "work-markdown-source-presence-mirror",
|
|
938
|
+
"data-activity": participant.activity,
|
|
939
|
+
"data-participant-id": participant.actor.id,
|
|
940
|
+
style: {
|
|
941
|
+
...officePresenceColorStyle(participant),
|
|
942
|
+
transform: `translate(${-viewport.scrollLeft}px, ${-viewport.scrollTop}px)`,
|
|
943
|
+
width: viewport.scrollWidth
|
|
944
|
+
},
|
|
945
|
+
children: [
|
|
946
|
+
markdown.slice(0, from),
|
|
947
|
+
/*#__PURE__*/ jsx("span", {
|
|
948
|
+
className: "work-markdown-source-remote-range",
|
|
949
|
+
"data-collapsed": collapsed ? 'true' : void 0,
|
|
950
|
+
"data-participant-name": participant.actor.name,
|
|
951
|
+
children: collapsed ? '\u200b' : markdown.slice(from, to)
|
|
952
|
+
}),
|
|
953
|
+
markdown.slice(to)
|
|
954
|
+
]
|
|
955
|
+
}, participant.presenceId);
|
|
956
|
+
})
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
function measureTiptapPresence(editor, container, participants, kind, markdownSurface) {
|
|
960
|
+
if (!container?.isConnected || editor.isDestroyed) return [];
|
|
961
|
+
const containerBounds = container.getBoundingClientRect();
|
|
962
|
+
if (containerBounds.width <= 0 || containerBounds.height <= 0) return [];
|
|
963
|
+
const scaleX = safeElementScale(containerBounds.width, container.offsetWidth);
|
|
964
|
+
const scaleY = safeElementScale(containerBounds.height, container.offsetHeight);
|
|
965
|
+
const maximum = editor.state.doc.content.size;
|
|
966
|
+
const result = [];
|
|
967
|
+
for (const participant of participants){
|
|
968
|
+
const location = participant.location;
|
|
969
|
+
if (location?.kind !== kind) continue;
|
|
970
|
+
if ('markdown' === kind && 'markdown' === location.kind && (location.surface ?? 'source') !== markdownSurface) continue;
|
|
971
|
+
if (!textPositionExists(location.anchor, maximum) || !textPositionExists(location.head, maximum)) continue;
|
|
972
|
+
const { anchor, head } = location;
|
|
973
|
+
const from = Math.min(anchor, head);
|
|
974
|
+
const to = Math.max(anchor, head);
|
|
975
|
+
try {
|
|
976
|
+
const caretBounds = editor.view.coordsAtPos(head);
|
|
977
|
+
const caret = localPresenceRect({
|
|
978
|
+
height: Math.max(1, caretBounds.bottom - caretBounds.top),
|
|
979
|
+
left: caretBounds.left,
|
|
980
|
+
top: caretBounds.top,
|
|
981
|
+
width: 2
|
|
982
|
+
}, container, containerBounds, scaleX, scaleY);
|
|
983
|
+
const ranges = from === to ? [] : tiptapSelectionRects(editor, from, to).slice(0, MAX_TEXT_SELECTION_RECTS).map((bounds)=>localPresenceRect(bounds, container, containerBounds, scaleX, scaleY)).filter((rect)=>rect.width > 0 && rect.height > 0);
|
|
984
|
+
result.push({
|
|
985
|
+
caret,
|
|
986
|
+
participant,
|
|
987
|
+
ranges
|
|
988
|
+
});
|
|
989
|
+
} catch {}
|
|
990
|
+
}
|
|
991
|
+
return result;
|
|
992
|
+
}
|
|
993
|
+
function tiptapSelectionRects(editor, from, to) {
|
|
994
|
+
const start = editor.view.domAtPos(from);
|
|
995
|
+
const end = editor.view.domAtPos(to);
|
|
996
|
+
const range = document.createRange();
|
|
997
|
+
range.setStart(start.node, start.offset);
|
|
998
|
+
range.setEnd(end.node, end.offset);
|
|
999
|
+
return Array.from(range.getClientRects());
|
|
1000
|
+
}
|
|
1001
|
+
function localPresenceRect(bounds, container, containerBounds, scaleX, scaleY) {
|
|
1002
|
+
return {
|
|
1003
|
+
height: Math.max(1, bounds.height / scaleY),
|
|
1004
|
+
left: (bounds.left - containerBounds.left) / scaleX + container.scrollLeft,
|
|
1005
|
+
top: (bounds.top - containerBounds.top) / scaleY + container.scrollTop,
|
|
1006
|
+
width: Math.max(1, bounds.width / scaleX)
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
function safeElementScale(rendered, layout) {
|
|
1010
|
+
const scale = layout > 0 ? rendered / layout : 1;
|
|
1011
|
+
return Number.isFinite(scale) && scale > 0 ? scale : 1;
|
|
1012
|
+
}
|
|
1013
|
+
function textPositionExists(value, maximum) {
|
|
1014
|
+
return Number.isSafeInteger(value) && value >= 0 && value <= maximum;
|
|
1015
|
+
}
|
|
1016
|
+
function presenceLocationKey(location) {
|
|
1017
|
+
return location ? JSON.stringify(location) : '';
|
|
1018
|
+
}
|
|
1019
|
+
function participantInitial(name) {
|
|
1020
|
+
return Array.from(name.trim())[0]?.toLocaleUpperCase() ?? '?';
|
|
1021
|
+
}
|
|
1022
|
+
function safeCssColor(value) {
|
|
1023
|
+
if (/[;{}]|url\(|var\(/i.test(value)) return false;
|
|
1024
|
+
if (/^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i.test(value)) return true;
|
|
1025
|
+
return "u" > typeof CSS && CSS.supports('color', value);
|
|
1026
|
+
}
|
|
1027
|
+
function safeAvatarUrl(value) {
|
|
1028
|
+
if (!value || "u" < typeof URL) return;
|
|
1029
|
+
try {
|
|
1030
|
+
const url = new URL(value, 'https://a3s.invalid/');
|
|
1031
|
+
if ('https:' === url.protocol || 'http:' === url.protocol || 'blob:' === url.protocol || 'data:' === url.protocol && value.startsWith('data:image/')) return value;
|
|
1032
|
+
} catch {}
|
|
1033
|
+
}
|
|
1034
|
+
function WorkOfficeCollaborationParticipants({ variant = 'status' }) {
|
|
1035
|
+
const snapshot = useOfficePresenceSnapshot();
|
|
1036
|
+
const navigateToParticipant = useOfficeCollaborationParticipantNavigation();
|
|
1037
|
+
const participants = useMemo(()=>orderedParticipants(snapshot?.participants ?? []), [
|
|
1038
|
+
snapshot
|
|
1039
|
+
]);
|
|
1040
|
+
if (!participants.length) return null;
|
|
1041
|
+
const count = participants.length;
|
|
1042
|
+
const summary = 1 === count ? '仅你在线' : `${count} 位协作者`;
|
|
1043
|
+
const visibleParticipants = participants.slice(0, 3);
|
|
1044
|
+
const overflow = Math.max(0, count - visibleParticipants.length);
|
|
1045
|
+
return /*#__PURE__*/ jsx(Popover, {
|
|
1046
|
+
label: `查看协作者,${summary}`,
|
|
1047
|
+
panelLabel: "协作者",
|
|
1048
|
+
panelRole: "dialog",
|
|
1049
|
+
className: "work-office-collaboration",
|
|
1050
|
+
panelClassName: "work-office-collaboration-popover",
|
|
1051
|
+
placement: 'status' === variant ? 'top-end' : 'bottom-end',
|
|
1052
|
+
portal: true,
|
|
1053
|
+
focusFirstOnOpen: participants.some((participant)=>!participant.local && Boolean(participant.location)),
|
|
1054
|
+
trigger: (triggerProps, { open })=>/*#__PURE__*/ jsxs("button", {
|
|
1055
|
+
...triggerProps,
|
|
1056
|
+
className: "work-office-collaboration-trigger",
|
|
1057
|
+
"data-collaboration-count": count,
|
|
1058
|
+
"data-variant": variant,
|
|
1059
|
+
title: `协作者:${summary}`,
|
|
1060
|
+
children: [
|
|
1061
|
+
/*#__PURE__*/ jsxs("span", {
|
|
1062
|
+
className: "work-office-collaboration-stack",
|
|
1063
|
+
"aria-hidden": "true",
|
|
1064
|
+
children: [
|
|
1065
|
+
visibleParticipants.map((participant)=>/*#__PURE__*/ jsx(OfficePresenceAvatar, {
|
|
1066
|
+
participant: participant,
|
|
1067
|
+
compact: true
|
|
1068
|
+
}, participant.presenceId)),
|
|
1069
|
+
overflow > 0 && /*#__PURE__*/ jsxs("span", {
|
|
1070
|
+
className: "work-office-collaboration-overflow",
|
|
1071
|
+
children: [
|
|
1072
|
+
"+",
|
|
1073
|
+
overflow
|
|
1074
|
+
]
|
|
1075
|
+
})
|
|
1076
|
+
]
|
|
1077
|
+
}),
|
|
1078
|
+
/*#__PURE__*/ jsx("span", {
|
|
1079
|
+
className: "work-office-collaboration-summary",
|
|
1080
|
+
children: 'status' === variant ? summary : count
|
|
1081
|
+
}),
|
|
1082
|
+
/*#__PURE__*/ jsx("span", {
|
|
1083
|
+
className: "sr-only",
|
|
1084
|
+
"aria-live": "polite",
|
|
1085
|
+
children: open ? '协作者列表已打开' : `${summary}在线`
|
|
1086
|
+
})
|
|
1087
|
+
]
|
|
1088
|
+
}),
|
|
1089
|
+
children: (close)=>/*#__PURE__*/ jsxs(Fragment, {
|
|
1090
|
+
children: [
|
|
1091
|
+
/*#__PURE__*/ jsxs("header", {
|
|
1092
|
+
className: "work-office-collaboration-heading",
|
|
1093
|
+
children: [
|
|
1094
|
+
/*#__PURE__*/ jsx("span", {
|
|
1095
|
+
className: "work-office-collaboration-heading-icon",
|
|
1096
|
+
children: /*#__PURE__*/ jsx(UsersRound, {
|
|
1097
|
+
size: 16,
|
|
1098
|
+
"aria-hidden": "true"
|
|
1099
|
+
})
|
|
1100
|
+
}),
|
|
1101
|
+
/*#__PURE__*/ jsxs("span", {
|
|
1102
|
+
children: [
|
|
1103
|
+
/*#__PURE__*/ jsx("strong", {
|
|
1104
|
+
children: "协作者"
|
|
1105
|
+
}),
|
|
1106
|
+
/*#__PURE__*/ jsxs("small", {
|
|
1107
|
+
children: [
|
|
1108
|
+
count,
|
|
1109
|
+
" 个在线会话"
|
|
1110
|
+
]
|
|
1111
|
+
})
|
|
1112
|
+
]
|
|
1113
|
+
})
|
|
1114
|
+
]
|
|
1115
|
+
}),
|
|
1116
|
+
/*#__PURE__*/ jsx("ul", {
|
|
1117
|
+
className: "work-office-collaboration-list",
|
|
1118
|
+
children: participants.map((participant)=>{
|
|
1119
|
+
const locationLabel = presenceLocationLabel(participant);
|
|
1120
|
+
const navigable = !participant.local && Boolean(participant.location) && Boolean(navigateToParticipant);
|
|
1121
|
+
const content = /*#__PURE__*/ jsxs(Fragment, {
|
|
1122
|
+
children: [
|
|
1123
|
+
/*#__PURE__*/ jsx(OfficePresenceAvatar, {
|
|
1124
|
+
participant: participant
|
|
1125
|
+
}),
|
|
1126
|
+
/*#__PURE__*/ jsxs("span", {
|
|
1127
|
+
className: "work-office-collaboration-person",
|
|
1128
|
+
children: [
|
|
1129
|
+
/*#__PURE__*/ jsxs("span", {
|
|
1130
|
+
className: "work-office-collaboration-name",
|
|
1131
|
+
children: [
|
|
1132
|
+
/*#__PURE__*/ jsx("strong", {
|
|
1133
|
+
children: participant.actor.name
|
|
1134
|
+
}),
|
|
1135
|
+
participant.local && /*#__PURE__*/ jsx("small", {
|
|
1136
|
+
children: "你"
|
|
1137
|
+
}),
|
|
1138
|
+
'agent' === participant.actor.kind && /*#__PURE__*/ jsx("small", {
|
|
1139
|
+
children: "Agent"
|
|
1140
|
+
}),
|
|
1141
|
+
'system' === participant.actor.kind && /*#__PURE__*/ jsx("small", {
|
|
1142
|
+
children: "系统"
|
|
1143
|
+
})
|
|
1144
|
+
]
|
|
1145
|
+
}),
|
|
1146
|
+
/*#__PURE__*/ jsxs("span", {
|
|
1147
|
+
className: "work-office-collaboration-detail",
|
|
1148
|
+
children: [
|
|
1149
|
+
presenceActivityLabel(participant.activity),
|
|
1150
|
+
" \xb7",
|
|
1151
|
+
' ',
|
|
1152
|
+
presenceModeLabel(participant.mode),
|
|
1153
|
+
" \xb7 ",
|
|
1154
|
+
locationLabel
|
|
1155
|
+
]
|
|
1156
|
+
})
|
|
1157
|
+
]
|
|
1158
|
+
}),
|
|
1159
|
+
navigable && /*#__PURE__*/ jsx(LocateFixed, {
|
|
1160
|
+
className: "work-office-collaboration-locate",
|
|
1161
|
+
size: 14,
|
|
1162
|
+
"aria-hidden": "true"
|
|
1163
|
+
})
|
|
1164
|
+
]
|
|
1165
|
+
});
|
|
1166
|
+
return /*#__PURE__*/ jsx("li", {
|
|
1167
|
+
"data-collaboration-participant": participant.actor.id,
|
|
1168
|
+
"data-activity": participant.activity,
|
|
1169
|
+
"data-local": participant.local ? 'true' : void 0,
|
|
1170
|
+
"data-navigable": navigable ? 'true' : void 0,
|
|
1171
|
+
children: navigable ? /*#__PURE__*/ jsx("button", {
|
|
1172
|
+
type: "button",
|
|
1173
|
+
className: "work-office-collaboration-participant",
|
|
1174
|
+
"aria-label": `跳转到 ${participant.actor.name} 的位置,${locationLabel}`,
|
|
1175
|
+
onClick: ()=>{
|
|
1176
|
+
close();
|
|
1177
|
+
requestAnimationFrame(()=>navigateToParticipant?.(participant));
|
|
1178
|
+
},
|
|
1179
|
+
children: content
|
|
1180
|
+
}) : /*#__PURE__*/ jsx("span", {
|
|
1181
|
+
className: "work-office-collaboration-participant",
|
|
1182
|
+
children: content
|
|
1183
|
+
})
|
|
1184
|
+
}, participant.presenceId);
|
|
1185
|
+
})
|
|
1186
|
+
})
|
|
1187
|
+
]
|
|
1188
|
+
})
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1191
|
+
function orderedParticipants(participants) {
|
|
1192
|
+
return [
|
|
1193
|
+
...participants
|
|
1194
|
+
].sort((left, right)=>Number(right.local) - Number(left.local) || presenceActivityOrder(left.activity) - presenceActivityOrder(right.activity) || left.actor.name.localeCompare(right.actor.name) || left.clientId - right.clientId);
|
|
1195
|
+
}
|
|
1196
|
+
function presenceActivityOrder(activity) {
|
|
1197
|
+
return 'active' === activity ? 0 : 'idle' === activity ? 1 : 2;
|
|
1198
|
+
}
|
|
1199
|
+
function presenceActivityLabel(activity) {
|
|
1200
|
+
return 'active' === activity ? '正在使用' : 'idle' === activity ? '空闲' : '离开';
|
|
1201
|
+
}
|
|
1202
|
+
function presenceModeLabel(mode) {
|
|
1203
|
+
if ('edit' === mode) return '可编辑';
|
|
1204
|
+
if ('suggest' === mode) return '建议';
|
|
1205
|
+
if ('comment' === mode) return '评论';
|
|
1206
|
+
return '只读';
|
|
1207
|
+
}
|
|
1208
|
+
function presenceLocationLabel(participant) {
|
|
1209
|
+
const location = participant.location;
|
|
1210
|
+
if (!location) return '未共享位置';
|
|
1211
|
+
switch(location.kind){
|
|
1212
|
+
case 'document':
|
|
1213
|
+
case 'markdown':
|
|
1214
|
+
{
|
|
1215
|
+
const selected = Math.abs(location.head - location.anchor);
|
|
1216
|
+
return selected > 0 ? `已选择 ${selected} 个位置` : `位置 ${location.head + 1}`;
|
|
1217
|
+
}
|
|
1218
|
+
case 'spreadsheet':
|
|
1219
|
+
{
|
|
1220
|
+
const active = location.activeCell ?? {
|
|
1221
|
+
row: location.ranges[0]?.startRow ?? 0,
|
|
1222
|
+
column: location.ranges[0]?.startColumn ?? 0
|
|
1223
|
+
};
|
|
1224
|
+
return `R${active.row + 1}C${active.column + 1}`;
|
|
1225
|
+
}
|
|
1226
|
+
case 'presentation':
|
|
1227
|
+
return location.elementIds.length > 0 ? `幻灯片中的 ${location.elementIds.length} 个对象` : '当前幻灯片';
|
|
1228
|
+
case 'pdf':
|
|
1229
|
+
return `第 ${location.pageIndex + 1} 页`;
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
695
1232
|
const OFFICE_MENU_NAVIGATION_KEYS = [
|
|
696
1233
|
'ArrowDown',
|
|
697
1234
|
'ArrowUp',
|
|
@@ -743,4 +1280,4 @@ function useOfficeEditorWheelZoom({ enabled = true, scopeRef, onZoomIn, onZoomOu
|
|
|
743
1280
|
scopeRef
|
|
744
1281
|
]);
|
|
745
1282
|
}
|
|
746
|
-
export { CommittedOfficeTextArea, CommittedOfficeTextField, Popover, button_Button, icon_button_IconButton, matchesAriaKeyShortcuts, matchesOfficeEditorKeyboardShortcut, moveOfficeMenuFocus, officeOverlayPortalRoot, office_text_field_OfficeFileInput, office_text_field_OfficeTextArea, office_text_field_OfficeTextField, stepOfficeZoom, useDialogFocusScope, useOfficeEditorWheelZoom };
|
|
1283
|
+
export { CommittedOfficeTextArea, CommittedOfficeTextField, MarkdownSourcePresenceLayer, OfficePresenceAvatar, OfficeTiptapPresenceLayer, Popover, WorkOfficeCollaborationParticipants, button_Button, icon_button_IconButton, matchesAriaKeyShortcuts, matchesOfficeEditorKeyboardShortcut, moveOfficeMenuFocus, officeOverlayPortalRoot, officePresenceColor, officePresenceColorStyle, office_text_field_OfficeFileInput, office_text_field_OfficeTextArea, office_text_field_OfficeTextField, stepOfficeZoom, useDialogFocusScope, useOfficeEditorWheelZoom, useOfficePublishPresenceLocation, useOfficeRemoteParticipants };
|