@abraca/nuxt 2.56.0 → 2.58.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/editor/AMetaChip.d.vue.ts +36 -0
- package/dist/runtime/components/editor/AMetaChip.vue +381 -0
- package/dist/runtime/components/editor/AMetaChip.vue.d.ts +36 -0
- 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/useDocSlugs.js +3 -1
- package/dist/runtime/composables/useDocTree.js +4 -2
- package/dist/runtime/extensions/views/DocEmbedView.vue +4 -2
- package/dist/runtime/server/plugins/abracadabra-service.js +1 -0
- package/dist/runtime/server/runners/doc-tree-cache.js +4 -3
- package/dist/runtime/server/utils/slugMap.d.ts +4 -2
- package/dist/runtime/server/utils/slugMap.js +4 -4
- package/dist/runtime/types.d.ts +8 -0
- package/dist/runtime/utils/slugify.d.ts +7 -1
- package/dist/runtime/utils/slugify.js +4 -3
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
fieldType: 'text' | 'url' | 'date' | 'datetime' | 'daterange' | 'location';
|
|
3
|
+
/** Chip label — shown while the field is empty, and as the popover title. */
|
|
4
|
+
label?: string;
|
|
5
|
+
/** Lucide icon override (defaults per field type). */
|
|
6
|
+
icon?: string;
|
|
7
|
+
/** Current meta snapshot (reactive from the parent). */
|
|
8
|
+
meta: Record<string, unknown>;
|
|
9
|
+
/** Key for single-value fields (text/url/date/datetime). */
|
|
10
|
+
metaKey?: string;
|
|
11
|
+
/** Keys for daterange. */
|
|
12
|
+
startKey?: string;
|
|
13
|
+
endKey?: string;
|
|
14
|
+
/** Keys for location. */
|
|
15
|
+
latKey?: string;
|
|
16
|
+
lngKey?: string;
|
|
17
|
+
/** Read-only chip (no popover, display only). */
|
|
18
|
+
readonly?: boolean;
|
|
19
|
+
/** daterange: offer an "Ongoing" action that clears endKey. */
|
|
20
|
+
allowOpenEnd?: boolean;
|
|
21
|
+
};
|
|
22
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
23
|
+
patch: (patch: Record<string, unknown>) => any;
|
|
24
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
25
|
+
onPatch?: ((patch: Record<string, unknown>) => any) | undefined;
|
|
26
|
+
}>, {
|
|
27
|
+
label: string;
|
|
28
|
+
icon: string;
|
|
29
|
+
metaKey: string;
|
|
30
|
+
startKey: string;
|
|
31
|
+
endKey: string;
|
|
32
|
+
latKey: string;
|
|
33
|
+
lngKey: string;
|
|
34
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
35
|
+
declare const _default: typeof __VLS_export;
|
|
36
|
+
export default _default;
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, ref } from "vue";
|
|
3
|
+
import {
|
|
4
|
+
DateFormatter,
|
|
5
|
+
getLocalTimeZone,
|
|
6
|
+
Time,
|
|
7
|
+
parseDate
|
|
8
|
+
} from "@internationalized/date";
|
|
9
|
+
import ALocationPickerPopover from "./ALocationPickerPopover.vue";
|
|
10
|
+
const props = defineProps({
|
|
11
|
+
fieldType: { type: String, required: true },
|
|
12
|
+
label: { type: String, required: false, default: "" },
|
|
13
|
+
icon: { type: String, required: false, default: "" },
|
|
14
|
+
meta: { type: Object, required: true },
|
|
15
|
+
metaKey: { type: String, required: false, default: "" },
|
|
16
|
+
startKey: { type: String, required: false, default: "" },
|
|
17
|
+
endKey: { type: String, required: false, default: "" },
|
|
18
|
+
latKey: { type: String, required: false, default: "" },
|
|
19
|
+
lngKey: { type: String, required: false, default: "" },
|
|
20
|
+
readonly: { type: Boolean, required: false },
|
|
21
|
+
allowOpenEnd: { type: Boolean, required: false }
|
|
22
|
+
});
|
|
23
|
+
const emit = defineEmits(["patch"]);
|
|
24
|
+
const df = new DateFormatter("en-US", { dateStyle: "medium" });
|
|
25
|
+
const CHIP_CLASS = "h-7 px-2.5 py-1 text-sm border border-(--ui-border) rounded-md hover:bg-(--ui-bg-elevated) gap-1.5 data-[state=open]:bg-(--ui-bg-elevated)";
|
|
26
|
+
const DEFAULT_ICONS = {
|
|
27
|
+
text: "i-lucide-text-cursor-input",
|
|
28
|
+
url: "i-lucide-link",
|
|
29
|
+
date: "i-lucide-calendar",
|
|
30
|
+
datetime: "i-lucide-calendar-clock",
|
|
31
|
+
daterange: "i-lucide-calendar-range",
|
|
32
|
+
location: "i-lucide-map-pin"
|
|
33
|
+
};
|
|
34
|
+
const chipIcon = computed(() => props.icon || DEFAULT_ICONS[props.fieldType] || "i-lucide-tag");
|
|
35
|
+
function getStr(key) {
|
|
36
|
+
const v = props.meta?.[key];
|
|
37
|
+
return typeof v === "string" ? v : v != null ? String(v) : "";
|
|
38
|
+
}
|
|
39
|
+
function getOptNum(key) {
|
|
40
|
+
const v = props.meta?.[key];
|
|
41
|
+
if (v === void 0 || v === null || v === "") return void 0;
|
|
42
|
+
return Number(v);
|
|
43
|
+
}
|
|
44
|
+
function patch(update) {
|
|
45
|
+
if (props.readonly) return;
|
|
46
|
+
emit("patch", update);
|
|
47
|
+
}
|
|
48
|
+
function isoToCalendarDate(s) {
|
|
49
|
+
if (s.length < 10) return void 0;
|
|
50
|
+
try {
|
|
51
|
+
return parseDate(s.slice(0, 10));
|
|
52
|
+
} catch {
|
|
53
|
+
return void 0;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function dvToIso(d) {
|
|
57
|
+
return d.toString().slice(0, 10);
|
|
58
|
+
}
|
|
59
|
+
function fmtDate(s) {
|
|
60
|
+
if (!s) return "";
|
|
61
|
+
const cd = isoToCalendarDate(s);
|
|
62
|
+
return cd ? df.format(cd.toDate(getLocalTimeZone())) : s;
|
|
63
|
+
}
|
|
64
|
+
function isoToTime(hhmm) {
|
|
65
|
+
const [h = 0, m = 0] = hhmm.split(":").map(Number);
|
|
66
|
+
return new Time(Number.isNaN(h) ? 0 : h, Number.isNaN(m) ? 0 : m);
|
|
67
|
+
}
|
|
68
|
+
function timeToHHMM(tv) {
|
|
69
|
+
return `${String(tv.hour).padStart(2, "0")}:${String(tv.minute).padStart(2, "0")}`;
|
|
70
|
+
}
|
|
71
|
+
function asSingleTime(raw) {
|
|
72
|
+
if (raw && typeof raw === "object" && "hour" in raw && "minute" in raw) {
|
|
73
|
+
const v = raw;
|
|
74
|
+
if (typeof v.hour === "number" && typeof v.minute === "number") {
|
|
75
|
+
return { hour: v.hour, minute: v.minute };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
const displayText = computed(() => {
|
|
81
|
+
switch (props.fieldType) {
|
|
82
|
+
case "text":
|
|
83
|
+
return getStr(props.metaKey);
|
|
84
|
+
case "url": {
|
|
85
|
+
const url = getStr(props.metaKey);
|
|
86
|
+
if (!url) return "";
|
|
87
|
+
try {
|
|
88
|
+
return new URL(url).hostname.replace(/^www\./, "");
|
|
89
|
+
} catch {
|
|
90
|
+
return url;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
case "date":
|
|
94
|
+
return fmtDate(getStr(props.metaKey));
|
|
95
|
+
case "datetime": {
|
|
96
|
+
const v = getStr(props.metaKey);
|
|
97
|
+
if (!v) return "";
|
|
98
|
+
const time = v.includes("T") ? v.slice(11, 16) : "";
|
|
99
|
+
return [fmtDate(v), time].filter(Boolean).join(" ");
|
|
100
|
+
}
|
|
101
|
+
case "daterange": {
|
|
102
|
+
const start = getStr(props.startKey);
|
|
103
|
+
const end = getStr(props.endKey);
|
|
104
|
+
if (!start && !end) return "";
|
|
105
|
+
const endLabel = end ? fmtDate(end) : props.allowOpenEnd ? "now" : "";
|
|
106
|
+
return endLabel ? `${fmtDate(start)} \u2013 ${endLabel}` : fmtDate(start);
|
|
107
|
+
}
|
|
108
|
+
case "location": {
|
|
109
|
+
const lat = getOptNum(props.latKey);
|
|
110
|
+
const lng = getOptNum(props.lngKey);
|
|
111
|
+
if (lat === void 0 || lng === void 0) return "";
|
|
112
|
+
return `${lat.toFixed(4)}, ${lng.toFixed(4)}`;
|
|
113
|
+
}
|
|
114
|
+
default:
|
|
115
|
+
return "";
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
const chipText = computed(() => displayText.value || props.label || props.fieldType);
|
|
119
|
+
const isEmpty = computed(() => !displayText.value);
|
|
120
|
+
const popoverOpen = ref(false);
|
|
121
|
+
const draft = ref("");
|
|
122
|
+
function openTextDraft(open) {
|
|
123
|
+
popoverOpen.value = open;
|
|
124
|
+
if (open) draft.value = getStr(props.metaKey);
|
|
125
|
+
}
|
|
126
|
+
function commitDraft() {
|
|
127
|
+
const v = draft.value.trim();
|
|
128
|
+
patch({ [props.metaKey]: v || void 0 });
|
|
129
|
+
popoverOpen.value = false;
|
|
130
|
+
}
|
|
131
|
+
function openUrl() {
|
|
132
|
+
const url = getStr(props.metaKey);
|
|
133
|
+
if (url) window.open(url, "_blank", "noopener");
|
|
134
|
+
}
|
|
135
|
+
function onSingleDate(d) {
|
|
136
|
+
if (!d || typeof d.toString !== "function") return;
|
|
137
|
+
const iso = dvToIso(d);
|
|
138
|
+
if (props.fieldType === "datetime") {
|
|
139
|
+
const time = getStr(props.metaKey).slice(11, 16) || "00:00";
|
|
140
|
+
patch({ [props.metaKey]: `${iso}T${time}:00.000Z` });
|
|
141
|
+
} else {
|
|
142
|
+
patch({ [props.metaKey]: iso });
|
|
143
|
+
popoverOpen.value = false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function onDatetimeTime(raw) {
|
|
147
|
+
const tv = asSingleTime(raw);
|
|
148
|
+
if (!tv) return;
|
|
149
|
+
const date = getStr(props.metaKey).slice(0, 10) || (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
150
|
+
patch({ [props.metaKey]: `${date}T${timeToHHMM(tv)}:00.000Z` });
|
|
151
|
+
}
|
|
152
|
+
const rangeModel = computed(() => {
|
|
153
|
+
const start = isoToCalendarDate(getStr(props.startKey));
|
|
154
|
+
const end = isoToCalendarDate(getStr(props.endKey));
|
|
155
|
+
return start && end ? { start, end } : void 0;
|
|
156
|
+
});
|
|
157
|
+
function onDateRange(range) {
|
|
158
|
+
if (!range?.start) return;
|
|
159
|
+
patch({
|
|
160
|
+
[props.startKey]: dvToIso(range.start),
|
|
161
|
+
[props.endKey]: range.end ? dvToIso(range.end) : void 0
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
function setOngoing() {
|
|
165
|
+
patch({ [props.endKey]: void 0 });
|
|
166
|
+
popoverOpen.value = false;
|
|
167
|
+
}
|
|
168
|
+
function clearField() {
|
|
169
|
+
const update = {};
|
|
170
|
+
if (props.metaKey) update[props.metaKey] = void 0;
|
|
171
|
+
if (props.startKey) update[props.startKey] = void 0;
|
|
172
|
+
if (props.endKey) update[props.endKey] = void 0;
|
|
173
|
+
patch(update);
|
|
174
|
+
popoverOpen.value = false;
|
|
175
|
+
}
|
|
176
|
+
function onLatLng(key, v) {
|
|
177
|
+
patch({ [key]: v != null ? Number(v) : void 0 });
|
|
178
|
+
}
|
|
179
|
+
</script>
|
|
180
|
+
|
|
181
|
+
<template>
|
|
182
|
+
<span
|
|
183
|
+
class="a-meta-chip inline-flex items-center"
|
|
184
|
+
:data-field-type="fieldType"
|
|
185
|
+
>
|
|
186
|
+
<!-- location delegates to the shared picker popover -->
|
|
187
|
+
<ALocationPickerPopover
|
|
188
|
+
v-if="fieldType === 'location' && !readonly"
|
|
189
|
+
:lat-value="getOptNum(latKey)"
|
|
190
|
+
:lng-value="getOptNum(lngKey)"
|
|
191
|
+
:open="popoverOpen"
|
|
192
|
+
@update:lat="(v) => onLatLng(latKey, v)"
|
|
193
|
+
@update:lng="(v) => onLatLng(lngKey, v)"
|
|
194
|
+
@update:open="popoverOpen = $event"
|
|
195
|
+
@clear="() => {
|
|
196
|
+
onLatLng(latKey, null);
|
|
197
|
+
onLatLng(lngKey, null);
|
|
198
|
+
}"
|
|
199
|
+
>
|
|
200
|
+
<UButton
|
|
201
|
+
size="sm"
|
|
202
|
+
color="neutral"
|
|
203
|
+
variant="ghost"
|
|
204
|
+
:icon="chipIcon"
|
|
205
|
+
:class="CHIP_CLASS"
|
|
206
|
+
>
|
|
207
|
+
<span
|
|
208
|
+
class="max-w-44 truncate"
|
|
209
|
+
:class="isEmpty ? 'text-(--ui-text-muted)' : ''"
|
|
210
|
+
>{{ chipText }}</span>
|
|
211
|
+
</UButton>
|
|
212
|
+
</ALocationPickerPopover>
|
|
213
|
+
|
|
214
|
+
<UPopover
|
|
215
|
+
v-else-if="!readonly"
|
|
216
|
+
:open="popoverOpen"
|
|
217
|
+
:content="{ align: 'start' }"
|
|
218
|
+
@update:open="fieldType === 'text' || fieldType === 'url' ? openTextDraft($event) : popoverOpen = $event"
|
|
219
|
+
>
|
|
220
|
+
<UButton
|
|
221
|
+
size="sm"
|
|
222
|
+
color="neutral"
|
|
223
|
+
variant="ghost"
|
|
224
|
+
:icon="chipIcon"
|
|
225
|
+
:class="CHIP_CLASS"
|
|
226
|
+
>
|
|
227
|
+
<span
|
|
228
|
+
class="max-w-44 truncate"
|
|
229
|
+
:class="isEmpty ? 'text-(--ui-text-muted)' : ''"
|
|
230
|
+
>{{ chipText }}</span>
|
|
231
|
+
</UButton>
|
|
232
|
+
|
|
233
|
+
<template #content>
|
|
234
|
+
<!-- text / url -->
|
|
235
|
+
<div
|
|
236
|
+
v-if="fieldType === 'text' || fieldType === 'url'"
|
|
237
|
+
class="p-2 w-72"
|
|
238
|
+
>
|
|
239
|
+
<p
|
|
240
|
+
v-if="label"
|
|
241
|
+
class="text-xs font-medium text-(--ui-text-muted) mb-1.5"
|
|
242
|
+
>
|
|
243
|
+
{{ label }}
|
|
244
|
+
</p>
|
|
245
|
+
<div class="flex items-center gap-1.5">
|
|
246
|
+
<UInput
|
|
247
|
+
v-model="draft"
|
|
248
|
+
size="sm"
|
|
249
|
+
class="flex-1"
|
|
250
|
+
:type="fieldType === 'url' ? 'url' : 'text'"
|
|
251
|
+
:placeholder="fieldType === 'url' ? 'https://\u2026' : label"
|
|
252
|
+
autofocus
|
|
253
|
+
@keydown.enter.prevent="commitDraft"
|
|
254
|
+
@keydown.escape.prevent="popoverOpen = false"
|
|
255
|
+
/>
|
|
256
|
+
<UButton
|
|
257
|
+
v-if="fieldType === 'url' && getStr(metaKey)"
|
|
258
|
+
size="sm"
|
|
259
|
+
color="neutral"
|
|
260
|
+
variant="ghost"
|
|
261
|
+
icon="i-lucide-external-link"
|
|
262
|
+
aria-label="Open link"
|
|
263
|
+
@click="openUrl"
|
|
264
|
+
/>
|
|
265
|
+
</div>
|
|
266
|
+
<div class="flex items-center justify-between mt-2">
|
|
267
|
+
<UButton
|
|
268
|
+
size="xs"
|
|
269
|
+
color="neutral"
|
|
270
|
+
variant="ghost"
|
|
271
|
+
@click="clearField"
|
|
272
|
+
>
|
|
273
|
+
Clear
|
|
274
|
+
</UButton>
|
|
275
|
+
<UButton
|
|
276
|
+
size="xs"
|
|
277
|
+
color="neutral"
|
|
278
|
+
variant="soft"
|
|
279
|
+
@click="commitDraft"
|
|
280
|
+
>
|
|
281
|
+
Save
|
|
282
|
+
</UButton>
|
|
283
|
+
</div>
|
|
284
|
+
</div>
|
|
285
|
+
|
|
286
|
+
<!-- single date -->
|
|
287
|
+
<div
|
|
288
|
+
v-else-if="fieldType === 'date'"
|
|
289
|
+
class="p-2"
|
|
290
|
+
>
|
|
291
|
+
<UCalendar
|
|
292
|
+
:model-value="isoToCalendarDate(getStr(metaKey))"
|
|
293
|
+
@update:model-value="onSingleDate($event)"
|
|
294
|
+
/>
|
|
295
|
+
<div class="flex justify-end pt-1">
|
|
296
|
+
<UButton
|
|
297
|
+
size="xs"
|
|
298
|
+
color="neutral"
|
|
299
|
+
variant="ghost"
|
|
300
|
+
@click="clearField"
|
|
301
|
+
>
|
|
302
|
+
Clear
|
|
303
|
+
</UButton>
|
|
304
|
+
</div>
|
|
305
|
+
</div>
|
|
306
|
+
|
|
307
|
+
<!-- datetime -->
|
|
308
|
+
<div
|
|
309
|
+
v-else-if="fieldType === 'datetime'"
|
|
310
|
+
class="p-2"
|
|
311
|
+
>
|
|
312
|
+
<UCalendar
|
|
313
|
+
:model-value="isoToCalendarDate(getStr(metaKey))"
|
|
314
|
+
@update:model-value="onSingleDate($event)"
|
|
315
|
+
/>
|
|
316
|
+
<div class="flex items-center gap-2 pt-3 mt-3 border-t border-(--ui-border)">
|
|
317
|
+
<UInputTime
|
|
318
|
+
size="sm"
|
|
319
|
+
:model-value="isoToTime(getStr(metaKey).slice(11, 16) || '00:00')"
|
|
320
|
+
@update:model-value="onDatetimeTime($event)"
|
|
321
|
+
/>
|
|
322
|
+
<div class="flex-1" />
|
|
323
|
+
<UButton
|
|
324
|
+
size="xs"
|
|
325
|
+
color="neutral"
|
|
326
|
+
variant="ghost"
|
|
327
|
+
@click="clearField"
|
|
328
|
+
>
|
|
329
|
+
Clear
|
|
330
|
+
</UButton>
|
|
331
|
+
</div>
|
|
332
|
+
</div>
|
|
333
|
+
|
|
334
|
+
<!-- daterange -->
|
|
335
|
+
<div
|
|
336
|
+
v-else-if="fieldType === 'daterange'"
|
|
337
|
+
class="p-2"
|
|
338
|
+
>
|
|
339
|
+
<UCalendar
|
|
340
|
+
range
|
|
341
|
+
:model-value="rangeModel"
|
|
342
|
+
@update:model-value="onDateRange($event)"
|
|
343
|
+
/>
|
|
344
|
+
<div class="flex items-center justify-between pt-1">
|
|
345
|
+
<UButton
|
|
346
|
+
v-if="allowOpenEnd"
|
|
347
|
+
size="xs"
|
|
348
|
+
color="neutral"
|
|
349
|
+
variant="soft"
|
|
350
|
+
icon="i-lucide-infinity"
|
|
351
|
+
@click="setOngoing"
|
|
352
|
+
>
|
|
353
|
+
Ongoing
|
|
354
|
+
</UButton>
|
|
355
|
+
<span v-else />
|
|
356
|
+
<UButton
|
|
357
|
+
size="xs"
|
|
358
|
+
color="neutral"
|
|
359
|
+
variant="ghost"
|
|
360
|
+
@click="clearField"
|
|
361
|
+
>
|
|
362
|
+
Clear
|
|
363
|
+
</UButton>
|
|
364
|
+
</div>
|
|
365
|
+
</div>
|
|
366
|
+
</template>
|
|
367
|
+
</UPopover>
|
|
368
|
+
|
|
369
|
+
<!-- read-only chip -->
|
|
370
|
+
<span
|
|
371
|
+
v-else
|
|
372
|
+
class="inline-flex items-center gap-1.5 h-7 px-2.5 py-1 text-sm border border-(--ui-border) rounded-md text-(--ui-text-muted)"
|
|
373
|
+
>
|
|
374
|
+
<UIcon
|
|
375
|
+
:name="chipIcon"
|
|
376
|
+
class="size-3.5"
|
|
377
|
+
/>
|
|
378
|
+
<span class="max-w-44 truncate">{{ chipText }}</span>
|
|
379
|
+
</span>
|
|
380
|
+
</span>
|
|
381
|
+
</template>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
fieldType: 'text' | 'url' | 'date' | 'datetime' | 'daterange' | 'location';
|
|
3
|
+
/** Chip label — shown while the field is empty, and as the popover title. */
|
|
4
|
+
label?: string;
|
|
5
|
+
/** Lucide icon override (defaults per field type). */
|
|
6
|
+
icon?: string;
|
|
7
|
+
/** Current meta snapshot (reactive from the parent). */
|
|
8
|
+
meta: Record<string, unknown>;
|
|
9
|
+
/** Key for single-value fields (text/url/date/datetime). */
|
|
10
|
+
metaKey?: string;
|
|
11
|
+
/** Keys for daterange. */
|
|
12
|
+
startKey?: string;
|
|
13
|
+
endKey?: string;
|
|
14
|
+
/** Keys for location. */
|
|
15
|
+
latKey?: string;
|
|
16
|
+
lngKey?: string;
|
|
17
|
+
/** Read-only chip (no popover, display only). */
|
|
18
|
+
readonly?: boolean;
|
|
19
|
+
/** daterange: offer an "Ongoing" action that clears endKey. */
|
|
20
|
+
allowOpenEnd?: boolean;
|
|
21
|
+
};
|
|
22
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
23
|
+
patch: (patch: Record<string, unknown>) => any;
|
|
24
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
25
|
+
onPatch?: ((patch: Record<string, unknown>) => any) | undefined;
|
|
26
|
+
}>, {
|
|
27
|
+
label: string;
|
|
28
|
+
icon: string;
|
|
29
|
+
metaKey: string;
|
|
30
|
+
startKey: string;
|
|
31
|
+
endKey: string;
|
|
32
|
+
latKey: string;
|
|
33
|
+
lngKey: string;
|
|
34
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
35
|
+
declare const _default: typeof __VLS_export;
|
|
36
|
+
export default _default;
|
|
@@ -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
|
-
isFollowing: boolean;
|
|
43
42
|
showFollow: boolean;
|
|
43
|
+
isFollowing: 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
|
-
isFollowing: boolean;
|
|
43
42
|
showFollow: boolean;
|
|
43
|
+
isFollowing: boolean;
|
|
44
44
|
currentDocLabel: string | null;
|
|
45
45
|
currentDocIcon: string;
|
|
46
46
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -11,7 +11,9 @@ export function useDocSlugs() {
|
|
|
11
11
|
const entries = computed(
|
|
12
12
|
() => Object.entries(treeMap.data).map(([id, entry]) => ({ id, ...entry }))
|
|
13
13
|
);
|
|
14
|
-
const slugMap = computed(
|
|
14
|
+
const slugMap = computed(
|
|
15
|
+
() => buildSlugMap(entries.value, abra.spaceDocId?.value ?? null)
|
|
16
|
+
);
|
|
15
17
|
const getSlug = (docId) => slugMap.value.idToSlug[docId] ?? docId;
|
|
16
18
|
const getDocId = (slug) => slugMap.value.slugToId[slug] ?? null;
|
|
17
19
|
const getDocUrl = (docId) => {
|
|
@@ -34,14 +34,16 @@ export function useDocTree(docId) {
|
|
|
34
34
|
() => Object.entries(treeMap.data).filter(([id]) => id !== spaceDocId.value).map(([id, entry]) => ({ id, ...entry }))
|
|
35
35
|
);
|
|
36
36
|
const topLevelDocs = computed(
|
|
37
|
-
() => entries.value.filter(
|
|
37
|
+
() => entries.value.filter(
|
|
38
|
+
(e) => (!e.parentId || e.parentId === spaceDocId.value) && !e.trashed && e.id !== spaceDocId.value
|
|
39
|
+
).sort((a, b) => (a.order ?? 0) - (b.order ?? 0))
|
|
38
40
|
);
|
|
39
41
|
const firstDocId = computed(() => topLevelDocs.value[0]?.id ?? null);
|
|
40
42
|
const getEntry = (id) => {
|
|
41
43
|
const raw = treeMap.data[id];
|
|
42
44
|
return raw ? { id, ...raw } : void 0;
|
|
43
45
|
};
|
|
44
|
-
const slugMap = computed(() => buildSlugMap(entries.value));
|
|
46
|
+
const slugMap = computed(() => buildSlugMap(entries.value, spaceDocId.value ?? null));
|
|
45
47
|
const navigationItems = computed(
|
|
46
48
|
() => topLevelDocs.value.filter((e) => e.meta?.hidden !== true).map((e) => {
|
|
47
49
|
const slug = slugMap.value.idToSlug[e.id];
|
|
@@ -6,6 +6,7 @@ import { navigateTo } from "#imports";
|
|
|
6
6
|
import { useAbracadabra } from "../../composables/useAbracadabra";
|
|
7
7
|
import { useSyncedMap } from "../../composables/useYDoc";
|
|
8
8
|
import { useDocSlugs } from "../../composables/useDocSlugs";
|
|
9
|
+
import { usePluginRegistry } from "../../composables/usePluginRegistry";
|
|
9
10
|
import { resolveDocType } from "../../utils/docTypes";
|
|
10
11
|
const props = defineProps({
|
|
11
12
|
decorations: { type: Array, required: true },
|
|
@@ -30,7 +31,8 @@ const treeMap = useSyncedMap(
|
|
|
30
31
|
const docId = computed(() => props.node.attrs.docId);
|
|
31
32
|
const treeEntry = computed(() => treeMap.data[docId.value]);
|
|
32
33
|
const exists = computed(() => !!treeEntry.value);
|
|
33
|
-
const
|
|
34
|
+
const registry = usePluginRegistry();
|
|
35
|
+
const docType = computed(() => resolveDocType(treeEntry.value?.type, registry));
|
|
34
36
|
const label = computed(() => treeEntry.value?.label || "Untitled");
|
|
35
37
|
const childProvider = shallowRef(null);
|
|
36
38
|
const isLoading = ref(false);
|
|
@@ -223,5 +225,5 @@ function removeEmbed() {
|
|
|
223
225
|
</template>
|
|
224
226
|
|
|
225
227
|
<style scoped>
|
|
226
|
-
.de-container{background:var(--ui-bg);border:1px solid var(--ui-border);border-radius:10px;box-shadow:0 8px 32px rgba(0,0,0,.1),0 2px 8px rgba(0,0,0,.06);overflow:hidden;transition:box-shadow .28s ease}.de-container:has(.de-body-collapsed){box-shadow:0 2px 8px rgba(0,0,0,.06),0 1px 3px rgba(0,0,0,.04)}.de-header{align-items:center;background:var(--ui-bg-elevated);border-bottom:1px solid var(--ui-border);cursor:grab;display:flex;flex-shrink:0;gap:6px;height:34px;padding:0 4px 0 10px;transition:border-color .28s ease;-webkit-user-select:none;-moz-user-select:none;user-select:none}.de-header:active{cursor:grabbing}.de-header-collapsed{border-bottom-color:transparent}.de-body{display:flex;flex-direction:column;height:400px;overflow:hidden;transition:height .28s cubic-bezier(.4,0,.2,1),border-color .28s ease}.de-body-tall{height:700px}.de-body-collapsed{height:0}.de-seamless{background:transparent;border:none;box-shadow:none}.de-seamless .de-header{background:transparent;border-bottom:none;height:26px;opacity:0;pointer-events:none;transition:opacity .15s ease}.de-seamless:focus-within .de-header,.de-seamless:hover .de-header{opacity:1;pointer-events:auto}.de-body-seamless{height:auto;min-height:0}.de-title{align-items:center;display:flex;flex:1;gap:4px;min-width:0;overflow:hidden;pointer-events:none}.de-title button,.de-title-link{pointer-events:auto}.de-title-link{cursor:pointer}.de-title-link .de-title-text{color:var(--ui-primary);text-decoration:underline;text-decoration-color:transparent;transition:text-decoration-color .12s}.de-title-link:hover .de-title-text{text-decoration-color:var(--ui-primary)}.de-title-text{color:var(--ui-text-muted);font-size:12px;font-weight:500;overflow:hidden;pointer-events:none;text-overflow:ellipsis;white-space:nowrap}.de-type-btn{align-items:center;border-radius:var(--ui-radius);color:var(--ui-text-muted);cursor:pointer;display:flex;flex-shrink:0;height:22px;justify-content:center;transition:background .1s,color .1s;width:22px}.de-type-btn:hover{background:var(--ui-bg-accented);color:var(--ui-text)}.de-controls{flex-shrink:0;gap:2px}.de-controls,.de-ctrl-btn{align-items:center;display:flex}.de-ctrl-btn{border-radius:50%;color:var(--ui-text-dimmed);cursor:pointer;height:22px;justify-content:center;transition:background .12s,color .12s;width:22px}.de-ctrl-btn:hover{background:var(--ui-bg-accented);color:var(--ui-text)}.de-ctrl-expand:hover{background:rgba(34,197,94,.15);color:#148f3e}.de-ctrl-close:hover{background:rgba(239,68,68,.15);color:#dc2626}
|
|
228
|
+
.de-container{background:var(--ui-bg);border:1px solid var(--ui-border);border-radius:10px;box-shadow:0 8px 32px rgba(0,0,0,.1),0 2px 8px rgba(0,0,0,.06);overflow:hidden;transition:box-shadow .28s ease}.de-container:has(.de-body-collapsed){box-shadow:0 2px 8px rgba(0,0,0,.06),0 1px 3px rgba(0,0,0,.04)}.de-header{align-items:center;background:var(--ui-bg-elevated);border-bottom:1px solid var(--ui-border);cursor:grab;display:flex;flex-shrink:0;gap:6px;height:34px;padding:0 4px 0 10px;transition:border-color .28s ease;-webkit-user-select:none;-moz-user-select:none;user-select:none}.de-header:active{cursor:grabbing}.de-header-collapsed{border-bottom-color:transparent}.de-body{display:flex;flex-direction:column;height:400px;overflow-x:hidden;overflow-y:auto;transition:height .28s cubic-bezier(.4,0,.2,1),border-color .28s ease}.de-body-collapsed{overflow-y:hidden}.de-body-tall{height:700px}.de-body-collapsed{height:0}.de-seamless{background:transparent;border:none;box-shadow:none}.de-seamless .de-header{background:transparent;border-bottom:none;height:26px;opacity:0;pointer-events:none;transition:opacity .15s ease}.de-seamless:focus-within .de-header,.de-seamless:hover .de-header{opacity:1;pointer-events:auto}.de-body-seamless{height:auto;min-height:0}.de-title{align-items:center;display:flex;flex:1;gap:4px;min-width:0;overflow:hidden;pointer-events:none}.de-title button,.de-title-link{pointer-events:auto}.de-title-link{cursor:pointer}.de-title-link .de-title-text{color:var(--ui-primary);text-decoration:underline;text-decoration-color:transparent;transition:text-decoration-color .12s}.de-title-link:hover .de-title-text{text-decoration-color:var(--ui-primary)}.de-title-text{color:var(--ui-text-muted);font-size:12px;font-weight:500;overflow:hidden;pointer-events:none;text-overflow:ellipsis;white-space:nowrap}.de-type-btn{align-items:center;border-radius:var(--ui-radius);color:var(--ui-text-muted);cursor:pointer;display:flex;flex-shrink:0;height:22px;justify-content:center;transition:background .1s,color .1s;width:22px}.de-type-btn:hover{background:var(--ui-bg-accented);color:var(--ui-text)}.de-controls{flex-shrink:0;gap:2px}.de-controls,.de-ctrl-btn{align-items:center;display:flex}.de-ctrl-btn{border-radius:50%;color:var(--ui-text-dimmed);cursor:pointer;height:22px;justify-content:center;transition:background .12s,color .12s;width:22px}.de-ctrl-btn:hover{background:var(--ui-bg-accented);color:var(--ui-text)}.de-ctrl-expand:hover{background:rgba(34,197,94,.15);color:#148f3e}.de-ctrl-close:hover{background:rgba(239,68,68,.15);color:#dc2626}
|
|
227
229
|
</style>
|
|
@@ -4,7 +4,7 @@ import { initSlugMap, rebuildSlugMapSync, rebuildSlugMap } from "../utils/slugMa
|
|
|
4
4
|
export const docTreeCacheRunner = {
|
|
5
5
|
name: "abracadabra:doc-tree-cache",
|
|
6
6
|
async start(ctx) {
|
|
7
|
-
const { rootDoc, rootProvider, storage } = ctx;
|
|
7
|
+
const { rootDoc, rootDocId, rootProvider, storage } = ctx;
|
|
8
8
|
const treeMap = rootDoc.getMap("doc-tree");
|
|
9
9
|
const loadedDocs = /* @__PURE__ */ new Map();
|
|
10
10
|
const pendingDocs = /* @__PURE__ */ new Set();
|
|
@@ -12,6 +12,7 @@ export const docTreeCacheRunner = {
|
|
|
12
12
|
initDocCache(storage, serverExts);
|
|
13
13
|
initSlugMap(storage);
|
|
14
14
|
async function trackDoc(docId) {
|
|
15
|
+
if (docId === rootDocId) return;
|
|
15
16
|
if (loadedDocs.has(docId) || pendingDocs.has(docId)) return;
|
|
16
17
|
pendingDocs.add(docId);
|
|
17
18
|
try {
|
|
@@ -44,7 +45,7 @@ export const docTreeCacheRunner = {
|
|
|
44
45
|
treeMap.forEach((_val, docId) => {
|
|
45
46
|
trackDoc(docId);
|
|
46
47
|
});
|
|
47
|
-
rebuildSlugMapSync(treeMap);
|
|
48
|
+
rebuildSlugMapSync(treeMap, rootDocId);
|
|
48
49
|
const observer = (event) => {
|
|
49
50
|
event.keysChanged.forEach((docId) => {
|
|
50
51
|
if (treeMap.has(docId)) {
|
|
@@ -55,7 +56,7 @@ export const docTreeCacheRunner = {
|
|
|
55
56
|
console.log(`[abracadabra:doc-tree-cache] Untracked: ${docId}`);
|
|
56
57
|
}
|
|
57
58
|
});
|
|
58
|
-
rebuildSlugMap(treeMap);
|
|
59
|
+
rebuildSlugMap(treeMap, rootDocId);
|
|
59
60
|
};
|
|
60
61
|
treeMap.observe(observer);
|
|
61
62
|
return () => {
|
|
@@ -18,12 +18,14 @@ export declare function loadPersistedSlugMap(): Promise<void>;
|
|
|
18
18
|
/**
|
|
19
19
|
* Rebuild the slug map from a Y.Map tree (debounced).
|
|
20
20
|
* Called by the doc-tree-cache runner when the tree changes.
|
|
21
|
+
* `rootId` = the space/root doc id — entries parented directly to it are
|
|
22
|
+
* top-level, and its self-descriptor entry gets no slug (mirrors the client).
|
|
21
23
|
*/
|
|
22
|
-
export declare function rebuildSlugMap(treeMap: any): void;
|
|
24
|
+
export declare function rebuildSlugMap(treeMap: any, rootId?: string | null): void;
|
|
23
25
|
/**
|
|
24
26
|
* Rebuild immediately (used for initial load).
|
|
25
27
|
*/
|
|
26
|
-
export declare function rebuildSlugMapSync(treeMap: any): void;
|
|
28
|
+
export declare function rebuildSlugMapSync(treeMap: any, rootId?: string | null): void;
|
|
27
29
|
/** Resolve a slug path to a docId. Returns null if not found. */
|
|
28
30
|
export declare function getDocIdFromSlug(slug: string): string | null;
|
|
29
31
|
/** Get the slug for a docId. Returns null if not found. */
|
|
@@ -19,14 +19,14 @@ export async function loadPersistedSlugMap() {
|
|
|
19
19
|
console.warn("[abracadabra:slug-map] Failed to load persisted slug map:", e);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
export function rebuildSlugMap(treeMap) {
|
|
22
|
+
export function rebuildSlugMap(treeMap, rootId) {
|
|
23
23
|
if (_rebuildTimer) clearTimeout(_rebuildTimer);
|
|
24
24
|
_rebuildTimer = setTimeout(() => {
|
|
25
25
|
_rebuildTimer = null;
|
|
26
|
-
rebuildSlugMapSync(treeMap);
|
|
26
|
+
rebuildSlugMapSync(treeMap, rootId);
|
|
27
27
|
}, REBUILD_DEBOUNCE_MS);
|
|
28
28
|
}
|
|
29
|
-
export function rebuildSlugMapSync(treeMap) {
|
|
29
|
+
export function rebuildSlugMapSync(treeMap, rootId) {
|
|
30
30
|
try {
|
|
31
31
|
const raw = treeMap.toJSON();
|
|
32
32
|
const entries = Object.entries(raw).map(([id, entry]) => ({
|
|
@@ -36,7 +36,7 @@ export function rebuildSlugMapSync(treeMap) {
|
|
|
36
36
|
order: entry.order ?? 0,
|
|
37
37
|
trashed: entry.trashed ?? false
|
|
38
38
|
}));
|
|
39
|
-
_slugMap = buildSlugMap(entries);
|
|
39
|
+
_slugMap = buildSlugMap(entries, rootId);
|
|
40
40
|
if (_storage) {
|
|
41
41
|
_storage.setItem(SLUG_STORAGE_KEY, _slugMap).catch((e) => {
|
|
42
42
|
console.warn("[abracadabra:slug-map] Failed to persist:", e);
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -629,6 +629,14 @@ export interface ServerRunnerContext {
|
|
|
629
629
|
wsp: AbracadabraWS;
|
|
630
630
|
/** Root Y.Doc (the world document) */
|
|
631
631
|
rootDoc: Y.Doc;
|
|
632
|
+
/**
|
|
633
|
+
* The root/space document ID the service synced (`service.rootDocId`
|
|
634
|
+
* override or the backend's `/info root_doc_id`). NOTE: `rootDoc.guid` is
|
|
635
|
+
* NOT this id — the root Y.Doc is created guid-less; the id lives on the
|
|
636
|
+
* provider. Use this for tree semantics (self-descriptor, space-rooted
|
|
637
|
+
* parentIds, slug maps).
|
|
638
|
+
*/
|
|
639
|
+
rootDocId: string;
|
|
632
640
|
/** Root AbracadabraProvider — call .loadChild(docId) to open sub-documents */
|
|
633
641
|
rootProvider: AbracadabraProvider;
|
|
634
642
|
/** Nitro useStorage() handle — use for persistent cache across requests */
|
|
@@ -35,6 +35,12 @@ export interface SlugMap {
|
|
|
35
35
|
* Duplicate slugs at the same level get `-1`, `-2` suffixes (first occurrence
|
|
36
36
|
* keeps the base slug).
|
|
37
37
|
*
|
|
38
|
+
* `rootId` (optional): the space/root doc id. Entries parented DIRECTLY to the
|
|
39
|
+
* root doc (`parentId === rootId`) are top-level — same as `parentId: null` —
|
|
40
|
+
* so trees that model nav pages as true children of the space doc still get
|
|
41
|
+
* root-level slugs. The root doc's own self-descriptor entry (`id === rootId`,
|
|
42
|
+
* the cou-sh space pattern) is skipped: the root is served at `/`, never a slug.
|
|
43
|
+
*
|
|
38
44
|
* The output is deterministic: entries are sorted by order, then by id.
|
|
39
45
|
*/
|
|
40
|
-
export declare function buildSlugMap(entries: SlugMapEntry[]): SlugMap;
|
|
46
|
+
export declare function buildSlugMap(entries: SlugMapEntry[], rootId?: string | null): SlugMap;
|
|
@@ -3,13 +3,14 @@ export function slugify(label) {
|
|
|
3
3
|
return slug || "untitled";
|
|
4
4
|
}
|
|
5
5
|
export const isUUID = (s) => /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s);
|
|
6
|
-
export function buildSlugMap(entries) {
|
|
6
|
+
export function buildSlugMap(entries, rootId) {
|
|
7
7
|
const slugToId = {};
|
|
8
8
|
const idToSlug = {};
|
|
9
|
-
const active = entries.filter((e) => !e.trashed);
|
|
9
|
+
const active = entries.filter((e) => !e.trashed && (!rootId || e.id !== rootId));
|
|
10
10
|
const byParent = /* @__PURE__ */ new Map();
|
|
11
11
|
for (const entry of active) {
|
|
12
|
-
const
|
|
12
|
+
const pid = entry.parentId ?? null;
|
|
13
|
+
const key = rootId && pid === rootId ? null : pid;
|
|
13
14
|
if (!byParent.has(key)) byParent.set(key, []);
|
|
14
15
|
byParent.get(key).push(entry);
|
|
15
16
|
}
|