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
package/README.md CHANGED
@@ -2,7 +2,9 @@ English | [中文](./README.zh-CN.md)
2
2
 
3
3
  # Vue Markdown Design
4
4
 
5
- Vue Markdown Design is an out-of-the-box Markdown rendering component for Vue 3, built on [markdown-it](https://github.com/markdown-it/markdown-it).
5
+ [![NPM Version](https://img.shields.io/npm/v/vue-markdown-design)](https://www.npmjs.com/package/vue-markdown-design) [![codecov](https://codecov.io/github/ZeroOneJs/markdown-design/graph/badge.svg?token=US6XWJTP8H)](https://codecov.io/github/ZeroOneJs/markdown-design) [![GitHub License](https://img.shields.io/github/license/ZeroOneJs/markdown-design)](https://github.com/ZeroOneJs/markdown-design/blob/main/packages/vue-markdown-design/LICENSE) [![Release](https://github.com/ZeroOneJs/markdown-design/actions/workflows/release.yml/badge.svg)](https://github.com/ZeroOneJs/markdown-design/actions/workflows/release.yml)
6
+
7
+ An out-of-the-box Markdown rendering component for Vue 3, built on [markdown-it](https://github.com/markdown-it/markdown-it).
6
8
 
7
9
  ## Key Features
8
10
 
@@ -22,6 +24,8 @@ Vue Markdown Design is an out-of-the-box Markdown rendering component for Vue 3,
22
24
 
23
25
  📋 **Typings** - Written in TypeScript with complete type definitions
24
26
 
27
+ 🧪 **Testing** - Achieves 99% coverage in both E2E and unit tests, ensuring component stability and reliability
28
+
25
29
  ## Quick Start
26
30
 
27
31
  ### Installation
package/README.zh-CN.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Vue Markdown Design
2
2
 
3
+ [![NPM Version](https://img.shields.io/npm/v/vue-markdown-design)](https://www.npmjs.com/package/vue-markdown-design) [![codecov](https://codecov.io/github/ZeroOneJs/markdown-design/graph/badge.svg?token=US6XWJTP8H)](https://codecov.io/github/ZeroOneJs/markdown-design) [![GitHub License](https://img.shields.io/github/license/ZeroOneJs/markdown-design)](https://github.com/ZeroOneJs/markdown-design/blob/main/packages/vue-markdown-design/LICENSE) [![Release](https://github.com/ZeroOneJs/markdown-design/actions/workflows/release.yml/badge.svg)](https://github.com/ZeroOneJs/markdown-design/actions/workflows/release.yml)
4
+
3
5
  一个基于 [markdown-it](https://github.com/markdown-it/markdown-it) 的 Vue 3 开箱即用 Markdown 渲染组件。
4
6
 
5
7
  ## 主要特性
@@ -20,6 +22,8 @@
20
22
 
21
23
  📋 **类型提示** - 使用 TypeScript 开发,提供完整的类型定义
22
24
 
25
+ 🧪 **组件测试** - 端到端和单元测试覆盖率到达 99%,确保组件稳定可靠
26
+
23
27
  ## 快速上手
24
28
 
25
29
  ### 安装
@@ -0,0 +1,27 @@
1
+ //#region \0@oxc-project+runtime@0.115.0/helpers/asyncToGenerator.js
2
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
3
+ try {
4
+ var i = n[a](c), u = i.value;
5
+ } catch (n) {
6
+ e(n);
7
+ return;
8
+ }
9
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
10
+ }
11
+ function _asyncToGenerator(n) {
12
+ return function() {
13
+ var t = this, e = arguments;
14
+ return new Promise(function(r, o) {
15
+ var a = n.apply(t, e);
16
+ function _next(n) {
17
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
18
+ }
19
+ function _throw(n) {
20
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
21
+ }
22
+ _next(void 0);
23
+ });
24
+ };
25
+ }
26
+ //#endregion
27
+ export { _asyncToGenerator };
@@ -0,0 +1,12 @@
1
+ import { toPropertyKey } from "./toPropertyKey.mjs";
2
+ //#region \0@oxc-project+runtime@0.115.0/helpers/defineProperty.js
3
+ function _defineProperty(e, r, t) {
4
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
5
+ value: t,
6
+ enumerable: !0,
7
+ configurable: !0,
8
+ writable: !0
9
+ }) : e[r] = t, e;
10
+ }
11
+ //#endregion
12
+ export { _defineProperty };
@@ -0,0 +1,25 @@
1
+ import { _defineProperty } from "./defineProperty.mjs";
2
+ //#region \0@oxc-project+runtime@0.115.0/helpers/objectSpread2.js
3
+ function ownKeys(e, r) {
4
+ var t = Object.keys(e);
5
+ if (Object.getOwnPropertySymbols) {
6
+ var o = Object.getOwnPropertySymbols(e);
7
+ r && (o = o.filter(function(r) {
8
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
9
+ })), t.push.apply(t, o);
10
+ }
11
+ return t;
12
+ }
13
+ function _objectSpread2(e) {
14
+ for (var r = 1; r < arguments.length; r++) {
15
+ var t = null != arguments[r] ? arguments[r] : {};
16
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
17
+ _defineProperty(e, r, t[r]);
18
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
19
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
20
+ });
21
+ }
22
+ return e;
23
+ }
24
+ //#endregion
25
+ export { _objectSpread2 };
@@ -0,0 +1,13 @@
1
+ import { _objectWithoutPropertiesLoose } from "./objectWithoutPropertiesLoose.mjs";
2
+ //#region \0@oxc-project+runtime@0.115.0/helpers/objectWithoutProperties.js
3
+ function _objectWithoutProperties(e, t) {
4
+ if (null == e) return {};
5
+ var o, r, i = _objectWithoutPropertiesLoose(e, t);
6
+ if (Object.getOwnPropertySymbols) {
7
+ var s = Object.getOwnPropertySymbols(e);
8
+ for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
9
+ }
10
+ return i;
11
+ }
12
+ //#endregion
13
+ export { _objectWithoutProperties };
@@ -0,0 +1,12 @@
1
+ //#region \0@oxc-project+runtime@0.115.0/helpers/objectWithoutPropertiesLoose.js
2
+ function _objectWithoutPropertiesLoose(r, e) {
3
+ if (null == r) return {};
4
+ var t = {};
5
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
6
+ if (e.includes(n)) continue;
7
+ t[n] = r[n];
8
+ }
9
+ return t;
10
+ }
11
+ //#endregion
12
+ export { _objectWithoutPropertiesLoose };
@@ -0,0 +1,14 @@
1
+ import { _typeof } from "./typeof.mjs";
2
+ //#region \0@oxc-project+runtime@0.115.0/helpers/toPrimitive.js
3
+ function toPrimitive(t, r) {
4
+ if ("object" != _typeof(t) || !t) return t;
5
+ var e = t[Symbol.toPrimitive];
6
+ if (void 0 !== e) {
7
+ var i = e.call(t, r || "default");
8
+ if ("object" != _typeof(i)) return i;
9
+ throw new TypeError("@@toPrimitive must return a primitive value.");
10
+ }
11
+ return ("string" === r ? String : Number)(t);
12
+ }
13
+ //#endregion
14
+ export { toPrimitive };
@@ -0,0 +1,9 @@
1
+ import { _typeof } from "./typeof.mjs";
2
+ import { toPrimitive } from "./toPrimitive.mjs";
3
+ //#region \0@oxc-project+runtime@0.115.0/helpers/toPropertyKey.js
4
+ function toPropertyKey(t) {
5
+ var i = toPrimitive(t, "string");
6
+ return "symbol" == _typeof(i) ? i : i + "";
7
+ }
8
+ //#endregion
9
+ export { toPropertyKey };
@@ -0,0 +1,11 @@
1
+ //#region \0@oxc-project+runtime@0.115.0/helpers/typeof.js
2
+ function _typeof(o) {
3
+ "@babel/helpers - typeof";
4
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
5
+ return typeof o;
6
+ } : function(o) {
7
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
8
+ }, _typeof(o);
9
+ }
10
+ //#endregion
11
+ export { _typeof };
@@ -1,22 +1,25 @@
1
- import { useMounted, toValue, unrefElement } from "@vueuse/core";
2
1
  import { isString } from "lodash";
3
2
  import { shallowRef, watchPostEffect } from "vue";
3
+ import { toValue, unrefElement, useMounted } from "@vueuse/core";
4
+ //#region src/hooks/use-element/index.ts
4
5
  function useElement(target) {
5
- const targetEl = shallowRef();
6
- const isMounted = useMounted();
7
- const update = () => {
8
- const targetVal = toValue(target);
9
- if (!(targetVal && isMounted.value)) return;
10
- if (!isString(targetVal)) {
11
- targetEl.value = unrefElement(targetVal);
12
- return;
13
- }
14
- targetEl.value = document.querySelector(targetVal);
15
- if (!targetEl.value) console.error("[vue-markdown-design] Target does not exist.");
16
- };
17
- watchPostEffect(update);
18
- return { targetEl, update };
6
+ const targetEl = shallowRef();
7
+ const isMounted = useMounted();
8
+ const update = () => {
9
+ const targetVal = toValue(target);
10
+ if (!(targetVal && isMounted.value)) return;
11
+ if (!isString(targetVal)) {
12
+ targetEl.value = unrefElement(targetVal);
13
+ return;
14
+ }
15
+ targetEl.value = document.querySelector(targetVal);
16
+ if (!targetEl.value) console.error("[vue-markdown-design] Target does not exist.");
17
+ };
18
+ watchPostEffect(update);
19
+ return {
20
+ targetEl,
21
+ update
22
+ };
19
23
  }
20
- export {
21
- useElement
22
- };
24
+ //#endregion
25
+ export { useElement };
@@ -1,52 +1,51 @@
1
- import { unrefElement, useMutationObserver } from "@vueuse/core";
2
- import { shallowRef, watch, onMounted } from "vue";
3
1
  import { allToArray } from "../../utils/format.mjs";
4
- const tagNames = /* @__PURE__ */ new Set(["HTML", "BODY"]);
5
- const scrollReg = /scroll|auto|overlay/i;
2
+ import { onMounted, shallowRef, watch } from "vue";
3
+ import { unrefElement, useMutationObserver } from "@vueuse/core";
4
+ //#region src/hooks/use-scroll-element/index.ts
5
+ var tagNames = new Set(["HTML", "BODY"]);
6
+ var scrollReg = /scroll|auto|overlay/i;
6
7
  function getScrollElement(el, onlyParent) {
7
- let node = el;
8
- const nodes = [];
9
- while (node.nodeType === 1 && !tagNames.has(node.tagName)) {
10
- const { overflowY } = window.getComputedStyle(node);
11
- if (scrollReg.test(overflowY)) {
12
- nodes.push(node);
13
- if (onlyParent) break;
14
- }
15
- const { parentNode } = node;
16
- if (!(parentNode instanceof Element)) break;
17
- node = parentNode;
18
- }
19
- return onlyParent ? nodes[0] : nodes;
8
+ let node = el;
9
+ const nodes = [];
10
+ while (node.nodeType === 1 && !tagNames.has(node.tagName)) {
11
+ const { overflowY } = window.getComputedStyle(node);
12
+ if (scrollReg.test(overflowY)) {
13
+ nodes.push(node);
14
+ if (onlyParent) break;
15
+ }
16
+ const { parentNode } = node;
17
+ if (!(parentNode instanceof Element)) break;
18
+ node = parentNode;
19
+ }
20
+ return onlyParent ? nodes[0] : nodes;
20
21
  }
21
22
  function isElement(el) {
22
- return [HTMLElement, SVGElement].some((type) => el instanceof type);
23
+ return [HTMLElement, SVGElement].some((type) => el instanceof type);
23
24
  }
24
25
  function useScrollParent(target, options = {}) {
25
- const { onlyParent = true } = options;
26
- const initialValue = onlyParent ? void 0 : [];
27
- const scrollEl = shallowRef(initialValue);
28
- const update = () => {
29
- const el = unrefElement(target);
30
- if (!el) {
31
- scrollEl.value = initialValue;
32
- return;
33
- }
34
- const scrollElement = getScrollElement(el, onlyParent);
35
- if (Array.isArray(scrollElement)) {
36
- scrollEl.value = scrollElement.filter(isElement);
37
- return;
38
- }
39
- if (isElement(scrollElement)) {
40
- scrollEl.value = scrollElement;
41
- }
42
- };
43
- watch(() => unrefElement(target), update, { flush: "post" });
44
- useMutationObserver(() => allToArray(scrollEl.value), update, {
45
- attributeFilter: ["style", "class"]
46
- });
47
- onMounted(update);
48
- return { scrollEl, update };
26
+ const { onlyParent = true } = options;
27
+ const initialValue = onlyParent ? void 0 : [];
28
+ const scrollEl = shallowRef(initialValue);
29
+ const update = () => {
30
+ const el = unrefElement(target);
31
+ if (!el) {
32
+ scrollEl.value = initialValue;
33
+ return;
34
+ }
35
+ const scrollElement = getScrollElement(el, onlyParent);
36
+ if (Array.isArray(scrollElement)) {
37
+ scrollEl.value = scrollElement.filter(isElement);
38
+ return;
39
+ }
40
+ if (isElement(scrollElement)) scrollEl.value = scrollElement;
41
+ };
42
+ watch(() => unrefElement(target), update, { flush: "post" });
43
+ useMutationObserver(() => allToArray(scrollEl.value), update, { attributeFilter: ["style", "class"] });
44
+ onMounted(update);
45
+ return {
46
+ scrollEl,
47
+ update
48
+ };
49
49
  }
50
- export {
51
- useScrollParent
52
- };
50
+ //#endregion
51
+ export { useScrollParent };
package/es/index.mjs CHANGED
@@ -1,22 +1,11 @@
1
- import './style/variables.css';/* empty css */
2
- import { VmdRender } from "./render/index.mjs";
3
- import { VmdSearch } from "./search/index.mjs";
4
- import { VmdToc } from "./toc/index.mjs";
5
- import { VmdSticky } from "./sticky/index.mjs";
6
- import { VueMarkdown, VueMarkdown as VueMarkdown2 } from "./markdown/index.mjs";
1
+ import './style/variables.css';/* empty css */
7
2
  import { renderProps } from "./render/Render.mjs";
3
+ import VmdRender from "./render/index2.mjs";
8
4
  import { searchProps } from "./search/Search.mjs";
5
+ import VmdSearch from "./search/index2.mjs";
9
6
  import { tocProps } from "./toc/Toc.mjs";
7
+ import VmdToc from "./toc/index2.mjs";
8
+ import VmdSticky from "./sticky/index2.mjs";
10
9
  import { markdownProps } from "./markdown/Markdown.mjs";
11
- export {
12
- VmdRender,
13
- VmdSearch,
14
- VmdSticky,
15
- VmdToc,
16
- VueMarkdown,
17
- VueMarkdown2 as default,
18
- markdownProps,
19
- renderProps,
20
- searchProps,
21
- tocProps
22
- };
10
+ import VueMarkdown from "./markdown/index2.mjs";
11
+ export { VmdRender, VmdSearch, VmdSticky, VmdToc, VueMarkdown, VueMarkdown as default, markdownProps, renderProps, searchProps, tocProps };