@abraca/nuxt 2.52.0 → 2.54.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/ADocRenderer.vue +6 -3
- package/dist/runtime/components/ADocSubPageList.vue +1 -0
- package/dist/runtime/components/ADocumentTree.vue +1 -0
- package/dist/runtime/components/AEditor.d.vue.ts +10 -10
- package/dist/runtime/components/AEditor.vue +246 -235
- package/dist/runtime/components/AEditor.vue.d.ts +10 -10
- package/dist/runtime/components/ANodePanel.d.vue.ts +10 -0
- package/dist/runtime/components/ANodePanel.vue +40 -12
- package/dist/runtime/components/ANodePanel.vue.d.ts +10 -0
- package/dist/runtime/components/ANodeSettingsPanel.d.vue.ts +8 -0
- package/dist/runtime/components/ANodeSettingsPanel.vue +22 -8
- package/dist/runtime/components/ANodeSettingsPanel.vue.d.ts +8 -0
- package/dist/runtime/components/aware/APresenceBlobs.vue +9 -2
- package/dist/runtime/components/renderers/ACalendarRenderer.vue +1 -0
- package/dist/runtime/components/renderers/AChartRenderer.client.vue +1 -0
- package/dist/runtime/components/renderers/AChecklistRenderer.vue +1 -0
- package/dist/runtime/components/renderers/ADashboardRenderer.vue +1 -0
- package/dist/runtime/components/renderers/AGalleryRenderer.vue +1 -0
- package/dist/runtime/components/renderers/AGraphRenderer.vue +1 -0
- package/dist/runtime/components/renderers/AKanbanRenderer.vue +1 -0
- package/dist/runtime/components/renderers/AMapRenderer.vue +1 -0
- package/dist/runtime/components/renderers/AMediaRenderer.vue +1 -0
- package/dist/runtime/components/renderers/AOutlineRenderer.vue +1 -0
- package/dist/runtime/components/renderers/AOverviewRenderer.vue +1 -0
- package/dist/runtime/components/renderers/ASheetsRenderer.client.vue +1 -0
- package/dist/runtime/components/renderers/ASlidesRenderer.vue +1 -0
- package/dist/runtime/components/renderers/ATableRenderer.vue +1 -0
- package/dist/runtime/components/renderers/ATimelineRenderer.vue +1 -0
- package/dist/runtime/components/shell/ADocPanelSettings.d.vue.ts +8 -0
- package/dist/runtime/components/shell/ADocPanelSettings.vue +5 -2
- package/dist/runtime/components/shell/ADocPanelSettings.vue.d.ts +8 -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/useNodePanel.d.ts +11 -4
- package/dist/runtime/composables/useNodePanel.js +2 -17
- package/dist/runtime/composables/useProviderRole.d.ts +17 -0
- package/dist/runtime/composables/useProviderRole.js +22 -0
- package/dist/runtime/composables/useYDoc.js +27 -5
- package/dist/runtime/extensions/views/DocLinkView.vue +5 -4
- package/dist/runtime/extensions/views/DocumentMetaView.vue +50 -0
- package/package.json +1 -1
|
@@ -5,6 +5,8 @@ import { useSyncedMap } from "../composables/useYDoc";
|
|
|
5
5
|
import { navigateTo, useRuntimeConfig } from "#imports";
|
|
6
6
|
import { useChildTree } from "../composables/useChildTree";
|
|
7
7
|
import { useSpaceConnections } from "../composables/useSpaceConnections";
|
|
8
|
+
import { useDocumentPermissions } from "../composables/useDocumentPermissions";
|
|
9
|
+
import { useProviderRole } from "../composables/useProviderRole";
|
|
8
10
|
import { useAbraLocale } from "../composables/useAbraLocale";
|
|
9
11
|
import { useDocSlugs } from "../composables/useDocSlugs";
|
|
10
12
|
import { useResizableWidth } from "../composables/useResizableWidth";
|
|
@@ -25,7 +27,8 @@ const props = defineProps({
|
|
|
25
27
|
labels: { type: Object, required: false },
|
|
26
28
|
initialTab: { type: String, required: false, default: "editor" },
|
|
27
29
|
tabs: { type: Array, required: false },
|
|
28
|
-
docHref: { type: Function, required: false }
|
|
30
|
+
docHref: { type: Function, required: false },
|
|
31
|
+
editable: { type: Boolean, required: false, default: true }
|
|
29
32
|
});
|
|
30
33
|
const emit = defineEmits(["close"]);
|
|
31
34
|
const open = computed({
|
|
@@ -36,7 +39,7 @@ const open = computed({
|
|
|
36
39
|
});
|
|
37
40
|
const locale = computed(() => useAbraLocale("nodePanel", props.labels));
|
|
38
41
|
const { doc: rootDoc, registry } = useAbracadabra();
|
|
39
|
-
const { connections, getDocForDoc } = useSpaceConnections();
|
|
42
|
+
const { connections, getDocForDoc, getProviderForDoc } = useSpaceConnections();
|
|
40
43
|
const ownerDoc = shallowRef(
|
|
41
44
|
props.nodeId ? getDocForDoc(props.nodeId) ?? rootDoc.value : rootDoc.value
|
|
42
45
|
);
|
|
@@ -53,6 +56,28 @@ const entry = computed(() => {
|
|
|
53
56
|
return treeMap.data[props.nodeId] ?? null;
|
|
54
57
|
});
|
|
55
58
|
const meta = computed(() => entry.value?.meta ?? {});
|
|
59
|
+
const selfProvider = shallowRef(null);
|
|
60
|
+
watch(() => [props.nodeId, props.childProvider], async ([id, supplied]) => {
|
|
61
|
+
if (supplied || !id) {
|
|
62
|
+
selfProvider.value = null;
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const prov = getProviderForDoc(id);
|
|
66
|
+
if (!prov) return;
|
|
67
|
+
try {
|
|
68
|
+
const child = await prov.loadChild(id);
|
|
69
|
+
if (child?.ready) await child.ready;
|
|
70
|
+
if (props.nodeId === id && !props.childProvider) selfProvider.value = child;
|
|
71
|
+
} catch (e) {
|
|
72
|
+
console.error("[ANodePanel] Failed to load child provider:", e);
|
|
73
|
+
}
|
|
74
|
+
}, { immediate: true });
|
|
75
|
+
const panelProvider = computed(() => props.childProvider ?? selfProvider.value);
|
|
76
|
+
const providerRole = useProviderRole(() => panelProvider.value);
|
|
77
|
+
const { canWrite: roleCanWrite } = useDocumentPermissions(providerRole);
|
|
78
|
+
const panelEditable = computed(
|
|
79
|
+
() => props.editable !== false && (!providerRole.value || roleCanWrite.value)
|
|
80
|
+
);
|
|
56
81
|
const resolvedLabel = computed(() => entry.value?.label || props.nodeLabel || "");
|
|
57
82
|
const currentType = computed(() => entry.value?.type ?? "doc");
|
|
58
83
|
const { getDocUrl } = useDocSlugs();
|
|
@@ -60,7 +85,7 @@ function hrefFor(id) {
|
|
|
60
85
|
return props.docHref ? props.docHref(id) : getDocUrl(id);
|
|
61
86
|
}
|
|
62
87
|
function patchMeta(patch) {
|
|
63
|
-
if (!props.nodeId) return;
|
|
88
|
+
if (!props.nodeId || !panelEditable.value) return;
|
|
64
89
|
const e = treeMap.data[props.nodeId];
|
|
65
90
|
if (e) {
|
|
66
91
|
treeMap.set(props.nodeId, {
|
|
@@ -71,7 +96,7 @@ function patchMeta(patch) {
|
|
|
71
96
|
}
|
|
72
97
|
}
|
|
73
98
|
function patchType(type) {
|
|
74
|
-
if (!props.nodeId) return;
|
|
99
|
+
if (!props.nodeId || !panelEditable.value) return;
|
|
75
100
|
const e = treeMap.data[props.nodeId];
|
|
76
101
|
if (e) treeMap.set(props.nodeId, { ...e, type, updatedAt: Date.now() });
|
|
77
102
|
}
|
|
@@ -134,7 +159,7 @@ const pluginSlots = computed(() => {
|
|
|
134
159
|
if (!e) return false;
|
|
135
160
|
return slot.when({
|
|
136
161
|
childId: props.nodeId,
|
|
137
|
-
childDoc:
|
|
162
|
+
childDoc: panelProvider.value?.document ?? null,
|
|
138
163
|
parentDocId: props.nodeId,
|
|
139
164
|
parentType: props.docType,
|
|
140
165
|
meta: meta.value,
|
|
@@ -274,15 +299,15 @@ const addFieldMenuItems = computed(
|
|
|
274
299
|
/>
|
|
275
300
|
</UTooltip>
|
|
276
301
|
<AConnectionBadge
|
|
277
|
-
v-if="
|
|
278
|
-
:provider="
|
|
302
|
+
v-if="panelProvider"
|
|
303
|
+
:provider="panelProvider"
|
|
279
304
|
class="ml-1"
|
|
280
305
|
/>
|
|
281
306
|
</div>
|
|
282
307
|
|
|
283
308
|
<!-- Right: undo/redo (editor tab) · unified view toggle · extras -->
|
|
284
309
|
<div class="flex items-center gap-0.5">
|
|
285
|
-
<template v-if="activeTab === 'editor' && tiptapEditor">
|
|
310
|
+
<template v-if="activeTab === 'editor' && tiptapEditor && panelEditable">
|
|
286
311
|
<AEditorUndoButton :editor="tiptapEditor" />
|
|
287
312
|
<AEditorRedoButton :editor="tiptapEditor" />
|
|
288
313
|
<USeparator
|
|
@@ -298,7 +323,8 @@ const addFieldMenuItems = computed(
|
|
|
298
323
|
:doc-type="currentType"
|
|
299
324
|
:chat-unread="chatUnread"
|
|
300
325
|
:editor-disabled="!showEditorTab"
|
|
301
|
-
:page-type-disabled="!
|
|
326
|
+
:page-type-disabled="!panelProvider"
|
|
327
|
+
:can-change-type="panelEditable"
|
|
302
328
|
:show-chat="showChatTab"
|
|
303
329
|
:show-settings="showSettingsTab"
|
|
304
330
|
@update:model-value="setTab"
|
|
@@ -371,7 +397,8 @@ const addFieldMenuItems = computed(
|
|
|
371
397
|
:key="`${nodeId}-${currentType}`"
|
|
372
398
|
:doc-id="nodeId"
|
|
373
399
|
:doc-label="resolvedLabel"
|
|
374
|
-
:child-provider="
|
|
400
|
+
:child-provider="panelProvider"
|
|
401
|
+
:editable="panelEditable"
|
|
375
402
|
class="flex-1 overflow-hidden"
|
|
376
403
|
/>
|
|
377
404
|
</div>
|
|
@@ -386,9 +413,9 @@ const addFieldMenuItems = computed(
|
|
|
386
413
|
ref="editorRef"
|
|
387
414
|
:doc-id="nodeId"
|
|
388
415
|
:doc-label="resolvedLabel"
|
|
389
|
-
:child-provider="childProvider"
|
|
390
416
|
:parent-type="docType"
|
|
391
417
|
:doc-meta="meta"
|
|
418
|
+
:editable="panelEditable"
|
|
392
419
|
class="flex-1 overflow-y-auto"
|
|
393
420
|
@update-meta="patchMeta"
|
|
394
421
|
/>
|
|
@@ -421,6 +448,7 @@ const addFieldMenuItems = computed(
|
|
|
421
448
|
:doc-type-key="currentType"
|
|
422
449
|
:doc-label="resolvedLabel"
|
|
423
450
|
:doc-meta="meta"
|
|
451
|
+
:editable="panelEditable"
|
|
424
452
|
@update-meta="patchMeta"
|
|
425
453
|
/>
|
|
426
454
|
</div>
|
|
@@ -816,7 +844,7 @@ const addFieldMenuItems = computed(
|
|
|
816
844
|
:is="slot.component"
|
|
817
845
|
v-if="nodeId"
|
|
818
846
|
:child-id="nodeId"
|
|
819
|
-
:child-doc="
|
|
847
|
+
:child-doc="panelProvider?.document ?? null"
|
|
820
848
|
:parent-doc-id="nodeId"
|
|
821
849
|
:parent-type="docType"
|
|
822
850
|
:meta="meta"
|
|
@@ -26,6 +26,15 @@ type __VLS_Props = {
|
|
|
26
26
|
* one and falls back to the raw id. Override to target a custom route shape.
|
|
27
27
|
*/
|
|
28
28
|
docHref?: (id: string) => string;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the panel may mutate the doc. Pass the host surface's `editable`
|
|
31
|
+
* so a read-only view never spawns an editable slideover. Even when left
|
|
32
|
+
* true (default, back-compat) the panel additionally gates on the child
|
|
33
|
+
* provider's PER-DOC role, so a viewer/observer-scoped doc always opens
|
|
34
|
+
* read-only: editor, page-type renderer, view-toggle type changes, and
|
|
35
|
+
* meta/type patches all follow `panelEditable`.
|
|
36
|
+
*/
|
|
37
|
+
editable?: boolean;
|
|
29
38
|
};
|
|
30
39
|
declare var __VLS_11: {
|
|
31
40
|
nodeId: string | null;
|
|
@@ -44,6 +53,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
|
|
|
44
53
|
onClose?: (() => any) | undefined;
|
|
45
54
|
}>, {
|
|
46
55
|
initialTab: "editor" | "properties" | "chat" | "settings" | "serverSettings" | string;
|
|
56
|
+
editable: boolean;
|
|
47
57
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
48
58
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
49
59
|
declare const _default: typeof __VLS_export;
|
|
@@ -22,6 +22,13 @@ type __VLS_Props = {
|
|
|
22
22
|
onlineNotGranted?: OnlineUser[];
|
|
23
23
|
/** Whether the current user is owner (ignored when `manage-permissions`). */
|
|
24
24
|
isOwner?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the panel may mutate the doc (snapshots create/restore/delete,
|
|
27
|
+
* meta edits). Pass the host surface's role-folded editability — e.g.
|
|
28
|
+
* <ANodePanel> threads its `panelEditable` — so a viewer-scoped doc never
|
|
29
|
+
* offers mutation affordances the server would reject anyway.
|
|
30
|
+
*/
|
|
31
|
+
editable?: boolean;
|
|
25
32
|
};
|
|
26
33
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
27
34
|
"update-meta": (patch: Partial<DocPageMeta>) => any;
|
|
@@ -48,6 +55,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
48
55
|
"onSync-doc"?: (() => any) | undefined;
|
|
49
56
|
"onOpen-encryption"?: (() => any) | undefined;
|
|
50
57
|
}>, {
|
|
58
|
+
editable: boolean;
|
|
51
59
|
isOwner: boolean;
|
|
52
60
|
permissions: PermissionEntry[];
|
|
53
61
|
loadingPermissions: boolean;
|
|
@@ -16,7 +16,8 @@ const props = defineProps({
|
|
|
16
16
|
permissions: { type: Array, required: false, default: () => [] },
|
|
17
17
|
loadingPermissions: { type: Boolean, required: false, default: false },
|
|
18
18
|
onlineNotGranted: { type: Array, required: false, default: () => [] },
|
|
19
|
-
isOwner: { type: Boolean, required: false, default: false }
|
|
19
|
+
isOwner: { type: Boolean, required: false, default: false },
|
|
20
|
+
editable: { type: Boolean, required: false, default: true }
|
|
20
21
|
});
|
|
21
22
|
const emit = defineEmits(["grant-permission", "change-role", "revoke-permission", "create-invite", "sync-doc", "open-encryption", "update-meta"]);
|
|
22
23
|
const abra = useAbracadabra();
|
|
@@ -74,6 +75,18 @@ function onRevoke(u) {
|
|
|
74
75
|
function onSetPublicAccess(v) {
|
|
75
76
|
if (managing.value) perms.setPublicAccess(v);
|
|
76
77
|
}
|
|
78
|
+
function snapCreate(label) {
|
|
79
|
+
if (props.editable !== false) snaps.create(label);
|
|
80
|
+
}
|
|
81
|
+
function snapRestore(v) {
|
|
82
|
+
if (props.editable !== false) snaps.restore(v);
|
|
83
|
+
}
|
|
84
|
+
function snapFork(v) {
|
|
85
|
+
if (props.editable !== false) snaps.fork(v);
|
|
86
|
+
}
|
|
87
|
+
function snapRemove(v) {
|
|
88
|
+
if (props.editable !== false) snaps.remove(v);
|
|
89
|
+
}
|
|
77
90
|
</script>
|
|
78
91
|
|
|
79
92
|
<template>
|
|
@@ -102,6 +115,7 @@ function onSetPublicAccess(v) {
|
|
|
102
115
|
:has-more-snapshots="snaps.hasMore.value"
|
|
103
116
|
:pending-snapshot-version="null"
|
|
104
117
|
:is-creating-snapshot="snaps.creating.value"
|
|
118
|
+
:editable="editable"
|
|
105
119
|
@grant-permission="onGrant"
|
|
106
120
|
@change-role="onChangeRole"
|
|
107
121
|
@revoke-permission="onRevoke"
|
|
@@ -110,10 +124,10 @@ function onSetPublicAccess(v) {
|
|
|
110
124
|
@sync-doc="emit('sync-doc')"
|
|
111
125
|
@open-encryption="emit('open-encryption')"
|
|
112
126
|
@update-meta="(p) => emit('update-meta', p)"
|
|
113
|
-
@create-snapshot="
|
|
114
|
-
@delete-snapshot="
|
|
115
|
-
@restore-snapshot="
|
|
116
|
-
@fork-snapshot="
|
|
127
|
+
@create-snapshot="snapCreate"
|
|
128
|
+
@delete-snapshot="snapRemove"
|
|
129
|
+
@restore-snapshot="snapRestore"
|
|
130
|
+
@fork-snapshot="snapFork"
|
|
117
131
|
@preview-snapshot="(v) => previewVersion = v"
|
|
118
132
|
@load-more-snapshots="snaps.loadMore"
|
|
119
133
|
/>
|
|
@@ -126,8 +140,8 @@ function onSetPublicAccess(v) {
|
|
|
126
140
|
:doc-type="docTypeKey"
|
|
127
141
|
:doc-meta="docMeta"
|
|
128
142
|
:is-owner="boundIsOwner"
|
|
129
|
-
@restore="
|
|
130
|
-
@fork="
|
|
131
|
-
@delete="
|
|
143
|
+
@restore="snapRestore"
|
|
144
|
+
@fork="snapFork"
|
|
145
|
+
@delete="snapRemove"
|
|
132
146
|
/>
|
|
133
147
|
</template>
|
|
@@ -22,6 +22,13 @@ type __VLS_Props = {
|
|
|
22
22
|
onlineNotGranted?: OnlineUser[];
|
|
23
23
|
/** Whether the current user is owner (ignored when `manage-permissions`). */
|
|
24
24
|
isOwner?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the panel may mutate the doc (snapshots create/restore/delete,
|
|
27
|
+
* meta edits). Pass the host surface's role-folded editability — e.g.
|
|
28
|
+
* <ANodePanel> threads its `panelEditable` — so a viewer-scoped doc never
|
|
29
|
+
* offers mutation affordances the server would reject anyway.
|
|
30
|
+
*/
|
|
31
|
+
editable?: boolean;
|
|
25
32
|
};
|
|
26
33
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
27
34
|
"update-meta": (patch: Partial<DocPageMeta>) => any;
|
|
@@ -48,6 +55,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
48
55
|
"onSync-doc"?: (() => any) | undefined;
|
|
49
56
|
"onOpen-encryption"?: (() => any) | undefined;
|
|
50
57
|
}>, {
|
|
58
|
+
editable: boolean;
|
|
51
59
|
isOwner: boolean;
|
|
52
60
|
permissions: PermissionEntry[];
|
|
53
61
|
loadingPermissions: boolean;
|
|
@@ -39,12 +39,14 @@ function computeViewportBlobs() {
|
|
|
39
39
|
}
|
|
40
40
|
return out;
|
|
41
41
|
}
|
|
42
|
+
const MAX_BLOBS = 16;
|
|
42
43
|
function computeWorldBlobs() {
|
|
43
44
|
const toScreen = props.toScreen;
|
|
44
45
|
if (!toScreen) return [];
|
|
45
46
|
const localId = provider.value?.awareness?.clientID;
|
|
46
47
|
const out = [];
|
|
47
48
|
for (const peer of worldStates.value) {
|
|
49
|
+
if (out.length >= MAX_BLOBS) break;
|
|
48
50
|
if (peer.clientId === localId) continue;
|
|
49
51
|
const raw = peer[props.worldChannel];
|
|
50
52
|
if (!raw || typeof raw !== "object") continue;
|
|
@@ -71,8 +73,13 @@ function isOffscreen(x, y) {
|
|
|
71
73
|
return x < -180 || y < -180 || x > vw + 180 || y > vh + 180;
|
|
72
74
|
}
|
|
73
75
|
let raf = 0;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
const WORLD_TICK_MS = 50;
|
|
77
|
+
let lastWorldTick = 0;
|
|
78
|
+
function bump(ts) {
|
|
79
|
+
if (ts - lastWorldTick >= WORLD_TICK_MS) {
|
|
80
|
+
lastWorldTick = ts;
|
|
81
|
+
tick.value++;
|
|
82
|
+
}
|
|
76
83
|
raf = requestAnimationFrame(bump);
|
|
77
84
|
}
|
|
78
85
|
function onScroll() {
|
|
@@ -1766,6 +1766,7 @@ defineExpose({ connectedUsers });
|
|
|
1766
1766
|
:node-label="openNodeLabel"
|
|
1767
1767
|
:child-provider="openNodeProvider"
|
|
1768
1768
|
:doc-type="openNodeId ? children.find((c2) => c2.id === openNodeId)?.type : void 0"
|
|
1769
|
+
:editable="editable"
|
|
1769
1770
|
@close="closePanel"
|
|
1770
1771
|
/>
|
|
1771
1772
|
</div>
|
|
@@ -75,6 +75,13 @@ type __VLS_Props = {
|
|
|
75
75
|
canEditPublicAccess?: boolean;
|
|
76
76
|
/** Whether a public-access change is currently in flight. */
|
|
77
77
|
savingPublicAccess?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Whether this surface may mutate the doc. Pass the host's role-folded
|
|
80
|
+
* editability; when false, snapshot restore/fork/delete and meta-field
|
|
81
|
+
* writes are withheld so viewer-scoped docs get a genuinely read-only
|
|
82
|
+
* settings panel.
|
|
83
|
+
*/
|
|
84
|
+
editable?: boolean;
|
|
78
85
|
};
|
|
79
86
|
declare var __VLS_230: {}, __VLS_394: {};
|
|
80
87
|
type __VLS_Slots = {} & {
|
|
@@ -125,6 +132,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
|
|
|
125
132
|
}>, {
|
|
126
133
|
snapshots: SnapshotMeta[];
|
|
127
134
|
userName: string;
|
|
135
|
+
editable: boolean;
|
|
128
136
|
docMeta: DocPageMeta | null;
|
|
129
137
|
effectiveRole: string | null;
|
|
130
138
|
userAvatarStyle: string;
|
|
@@ -30,7 +30,8 @@ const props = defineProps({
|
|
|
30
30
|
publicAccessValue: { type: String, required: false, default: "inherit" },
|
|
31
31
|
publicAccessOptions: { type: Array, required: false, default: () => [] },
|
|
32
32
|
canEditPublicAccess: { type: Boolean, required: false, default: false },
|
|
33
|
-
savingPublicAccess: { type: Boolean, required: false, default: false }
|
|
33
|
+
savingPublicAccess: { type: Boolean, required: false, default: false },
|
|
34
|
+
editable: { type: Boolean, required: false, default: true }
|
|
34
35
|
});
|
|
35
36
|
const emit = defineEmits(["grant-permission", "change-role", "revoke-permission", "set-public-access", "create-invite", "sync-doc", "open-encryption", "user-context-menu", "update-meta", "create-snapshot", "delete-snapshot", "restore-snapshot", "fork-snapshot", "preview-snapshot", "load-more-snapshots"]);
|
|
36
37
|
const grantUserId = ref("");
|
|
@@ -145,6 +146,7 @@ function snapshotMenu(version) {
|
|
|
145
146
|
onSelect: () => askSnapDelete(version)
|
|
146
147
|
}
|
|
147
148
|
];
|
|
149
|
+
if (props.editable === false) return [view];
|
|
148
150
|
return props.isOwner ? [view, manage, destructive] : [view, manage];
|
|
149
151
|
}
|
|
150
152
|
function triggerColor(trigger) {
|
|
@@ -194,6 +196,7 @@ function getMetaValue(key) {
|
|
|
194
196
|
return props.docMeta?.[key] ?? void 0;
|
|
195
197
|
}
|
|
196
198
|
function patchMeta(key, value) {
|
|
199
|
+
if (props.editable === false) return;
|
|
197
200
|
emit("update-meta", { [key]: value });
|
|
198
201
|
}
|
|
199
202
|
</script>
|
|
@@ -688,7 +691,7 @@ function patchMeta(key, value) {
|
|
|
688
691
|
Snapshots
|
|
689
692
|
</p>
|
|
690
693
|
<UTooltip
|
|
691
|
-
v-if="isOwner"
|
|
694
|
+
v-if="isOwner && editable !== false"
|
|
692
695
|
text="Create snapshot"
|
|
693
696
|
:content="{ side: 'bottom' }"
|
|
694
697
|
>
|
|
@@ -75,6 +75,13 @@ type __VLS_Props = {
|
|
|
75
75
|
canEditPublicAccess?: boolean;
|
|
76
76
|
/** Whether a public-access change is currently in flight. */
|
|
77
77
|
savingPublicAccess?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Whether this surface may mutate the doc. Pass the host's role-folded
|
|
80
|
+
* editability; when false, snapshot restore/fork/delete and meta-field
|
|
81
|
+
* writes are withheld so viewer-scoped docs get a genuinely read-only
|
|
82
|
+
* settings panel.
|
|
83
|
+
*/
|
|
84
|
+
editable?: boolean;
|
|
78
85
|
};
|
|
79
86
|
declare var __VLS_230: {}, __VLS_394: {};
|
|
80
87
|
type __VLS_Slots = {} & {
|
|
@@ -125,6 +132,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
|
|
|
125
132
|
}>, {
|
|
126
133
|
snapshots: SnapshotMeta[];
|
|
127
134
|
userName: string;
|
|
135
|
+
editable: boolean;
|
|
128
136
|
docMeta: DocPageMeta | null;
|
|
129
137
|
effectiveRole: string | null;
|
|
130
138
|
userAvatarStyle: string;
|
|
@@ -14,13 +14,13 @@ type __VLS_Props = {
|
|
|
14
14
|
extraItems?: DropdownMenuItem[][];
|
|
15
15
|
};
|
|
16
16
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
17
|
+
logout: () => any;
|
|
17
18
|
"open-settings": () => any;
|
|
18
19
|
"open-account": () => any;
|
|
19
|
-
logout: () => any;
|
|
20
20
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
21
|
+
onLogout?: (() => any) | undefined;
|
|
21
22
|
"onOpen-settings"?: (() => any) | undefined;
|
|
22
23
|
"onOpen-account"?: (() => any) | undefined;
|
|
23
|
-
onLogout?: (() => any) | undefined;
|
|
24
24
|
}>, {
|
|
25
25
|
color: string;
|
|
26
26
|
collapsed: boolean;
|
|
@@ -14,13 +14,13 @@ type __VLS_Props = {
|
|
|
14
14
|
extraItems?: DropdownMenuItem[][];
|
|
15
15
|
};
|
|
16
16
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
17
|
+
logout: () => any;
|
|
17
18
|
"open-settings": () => any;
|
|
18
19
|
"open-account": () => any;
|
|
19
|
-
logout: () => any;
|
|
20
20
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
21
|
+
onLogout?: (() => any) | undefined;
|
|
21
22
|
"onOpen-settings"?: (() => any) | undefined;
|
|
22
23
|
"onOpen-account"?: (() => any) | undefined;
|
|
23
|
-
onLogout?: (() => any) | undefined;
|
|
24
24
|
}>, {
|
|
25
25
|
color: string;
|
|
26
26
|
collapsed: boolean;
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import type { ShallowRef } from 'vue';
|
|
2
2
|
export interface UseNodePanelOptions {
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated No longer used — the panel opens on local hydration and
|
|
5
|
+
* streams server content through the live binding instead of blocking on
|
|
6
|
+
* network sync. Kept for call-site compatibility.
|
|
7
|
+
*/
|
|
4
8
|
syncTimeout?: number;
|
|
5
9
|
}
|
|
6
10
|
/**
|
|
7
11
|
* Manages the state for opening a child document in a slide-over panel.
|
|
8
|
-
* Loads the child provider,
|
|
9
|
-
* so TipTap can initialise without errors.
|
|
12
|
+
* Loads the child provider, awaits only local (IndexedDB) hydration, and
|
|
13
|
+
* primes the Y.XmlFragment so TipTap can initialise without errors. Server
|
|
14
|
+
* content streams into the live binding after open — blocking on network
|
|
15
|
+
* `synced` here is what made cold opens fail on slow or unreachable
|
|
16
|
+
* connections while cached docs appeared to work (matches ADocRenderer).
|
|
10
17
|
*/
|
|
11
|
-
export declare function useNodePanel(parentProvider: ShallowRef<any>,
|
|
18
|
+
export declare function useNodePanel(parentProvider: ShallowRef<any>, _options?: UseNodePanelOptions): {
|
|
12
19
|
openNodeId: import("vue").Ref<string | null, string | null>;
|
|
13
20
|
openNodeLabel: import("vue").Ref<string, string>;
|
|
14
21
|
openNodeProvider: import("vue").Ref<any, any>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ref } from "vue";
|
|
2
|
-
export function useNodePanel(parentProvider,
|
|
3
|
-
const syncTimeout = options?.syncTimeout ?? 8e3;
|
|
2
|
+
export function useNodePanel(parentProvider, _options) {
|
|
4
3
|
const openNodeId = ref(null);
|
|
5
4
|
const openNodeLabel = ref("");
|
|
6
5
|
const openNodeProvider = ref(null);
|
|
@@ -22,21 +21,7 @@ export function useNodePanel(parentProvider, options) {
|
|
|
22
21
|
try {
|
|
23
22
|
const childProv = await parentProvider.value.loadChild(nodeId);
|
|
24
23
|
if (_lastNodeId !== nodeId) return;
|
|
25
|
-
if (
|
|
26
|
-
await new Promise((resolve, reject) => {
|
|
27
|
-
const timer = setTimeout(() => {
|
|
28
|
-
childProv.off("synced", onSynced);
|
|
29
|
-
reject(new Error(`Sync timeout after ${syncTimeout}ms`));
|
|
30
|
-
}, syncTimeout);
|
|
31
|
-
function onSynced({ state }) {
|
|
32
|
-
if (!state) return;
|
|
33
|
-
clearTimeout(timer);
|
|
34
|
-
childProv.off("synced", onSynced);
|
|
35
|
-
resolve();
|
|
36
|
-
}
|
|
37
|
-
childProv.on("synced", onSynced);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
24
|
+
if (childProv?.ready) await childProv.ready;
|
|
40
25
|
if (_lastNodeId !== nodeId) return;
|
|
41
26
|
const doc = childProv.document;
|
|
42
27
|
const frag = doc.getXmlFragment("default");
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { MaybeRefOrGetter, ShallowRef } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Reactive effective role of a provider instance — the PER-DOCUMENT scope the
|
|
4
|
+
* server granted when this provider's doc subscription authenticated.
|
|
5
|
+
*
|
|
6
|
+
* The global `useAbracadabra().effectiveRole` reflects the ENTRY doc's scope
|
|
7
|
+
* only; on servers with per-document access (e.g. a public landing space with
|
|
8
|
+
* `editor` access whose docs subtree is `viewer`) it is the wrong gate for any
|
|
9
|
+
* other doc. Each child provider carries its own authoritative
|
|
10
|
+
* `effectiveRole`, updated via the SDK's `roleChanged` event — this composable
|
|
11
|
+
* exposes it as a ref.
|
|
12
|
+
*
|
|
13
|
+
* Returns `null` while the role is unknown (no provider yet, offline restore,
|
|
14
|
+
* pre-auth) — callers should treat unknown as permissive so offline-first
|
|
15
|
+
* editing isn't broken, mirroring ADocRenderer's role fold.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useProviderRole(provider: MaybeRefOrGetter<any>): ShallowRef<string | null>;
|