@oiij/markdown-it 0.0.13 → 0.0.14

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/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import markdownIt, { Options } from "markdown-it";
2
- import * as vue0 from "vue";
2
+ import * as vue from "vue";
3
3
  import { MaybeRefOrGetter, TemplateRef } from "vue";
4
4
 
5
5
  //#region src/index.d.ts
@@ -51,9 +51,9 @@ type UseMarkDownItOptions = {
51
51
  * ```
52
52
  */
53
53
  declare function useMarkdownIt(templateRef?: TemplateRef<HTMLElement>, options?: UseMarkDownItOptions): {
54
- templateRef: Readonly<vue0.ShallowRef<HTMLElement | null>> | undefined;
55
- value: vue0.Ref<string | undefined, string | undefined>;
56
- html: vue0.Ref<string, string>;
54
+ templateRef: Readonly<vue.ShallowRef<HTMLElement | null>> | undefined;
55
+ value: vue.Ref<string | undefined, string | undefined>;
56
+ html: vue.Ref<string, string>;
57
57
  markdownItInst: markdownIt;
58
58
  render: (value?: string) => string;
59
59
  };
package/dist/index.mjs CHANGED
@@ -2,7 +2,6 @@ import DOMPurify from "dompurify";
2
2
  import markdownIt from "markdown-it";
3
3
  import { onMounted, onUnmounted, ref, toValue, watch, watchEffect } from "vue";
4
4
  import "@vueuse/core";
5
-
6
5
  //#region ../_utils/custom-watch.ts
7
6
  function watchRefOrGetter(value, callback) {
8
7
  const refValue = ref(toValue(value));
@@ -14,7 +13,6 @@ function watchRefOrGetter(value, callback) {
14
13
  });
15
14
  return refValue;
16
15
  }
17
-
18
16
  //#endregion
19
17
  //#region src/index.ts
20
18
  /**
@@ -43,9 +41,7 @@ function watchRefOrGetter(value, callback) {
43
41
  */
44
42
  function useMarkdownIt(templateRef, options) {
45
43
  const { value, manual = false, domPurify = true, markdownItOptions } = options ?? {};
46
- const valueRef = watchRefOrGetter(value, () => {
47
- if (!manual) render();
48
- });
44
+ const valueRef = watchRefOrGetter(value, () => !manual && render());
49
45
  const htmlRef = ref("");
50
46
  const markdownItInst = markdownIt({ ...markdownItOptions });
51
47
  /**
@@ -64,7 +60,7 @@ function useMarkdownIt(templateRef, options) {
64
60
  * ```
65
61
  */
66
62
  function render(value) {
67
- if (value !== void 0 && value !== valueRef.value) valueRef.value = value;
63
+ if (value !== void 0) valueRef.value = value;
68
64
  const mdValue = markdownItInst.render(valueRef.value ?? "");
69
65
  htmlRef.value = domPurify ? DOMPurify.sanitize(mdValue) : mdValue;
70
66
  if (templateRef?.value) templateRef.value.innerHTML = htmlRef.value;
@@ -84,6 +80,5 @@ function useMarkdownIt(templateRef, options) {
84
80
  render
85
81
  };
86
82
  }
87
-
88
83
  //#endregion
89
- export { useMarkdownIt };
84
+ export { useMarkdownIt };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oiij/markdown-it",
3
3
  "type": "module",
4
- "version": "0.0.13",
4
+ "version": "0.0.14",
5
5
  "description": "A Vue Composable for markdown-it",
6
6
  "author": "oiij",
7
7
  "license": "MIT",
@@ -26,17 +26,17 @@
26
26
  "package.json"
27
27
  ],
28
28
  "peerDependencies": {
29
- "@vueuse/core": "^14.1.0",
30
- "dompurify": "^3.3.1",
31
- "markdown-it": "^14.1.0",
32
- "vue": "^3.5.27"
29
+ "@vueuse/core": "^14.2.1",
30
+ "dompurify": "^3.3.3",
31
+ "markdown-it": "^14.1.1",
32
+ "vue": "^3.5.30"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/markdown-it": "^14.1.2",
36
- "@vueuse/core": "^14.1.0",
37
- "dompurify": "^3.3.1",
38
- "markdown-it": "^14.1.0",
39
- "vue": "^3.5.27"
36
+ "@vueuse/core": "^14.2.1",
37
+ "dompurify": "^3.3.3",
38
+ "markdown-it": "^14.1.1",
39
+ "vue": "^3.5.30"
40
40
  },
41
41
  "publishConfig": {
42
42
  "access": "public"