vue-markdown-design 0.3.0 → 0.3.2-beta
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/README.md +26 -4
- package/README.zh-CN.md +5 -1
- package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/asyncToGenerator.mjs +27 -0
- package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.mjs +12 -0
- package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectSpread2.mjs +25 -0
- package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutProperties.mjs +13 -0
- package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutPropertiesLoose.mjs +12 -0
- package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPrimitive.mjs +14 -0
- package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPropertyKey.mjs +9 -0
- package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/typeof.mjs +11 -0
- package/es/hooks/use-element/index.mjs +21 -18
- package/es/hooks/use-scroll-element/index.mjs +44 -45
- package/es/index.mjs +7 -18
- package/es/markdown/Markdown.mjs +221 -316
- package/es/markdown/index.css +3 -0
- package/es/markdown/index2.mjs +6 -0
- package/es/render/Render.mjs +143 -173
- package/es/render/index.css +37 -21
- package/es/render/index2.mjs +6 -0
- package/es/search/Search.mjs +236 -284
- package/es/search/index.css +4 -0
- package/es/search/index2.mjs +6 -0
- package/es/sticky/Sticky.mjs +66 -99
- package/es/sticky/index2.mjs +6 -0
- package/es/toc/Toc.mjs +253 -347
- package/es/toc/index2.mjs +6 -0
- package/es/utils/constant.mjs +4 -4
- package/es/utils/dom.mjs +44 -68
- package/es/utils/format.mjs +33 -39
- package/es/utils/functions.mjs +5 -5
- package/es/utils/vue.mjs +10 -32
- package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/asyncToGenerator.js +27 -0
- package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js +12 -0
- package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectSpread2.js +25 -0
- package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutProperties.js +13 -0
- package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutPropertiesLoose.js +12 -0
- package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPrimitive.js +14 -0
- package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPropertyKey.js +9 -0
- package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/typeof.js +16 -0
- package/lib/_virtual/_rolldown/runtime.js +23 -0
- package/lib/hooks/use-element/index.js +23 -19
- package/lib/hooks/use-scroll-element/index.js +45 -45
- package/lib/index.js +24 -22
- package/lib/markdown/Markdown.js +224 -317
- package/lib/markdown/index.css +3 -0
- package/lib/markdown/index2.js +6 -0
- package/lib/render/Render.js +152 -176
- package/lib/render/index.css +37 -21
- package/lib/render/index2.js +6 -0
- package/lib/search/Search.js +242 -286
- package/lib/search/index.css +4 -0
- package/lib/search/index2.js +6 -0
- package/lib/sticky/Sticky.js +68 -99
- package/lib/sticky/index2.js +6 -0
- package/lib/toc/Toc.js +259 -349
- package/lib/toc/index2.js +6 -0
- package/lib/utils/constant.js +3 -3
- package/lib/utils/dom.js +46 -69
- package/lib/utils/format.js +33 -33
- package/lib/utils/functions.js +4 -4
- package/lib/utils/vue.js +10 -31
- package/package.json +4 -9
- package/es/markdown/index.mjs +0 -9
- package/es/render/index.mjs +0 -9
- package/es/search/index.mjs +0 -9
- package/es/sticky/index.mjs +0 -7
- package/es/toc/index.mjs +0 -9
- package/lib/markdown/index.js +0 -8
- package/lib/render/index.js +0 -8
- package/lib/search/index.js +0 -8
- package/lib/sticky/index.js +0 -7
- package/lib/toc/index.js +0 -8
package/es/markdown/Markdown.mjs
CHANGED
|
@@ -1,321 +1,226 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __async = (__this, __arguments, generator) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
var fulfilled = (value) => {
|
|
23
|
-
try {
|
|
24
|
-
step(generator.next(value));
|
|
25
|
-
} catch (e) {
|
|
26
|
-
reject(e);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var rejected = (value) => {
|
|
30
|
-
try {
|
|
31
|
-
step(generator.throw(value));
|
|
32
|
-
} catch (e) {
|
|
33
|
-
reject(e);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
import { defineComponent, shallowRef, computed, createVNode, mergeProps, Transition } from "vue";
|
|
41
|
-
/* empty css */
|
|
42
|
-
import { VmdRender } from "../render/index.mjs";
|
|
43
|
-
import { VmdSearch } from "../search/index.mjs";
|
|
44
|
-
import { VmdToc } from "../toc/index.mjs";
|
|
45
|
-
import { keysAddPrefix, addUnit, allToObject, createNamespace, computeOffset } from "../utils/format.mjs";
|
|
46
|
-
import { renderProps, renderEmits } from "../render/Render.mjs";
|
|
47
|
-
import { searchProps, searchEmits } from "../search/Search.mjs";
|
|
48
|
-
import { tocProps, tocEmits } from "../toc/Toc.mjs";
|
|
49
|
-
import { isBoolean, sum, values, mapValues, chain, upperFirst, isUndefined } from "lodash";
|
|
50
|
-
import { useVModels, useElementBounding, useWindowSize } from "@vueuse/core";
|
|
1
|
+
import { _objectSpread2 } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/objectSpread2.mjs";
|
|
2
|
+
import { addUnit, allToObject, computeOffset, createNamespace, keysAddPrefix } from "../utils/format.mjs";
|
|
3
|
+
import { renderEmits, renderProps } from "../render/Render.mjs";
|
|
4
|
+
import VmdRender from "../render/index2.mjs";
|
|
5
|
+
import { _asyncToGenerator } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/asyncToGenerator.mjs";
|
|
6
|
+
import { searchEmits, searchProps } from "../search/Search.mjs";
|
|
7
|
+
import VmdSearch from "../search/index2.mjs";
|
|
51
8
|
import { useScrollParent } from "../hooks/use-scroll-element/index.mjs";
|
|
52
|
-
import {
|
|
9
|
+
import { tocEmits, tocProps } from "../toc/Toc.mjs";
|
|
10
|
+
import VmdToc from "../toc/index2.mjs";
|
|
11
|
+
import VmdSticky from "../sticky/index2.mjs";
|
|
12
|
+
import './index.css';/* empty css */
|
|
13
|
+
import { chain, isBoolean, isUndefined, mapValues, sum, upperFirst, values } from "lodash";
|
|
14
|
+
import { Transition, computed, createVNode, defineComponent, mergeProps, shallowRef } from "vue";
|
|
15
|
+
import { useElementBounding, useVModels, useWindowSize } from "@vueuse/core";
|
|
53
16
|
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
|
|
54
|
-
import {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
17
|
+
import { faList, faMagnifyingGlass } from "@fortawesome/free-solid-svg-icons";
|
|
18
|
+
//#region src/markdown/Markdown.tsx
|
|
19
|
+
var { name, addPrefix } = createNamespace("markdown");
|
|
20
|
+
var markdownProps = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, renderProps), keysAddPrefix(searchProps, "search")), keysAddPrefix(tocProps, "toc")), {}, {
|
|
21
|
+
keyword: searchProps.modelValue,
|
|
22
|
+
tocOffset: tocProps.offset.type,
|
|
23
|
+
showBtn: {
|
|
24
|
+
type: [
|
|
25
|
+
Boolean,
|
|
26
|
+
Array,
|
|
27
|
+
Object
|
|
28
|
+
],
|
|
29
|
+
default: false
|
|
30
|
+
},
|
|
31
|
+
search: Boolean,
|
|
32
|
+
toc: Boolean,
|
|
33
|
+
topOffset: {
|
|
34
|
+
type: [Number, String],
|
|
35
|
+
default: 0
|
|
36
|
+
},
|
|
37
|
+
bottomOffset: {
|
|
38
|
+
type: [Number, String],
|
|
39
|
+
default: 0
|
|
40
|
+
},
|
|
41
|
+
miniScreenWidth: {
|
|
42
|
+
type: [Number, String],
|
|
43
|
+
default: 768
|
|
44
|
+
}
|
|
81
45
|
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
46
|
+
var emits = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, renderEmits), keysAddPrefix(searchEmits, "search")), keysAddPrefix(tocEmits, "toc")), {}, {
|
|
47
|
+
"update:keyword": searchEmits["update:modelValue"],
|
|
48
|
+
"update:search": (payload) => isBoolean(payload),
|
|
49
|
+
"update:toc": (payload) => isBoolean(payload)
|
|
86
50
|
});
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
"class": addPrefix("__search-input")
|
|
261
|
-
}, [createVNode(VmdSearch, mergeProps(searchAttrs.value, {
|
|
262
|
-
"ref": searchRef,
|
|
263
|
-
"modelValue": keyword.value,
|
|
264
|
-
"onUpdate:modelValue": ($event) => keyword.value = $event,
|
|
265
|
-
"target": renderRef.value
|
|
266
|
-
}), null)])])]
|
|
267
|
-
}), createVNode(VmdRender, mergeProps(renderAttrs.value, {
|
|
268
|
-
"ref": renderRef
|
|
269
|
-
}), null), !!btnCount.value && createVNode(VmdSticky, {
|
|
270
|
-
"posY": "bottom",
|
|
271
|
-
"posX": "right",
|
|
272
|
-
"flow": false,
|
|
273
|
-
"zIndex": "var(--vmd-markdown-btn-z-index)",
|
|
274
|
-
"offset": props.bottomOffset
|
|
275
|
-
}, {
|
|
276
|
-
default: () => [createVNode("div", {
|
|
277
|
-
"class": addPrefix("__btn"),
|
|
278
|
-
"style": {
|
|
279
|
-
width: `${btnCount.value * 40}px`
|
|
280
|
-
}
|
|
281
|
-
}, [showBtnWithObj.value.search && createVNode("span", {
|
|
282
|
-
"class": [addPrefix("__btn-search"), createBtnClass(search.value)],
|
|
283
|
-
"onClick": () => search.value = !search.value
|
|
284
|
-
}, [createVNode(FontAwesomeIcon, {
|
|
285
|
-
"size": "xs",
|
|
286
|
-
"icon": faMagnifyingGlass
|
|
287
|
-
}, null)]), showBtnWithObj.value.toc && createVNode("span", {
|
|
288
|
-
"class": [addPrefix("__btn-toc"), createBtnClass(toc.value)],
|
|
289
|
-
"onClick": () => toc.value = !toc.value
|
|
290
|
-
}, [createVNode(FontAwesomeIcon, {
|
|
291
|
-
"size": "xs",
|
|
292
|
-
"icon": faList
|
|
293
|
-
}, null)])])]
|
|
294
|
-
})]), createVNode(Transition, {
|
|
295
|
-
"name": addPrefix("__ani")
|
|
296
|
-
}, {
|
|
297
|
-
default: () => [toc.value && createVNode("aside", {
|
|
298
|
-
"class": [addPrefix("__aside"), {
|
|
299
|
-
[addPrefix("--mini")]: isMiniScreen.value
|
|
300
|
-
}]
|
|
301
|
-
}, [createVNode(VmdSticky, {
|
|
302
|
-
"class": addPrefix("__aside-sticky"),
|
|
303
|
-
"offset": props.topOffset
|
|
304
|
-
}, {
|
|
305
|
-
default: () => [createVNode("div", {
|
|
306
|
-
"style": tocStyles.value.wrapper,
|
|
307
|
-
"class": addPrefix("__toc")
|
|
308
|
-
}, [createVNode(VmdToc, mergeProps(tocAttrs.value, {
|
|
309
|
-
"ref": tocRef,
|
|
310
|
-
"style": tocStyles.value.content,
|
|
311
|
-
"target": renderRef.value
|
|
312
|
-
}), null)])]
|
|
313
|
-
})])]
|
|
314
|
-
})])])
|
|
315
|
-
);
|
|
316
|
-
}
|
|
51
|
+
var Markdown_default = /* @__PURE__ */ defineComponent({
|
|
52
|
+
name: "vue-markdown",
|
|
53
|
+
props: markdownProps,
|
|
54
|
+
emits,
|
|
55
|
+
setup(props, { emit, expose }) {
|
|
56
|
+
const { search, toc, keyword } = useVModels(props, emit, { passive: true });
|
|
57
|
+
const root = shallowRef();
|
|
58
|
+
const { width: rootWidth, height: rootHeight } = useElementBounding(root);
|
|
59
|
+
const isMiniScreen = computed(() => rootWidth.value <= Number(props.miniScreenWidth));
|
|
60
|
+
const getPrefixedKey = (key, prefix) => prefix ? prefix + upperFirst(key) : key;
|
|
61
|
+
const createAttrs = (propAttrs, emitAttrs, prefix) => {
|
|
62
|
+
const targetProps = mapValues(propAttrs, (_, key) => {
|
|
63
|
+
const prefixedKey = getPrefixedKey(key, prefix);
|
|
64
|
+
if (prefixedKey in props) return props[prefixedKey];
|
|
65
|
+
});
|
|
66
|
+
const targetEmits = chain(emitAttrs).mapValues((_, key) => {
|
|
67
|
+
const prefixedKey = getPrefixedKey(key, prefix);
|
|
68
|
+
if (prefixedKey in emits) return (...arg) => emit(prefixedKey, ...arg);
|
|
69
|
+
}).mapKeys((_, key) => `on${upperFirst(key)}`).value();
|
|
70
|
+
return _objectSpread2(_objectSpread2({}, targetProps), targetEmits);
|
|
71
|
+
};
|
|
72
|
+
const renderRef = shallowRef();
|
|
73
|
+
const renderAttrs = computed(() => createAttrs(renderProps, renderEmits));
|
|
74
|
+
const offsetWithNum = computed(() => [props.topOffset, props.bottomOffset].map(Number));
|
|
75
|
+
const { scrollEl } = useScrollParent(root);
|
|
76
|
+
const getDefaultOffset = (offset) => {
|
|
77
|
+
const { block, getOffset } = computeOffset(offset);
|
|
78
|
+
if (block !== "start") return block;
|
|
79
|
+
const [topOffset] = offsetWithNum.value;
|
|
80
|
+
return (scrollAction) => {
|
|
81
|
+
const { el } = scrollAction;
|
|
82
|
+
const isParent = (scrollEl.value || document.documentElement) === el;
|
|
83
|
+
const curOffset = getOffset(scrollAction, isParent);
|
|
84
|
+
if (!isParent) return curOffset;
|
|
85
|
+
return (isUndefined(offset) ? topOffset : curOffset) + searchRect.height.value;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
const searchAttrs = computed(() => _objectSpread2(_objectSpread2({}, createAttrs(searchProps, searchEmits, "search")), {}, { onClose: () => {
|
|
89
|
+
search.value = false;
|
|
90
|
+
emit("searchClose");
|
|
91
|
+
} }));
|
|
92
|
+
const searchRef = shallowRef();
|
|
93
|
+
const searchRect = useElementBounding(searchRef);
|
|
94
|
+
const searchIsOnMiniScreen = computed(() => isMiniScreen.value && toc.value);
|
|
95
|
+
const tocRef = shallowRef();
|
|
96
|
+
const tocRect = useElementBounding(tocRef);
|
|
97
|
+
const onTocClick = () => {
|
|
98
|
+
if (!isMiniScreen.value) return;
|
|
99
|
+
toc.value = false;
|
|
100
|
+
};
|
|
101
|
+
const tocAttrs = computed(() => {
|
|
102
|
+
return _objectSpread2(_objectSpread2({}, createAttrs(tocProps, tocEmits, "toc")), {}, {
|
|
103
|
+
offset: getDefaultOffset(props.tocOffset),
|
|
104
|
+
onClick: (tocItem) => {
|
|
105
|
+
onTocClick();
|
|
106
|
+
emit("tocClick", tocItem);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
const scrollRect = useElementBounding(scrollEl);
|
|
111
|
+
const windowSize = useWindowSize();
|
|
112
|
+
const tocStyles = computed(() => {
|
|
113
|
+
const offset = sum(offsetWithNum.value);
|
|
114
|
+
const scrollHeight = Math.min(scrollRect.height.value || windowSize.height.value, rootHeight.value);
|
|
115
|
+
if (isMiniScreen.value) return { wrapper: {
|
|
116
|
+
width: addUnit(rootWidth.value),
|
|
117
|
+
height: addUnit(scrollHeight - offset)
|
|
118
|
+
} };
|
|
119
|
+
const tocHeight = tocRect.height.value;
|
|
120
|
+
if (tocHeight + offset < scrollHeight) return {};
|
|
121
|
+
return {
|
|
122
|
+
wrapper: { height: addUnit(tocHeight) },
|
|
123
|
+
content: { marginBottom: addUnit(tocHeight + offset - scrollHeight) }
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
const showBtnWithObj = computed(() => {
|
|
127
|
+
const { toc, search } = allToObject(props.showBtn, ["search", "toc"]);
|
|
128
|
+
return {
|
|
129
|
+
search: search && !searchIsOnMiniScreen.value,
|
|
130
|
+
toc
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
const btnCount = computed(() => values(showBtnWithObj.value).filter(Boolean).length);
|
|
134
|
+
const createBtnClass = (isActive) => [addPrefix("__btn-icon"), { [addPrefix("__btn-icon--active")]: isActive }];
|
|
135
|
+
expose({
|
|
136
|
+
tocRefresh: function() {
|
|
137
|
+
var _ref = _asyncToGenerator(function* () {
|
|
138
|
+
var _tocRef$value;
|
|
139
|
+
return (_tocRef$value = tocRef.value) === null || _tocRef$value === void 0 ? void 0 : _tocRef$value.refresh();
|
|
140
|
+
});
|
|
141
|
+
return function tocRefresh() {
|
|
142
|
+
return _ref.apply(this, arguments);
|
|
143
|
+
};
|
|
144
|
+
}(),
|
|
145
|
+
tocScrollTo: (href) => {
|
|
146
|
+
var _tocRef$value2;
|
|
147
|
+
return (_tocRef$value2 = tocRef.value) === null || _tocRef$value2 === void 0 ? void 0 : _tocRef$value2.scrollTo(href);
|
|
148
|
+
},
|
|
149
|
+
searchRefresh: function() {
|
|
150
|
+
var _ref2 = _asyncToGenerator(function* (resetIndex) {
|
|
151
|
+
var _searchRef$value;
|
|
152
|
+
return (_searchRef$value = searchRef.value) === null || _searchRef$value === void 0 ? void 0 : _searchRef$value.refresh(resetIndex);
|
|
153
|
+
});
|
|
154
|
+
return function searchRefresh(_x) {
|
|
155
|
+
return _ref2.apply(this, arguments);
|
|
156
|
+
};
|
|
157
|
+
}(),
|
|
158
|
+
searchFocus: () => {
|
|
159
|
+
var _searchRef$value2;
|
|
160
|
+
return (_searchRef$value2 = searchRef.value) === null || _searchRef$value2 === void 0 ? void 0 : _searchRef$value2.focus();
|
|
161
|
+
},
|
|
162
|
+
searchBlur: () => {
|
|
163
|
+
var _searchRef$value3;
|
|
164
|
+
return (_searchRef$value3 = searchRef.value) === null || _searchRef$value3 === void 0 ? void 0 : _searchRef$value3.blur();
|
|
165
|
+
},
|
|
166
|
+
searchClear: () => {
|
|
167
|
+
var _searchRef$value4;
|
|
168
|
+
return (_searchRef$value4 = searchRef.value) === null || _searchRef$value4 === void 0 ? void 0 : _searchRef$value4.clear();
|
|
169
|
+
},
|
|
170
|
+
searchToggle: (...arg) => {
|
|
171
|
+
var _searchRef$value5;
|
|
172
|
+
return (_searchRef$value5 = searchRef.value) === null || _searchRef$value5 === void 0 ? void 0 : _searchRef$value5.toggle(...arg);
|
|
173
|
+
},
|
|
174
|
+
mdInstance: computed(() => {
|
|
175
|
+
var _renderRef$value;
|
|
176
|
+
return (_renderRef$value = renderRef.value) === null || _renderRef$value === void 0 ? void 0 : _renderRef$value.mdInstance;
|
|
177
|
+
}),
|
|
178
|
+
htmlStr: computed(() => {
|
|
179
|
+
var _renderRef$value2;
|
|
180
|
+
return ((_renderRef$value2 = renderRef.value) === null || _renderRef$value2 === void 0 ? void 0 : _renderRef$value2.htmlStr) || "";
|
|
181
|
+
})
|
|
182
|
+
});
|
|
183
|
+
return () => createVNode("div", {
|
|
184
|
+
"ref": root,
|
|
185
|
+
"class": name
|
|
186
|
+
}, [createVNode("div", { "class": addPrefix("__wrapper") }, [createVNode("div", { "class": addPrefix("__main") }, [
|
|
187
|
+
search.value && createVNode(VmdSticky, { "offset": props.topOffset }, { default: () => [createVNode("div", { "class": addPrefix("__search") }, [createVNode("div", { "class": addPrefix("__search-input") }, [createVNode(VmdSearch, mergeProps(searchAttrs.value, {
|
|
188
|
+
"ref": searchRef,
|
|
189
|
+
"modelValue": keyword.value,
|
|
190
|
+
"onUpdate:modelValue": ($event) => keyword.value = $event,
|
|
191
|
+
"target": renderRef.value
|
|
192
|
+
}), null)])])] }),
|
|
193
|
+
createVNode(VmdRender, mergeProps(renderAttrs.value, { "ref": renderRef }), null),
|
|
194
|
+
!!btnCount.value && createVNode(VmdSticky, {
|
|
195
|
+
"posY": "bottom",
|
|
196
|
+
"posX": "right",
|
|
197
|
+
"flow": false,
|
|
198
|
+
"zIndex": "var(--vmd-markdown-btn-z-index)",
|
|
199
|
+
"offset": props.bottomOffset
|
|
200
|
+
}, { default: () => [createVNode("div", {
|
|
201
|
+
"class": addPrefix("__btn"),
|
|
202
|
+
"style": { width: `${btnCount.value * 40}px` }
|
|
203
|
+
}, [showBtnWithObj.value.search && createVNode("button", {
|
|
204
|
+
"aria-label": "Search",
|
|
205
|
+
"class": [addPrefix("__btn-search"), createBtnClass(search.value)],
|
|
206
|
+
"onClick": () => search.value = !search.value
|
|
207
|
+
}, [createVNode(FontAwesomeIcon, { "icon": faMagnifyingGlass }, null)]), showBtnWithObj.value.toc && createVNode("button", {
|
|
208
|
+
"aria-label": "Table of contents",
|
|
209
|
+
"class": [addPrefix("__btn-toc"), createBtnClass(toc.value)],
|
|
210
|
+
"onClick": () => toc.value = !toc.value
|
|
211
|
+
}, [createVNode(FontAwesomeIcon, { "icon": faList }, null)])])] })
|
|
212
|
+
]), createVNode(Transition, { "name": addPrefix("__ani") }, { default: () => [toc.value && createVNode("aside", { "class": [addPrefix("__aside"), { [addPrefix("--mini")]: isMiniScreen.value }] }, [createVNode(VmdSticky, {
|
|
213
|
+
"class": addPrefix("__aside-sticky"),
|
|
214
|
+
"offset": props.topOffset
|
|
215
|
+
}, { default: () => [createVNode("div", {
|
|
216
|
+
"style": tocStyles.value.wrapper,
|
|
217
|
+
"class": addPrefix("__toc")
|
|
218
|
+
}, [createVNode(VmdToc, mergeProps(tocAttrs.value, {
|
|
219
|
+
"ref": tocRef,
|
|
220
|
+
"style": tocStyles.value.content,
|
|
221
|
+
"target": renderRef.value
|
|
222
|
+
}), null)])] })])] })])]);
|
|
223
|
+
}
|
|
317
224
|
});
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
markdownProps
|
|
321
|
-
};
|
|
225
|
+
//#endregion
|
|
226
|
+
export { Markdown_default as default, markdownProps };
|
package/es/markdown/index.css
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
--vmd-markdown-btn-icon-border-w: 2px;
|
|
18
18
|
--vmd-markdown-btn-icon-border: var(--vmd-markdown-btn-icon-border-w) #fff solid;
|
|
19
19
|
--vmd-markdown-btn-icon-line-left: calc(0px - var(--vmd-markdown-btn-icon-border-w) - 0.5px);
|
|
20
|
+
--vmd-markdown-btn-icon-size: 12px;
|
|
20
21
|
--vmd-markdown-btn-icon-active: var(--vmd-active-color);
|
|
21
22
|
--vmd-markdown-btn-icon-line-w: 1px;
|
|
22
23
|
--vmd-markdown-btn-icon-line-h: 18px;
|
|
@@ -70,6 +71,8 @@
|
|
|
70
71
|
border-radius: inherit;
|
|
71
72
|
box-sizing: border-box;
|
|
72
73
|
color: var(--vmd-icon-color);
|
|
74
|
+
background: none;
|
|
75
|
+
font-size: var(--vmd-markdown-btn-icon-size);
|
|
73
76
|
}
|
|
74
77
|
.vmd-markdown__btn-icon--active {
|
|
75
78
|
background: var(--vmd-markdown-btn-icon-active);
|