@abraca/nuxt 2.49.0 → 2.51.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 (62) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +6 -2
  3. package/dist/runtime/assets/editor.css +1 -1
  4. package/dist/runtime/components/ADocRenderer.d.vue.ts +10 -0
  5. package/dist/runtime/components/ADocRenderer.vue +23 -11
  6. package/dist/runtime/components/ADocRenderer.vue.d.ts +10 -0
  7. package/dist/runtime/components/AEditor.d.vue.ts +2 -2
  8. package/dist/runtime/components/AEditor.vue.d.ts +2 -2
  9. package/dist/runtime/components/ASubPageList.d.vue.ts +2 -2
  10. package/dist/runtime/components/ASubPageList.vue.d.ts +2 -2
  11. package/dist/runtime/components/aware/AMedia.d.vue.ts +1 -1
  12. package/dist/runtime/components/aware/AMedia.vue.d.ts +1 -1
  13. package/dist/runtime/components/editor/ANodeInlineLabel.vue +3 -2
  14. package/dist/runtime/components/renderers/AProseRenderer.d.vue.ts +2 -2
  15. package/dist/runtime/components/renderers/AProseRenderer.vue.d.ts +2 -2
  16. package/dist/runtime/composables/useNodeView.d.ts +36 -0
  17. package/dist/runtime/composables/useNodeView.js +46 -0
  18. package/dist/runtime/extensions/callout.js +13 -3
  19. package/dist/runtime/extensions/views/AccordionItemView.vue +64 -13
  20. package/dist/runtime/extensions/views/BadgeView.vue +125 -4
  21. package/dist/runtime/extensions/views/ButtonGroupView.vue +2 -2
  22. package/dist/runtime/extensions/views/ButtonView.vue +27 -0
  23. package/dist/runtime/extensions/views/CalloutView.vue +68 -11
  24. package/dist/runtime/extensions/views/CardGroupView.vue +2 -2
  25. package/dist/runtime/extensions/views/CardView.vue +150 -11
  26. package/dist/runtime/extensions/views/CodeCollapseView.vue +8 -3
  27. package/dist/runtime/extensions/views/CodeGroupView.vue +104 -15
  28. package/dist/runtime/extensions/views/CodePreviewView.vue +1 -1
  29. package/dist/runtime/extensions/views/CodeTreeView.vue +241 -20
  30. package/dist/runtime/extensions/views/CollapsibleView.vue +45 -13
  31. package/dist/runtime/extensions/views/ColorSwatchView.vue +17 -1
  32. package/dist/runtime/extensions/views/DiffView.vue +8 -1
  33. package/dist/runtime/extensions/views/DividerView.vue +9 -1
  34. package/dist/runtime/extensions/views/DocEmbedView.vue +15 -3
  35. package/dist/runtime/extensions/views/DocumentMetaView.vue +3 -1
  36. package/dist/runtime/extensions/views/EmbedView.vue +14 -1
  37. package/dist/runtime/extensions/views/FieldGroupView.vue +2 -2
  38. package/dist/runtime/extensions/views/FieldView.vue +16 -0
  39. package/dist/runtime/extensions/views/FigureView.vue +18 -1
  40. package/dist/runtime/extensions/views/KbdView.vue +72 -2
  41. package/dist/runtime/extensions/views/MathBlockView.vue +26 -0
  42. package/dist/runtime/extensions/views/MathInlineView.vue +18 -0
  43. package/dist/runtime/extensions/views/MetaFieldView.vue +3 -2
  44. package/dist/runtime/extensions/views/ProgressView.vue +13 -0
  45. package/dist/runtime/extensions/views/ProseIconView.vue +33 -2
  46. package/dist/runtime/extensions/views/QuoteView.vue +72 -47
  47. package/dist/runtime/extensions/views/SpoilerView.vue +17 -5
  48. package/dist/runtime/extensions/views/StatGroupView.vue +2 -2
  49. package/dist/runtime/extensions/views/StatView.vue +13 -3
  50. package/dist/runtime/extensions/views/StepsView.vue +25 -2
  51. package/dist/runtime/extensions/views/SvgEmbedView.vue +7 -2
  52. package/dist/runtime/extensions/views/TabsView.vue +142 -19
  53. package/dist/runtime/extensions/views/TimelineItemView.vue +19 -1
  54. package/dist/runtime/extensions/views/TimelineView.d.vue.ts +0 -5
  55. package/dist/runtime/extensions/views/TimelineView.vue.d.ts +0 -5
  56. package/dist/runtime/extensions/views/VideoView.vue +84 -8
  57. package/dist/runtime/server/utils/docCache.js +6 -3
  58. package/dist/runtime/server/utils/serverSchemaStubs.d.ts +9 -0
  59. package/dist/runtime/server/utils/serverSchemaStubs.js +41 -0
  60. package/dist/runtime/utils/docTypes.d.ts +16 -0
  61. package/dist/runtime/utils/docTypes.js +4 -0
  62. package/package.json +1 -1
@@ -1,6 +1,8 @@
1
1
  <script setup>
2
+ import { ref, computed, watch, nextTick } from "vue";
2
3
  import { NodeViewWrapper, NodeViewContent } from "@tiptap/vue-3";
3
- import { ref, computed, watch } from "vue";
4
+ import ANodeInlineLabel from "../../components/editor/ANodeInlineLabel.vue";
5
+ import { useNodeViewEditable, useNodeViewSelectionInside } from "../../composables/useNodeView";
4
6
  const props = defineProps({
5
7
  decorations: { type: Array, required: true },
6
8
  selected: { type: Boolean, required: true },
@@ -14,20 +16,70 @@ const props = defineProps({
14
16
  extension: { type: Object, required: true },
15
17
  HTMLAttributes: { type: Object, required: true }
16
18
  });
19
+ const editable = useNodeViewEditable(props);
17
20
  const activeIndex = ref(0);
18
21
  const tabs = computed(() => {
22
+ const parentPos = props.getPos();
19
23
  const result = [];
20
- props.node.forEach((child, _offset, index) => {
21
- const lang = child.attrs?.language || `Tab ${index + 1}`;
22
- result.push(lang);
24
+ if (parentPos === void 0) return result;
25
+ props.node.forEach((child, offset) => {
26
+ result.push({
27
+ label: child.attrs?.language || "",
28
+ pos: parentPos + 1 + offset
29
+ });
23
30
  });
24
31
  return result;
25
32
  });
26
- watch(() => props.node.childCount, () => {
27
- if (activeIndex.value >= props.node.childCount) {
28
- activeIndex.value = Math.max(0, props.node.childCount - 1);
33
+ watch(() => props.node.childCount, (next) => {
34
+ if (activeIndex.value >= next) {
35
+ activeIndex.value = Math.max(0, next - 1);
29
36
  }
30
37
  });
38
+ const panelsUid = `code-group-${Math.random().toString(36).slice(2, 10)}`;
39
+ const panelsCss = computed(
40
+ () => `[data-panels-uid="${panelsUid}"] > div > * { display: none; }[data-panels-uid="${panelsUid}"] > div > :nth-child(${activeIndex.value + 1}) { display: revert; }`
41
+ );
42
+ useNodeViewSelectionInside(props, (childIndex) => {
43
+ if (activeIndex.value !== childIndex) activeIndex.value = childIndex;
44
+ });
45
+ function setLanguage(childPos, v) {
46
+ if (!editable.value) return;
47
+ const tr = props.editor.state.tr;
48
+ tr.setNodeAttribute(childPos, "language", v);
49
+ props.editor.view.dispatch(tr);
50
+ }
51
+ function addBlock() {
52
+ if (!editable.value) return;
53
+ const pos = props.getPos();
54
+ if (pos === void 0) return;
55
+ const n = props.node;
56
+ const newIndex = n.childCount;
57
+ props.editor.chain().focus().insertContentAt(pos + n.nodeSize - 1, {
58
+ type: "codeBlock",
59
+ attrs: { language: `tab${newIndex + 1}` }
60
+ }).run();
61
+ nextTick(() => {
62
+ activeIndex.value = newIndex;
63
+ });
64
+ }
65
+ function removeBlock(index) {
66
+ if (!editable.value) return;
67
+ const parentPos = props.getPos();
68
+ if (parentPos === void 0) return;
69
+ if (props.node.childCount <= 1) return;
70
+ let target = null;
71
+ props.node.forEach((child, offset, i) => {
72
+ if (i === index) {
73
+ const from = parentPos + 1 + offset;
74
+ target = { from, to: from + child.nodeSize };
75
+ }
76
+ });
77
+ if (!target) return;
78
+ props.editor.chain().focus().deleteRange(target).run();
79
+ if (activeIndex.value >= index && activeIndex.value > 0) {
80
+ activeIndex.value = activeIndex.value - 1;
81
+ }
82
+ }
31
83
  </script>
32
84
 
33
85
  <template>
@@ -38,20 +90,57 @@ watch(() => props.node.childCount, () => {
38
90
  <div
39
91
  class="relative flex items-center gap-1 border border-(--ui-border-muted) bg-(--ui-bg) border-b-0 rounded-t-md overflow-x-auto p-2"
40
92
  contenteditable="false"
93
+ role="tablist"
41
94
  >
42
- <button
95
+ <div
43
96
  v-for="(tab, i) in tabs"
44
- :key="i"
45
- class="relative inline-flex items-center gap-1.5 px-2 py-1.5 text-sm rounded-md transition-colors"
97
+ :key="tab.pos"
98
+ class="group/tab relative inline-flex items-center gap-1 px-2 py-1.5 text-sm rounded-md transition-colors cursor-pointer"
46
99
  :class="activeIndex === i ? 'text-(--ui-text-highlighted) bg-(--ui-bg-elevated) shadow-xs' : 'text-(--ui-text) hover:bg-(--ui-bg-elevated)/50'"
100
+ role="tab"
101
+ :aria-selected="activeIndex === i"
47
102
  @click="activeIndex = i"
48
103
  >
49
- <span class="truncate">{{ tab }}</span>
104
+ <ANodeInlineLabel
105
+ :model-value="tab.label"
106
+ :placeholder="`tab${i + 1}`"
107
+ variant="label"
108
+ :disabled="!editable"
109
+ @update:model-value="(v) => setLanguage(tab.pos, v)"
110
+ />
111
+ <span
112
+ v-if="!editable && !tab.label"
113
+ class="text-(--ui-text-muted)"
114
+ >tab{{ i + 1 }}</span>
115
+ <button
116
+ v-if="editable && tabs.length > 1"
117
+ class="shrink-0 size-4 flex items-center justify-center rounded-sm text-(--ui-text-muted) hover:text-(--ui-error) opacity-0 group-hover/tab:opacity-100 transition-opacity"
118
+ title="Remove"
119
+ @click.stop="removeBlock(i)"
120
+ >
121
+ <UIcon
122
+ name="i-lucide-x"
123
+ class="size-3"
124
+ />
125
+ </button>
126
+ </div>
127
+ <button
128
+ v-if="editable"
129
+ class="shrink-0 size-7 flex items-center justify-center rounded-md text-(--ui-text-muted) hover:text-(--ui-text) hover:bg-(--ui-bg-elevated)"
130
+ title="Add code block"
131
+ @click="addBlock"
132
+ >
133
+ <UIcon
134
+ name="i-lucide-plus"
135
+ class="size-4"
136
+ />
50
137
  </button>
51
138
  </div>
52
- <NodeViewContent
53
- class="[&>*]:hidden [&>*]:!my-0 [&>*:first-child_pre]:rounded-t-none"
54
- :class="`[&>*:nth-child(${activeIndex + 1})]:block`"
55
- />
139
+ <div :data-panels-uid="panelsUid">
140
+ <component :is="'style'">
141
+ {{ panelsCss }}
142
+ </component>
143
+ <NodeViewContent class="[&>*]:!my-0 [&_pre]:rounded-t-none" />
144
+ </div>
56
145
  </NodeViewWrapper>
57
146
  </template>
@@ -1,6 +1,6 @@
1
1
  <script setup>
2
- import { NodeViewWrapper, NodeViewContent } from "@tiptap/vue-3";
3
2
  import { ref } from "vue";
3
+ import { NodeViewWrapper, NodeViewContent } from "@tiptap/vue-3";
4
4
  defineProps({
5
5
  decorations: { type: Array, required: true },
6
6
  selected: { type: Boolean, required: true },
@@ -1,6 +1,7 @@
1
1
  <script setup>
2
+ import { ref, computed } from "vue";
2
3
  import { NodeViewWrapper } from "@tiptap/vue-3";
3
- import { computed, ref } from "vue";
4
+ import { useNodeViewEditable } from "../../composables/useNodeView";
4
5
  const props = defineProps({
5
6
  decorations: { type: Array, required: true },
6
7
  selected: { type: Boolean, required: true },
@@ -14,6 +15,7 @@ const props = defineProps({
14
15
  extension: { type: Object, required: true },
15
16
  HTMLAttributes: { type: Object, required: true }
16
17
  });
18
+ const editable = useNodeViewEditable(props);
17
19
  const files = computed(() => {
18
20
  try {
19
21
  return JSON.parse(props.node.attrs.files || "[]");
@@ -21,7 +23,14 @@ const files = computed(() => {
21
23
  return [];
22
24
  }
23
25
  });
24
- const selected = ref("");
26
+ const selectedPath = ref("");
27
+ const editMode = ref(false);
28
+ const renameTarget = ref("");
29
+ const renameDraft = ref("");
30
+ function persist(next) {
31
+ if (!editable.value) return;
32
+ props.updateAttributes({ files: JSON.stringify(next) });
33
+ }
25
34
  function isFolder(entry) {
26
35
  return Array.isArray(entry.children);
27
36
  }
@@ -31,58 +40,270 @@ function getIcon(entry) {
31
40
  switch (ext) {
32
41
  case "ts":
33
42
  case "tsx":
34
- return "i-lucide-file-code";
35
43
  case "js":
36
44
  case "jsx":
37
- return "i-lucide-file-code";
38
45
  case "vue":
46
+ case "py":
47
+ case "rs":
48
+ case "go":
39
49
  return "i-lucide-file-code";
40
50
  case "json":
41
51
  return "i-lucide-file-json";
42
52
  case "md":
53
+ case "txt":
43
54
  return "i-lucide-file-text";
44
55
  case "css":
45
56
  case "scss":
46
57
  return "i-lucide-file-code";
58
+ case "png":
59
+ case "jpg":
60
+ case "jpeg":
61
+ case "svg":
62
+ case "gif":
63
+ return "i-lucide-image";
47
64
  default:
48
65
  return "i-lucide-file";
49
66
  }
50
67
  }
51
- function flatEntries(entries, depth = 0) {
68
+ function flatEntries(entries, depth = 0, prefix = "") {
52
69
  const result = [];
53
70
  for (const entry of entries) {
54
- result.push({ entry, depth });
71
+ const path = prefix ? `${prefix}/${entry.name}` : entry.name;
72
+ result.push({ entry, depth, path });
55
73
  if (isFolder(entry) && entry.children) {
56
- result.push(...flatEntries(entry.children, depth + 1));
74
+ result.push(...flatEntries(entry.children, depth + 1, path));
57
75
  }
58
76
  }
59
77
  return result;
60
78
  }
61
79
  const flatFiles = computed(() => flatEntries(files.value));
80
+ const selectedEntry = computed(() => {
81
+ const hit = flatFiles.value.find((f) => f.path === selectedPath.value);
82
+ return hit?.entry ?? null;
83
+ });
84
+ function cloneTree(tree) {
85
+ return tree.map((e) => ({
86
+ name: e.name,
87
+ ...e.children !== void 0 ? { children: cloneTree(e.children) } : {},
88
+ ...e.content !== void 0 ? { content: e.content } : {}
89
+ }));
90
+ }
91
+ function updateEntryAtPath(tree, path, updater) {
92
+ const parts = path.split("/");
93
+ const [head, ...rest] = parts;
94
+ const out = [];
95
+ for (const entry of tree) {
96
+ if (entry.name !== head) {
97
+ out.push(entry);
98
+ continue;
99
+ }
100
+ if (rest.length === 0) {
101
+ const updated = updater(entry);
102
+ if (updated !== null) out.push(updated);
103
+ } else if (entry.children) {
104
+ out.push({ ...entry, children: updateEntryAtPath(entry.children, rest.join("/"), updater) });
105
+ } else {
106
+ out.push(entry);
107
+ }
108
+ }
109
+ return out;
110
+ }
111
+ function addFile(parentPath, isDir) {
112
+ const suggestedName = isDir ? "new-folder" : "new-file.txt";
113
+ const newEntry = isDir ? { name: suggestedName, children: [] } : { name: suggestedName, content: "" };
114
+ if (!parentPath) {
115
+ persist([...cloneTree(files.value), newEntry]);
116
+ return;
117
+ }
118
+ const next = updateEntryAtPath(cloneTree(files.value), parentPath, (e) => {
119
+ if (!e.children) return e;
120
+ return { ...e, children: [...e.children, newEntry] };
121
+ });
122
+ persist(next);
123
+ }
124
+ function removeAt(path) {
125
+ const next = updateEntryAtPath(cloneTree(files.value), path, () => null);
126
+ persist(next);
127
+ if (selectedPath.value === path || selectedPath.value.startsWith(`${path}/`)) {
128
+ selectedPath.value = "";
129
+ }
130
+ }
131
+ function startRename(path, currentName) {
132
+ renameTarget.value = path;
133
+ renameDraft.value = currentName;
134
+ }
135
+ function commitRename(path) {
136
+ const newName = renameDraft.value.trim();
137
+ renameTarget.value = "";
138
+ if (!newName) return;
139
+ const next = updateEntryAtPath(cloneTree(files.value), path, (e) => ({ ...e, name: newName }));
140
+ persist(next);
141
+ if (selectedPath.value === path) {
142
+ const parts = path.split("/");
143
+ parts[parts.length - 1] = newName;
144
+ selectedPath.value = parts.join("/");
145
+ }
146
+ }
147
+ function setContent(path, content) {
148
+ const next = updateEntryAtPath(cloneTree(files.value), path, (e) => ({ ...e, content }));
149
+ persist(next);
150
+ }
62
151
  </script>
63
152
 
64
153
  <template>
65
154
  <NodeViewWrapper
66
155
  as="div"
67
- class="relative lg:h-[450px] my-5 grid lg:grid-cols-3 border border-(--ui-border-muted) rounded-md"
156
+ class="relative lg:h-[400px] my-5 grid lg:grid-cols-3 border border-(--ui-border-muted) rounded-md overflow-hidden"
68
157
  contenteditable="false"
69
158
  >
70
- <div class="isolate relative p-2 border-b lg:border-b-0 lg:border-e border-(--ui-border-muted) overflow-y-auto">
71
- <button
72
- v-for="{ entry, depth } in flatFiles"
73
- :key="entry.name + depth"
74
- class="relative w-full px-2.5 py-1.5 flex items-center gap-1.5 text-sm rounded-md text-left transition-colors"
75
- :class="selected === entry.name ? 'text-(--ui-text-highlighted) bg-(--ui-bg-elevated)' : 'text-(--ui-text) hover:text-(--ui-text-highlighted) hover:bg-(--ui-bg-elevated)/50'"
76
- :style="{ paddingLeft: `${depth * 18 + 10}px` }"
77
- @click="selected = entry.name"
159
+ <div class="relative p-2 border-b lg:border-b-0 lg:border-e border-(--ui-border-muted) overflow-y-auto bg-(--ui-bg-elevated)/40">
160
+ <div class="flex items-center justify-between mb-1 px-1">
161
+ <span class="text-xs font-medium text-(--ui-text-muted) uppercase tracking-wide">Files</span>
162
+ <div class="flex items-center gap-0.5">
163
+ <UButton
164
+ v-if="editable"
165
+ size="xs"
166
+ color="neutral"
167
+ variant="ghost"
168
+ :icon="editMode ? 'i-lucide-check' : 'i-lucide-pencil'"
169
+ :title="editMode ? 'Done' : 'Edit'"
170
+ @click="editMode = !editMode"
171
+ />
172
+ <UButton
173
+ v-if="editMode && editable"
174
+ size="xs"
175
+ color="neutral"
176
+ variant="ghost"
177
+ icon="i-lucide-file-plus"
178
+ title="Add file"
179
+ @click="addFile(null, false)"
180
+ />
181
+ <UButton
182
+ v-if="editMode && editable"
183
+ size="xs"
184
+ color="neutral"
185
+ variant="ghost"
186
+ icon="i-lucide-folder-plus"
187
+ title="Add folder"
188
+ @click="addFile(null, true)"
189
+ />
190
+ </div>
191
+ </div>
192
+ <div
193
+ v-if="flatFiles.length === 0"
194
+ class="text-xs text-(--ui-text-muted) px-2 py-4 text-center"
195
+ >
196
+ Empty. Enable edit mode to add files.
197
+ </div>
198
+ <div
199
+ v-for="{ entry, depth, path } in flatFiles"
200
+ :key="path"
201
+ class="group/row relative flex items-center gap-1.5 rounded-md transition-colors"
202
+ :class="selectedPath === path ? 'bg-(--ui-bg-elevated) text-(--ui-text-highlighted)' : 'hover:bg-(--ui-bg-elevated)/50 text-(--ui-text)'"
203
+ :style="{ paddingLeft: `${depth * 16 + 8}px`, paddingRight: '4px' }"
78
204
  >
79
205
  <UIcon
80
206
  :name="getIcon(entry)"
81
- class="size-4 shrink-0"
207
+ class="size-3.5 shrink-0"
208
+ />
209
+ <template v-if="renameTarget === path">
210
+ <input
211
+ v-model="renameDraft"
212
+ class="flex-1 text-sm py-1 bg-transparent outline-none focus:ring-1 focus:ring-(--ui-primary) rounded-sm px-1"
213
+ autofocus
214
+ @keydown.enter.prevent="commitRename(path)"
215
+ @keydown.escape="renameTarget = ''"
216
+ @blur="commitRename(path)"
217
+ >
218
+ </template>
219
+ <button
220
+ v-else
221
+ class="flex-1 text-left text-sm py-1 truncate"
222
+ @click="selectedPath = path"
223
+ @dblclick="editMode && startRename(path, entry.name)"
224
+ >
225
+ {{ entry.name }}
226
+ </button>
227
+ <div
228
+ v-if="editMode && editable"
229
+ class="flex items-center gap-0.5 opacity-0 group-hover/row:opacity-100 transition-opacity"
230
+ >
231
+ <button
232
+ v-if="isFolder(entry)"
233
+ class="size-5 flex items-center justify-center rounded-sm hover:bg-(--ui-bg-accented) text-(--ui-text-muted)"
234
+ title="Add file inside"
235
+ @click.stop="addFile(path, false)"
236
+ >
237
+ <UIcon
238
+ name="i-lucide-plus"
239
+ class="size-3"
240
+ />
241
+ </button>
242
+ <button
243
+ class="size-5 flex items-center justify-center rounded-sm hover:bg-(--ui-bg-accented) text-(--ui-text-muted)"
244
+ title="Rename"
245
+ @click.stop="startRename(path, entry.name)"
246
+ >
247
+ <UIcon
248
+ name="i-lucide-pencil"
249
+ class="size-3"
250
+ />
251
+ </button>
252
+ <button
253
+ class="size-5 flex items-center justify-center rounded-sm hover:bg-(--ui-bg-accented) text-(--ui-text-muted) hover:text-(--ui-error)"
254
+ title="Remove"
255
+ @click.stop="removeAt(path)"
256
+ >
257
+ <UIcon
258
+ name="i-lucide-x"
259
+ class="size-3"
260
+ />
261
+ </button>
262
+ </div>
263
+ </div>
264
+ </div>
265
+
266
+ <div class="lg:col-span-2 overflow-auto flex flex-col">
267
+ <div
268
+ v-if="!selectedEntry"
269
+ class="flex-1 flex items-center justify-center text-sm text-(--ui-text-muted)"
270
+ >
271
+ Select a file to view
272
+ </div>
273
+ <div
274
+ v-else-if="isFolder(selectedEntry)"
275
+ class="flex-1 flex items-center justify-center text-sm text-(--ui-text-muted) gap-2"
276
+ >
277
+ <UIcon
278
+ name="i-lucide-folder"
279
+ class="size-4"
280
+ />
281
+ {{ selectedEntry.name }}
282
+ </div>
283
+ <template v-else>
284
+ <div class="px-3 py-1.5 text-xs text-(--ui-text-muted) border-b border-(--ui-border-muted) flex items-center gap-1.5 bg-(--ui-bg-elevated)/30">
285
+ <UIcon
286
+ :name="getIcon(selectedEntry)"
287
+ class="size-3.5"
288
+ />
289
+ {{ selectedPath }}
290
+ </div>
291
+ <textarea
292
+ v-if="editMode && editable"
293
+ :value="selectedEntry.content || ''"
294
+ class="flex-1 p-3 font-mono text-sm bg-transparent outline-none resize-none text-(--ui-text) min-h-[200px]"
295
+ placeholder="File content…"
296
+ spellcheck="false"
297
+ @input="setContent(selectedPath, $event.target.value)"
82
298
  />
83
- <span class="truncate">{{ entry.name }}</span>
84
- </button>
299
+ <pre
300
+ v-else
301
+ class="flex-1 p-3 font-mono text-sm overflow-auto text-(--ui-text) whitespace-pre"
302
+ ><code v-if="selectedEntry.content">{{ selectedEntry.content }}</code><span
303
+ v-else
304
+ class="text-(--ui-text-muted) italic"
305
+ >Empty — enable edit mode to add content</span></pre>
306
+ </template>
85
307
  </div>
86
- <div class="lg:col-span-2 overflow-hidden flex flex-col" />
87
308
  </NodeViewWrapper>
88
309
  </template>
@@ -1,6 +1,8 @@
1
1
  <script setup>
2
+ import { ref, computed, watch } from "vue";
2
3
  import { NodeViewWrapper, NodeViewContent } from "@tiptap/vue-3";
3
- import { ref, computed } from "vue";
4
+ import ANodeInlineLabel from "../../components/editor/ANodeInlineLabel.vue";
5
+ import { useNodeViewEditable, useNodeViewSelectionInside, persistAttrsQuietly } from "../../composables/useNodeView";
4
6
  const props = defineProps({
5
7
  decorations: { type: Array, required: true },
6
8
  selected: { type: Boolean, required: true },
@@ -14,12 +16,24 @@ const props = defineProps({
14
16
  extension: { type: Object, required: true },
15
17
  HTMLAttributes: { type: Object, required: true }
16
18
  });
17
- const open = ref(props.node.attrs.open ?? false);
19
+ const editable = useNodeViewEditable(props);
20
+ const open = ref(!!props.node.attrs.open);
21
+ watch(() => props.node.attrs.open, (v) => {
22
+ if (!editable.value) return;
23
+ open.value = !!v;
24
+ });
25
+ useNodeViewSelectionInside(props, () => {
26
+ open.value = true;
27
+ });
18
28
  function toggleOpen() {
19
29
  open.value = !open.value;
20
- props.updateAttributes({ open: open.value });
30
+ if (editable.value) persistAttrsQuietly(props, { open: open.value });
31
+ }
32
+ function setLabel(v) {
33
+ if (!editable.value) return;
34
+ props.updateAttributes({ label: v });
21
35
  }
22
- const label = computed(() => props.node.attrs.label || "Details");
36
+ const label = computed(() => props.node.attrs.label || "");
23
37
  </script>
24
38
 
25
39
  <template>
@@ -27,18 +41,36 @@ const label = computed(() => props.node.attrs.label || "Details");
27
41
  as="div"
28
42
  class="my-5"
29
43
  >
30
- <button
44
+ <div
31
45
  contenteditable="false"
32
- class="group relative rounded-xs inline-flex items-center gap-1.5 text-(--ui-text-muted) hover:text-(--ui-text) text-sm transition-colors focus-visible:ring-2 focus-visible:ring-(--ui-primary) focus:outline-none"
46
+ class="inline-flex items-center gap-1.5 text-(--ui-text-muted) text-sm"
33
47
  :data-state="open ? 'open' : 'closed'"
34
- @click="toggleOpen"
35
48
  >
36
- <UIcon
37
- name="i-lucide-chevron-down"
38
- class="size-4 shrink-0 transition-transform duration-200 group-data-[state=open]:rotate-180"
39
- />
40
- <span class="truncate">{{ open ? "Hide" : "Show" }} {{ label }}</span>
41
- </button>
49
+ <button
50
+ class="group rounded-xs inline-flex items-center gap-1.5 hover:text-(--ui-text) transition-colors focus-visible:ring-2 focus-visible:ring-(--ui-primary) focus:outline-none"
51
+ :aria-expanded="open"
52
+ @click="toggleOpen"
53
+ >
54
+ <UIcon
55
+ name="i-lucide-chevron-down"
56
+ class="size-4 shrink-0 transition-transform duration-200"
57
+ :class="{ 'rotate-180': open }"
58
+ />
59
+ <span class="truncate">{{ open ? "Hide" : "Show" }}</span>
60
+ </button>
61
+ <span
62
+ :class="!editable ? 'cursor-pointer' : ''"
63
+ @click="editable ? void 0 : toggleOpen()"
64
+ >
65
+ <ANodeInlineLabel
66
+ :model-value="label"
67
+ placeholder="Details"
68
+ variant="label"
69
+ :disabled="!editable"
70
+ @update:model-value="setLabel"
71
+ />
72
+ </span>
73
+ </div>
42
74
  <div
43
75
  v-show="open"
44
76
  class="[&>*:first-child]:mt-2.5 [&>*:last-child]:mb-0 [&>*]:my-1.5"
@@ -1,6 +1,7 @@
1
1
  <script setup>
2
2
  import { ref, computed, watch } from "vue";
3
3
  import { NodeViewWrapper } from "@tiptap/vue-3";
4
+ import { useNodeViewEditable } from "../../composables/useNodeView";
4
5
  const props = defineProps({
5
6
  decorations: { type: Array, required: true },
6
7
  selected: { type: Boolean, required: true },
@@ -14,6 +15,7 @@ const props = defineProps({
14
15
  extension: { type: Object, required: true },
15
16
  HTMLAttributes: { type: Object, required: true }
16
17
  });
18
+ const editable = useNodeViewEditable(props);
17
19
  const PRESETS = [
18
20
  "#ef4444",
19
21
  "#f97316",
@@ -43,9 +45,10 @@ watch(popoverOpen, (open) => {
43
45
  if (open) draft.value = color.value;
44
46
  });
45
47
  function isValidHex(v) {
46
- return /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(v);
48
+ return /^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(v);
47
49
  }
48
50
  function commit(value) {
51
+ if (!editable.value) return;
49
52
  if (!isValidHex(value)) return;
50
53
  props.updateAttributes({ color: value });
51
54
  }
@@ -61,6 +64,7 @@ function selectPreset(hex) {
61
64
  popoverOpen.value = false;
62
65
  }
63
66
  function remove() {
67
+ if (!editable.value) return;
64
68
  const pos = props.getPos();
65
69
  if (pos === void 0) return;
66
70
  props.editor.chain().focus().deleteRange({ from: pos, to: pos + 1 }).run();
@@ -73,7 +77,19 @@ function remove() {
73
77
  as="span"
74
78
  class="inline"
75
79
  >
80
+ <span
81
+ v-if="!editable"
82
+ class="inline-flex align-middle items-center gap-1 px-1.5 py-0.5 rounded-full border border-(--ui-border) bg-(--ui-bg)"
83
+ :title="color"
84
+ >
85
+ <span
86
+ class="size-3 rounded-full border border-black/10"
87
+ :style="{ backgroundColor: color }"
88
+ />
89
+ <span class="text-xs font-mono text-(--ui-text)">{{ color }}</span>
90
+ </span>
76
91
  <UPopover
92
+ v-else
77
93
  v-model:open="popoverOpen"
78
94
  :content="{ align: 'start' }"
79
95
  >
@@ -1,5 +1,6 @@
1
1
  <script setup>
2
2
  import { ref, computed } from "vue";
3
+ import { useNodeViewEditable } from "../../composables/useNodeView";
3
4
  import { NodeViewWrapper } from "@tiptap/vue-3";
4
5
  import ANodeInlineLabel from "../../components/editor/ANodeInlineLabel.vue";
5
6
  const props = defineProps({
@@ -15,6 +16,7 @@ const props = defineProps({
15
16
  extension: { type: Object, required: true },
16
17
  HTMLAttributes: { type: Object, required: true }
17
18
  });
19
+ const editable = useNodeViewEditable(props);
18
20
  const before = computed(() => props.node.attrs.before || "");
19
21
  const after = computed(() => props.node.attrs.after || "");
20
22
  const language = computed(() => props.node.attrs.language || "text");
@@ -55,12 +57,15 @@ const diffLines = computed(() => lineDiff(before.value, after.value));
55
57
  const added = computed(() => diffLines.value.filter((d) => d.op === "add").length);
56
58
  const removed = computed(() => diffLines.value.filter((d) => d.op === "remove").length);
57
59
  function setBefore(v) {
60
+ if (!editable.value) return;
58
61
  props.updateAttributes({ before: v });
59
62
  }
60
63
  function setAfter(v) {
64
+ if (!editable.value) return;
61
65
  props.updateAttributes({ after: v });
62
66
  }
63
67
  function setLanguage(v) {
68
+ if (!editable.value) return;
64
69
  props.updateAttributes({ language: v.trim() || "text" });
65
70
  }
66
71
  </script>
@@ -81,6 +86,7 @@ function setLanguage(v) {
81
86
  :model-value="language"
82
87
  placeholder="text"
83
88
  variant="label"
89
+ :disabled="!editable"
84
90
  @update:model-value="setLanguage"
85
91
  />
86
92
  </div>
@@ -91,6 +97,7 @@ function setLanguage(v) {
91
97
  <span class="text-(--ui-error)">−{{ removed }}</span>
92
98
  </span>
93
99
  <UButton
100
+ v-if="editable"
94
101
  size="xs"
95
102
  color="neutral"
96
103
  variant="ghost"
@@ -101,7 +108,7 @@ function setLanguage(v) {
101
108
  </div>
102
109
  </div>
103
110
  <div
104
- v-if="editMode"
111
+ v-if="editMode && editable"
105
112
  class="grid grid-cols-1 md:grid-cols-2 divide-y md:divide-y-0 md:divide-x divide-(--ui-border-muted)"
106
113
  >
107
114
  <div class="flex flex-col">