@mantine-vue/code-highlight 2.4.0 → 3.1.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/cjs/index.cjs +511 -576
- package/cjs/index.cjs.map +1 -1
- package/esm/index.mjs +511 -576
- package/esm/index.mjs.map +1 -1
- package/lib/CodeHighlight/CodeHighlight.d.ts +46 -496
- package/lib/CodeHighlight/CodeHighlight.types.d.ts +80 -0
- package/lib/CodeHighlight/CodeHighlight.vue.d.ts +17 -0
- package/lib/CodeHighlight/CodeHighlightControl/CodeHighlightControl.d.ts +2 -68
- package/lib/CodeHighlight/CodeHighlightControl/CodeHighlightControl.types.d.ts +20 -0
- package/lib/CodeHighlight/CodeHighlightControl/CodeHighlightControl.vue.d.ts +15 -0
- package/lib/CodeHighlight/CopyCodeButton/CopyCodeButton.d.ts +1 -32
- package/lib/CodeHighlight/CopyCodeButton/CopyCodeButton.vue.d.ts +8 -0
- package/lib/CodeHighlight/CopyCodeButton/CopyIcon.d.ts +1 -13
- package/lib/CodeHighlight/CopyCodeButton/CopyIcon.vue.d.ts +6 -0
- package/lib/CodeHighlight/ExpandCodeButton/ExpandCodeButton.d.ts +1 -41
- package/lib/CodeHighlight/ExpandCodeButton/ExpandCodeButton.vue.d.ts +15 -0
- package/lib/CodeHighlight/ExpandCodeButton/ExpandIcon.d.ts +1 -13
- package/lib/CodeHighlight/ExpandCodeButton/ExpandIcon.vue.d.ts +6 -0
- package/lib/CodeHighlight/InlineCodeHighlight.d.ts +16 -107
- package/lib/CodeHighlight/InlineCodeHighlight.types.d.ts +30 -0
- package/lib/CodeHighlight/InlineCodeHighlight.vue.d.ts +5 -0
- package/lib/CodeHighlightProvider/CodeHighlightAdapterProvider.vue.d.ts +14 -0
- package/lib/CodeHighlightProvider/CodeHighlightProvider.d.ts +19 -32
- package/lib/CodeHighlightProvider/CodeHighlightProvider.types.d.ts +25 -0
- package/lib/CodeHighlightTabs/CodeHighlightTabs.d.ts +43 -262
- package/lib/CodeHighlightTabs/CodeHighlightTabs.types.d.ts +47 -0
- package/lib/CodeHighlightTabs/CodeHighlightTabs.vue.d.ts +21 -0
- package/lib/CodeHighlightTabs/FileIcon.d.ts +1 -40
- package/lib/CodeHighlightTabs/FileIcon.vue.d.ts +21 -0
- package/lib/index.d.mts +3 -3
- package/lib/index.d.ts +3 -3
- package/package.json +3 -3
package/esm/index.mjs
CHANGED
|
@@ -1,300 +1,283 @@
|
|
|
1
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createStaticVNode, createTextVNode, createVNode, defineComponent, guardReactiveProps, inject, mergeProps, normalizeProps, onMounted, openBlock, provide, ref, renderList, renderSlot, resolveDynamicComponent, toDisplayString, unref, useAttrs, useSlots, watch, withCtx } from "vue";
|
|
1
2
|
import { ActionIcon, Box, ScrollArea, Tooltip, UnstyledButton, createSafeContext, createVarsResolver, getRadius, getThemeColor, rem, useMantineContext, useProps, useStyles } from "@mantine-vue/core";
|
|
2
3
|
import { useClipboard, useUncontrolled } from "@mantine-vue/hooks";
|
|
3
|
-
import { computed, defineComponent, h, inject, onMounted, provide, ref, watch } from "vue";
|
|
4
|
-
var CodeHighlight_module_default = {
|
|
5
|
-
root: "_root_1avu3_1",
|
|
6
|
-
codeHighlight: "_codeHighlight_1avu3_5",
|
|
7
|
-
inlineCodeHighlight: "_inlineCodeHighlight_1avu3_37",
|
|
8
|
-
pre: "_pre_1avu3_71",
|
|
9
|
-
code: "_code_1avu3_5",
|
|
10
|
-
controls: "_controls_1avu3_101",
|
|
11
|
-
control: "_control_1avu3_101",
|
|
12
|
-
controlTooltip: "_controlTooltip_1avu3_146",
|
|
13
|
-
codeWrapper: "_codeWrapper_1avu3_158",
|
|
14
|
-
lineNumbers: "_lineNumbers_1avu3_165",
|
|
15
|
-
scrollarea: "_scrollarea_1avu3_182",
|
|
16
|
-
showCodeButton: "_showCodeButton_1avu3_207",
|
|
17
|
-
file: "_file_1avu3_234",
|
|
18
|
-
fileIcon: "_fileIcon_1avu3_305",
|
|
19
|
-
filesScrollarea: "_filesScrollarea_1avu3_311",
|
|
20
|
-
files: "_files_1avu3_311"
|
|
21
|
-
};
|
|
22
|
-
//#endregion
|
|
23
4
|
//#region src/CodeHighlightProvider/adapters/plain-text-adapter.ts
|
|
24
5
|
var plainTextAdapter = { getHighlighter: () => ({ code }) => ({
|
|
25
6
|
highlightedCode: code,
|
|
26
7
|
isHighlighted: false
|
|
27
8
|
}) };
|
|
28
9
|
//#endregion
|
|
29
|
-
//#region src/CodeHighlightProvider/
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
function useHighlight() {
|
|
35
|
-
return inject(CodeHighlightContext, null)?.highlight || plainTextAdapter.getHighlighter(null);
|
|
36
|
-
}
|
|
37
|
-
var CodeHighlightAdapterProvider = defineComponent({
|
|
10
|
+
//#region src/CodeHighlightProvider/CodeHighlightAdapterProvider.vue?vue&type=script&setup=true&lang.ts
|
|
11
|
+
var _hoisted_1$1 = { style: { "display": "contents" } };
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/CodeHighlightProvider/CodeHighlightAdapterProvider.vue
|
|
14
|
+
var CodeHighlightAdapterProvider_default = /* @__PURE__ */ defineComponent({
|
|
38
15
|
name: "CodeHighlightAdapterProvider",
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
setup(props, { slots }) {
|
|
16
|
+
__name: "CodeHighlightAdapterProvider",
|
|
17
|
+
props: { adapter: {} },
|
|
18
|
+
setup(__props) {
|
|
19
|
+
const props = __props;
|
|
44
20
|
const context = ref(null);
|
|
45
21
|
const highlight = computed(() => props.adapter.getHighlighter(context.value));
|
|
46
|
-
onMounted(() => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
});
|
|
22
|
+
onMounted(() => props.adapter.loadContext?.().then((value) => {
|
|
23
|
+
context.value = value;
|
|
24
|
+
}));
|
|
51
25
|
provideCodeHighlightAdapterContext({
|
|
52
26
|
adapter: props.adapter,
|
|
53
27
|
get highlight() {
|
|
54
28
|
return highlight.value;
|
|
55
29
|
}
|
|
56
30
|
});
|
|
57
|
-
return () =>
|
|
31
|
+
return (_ctx, _cache) => {
|
|
32
|
+
return openBlock(), createElementBlock("div", _hoisted_1$1, [renderSlot(_ctx.$slots, "default")]);
|
|
33
|
+
};
|
|
58
34
|
}
|
|
59
35
|
});
|
|
60
36
|
//#endregion
|
|
37
|
+
//#region src/CodeHighlightProvider/CodeHighlightProvider.ts
|
|
38
|
+
var CodeHighlightContext = Symbol("CodeHighlightContext");
|
|
39
|
+
function provideCodeHighlightAdapterContext(value) {
|
|
40
|
+
provide(CodeHighlightContext, value);
|
|
41
|
+
}
|
|
42
|
+
function useHighlight() {
|
|
43
|
+
return inject(CodeHighlightContext, null)?.highlight || plainTextAdapter.getHighlighter(null);
|
|
44
|
+
}
|
|
45
|
+
var CodeHighlightAdapterProvider = CodeHighlightAdapterProvider_default;
|
|
46
|
+
//#endregion
|
|
61
47
|
//#region src/CodeHighlight/CodeHighlight.context.ts
|
|
62
48
|
var [provideCodeHighlightContext, useCodeHighlightContext] = createSafeContext("CodeHighlightProvider was not found in the component tree");
|
|
63
49
|
//#endregion
|
|
64
|
-
//#region src/CodeHighlight/CodeHighlightControl/CodeHighlightControl.
|
|
65
|
-
var
|
|
50
|
+
//#region src/CodeHighlight/CodeHighlightControl/CodeHighlightControl.vue
|
|
51
|
+
var CodeHighlightControl_default = /* @__PURE__ */ defineComponent({
|
|
66
52
|
name: "CodeHighlightControl",
|
|
67
53
|
inheritAttrs: false,
|
|
54
|
+
__name: "CodeHighlightControl",
|
|
68
55
|
props: {
|
|
69
|
-
tooltipLabel: {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
type: [Object, Function],
|
|
75
|
-
default: void 0
|
|
76
|
-
},
|
|
77
|
-
styles: {
|
|
78
|
-
type: [Object, Function],
|
|
79
|
-
default: void 0
|
|
80
|
-
},
|
|
81
|
-
vars: {
|
|
82
|
-
type: [Object, Function],
|
|
83
|
-
default: void 0
|
|
84
|
-
},
|
|
85
|
-
component: {
|
|
86
|
-
type: String,
|
|
87
|
-
default: "button"
|
|
88
|
-
},
|
|
89
|
-
onClick: {
|
|
90
|
-
type: Function,
|
|
91
|
-
default: void 0
|
|
92
|
-
}
|
|
56
|
+
tooltipLabel: {},
|
|
57
|
+
component: { default: "button" },
|
|
58
|
+
classNames: {},
|
|
59
|
+
styles: {},
|
|
60
|
+
vars: {}
|
|
93
61
|
},
|
|
94
|
-
|
|
62
|
+
emits: ["click"],
|
|
63
|
+
setup(__props, { emit: __emit }) {
|
|
64
|
+
const rawProps = __props;
|
|
65
|
+
const emit = __emit;
|
|
95
66
|
const props = useProps("CodeHighlightControl", null, rawProps);
|
|
67
|
+
const attrs = useAttrs();
|
|
96
68
|
const ctx = useCodeHighlightContext();
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
component: props.component,
|
|
103
|
-
variant: "none",
|
|
104
|
-
"data-code-color-scheme": ctx.codeColorScheme,
|
|
105
|
-
onClick: props.onClick
|
|
106
|
-
}, slots);
|
|
107
|
-
return props.tooltipLabel ? h(Tooltip, {
|
|
108
|
-
label: props.tooltipLabel,
|
|
69
|
+
const tooltipStyles = computed(() => ctx.getStyles("controlTooltip"));
|
|
70
|
+
return (_ctx, _cache) => {
|
|
71
|
+
return unref(props).tooltipLabel ? (openBlock(), createBlock(unref(Tooltip), {
|
|
72
|
+
key: 0,
|
|
73
|
+
label: unref(props).tooltipLabel,
|
|
109
74
|
fz: "sm",
|
|
110
75
|
position: "bottom",
|
|
111
|
-
|
|
112
|
-
styles: { tooltip: tooltipStyles.style },
|
|
113
|
-
"data-code-color-scheme": ctx.codeColorScheme,
|
|
114
|
-
|
|
115
|
-
},
|
|
76
|
+
"class-names": { tooltip: tooltipStyles.value.class },
|
|
77
|
+
styles: { tooltip: tooltipStyles.value.style },
|
|
78
|
+
"data-code-color-scheme": unref(ctx).codeColorScheme,
|
|
79
|
+
"transition-props": { duration: 0 }
|
|
80
|
+
}, {
|
|
81
|
+
default: withCtx(() => [createVNode(unref(ActionIcon), mergeProps({
|
|
82
|
+
...unref(ctx).getStyles("control"),
|
|
83
|
+
...unref(attrs)
|
|
84
|
+
}, {
|
|
85
|
+
component: unref(props).component,
|
|
86
|
+
variant: "none",
|
|
87
|
+
"data-code-color-scheme": unref(ctx).codeColorScheme,
|
|
88
|
+
onClick: _cache[0] || (_cache[0] = (event) => emit("click", event))
|
|
89
|
+
}), {
|
|
90
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
91
|
+
_: 3
|
|
92
|
+
}, 16, ["component", "data-code-color-scheme"])]),
|
|
93
|
+
_: 3
|
|
94
|
+
}, 8, [
|
|
95
|
+
"label",
|
|
96
|
+
"class-names",
|
|
97
|
+
"styles",
|
|
98
|
+
"data-code-color-scheme"
|
|
99
|
+
])) : (openBlock(), createBlock(unref(ActionIcon), mergeProps({ key: 1 }, {
|
|
100
|
+
...unref(ctx).getStyles("control"),
|
|
101
|
+
...unref(attrs)
|
|
102
|
+
}, {
|
|
103
|
+
component: unref(props).component,
|
|
104
|
+
variant: "none",
|
|
105
|
+
"data-code-color-scheme": unref(ctx).codeColorScheme,
|
|
106
|
+
onClick: _cache[1] || (_cache[1] = (event) => emit("click", event))
|
|
107
|
+
}), {
|
|
108
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
109
|
+
_: 3
|
|
110
|
+
}, 16, ["component", "data-code-color-scheme"]));
|
|
116
111
|
};
|
|
117
112
|
}
|
|
118
113
|
});
|
|
119
114
|
//#endregion
|
|
120
|
-
//#region src/CodeHighlight/CopyCodeButton/CopyIcon.
|
|
121
|
-
var
|
|
115
|
+
//#region src/CodeHighlight/CopyCodeButton/CopyIcon.vue
|
|
116
|
+
var CopyIcon_default = /* @__PURE__ */ defineComponent({
|
|
122
117
|
name: "CopyIcon",
|
|
123
118
|
inheritAttrs: false,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
strokeLinejoin: "round"
|
|
138
|
-
}, props.copied ? [h("path", {
|
|
139
|
-
stroke: "none",
|
|
140
|
-
d: "M0 0h24v24H0z",
|
|
141
|
-
fill: "none"
|
|
142
|
-
}), h("path", { d: "M5 12l5 5l10 -10" })] : [
|
|
143
|
-
h("path", {
|
|
119
|
+
__name: "CopyIcon",
|
|
120
|
+
props: { copied: { type: Boolean } },
|
|
121
|
+
setup(__props) {
|
|
122
|
+
return (_ctx, _cache) => {
|
|
123
|
+
return openBlock(), createElementBlock("svg", mergeProps(_ctx.$attrs, {
|
|
124
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
125
|
+
viewBox: "0 0 24 24",
|
|
126
|
+
"stroke-width": "2",
|
|
127
|
+
stroke: "currentColor",
|
|
128
|
+
fill: "none",
|
|
129
|
+
"stroke-linecap": "round",
|
|
130
|
+
"stroke-linejoin": "round"
|
|
131
|
+
}), [__props.copied ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [_cache[0] || (_cache[0] = createElementVNode("path", {
|
|
144
132
|
stroke: "none",
|
|
145
133
|
d: "M0 0h24v24H0z",
|
|
146
134
|
fill: "none"
|
|
147
|
-
}),
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
135
|
+
}, null, -1)), _cache[1] || (_cache[1] = createElementVNode("path", { d: "M5 12l5 5l10 -10" }, null, -1))], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
136
|
+
_cache[2] || (_cache[2] = createElementVNode("path", {
|
|
137
|
+
stroke: "none",
|
|
138
|
+
d: "M0 0h24v24H0z",
|
|
139
|
+
fill: "none"
|
|
140
|
+
}, null, -1)),
|
|
141
|
+
_cache[3] || (_cache[3] = createElementVNode("path", { d: "M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z" }, null, -1)),
|
|
142
|
+
_cache[4] || (_cache[4] = createElementVNode("path", { d: "M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2" }, null, -1))
|
|
143
|
+
], 64))], 16);
|
|
144
|
+
};
|
|
151
145
|
}
|
|
152
146
|
});
|
|
153
147
|
//#endregion
|
|
154
|
-
//#region src/CodeHighlight/CopyCodeButton/CopyCodeButton.
|
|
155
|
-
var
|
|
148
|
+
//#region src/CodeHighlight/CopyCodeButton/CopyCodeButton.vue
|
|
149
|
+
var CopyCodeButton_default = /* @__PURE__ */ defineComponent({
|
|
156
150
|
name: "CopyCodeButton",
|
|
151
|
+
__name: "CopyCodeButton",
|
|
157
152
|
props: {
|
|
158
|
-
code: {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
},
|
|
162
|
-
copiedLabel: {
|
|
163
|
-
type: String,
|
|
164
|
-
default: "Copied"
|
|
165
|
-
},
|
|
166
|
-
copyLabel: {
|
|
167
|
-
type: String,
|
|
168
|
-
default: "Copy"
|
|
169
|
-
}
|
|
153
|
+
code: {},
|
|
154
|
+
copiedLabel: { default: "Copied" },
|
|
155
|
+
copyLabel: { default: "Copy" }
|
|
170
156
|
},
|
|
171
|
-
setup(
|
|
157
|
+
setup(__props) {
|
|
158
|
+
const props = __props;
|
|
172
159
|
const clipboard = useClipboard();
|
|
173
|
-
return () =>
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
160
|
+
return (_ctx, _cache) => {
|
|
161
|
+
return openBlock(), createBlock(CodeHighlightControl_default, {
|
|
162
|
+
variant: "none",
|
|
163
|
+
"tooltip-label": unref(clipboard).copied.value ? props.copiedLabel : props.copyLabel,
|
|
164
|
+
"aria-label": unref(clipboard).copied.value ? props.copiedLabel : `${props.copyLabel} code`,
|
|
165
|
+
onClick: _cache[0] || (_cache[0] = ($event) => unref(clipboard).copy(props.code.trim()))
|
|
166
|
+
}, {
|
|
167
|
+
default: withCtx(() => [createVNode(CopyIcon_default, { copied: unref(clipboard).copied.value }, null, 8, ["copied"])]),
|
|
168
|
+
_: 1
|
|
169
|
+
}, 8, ["tooltip-label", "aria-label"]);
|
|
170
|
+
};
|
|
179
171
|
}
|
|
180
172
|
});
|
|
181
173
|
//#endregion
|
|
182
|
-
//#region src/CodeHighlight/ExpandCodeButton/ExpandIcon.
|
|
183
|
-
var
|
|
174
|
+
//#region src/CodeHighlight/ExpandCodeButton/ExpandIcon.vue
|
|
175
|
+
var ExpandIcon_default = /* @__PURE__ */ defineComponent({
|
|
184
176
|
name: "ExpandIcon",
|
|
185
177
|
inheritAttrs: false,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
strokeLinejoin: "round"
|
|
200
|
-
}, props.expanded ? [
|
|
201
|
-
h("path", {
|
|
202
|
-
stroke: "none",
|
|
203
|
-
d: "M0 0h24v24H0z",
|
|
204
|
-
fill: "none"
|
|
205
|
-
}),
|
|
206
|
-
h("path", { d: "M12 13v-8l-3 3m6 0l-3 -3" }),
|
|
207
|
-
h("path", { d: "M9 17l1 0" }),
|
|
208
|
-
h("path", { d: "M14 17l1 0" }),
|
|
209
|
-
h("path", { d: "M19 17l1 0" }),
|
|
210
|
-
h("path", { d: "M4 17l1 0" })
|
|
211
|
-
] : [
|
|
212
|
-
h("path", {
|
|
178
|
+
__name: "ExpandIcon",
|
|
179
|
+
props: { expanded: { type: Boolean } },
|
|
180
|
+
setup(__props) {
|
|
181
|
+
return (_ctx, _cache) => {
|
|
182
|
+
return openBlock(), createElementBlock("svg", mergeProps(_ctx.$attrs, {
|
|
183
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
184
|
+
viewBox: "0 0 24 24",
|
|
185
|
+
"stroke-width": "2",
|
|
186
|
+
stroke: "currentColor",
|
|
187
|
+
fill: "none",
|
|
188
|
+
"stroke-linecap": "round",
|
|
189
|
+
"stroke-linejoin": "round"
|
|
190
|
+
}), [_cache[2] || (_cache[2] = createElementVNode("path", {
|
|
213
191
|
stroke: "none",
|
|
214
192
|
d: "M0 0h24v24H0z",
|
|
215
193
|
fill: "none"
|
|
216
|
-
}),
|
|
217
|
-
|
|
218
|
-
h("path", { d: "M9 7l1 0" }),
|
|
219
|
-
h("path", { d: "M14 7l1 0" }),
|
|
220
|
-
h("path", { d: "M19 7l1 0" }),
|
|
221
|
-
h("path", { d: "M4 7l1 0" })
|
|
222
|
-
]);
|
|
194
|
+
}, null, -1)), __props.expanded ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [_cache[0] || (_cache[0] = createStaticVNode("<path d=\"M12 13v-8l-3 3m6 0l-3 -3\"></path><path d=\"M9 17l1 0\"></path><path d=\"M14 17l1 0\"></path><path d=\"M19 17l1 0\"></path><path d=\"M4 17l1 0\"></path>", 5))], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [_cache[1] || (_cache[1] = createStaticVNode("<path d=\"M12 11v8l3 -3m-6 0l3 3\"></path><path d=\"M9 7l1 0\"></path><path d=\"M14 7l1 0\"></path><path d=\"M19 7l1 0\"></path><path d=\"M4 7l1 0\"></path>", 5))], 64))], 16);
|
|
195
|
+
};
|
|
223
196
|
}
|
|
224
197
|
});
|
|
225
198
|
//#endregion
|
|
226
|
-
//#region src/CodeHighlight/ExpandCodeButton/ExpandCodeButton.
|
|
227
|
-
var
|
|
199
|
+
//#region src/CodeHighlight/ExpandCodeButton/ExpandCodeButton.vue
|
|
200
|
+
var ExpandCodeButton_default = /* @__PURE__ */ defineComponent({
|
|
228
201
|
name: "ExpandCodeButton",
|
|
202
|
+
__name: "ExpandCodeButton",
|
|
229
203
|
props: {
|
|
230
|
-
expanded: {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
},
|
|
234
|
-
onExpand: {
|
|
235
|
-
type: Function,
|
|
236
|
-
required: true
|
|
237
|
-
},
|
|
238
|
-
collapseCodeLabel: {
|
|
239
|
-
type: String,
|
|
240
|
-
default: "Collapse code"
|
|
241
|
-
},
|
|
242
|
-
expandCodeLabel: {
|
|
243
|
-
type: String,
|
|
244
|
-
default: "Expand code"
|
|
245
|
-
}
|
|
204
|
+
expanded: { type: Boolean },
|
|
205
|
+
collapseCodeLabel: { default: "Collapse code" },
|
|
206
|
+
expandCodeLabel: { default: "Expand code" }
|
|
246
207
|
},
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
208
|
+
emits: ["expand"],
|
|
209
|
+
setup(__props, { emit: __emit }) {
|
|
210
|
+
const props = __props;
|
|
211
|
+
const emit = __emit;
|
|
212
|
+
return (_ctx, _cache) => {
|
|
213
|
+
return openBlock(), createBlock(CodeHighlightControl_default, {
|
|
214
|
+
"tooltip-label": props.expanded ? props.collapseCodeLabel : props.expandCodeLabel,
|
|
215
|
+
"aria-label": props.expanded ? props.collapseCodeLabel : props.expandCodeLabel,
|
|
216
|
+
onClick: _cache[0] || (_cache[0] = ($event) => emit("expand", !props.expanded))
|
|
217
|
+
}, {
|
|
218
|
+
default: withCtx(() => [createVNode(ExpandIcon_default, { expanded: props.expanded }, null, 8, ["expanded"])]),
|
|
219
|
+
_: 1
|
|
220
|
+
}, 8, ["tooltip-label", "aria-label"]);
|
|
221
|
+
};
|
|
253
222
|
}
|
|
254
223
|
});
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
224
|
+
var CodeHighlight_module_default = {
|
|
225
|
+
root: "_root_1avu3_1",
|
|
226
|
+
codeHighlight: "_codeHighlight_1avu3_5",
|
|
227
|
+
inlineCodeHighlight: "_inlineCodeHighlight_1avu3_37",
|
|
228
|
+
pre: "_pre_1avu3_71",
|
|
229
|
+
code: "_code_1avu3_5",
|
|
230
|
+
controls: "_controls_1avu3_101",
|
|
231
|
+
control: "_control_1avu3_101",
|
|
232
|
+
controlTooltip: "_controlTooltip_1avu3_146",
|
|
233
|
+
codeWrapper: "_codeWrapper_1avu3_158",
|
|
234
|
+
lineNumbers: "_lineNumbers_1avu3_165",
|
|
235
|
+
scrollarea: "_scrollarea_1avu3_182",
|
|
236
|
+
showCodeButton: "_showCodeButton_1avu3_207",
|
|
237
|
+
file: "_file_1avu3_234",
|
|
238
|
+
fileIcon: "_fileIcon_1avu3_305",
|
|
239
|
+
filesScrollarea: "_filesScrollarea_1avu3_311",
|
|
240
|
+
files: "_files_1avu3_311"
|
|
261
241
|
};
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/CodeHighlight/CodeHighlight.vue?vue&type=script&setup=true&lang.ts
|
|
244
|
+
var _hoisted_1 = ["data-with-border", "innerHTML"];
|
|
245
|
+
var _hoisted_2 = ["data-with-border"];
|
|
246
|
+
var _hoisted_3 = ["data-with-offset"];
|
|
247
|
+
var _hoisted_4 = ["data-with-offset"];
|
|
248
|
+
var _hoisted_5 = ["data-with-offset"];
|
|
249
|
+
var _hoisted_6 = ["innerHTML"];
|
|
262
250
|
var varsResolver$1 = createVarsResolver((theme, { maxCollapsedHeight, background, radius }) => ({ codeHighlight: {
|
|
263
251
|
"--ch-max-height": rem(maxCollapsedHeight),
|
|
264
252
|
"--ch-background": background ? getThemeColor(background, theme) : void 0,
|
|
265
253
|
"--ch-radius": typeof radius !== "undefined" ? getRadius(radius) : void 0
|
|
266
254
|
} }));
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
function cx(...values) {
|
|
271
|
-
return values.filter(Boolean);
|
|
272
|
-
}
|
|
273
|
-
function resolveColorScheme(value) {
|
|
274
|
-
if (value !== "auto") return value;
|
|
275
|
-
return typeof window !== "undefined" && window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
276
|
-
}
|
|
277
|
-
var CodeHighlightBase = defineComponent({
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region src/CodeHighlight/CodeHighlight.vue
|
|
257
|
+
var CodeHighlight_default = /* @__PURE__ */ defineComponent({
|
|
278
258
|
name: "CodeHighlight",
|
|
279
259
|
inheritAttrs: false,
|
|
280
|
-
|
|
260
|
+
__name: "CodeHighlight",
|
|
281
261
|
props: {
|
|
282
|
-
|
|
283
|
-
type:
|
|
284
|
-
|
|
285
|
-
},
|
|
286
|
-
language: {
|
|
287
|
-
type: String,
|
|
288
|
-
default: void 0
|
|
289
|
-
},
|
|
290
|
-
copyLabel: {
|
|
291
|
-
type: String,
|
|
292
|
-
default: void 0
|
|
262
|
+
__withOffset: {
|
|
263
|
+
type: Boolean,
|
|
264
|
+
default: false
|
|
293
265
|
},
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
266
|
+
__staticSelector: {},
|
|
267
|
+
__inline: {
|
|
268
|
+
type: Boolean,
|
|
269
|
+
default: false
|
|
297
270
|
},
|
|
271
|
+
code: {},
|
|
272
|
+
language: {},
|
|
273
|
+
classNames: {},
|
|
274
|
+
styles: {},
|
|
275
|
+
vars: {},
|
|
276
|
+
unstyled: { type: Boolean },
|
|
277
|
+
class: {},
|
|
278
|
+
style: {},
|
|
279
|
+
copyLabel: {},
|
|
280
|
+
copiedLabel: {},
|
|
298
281
|
defaultExpanded: {
|
|
299
282
|
type: Boolean,
|
|
300
283
|
default: void 0
|
|
@@ -303,38 +286,19 @@ var CodeHighlightBase = defineComponent({
|
|
|
303
286
|
type: Boolean,
|
|
304
287
|
default: void 0
|
|
305
288
|
},
|
|
306
|
-
|
|
307
|
-
type: Function,
|
|
308
|
-
default: void 0
|
|
309
|
-
},
|
|
310
|
-
maxCollapsedHeight: {
|
|
311
|
-
type: [String, Number],
|
|
312
|
-
default: void 0
|
|
313
|
-
},
|
|
289
|
+
maxCollapsedHeight: {},
|
|
314
290
|
withCopyButton: {
|
|
315
291
|
type: Boolean,
|
|
316
|
-
default:
|
|
292
|
+
default: true
|
|
317
293
|
},
|
|
318
294
|
withExpandButton: {
|
|
319
295
|
type: Boolean,
|
|
320
296
|
default: false
|
|
321
297
|
},
|
|
322
|
-
expandCodeLabel: {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
},
|
|
326
|
-
collapseCodeLabel: {
|
|
327
|
-
type: String,
|
|
328
|
-
default: void 0
|
|
329
|
-
},
|
|
330
|
-
background: {
|
|
331
|
-
type: String,
|
|
332
|
-
default: void 0
|
|
333
|
-
},
|
|
334
|
-
radius: {
|
|
335
|
-
type: [String, Number],
|
|
336
|
-
default: void 0
|
|
337
|
-
},
|
|
298
|
+
expandCodeLabel: { default: "Expand code" },
|
|
299
|
+
collapseCodeLabel: { default: "Collapse code" },
|
|
300
|
+
background: {},
|
|
301
|
+
radius: {},
|
|
338
302
|
withBorder: {
|
|
339
303
|
type: Boolean,
|
|
340
304
|
default: false
|
|
@@ -343,45 +307,16 @@ var CodeHighlightBase = defineComponent({
|
|
|
343
307
|
type: Boolean,
|
|
344
308
|
default: false
|
|
345
309
|
},
|
|
346
|
-
controls: {
|
|
347
|
-
|
|
348
|
-
default: void 0
|
|
349
|
-
},
|
|
350
|
-
codeColorScheme: {
|
|
351
|
-
type: String,
|
|
352
|
-
default: void 0
|
|
353
|
-
},
|
|
354
|
-
__withOffset: {
|
|
355
|
-
type: Boolean,
|
|
356
|
-
default: false
|
|
357
|
-
},
|
|
358
|
-
__staticSelector: {
|
|
359
|
-
type: String,
|
|
360
|
-
default: void 0
|
|
361
|
-
},
|
|
362
|
-
__inline: {
|
|
363
|
-
type: Boolean,
|
|
364
|
-
default: false
|
|
365
|
-
},
|
|
366
|
-
classNames: {
|
|
367
|
-
type: [Object, Function],
|
|
368
|
-
default: void 0
|
|
369
|
-
},
|
|
370
|
-
styles: {
|
|
371
|
-
type: [Object, Function],
|
|
372
|
-
default: void 0
|
|
373
|
-
},
|
|
374
|
-
vars: {
|
|
375
|
-
type: [Object, Function],
|
|
376
|
-
default: void 0
|
|
377
|
-
},
|
|
378
|
-
unstyled: {
|
|
379
|
-
type: Boolean,
|
|
380
|
-
default: false
|
|
381
|
-
}
|
|
310
|
+
controls: {},
|
|
311
|
+
codeColorScheme: {}
|
|
382
312
|
},
|
|
383
|
-
|
|
384
|
-
|
|
313
|
+
emits: ["update:expanded", "expanded-change"],
|
|
314
|
+
setup(__props, { emit: __emit }) {
|
|
315
|
+
const rawProps = __props;
|
|
316
|
+
const emit = __emit;
|
|
317
|
+
const props = useProps("CodeHighlight", null, rawProps);
|
|
318
|
+
const attrs = useAttrs();
|
|
319
|
+
const slots = useSlots();
|
|
385
320
|
const mantine = useMantineContext();
|
|
386
321
|
const getStyles = useStyles({
|
|
387
322
|
name: props.__staticSelector || "CodeHighlight",
|
|
@@ -400,147 +335,161 @@ var CodeHighlightBase = defineComponent({
|
|
|
400
335
|
value: () => props.expanded,
|
|
401
336
|
defaultValue: props.defaultExpanded,
|
|
402
337
|
finalValue: true,
|
|
403
|
-
onChange: (value) =>
|
|
338
|
+
onChange: (value) => {
|
|
339
|
+
emit("update:expanded", value);
|
|
340
|
+
emit("expanded-change", value);
|
|
341
|
+
}
|
|
404
342
|
});
|
|
405
343
|
const highlight = useHighlight();
|
|
344
|
+
function resolveColorScheme(value) {
|
|
345
|
+
if (value !== "auto") return value;
|
|
346
|
+
return typeof window !== "undefined" && window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
347
|
+
}
|
|
348
|
+
const highlighted = computed(() => highlight({
|
|
349
|
+
code: props.code.trim(),
|
|
350
|
+
language: props.language,
|
|
351
|
+
colorScheme: props.codeColorScheme ?? resolveColorScheme(mantine.colorScheme.value)
|
|
352
|
+
}));
|
|
353
|
+
const renderedControls = computed(() => {
|
|
354
|
+
const value = props.controls !== void 0 ? typeof props.controls === "function" ? props.controls() : props.controls : slots.controls?.();
|
|
355
|
+
return Array.isArray(value) ? value : value ? [value] : [];
|
|
356
|
+
});
|
|
357
|
+
const shouldDisplayControls = computed(() => renderedControls.value.length > 0 || props.withExpandButton || props.withCopyButton);
|
|
358
|
+
const lineNumbers = computed(() => props.code.trim().split("\n").map((_, index) => index + 1));
|
|
359
|
+
const renderControls = () => renderedControls.value;
|
|
406
360
|
provideCodeHighlightContext({
|
|
407
361
|
getStyles,
|
|
408
362
|
get codeColorScheme() {
|
|
409
363
|
return props.codeColorScheme;
|
|
410
364
|
}
|
|
411
365
|
});
|
|
412
|
-
return () => {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
...
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
})
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
return h(Box, {
|
|
435
|
-
...attrs,
|
|
436
|
-
...getStyles("codeHighlight"),
|
|
366
|
+
return (_ctx, _cache) => {
|
|
367
|
+
return unref(props).__inline && highlighted.value.isHighlighted ? (openBlock(), createElementBlock("code", mergeProps({ key: 0 }, {
|
|
368
|
+
...unref(attrs),
|
|
369
|
+
...highlighted.value.codeElementProps,
|
|
370
|
+
...unref(getStyles)("codeHighlight", {
|
|
371
|
+
className: [highlighted.value.codeElementProps?.class, unref(attrs).class],
|
|
372
|
+
style: [highlighted.value.codeElementProps?.style, unref(attrs).style]
|
|
373
|
+
})
|
|
374
|
+
}, {
|
|
375
|
+
"data-with-border": unref(props).withBorder || void 0,
|
|
376
|
+
innerHTML: highlighted.value.highlightedCode
|
|
377
|
+
}), null, 16, _hoisted_1)) : unref(props).__inline ? (openBlock(), createElementBlock("code", mergeProps({ key: 1 }, {
|
|
378
|
+
...unref(attrs),
|
|
379
|
+
...highlighted.value.codeElementProps,
|
|
380
|
+
...unref(getStyles)("codeHighlight", {
|
|
381
|
+
className: [highlighted.value.codeElementProps?.class, unref(attrs).class],
|
|
382
|
+
style: [highlighted.value.codeElementProps?.style, unref(attrs).style]
|
|
383
|
+
})
|
|
384
|
+
}, { "data-with-border": unref(props).withBorder || void 0 }), toDisplayString(unref(props).code.trim()), 17, _hoisted_2)) : (openBlock(), createBlock(unref(Box), mergeProps({ key: 2 }, {
|
|
385
|
+
...unref(attrs),
|
|
386
|
+
...unref(getStyles)("codeHighlight")
|
|
387
|
+
}, {
|
|
437
388
|
dir: "ltr",
|
|
438
|
-
"data-code-color-scheme": props.codeColorScheme,
|
|
439
|
-
"data-with-border": props.withBorder || void 0
|
|
440
|
-
},
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
389
|
+
"data-code-color-scheme": unref(props).codeColorScheme,
|
|
390
|
+
"data-with-border": unref(props).withBorder || void 0
|
|
391
|
+
}), {
|
|
392
|
+
default: withCtx(() => [
|
|
393
|
+
shouldDisplayControls.value ? (openBlock(), createElementBlock("div", mergeProps({ key: 0 }, unref(getStyles)("controls"), { "data-with-offset": unref(props).__withOffset || void 0 }), [
|
|
394
|
+
(openBlock(), createBlock(resolveDynamicComponent(renderControls))),
|
|
395
|
+
unref(props).withExpandButton ? (openBlock(), createBlock(ExpandCodeButton_default, {
|
|
396
|
+
key: 0,
|
|
397
|
+
expanded: unref(expanded),
|
|
398
|
+
"expand-code-label": unref(props).expandCodeLabel,
|
|
399
|
+
"collapse-code-label": unref(props).collapseCodeLabel,
|
|
400
|
+
onExpand: unref(setExpanded)
|
|
401
|
+
}, null, 8, [
|
|
402
|
+
"expanded",
|
|
403
|
+
"expand-code-label",
|
|
404
|
+
"collapse-code-label",
|
|
405
|
+
"onExpand"
|
|
406
|
+
])) : createCommentVNode("", true),
|
|
407
|
+
unref(props).withCopyButton ? (openBlock(), createBlock(CopyCodeButton_default, {
|
|
408
|
+
key: 1,
|
|
409
|
+
code: unref(props).code,
|
|
410
|
+
"copied-label": unref(props).copiedLabel,
|
|
411
|
+
"copy-label": unref(props).copyLabel
|
|
412
|
+
}, null, 8, [
|
|
413
|
+
"code",
|
|
414
|
+
"copied-label",
|
|
415
|
+
"copy-label"
|
|
416
|
+
])) : createCommentVNode("", true)
|
|
417
|
+
], 16, _hoisted_3)) : createCommentVNode("", true),
|
|
418
|
+
createVNode(unref(ScrollArea), mergeProps({
|
|
419
|
+
type: "hover",
|
|
420
|
+
"scrollbar-size": 4,
|
|
421
|
+
dir: "ltr",
|
|
422
|
+
"offset-scrollbars": false,
|
|
423
|
+
"data-collapsed": !unref(expanded) || void 0,
|
|
424
|
+
styles: { viewport: { overscrollBehaviorInline: "none" } }
|
|
425
|
+
}, unref(getStyles)("scrollarea")), {
|
|
426
|
+
default: withCtx(() => [createElementVNode("div", normalizeProps(guardReactiveProps(unref(getStyles)("codeWrapper"))), [unref(props).withLineNumbers ? (openBlock(), createElementBlock("div", mergeProps({ key: 0 }, unref(getStyles)("lineNumbers"), { "data-with-offset": unref(props).__withOffset || void 0 }), [(openBlock(true), createElementBlock(Fragment, null, renderList(lineNumbers.value, (line) => {
|
|
427
|
+
return openBlock(), createElementBlock("div", { key: line }, toDisplayString(line), 1);
|
|
428
|
+
}), 128))], 16, _hoisted_4)) : createCommentVNode("", true), createElementVNode("pre", mergeProps(unref(getStyles)("pre"), { "data-with-offset": unref(props).__withOffset || void 0 }), [highlighted.value.isHighlighted ? (openBlock(), createElementBlock("code", mergeProps({ key: 0 }, {
|
|
429
|
+
...highlighted.value.codeElementProps,
|
|
430
|
+
...unref(getStyles)("code", {
|
|
431
|
+
className: highlighted.value.codeElementProps?.class,
|
|
432
|
+
style: highlighted.value.codeElementProps?.style
|
|
433
|
+
})
|
|
434
|
+
}, { innerHTML: highlighted.value.highlightedCode }), null, 16, _hoisted_6)) : (openBlock(), createElementBlock("code", normalizeProps(mergeProps({ key: 1 }, {
|
|
435
|
+
...highlighted.value.codeElementProps,
|
|
436
|
+
...unref(getStyles)("code", {
|
|
437
|
+
className: highlighted.value.codeElementProps?.class,
|
|
438
|
+
style: highlighted.value.codeElementProps?.style
|
|
439
|
+
})
|
|
440
|
+
})), toDisplayString(unref(props).code.trim()), 17))], 16, _hoisted_5)], 16)]),
|
|
441
|
+
_: 1
|
|
442
|
+
}, 16, ["data-collapsed"]),
|
|
443
|
+
createVNode(unref(UnstyledButton), mergeProps(unref(getStyles)("showCodeButton"), {
|
|
444
|
+
mod: { hidden: unref(expanded) },
|
|
445
|
+
"data-code-color-scheme": unref(props).codeColorScheme,
|
|
446
|
+
onClick: _cache[0] || (_cache[0] = ($event) => unref(setExpanded)(true))
|
|
447
|
+
}), {
|
|
448
|
+
default: withCtx(() => [createTextVNode(toDisplayString(unref(props).expandCodeLabel), 1)]),
|
|
449
|
+
_: 1
|
|
450
|
+
}, 16, ["mod", "data-code-color-scheme"])
|
|
451
|
+
]),
|
|
452
|
+
_: 1
|
|
453
|
+
}, 16, ["data-code-color-scheme", "data-with-border"]));
|
|
487
454
|
};
|
|
488
455
|
}
|
|
489
456
|
});
|
|
490
|
-
|
|
457
|
+
//#endregion
|
|
458
|
+
//#region src/CodeHighlight/CodeHighlight.ts
|
|
459
|
+
var CodeHighlight = Object.assign(CodeHighlight_default, {
|
|
491
460
|
classes: CodeHighlight_module_default,
|
|
492
461
|
varsResolver: varsResolver$1,
|
|
493
|
-
Control:
|
|
462
|
+
Control: CodeHighlightControl_default
|
|
494
463
|
});
|
|
495
464
|
//#endregion
|
|
496
|
-
//#region src/CodeHighlight/InlineCodeHighlight.ts
|
|
465
|
+
//#region src/CodeHighlight/InlineCodeHighlight.vue?vue&type=script&setup=true&lang.ts
|
|
497
466
|
var varsResolver = createVarsResolver((theme, { background, radius }) => ({ inlineCodeHighlight: {
|
|
498
467
|
"--ch-background": background ? getThemeColor(background, theme) : void 0,
|
|
499
468
|
"--ch-radius": typeof radius !== "undefined" ? getRadius(radius) : void 0
|
|
500
469
|
} }));
|
|
501
|
-
|
|
470
|
+
//#endregion
|
|
471
|
+
//#region src/CodeHighlight/InlineCodeHighlight.ts
|
|
472
|
+
var InlineCodeHighlight = Object.assign(/* @__PURE__ */ defineComponent({
|
|
502
473
|
name: "InlineCodeHighlight",
|
|
503
474
|
inheritAttrs: false,
|
|
475
|
+
__name: "InlineCodeHighlight",
|
|
504
476
|
props: {
|
|
505
|
-
code: {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
},
|
|
509
|
-
language: {
|
|
510
|
-
type: String,
|
|
511
|
-
default: void 0
|
|
512
|
-
},
|
|
513
|
-
background: {
|
|
514
|
-
type: String,
|
|
515
|
-
default: void 0
|
|
516
|
-
},
|
|
517
|
-
radius: {
|
|
518
|
-
type: [String, Number],
|
|
519
|
-
default: void 0
|
|
520
|
-
},
|
|
477
|
+
code: {},
|
|
478
|
+
language: {},
|
|
479
|
+
background: {},
|
|
480
|
+
radius: {},
|
|
521
481
|
withBorder: {
|
|
522
482
|
type: Boolean,
|
|
523
483
|
default: false
|
|
524
484
|
},
|
|
525
|
-
classNames: {
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
}
|
|
529
|
-
styles: {
|
|
530
|
-
type: [Object, Function],
|
|
531
|
-
default: void 0
|
|
532
|
-
},
|
|
533
|
-
vars: {
|
|
534
|
-
type: [Object, Function],
|
|
535
|
-
default: void 0
|
|
536
|
-
},
|
|
537
|
-
unstyled: {
|
|
538
|
-
type: Boolean,
|
|
539
|
-
default: false
|
|
540
|
-
}
|
|
485
|
+
classNames: {},
|
|
486
|
+
styles: {},
|
|
487
|
+
vars: {},
|
|
488
|
+
unstyled: { type: Boolean }
|
|
541
489
|
},
|
|
542
|
-
setup(
|
|
543
|
-
const props = useProps("InlineCodeHighlight", null,
|
|
490
|
+
setup(__props) {
|
|
491
|
+
const props = useProps("InlineCodeHighlight", null, __props);
|
|
492
|
+
const attrs = useAttrs();
|
|
544
493
|
const getStyles = useStyles({
|
|
545
494
|
name: "InlineCodeHighlight",
|
|
546
495
|
classes: CodeHighlight_module_default,
|
|
@@ -554,81 +503,68 @@ var InlineCodeHighlight = defineComponent({
|
|
|
554
503
|
varsResolver,
|
|
555
504
|
rootSelector: "inlineCodeHighlight"
|
|
556
505
|
});
|
|
557
|
-
return () =>
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
506
|
+
return (_ctx, _cache) => {
|
|
507
|
+
return openBlock(), createBlock(CodeHighlight_default, mergeProps({
|
|
508
|
+
...unref(attrs),
|
|
509
|
+
...unref(props),
|
|
510
|
+
...unref(getStyles)("inlineCodeHighlight")
|
|
511
|
+
}, { __inline: "" }), null, 16);
|
|
512
|
+
};
|
|
563
513
|
}
|
|
564
|
-
})
|
|
565
|
-
Object.assign(InlineCodeHighlight, {
|
|
514
|
+
}), {
|
|
566
515
|
classes: CodeHighlight_module_default,
|
|
567
516
|
varsResolver
|
|
568
517
|
});
|
|
569
518
|
//#endregion
|
|
570
|
-
//#region src/CodeHighlightTabs/FileIcon.
|
|
571
|
-
var
|
|
519
|
+
//#region src/CodeHighlightTabs/FileIcon.vue
|
|
520
|
+
var FileIcon_default = /* @__PURE__ */ defineComponent({
|
|
572
521
|
name: "FileIcon",
|
|
573
522
|
inheritAttrs: false,
|
|
574
|
-
|
|
523
|
+
__name: "FileIcon",
|
|
575
524
|
props: {
|
|
576
|
-
fileName: {
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
String,
|
|
587
|
-
Number,
|
|
588
|
-
Object,
|
|
589
|
-
Function,
|
|
590
|
-
Array
|
|
591
|
-
],
|
|
592
|
-
default: void 0
|
|
593
|
-
}
|
|
525
|
+
fileName: {},
|
|
526
|
+
getFileIcon: { type: Function },
|
|
527
|
+
fileIcon: { type: [
|
|
528
|
+
Object,
|
|
529
|
+
String,
|
|
530
|
+
Number,
|
|
531
|
+
Boolean,
|
|
532
|
+
null,
|
|
533
|
+
Array
|
|
534
|
+
] }
|
|
594
535
|
},
|
|
595
|
-
setup(
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
if (
|
|
600
|
-
if (
|
|
536
|
+
setup(__props) {
|
|
537
|
+
const props = __props;
|
|
538
|
+
const slots = useSlots();
|
|
539
|
+
const renderIcon = () => {
|
|
540
|
+
if (props.fileIcon) return props.fileIcon;
|
|
541
|
+
if (props.getFileIcon && props.fileName) return props.getFileIcon(props.fileName);
|
|
542
|
+
if (slots.fileIcon) return slots.fileIcon();
|
|
543
|
+
if (slots.getFileIcon && props.fileName) return slots.getFileIcon({ fileName: props.fileName });
|
|
601
544
|
return null;
|
|
602
545
|
};
|
|
546
|
+
return (_ctx, _cache) => {
|
|
547
|
+
return renderIcon() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), [(openBlock(), createBlock(resolveDynamicComponent(renderIcon)))], 16)) : createCommentVNode("", true);
|
|
548
|
+
};
|
|
603
549
|
}
|
|
604
550
|
});
|
|
605
551
|
//#endregion
|
|
606
552
|
//#region src/CodeHighlightTabs/CodeHighlightTabs.ts
|
|
607
|
-
var CodeHighlightTabs = defineComponent({
|
|
553
|
+
var CodeHighlightTabs = Object.assign(/* @__PURE__ */ defineComponent({
|
|
608
554
|
name: "CodeHighlightTabs",
|
|
609
555
|
inheritAttrs: false,
|
|
610
|
-
|
|
556
|
+
__name: "CodeHighlightTabs",
|
|
611
557
|
props: {
|
|
612
|
-
code: {
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
},
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
},
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
default: void 0
|
|
623
|
-
},
|
|
624
|
-
activeTab: {
|
|
625
|
-
type: Number,
|
|
626
|
-
default: void 0
|
|
627
|
-
},
|
|
628
|
-
onTabChange: {
|
|
629
|
-
type: Function,
|
|
630
|
-
default: void 0
|
|
631
|
-
},
|
|
558
|
+
code: {},
|
|
559
|
+
getFileIcon: {},
|
|
560
|
+
defaultActiveTab: {},
|
|
561
|
+
activeTab: {},
|
|
562
|
+
classNames: {},
|
|
563
|
+
styles: {},
|
|
564
|
+
vars: {},
|
|
565
|
+
unstyled: { type: Boolean },
|
|
566
|
+
copyLabel: {},
|
|
567
|
+
copiedLabel: {},
|
|
632
568
|
defaultExpanded: {
|
|
633
569
|
type: Boolean,
|
|
634
570
|
default: void 0
|
|
@@ -637,81 +573,39 @@ var CodeHighlightTabs = defineComponent({
|
|
|
637
573
|
type: Boolean,
|
|
638
574
|
default: void 0
|
|
639
575
|
},
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
default: void 0
|
|
643
|
-
},
|
|
644
|
-
withCopyButton: {
|
|
645
|
-
type: Boolean,
|
|
646
|
-
default: void 0
|
|
647
|
-
},
|
|
576
|
+
maxCollapsedHeight: {},
|
|
577
|
+
withCopyButton: { type: Boolean },
|
|
648
578
|
withExpandButton: {
|
|
649
579
|
type: Boolean,
|
|
650
580
|
default: false
|
|
651
581
|
},
|
|
582
|
+
expandCodeLabel: {},
|
|
583
|
+
collapseCodeLabel: {},
|
|
584
|
+
background: {},
|
|
585
|
+
radius: {},
|
|
652
586
|
withBorder: {
|
|
653
587
|
type: Boolean,
|
|
654
588
|
default: false
|
|
655
589
|
},
|
|
656
|
-
radius: {
|
|
657
|
-
type: [String, Number],
|
|
658
|
-
default: void 0
|
|
659
|
-
},
|
|
660
|
-
maxCollapsedHeight: {
|
|
661
|
-
type: [String, Number],
|
|
662
|
-
default: void 0
|
|
663
|
-
},
|
|
664
|
-
copyLabel: {
|
|
665
|
-
type: String,
|
|
666
|
-
default: void 0
|
|
667
|
-
},
|
|
668
|
-
copiedLabel: {
|
|
669
|
-
type: String,
|
|
670
|
-
default: void 0
|
|
671
|
-
},
|
|
672
|
-
expandCodeLabel: {
|
|
673
|
-
type: String,
|
|
674
|
-
default: void 0
|
|
675
|
-
},
|
|
676
|
-
collapseCodeLabel: {
|
|
677
|
-
type: String,
|
|
678
|
-
default: void 0
|
|
679
|
-
},
|
|
680
|
-
background: {
|
|
681
|
-
type: String,
|
|
682
|
-
default: void 0
|
|
683
|
-
},
|
|
684
|
-
controls: {
|
|
685
|
-
type: [Array, Function],
|
|
686
|
-
default: void 0
|
|
687
|
-
},
|
|
688
|
-
codeColorScheme: {
|
|
689
|
-
type: String,
|
|
690
|
-
default: void 0
|
|
691
|
-
},
|
|
692
590
|
withLineNumbers: {
|
|
693
591
|
type: Boolean,
|
|
694
592
|
default: false
|
|
695
593
|
},
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
default: void 0
|
|
699
|
-
},
|
|
700
|
-
styles: {
|
|
701
|
-
type: [Object, Function],
|
|
702
|
-
default: void 0
|
|
703
|
-
},
|
|
704
|
-
vars: {
|
|
705
|
-
type: [Object, Function],
|
|
706
|
-
default: void 0
|
|
707
|
-
},
|
|
708
|
-
unstyled: {
|
|
709
|
-
type: Boolean,
|
|
710
|
-
default: false
|
|
711
|
-
}
|
|
594
|
+
controls: {},
|
|
595
|
+
codeColorScheme: {}
|
|
712
596
|
},
|
|
713
|
-
|
|
597
|
+
emits: [
|
|
598
|
+
"update:activeTab",
|
|
599
|
+
"tab-change",
|
|
600
|
+
"update:expanded",
|
|
601
|
+
"expanded-change"
|
|
602
|
+
],
|
|
603
|
+
setup(__props, { emit: __emit }) {
|
|
604
|
+
const rawProps = __props;
|
|
605
|
+
const emit = __emit;
|
|
714
606
|
const props = useProps("CodeHighlightTabs", null, rawProps);
|
|
607
|
+
const attrs = useAttrs();
|
|
608
|
+
const slots = useSlots();
|
|
715
609
|
const getStyles = useStyles({
|
|
716
610
|
name: "CodeHighlightTabs",
|
|
717
611
|
classes: CodeHighlight_module_default,
|
|
@@ -727,73 +621,114 @@ var CodeHighlightTabs = defineComponent({
|
|
|
727
621
|
defaultValue: props.defaultActiveTab,
|
|
728
622
|
value: () => props.activeTab,
|
|
729
623
|
finalValue: 0,
|
|
730
|
-
onChange: (tab) =>
|
|
624
|
+
onChange: (tab) => {
|
|
625
|
+
emit("update:activeTab", tab);
|
|
626
|
+
emit("tab-change", tab);
|
|
627
|
+
}
|
|
731
628
|
});
|
|
732
629
|
const [expanded, setExpanded] = useUncontrolled({
|
|
733
630
|
defaultValue: props.defaultExpanded,
|
|
734
631
|
value: () => props.expanded,
|
|
735
632
|
finalValue: true,
|
|
736
|
-
onChange: (next) =>
|
|
633
|
+
onChange: (next) => {
|
|
634
|
+
emit("update:expanded", next);
|
|
635
|
+
emit("expanded-change", next);
|
|
636
|
+
}
|
|
737
637
|
});
|
|
738
|
-
watch(() => [value.value, props.code.length], ([
|
|
739
|
-
if (
|
|
638
|
+
watch(() => [value.value, props.code.length], ([current, length]) => {
|
|
639
|
+
if (current >= length) setValue(length - 1);
|
|
740
640
|
}, { immediate: true });
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
...getStyles("
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
641
|
+
const currentCode = computed(() => props.code[value.value] || {
|
|
642
|
+
code: "",
|
|
643
|
+
language: "tsx",
|
|
644
|
+
fileName: ""
|
|
645
|
+
});
|
|
646
|
+
const fileIconResolver = computed(() => props.getFileIcon ?? (slots.getFileIcon ? (fileName) => slots.getFileIcon?.({ fileName }) : void 0));
|
|
647
|
+
return (_ctx, _cache) => {
|
|
648
|
+
return unref(props).code.length ? (openBlock(), createBlock(unref(Box), normalizeProps(mergeProps({ key: 0 }, {
|
|
649
|
+
...unref(attrs),
|
|
650
|
+
...unref(getStyles)("root")
|
|
651
|
+
})), {
|
|
652
|
+
default: withCtx(() => [createVNode(unref(ScrollArea), mergeProps({
|
|
653
|
+
type: "never",
|
|
654
|
+
dir: "ltr",
|
|
655
|
+
"offset-scrollbars": false
|
|
656
|
+
}, unref(getStyles)("filesScrollarea")), {
|
|
657
|
+
default: withCtx(() => [createElementVNode("div", normalizeProps(guardReactiveProps(unref(getStyles)("files"))), [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(props).code, (node, index) => {
|
|
658
|
+
return openBlock(), createBlock(unref(UnstyledButton), mergeProps({ key: node.fileName ?? index }, { ref_for: true }, unref(getStyles)("file"), {
|
|
659
|
+
mod: { active: index === unref(value) },
|
|
660
|
+
"data-color-scheme": unref(props).codeColorScheme,
|
|
661
|
+
onClick: ($event) => unref(setValue)(index)
|
|
662
|
+
}), {
|
|
663
|
+
default: withCtx(() => [createVNode(FileIcon_default, mergeProps({
|
|
664
|
+
"file-icon": node.icon,
|
|
665
|
+
"get-file-icon": fileIconResolver.value,
|
|
666
|
+
"file-name": node.fileName
|
|
667
|
+
}, { ref_for: true }, unref(getStyles)("fileIcon")), null, 16, [
|
|
668
|
+
"file-icon",
|
|
669
|
+
"get-file-icon",
|
|
670
|
+
"file-name"
|
|
671
|
+
]), createElementVNode("span", null, toDisplayString(node.fileName), 1)]),
|
|
672
|
+
_: 2
|
|
673
|
+
}, 1040, [
|
|
674
|
+
"mod",
|
|
675
|
+
"data-color-scheme",
|
|
676
|
+
"onClick"
|
|
677
|
+
]);
|
|
678
|
+
}), 128))], 16)]),
|
|
679
|
+
_: 1
|
|
680
|
+
}, 16), createVNode(CodeHighlight_default, {
|
|
681
|
+
code: currentCode.value.code,
|
|
682
|
+
language: currentCode.value.language,
|
|
683
|
+
expanded: unref(expanded),
|
|
684
|
+
"with-copy-button": unref(props).withCopyButton,
|
|
685
|
+
"with-expand-button": unref(props).withExpandButton,
|
|
686
|
+
"with-border": unref(props).withBorder,
|
|
687
|
+
radius: unref(props).radius,
|
|
688
|
+
"max-collapsed-height": unref(props).maxCollapsedHeight,
|
|
689
|
+
"copied-label": unref(props).copiedLabel,
|
|
690
|
+
"copy-label": unref(props).copyLabel,
|
|
691
|
+
"expand-code-label": unref(props).expandCodeLabel,
|
|
692
|
+
"collapse-code-label": unref(props).collapseCodeLabel,
|
|
693
|
+
background: unref(props).background,
|
|
694
|
+
controls: unref(props).controls,
|
|
695
|
+
"code-color-scheme": unref(props).codeColorScheme,
|
|
696
|
+
"with-line-numbers": unref(props).withLineNumbers,
|
|
697
|
+
"__with-offset": "",
|
|
698
|
+
"__static-selector": "CodeHighlightTabs",
|
|
699
|
+
onExpandedChange: unref(setExpanded),
|
|
700
|
+
"class-names": unref(props).classNames,
|
|
701
|
+
styles: unref(props).styles
|
|
702
|
+
}, createSlots({ _: 2 }, [_ctx.$slots.controls ? {
|
|
703
|
+
name: "controls",
|
|
704
|
+
fn: withCtx(() => [renderSlot(_ctx.$slots, "controls")]),
|
|
705
|
+
key: "0"
|
|
706
|
+
} : void 0]), 1032, [
|
|
707
|
+
"code",
|
|
708
|
+
"language",
|
|
709
|
+
"expanded",
|
|
710
|
+
"with-copy-button",
|
|
711
|
+
"with-expand-button",
|
|
712
|
+
"with-border",
|
|
713
|
+
"radius",
|
|
714
|
+
"max-collapsed-height",
|
|
715
|
+
"copied-label",
|
|
716
|
+
"copy-label",
|
|
717
|
+
"expand-code-label",
|
|
718
|
+
"collapse-code-label",
|
|
719
|
+
"background",
|
|
720
|
+
"controls",
|
|
721
|
+
"code-color-scheme",
|
|
722
|
+
"with-line-numbers",
|
|
723
|
+
"onExpandedChange",
|
|
724
|
+
"class-names",
|
|
725
|
+
"styles"
|
|
726
|
+
])]),
|
|
727
|
+
_: 3
|
|
728
|
+
}, 16)) : createCommentVNode("", true);
|
|
793
729
|
};
|
|
794
730
|
}
|
|
795
|
-
});
|
|
796
|
-
Object.assign(CodeHighlightTabs, { classes: CodeHighlight_module_default });
|
|
731
|
+
}), { classes: CodeHighlight_module_default });
|
|
797
732
|
//#endregion
|
|
798
733
|
//#region src/CodeHighlightProvider/adapters/highlight-js-adapter.ts
|
|
799
734
|
function createHighlightJsAdapter(hljs) {
|
|
@@ -1975,6 +1910,6 @@ var createShikiAdapter = (loadShiki, { forceColorScheme } = {}) => ({
|
|
|
1975
1910
|
}
|
|
1976
1911
|
});
|
|
1977
1912
|
//#endregion
|
|
1978
|
-
export { CodeHighlight, CodeHighlightAdapterProvider, CodeHighlightControl, CodeHighlightTabs, InlineCodeHighlight, createHighlightJsAdapter, createShikiAdapter, plainTextAdapter, stripShikiCodeBlocks, useCodeHighlightContext, useHighlight };
|
|
1913
|
+
export { CodeHighlight, CodeHighlightAdapterProvider, CodeHighlightControl_default as CodeHighlightControl, CodeHighlightTabs, InlineCodeHighlight, createHighlightJsAdapter, createShikiAdapter, plainTextAdapter, stripShikiCodeBlocks, useCodeHighlightContext, useHighlight };
|
|
1979
1914
|
|
|
1980
1915
|
//# sourceMappingURL=index.mjs.map
|