@abraca/nuxt 2.55.0 → 2.56.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/shell/AUserMenu.d.vue.ts +2 -2
- package/dist/runtime/components/shell/AUserMenu.vue.d.ts +2 -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/DocLinkView.vue +32 -14
- package/dist/runtime/extensions/views/MetaFieldView.vue +19 -9
- package/dist/runtime/server/plugins/abracadabra-service.js +2 -2
- package/dist/runtime/utils/metaFieldDefinitions.d.ts +25 -0
- package/dist/runtime/utils/metaFieldDefinitions.js +33 -60
- 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) {
|
|
@@ -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;
|
|
@@ -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,
|
|
@@ -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
|
}
|
|
@@ -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
|
];
|