@abraca/nuxt 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -0
- package/dist/module.d.mts +201 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +170 -0
- package/dist/runtime/components/ACollaborationUsers.d.vue.ts +11 -0
- package/dist/runtime/components/ACollaborationUsers.vue +48 -0
- package/dist/runtime/components/ACollaborationUsers.vue.d.ts +11 -0
- package/dist/runtime/components/AColorPicker.d.vue.ts +13 -0
- package/dist/runtime/components/AColorPicker.vue +71 -0
- package/dist/runtime/components/AColorPicker.vue.d.ts +13 -0
- package/dist/runtime/components/ACommandPalette.d.vue.ts +13 -0
- package/dist/runtime/components/ACommandPalette.vue +31 -0
- package/dist/runtime/components/ACommandPalette.vue.d.ts +13 -0
- package/dist/runtime/components/AConnectionStatus.d.vue.ts +13 -0
- package/dist/runtime/components/AConnectionStatus.vue +50 -0
- package/dist/runtime/components/AConnectionStatus.vue.d.ts +13 -0
- package/dist/runtime/components/ADocTypeSelect.d.vue.ts +10 -0
- package/dist/runtime/components/ADocTypeSelect.vue +34 -0
- package/dist/runtime/components/ADocTypeSelect.vue.d.ts +10 -0
- package/dist/runtime/components/ADocumentTree.d.vue.ts +53 -0
- package/dist/runtime/components/ADocumentTree.vue +350 -0
- package/dist/runtime/components/ADocumentTree.vue.d.ts +53 -0
- package/dist/runtime/components/AEditor.d.vue.ts +60 -0
- package/dist/runtime/components/AEditor.vue +174 -0
- package/dist/runtime/components/AEditor.vue.d.ts +60 -0
- package/dist/runtime/components/AFloatingWindow.d.vue.ts +24 -0
- package/dist/runtime/components/AFloatingWindow.vue +232 -0
- package/dist/runtime/components/AFloatingWindow.vue.d.ts +24 -0
- package/dist/runtime/components/AIconPicker.d.vue.ts +13 -0
- package/dist/runtime/components/AIconPicker.vue +257 -0
- package/dist/runtime/components/AIconPicker.vue.d.ts +13 -0
- package/dist/runtime/components/ANodePanel.d.vue.ts +15 -0
- package/dist/runtime/components/ANodePanel.vue +541 -0
- package/dist/runtime/components/ANodePanel.vue.d.ts +15 -0
- package/dist/runtime/components/ANotifications.d.vue.ts +7 -0
- package/dist/runtime/components/ANotifications.vue +75 -0
- package/dist/runtime/components/ANotifications.vue.d.ts +7 -0
- package/dist/runtime/components/APermissionGuard.d.vue.ts +21 -0
- package/dist/runtime/components/APermissionGuard.vue +22 -0
- package/dist/runtime/components/APermissionGuard.vue.d.ts +21 -0
- package/dist/runtime/components/APresence.d.vue.ts +43 -0
- package/dist/runtime/components/APresence.vue +36 -0
- package/dist/runtime/components/APresence.vue.d.ts +43 -0
- package/dist/runtime/components/AProvider.d.vue.ts +27 -0
- package/dist/runtime/components/AProvider.vue +42 -0
- package/dist/runtime/components/AProvider.vue.d.ts +27 -0
- package/dist/runtime/components/ARoleBadge.d.vue.ts +11 -0
- package/dist/runtime/components/ARoleBadge.vue +29 -0
- package/dist/runtime/components/ARoleBadge.vue.d.ts +11 -0
- package/dist/runtime/components/AVoiceBar.d.vue.ts +13 -0
- package/dist/runtime/components/AVoiceBar.vue +379 -0
- package/dist/runtime/components/AVoiceBar.vue.d.ts +13 -0
- package/dist/runtime/components/AVoiceTile.d.vue.ts +10 -0
- package/dist/runtime/components/AVoiceTile.vue +48 -0
- package/dist/runtime/components/AVoiceTile.vue.d.ts +10 -0
- package/dist/runtime/components/AWindowLayer.d.vue.ts +3 -0
- package/dist/runtime/components/AWindowLayer.vue +17 -0
- package/dist/runtime/components/AWindowLayer.vue.d.ts +3 -0
- package/dist/runtime/components/aware/AArea.d.vue.ts +42 -0
- package/dist/runtime/components/aware/AArea.vue +45 -0
- package/dist/runtime/components/aware/AArea.vue.d.ts +42 -0
- package/dist/runtime/components/aware/AAvatar.d.vue.ts +25 -0
- package/dist/runtime/components/aware/AAvatar.vue +86 -0
- package/dist/runtime/components/aware/AAvatar.vue.d.ts +25 -0
- package/dist/runtime/components/aware/AButton.d.vue.ts +7 -0
- package/dist/runtime/components/aware/AButton.vue +39 -0
- package/dist/runtime/components/aware/AButton.vue.d.ts +7 -0
- package/dist/runtime/components/aware/ACursorLabel.d.vue.ts +12 -0
- package/dist/runtime/components/aware/ACursorLabel.vue +44 -0
- package/dist/runtime/components/aware/ACursorLabel.vue.d.ts +12 -0
- package/dist/runtime/components/aware/ADocBadge.d.vue.ts +11 -0
- package/dist/runtime/components/aware/ADocBadge.vue +27 -0
- package/dist/runtime/components/aware/ADocBadge.vue.d.ts +11 -0
- package/dist/runtime/components/aware/AFacepile.d.vue.ts +20 -0
- package/dist/runtime/components/aware/AFacepile.vue +92 -0
- package/dist/runtime/components/aware/AFacepile.vue.d.ts +20 -0
- package/dist/runtime/components/aware/AInput.d.vue.ts +7 -0
- package/dist/runtime/components/aware/AInput.vue +44 -0
- package/dist/runtime/components/aware/AInput.vue.d.ts +7 -0
- package/dist/runtime/components/aware/ASelect.d.vue.ts +7 -0
- package/dist/runtime/components/aware/ASelect.vue +51 -0
- package/dist/runtime/components/aware/ASelect.vue.d.ts +7 -0
- package/dist/runtime/components/aware/ATextarea.d.vue.ts +7 -0
- package/dist/runtime/components/aware/ATextarea.vue +44 -0
- package/dist/runtime/components/aware/ATextarea.vue.d.ts +7 -0
- package/dist/runtime/components/aware/AUserList.d.vue.ts +17 -0
- package/dist/runtime/components/aware/AUserList.vue +72 -0
- package/dist/runtime/components/aware/AUserList.vue.d.ts +17 -0
- package/dist/runtime/components/renderers/ACalendarRenderer.d.vue.ts +8 -0
- package/dist/runtime/components/renderers/ACalendarRenderer.vue +154 -0
- package/dist/runtime/components/renderers/ACalendarRenderer.vue.d.ts +8 -0
- package/dist/runtime/components/renderers/AGalleryRenderer.d.vue.ts +8 -0
- package/dist/runtime/components/renderers/AGalleryRenderer.vue +88 -0
- package/dist/runtime/components/renderers/AGalleryRenderer.vue.d.ts +8 -0
- package/dist/runtime/components/renderers/AKanbanRenderer.d.vue.ts +8 -0
- package/dist/runtime/components/renderers/AKanbanRenderer.vue +179 -0
- package/dist/runtime/components/renderers/AKanbanRenderer.vue.d.ts +8 -0
- package/dist/runtime/components/renderers/AOutlineRenderer.d.vue.ts +8 -0
- package/dist/runtime/components/renderers/AOutlineRenderer.vue +180 -0
- package/dist/runtime/components/renderers/AOutlineRenderer.vue.d.ts +8 -0
- package/dist/runtime/components/renderers/ATableRenderer.d.vue.ts +8 -0
- package/dist/runtime/components/renderers/ATableRenderer.vue +191 -0
- package/dist/runtime/components/renderers/ATableRenderer.vue.d.ts +8 -0
- package/dist/runtime/composables/useAAField.d.ts +42 -0
- package/dist/runtime/composables/useAAField.js +62 -0
- package/dist/runtime/composables/useAbraLocale.d.ts +14 -0
- package/dist/runtime/composables/useAbraLocale.js +11 -0
- package/dist/runtime/composables/useAbracadabra.d.ts +11 -0
- package/dist/runtime/composables/useAbracadabra.js +3 -0
- package/dist/runtime/composables/useAbracadabraAuth.d.ts +23 -0
- package/dist/runtime/composables/useAbracadabraAuth.js +22 -0
- package/dist/runtime/composables/useAwareness.d.ts +22 -0
- package/dist/runtime/composables/useAwareness.js +48 -0
- package/dist/runtime/composables/useAwarenessPeers.d.ts +34 -0
- package/dist/runtime/composables/useAwarenessPeers.js +33 -0
- package/dist/runtime/composables/useBackgroundSync.d.ts +37 -0
- package/dist/runtime/composables/useBackgroundSync.js +73 -0
- package/dist/runtime/composables/useChat.d.ts +65 -0
- package/dist/runtime/composables/useChat.js +210 -0
- package/dist/runtime/composables/useChatUsers.d.ts +21 -0
- package/dist/runtime/composables/useChatUsers.js +39 -0
- package/dist/runtime/composables/useChildTree.d.ts +119 -0
- package/dist/runtime/composables/useChildTree.js +100 -0
- package/dist/runtime/composables/useCommandPalette.d.ts +58 -0
- package/dist/runtime/composables/useCommandPalette.js +94 -0
- package/dist/runtime/composables/useConnectionStatus.d.ts +17 -0
- package/dist/runtime/composables/useConnectionStatus.js +37 -0
- package/dist/runtime/composables/useDashboard.d.ts +3 -0
- package/dist/runtime/composables/useDashboard.js +23 -0
- package/dist/runtime/composables/useDocExport.d.ts +5 -0
- package/dist/runtime/composables/useDocExport.js +256 -0
- package/dist/runtime/composables/useDocImport.d.ts +10 -0
- package/dist/runtime/composables/useDocImport.js +227 -0
- package/dist/runtime/composables/useDocJump.d.ts +29 -0
- package/dist/runtime/composables/useDocJump.js +17 -0
- package/dist/runtime/composables/useDocumentPermissions.d.ts +20 -0
- package/dist/runtime/composables/useDocumentPermissions.js +33 -0
- package/dist/runtime/composables/useEditor.d.ts +45 -0
- package/dist/runtime/composables/useEditor.js +121 -0
- package/dist/runtime/composables/useEditorDragHandle.d.ts +26 -0
- package/dist/runtime/composables/useEditorDragHandle.js +219 -0
- package/dist/runtime/composables/useEditorMentions.d.ts +28 -0
- package/dist/runtime/composables/useEditorMentions.js +40 -0
- package/dist/runtime/composables/useEditorSuggestions.d.ts +18 -0
- package/dist/runtime/composables/useEditorSuggestions.js +45 -0
- package/dist/runtime/composables/useEditorToolbar.d.ts +22 -0
- package/dist/runtime/composables/useEditorToolbar.js +60 -0
- package/dist/runtime/composables/useFileBlobStore.d.ts +15 -0
- package/dist/runtime/composables/useFileBlobStore.js +22 -0
- package/dist/runtime/composables/useFileIndex.d.ts +20 -0
- package/dist/runtime/composables/useFileIndex.js +69 -0
- package/dist/runtime/composables/useFollowUser.d.ts +5 -0
- package/dist/runtime/composables/useFollowUser.js +40 -0
- package/dist/runtime/composables/useNotifications.d.ts +82 -0
- package/dist/runtime/composables/useNotifications.js +171 -0
- package/dist/runtime/composables/useOfflineUploadQueue.d.ts +90 -0
- package/dist/runtime/composables/useOfflineUploadQueue.js +33 -0
- package/dist/runtime/composables/usePasskeyAccounts.d.ts +32 -0
- package/dist/runtime/composables/usePasskeyAccounts.js +46 -0
- package/dist/runtime/composables/usePluginRegistry.d.ts +6 -0
- package/dist/runtime/composables/usePluginRegistry.js +3 -0
- package/dist/runtime/composables/useRendererBase.d.ts +186 -0
- package/dist/runtime/composables/useRendererBase.js +46 -0
- package/dist/runtime/composables/useSearchIndex.d.ts +20 -0
- package/dist/runtime/composables/useSearchIndex.js +104 -0
- package/dist/runtime/composables/useTrash.d.ts +50 -0
- package/dist/runtime/composables/useTrash.js +127 -0
- package/dist/runtime/composables/useVoice.d.ts +51 -0
- package/dist/runtime/composables/useVoice.js +220 -0
- package/dist/runtime/composables/useWindowManager.d.ts +122 -0
- package/dist/runtime/composables/useWindowManager.js +141 -0
- package/dist/runtime/composables/useYDoc.d.ts +142 -0
- package/dist/runtime/composables/useYDoc.js +172 -0
- package/dist/runtime/extensions/accordion.d.ts +3 -0
- package/dist/runtime/extensions/accordion.js +49 -0
- package/dist/runtime/extensions/badge.d.ts +2 -0
- package/dist/runtime/extensions/badge.js +39 -0
- package/dist/runtime/extensions/callout.d.ts +2 -0
- package/dist/runtime/extensions/callout.js +28 -0
- package/dist/runtime/extensions/card.d.ts +3 -0
- package/dist/runtime/extensions/card.js +53 -0
- package/dist/runtime/extensions/code-collapse.d.ts +2 -0
- package/dist/runtime/extensions/code-collapse.js +32 -0
- package/dist/runtime/extensions/code-group.d.ts +2 -0
- package/dist/runtime/extensions/code-group.js +17 -0
- package/dist/runtime/extensions/collapsible.d.ts +2 -0
- package/dist/runtime/extensions/collapsible.js +35 -0
- package/dist/runtime/extensions/document-header.d.ts +11 -0
- package/dist/runtime/extensions/document-header.js +82 -0
- package/dist/runtime/extensions/document-meta.d.ts +20 -0
- package/dist/runtime/extensions/document-meta.js +121 -0
- package/dist/runtime/extensions/document.d.ts +6 -0
- package/dist/runtime/extensions/document.js +6 -0
- package/dist/runtime/extensions/file-block.d.ts +15 -0
- package/dist/runtime/extensions/file-block.js +34 -0
- package/dist/runtime/extensions/file-drop.d.ts +6 -0
- package/dist/runtime/extensions/file-drop.js +65 -0
- package/dist/runtime/extensions/kbd.d.ts +2 -0
- package/dist/runtime/extensions/kbd.js +33 -0
- package/dist/runtime/extensions/prose-icon.d.ts +2 -0
- package/dist/runtime/extensions/prose-icon.js +33 -0
- package/dist/runtime/extensions/search-highlight.d.ts +10 -0
- package/dist/runtime/extensions/search-highlight.js +129 -0
- package/dist/runtime/extensions/steps.d.ts +2 -0
- package/dist/runtime/extensions/steps.js +32 -0
- package/dist/runtime/extensions/tabs.d.ts +3 -0
- package/dist/runtime/extensions/tabs.js +49 -0
- package/dist/runtime/extensions/views/AccordionItemView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/AccordionItemView.vue +41 -0
- package/dist/runtime/extensions/views/AccordionItemView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/AccordionView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/AccordionView.vue +22 -0
- package/dist/runtime/extensions/views/AccordionView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/BadgeView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/BadgeView.vue +23 -0
- package/dist/runtime/extensions/views/BadgeView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/CalloutView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/CalloutView.vue +43 -0
- package/dist/runtime/extensions/views/CalloutView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/CardGroupView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/CardGroupView.vue +22 -0
- package/dist/runtime/extensions/views/CardGroupView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/CardView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/CardView.vue +28 -0
- package/dist/runtime/extensions/views/CardView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/CodeCollapseView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/CodeCollapseView.vue +45 -0
- package/dist/runtime/extensions/views/CodeCollapseView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/CodeGroupView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/CodeGroupView.vue +53 -0
- package/dist/runtime/extensions/views/CodeGroupView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/CollapsibleView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/CollapsibleView.vue +42 -0
- package/dist/runtime/extensions/views/CollapsibleView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/FileNodeView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/FileNodeView.vue +140 -0
- package/dist/runtime/extensions/views/FileNodeView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/KbdView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/KbdView.vue +23 -0
- package/dist/runtime/extensions/views/KbdView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/ProseIconView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/ProseIconView.vue +23 -0
- package/dist/runtime/extensions/views/ProseIconView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/StepsView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/StepsView.vue +32 -0
- package/dist/runtime/extensions/views/StepsView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/TabsItemView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/TabsItemView.vue +22 -0
- package/dist/runtime/extensions/views/TabsItemView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/TabsView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/TabsView.vue +56 -0
- package/dist/runtime/extensions/views/TabsView.vue.d.ts +4 -0
- package/dist/runtime/locale.d.ts +134 -0
- package/dist/runtime/locale.js +119 -0
- package/dist/runtime/middleware/abracadabra-auth.d.ts +11 -0
- package/dist/runtime/middleware/abracadabra-auth.js +9 -0
- package/dist/runtime/plugin-abracadabra.client.d.ts +7 -0
- package/dist/runtime/plugin-abracadabra.client.js +898 -0
- package/dist/runtime/plugin-abracadabra.server.d.ts +2 -0
- package/dist/runtime/plugin-abracadabra.server.js +71 -0
- package/dist/runtime/plugin-registry.d.ts +34 -0
- package/dist/runtime/plugin-registry.js +83 -0
- package/dist/runtime/plugin-shared-globals.client.d.ts +2 -0
- package/dist/runtime/plugin-shared-globals.client.js +20 -0
- package/dist/runtime/plugins/core.plugin.d.ts +12 -0
- package/dist/runtime/plugins/core.plugin.js +179 -0
- package/dist/runtime/server/api/_abracadabra/render/[docId].get.d.ts +18 -0
- package/dist/runtime/server/api/_abracadabra/render/[docId].get.js +51 -0
- package/dist/runtime/server/api/_abracadabra/spaces.get.d.ts +11 -0
- package/dist/runtime/server/api/_abracadabra/spaces.get.js +16 -0
- package/dist/runtime/server/plugins/abracadabra-service.d.ts +2 -0
- package/dist/runtime/server/plugins/abracadabra-service.js +116 -0
- package/dist/runtime/server/runners/doc-tree-cache.d.ts +11 -0
- package/dist/runtime/server/runners/doc-tree-cache.js +65 -0
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/runtime/server/utils/docCache.d.ts +25 -0
- package/dist/runtime/server/utils/docCache.js +131 -0
- package/dist/runtime/server/utils/serverRunner.d.ts +28 -0
- package/dist/runtime/server/utils/serverRunner.js +58 -0
- package/dist/runtime/types.d.ts +444 -0
- package/dist/runtime/types.js +93 -0
- package/dist/runtime/utils/VoiceClient.d.ts +94 -0
- package/dist/runtime/utils/VoiceClient.js +599 -0
- package/dist/runtime/utils/avatarStyle.d.ts +15 -0
- package/dist/runtime/utils/avatarStyle.js +20 -0
- package/dist/runtime/utils/colorPalettes.d.ts +13 -0
- package/dist/runtime/utils/colorPalettes.js +49 -0
- package/dist/runtime/utils/docTypes.d.ts +129 -0
- package/dist/runtime/utils/docTypes.js +116 -0
- package/dist/runtime/utils/markdownToYjs.d.ts +23 -0
- package/dist/runtime/utils/markdownToYjs.js +440 -0
- package/dist/runtime/utils/metaFieldDefinitions.d.ts +7 -0
- package/dist/runtime/utils/metaFieldDefinitions.js +182 -0
- package/dist/runtime/utils/voiceErrors.d.ts +33 -0
- package/dist/runtime/utils/voiceErrors.js +54 -0
- package/dist/runtime/utils/yjsConvert.d.ts +14 -0
- package/dist/runtime/utils/yjsConvert.js +331 -0
- package/dist/types.d.mts +13 -0
- package/package.json +100 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useWindowManager
|
|
3
|
+
*
|
|
4
|
+
* Floating window (PiP/panel) management for desktop-like UIs.
|
|
5
|
+
* Pure Vue reactive state — no CRDT required.
|
|
6
|
+
* Windows can be opened for any document or content.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* const { windows, openWindow, closeWindow, focusWindow } = useWindowManager()
|
|
10
|
+
*/
|
|
11
|
+
export interface FloatingWindowState {
|
|
12
|
+
id: string;
|
|
13
|
+
title: string;
|
|
14
|
+
icon?: string;
|
|
15
|
+
docId: string;
|
|
16
|
+
docType?: string;
|
|
17
|
+
channelId?: string;
|
|
18
|
+
provider: any;
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
zIndex: number;
|
|
24
|
+
isMinimized: boolean;
|
|
25
|
+
isMaximized: boolean;
|
|
26
|
+
isFocused: boolean;
|
|
27
|
+
prevX: number;
|
|
28
|
+
prevY: number;
|
|
29
|
+
prevWidth: number;
|
|
30
|
+
prevHeight: number;
|
|
31
|
+
minimizeTarget?: {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
};
|
|
35
|
+
initialTab?: 'editor' | 'chat';
|
|
36
|
+
meta?: Record<string, any>;
|
|
37
|
+
}
|
|
38
|
+
export declare function useWindowManager(): {
|
|
39
|
+
windows: import("vue").Reactive<Map<string, FloatingWindowState>>;
|
|
40
|
+
activeWindows: import("vue").ComputedRef<{
|
|
41
|
+
id: string;
|
|
42
|
+
title: string;
|
|
43
|
+
icon?: string | undefined;
|
|
44
|
+
docId: string;
|
|
45
|
+
docType?: string | undefined;
|
|
46
|
+
channelId?: string | undefined;
|
|
47
|
+
provider: any;
|
|
48
|
+
x: number;
|
|
49
|
+
y: number;
|
|
50
|
+
width: number;
|
|
51
|
+
height: number;
|
|
52
|
+
zIndex: number;
|
|
53
|
+
isMinimized: boolean;
|
|
54
|
+
isMaximized: boolean;
|
|
55
|
+
isFocused: boolean;
|
|
56
|
+
prevX: number;
|
|
57
|
+
prevY: number;
|
|
58
|
+
prevWidth: number;
|
|
59
|
+
prevHeight: number;
|
|
60
|
+
minimizeTarget?: {
|
|
61
|
+
x: number;
|
|
62
|
+
y: number;
|
|
63
|
+
} | undefined;
|
|
64
|
+
initialTab?: "editor" | "chat" | undefined;
|
|
65
|
+
meta?: Record<string, any> | undefined;
|
|
66
|
+
}[]>;
|
|
67
|
+
minimizedWindows: import("vue").ComputedRef<{
|
|
68
|
+
id: string;
|
|
69
|
+
title: string;
|
|
70
|
+
icon?: string | undefined;
|
|
71
|
+
docId: string;
|
|
72
|
+
docType?: string | undefined;
|
|
73
|
+
channelId?: string | undefined;
|
|
74
|
+
provider: any;
|
|
75
|
+
x: number;
|
|
76
|
+
y: number;
|
|
77
|
+
width: number;
|
|
78
|
+
height: number;
|
|
79
|
+
zIndex: number;
|
|
80
|
+
isMinimized: boolean;
|
|
81
|
+
isMaximized: boolean;
|
|
82
|
+
isFocused: boolean;
|
|
83
|
+
prevX: number;
|
|
84
|
+
prevY: number;
|
|
85
|
+
prevWidth: number;
|
|
86
|
+
prevHeight: number;
|
|
87
|
+
minimizeTarget?: {
|
|
88
|
+
x: number;
|
|
89
|
+
y: number;
|
|
90
|
+
} | undefined;
|
|
91
|
+
initialTab?: "editor" | "chat" | undefined;
|
|
92
|
+
meta?: Record<string, any> | undefined;
|
|
93
|
+
}[]>;
|
|
94
|
+
openWindow: (opts: {
|
|
95
|
+
id: string;
|
|
96
|
+
title: string;
|
|
97
|
+
icon?: string;
|
|
98
|
+
docId: string;
|
|
99
|
+
docType?: string;
|
|
100
|
+
channelId?: string;
|
|
101
|
+
provider?: any;
|
|
102
|
+
width?: number;
|
|
103
|
+
height?: number;
|
|
104
|
+
spawnX?: number;
|
|
105
|
+
spawnY?: number;
|
|
106
|
+
initialX?: number;
|
|
107
|
+
initialY?: number;
|
|
108
|
+
initialTab?: "editor" | "chat";
|
|
109
|
+
meta?: Record<string, any>;
|
|
110
|
+
}) => void;
|
|
111
|
+
closeWindow: (id: string) => void;
|
|
112
|
+
closeAll: () => void;
|
|
113
|
+
focusWindow: (id: string) => void;
|
|
114
|
+
minimizeWindow: (id: string, target?: {
|
|
115
|
+
x: number;
|
|
116
|
+
y: number;
|
|
117
|
+
}) => void;
|
|
118
|
+
restoreWindow: (id: string) => void;
|
|
119
|
+
toggleMaximize: (id: string) => void;
|
|
120
|
+
moveWindow: (id: string, x: number, y: number) => void;
|
|
121
|
+
resizeWindow: (id: string, width: number, height: number, x?: number, y?: number) => void;
|
|
122
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { reactive, ref, computed } from "vue";
|
|
2
|
+
const windows = reactive(/* @__PURE__ */ new Map());
|
|
3
|
+
const topZIndex = ref(30);
|
|
4
|
+
let cascadeOffset = 0;
|
|
5
|
+
export function useWindowManager() {
|
|
6
|
+
function bringToFront(id) {
|
|
7
|
+
const win = windows.get(id);
|
|
8
|
+
if (!win) return;
|
|
9
|
+
topZIndex.value++;
|
|
10
|
+
win.zIndex = topZIndex.value;
|
|
11
|
+
}
|
|
12
|
+
function focusWindow(id) {
|
|
13
|
+
for (const [wid, win] of windows) {
|
|
14
|
+
win.isFocused = wid === id;
|
|
15
|
+
}
|
|
16
|
+
bringToFront(id);
|
|
17
|
+
}
|
|
18
|
+
function openWindow(opts) {
|
|
19
|
+
if (windows.has(opts.id)) {
|
|
20
|
+
const win = windows.get(opts.id);
|
|
21
|
+
if (win.isMinimized) win.isMinimized = false;
|
|
22
|
+
focusWindow(opts.id);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const width = opts.width ?? 700;
|
|
26
|
+
const height = opts.height ?? 500;
|
|
27
|
+
let x, y;
|
|
28
|
+
if (opts.initialX !== void 0 && opts.initialY !== void 0) {
|
|
29
|
+
x = opts.initialX;
|
|
30
|
+
y = opts.initialY;
|
|
31
|
+
} else if (opts.spawnX !== void 0 && opts.spawnY !== void 0) {
|
|
32
|
+
x = Math.min(opts.spawnX + 16, window.innerWidth - width - 20);
|
|
33
|
+
y = Math.min(Math.max(opts.spawnY - height / 2, 20), window.innerHeight - height - 20);
|
|
34
|
+
} else {
|
|
35
|
+
const offset = cascadeOffset * 30;
|
|
36
|
+
cascadeOffset = (cascadeOffset + 1) % 10;
|
|
37
|
+
x = Math.min(100 + offset, window.innerWidth - width - 20);
|
|
38
|
+
y = Math.min(80 + offset, window.innerHeight - height - 20);
|
|
39
|
+
}
|
|
40
|
+
topZIndex.value++;
|
|
41
|
+
for (const win of windows.values()) win.isFocused = false;
|
|
42
|
+
windows.set(opts.id, {
|
|
43
|
+
id: opts.id,
|
|
44
|
+
title: opts.title,
|
|
45
|
+
icon: opts.icon,
|
|
46
|
+
docId: opts.docId,
|
|
47
|
+
docType: opts.docType,
|
|
48
|
+
channelId: opts.channelId,
|
|
49
|
+
provider: opts.provider ?? null,
|
|
50
|
+
x,
|
|
51
|
+
y,
|
|
52
|
+
width,
|
|
53
|
+
height,
|
|
54
|
+
zIndex: topZIndex.value,
|
|
55
|
+
isMinimized: false,
|
|
56
|
+
isMaximized: false,
|
|
57
|
+
isFocused: true,
|
|
58
|
+
prevX: x,
|
|
59
|
+
prevY: y,
|
|
60
|
+
prevWidth: width,
|
|
61
|
+
prevHeight: height,
|
|
62
|
+
initialTab: opts.initialTab,
|
|
63
|
+
meta: opts.meta
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function closeWindow(id) {
|
|
67
|
+
windows.delete(id);
|
|
68
|
+
}
|
|
69
|
+
function closeAll() {
|
|
70
|
+
windows.clear();
|
|
71
|
+
}
|
|
72
|
+
function minimizeWindow(id, target) {
|
|
73
|
+
const win = windows.get(id);
|
|
74
|
+
if (!win) return;
|
|
75
|
+
win.isMinimized = true;
|
|
76
|
+
win.isFocused = false;
|
|
77
|
+
if (target) win.minimizeTarget = target;
|
|
78
|
+
}
|
|
79
|
+
function restoreWindow(id) {
|
|
80
|
+
const win = windows.get(id);
|
|
81
|
+
if (!win) return;
|
|
82
|
+
win.isMinimized = false;
|
|
83
|
+
focusWindow(id);
|
|
84
|
+
}
|
|
85
|
+
function toggleMaximize(id) {
|
|
86
|
+
const win = windows.get(id);
|
|
87
|
+
if (!win) return;
|
|
88
|
+
if (win.isMaximized) {
|
|
89
|
+
win.x = win.prevX;
|
|
90
|
+
win.y = win.prevY;
|
|
91
|
+
win.width = win.prevWidth;
|
|
92
|
+
win.height = win.prevHeight;
|
|
93
|
+
win.isMaximized = false;
|
|
94
|
+
} else {
|
|
95
|
+
win.prevX = win.x;
|
|
96
|
+
win.prevY = win.y;
|
|
97
|
+
win.prevWidth = win.width;
|
|
98
|
+
win.prevHeight = win.height;
|
|
99
|
+
win.x = 0;
|
|
100
|
+
win.y = 0;
|
|
101
|
+
win.width = window.innerWidth;
|
|
102
|
+
win.height = window.innerHeight;
|
|
103
|
+
win.isMaximized = true;
|
|
104
|
+
}
|
|
105
|
+
focusWindow(id);
|
|
106
|
+
}
|
|
107
|
+
function moveWindow(id, x, y) {
|
|
108
|
+
const win = windows.get(id);
|
|
109
|
+
if (!win || win.isMaximized) return;
|
|
110
|
+
win.x = x;
|
|
111
|
+
win.y = y;
|
|
112
|
+
}
|
|
113
|
+
function resizeWindow(id, width, height, x, y) {
|
|
114
|
+
const win = windows.get(id);
|
|
115
|
+
if (!win || win.isMaximized) return;
|
|
116
|
+
win.width = Math.max(width, 300);
|
|
117
|
+
win.height = Math.max(height, 200);
|
|
118
|
+
if (x !== void 0) win.x = x;
|
|
119
|
+
if (y !== void 0) win.y = y;
|
|
120
|
+
}
|
|
121
|
+
const activeWindows = computed(
|
|
122
|
+
() => [...windows.values()].filter((w) => !w.isMinimized).sort((a, b) => a.zIndex - b.zIndex)
|
|
123
|
+
);
|
|
124
|
+
const minimizedWindows = computed(
|
|
125
|
+
() => [...windows.values()].filter((w) => w.isMinimized)
|
|
126
|
+
);
|
|
127
|
+
return {
|
|
128
|
+
windows,
|
|
129
|
+
activeWindows,
|
|
130
|
+
minimizedWindows,
|
|
131
|
+
openWindow,
|
|
132
|
+
closeWindow,
|
|
133
|
+
closeAll,
|
|
134
|
+
focusWindow,
|
|
135
|
+
minimizeWindow,
|
|
136
|
+
restoreWindow,
|
|
137
|
+
toggleMaximize,
|
|
138
|
+
moveWindow,
|
|
139
|
+
resizeWindow
|
|
140
|
+
};
|
|
141
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Y.js reactive primitives for Vue 3.
|
|
3
|
+
*
|
|
4
|
+
* IMPORTANT: All `doc` and `provider` parameters must be ShallowRef.
|
|
5
|
+
* Never pass plain refs or reactive() wrappers — Vue's deep proxy breaks Yjs internals.
|
|
6
|
+
*
|
|
7
|
+
* Ported from cou-sh/app/composables/useYDoc.ts with minor cleanup.
|
|
8
|
+
* Three.js multiplayer utilities (useMultiplayerObject, useSmoothedCursors) are
|
|
9
|
+
* included for parity but require Three.js in the consuming app.
|
|
10
|
+
*/
|
|
11
|
+
import { type Ref, type ShallowRef } from 'vue';
|
|
12
|
+
import type * as Y from 'yjs';
|
|
13
|
+
export interface AwarenessUser {
|
|
14
|
+
clientId: number;
|
|
15
|
+
user?: {
|
|
16
|
+
name?: string;
|
|
17
|
+
color?: string;
|
|
18
|
+
avatar?: string;
|
|
19
|
+
};
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}
|
|
22
|
+
export declare function useSyncedMap<T = any>(doc: ShallowRef<Y.Doc | null>, mapName: string): {
|
|
23
|
+
data: Record<string, T>;
|
|
24
|
+
lastUpdateLocal: ShallowRef<boolean, boolean>;
|
|
25
|
+
set: (key: string, value: T) => T | undefined;
|
|
26
|
+
remove: (key: string) => void | undefined;
|
|
27
|
+
clear: () => void | undefined;
|
|
28
|
+
get: (key: string) => T | undefined;
|
|
29
|
+
yMap: import("vue").ComputedRef<Y.Map<T> | null>;
|
|
30
|
+
};
|
|
31
|
+
export declare function useSyncedArray<T = any>(doc: ShallowRef<Y.Doc | null>, arrayName: string): {
|
|
32
|
+
list: Ref<T[], T[]>;
|
|
33
|
+
push: (item: T) => void | undefined;
|
|
34
|
+
unshift: (item: T) => void | undefined;
|
|
35
|
+
insert: (index: number, items: T[]) => void | undefined;
|
|
36
|
+
deleteAt: (index: number, length?: number) => void | undefined;
|
|
37
|
+
replace: (index: number, item: T) => void;
|
|
38
|
+
yArray: import("vue").ComputedRef<Y.Array<T> | null>;
|
|
39
|
+
};
|
|
40
|
+
export declare function useSyncedText(doc: ShallowRef<Y.Doc | null>, textName: string): {
|
|
41
|
+
text: Ref<string, string>;
|
|
42
|
+
insert: (index: number, content: string, attrs?: Record<string, any>) => void | undefined;
|
|
43
|
+
delete: (index: number, length: number) => void | undefined;
|
|
44
|
+
format: (index: number, length: number, attrs: Record<string, any>) => void | undefined;
|
|
45
|
+
yText: import("vue").ComputedRef<Y.Text | null>;
|
|
46
|
+
};
|
|
47
|
+
export declare function useSyncedXml(doc: ShallowRef<Y.Doc | null>, xmlName: string): {
|
|
48
|
+
yXml: ShallowRef<Y.XmlFragment | null, Y.XmlFragment | null>;
|
|
49
|
+
};
|
|
50
|
+
export declare function useAwarenessOf(provider: ShallowRef<{
|
|
51
|
+
awareness: any;
|
|
52
|
+
} | null>): {
|
|
53
|
+
states: Ref<{
|
|
54
|
+
[x: string]: any;
|
|
55
|
+
clientId: number;
|
|
56
|
+
user?: {
|
|
57
|
+
name?: string | undefined;
|
|
58
|
+
color?: string | undefined;
|
|
59
|
+
avatar?: string | undefined;
|
|
60
|
+
} | undefined;
|
|
61
|
+
}[], AwarenessUser[] | {
|
|
62
|
+
[x: string]: any;
|
|
63
|
+
clientId: number;
|
|
64
|
+
user?: {
|
|
65
|
+
name?: string | undefined;
|
|
66
|
+
color?: string | undefined;
|
|
67
|
+
avatar?: string | undefined;
|
|
68
|
+
} | undefined;
|
|
69
|
+
}[]>;
|
|
70
|
+
currentUser: Ref<{
|
|
71
|
+
[x: string]: any;
|
|
72
|
+
clientId: number;
|
|
73
|
+
user?: {
|
|
74
|
+
name?: string | undefined;
|
|
75
|
+
color?: string | undefined;
|
|
76
|
+
avatar?: string | undefined;
|
|
77
|
+
} | undefined;
|
|
78
|
+
} | null, AwarenessUser | {
|
|
79
|
+
[x: string]: any;
|
|
80
|
+
clientId: number;
|
|
81
|
+
user?: {
|
|
82
|
+
name?: string | undefined;
|
|
83
|
+
color?: string | undefined;
|
|
84
|
+
avatar?: string | undefined;
|
|
85
|
+
} | undefined;
|
|
86
|
+
} | null>;
|
|
87
|
+
setLocalState: (state: any) => void;
|
|
88
|
+
};
|
|
89
|
+
export declare function useSmoothedCursors(provider: ShallowRef<{
|
|
90
|
+
awareness: any;
|
|
91
|
+
} | null>, posKey?: string, lerpFactor?: number): {
|
|
92
|
+
cursors: Ref<{
|
|
93
|
+
clientId: number;
|
|
94
|
+
x: number;
|
|
95
|
+
y: number;
|
|
96
|
+
state: {
|
|
97
|
+
[x: string]: any;
|
|
98
|
+
clientId: number;
|
|
99
|
+
user?: {
|
|
100
|
+
name?: string | undefined;
|
|
101
|
+
color?: string | undefined;
|
|
102
|
+
avatar?: string | undefined;
|
|
103
|
+
} | undefined;
|
|
104
|
+
};
|
|
105
|
+
}[], {
|
|
106
|
+
clientId: number;
|
|
107
|
+
x: number;
|
|
108
|
+
y: number;
|
|
109
|
+
state: AwarenessUser;
|
|
110
|
+
}[] | {
|
|
111
|
+
clientId: number;
|
|
112
|
+
x: number;
|
|
113
|
+
y: number;
|
|
114
|
+
state: {
|
|
115
|
+
[x: string]: any;
|
|
116
|
+
clientId: number;
|
|
117
|
+
user?: {
|
|
118
|
+
name?: string | undefined;
|
|
119
|
+
color?: string | undefined;
|
|
120
|
+
avatar?: string | undefined;
|
|
121
|
+
} | undefined;
|
|
122
|
+
};
|
|
123
|
+
}[]>;
|
|
124
|
+
states: Ref<{
|
|
125
|
+
[x: string]: any;
|
|
126
|
+
clientId: number;
|
|
127
|
+
user?: {
|
|
128
|
+
name?: string | undefined;
|
|
129
|
+
color?: string | undefined;
|
|
130
|
+
avatar?: string | undefined;
|
|
131
|
+
} | undefined;
|
|
132
|
+
}[], AwarenessUser[] | {
|
|
133
|
+
[x: string]: any;
|
|
134
|
+
clientId: number;
|
|
135
|
+
user?: {
|
|
136
|
+
name?: string | undefined;
|
|
137
|
+
color?: string | undefined;
|
|
138
|
+
avatar?: string | undefined;
|
|
139
|
+
} | undefined;
|
|
140
|
+
}[]>;
|
|
141
|
+
setLocalState: (state: any) => void;
|
|
142
|
+
};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import {
|
|
2
|
+
reactive,
|
|
3
|
+
ref,
|
|
4
|
+
shallowRef,
|
|
5
|
+
computed,
|
|
6
|
+
watch,
|
|
7
|
+
onMounted,
|
|
8
|
+
onBeforeUnmount
|
|
9
|
+
} from "vue";
|
|
10
|
+
export function useSyncedMap(doc, mapName) {
|
|
11
|
+
const state = reactive({});
|
|
12
|
+
const ymap = shallowRef(null);
|
|
13
|
+
const lastUpdateLocal = shallowRef(true);
|
|
14
|
+
const observer = (event) => {
|
|
15
|
+
lastUpdateLocal.value = event.transaction.local;
|
|
16
|
+
event.keysChanged.forEach((key) => {
|
|
17
|
+
if (ymap.value.has(key)) state[key] = ymap.value.get(key);
|
|
18
|
+
else delete state[key];
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const init = (newDoc) => {
|
|
22
|
+
if (ymap.value) ymap.value.unobserve(observer);
|
|
23
|
+
ymap.value = newDoc.getMap(mapName);
|
|
24
|
+
for (const key in state) delete state[key];
|
|
25
|
+
ymap.value.forEach((value, key) => {
|
|
26
|
+
state[key] = value;
|
|
27
|
+
});
|
|
28
|
+
ymap.value.observe(observer);
|
|
29
|
+
};
|
|
30
|
+
watch(doc, (d) => d && init(d), { immediate: true });
|
|
31
|
+
onBeforeUnmount(() => {
|
|
32
|
+
if (ymap.value) ymap.value.unobserve(observer);
|
|
33
|
+
});
|
|
34
|
+
return {
|
|
35
|
+
data: state,
|
|
36
|
+
lastUpdateLocal,
|
|
37
|
+
set: (key, value) => ymap.value?.set(key, value),
|
|
38
|
+
remove: (key) => ymap.value?.delete(key),
|
|
39
|
+
clear: () => ymap.value?.clear(),
|
|
40
|
+
get: (key) => ymap.value?.get(key),
|
|
41
|
+
yMap: computed(() => ymap.value)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export function useSyncedArray(doc, arrayName) {
|
|
45
|
+
const list = ref([]);
|
|
46
|
+
const yarray = shallowRef(null);
|
|
47
|
+
const observer = (event) => {
|
|
48
|
+
let index = 0;
|
|
49
|
+
event.delta.forEach((op) => {
|
|
50
|
+
if (op.retain) {
|
|
51
|
+
index += op.retain;
|
|
52
|
+
} else if (op.insert) {
|
|
53
|
+
const items = op.insert;
|
|
54
|
+
list.value.splice(index, 0, ...items);
|
|
55
|
+
index += items.length;
|
|
56
|
+
} else if (op.delete) {
|
|
57
|
+
list.value.splice(index, op.delete);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const init = (newDoc) => {
|
|
62
|
+
if (yarray.value) yarray.value.unobserve(observer);
|
|
63
|
+
yarray.value = newDoc.getArray(arrayName);
|
|
64
|
+
list.value = yarray.value.toArray();
|
|
65
|
+
yarray.value.observe(observer);
|
|
66
|
+
};
|
|
67
|
+
watch(doc, (d) => d && init(d), { immediate: true });
|
|
68
|
+
onBeforeUnmount(() => {
|
|
69
|
+
if (yarray.value) yarray.value.unobserve(observer);
|
|
70
|
+
});
|
|
71
|
+
return {
|
|
72
|
+
list,
|
|
73
|
+
push: (item) => yarray.value?.push([item]),
|
|
74
|
+
unshift: (item) => yarray.value?.insert(0, [item]),
|
|
75
|
+
insert: (index, items) => yarray.value?.insert(index, items),
|
|
76
|
+
deleteAt: (index, length = 1) => yarray.value?.delete(index, length),
|
|
77
|
+
replace: (index, item) => {
|
|
78
|
+
if (!yarray.value || !doc.value) return;
|
|
79
|
+
doc.value.transact(() => {
|
|
80
|
+
yarray.value.delete(index, 1);
|
|
81
|
+
yarray.value.insert(index, [item]);
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
yArray: computed(() => yarray.value)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export function useSyncedText(doc, textName) {
|
|
88
|
+
const text = ref("");
|
|
89
|
+
const ytext = shallowRef(null);
|
|
90
|
+
const observer = () => {
|
|
91
|
+
text.value = ytext.value.toString();
|
|
92
|
+
};
|
|
93
|
+
const init = (newDoc) => {
|
|
94
|
+
if (ytext.value) ytext.value.unobserve(observer);
|
|
95
|
+
ytext.value = newDoc.getText(textName);
|
|
96
|
+
text.value = ytext.value.toString();
|
|
97
|
+
ytext.value.observe(observer);
|
|
98
|
+
};
|
|
99
|
+
watch(doc, (d) => d && init(d), { immediate: true });
|
|
100
|
+
onBeforeUnmount(() => {
|
|
101
|
+
if (ytext.value) ytext.value.unobserve(observer);
|
|
102
|
+
});
|
|
103
|
+
return {
|
|
104
|
+
text,
|
|
105
|
+
insert: (index, content, attrs) => ytext.value?.insert(index, content, attrs),
|
|
106
|
+
delete: (index, length) => ytext.value?.delete(index, length),
|
|
107
|
+
format: (index, length, attrs) => ytext.value?.format(index, length, attrs),
|
|
108
|
+
yText: computed(() => ytext.value)
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export function useSyncedXml(doc, xmlName) {
|
|
112
|
+
const yXml = shallowRef(null);
|
|
113
|
+
watch(doc, (d) => {
|
|
114
|
+
if (d) yXml.value = d.getXmlFragment(xmlName);
|
|
115
|
+
}, { immediate: true });
|
|
116
|
+
return { yXml };
|
|
117
|
+
}
|
|
118
|
+
export function useAwarenessOf(provider) {
|
|
119
|
+
const states = ref([]);
|
|
120
|
+
const currentUser = ref(null);
|
|
121
|
+
const update = () => {
|
|
122
|
+
if (!provider.value) return;
|
|
123
|
+
const awareness = provider.value.awareness;
|
|
124
|
+
states.value = Array.from(awareness.getStates().entries()).map(([id, state]) => ({ clientId: id, ...state }));
|
|
125
|
+
const local = awareness.getLocalState();
|
|
126
|
+
if (local) currentUser.value = { clientId: awareness.clientID, ...local };
|
|
127
|
+
};
|
|
128
|
+
watch(provider, (p, oldP) => {
|
|
129
|
+
if (oldP) oldP.awareness.off("change", update);
|
|
130
|
+
if (p) {
|
|
131
|
+
p.awareness.on("change", update);
|
|
132
|
+
update();
|
|
133
|
+
}
|
|
134
|
+
}, { immediate: true });
|
|
135
|
+
const setLocalState = (state) => {
|
|
136
|
+
if (!provider.value) return;
|
|
137
|
+
const awareness = provider.value.awareness;
|
|
138
|
+
const current = awareness.getLocalState() || {};
|
|
139
|
+
awareness.setLocalState({ ...current, ...state });
|
|
140
|
+
};
|
|
141
|
+
return { states, currentUser, setLocalState };
|
|
142
|
+
}
|
|
143
|
+
export function useSmoothedCursors(provider, posKey = "pos", lerpFactor = 0.3) {
|
|
144
|
+
const { states, setLocalState } = useAwarenessOf(provider);
|
|
145
|
+
const localId = computed(() => provider.value?.awareness?.clientID ?? 0);
|
|
146
|
+
const cursors = ref([]);
|
|
147
|
+
let frame;
|
|
148
|
+
const tick = () => {
|
|
149
|
+
const activeIds = /* @__PURE__ */ new Set();
|
|
150
|
+
for (const s of states.value) {
|
|
151
|
+
if (s.clientId === localId.value) continue;
|
|
152
|
+
const pos = s[posKey];
|
|
153
|
+
if (pos == null) continue;
|
|
154
|
+
activeIds.add(s.clientId);
|
|
155
|
+
const entry = cursors.value.find((c) => c.clientId === s.clientId);
|
|
156
|
+
if (!entry) {
|
|
157
|
+
cursors.value.push({ clientId: s.clientId, x: pos.x, y: pos.y, state: s });
|
|
158
|
+
} else {
|
|
159
|
+
entry.x += (pos.x - entry.x) * lerpFactor;
|
|
160
|
+
entry.y += (pos.y - entry.y) * lerpFactor;
|
|
161
|
+
entry.state = s;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
for (let i = cursors.value.length - 1; i >= 0; i--) {
|
|
165
|
+
if (!activeIds.has(cursors.value[i].clientId)) cursors.value.splice(i, 1);
|
|
166
|
+
}
|
|
167
|
+
frame = requestAnimationFrame(tick);
|
|
168
|
+
};
|
|
169
|
+
onMounted(() => tick());
|
|
170
|
+
onBeforeUnmount(() => cancelAnimationFrame(frame));
|
|
171
|
+
return { cursors, states, setLocalState };
|
|
172
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Node, mergeAttributes } from "@tiptap/core";
|
|
2
|
+
import { VueNodeViewRenderer } from "@tiptap/vue-3";
|
|
3
|
+
import AccordionView from "./views/AccordionView.vue";
|
|
4
|
+
import AccordionItemView from "./views/AccordionItemView.vue";
|
|
5
|
+
export const AccordionItem = Node.create({
|
|
6
|
+
name: "accordionItem",
|
|
7
|
+
content: "block+",
|
|
8
|
+
addAttributes() {
|
|
9
|
+
return {
|
|
10
|
+
label: { default: "Item" },
|
|
11
|
+
icon: { default: "" }
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
parseHTML() {
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
tag: "div[data-accordion-item]",
|
|
18
|
+
getAttrs: (el) => ({
|
|
19
|
+
label: el.getAttribute("data-label"),
|
|
20
|
+
icon: el.getAttribute("data-icon")
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
];
|
|
24
|
+
},
|
|
25
|
+
renderHTML({ HTMLAttributes }) {
|
|
26
|
+
return ["div", mergeAttributes({
|
|
27
|
+
"data-accordion-item": "",
|
|
28
|
+
"data-label": HTMLAttributes.label,
|
|
29
|
+
"data-icon": HTMLAttributes.icon
|
|
30
|
+
}), 0];
|
|
31
|
+
},
|
|
32
|
+
addNodeView() {
|
|
33
|
+
return VueNodeViewRenderer(AccordionItemView);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
export const Accordion = Node.create({
|
|
37
|
+
name: "accordion",
|
|
38
|
+
group: "block",
|
|
39
|
+
content: "accordionItem+",
|
|
40
|
+
parseHTML() {
|
|
41
|
+
return [{ tag: "div[data-accordion]" }];
|
|
42
|
+
},
|
|
43
|
+
renderHTML() {
|
|
44
|
+
return ["div", { "data-accordion": "" }, 0];
|
|
45
|
+
},
|
|
46
|
+
addNodeView() {
|
|
47
|
+
return VueNodeViewRenderer(AccordionView);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Node, mergeAttributes } from "@tiptap/core";
|
|
2
|
+
import { VueNodeViewRenderer } from "@tiptap/vue-3";
|
|
3
|
+
import BadgeView from "./views/BadgeView.vue";
|
|
4
|
+
export const Badge = Node.create({
|
|
5
|
+
name: "badge",
|
|
6
|
+
group: "inline",
|
|
7
|
+
inline: true,
|
|
8
|
+
atom: true,
|
|
9
|
+
addAttributes() {
|
|
10
|
+
return {
|
|
11
|
+
label: { default: "Badge" },
|
|
12
|
+
color: { default: "neutral" },
|
|
13
|
+
variant: { default: "subtle" }
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
parseHTML() {
|
|
17
|
+
return [
|
|
18
|
+
{
|
|
19
|
+
tag: "span[data-badge]",
|
|
20
|
+
getAttrs: (el) => ({
|
|
21
|
+
label: el.getAttribute("data-label"),
|
|
22
|
+
color: el.getAttribute("data-color"),
|
|
23
|
+
variant: el.getAttribute("data-variant")
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
];
|
|
27
|
+
},
|
|
28
|
+
renderHTML({ HTMLAttributes }) {
|
|
29
|
+
return ["span", mergeAttributes({
|
|
30
|
+
"data-badge": "",
|
|
31
|
+
"data-label": HTMLAttributes.label,
|
|
32
|
+
"data-color": HTMLAttributes.color,
|
|
33
|
+
"data-variant": HTMLAttributes.variant
|
|
34
|
+
})];
|
|
35
|
+
},
|
|
36
|
+
addNodeView() {
|
|
37
|
+
return VueNodeViewRenderer(BadgeView);
|
|
38
|
+
}
|
|
39
|
+
});
|