@10yun/cv-mobile-ui 0.5.7 → 0.5.9
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/package.json +1 -1
- package/ui-cv/cv-block/cv-block.vue +1 -4
- package/ui-cv/cv-cell/cv-cell.vue +3 -2
- package/ui-cv/cv-editor-parse/components/wxParseAudio.vue +14 -5
- package/ui-cv/cv-editor-parse/components/wxParseImg.vue +26 -36
- package/ui-cv/cv-editor-parse/components/wxParseTable.vue +7 -7
- package/ui-cv/cv-editor-parse/components/wxParseTemplate0.vue +105 -88
- package/ui-cv/cv-editor-parse/components/wxParseTemplate1.vue +96 -88
- package/ui-cv/cv-editor-parse/components/wxParseTemplate10.vue +95 -88
- package/ui-cv/cv-editor-parse/components/wxParseTemplate11.vue +84 -82
- package/ui-cv/cv-editor-parse/components/wxParseTemplate2.vue +95 -88
- package/ui-cv/cv-editor-parse/components/wxParseTemplate3.vue +95 -88
- package/ui-cv/cv-editor-parse/components/wxParseTemplate4.vue +95 -88
- package/ui-cv/cv-editor-parse/components/wxParseTemplate5.vue +95 -88
- package/ui-cv/cv-editor-parse/components/wxParseTemplate6.vue +95 -88
- package/ui-cv/cv-editor-parse/components/wxParseTemplate7.vue +95 -88
- package/ui-cv/cv-editor-parse/components/wxParseTemplate8.vue +95 -88
- package/ui-cv/cv-editor-parse/components/wxParseTemplate9.vue +95 -88
- package/ui-cv/cv-editor-parse/components/wxParseVideo.vue +15 -15
- package/ui-cv/cv-editor-parse/cv-editor-parse.vue +1 -3
- package/ui-cv/cv-editor-parse/libs/html2json.js +15 -18
- package/ui-cv/cv-editor-parse/libs/htmlparser.js +12 -5
- package/ui-cv/cv-editor-parse/libs/wxDiscode.js +1 -1
- package/ui-cv/cv-editor-parse/readme.md +6 -0
- package/ui-cv/cv-editor-parse/u-parse.css +52 -95
- package/ui-cv/cv-icons/cv-icons.vue +2 -11
- package/ui-cv/cv-markdown-show/cv-markdown-show.vue +109 -0
- package/ui-cv/cv-markdown-show/lib/highlight/atom-one-dark.css +1 -0
- package/ui-cv/cv-markdown-show/lib/highlight/atom-one-light.css +1 -0
- package/ui-cv/cv-markdown-show/lib/highlight/github-dark.min.css +10 -0
- package/ui-cv/cv-markdown-show/lib/highlight/uni-highlight.min.js +5254 -0
- package/ui-cv/cv-markdown-show/lib/html-parser.js +352 -0
- package/ui-cv/cv-markdown-show/lib/markdown-it.min.js +2 -0
- package/ui-cv/cv-markdown-show/markdown.css +340 -0
- package/ui-cv/cv-markdown-show/package.json +18 -0
- package/ui-cv/cv-markdown-show/readme.md +45 -0
- package/ui-cv/cv-nav-col/cv-nav-col.vue +2 -1
- package/ui-cv/cv-nav-row/cv-nav-row.vue +3 -2
- package/ui-cv/cv-treaty/cv-treaty.vue +1 -0
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<text
|
|
3
|
-
:style="{ color: color, 'font-size': size + 'px' }"
|
|
4
|
-
class="cv-icons"
|
|
5
|
-
:class="rotate ? 'cv-icons-turn' : ''"
|
|
6
|
-
@click="_onClick"
|
|
7
|
-
>
|
|
2
|
+
<text :style="{ color: color, 'font-size': size + 'px' }" class="cv-icons" :class="rotate ? 'cv-icons-turn' : ''">
|
|
8
3
|
{{ icons[type] }}
|
|
9
4
|
</text>
|
|
10
5
|
</template>
|
|
@@ -74,11 +69,7 @@ export default {
|
|
|
74
69
|
};
|
|
75
70
|
},
|
|
76
71
|
created() {},
|
|
77
|
-
methods: {
|
|
78
|
-
_onClick() {
|
|
79
|
-
this.$emit('click');
|
|
80
|
-
}
|
|
81
|
-
}
|
|
72
|
+
methods: {}
|
|
82
73
|
};
|
|
83
74
|
</script>
|
|
84
75
|
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<!-- uniapp vue3 markdown解析 -->
|
|
2
|
+
<template>
|
|
3
|
+
<view class="ua__markdown">
|
|
4
|
+
<rich-text space="nbsp" :nodes="parseNodes(source)" @itemclick="handleItemClick"></rich-text>
|
|
5
|
+
</view>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script setup>
|
|
9
|
+
import { ref, computed } from 'vue';
|
|
10
|
+
import MarkdownIt from './lib/markdown-it.min.js';
|
|
11
|
+
import hljs from './lib/highlight/uni-highlight.min.js';
|
|
12
|
+
import './lib/highlight/atom-one-dark.css';
|
|
13
|
+
import parseHtml from './lib/html-parser.js';
|
|
14
|
+
const props = defineProps({
|
|
15
|
+
// 解析内容
|
|
16
|
+
source: String,
|
|
17
|
+
showLine: { type: [Boolean, String], default: true }
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
let copyCodeData = [];
|
|
21
|
+
const markdown = MarkdownIt({
|
|
22
|
+
html: true,
|
|
23
|
+
highlight: function (str, lang) {
|
|
24
|
+
let preCode = '';
|
|
25
|
+
try {
|
|
26
|
+
preCode = hljs.highlightAuto(str).value;
|
|
27
|
+
} catch (err) {
|
|
28
|
+
preCode = markdown.utils.escapeHtml(str);
|
|
29
|
+
}
|
|
30
|
+
const lines = preCode.split(/\n/).slice(0, -1);
|
|
31
|
+
// 添加自定义行号
|
|
32
|
+
let html = lines
|
|
33
|
+
.map((item, index) => {
|
|
34
|
+
if (item == '') {
|
|
35
|
+
return '';
|
|
36
|
+
}
|
|
37
|
+
return '<li><span class="line-num" data-line="' + (index + 1) + '"></span>' + item + '</li>';
|
|
38
|
+
})
|
|
39
|
+
.join('');
|
|
40
|
+
if (props.showLine) {
|
|
41
|
+
html = '<ol style="padding: 0px 30px;">' + html + '</ol>';
|
|
42
|
+
} else {
|
|
43
|
+
html = '<ol style="padding: 0px 7px;list-style:none;">' + html + '</ol>';
|
|
44
|
+
}
|
|
45
|
+
copyCodeData.push(str);
|
|
46
|
+
let htmlCode = `<div class="markdown-wrap">`;
|
|
47
|
+
// #ifndef MP-WEIXIN
|
|
48
|
+
htmlCode += `<div style="color: #aaa;text-align: right;font-size: 12px;padding:8px;">`;
|
|
49
|
+
htmlCode += `${lang}<a class="copy-btn" code-data-index="${copyCodeData.length - 1}" style="margin-left: 8px;">复制代码</a>`;
|
|
50
|
+
htmlCode += `</div>`;
|
|
51
|
+
// #endif
|
|
52
|
+
htmlCode += `<pre class="hljs" style="padding:10px 8px 0;margin-bottom:5px;overflow: auto;display: block;border-radius: 5px;"><code>${html}</code></pre>`;
|
|
53
|
+
htmlCode += '</div>';
|
|
54
|
+
return htmlCode;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const parseNodes = (value) => {
|
|
58
|
+
if (!value) return;
|
|
59
|
+
// 解析<br />到\n
|
|
60
|
+
value = value.replace(/<br>|<br\/>|<br \/>/g, '\n');
|
|
61
|
+
value = value.replace(/ /g, ' ');
|
|
62
|
+
let htmlString = '';
|
|
63
|
+
if (value.split('```').length % 2) {
|
|
64
|
+
let mdtext = value;
|
|
65
|
+
if (mdtext[mdtext.length - 1] != '\n') {
|
|
66
|
+
mdtext += '\n';
|
|
67
|
+
}
|
|
68
|
+
htmlString = markdown.render(mdtext);
|
|
69
|
+
} else {
|
|
70
|
+
htmlString = markdown.render(value);
|
|
71
|
+
}
|
|
72
|
+
// 解决小程序表格边框型失效问题
|
|
73
|
+
htmlString = htmlString.replace(/<table/g, `<table class="table"`);
|
|
74
|
+
htmlString = htmlString.replace(/<tr/g, `<tr class="tr"`);
|
|
75
|
+
htmlString = htmlString.replace(/<th>/g, `<th class="th">`);
|
|
76
|
+
htmlString = htmlString.replace(/<td/g, `<td class="td"`);
|
|
77
|
+
htmlString = htmlString.replace(/<hr>|<hr\/>|<hr \/>/g, `<hr class="hr">`);
|
|
78
|
+
|
|
79
|
+
// #ifndef APP-NVUE
|
|
80
|
+
return htmlString;
|
|
81
|
+
// #endif
|
|
82
|
+
|
|
83
|
+
// 将htmlString转成htmlArray,反之使用rich-text解析
|
|
84
|
+
// #ifdef APP-NVUE
|
|
85
|
+
return parseHtml(htmlString);
|
|
86
|
+
// #endif
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// 复制代码
|
|
90
|
+
const handleItemClick = (e) => {
|
|
91
|
+
let { attrs } = e.detail.node;
|
|
92
|
+
let { 'code-data-index': codeDataIndex, class: className } = attrs;
|
|
93
|
+
if (className == 'copy-btn') {
|
|
94
|
+
uni.setClipboardData({
|
|
95
|
+
data: copyCodeData[codeDataIndex],
|
|
96
|
+
showToast: false,
|
|
97
|
+
success() {
|
|
98
|
+
uni.showToast({
|
|
99
|
+
title: '复制成功',
|
|
100
|
+
icon: 'none'
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
</script>
|
|
107
|
+
<style scoped>
|
|
108
|
+
@import url('./markdown.css');
|
|
109
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#abb2bf;background:#282c34}.hljs-comment,.hljs-quote{color:#5c6370;font-style:italic}.hljs-doctag,.hljs-formula,.hljs-keyword{color:#c678dd}.hljs-deletion,.hljs-name,.hljs-section,.hljs-selector-tag,.hljs-subst{color:#e06c75}.hljs-literal{color:#56b6c2}.hljs-addition,.hljs-attribute,.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#98c379}.hljs-attr,.hljs-number,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-pseudo,.hljs-template-variable,.hljs-type,.hljs-variable{color:#d19a66}.hljs-bullet,.hljs-link,.hljs-meta,.hljs-selector-id,.hljs-symbol,.hljs-title{color:#61aeee}.hljs-built_in,.hljs-class .hljs-title,.hljs-title.class_{color:#e6c07b}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}.hljs-link{text-decoration:underline}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#383a42;background:#fafafa}.hljs-comment,.hljs-quote{color:#a0a1a7;font-style:italic}.hljs-doctag,.hljs-formula,.hljs-keyword{color:#a626a4}.hljs-deletion,.hljs-name,.hljs-section,.hljs-selector-tag,.hljs-subst{color:#e45649}.hljs-literal{color:#0184bb}.hljs-addition,.hljs-attribute,.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#50a14f}.hljs-attr,.hljs-number,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-pseudo,.hljs-template-variable,.hljs-type,.hljs-variable{color:#986801}.hljs-bullet,.hljs-link,.hljs-meta,.hljs-selector-id,.hljs-symbol,.hljs-title{color:#4078f2}.hljs-built_in,.hljs-class .hljs-title,.hljs-title.class_{color:#c18401}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}.hljs-link{text-decoration:underline}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!
|
|
2
|
+
Theme: GitHub Dark
|
|
3
|
+
Description: Dark theme as seen on github.com
|
|
4
|
+
Author: github.com
|
|
5
|
+
Maintainer: @Hirse
|
|
6
|
+
Updated: 2021-05-15
|
|
7
|
+
|
|
8
|
+
Outdated base version: https://github.com/primer/github-syntax-dark
|
|
9
|
+
Current colors taken from GitHub's CSS
|
|
10
|
+
*/.hljs{color:#c9d1d9;background:#0d1117}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#ff7b72}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#d2a8ff}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#79c0ff}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#a5d6ff}.hljs-built_in,.hljs-symbol{color:#ffa657}.hljs-code,.hljs-comment,.hljs-formula{color:#8b949e}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#7ee787}.hljs-subst{color:#c9d1d9}.hljs-section{color:#1f6feb;font-weight:700}.hljs-bullet{color:#f2cc60}.hljs-emphasis{color:#c9d1d9;font-style:italic}.hljs-strong{color:#c9d1d9;font-weight:700}.hljs-addition{color:#aff5b4;background-color:#033a16}.hljs-deletion{color:#ffdcd7;background-color:#67060c}
|