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/es/utils/dom.mjs CHANGED
@@ -1,76 +1,52 @@
1
- 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 __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
32
- import { compute } from "compute-scroll-into-view";
1
+ import { _objectSpread2 } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/objectSpread2.mjs";
2
+ import { computeOffset } from "./format.mjs";
3
+ import { _objectWithoutProperties } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutProperties.mjs";
33
4
  import { omit, pick } from "lodash";
5
+ import { compute } from "compute-scroll-into-view";
34
6
  import { animate } from "popmotion";
35
- import { computeOffset } from "./format.mjs";
7
+ //#region src/utils/dom.ts
8
+ var _excluded = ["onUpdate"], _excluded2 = ["offset", "smooth"];
36
9
  function setScrollTop({ el, to }) {
37
- el.scrollTop = to;
10
+ el.scrollTop = to;
38
11
  }
39
- const playAnimation = (scroller, options) => {
40
- const { el, to } = scroller;
41
- const _a = options, { onUpdate } = _a, others = __objRest(_a, ["onUpdate"]);
42
- animate(__spreadProps(__spreadValues({}, others), {
43
- from: el.scrollTop,
44
- to,
45
- onUpdate: (top) => {
46
- onUpdate == null ? void 0 : onUpdate(top);
47
- setScrollTop({ el, to: top });
48
- }
49
- }));
12
+ var playAnimation = (scroller, options) => {
13
+ const { el, to } = scroller;
14
+ const { onUpdate } = options;
15
+ animate(_objectSpread2(_objectSpread2({}, _objectWithoutProperties(options, _excluded)), {}, {
16
+ from: el.scrollTop,
17
+ to,
18
+ onUpdate: (top) => {
19
+ onUpdate === null || onUpdate === void 0 || onUpdate(top);
20
+ setScrollTop({
21
+ el,
22
+ to: top
23
+ });
24
+ }
25
+ }));
50
26
  };
51
- const computeOptionsKeys = [
52
- "inline",
53
- "scrollMode",
54
- "boundary",
55
- "skipOverflowHiddenElements"
27
+ var computeOptionsKeys = [
28
+ "inline",
29
+ "scrollMode",
30
+ "boundary",
31
+ "skipOverflowHiddenElements"
56
32
  ];
57
33
  function scrollToEl(target, options = {}) {
58
- const _a = options, { offset, smooth } = _a, others = __objRest(_a, ["offset", "smooth"]);
59
- const { block, getOffset } = computeOffset(offset);
60
- const animationOptions = omit(others, computeOptionsKeys);
61
- compute(target, __spreadProps(__spreadValues({}, pick(others, computeOptionsKeys)), {
62
- block
63
- })).forEach((scrollAction, index) => {
64
- const { el, top } = scrollAction;
65
- let to = el.scrollTop;
66
- if (!index) {
67
- const curOffset = getOffset(scrollAction, !index);
68
- to = el.scrollHeight - top > el.clientHeight ? Math.max(top - curOffset, 0) : top;
69
- }
70
- const scroller = { el, to };
71
- smooth ? playAnimation(scroller, animationOptions) : setTimeout(() => setScrollTop(scroller), 0);
72
- });
34
+ const { offset, smooth } = options, others = _objectWithoutProperties(options, _excluded2);
35
+ const { block, getOffset } = computeOffset(offset);
36
+ const animationOptions = omit(others, computeOptionsKeys);
37
+ compute(target, _objectSpread2(_objectSpread2({}, pick(others, computeOptionsKeys)), {}, { block })).forEach((scrollAction, index) => {
38
+ const { el, top } = scrollAction;
39
+ let to = el.scrollTop;
40
+ if (!index) {
41
+ const curOffset = getOffset(scrollAction, !index);
42
+ to = el.scrollHeight - top > el.clientHeight ? Math.max(top - curOffset, 0) : top;
43
+ }
44
+ const scroller = {
45
+ el,
46
+ to
47
+ };
48
+ smooth ? playAnimation(scroller, animationOptions) : setTimeout(() => setScrollTop(scroller), 0);
49
+ });
73
50
  }
74
- export {
75
- scrollToEl
76
- };
51
+ //#endregion
52
+ export { scrollToEl };
@@ -1,53 +1,47 @@
1
- import { isString, isFunction, mapKeys, upperFirst, isBoolean, fromPairs } from "lodash";
2
- const scrollLogicalPosition = /* @__PURE__ */ new Set(["start", "end", "center", "nearest"]);
1
+ import { fromPairs, isBoolean, isFunction, isString, mapKeys, upperFirst } from "lodash";
2
+ //#region src/utils/format.ts
3
+ var scrollLogicalPosition = new Set([
4
+ "start",
5
+ "end",
6
+ "center",
7
+ "nearest"
8
+ ]);
3
9
  function computeOffset(offset = "start") {
4
- if (isString(offset) && scrollLogicalPosition.has(offset)) {
5
- return {
6
- block: offset,
7
- getOffset: () => 0
8
- };
9
- }
10
- return {
11
- block: "start",
12
- getOffset: (scrollAction, isParent) => {
13
- if (isFunction(offset)) return offset(scrollAction) || 0;
14
- return isParent ? Number(offset) : 0;
15
- }
16
- };
10
+ if (isString(offset) && scrollLogicalPosition.has(offset)) return {
11
+ block: offset,
12
+ getOffset: () => 0
13
+ };
14
+ return {
15
+ block: "start",
16
+ getOffset: (scrollAction, isParent) => {
17
+ if (isFunction(offset)) return offset(scrollAction) || 0;
18
+ return isParent ? Number(offset) : 0;
19
+ }
20
+ };
17
21
  }
18
22
  function keysAddPrefix(props, prefix) {
19
- return mapKeys(props, (_, key) => prefix + upperFirst(key));
23
+ return mapKeys(props, (_, key) => prefix + upperFirst(key));
20
24
  }
21
25
  function arrToObject(arr, value = true) {
22
- return fromPairs(arr.map((key) => [key, value]));
26
+ return fromPairs(arr.map((key) => [key, value]));
23
27
  }
24
28
  function allToObject(value, keys) {
25
- if (isBoolean(value)) {
26
- return arrToObject(keys, value);
27
- }
28
- if (Array.isArray(value)) {
29
- return arrToObject(value);
30
- }
31
- return value;
29
+ if (isBoolean(value)) return arrToObject(keys, value);
30
+ if (Array.isArray(value)) return arrToObject(value);
31
+ return value;
32
32
  }
33
33
  function addUnit(value) {
34
- return `${value}px`;
34
+ return `${value}px`;
35
35
  }
36
36
  function createNamespace(str) {
37
- const name = `vmd-${str}`;
38
- return {
39
- name,
40
- addPrefix: (str2) => name + str2
41
- };
37
+ const name = `vmd-${str}`;
38
+ return {
39
+ name,
40
+ addPrefix: (str) => name + str
41
+ };
42
42
  }
43
43
  function allToArray(value) {
44
- return Array.isArray(value) ? value : [value];
44
+ return Array.isArray(value) ? value : [value];
45
45
  }
46
- export {
47
- addUnit,
48
- allToArray,
49
- allToObject,
50
- computeOffset,
51
- createNamespace,
52
- keysAddPrefix
53
- };
46
+ //#endregion
47
+ export { addUnit, allToArray, allToObject, computeOffset, createNamespace, keysAddPrefix };
@@ -1,7 +1,7 @@
1
+ //#region src/utils/functions.ts
1
2
  function runFnWithOptions(options, fn) {
2
- if (!options) return;
3
- options === true ? fn() : fn(options);
3
+ if (!options) return;
4
+ options === true ? fn() : fn(options);
4
5
  }
5
- export {
6
- runFnWithOptions
7
- };
6
+ //#endregion
7
+ export { runFnWithOptions };
package/es/utils/vue.mjs CHANGED
@@ -1,34 +1,12 @@
1
- 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
- import { upperFirst, camelCase } from "lodash";
1
+ import { _objectSpread2 } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/objectSpread2.mjs";
2
+ import { camelCase, upperFirst } from "lodash";
3
+ //#region src/utils/vue.ts
21
4
  function withInstall(component, aliases = []) {
22
- return __spreadProps(__spreadValues({}, component), {
23
- install: (app) => {
24
- const { name } = component;
25
- if (!(name || aliases.length)) return;
26
- const pascalCaseName = name && upperFirst(camelCase(name));
27
- const names = [pascalCaseName, ...aliases].filter(Boolean);
28
- names.forEach((item) => app.component(item, component));
29
- }
30
- });
5
+ return _objectSpread2(_objectSpread2({}, component), {}, { install: (app) => {
6
+ const { name } = component;
7
+ if (!(name || aliases.length)) return;
8
+ [name && upperFirst(camelCase(name)), ...aliases].filter(Boolean).forEach((item) => app.component(item, component));
9
+ } });
31
10
  }
32
- export {
33
- withInstall
34
- };
11
+ //#endregion
12
+ export { withInstall };
@@ -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
+ exports._asyncToGenerator = _asyncToGenerator;
@@ -0,0 +1,12 @@
1
+ const require_toPropertyKey = require("./toPropertyKey.js");
2
+ //#region \0@oxc-project+runtime@0.115.0/helpers/defineProperty.js
3
+ function _defineProperty(e, r, t) {
4
+ return (r = require_toPropertyKey.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
+ exports._defineProperty = _defineProperty;
@@ -0,0 +1,25 @@
1
+ const require_defineProperty = require("./defineProperty.js");
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
+ require_defineProperty._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
+ exports._objectSpread2 = _objectSpread2;
@@ -0,0 +1,13 @@
1
+ const require_objectWithoutPropertiesLoose = require("./objectWithoutPropertiesLoose.js");
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 = require_objectWithoutPropertiesLoose._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
+ exports._objectWithoutProperties = _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
+ exports._objectWithoutPropertiesLoose = _objectWithoutPropertiesLoose;
@@ -0,0 +1,14 @@
1
+ const require_typeof = require("./typeof.js");
2
+ //#region \0@oxc-project+runtime@0.115.0/helpers/toPrimitive.js
3
+ function toPrimitive(t, r) {
4
+ if ("object" != require_typeof._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" != require_typeof._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
+ exports.toPrimitive = toPrimitive;
@@ -0,0 +1,9 @@
1
+ const require_typeof = require("./typeof.js");
2
+ const require_toPrimitive = require("./toPrimitive.js");
3
+ //#region \0@oxc-project+runtime@0.115.0/helpers/toPropertyKey.js
4
+ function toPropertyKey(t) {
5
+ var i = require_toPrimitive.toPrimitive(t, "string");
6
+ return "symbol" == require_typeof._typeof(i) ? i : i + "";
7
+ }
8
+ //#endregion
9
+ exports.toPropertyKey = toPropertyKey;
@@ -0,0 +1,16 @@
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
+ Object.defineProperty(exports, "_typeof", {
12
+ enumerable: true,
13
+ get: function() {
14
+ return _typeof;
15
+ }
16
+ });
@@ -0,0 +1,23 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ exports.__toESM = __toESM;
@@ -1,22 +1,26 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const core = require("@vueuse/core");
4
- const lodash = require("lodash");
5
- const vue = require("vue");
1
+ require("../../_virtual/_rolldown/runtime.js");
2
+ let lodash = require("lodash");
3
+ let vue = require("vue");
4
+ let _vueuse_core = require("@vueuse/core");
5
+ //#region src/hooks/use-element/index.ts
6
6
  function useElement(target) {
7
- const targetEl = vue.shallowRef();
8
- const isMounted = core.useMounted();
9
- const update = () => {
10
- const targetVal = core.toValue(target);
11
- if (!(targetVal && isMounted.value)) return;
12
- if (!lodash.isString(targetVal)) {
13
- targetEl.value = core.unrefElement(targetVal);
14
- return;
15
- }
16
- targetEl.value = document.querySelector(targetVal);
17
- if (!targetEl.value) console.error("[vue-markdown-design] Target does not exist.");
18
- };
19
- vue.watchPostEffect(update);
20
- return { targetEl, update };
7
+ const targetEl = (0, vue.shallowRef)();
8
+ const isMounted = (0, _vueuse_core.useMounted)();
9
+ const update = () => {
10
+ const targetVal = (0, _vueuse_core.toValue)(target);
11
+ if (!(targetVal && isMounted.value)) return;
12
+ if (!(0, lodash.isString)(targetVal)) {
13
+ targetEl.value = (0, _vueuse_core.unrefElement)(targetVal);
14
+ return;
15
+ }
16
+ targetEl.value = document.querySelector(targetVal);
17
+ if (!targetEl.value) console.error("[vue-markdown-design] Target does not exist.");
18
+ };
19
+ (0, vue.watchPostEffect)(update);
20
+ return {
21
+ targetEl,
22
+ update
23
+ };
21
24
  }
25
+ //#endregion
22
26
  exports.useElement = useElement;
@@ -1,52 +1,52 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const core = require("@vueuse/core");
4
- const vue = require("vue");
5
- const format = require("../../utils/format.js");
6
- const tagNames = /* @__PURE__ */ new Set(["HTML", "BODY"]);
7
- const scrollReg = /scroll|auto|overlay/i;
1
+ require("../../_virtual/_rolldown/runtime.js");
2
+ const require_format = require("../../utils/format.js");
3
+ let vue = require("vue");
4
+ let _vueuse_core = require("@vueuse/core");
5
+ //#region src/hooks/use-scroll-element/index.ts
6
+ var tagNames = new Set(["HTML", "BODY"]);
7
+ var scrollReg = /scroll|auto|overlay/i;
8
8
  function getScrollElement(el, onlyParent) {
9
- let node = el;
10
- const nodes = [];
11
- while (node.nodeType === 1 && !tagNames.has(node.tagName)) {
12
- const { overflowY } = window.getComputedStyle(node);
13
- if (scrollReg.test(overflowY)) {
14
- nodes.push(node);
15
- if (onlyParent) break;
16
- }
17
- const { parentNode } = node;
18
- if (!(parentNode instanceof Element)) break;
19
- node = parentNode;
20
- }
21
- return onlyParent ? nodes[0] : nodes;
9
+ let node = el;
10
+ const nodes = [];
11
+ while (node.nodeType === 1 && !tagNames.has(node.tagName)) {
12
+ const { overflowY } = window.getComputedStyle(node);
13
+ if (scrollReg.test(overflowY)) {
14
+ nodes.push(node);
15
+ if (onlyParent) break;
16
+ }
17
+ const { parentNode } = node;
18
+ if (!(parentNode instanceof Element)) break;
19
+ node = parentNode;
20
+ }
21
+ return onlyParent ? nodes[0] : nodes;
22
22
  }
23
23
  function isElement(el) {
24
- return [HTMLElement, SVGElement].some((type) => el instanceof type);
24
+ return [HTMLElement, SVGElement].some((type) => el instanceof type);
25
25
  }
26
26
  function useScrollParent(target, options = {}) {
27
- const { onlyParent = true } = options;
28
- const initialValue = onlyParent ? void 0 : [];
29
- const scrollEl = vue.shallowRef(initialValue);
30
- const update = () => {
31
- const el = core.unrefElement(target);
32
- if (!el) {
33
- scrollEl.value = initialValue;
34
- return;
35
- }
36
- const scrollElement = getScrollElement(el, onlyParent);
37
- if (Array.isArray(scrollElement)) {
38
- scrollEl.value = scrollElement.filter(isElement);
39
- return;
40
- }
41
- if (isElement(scrollElement)) {
42
- scrollEl.value = scrollElement;
43
- }
44
- };
45
- vue.watch(() => core.unrefElement(target), update, { flush: "post" });
46
- core.useMutationObserver(() => format.allToArray(scrollEl.value), update, {
47
- attributeFilter: ["style", "class"]
48
- });
49
- vue.onMounted(update);
50
- return { scrollEl, update };
27
+ const { onlyParent = true } = options;
28
+ const initialValue = onlyParent ? void 0 : [];
29
+ const scrollEl = (0, vue.shallowRef)(initialValue);
30
+ const update = () => {
31
+ const el = (0, _vueuse_core.unrefElement)(target);
32
+ if (!el) {
33
+ scrollEl.value = initialValue;
34
+ return;
35
+ }
36
+ const scrollElement = getScrollElement(el, onlyParent);
37
+ if (Array.isArray(scrollElement)) {
38
+ scrollEl.value = scrollElement.filter(isElement);
39
+ return;
40
+ }
41
+ if (isElement(scrollElement)) scrollEl.value = scrollElement;
42
+ };
43
+ (0, vue.watch)(() => (0, _vueuse_core.unrefElement)(target), update, { flush: "post" });
44
+ (0, _vueuse_core.useMutationObserver)(() => require_format.allToArray(scrollEl.value), update, { attributeFilter: ["style", "class"] });
45
+ (0, vue.onMounted)(update);
46
+ return {
47
+ scrollEl,
48
+ update
49
+ };
51
50
  }
51
+ //#endregion
52
52
  exports.useScrollParent = useScrollParent;
package/lib/index.js CHANGED
@@ -1,22 +1,24 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- require('./style/variables.css');;/* empty css */
4
- const index$1 = require("./render/index.js");
5
- const index$2 = require("./search/index.js");
6
- const index$3 = require("./toc/index.js");
7
- const index$4 = require("./sticky/index.js");
8
- const index = require("./markdown/index.js");
9
- const Render = require("./render/Render.js");
10
- const Search = require("./search/Search.js");
11
- const Toc = require("./toc/Toc.js");
12
- const Markdown = require("./markdown/Markdown.js");
13
- exports.VmdRender = index$1.VmdRender;
14
- exports.VmdSearch = index$2.VmdSearch;
15
- exports.VmdToc = index$3.VmdToc;
16
- exports.VmdSticky = index$4.VmdSticky;
17
- exports.VueMarkdown = index.VueMarkdown;
18
- exports.default = index.VueMarkdown;
19
- exports.renderProps = Render.renderProps;
20
- exports.searchProps = Search.searchProps;
21
- exports.tocProps = Toc.tocProps;
22
- exports.markdownProps = Markdown.markdownProps;
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
5
+ require('./style/variables.css');;/* empty css */
6
+ const require_Render = require("./render/Render.js");
7
+ const require_index = require("./render/index2.js");
8
+ const require_Search = require("./search/Search.js");
9
+ const require_index$1 = require("./search/index2.js");
10
+ const require_Toc = require("./toc/Toc.js");
11
+ const require_index$2 = require("./toc/index2.js");
12
+ const require_index$3 = require("./sticky/index2.js");
13
+ const require_Markdown = require("./markdown/Markdown.js");
14
+ const require_index$4 = require("./markdown/index2.js");
15
+ exports.VmdRender = require_index;
16
+ exports.VmdSearch = require_index$1;
17
+ exports.VmdSticky = require_index$3;
18
+ exports.VmdToc = require_index$2;
19
+ exports.VueMarkdown = require_index$4;
20
+ exports.default = require_index$4;
21
+ exports.markdownProps = require_Markdown.markdownProps;
22
+ exports.renderProps = require_Render.renderProps;
23
+ exports.searchProps = require_Search.searchProps;
24
+ exports.tocProps = require_Toc.tocProps;