@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,219 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
function upperFirst(s) {
|
|
3
|
+
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
4
|
+
}
|
|
5
|
+
const CONVERTIBLE_TYPES = [
|
|
6
|
+
"paragraph",
|
|
7
|
+
"heading",
|
|
8
|
+
"bulletList",
|
|
9
|
+
"orderedList",
|
|
10
|
+
"taskList",
|
|
11
|
+
"blockquote",
|
|
12
|
+
"codeBlock",
|
|
13
|
+
"listItem",
|
|
14
|
+
"taskItem"
|
|
15
|
+
];
|
|
16
|
+
export function useEditorDragHandle(pageConfig) {
|
|
17
|
+
const selectedNode = ref();
|
|
18
|
+
function getTypeSpecificItems(editor, nodeType) {
|
|
19
|
+
const pos = selectedNode.value?.pos;
|
|
20
|
+
if (CONVERTIBLE_TYPES.includes(nodeType)) {
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
label: "Turn into",
|
|
24
|
+
icon: "i-lucide-repeat-2",
|
|
25
|
+
children: [
|
|
26
|
+
{ label: "Paragraph", icon: "i-lucide-type", onSelect: () => editor.chain().focus().setParagraph().run() },
|
|
27
|
+
{ label: "Heading 1", icon: "i-lucide-heading-1", onSelect: () => editor.chain().focus().toggleHeading({ level: 1 }).run() },
|
|
28
|
+
{ label: "Heading 2", icon: "i-lucide-heading-2", onSelect: () => editor.chain().focus().toggleHeading({ level: 2 }).run() },
|
|
29
|
+
{ label: "Heading 3", icon: "i-lucide-heading-3", onSelect: () => editor.chain().focus().toggleHeading({ level: 3 }).run() },
|
|
30
|
+
{ label: "Bullet List", icon: "i-lucide-list", onSelect: () => editor.chain().focus().toggleBulletList().run() },
|
|
31
|
+
{ label: "Ordered List", icon: "i-lucide-list-ordered", onSelect: () => editor.chain().focus().toggleOrderedList().run() },
|
|
32
|
+
{ label: "Task List", icon: "i-lucide-list-check", onSelect: () => editor.chain().focus().toggleTaskList().run() },
|
|
33
|
+
{ label: "Blockquote", icon: "i-lucide-text-quote", onSelect: () => editor.chain().focus().toggleBlockquote().run() },
|
|
34
|
+
{ label: "Code Block", icon: "i-lucide-square-code", onSelect: () => editor.chain().focus().toggleCodeBlock().run() }
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
if (nodeType === "fileBlock") {
|
|
40
|
+
const node = pos !== void 0 ? editor.state.doc.nodeAt(pos) : null;
|
|
41
|
+
const filename = node?.attrs?.filename || "file";
|
|
42
|
+
const uploadId = node?.attrs?.uploadId;
|
|
43
|
+
const docId = node?.attrs?.docId;
|
|
44
|
+
return [
|
|
45
|
+
{
|
|
46
|
+
label: "Download",
|
|
47
|
+
icon: "i-lucide-download",
|
|
48
|
+
onSelect: async () => {
|
|
49
|
+
if (!uploadId || !docId) return;
|
|
50
|
+
const { getBlobUrl } = useFileBlobStore();
|
|
51
|
+
try {
|
|
52
|
+
const url = await getBlobUrl(docId, uploadId);
|
|
53
|
+
if (!url) return;
|
|
54
|
+
const a = document.createElement("a");
|
|
55
|
+
a.href = url;
|
|
56
|
+
a.download = filename;
|
|
57
|
+
a.click();
|
|
58
|
+
} catch {
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
if (nodeType === "image") {
|
|
65
|
+
const node = pos !== void 0 ? editor.state.doc.nodeAt(pos) : null;
|
|
66
|
+
return [
|
|
67
|
+
{ label: "Download image", icon: "i-lucide-download", to: node?.attrs?.src, download: true }
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
if (nodeType === "table") {
|
|
71
|
+
return [
|
|
72
|
+
{
|
|
73
|
+
label: "Clear all contents",
|
|
74
|
+
icon: "i-lucide-square-x",
|
|
75
|
+
onSelect: () => {
|
|
76
|
+
if (pos === void 0) return;
|
|
77
|
+
const tableNode = editor.state.doc.nodeAt(pos);
|
|
78
|
+
if (!tableNode) return;
|
|
79
|
+
const cellRanges = [];
|
|
80
|
+
tableNode.descendants((node, nodePos) => {
|
|
81
|
+
if (node.type.name === "tableCell" || node.type.name === "tableHeader") {
|
|
82
|
+
const cellStart = pos + 1 + nodePos + 1;
|
|
83
|
+
const cellEnd = cellStart + node.content.size;
|
|
84
|
+
if (node.content.size > 0) cellRanges.push({ from: cellStart, to: cellEnd });
|
|
85
|
+
}
|
|
86
|
+
return true;
|
|
87
|
+
});
|
|
88
|
+
const { tr } = editor.state;
|
|
89
|
+
cellRanges.reverse().forEach(({ from, to }) => tr.delete(from, to));
|
|
90
|
+
editor.view.dispatch(tr);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
function getItems(editor) {
|
|
98
|
+
if (!selectedNode.value?.node?.type) return [];
|
|
99
|
+
const nodeType = selectedNode.value.node.type;
|
|
100
|
+
const typeSpecificItems = getTypeSpecificItems(editor, nodeType);
|
|
101
|
+
const pos = selectedNode.value.pos;
|
|
102
|
+
const result = [
|
|
103
|
+
[
|
|
104
|
+
{ type: "label", label: upperFirst(nodeType) },
|
|
105
|
+
...typeSpecificItems
|
|
106
|
+
],
|
|
107
|
+
[
|
|
108
|
+
{
|
|
109
|
+
label: "Duplicate",
|
|
110
|
+
icon: "i-lucide-copy",
|
|
111
|
+
onSelect: () => {
|
|
112
|
+
if (pos === void 0) return;
|
|
113
|
+
const node = editor.state.doc.nodeAt(pos);
|
|
114
|
+
if (!node) return;
|
|
115
|
+
editor.chain().focus().insertContentAt(pos + node.nodeSize, node.toJSON()).run();
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
label: "Copy to clipboard",
|
|
120
|
+
icon: "i-lucide-clipboard",
|
|
121
|
+
onSelect: async () => {
|
|
122
|
+
if (!selectedNode.value) return;
|
|
123
|
+
const node = editor.state.doc.nodeAt(selectedNode.value.pos);
|
|
124
|
+
if (node) await navigator.clipboard.writeText(node.textContent);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
...pageConfig?.onInsertDocLink ? [{
|
|
128
|
+
label: "Insert doc link",
|
|
129
|
+
icon: "i-lucide-file-symlink",
|
|
130
|
+
onSelect: () => pageConfig.onInsertDocLink()
|
|
131
|
+
}] : []
|
|
132
|
+
],
|
|
133
|
+
[
|
|
134
|
+
{
|
|
135
|
+
label: "Move up",
|
|
136
|
+
icon: "i-lucide-arrow-up",
|
|
137
|
+
onSelect: () => {
|
|
138
|
+
if (pos === void 0) return;
|
|
139
|
+
const node = editor.state.doc.nodeAt(pos);
|
|
140
|
+
if (!node || pos === 0) return;
|
|
141
|
+
const $pos = editor.state.doc.resolve(pos);
|
|
142
|
+
const parent = $pos.parent;
|
|
143
|
+
const index = $pos.index();
|
|
144
|
+
if (index === 0) return;
|
|
145
|
+
const before = parent.child(index - 1);
|
|
146
|
+
const tr = editor.state.tr;
|
|
147
|
+
tr.delete(pos - before.nodeSize, pos);
|
|
148
|
+
tr.insert(pos + node.nodeSize - before.nodeSize, before);
|
|
149
|
+
editor.view.dispatch(tr);
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
label: "Move down",
|
|
154
|
+
icon: "i-lucide-arrow-down",
|
|
155
|
+
onSelect: () => {
|
|
156
|
+
if (pos === void 0) return;
|
|
157
|
+
const node = editor.state.doc.nodeAt(pos);
|
|
158
|
+
if (!node) return;
|
|
159
|
+
const $pos = editor.state.doc.resolve(pos);
|
|
160
|
+
const parent = $pos.parent;
|
|
161
|
+
const index = $pos.index();
|
|
162
|
+
if (index >= parent.childCount - 1) return;
|
|
163
|
+
const after = parent.child(index + 1);
|
|
164
|
+
const tr = editor.state.tr;
|
|
165
|
+
tr.delete(pos + node.nodeSize, pos + node.nodeSize + after.nodeSize);
|
|
166
|
+
tr.insert(pos, after);
|
|
167
|
+
editor.view.dispatch(tr);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
],
|
|
171
|
+
[
|
|
172
|
+
{
|
|
173
|
+
label: "Delete",
|
|
174
|
+
icon: "i-lucide-trash",
|
|
175
|
+
color: "error",
|
|
176
|
+
onSelect: () => {
|
|
177
|
+
if (pos === void 0) return;
|
|
178
|
+
const node = editor.state.doc.nodeAt(pos);
|
|
179
|
+
if (!node) return;
|
|
180
|
+
editor.chain().focus().deleteRange({ from: pos, to: pos + node.nodeSize }).run();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
];
|
|
185
|
+
if (pageConfig?.pageTypes?.length && pageConfig?.onChangePageType) {
|
|
186
|
+
result.push([
|
|
187
|
+
{
|
|
188
|
+
label: "Convert Page to",
|
|
189
|
+
icon: "i-lucide-repeat-2",
|
|
190
|
+
children: pageConfig.pageTypes.map((t) => ({
|
|
191
|
+
label: t.label,
|
|
192
|
+
icon: t.icon,
|
|
193
|
+
onSelect: () => pageConfig.onChangePageType(t.key)
|
|
194
|
+
}))
|
|
195
|
+
}
|
|
196
|
+
]);
|
|
197
|
+
}
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
function getMergedItems(editor, ctx) {
|
|
201
|
+
const { registry } = useAbracadabra();
|
|
202
|
+
const base = getItems(editor);
|
|
203
|
+
const pluginItems = registry.getAllDragHandleItems(ctx).map(
|
|
204
|
+
(items) => items.map((item) => ({
|
|
205
|
+
label: item.label,
|
|
206
|
+
icon: item.icon,
|
|
207
|
+
onSelect: () => item.action(ctx)
|
|
208
|
+
}))
|
|
209
|
+
);
|
|
210
|
+
if (pluginItems.length) {
|
|
211
|
+
return [...base, ...pluginItems];
|
|
212
|
+
}
|
|
213
|
+
return base;
|
|
214
|
+
}
|
|
215
|
+
function onNodeChange(event) {
|
|
216
|
+
selectedNode.value = event;
|
|
217
|
+
}
|
|
218
|
+
return { selectedNode, getItems, getMergedItems, onNodeChange };
|
|
219
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useEditorMentions
|
|
3
|
+
*
|
|
4
|
+
* Returns mention items for UEditorMentionMenu.
|
|
5
|
+
* Combines awareness users (currently online) with plugin mention providers.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* const { items } = useEditorMentions()
|
|
9
|
+
* <UEditorMentionMenu :editor="editor" :items="items" />
|
|
10
|
+
*/
|
|
11
|
+
export interface MentionItem {
|
|
12
|
+
label: string;
|
|
13
|
+
value: string;
|
|
14
|
+
icon?: string;
|
|
15
|
+
avatar?: {
|
|
16
|
+
alt: string;
|
|
17
|
+
style?: Record<string, string>;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export interface UseEditorMentionsOptions {
|
|
21
|
+
/** Additional static items */
|
|
22
|
+
extraItems?: MentionItem[];
|
|
23
|
+
/** Doc ID for provider context */
|
|
24
|
+
docId?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare function useEditorMentions(options?: UseEditorMentionsOptions): {
|
|
27
|
+
items: any;
|
|
28
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export function useEditorMentions(options = {}) {
|
|
2
|
+
const { provider } = useAbracadabra();
|
|
3
|
+
const registry = usePluginRegistry();
|
|
4
|
+
const items = computed(() => {
|
|
5
|
+
const result = [];
|
|
6
|
+
if (provider.value) {
|
|
7
|
+
try {
|
|
8
|
+
const states = provider.value.awareness?.states ? [...provider.value.awareness.states.values()] : [];
|
|
9
|
+
for (const state of states) {
|
|
10
|
+
const user = state.user;
|
|
11
|
+
if (user?.name) {
|
|
12
|
+
result.push({
|
|
13
|
+
label: user.name,
|
|
14
|
+
value: user.name,
|
|
15
|
+
avatar: {
|
|
16
|
+
alt: user.name,
|
|
17
|
+
style: user.color ? { borderColor: user.color, borderWidth: "2px", borderStyle: "solid" } : void 0
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
} catch {
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const providers = registry.getAllMentionProviders();
|
|
27
|
+
for (const p of providers) {
|
|
28
|
+
if (p.staticItems) {
|
|
29
|
+
result.push(...p.staticItems);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
} catch {
|
|
33
|
+
}
|
|
34
|
+
if (options.extraItems?.length) {
|
|
35
|
+
result.push(...options.extraItems);
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
});
|
|
39
|
+
return { items };
|
|
40
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useEditorSuggestions
|
|
3
|
+
*
|
|
4
|
+
* Returns pre-built slash command suggestion item groups for UEditorSuggestionMenu,
|
|
5
|
+
* merging standard blocks with plugin registry contributions.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* const { items } = useEditorSuggestions()
|
|
9
|
+
* <UEditorSuggestionMenu :editor="editor" :items="items" />
|
|
10
|
+
*/
|
|
11
|
+
export interface UseEditorSuggestionsOptions {
|
|
12
|
+
docId?: string;
|
|
13
|
+
/** Skip default items and return only plugin contributions */
|
|
14
|
+
onlyPlugins?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function useEditorSuggestions(options?: UseEditorSuggestionsOptions): {
|
|
17
|
+
items: any;
|
|
18
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export function useEditorSuggestions(options = {}) {
|
|
2
|
+
const registry = usePluginRegistry();
|
|
3
|
+
const items = computed(() => {
|
|
4
|
+
const ctx = { docId: options.docId ?? "" };
|
|
5
|
+
const base = options.onlyPlugins ? [] : [
|
|
6
|
+
[
|
|
7
|
+
{ type: "label", label: "Style" },
|
|
8
|
+
{ kind: "paragraph", label: "Paragraph", icon: "i-lucide-type" },
|
|
9
|
+
{ kind: "heading", level: 1, label: "Heading 1", icon: "i-lucide-heading-1" },
|
|
10
|
+
{ kind: "heading", level: 2, label: "Heading 2", icon: "i-lucide-heading-2" },
|
|
11
|
+
{ kind: "heading", level: 3, label: "Heading 3", icon: "i-lucide-heading-3" },
|
|
12
|
+
{ kind: "bulletList", label: "Bullet List", icon: "i-lucide-list" },
|
|
13
|
+
{ kind: "orderedList", label: "Numbered List", icon: "i-lucide-list-ordered" },
|
|
14
|
+
{ kind: "taskList", label: "Task List", icon: "i-lucide-list-check" },
|
|
15
|
+
{ kind: "blockquote", label: "Blockquote", icon: "i-lucide-text-quote" },
|
|
16
|
+
{ kind: "codeBlock", label: "Code Block", icon: "i-lucide-square-code" }
|
|
17
|
+
],
|
|
18
|
+
[
|
|
19
|
+
{ type: "label", label: "Insert" },
|
|
20
|
+
{ kind: "mention", label: "Mention", icon: "i-lucide-at-sign" },
|
|
21
|
+
{ kind: "table", label: "Table", icon: "i-lucide-table" },
|
|
22
|
+
{ kind: "horizontalRule", label: "Divider", icon: "i-lucide-minus" }
|
|
23
|
+
],
|
|
24
|
+
[
|
|
25
|
+
{ type: "label", label: "Components" },
|
|
26
|
+
{ kind: "callout", label: "Callout", icon: "i-lucide-info" },
|
|
27
|
+
{ kind: "collapsible", label: "Collapsible", icon: "i-lucide-chevron-down" },
|
|
28
|
+
{ kind: "accordion", label: "Accordion", icon: "i-lucide-chevrons-down-up" },
|
|
29
|
+
{ kind: "tabs", label: "Tabs", icon: "i-lucide-panel-top" },
|
|
30
|
+
{ kind: "card", label: "Card", icon: "i-lucide-square" },
|
|
31
|
+
{ kind: "steps", label: "Steps", icon: "i-lucide-list-ordered" },
|
|
32
|
+
{ kind: "codeGroup", label: "Code Group", icon: "i-lucide-folder-code" }
|
|
33
|
+
]
|
|
34
|
+
];
|
|
35
|
+
try {
|
|
36
|
+
const pluginGroups = registry.getAllSuggestionItems(ctx);
|
|
37
|
+
for (const group of pluginGroups) {
|
|
38
|
+
if (group.items?.length) base.push(group.items);
|
|
39
|
+
}
|
|
40
|
+
} catch {
|
|
41
|
+
}
|
|
42
|
+
return base;
|
|
43
|
+
});
|
|
44
|
+
return { items };
|
|
45
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useEditorToolbar
|
|
3
|
+
*
|
|
4
|
+
* Returns pre-built toolbar item groups for UEditorToolbar,
|
|
5
|
+
* merging the plugin registry's contributions with standard formatting items.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* const { items } = useEditorToolbar()
|
|
9
|
+
* <UEditorToolbar :editor="editor" :items="items" />
|
|
10
|
+
*/
|
|
11
|
+
import type { Editor } from '@tiptap/vue-3';
|
|
12
|
+
export interface UseEditorToolbarOptions {
|
|
13
|
+
/** Current editor instance (used to build plugin context) */
|
|
14
|
+
editor?: Editor | null;
|
|
15
|
+
/** Doc ID for plugin context */
|
|
16
|
+
docId?: string;
|
|
17
|
+
/** Additional custom items appended after plugin items */
|
|
18
|
+
extraItems?: any[][];
|
|
19
|
+
}
|
|
20
|
+
export declare function useEditorToolbar(options?: UseEditorToolbarOptions): {
|
|
21
|
+
items: any;
|
|
22
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export function useEditorToolbar(options = {}) {
|
|
2
|
+
const registry = usePluginRegistry();
|
|
3
|
+
const abra = useAbracadabra();
|
|
4
|
+
const items = computed(() => {
|
|
5
|
+
const editor = options.editor ?? null;
|
|
6
|
+
const ctx = {
|
|
7
|
+
editor,
|
|
8
|
+
docId: options.docId,
|
|
9
|
+
abracadabra: abra
|
|
10
|
+
};
|
|
11
|
+
const base = [[
|
|
12
|
+
{ kind: "undo", icon: "i-lucide-undo", tooltip: { text: "Undo" } },
|
|
13
|
+
{ kind: "redo", icon: "i-lucide-redo", tooltip: { text: "Redo" } }
|
|
14
|
+
], [
|
|
15
|
+
{
|
|
16
|
+
label: "Turn into",
|
|
17
|
+
trailingIcon: "i-lucide-chevron-down",
|
|
18
|
+
activeColor: "neutral",
|
|
19
|
+
activeVariant: "ghost",
|
|
20
|
+
tooltip: { text: "Turn into" },
|
|
21
|
+
content: { align: "start" },
|
|
22
|
+
ui: { label: "text-xs" },
|
|
23
|
+
items: [
|
|
24
|
+
{ type: "label", label: "Turn into" },
|
|
25
|
+
{ kind: "paragraph", label: "Paragraph", icon: "i-lucide-type" },
|
|
26
|
+
{ kind: "heading", level: 1, label: "Heading 1", icon: "i-lucide-heading-1" },
|
|
27
|
+
{ kind: "heading", level: 2, label: "Heading 2", icon: "i-lucide-heading-2" },
|
|
28
|
+
{ kind: "heading", level: 3, label: "Heading 3", icon: "i-lucide-heading-3" },
|
|
29
|
+
{ kind: "bulletList", label: "Bullet List", icon: "i-lucide-list" },
|
|
30
|
+
{ kind: "orderedList", label: "Ordered List", icon: "i-lucide-list-ordered" },
|
|
31
|
+
{ kind: "taskList", label: "Task List", icon: "i-lucide-list-check" },
|
|
32
|
+
{ kind: "blockquote", label: "Blockquote", icon: "i-lucide-text-quote" },
|
|
33
|
+
{ kind: "codeBlock", label: "Code Block", icon: "i-lucide-square-code" }
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
], [
|
|
37
|
+
{ kind: "mark", mark: "bold", icon: "i-lucide-bold", tooltip: { text: "Bold" } },
|
|
38
|
+
{ kind: "mark", mark: "italic", icon: "i-lucide-italic", tooltip: { text: "Italic" } },
|
|
39
|
+
{ kind: "mark", mark: "underline", icon: "i-lucide-underline", tooltip: { text: "Underline" } },
|
|
40
|
+
{ kind: "mark", mark: "strike", icon: "i-lucide-strikethrough", tooltip: { text: "Strikethrough" } },
|
|
41
|
+
{ kind: "mark", mark: "code", icon: "i-lucide-code", tooltip: { text: "Inline code" } }
|
|
42
|
+
], [
|
|
43
|
+
{ kind: "mark", mark: "link", icon: "i-lucide-link", tooltip: { text: "Link" } }
|
|
44
|
+
]];
|
|
45
|
+
try {
|
|
46
|
+
const pluginGroups = registry.getAllToolbarItems(ctx);
|
|
47
|
+
for (const group of pluginGroups) {
|
|
48
|
+
if (group.items?.length) {
|
|
49
|
+
base.push(group.items);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
} catch {
|
|
53
|
+
}
|
|
54
|
+
if (options.extraItems?.length) {
|
|
55
|
+
base.push(...options.extraItems);
|
|
56
|
+
}
|
|
57
|
+
return base;
|
|
58
|
+
});
|
|
59
|
+
return { items };
|
|
60
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useFileBlobStore
|
|
3
|
+
*
|
|
4
|
+
* Wraps FileBlobStore from @abraca/dabra.
|
|
5
|
+
* Provides getBlobUrl() which caches file blobs in IndexedDB for offline access.
|
|
6
|
+
* Initialized right after the client is created (before first sync) so
|
|
7
|
+
* IDB-cached blobs are served even when offline.
|
|
8
|
+
*/
|
|
9
|
+
export declare function _initFileBlobStore(store: any): void;
|
|
10
|
+
export declare function _getFileBlobStore(): any;
|
|
11
|
+
export declare function _destroyFileBlobStore(): void;
|
|
12
|
+
export declare function useFileBlobStore(): {
|
|
13
|
+
getBlobUrl: (docId: string, uploadId: string) => Promise<string | null>;
|
|
14
|
+
putBlob: (docId: string, id: string, file: File, filename: string) => Promise<void>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
let _store = null;
|
|
2
|
+
export function _initFileBlobStore(store) {
|
|
3
|
+
_store = store;
|
|
4
|
+
}
|
|
5
|
+
export function _getFileBlobStore() {
|
|
6
|
+
return _store;
|
|
7
|
+
}
|
|
8
|
+
export function _destroyFileBlobStore() {
|
|
9
|
+
_store?.destroy();
|
|
10
|
+
_store = null;
|
|
11
|
+
}
|
|
12
|
+
export function useFileBlobStore() {
|
|
13
|
+
async function getBlobUrl(docId, uploadId) {
|
|
14
|
+
if (!_store) return null;
|
|
15
|
+
return _store.getBlobUrl(docId, uploadId);
|
|
16
|
+
}
|
|
17
|
+
async function putBlob(docId, id, file, filename) {
|
|
18
|
+
if (!_store) return;
|
|
19
|
+
return _store.putBlob(docId, id, file, filename);
|
|
20
|
+
}
|
|
21
|
+
return { getBlobUrl, putBlob };
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useFileIndex
|
|
3
|
+
*
|
|
4
|
+
* Indexes fileBlock nodes from all synced documents, enabling
|
|
5
|
+
* file-centric search. Watches BackgroundSync states and re-indexes
|
|
6
|
+
* each document's file blocks when it syncs.
|
|
7
|
+
*/
|
|
8
|
+
export interface FileEntry {
|
|
9
|
+
uploadId: string;
|
|
10
|
+
filename: string;
|
|
11
|
+
mimeType: string;
|
|
12
|
+
docId: string;
|
|
13
|
+
docLabel: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function _initFileIndex(): void;
|
|
16
|
+
export declare function _destroyFileIndex(): void;
|
|
17
|
+
export declare function useFileIndex(): {
|
|
18
|
+
searchFiles: (query: string, limit?: number) => FileEntry[];
|
|
19
|
+
getAllFiles: () => FileEntry[];
|
|
20
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { watch } from "vue";
|
|
2
|
+
import * as Y from "yjs";
|
|
3
|
+
let _fileEntries = /* @__PURE__ */ new Map();
|
|
4
|
+
let _stopWatcher = null;
|
|
5
|
+
function walkXmlForFiles(node, docId, docLabel, results) {
|
|
6
|
+
for (const child of node.toArray()) {
|
|
7
|
+
if (child instanceof Y.XmlElement) {
|
|
8
|
+
if (child.nodeName === "fileBlock") {
|
|
9
|
+
const uploadId = child.getAttribute("uploadId");
|
|
10
|
+
const filename = child.getAttribute("filename") ?? "";
|
|
11
|
+
const mimeType = child.getAttribute("mimeType") ?? "";
|
|
12
|
+
if (uploadId) results.push({ uploadId, filename, mimeType, docId, docLabel });
|
|
13
|
+
}
|
|
14
|
+
walkXmlForFiles(child, docId, docLabel, results);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function _initFileIndex() {
|
|
19
|
+
_fileEntries = /* @__PURE__ */ new Map();
|
|
20
|
+
_startWatcher();
|
|
21
|
+
}
|
|
22
|
+
export function _destroyFileIndex() {
|
|
23
|
+
_stopWatcher?.();
|
|
24
|
+
_stopWatcher = null;
|
|
25
|
+
_fileEntries = /* @__PURE__ */ new Map();
|
|
26
|
+
}
|
|
27
|
+
function _startWatcher() {
|
|
28
|
+
const { syncStates } = useBackgroundSync();
|
|
29
|
+
const { provider } = useAbracadabra();
|
|
30
|
+
const stop = watch(syncStates, async (states) => {
|
|
31
|
+
const p = provider.value;
|
|
32
|
+
if (!p) return;
|
|
33
|
+
for (const [docId, state] of states.entries()) {
|
|
34
|
+
if (state.status !== "synced") continue;
|
|
35
|
+
try {
|
|
36
|
+
const childProvider = await p.loadChild(docId);
|
|
37
|
+
await childProvider.ready;
|
|
38
|
+
const treeMap = p.document.getMap("doc-tree");
|
|
39
|
+
const docLabel = treeMap.get(docId)?.label ?? "";
|
|
40
|
+
const files = [];
|
|
41
|
+
walkXmlForFiles(childProvider.document.getXmlFragment("default"), docId, docLabel, files);
|
|
42
|
+
for (const [key, val] of _fileEntries.entries()) {
|
|
43
|
+
if (val.docId === docId) _fileEntries.delete(key);
|
|
44
|
+
}
|
|
45
|
+
for (const f of files) _fileEntries.set(f.uploadId, f);
|
|
46
|
+
} catch {
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}, { deep: false });
|
|
50
|
+
_stopWatcher = stop;
|
|
51
|
+
}
|
|
52
|
+
export function useFileIndex() {
|
|
53
|
+
function searchFiles(query, limit = 15) {
|
|
54
|
+
if (!query || query.length < 2) return [];
|
|
55
|
+
const q = query.toLowerCase();
|
|
56
|
+
const results = [];
|
|
57
|
+
for (const entry of _fileEntries.values()) {
|
|
58
|
+
if (entry.filename.toLowerCase().includes(q) || entry.mimeType.toLowerCase().includes(q)) {
|
|
59
|
+
results.push(entry);
|
|
60
|
+
if (results.length >= limit) break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return results;
|
|
64
|
+
}
|
|
65
|
+
function getAllFiles() {
|
|
66
|
+
return [..._fileEntries.values()];
|
|
67
|
+
}
|
|
68
|
+
return { searchFiles, getAllFiles };
|
|
69
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
const followingUserKey = ref(null);
|
|
3
|
+
let cleanup = null;
|
|
4
|
+
let navLock = false;
|
|
5
|
+
export function useFollowUser() {
|
|
6
|
+
function setFollowing(key, provider, getCurrentDocId) {
|
|
7
|
+
cleanup?.();
|
|
8
|
+
cleanup = null;
|
|
9
|
+
navLock = false;
|
|
10
|
+
followingUserKey.value = key;
|
|
11
|
+
if (!key || !provider?.awareness) return;
|
|
12
|
+
const awareness = provider.awareness;
|
|
13
|
+
function check() {
|
|
14
|
+
if (navLock) return;
|
|
15
|
+
const states = awareness.getStates();
|
|
16
|
+
for (const state of states.values()) {
|
|
17
|
+
if (state.user?.publicKey === key) {
|
|
18
|
+
const targetDocId = state.docId;
|
|
19
|
+
if (targetDocId && targetDocId !== getCurrentDocId()) {
|
|
20
|
+
navLock = true;
|
|
21
|
+
navigateTo(`${useRuntimeConfig().public.abracadabra?.docBasePath ?? "/doc"}/${targetDocId}`);
|
|
22
|
+
setTimeout(() => {
|
|
23
|
+
navLock = false;
|
|
24
|
+
}, 1e3);
|
|
25
|
+
}
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
check();
|
|
31
|
+
awareness.on("change", check);
|
|
32
|
+
cleanup = () => awareness.off("change", check);
|
|
33
|
+
}
|
|
34
|
+
function stopFollowing() {
|
|
35
|
+
followingUserKey.value = null;
|
|
36
|
+
cleanup?.();
|
|
37
|
+
cleanup = null;
|
|
38
|
+
}
|
|
39
|
+
return { followingUserKey, setFollowing, stopFollowing };
|
|
40
|
+
}
|