@cloudbase/weda-ui-mp 3.15.3 → 3.15.7

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.
@@ -0,0 +1,105 @@
1
+
2
+ const htmlTags = [
3
+ 'address',
4
+ 'article',
5
+ 'aside',
6
+ 'base',
7
+ 'basefont',
8
+ 'blockquote',
9
+ 'body',
10
+ 'caption',
11
+ 'center',
12
+ 'col',
13
+ 'colgroup',
14
+ 'dd',
15
+ 'details',
16
+ 'dialog',
17
+ 'dir',
18
+ 'div',
19
+ 'dl',
20
+ 'dt',
21
+ 'fieldset',
22
+ 'figcaption',
23
+ 'figure',
24
+ 'footer',
25
+ 'form',
26
+ 'frame',
27
+ 'frameset',
28
+ 'h1',
29
+ 'h2',
30
+ 'h3',
31
+ 'h4',
32
+ 'h5',
33
+ 'h6',
34
+ 'head',
35
+ 'header',
36
+ 'hr',
37
+ 'html',
38
+ 'iframe',
39
+ 'legend',
40
+ 'li',
41
+ 'link',
42
+ 'main',
43
+ 'menu',
44
+ 'menuitem',
45
+ 'nav',
46
+ 'noframes',
47
+ 'ol',
48
+ 'optgroup',
49
+ 'option',
50
+ 'p',
51
+ 'param',
52
+ 'search',
53
+ 'section',
54
+ 'summary',
55
+ 'table',
56
+ 'tbody',
57
+ 'td',
58
+ 'tfoot',
59
+ 'th',
60
+ 'thead',
61
+ 'title',
62
+ 'tr',
63
+ 'track',
64
+ 'ul',
65
+ ];
66
+ export function addCustomClassPlugin(md) {
67
+ const addCustomClass = (state) => {
68
+ state?.tokens?.forEach((token) => {
69
+ if (htmlTags.includes(token.tag)) {
70
+ // 添加自定义类
71
+ token.attrJoin('class', token.tag);
72
+ }
73
+ });
74
+ };
75
+ md.core.ruler.push('addCustomClass', addCustomClass);
76
+ }
77
+
78
+
79
+ function renderCode(origRule, options) {
80
+ options ={...options}
81
+ return (...args) => {
82
+ const [tokens, idx] = args;
83
+ const content = tokens[idx].content
84
+ .replaceAll('"', '"')
85
+ .replaceAll("'", "'");
86
+ const origRendered = origRule(...args);
87
+
88
+ if (content.length === 0)
89
+ return origRendered;
90
+
91
+ return `
92
+ <div style="position: relative" >
93
+ ${origRendered}
94
+ <a class="__preCodeCopyWrap" href="${content}"></a>
95
+ </div>
96
+ `;
97
+ };
98
+ }
99
+
100
+ export const copy = (md, options) => {
101
+ md.renderer.rules.code_block = renderCode(md.renderer.rules.code_block, options);
102
+ md.renderer.rules.fence = renderCode(md.renderer.rules.fence, options);
103
+ };
104
+
105
+
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "miniprogram": "./",
4
4
  "packageManager": "yarn@3.0.2",
5
5
  "dependencies": {},
6
- "version": "3.15.3",
6
+ "version": "3.15.7",
7
7
  "main": "./",
8
8
  "publishConfig": {
9
9
  "access": "public"