@abraca/nuxt 2.58.0 → 2.60.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/ANodePanel.vue +5 -1
- package/dist/runtime/components/renderers/AGraphRenderer.vue +15 -6
- package/dist/runtime/components/renderers/AMapRenderer.vue +38 -33
- package/dist/runtime/components/shell/AUserProfilePopover.d.vue.ts +1 -1
- package/dist/runtime/components/shell/AUserProfilePopover.vue.d.ts +1 -1
- package/dist/runtime/composables/useChildTree.d.ts +4 -0
- package/dist/runtime/composables/useChildTree.js +22 -1
- package/dist/runtime/composables/useDocSeo.js +6 -5
- package/dist/runtime/composables/useRendererBase.d.ts +4 -0
- package/dist/runtime/composables/useSpaceConfig.d.ts +12 -0
- package/dist/runtime/composables/useSpaceConfig.js +37 -0
- package/dist/runtime/server/utils/docCache.js +3 -6
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -408,6 +408,10 @@ const addFieldMenuItems = computed(
|
|
|
408
408
|
v-show="activeTab === 'editor'"
|
|
409
409
|
class="flex flex-col flex-1 min-h-0"
|
|
410
410
|
>
|
|
411
|
+
<!-- px-4: breathing room inside the panel (cou-sh's slideover pads
|
|
412
|
+
its DocRenderer likewise). UEditor's own base padding is
|
|
413
|
+
viewport-driven (`sm:px-8`) and collapses to 0 below `sm`, so
|
|
414
|
+
without this the panel's prose sits flush against the edge. -->
|
|
411
415
|
<AEditor
|
|
412
416
|
v-if="nodeId"
|
|
413
417
|
ref="editorRef"
|
|
@@ -416,7 +420,7 @@ const addFieldMenuItems = computed(
|
|
|
416
420
|
:parent-type="docType"
|
|
417
421
|
:doc-meta="meta"
|
|
418
422
|
:editable="panelEditable"
|
|
419
|
-
class="flex-1 overflow-y-auto"
|
|
423
|
+
class="flex-1 overflow-y-auto px-4"
|
|
420
424
|
@update-meta="patchMeta"
|
|
421
425
|
/>
|
|
422
426
|
</div>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { ref, computed, watch, nextTick, onMounted, onBeforeUnmount } from "vue";
|
|
3
|
-
import { useRuntimeConfig, defineShortcuts } from "#imports";
|
|
3
|
+
import { useRuntimeConfig, defineShortcuts, useColorMode } from "#imports";
|
|
4
4
|
import { useLocalStorage } from "@vueuse/core";
|
|
5
5
|
import { getIcon, loadIcon } from "@iconify/vue";
|
|
6
6
|
import * as Y from "yjs";
|
|
@@ -641,7 +641,7 @@ function applySizeScale(base, n) {
|
|
|
641
641
|
const scaledSpacing = computed(() => applySizeScale(SPACING_PRESETS[spacingLevel.value], simNodes.value.length));
|
|
642
642
|
function setSpacing(level) {
|
|
643
643
|
spacingLevel.value = level;
|
|
644
|
-
tree.updateMeta(props.docId, { graphSpacing: level });
|
|
644
|
+
if (canWrite.value) tree.updateMeta(props.docId, { graphSpacing: level });
|
|
645
645
|
if (!simReady) return;
|
|
646
646
|
graphSim.setSpacing(scaledSpacing.value, 0.5);
|
|
647
647
|
}
|
|
@@ -663,7 +663,6 @@ const spacingIcon = computed(() => {
|
|
|
663
663
|
return icons[spacingLevel.value];
|
|
664
664
|
});
|
|
665
665
|
function cycleSpacing() {
|
|
666
|
-
if (!canWrite.value) return;
|
|
667
666
|
const idx = SPACING_CYCLE.indexOf(spacingLevel.value);
|
|
668
667
|
setSpacing(SPACING_CYCLE[(idx + 1) % SPACING_CYCLE.length]);
|
|
669
668
|
}
|
|
@@ -796,6 +795,19 @@ function refreshEdgeColors() {
|
|
|
796
795
|
muted: cs.getPropertyValue("--ui-text-muted").trim() || edgeColors.muted
|
|
797
796
|
};
|
|
798
797
|
}
|
|
798
|
+
const graphColorModeRef = useColorMode();
|
|
799
|
+
watch(
|
|
800
|
+
() => graphColorModeRef.value,
|
|
801
|
+
() => {
|
|
802
|
+
_colorCache.clear();
|
|
803
|
+
nextTick(() => {
|
|
804
|
+
refreshEdgeColors();
|
|
805
|
+
renderTick.value++;
|
|
806
|
+
scheduleCanvasRedraw();
|
|
807
|
+
});
|
|
808
|
+
},
|
|
809
|
+
{ flush: "post" }
|
|
810
|
+
);
|
|
799
811
|
function syncCanvasSize() {
|
|
800
812
|
const c = edgeCanvasRef.value;
|
|
801
813
|
if (!c) return;
|
|
@@ -1529,7 +1541,6 @@ function onNodePointerDown(e, id) {
|
|
|
1529
1541
|
}
|
|
1530
1542
|
}
|
|
1531
1543
|
armLongPress(e);
|
|
1532
|
-
if (!canWrite.value) return;
|
|
1533
1544
|
const node = nodeById.get(id);
|
|
1534
1545
|
if (!node) return;
|
|
1535
1546
|
try {
|
|
@@ -1556,7 +1567,6 @@ function onNodePointerMove(e, id) {
|
|
|
1556
1567
|
schedulePointerFlush();
|
|
1557
1568
|
return;
|
|
1558
1569
|
}
|
|
1559
|
-
if (!canWrite.value) return;
|
|
1560
1570
|
if (draggingId.value !== id) return;
|
|
1561
1571
|
pendingNodeMove = { clientX: e.clientX, clientY: e.clientY, pointerId: e.pointerId, pointerType: e.pointerType };
|
|
1562
1572
|
schedulePointerFlush();
|
|
@@ -2446,7 +2456,6 @@ defineExpose({ connectedUsers });
|
|
|
2446
2456
|
size="sm"
|
|
2447
2457
|
variant="ghost"
|
|
2448
2458
|
color="neutral"
|
|
2449
|
-
:disabled="!canWrite"
|
|
2450
2459
|
@click="cycleSpacing"
|
|
2451
2460
|
/>
|
|
2452
2461
|
</UTooltip>
|
|
@@ -166,48 +166,52 @@ let mapResizeObserver = null;
|
|
|
166
166
|
const mapReady = ref(false);
|
|
167
167
|
const mapFadedIn = ref(false);
|
|
168
168
|
const colorMode = useColorMode();
|
|
169
|
-
const isDark = computed(() =>
|
|
169
|
+
const isDark = computed(() => {
|
|
170
|
+
if (colorMode.value === "dark") return true;
|
|
171
|
+
if (colorMode.value === "light") return false;
|
|
172
|
+
return import.meta.client && document.documentElement.classList.contains("dark");
|
|
173
|
+
});
|
|
170
174
|
const mapAppConfig = useAppConfig();
|
|
171
175
|
const mapNeutralColor = computed(() => mapAppConfig.ui?.colors?.neutral ?? "zinc");
|
|
172
176
|
const activeMode = ref("pan");
|
|
173
177
|
const docMeta = computed(() => tree.treeMap.data?.[props.docId]?.meta);
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
function viewSetting(read, persist) {
|
|
179
|
+
const local = ref(null);
|
|
180
|
+
return computed({
|
|
181
|
+
get: () => !props.editable && local.value !== null ? local.value : read(),
|
|
182
|
+
set: (v) => {
|
|
183
|
+
if (props.editable) persist(v);
|
|
184
|
+
else local.value = v;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
const showLabels = viewSetting(
|
|
189
|
+
() => docMeta.value?.mapShowLabels ?? true,
|
|
190
|
+
(v) => tree.updateMeta(props.docId, { mapShowLabels: v })
|
|
191
|
+
);
|
|
180
192
|
const MAP_STYLE_URLS = {
|
|
181
193
|
"standard": "mapbox://styles/mapbox/standard",
|
|
182
194
|
"streets": "mapbox://styles/mapbox/streets-v12",
|
|
183
195
|
"satellite": "mapbox://styles/mapbox/satellite-v9",
|
|
184
196
|
"satellite-streets": "mapbox://styles/mapbox/satellite-streets-v12"
|
|
185
197
|
};
|
|
186
|
-
const mapStyleKey =
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
});
|
|
198
|
+
const mapStyleKey = viewSetting(
|
|
199
|
+
() => docMeta.value?.mapStyle ?? "standard",
|
|
200
|
+
(v) => tree.updateMeta(props.docId, { mapStyle: v })
|
|
201
|
+
);
|
|
192
202
|
const isStandardStyle = computed(() => mapStyleKey.value === "standard");
|
|
193
|
-
const show3dBuildings =
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
const showTerrain = computed({
|
|
206
|
-
get: () => docMeta.value?.mapTerrain ?? true,
|
|
207
|
-
set: (v) => {
|
|
208
|
-
if (props.editable) tree.updateMeta(props.docId, { mapTerrain: v });
|
|
209
|
-
}
|
|
210
|
-
});
|
|
203
|
+
const show3dBuildings = viewSetting(
|
|
204
|
+
() => docMeta.value?.map3dBuildings ?? true,
|
|
205
|
+
(v) => tree.updateMeta(props.docId, { map3dBuildings: v })
|
|
206
|
+
);
|
|
207
|
+
const lightPreset = viewSetting(
|
|
208
|
+
() => docMeta.value?.mapLightPreset ?? "auto",
|
|
209
|
+
(v) => tree.updateMeta(props.docId, { mapLightPreset: v })
|
|
210
|
+
);
|
|
211
|
+
const showTerrain = viewSetting(
|
|
212
|
+
() => docMeta.value?.mapTerrain ?? true,
|
|
213
|
+
(v) => tree.updateMeta(props.docId, { mapTerrain: v })
|
|
214
|
+
);
|
|
211
215
|
const popupProvider = shallowRef(null);
|
|
212
216
|
const popupDocId = ref(null);
|
|
213
217
|
const popupDocLabel = ref("");
|
|
@@ -641,7 +645,7 @@ function toolBtn(mode) {
|
|
|
641
645
|
};
|
|
642
646
|
}
|
|
643
647
|
function setMode(mode) {
|
|
644
|
-
if (!props.editable) return;
|
|
648
|
+
if (!props.editable && mode !== "pan" && mode !== "ping") return;
|
|
645
649
|
if (activeMode.value === mode) {
|
|
646
650
|
activeMode.value = "pan";
|
|
647
651
|
return;
|
|
@@ -1923,13 +1927,14 @@ defineExpose({ connectedUsers });
|
|
|
1923
1927
|
|
|
1924
1928
|
<!-- Map settings -->
|
|
1925
1929
|
<UPopover :content="{ side: 'top', align: 'center' }">
|
|
1930
|
+
<!-- View settings are viewer-safe: read-only mounts apply them
|
|
1931
|
+
locally (viewSetting), editable mounts persist to the doc. -->
|
|
1926
1932
|
<UButton
|
|
1927
1933
|
icon="i-lucide-sliders-horizontal"
|
|
1928
1934
|
size="sm"
|
|
1929
1935
|
color="neutral"
|
|
1930
1936
|
:variant="mapStyleKey !== 'standard' || !show3dBuildings || !showTerrain || lightPreset !== 'auto' ? 'soft' : 'ghost'"
|
|
1931
1937
|
:title="'View settings'"
|
|
1932
|
-
:disabled="!editable"
|
|
1933
1938
|
/>
|
|
1934
1939
|
<template #content>
|
|
1935
1940
|
<div class="flex flex-col gap-3 p-3 w-60">
|
|
@@ -39,8 +39,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
|
|
|
39
39
|
currentDocId: string | null;
|
|
40
40
|
isSelf: boolean;
|
|
41
41
|
avatarStyle: string;
|
|
42
|
-
showFollow: boolean;
|
|
43
42
|
isFollowing: boolean;
|
|
43
|
+
showFollow: boolean;
|
|
44
44
|
currentDocLabel: string | null;
|
|
45
45
|
currentDocIcon: string;
|
|
46
46
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -39,8 +39,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
|
|
|
39
39
|
currentDocId: string | null;
|
|
40
40
|
isSelf: boolean;
|
|
41
41
|
avatarStyle: string;
|
|
42
|
-
showFollow: boolean;
|
|
43
42
|
isFollowing: boolean;
|
|
43
|
+
showFollow: boolean;
|
|
44
44
|
currentDocLabel: string | null;
|
|
45
45
|
currentDocIcon: string;
|
|
46
46
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -20,6 +20,10 @@ export declare function useChildTree(rootDoc: ShallowRef<Y.Doc | null>, parentDo
|
|
|
20
20
|
childrenOf: (parentId: string | null) => TreeEntry[];
|
|
21
21
|
descendantsOf: (id: string) => TreeEntry[];
|
|
22
22
|
createChild: (parentId: string | null, label: string, type?: string) => string;
|
|
23
|
+
registerDoc: (id: string, parentId: string, opts?: {
|
|
24
|
+
label?: string;
|
|
25
|
+
type?: string;
|
|
26
|
+
}) => void;
|
|
23
27
|
moveEntry: (id: string, newParentId: string | null, newOrder: number) => void;
|
|
24
28
|
deleteEntry: (id: string) => void;
|
|
25
29
|
renameEntry: (id: string, label: string) => void;
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { computed } from "vue";
|
|
2
2
|
import { useSyncedMap } from "./useYDoc.js";
|
|
3
|
+
import { useAbracadabra } from "./useAbracadabra.js";
|
|
3
4
|
import { isDescendantInMap } from "../utils/docDragDrop.js";
|
|
4
5
|
export function useChildTree(rootDoc, parentDocId, options) {
|
|
6
|
+
const abraState = (() => {
|
|
7
|
+
try {
|
|
8
|
+
return useAbracadabra();
|
|
9
|
+
} catch {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
})();
|
|
5
13
|
const treeMap = useSyncedMap(rootDoc, "doc-tree");
|
|
6
14
|
const trashMap = useSyncedMap(rootDoc, "doc-trash");
|
|
7
15
|
const entries = computed(() => {
|
|
@@ -52,17 +60,29 @@ export function useChildTree(rootDoc, parentDocId, options) {
|
|
|
52
60
|
collect(id);
|
|
53
61
|
return result;
|
|
54
62
|
}
|
|
63
|
+
function registerDoc(id, parentId, opts) {
|
|
64
|
+
const client = abraState?.client?.value;
|
|
65
|
+
if (import.meta.server || !client?.createChild) return;
|
|
66
|
+
client.createChild(parentId, {
|
|
67
|
+
child_id: id,
|
|
68
|
+
label: opts?.label,
|
|
69
|
+
doc_type: opts?.type
|
|
70
|
+
}).catch(() => {
|
|
71
|
+
});
|
|
72
|
+
}
|
|
55
73
|
function createChild(parentId, label, type) {
|
|
56
74
|
const id = crypto.randomUUID();
|
|
57
75
|
const now = Date.now();
|
|
76
|
+
const resolvedParent = parentId === null ? parentDocId : parentId;
|
|
58
77
|
treeMap.set(id, {
|
|
59
78
|
label,
|
|
60
|
-
parentId:
|
|
79
|
+
parentId: resolvedParent,
|
|
61
80
|
order: now,
|
|
62
81
|
type,
|
|
63
82
|
createdAt: now,
|
|
64
83
|
updatedAt: now
|
|
65
84
|
});
|
|
85
|
+
registerDoc(id, resolvedParent, { label, type });
|
|
66
86
|
return id;
|
|
67
87
|
}
|
|
68
88
|
function moveEntry(id, newParentId, newOrder) {
|
|
@@ -113,6 +133,7 @@ export function useChildTree(rootDoc, parentDocId, options) {
|
|
|
113
133
|
childrenOf,
|
|
114
134
|
descendantsOf,
|
|
115
135
|
createChild,
|
|
136
|
+
registerDoc,
|
|
116
137
|
moveEntry,
|
|
117
138
|
deleteEntry,
|
|
118
139
|
renameEntry,
|
|
@@ -2,11 +2,12 @@ import { computed, unref } from "vue";
|
|
|
2
2
|
import { useAbracadabra, useSyncedMap, useFetch, useHead, useSeoMeta } from "#imports";
|
|
3
3
|
function extractFirstParagraph(html) {
|
|
4
4
|
if (!html) return void 0;
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const strip = (raw) => raw.replace(/<[^>]+>/g, "").replace(/&[a-z]+;/gi, " ").trim();
|
|
6
|
+
for (const m of html.matchAll(/<p[^>]*>(.*?)<\/p>/gis)) {
|
|
7
|
+
const text = strip(m[1] ?? "");
|
|
8
|
+
if (text) return text.length > 160 ? text.slice(0, 157) + "..." : text;
|
|
9
|
+
}
|
|
10
|
+
return void 0;
|
|
10
11
|
}
|
|
11
12
|
function extractFirstImage(html) {
|
|
12
13
|
if (!html) return void 0;
|
|
@@ -77,6 +77,10 @@ export declare function useRendererBase(props: RendererBaseProps): {
|
|
|
77
77
|
childrenOf: (parentId: string | null) => import("./useChildTree.js").TreeEntry[];
|
|
78
78
|
descendantsOf: (id: string) => import("./useChildTree.js").TreeEntry[];
|
|
79
79
|
createChild: (parentId: string | null, label: string, type?: string) => string;
|
|
80
|
+
registerDoc: (id: string, parentId: string, opts?: {
|
|
81
|
+
label?: string;
|
|
82
|
+
type?: string;
|
|
83
|
+
}) => void;
|
|
80
84
|
moveEntry: (id: string, newParentId: string | null, newOrder: number) => void;
|
|
81
85
|
deleteEntry: (id: string) => void;
|
|
82
86
|
renameEntry: (id: string, label: string) => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface SpaceConfigOptions {
|
|
2
|
+
/** Display label for the config doc (default "Space Config"). */
|
|
3
|
+
label?: string;
|
|
4
|
+
/** Page type assigned on creation (default "doc"). */
|
|
5
|
+
type?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function useSpaceConfig(options?: SpaceConfigOptions): {
|
|
8
|
+
docId: import("vue").ComputedRef<string | null>;
|
|
9
|
+
config: import("vue").ComputedRef<Record<string, unknown>>;
|
|
10
|
+
ensure: () => string;
|
|
11
|
+
set: (patch: Record<string, unknown>) => void;
|
|
12
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
import { useAbracadabra } from "./useAbracadabra.js";
|
|
3
|
+
import { useChildTree } from "./useChildTree.js";
|
|
4
|
+
export function useSpaceConfig(options) {
|
|
5
|
+
const abra = useAbracadabra();
|
|
6
|
+
const tree = useChildTree(abra.doc, "space-config");
|
|
7
|
+
const docId = computed(() => {
|
|
8
|
+
for (const e of tree.entries.value) {
|
|
9
|
+
if (e.meta?.spaceConfig === true) return e.id;
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
});
|
|
13
|
+
const config = computed(
|
|
14
|
+
() => (docId.value ? tree.treeMap.get(docId.value)?.meta : void 0) ?? {}
|
|
15
|
+
);
|
|
16
|
+
function ensure() {
|
|
17
|
+
if (docId.value) return docId.value;
|
|
18
|
+
const id = crypto.randomUUID();
|
|
19
|
+
const now = Date.now();
|
|
20
|
+
const parent = abra.spaceDocId.value ?? null;
|
|
21
|
+
tree.treeMap.set(id, {
|
|
22
|
+
label: options?.label ?? "Space Config",
|
|
23
|
+
parentId: parent,
|
|
24
|
+
order: now,
|
|
25
|
+
type: options?.type ?? "doc",
|
|
26
|
+
createdAt: now,
|
|
27
|
+
updatedAt: now,
|
|
28
|
+
meta: { spaceConfig: true, hidden: true }
|
|
29
|
+
});
|
|
30
|
+
if (parent) tree.registerDoc(id, parent, { label: options?.label ?? "Space Config", type: options?.type ?? "doc" });
|
|
31
|
+
return id;
|
|
32
|
+
}
|
|
33
|
+
function set(patch) {
|
|
34
|
+
tree.updateMeta(ensure(), patch);
|
|
35
|
+
}
|
|
36
|
+
return { docId, config, ensure, set };
|
|
37
|
+
}
|
|
@@ -52,14 +52,11 @@ export async function renderDocToHTML(ydoc) {
|
|
|
52
52
|
}
|
|
53
53
|
async function renderDocToJSON(ydoc) {
|
|
54
54
|
try {
|
|
55
|
-
const Y = await import("yjs");
|
|
56
55
|
const result = {};
|
|
57
56
|
ydoc.share.forEach((type, key) => {
|
|
58
|
-
if (type
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
result[key] = type.toJSON();
|
|
62
|
-
}
|
|
57
|
+
if (typeof type?.toJSON !== "function") return;
|
|
58
|
+
const json = type.toJSON();
|
|
59
|
+
if (json !== null && typeof json === "object") result[key] = json;
|
|
63
60
|
});
|
|
64
61
|
return result;
|
|
65
62
|
} catch (e) {
|