@abraca/nuxt 2.55.0 → 2.57.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.d.mts +11 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +4 -0
- package/dist/runtime/components/AEditor.vue +3 -0
- package/dist/runtime/components/aware/AMedia.d.vue.ts +1 -1
- package/dist/runtime/components/aware/AMedia.vue.d.ts +1 -1
- 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/useDocSlugs.js +3 -1
- package/dist/runtime/composables/useDocTree.js +4 -2
- package/dist/runtime/composables/useMetaMenuItems.d.ts +7 -3
- package/dist/runtime/composables/useMetaMenuItems.js +12 -7
- package/dist/runtime/extensions/document-meta.js +9 -13
- package/dist/runtime/extensions/views/DocEmbedView.vue +3 -1
- package/dist/runtime/extensions/views/DocLinkView.vue +32 -14
- package/dist/runtime/extensions/views/MetaFieldView.vue +19 -9
- package/dist/runtime/server/plugins/abracadabra-service.js +3 -2
- 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/metaFieldDefinitions.d.ts +25 -0
- package/dist/runtime/utils/metaFieldDefinitions.js +33 -60
- 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.d.mts
CHANGED
|
@@ -100,6 +100,7 @@ declare module '@nuxt/schema' {
|
|
|
100
100
|
servicePublicKey: string;
|
|
101
101
|
servicePrivateKey: string;
|
|
102
102
|
serviceRootDocId: string;
|
|
103
|
+
serviceServerUrl: string;
|
|
103
104
|
serviceDisabled: boolean;
|
|
104
105
|
};
|
|
105
106
|
}
|
|
@@ -404,6 +405,16 @@ interface ModuleOptions {
|
|
|
404
405
|
privateKey?: string;
|
|
405
406
|
/** Root document ID to connect to. Defaults to the server's root_doc_id. */
|
|
406
407
|
rootDocId?: string;
|
|
408
|
+
/**
|
|
409
|
+
* Base URL (http/https) the SERVER-SIDE service runner uses to reach the
|
|
410
|
+
* backend. Defaults to the public `url`. Set this when the browser and the
|
|
411
|
+
* in-container SSR runner need DIFFERENT origins — e.g. a hosted deploy
|
|
412
|
+
* where the browser talks to a public HTTPS domain (`url`) while the runner
|
|
413
|
+
* talks to the backend over internal container networking
|
|
414
|
+
* (`http://abracadabra:3000`). Server-only; never exposed to the client.
|
|
415
|
+
* Can be overridden at runtime via NUXT_ABRACADABRA_SERVICE_SERVER_URL.
|
|
416
|
+
*/
|
|
417
|
+
serverUrl?: string;
|
|
407
418
|
/** Disable the service provider even if keys are present. Default: false. */
|
|
408
419
|
disabled?: boolean;
|
|
409
420
|
};
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -135,6 +135,10 @@ const module$1 = defineNuxtModule({
|
|
|
135
135
|
// An explicit service.rootDocId still wins; /info discovery remains
|
|
136
136
|
// the last resort inside the service plugin when both are unset.
|
|
137
137
|
serviceRootDocId: options.service?.rootDocId ?? options.entryDocId ?? "",
|
|
138
|
+
// Internal/private origin for the SSR service runner. Empty → the
|
|
139
|
+
// runner falls back to the public `url` (single-origin deploys). Set it
|
|
140
|
+
// to split the runner off the browser origin (public HTTPS ↔ internal).
|
|
141
|
+
serviceServerUrl: options.service?.serverUrl ?? "",
|
|
138
142
|
serviceDisabled: options.service?.disabled ?? false
|
|
139
143
|
}
|
|
140
144
|
});
|
|
@@ -455,6 +455,9 @@ watchEffect((onCleanup) => {
|
|
|
455
455
|
};
|
|
456
456
|
function onUpdate({ transaction }) {
|
|
457
457
|
const isRemote = !!transaction?.getMeta?.("y-sync$")?.isChangeOrigin;
|
|
458
|
+
if (isRemote) {
|
|
459
|
+
deduplicateMetaFields(ed);
|
|
460
|
+
}
|
|
458
461
|
initDocumentMeta(ed);
|
|
459
462
|
if (isRemote || !initialSyncDone) {
|
|
460
463
|
if (headerTimer) {
|
|
@@ -12,8 +12,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
12
12
|
awareness: boolean;
|
|
13
13
|
tag: "video" | "audio";
|
|
14
14
|
live: boolean;
|
|
15
|
-
controls: boolean;
|
|
16
15
|
total: boolean;
|
|
16
|
+
controls: boolean;
|
|
17
17
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
18
18
|
declare const _default: typeof __VLS_export;
|
|
19
19
|
export default _default;
|
|
@@ -12,8 +12,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
12
12
|
awareness: boolean;
|
|
13
13
|
tag: "video" | "audio";
|
|
14
14
|
live: boolean;
|
|
15
|
-
controls: boolean;
|
|
16
15
|
total: boolean;
|
|
16
|
+
controls: boolean;
|
|
17
17
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
18
18
|
declare const _default: typeof __VLS_export;
|
|
19
19
|
export default _default;
|
|
@@ -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;
|
|
18
17
|
"open-settings": () => any;
|
|
19
18
|
"open-account": () => any;
|
|
19
|
+
logout: () => any;
|
|
20
20
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
21
|
-
onLogout?: (() => any) | undefined;
|
|
22
21
|
"onOpen-settings"?: (() => any) | undefined;
|
|
23
22
|
"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;
|
|
18
17
|
"open-settings": () => any;
|
|
19
18
|
"open-account": () => any;
|
|
19
|
+
logout: () => any;
|
|
20
20
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
21
|
-
onLogout?: (() => any) | undefined;
|
|
22
21
|
"onOpen-settings"?: (() => any) | undefined;
|
|
23
22
|
"onOpen-account"?: (() => any) | undefined;
|
|
23
|
+
onLogout?: (() => any) | undefined;
|
|
24
24
|
}>, {
|
|
25
25
|
color: string;
|
|
26
26
|
collapsed: boolean;
|
|
@@ -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];
|
|
@@ -10,9 +10,13 @@
|
|
|
10
10
|
* [1] Standard properties (from `META_FIELD_DEFINITIONS`)
|
|
11
11
|
*
|
|
12
12
|
* Items already present are marked with a check trailing icon. Schema fields
|
|
13
|
-
* focus the existing chip instead of duplicating
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* focus the existing chip instead of duplicating. Standard fields split by key:
|
|
14
|
+
* semantic fields write a CANONICAL universal-meta key (dateStart, taskProgress,
|
|
15
|
+
* color, icon, tags, geoLat…) so they are per-doc singletons — the menu focuses
|
|
16
|
+
* the existing chip and overlapping fields (e.g. Date vs Date Range on
|
|
17
|
+
* `dateStart`) block one another; generic fields (Slider, Select, Multi Select,
|
|
18
|
+
* Text Area) use a timestamped `_<type>_<ts>` key and keep inserting fresh
|
|
19
|
+
* multi-instance chips.
|
|
16
20
|
*
|
|
17
21
|
* Ported 1:1 from cou-sh/app/composables/useMetaMenuItems.ts.
|
|
18
22
|
*/
|
|
@@ -21,6 +21,13 @@ function collectPresentFields(editor) {
|
|
|
21
21
|
});
|
|
22
22
|
return present;
|
|
23
23
|
}
|
|
24
|
+
function canonicalKeysOf(o) {
|
|
25
|
+
const keys = [];
|
|
26
|
+
for (const v of [o.metaKey, o.startKey, o.endKey, o.latKey, o.lngKey, o.allDayKey]) {
|
|
27
|
+
if (typeof v === "string" && v && !v.startsWith("_")) keys.push(v);
|
|
28
|
+
}
|
|
29
|
+
return keys;
|
|
30
|
+
}
|
|
24
31
|
function schemaFieldKey(field) {
|
|
25
32
|
if (field.type === "daterange" || field.type === "timerange")
|
|
26
33
|
return `${field.type}:${String(field.startKey)}|${String(field.endKey)}`;
|
|
@@ -54,7 +61,7 @@ export function buildMetaMenuItems(editor) {
|
|
|
54
61
|
const configFields = storage?.configFields ?? [];
|
|
55
62
|
const present = collectPresentFields(editor);
|
|
56
63
|
const presentKeys = new Set(present.map(presentFieldKey));
|
|
57
|
-
const
|
|
64
|
+
const usedCanonicalKeys = new Set(present.flatMap(canonicalKeysOf));
|
|
58
65
|
const groups = [];
|
|
59
66
|
if (configFields.length) {
|
|
60
67
|
groups.push(configFields.map((f) => {
|
|
@@ -79,14 +86,15 @@ export function buildMetaMenuItems(editor) {
|
|
|
79
86
|
}
|
|
80
87
|
groups.push(META_FIELD_DEFINITIONS.map((def) => {
|
|
81
88
|
const sampleAttrs = def.buildAttrs();
|
|
82
|
-
const
|
|
83
|
-
const
|
|
89
|
+
const sampleKeys = canonicalKeysOf(sampleAttrs);
|
|
90
|
+
const already = sampleKeys.length > 0 && sampleKeys.some((k) => usedCanonicalKeys.has(k));
|
|
91
|
+
const existing = already ? present.find((p) => canonicalKeysOf(p).some((k) => sampleKeys.includes(k))) : void 0;
|
|
84
92
|
return {
|
|
85
93
|
label: def.label,
|
|
86
94
|
icon: def.icon,
|
|
87
95
|
trailingIcon: already ? "i-lucide-check" : void 0,
|
|
88
96
|
onSelect: () => {
|
|
89
|
-
if (already && existing
|
|
97
|
+
if (already && existing) {
|
|
90
98
|
focusExistingChip(editor, existing.pos);
|
|
91
99
|
return;
|
|
92
100
|
}
|
|
@@ -98,9 +106,6 @@ export function buildMetaMenuItems(editor) {
|
|
|
98
106
|
}));
|
|
99
107
|
return groups;
|
|
100
108
|
}
|
|
101
|
-
function isSingletonFieldType(fieldType) {
|
|
102
|
-
return fieldType === "rating" || fieldType === "icon" || fieldType === "colorPreset" || fieldType === "colorPicker" || fieldType === "members";
|
|
103
|
-
}
|
|
104
109
|
function isPopoverFieldType(fieldType) {
|
|
105
110
|
return fieldType === "colorPreset" || fieldType === "colorPicker" || fieldType === "icon" || fieldType === "location" || fieldType === "select" || fieldType === "multiselect" || fieldType === "members" || fieldType === "textarea" || fieldType === "date" || fieldType === "datetime" || fieldType === "time" || fieldType === "daterange" || fieldType === "datetimerange";
|
|
106
111
|
}
|
|
@@ -162,23 +162,19 @@ export const DocumentMeta = Node.create({
|
|
|
162
162
|
};
|
|
163
163
|
const seen = /* @__PURE__ */ new Set();
|
|
164
164
|
const mergedFields = [];
|
|
165
|
+
const consider = (child) => {
|
|
166
|
+
if (child?.type?.name !== "metaField") return;
|
|
167
|
+
const id = identityOf(child);
|
|
168
|
+
if (id && seen.has(id)) return;
|
|
169
|
+
if (id) seen.add(id);
|
|
170
|
+
mergedFields.push(child);
|
|
171
|
+
};
|
|
165
172
|
const collectFields = (source) => {
|
|
166
|
-
source.forEach?.((child) =>
|
|
167
|
-
if (child.type.name !== "metaField") return;
|
|
168
|
-
const id = identityOf(child);
|
|
169
|
-
if (!id || seen.has(id)) return;
|
|
170
|
-
seen.add(id);
|
|
171
|
-
mergedFields.push(child);
|
|
172
|
-
});
|
|
173
|
+
source.forEach?.((child) => consider(child));
|
|
173
174
|
};
|
|
174
175
|
if (canonicalMeta?.node) collectFields(canonicalMeta.node);
|
|
175
176
|
for (const m of metaExtras) collectFields(m.node);
|
|
176
|
-
for (const sf of strayMetaFields)
|
|
177
|
-
const id = identityOf(sf);
|
|
178
|
-
if (!id || seen.has(id)) continue;
|
|
179
|
-
seen.add(id);
|
|
180
|
-
mergedFields.push(sf);
|
|
181
|
-
}
|
|
177
|
+
for (const sf of strayMetaFields) consider(sf);
|
|
182
178
|
const metaNeedsRebuild = metaExtras.length > 0 || strayMetaFields.length > 0;
|
|
183
179
|
const repairedMeta = !metaNeedsRebuild && canonicalMeta?.node ? canonicalMeta.node : metaType.create(
|
|
184
180
|
null,
|
|
@@ -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);
|
|
@@ -10,7 +10,8 @@ import { useNodePanel } from "../../composables/useNodePanel";
|
|
|
10
10
|
import { useNodeContextMenu } from "../../composables/useNodeContextMenu";
|
|
11
11
|
import { useNodeViewEditable } from "../../composables/useNodeView";
|
|
12
12
|
import { useDocSlugs } from "../../composables/useDocSlugs";
|
|
13
|
-
import {
|
|
13
|
+
import { resolveDocIcon } from "../../utils/resolveDocIcon";
|
|
14
|
+
import { resolveDocColor } from "../../utils/resolveDocColor";
|
|
14
15
|
import ANodeContextMenu from "../../components/shell/ANodeContextMenu.vue";
|
|
15
16
|
import AModalShell from "../../components/AModalShell.vue";
|
|
16
17
|
const ANodePanel = defineAsyncComponent(() => import("../../components/ANodePanel.vue"));
|
|
@@ -38,7 +39,18 @@ const hostEditable = useNodeViewEditable(props);
|
|
|
38
39
|
const canWrite = hostEditable;
|
|
39
40
|
const treeEntry = computed(() => treeMap.data[docId.value]);
|
|
40
41
|
const exists = computed(() => !!treeEntry.value);
|
|
41
|
-
const
|
|
42
|
+
const icon = computed(
|
|
43
|
+
() => resolveDocIcon(treeEntry.value?.meta, treeEntry.value?.type, {
|
|
44
|
+
selfId: docId.value,
|
|
45
|
+
lookup: (id) => treeMap.data[id]
|
|
46
|
+
})
|
|
47
|
+
);
|
|
48
|
+
const iconColor = computed(
|
|
49
|
+
() => resolveDocColor(treeEntry.value?.meta, treeEntry.value?.type, {
|
|
50
|
+
selfId: docId.value,
|
|
51
|
+
lookup: (id) => treeMap.data[id]
|
|
52
|
+
})
|
|
53
|
+
);
|
|
42
54
|
const label = computed(() => treeEntry.value?.label || "Untitled");
|
|
43
55
|
const { openNodeId, openNodeLabel, openNodeProvider, openNode, closePanel } = useNodePanel(provider);
|
|
44
56
|
async function openAsWindow(id, title) {
|
|
@@ -122,28 +134,34 @@ const menuItems = computed(() => useNodeContextMenu({
|
|
|
122
134
|
v-if="exists"
|
|
123
135
|
:items="menuItems"
|
|
124
136
|
>
|
|
125
|
-
<
|
|
126
|
-
:icon="docType.icon"
|
|
137
|
+
<UButton
|
|
127
138
|
color="neutral"
|
|
128
|
-
variant="
|
|
129
|
-
size="
|
|
130
|
-
class="dl-
|
|
131
|
-
:class="{ 'dl-
|
|
139
|
+
variant="outline"
|
|
140
|
+
size="xs"
|
|
141
|
+
class="dl-btn cursor-pointer"
|
|
142
|
+
:class="{ 'dl-btn-selected': props.selected }"
|
|
132
143
|
@click="onClick"
|
|
133
144
|
>
|
|
145
|
+
<template #leading>
|
|
146
|
+
<UIcon
|
|
147
|
+
:name="icon"
|
|
148
|
+
class="size-4 shrink-0"
|
|
149
|
+
:style="iconColor ? { color: iconColor } : void 0"
|
|
150
|
+
/>
|
|
151
|
+
</template>
|
|
134
152
|
{{ label }}
|
|
135
|
-
</
|
|
153
|
+
</UButton>
|
|
136
154
|
</ANodeContextMenu>
|
|
137
|
-
<
|
|
155
|
+
<UButton
|
|
138
156
|
v-else
|
|
139
157
|
icon="i-lucide-file-x"
|
|
140
158
|
color="error"
|
|
141
159
|
variant="outline"
|
|
142
|
-
size="
|
|
143
|
-
class="dl-
|
|
160
|
+
size="xs"
|
|
161
|
+
class="dl-btn"
|
|
144
162
|
>
|
|
145
163
|
Missing document
|
|
146
|
-
</
|
|
164
|
+
</UButton>
|
|
147
165
|
|
|
148
166
|
<!-- Slide-over host: heavy panel mounts only while a link is open -->
|
|
149
167
|
<ANodePanel
|
|
@@ -189,5 +207,5 @@ const menuItems = computed(() => useNodeContextMenu({
|
|
|
189
207
|
</template>
|
|
190
208
|
|
|
191
209
|
<style scoped>
|
|
192
|
-
.dl-
|
|
210
|
+
.dl-btn{transition:background-color .12s ease,box-shadow .12s ease;vertical-align:baseline}.dl-btn-selected,:deep(.ProseMirror-selectednode) .dl-btn{box-shadow:0 0 0 2px var(--ui-primary)}
|
|
193
211
|
</style>
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
Time,
|
|
14
14
|
parseDate
|
|
15
15
|
} from "@internationalized/date";
|
|
16
|
+
import { DATE_SIBLING_KEY } from "../../utils/dateField";
|
|
16
17
|
const props = defineProps({
|
|
17
18
|
decorations: { type: Array, required: true },
|
|
18
19
|
selected: { type: Boolean, required: true },
|
|
@@ -69,6 +70,9 @@ const numMax = computed(() => props.node.attrs.sliderMax);
|
|
|
69
70
|
function getStr(key) {
|
|
70
71
|
return storage()?.pageMeta?.[key] ?? "";
|
|
71
72
|
}
|
|
73
|
+
function getDateStr(key) {
|
|
74
|
+
return getStr(key) || getStr(DATE_SIBLING_KEY[key] ?? "");
|
|
75
|
+
}
|
|
72
76
|
function getStrArr(key) {
|
|
73
77
|
const v = storage()?.pageMeta?.[key];
|
|
74
78
|
if (!v || !Array.isArray(v)) return [];
|
|
@@ -144,13 +148,13 @@ function timeToHHMM(t2) {
|
|
|
144
148
|
return `${String(t2.hour).padStart(2, "0")}:${String(t2.minute).padStart(2, "0")}`;
|
|
145
149
|
}
|
|
146
150
|
function getDateRange(sk, ek) {
|
|
147
|
-
const start = isoToCalendarDate(
|
|
148
|
-
const end = isoToCalendarDate(
|
|
151
|
+
const start = isoToCalendarDate(getDateStr(sk));
|
|
152
|
+
const end = isoToCalendarDate(getDateStr(ek));
|
|
149
153
|
return start && end ? { start, end } : void 0;
|
|
150
154
|
}
|
|
151
155
|
function formatDateRange(sk, ek) {
|
|
152
|
-
const startStr =
|
|
153
|
-
const endStr =
|
|
156
|
+
const startStr = getDateStr(sk).slice(0, 10);
|
|
157
|
+
const endStr = getDateStr(ek).slice(0, 10);
|
|
154
158
|
if (!startStr) return t.pickDate;
|
|
155
159
|
const sd = isoToCalendarDate(startStr);
|
|
156
160
|
if (!sd) return t.pickDate;
|
|
@@ -312,10 +316,14 @@ function deleteField() {
|
|
|
312
316
|
if (allDayKey.value) clearPatch[allDayKey.value] = void 0;
|
|
313
317
|
if (latKey.value) clearPatch[latKey.value] = void 0;
|
|
314
318
|
if (lngKey.value) clearPatch[lngKey.value] = void 0;
|
|
319
|
+
const mirror = fieldType.value === "colorPreset" || fieldType.value === "colorPicker" ? "color" : fieldType.value === "icon" ? "icon" : fieldType.value === "rating" ? "rating" : "";
|
|
320
|
+
if (mirror && mirror !== metaKey.value) clearPatch[mirror] = void 0;
|
|
315
321
|
if (Object.keys(clearPatch).length) patch(clearPatch);
|
|
316
322
|
const pos = props.getPos();
|
|
317
|
-
if (pos
|
|
318
|
-
|
|
323
|
+
if (typeof pos === "number") {
|
|
324
|
+
const live = props.editor.state.doc.nodeAt(pos);
|
|
325
|
+
const size = live && live.type.name === "metaField" ? live.nodeSize : 1;
|
|
326
|
+
props.editor.chain().deleteRange({ from: pos, to: pos + size }).run();
|
|
319
327
|
}
|
|
320
328
|
}
|
|
321
329
|
const isDragging = ref(false);
|
|
@@ -901,7 +909,7 @@ function removeOption(opt) {
|
|
|
901
909
|
>
|
|
902
910
|
<div class="flex items-center gap-2">
|
|
903
911
|
<UIcon
|
|
904
|
-
v-if="
|
|
912
|
+
v-if="selectChipLabel === opt"
|
|
905
913
|
name="i-lucide-check"
|
|
906
914
|
class="size-3.5 text-primary shrink-0"
|
|
907
915
|
/>
|
|
@@ -972,11 +980,11 @@ function removeOption(opt) {
|
|
|
972
980
|
v-for="opt in options"
|
|
973
981
|
:key="opt"
|
|
974
982
|
class="flex items-center justify-between px-3 py-1.5 hover:bg-(--ui-bg-elevated) cursor-pointer group"
|
|
975
|
-
@click="onMultiSelect(
|
|
983
|
+
@click="onMultiSelect(multiSelectChipValues.includes(opt) ? multiSelectChipValues.filter((v) => v !== opt) : [...multiSelectChipValues, opt])"
|
|
976
984
|
>
|
|
977
985
|
<div class="flex items-center gap-2">
|
|
978
986
|
<UIcon
|
|
979
|
-
v-if="
|
|
987
|
+
v-if="multiSelectChipValues.includes(opt)"
|
|
980
988
|
name="i-lucide-check"
|
|
981
989
|
class="size-3.5 text-primary shrink-0"
|
|
982
990
|
/>
|
|
@@ -1359,6 +1367,8 @@ function removeOption(opt) {
|
|
|
1359
1367
|
:text="justCopied ? t.copied : disabledValue"
|
|
1360
1368
|
:content="{ side: 'top' }"
|
|
1361
1369
|
:delay-duration="150"
|
|
1370
|
+
:open="justCopied ? true : void 0"
|
|
1371
|
+
:disable-closing-trigger="true"
|
|
1362
1372
|
>
|
|
1363
1373
|
<span
|
|
1364
1374
|
class="absolute inset-0 z-20 cursor-pointer"
|
|
@@ -93,7 +93,7 @@ export default defineNitroPlugin(async (nitroApp) => {
|
|
|
93
93
|
const explicitPrivKey = abraConfig?.servicePrivateKey ?? "";
|
|
94
94
|
const rootDocIdOverride = abraConfig?.serviceRootDocId ?? "";
|
|
95
95
|
const disabled = abraConfig?.serviceDisabled ?? false;
|
|
96
|
-
const serverUrl = config.public?.abracadabra?.url;
|
|
96
|
+
const serverUrl = abraConfig?.serviceServerUrl || config.public?.abracadabra?.url;
|
|
97
97
|
if (disabled) return;
|
|
98
98
|
if (!serverUrl) {
|
|
99
99
|
console.warn("[abracadabra-service] no abracadabra.url configured \u2014 service plugin disabled");
|
|
@@ -160,7 +160,7 @@ export default defineNitroPlugin(async (nitroApp) => {
|
|
|
160
160
|
let rootDocId = rootDocIdOverride;
|
|
161
161
|
if (!rootDocId) {
|
|
162
162
|
try {
|
|
163
|
-
const info = await $fetch(`${
|
|
163
|
+
const info = await $fetch(`${serverUrl}/info`);
|
|
164
164
|
rootDocId = info?.root_doc_id ?? "";
|
|
165
165
|
} catch {
|
|
166
166
|
}
|
|
@@ -202,6 +202,7 @@ export default defineNitroPlugin(async (nitroApp) => {
|
|
|
202
202
|
client,
|
|
203
203
|
wsp,
|
|
204
204
|
rootDoc,
|
|
205
|
+
rootDocId,
|
|
205
206
|
rootProvider,
|
|
206
207
|
storage: storage2,
|
|
207
208
|
docCache: createDocCacheAPI(rootDoc)
|
|
@@ -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 */
|
|
@@ -4,4 +4,29 @@ export interface MetaFieldDefinition {
|
|
|
4
4
|
kind: string;
|
|
5
5
|
buildAttrs: () => Record<string, unknown>;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Two classes of field, by design:
|
|
9
|
+
*
|
|
10
|
+
* 1. **Semantic / canonical** — the field maps to a key in the universal-meta
|
|
11
|
+
* registry (`@abraca/schema` → `universal-meta.ts`): `dateStart`,
|
|
12
|
+
* `datetimeStart`, `timeStart`, `taskProgress`, `tags`, `url`, `number`,
|
|
13
|
+
* `checked`, `rating`, `color`, `icon`, `members`, `geoLat`/`geoLng`. These
|
|
14
|
+
* write the CANONICAL key directly (never a `_<type>_<ts>` shadow) so every
|
|
15
|
+
* renderer, the tree, sorting, and the Markdown converter recognise the
|
|
16
|
+
* value. They are singletons per doc (one map position, one progress, one
|
|
17
|
+
* date) — the "Add property" menu focuses the existing chip instead of
|
|
18
|
+
* inserting a duplicate. Singleton-ness is detected purely by the key NOT
|
|
19
|
+
* starting with `_` (see useMetaMenuItems), which is why Progress
|
|
20
|
+
* (`taskProgress`) and generic Slider (`_slider_…`) can share fieldType
|
|
21
|
+
* `slider` yet behave differently.
|
|
22
|
+
*
|
|
23
|
+
* 2. **Generic / user-defined** — no universal meaning (plain Slider, Select,
|
|
24
|
+
* Multi Select, Text Area). These keep a per-instance `_<type>_<ts>` key so
|
|
25
|
+
* a doc can carry several, and they are intentionally NOT surfaced by
|
|
26
|
+
* renderers — they're free-form annotations.
|
|
27
|
+
*
|
|
28
|
+
* Do NOT give a semantic field a `_<type>_<ts>` key again: that's what made a
|
|
29
|
+
* hand-added "Progress"/"Date"/"Location" invisible to the renderers that read
|
|
30
|
+
* the canonical key.
|
|
31
|
+
*/
|
|
7
32
|
export declare const META_FIELD_DEFINITIONS: MetaFieldDefinition[];
|
|
@@ -3,69 +3,50 @@ export const META_FIELD_DEFINITIONS = [
|
|
|
3
3
|
label: "Date Range",
|
|
4
4
|
icon: "i-lucide-calendar-range",
|
|
5
5
|
kind: "metaFieldDate",
|
|
6
|
-
buildAttrs: () => {
|
|
7
|
-
const t = Date.now();
|
|
8
|
-
return { fieldType: "daterange", fieldLabel: "Date", userDefined: true, startKey: `_start_${t}`, endKey: `_end_${t}` };
|
|
9
|
-
}
|
|
6
|
+
buildAttrs: () => ({ fieldType: "daterange", fieldLabel: "Date", userDefined: true, startKey: "dateStart", endKey: "dateEnd" })
|
|
10
7
|
},
|
|
11
8
|
{
|
|
12
9
|
label: "Date & Time",
|
|
13
10
|
icon: "i-lucide-calendar-clock",
|
|
14
11
|
kind: "metaFieldDateTime",
|
|
15
|
-
buildAttrs: () => {
|
|
16
|
-
const t = Date.now();
|
|
17
|
-
return { fieldType: "datetimerange", fieldLabel: "Date & Time", userDefined: true, startKey: `_dtstart_${t}`, endKey: `_dtend_${t}`, allDayKey: `_allday_${t}` };
|
|
18
|
-
}
|
|
12
|
+
buildAttrs: () => ({ fieldType: "datetimerange", fieldLabel: "Date & Time", userDefined: true, startKey: "datetimeStart", endKey: "datetimeEnd", allDayKey: "allDay" })
|
|
19
13
|
},
|
|
20
14
|
{
|
|
21
15
|
label: "Date",
|
|
22
16
|
icon: "i-lucide-calendar",
|
|
23
17
|
kind: "metaFieldDateSingle",
|
|
24
|
-
buildAttrs: () => {
|
|
25
|
-
const t = Date.now();
|
|
26
|
-
return { fieldType: "date", fieldLabel: "Date", userDefined: true, metaKey: `_date_${t}` };
|
|
27
|
-
}
|
|
18
|
+
buildAttrs: () => ({ fieldType: "date", fieldLabel: "Date", userDefined: true, metaKey: "dateStart" })
|
|
28
19
|
},
|
|
29
20
|
{
|
|
30
21
|
label: "Datetime",
|
|
31
22
|
icon: "i-lucide-calendar-clock",
|
|
32
23
|
kind: "metaFieldDatetimeSingle",
|
|
33
|
-
buildAttrs: () => {
|
|
34
|
-
const t = Date.now();
|
|
35
|
-
return { fieldType: "datetime", fieldLabel: "Datetime", userDefined: true, metaKey: `_datetime_${t}` };
|
|
36
|
-
}
|
|
24
|
+
buildAttrs: () => ({ fieldType: "datetime", fieldLabel: "Datetime", userDefined: true, metaKey: "datetimeStart" })
|
|
37
25
|
},
|
|
38
26
|
{
|
|
39
27
|
label: "Time",
|
|
40
28
|
icon: "i-lucide-clock",
|
|
41
29
|
kind: "metaFieldTime",
|
|
42
|
-
buildAttrs: () => {
|
|
43
|
-
const t = Date.now();
|
|
44
|
-
return { fieldType: "time", fieldLabel: "Time", userDefined: true, metaKey: `_time_${t}` };
|
|
45
|
-
}
|
|
30
|
+
buildAttrs: () => ({ fieldType: "time", fieldLabel: "Time", userDefined: true, metaKey: "timeStart" })
|
|
46
31
|
},
|
|
47
32
|
{
|
|
48
33
|
label: "Time Range",
|
|
49
34
|
icon: "i-lucide-clock-4",
|
|
50
35
|
kind: "metaFieldTimeRange",
|
|
51
|
-
buildAttrs: () => {
|
|
52
|
-
const t = Date.now();
|
|
53
|
-
return { fieldType: "timerange", fieldLabel: "Time Range", userDefined: true, startKey: `_tstart_${t}`, endKey: `_tend_${t}` };
|
|
54
|
-
}
|
|
36
|
+
buildAttrs: () => ({ fieldType: "timerange", fieldLabel: "Time Range", userDefined: true, startKey: "timeStart", endKey: "timeEnd" })
|
|
55
37
|
},
|
|
56
38
|
{
|
|
57
39
|
label: "Number",
|
|
58
40
|
icon: "i-lucide-hash",
|
|
59
41
|
kind: "metaFieldNumber",
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return { fieldType: "number", fieldLabel: "Number", userDefined: true, metaKey: `_num_${t}` };
|
|
63
|
-
}
|
|
42
|
+
// Universal `number` (+ `unit`) key — sortable/visible as a first-class property.
|
|
43
|
+
buildAttrs: () => ({ fieldType: "number", fieldLabel: "Number", userDefined: true, metaKey: "number" })
|
|
64
44
|
},
|
|
65
45
|
{
|
|
66
46
|
label: "Slider",
|
|
67
47
|
icon: "i-lucide-sliders-horizontal",
|
|
68
48
|
kind: "metaFieldSlider",
|
|
49
|
+
// Generic, no universal meaning — keep a per-instance key so several can coexist.
|
|
69
50
|
buildAttrs: () => {
|
|
70
51
|
const t = Date.now();
|
|
71
52
|
return { fieldType: "slider", fieldLabel: "Slider", userDefined: true, metaKey: `_slider_${t}`, sliderMin: 0, sliderMax: 100 };
|
|
@@ -75,45 +56,42 @@ export const META_FIELD_DEFINITIONS = [
|
|
|
75
56
|
label: "Progress",
|
|
76
57
|
icon: "i-lucide-bar-chart-2",
|
|
77
58
|
kind: "metaFieldProgress",
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return { fieldType: "slider", fieldLabel: "Progress", userDefined: true, metaKey: `_progress_${t}`, sliderMin: 0, sliderMax: 100 };
|
|
81
|
-
}
|
|
59
|
+
// Universal `taskProgress` (0–100) — drives the tree progress bar, timeline, etc.
|
|
60
|
+
buildAttrs: () => ({ fieldType: "slider", fieldLabel: "Progress", userDefined: true, metaKey: "taskProgress", sliderMin: 0, sliderMax: 100 })
|
|
82
61
|
},
|
|
83
62
|
{
|
|
84
63
|
label: "Rating",
|
|
85
64
|
icon: "i-lucide-star",
|
|
86
65
|
kind: "metaFieldRating",
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return { fieldType: "rating", fieldLabel: "Rating", userDefined: true, metaKey: `_rating_${t}`, sliderMax: 5 };
|
|
90
|
-
}
|
|
66
|
+
// Universal `rating` meta key — visible everywhere rating is first-class.
|
|
67
|
+
buildAttrs: () => ({ fieldType: "rating", fieldLabel: "Rating", userDefined: true, metaKey: "rating", sliderMax: 5 })
|
|
91
68
|
},
|
|
92
69
|
{
|
|
93
70
|
label: "Toggle",
|
|
94
71
|
icon: "i-lucide-toggle-right",
|
|
95
72
|
kind: "metaFieldToggle",
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return { fieldType: "toggle", fieldLabel: "Toggle", userDefined: true, metaKey: `_toggle_${t}` };
|
|
99
|
-
}
|
|
73
|
+
// Universal `checked` boolean — the same flag checklist/kanban "done" reads.
|
|
74
|
+
buildAttrs: () => ({ fieldType: "toggle", fieldLabel: "Toggle", userDefined: true, metaKey: "checked" })
|
|
100
75
|
},
|
|
101
76
|
{
|
|
102
77
|
label: "Color Preset",
|
|
103
78
|
icon: "i-lucide-palette",
|
|
104
79
|
kind: "metaFieldColor",
|
|
80
|
+
// Uses the universal `color` meta key — DocumentTree, renderers, and
|
|
81
|
+
// getMetaColor() all read from meta.color for item styling.
|
|
105
82
|
buildAttrs: () => {
|
|
106
|
-
|
|
107
|
-
return { fieldType: "colorPreset", fieldLabel: "Color", userDefined: true, metaKey: `_color_${t}`, presets: JSON.stringify(["#6366f1", "#f97316", "#22c55e", "#ef4444", "#a855f7"]) };
|
|
83
|
+
return { fieldType: "colorPreset", fieldLabel: "Color", userDefined: true, metaKey: "color", presets: JSON.stringify(["#6366f1", "#f97316", "#22c55e", "#ef4444", "#a855f7"]) };
|
|
108
84
|
}
|
|
109
85
|
},
|
|
110
86
|
{
|
|
111
87
|
label: "Color Picker",
|
|
112
88
|
icon: "i-lucide-pipette",
|
|
113
89
|
kind: "metaFieldColorPicker",
|
|
90
|
+
// Also writes to the universal `color` key — adding Color Preset + Color
|
|
91
|
+
// Picker to the same doc is prevented by the "already added" marker in
|
|
92
|
+
// the property menus (keyed on fieldType).
|
|
114
93
|
buildAttrs: () => {
|
|
115
|
-
|
|
116
|
-
return { fieldType: "colorPicker", fieldLabel: "Color", userDefined: true, metaKey: `_cpick_${t}` };
|
|
94
|
+
return { fieldType: "colorPicker", fieldLabel: "Color", userDefined: true, metaKey: "color" };
|
|
117
95
|
}
|
|
118
96
|
},
|
|
119
97
|
{
|
|
@@ -138,19 +116,15 @@ export const META_FIELD_DEFINITIONS = [
|
|
|
138
116
|
label: "Tags",
|
|
139
117
|
icon: "i-lucide-tags",
|
|
140
118
|
kind: "metaFieldTags",
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return { fieldType: "tags", fieldLabel: "Tags", userDefined: true, metaKey: `_tags_${t}` };
|
|
144
|
-
}
|
|
119
|
+
// Universal `tags` array — the same tags the tree/kanban/sorting read.
|
|
120
|
+
buildAttrs: () => ({ fieldType: "tags", fieldLabel: "Tags", userDefined: true, metaKey: "tags" })
|
|
145
121
|
},
|
|
146
122
|
{
|
|
147
123
|
label: "URL",
|
|
148
124
|
icon: "i-lucide-link",
|
|
149
125
|
kind: "metaFieldUrl",
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return { fieldType: "url", fieldLabel: "URL", userDefined: true, metaKey: `_url_${t}` };
|
|
153
|
-
}
|
|
126
|
+
// Universal `url` key.
|
|
127
|
+
buildAttrs: () => ({ fieldType: "url", fieldLabel: "URL", userDefined: true, metaKey: "url" })
|
|
154
128
|
},
|
|
155
129
|
{
|
|
156
130
|
label: "Text Area",
|
|
@@ -165,27 +139,26 @@ export const META_FIELD_DEFINITIONS = [
|
|
|
165
139
|
label: "Location",
|
|
166
140
|
icon: "i-lucide-map-pin",
|
|
167
141
|
kind: "metaFieldLocation",
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
return { fieldType: "location", fieldLabel: "Location", userDefined: true, latKey: `_lat_${t}`, lngKey: `_lng_${t}` };
|
|
171
|
-
}
|
|
142
|
+
// Universal `geoLat`/`geoLng` — the same coords the Map renderer reads.
|
|
143
|
+
buildAttrs: () => ({ fieldType: "location", fieldLabel: "Location", userDefined: true, latKey: "geoLat", lngKey: "geoLng" })
|
|
172
144
|
},
|
|
173
145
|
{
|
|
174
146
|
label: "Icon",
|
|
175
147
|
icon: "i-lucide-smile",
|
|
176
148
|
kind: "metaFieldIcon",
|
|
149
|
+
// Uses the universal `icon` meta key — DocumentTree renders it as the
|
|
150
|
+
// document's tree icon when present.
|
|
177
151
|
buildAttrs: () => {
|
|
178
|
-
|
|
179
|
-
return { fieldType: "icon", fieldLabel: "Icon", userDefined: true, metaKey: `_icon_${t}` };
|
|
152
|
+
return { fieldType: "icon", fieldLabel: "Icon", userDefined: true, metaKey: "icon" };
|
|
180
153
|
}
|
|
181
154
|
},
|
|
182
155
|
{
|
|
183
156
|
label: "Members",
|
|
184
157
|
icon: "i-lucide-users",
|
|
185
158
|
kind: "metaFieldMembers",
|
|
159
|
+
// Uses the universal `members` meta key so mentions/avatars pick it up.
|
|
186
160
|
buildAttrs: () => {
|
|
187
|
-
|
|
188
|
-
return { fieldType: "members", fieldLabel: "Members", userDefined: true, metaKey: `_members_${t}` };
|
|
161
|
+
return { fieldType: "members", fieldLabel: "Members", userDefined: true, metaKey: "members" };
|
|
189
162
|
}
|
|
190
163
|
}
|
|
191
164
|
];
|
|
@@ -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
|
}
|