@abraca/nuxt 2.96.0 → 2.99.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.
Files changed (58) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/runtime/components/ADocSubPageList.vue +8 -0
  3. package/dist/runtime/components/ANodePanel.vue +11 -1
  4. package/dist/runtime/components/ANodePanelStack.d.vue.ts +19 -0
  5. package/dist/runtime/components/ANodePanelStack.vue +35 -0
  6. package/dist/runtime/components/ANodePanelStack.vue.d.ts +19 -0
  7. package/dist/runtime/components/APresence.d.vue.ts +1 -13
  8. package/dist/runtime/components/APresence.vue.d.ts +1 -13
  9. package/dist/runtime/components/ATagsPopover.d.vue.ts +34 -0
  10. package/dist/runtime/components/ATagsPopover.vue +114 -0
  11. package/dist/runtime/components/ATagsPopover.vue.d.ts +34 -0
  12. package/dist/runtime/components/aware/AMedia.d.vue.ts +1 -1
  13. package/dist/runtime/components/aware/AMedia.vue.d.ts +1 -1
  14. package/dist/runtime/components/chat/AChatMessages.d.vue.ts +14 -0
  15. package/dist/runtime/components/chat/AChatMessages.vue +94 -14
  16. package/dist/runtime/components/chat/AChatMessages.vue.d.ts +14 -0
  17. package/dist/runtime/components/chat/AChatPanel.d.vue.ts +10 -0
  18. package/dist/runtime/components/chat/AChatPanel.vue +5 -1
  19. package/dist/runtime/components/chat/AChatPanel.vue.d.ts +10 -0
  20. package/dist/runtime/components/chat/ANodeChatPanel.d.vue.ts +10 -3
  21. package/dist/runtime/components/chat/ANodeChatPanel.vue +6 -2
  22. package/dist/runtime/components/chat/ANodeChatPanel.vue.d.ts +10 -3
  23. package/dist/runtime/components/docs/ADocsSearch.d.vue.ts +2 -2
  24. package/dist/runtime/components/docs/ADocsSearch.vue.d.ts +2 -2
  25. package/dist/runtime/components/docs/ADocsSearchButton.d.vue.ts +1 -1
  26. package/dist/runtime/components/docs/ADocsSearchButton.vue.d.ts +1 -1
  27. package/dist/runtime/components/editor/ALocationPickerPopover.vue +6 -2
  28. package/dist/runtime/components/editor/AMetaChip.vue +18 -16
  29. package/dist/runtime/components/renderers/AMapRenderer.vue +3 -2
  30. package/dist/runtime/components/settings/ASettingsAboutPanel.d.vue.ts +3 -0
  31. package/dist/runtime/components/settings/ASettingsAboutPanel.vue +143 -0
  32. package/dist/runtime/components/settings/ASettingsAboutPanel.vue.d.ts +3 -0
  33. package/dist/runtime/components/settings/ASettingsConnectionPanel.vue +65 -100
  34. package/dist/runtime/components/settings/ASettingsModal.vue +7 -2
  35. package/dist/runtime/components/settings/sections.d.ts +28 -2
  36. package/dist/runtime/components/settings/sections.js +23 -0
  37. package/dist/runtime/composables/awarenessView.d.ts +46 -0
  38. package/dist/runtime/composables/awarenessView.js +65 -0
  39. package/dist/runtime/composables/useAwareness.js +19 -28
  40. package/dist/runtime/composables/useAwarenessPeers.d.ts +1 -25
  41. package/dist/runtime/composables/useChat.d.ts +21 -0
  42. package/dist/runtime/composables/useChat.js +77 -3
  43. package/dist/runtime/composables/useDocOpen.d.ts +69 -0
  44. package/dist/runtime/composables/useDocOpen.js +158 -0
  45. package/dist/runtime/composables/useRendererBase.d.ts +1 -25
  46. package/dist/runtime/composables/useSettingsModal.d.ts +1 -1
  47. package/dist/runtime/composables/useSpaceConnections.js +1 -60
  48. package/dist/runtime/composables/useYDoc.d.ts +3 -75
  49. package/dist/runtime/composables/useYDoc.js +28 -33
  50. package/dist/runtime/extensions/views/DocLinkView.vue +15 -5
  51. package/dist/runtime/extensions/views/MetaFieldView.vue +61 -49
  52. package/dist/runtime/locale.d.ts +2 -0
  53. package/dist/runtime/locale.js +1 -0
  54. package/dist/runtime/utils/mapboxToken.d.ts +7 -0
  55. package/dist/runtime/utils/mapboxToken.js +7 -0
  56. package/dist/runtime/utils/observeYMap.d.ts +44 -0
  57. package/dist/runtime/utils/observeYMap.js +86 -0
  58. package/package.json +5 -5
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=4.0.0"
6
6
  },
7
- "version": "2.96.0",
7
+ "version": "2.99.0",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
@@ -6,6 +6,7 @@ import { useAbracadabra } from "../composables/useAbracadabra";
6
6
  import { useChildTree } from "../composables/useChildTree";
7
7
  import { useDocSlugs } from "../composables/useDocSlugs";
8
8
  import { useNodePanel } from "../composables/useNodePanel";
9
+ import { useDocOpen } from "../composables/useDocOpen";
9
10
  import { useWindowManager } from "../composables/useWindowManager";
10
11
  import { useItemPresence, useViewingBroadcast } from "../composables/useItemPresence";
11
12
  import { useTreeExpansion } from "../composables/useTreeExpansion";
@@ -86,6 +87,7 @@ const {
86
87
  openNode,
87
88
  closePanel
88
89
  } = useNodePanel(provider);
90
+ const { onDocActivate, panelStackMounted } = useDocOpen();
89
91
  useViewingBroadcast(() => props.docId, openNodeId);
90
92
  const { getViewers: getDocViewers } = useItemPresence();
91
93
  function pageIcon(id, entry) {
@@ -125,6 +127,10 @@ function openFull(id, label) {
125
127
  router.push(getDocUrl(id));
126
128
  }
127
129
  function onItemActivate(e, id, label) {
130
+ if (panelStackMounted.value) {
131
+ onDocActivate(e, id, { label, onPlain: () => openFull(id, label) });
132
+ return;
133
+ }
128
134
  if (e.metaKey || e.ctrlKey) {
129
135
  openNode(id, label);
130
136
  return;
@@ -999,7 +1005,9 @@ const isDragActive = computed(() => tiptapDragActive.value || externalDragActive
999
1005
  </div>
1000
1006
  </Transition>
1001
1007
 
1008
+ <!-- Local fallback panel: only when the app has no shared <ANodePanelStack>. -->
1002
1009
  <ANodePanel
1010
+ v-if="!panelStackMounted"
1003
1011
  :node-id="openNodeId"
1004
1012
  :node-label="openNodeLabel"
1005
1013
  :child-provider="openNodeProvider"
@@ -10,6 +10,7 @@ import { useProviderRole } from "../composables/useProviderRole";
10
10
  import { provideRendererSurface } from "../composables/useRendererSurface";
11
11
  import { useAbraLocale } from "../composables/useAbraLocale";
12
12
  import { useDocSlugs } from "../composables/useDocSlugs";
13
+ import { useDocOpen } from "../composables/useDocOpen";
13
14
  import { useResizableWidth } from "../composables/useResizableWidth";
14
15
  import { useSlideoverSwipe } from "../composables/useSlideoverSwipe";
15
16
  import AConnectionBadge from "./AConnectionBadge.vue";
@@ -130,6 +131,15 @@ const toggleValue = computed(
130
131
  );
131
132
  const editorRef = ref(null);
132
133
  const tiptapEditor = computed(() => editorRef.value?.editor ?? null);
134
+ const { onDocActivate } = useDocOpen();
135
+ function onExpand(e) {
136
+ if (!props.nodeId) return;
137
+ const id = props.nodeId;
138
+ onDocActivate(e, id, {
139
+ label: resolvedLabel.value,
140
+ onPlain: () => navigateTo(hrefFor(id))
141
+ });
142
+ }
133
143
  const resize = useResizableWidth({
134
144
  defaultWidth: 672,
135
145
  minWidth: 320,
@@ -328,7 +338,7 @@ const addFieldMenuItems = computed(
328
338
  size="xs"
329
339
  color="neutral"
330
340
  variant="ghost"
331
- @click="nodeId && navigateTo(hrefFor(nodeId))"
341
+ @click="onExpand"
332
342
  />
333
343
  </UTooltip>
334
344
  <AConnectionBadge
@@ -0,0 +1,19 @@
1
+ import type { AbracadabraLocale } from '../locale.js';
2
+ type __VLS_Props = {
3
+ /** Tab each panel opens on. See `ANodePanel`. */
4
+ initialTab?: 'editor' | 'properties' | 'chat' | 'settings' | 'serverSettings' | string;
5
+ /** Built-in tabs to render. See `ANodePanel`. */
6
+ tabs?: Array<'editor' | 'properties' | 'chat' | 'settings' | 'serverSettings'>;
7
+ /** Build the "open as full page" URL. Defaults to the slug-aware doc URL. */
8
+ docHref?: (id: string) => string;
9
+ /** Whether panels may mutate their doc. Still gated per-doc by the child provider's role. */
10
+ editable?: boolean;
11
+ /** Whether the Chat tab requires write access. See `ANodePanel`. */
12
+ chatRequiresWrite?: boolean;
13
+ labels?: Partial<AbracadabraLocale['nodePanel']>;
14
+ };
15
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
16
+ editable: boolean;
17
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
18
+ declare const _default: typeof __VLS_export;
19
+ export default _default;
@@ -0,0 +1,35 @@
1
+ <script setup>
2
+ import { computed, onMounted, onBeforeUnmount } from "vue";
3
+ import { useDocOpen, registerNodePanelStack, unregisterNodePanelStack } from "../composables/useDocOpen";
4
+ const props = defineProps({
5
+ initialTab: { type: String, required: false },
6
+ tabs: { type: Array, required: false },
7
+ docHref: { type: Function, required: false },
8
+ editable: { type: Boolean, required: false, default: true },
9
+ chatRequiresWrite: { type: Boolean, required: false },
10
+ labels: { type: Object, required: false }
11
+ });
12
+ const { overlayStack, closeSlideoverAt } = useDocOpen();
13
+ onMounted(() => registerNodePanelStack());
14
+ onBeforeUnmount(() => unregisterNodePanelStack());
15
+ const panelProps = computed(() => ({
16
+ initialTab: props.initialTab,
17
+ tabs: props.tabs,
18
+ docHref: props.docHref,
19
+ editable: props.editable,
20
+ chatRequiresWrite: props.chatRequiresWrite,
21
+ labels: props.labels
22
+ }));
23
+ </script>
24
+
25
+ <template>
26
+ <ANodePanel
27
+ v-for="(entry, index) in overlayStack"
28
+ :key="entry.key"
29
+ v-bind="panelProps"
30
+ :node-id="entry.id"
31
+ :node-label="entry.label"
32
+ :child-provider="entry.provider"
33
+ @close="closeSlideoverAt(index)"
34
+ />
35
+ </template>
@@ -0,0 +1,19 @@
1
+ import type { AbracadabraLocale } from '../locale.js';
2
+ type __VLS_Props = {
3
+ /** Tab each panel opens on. See `ANodePanel`. */
4
+ initialTab?: 'editor' | 'properties' | 'chat' | 'settings' | 'serverSettings' | string;
5
+ /** Built-in tabs to render. See `ANodePanel`. */
6
+ tabs?: Array<'editor' | 'properties' | 'chat' | 'settings' | 'serverSettings'>;
7
+ /** Build the "open as full page" URL. Defaults to the slug-aware doc URL. */
8
+ docHref?: (id: string) => string;
9
+ /** Whether panels may mutate their doc. Still gated per-doc by the child provider's role. */
10
+ editable?: boolean;
11
+ /** Whether the Chat tab requires write access. See `ANodePanel`. */
12
+ chatRequiresWrite?: boolean;
13
+ labels?: Partial<AbracadabraLocale['nodePanel']>;
14
+ };
15
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
16
+ editable: boolean;
17
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
18
+ declare const _default: typeof __VLS_export;
19
+ export default _default;
@@ -11,19 +11,7 @@ declare function userAvatarStyle(user: AwarenessUser): string;
11
11
  declare var __VLS_1: {
12
12
  users: AwarenessUser[];
13
13
  overflow: number;
14
- currentUser: {
15
- [x: string]: any;
16
- clientId: number;
17
- user?: {
18
- name?: string | undefined;
19
- color?: string | undefined;
20
- avatar?: string | undefined;
21
- statusIcon?: string | undefined;
22
- statusText?: string | undefined;
23
- publicKey?: string | undefined;
24
- } | undefined;
25
- docId?: string | undefined;
26
- } | null;
14
+ currentUser: AwarenessUser | null;
27
15
  avatarStyle: typeof userAvatarStyle;
28
16
  }, __VLS_3: {
29
17
  user: AwarenessUser;
@@ -11,19 +11,7 @@ declare function userAvatarStyle(user: AwarenessUser): string;
11
11
  declare var __VLS_1: {
12
12
  users: AwarenessUser[];
13
13
  overflow: number;
14
- currentUser: {
15
- [x: string]: any;
16
- clientId: number;
17
- user?: {
18
- name?: string | undefined;
19
- color?: string | undefined;
20
- avatar?: string | undefined;
21
- statusIcon?: string | undefined;
22
- statusText?: string | undefined;
23
- publicKey?: string | undefined;
24
- } | undefined;
25
- docId?: string | undefined;
26
- } | null;
14
+ currentUser: AwarenessUser | null;
27
15
  avatarStyle: typeof userAvatarStyle;
28
16
  }, __VLS_3: {
29
17
  user: AwarenessUser;
@@ -0,0 +1,34 @@
1
+ type __VLS_Props = {
2
+ /** Current tags for the document. */
3
+ tags?: string[];
4
+ /** Heading inside the panel. */
5
+ title?: string;
6
+ /** Read-only: the panel never opens. */
7
+ disabled?: boolean;
8
+ /** Two-way open state, for a parent that drives it. */
9
+ open?: boolean;
10
+ };
11
+ declare var __VLS_8: {};
12
+ type __VLS_Slots = {} & {
13
+ default?: (props: typeof __VLS_8) => any;
14
+ };
15
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
16
+ "update:open": (v: boolean) => any;
17
+ save: (tags: string[]) => any;
18
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
19
+ "onUpdate:open"?: ((v: boolean) => any) | undefined;
20
+ onSave?: ((tags: string[]) => any) | undefined;
21
+ }>, {
22
+ title: string;
23
+ tags: string[];
24
+ disabled: boolean;
25
+ open: boolean;
26
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
27
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
28
+ declare const _default: typeof __VLS_export;
29
+ export default _default;
30
+ type __VLS_WithSlots<T, S> = T & {
31
+ new (): {
32
+ $slots: S;
33
+ };
34
+ };
@@ -0,0 +1,114 @@
1
+ <script setup>
2
+ import { computed, nextTick, ref, watch } from "vue";
3
+ const props = defineProps({
4
+ tags: { type: Array, required: false, default: () => [] },
5
+ title: { type: String, required: false, default: "Tags" },
6
+ disabled: { type: Boolean, required: false, default: false },
7
+ open: { type: Boolean, required: false, default: void 0 }
8
+ });
9
+ const emit = defineEmits(["update:open", "save"]);
10
+ const localOpen = ref(false);
11
+ const isOpen = computed({
12
+ get: () => props.open === void 0 ? localOpen.value : props.open,
13
+ set: (v) => {
14
+ localOpen.value = v;
15
+ emit("update:open", v);
16
+ }
17
+ });
18
+ const draft = ref("");
19
+ const inputEl = ref(null);
20
+ const list = computed(() => (props.tags ?? []).map((t) => String(t).trim()).filter(Boolean));
21
+ watch(isOpen, (v) => {
22
+ if (!v) {
23
+ draft.value = "";
24
+ return;
25
+ }
26
+ void nextTick(() => inputEl.value?.inputRef?.focus());
27
+ });
28
+ function commit(next) {
29
+ emit("save", Array.from(new Set(next.map((t) => t.trim()).filter(Boolean))));
30
+ }
31
+ function addDraft() {
32
+ const value = draft.value.trim();
33
+ draft.value = "";
34
+ if (!value) return;
35
+ const parts = value.split(",").map((t) => t.trim()).filter(Boolean);
36
+ if (!parts.length) return;
37
+ commit([...list.value, ...parts]);
38
+ }
39
+ function removeAt(tag) {
40
+ commit(list.value.filter((t) => t !== tag));
41
+ }
42
+ function onKeydown(e) {
43
+ if (e.key === "Enter" || e.key === ",") {
44
+ e.preventDefault();
45
+ addDraft();
46
+ return;
47
+ }
48
+ if (e.key === "Backspace") {
49
+ if (draft.value.length || !list.value.length) return;
50
+ e.preventDefault();
51
+ commit(list.value.slice(0, -1));
52
+ }
53
+ }
54
+ </script>
55
+
56
+ <template>
57
+ <UPopover
58
+ v-model:open="isOpen"
59
+ :content="{ align: 'start' }"
60
+ :disabled="disabled"
61
+ >
62
+ <slot />
63
+
64
+ <template #content>
65
+ <div class="p-2 w-72">
66
+ <p
67
+ v-if="title"
68
+ class="text-xs font-medium text-(--ui-text-muted) mb-1.5"
69
+ >
70
+ {{ title }}
71
+ </p>
72
+
73
+ <!-- The tags themselves. Each one removable where it sits, which is the
74
+ half a modal with a Save button made into a round trip. -->
75
+ <div
76
+ v-if="list.length"
77
+ class="flex flex-wrap gap-1 mb-2"
78
+ >
79
+ <span
80
+ v-for="tag in list"
81
+ :key="tag"
82
+ class="inline-flex items-center gap-1 h-6 pl-2 pr-1 text-xs rounded-md border border-(--ui-border) bg-(--ui-bg-elevated)"
83
+ >
84
+ <span class="max-w-32 truncate">{{ tag }}</span>
85
+ <UButton
86
+ size="xs"
87
+ color="neutral"
88
+ variant="ghost"
89
+ icon="i-lucide-x"
90
+ :aria-label="`Remove ${tag}`"
91
+ class="size-4 p-0"
92
+ @click="removeAt(tag)"
93
+ />
94
+ </span>
95
+ </div>
96
+
97
+ <UInput
98
+ ref="inputEl"
99
+ v-model="draft"
100
+ size="sm"
101
+ class="w-full"
102
+ :ui="{ root: 'w-full' }"
103
+ placeholder="Add a tag…"
104
+ @keydown="onKeydown"
105
+ @blur="addDraft"
106
+ />
107
+
108
+ <p class="mt-1.5 text-[11px] text-(--ui-text-dimmed)">
109
+ Enter or comma adds. Backspace removes the last.
110
+ </p>
111
+ </div>
112
+ </template>
113
+ </UPopover>
114
+ </template>
@@ -0,0 +1,34 @@
1
+ type __VLS_Props = {
2
+ /** Current tags for the document. */
3
+ tags?: string[];
4
+ /** Heading inside the panel. */
5
+ title?: string;
6
+ /** Read-only: the panel never opens. */
7
+ disabled?: boolean;
8
+ /** Two-way open state, for a parent that drives it. */
9
+ open?: boolean;
10
+ };
11
+ declare var __VLS_8: {};
12
+ type __VLS_Slots = {} & {
13
+ default?: (props: typeof __VLS_8) => any;
14
+ };
15
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
16
+ "update:open": (v: boolean) => any;
17
+ save: (tags: string[]) => any;
18
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
19
+ "onUpdate:open"?: ((v: boolean) => any) | undefined;
20
+ onSave?: ((tags: string[]) => any) | undefined;
21
+ }>, {
22
+ title: string;
23
+ tags: string[];
24
+ disabled: boolean;
25
+ open: boolean;
26
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
27
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
28
+ declare const _default: typeof __VLS_export;
29
+ export default _default;
30
+ type __VLS_WithSlots<T, S> = T & {
31
+ new (): {
32
+ $slots: S;
33
+ };
34
+ };
@@ -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;
@@ -8,6 +8,8 @@ export interface ChatMessage {
8
8
  readState?: string;
9
9
  /** Id of the message this one replies to (threaded reply). */
10
10
  replyTo?: string;
11
+ /** When the message was last edited, if ever. Renders the "(edited)" marker. */
12
+ editedAt?: number;
11
13
  }
12
14
  type __VLS_Props = {
13
15
  messages: ChatMessage[];
@@ -16,13 +18,24 @@ type __VLS_Props = {
16
18
  emptyIcon?: string;
17
19
  emptyText?: string;
18
20
  emptySubtext?: string;
21
+ /**
22
+ * Show edit/delete affordances on the current user's own messages. Off by
23
+ * default: the host has to be wired to `channel.edit`/`channel.remove` for
24
+ * the buttons to do anything, and the server refuses anyone but the sender
25
+ * (or an admin) regardless.
26
+ */
27
+ allowEdit?: boolean;
19
28
  };
20
29
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
30
+ delete: (messageId: string) => any;
21
31
  reply: (message: ChatMessage) => any;
32
+ edit: (messageId: string, content: string) => any;
22
33
  "open-doc": (docId: string) => any;
23
34
  "jump-to-quote": (docId: string, from: number, to: number) => any;
24
35
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
36
+ onDelete?: ((messageId: string) => any) | undefined;
25
37
  onReply?: ((message: ChatMessage) => any) | undefined;
38
+ onEdit?: ((messageId: string, content: string) => any) | undefined;
26
39
  "onOpen-doc"?: ((docId: string) => any) | undefined;
27
40
  "onJump-to-quote"?: ((docId: string, from: number, to: number) => any) | undefined;
28
41
  }>, {
@@ -30,6 +43,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
30
43
  currentUserId: string;
31
44
  emptyIcon: string;
32
45
  emptySubtext: string;
46
+ allowEdit: boolean;
33
47
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
34
48
  declare const _default: typeof __VLS_export;
35
49
  export default _default;
@@ -1,14 +1,34 @@
1
1
  <script setup>
2
- import { computed } from "vue";
2
+ import { computed, ref } from "vue";
3
3
  import { hasRichText, parseMessageContent, previewMessageContent, renderMessageSegments } from "../../utils/chatContent";
4
4
  const props = defineProps({
5
5
  messages: { type: Array, required: true },
6
6
  currentUserId: { type: String, required: false, default: "" },
7
7
  emptyIcon: { type: String, required: false, default: "i-lucide-message-circle" },
8
8
  emptyText: { type: String, required: false, default: "No messages yet" },
9
- emptySubtext: { type: String, required: false, default: "Be the first to send a message" }
9
+ emptySubtext: { type: String, required: false, default: "Be the first to send a message" },
10
+ allowEdit: { type: Boolean, required: false, default: false }
10
11
  });
11
- const emit = defineEmits(["open-doc", "jump-to-quote", "reply"]);
12
+ const emit = defineEmits(["open-doc", "jump-to-quote", "reply", "edit", "delete"]);
13
+ const editingId = ref(null);
14
+ const editDraft = ref("");
15
+ function startEdit(msg) {
16
+ editingId.value = msg.id;
17
+ editDraft.value = msg.content;
18
+ }
19
+ function cancelEdit() {
20
+ editingId.value = null;
21
+ editDraft.value = "";
22
+ }
23
+ function commitEdit(msg) {
24
+ const next = editDraft.value.trim();
25
+ if (!next) emit("delete", msg.id);
26
+ else if (next !== msg.content) emit("edit", msg.id, next);
27
+ cancelEdit();
28
+ }
29
+ function canEdit(msg) {
30
+ return props.allowEdit && isSelf(msg.senderId) && parseMessageContent(msg.content).kind === "text";
31
+ }
12
32
  const messageById = computed(() => {
13
33
  const map = /* @__PURE__ */ new Map();
14
34
  for (const m of props.messages) map.set(m.id, m);
@@ -84,17 +104,38 @@ function hasRichContent(text) {
84
104
  msg.isFirstInGroup ? '' : isSelf(msg.senderId) ? 'rounded-tr-sm' : 'rounded-tl-sm'
85
105
  ]"
86
106
  >
87
- <!-- Reply affordance — appears on hover -->
88
- <UButton
89
- icon="i-lucide-reply"
90
- size="xs"
91
- color="neutral"
92
- variant="ghost"
93
- class="absolute -top-2 opacity-0 group-hover:opacity-100 transition-opacity bg-(--ui-bg-elevated) ring-1 ring-(--ui-border)"
107
+ <!-- Hover affordances: reply always, edit/delete on your own prose -->
108
+ <div
109
+ class="absolute -top-2 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity bg-(--ui-bg-elevated) ring-1 ring-(--ui-border) rounded-md"
94
110
  :class="isSelf(msg.senderId) ? '-left-2' : '-right-2'"
95
- :aria-label="`Reply to ${msg.senderName}`"
96
- @click="emit('reply', msg)"
97
- />
111
+ >
112
+ <UButton
113
+ icon="i-lucide-reply"
114
+ size="xs"
115
+ color="neutral"
116
+ variant="ghost"
117
+ :aria-label="`Reply to ${msg.senderName}`"
118
+ @click="emit('reply', msg)"
119
+ />
120
+ <template v-if="canEdit(msg)">
121
+ <UButton
122
+ icon="i-lucide-pencil"
123
+ size="xs"
124
+ color="neutral"
125
+ variant="ghost"
126
+ aria-label="Edit message"
127
+ @click="startEdit(msg)"
128
+ />
129
+ <UButton
130
+ icon="i-lucide-trash-2"
131
+ size="xs"
132
+ color="neutral"
133
+ variant="ghost"
134
+ aria-label="Delete message"
135
+ @click="emit('delete', msg.id)"
136
+ />
137
+ </template>
138
+ </div>
98
139
 
99
140
  <!-- Quoted preview of the message being replied to -->
100
141
  <button
@@ -127,10 +168,49 @@ function hasRichContent(text) {
127
168
  <span class="text-[10px] text-(--ui-text-dimmed)">
128
169
  {{ formatTime(msg.createdAt) }}
129
170
  </span>
171
+ <span
172
+ v-if="msg.editedAt"
173
+ class="text-[10px] text-(--ui-text-dimmed) italic"
174
+ :title="`Edited ${formatTime(msg.editedAt)}`"
175
+ >(edited)</span>
176
+ </div>
177
+
178
+ <!-- Inline editor — replaces the bubble content while editing -->
179
+ <div
180
+ v-if="editingId === msg.id"
181
+ class="flex flex-col gap-1.5"
182
+ >
183
+ <UTextarea
184
+ v-model="editDraft"
185
+ autoresize
186
+ :rows="1"
187
+ size="sm"
188
+ autofocus
189
+ class="w-full"
190
+ :ui="{ root: 'w-full' }"
191
+ @keydown.enter.exact.prevent="commitEdit(msg)"
192
+ @keydown.esc.prevent="cancelEdit"
193
+ />
194
+ <div class="flex items-center gap-1.5">
195
+ <UButton
196
+ label="Save"
197
+ size="2xs"
198
+ color="primary"
199
+ @click="commitEdit(msg)"
200
+ />
201
+ <UButton
202
+ label="Cancel"
203
+ size="2xs"
204
+ color="neutral"
205
+ variant="ghost"
206
+ @click="cancelEdit"
207
+ />
208
+ <span class="text-[10px] text-(--ui-text-dimmed)">Enter to save · Esc to cancel · empty deletes</span>
209
+ </div>
130
210
  </div>
131
211
 
132
212
  <!-- Message content -->
133
- <template v-if="parseMessageContent(msg.content).kind === 'doc-quote'">
213
+ <template v-else-if="parseMessageContent(msg.content).kind === 'doc-quote'">
134
214
  <AChatDocQuote
135
215
  v-bind="parseMessageContent(msg.content)"
136
216
  :is-self="isSelf(msg.senderId)"
@@ -8,6 +8,8 @@ export interface ChatMessage {
8
8
  readState?: string;
9
9
  /** Id of the message this one replies to (threaded reply). */
10
10
  replyTo?: string;
11
+ /** When the message was last edited, if ever. Renders the "(edited)" marker. */
12
+ editedAt?: number;
11
13
  }
12
14
  type __VLS_Props = {
13
15
  messages: ChatMessage[];
@@ -16,13 +18,24 @@ type __VLS_Props = {
16
18
  emptyIcon?: string;
17
19
  emptyText?: string;
18
20
  emptySubtext?: string;
21
+ /**
22
+ * Show edit/delete affordances on the current user's own messages. Off by
23
+ * default: the host has to be wired to `channel.edit`/`channel.remove` for
24
+ * the buttons to do anything, and the server refuses anyone but the sender
25
+ * (or an admin) regardless.
26
+ */
27
+ allowEdit?: boolean;
19
28
  };
20
29
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
30
+ delete: (messageId: string) => any;
21
31
  reply: (message: ChatMessage) => any;
32
+ edit: (messageId: string, content: string) => any;
22
33
  "open-doc": (docId: string) => any;
23
34
  "jump-to-quote": (docId: string, from: number, to: number) => any;
24
35
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
36
+ onDelete?: ((messageId: string) => any) | undefined;
25
37
  onReply?: ((message: ChatMessage) => any) | undefined;
38
+ onEdit?: ((messageId: string, content: string) => any) | undefined;
26
39
  "onOpen-doc"?: ((docId: string) => any) | undefined;
27
40
  "onJump-to-quote"?: ((docId: string, from: number, to: number) => any) | undefined;
28
41
  }>, {
@@ -30,6 +43,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
30
43
  currentUserId: string;
31
44
  emptyIcon: string;
32
45
  emptySubtext: string;
46
+ allowEdit: boolean;
33
47
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
34
48
  declare const _default: typeof __VLS_export;
35
49
  export default _default;
@@ -17,6 +17,12 @@ type __VLS_Props = {
17
17
  currentUserId?: string;
18
18
  /** Whether the user can send messages */
19
19
  canSend?: boolean;
20
+ /**
21
+ * Offer edit/delete on the user's own messages. Off by default — the host
22
+ * must handle `@edit`/`@delete` (wire them to `useChatChannel().edit/remove`)
23
+ * for the affordances to do anything.
24
+ */
25
+ allowEdit?: boolean;
20
26
  /** Users currently typing */
21
27
  typingUsers?: TypingUser[];
22
28
  /** Active agent indicators */
@@ -53,9 +59,11 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
53
59
  focus: () => void | undefined;
54
60
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
55
61
  close: () => any;
62
+ delete: (messageId: string) => any;
56
63
  send: (content: string, opts?: {
57
64
  replyTo?: string;
58
65
  } | undefined) => any;
66
+ edit: (messageId: string, content: string) => any;
59
67
  "open-doc": (docId: string) => any;
60
68
  "jump-to-quote": (docId: string, from: number, to: number) => any;
61
69
  typing: () => any;
@@ -65,9 +73,11 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
65
73
  }) => any;
66
74
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
67
75
  onClose?: (() => any) | undefined;
76
+ onDelete?: ((messageId: string) => any) | undefined;
68
77
  onSend?: ((content: string, opts?: {
69
78
  replyTo?: string;
70
79
  } | undefined) => any) | undefined;
80
+ onEdit?: ((messageId: string, content: string) => any) | undefined;
71
81
  "onOpen-doc"?: ((docId: string) => any) | undefined;
72
82
  "onJump-to-quote"?: ((docId: string, from: number, to: number) => any) | undefined;
73
83
  onTyping?: (() => any) | undefined;