@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.
Files changed (57) 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/editor/ANodeInlineLabel.vue +3 -2
  12. package/dist/runtime/components/renderers/AProseRenderer.d.vue.ts +2 -2
  13. package/dist/runtime/components/renderers/AProseRenderer.vue.d.ts +2 -2
  14. package/dist/runtime/composables/useNodeView.d.ts +36 -0
  15. package/dist/runtime/composables/useNodeView.js +46 -0
  16. package/dist/runtime/extensions/callout.js +13 -3
  17. package/dist/runtime/extensions/views/AccordionItemView.vue +64 -13
  18. package/dist/runtime/extensions/views/BadgeView.vue +125 -4
  19. package/dist/runtime/extensions/views/ButtonGroupView.vue +2 -2
  20. package/dist/runtime/extensions/views/ButtonView.vue +27 -0
  21. package/dist/runtime/extensions/views/CalloutView.vue +68 -11
  22. package/dist/runtime/extensions/views/CardGroupView.vue +2 -2
  23. package/dist/runtime/extensions/views/CardView.vue +150 -11
  24. package/dist/runtime/extensions/views/CodeCollapseView.vue +8 -3
  25. package/dist/runtime/extensions/views/CodeGroupView.vue +104 -15
  26. package/dist/runtime/extensions/views/CodePreviewView.vue +1 -1
  27. package/dist/runtime/extensions/views/CodeTreeView.vue +241 -20
  28. package/dist/runtime/extensions/views/CollapsibleView.vue +45 -13
  29. package/dist/runtime/extensions/views/ColorSwatchView.vue +17 -1
  30. package/dist/runtime/extensions/views/DiffView.vue +8 -1
  31. package/dist/runtime/extensions/views/DividerView.vue +9 -1
  32. package/dist/runtime/extensions/views/DocEmbedView.vue +15 -3
  33. package/dist/runtime/extensions/views/DocumentMetaView.vue +3 -1
  34. package/dist/runtime/extensions/views/EmbedView.vue +14 -1
  35. package/dist/runtime/extensions/views/FieldGroupView.vue +2 -2
  36. package/dist/runtime/extensions/views/FieldView.vue +16 -0
  37. package/dist/runtime/extensions/views/FigureView.vue +18 -1
  38. package/dist/runtime/extensions/views/KbdView.vue +72 -2
  39. package/dist/runtime/extensions/views/MathBlockView.vue +26 -0
  40. package/dist/runtime/extensions/views/MathInlineView.vue +18 -0
  41. package/dist/runtime/extensions/views/MetaFieldView.vue +3 -2
  42. package/dist/runtime/extensions/views/ProgressView.vue +13 -0
  43. package/dist/runtime/extensions/views/ProseIconView.vue +33 -2
  44. package/dist/runtime/extensions/views/QuoteView.vue +72 -47
  45. package/dist/runtime/extensions/views/SpoilerView.vue +17 -5
  46. package/dist/runtime/extensions/views/StatGroupView.vue +2 -2
  47. package/dist/runtime/extensions/views/StatView.vue +13 -3
  48. package/dist/runtime/extensions/views/StepsView.vue +25 -2
  49. package/dist/runtime/extensions/views/SvgEmbedView.vue +7 -2
  50. package/dist/runtime/extensions/views/TabsView.vue +142 -19
  51. package/dist/runtime/extensions/views/TimelineItemView.vue +19 -1
  52. package/dist/runtime/extensions/views/TimelineView.d.vue.ts +0 -5
  53. package/dist/runtime/extensions/views/TimelineView.vue.d.ts +0 -5
  54. package/dist/runtime/extensions/views/VideoView.vue +84 -8
  55. package/dist/runtime/utils/docTypes.d.ts +16 -0
  56. package/dist/runtime/utils/docTypes.js +4 -0
  57. package/package.json +1 -1
@@ -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
- tip: { icon: "i-lucide-lightbulb", color: "success" },
19
- note: { icon: "i-lucide-info", color: "info" },
20
- info: { icon: "i-lucide-info", color: "info" },
21
- callout: { icon: "i-lucide-info", color: "info" },
22
- alert: { icon: "i-lucide-info", color: "info" },
23
- warning: { icon: "i-lucide-triangle-alert", color: "warning" },
24
- caution: { icon: "i-lucide-triangle-alert", color: "warning" },
25
- danger: { icon: "i-lucide-circle-x", color: "error" }
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["note"]);
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="cfg.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="grid grid-cols-1 sm:grid-cols-2 gap-5 my-5 [&>*]:my-0"
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 { computed } from "vue";
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
- <UIcon
27
- v-if="icon"
28
- :name="icon"
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
- <p
33
- v-if="title"
34
- class="text-(--ui-text-highlighted) font-semibold"
128
+
129
+ <div
130
+ v-if="editable || icon"
35
131
  contenteditable="false"
132
+ class="flex items-center gap-2 mb-2"
36
133
  >
37
- {{ title }}
38
- </p>
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 open = ref(props.node.attrs.open ?? false);
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
- props.updateAttributes({ open: open.value });
25
+ if (editable.value) persistAttrsQuietly(props, { open: open.value });
21
26
  }
22
27
  </script>
23
28
 
@@ -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 },