@abraca/nuxt 2.48.0 → 2.50.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 +1 -1
- package/dist/module.mjs +6 -2
- package/dist/runtime/assets/editor.css +1 -1
- package/dist/runtime/components/ADocRenderer.d.vue.ts +10 -0
- package/dist/runtime/components/ADocRenderer.vue +23 -11
- package/dist/runtime/components/ADocRenderer.vue.d.ts +10 -0
- package/dist/runtime/components/AEditor.d.vue.ts +2 -2
- package/dist/runtime/components/AEditor.vue.d.ts +2 -2
- package/dist/runtime/components/ASubPageList.d.vue.ts +2 -2
- package/dist/runtime/components/ASubPageList.vue.d.ts +2 -2
- package/dist/runtime/components/editor/ANodeInlineLabel.vue +3 -2
- package/dist/runtime/components/renderers/AProseRenderer.d.vue.ts +2 -2
- package/dist/runtime/components/renderers/AProseRenderer.vue.d.ts +2 -2
- package/dist/runtime/composables/useNodeView.d.ts +36 -0
- package/dist/runtime/composables/useNodeView.js +46 -0
- package/dist/runtime/extensions/callout.js +13 -3
- package/dist/runtime/extensions/views/AccordionItemView.vue +64 -13
- package/dist/runtime/extensions/views/BadgeView.vue +125 -4
- package/dist/runtime/extensions/views/ButtonGroupView.vue +2 -2
- package/dist/runtime/extensions/views/ButtonView.vue +27 -0
- package/dist/runtime/extensions/views/CalloutView.vue +68 -11
- package/dist/runtime/extensions/views/CardGroupView.vue +2 -2
- package/dist/runtime/extensions/views/CardView.vue +150 -11
- package/dist/runtime/extensions/views/CodeCollapseView.vue +8 -3
- package/dist/runtime/extensions/views/CodeGroupView.vue +104 -15
- package/dist/runtime/extensions/views/CodePreviewView.vue +1 -1
- package/dist/runtime/extensions/views/CodeTreeView.vue +241 -20
- package/dist/runtime/extensions/views/CollapsibleView.vue +45 -13
- package/dist/runtime/extensions/views/ColorSwatchView.vue +17 -1
- package/dist/runtime/extensions/views/DiffView.vue +8 -1
- package/dist/runtime/extensions/views/DividerView.vue +9 -1
- package/dist/runtime/extensions/views/DocEmbedView.vue +15 -3
- package/dist/runtime/extensions/views/DocumentMetaView.vue +3 -1
- package/dist/runtime/extensions/views/EmbedView.vue +14 -1
- package/dist/runtime/extensions/views/FieldGroupView.vue +2 -2
- package/dist/runtime/extensions/views/FieldView.vue +16 -0
- package/dist/runtime/extensions/views/FigureView.vue +18 -1
- package/dist/runtime/extensions/views/KbdView.vue +72 -2
- package/dist/runtime/extensions/views/MathBlockView.vue +26 -0
- package/dist/runtime/extensions/views/MathInlineView.vue +18 -0
- package/dist/runtime/extensions/views/MetaFieldView.vue +3 -2
- package/dist/runtime/extensions/views/ProgressView.vue +13 -0
- package/dist/runtime/extensions/views/ProseIconView.vue +33 -2
- package/dist/runtime/extensions/views/QuoteView.vue +72 -47
- package/dist/runtime/extensions/views/SpoilerView.vue +17 -5
- package/dist/runtime/extensions/views/StatGroupView.vue +2 -2
- package/dist/runtime/extensions/views/StatView.vue +13 -3
- package/dist/runtime/extensions/views/StepsView.vue +25 -2
- package/dist/runtime/extensions/views/SvgEmbedView.vue +7 -2
- package/dist/runtime/extensions/views/TabsView.vue +142 -19
- package/dist/runtime/extensions/views/TimelineItemView.vue +19 -1
- package/dist/runtime/extensions/views/TimelineView.d.vue.ts +0 -5
- package/dist/runtime/extensions/views/TimelineView.vue.d.ts +0 -5
- package/dist/runtime/extensions/views/VideoView.vue +84 -8
- package/dist/runtime/utils/docTypes.d.ts +16 -0
- package/dist/runtime/utils/docTypes.js +4 -0
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import { ref, computed } from "vue";
|
|
2
3
|
import { NodeViewWrapper } from "@tiptap/vue-3";
|
|
3
|
-
import {
|
|
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
|
|
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
|
-
|
|
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-[
|
|
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="
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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-
|
|
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
|
-
<
|
|
84
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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 || "
|
|
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
|
-
<
|
|
44
|
+
<div
|
|
31
45
|
contenteditable="false"
|
|
32
|
-
class="
|
|
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
|
-
<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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-
|
|
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">
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { computed } from "vue";
|
|
3
3
|
import { NodeViewWrapper } from "@tiptap/vue-3";
|
|
4
4
|
import ANodeInlineLabel from "../../components/editor/ANodeInlineLabel.vue";
|
|
5
|
+
import { useNodeViewEditable } from "../../composables/useNodeView";
|
|
5
6
|
const props = defineProps({
|
|
6
7
|
decorations: { type: Array, required: true },
|
|
7
8
|
selected: { type: Boolean, required: true },
|
|
@@ -15,8 +16,10 @@ 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 label = computed(() => props.node.attrs.label || "");
|
|
19
21
|
function setLabel(v) {
|
|
22
|
+
if (!editable.value) return;
|
|
20
23
|
props.updateAttributes({ label: v });
|
|
21
24
|
}
|
|
22
25
|
</script>
|
|
@@ -29,12 +32,17 @@ function setLabel(v) {
|
|
|
29
32
|
>
|
|
30
33
|
<div class="flex-1 h-px bg-(--ui-border)" />
|
|
31
34
|
<ANodeInlineLabel
|
|
35
|
+
v-if="editable || label"
|
|
32
36
|
:model-value="label"
|
|
33
37
|
placeholder="Add label"
|
|
34
38
|
variant="label"
|
|
35
39
|
class="text-xs uppercase tracking-wider"
|
|
40
|
+
:disabled="!editable"
|
|
36
41
|
@update:model-value="setLabel"
|
|
37
42
|
/>
|
|
38
|
-
<div
|
|
43
|
+
<div
|
|
44
|
+
v-if="editable || label"
|
|
45
|
+
class="flex-1 h-px bg-(--ui-border)"
|
|
46
|
+
/>
|
|
39
47
|
</NodeViewWrapper>
|
|
40
48
|
</template>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import { useNodeViewEditable, persistAttrsQuietly } from "../../composables/useNodeView";
|
|
2
3
|
import { NodeViewWrapper } from "@tiptap/vue-3";
|
|
3
4
|
import { computed, ref, shallowRef, watch } from "vue";
|
|
4
5
|
import { navigateTo } from "#imports";
|
|
@@ -19,6 +20,7 @@ const props = defineProps({
|
|
|
19
20
|
extension: { type: Object, required: true },
|
|
20
21
|
HTMLAttributes: { type: Object, required: true }
|
|
21
22
|
});
|
|
23
|
+
const editable = useNodeViewEditable(props);
|
|
22
24
|
const { doc: rootDoc, provider } = useAbracadabra();
|
|
23
25
|
const { getDocUrl } = useDocSlugs();
|
|
24
26
|
const treeMap = useSyncedMap(
|
|
@@ -57,19 +59,27 @@ watch(
|
|
|
57
59
|
function navigate() {
|
|
58
60
|
navigateTo(getDocUrl(docId.value));
|
|
59
61
|
}
|
|
60
|
-
const collapsed =
|
|
62
|
+
const collapsed = ref(!!props.node.attrs.collapsed);
|
|
61
63
|
const tall = computed(() => props.node.attrs.tall);
|
|
62
64
|
const seamless = computed(() => props.node.attrs.seamless);
|
|
65
|
+
watch(() => props.node.attrs.collapsed, (v) => {
|
|
66
|
+
if (!editable.value) return;
|
|
67
|
+
collapsed.value = !!v;
|
|
68
|
+
});
|
|
63
69
|
function toggleCollapsed() {
|
|
64
|
-
|
|
70
|
+
collapsed.value = !collapsed.value;
|
|
71
|
+
if (editable.value) persistAttrsQuietly(props, { collapsed: collapsed.value });
|
|
65
72
|
}
|
|
66
73
|
function toggleHeight() {
|
|
74
|
+
if (!editable.value) return;
|
|
67
75
|
props.updateAttributes({ tall: !tall.value });
|
|
68
76
|
}
|
|
69
77
|
function toggleSeamless() {
|
|
78
|
+
if (!editable.value) return;
|
|
70
79
|
props.updateAttributes({ seamless: !seamless.value });
|
|
71
80
|
}
|
|
72
81
|
function removeEmbed() {
|
|
82
|
+
if (!editable.value) return;
|
|
73
83
|
props.deleteNode();
|
|
74
84
|
}
|
|
75
85
|
</script>
|
|
@@ -117,7 +127,7 @@ function removeEmbed() {
|
|
|
117
127
|
/>
|
|
118
128
|
</button>
|
|
119
129
|
<button
|
|
120
|
-
v-if="!seamless && !collapsed"
|
|
130
|
+
v-if="editable && !seamless && !collapsed"
|
|
121
131
|
class="de-ctrl-btn"
|
|
122
132
|
@click.stop="toggleHeight"
|
|
123
133
|
>
|
|
@@ -127,6 +137,7 @@ function removeEmbed() {
|
|
|
127
137
|
/>
|
|
128
138
|
</button>
|
|
129
139
|
<button
|
|
140
|
+
v-if="editable"
|
|
130
141
|
class="de-ctrl-btn"
|
|
131
142
|
@click.stop="toggleSeamless"
|
|
132
143
|
>
|
|
@@ -145,6 +156,7 @@ function removeEmbed() {
|
|
|
145
156
|
/>
|
|
146
157
|
</button>
|
|
147
158
|
<button
|
|
159
|
+
v-if="editable"
|
|
148
160
|
class="de-ctrl-btn de-ctrl-close"
|
|
149
161
|
@click.stop="removeEmbed"
|
|
150
162
|
>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed } from "vue";
|
|
3
|
+
import { useNodeViewEditable } from "../../composables/useNodeView";
|
|
3
4
|
import { NodeViewWrapper, NodeViewContent } from "@tiptap/vue-3";
|
|
4
5
|
import { buildMetaMenuItems } from "../../composables/useMetaMenuItems";
|
|
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 items = computed(() => {
|
|
19
21
|
void props.node.content.size;
|
|
20
22
|
return buildMetaMenuItems(props.editor);
|
|
@@ -67,7 +69,7 @@ function placeCursorInMeta(event) {
|
|
|
67
69
|
style="display: contents"
|
|
68
70
|
/>
|
|
69
71
|
<span
|
|
70
|
-
v-show="
|
|
72
|
+
v-show="editable"
|
|
71
73
|
contenteditable="false"
|
|
72
74
|
class="inline-flex items-center"
|
|
73
75
|
>
|