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