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.
- 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/README.md
CHANGED
|
@@ -2,7 +2,9 @@ English | [中文](./README.zh-CN.md)
|
|
|
2
2
|
|
|
3
3
|
# Vue Markdown Design
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/vue-markdown-design) [](https://codecov.io/github/ZeroOneJs/markdown-design) [](https://github.com/ZeroOneJs/markdown-design/blob/main/packages/vue-markdown-design/LICENSE) [](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
|
+
[](https://www.npmjs.com/package/vue-markdown-design) [](https://codecov.io/github/ZeroOneJs/markdown-design) [](https://github.com/ZeroOneJs/markdown-design/blob/main/packages/vue-markdown-design/LICENSE) [](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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
21
|
-
|
|
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
|
-
|
|
5
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
23
|
+
return [HTMLElement, SVGElement].some((type) => el instanceof type);
|
|
23
24
|
}
|
|
24
25
|
function useScrollParent(target, options = {}) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
51
|
-
|
|
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
|
-
|
|
12
|
-
|
|
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 };
|