@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,227 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
import * as Y from "yjs";
|
|
3
|
+
import { populateYDocFromMarkdown, filenameToLabel, parseFrontmatter } from "../utils/markdownToYjs.js";
|
|
4
|
+
const TEXT_EXTENSIONS = ["md", "mdx", "txt", "html", "htm"];
|
|
5
|
+
export function useDocImport() {
|
|
6
|
+
const toast = useToast();
|
|
7
|
+
const { provider, client, isReady } = useAbracadabra();
|
|
8
|
+
const { enqueue } = useOfflineUploadQueue();
|
|
9
|
+
const externalDragActive = ref(false);
|
|
10
|
+
let externalDragCounter = 0;
|
|
11
|
+
function getTreeMap() {
|
|
12
|
+
const p = provider.value;
|
|
13
|
+
if (!p?.document) return null;
|
|
14
|
+
return p.document.getMap("doc-tree");
|
|
15
|
+
}
|
|
16
|
+
function isExternalFileDrag(e) {
|
|
17
|
+
return !!e.dataTransfer?.types.includes("Files");
|
|
18
|
+
}
|
|
19
|
+
function onDragEnter(e) {
|
|
20
|
+
if (!isExternalFileDrag(e)) return;
|
|
21
|
+
externalDragCounter++;
|
|
22
|
+
externalDragActive.value = true;
|
|
23
|
+
}
|
|
24
|
+
function onDragLeave(e) {
|
|
25
|
+
if (!isExternalFileDrag(e)) return;
|
|
26
|
+
externalDragCounter--;
|
|
27
|
+
if (externalDragCounter <= 0) {
|
|
28
|
+
externalDragCounter = 0;
|
|
29
|
+
externalDragActive.value = false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function onDragOver(e) {
|
|
33
|
+
if (!isExternalFileDrag(e)) return;
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
if (e.dataTransfer) e.dataTransfer.dropEffect = "copy";
|
|
36
|
+
}
|
|
37
|
+
async function onFileDrop(e, parentId = null) {
|
|
38
|
+
externalDragActive.value = false;
|
|
39
|
+
externalDragCounter = 0;
|
|
40
|
+
if (!isReady.value || !provider.value) return;
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
const entries = Array.from(e.dataTransfer?.items ?? []).map((item) => item.webkitGetAsEntry()).filter((entry) => entry !== null);
|
|
43
|
+
if (!entries.length) return;
|
|
44
|
+
let firstId = null;
|
|
45
|
+
for (const entry of entries) {
|
|
46
|
+
const id = await importEntry(entry, parentId);
|
|
47
|
+
if (firstId === null && id !== null) firstId = id;
|
|
48
|
+
}
|
|
49
|
+
if (firstId) navigateTo(`${useRuntimeConfig().public.abracadabra?.docBasePath ?? "/doc"}/${firstId}`);
|
|
50
|
+
}
|
|
51
|
+
function importFiles(parentId = null) {
|
|
52
|
+
const input = document.createElement("input");
|
|
53
|
+
input.type = "file";
|
|
54
|
+
input.multiple = true;
|
|
55
|
+
input.onchange = async () => {
|
|
56
|
+
if (!input.files?.length) return;
|
|
57
|
+
let firstId = null;
|
|
58
|
+
for (const file of Array.from(input.files)) {
|
|
59
|
+
const id = await importFile(file, parentId);
|
|
60
|
+
if (firstId === null) firstId = id;
|
|
61
|
+
}
|
|
62
|
+
if (firstId) navigateTo(`${useRuntimeConfig().public.abracadabra?.docBasePath ?? "/doc"}/${firstId}`);
|
|
63
|
+
};
|
|
64
|
+
input.click();
|
|
65
|
+
}
|
|
66
|
+
function importFolder(parentId = null) {
|
|
67
|
+
const input = document.createElement("input");
|
|
68
|
+
input.type = "file";
|
|
69
|
+
input.setAttribute("webkitdirectory", "");
|
|
70
|
+
input.onchange = async () => {
|
|
71
|
+
if (!input.files?.length) return;
|
|
72
|
+
const folderIds = /* @__PURE__ */ new Map();
|
|
73
|
+
const files = Array.from(input.files).sort(
|
|
74
|
+
(a, b) => (a.webkitRelativePath || a.name).localeCompare(b.webkitRelativePath || b.name)
|
|
75
|
+
);
|
|
76
|
+
let firstId = null;
|
|
77
|
+
for (const file of files) {
|
|
78
|
+
if (file.name.startsWith(".")) continue;
|
|
79
|
+
const relPath = file.webkitRelativePath || file.name;
|
|
80
|
+
const segments = relPath.split("/");
|
|
81
|
+
let currentParent = parentId;
|
|
82
|
+
for (let i = 0; i < segments.length - 1; i++) {
|
|
83
|
+
const folderPath = segments.slice(0, i + 1).join("/");
|
|
84
|
+
if (!folderIds.has(folderPath)) {
|
|
85
|
+
const folderId = crypto.randomUUID();
|
|
86
|
+
getTreeMap()?.set(folderId, {
|
|
87
|
+
label: filenameToLabel(segments[i]),
|
|
88
|
+
parentId: currentParent,
|
|
89
|
+
order: Date.now() + i,
|
|
90
|
+
type: "doc"
|
|
91
|
+
});
|
|
92
|
+
folderIds.set(folderPath, folderId);
|
|
93
|
+
}
|
|
94
|
+
currentParent = folderIds.get(folderPath);
|
|
95
|
+
}
|
|
96
|
+
const id = await importFile(file, currentParent);
|
|
97
|
+
if (firstId === null) firstId = id;
|
|
98
|
+
}
|
|
99
|
+
if (firstId) navigateTo(`${useRuntimeConfig().public.abracadabra?.docBasePath ?? "/doc"}/${firstId}`);
|
|
100
|
+
};
|
|
101
|
+
input.click();
|
|
102
|
+
}
|
|
103
|
+
async function importEntry(entry, parentId) {
|
|
104
|
+
if (entry.isFile) {
|
|
105
|
+
if (entry.name.startsWith(".")) return null;
|
|
106
|
+
const file = await new Promise(
|
|
107
|
+
(resolve, reject) => entry.file(resolve, reject)
|
|
108
|
+
);
|
|
109
|
+
return importFile(file, parentId);
|
|
110
|
+
}
|
|
111
|
+
if (entry.isDirectory) {
|
|
112
|
+
if (entry.name.startsWith(".")) return null;
|
|
113
|
+
const label = filenameToLabel(entry.name);
|
|
114
|
+
const id = crypto.randomUUID();
|
|
115
|
+
getTreeMap()?.set(id, { label, parentId, order: Date.now(), type: "doc" });
|
|
116
|
+
const children = await readDirEntries(entry);
|
|
117
|
+
children.sort((a, b) => {
|
|
118
|
+
if (a.isDirectory !== b.isDirectory) return a.isDirectory ? -1 : 1;
|
|
119
|
+
return a.name.localeCompare(b.name);
|
|
120
|
+
});
|
|
121
|
+
for (const child of children) await importEntry(child, id);
|
|
122
|
+
return id;
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
async function importFile(file, parentId) {
|
|
127
|
+
const ext = file.name.split(".").pop()?.toLowerCase() ?? "";
|
|
128
|
+
if (TEXT_EXTENSIONS.includes(ext)) {
|
|
129
|
+
return importTextFile(file, parentId);
|
|
130
|
+
}
|
|
131
|
+
return importBinaryFile(file, parentId);
|
|
132
|
+
}
|
|
133
|
+
async function importTextFile(file, parentId) {
|
|
134
|
+
const ext = file.name.split(".").pop()?.toLowerCase() ?? "";
|
|
135
|
+
const text = await file.text();
|
|
136
|
+
let label = filenameToLabel(file.name);
|
|
137
|
+
let meta = {};
|
|
138
|
+
let body = text;
|
|
139
|
+
let docType = "doc";
|
|
140
|
+
if (ext === "md" || ext === "mdx" || ext === "txt") {
|
|
141
|
+
const fm = parseFrontmatter(text);
|
|
142
|
+
if (fm.title) label = fm.title;
|
|
143
|
+
if (fm.type) docType = fm.type;
|
|
144
|
+
meta = fm.meta;
|
|
145
|
+
body = fm.body;
|
|
146
|
+
}
|
|
147
|
+
const id = crypto.randomUUID();
|
|
148
|
+
getTreeMap()?.set(id, {
|
|
149
|
+
label,
|
|
150
|
+
parentId,
|
|
151
|
+
order: Date.now(),
|
|
152
|
+
type: docType,
|
|
153
|
+
...Object.keys(meta).length ? { meta } : {}
|
|
154
|
+
});
|
|
155
|
+
const childProv = await provider.value.loadChild(id);
|
|
156
|
+
const fragment = childProv.document.getXmlFragment("default");
|
|
157
|
+
if (ext === "html" || ext === "htm") {
|
|
158
|
+
const stripped = text.replace(/<[^>]+>/g, "");
|
|
159
|
+
populateYDocFromMarkdown(fragment, stripped, label);
|
|
160
|
+
} else {
|
|
161
|
+
populateYDocFromMarkdown(fragment, body, label);
|
|
162
|
+
}
|
|
163
|
+
return id;
|
|
164
|
+
}
|
|
165
|
+
async function importBinaryFile(file, parentId) {
|
|
166
|
+
const id = crypto.randomUUID();
|
|
167
|
+
const label = filenameToLabel(file.name);
|
|
168
|
+
const mimeType = file.type || "application/octet-stream";
|
|
169
|
+
getTreeMap()?.set(id, { label, parentId, order: Date.now(), type: "doc" });
|
|
170
|
+
let uploadId;
|
|
171
|
+
let uploadDocId;
|
|
172
|
+
try {
|
|
173
|
+
if (!client.value) throw new Error("offline");
|
|
174
|
+
const meta = await client.value.upload(id, file);
|
|
175
|
+
uploadId = meta.id;
|
|
176
|
+
uploadDocId = meta.doc_id;
|
|
177
|
+
} catch {
|
|
178
|
+
const meta = await enqueue(id, file);
|
|
179
|
+
uploadId = meta.id;
|
|
180
|
+
uploadDocId = meta.doc_id;
|
|
181
|
+
toast.add({
|
|
182
|
+
title: "Upload queued",
|
|
183
|
+
description: `"${file.name}" will upload when reconnected.`,
|
|
184
|
+
color: "warning",
|
|
185
|
+
icon: "i-lucide-cloud-off"
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
const childProv = await provider.value.loadChild(id);
|
|
189
|
+
const fragment = childProv.document.getXmlFragment("default");
|
|
190
|
+
childProv.document.transact(() => {
|
|
191
|
+
const el = new Y.XmlElement("fileBlock");
|
|
192
|
+
el.setAttribute("uploadId", uploadId);
|
|
193
|
+
el.setAttribute("docId", uploadDocId);
|
|
194
|
+
el.setAttribute("filename", file.name);
|
|
195
|
+
el.setAttribute("mimeType", mimeType);
|
|
196
|
+
fragment.insert(0, [el]);
|
|
197
|
+
});
|
|
198
|
+
return id;
|
|
199
|
+
}
|
|
200
|
+
function readDirEntries(dir) {
|
|
201
|
+
return new Promise((resolve, reject) => {
|
|
202
|
+
const reader = dir.createReader();
|
|
203
|
+
const all = [];
|
|
204
|
+
function next() {
|
|
205
|
+
reader.readEntries((batch) => {
|
|
206
|
+
if (!batch.length) {
|
|
207
|
+
resolve(all);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
all.push(...batch);
|
|
211
|
+
next();
|
|
212
|
+
}, reject);
|
|
213
|
+
}
|
|
214
|
+
next();
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
externalDragActive,
|
|
219
|
+
onDragEnter,
|
|
220
|
+
onDragLeave,
|
|
221
|
+
onDragOver,
|
|
222
|
+
onFileDrop,
|
|
223
|
+
importFiles,
|
|
224
|
+
importFolder,
|
|
225
|
+
importFile
|
|
226
|
+
};
|
|
227
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
interface JumpTarget {
|
|
2
|
+
docId: string;
|
|
3
|
+
from: number;
|
|
4
|
+
to: number;
|
|
5
|
+
}
|
|
6
|
+
export declare const useDocJump: () => {
|
|
7
|
+
hoverHighlight: import("vue").Ref<{
|
|
8
|
+
docId: string;
|
|
9
|
+
from: number;
|
|
10
|
+
to: number;
|
|
11
|
+
} | null, JumpTarget | {
|
|
12
|
+
docId: string;
|
|
13
|
+
from: number;
|
|
14
|
+
to: number;
|
|
15
|
+
} | null>;
|
|
16
|
+
pendingJump: import("vue").Ref<{
|
|
17
|
+
docId: string;
|
|
18
|
+
from: number;
|
|
19
|
+
to: number;
|
|
20
|
+
} | null, JumpTarget | {
|
|
21
|
+
docId: string;
|
|
22
|
+
from: number;
|
|
23
|
+
to: number;
|
|
24
|
+
} | null>;
|
|
25
|
+
hoverStart: (docId: string, from: number, to: number) => void;
|
|
26
|
+
hoverEnd: () => void;
|
|
27
|
+
jumpTo: (docId: string, from: number, to: number) => void;
|
|
28
|
+
};
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
import { createSharedComposable } from "@vueuse/core";
|
|
3
|
+
const _useDocJump = () => {
|
|
4
|
+
const hoverHighlight = ref(null);
|
|
5
|
+
const pendingJump = ref(null);
|
|
6
|
+
function hoverStart(docId, from, to) {
|
|
7
|
+
hoverHighlight.value = { docId, from, to };
|
|
8
|
+
}
|
|
9
|
+
function hoverEnd() {
|
|
10
|
+
hoverHighlight.value = null;
|
|
11
|
+
}
|
|
12
|
+
function jumpTo(docId, from, to) {
|
|
13
|
+
pendingJump.value = { docId, from, to };
|
|
14
|
+
}
|
|
15
|
+
return { hoverHighlight, pendingJump, hoverStart, hoverEnd, jumpTo };
|
|
16
|
+
};
|
|
17
|
+
export const useDocJump = createSharedComposable(_useDocJump);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type MaybeRef } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* RBAC composable — maps a role string to permission flags.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* const { canWrite, canDelete, meetsRole } = useDocumentPermissions(role)
|
|
7
|
+
* if (canWrite.value) { ... }
|
|
8
|
+
* if (meetsRole('editor')) { ... }
|
|
9
|
+
*/
|
|
10
|
+
export declare function useDocumentPermissions(role: MaybeRef<string | undefined | null>): {
|
|
11
|
+
canRead: import("vue").ComputedRef<boolean>;
|
|
12
|
+
canWrite: import("vue").ComputedRef<boolean>;
|
|
13
|
+
canCreate: import("vue").ComputedRef<boolean>;
|
|
14
|
+
canDelete: import("vue").ComputedRef<boolean>;
|
|
15
|
+
canUpload: import("vue").ComputedRef<boolean>;
|
|
16
|
+
canManage: import("vue").ComputedRef<boolean>;
|
|
17
|
+
isOwner: import("vue").ComputedRef<boolean>;
|
|
18
|
+
meetsRole: (required: string | string[]) => boolean;
|
|
19
|
+
level: import("vue").ComputedRef<number>;
|
|
20
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { computed, toValue } from "vue";
|
|
2
|
+
const ROLE_HIERARCHY = {
|
|
3
|
+
owner: 5,
|
|
4
|
+
admin: 4,
|
|
5
|
+
member: 3,
|
|
6
|
+
editor: 2,
|
|
7
|
+
viewer: 1
|
|
8
|
+
};
|
|
9
|
+
export function useDocumentPermissions(role) {
|
|
10
|
+
const level = computed(() => ROLE_HIERARCHY[toValue(role) ?? ""] ?? 0);
|
|
11
|
+
const canRead = computed(() => level.value >= 1);
|
|
12
|
+
const canWrite = computed(() => level.value >= 2);
|
|
13
|
+
const canCreate = computed(() => level.value >= 2);
|
|
14
|
+
const canDelete = computed(() => level.value >= 3);
|
|
15
|
+
const canUpload = computed(() => level.value >= 2);
|
|
16
|
+
const canManage = computed(() => level.value >= 4);
|
|
17
|
+
const isOwner = computed(() => level.value >= 5);
|
|
18
|
+
function meetsRole(required) {
|
|
19
|
+
const requirements = Array.isArray(required) ? required : [required];
|
|
20
|
+
return requirements.some((r) => level.value >= (ROLE_HIERARCHY[r] ?? 0));
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
canRead,
|
|
24
|
+
canWrite,
|
|
25
|
+
canCreate,
|
|
26
|
+
canDelete,
|
|
27
|
+
canUpload,
|
|
28
|
+
canManage,
|
|
29
|
+
isOwner,
|
|
30
|
+
meetsRole,
|
|
31
|
+
level
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TipTap collaboration editor composable.
|
|
3
|
+
*
|
|
4
|
+
* Sets up Collaboration + CollaborationCaret extensions for a child Y.Doc,
|
|
5
|
+
* merges in all plugin-contributed extensions, and manages awareness user state.
|
|
6
|
+
*
|
|
7
|
+
* This composable is used internally by <AbracadabraEditor> but is also
|
|
8
|
+
* exported for app authors who want to use <UEditor> directly:
|
|
9
|
+
*
|
|
10
|
+
* const { extensions } = useEditor({ childProvider, docId })
|
|
11
|
+
* <UEditor :extensions="extensions" v-model="content" />
|
|
12
|
+
*
|
|
13
|
+
* IMPORTANT: provider and doc references are shallowRef — never deep-watch them.
|
|
14
|
+
*
|
|
15
|
+
* Ported from cou-sh/app/composables/useEditorCollaboration.ts.
|
|
16
|
+
*/
|
|
17
|
+
import { type Ref, type ShallowRef } from 'vue';
|
|
18
|
+
import type { Extensions } from '@tiptap/core';
|
|
19
|
+
import type { CollaborationUser } from '../types.js';
|
|
20
|
+
export { type CollaborationUser } from '../types.js';
|
|
21
|
+
export interface UseEditorOptions {
|
|
22
|
+
/** Child Y.Doc provider (shallowRef). Loaded via provider.value.loadChild(docId). */
|
|
23
|
+
childProvider: ShallowRef<any | null>;
|
|
24
|
+
/** Document ID — used in editor plugin context objects. */
|
|
25
|
+
docId: string;
|
|
26
|
+
/** Extra TipTap extensions beyond what the plugin registry contributes. */
|
|
27
|
+
extraExtensions?: Extensions;
|
|
28
|
+
/** Whether the editor is editable. Default: true. */
|
|
29
|
+
editable?: Ref<boolean> | boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare function useEditor(options: UseEditorOptions): {
|
|
32
|
+
extensions: ShallowRef<Extensions, Extensions>;
|
|
33
|
+
connectedUsers: Ref<{
|
|
34
|
+
name: string;
|
|
35
|
+
color: string;
|
|
36
|
+
publicKey?: string | undefined;
|
|
37
|
+
docId?: string | undefined;
|
|
38
|
+
}[], CollaborationUser[] | {
|
|
39
|
+
name: string;
|
|
40
|
+
color: string;
|
|
41
|
+
publicKey?: string | undefined;
|
|
42
|
+
docId?: string | undefined;
|
|
43
|
+
}[]>;
|
|
44
|
+
ready: Ref<boolean, boolean>;
|
|
45
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { ref, shallowRef, watch, onUnmounted } from "vue";
|
|
2
|
+
import { XmlElement } from "yjs";
|
|
3
|
+
export function useEditor(options) {
|
|
4
|
+
const { childProvider, extraExtensions = [] } = options;
|
|
5
|
+
const { userName, userColor, publicKeyB64, registry } = useNuxtApp().$abracadabra;
|
|
6
|
+
const connectedUsers = ref([]);
|
|
7
|
+
const extensions = shallowRef([]);
|
|
8
|
+
const ready = ref(false);
|
|
9
|
+
let cleanup = null;
|
|
10
|
+
watch(childProvider, async (prov) => {
|
|
11
|
+
cleanup?.();
|
|
12
|
+
cleanup = null;
|
|
13
|
+
if (!prov) {
|
|
14
|
+
ready.value = false;
|
|
15
|
+
extensions.value = [];
|
|
16
|
+
connectedUsers.value = [];
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const [
|
|
20
|
+
{ default: Collaboration },
|
|
21
|
+
{ default: CollaborationCaret }
|
|
22
|
+
] = await Promise.all([
|
|
23
|
+
import("@tiptap/extension-collaboration"),
|
|
24
|
+
import("@tiptap/extension-collaboration-caret")
|
|
25
|
+
]);
|
|
26
|
+
const user = { name: userName.value, color: userColor.value, publicKey: publicKeyB64.value };
|
|
27
|
+
prov.awareness?.setLocalStateField("user", user);
|
|
28
|
+
await registry.waitForExtensions();
|
|
29
|
+
const pluginExtensions = registry.getAllExtensions();
|
|
30
|
+
extensions.value = [
|
|
31
|
+
...pluginExtensions,
|
|
32
|
+
Collaboration.configure({ document: prov.document }),
|
|
33
|
+
CollaborationCaret.configure({
|
|
34
|
+
provider: prov,
|
|
35
|
+
user,
|
|
36
|
+
selectionRender: (u) => {
|
|
37
|
+
const color = u.color || "#999";
|
|
38
|
+
const selectionColor = color.startsWith("hsl") ? color.replace("hsl", "hsla").replace(")", ", 0.4)") : `${color}66`;
|
|
39
|
+
return {
|
|
40
|
+
class: "collaboration-carets__selection",
|
|
41
|
+
style: `--collaboration-selection-color: ${selectionColor}`
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}),
|
|
45
|
+
...extraExtensions
|
|
46
|
+
];
|
|
47
|
+
const ydoc = prov.document;
|
|
48
|
+
const fragment = ydoc?.getXmlFragment?.("default");
|
|
49
|
+
function dedupeByName(nodeName) {
|
|
50
|
+
if (!fragment) return;
|
|
51
|
+
const children = fragment.toArray();
|
|
52
|
+
const indices = [];
|
|
53
|
+
children.forEach((child, idx) => {
|
|
54
|
+
if (child.nodeName === nodeName) indices.push(idx);
|
|
55
|
+
});
|
|
56
|
+
if (indices.length <= 1) return;
|
|
57
|
+
const toRemove = /* @__PURE__ */ new Set();
|
|
58
|
+
for (let i = 1; i < indices.length; i++) {
|
|
59
|
+
const hi = indices[i];
|
|
60
|
+
toRemove.add(hi);
|
|
61
|
+
const afterIdx = hi + 1;
|
|
62
|
+
const beforeIdx = hi - 1;
|
|
63
|
+
if (afterIdx < children.length && !toRemove.has(afterIdx) && children[afterIdx]?.nodeName === "paragraph" && children[afterIdx].length === 0) {
|
|
64
|
+
toRemove.add(afterIdx);
|
|
65
|
+
} else if (beforeIdx >= 0 && !toRemove.has(beforeIdx) && children[beforeIdx]?.nodeName === "paragraph" && children[beforeIdx].length === 0) {
|
|
66
|
+
toRemove.add(beforeIdx);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const sortedDesc = [...toRemove].sort((a, b) => b - a);
|
|
70
|
+
ydoc.transact(() => {
|
|
71
|
+
for (const idx of sortedDesc) fragment.delete(idx, 1);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const dedupeHeaders = () => dedupeByName("documentHeader");
|
|
75
|
+
const dedupeDocumentMeta = () => dedupeByName("documentMeta");
|
|
76
|
+
function ensureDocumentMeta() {
|
|
77
|
+
if (!fragment) return;
|
|
78
|
+
const children = fragment.toArray();
|
|
79
|
+
if (children.some((c) => c.nodeName === "documentMeta")) return;
|
|
80
|
+
const headerIdx = children.findIndex((c) => c.nodeName === "documentHeader");
|
|
81
|
+
const insertIdx = headerIdx >= 0 ? headerIdx + 1 : 0;
|
|
82
|
+
const metaEl = new XmlElement("documentMeta");
|
|
83
|
+
ydoc.transact(() => {
|
|
84
|
+
fragment.insert(insertIdx, [metaEl]);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
if (fragment) {
|
|
88
|
+
fragment.observe(dedupeHeaders);
|
|
89
|
+
fragment.observe(dedupeDocumentMeta);
|
|
90
|
+
dedupeHeaders();
|
|
91
|
+
dedupeDocumentMeta();
|
|
92
|
+
ensureDocumentMeta();
|
|
93
|
+
}
|
|
94
|
+
ready.value = true;
|
|
95
|
+
const updateUsers = () => {
|
|
96
|
+
const states = prov.awareness?.getStates() ?? /* @__PURE__ */ new Map();
|
|
97
|
+
const users = [];
|
|
98
|
+
states.forEach((state) => {
|
|
99
|
+
if (state.user && typeof state.user === "object") {
|
|
100
|
+
const u = state.user;
|
|
101
|
+
users.push({ name: u.name || "", color: u.color || "#999", publicKey: u.publicKey || void 0 });
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
connectedUsers.value = users;
|
|
105
|
+
};
|
|
106
|
+
prov.awareness?.on("change", updateUsers);
|
|
107
|
+
updateUsers();
|
|
108
|
+
cleanup = () => {
|
|
109
|
+
prov.awareness?.off("change", updateUsers);
|
|
110
|
+
if (fragment) {
|
|
111
|
+
fragment.unobserve(dedupeHeaders);
|
|
112
|
+
fragment.unobserve(dedupeDocumentMeta);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}, { immediate: true });
|
|
116
|
+
onUnmounted(() => cleanup?.());
|
|
117
|
+
watch([userName, userColor, publicKeyB64], ([name, color, publicKey]) => {
|
|
118
|
+
childProvider.value?.awareness?.setLocalStateField("user", { name, color, publicKey });
|
|
119
|
+
});
|
|
120
|
+
return { extensions, connectedUsers, ready };
|
|
121
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { DropdownMenuItem } from '@nuxt/ui';
|
|
2
|
+
import type { Editor, JSONContent } from '@tiptap/vue-3';
|
|
3
|
+
import type { DragHandlePluginCtx } from '../types.js';
|
|
4
|
+
export declare function useEditorDragHandle(pageConfig?: {
|
|
5
|
+
pageTypes?: Array<{
|
|
6
|
+
key: string;
|
|
7
|
+
label: string;
|
|
8
|
+
icon: string;
|
|
9
|
+
}>;
|
|
10
|
+
onChangePageType?: (typeKey: string) => void;
|
|
11
|
+
onInsertDocLink?: () => void;
|
|
12
|
+
}): {
|
|
13
|
+
selectedNode: import("vue").Ref<{
|
|
14
|
+
node: JSONContent | null;
|
|
15
|
+
pos: number;
|
|
16
|
+
} | undefined, {
|
|
17
|
+
node: JSONContent | null;
|
|
18
|
+
pos: number;
|
|
19
|
+
} | undefined>;
|
|
20
|
+
getItems: (editor: Editor) => DropdownMenuItem[][];
|
|
21
|
+
getMergedItems: (editor: Editor, ctx: DragHandlePluginCtx) => DropdownMenuItem[][];
|
|
22
|
+
onNodeChange: (event: {
|
|
23
|
+
node: JSONContent | null;
|
|
24
|
+
pos: number;
|
|
25
|
+
}) => void;
|
|
26
|
+
};
|