@abraca/nuxt 2.96.0 → 2.97.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/dist/module.json +1 -1
- package/dist/runtime/components/ADocSubPageList.vue +8 -0
- package/dist/runtime/components/ANodePanel.vue +11 -1
- package/dist/runtime/components/ANodePanelStack.d.vue.ts +19 -0
- package/dist/runtime/components/ANodePanelStack.vue +35 -0
- package/dist/runtime/components/ANodePanelStack.vue.d.ts +19 -0
- package/dist/runtime/components/APresence.d.vue.ts +1 -13
- package/dist/runtime/components/APresence.vue.d.ts +1 -13
- package/dist/runtime/components/ATagsPopover.d.vue.ts +34 -0
- package/dist/runtime/components/ATagsPopover.vue +114 -0
- package/dist/runtime/components/ATagsPopover.vue.d.ts +34 -0
- package/dist/runtime/components/chat/AChatMessages.d.vue.ts +14 -0
- package/dist/runtime/components/chat/AChatMessages.vue +94 -14
- package/dist/runtime/components/chat/AChatMessages.vue.d.ts +14 -0
- package/dist/runtime/components/chat/AChatPanel.d.vue.ts +10 -0
- package/dist/runtime/components/chat/AChatPanel.vue +5 -1
- package/dist/runtime/components/chat/AChatPanel.vue.d.ts +10 -0
- package/dist/runtime/components/chat/ANodeChatPanel.d.vue.ts +10 -3
- package/dist/runtime/components/chat/ANodeChatPanel.vue +6 -2
- package/dist/runtime/components/chat/ANodeChatPanel.vue.d.ts +10 -3
- package/dist/runtime/components/docs/ADocsSearch.d.vue.ts +2 -2
- package/dist/runtime/components/docs/ADocsSearch.vue.d.ts +2 -2
- package/dist/runtime/components/docs/ADocsSearchButton.d.vue.ts +1 -1
- package/dist/runtime/components/docs/ADocsSearchButton.vue.d.ts +1 -1
- package/dist/runtime/components/editor/AMetaChip.vue +18 -16
- package/dist/runtime/components/settings/ASettingsAboutPanel.d.vue.ts +3 -0
- package/dist/runtime/components/settings/ASettingsAboutPanel.vue +143 -0
- package/dist/runtime/components/settings/ASettingsAboutPanel.vue.d.ts +3 -0
- package/dist/runtime/components/settings/ASettingsConnectionPanel.vue +65 -100
- package/dist/runtime/components/settings/ASettingsModal.vue +7 -2
- package/dist/runtime/components/settings/sections.d.ts +28 -2
- package/dist/runtime/components/settings/sections.js +23 -0
- package/dist/runtime/components/shell/AUserMenu.d.vue.ts +2 -2
- package/dist/runtime/components/shell/AUserMenu.vue.d.ts +2 -2
- package/dist/runtime/composables/awarenessView.d.ts +46 -0
- package/dist/runtime/composables/awarenessView.js +65 -0
- package/dist/runtime/composables/useAwareness.js +19 -28
- package/dist/runtime/composables/useAwarenessPeers.d.ts +1 -25
- package/dist/runtime/composables/useChat.d.ts +21 -0
- package/dist/runtime/composables/useChat.js +77 -3
- package/dist/runtime/composables/useDocOpen.d.ts +69 -0
- package/dist/runtime/composables/useDocOpen.js +158 -0
- package/dist/runtime/composables/useRendererBase.d.ts +1 -25
- package/dist/runtime/composables/useSettingsModal.d.ts +1 -1
- package/dist/runtime/composables/useSpaceConnections.js +1 -60
- package/dist/runtime/composables/useYDoc.d.ts +3 -75
- package/dist/runtime/composables/useYDoc.js +28 -33
- package/dist/runtime/extensions/views/DocLinkView.vue +15 -5
- package/dist/runtime/extensions/views/MetaFieldView.vue +61 -49
- package/dist/runtime/locale.d.ts +2 -0
- package/dist/runtime/locale.js +1 -0
- package/dist/runtime/utils/observeYMap.d.ts +44 -0
- package/dist/runtime/utils/observeYMap.js +86 -0
- package/package.json +5 -5
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { reactive, markRaw, ref, computed } from "vue";
|
|
2
|
+
import { navigateTo } from "#imports";
|
|
3
|
+
import { useSpaceConnections } from "./useSpaceConnections.js";
|
|
4
|
+
import { useDocSlugs } from "./useDocSlugs.js";
|
|
5
|
+
import { useWindowManager } from "./useWindowManager.js";
|
|
6
|
+
const overlayStack = reactive([]);
|
|
7
|
+
let _overlayKey = 0;
|
|
8
|
+
let _config = {};
|
|
9
|
+
const _stackHosts = ref(0);
|
|
10
|
+
export function registerNodePanelStack() {
|
|
11
|
+
_stackHosts.value++;
|
|
12
|
+
}
|
|
13
|
+
export function unregisterNodePanelStack() {
|
|
14
|
+
_stackHosts.value = Math.max(0, _stackHosts.value - 1);
|
|
15
|
+
}
|
|
16
|
+
export function configureDocOpen(config) {
|
|
17
|
+
_config = { ..._config, ...config };
|
|
18
|
+
}
|
|
19
|
+
export function getDocOpenConfig() {
|
|
20
|
+
return _config;
|
|
21
|
+
}
|
|
22
|
+
export function useDocOpen() {
|
|
23
|
+
const { getProviderForDoc, findDocSpaceId, resolveEntry } = useSpaceConnections();
|
|
24
|
+
async function loadChildProvider(id) {
|
|
25
|
+
const docProvider = getProviderForDoc(id);
|
|
26
|
+
if (!docProvider) return null;
|
|
27
|
+
const childProv = await docProvider.loadChild(id);
|
|
28
|
+
if (childProv?.ready) await childProv.ready;
|
|
29
|
+
return childProv ?? null;
|
|
30
|
+
}
|
|
31
|
+
function openInMain(id) {
|
|
32
|
+
if (!id) return;
|
|
33
|
+
const entry = resolveEntry(id);
|
|
34
|
+
if (_config.navigateToDoc) return _config.navigateToDoc(id, entry);
|
|
35
|
+
const { getDocUrl } = useDocSlugs();
|
|
36
|
+
return navigateTo(getDocUrl(id));
|
|
37
|
+
}
|
|
38
|
+
async function openInSlideover(id, label) {
|
|
39
|
+
if (!id) return;
|
|
40
|
+
if (!getProviderForDoc(id)) return;
|
|
41
|
+
const top = overlayStack[overlayStack.length - 1];
|
|
42
|
+
if (top && top.id === id) return;
|
|
43
|
+
const entry = reactive({
|
|
44
|
+
key: ++_overlayKey,
|
|
45
|
+
id,
|
|
46
|
+
label: label || resolveEntry(id)?.label || "",
|
|
47
|
+
provider: null,
|
|
48
|
+
loading: true
|
|
49
|
+
});
|
|
50
|
+
overlayStack.push(entry);
|
|
51
|
+
try {
|
|
52
|
+
const prov = await loadChildProvider(id);
|
|
53
|
+
if (!overlayStack.includes(entry)) {
|
|
54
|
+
try {
|
|
55
|
+
prov?.detach?.();
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
entry.provider = prov ? markRaw(prov) : null;
|
|
61
|
+
} finally {
|
|
62
|
+
entry.loading = false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function closeSlideover() {
|
|
66
|
+
const entry = overlayStack.pop();
|
|
67
|
+
detachEntry(entry);
|
|
68
|
+
}
|
|
69
|
+
function closeSlideoverAt(index) {
|
|
70
|
+
if (index < 0 || index >= overlayStack.length) return;
|
|
71
|
+
for (const entry of overlayStack.splice(index)) detachEntry(entry);
|
|
72
|
+
}
|
|
73
|
+
function closeAllSlideovers() {
|
|
74
|
+
for (const entry of overlayStack.splice(0)) detachEntry(entry);
|
|
75
|
+
}
|
|
76
|
+
function detachEntry(entry) {
|
|
77
|
+
if (!entry?.provider) return;
|
|
78
|
+
try {
|
|
79
|
+
entry.provider.detach?.();
|
|
80
|
+
} catch {
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
async function openInWindow(id, label) {
|
|
84
|
+
if (!id) return;
|
|
85
|
+
if (!getProviderForDoc(id)) return;
|
|
86
|
+
const entry = resolveEntry(id);
|
|
87
|
+
const resolvedLabel = label || entry?.label || "";
|
|
88
|
+
if (_config.openWindow === null) return openInSlideover(id, label);
|
|
89
|
+
if (!_config.openWindow) {
|
|
90
|
+
const wm = useWindowManager();
|
|
91
|
+
if (wm.windows.has(id)) {
|
|
92
|
+
wm.focusWindow(id);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const childProv2 = await loadChildProvider(id);
|
|
96
|
+
if (!childProv2) return;
|
|
97
|
+
return wm.openWindow({
|
|
98
|
+
id,
|
|
99
|
+
title: resolvedLabel,
|
|
100
|
+
docId: id,
|
|
101
|
+
docType: entry?.type,
|
|
102
|
+
provider: childProv2
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const childProv = await loadChildProvider(id);
|
|
106
|
+
if (!childProv) return;
|
|
107
|
+
return _config.openWindow({
|
|
108
|
+
id,
|
|
109
|
+
label: resolvedLabel,
|
|
110
|
+
entry,
|
|
111
|
+
spaceId: findDocSpaceId(id),
|
|
112
|
+
provider: childProv
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function floatsAvailable() {
|
|
116
|
+
if (_config.openWindow === null) return false;
|
|
117
|
+
if (_config.floatWindowsAvailable) return _config.floatWindowsAvailable();
|
|
118
|
+
if (_config.openWindow) return true;
|
|
119
|
+
return !!useWindowManager().floatWindowsAvailable.value;
|
|
120
|
+
}
|
|
121
|
+
function onDocActivate(e, id, opts) {
|
|
122
|
+
if (!id) return false;
|
|
123
|
+
if (!e.shiftKey && (e.metaKey || e.ctrlKey)) {
|
|
124
|
+
e.preventDefault();
|
|
125
|
+
e.stopPropagation();
|
|
126
|
+
void openInSlideover(id, opts?.label);
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
if (!e.shiftKey && e.altKey) {
|
|
130
|
+
e.preventDefault();
|
|
131
|
+
e.stopPropagation();
|
|
132
|
+
if (floatsAvailable()) void openInWindow(id, opts?.label);
|
|
133
|
+
else void openInSlideover(id, opts?.label);
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
if (opts?.onPlain) opts.onPlain();
|
|
137
|
+
else void openInMain(id);
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
/** The shared slideover stack — render it with `<ANodePanelStack>`. */
|
|
142
|
+
overlayStack,
|
|
143
|
+
/**
|
|
144
|
+
* True when an `<ANodePanelStack>` host is mounted. Surfaces with their own
|
|
145
|
+
* fallback panel check this before routing a Cmd-click through the stack.
|
|
146
|
+
*/
|
|
147
|
+
panelStackMounted: computed(() => _stackHosts.value > 0),
|
|
148
|
+
openInMain,
|
|
149
|
+
openInSlideover,
|
|
150
|
+
openInWindow,
|
|
151
|
+
closeSlideover,
|
|
152
|
+
closeSlideoverAt,
|
|
153
|
+
closeAllSlideovers,
|
|
154
|
+
onDocActivate,
|
|
155
|
+
/** Handy for callers that need a doc's label/type without opening it. */
|
|
156
|
+
resolveEntry
|
|
157
|
+
};
|
|
158
|
+
}
|
|
@@ -62,31 +62,7 @@ export declare function useRendererBase(props: RendererBaseProps): {
|
|
|
62
62
|
docId?: string | undefined;
|
|
63
63
|
};
|
|
64
64
|
}[]>;
|
|
65
|
-
states: import("
|
|
66
|
-
[x: string]: any;
|
|
67
|
-
clientId: number;
|
|
68
|
-
user?: {
|
|
69
|
-
name?: string | undefined;
|
|
70
|
-
color?: string | undefined;
|
|
71
|
-
avatar?: string | undefined;
|
|
72
|
-
statusIcon?: string | undefined;
|
|
73
|
-
statusText?: string | undefined;
|
|
74
|
-
publicKey?: string | undefined;
|
|
75
|
-
} | undefined;
|
|
76
|
-
docId?: string | undefined;
|
|
77
|
-
}[], import("./useYDoc.js").AwarenessUser[] | {
|
|
78
|
-
[x: string]: any;
|
|
79
|
-
clientId: number;
|
|
80
|
-
user?: {
|
|
81
|
-
name?: string | undefined;
|
|
82
|
-
color?: string | undefined;
|
|
83
|
-
avatar?: string | undefined;
|
|
84
|
-
statusIcon?: string | undefined;
|
|
85
|
-
statusText?: string | undefined;
|
|
86
|
-
publicKey?: string | undefined;
|
|
87
|
-
} | undefined;
|
|
88
|
-
docId?: string | undefined;
|
|
89
|
-
}[]>;
|
|
65
|
+
states: ShallowRef<import("./useYDoc.js").AwarenessUser[], import("./useYDoc.js").AwarenessUser[]>;
|
|
90
66
|
setLocalState: (state: any) => void;
|
|
91
67
|
tree: {
|
|
92
68
|
entries: import("vue").ComputedRef<import("./useChildTree.js").TreeEntry[]>;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Usage:
|
|
10
10
|
* const { isOpen, activeTab, openSettings, closeSettings } = useSettingsModal()
|
|
11
11
|
*/
|
|
12
|
-
export type SettingsTab = 'profile' | 'appearance' | 'connection' | 'spaces' | 'security' | 'invites' | 'members' | 'trash' | 'offline' | 'plugins' | 'admin';
|
|
12
|
+
export type SettingsTab = 'profile' | 'appearance' | 'connection' | 'spaces' | 'security' | 'invites' | 'members' | 'trash' | 'offline' | 'about' | 'plugins' | 'admin';
|
|
13
13
|
export declare function useSettingsModal(): {
|
|
14
14
|
isOpen: import("vue").WritableComputedRef<boolean, boolean>;
|
|
15
15
|
activeTab: import("vue").WritableComputedRef<SettingsTab, SettingsTab>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ref, shallowReactive, watch } from "vue";
|
|
2
2
|
import * as Y from "yjs";
|
|
3
|
+
import { observeYMap } from "../utils/observeYMap.js";
|
|
3
4
|
import { useAbracadabra } from "./useAbracadabra.js";
|
|
4
5
|
let _ctx = null;
|
|
5
6
|
export function _initSpaceConnections(ctx) {
|
|
@@ -15,66 +16,6 @@ export function _resetSpaceConnections() {
|
|
|
15
16
|
}
|
|
16
17
|
const connections = shallowReactive(/* @__PURE__ */ new Map());
|
|
17
18
|
const _connectPromises = /* @__PURE__ */ new Map();
|
|
18
|
-
function observeYMap(doc, mapName) {
|
|
19
|
-
const ymap = doc.getMap(mapName);
|
|
20
|
-
const data = ref({});
|
|
21
|
-
const snapshot = () => {
|
|
22
|
-
const obj = {};
|
|
23
|
-
ymap.forEach((val, key) => {
|
|
24
|
-
obj[key] = val instanceof Y.Map ? val.toJSON() : val;
|
|
25
|
-
});
|
|
26
|
-
return obj;
|
|
27
|
-
};
|
|
28
|
-
data.value = snapshot();
|
|
29
|
-
let rafId = null;
|
|
30
|
-
const flush = () => {
|
|
31
|
-
rafId = null;
|
|
32
|
-
data.value = snapshot();
|
|
33
|
-
};
|
|
34
|
-
const observer = (_events, transaction) => {
|
|
35
|
-
if (transaction.local) {
|
|
36
|
-
if (rafId !== null) {
|
|
37
|
-
cancelAnimationFrame(rafId);
|
|
38
|
-
rafId = null;
|
|
39
|
-
}
|
|
40
|
-
data.value = snapshot();
|
|
41
|
-
} else if (typeof requestAnimationFrame !== "undefined") {
|
|
42
|
-
if (rafId === null) rafId = requestAnimationFrame(flush);
|
|
43
|
-
} else {
|
|
44
|
-
data.value = snapshot();
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
ymap.observeDeep(observer);
|
|
48
|
-
const onVisibilityChange = () => {
|
|
49
|
-
if (typeof document !== "undefined" && !document.hidden) {
|
|
50
|
-
if (rafId !== null) {
|
|
51
|
-
cancelAnimationFrame(rafId);
|
|
52
|
-
rafId = null;
|
|
53
|
-
}
|
|
54
|
-
data.value = snapshot();
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
if (typeof document !== "undefined") {
|
|
58
|
-
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
59
|
-
}
|
|
60
|
-
queueMicrotask(() => {
|
|
61
|
-
data.value = snapshot();
|
|
62
|
-
});
|
|
63
|
-
const cleanup = () => {
|
|
64
|
-
try {
|
|
65
|
-
ymap.unobserveDeep(observer);
|
|
66
|
-
} catch {
|
|
67
|
-
}
|
|
68
|
-
if (rafId !== null) {
|
|
69
|
-
cancelAnimationFrame(rafId);
|
|
70
|
-
rafId = null;
|
|
71
|
-
}
|
|
72
|
-
if (typeof document !== "undefined") {
|
|
73
|
-
document.removeEventListener("visibilitychange", onVisibilityChange);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
return { data, cleanup };
|
|
77
|
-
}
|
|
78
19
|
let _activeBound = false;
|
|
79
20
|
let _activeSpaceId = null;
|
|
80
21
|
function _ensureActiveBinding() {
|
|
@@ -43,56 +43,8 @@ export declare function useSyncedXml(doc: ShallowRef<Y.Doc | null>, xmlName: str
|
|
|
43
43
|
export declare function useAwarenessOf(provider: ShallowRef<{
|
|
44
44
|
awareness: any;
|
|
45
45
|
} | null>): {
|
|
46
|
-
states:
|
|
47
|
-
|
|
48
|
-
clientId: number;
|
|
49
|
-
user?: {
|
|
50
|
-
name?: string | undefined;
|
|
51
|
-
color?: string | undefined;
|
|
52
|
-
avatar?: string | undefined;
|
|
53
|
-
statusIcon?: string | undefined;
|
|
54
|
-
statusText?: string | undefined;
|
|
55
|
-
publicKey?: string | undefined;
|
|
56
|
-
} | undefined;
|
|
57
|
-
docId?: string | undefined;
|
|
58
|
-
}[], AwarenessUser[] | {
|
|
59
|
-
[x: string]: any;
|
|
60
|
-
clientId: number;
|
|
61
|
-
user?: {
|
|
62
|
-
name?: string | undefined;
|
|
63
|
-
color?: string | undefined;
|
|
64
|
-
avatar?: string | undefined;
|
|
65
|
-
statusIcon?: string | undefined;
|
|
66
|
-
statusText?: string | undefined;
|
|
67
|
-
publicKey?: string | undefined;
|
|
68
|
-
} | undefined;
|
|
69
|
-
docId?: string | undefined;
|
|
70
|
-
}[]>;
|
|
71
|
-
currentUser: Ref<{
|
|
72
|
-
[x: string]: any;
|
|
73
|
-
clientId: number;
|
|
74
|
-
user?: {
|
|
75
|
-
name?: string | undefined;
|
|
76
|
-
color?: string | undefined;
|
|
77
|
-
avatar?: string | undefined;
|
|
78
|
-
statusIcon?: string | undefined;
|
|
79
|
-
statusText?: string | undefined;
|
|
80
|
-
publicKey?: string | undefined;
|
|
81
|
-
} | undefined;
|
|
82
|
-
docId?: string | undefined;
|
|
83
|
-
} | null, AwarenessUser | {
|
|
84
|
-
[x: string]: any;
|
|
85
|
-
clientId: number;
|
|
86
|
-
user?: {
|
|
87
|
-
name?: string | undefined;
|
|
88
|
-
color?: string | undefined;
|
|
89
|
-
avatar?: string | undefined;
|
|
90
|
-
statusIcon?: string | undefined;
|
|
91
|
-
statusText?: string | undefined;
|
|
92
|
-
publicKey?: string | undefined;
|
|
93
|
-
} | undefined;
|
|
94
|
-
docId?: string | undefined;
|
|
95
|
-
} | null>;
|
|
46
|
+
states: ShallowRef<AwarenessUser[], AwarenessUser[]>;
|
|
47
|
+
currentUser: ShallowRef<AwarenessUser | null, AwarenessUser | null>;
|
|
96
48
|
setLocalState: (state: any) => void;
|
|
97
49
|
};
|
|
98
50
|
export declare function useSmoothedCursors(provider: ShallowRef<{
|
|
@@ -138,30 +90,6 @@ export declare function useSmoothedCursors(provider: ShallowRef<{
|
|
|
138
90
|
docId?: string | undefined;
|
|
139
91
|
};
|
|
140
92
|
}[]>;
|
|
141
|
-
states:
|
|
142
|
-
[x: string]: any;
|
|
143
|
-
clientId: number;
|
|
144
|
-
user?: {
|
|
145
|
-
name?: string | undefined;
|
|
146
|
-
color?: string | undefined;
|
|
147
|
-
avatar?: string | undefined;
|
|
148
|
-
statusIcon?: string | undefined;
|
|
149
|
-
statusText?: string | undefined;
|
|
150
|
-
publicKey?: string | undefined;
|
|
151
|
-
} | undefined;
|
|
152
|
-
docId?: string | undefined;
|
|
153
|
-
}[], AwarenessUser[] | {
|
|
154
|
-
[x: string]: any;
|
|
155
|
-
clientId: number;
|
|
156
|
-
user?: {
|
|
157
|
-
name?: string | undefined;
|
|
158
|
-
color?: string | undefined;
|
|
159
|
-
avatar?: string | undefined;
|
|
160
|
-
statusIcon?: string | undefined;
|
|
161
|
-
statusText?: string | undefined;
|
|
162
|
-
publicKey?: string | undefined;
|
|
163
|
-
} | undefined;
|
|
164
|
-
docId?: string | undefined;
|
|
165
|
-
}[]>;
|
|
93
|
+
states: ShallowRef<AwarenessUser[], AwarenessUser[]>;
|
|
166
94
|
setLocalState: (state: any) => void;
|
|
167
95
|
};
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
onMounted,
|
|
9
9
|
onBeforeUnmount
|
|
10
10
|
} from "vue";
|
|
11
|
+
import { acquireAwarenessView, releaseAwarenessView } from "./awarenessView.js";
|
|
11
12
|
export function useSyncedMap(doc, mapName) {
|
|
12
13
|
const state = reactive({});
|
|
13
14
|
const ymap = shallowRef(null);
|
|
@@ -142,44 +143,38 @@ export function useSyncedXml(doc, xmlName) {
|
|
|
142
143
|
return { yXml };
|
|
143
144
|
}
|
|
144
145
|
export function useAwarenessOf(provider) {
|
|
145
|
-
const states =
|
|
146
|
-
const currentUser =
|
|
147
|
-
let _rafId = null;
|
|
148
|
-
const flush = () => {
|
|
149
|
-
_rafId = null;
|
|
150
|
-
if (!provider.value?.awareness) return;
|
|
151
|
-
const awareness = provider.value.awareness;
|
|
152
|
-
states.value = Array.from(awareness.getStates().entries()).map(([id, state]) => ({ clientId: id, ...state }));
|
|
153
|
-
const local = awareness.getLocalState();
|
|
154
|
-
if (local) currentUser.value = { clientId: awareness.clientID, ...local };
|
|
155
|
-
};
|
|
156
|
-
const update = () => {
|
|
157
|
-
if (_rafId === null) _rafId = requestAnimationFrame(flush);
|
|
158
|
-
};
|
|
146
|
+
const states = shallowRef([]);
|
|
147
|
+
const currentUser = shallowRef(null);
|
|
159
148
|
let _attachedAwareness = null;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if (p?.awareness) {
|
|
167
|
-
p.awareness.on("change", update);
|
|
168
|
-
_attachedAwareness = p.awareness;
|
|
169
|
-
flush();
|
|
170
|
-
} else {
|
|
149
|
+
let _stopMirror = null;
|
|
150
|
+
const detach = () => {
|
|
151
|
+
_stopMirror?.();
|
|
152
|
+
_stopMirror = null;
|
|
153
|
+
if (_attachedAwareness) {
|
|
154
|
+
releaseAwarenessView(_attachedAwareness);
|
|
171
155
|
_attachedAwareness = null;
|
|
172
156
|
}
|
|
157
|
+
};
|
|
158
|
+
const attach = (awareness) => {
|
|
159
|
+
const view = acquireAwarenessView(awareness);
|
|
160
|
+
_attachedAwareness = awareness;
|
|
161
|
+
const stopStates = watch(view.states, (v) => {
|
|
162
|
+
states.value = v;
|
|
163
|
+
}, { immediate: true });
|
|
164
|
+
const stopUser = watch(view.currentUser, (v) => {
|
|
165
|
+
currentUser.value = v;
|
|
166
|
+
}, { immediate: true });
|
|
167
|
+
_stopMirror = () => {
|
|
168
|
+
stopStates();
|
|
169
|
+
stopUser();
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
watch(provider, (p) => {
|
|
173
|
+
detach();
|
|
174
|
+
if (p?.awareness) attach(p.awareness);
|
|
173
175
|
}, { immediate: true });
|
|
174
176
|
onBeforeUnmount(() => {
|
|
175
|
-
|
|
176
|
-
_attachedAwareness.off("change", update);
|
|
177
|
-
_attachedAwareness = null;
|
|
178
|
-
}
|
|
179
|
-
if (_rafId !== null) {
|
|
180
|
-
cancelAnimationFrame(_rafId);
|
|
181
|
-
_rafId = null;
|
|
182
|
-
}
|
|
177
|
+
detach();
|
|
183
178
|
});
|
|
184
179
|
const setLocalState = (state) => {
|
|
185
180
|
if (!provider.value) return;
|
|
@@ -7,6 +7,7 @@ import { useChildTree } from "../../composables/useChildTree";
|
|
|
7
7
|
import { useFavorites } from "../../composables/useFavorites";
|
|
8
8
|
import { useWindowManager } from "../../composables/useWindowManager";
|
|
9
9
|
import { useNodePanel } from "../../composables/useNodePanel";
|
|
10
|
+
import { useDocOpen } from "../../composables/useDocOpen";
|
|
10
11
|
import { useNodeContextMenu } from "../../composables/useNodeContextMenu";
|
|
11
12
|
import { useNodeViewEditable } from "../../composables/useNodeView";
|
|
12
13
|
import { useDocSlugs } from "../../composables/useDocSlugs";
|
|
@@ -53,6 +54,7 @@ const iconColor = computed(
|
|
|
53
54
|
);
|
|
54
55
|
const label = computed(() => treeEntry.value?.label || "Untitled");
|
|
55
56
|
const { openNodeId, openNodeLabel, openNodeProvider, openNode, closePanel } = useNodePanel(provider);
|
|
57
|
+
const { onDocActivate, openInSlideover, panelStackMounted } = useDocOpen();
|
|
56
58
|
async function openAsWindow(id, title) {
|
|
57
59
|
const wm = useWindowManager();
|
|
58
60
|
if (wm.windows.has(id)) {
|
|
@@ -78,15 +80,23 @@ function onClick(e) {
|
|
|
78
80
|
if (!docId.value) return;
|
|
79
81
|
e.preventDefault();
|
|
80
82
|
e.stopPropagation();
|
|
83
|
+
const id = docId.value;
|
|
84
|
+
if (panelStackMounted.value) {
|
|
85
|
+
onDocActivate(e, id, {
|
|
86
|
+
label: label.value,
|
|
87
|
+
onPlain: () => navigateTo(getDocUrl(id))
|
|
88
|
+
});
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
81
91
|
if (!e.shiftKey && (e.metaKey || e.ctrlKey)) {
|
|
82
|
-
openNode(
|
|
92
|
+
openNode(id, label.value);
|
|
83
93
|
return;
|
|
84
94
|
}
|
|
85
95
|
if (!e.shiftKey && e.altKey && floatWindowsAvailable.value) {
|
|
86
|
-
void openAsWindow(
|
|
96
|
+
void openAsWindow(id, label.value);
|
|
87
97
|
return;
|
|
88
98
|
}
|
|
89
|
-
navigateTo(getDocUrl(
|
|
99
|
+
navigateTo(getDocUrl(id));
|
|
90
100
|
}
|
|
91
101
|
const renameOpen = ref(false);
|
|
92
102
|
const renameValue = ref("");
|
|
@@ -109,7 +119,7 @@ const menuItems = computed(() => useNodeContextMenu({
|
|
|
109
119
|
canWrite: canWrite.value,
|
|
110
120
|
favorites: { isFavorite, toggleFavorite },
|
|
111
121
|
onOpen: (id) => navigateTo(getDocUrl(id)),
|
|
112
|
-
onOpenOverlay: (id) => openNode(id, label.value),
|
|
122
|
+
onOpenOverlay: (id) => panelStackMounted.value ? void openInSlideover(id, label.value) : openNode(id, label.value),
|
|
113
123
|
onOpenInWindow: floatWindowsAvailable.value ? (id) => void openAsWindow(id, label.value) : void 0,
|
|
114
124
|
onRename: () => startRename(),
|
|
115
125
|
onAddChild: (parentId) => {
|
|
@@ -165,7 +175,7 @@ const menuItems = computed(() => useNodeContextMenu({
|
|
|
165
175
|
|
|
166
176
|
<!-- Slide-over host: heavy panel mounts only while a link is open -->
|
|
167
177
|
<ANodePanel
|
|
168
|
-
v-if="openNodeId"
|
|
178
|
+
v-if="openNodeId && !panelStackMounted"
|
|
169
179
|
:node-id="openNodeId"
|
|
170
180
|
:node-label="openNodeLabel"
|
|
171
181
|
:child-provider="openNodeProvider"
|