vue-markdown-design 0.3.0 → 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 +26 -4
  2. package/README.zh-CN.md +5 -1
  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 -284
  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 -286
  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
@@ -1,181 +1,151 @@
1
- import './index.css';var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
- import { defineComponent, watch, watchEffect, ref, createVNode } from "vue";
18
- /* empty css */
1
+ import { _objectSpread2 } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/objectSpread2.mjs";
2
+ import './index.css';/* empty css */
3
+ import { allToArray, createNamespace } from "../utils/format.mjs";
4
+ import { runFnWithOptions } from "../utils/functions.mjs";
5
+ import { DATA_ANCHOR } from "../utils/constant.mjs";
6
+ import { isFunction, isObject, isUndefined, pickBy } from "lodash";
7
+ import { createVNode, defineComponent, ref, watch, watchEffect } from "vue";
19
8
  import hljs from "highlight.js";
20
9
  import { full } from "markdown-it-emoji";
21
10
  import { sanitize } from "@markdown-design/markdown-it-sanitize";
22
- import { createNamespace, allToArray } from "../utils/format.mjs";
23
11
  import anchor from "markdown-it-anchor";
24
- import { isObject, pickBy, isUndefined, isFunction } from "lodash";
25
12
  import MarkdownIt from "markdown-it";
26
- import { runFnWithOptions } from "../utils/functions.mjs";
27
- import { DATA_ANCHOR } from "../utils/constant.mjs";
28
- const defaultBoolean = {
29
- type: Boolean,
30
- default: void 0
31
- };
32
- const {
33
- name,
34
- addPrefix
35
- } = createNamespace("render");
36
- const renderProps = {
37
- src: {
38
- type: [String, Number],
39
- default: ""
40
- },
41
- plugins: {
42
- type: [Function, Array],
43
- default: () => []
44
- },
45
- inline: Boolean,
46
- presetName: {
47
- type: String,
48
- default: "default"
49
- },
50
- html: {
51
- type: Boolean,
52
- default: true
53
- },
54
- sanitize: {
55
- type: [Boolean, Object],
56
- default: true
57
- },
58
- xhtmlOut: defaultBoolean,
59
- breaks: defaultBoolean,
60
- langPrefix: String,
61
- linkify: defaultBoolean,
62
- typographer: defaultBoolean,
63
- quotes: [String, Array],
64
- highlight: {
65
- type: [Boolean, Function, null],
66
- default: true
67
- },
68
- highlightOptions: Object,
69
- emoji: {
70
- type: [Boolean, Object],
71
- default: true
72
- },
73
- anchor: {
74
- type: [Boolean, Object, Function],
75
- default: true
76
- },
77
- permalink: {
78
- type: Boolean,
79
- default: true
80
- },
81
- markdownClass: {
82
- type: String,
83
- default: "markdown-body"
84
- }
13
+ //#region src/render/Render.tsx
14
+ var defaultBoolean = {
15
+ type: Boolean,
16
+ default: void 0
85
17
  };
86
- const renderEmits = {
87
- envChange: (payload) => isObject(payload)
18
+ var { name, addPrefix } = createNamespace("render");
19
+ var renderProps = {
20
+ src: {
21
+ type: [String, Number],
22
+ default: ""
23
+ },
24
+ plugins: {
25
+ type: [Function, Array],
26
+ default: () => []
27
+ },
28
+ inline: Boolean,
29
+ presetName: {
30
+ type: String,
31
+ default: "default"
32
+ },
33
+ html: {
34
+ type: Boolean,
35
+ default: true
36
+ },
37
+ sanitize: {
38
+ type: [Boolean, Object],
39
+ default: true
40
+ },
41
+ xhtmlOut: defaultBoolean,
42
+ breaks: defaultBoolean,
43
+ langPrefix: String,
44
+ linkify: defaultBoolean,
45
+ typographer: defaultBoolean,
46
+ quotes: [String, Array],
47
+ highlight: {
48
+ type: [
49
+ Boolean,
50
+ Function,
51
+ null
52
+ ],
53
+ default: true
54
+ },
55
+ highlightOptions: Object,
56
+ emoji: {
57
+ type: [Boolean, Object],
58
+ default: true
59
+ },
60
+ anchor: {
61
+ type: [
62
+ Boolean,
63
+ Object,
64
+ Function
65
+ ],
66
+ default: true
67
+ },
68
+ permalink: {
69
+ type: Boolean,
70
+ default: true
71
+ },
72
+ markdownClass: {
73
+ type: String,
74
+ default: "markdown-body"
75
+ }
88
76
  };
89
- const _Render = /* @__PURE__ */ defineComponent({
90
- name,
91
- props: renderProps,
92
- emits: renderEmits,
93
- setup(props, {
94
- emit,
95
- expose
96
- }) {
97
- const mdInstance = new MarkdownIt(props.presetName);
98
- const optionKeys = ["html", "xhtmlOut", "breaks", "langPrefix", "linkify", "typographer", "quotes"];
99
- watch(() => optionKeys.map((key) => props[key]), () => {
100
- mdInstance.set(pickBy(props, (value, key) => optionKeys.includes(key) && !isUndefined(value)));
101
- }, {
102
- immediate: true
103
- });
104
- props.highlightOptions && hljs.configure(props.highlightOptions);
105
- watchEffect(() => {
106
- let highlight = props.highlight || null;
107
- if (highlight === true) {
108
- highlight = (str, language) => {
109
- const {
110
- getLanguage,
111
- highlight: highlight2,
112
- highlightAuto
113
- } = hljs;
114
- const {
115
- value
116
- } = getLanguage(language) ? highlight2(str, {
117
- language
118
- }) : highlightAuto(str);
119
- return value;
120
- };
121
- }
122
- mdInstance.set({
123
- highlight
124
- });
125
- });
126
- runFnWithOptions(props.sanitize, (options) => mdInstance.use(sanitize, options));
127
- runFnWithOptions(props.emoji, (options) => mdInstance.use(full, options));
128
- runFnWithOptions(props.anchor, (options = {}) => {
129
- const permalink = props.permalink ? {
130
- permalink: anchor.permalink.linkInsideHeader({
131
- placement: "before",
132
- class: addPrefix("__anchor"),
133
- space: false,
134
- renderAttrs: () => ({
135
- [DATA_ANCHOR]: ""
136
- })
137
- // 适配 toc 组件,使之可以准确获取 HTMLHeadingElement
138
- })
139
- } : {};
140
- const anchorOptions = isFunction(options) ? options(anchor) : options;
141
- mdInstance.use(anchor, __spreadValues(__spreadValues({}, permalink), anchorOptions));
142
- });
143
- const getPlugins = () => {
144
- const {
145
- plugins
146
- } = props;
147
- return Array.isArray(plugins) ? plugins.map(allToArray) : [[plugins]];
148
- };
149
- getPlugins().forEach((plugin) => mdInstance.use(...plugin));
150
- const refreshKeys = ["src", "inline", "highlight", ...optionKeys];
151
- const htmlStr = ref("");
152
- watch(() => refreshKeys.map((key) => props[key]), () => {
153
- const {
154
- src,
155
- inline
156
- } = props;
157
- const env = {};
158
- htmlStr.value = mdInstance[inline ? "renderInline" : "render"](String(src), env);
159
- emit("envChange", env);
160
- }, {
161
- immediate: true
162
- });
163
- expose({
164
- mdInstance,
165
- htmlStr
166
- });
167
- return () => createVNode("div", {
168
- "class": name
169
- }, [createVNode("div", {
170
- "class": [addPrefix("__wrapper"), props.markdownClass, {
171
- [addPrefix("--permalink")]: props.permalink
172
- }],
173
- "innerHTML": htmlStr.value
174
- }, null)]);
175
- }
77
+ var renderEmits = { envChange: (payload) => isObject(payload) };
78
+ var Render_default = /* @__PURE__ */ defineComponent({
79
+ name,
80
+ props: renderProps,
81
+ emits: renderEmits,
82
+ setup(props, { emit, expose }) {
83
+ const mdInstance = new MarkdownIt(props.presetName);
84
+ const optionKeys = [
85
+ "html",
86
+ "xhtmlOut",
87
+ "breaks",
88
+ "langPrefix",
89
+ "linkify",
90
+ "typographer",
91
+ "quotes"
92
+ ];
93
+ watch(() => optionKeys.map((key) => props[key]), () => {
94
+ mdInstance.set(pickBy(props, (value, key) => optionKeys.includes(key) && !isUndefined(value)));
95
+ }, { immediate: true });
96
+ props.highlightOptions && hljs.configure(props.highlightOptions);
97
+ watchEffect(() => {
98
+ let highlight = props.highlight || null;
99
+ if (highlight === true) highlight = (str, language) => {
100
+ const { getLanguage, highlight, highlightAuto } = hljs;
101
+ const { value } = getLanguage(language) ? highlight(str, { language }) : highlightAuto(str);
102
+ return value;
103
+ };
104
+ mdInstance.set({ highlight });
105
+ });
106
+ runFnWithOptions(props.sanitize, (options) => mdInstance.use(sanitize, options));
107
+ runFnWithOptions(props.emoji, (options) => mdInstance.use(full, options));
108
+ runFnWithOptions(props.anchor, (options = {}) => {
109
+ const permalink = props.permalink ? { permalink: anchor.permalink.linkInsideHeader({
110
+ placement: "before",
111
+ class: addPrefix("__anchor"),
112
+ space: false,
113
+ renderAttrs: () => ({ [DATA_ANCHOR]: "" })
114
+ }) } : {};
115
+ const anchorOptions = isFunction(options) ? options(anchor) : options;
116
+ mdInstance.use(anchor, _objectSpread2(_objectSpread2({}, permalink), anchorOptions));
117
+ });
118
+ const getPlugins = () => {
119
+ const { plugins } = props;
120
+ return Array.isArray(plugins) ? plugins.map(allToArray) : [[plugins]];
121
+ };
122
+ getPlugins().forEach((plugin) => mdInstance.use(...plugin));
123
+ const refreshKeys = [
124
+ "src",
125
+ "inline",
126
+ "highlight",
127
+ ...optionKeys
128
+ ];
129
+ const htmlStr = ref("");
130
+ watch(() => refreshKeys.map((key) => props[key]), () => {
131
+ const { src, inline } = props;
132
+ const env = {};
133
+ htmlStr.value = mdInstance[inline ? "renderInline" : "render"](String(src), env);
134
+ emit("envChange", env);
135
+ }, { immediate: true });
136
+ expose({
137
+ mdInstance,
138
+ htmlStr
139
+ });
140
+ return () => createVNode("div", { "class": name }, [createVNode("div", {
141
+ "class": [
142
+ addPrefix("__wrapper"),
143
+ props.markdownClass,
144
+ { [addPrefix("--permalink")]: props.permalink }
145
+ ],
146
+ "innerHTML": htmlStr.value
147
+ }, null)]);
148
+ }
176
149
  });
177
- export {
178
- _Render as default,
179
- renderEmits,
180
- renderProps
181
- };
150
+ //#endregion
151
+ export { Render_default as default, renderEmits, renderProps };
@@ -1,16 +1,26 @@
1
- /* light */
1
+ /*light */
2
2
  .markdown-body {
3
3
  color-scheme: light;
4
+ /** CSS default easing. Use for hover state changes and micro-interactions. */
5
+ /** Accelerating motion. Use for elements exiting the viewport (moving off-screen). */
6
+ /** Smooth acceleration and deceleration. Use for elements moving or morphing within the viewport. */
7
+ /** Decelerating motion. Use for elements entering the viewport or appearing on screen. */
8
+ /** Constant motion with no acceleration. Use for continuous animations like progress bars or loaders. */
4
9
  -ms-text-size-adjust: 100%;
5
10
  -webkit-text-size-adjust: 100%;
6
11
  margin: 0;
12
+ font-weight: 400;
7
13
  color: #1f2328;
8
14
  background-color: #ffffff;
9
- font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";
15
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
10
16
  font-size: 16px;
11
17
  line-height: 1.5;
12
18
  word-wrap: break-word;
13
19
  }
20
+ .markdown-body a {
21
+ text-decoration: underline;
22
+ text-underline-offset: .2rem;
23
+ }
14
24
  .markdown-body .octicon {
15
25
  display: inline-block;
16
26
  fill: currentColor;
@@ -42,7 +52,7 @@
42
52
  display: none !important;
43
53
  }
44
54
  .markdown-body a {
45
- background-color: transparent;
55
+ background-color: rgba(0,0,0,0);
46
56
  color: #0969da;
47
57
  text-decoration: none;
48
58
  }
@@ -103,7 +113,7 @@
103
113
  .markdown-body hr {
104
114
  box-sizing: content-box;
105
115
  overflow: hidden;
106
- background: transparent;
116
+ background: rgba(0,0,0,0);
107
117
  border-bottom: 1px solid #d1d9e0b3;
108
118
  height: .25em;
109
119
  padding: 0;
@@ -184,7 +194,7 @@
184
194
  .markdown-body [role=button]:focus,
185
195
  .markdown-body input[type=radio]:focus,
186
196
  .markdown-body input[type=checkbox]:focus {
187
- outline: 2px solid #0969da;
197
+ outline: 2px solid var(--borderColor-accent-emphasis);
188
198
  outline-offset: -2px;
189
199
  box-shadow: none;
190
200
  }
@@ -192,13 +202,13 @@
192
202
  .markdown-body [role=button]:focus:not(:focus-visible),
193
203
  .markdown-body input[type=radio]:focus:not(:focus-visible),
194
204
  .markdown-body input[type=checkbox]:focus:not(:focus-visible) {
195
- outline: solid 1px transparent;
205
+ outline: solid 1px rgba(0,0,0,0);
196
206
  }
197
207
  .markdown-body a:focus-visible,
198
208
  .markdown-body [role=button]:focus-visible,
199
209
  .markdown-body input[type=radio]:focus-visible,
200
210
  .markdown-body input[type=checkbox]:focus-visible {
201
- outline: 2px solid #0969da;
211
+ outline: 2px solid var(--borderColor-accent-emphasis);
202
212
  outline-offset: -2px;
203
213
  box-shadow: none;
204
214
  }
@@ -218,10 +228,10 @@
218
228
  color: #1f2328;
219
229
  vertical-align: middle;
220
230
  background-color: #f6f8fa;
221
- border: solid 1px #d1d9e0b3;
222
- border-bottom-color: #d1d9e0b3;
231
+ border: solid 1px var(--borderColor-muted);
232
+ border-bottom-color: var(--borderColor-muted);
223
233
  border-radius: 6px;
224
- box-shadow: inset 0 -1px 0 #d1d9e0b3;
234
+ box-shadow: inset 0 -1px 0 var(--borderColor-muted);
225
235
  }
226
236
  .markdown-body h1,
227
237
  .markdown-body h2,
@@ -492,7 +502,7 @@
492
502
  background-color: #f6f8fa;
493
503
  }
494
504
  .markdown-body table img {
495
- background-color: transparent;
505
+ background-color: rgba(0,0,0,0);
496
506
  }
497
507
  .markdown-body img[align=right] {
498
508
  padding-left: 20px;
@@ -503,7 +513,7 @@
503
513
  .markdown-body .emoji {
504
514
  max-width: none;
505
515
  vertical-align: text-top;
506
- background-color: transparent;
516
+ background-color: rgba(0,0,0,0);
507
517
  }
508
518
  .markdown-body span.frame {
509
519
  display: block;
@@ -606,7 +616,7 @@
606
616
  margin: 0;
607
617
  word-break: normal;
608
618
  white-space: pre;
609
- background: transparent;
619
+ background: rgba(0,0,0,0);
610
620
  border: 0;
611
621
  }
612
622
  .markdown-body .highlight {
@@ -629,13 +639,12 @@
629
639
  .markdown-body pre code,
630
640
  .markdown-body pre tt {
631
641
  display: inline;
632
- max-width: auto;
633
642
  padding: 0;
634
643
  margin: 0;
635
644
  overflow: visible;
636
645
  line-height: inherit;
637
646
  word-wrap: normal;
638
- background-color: transparent;
647
+ background-color: rgba(0,0,0,0);
639
648
  border: 0;
640
649
  }
641
650
  .markdown-body .csv-data td,
@@ -700,9 +709,6 @@
700
709
  .markdown-body .footnotes .data-footnote-backref g-emoji {
701
710
  font-family: monospace;
702
711
  }
703
- .markdown-body body:has(:modal) {
704
- padding-right: var(--dialog-scrollgutter) !important;
705
- }
706
712
  .markdown-body .pl-c {
707
713
  color: #59636e;
708
714
  }
@@ -741,8 +747,8 @@
741
747
  color: #82071e;
742
748
  }
743
749
  .markdown-body .pl-ii {
744
- color: #f6f8fa;
745
- background-color: #82071e;
750
+ color: var(--fgColor-danger);
751
+ background-color: var(--bgColor-danger-muted);
746
752
  }
747
753
  .markdown-body .pl-c2 {
748
754
  color: #f6f8fa;
@@ -825,6 +831,16 @@
825
831
  width: 1em;
826
832
  height: 1em;
827
833
  }
834
+ .markdown-body a:has(>p,>div,>pre,>blockquote) {
835
+ display: block;
836
+ }
837
+ .markdown-body a:has(>p,>div,>pre,>blockquote):not(:has(.snippet-clipboard-content,>pre)) {
838
+ width: fit-content;
839
+ }
840
+ .markdown-body a:has(>p,>div,>pre,>blockquote):has(.snippet-clipboard-content,>pre):focus-visible {
841
+ outline: 2px solid var(--borderColor-accent-emphasis);
842
+ outline-offset: 2px;
843
+ }
828
844
  .markdown-body .task-list-item {
829
845
  list-style-type: none;
830
846
  }
@@ -856,7 +872,7 @@
856
872
  width: auto;
857
873
  height: 24px;
858
874
  overflow: visible;
859
- clip: auto;
875
+ clip-path: none;
860
876
  }
861
877
  .markdown-body ::-webkit-calendar-picker-indicator {
862
878
  filter: invert(50%);
@@ -0,0 +1,6 @@
1
+ import { withInstall } from "../utils/vue.mjs";
2
+ import Render_default from "./Render.mjs";
3
+ //#region src/render/index.ts
4
+ var VmdRender = withInstall(Render_default);
5
+ //#endregion
6
+ export { VmdRender as default };