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