@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.
- 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/aware/AMedia.d.vue.ts +1 -1
- package/dist/runtime/components/aware/AMedia.vue.d.ts +1 -1
- 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/server/utils/docCache.js +6 -3
- package/dist/runtime/server/utils/serverSchemaStubs.d.ts +9 -0
- package/dist/runtime/server/utils/serverSchemaStubs.js +41 -0
- 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, watch } 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,7 +15,44 @@ 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 COLORS = ["primary", "secondary", "success", "info", "warning", "error", "neutral"];
|
|
20
|
+
const VARIANTS = ["solid", "outline", "soft", "subtle"];
|
|
17
21
|
const label = computed(() => props.node.attrs.label || "Badge");
|
|
22
|
+
const badgeColor = computed(() => props.node.attrs.color || "neutral");
|
|
23
|
+
const badgeVariant = computed(() => props.node.attrs.variant || "subtle");
|
|
24
|
+
const popoverOpen = ref(false);
|
|
25
|
+
const labelDraft = ref("");
|
|
26
|
+
watch(popoverOpen, (open) => {
|
|
27
|
+
if (open) labelDraft.value = label.value;
|
|
28
|
+
});
|
|
29
|
+
function commit() {
|
|
30
|
+
if (!editable.value) return;
|
|
31
|
+
const next = labelDraft.value.trim() || "Badge";
|
|
32
|
+
props.updateAttributes({ label: next });
|
|
33
|
+
}
|
|
34
|
+
function onLabelKeydown(e) {
|
|
35
|
+
if (e.key === "Enter") {
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
commit();
|
|
38
|
+
popoverOpen.value = false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function setColor(c) {
|
|
42
|
+
if (!editable.value) return;
|
|
43
|
+
props.updateAttributes({ color: c });
|
|
44
|
+
}
|
|
45
|
+
function setVariant(v) {
|
|
46
|
+
if (!editable.value) return;
|
|
47
|
+
props.updateAttributes({ variant: v });
|
|
48
|
+
}
|
|
49
|
+
function remove() {
|
|
50
|
+
if (!editable.value) return;
|
|
51
|
+
const pos = props.getPos();
|
|
52
|
+
if (pos === void 0) return;
|
|
53
|
+
props.editor.chain().focus().deleteRange({ from: pos, to: pos + 1 }).run();
|
|
54
|
+
popoverOpen.value = false;
|
|
55
|
+
}
|
|
18
56
|
</script>
|
|
19
57
|
|
|
20
58
|
<template>
|
|
@@ -23,11 +61,94 @@ const label = computed(() => props.node.attrs.label || "Badge");
|
|
|
23
61
|
class="inline"
|
|
24
62
|
>
|
|
25
63
|
<UBadge
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
64
|
+
v-if="!editable"
|
|
65
|
+
:color="badgeColor"
|
|
66
|
+
:variant="badgeVariant"
|
|
67
|
+
class="rounded-full align-middle"
|
|
29
68
|
>
|
|
30
69
|
{{ label }}
|
|
31
70
|
</UBadge>
|
|
71
|
+
<UPopover
|
|
72
|
+
v-else
|
|
73
|
+
v-model:open="popoverOpen"
|
|
74
|
+
:content="{ align: 'start' }"
|
|
75
|
+
>
|
|
76
|
+
<button
|
|
77
|
+
class="inline-flex align-middle rounded-full focus:outline-none focus-visible:ring-2 focus-visible:ring-(--ui-primary)"
|
|
78
|
+
type="button"
|
|
79
|
+
>
|
|
80
|
+
<UBadge
|
|
81
|
+
:color="badgeColor"
|
|
82
|
+
:variant="badgeVariant"
|
|
83
|
+
class="rounded-full cursor-pointer"
|
|
84
|
+
>
|
|
85
|
+
{{ label }}
|
|
86
|
+
</UBadge>
|
|
87
|
+
</button>
|
|
88
|
+
<template #content>
|
|
89
|
+
<div
|
|
90
|
+
class="p-2 w-64 flex flex-col gap-2"
|
|
91
|
+
contenteditable="false"
|
|
92
|
+
>
|
|
93
|
+
<UInput
|
|
94
|
+
v-model="labelDraft"
|
|
95
|
+
autofocus
|
|
96
|
+
size="sm"
|
|
97
|
+
placeholder="Badge text"
|
|
98
|
+
@keydown="onLabelKeydown"
|
|
99
|
+
@blur="commit"
|
|
100
|
+
/>
|
|
101
|
+
<div class="flex flex-col gap-1">
|
|
102
|
+
<div class="text-xs text-(--ui-text-muted) px-0.5">
|
|
103
|
+
Color
|
|
104
|
+
</div>
|
|
105
|
+
<div class="grid grid-cols-7 gap-0.5">
|
|
106
|
+
<button
|
|
107
|
+
v-for="c in COLORS"
|
|
108
|
+
:key="c"
|
|
109
|
+
class="size-7 flex items-center justify-center rounded-sm hover:bg-(--ui-bg-elevated) transition-colors"
|
|
110
|
+
:class="badgeColor === c ? 'bg-(--ui-bg-elevated) ring-1 ring-(--ui-primary)' : ''"
|
|
111
|
+
:title="c"
|
|
112
|
+
@click="setColor(c)"
|
|
113
|
+
>
|
|
114
|
+
<UBadge
|
|
115
|
+
:color="c"
|
|
116
|
+
:variant="badgeVariant"
|
|
117
|
+
class="rounded-full pointer-events-none text-[10px]"
|
|
118
|
+
>
|
|
119
|
+
•
|
|
120
|
+
</UBadge>
|
|
121
|
+
</button>
|
|
122
|
+
</div>
|
|
123
|
+
</div>
|
|
124
|
+
<div class="flex flex-col gap-1">
|
|
125
|
+
<div class="text-xs text-(--ui-text-muted) px-0.5">
|
|
126
|
+
Style
|
|
127
|
+
</div>
|
|
128
|
+
<div class="grid grid-cols-4 gap-1">
|
|
129
|
+
<button
|
|
130
|
+
v-for="v in VARIANTS"
|
|
131
|
+
:key="v"
|
|
132
|
+
class="px-2 py-1 text-xs rounded-sm hover:bg-(--ui-bg-elevated) transition-colors capitalize"
|
|
133
|
+
:class="badgeVariant === v ? 'bg-(--ui-bg-elevated) text-(--ui-text-highlighted) ring-1 ring-(--ui-primary)' : 'text-(--ui-text-muted)'"
|
|
134
|
+
@click="setVariant(v)"
|
|
135
|
+
>
|
|
136
|
+
{{ v }}
|
|
137
|
+
</button>
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
<UButton
|
|
141
|
+
size="sm"
|
|
142
|
+
color="neutral"
|
|
143
|
+
variant="ghost"
|
|
144
|
+
icon="i-lucide-trash"
|
|
145
|
+
block
|
|
146
|
+
@click="remove"
|
|
147
|
+
>
|
|
148
|
+
Remove
|
|
149
|
+
</UButton>
|
|
150
|
+
</div>
|
|
151
|
+
</template>
|
|
152
|
+
</UPopover>
|
|
32
153
|
</NodeViewWrapper>
|
|
33
154
|
</template>
|
|
@@ -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="flex flex-wrap items-center gap-2 [&>*]:my-0 [&>*]:me-0" />
|
|
24
24
|
</NodeViewWrapper>
|
|
25
25
|
</template>
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { ref, computed, watch } from "vue";
|
|
3
|
+
import { navigateTo } from "#imports";
|
|
3
4
|
import { NodeViewWrapper } from "@tiptap/vue-3";
|
|
4
5
|
import AIconPickerPopover from "../../components/editor/AIconPickerPopover.vue";
|
|
6
|
+
import { useNodeViewEditable } from "../../composables/useNodeView";
|
|
5
7
|
const props = defineProps({
|
|
6
8
|
decorations: { type: Array, required: true },
|
|
7
9
|
selected: { type: Boolean, required: true },
|
|
@@ -15,6 +17,7 @@ const props = defineProps({
|
|
|
15
17
|
extension: { type: Object, required: true },
|
|
16
18
|
HTMLAttributes: { type: Object, required: true }
|
|
17
19
|
});
|
|
20
|
+
const editable = useNodeViewEditable(props);
|
|
18
21
|
const COLORS = ["primary", "secondary", "success", "info", "warning", "error", "neutral"];
|
|
19
22
|
const VARIANTS = ["solid", "outline", "soft", "ghost", "subtle", "link"];
|
|
20
23
|
const label = computed(() => props.node.attrs.label || "Button");
|
|
@@ -23,6 +26,7 @@ const variant = computed(() => props.node.attrs.variant || "solid");
|
|
|
23
26
|
const color = computed(() => props.node.attrs.color || "primary");
|
|
24
27
|
const icon = computed(() => props.node.attrs.icon || "");
|
|
25
28
|
const iconShort = computed(() => icon.value.replace(/^i-lucide-/, ""));
|
|
29
|
+
const isExternal = computed(() => /^[a-z][a-z0-9+.-]*:/i.test(to.value));
|
|
26
30
|
const popoverOpen = ref(false);
|
|
27
31
|
const iconPopoverOpen = ref(false);
|
|
28
32
|
const labelDraft = ref("");
|
|
@@ -34,22 +38,27 @@ watch(popoverOpen, (open) => {
|
|
|
34
38
|
}
|
|
35
39
|
});
|
|
36
40
|
function commit() {
|
|
41
|
+
if (!editable.value) return;
|
|
37
42
|
props.updateAttributes({
|
|
38
43
|
label: labelDraft.value.trim() || "Button",
|
|
39
44
|
to: linkDraft.value.trim()
|
|
40
45
|
});
|
|
41
46
|
}
|
|
42
47
|
function setVariant(v) {
|
|
48
|
+
if (!editable.value) return;
|
|
43
49
|
props.updateAttributes({ variant: v });
|
|
44
50
|
}
|
|
45
51
|
function setColor(c) {
|
|
52
|
+
if (!editable.value) return;
|
|
46
53
|
props.updateAttributes({ color: c });
|
|
47
54
|
}
|
|
48
55
|
function setIcon(name) {
|
|
56
|
+
if (!editable.value) return;
|
|
49
57
|
props.updateAttributes({ icon: name ? `i-lucide-${name}` : "" });
|
|
50
58
|
iconPopoverOpen.value = false;
|
|
51
59
|
}
|
|
52
60
|
function remove() {
|
|
61
|
+
if (!editable.value) return;
|
|
53
62
|
const pos = props.getPos();
|
|
54
63
|
if (pos === void 0) return;
|
|
55
64
|
props.editor.chain().focus().deleteRange({ from: pos, to: pos + 1 }).run();
|
|
@@ -62,6 +71,14 @@ function onKeydown(e) {
|
|
|
62
71
|
popoverOpen.value = false;
|
|
63
72
|
}
|
|
64
73
|
}
|
|
74
|
+
function activate() {
|
|
75
|
+
if (editable.value || !to.value) return;
|
|
76
|
+
if (isExternal.value) {
|
|
77
|
+
window.open(to.value, "_blank", "noopener,noreferrer");
|
|
78
|
+
} else {
|
|
79
|
+
navigateTo(to.value);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
65
82
|
</script>
|
|
66
83
|
|
|
67
84
|
<template>
|
|
@@ -70,7 +87,17 @@ function onKeydown(e) {
|
|
|
70
87
|
class="my-2 inline-block not-prose align-middle me-2"
|
|
71
88
|
contenteditable="false"
|
|
72
89
|
>
|
|
90
|
+
<UButton
|
|
91
|
+
v-if="!editable"
|
|
92
|
+
:color="color"
|
|
93
|
+
:variant="variant"
|
|
94
|
+
:icon="icon || void 0"
|
|
95
|
+
:label="label"
|
|
96
|
+
:class="to ? 'cursor-pointer' : 'cursor-default'"
|
|
97
|
+
@click="activate"
|
|
98
|
+
/>
|
|
73
99
|
<UPopover
|
|
100
|
+
v-else
|
|
74
101
|
v-model:open="popoverOpen"
|
|
75
102
|
:content="{ align: 'start' }"
|
|
76
103
|
>
|
|
@@ -1,6 +1,9 @@
|
|
|
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
|
+
import ANodeInlineLabel from "../../components/editor/ANodeInlineLabel.vue";
|
|
5
|
+
import AIconPickerPopover from "../../components/editor/AIconPickerPopover.vue";
|
|
6
|
+
import { useNodeViewEditable } from "../../composables/useNodeView";
|
|
4
7
|
const props = defineProps({
|
|
5
8
|
decorations: { type: Array, required: true },
|
|
6
9
|
selected: { type: Boolean, required: true },
|
|
@@ -14,17 +17,31 @@ 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 CONFIG = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
note: { icon: "i-lucide-info", color: "info", label: "Note" },
|
|
23
|
+
info: { icon: "i-lucide-info", color: "info", label: "Info" },
|
|
24
|
+
tip: { icon: "i-lucide-lightbulb", color: "success", label: "Tip" },
|
|
25
|
+
warning: { icon: "i-lucide-triangle-alert", color: "warning", label: "Warning" },
|
|
26
|
+
caution: { icon: "i-lucide-triangle-alert", color: "warning", label: "Caution" },
|
|
27
|
+
danger: { icon: "i-lucide-circle-x", color: "error", label: "Danger" },
|
|
28
|
+
callout: { icon: "i-lucide-info", color: "info", label: "Callout" },
|
|
29
|
+
alert: { icon: "i-lucide-info", color: "info", label: "Alert" }
|
|
26
30
|
};
|
|
27
|
-
const cfg = computed(() => CONFIG[props.node.attrs.type] ?? CONFIG
|
|
31
|
+
const cfg = computed(() => CONFIG[props.node.attrs.type] ?? CONFIG.note);
|
|
32
|
+
const title = computed(() => props.node.attrs.title || "");
|
|
33
|
+
const customIcon = computed(() => props.node.attrs.icon || "");
|
|
34
|
+
const effectiveIcon = computed(() => customIcon.value || cfg.value.icon);
|
|
35
|
+
const iconShort = computed(() => effectiveIcon.value.replace(/^i-lucide-/, ""));
|
|
36
|
+
const iconPopoverOpen = ref(false);
|
|
37
|
+
function setTitle(v) {
|
|
38
|
+
if (!editable.value) return;
|
|
39
|
+
props.updateAttributes({ title: v });
|
|
40
|
+
}
|
|
41
|
+
function setIcon(name) {
|
|
42
|
+
if (!editable.value) return;
|
|
43
|
+
props.updateAttributes({ icon: name ? `i-lucide-${name}` : "" });
|
|
44
|
+
}
|
|
28
45
|
</script>
|
|
29
46
|
|
|
30
47
|
<template>
|
|
@@ -34,10 +51,50 @@ const cfg = computed(() => CONFIG[props.node.attrs.type] ?? CONFIG["note"]);
|
|
|
34
51
|
>
|
|
35
52
|
<UAlert
|
|
36
53
|
:color="cfg.color"
|
|
37
|
-
:icon="
|
|
54
|
+
:icon="editable || title ? void 0 : effectiveIcon"
|
|
38
55
|
variant="soft"
|
|
39
56
|
:ui="{ description: '[&>*:first-child]:mt-0 [&>*:last-child]:mb-0' }"
|
|
40
57
|
>
|
|
58
|
+
<template
|
|
59
|
+
v-if="editable || title"
|
|
60
|
+
#title
|
|
61
|
+
>
|
|
62
|
+
<div
|
|
63
|
+
class="flex items-center gap-2"
|
|
64
|
+
contenteditable="false"
|
|
65
|
+
>
|
|
66
|
+
<AIconPickerPopover
|
|
67
|
+
v-if="editable"
|
|
68
|
+
:model-value="iconShort"
|
|
69
|
+
:open="iconPopoverOpen"
|
|
70
|
+
@update:model-value="setIcon"
|
|
71
|
+
@update:open="iconPopoverOpen = $event"
|
|
72
|
+
>
|
|
73
|
+
<button
|
|
74
|
+
class="shrink-0 size-5 flex items-center justify-center rounded-sm hover:bg-(--ui-bg-elevated)/60"
|
|
75
|
+
title="Change icon"
|
|
76
|
+
@click.stop="iconPopoverOpen = true"
|
|
77
|
+
>
|
|
78
|
+
<UIcon
|
|
79
|
+
:name="effectiveIcon"
|
|
80
|
+
class="size-4"
|
|
81
|
+
/>
|
|
82
|
+
</button>
|
|
83
|
+
</AIconPickerPopover>
|
|
84
|
+
<UIcon
|
|
85
|
+
v-else
|
|
86
|
+
:name="effectiveIcon"
|
|
87
|
+
class="shrink-0 size-4"
|
|
88
|
+
/>
|
|
89
|
+
<ANodeInlineLabel
|
|
90
|
+
:model-value="title"
|
|
91
|
+
:placeholder="cfg.label"
|
|
92
|
+
variant="title"
|
|
93
|
+
:disabled="!editable"
|
|
94
|
+
@update:model-value="setTitle"
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
97
|
+
</template>
|
|
41
98
|
<template #description>
|
|
42
99
|
<NodeViewContent />
|
|
43
100
|
</template>
|
|
@@ -18,8 +18,8 @@ defineProps({
|
|
|
18
18
|
<template>
|
|
19
19
|
<NodeViewWrapper
|
|
20
20
|
as="div"
|
|
21
|
-
class="
|
|
21
|
+
class="my-5"
|
|
22
22
|
>
|
|
23
|
-
<NodeViewContent />
|
|
23
|
+
<NodeViewContent class="grid grid-cols-1 sm:grid-cols-2 gap-5 [&>*]:my-0" />
|
|
24
24
|
</NodeViewWrapper>
|
|
25
25
|
</template>
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import { ref, computed, watch } from "vue";
|
|
3
|
+
import { navigateTo } from "#imports";
|
|
2
4
|
import { NodeViewWrapper, NodeViewContent } from "@tiptap/vue-3";
|
|
3
|
-
import
|
|
5
|
+
import ANodeInlineLabel from "../../components/editor/ANodeInlineLabel.vue";
|
|
6
|
+
import AIconPickerPopover from "../../components/editor/AIconPickerPopover.vue";
|
|
7
|
+
import { useNodeViewEditable } from "../../composables/useNodeView";
|
|
4
8
|
const props = defineProps({
|
|
5
9
|
decorations: { type: Array, required: true },
|
|
6
10
|
selected: { type: Boolean, required: true },
|
|
@@ -14,28 +18,163 @@ const props = defineProps({
|
|
|
14
18
|
extension: { type: Object, required: true },
|
|
15
19
|
HTMLAttributes: { type: Object, required: true }
|
|
16
20
|
});
|
|
21
|
+
const editable = useNodeViewEditable(props);
|
|
17
22
|
const title = computed(() => props.node.attrs.title || "");
|
|
18
23
|
const icon = computed(() => props.node.attrs.icon || "");
|
|
24
|
+
const to = computed(() => props.node.attrs.to || "");
|
|
25
|
+
const iconShort = computed(() => icon.value.replace(/^i-lucide-/, ""));
|
|
26
|
+
const isExternal = computed(() => /^[a-z][a-z0-9+.-]*:/i.test(to.value));
|
|
27
|
+
const iconPopoverOpen = ref(false);
|
|
28
|
+
const linkPopoverOpen = ref(false);
|
|
29
|
+
const linkDraft = ref("");
|
|
30
|
+
watch(linkPopoverOpen, (open) => {
|
|
31
|
+
if (open) linkDraft.value = to.value;
|
|
32
|
+
});
|
|
33
|
+
function setTitle(v) {
|
|
34
|
+
if (!editable.value) return;
|
|
35
|
+
props.updateAttributes({ title: v });
|
|
36
|
+
}
|
|
37
|
+
function setIcon(name) {
|
|
38
|
+
if (!editable.value) return;
|
|
39
|
+
props.updateAttributes({ icon: name ? `i-lucide-${name}` : "" });
|
|
40
|
+
}
|
|
41
|
+
function saveLink() {
|
|
42
|
+
if (!editable.value) return;
|
|
43
|
+
props.updateAttributes({ to: linkDraft.value.trim() });
|
|
44
|
+
linkPopoverOpen.value = false;
|
|
45
|
+
}
|
|
46
|
+
function clearLink() {
|
|
47
|
+
if (!editable.value) return;
|
|
48
|
+
props.updateAttributes({ to: "" });
|
|
49
|
+
linkPopoverOpen.value = false;
|
|
50
|
+
}
|
|
51
|
+
function onLinkKeydown(e) {
|
|
52
|
+
if (e.key === "Enter") {
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
saveLink();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function onCardClick(e) {
|
|
58
|
+
if (editable.value || !to.value) return;
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
if (isExternal.value) {
|
|
61
|
+
window.open(to.value, "_blank", "noopener,noreferrer");
|
|
62
|
+
} else {
|
|
63
|
+
navigateTo(to.value);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
19
66
|
</script>
|
|
20
67
|
|
|
21
68
|
<template>
|
|
22
69
|
<NodeViewWrapper
|
|
23
70
|
as="div"
|
|
24
|
-
class="group relative block my-5 p-4 sm:p-6 border border-(--ui-border) rounded-md bg-(--ui-bg) transition-colors"
|
|
71
|
+
class="group/card relative block my-5 p-4 sm:p-6 border border-(--ui-border) rounded-md bg-(--ui-bg) transition-colors"
|
|
72
|
+
:class="!editable && to ? 'cursor-pointer hover:border-(--ui-border-accented) hover:bg-(--ui-bg-elevated)/40' : ''"
|
|
73
|
+
@click="onCardClick"
|
|
25
74
|
>
|
|
26
|
-
<
|
|
27
|
-
v-if="
|
|
28
|
-
|
|
29
|
-
class="size-6 mb-2 block text-(--ui-text-highlighted)"
|
|
75
|
+
<div
|
|
76
|
+
v-if="editable"
|
|
77
|
+
class="absolute top-2 right-2 flex items-center gap-1 opacity-0 group-hover/card:opacity-100 transition-opacity"
|
|
30
78
|
contenteditable="false"
|
|
79
|
+
>
|
|
80
|
+
<UPopover
|
|
81
|
+
v-model:open="linkPopoverOpen"
|
|
82
|
+
:content="{ align: 'end' }"
|
|
83
|
+
>
|
|
84
|
+
<button
|
|
85
|
+
class="size-6 flex items-center justify-center rounded-sm hover:bg-(--ui-bg-elevated) text-(--ui-text-muted) hover:text-(--ui-text-highlighted)"
|
|
86
|
+
:class="to ? 'text-(--ui-primary)' : ''"
|
|
87
|
+
:title="to ? `Edit link (${to})` : 'Add link'"
|
|
88
|
+
>
|
|
89
|
+
<UIcon
|
|
90
|
+
name="i-lucide-link"
|
|
91
|
+
class="size-3.5"
|
|
92
|
+
/>
|
|
93
|
+
</button>
|
|
94
|
+
<template #content>
|
|
95
|
+
<div class="p-2 w-80 flex items-center gap-1">
|
|
96
|
+
<UInput
|
|
97
|
+
v-model="linkDraft"
|
|
98
|
+
autofocus
|
|
99
|
+
size="sm"
|
|
100
|
+
placeholder="https://example.com or /doc/…"
|
|
101
|
+
class="flex-1"
|
|
102
|
+
@keydown="onLinkKeydown"
|
|
103
|
+
/>
|
|
104
|
+
<UButton
|
|
105
|
+
size="sm"
|
|
106
|
+
variant="ghost"
|
|
107
|
+
icon="i-lucide-check"
|
|
108
|
+
:disabled="!linkDraft.trim()"
|
|
109
|
+
@click="saveLink"
|
|
110
|
+
/>
|
|
111
|
+
<UButton
|
|
112
|
+
v-if="to"
|
|
113
|
+
size="sm"
|
|
114
|
+
variant="ghost"
|
|
115
|
+
color="neutral"
|
|
116
|
+
icon="i-lucide-trash"
|
|
117
|
+
@click="clearLink"
|
|
118
|
+
/>
|
|
119
|
+
</div>
|
|
120
|
+
</template>
|
|
121
|
+
</UPopover>
|
|
122
|
+
</div>
|
|
123
|
+
<UIcon
|
|
124
|
+
v-if="!editable && to"
|
|
125
|
+
name="i-lucide-arrow-up-right"
|
|
126
|
+
class="absolute top-3 right-3 size-4 text-(--ui-text-muted) opacity-0 group-hover/card:opacity-100 transition-opacity"
|
|
31
127
|
/>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
128
|
+
|
|
129
|
+
<div
|
|
130
|
+
v-if="editable || icon"
|
|
35
131
|
contenteditable="false"
|
|
132
|
+
class="flex items-center gap-2 mb-2"
|
|
36
133
|
>
|
|
37
|
-
|
|
38
|
-
|
|
134
|
+
<AIconPickerPopover
|
|
135
|
+
v-if="editable"
|
|
136
|
+
:model-value="iconShort"
|
|
137
|
+
:open="iconPopoverOpen"
|
|
138
|
+
@update:model-value="setIcon"
|
|
139
|
+
@update:open="iconPopoverOpen = $event"
|
|
140
|
+
>
|
|
141
|
+
<button
|
|
142
|
+
class="shrink-0 size-7 flex items-center justify-center rounded-sm hover:bg-(--ui-bg-elevated) text-(--ui-text-highlighted)"
|
|
143
|
+
:title="icon ? 'Change icon' : 'Add icon'"
|
|
144
|
+
@click.stop="iconPopoverOpen = true"
|
|
145
|
+
>
|
|
146
|
+
<UIcon
|
|
147
|
+
v-if="icon"
|
|
148
|
+
:name="icon"
|
|
149
|
+
class="size-6"
|
|
150
|
+
/>
|
|
151
|
+
<UIcon
|
|
152
|
+
v-else
|
|
153
|
+
name="i-lucide-image"
|
|
154
|
+
class="size-5 opacity-30 group-hover/card:opacity-60 transition-opacity"
|
|
155
|
+
/>
|
|
156
|
+
</button>
|
|
157
|
+
</AIconPickerPopover>
|
|
158
|
+
<UIcon
|
|
159
|
+
v-else
|
|
160
|
+
:name="icon"
|
|
161
|
+
class="shrink-0 size-6 text-(--ui-text-highlighted)"
|
|
162
|
+
/>
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
<div
|
|
166
|
+
v-if="editable || title"
|
|
167
|
+
contenteditable="false"
|
|
168
|
+
>
|
|
169
|
+
<ANodeInlineLabel
|
|
170
|
+
:model-value="title"
|
|
171
|
+
placeholder="Card title"
|
|
172
|
+
variant="title"
|
|
173
|
+
:disabled="!editable"
|
|
174
|
+
@update:model-value="setTitle"
|
|
175
|
+
/>
|
|
176
|
+
</div>
|
|
177
|
+
|
|
39
178
|
<div :class="['text-[15px] text-(--ui-text-muted) [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&>*]:my-1', title ? 'mt-1' : '']">
|
|
40
179
|
<NodeViewContent />
|
|
41
180
|
</div>
|
|
@@ -1,6 +1,7 @@
|
|
|
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
|
+
import { useNodeViewEditable, useNodeViewSelectionInside, persistAttrsQuietly } from "../../composables/useNodeView";
|
|
4
5
|
const props = defineProps({
|
|
5
6
|
decorations: { type: Array, required: true },
|
|
6
7
|
selected: { type: Boolean, required: true },
|
|
@@ -14,10 +15,14 @@ const props = defineProps({
|
|
|
14
15
|
extension: { type: Object, required: true },
|
|
15
16
|
HTMLAttributes: { type: Object, required: true }
|
|
16
17
|
});
|
|
17
|
-
const
|
|
18
|
+
const editable = useNodeViewEditable(props);
|
|
19
|
+
const open = ref(!!props.node.attrs.open);
|
|
20
|
+
useNodeViewSelectionInside(props, () => {
|
|
21
|
+
open.value = true;
|
|
22
|
+
});
|
|
18
23
|
function toggleOpen() {
|
|
19
24
|
open.value = !open.value;
|
|
20
|
-
|
|
25
|
+
if (editable.value) persistAttrsQuietly(props, { open: open.value });
|
|
21
26
|
}
|
|
22
27
|
</script>
|
|
23
28
|
|