@abraca/nuxt 2.49.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
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { ref, computed, watch } from "vue";
|
|
3
3
|
import { NodeViewWrapper, NodeViewContent } 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,25 +16,31 @@ 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 author = computed(() => props.node.attrs.author || "");
|
|
19
21
|
const role = computed(() => props.node.attrs.role || "");
|
|
20
22
|
const avatar = computed(() => props.node.attrs.avatar || "");
|
|
23
|
+
const hasAttribution = computed(() => !!(author.value || role.value || avatar.value));
|
|
21
24
|
const avatarPopoverOpen = ref(false);
|
|
22
25
|
const avatarDraft = ref("");
|
|
23
26
|
watch(avatarPopoverOpen, (open) => {
|
|
24
27
|
if (open) avatarDraft.value = avatar.value;
|
|
25
28
|
});
|
|
26
29
|
function setAuthor(v) {
|
|
30
|
+
if (!editable.value) return;
|
|
27
31
|
props.updateAttributes({ author: v });
|
|
28
32
|
}
|
|
29
33
|
function setRole(v) {
|
|
34
|
+
if (!editable.value) return;
|
|
30
35
|
props.updateAttributes({ role: v });
|
|
31
36
|
}
|
|
32
37
|
function saveAvatar() {
|
|
38
|
+
if (!editable.value) return;
|
|
33
39
|
props.updateAttributes({ avatar: avatarDraft.value.trim() });
|
|
34
40
|
avatarPopoverOpen.value = false;
|
|
35
41
|
}
|
|
36
42
|
function clearAvatar() {
|
|
43
|
+
if (!editable.value) return;
|
|
37
44
|
props.updateAttributes({ avatar: "" });
|
|
38
45
|
avatarPopoverOpen.value = false;
|
|
39
46
|
}
|
|
@@ -54,71 +61,89 @@ function onAvatarKeydown(e) {
|
|
|
54
61
|
<NodeViewContent />
|
|
55
62
|
</div>
|
|
56
63
|
<div
|
|
64
|
+
v-if="editable || hasAttribution"
|
|
57
65
|
class="mt-3 flex items-center gap-2.5"
|
|
58
66
|
contenteditable="false"
|
|
59
67
|
>
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
<button
|
|
65
|
-
class="shrink-0 size-8 rounded-full overflow-hidden border border-(--ui-border) bg-(--ui-bg-elevated) flex items-center justify-center text-(--ui-text-muted) hover:border-(--ui-border-accented) transition-colors"
|
|
66
|
-
type="button"
|
|
67
|
-
:title="avatar ? 'Change avatar' : 'Add avatar'"
|
|
68
|
+
<template v-if="editable">
|
|
69
|
+
<UPopover
|
|
70
|
+
v-model:open="avatarPopoverOpen"
|
|
71
|
+
:content="{ align: 'start' }"
|
|
68
72
|
>
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
alt=""
|
|
73
|
+
<button
|
|
74
|
+
class="shrink-0 size-8 rounded-full overflow-hidden border border-(--ui-border) bg-(--ui-bg-elevated) flex items-center justify-center text-(--ui-text-muted) hover:border-(--ui-border-accented) transition-colors"
|
|
75
|
+
type="button"
|
|
76
|
+
:title="avatar ? 'Change avatar' : 'Add avatar'"
|
|
74
77
|
>
|
|
75
|
-
|
|
76
|
-
v-else
|
|
77
|
-
name="i-lucide-user"
|
|
78
|
-
class="size-4"
|
|
79
|
-
/>
|
|
80
|
-
</button>
|
|
81
|
-
<template #content>
|
|
82
|
-
<div class="p-2 w-80 flex items-center gap-1">
|
|
83
|
-
<UInput
|
|
84
|
-
v-model="avatarDraft"
|
|
85
|
-
autofocus
|
|
86
|
-
size="sm"
|
|
87
|
-
placeholder="Avatar URL"
|
|
88
|
-
icon="i-lucide-image"
|
|
89
|
-
class="flex-1"
|
|
90
|
-
@keydown="onAvatarKeydown"
|
|
91
|
-
/>
|
|
92
|
-
<UButton
|
|
93
|
-
size="sm"
|
|
94
|
-
variant="ghost"
|
|
95
|
-
icon="i-lucide-check"
|
|
96
|
-
:disabled="!avatarDraft.trim()"
|
|
97
|
-
@click="saveAvatar"
|
|
98
|
-
/>
|
|
99
|
-
<UButton
|
|
78
|
+
<img
|
|
100
79
|
v-if="avatar"
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
80
|
+
:src="avatar"
|
|
81
|
+
class="size-full object-cover"
|
|
82
|
+
alt=""
|
|
83
|
+
>
|
|
84
|
+
<UIcon
|
|
85
|
+
v-else
|
|
86
|
+
name="i-lucide-user"
|
|
87
|
+
class="size-4"
|
|
106
88
|
/>
|
|
107
|
-
</
|
|
108
|
-
|
|
109
|
-
|
|
89
|
+
</button>
|
|
90
|
+
<template #content>
|
|
91
|
+
<div class="p-2 w-80 flex items-center gap-1">
|
|
92
|
+
<UInput
|
|
93
|
+
v-model="avatarDraft"
|
|
94
|
+
autofocus
|
|
95
|
+
size="sm"
|
|
96
|
+
placeholder="Avatar URL"
|
|
97
|
+
icon="i-lucide-image"
|
|
98
|
+
class="flex-1"
|
|
99
|
+
@keydown="onAvatarKeydown"
|
|
100
|
+
/>
|
|
101
|
+
<UButton
|
|
102
|
+
size="sm"
|
|
103
|
+
variant="ghost"
|
|
104
|
+
icon="i-lucide-check"
|
|
105
|
+
:disabled="!avatarDraft.trim()"
|
|
106
|
+
@click="saveAvatar"
|
|
107
|
+
/>
|
|
108
|
+
<UButton
|
|
109
|
+
v-if="avatar"
|
|
110
|
+
size="sm"
|
|
111
|
+
variant="ghost"
|
|
112
|
+
color="neutral"
|
|
113
|
+
icon="i-lucide-trash"
|
|
114
|
+
@click="clearAvatar"
|
|
115
|
+
/>
|
|
116
|
+
</div>
|
|
117
|
+
</template>
|
|
118
|
+
</UPopover>
|
|
119
|
+
</template>
|
|
120
|
+
<span
|
|
121
|
+
v-else-if="avatar"
|
|
122
|
+
class="shrink-0 size-8 rounded-full overflow-hidden border border-(--ui-border) bg-(--ui-bg-elevated) flex items-center justify-center"
|
|
123
|
+
>
|
|
124
|
+
<img
|
|
125
|
+
:src="avatar"
|
|
126
|
+
class="size-full object-cover"
|
|
127
|
+
alt=""
|
|
128
|
+
>
|
|
129
|
+
</span>
|
|
110
130
|
<div class="flex flex-col text-sm leading-tight">
|
|
111
131
|
<ANodeInlineLabel
|
|
112
132
|
:model-value="author"
|
|
113
133
|
placeholder="Author"
|
|
114
134
|
variant="title"
|
|
135
|
+
:disabled="!editable"
|
|
115
136
|
@update:model-value="setAuthor"
|
|
116
137
|
/>
|
|
117
|
-
<div
|
|
138
|
+
<div
|
|
139
|
+
v-if="editable || role"
|
|
140
|
+
class="text-xs text-(--ui-text-muted)"
|
|
141
|
+
>
|
|
118
142
|
<ANodeInlineLabel
|
|
119
143
|
:model-value="role"
|
|
120
144
|
placeholder="Role"
|
|
121
145
|
variant="label"
|
|
146
|
+
:disabled="!editable"
|
|
122
147
|
@update:model-value="setRole"
|
|
123
148
|
/>
|
|
124
149
|
</div>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed } from "vue";
|
|
2
|
+
import { ref, computed } from "vue";
|
|
3
3
|
import { NodeViewWrapper, NodeViewContent } from "@tiptap/vue-3";
|
|
4
4
|
import ANodeInlineLabel from "../../components/editor/ANodeInlineLabel.vue";
|
|
5
|
+
import { useNodeViewEditable, useNodeViewSelectionInside, persistAttrsQuietly } from "../../composables/useNodeView";
|
|
5
6
|
const props = defineProps({
|
|
6
7
|
decorations: { type: Array, required: true },
|
|
7
8
|
selected: { type: Boolean, required: true },
|
|
@@ -15,14 +16,20 @@ const props = defineProps({
|
|
|
15
16
|
extension: { type: Object, required: true },
|
|
16
17
|
HTMLAttributes: { type: Object, required: true }
|
|
17
18
|
});
|
|
18
|
-
const
|
|
19
|
-
const revealed =
|
|
19
|
+
const editable = useNodeViewEditable(props);
|
|
20
|
+
const revealed = ref(!!props.node.attrs.revealed);
|
|
21
|
+
useNodeViewSelectionInside(props, () => {
|
|
22
|
+
revealed.value = true;
|
|
23
|
+
});
|
|
20
24
|
function toggle() {
|
|
21
|
-
|
|
25
|
+
revealed.value = !revealed.value;
|
|
26
|
+
if (editable.value) persistAttrsQuietly(props, { revealed: revealed.value });
|
|
22
27
|
}
|
|
23
28
|
function setLabel(v) {
|
|
29
|
+
if (!editable.value) return;
|
|
24
30
|
props.updateAttributes({ label: v });
|
|
25
31
|
}
|
|
32
|
+
const label = computed(() => props.node.attrs.label || "");
|
|
26
33
|
</script>
|
|
27
34
|
|
|
28
35
|
<template>
|
|
@@ -40,11 +47,15 @@ function setLabel(v) {
|
|
|
40
47
|
:name="revealed ? 'i-lucide-eye' : 'i-lucide-eye-off'"
|
|
41
48
|
class="size-4 shrink-0"
|
|
42
49
|
/>
|
|
43
|
-
<span
|
|
50
|
+
<span
|
|
51
|
+
class="flex-1"
|
|
52
|
+
@click.stop="editable ? void 0 : toggle()"
|
|
53
|
+
>
|
|
44
54
|
<ANodeInlineLabel
|
|
45
55
|
:model-value="label"
|
|
46
56
|
placeholder="Spoiler"
|
|
47
57
|
variant="label"
|
|
58
|
+
:disabled="!editable"
|
|
48
59
|
@update:model-value="setLabel"
|
|
49
60
|
/>
|
|
50
61
|
</span>
|
|
@@ -55,6 +66,7 @@ function setLabel(v) {
|
|
|
55
66
|
<div
|
|
56
67
|
class="px-3 py-2 transition-all"
|
|
57
68
|
:class="revealed ? '' : 'blur-md select-none pointer-events-none'"
|
|
69
|
+
:aria-hidden="!revealed"
|
|
58
70
|
>
|
|
59
71
|
<NodeViewContent class="[&>*:first-child]:mt-0 [&>*:last-child]:mb-0" />
|
|
60
72
|
</div>
|
|
@@ -18,8 +18,8 @@ defineProps({
|
|
|
18
18
|
<template>
|
|
19
19
|
<NodeViewWrapper
|
|
20
20
|
as="div"
|
|
21
|
-
class="my-5
|
|
21
|
+
class="my-5"
|
|
22
22
|
>
|
|
23
|
-
<NodeViewContent />
|
|
23
|
+
<NodeViewContent class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 [&>*]:my-0" />
|
|
24
24
|
</NodeViewWrapper>
|
|
25
25
|
</template>
|
|
@@ -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,20 +16,25 @@ 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
|
const value = computed(() => props.node.attrs.value || "");
|
|
20
22
|
const trend = computed(() => props.node.attrs.trend || "none");
|
|
21
23
|
const trendValue = computed(() => props.node.attrs.trendValue || "");
|
|
22
24
|
function setLabel(v) {
|
|
25
|
+
if (!editable.value) return;
|
|
23
26
|
props.updateAttributes({ label: v });
|
|
24
27
|
}
|
|
25
28
|
function setValue(v) {
|
|
29
|
+
if (!editable.value) return;
|
|
26
30
|
props.updateAttributes({ value: v });
|
|
27
31
|
}
|
|
28
32
|
function setTrendValue(v) {
|
|
33
|
+
if (!editable.value) return;
|
|
29
34
|
props.updateAttributes({ trendValue: v });
|
|
30
35
|
}
|
|
31
36
|
function cycleTrend() {
|
|
37
|
+
if (!editable.value) return;
|
|
32
38
|
const next = trend.value === "none" ? "up" : trend.value === "up" ? "down" : "none";
|
|
33
39
|
props.updateAttributes({ trend: next });
|
|
34
40
|
}
|
|
@@ -55,6 +61,7 @@ const trendIcon = computed(() => {
|
|
|
55
61
|
:model-value="label"
|
|
56
62
|
placeholder="Label"
|
|
57
63
|
variant="label"
|
|
64
|
+
:disabled="!editable"
|
|
58
65
|
@update:model-value="setLabel"
|
|
59
66
|
/>
|
|
60
67
|
</div>
|
|
@@ -63,13 +70,15 @@ const trendIcon = computed(() => {
|
|
|
63
70
|
:model-value="value"
|
|
64
71
|
placeholder="0"
|
|
65
72
|
variant="title"
|
|
73
|
+
:disabled="!editable"
|
|
66
74
|
@update:model-value="setValue"
|
|
67
75
|
/>
|
|
68
76
|
</div>
|
|
69
77
|
<button
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
:
|
|
78
|
+
v-if="editable || trend !== 'none'"
|
|
79
|
+
class="inline-flex items-center gap-1 text-xs self-start rounded-sm px-1 -mx-1"
|
|
80
|
+
:class="[trendColor, editable ? 'hover:bg-(--ui-bg-elevated)/60' : 'cursor-default']"
|
|
81
|
+
:title="editable ? `Trend: ${trend} (click to change)` : void 0"
|
|
73
82
|
@click="cycleTrend"
|
|
74
83
|
>
|
|
75
84
|
<UIcon
|
|
@@ -81,6 +90,7 @@ const trendIcon = computed(() => {
|
|
|
81
90
|
:model-value="trendValue"
|
|
82
91
|
placeholder="+0%"
|
|
83
92
|
variant="label"
|
|
93
|
+
:disabled="!editable"
|
|
84
94
|
@update:model-value="setTrendValue"
|
|
85
95
|
/>
|
|
86
96
|
</span>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { NodeViewWrapper, NodeViewContent } from "@tiptap/vue-3";
|
|
3
2
|
import { computed } from "vue";
|
|
3
|
+
import { NodeViewWrapper, NodeViewContent } 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,13 +15,19 @@ const props = defineProps({
|
|
|
14
15
|
extension: { type: Object, required: true },
|
|
15
16
|
HTMLAttributes: { type: Object, required: true }
|
|
16
17
|
});
|
|
18
|
+
const editable = useNodeViewEditable(props);
|
|
19
|
+
const LEVEL_OPTIONS = [2, 3, 4];
|
|
17
20
|
const level = computed(() => props.node.attrs.level || 3);
|
|
21
|
+
function setLevel(v) {
|
|
22
|
+
if (!editable.value) return;
|
|
23
|
+
props.updateAttributes({ level: v });
|
|
24
|
+
}
|
|
18
25
|
</script>
|
|
19
26
|
|
|
20
27
|
<template>
|
|
21
28
|
<NodeViewWrapper
|
|
22
29
|
as="div"
|
|
23
|
-
class="my-5 ms-4 border-s border-(--ui-border) ps-8"
|
|
30
|
+
class="group/steps relative my-5 ms-4 border-s border-(--ui-border) ps-8"
|
|
24
31
|
style="counter-reset: step;"
|
|
25
32
|
:class="{
|
|
26
33
|
'[&>div>h2]:[counter-increment:step] [&>div>h2]:relative [&>div>h2]:before:absolute [&>div>h2]:before:size-8 [&>div>h2]:before:bg-(--ui-bg-elevated) [&>div>h2]:before:rounded-full [&>div>h2]:before:font-semibold [&>div>h2]:before:text-sm [&>div>h2]:before:tabular-nums [&>div>h2]:before:inline-flex [&>div>h2]:before:items-center [&>div>h2]:before:justify-center [&>div>h2]:before:ring-4 [&>div>h2]:before:ring-(--ui-bg) [&>div>h2]:before:-ms-[48.5px] [&>div>h2]:before:content-[counter(step)]': level === 2,
|
|
@@ -28,6 +35,22 @@ const level = computed(() => props.node.attrs.level || 3);
|
|
|
28
35
|
'[&>div>h4]:[counter-increment:step] [&>div>h4]:relative [&>div>h4]:before:absolute [&>div>h4]:before:size-7 [&>div>h4]:before:bg-(--ui-bg-elevated) [&>div>h4]:before:rounded-full [&>div>h4]:before:font-semibold [&>div>h4]:before:text-sm [&>div>h4]:before:tabular-nums [&>div>h4]:before:inline-flex [&>div>h4]:before:items-center [&>div>h4]:before:justify-center [&>div>h4]:before:ring-4 [&>div>h4]:before:ring-(--ui-bg) [&>div>h4]:before:-ms-[48.5px] [&>div>h4]:before:content-[counter(step)]': level === 4
|
|
29
36
|
}"
|
|
30
37
|
>
|
|
38
|
+
<div
|
|
39
|
+
v-if="editable"
|
|
40
|
+
class="absolute top-0 end-0 flex items-center gap-0.5 rounded-md border border-(--ui-border) bg-(--ui-bg) p-0.5 shadow-sm opacity-0 group-hover/steps:opacity-100 transition-opacity"
|
|
41
|
+
contenteditable="false"
|
|
42
|
+
>
|
|
43
|
+
<button
|
|
44
|
+
v-for="opt in LEVEL_OPTIONS"
|
|
45
|
+
:key="opt"
|
|
46
|
+
class="size-6 flex items-center justify-center text-xs font-medium rounded-sm transition-colors"
|
|
47
|
+
:class="level === opt || opt === 3 && level === 1 ? 'bg-(--ui-bg-elevated) text-(--ui-text-highlighted)' : 'text-(--ui-text-muted) hover:text-(--ui-text) hover:bg-(--ui-bg-elevated)/60'"
|
|
48
|
+
:title="`Number H${opt} headings`"
|
|
49
|
+
@click="setLevel(opt)"
|
|
50
|
+
>
|
|
51
|
+
H{{ opt }}
|
|
52
|
+
</button>
|
|
53
|
+
</div>
|
|
31
54
|
<NodeViewContent />
|
|
32
55
|
</NodeViewWrapper>
|
|
33
56
|
</template>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { ref, computed,
|
|
2
|
+
import { ref, computed, watchEffect } from "vue";
|
|
3
|
+
import { useNodeViewEditable } from "../../composables/useNodeView";
|
|
3
4
|
import { NodeViewWrapper } from "@tiptap/vue-3";
|
|
4
5
|
import { sanitizeSvg } from "../../utils/sanitizeSvg";
|
|
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 rawSvg = computed(() => props.node.attrs.svg || "");
|
|
19
21
|
const title = computed(() => props.node.attrs.title || "");
|
|
20
22
|
const hasSvg = computed(() => !!rawSvg.value);
|
|
@@ -33,6 +35,7 @@ function isSvgFile(file) {
|
|
|
33
35
|
return file.type === "image/svg+xml" || file.name.toLowerCase().endsWith(".svg");
|
|
34
36
|
}
|
|
35
37
|
async function loadSvgFile(file) {
|
|
38
|
+
if (!editable.value) return;
|
|
36
39
|
const text = await file.text();
|
|
37
40
|
if (!text.includes("<svg")) return;
|
|
38
41
|
props.updateAttributes({
|
|
@@ -41,6 +44,7 @@ async function loadSvgFile(file) {
|
|
|
41
44
|
});
|
|
42
45
|
}
|
|
43
46
|
function pickSvgFile() {
|
|
47
|
+
if (!editable.value) return;
|
|
44
48
|
const input = document.createElement("input");
|
|
45
49
|
input.type = "file";
|
|
46
50
|
input.accept = ".svg,image/svg+xml";
|
|
@@ -58,6 +62,7 @@ function onDrop(e) {
|
|
|
58
62
|
if (file) loadSvgFile(file);
|
|
59
63
|
}
|
|
60
64
|
function onDragOver(e) {
|
|
65
|
+
if (!editable.value) return;
|
|
61
66
|
e.preventDefault();
|
|
62
67
|
e.stopPropagation();
|
|
63
68
|
isDragOver.value = true;
|
|
@@ -102,7 +107,7 @@ const placeholderText = computed(() => {
|
|
|
102
107
|
v-html="sanitized"
|
|
103
108
|
/>
|
|
104
109
|
<div
|
|
105
|
-
v-else
|
|
110
|
+
v-else-if="editable"
|
|
106
111
|
class="flex flex-col items-center justify-center gap-2 px-6 py-10 cursor-pointer text-(--ui-text-dimmed) hover:bg-(--ui-bg-elevated)/40 transition-colors"
|
|
107
112
|
role="button"
|
|
108
113
|
tabindex="0"
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import { ref, computed, watch, nextTick } from "vue";
|
|
2
3
|
import { NodeViewWrapper, NodeViewContent } from "@tiptap/vue-3";
|
|
3
|
-
import
|
|
4
|
+
import ANodeInlineLabel from "../../components/editor/ANodeInlineLabel.vue";
|
|
5
|
+
import AIconPickerPopover from "../../components/editor/AIconPickerPopover.vue";
|
|
6
|
+
import { useNodeViewEditable, useNodeViewSelectionInside } from "../../composables/useNodeView";
|
|
4
7
|
const props = defineProps({
|
|
5
8
|
decorations: { type: Array, required: true },
|
|
6
9
|
selected: { type: Boolean, required: true },
|
|
@@ -14,22 +17,84 @@ const props = defineProps({
|
|
|
14
17
|
extension: { type: Object, required: true },
|
|
15
18
|
HTMLAttributes: { type: Object, required: true }
|
|
16
19
|
});
|
|
20
|
+
const editable = useNodeViewEditable(props);
|
|
17
21
|
const activeIndex = ref(0);
|
|
22
|
+
const iconPopoverFor = ref(null);
|
|
18
23
|
const tabs = computed(() => {
|
|
24
|
+
const parentPos = props.getPos();
|
|
19
25
|
const result = [];
|
|
20
|
-
|
|
26
|
+
if (parentPos === void 0) return result;
|
|
27
|
+
props.node.forEach((child, offset) => {
|
|
28
|
+
const icon = child.attrs?.icon || "";
|
|
21
29
|
result.push({
|
|
22
|
-
label: child.attrs?.label ||
|
|
23
|
-
icon
|
|
30
|
+
label: child.attrs?.label || "",
|
|
31
|
+
icon,
|
|
32
|
+
iconShort: icon.replace(/^i-lucide-/, ""),
|
|
33
|
+
pos: parentPos + 1 + offset
|
|
24
34
|
});
|
|
25
35
|
});
|
|
26
36
|
return result;
|
|
27
37
|
});
|
|
28
|
-
watch(() => props.node.childCount, () => {
|
|
29
|
-
if (activeIndex.value >=
|
|
30
|
-
activeIndex.value = Math.max(0,
|
|
38
|
+
watch(() => props.node.childCount, (next) => {
|
|
39
|
+
if (activeIndex.value >= next) {
|
|
40
|
+
activeIndex.value = Math.max(0, next - 1);
|
|
31
41
|
}
|
|
32
42
|
});
|
|
43
|
+
const panelsUid = `tabs-${Math.random().toString(36).slice(2, 10)}`;
|
|
44
|
+
const panelsCss = computed(
|
|
45
|
+
() => `[data-panels-uid="${panelsUid}"] > div > * { display: none; }[data-panels-uid="${panelsUid}"] > div > :nth-child(${activeIndex.value + 1}) { display: revert; }`
|
|
46
|
+
);
|
|
47
|
+
useNodeViewSelectionInside(props, (childIndex) => {
|
|
48
|
+
if (activeIndex.value !== childIndex) activeIndex.value = childIndex;
|
|
49
|
+
});
|
|
50
|
+
function setChildAttr(childPos, attrs) {
|
|
51
|
+
if (!editable.value) return;
|
|
52
|
+
const tr = props.editor.state.tr;
|
|
53
|
+
for (const [k, v] of Object.entries(attrs)) {
|
|
54
|
+
tr.setNodeAttribute(childPos, k, v);
|
|
55
|
+
}
|
|
56
|
+
props.editor.view.dispatch(tr);
|
|
57
|
+
}
|
|
58
|
+
function setTabLabel(childPos, v) {
|
|
59
|
+
setChildAttr(childPos, { label: v });
|
|
60
|
+
}
|
|
61
|
+
function setTabIcon(childPos, name) {
|
|
62
|
+
setChildAttr(childPos, { icon: name ? `i-lucide-${name}` : "" });
|
|
63
|
+
iconPopoverFor.value = null;
|
|
64
|
+
}
|
|
65
|
+
function addTab() {
|
|
66
|
+
if (!editable.value) return;
|
|
67
|
+
const pos = props.getPos();
|
|
68
|
+
if (pos === void 0) return;
|
|
69
|
+
const n = props.node;
|
|
70
|
+
const newIndex = n.childCount;
|
|
71
|
+
props.editor.chain().focus().insertContentAt(pos + n.nodeSize - 1, {
|
|
72
|
+
type: "tabsItem",
|
|
73
|
+
attrs: { label: `Tab ${newIndex + 1}` },
|
|
74
|
+
content: [{ type: "paragraph" }]
|
|
75
|
+
}).run();
|
|
76
|
+
nextTick(() => {
|
|
77
|
+
activeIndex.value = newIndex;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function removeTab(index) {
|
|
81
|
+
if (!editable.value) return;
|
|
82
|
+
const parentPos = props.getPos();
|
|
83
|
+
if (parentPos === void 0) return;
|
|
84
|
+
if (props.node.childCount <= 1) return;
|
|
85
|
+
let target = null;
|
|
86
|
+
props.node.forEach((child, offset, i) => {
|
|
87
|
+
if (i === index) {
|
|
88
|
+
const from = parentPos + 1 + offset;
|
|
89
|
+
target = { from, to: from + child.nodeSize };
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
if (!target) return;
|
|
93
|
+
props.editor.chain().focus().deleteRange(target).run();
|
|
94
|
+
if (activeIndex.value >= index && activeIndex.value > 0) {
|
|
95
|
+
activeIndex.value = activeIndex.value - 1;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
33
98
|
</script>
|
|
34
99
|
|
|
35
100
|
<template>
|
|
@@ -38,33 +103,91 @@ watch(() => props.node.childCount, () => {
|
|
|
38
103
|
class="my-5"
|
|
39
104
|
>
|
|
40
105
|
<div
|
|
41
|
-
class="relative flex items-
|
|
106
|
+
class="relative flex items-stretch gap-0.5 border-b border-(--ui-border)"
|
|
42
107
|
contenteditable="false"
|
|
108
|
+
role="tablist"
|
|
43
109
|
>
|
|
44
|
-
<
|
|
110
|
+
<div
|
|
45
111
|
v-for="(tab, i) in tabs"
|
|
46
|
-
:key="
|
|
47
|
-
class="relative px-
|
|
112
|
+
:key="tab.pos"
|
|
113
|
+
class="group/tab relative flex items-center gap-1 px-2 py-1.5 text-sm font-medium transition-colors cursor-pointer"
|
|
48
114
|
:class="activeIndex === i ? 'text-(--ui-primary)' : 'text-(--ui-text-muted) hover:text-(--ui-text)'"
|
|
115
|
+
role="tab"
|
|
116
|
+
:aria-selected="activeIndex === i"
|
|
49
117
|
@click="activeIndex = i"
|
|
50
118
|
>
|
|
119
|
+
<template v-if="editable">
|
|
120
|
+
<AIconPickerPopover
|
|
121
|
+
:model-value="tab.iconShort"
|
|
122
|
+
:open="iconPopoverFor === i"
|
|
123
|
+
@update:model-value="(name) => setTabIcon(tab.pos, name)"
|
|
124
|
+
@update:open="(v) => iconPopoverFor = v ? i : null"
|
|
125
|
+
>
|
|
126
|
+
<button
|
|
127
|
+
class="shrink-0 size-5 flex items-center justify-center rounded-sm hover:bg-(--ui-bg-elevated)"
|
|
128
|
+
:title="tab.icon ? 'Change icon' : 'Add icon'"
|
|
129
|
+
@click.stop="iconPopoverFor = i"
|
|
130
|
+
>
|
|
131
|
+
<UIcon
|
|
132
|
+
:name="tab.icon || 'i-lucide-plus'"
|
|
133
|
+
class="size-4"
|
|
134
|
+
:class="!tab.icon ? 'opacity-0 group-hover/tab:opacity-60 transition-opacity' : ''"
|
|
135
|
+
/>
|
|
136
|
+
</button>
|
|
137
|
+
</AIconPickerPopover>
|
|
138
|
+
</template>
|
|
51
139
|
<UIcon
|
|
52
|
-
v-if="tab.icon"
|
|
140
|
+
v-else-if="tab.icon"
|
|
53
141
|
:name="tab.icon"
|
|
54
|
-
class="
|
|
142
|
+
class="shrink-0 size-4"
|
|
143
|
+
/>
|
|
144
|
+
<ANodeInlineLabel
|
|
145
|
+
:model-value="tab.label"
|
|
146
|
+
:placeholder="`Tab ${i + 1}`"
|
|
147
|
+
variant="label"
|
|
148
|
+
:disabled="!editable"
|
|
149
|
+
@update:model-value="(v) => setTabLabel(tab.pos, v)"
|
|
55
150
|
/>
|
|
56
|
-
<span
|
|
151
|
+
<span
|
|
152
|
+
v-if="!editable && !tab.label"
|
|
153
|
+
class="text-(--ui-text-muted)"
|
|
154
|
+
>{{ `Tab ${i + 1}` }}</span>
|
|
155
|
+
<button
|
|
156
|
+
v-if="editable && tabs.length > 1"
|
|
157
|
+
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"
|
|
158
|
+
title="Remove tab"
|
|
159
|
+
@click.stop="removeTab(i)"
|
|
160
|
+
>
|
|
161
|
+
<UIcon
|
|
162
|
+
name="i-lucide-x"
|
|
163
|
+
class="size-3"
|
|
164
|
+
/>
|
|
165
|
+
</button>
|
|
57
166
|
<span
|
|
58
167
|
v-if="activeIndex === i"
|
|
59
168
|
class="absolute bottom-0 inset-x-0 h-0.5 bg-(--ui-primary) rounded-full"
|
|
60
169
|
/>
|
|
170
|
+
</div>
|
|
171
|
+
<button
|
|
172
|
+
v-if="editable"
|
|
173
|
+
class="shrink-0 px-2 py-1.5 text-sm text-(--ui-text-muted) hover:text-(--ui-text) hover:bg-(--ui-bg-elevated) rounded-sm self-center flex items-center gap-1"
|
|
174
|
+
title="Add tab"
|
|
175
|
+
@click="addTab"
|
|
176
|
+
>
|
|
177
|
+
<UIcon
|
|
178
|
+
name="i-lucide-plus"
|
|
179
|
+
class="size-4"
|
|
180
|
+
/>
|
|
61
181
|
</button>
|
|
62
182
|
</div>
|
|
63
|
-
<div
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
183
|
+
<div
|
|
184
|
+
class="mt-4"
|
|
185
|
+
:data-panels-uid="panelsUid"
|
|
186
|
+
>
|
|
187
|
+
<component :is="'style'">
|
|
188
|
+
{{ panelsCss }}
|
|
189
|
+
</component>
|
|
190
|
+
<NodeViewContent />
|
|
68
191
|
</div>
|
|
69
192
|
</NodeViewWrapper>
|
|
70
193
|
</template>
|