@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
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -383,8 +383,12 @@ const module$1 = defineNuxtModule({
|
|
|
383
383
|
appConfig.ui.editor = defu(appConfig.ui.editor ?? {}, {
|
|
384
384
|
slots: {
|
|
385
385
|
base: [
|
|
386
|
-
// Tables
|
|
387
|
-
|
|
386
|
+
// Tables — wrapper scrolls horizontally so the main view never overflows.
|
|
387
|
+
// NB: the authoritative table borders now ship as plain CSS in
|
|
388
|
+
// runtime/assets/editor.css (scan-independent); these utilities remain
|
|
389
|
+
// for apps that extend the editor slot and keep parity with cou-sh.
|
|
390
|
+
"[&_.tableWrapper]:overflow-x-auto [&_.tableWrapper]:max-w-full",
|
|
391
|
+
"[&_table]:w-full [&_table]:border-separate [&_table]:border-spacing-0 [&_table]:rounded-md [&_table]:min-w-max",
|
|
388
392
|
"[&_th]:py-3 [&_th]:px-4 [&_th]:font-semibold [&_th]:text-sm [&_th]:text-left [&_th]:bg-muted/50 [&_th]:border-t [&_th]:border-b [&_th]:border-e [&_th]:first:border-s [&_th]:border-muted",
|
|
389
393
|
"[&_th_p]:my-0 [&_th_p]:leading-5",
|
|
390
394
|
"[&_td]:py-3 [&_td]:px-4 [&_td]:text-sm [&_td]:text-left [&_td]:border-b [&_td]:border-e [&_td]:first:border-s [&_td]:border-muted",
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
html .cm-editor,html .cm-editor .cm-content,html .cm-editor .cm-gutters,html .cm-editor .cm-scroller,html .cm-editor .cm-tooltip{font-family:var(
|
|
2
2
|
--font-code,ui-monospace,"SF Mono",Menlo,Monaco,Consolas,monospace
|
|
3
|
-
)!important}html.dark .tiptap .shiki,html.dark .tiptap .shiki span{background-color:var(--ui-bg-muted)!important;color:var(--shiki-dark)!important}.collaboration-carets__caret{border-left:1px solid #0d0d0d;border-right:1px solid #0d0d0d;margin-left:-1px;margin-right:-1px;opacity:0;pointer-events:none;position:relative;transition:opacity .3s ease;word-break:normal}.collaboration-carets__caret.is-hidden{display:none}.collaboration-carets__caret.is-active{opacity:1}.collaboration-carets__label{border-radius:3px 3px 3px 0;color:#0d0d0d;font-size:12px;font-style:normal;font-weight:600;left:-1px;line-height:normal;padding:.1rem .3rem;position:absolute;top:-1.4em;-webkit-user-select:none;-moz-user-select:none;user-select:none;white-space:nowrap}.ProseMirror-yjs-selection,.collaboration-carets__selection{background-color:var(--collaboration-selection-color)!important;pointer-events:none}.search-highlight{background-color:color-mix(in srgb,var(--color-primary-400) 35%,transparent);border-radius:2px;padding:0 1px}.doc-passage-highlight{background-color:color-mix(in srgb,var(--color-success-400) 35%,transparent);border-radius:2px;padding:0 1px}.tiptap{min-height:100%;padding-bottom:8rem}.tiptap.file-drop-active{border-radius:4px;outline:2px dashed var(--ui-primary);outline-offset:4px}.tiptap .document-header{font-size:2.5rem;font-weight:800;letter-spacing:-.025em;line-height:1.2;margin-bottom:1rem}.tiptap [data-type=document-meta]{align-items:center;display:flex;flex-wrap:wrap;font-size:.875rem;gap:.375rem;line-height:1.75rem;margin-bottom:1.5rem;min-height:1.75rem}.tiptap [data-type=document-meta][data-cursor-in-meta=true][data-empty=true]:after{color:var(--ui-text-dimmed);content:"Type '/' to add a property…";pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.prose-variant .tiptap [data-type=document-meta]{display:none}
|
|
3
|
+
)!important}html.dark .tiptap .shiki,html.dark .tiptap .shiki span{background-color:var(--ui-bg-muted)!important;color:var(--shiki-dark)!important}.collaboration-carets__caret{border-left:1px solid #0d0d0d;border-right:1px solid #0d0d0d;margin-left:-1px;margin-right:-1px;opacity:0;pointer-events:none;position:relative;transition:opacity .3s ease;word-break:normal}.collaboration-carets__caret.is-hidden{display:none}.collaboration-carets__caret.is-active{opacity:1}.collaboration-carets__label{border-radius:3px 3px 3px 0;color:#0d0d0d;font-size:12px;font-style:normal;font-weight:600;left:-1px;line-height:normal;padding:.1rem .3rem;position:absolute;top:-1.4em;-webkit-user-select:none;-moz-user-select:none;user-select:none;white-space:nowrap}.ProseMirror-yjs-selection,.collaboration-carets__selection{background-color:var(--collaboration-selection-color)!important;pointer-events:none}.search-highlight{background-color:color-mix(in srgb,var(--color-primary-400) 35%,transparent);border-radius:2px;padding:0 1px}.doc-passage-highlight{background-color:color-mix(in srgb,var(--color-success-400) 35%,transparent);border-radius:2px;padding:0 1px}.tiptap{min-height:100%;padding-bottom:8rem}.tiptap.file-drop-active{border-radius:4px;outline:2px dashed var(--ui-primary);outline-offset:4px}.tiptap .document-header{font-size:2.5rem;font-weight:800;letter-spacing:-.025em;line-height:1.2;margin-bottom:1rem}.tiptap [data-type=document-meta]{align-items:center;display:flex;flex-wrap:wrap;font-size:.875rem;gap:.375rem;line-height:1.75rem;margin-bottom:1.5rem;min-height:1.75rem}.tiptap [data-type=document-meta][data-cursor-in-meta=true][data-empty=true]:after{color:var(--ui-text-dimmed);content:"Type '/' to add a property…";pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.prose-variant .tiptap [data-type=document-meta]{display:none}.tiptap .tableWrapper{max-width:100%;overflow-x:auto}.tiptap table{border-collapse:separate;border-spacing:0;margin:.75rem 0;min-width:-moz-max-content;min-width:max-content;width:100%}.tiptap :is(th,td){border-bottom:1px solid var(--ui-border);border-right:1px solid var(--ui-border);font-size:.875rem;padding:.75rem 1rem;text-align:left;vertical-align:top}.tiptap :is(th,td):first-child{border-left:1px solid var(--ui-border)}.tiptap th{background-color:color-mix(in srgb,var(--ui-bg-muted) 50%,transparent);border-top:1px solid var(--ui-border);font-weight:600}.tiptap tr:first-child th:first-child{border-top-left-radius:.375rem}.tiptap tr:first-child th:last-child{border-top-right-radius:.375rem}.tiptap tr:last-child td:first-child{border-bottom-left-radius:.375rem}.tiptap tr:last-child td:last-child{border-bottom-right-radius:.375rem}.tiptap :is(th,td)>p{line-height:1.25rem;margin:0}.tiptap .selectedCell{background-color:color-mix(in srgb,var(--ui-primary) 10%,transparent);box-shadow:inset 0 0 0 2px var(--ui-primary)}
|
|
@@ -13,6 +13,15 @@ type __VLS_Props = {
|
|
|
13
13
|
editorClass?: string;
|
|
14
14
|
/** CSS class applied to structured renderers (kanban, table, etc.) */
|
|
15
15
|
rendererClass?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Wrapper classes for `layout: 'canvas'` renderers (graph, map, sheets, …)
|
|
18
|
+
* when NO `rendererClass` is supplied. Those renderers root at
|
|
19
|
+
* `flex-1 min-h-0` and collapse to ~0px in normal document flow, so we give
|
|
20
|
+
* them a bounded flex-column viewport by default. Override to change the
|
|
21
|
+
* height (e.g. `'flex flex-col w-full h-[80vh]'`) or pass `rendererClass`
|
|
22
|
+
* to opt out of the wrapper entirely and size the renderer yourself.
|
|
23
|
+
*/
|
|
24
|
+
canvasClass?: string;
|
|
16
25
|
/**
|
|
17
26
|
* Override the doc-tree lookup with an explicit entry (`type`/`label`/`meta`).
|
|
18
27
|
* Use this when rendering a doc that is NOT in the active provider's root
|
|
@@ -37,6 +46,7 @@ type __VLS_Slots = {} & {
|
|
|
37
46
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
38
47
|
editable: boolean;
|
|
39
48
|
breadcrumbMenu: boolean;
|
|
49
|
+
canvasClass: string;
|
|
40
50
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
41
51
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
42
52
|
declare const _default: typeof __VLS_export;
|
|
@@ -11,6 +11,7 @@ const props = defineProps({
|
|
|
11
11
|
breadcrumbMenu: { type: Boolean, required: false, default: true },
|
|
12
12
|
editorClass: { type: String, required: false },
|
|
13
13
|
rendererClass: { type: String, required: false },
|
|
14
|
+
canvasClass: { type: String, required: false, default: "flex flex-col w-full h-[70vh] min-h-[420px]" },
|
|
14
15
|
entry: { type: [Object, null], required: false }
|
|
15
16
|
});
|
|
16
17
|
const abra = useAbracadabra();
|
|
@@ -52,6 +53,12 @@ const { data: ssrContent } = useFetch(
|
|
|
52
53
|
const resolvedClass = computed(
|
|
53
54
|
() => docTypeDef.value.hasEditor ? props.editorClass ?? void 0 : props.rendererClass ?? void 0
|
|
54
55
|
);
|
|
56
|
+
const effectiveLayout = computed(
|
|
57
|
+
() => docTypeDef.value.layout ?? (docTypeDef.value.hasEditor ? "flow" : "canvas")
|
|
58
|
+
);
|
|
59
|
+
const wrapperClass = computed(
|
|
60
|
+
() => effectiveLayout.value === "canvas" && !props.rendererClass ? props.canvasClass : "contents"
|
|
61
|
+
);
|
|
55
62
|
</script>
|
|
56
63
|
|
|
57
64
|
<template>
|
|
@@ -93,16 +100,21 @@ const resolvedClass = computed(
|
|
|
93
100
|
/>
|
|
94
101
|
</slot>
|
|
95
102
|
|
|
96
|
-
<!-- Resolved renderer
|
|
97
|
-
|
|
98
|
-
|
|
103
|
+
<!-- Resolved renderer — wrapped so `layout: 'canvas'` types get a bounded
|
|
104
|
+
viewport (wrapper is `display: contents` for flow/consumer-sized types). -->
|
|
105
|
+
<div
|
|
99
106
|
v-else
|
|
100
|
-
:
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
:class="wrapperClass"
|
|
108
|
+
>
|
|
109
|
+
<component
|
|
110
|
+
:is="docTypeDef.component"
|
|
111
|
+
:doc-id="docId"
|
|
112
|
+
:doc-label="docTitle"
|
|
113
|
+
:doc-meta="docMeta"
|
|
114
|
+
:child-provider="childProvider"
|
|
115
|
+
:editable="editable"
|
|
116
|
+
:breadcrumb-menu="breadcrumbMenu"
|
|
117
|
+
:class="resolvedClass"
|
|
118
|
+
/>
|
|
119
|
+
</div>
|
|
108
120
|
</template>
|
|
@@ -13,6 +13,15 @@ type __VLS_Props = {
|
|
|
13
13
|
editorClass?: string;
|
|
14
14
|
/** CSS class applied to structured renderers (kanban, table, etc.) */
|
|
15
15
|
rendererClass?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Wrapper classes for `layout: 'canvas'` renderers (graph, map, sheets, …)
|
|
18
|
+
* when NO `rendererClass` is supplied. Those renderers root at
|
|
19
|
+
* `flex-1 min-h-0` and collapse to ~0px in normal document flow, so we give
|
|
20
|
+
* them a bounded flex-column viewport by default. Override to change the
|
|
21
|
+
* height (e.g. `'flex flex-col w-full h-[80vh]'`) or pass `rendererClass`
|
|
22
|
+
* to opt out of the wrapper entirely and size the renderer yourself.
|
|
23
|
+
*/
|
|
24
|
+
canvasClass?: string;
|
|
16
25
|
/**
|
|
17
26
|
* Override the doc-tree lookup with an explicit entry (`type`/`label`/`meta`).
|
|
18
27
|
* Use this when rendering a doc that is NOT in the active provider's root
|
|
@@ -37,6 +46,7 @@ type __VLS_Slots = {} & {
|
|
|
37
46
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
38
47
|
editable: boolean;
|
|
39
48
|
breadcrumbMenu: boolean;
|
|
49
|
+
canvasClass: string;
|
|
40
50
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
41
51
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
42
52
|
declare const _default: typeof __VLS_export;
|
|
@@ -95,15 +95,15 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
95
95
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
96
96
|
rename: (label: string) => any;
|
|
97
97
|
ready: () => any;
|
|
98
|
+
update: (content: any) => any;
|
|
98
99
|
"update:modelValue": (value: any) => any;
|
|
99
100
|
updateMeta: (patch: Partial<DocPageMeta>) => any;
|
|
100
|
-
update: (content: any) => any;
|
|
101
101
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
102
102
|
onRename?: ((label: string) => any) | undefined;
|
|
103
103
|
onReady?: (() => any) | undefined;
|
|
104
|
+
onUpdate?: ((content: any) => any) | undefined;
|
|
104
105
|
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
105
106
|
onUpdateMeta?: ((patch: Partial<DocPageMeta>) => any) | undefined;
|
|
106
|
-
onUpdate?: ((content: any) => any) | undefined;
|
|
107
107
|
}>, {
|
|
108
108
|
contentType: "json" | "html" | "markdown";
|
|
109
109
|
editable: boolean;
|
|
@@ -95,15 +95,15 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
95
95
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
96
96
|
rename: (label: string) => any;
|
|
97
97
|
ready: () => any;
|
|
98
|
+
update: (content: any) => any;
|
|
98
99
|
"update:modelValue": (value: any) => any;
|
|
99
100
|
updateMeta: (patch: Partial<DocPageMeta>) => any;
|
|
100
|
-
update: (content: any) => any;
|
|
101
101
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
102
102
|
onRename?: ((label: string) => any) | undefined;
|
|
103
103
|
onReady?: (() => any) | undefined;
|
|
104
|
+
onUpdate?: ((content: any) => any) | undefined;
|
|
104
105
|
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
105
106
|
onUpdateMeta?: ((patch: Partial<DocPageMeta>) => any) | undefined;
|
|
106
|
-
onUpdate?: ((content: any) => any) | undefined;
|
|
107
107
|
}>, {
|
|
108
108
|
contentType: "json" | "html" | "markdown";
|
|
109
109
|
editable: boolean;
|
|
@@ -45,11 +45,11 @@ type __VLS_Slots = {} & {
|
|
|
45
45
|
item?: (props: typeof __VLS_24) => any;
|
|
46
46
|
};
|
|
47
47
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
48
|
-
open: (id: string, label: string) => any;
|
|
49
48
|
create: () => any;
|
|
49
|
+
open: (id: string, label: string) => any;
|
|
50
50
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
51
|
-
onOpen?: ((id: string, label: string) => any) | undefined;
|
|
52
51
|
onCreate?: (() => any) | undefined;
|
|
52
|
+
onOpen?: ((id: string, label: string) => any) | undefined;
|
|
53
53
|
}>, {
|
|
54
54
|
layout: "list" | "grid" | "compact";
|
|
55
55
|
emptyText: string;
|
|
@@ -45,11 +45,11 @@ type __VLS_Slots = {} & {
|
|
|
45
45
|
item?: (props: typeof __VLS_24) => any;
|
|
46
46
|
};
|
|
47
47
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
48
|
-
open: (id: string, label: string) => any;
|
|
49
48
|
create: () => any;
|
|
49
|
+
open: (id: string, label: string) => any;
|
|
50
50
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
51
|
-
onOpen?: ((id: string, label: string) => any) | undefined;
|
|
52
51
|
onCreate?: (() => any) | undefined;
|
|
52
|
+
onOpen?: ((id: string, label: string) => any) | undefined;
|
|
53
53
|
}>, {
|
|
54
54
|
layout: "list" | "grid" | "compact";
|
|
55
55
|
emptyText: string;
|
|
@@ -73,12 +73,13 @@ defineExpose({ startEdit });
|
|
|
73
73
|
|
|
74
74
|
<template>
|
|
75
75
|
<span
|
|
76
|
+
v-if="modelValue || !disabled"
|
|
76
77
|
class="inline-node-label group/label inline-flex items-center rounded-sm min-w-[1ch]"
|
|
77
78
|
:class="[
|
|
78
79
|
variant === 'title' && 'font-semibold text-(--ui-text-highlighted)',
|
|
79
80
|
variant === 'name' && 'font-mono font-semibold text-(--ui-primary)',
|
|
80
81
|
variant === 'label' && 'text-(--ui-text-highlighted)',
|
|
81
|
-
editing ? 'ring-1 ring-(--ui-primary) bg-(--ui-bg-elevated) px-1 -mx-1' : 'hover:bg-(--ui-bg-elevated)/60 px-1 -mx-1 cursor-text'
|
|
82
|
+
disabled ? '' : editing ? 'ring-1 ring-(--ui-primary) bg-(--ui-bg-elevated) px-1 -mx-1' : 'hover:bg-(--ui-bg-elevated)/60 px-1 -mx-1 cursor-text'
|
|
82
83
|
]"
|
|
83
84
|
contenteditable="false"
|
|
84
85
|
@click="startEdit"
|
|
@@ -96,6 +97,6 @@ defineExpose({ startEdit });
|
|
|
96
97
|
@blur="commit"
|
|
97
98
|
@keydown="onKeydown"
|
|
98
99
|
@paste="onPaste"
|
|
99
|
-
>{{ modelValue || (editing ? "" : placeholder) }}</span>
|
|
100
|
+
>{{ modelValue || (editing || disabled ? "" : placeholder) }}</span>
|
|
100
101
|
</span>
|
|
101
102
|
</template>
|
|
@@ -11,13 +11,13 @@ type __VLS_Props = {
|
|
|
11
11
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, Record<PropertyKey, unknown>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
12
12
|
rename: (label: string) => any;
|
|
13
13
|
ready: () => any;
|
|
14
|
-
updateMeta: (patch: Partial<DocPageMeta>) => any;
|
|
15
14
|
update: (content: any) => any;
|
|
15
|
+
updateMeta: (patch: Partial<DocPageMeta>) => any;
|
|
16
16
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
17
17
|
onRename?: ((label: string) => any) | undefined;
|
|
18
18
|
onReady?: (() => any) | undefined;
|
|
19
|
-
onUpdateMeta?: ((patch: Partial<DocPageMeta>) => any) | undefined;
|
|
20
19
|
onUpdate?: ((content: any) => any) | undefined;
|
|
20
|
+
onUpdateMeta?: ((patch: Partial<DocPageMeta>) => any) | undefined;
|
|
21
21
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
22
22
|
declare const _default: typeof __VLS_export;
|
|
23
23
|
export default _default;
|
|
@@ -11,13 +11,13 @@ type __VLS_Props = {
|
|
|
11
11
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, Record<PropertyKey, unknown>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
12
12
|
rename: (label: string) => any;
|
|
13
13
|
ready: () => any;
|
|
14
|
-
updateMeta: (patch: Partial<DocPageMeta>) => any;
|
|
15
14
|
update: (content: any) => any;
|
|
15
|
+
updateMeta: (patch: Partial<DocPageMeta>) => any;
|
|
16
16
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
17
17
|
onRename?: ((label: string) => any) | undefined;
|
|
18
18
|
onReady?: (() => any) | undefined;
|
|
19
|
-
onUpdateMeta?: ((patch: Partial<DocPageMeta>) => any) | undefined;
|
|
20
19
|
onUpdate?: ((content: any) => any) | undefined;
|
|
20
|
+
onUpdateMeta?: ((patch: Partial<DocPageMeta>) => any) | undefined;
|
|
21
21
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
22
22
|
declare const _default: typeof __VLS_export;
|
|
23
23
|
export default _default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
import type { Editor } from '@tiptap/core';
|
|
3
|
+
import type { Node as PMNode } from '@tiptap/pm/model';
|
|
4
|
+
interface NodeViewLike {
|
|
5
|
+
editor: Editor;
|
|
6
|
+
node: PMNode;
|
|
7
|
+
getPos: () => number | undefined;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Reactive `editor.isEditable` for TipTap Vue node views.
|
|
11
|
+
*
|
|
12
|
+
* Node views receive `editor` as a plain (non-reactive) object, so reading
|
|
13
|
+
* `editor.isEditable` in a template never updates when the surrounding
|
|
14
|
+
* editor flips between editable and read-only (role changes, offline
|
|
15
|
+
* fallback, `setEditable`). This keeps a ref in sync via editor events.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useNodeViewEditable(props: Pick<NodeViewLike, 'editor'>): Ref<boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* Calls `onInside(childIndex)` whenever the text selection moves inside this
|
|
20
|
+
* node's content. Collapsed containers (accordion items, collapsibles, tab
|
|
21
|
+
* panels) use it to reveal themselves instead of trapping the caret in
|
|
22
|
+
* `display: none` content — arrow keys, find-in-doc jumps, and remote
|
|
23
|
+
* collaborator follows all land in hidden regions otherwise.
|
|
24
|
+
*
|
|
25
|
+
* `childIndex` is the index of the direct child containing the selection
|
|
26
|
+
* start (for tab panels); ignore it for single-content containers.
|
|
27
|
+
*/
|
|
28
|
+
export declare function useNodeViewSelectionInside(props: NodeViewLike, onInside: (childIndex: number) => void): void;
|
|
29
|
+
/**
|
|
30
|
+
* Persist node attributes without polluting undo history. For view-state
|
|
31
|
+
* attributes (collapsible `open`, spoiler `revealed`) the author's last
|
|
32
|
+
* toggle becomes the document default, but Cmd+Z must never "un-toggle" a
|
|
33
|
+
* disclosure. Only call from editable editors.
|
|
34
|
+
*/
|
|
35
|
+
export declare function persistAttrsQuietly(props: Pick<NodeViewLike, 'editor' | 'getPos'>, attrs: Record<string, unknown>): void;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ref, onBeforeUnmount } from "vue";
|
|
2
|
+
export function useNodeViewEditable(props) {
|
|
3
|
+
const editable = ref(props.editor.isEditable);
|
|
4
|
+
const sync = () => {
|
|
5
|
+
editable.value = props.editor.isEditable;
|
|
6
|
+
};
|
|
7
|
+
props.editor.on("update", sync);
|
|
8
|
+
props.editor.on("transaction", sync);
|
|
9
|
+
onBeforeUnmount(() => {
|
|
10
|
+
props.editor.off("update", sync);
|
|
11
|
+
props.editor.off("transaction", sync);
|
|
12
|
+
});
|
|
13
|
+
return editable;
|
|
14
|
+
}
|
|
15
|
+
export function useNodeViewSelectionInside(props, onInside) {
|
|
16
|
+
const handler = () => {
|
|
17
|
+
const pos = props.getPos();
|
|
18
|
+
if (typeof pos !== "number") return;
|
|
19
|
+
const { from } = props.editor.state.selection;
|
|
20
|
+
const start = pos + 1;
|
|
21
|
+
const end = pos + props.node.nodeSize - 1;
|
|
22
|
+
if (from <= start || from >= end) return;
|
|
23
|
+
let index = 0;
|
|
24
|
+
let offset = 0;
|
|
25
|
+
props.node.forEach((child, childOffset, i) => {
|
|
26
|
+
if (from >= start + childOffset && from < start + childOffset + child.nodeSize) {
|
|
27
|
+
index = i;
|
|
28
|
+
offset = childOffset;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
void offset;
|
|
32
|
+
onInside(index);
|
|
33
|
+
};
|
|
34
|
+
props.editor.on("selectionUpdate", handler);
|
|
35
|
+
onBeforeUnmount(() => props.editor.off("selectionUpdate", handler));
|
|
36
|
+
}
|
|
37
|
+
export function persistAttrsQuietly(props, attrs) {
|
|
38
|
+
const pos = props.getPos();
|
|
39
|
+
if (typeof pos !== "number") return;
|
|
40
|
+
const { tr } = props.editor.state;
|
|
41
|
+
for (const [key, value] of Object.entries(attrs)) {
|
|
42
|
+
tr.setNodeAttribute(pos, key, value);
|
|
43
|
+
}
|
|
44
|
+
tr.setMeta("addToHistory", false);
|
|
45
|
+
props.editor.view.dispatch(tr);
|
|
46
|
+
}
|
|
@@ -7,7 +7,9 @@ export const Callout = Node.create({
|
|
|
7
7
|
content: "block+",
|
|
8
8
|
addAttributes() {
|
|
9
9
|
return {
|
|
10
|
-
type: { default: "note" }
|
|
10
|
+
type: { default: "note" },
|
|
11
|
+
title: { default: "" },
|
|
12
|
+
icon: { default: "" }
|
|
11
13
|
};
|
|
12
14
|
},
|
|
13
15
|
parseHTML() {
|
|
@@ -15,12 +17,20 @@ export const Callout = Node.create({
|
|
|
15
17
|
{
|
|
16
18
|
tag: "div[data-callout]",
|
|
17
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
-
getAttrs: (el) => ({
|
|
20
|
+
getAttrs: (el) => ({
|
|
21
|
+
type: el.getAttribute("data-callout"),
|
|
22
|
+
title: el.getAttribute("data-title") || "",
|
|
23
|
+
icon: el.getAttribute("data-icon") || ""
|
|
24
|
+
})
|
|
19
25
|
}
|
|
20
26
|
];
|
|
21
27
|
},
|
|
22
28
|
renderHTML({ HTMLAttributes }) {
|
|
23
|
-
return ["div", mergeAttributes({
|
|
29
|
+
return ["div", mergeAttributes({
|
|
30
|
+
"data-callout": HTMLAttributes.type,
|
|
31
|
+
"data-title": HTMLAttributes.title,
|
|
32
|
+
"data-icon": HTMLAttributes.icon
|
|
33
|
+
}), 0];
|
|
24
34
|
},
|
|
25
35
|
addNodeView() {
|
|
26
36
|
return VueNodeViewRenderer(CalloutView);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { NodeViewWrapper, NodeViewContent } from "@tiptap/vue-3";
|
|
3
2
|
import { ref, computed } from "vue";
|
|
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, useNodeViewSelectionInside } from "../../composables/useNodeView";
|
|
4
7
|
const props = defineProps({
|
|
5
8
|
decorations: { type: Array, required: true },
|
|
6
9
|
selected: { type: Boolean, required: true },
|
|
@@ -14,9 +17,23 @@ 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 open = ref(false);
|
|
18
|
-
const label = computed(() => props.node.attrs.label || "
|
|
22
|
+
const label = computed(() => props.node.attrs.label || "");
|
|
19
23
|
const icon = computed(() => props.node.attrs.icon || "");
|
|
24
|
+
const iconShort = computed(() => icon.value.replace(/^i-lucide-/, ""));
|
|
25
|
+
const iconPopoverOpen = ref(false);
|
|
26
|
+
useNodeViewSelectionInside(props, () => {
|
|
27
|
+
open.value = true;
|
|
28
|
+
});
|
|
29
|
+
function setLabel(v) {
|
|
30
|
+
if (!editable.value) return;
|
|
31
|
+
props.updateAttributes({ label: v });
|
|
32
|
+
}
|
|
33
|
+
function setIcon(name) {
|
|
34
|
+
if (!editable.value) return;
|
|
35
|
+
props.updateAttributes({ icon: name ? `i-lucide-${name}` : "" });
|
|
36
|
+
}
|
|
20
37
|
</script>
|
|
21
38
|
|
|
22
39
|
<template>
|
|
@@ -24,24 +41,58 @@ const icon = computed(() => props.node.attrs.icon || "");
|
|
|
24
41
|
as="div"
|
|
25
42
|
class="border-b border-(--ui-border) last:border-b-0"
|
|
26
43
|
>
|
|
27
|
-
<
|
|
44
|
+
<div
|
|
28
45
|
contenteditable="false"
|
|
29
|
-
class="group w-full flex
|
|
46
|
+
class="group w-full flex items-center gap-1.5 font-medium text-sm py-3.5 px-4 text-left text-(--ui-text-highlighted) min-w-0 cursor-pointer select-none"
|
|
30
47
|
:data-state="open ? 'open' : 'closed'"
|
|
48
|
+
role="button"
|
|
49
|
+
:aria-expanded="open"
|
|
31
50
|
@click="open = !open"
|
|
32
51
|
>
|
|
52
|
+
<AIconPickerPopover
|
|
53
|
+
v-if="editable"
|
|
54
|
+
:model-value="iconShort"
|
|
55
|
+
:open="iconPopoverOpen"
|
|
56
|
+
@update:model-value="setIcon"
|
|
57
|
+
@update:open="iconPopoverOpen = $event"
|
|
58
|
+
>
|
|
59
|
+
<button
|
|
60
|
+
class="shrink-0 size-5 flex items-center justify-center rounded-sm hover:bg-(--ui-bg-elevated) text-(--ui-text-muted) hover:text-(--ui-text-highlighted)"
|
|
61
|
+
:title="icon ? 'Change icon' : 'Add icon'"
|
|
62
|
+
@click.stop="iconPopoverOpen = true"
|
|
63
|
+
>
|
|
64
|
+
<UIcon
|
|
65
|
+
:name="icon || 'i-lucide-plus'"
|
|
66
|
+
class="size-5"
|
|
67
|
+
:class="!icon ? 'opacity-0 group-hover:opacity-60 transition-opacity' : ''"
|
|
68
|
+
/>
|
|
69
|
+
</button>
|
|
70
|
+
</AIconPickerPopover>
|
|
33
71
|
<UIcon
|
|
34
|
-
v-if="icon"
|
|
72
|
+
v-else-if="icon"
|
|
35
73
|
:name="icon"
|
|
36
|
-
class="shrink-0 size-5"
|
|
74
|
+
class="shrink-0 size-5 text-(--ui-text-muted)"
|
|
37
75
|
/>
|
|
38
|
-
<span
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
76
|
+
<span
|
|
77
|
+
class="flex-1 min-w-0"
|
|
78
|
+
@click.stop="editable ? void 0 : open = !open"
|
|
79
|
+
>
|
|
80
|
+
<ANodeInlineLabel
|
|
81
|
+
:model-value="label"
|
|
82
|
+
placeholder="Item"
|
|
83
|
+
variant="label"
|
|
84
|
+
:disabled="!editable"
|
|
85
|
+
@update:model-value="setLabel"
|
|
86
|
+
/>
|
|
87
|
+
</span>
|
|
88
|
+
<span class="shrink-0 size-6 flex items-center justify-center rounded-sm">
|
|
89
|
+
<UIcon
|
|
90
|
+
name="i-lucide-chevron-down"
|
|
91
|
+
class="size-5 transition-transform duration-200"
|
|
92
|
+
:class="{ 'rotate-180': open }"
|
|
93
|
+
/>
|
|
94
|
+
</span>
|
|
95
|
+
</div>
|
|
45
96
|
<div
|
|
46
97
|
v-show="open"
|
|
47
98
|
class="text-sm pb-3.5 px-4"
|
|
@@ -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>
|