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/utils/dom.js
CHANGED
|
@@ -1,76 +1,53 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
for (var prop in b || (b = {}))
|
|
11
|
-
if (__hasOwnProp.call(b, prop))
|
|
12
|
-
__defNormalProp(a, prop, b[prop]);
|
|
13
|
-
if (__getOwnPropSymbols)
|
|
14
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
-
if (__propIsEnum.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
}
|
|
18
|
-
return a;
|
|
19
|
-
};
|
|
20
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
-
var __objRest = (source, exclude) => {
|
|
22
|
-
var target = {};
|
|
23
|
-
for (var prop in source)
|
|
24
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
-
target[prop] = source[prop];
|
|
26
|
-
if (source != null && __getOwnPropSymbols)
|
|
27
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
-
target[prop] = source[prop];
|
|
30
|
-
}
|
|
31
|
-
return target;
|
|
32
|
-
};
|
|
33
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
34
|
-
const computeScrollIntoView = require("compute-scroll-into-view");
|
|
35
|
-
const lodash = require("lodash");
|
|
36
|
-
const popmotion = require("popmotion");
|
|
37
|
-
const format = require("./format.js");
|
|
1
|
+
require("../_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_objectSpread2 = require("../_virtual/_@oxc-project_runtime@0.115.0/helpers/objectSpread2.js");
|
|
3
|
+
const require_format = require("./format.js");
|
|
4
|
+
const require_objectWithoutProperties = require("../_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutProperties.js");
|
|
5
|
+
let lodash = require("lodash");
|
|
6
|
+
let compute_scroll_into_view = require("compute-scroll-into-view");
|
|
7
|
+
let popmotion = require("popmotion");
|
|
8
|
+
//#region src/utils/dom.ts
|
|
9
|
+
var _excluded = ["onUpdate"], _excluded2 = ["offset", "smooth"];
|
|
38
10
|
function setScrollTop({ el, to }) {
|
|
39
|
-
|
|
11
|
+
el.scrollTop = to;
|
|
40
12
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
13
|
+
var playAnimation = (scroller, options) => {
|
|
14
|
+
const { el, to } = scroller;
|
|
15
|
+
const { onUpdate } = options;
|
|
16
|
+
(0, popmotion.animate)(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, require_objectWithoutProperties._objectWithoutProperties(options, _excluded)), {}, {
|
|
17
|
+
from: el.scrollTop,
|
|
18
|
+
to,
|
|
19
|
+
onUpdate: (top) => {
|
|
20
|
+
onUpdate === null || onUpdate === void 0 || onUpdate(top);
|
|
21
|
+
setScrollTop({
|
|
22
|
+
el,
|
|
23
|
+
to: top
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}));
|
|
52
27
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
28
|
+
var computeOptionsKeys = [
|
|
29
|
+
"inline",
|
|
30
|
+
"scrollMode",
|
|
31
|
+
"boundary",
|
|
32
|
+
"skipOverflowHiddenElements"
|
|
58
33
|
];
|
|
59
34
|
function scrollToEl(target, options = {}) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
35
|
+
const { offset, smooth } = options, others = require_objectWithoutProperties._objectWithoutProperties(options, _excluded2);
|
|
36
|
+
const { block, getOffset } = require_format.computeOffset(offset);
|
|
37
|
+
const animationOptions = (0, lodash.omit)(others, computeOptionsKeys);
|
|
38
|
+
(0, compute_scroll_into_view.compute)(target, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, (0, lodash.pick)(others, computeOptionsKeys)), {}, { block })).forEach((scrollAction, index) => {
|
|
39
|
+
const { el, top } = scrollAction;
|
|
40
|
+
let to = el.scrollTop;
|
|
41
|
+
if (!index) {
|
|
42
|
+
const curOffset = getOffset(scrollAction, !index);
|
|
43
|
+
to = el.scrollHeight - top > el.clientHeight ? Math.max(top - curOffset, 0) : top;
|
|
44
|
+
}
|
|
45
|
+
const scroller = {
|
|
46
|
+
el,
|
|
47
|
+
to
|
|
48
|
+
};
|
|
49
|
+
smooth ? playAnimation(scroller, animationOptions) : setTimeout(() => setScrollTop(scroller), 0);
|
|
50
|
+
});
|
|
75
51
|
}
|
|
52
|
+
//#endregion
|
|
76
53
|
exports.scrollToEl = scrollToEl;
|
package/lib/utils/format.js
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
require("../_virtual/_rolldown/runtime.js");
|
|
2
|
+
let lodash = require("lodash");
|
|
3
|
+
//#region src/utils/format.ts
|
|
4
|
+
var scrollLogicalPosition = new Set([
|
|
5
|
+
"start",
|
|
6
|
+
"end",
|
|
7
|
+
"center",
|
|
8
|
+
"nearest"
|
|
9
|
+
]);
|
|
5
10
|
function computeOffset(offset = "start") {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
};
|
|
11
|
+
if ((0, lodash.isString)(offset) && scrollLogicalPosition.has(offset)) return {
|
|
12
|
+
block: offset,
|
|
13
|
+
getOffset: () => 0
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
block: "start",
|
|
17
|
+
getOffset: (scrollAction, isParent) => {
|
|
18
|
+
if ((0, lodash.isFunction)(offset)) return offset(scrollAction) || 0;
|
|
19
|
+
return isParent ? Number(offset) : 0;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
19
22
|
}
|
|
20
23
|
function keysAddPrefix(props, prefix) {
|
|
21
|
-
|
|
24
|
+
return (0, lodash.mapKeys)(props, (_, key) => prefix + (0, lodash.upperFirst)(key));
|
|
22
25
|
}
|
|
23
26
|
function arrToObject(arr, value = true) {
|
|
24
|
-
|
|
27
|
+
return (0, lodash.fromPairs)(arr.map((key) => [key, value]));
|
|
25
28
|
}
|
|
26
29
|
function allToObject(value, keys) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (Array.isArray(value)) {
|
|
31
|
-
return arrToObject(value);
|
|
32
|
-
}
|
|
33
|
-
return value;
|
|
30
|
+
if ((0, lodash.isBoolean)(value)) return arrToObject(keys, value);
|
|
31
|
+
if (Array.isArray(value)) return arrToObject(value);
|
|
32
|
+
return value;
|
|
34
33
|
}
|
|
35
34
|
function addUnit(value) {
|
|
36
|
-
|
|
35
|
+
return `${value}px`;
|
|
37
36
|
}
|
|
38
37
|
function createNamespace(str) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
const name = `vmd-${str}`;
|
|
39
|
+
return {
|
|
40
|
+
name,
|
|
41
|
+
addPrefix: (str) => name + str
|
|
42
|
+
};
|
|
44
43
|
}
|
|
45
44
|
function allToArray(value) {
|
|
46
|
-
|
|
45
|
+
return Array.isArray(value) ? value : [value];
|
|
47
46
|
}
|
|
47
|
+
//#endregion
|
|
48
48
|
exports.addUnit = addUnit;
|
|
49
49
|
exports.allToArray = allToArray;
|
|
50
50
|
exports.allToObject = allToObject;
|
package/lib/utils/functions.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
1
|
+
//#region src/utils/functions.ts
|
|
3
2
|
function runFnWithOptions(options, fn) {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
if (!options) return;
|
|
4
|
+
options === true ? fn() : fn(options);
|
|
6
5
|
}
|
|
6
|
+
//#endregion
|
|
7
7
|
exports.runFnWithOptions = runFnWithOptions;
|
package/lib/utils/vue.js
CHANGED
|
@@ -1,34 +1,13 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __spreadValues = (a, b) => {
|
|
10
|
-
for (var prop in b || (b = {}))
|
|
11
|
-
if (__hasOwnProp.call(b, prop))
|
|
12
|
-
__defNormalProp(a, prop, b[prop]);
|
|
13
|
-
if (__getOwnPropSymbols)
|
|
14
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
-
if (__propIsEnum.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
}
|
|
18
|
-
return a;
|
|
19
|
-
};
|
|
20
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
22
|
-
const lodash = require("lodash");
|
|
1
|
+
require("../_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_objectSpread2 = require("../_virtual/_@oxc-project_runtime@0.115.0/helpers/objectSpread2.js");
|
|
3
|
+
let lodash = require("lodash");
|
|
4
|
+
//#region src/utils/vue.ts
|
|
23
5
|
function withInstall(component, aliases = []) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const names = [pascalCaseName, ...aliases].filter(Boolean);
|
|
30
|
-
names.forEach((item) => app.component(item, component));
|
|
31
|
-
}
|
|
32
|
-
});
|
|
6
|
+
return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, component), {}, { install: (app) => {
|
|
7
|
+
const { name } = component;
|
|
8
|
+
if (!(name || aliases.length)) return;
|
|
9
|
+
[name && (0, lodash.upperFirst)((0, lodash.camelCase)(name)), ...aliases].filter(Boolean).forEach((item) => app.component(item, component));
|
|
10
|
+
} });
|
|
33
11
|
}
|
|
12
|
+
//#endregion
|
|
34
13
|
exports.withInstall = withInstall;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-markdown-design",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Vue 3 markdown component built on markdown-it.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -47,25 +47,20 @@
|
|
|
47
47
|
"vue": "^3.0.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@cypress/code-coverage": "^3.13.10",
|
|
51
50
|
"@types/lodash": "^4.17.7",
|
|
52
51
|
"@types/mark.js": "^8.11.12",
|
|
53
|
-
"@vitejs/plugin-vue": "^
|
|
54
|
-
"@vitejs/plugin-vue-jsx": "^
|
|
55
|
-
"cypress": "^14.5.0",
|
|
52
|
+
"@vitejs/plugin-vue": "^6.0.4",
|
|
53
|
+
"@vitejs/plugin-vue-jsx": "^5.1.4",
|
|
56
54
|
"less": "^4.2.0",
|
|
57
55
|
"npm-run-all2": "^6.2.0",
|
|
58
56
|
"typescript": "~5.4.0",
|
|
59
|
-
"vite": "^
|
|
57
|
+
"vite": "^8.0.0",
|
|
60
58
|
"vite-plugin-dts": "^4.5.0",
|
|
61
|
-
"vite-plugin-istanbul": "^6.0.2",
|
|
62
59
|
"vite-plugin-lib-inject-css": "^2.2.1",
|
|
63
60
|
"vue": "^3.4.29",
|
|
64
61
|
"vue-tsc": "^2.0.21"
|
|
65
62
|
},
|
|
66
63
|
"scripts": {
|
|
67
|
-
"test": "cypress run --component",
|
|
68
|
-
"test:dev": "cypress open --component",
|
|
69
64
|
"type-check": "vue-tsc -p tsconfig.build.json",
|
|
70
65
|
"build-only": "vite build",
|
|
71
66
|
"build": "run-p type-check build-only"
|
package/es/markdown/index.mjs
DELETED
package/es/render/index.mjs
DELETED
package/es/search/index.mjs
DELETED
package/es/sticky/index.mjs
DELETED
package/es/toc/index.mjs
DELETED
package/lib/markdown/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const vue = require("../utils/vue.js");
|
|
4
|
-
const Markdown = require("./Markdown.js");
|
|
5
|
-
const VueMarkdown = vue.withInstall(Markdown.default);
|
|
6
|
-
exports.markdownProps = Markdown.markdownProps;
|
|
7
|
-
exports.VueMarkdown = VueMarkdown;
|
|
8
|
-
exports.default = VueMarkdown;
|
package/lib/render/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const vue = require("../utils/vue.js");
|
|
4
|
-
const Render = require("./Render.js");
|
|
5
|
-
const VmdRender = vue.withInstall(Render.default);
|
|
6
|
-
exports.renderProps = Render.renderProps;
|
|
7
|
-
exports.VmdRender = VmdRender;
|
|
8
|
-
exports.default = VmdRender;
|
package/lib/search/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const vue = require("../utils/vue.js");
|
|
4
|
-
const Search = require("./Search.js");
|
|
5
|
-
const VmdSearch = vue.withInstall(Search.default);
|
|
6
|
-
exports.searchProps = Search.searchProps;
|
|
7
|
-
exports.VmdSearch = VmdSearch;
|
|
8
|
-
exports.default = VmdSearch;
|
package/lib/sticky/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const vue = require("../utils/vue.js");
|
|
4
|
-
const Sticky = require("./Sticky.js");
|
|
5
|
-
const VmdSticky = vue.withInstall(Sticky);
|
|
6
|
-
exports.VmdSticky = VmdSticky;
|
|
7
|
-
exports.default = VmdSticky;
|
package/lib/toc/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const vue = require("../utils/vue.js");
|
|
4
|
-
const Toc = require("./Toc.js");
|
|
5
|
-
const VmdToc = vue.withInstall(Toc.default);
|
|
6
|
-
exports.tocProps = Toc.tocProps;
|
|
7
|
-
exports.VmdToc = VmdToc;
|
|
8
|
-
exports.default = VmdToc;
|