vue-markdown-design 0.3.1 → 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.
Files changed (72) hide show
  1. package/README.md +5 -1
  2. package/README.zh-CN.md +4 -0
  3. package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/asyncToGenerator.mjs +27 -0
  4. package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.mjs +12 -0
  5. package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectSpread2.mjs +25 -0
  6. package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutProperties.mjs +13 -0
  7. package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutPropertiesLoose.mjs +12 -0
  8. package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPrimitive.mjs +14 -0
  9. package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPropertyKey.mjs +9 -0
  10. package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/typeof.mjs +11 -0
  11. package/es/hooks/use-element/index.mjs +21 -18
  12. package/es/hooks/use-scroll-element/index.mjs +44 -45
  13. package/es/index.mjs +7 -18
  14. package/es/markdown/Markdown.mjs +221 -316
  15. package/es/markdown/index.css +3 -0
  16. package/es/markdown/index2.mjs +6 -0
  17. package/es/render/Render.mjs +143 -173
  18. package/es/render/index.css +37 -21
  19. package/es/render/index2.mjs +6 -0
  20. package/es/search/Search.mjs +236 -285
  21. package/es/search/index.css +4 -0
  22. package/es/search/index2.mjs +6 -0
  23. package/es/sticky/Sticky.mjs +66 -99
  24. package/es/sticky/index2.mjs +6 -0
  25. package/es/toc/Toc.mjs +253 -347
  26. package/es/toc/index2.mjs +6 -0
  27. package/es/utils/constant.mjs +4 -4
  28. package/es/utils/dom.mjs +44 -68
  29. package/es/utils/format.mjs +33 -39
  30. package/es/utils/functions.mjs +5 -5
  31. package/es/utils/vue.mjs +10 -32
  32. package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/asyncToGenerator.js +27 -0
  33. package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js +12 -0
  34. package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectSpread2.js +25 -0
  35. package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutProperties.js +13 -0
  36. package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutPropertiesLoose.js +12 -0
  37. package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPrimitive.js +14 -0
  38. package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPropertyKey.js +9 -0
  39. package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/typeof.js +16 -0
  40. package/lib/_virtual/_rolldown/runtime.js +23 -0
  41. package/lib/hooks/use-element/index.js +23 -19
  42. package/lib/hooks/use-scroll-element/index.js +45 -45
  43. package/lib/index.js +24 -22
  44. package/lib/markdown/Markdown.js +224 -317
  45. package/lib/markdown/index.css +3 -0
  46. package/lib/markdown/index2.js +6 -0
  47. package/lib/render/Render.js +152 -176
  48. package/lib/render/index.css +37 -21
  49. package/lib/render/index2.js +6 -0
  50. package/lib/search/Search.js +242 -287
  51. package/lib/search/index.css +4 -0
  52. package/lib/search/index2.js +6 -0
  53. package/lib/sticky/Sticky.js +68 -99
  54. package/lib/sticky/index2.js +6 -0
  55. package/lib/toc/Toc.js +259 -349
  56. package/lib/toc/index2.js +6 -0
  57. package/lib/utils/constant.js +3 -3
  58. package/lib/utils/dom.js +46 -69
  59. package/lib/utils/format.js +33 -33
  60. package/lib/utils/functions.js +4 -4
  61. package/lib/utils/vue.js +10 -31
  62. package/package.json +4 -9
  63. package/es/markdown/index.mjs +0 -9
  64. package/es/render/index.mjs +0 -9
  65. package/es/search/index.mjs +0 -9
  66. package/es/sticky/index.mjs +0 -7
  67. package/es/toc/index.mjs +0 -9
  68. package/lib/markdown/index.js +0 -8
  69. package/lib/render/index.js +0 -8
  70. package/lib/search/index.js +0 -8
  71. package/lib/sticky/index.js +0 -7
  72. package/lib/toc/index.js +0 -8
@@ -1,321 +1,226 @@
1
- import './index.css';var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
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 { VmdSticky } from "../sticky/index.mjs";
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 { faMagnifyingGlass, faList } from "@fortawesome/free-solid-svg-icons";
55
- const {
56
- name,
57
- addPrefix
58
- } = createNamespace("markdown");
59
- const markdownProps = __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, renderProps), keysAddPrefix(searchProps, "search")), keysAddPrefix(tocProps, "toc")), {
60
- keyword: searchProps.modelValue,
61
- tocOffset: tocProps.offset.type,
62
- // 不设置默认值,toc 需要 undefined 作为判断依据
63
- showBtn: {
64
- type: [Boolean, Array, Object],
65
- default: false
66
- },
67
- search: Boolean,
68
- toc: Boolean,
69
- topOffset: {
70
- type: [Number, String],
71
- default: 0
72
- },
73
- bottomOffset: {
74
- type: [Number, String],
75
- default: 0
76
- },
77
- miniScreenWidth: {
78
- type: [Number, String],
79
- default: 768
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
- const emits = __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, renderEmits), keysAddPrefix(searchEmits, "search")), keysAddPrefix(tocEmits, "toc")), {
83
- "update:keyword": searchEmits["update:modelValue"],
84
- "update:search": (payload) => isBoolean(payload),
85
- "update:toc": (payload) => isBoolean(payload)
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
- const _Markdown = /* @__PURE__ */ defineComponent({
88
- name: "vue-markdown",
89
- props: markdownProps,
90
- emits,
91
- setup(props, {
92
- emit,
93
- expose
94
- }) {
95
- const {
96
- search,
97
- toc,
98
- keyword
99
- } = useVModels(props, emit, {
100
- passive: true
101
- });
102
- const root = shallowRef();
103
- const {
104
- width: rootWidth,
105
- height: rootHeight
106
- } = useElementBounding(root);
107
- const isMiniScreen = computed(() => rootWidth.value <= Number(props.miniScreenWidth));
108
- const getPrefixedKey = (key, prefix) => prefix ? prefix + upperFirst(key) : key;
109
- const createAttrs = (propAttrs, emitAttrs, prefix) => {
110
- const targetProps = mapValues(propAttrs, (_, key) => {
111
- const prefixedKey = getPrefixedKey(key, prefix);
112
- if (prefixedKey in props) return props[prefixedKey];
113
- });
114
- const targetEmits = chain(emitAttrs).mapValues((_, key) => {
115
- const prefixedKey = getPrefixedKey(key, prefix);
116
- if (prefixedKey in emits) return (...arg) => emit(prefixedKey, ...arg);
117
- }).mapKeys((_, key) => `on${upperFirst(key)}`).value();
118
- return __spreadValues(__spreadValues({}, targetProps), targetEmits);
119
- };
120
- const renderRef = shallowRef();
121
- const renderAttrs = computed(() => createAttrs(renderProps, renderEmits));
122
- const offsetWithNum = computed(() => [props.topOffset, props.bottomOffset].map(Number));
123
- const {
124
- scrollEl
125
- } = useScrollParent(root);
126
- const getDefaultOffset = (offset) => {
127
- const {
128
- block,
129
- getOffset
130
- } = computeOffset(offset);
131
- if (block !== "start") return block;
132
- const [topOffset] = offsetWithNum.value;
133
- return (scrollAction) => {
134
- const {
135
- el
136
- } = scrollAction;
137
- const isParent = (scrollEl.value || document.documentElement) === el;
138
- const curOffset = getOffset(scrollAction, isParent);
139
- if (!isParent) return curOffset;
140
- const targetOffset = isUndefined(offset) ? topOffset : curOffset;
141
- return targetOffset + searchRect.height.value;
142
- };
143
- };
144
- const searchAttrs = computed(() => __spreadProps(__spreadValues({}, createAttrs(searchProps, searchEmits, "search")), {
145
- onClose: () => {
146
- search.value = false;
147
- emit("searchClose");
148
- }
149
- }));
150
- const searchRef = shallowRef();
151
- const searchRect = useElementBounding(searchRef);
152
- const searchIsOnMiniScreen = computed(() => isMiniScreen.value && toc.value);
153
- const tocRef = shallowRef();
154
- const tocRect = useElementBounding(tocRef);
155
- const onTocClick = () => {
156
- if (!isMiniScreen.value) return;
157
- toc.value = false;
158
- };
159
- const tocAttrs = computed(() => {
160
- const tocAttrs2 = createAttrs(tocProps, tocEmits, "toc");
161
- return __spreadProps(__spreadValues({}, tocAttrs2), {
162
- offset: getDefaultOffset(props.tocOffset),
163
- onClick: (tocItem) => {
164
- onTocClick();
165
- emit("tocClick", tocItem);
166
- }
167
- });
168
- });
169
- const scrollRect = useElementBounding(scrollEl);
170
- const windowSize = useWindowSize();
171
- const tocStyles = computed(() => {
172
- const offset = sum(offsetWithNum.value);
173
- const scrollHeight = Math.min(scrollRect.height.value || windowSize.height.value, rootHeight.value);
174
- if (isMiniScreen.value) {
175
- return {
176
- wrapper: {
177
- width: addUnit(rootWidth.value),
178
- height: addUnit(scrollHeight - offset)
179
- }
180
- };
181
- }
182
- const tocHeight = tocRect.height.value;
183
- if (tocHeight + offset < scrollHeight) return {};
184
- return {
185
- wrapper: {
186
- height: addUnit(tocHeight)
187
- },
188
- content: {
189
- marginBottom: addUnit(tocHeight + offset - scrollHeight)
190
- }
191
- };
192
- });
193
- const showBtnWithObj = computed(() => {
194
- const {
195
- toc: toc2,
196
- search: search2
197
- } = allToObject(props.showBtn, ["search", "toc"]);
198
- return {
199
- search: search2 && !searchIsOnMiniScreen.value,
200
- toc: toc2
201
- };
202
- });
203
- const btnCount = computed(() => values(showBtnWithObj.value).filter(Boolean).length);
204
- const createBtnClass = (isActive) => [addPrefix("__btn-icon"), {
205
- [addPrefix("__btn-icon--active")]: isActive
206
- }];
207
- expose({
208
- tocRefresh: () => __async(this, null, function* () {
209
- var _a;
210
- return (_a = tocRef.value) == null ? void 0 : _a.refresh();
211
- }),
212
- tocScrollTo: (href) => {
213
- var _a;
214
- return (_a = tocRef.value) == null ? void 0 : _a.scrollTo(href);
215
- },
216
- searchRefresh: (resetIndex) => __async(this, null, function* () {
217
- var _a;
218
- return (_a = searchRef.value) == null ? void 0 : _a.refresh(resetIndex);
219
- }),
220
- searchFocus: () => {
221
- var _a;
222
- return (_a = searchRef.value) == null ? void 0 : _a.focus();
223
- },
224
- searchBlur: () => {
225
- var _a;
226
- return (_a = searchRef.value) == null ? void 0 : _a.blur();
227
- },
228
- searchClear: () => {
229
- var _a;
230
- return (_a = searchRef.value) == null ? void 0 : _a.clear();
231
- },
232
- searchToggle: (...arg) => {
233
- var _a;
234
- return (_a = searchRef.value) == null ? void 0 : _a.toggle(...arg);
235
- },
236
- mdInstance: computed(() => {
237
- var _a;
238
- return (_a = renderRef.value) == null ? void 0 : _a.mdInstance;
239
- }),
240
- htmlStr: computed(() => {
241
- var _a;
242
- return ((_a = renderRef.value) == null ? void 0 : _a.htmlStr) || "";
243
- })
244
- });
245
- return () => (
246
- // 加多一层 div 可保证外部样式不影响内部粘性布局
247
- createVNode("div", {
248
- "ref": root,
249
- "class": name
250
- }, [createVNode("div", {
251
- "class": addPrefix("__wrapper")
252
- }, [createVNode("div", {
253
- "class": addPrefix("__main")
254
- }, [search.value && createVNode(VmdSticky, {
255
- "offset": props.topOffset
256
- }, {
257
- default: () => [createVNode("div", {
258
- "class": addPrefix("__search")
259
- }, [createVNode("div", {
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
- export {
319
- _Markdown as default,
320
- markdownProps
321
- };
225
+ //#endregion
226
+ export { Markdown_default as default, markdownProps };
@@ -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);
@@ -0,0 +1,6 @@
1
+ import { withInstall } from "../utils/vue.mjs";
2
+ import Markdown_default from "./Markdown.mjs";
3
+ //#region src/markdown/index.ts
4
+ var VueMarkdown = withInstall(Markdown_default);
5
+ //#endregion
6
+ export { VueMarkdown as default };