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.
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/lib/utils/dom.js CHANGED
@@ -1,76 +1,53 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
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
- 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
- el.scrollTop = to;
11
+ el.scrollTop = to;
40
12
  }
41
- const playAnimation = (scroller, options) => {
42
- const { el, to } = scroller;
43
- const _a = options, { onUpdate } = _a, others = __objRest(_a, ["onUpdate"]);
44
- popmotion.animate(__spreadProps(__spreadValues({}, others), {
45
- from: el.scrollTop,
46
- to,
47
- onUpdate: (top) => {
48
- onUpdate == null ? void 0 : onUpdate(top);
49
- setScrollTop({ el, to: top });
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
- const computeOptionsKeys = [
54
- "inline",
55
- "scrollMode",
56
- "boundary",
57
- "skipOverflowHiddenElements"
28
+ var computeOptionsKeys = [
29
+ "inline",
30
+ "scrollMode",
31
+ "boundary",
32
+ "skipOverflowHiddenElements"
58
33
  ];
59
34
  function scrollToEl(target, options = {}) {
60
- const _a = options, { offset, smooth } = _a, others = __objRest(_a, ["offset", "smooth"]);
61
- const { block, getOffset } = format.computeOffset(offset);
62
- const animationOptions = lodash.omit(others, computeOptionsKeys);
63
- computeScrollIntoView.compute(target, __spreadProps(__spreadValues({}, lodash.pick(others, computeOptionsKeys)), {
64
- block
65
- })).forEach((scrollAction, index) => {
66
- const { el, top } = scrollAction;
67
- let to = el.scrollTop;
68
- if (!index) {
69
- const curOffset = getOffset(scrollAction, !index);
70
- to = el.scrollHeight - top > el.clientHeight ? Math.max(top - curOffset, 0) : top;
71
- }
72
- const scroller = { el, to };
73
- smooth ? playAnimation(scroller, animationOptions) : setTimeout(() => setScrollTop(scroller), 0);
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;
@@ -1,50 +1,50 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const lodash = require("lodash");
4
- const scrollLogicalPosition = /* @__PURE__ */ new Set(["start", "end", "center", "nearest"]);
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
- if (lodash.isString(offset) && scrollLogicalPosition.has(offset)) {
7
- return {
8
- block: offset,
9
- getOffset: () => 0
10
- };
11
- }
12
- return {
13
- block: "start",
14
- getOffset: (scrollAction, isParent) => {
15
- if (lodash.isFunction(offset)) return offset(scrollAction) || 0;
16
- return isParent ? Number(offset) : 0;
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
- return lodash.mapKeys(props, (_, key) => prefix + lodash.upperFirst(key));
24
+ return (0, lodash.mapKeys)(props, (_, key) => prefix + (0, lodash.upperFirst)(key));
22
25
  }
23
26
  function arrToObject(arr, value = true) {
24
- return lodash.fromPairs(arr.map((key) => [key, value]));
27
+ return (0, lodash.fromPairs)(arr.map((key) => [key, value]));
25
28
  }
26
29
  function allToObject(value, keys) {
27
- if (lodash.isBoolean(value)) {
28
- return arrToObject(keys, value);
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
- return `${value}px`;
35
+ return `${value}px`;
37
36
  }
38
37
  function createNamespace(str) {
39
- const name = `vmd-${str}`;
40
- return {
41
- name,
42
- addPrefix: (str2) => name + str2
43
- };
38
+ const name = `vmd-${str}`;
39
+ return {
40
+ name,
41
+ addPrefix: (str) => name + str
42
+ };
44
43
  }
45
44
  function allToArray(value) {
46
- return Array.isArray(value) ? value : [value];
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;
@@ -1,7 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
1
+ //#region src/utils/functions.ts
3
2
  function runFnWithOptions(options, fn) {
4
- if (!options) return;
5
- options === true ? fn() : fn(options);
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
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
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
- return __spreadProps(__spreadValues({}, component), {
25
- install: (app) => {
26
- const { name } = component;
27
- if (!(name || aliases.length)) return;
28
- const pascalCaseName = name && lodash.upperFirst(lodash.camelCase(name));
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.1",
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": "^5.0.5",
54
- "@vitejs/plugin-vue-jsx": "^4.0.0",
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": "^5.3.1",
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"
@@ -1,9 +0,0 @@
1
- import { withInstall } from "../utils/vue.mjs";
2
- import _Markdown from "./Markdown.mjs";
3
- import { markdownProps } from "./Markdown.mjs";
4
- const VueMarkdown = withInstall(_Markdown);
5
- export {
6
- VueMarkdown,
7
- VueMarkdown as default,
8
- markdownProps
9
- };
@@ -1,9 +0,0 @@
1
- import { withInstall } from "../utils/vue.mjs";
2
- import _Render from "./Render.mjs";
3
- import { renderProps } from "./Render.mjs";
4
- const VmdRender = withInstall(_Render);
5
- export {
6
- VmdRender,
7
- VmdRender as default,
8
- renderProps
9
- };
@@ -1,9 +0,0 @@
1
- import { withInstall } from "../utils/vue.mjs";
2
- import _Search from "./Search.mjs";
3
- import { searchProps } from "./Search.mjs";
4
- const VmdSearch = withInstall(_Search);
5
- export {
6
- VmdSearch,
7
- VmdSearch as default,
8
- searchProps
9
- };
@@ -1,7 +0,0 @@
1
- import { withInstall } from "../utils/vue.mjs";
2
- import _Sticky from "./Sticky.mjs";
3
- const VmdSticky = withInstall(_Sticky);
4
- export {
5
- VmdSticky,
6
- VmdSticky as default
7
- };
package/es/toc/index.mjs DELETED
@@ -1,9 +0,0 @@
1
- import { withInstall } from "../utils/vue.mjs";
2
- import _Toc from "./Toc.mjs";
3
- import { tocProps } from "./Toc.mjs";
4
- const VmdToc = withInstall(_Toc);
5
- export {
6
- VmdToc,
7
- VmdToc as default,
8
- tocProps
9
- };
@@ -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;
@@ -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;
@@ -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;
@@ -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;