oxy-uni-ui 1.2.0 → 1.2.3
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/attributes.json +1 -1
- package/components/common/abstracts/variable.scss +51 -1
- package/components/common/path.ts +9 -0
- package/components/common/util.ts +42 -0
- package/components/composables/useGlobalLoading.ts +42 -0
- package/components/composables/useGlobalMessage.ts +48 -0
- package/components/composables/useGlobalToast.ts +84 -0
- package/components/composables/useVirtualScroll.ts +3 -2
- package/components/oxy-cell/oxy-cell.vue +15 -2
- package/components/oxy-cell/types.ts +4 -0
- package/components/oxy-checkbox/index.scss +1 -1
- package/components/oxy-checkbox/oxy-checkbox.vue +2 -2
- package/components/oxy-col-picker/oxy-col-picker.vue +3 -0
- package/components/oxy-col-picker/types.ts +5 -1
- package/components/oxy-corner/oxy-corner.vue +15 -3
- package/components/oxy-corner/types.ts +15 -1
- package/components/oxy-date-strip/index.scss +10 -0
- package/components/oxy-date-strip/oxy-date-strip.vue +198 -0
- package/components/oxy-date-strip/types.ts +98 -0
- package/components/oxy-date-strip/utils.ts +67 -0
- package/components/oxy-date-strip-item/index.scss +94 -0
- package/components/oxy-date-strip-item/oxy-date-strip-item.vue +102 -0
- package/components/oxy-date-strip-item/types.ts +53 -0
- package/components/oxy-datetime-picker/oxy-datetime-picker.vue +3 -1
- package/components/oxy-datetime-picker/types.ts +5 -1
- package/components/oxy-echarts/index.scss +17 -0
- package/components/oxy-echarts/index.ts +1 -0
- package/components/oxy-echarts/oxy-echarts.vue +32 -0
- package/components/oxy-echarts/types.ts +12 -0
- package/components/oxy-file-list/index.scss +26 -0
- package/components/oxy-file-list/oxy-file-list.vue +208 -34
- package/components/oxy-file-list/types.ts +58 -2
- package/components/oxy-global-loading/oxy-global-loading.vue +53 -0
- package/components/oxy-global-message/oxy-global-message.vue +64 -0
- package/components/oxy-global-toast/oxy-global-toast.vue +53 -0
- package/components/oxy-img-lazy/index.scss +17 -0
- package/components/oxy-img-lazy/oxy-img-lazy.vue +332 -0
- package/components/oxy-img-lazy/types.ts +69 -0
- package/components/oxy-link/index.scss +57 -0
- package/components/oxy-link/oxy-link.vue +130 -0
- package/components/oxy-link/types.ts +81 -0
- package/components/oxy-list/index.scss +7 -1
- package/components/oxy-list/types.ts +1 -1
- package/components/oxy-picker/oxy-picker.vue +3 -0
- package/components/oxy-picker/types.ts +5 -1
- package/components/oxy-radio/index.scss +3 -3
- package/components/oxy-radio/oxy-radio.vue +1 -1
- package/components/oxy-rich-text/icon/emjio.svg +1 -0
- package/components/oxy-rich-text/icon/quote.svg +1 -0
- package/components/oxy-rich-text/icon/text.svg +1 -0
- package/components/oxy-rich-text/icon/title.svg +1 -0
- package/components/oxy-rich-text/index.scss +159 -0
- package/components/oxy-rich-text/mp-html/card/card.vue +122 -0
- package/components/oxy-rich-text/mp-html/card/index.js +7 -0
- package/components/oxy-rich-text/mp-html/editable/config.js +15 -0
- package/components/oxy-rich-text/mp-html/editable/index.js +553 -0
- package/components/oxy-rich-text/mp-html/emoji/index.js +203 -0
- package/components/oxy-rich-text/mp-html/highlight/config.js +5 -0
- package/components/oxy-rich-text/mp-html/highlight/index.js +96 -0
- package/components/oxy-rich-text/mp-html/highlight/prism.css +1 -0
- package/components/oxy-rich-text/mp-html/highlight/prism.min.js +7 -0
- package/components/oxy-rich-text/mp-html/img-cache/index.js +138 -0
- package/components/oxy-rich-text/mp-html/latex/index.js +80 -0
- package/components/oxy-rich-text/mp-html/latex/katex.css +1 -0
- package/components/oxy-rich-text/mp-html/latex/katex.min.js +1 -0
- package/components/oxy-rich-text/mp-html/markdown/index.js +50 -0
- package/components/oxy-rich-text/mp-html/markdown/marked.min.js +71 -0
- package/components/oxy-rich-text/mp-html/mp-html.d.ts +184 -0
- package/components/oxy-rich-text/mp-html/mp-html.vue +675 -0
- package/components/oxy-rich-text/mp-html/node/node.vue +1161 -0
- package/components/oxy-rich-text/mp-html/parser.js +1428 -0
- package/components/oxy-rich-text/mp-html/search/index.js +132 -0
- package/components/oxy-rich-text/mp-html/style/index.js +129 -0
- package/components/oxy-rich-text/mp-html/style/parser.js +175 -0
- package/components/oxy-rich-text/mp-html/template/index.js +67 -0
- package/components/oxy-rich-text/mp-html/txv-video/index.js +46 -0
- package/components/oxy-rich-text/oxy-rich-text.vue +642 -0
- package/components/oxy-rich-text/types.ts +71 -0
- package/components/oxy-select/index.scss +255 -0
- package/components/oxy-select/oxy-select.vue +421 -0
- package/components/oxy-select/types.ts +71 -0
- package/components/oxy-select-picker/oxy-select-picker.vue +3 -0
- package/components/oxy-select-picker/types.ts +5 -1
- package/components/oxy-stream-render/index.scss +6 -0
- package/components/oxy-stream-render/oxy-stream-render.vue +204 -0
- package/components/oxy-stream-render/types.ts +5 -0
- package/components/oxy-tree/index.scss +17 -1
- package/components/oxy-tree/oxy-tree.vue +89 -8
- package/components/oxy-tree/types.ts +11 -1
- package/components/oxy-waterfall/index.scss +18 -0
- package/components/oxy-waterfall/oxy-waterfall.vue +218 -0
- package/components/oxy-waterfall/types.ts +90 -0
- package/components/oxy-waterfall-item/index.scss +8 -0
- package/components/oxy-waterfall-item/oxy-waterfall-item.vue +89 -0
- package/components/oxy-waterfall-item/types.ts +16 -0
- package/global.d.ts +7 -0
- package/index.ts +3 -0
- package/locale/lang/en-US.ts +26 -0
- package/locale/lang/zh-CN.ts +26 -0
- package/oxy-uni-ui.zip +0 -0
- package/package.json +1 -1
- package/tags.json +1 -1
- package/uni-echarts/changelog.md +2 -0
- package/uni-echarts/components/index.js +1 -0
- package/uni-echarts/components/uni-echarts/events.js +95 -0
- package/uni-echarts/components/uni-echarts/types.d.ts +183 -0
- package/uni-echarts/components/uni-echarts/types.js +1 -0
- package/uni-echarts/components/uni-echarts/uni-echarts.vue +530 -0
- package/uni-echarts/components/uni-echarts/uni-echarts.vue.d.ts +19 -0
- package/uni-echarts/global.d.ts +7 -0
- package/uni-echarts/index.d.ts +440 -0
- package/uni-echarts/index.js +2 -0
- package/uni-echarts/package.json +105 -0
- package/uni-echarts/shared-core.d.ts +269 -0
- package/uni-echarts/shared-core.js +900 -0
- package/web-types.json +1 -1
|
@@ -0,0 +1,1161 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view @tap="nodeTap" :id="attrs.id" :class="'_block _'+name+' '+attrs.class" :style="(ctrl.root&&opts[5]!=='simple'?'border:1px solid black;padding:5px;display:block;':'')+attrs.style">
|
|
3
|
+
<block v-for="(n, i) in nodes" v-bind:key="i">
|
|
4
|
+
<!-- 图片 -->
|
|
5
|
+
<!-- 占位图 -->
|
|
6
|
+
<image v-if="n.name==='img'&&!n.t&&((opts[1]&&!ctrl[i])||ctrl[i]<0)" class="_img" :style="n.attrs.style" :src="ctrl[i]<0?opts[2]:opts[1]" mode="widthFix" />
|
|
7
|
+
<!-- 显示图片 -->
|
|
8
|
+
<!-- #ifdef H5 || (APP-PLUS && VUE2) -->
|
|
9
|
+
<img v-if="n.name==='img'" :id="n.attrs.id" :class="'_img '+n.attrs.class" :style="(ctrl['e'+i]&&opts[5]!=='simple'?'border:1px dashed black;padding:3px;':'')+(ctrl[i]===-1?'display:none;':'')+n.attrs.style" :src="n.attrs.src||(ctrl.load?n.attrs['data-src']:'')" :data-i="i" @load="imgLoad" @error="mediaError" @tap.stop="imgTap" @longpress="imgLongTap" />
|
|
10
|
+
<!-- #endif -->
|
|
11
|
+
<!-- #ifndef H5 || (APP-PLUS && VUE2) -->
|
|
12
|
+
<!-- 表格中的图片,使用 rich-text 防止大小不正确 -->
|
|
13
|
+
<rich-text v-if="n.name==='img'&&n.t" :style="'display:'+n.t" :nodes="[{attrs:{style:n.attrs.style||'',src:n.attrs.src},name:'img'}]" :data-i="i" @tap.stop="imgTap" />
|
|
14
|
+
<!-- #endif -->
|
|
15
|
+
<!-- #ifdef APP-HARMONY -->
|
|
16
|
+
<image v-else-if="n.name==='img'" :id="n.attrs.id||('n'+i)" :class="'_img '+n.attrs.class" :style="(ctrl['e'+i]&&opts[5]!=='simple'?'border:1px dashed black;padding:3px;':'')+(ctrl[i]===-1?'display:none;':'')+'width:'+ctrl[i]+'px;'+n.attrs.style" :src="n.attrs.src||(ctrl.load?n.attrs['data-src']:'')" :mode="!n.h?'widthFix':(!n.w?'heightFix':(n.m||'scaleToFill'))" :data-i="i" @load="imgLoad" @error="mediaError" @tap.stop="imgTap" @longpress="imgLongTap" />
|
|
17
|
+
<!-- #endif -->
|
|
18
|
+
<!-- #ifndef H5 || APP-PLUS || MP-KUAISHOU -->
|
|
19
|
+
<image v-else-if="n.name==='img'" :id="n.attrs.id" :class="'_img '+n.attrs.class" :style="(ctrl['e'+i]&&opts[5]!=='simple'?'border:1px dashed black;padding:3px;':'')+(ctrl[i]===-1?'display:none;':'')+'width:'+(ctrl[i]||1)+'px;height:'+(ctrl['h'+i]||1)+'px;'+n.attrs.style" :src="n.attrs.src" :mode="!n.h?'widthFix':(!n.w?'heightFix':(n.m||'scaleToFill'))" :lazy-load="opts[0]" :webp="n.webp" :show-menu-by-longpress="!opts[5]&&opts[3]&&!n.attrs.ignore" :image-menu-prevent="opts[5]||!opts[3]||n.attrs.ignore" :data-i="i" @load="imgLoad" @error="mediaError" @tap.stop="imgTap" @longpress="imgLongTap" />
|
|
20
|
+
<!-- #endif -->
|
|
21
|
+
<!-- #ifdef MP-KUAISHOU -->
|
|
22
|
+
<image v-else-if="n.name==='img'" :id="n.attrs.id" :class="'_img '+n.attrs.class" :style="(ctrl['e'+i]&&opts[5]!=='simple'?'border:1px dashed black;padding:3px;':'')+(ctrl[i]===-1?'display:none;':'')+n.attrs.style" :src="n.attrs.src" :lazy-load="opts[0]" :data-i="i" @load="imgLoad" @error="mediaError" @tap.stop="imgTap"></image>
|
|
23
|
+
<!-- #endif -->
|
|
24
|
+
<!-- #ifdef APP-PLUS && VUE3 -->
|
|
25
|
+
<image v-else-if="n.name==='img'" :id="n.attrs.id" :class="'_img '+n.attrs.class" :style="(ctrl['e'+i]&&opts[5]!=='simple'?'border:1px dashed black;padding:3px;':'')+(ctrl[i]===-1?'display:none;':'')+'width:'+(ctrl[i]||1)+'px;'+n.attrs.style" :src="n.attrs.src||(ctrl.load?n.attrs['data-src']:'')" :mode="!n.h?'widthFix':(!n.w?'heightFix':(n.m||''))" :data-i="i" @load="imgLoad" @error="mediaError" @tap.stop="imgTap" @longpress="imgLongTap" />
|
|
26
|
+
<!-- #endif -->
|
|
27
|
+
<!-- 文本 -->
|
|
28
|
+
<text v-else-if="n.type==='text'&&!ctrl['e'+i]" :data-i="i" :user-select="opts[4]" :decode="!opts[5]" @tap="editStart">{{n.text}}
|
|
29
|
+
<text v-if="!n.text" style="color:gray">{{opts[6]||'请输入'}}</text>
|
|
30
|
+
</text>
|
|
31
|
+
<text v-else-if="n.type==='text'&&ctrl['e'+i]===1" :data-i="i" style="border:1px dashed black;min-width:50px;width:auto;padding:5px;display:block" @tap.stop="editStart">{{n.text}}
|
|
32
|
+
<text v-if="!n.text" style="color:gray">{{opts[6]||'请输入'}}</text>
|
|
33
|
+
</text>
|
|
34
|
+
<textarea v-else-if="n.type==='text'" :style="opts[5]==='simple'?'':'border:1px dashed black;'+'min-width:50px;width:auto;padding:5px'" auto-height maxlength="-1" :focus="ctrl['e'+i]===3" :value="n.text" :data-i="i" @input="editInput" @blur="editEnd" />
|
|
35
|
+
<text v-else-if="n.name==='br'">\n</text>
|
|
36
|
+
<!-- 链接 -->
|
|
37
|
+
<view v-else-if="n.name==='a'" :id="n.attrs.id" :class="(n.attrs.href?'_a ':'')+n.attrs.class" hover-class="_hover" :style="'display:inline;'+n.attrs.style" :data-i="i" @tap.stop="linkTap">
|
|
38
|
+
<node name="span" :childs="n.children" :opts="[opts[0],opts[1],opts[2],opts[3],opts[4],opts[5],opts[6],opts[7]+'.'+i+'.children']" style="display:inherit" />
|
|
39
|
+
</view>
|
|
40
|
+
<!-- 视频 -->
|
|
41
|
+
<!-- #ifdef APP-PLUS -->
|
|
42
|
+
<view v-else-if="n.html" :data-i="i" @tap="mediaTap" :id="n.attrs.id" :class="'_video '+n.attrs.class" :style="n.attrs.style" v-html="n.html" @vplay.stop="play" />
|
|
43
|
+
<!-- #endif -->
|
|
44
|
+
<!-- #ifndef APP-PLUS -->
|
|
45
|
+
<video :show-center-play-btn="!opts[5]" @tap="mediaTap" v-else-if="n.name==='video'" :id="n.attrs.id" :class="n.attrs.class" :style="n.attrs.style" :autoplay="n.attrs.autoplay" :controls="n.attrs.controls" :loop="n.attrs.loop" :muted="n.attrs.muted" :object-fit="n.attrs['object-fit']" :poster="n.attrs.poster" :src="n.src[ctrl[i]||0]" :data-i="i" @play="play" @pause="mediaEvent" @fullscreenchange="mediaEvent" @error="mediaError" />
|
|
46
|
+
<!-- #endif -->
|
|
47
|
+
<!-- #ifdef H5 || APP-PLUS -->
|
|
48
|
+
<iframe v-else-if="n.name==='iframe'" :style="n.attrs.style" :allowfullscreen="n.attrs.allowfullscreen" :frameborder="n.attrs.frameborder" :src="n.attrs.src" />
|
|
49
|
+
<embed v-else-if="n.name==='embed'" :style="n.attrs.style" :src="n.attrs.src" />
|
|
50
|
+
<!-- #endif -->
|
|
51
|
+
<!-- #ifndef MP-TOUTIAO || ((H5 || APP-PLUS) && VUE3) -->
|
|
52
|
+
<!-- 音频 -->
|
|
53
|
+
<audio @tap="mediaTap" v-else-if="n.name==='audio'" :id="n.attrs.id" :class="n.attrs.class" :style="n.attrs.style" :author="n.attrs.author" :controls="n.attrs.controls" :loop="n.attrs.loop" :name="n.attrs.name" :poster="n.attrs.poster" :src="n.src[ctrl[i]||0]" :data-i="i" @play="play" @pause="mediaEvent" @error="mediaError" />
|
|
54
|
+
<!-- #endif -->
|
|
55
|
+
<view v-else-if="(n.name==='table'&&(n.c||opts[5]))||n.name==='li'" :id="n.attrs.id" :class="'_'+n.name+' '+n.attrs.class" :style="n.attrs.style">
|
|
56
|
+
<node v-if="n.name==='li'" :childs="n.children" :opts="[opts[0],opts[1],opts[2],opts[3],opts[4],opts[5],opts[6],opts[7]+'.'+i+'.children']" />
|
|
57
|
+
<view v-else v-for="(tbody, x) in n.children" v-bind:key="x" :class="'_'+tbody.name+' '+tbody.attrs.class" :style="tbody.attrs.style">
|
|
58
|
+
<node v-if="tbody.name==='td'||tbody.name==='th'" :childs="tbody.children" :opts="[opts[0],opts[1],opts[2],opts[3],opts[4],opts[5],opts[6],opts[7]+'.'+i+'.children.'+x+'.children']" />
|
|
59
|
+
<block v-else v-for="(tr, y) in tbody.children" v-bind:key="y">
|
|
60
|
+
<view v-if="tr.name==='td'||tr.name==='th'" :class="'_'+tr.name+' '+tr.attrs.class" :style="tr.attrs.style">
|
|
61
|
+
<node :childs="tr.children" :opts="[opts[0],opts[1],opts[2],opts[3],opts[4],opts[5],opts[6],opts[7]+'.'+i+'.children.'+x+'.children.'+y+'.children']" />
|
|
62
|
+
</view>
|
|
63
|
+
<view v-else :class="'_'+tr.name+' '+tr.attrs.class" :style="tr.attrs.style">
|
|
64
|
+
<view v-for="(td, z) in tr.children" v-bind:key="z" :class="'_'+td.name+' '+td.attrs.class" :style="td.attrs.style">
|
|
65
|
+
<node :childs="td.children" :opts="[opts[0],opts[1],opts[2],opts[3],opts[4],opts[5],opts[6],opts[7]+'.'+i+'.children.'+x+'.children.'+y+'.children.'+z+'.children']" />
|
|
66
|
+
</view>
|
|
67
|
+
</view>
|
|
68
|
+
</block>
|
|
69
|
+
</view>
|
|
70
|
+
</view>
|
|
71
|
+
|
|
72
|
+
<!-- 富文本 -->
|
|
73
|
+
<!-- #ifdef H5 || ((MP-WEIXIN || MP-QQ || APP-PLUS || MP-360) && VUE2) -->
|
|
74
|
+
<rich-text v-else-if="!opts[5]&&!n.c&&(n.l||!handler.isInline(n.name, n.attrs.style))" :id="n.attrs.id" :style="n.f" :user-select="opts[4]" :nodes="[n]" />
|
|
75
|
+
<!-- #endif -->
|
|
76
|
+
<!-- #ifndef H5 || ((MP-WEIXIN || MP-QQ || APP-PLUS || MP-360) && VUE2) -->
|
|
77
|
+
<rich-text v-else-if="!opts[5]&&!n.c" :id="n.attrs.id" :style="'display:inline;'+n.f" :preview="false" :selectable="opts[4]" :user-select="opts[4]" :nodes="[n]" />
|
|
78
|
+
<!-- #endif -->
|
|
79
|
+
<!-- 继续递归 -->
|
|
80
|
+
<view v-else-if="n.c===2" :id="n.attrs.id" :class="'_block _'+n.name+' '+n.attrs.class" :style="n.f+';'+n.attrs.style">
|
|
81
|
+
<node v-for="(n2, j) in n.children" v-bind:key="j" :style="n2.f" :name="n2.name" :attrs="n2.attrs" :childs="n2.children" :opts="[opts[0],opts[1],opts[2],opts[3],opts[4],opts[5],opts[6],opts[7]+'.'+i+'.children.'+j+'.children']" />
|
|
82
|
+
</view>
|
|
83
|
+
<node v-else :style="n.f" :name="n.name" :attrs="n.attrs" :childs="n.children" :opts="[opts[0],opts[1],opts[2],opts[3],opts[4],opts[5],opts[6],opts[7]+'.'+i+'.children']" />
|
|
84
|
+
</block>
|
|
85
|
+
</view>
|
|
86
|
+
</template>
|
|
87
|
+
<script module="handler" lang="wxs">
|
|
88
|
+
// 行内标签列表
|
|
89
|
+
var inlineTags = {
|
|
90
|
+
abbr: true,
|
|
91
|
+
b: true,
|
|
92
|
+
big: true,
|
|
93
|
+
code: true,
|
|
94
|
+
del: true,
|
|
95
|
+
em: true,
|
|
96
|
+
i: true,
|
|
97
|
+
ins: true,
|
|
98
|
+
label: true,
|
|
99
|
+
q: true,
|
|
100
|
+
small: true,
|
|
101
|
+
span: true,
|
|
102
|
+
strong: true,
|
|
103
|
+
sub: true,
|
|
104
|
+
sup: true
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* @description 判断是否为行内标签
|
|
108
|
+
*/
|
|
109
|
+
module.exports = {
|
|
110
|
+
isInline: function (tagName, style) {
|
|
111
|
+
return inlineTags[tagName] || (style || '').indexOf('display:inline') !== -1
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
</script>
|
|
115
|
+
<script>
|
|
116
|
+
import Parser from '../parser'
|
|
117
|
+
function getTop(e) {
|
|
118
|
+
let top
|
|
119
|
+
top = e.currentTarget.offsetTop
|
|
120
|
+
if (top < 30) {
|
|
121
|
+
top += 70
|
|
122
|
+
}
|
|
123
|
+
return top - 30
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
import node from './node'
|
|
127
|
+
export default {
|
|
128
|
+
name: 'node',
|
|
129
|
+
options: {
|
|
130
|
+
// #ifdef MP-WEIXIN
|
|
131
|
+
virtualHost: true,
|
|
132
|
+
// #endif
|
|
133
|
+
// #ifdef MP-TOUTIAO
|
|
134
|
+
addGlobalClass: false
|
|
135
|
+
// #endif
|
|
136
|
+
},
|
|
137
|
+
data () {
|
|
138
|
+
return {
|
|
139
|
+
ctrl: {},
|
|
140
|
+
nodes: [],
|
|
141
|
+
// #ifdef MP-WEIXIN
|
|
142
|
+
isiOS: (uni.canIUse('getDeviceInfo') ? uni.getDeviceInfo() : uni.getSystemInfoSync()).system.includes('iOS')
|
|
143
|
+
// #endif
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
props: {
|
|
147
|
+
name: String,
|
|
148
|
+
attrs: {
|
|
149
|
+
type: Object,
|
|
150
|
+
default () {
|
|
151
|
+
return {}
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
childs: Array,
|
|
155
|
+
opts: Array
|
|
156
|
+
},
|
|
157
|
+
watch: {
|
|
158
|
+
childs: {
|
|
159
|
+
handler (nodes) {
|
|
160
|
+
// 列表缩短会刷新整个列表,因此进行空填充
|
|
161
|
+
if(!nodes) return
|
|
162
|
+
while (this.nodes.length > nodes.length) {
|
|
163
|
+
nodes.push({})
|
|
164
|
+
}
|
|
165
|
+
this.nodes = nodes
|
|
166
|
+
},
|
|
167
|
+
immediate: true
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
components: {
|
|
171
|
+
|
|
172
|
+
// #ifndef ((H5 || APP-PLUS) && VUE3) || APP-HARMONY
|
|
173
|
+
node
|
|
174
|
+
// #endif
|
|
175
|
+
},
|
|
176
|
+
mounted () {
|
|
177
|
+
this.$nextTick(() => {
|
|
178
|
+
for (this.root = this.$parent; this.root.$options.name !== 'mp-html'; this.root = this.root.$parent);
|
|
179
|
+
})
|
|
180
|
+
// #ifdef H5 || APP-PLUS
|
|
181
|
+
if (this.opts[0]) {
|
|
182
|
+
let i
|
|
183
|
+
for (i = this.childs.length; i--;) {
|
|
184
|
+
if (this.childs[i].name === 'img') break
|
|
185
|
+
}
|
|
186
|
+
if (i !== -1) {
|
|
187
|
+
this.observer = uni.createIntersectionObserver(this).relativeToViewport({
|
|
188
|
+
top: 500,
|
|
189
|
+
bottom: 500
|
|
190
|
+
})
|
|
191
|
+
this.observer.observe('._img', res => {
|
|
192
|
+
if (res.intersectionRatio) {
|
|
193
|
+
this.$set(this.ctrl, 'load', 1)
|
|
194
|
+
this.observer.disconnect()
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
// #endif
|
|
200
|
+
},
|
|
201
|
+
beforeDestroy () {
|
|
202
|
+
if (this.root && this.root._edit === this) {
|
|
203
|
+
this.root._edit = undefined
|
|
204
|
+
}
|
|
205
|
+
// #ifdef H5 || APP-PLUS
|
|
206
|
+
if (this.observer) {
|
|
207
|
+
this.observer.disconnect()
|
|
208
|
+
}
|
|
209
|
+
// #endif
|
|
210
|
+
},
|
|
211
|
+
methods:{editStart (e) {
|
|
212
|
+
if (this.opts[5]) {
|
|
213
|
+
const i = e.currentTarget.dataset.i
|
|
214
|
+
if (!this.ctrl['e' + i] && this.opts[5] !== 'simple') {
|
|
215
|
+
// 显示虚线框
|
|
216
|
+
this.$set(this.ctrl, 'e' + i, 1)
|
|
217
|
+
setTimeout(() => {
|
|
218
|
+
this.root._mask.push(() => this.$set(this.ctrl, 'e' + i, 0))
|
|
219
|
+
}, 50)
|
|
220
|
+
this.root._edit = this
|
|
221
|
+
this.i = i
|
|
222
|
+
this.cursor = this.childs[i].text.length
|
|
223
|
+
} else {
|
|
224
|
+
if (this.opts[5] === 'simple') {
|
|
225
|
+
this.root._edit = this
|
|
226
|
+
this.i = i
|
|
227
|
+
this.cursor = this.childs[i].text.length
|
|
228
|
+
}
|
|
229
|
+
this.root._mask.pop()
|
|
230
|
+
this.root._maskTap()
|
|
231
|
+
// 将 text 转为 textarea
|
|
232
|
+
this.$set(this.ctrl, 'e' + i, 2)
|
|
233
|
+
// 延时对焦,避免高度错误
|
|
234
|
+
setTimeout(() => {
|
|
235
|
+
this.$set(this.ctrl, 'e' + i, 3)
|
|
236
|
+
}, 50)
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
},editInput (e) {
|
|
240
|
+
const i = e.target.dataset.i
|
|
241
|
+
// 替换连续空格
|
|
242
|
+
const value = e.detail.value.replace(/ {2,}/, $ => {
|
|
243
|
+
let res = '\xa0'
|
|
244
|
+
for (let i = 1; i < $.length; i++) {
|
|
245
|
+
res += '\xa0'
|
|
246
|
+
}
|
|
247
|
+
return res
|
|
248
|
+
})
|
|
249
|
+
this.root._editVal(`${this.opts[7]}.${i}.text`, this.childs[i].text, value) // 记录编辑历史
|
|
250
|
+
this.cursor = e.detail.cursor
|
|
251
|
+
},editEnd (e) {
|
|
252
|
+
const i = e.target.dataset.i
|
|
253
|
+
this.$set(this.ctrl, 'e' + i, 0)
|
|
254
|
+
// 更新到视图
|
|
255
|
+
this.root._setData(`${this.opts[7]}.${i}.text`, e.detail.value.replace(/ {2}/g, '\xa0 '))
|
|
256
|
+
if (e.detail.cursor !== undefined) {
|
|
257
|
+
this.cursor = e.detail.cursor
|
|
258
|
+
}
|
|
259
|
+
},insert (node) {
|
|
260
|
+
setTimeout(() => {
|
|
261
|
+
const childs = this.childs.slice(0)
|
|
262
|
+
if (!childs[this.i]) {
|
|
263
|
+
childs.push(node)
|
|
264
|
+
} else if (childs[this.i].text) {
|
|
265
|
+
// 在文本中插入
|
|
266
|
+
const text = childs[this.i].text
|
|
267
|
+
if (node.type === 'text') {
|
|
268
|
+
if (this.cursor) {
|
|
269
|
+
childs[this.i].text = text.substring(0, this.cursor) + node.text + text.substring(this.cursor)
|
|
270
|
+
} else {
|
|
271
|
+
childs[this.i].text += node.text
|
|
272
|
+
}
|
|
273
|
+
} else {
|
|
274
|
+
const list = []
|
|
275
|
+
if (this.cursor) {
|
|
276
|
+
list.push({
|
|
277
|
+
type: 'text',
|
|
278
|
+
text: text.substring(0, this.cursor)
|
|
279
|
+
})
|
|
280
|
+
}
|
|
281
|
+
list.push(node)
|
|
282
|
+
if (this.cursor < text.length) {
|
|
283
|
+
list.push({
|
|
284
|
+
type: 'text',
|
|
285
|
+
text: text.substring(this.cursor)
|
|
286
|
+
})
|
|
287
|
+
}
|
|
288
|
+
childs.splice(this.i, 1, ...list)
|
|
289
|
+
}
|
|
290
|
+
} else {
|
|
291
|
+
childs.splice(parseInt(this.i) + 1, 0, node)
|
|
292
|
+
}
|
|
293
|
+
this.root._editVal(this.opts[7], this.childs, childs, true)
|
|
294
|
+
this.i = parseInt(this.i) + 1
|
|
295
|
+
}, 200)
|
|
296
|
+
},remove (i) {
|
|
297
|
+
const arr = this.childs.slice(0)
|
|
298
|
+
const delEle = arr.splice(i, 1)[0]
|
|
299
|
+
if (delEle.name === 'img' || delEle.name === 'video' || delEle.name === 'audio') {
|
|
300
|
+
let src = delEle.attrs.src
|
|
301
|
+
if (delEle.src) {
|
|
302
|
+
src = delEle.src.length === 1 ? delEle.src[0] : delEle.src
|
|
303
|
+
}
|
|
304
|
+
this.root.$emit('remove', {
|
|
305
|
+
type: delEle.name,
|
|
306
|
+
src
|
|
307
|
+
})
|
|
308
|
+
}
|
|
309
|
+
this.root._edit = undefined
|
|
310
|
+
this.root._maskTap()
|
|
311
|
+
this.root._editVal(this.opts[7], this.childs, arr, true)
|
|
312
|
+
},nodeTap (e) {
|
|
313
|
+
if (this.opts[5]) {
|
|
314
|
+
if (this.root._lock) return
|
|
315
|
+
this.root._lock = true
|
|
316
|
+
setTimeout(() => {
|
|
317
|
+
this.root._lock = false
|
|
318
|
+
}, 50)
|
|
319
|
+
if (this.ctrl['e' + this.i] === 3) return
|
|
320
|
+
this.root._maskTap()
|
|
321
|
+
this.root._edit = this
|
|
322
|
+
if (this.opts[5] === 'simple') return
|
|
323
|
+
let start = this.opts[7].lastIndexOf('children.')
|
|
324
|
+
if (start !== -1) {
|
|
325
|
+
start += 9
|
|
326
|
+
} else {
|
|
327
|
+
start = 6
|
|
328
|
+
}
|
|
329
|
+
const i = parseInt(this.opts[7].substring(start, this.opts[7].lastIndexOf('.children')))
|
|
330
|
+
let parent = this.$parent
|
|
331
|
+
while (parent && parent.$options.name !== 'node') {
|
|
332
|
+
parent = parent.$parent
|
|
333
|
+
}
|
|
334
|
+
let remove = () => {
|
|
335
|
+
parent.remove(i)
|
|
336
|
+
}
|
|
337
|
+
if (parent && (this.opts[7].length - parent.opts[7].length > 15)) {
|
|
338
|
+
const parts = this.opts[7].split('.')
|
|
339
|
+
let childs = parent.childs
|
|
340
|
+
const i = parseInt(parts[parent.opts[7].split('.').length])
|
|
341
|
+
const oldParent = parent
|
|
342
|
+
// 删除整个表格
|
|
343
|
+
remove = () => {
|
|
344
|
+
oldParent.remove(i)
|
|
345
|
+
}
|
|
346
|
+
for (let i = parent.opts[7].split('.').length; i < parts.length - 2; i++) {
|
|
347
|
+
childs = childs[parts[i]]
|
|
348
|
+
}
|
|
349
|
+
const that = this
|
|
350
|
+
parent = {
|
|
351
|
+
childs,
|
|
352
|
+
opts: [undefined, undefined, undefined, undefined, undefined, undefined, undefined, parts.slice(0, parts.length - 2).join('.')],
|
|
353
|
+
changeStyle (name, i, value, oldVal) {
|
|
354
|
+
let style = this.childs[i].attrs.style || ''
|
|
355
|
+
if (style.includes(';' + name + ':' + oldVal)) {
|
|
356
|
+
style = style.replace(';' + name + ':' + oldVal, ';' + name + ':' + value)
|
|
357
|
+
} else {
|
|
358
|
+
style += ';' + name + ':' + value
|
|
359
|
+
}
|
|
360
|
+
that.root._setData(`${this.opts[7]}.${i}.attrs.style`, style)
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
if (!parent) return
|
|
365
|
+
// 显示实线框
|
|
366
|
+
this.$set(this.ctrl, 'root', 1)
|
|
367
|
+
this.root._mask.push(() => this.$set(this.ctrl, 'root', 0))
|
|
368
|
+
if (this.childs.length === 1 && this.childs[0].type === 'text' && !this.ctrl.e0) {
|
|
369
|
+
this.$set(this.ctrl, 'e0', 1)
|
|
370
|
+
this.root._mask.push(() => this.$set(this.ctrl, 'e0', 0))
|
|
371
|
+
this.i = 0
|
|
372
|
+
this.cursor = this.childs[0].text.length
|
|
373
|
+
}
|
|
374
|
+
const items = this.root._getItem(parent.childs[i], i !== 0, i !== parent.childs.length - 1)
|
|
375
|
+
this.root._tooltip({
|
|
376
|
+
top: getTop(e),
|
|
377
|
+
items,
|
|
378
|
+
success: tapIndex => {
|
|
379
|
+
if (items[tapIndex] === '大小') {
|
|
380
|
+
// 改变字体大小
|
|
381
|
+
const style = parent.childs[i].attrs.style || ''
|
|
382
|
+
let value = style.match(/;font-size:([0-9]+)px/)
|
|
383
|
+
if (value) {
|
|
384
|
+
value = parseInt(value[1])
|
|
385
|
+
} else {
|
|
386
|
+
value = 16
|
|
387
|
+
}
|
|
388
|
+
this.root._slider({
|
|
389
|
+
min: 10,
|
|
390
|
+
max: 30,
|
|
391
|
+
value,
|
|
392
|
+
top: getTop(e),
|
|
393
|
+
changing: val => {
|
|
394
|
+
if (Math.abs(val - value) > 2) {
|
|
395
|
+
// 字号变换超过 2 时更新到视图
|
|
396
|
+
parent.changeStyle('font-size', i, val + 'px', value + 'px')
|
|
397
|
+
value = e.detail.value
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
change: val => {
|
|
401
|
+
if (val !== value) {
|
|
402
|
+
parent.changeStyle('font-size', i, val + 'px', value + 'px')
|
|
403
|
+
}
|
|
404
|
+
this.root._editVal(`${parent.opts[7]}.${i}.attrs.style`, style, parent.childs[i].attrs.style)
|
|
405
|
+
}
|
|
406
|
+
})
|
|
407
|
+
} else if (items[tapIndex] === '颜色') {
|
|
408
|
+
// 改变文字颜色
|
|
409
|
+
const items = this.root._getItem('color')
|
|
410
|
+
this.root._color({
|
|
411
|
+
top: getTop(e),
|
|
412
|
+
items,
|
|
413
|
+
success: tapIndex => {
|
|
414
|
+
const style = parent.childs[i].attrs.style || ''
|
|
415
|
+
const value = style.match(/;color:([^;]+)/)
|
|
416
|
+
parent.changeStyle('color', i, items[tapIndex], value ? value[1] : undefined)
|
|
417
|
+
this.root._editVal(`${parent.opts[7]}.${i}.attrs.style`, style, parent.childs[i].attrs.style)
|
|
418
|
+
}
|
|
419
|
+
})
|
|
420
|
+
} else if (items[tapIndex] === '上移' || items[tapIndex] === '下移') {
|
|
421
|
+
const arr = parent.childs.slice(0)
|
|
422
|
+
const item = arr[i]
|
|
423
|
+
if (items[tapIndex] === '上移') {
|
|
424
|
+
arr[i] = arr[i - 1]
|
|
425
|
+
arr[i - 1] = item
|
|
426
|
+
} else {
|
|
427
|
+
arr[i] = arr[i + 1]
|
|
428
|
+
arr[i + 1] = item
|
|
429
|
+
}
|
|
430
|
+
this.root._editVal(parent.opts[7], parent.childs, arr, true)
|
|
431
|
+
} else if (items[tapIndex] === '删除') {
|
|
432
|
+
remove()
|
|
433
|
+
} else {
|
|
434
|
+
const style = parent.childs[i].attrs.style || ''
|
|
435
|
+
let newStyle = ''
|
|
436
|
+
const item = items[tapIndex]
|
|
437
|
+
let name
|
|
438
|
+
let value
|
|
439
|
+
if (item === '斜体') {
|
|
440
|
+
name = 'font-style'
|
|
441
|
+
value = 'italic'
|
|
442
|
+
} else if (item === '粗体') {
|
|
443
|
+
name = 'font-weight'
|
|
444
|
+
value = 'bold'
|
|
445
|
+
} else if (item === '下划线') {
|
|
446
|
+
name = 'text-decoration'
|
|
447
|
+
value = 'underline'
|
|
448
|
+
} else if (item === '居中') {
|
|
449
|
+
name = 'text-align'
|
|
450
|
+
value = 'center'
|
|
451
|
+
} else if (item === '缩进') {
|
|
452
|
+
name = 'text-indent'
|
|
453
|
+
value = '2em'
|
|
454
|
+
}
|
|
455
|
+
if (style.includes(name + ':')) {
|
|
456
|
+
// 已有则取消
|
|
457
|
+
newStyle = style.replace(new RegExp(name + ':[^;]+'), '')
|
|
458
|
+
} else {
|
|
459
|
+
// 没有则添加
|
|
460
|
+
newStyle = style + ';' + name + ':' + value
|
|
461
|
+
}
|
|
462
|
+
this.root._editVal(`${parent.opts[7]}.${i}.attrs.style`, style, newStyle, true)
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
})
|
|
466
|
+
}
|
|
467
|
+
},mediaTap (e, index) {
|
|
468
|
+
if (this.opts[5]) {
|
|
469
|
+
const i = e.target.dataset.i || index
|
|
470
|
+
const node = this.childs[i]
|
|
471
|
+
const items = this.root._getItem(node)
|
|
472
|
+
this.root._maskTap()
|
|
473
|
+
this.root._edit = this
|
|
474
|
+
this.i = i
|
|
475
|
+
this.root._tooltip({
|
|
476
|
+
top: e.currentTarget.offsetTop - 30,
|
|
477
|
+
items,
|
|
478
|
+
success: tapIndex => {
|
|
479
|
+
switch (items[tapIndex]) {
|
|
480
|
+
case '封面':
|
|
481
|
+
// 设置封面
|
|
482
|
+
this.root.getSrc('img', node.attrs.poster || '').then(url => {
|
|
483
|
+
this.root._editVal(`${this.opts[7]}.${i}.attrs.poster`, node.attrs.poster, url instanceof Array ? url[0] : url, true)
|
|
484
|
+
}).catch(() => { })
|
|
485
|
+
break
|
|
486
|
+
case '删除':
|
|
487
|
+
this.remove(i)
|
|
488
|
+
break
|
|
489
|
+
case '循环':
|
|
490
|
+
case '不循环':
|
|
491
|
+
// 切换循环播放
|
|
492
|
+
this.root._setData(`${this.opts[7]}.${i}.attrs.loop`, !node.attrs.loop)
|
|
493
|
+
uni.showToast({
|
|
494
|
+
title: '成功'
|
|
495
|
+
})
|
|
496
|
+
break
|
|
497
|
+
case '自动播放':
|
|
498
|
+
case '不自动播放':
|
|
499
|
+
// 切换自动播放播放
|
|
500
|
+
this.root._setData(`${this.opts[7]}.${i}.attrs.autoplay`, !node.attrs.autoplay)
|
|
501
|
+
uni.showToast({
|
|
502
|
+
title: '成功'
|
|
503
|
+
})
|
|
504
|
+
break
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
})
|
|
508
|
+
// 避免上层出现点击态
|
|
509
|
+
this.root._lock = true
|
|
510
|
+
setTimeout(() => {
|
|
511
|
+
this.root._lock = false
|
|
512
|
+
}, 50)
|
|
513
|
+
}
|
|
514
|
+
},changeStyle (name, i, value, oldVal) {
|
|
515
|
+
let style = this.childs[i].attrs.style || ''
|
|
516
|
+
if (style.includes(';' + name + ':' + oldVal)) {
|
|
517
|
+
// style 中已经有
|
|
518
|
+
style = style.replace(';' + name + ':' + oldVal, ';' + name + ':' + value)
|
|
519
|
+
} else {
|
|
520
|
+
// 没有则新增
|
|
521
|
+
style += ';' + name + ':' + value
|
|
522
|
+
}
|
|
523
|
+
this.root._setData(`${this.opts[7]}.${i}.attrs.style`, style)
|
|
524
|
+
},
|
|
525
|
+
// #ifdef MP-WEIXIN
|
|
526
|
+
toJSON () { return this },
|
|
527
|
+
// #endif
|
|
528
|
+
/**
|
|
529
|
+
* @description 播放视频事件
|
|
530
|
+
* @param {Event} e
|
|
531
|
+
*/
|
|
532
|
+
play (e) {
|
|
533
|
+
const i = e.currentTarget.dataset.i
|
|
534
|
+
const node = this.childs[i]
|
|
535
|
+
this.root.$emit('play', {
|
|
536
|
+
source: node.name,
|
|
537
|
+
attrs: {
|
|
538
|
+
...node.attrs,
|
|
539
|
+
src: node.src[this.ctrl[i] || 0]
|
|
540
|
+
}
|
|
541
|
+
})
|
|
542
|
+
// #ifndef APP-PLUS
|
|
543
|
+
if (this.root.pauseVideo) {
|
|
544
|
+
let flag = false
|
|
545
|
+
const id = e.target.id
|
|
546
|
+
for (let i = this.root._videos.length; i--;) {
|
|
547
|
+
if (this.root._videos[i].id === id) {
|
|
548
|
+
flag = true
|
|
549
|
+
} else {
|
|
550
|
+
this.root._videos[i].pause() // 自动暂停其他视频
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
// 将自己加入列表
|
|
554
|
+
if (!flag) {
|
|
555
|
+
const ctx = uni.createVideoContext(id
|
|
556
|
+
// #ifndef MP-BAIDU
|
|
557
|
+
, this
|
|
558
|
+
// #endif
|
|
559
|
+
)
|
|
560
|
+
ctx.id = id
|
|
561
|
+
if (this.root.playbackRate) {
|
|
562
|
+
ctx.playbackRate(this.root.playbackRate)
|
|
563
|
+
}
|
|
564
|
+
this.root._videos.push(ctx)
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
// #endif
|
|
568
|
+
},
|
|
569
|
+
/**
|
|
570
|
+
* @description 音视频其他事件
|
|
571
|
+
* @param {Event} e
|
|
572
|
+
*/
|
|
573
|
+
mediaEvent (e) {
|
|
574
|
+
const i = e.currentTarget.dataset.i
|
|
575
|
+
const node = this.childs[i]
|
|
576
|
+
this.root.$emit(e.type, {
|
|
577
|
+
...e.detail,
|
|
578
|
+
source: node.name,
|
|
579
|
+
attrs: {
|
|
580
|
+
...node.attrs,
|
|
581
|
+
src: node.src[this.ctrl[i] || 0]
|
|
582
|
+
}
|
|
583
|
+
})
|
|
584
|
+
},
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* @description 图片点击事件
|
|
588
|
+
* @param {Event} e
|
|
589
|
+
*/
|
|
590
|
+
imgTap (e) {
|
|
591
|
+
if (!this.opts[5]) {
|
|
592
|
+
const node = this.childs[e.currentTarget.dataset.i]
|
|
593
|
+
if (node.a) {
|
|
594
|
+
this.linkTap(node.a)
|
|
595
|
+
return
|
|
596
|
+
}
|
|
597
|
+
if (node.attrs.ignore) return
|
|
598
|
+
// #ifdef H5 || APP-PLUS
|
|
599
|
+
node.attrs.src = node.attrs.src || node.attrs['data-src']
|
|
600
|
+
// #endif
|
|
601
|
+
// #ifndef APP-HARMONY
|
|
602
|
+
this.root.$emit('imgtap', node.attrs)
|
|
603
|
+
// #endif
|
|
604
|
+
// #ifdef APP-HARMONY
|
|
605
|
+
this.root.$emit('imgtap', {
|
|
606
|
+
...node.attrs
|
|
607
|
+
})
|
|
608
|
+
// #endif
|
|
609
|
+
// 自动预览图片
|
|
610
|
+
if (this.root.previewImg) {
|
|
611
|
+
uni.previewImage({
|
|
612
|
+
// #ifdef MP-WEIXIN
|
|
613
|
+
showmenu: this.root.showImgMenu,
|
|
614
|
+
// #endif
|
|
615
|
+
// #ifdef MP-ALIPAY
|
|
616
|
+
enablesavephoto: this.root.showImgMenu,
|
|
617
|
+
enableShowPhotoDownload: this.root.showImgMenu,
|
|
618
|
+
// #endif
|
|
619
|
+
current: parseInt(node.attrs.i),
|
|
620
|
+
urls: this.root.imgList
|
|
621
|
+
})
|
|
622
|
+
}
|
|
623
|
+
} else {
|
|
624
|
+
const i = e.currentTarget.dataset.i
|
|
625
|
+
const node = this.childs[i]
|
|
626
|
+
const items = this.root._getItem(node)
|
|
627
|
+
const parser = new Parser(this.root)
|
|
628
|
+
this.root._edit = this
|
|
629
|
+
this.i = i
|
|
630
|
+
this.root._maskTap()
|
|
631
|
+
this.$set(this.ctrl, 'e' + i, 1)
|
|
632
|
+
this.root._mask.push(() => this.$set(this.ctrl, 'e' + i, 0))
|
|
633
|
+
this.root._tooltip({
|
|
634
|
+
top: getTop(e),
|
|
635
|
+
items,
|
|
636
|
+
success: tapIndex => {
|
|
637
|
+
if (items[tapIndex] === '换图') {
|
|
638
|
+
// 换图
|
|
639
|
+
this.root.getSrc('img', node.attrs.src || '').then(url => {
|
|
640
|
+
this.root._editVal(this.opts[7] + '.' + i + '.attrs.src', node.attrs.src, parser.getUrl(url instanceof Array ? url[0] : url), true)
|
|
641
|
+
}).catch(() => { })
|
|
642
|
+
} else if (items[tapIndex] === '宽度') {
|
|
643
|
+
// 更改宽度
|
|
644
|
+
const style = node.attrs.style || ''
|
|
645
|
+
let value = style.match(/max-width:([0-9]+)%/)
|
|
646
|
+
if (value) {
|
|
647
|
+
value = parseInt(value[1])
|
|
648
|
+
} else {
|
|
649
|
+
value = 100
|
|
650
|
+
}
|
|
651
|
+
this.root._slider({
|
|
652
|
+
min: 0,
|
|
653
|
+
max: 100,
|
|
654
|
+
value,
|
|
655
|
+
top: getTop(e),
|
|
656
|
+
changing: val => {
|
|
657
|
+
// 变化超过 5% 更新时视图
|
|
658
|
+
if (Math.abs(val - value) > 5) {
|
|
659
|
+
this.changeStyle('max-width', i, val + '%', value + '%')
|
|
660
|
+
value = val
|
|
661
|
+
}
|
|
662
|
+
},
|
|
663
|
+
change: val => {
|
|
664
|
+
if (val !== value) {
|
|
665
|
+
this.changeStyle('max-width', i, val + '%', value + '%')
|
|
666
|
+
value = val
|
|
667
|
+
}
|
|
668
|
+
this.root._editVal(this.opts[7] + '.' + i + '.attrs.style', style, this.childs[i].attrs.style)
|
|
669
|
+
}
|
|
670
|
+
})
|
|
671
|
+
} else if (items[tapIndex] === '超链接') {
|
|
672
|
+
// 将图片设置为链接
|
|
673
|
+
this.root.getSrc('link', node.a ? node.a.href : '').then(url => {
|
|
674
|
+
// 如果有 a 标签则替换 href
|
|
675
|
+
if (node.a) {
|
|
676
|
+
this.root._editVal(this.opts[7] + '.' + i + '.a.href', node.a.href, parser.getUrl(url), true)
|
|
677
|
+
} else {
|
|
678
|
+
const link = {
|
|
679
|
+
name: 'a',
|
|
680
|
+
attrs: {
|
|
681
|
+
href: parser.getUrl(url)
|
|
682
|
+
},
|
|
683
|
+
children: [node]
|
|
684
|
+
}
|
|
685
|
+
node.a = link.attrs
|
|
686
|
+
this.root._editVal(this.opts[7] + '.' + i, node, link, true)
|
|
687
|
+
}
|
|
688
|
+
wx.showToast({
|
|
689
|
+
title: '成功'
|
|
690
|
+
})
|
|
691
|
+
}).catch(() => { })
|
|
692
|
+
} else if (items[tapIndex] === '预览图') {
|
|
693
|
+
// 设置预览图链接
|
|
694
|
+
this.root.getSrc('img', node.attrs['original-src'] || '').then(url => {
|
|
695
|
+
this.root._editVal(this.opts[7] + '.' + i + '.attrs.original-src', node.attrs['original-src'], parser.getUrl(url instanceof Array ? url[0] : url), true)
|
|
696
|
+
uni.showToast({
|
|
697
|
+
title: '成功'
|
|
698
|
+
})
|
|
699
|
+
}).catch(() => { })
|
|
700
|
+
} else if (items[tapIndex] === '删除') {
|
|
701
|
+
this.remove(i)
|
|
702
|
+
} else {
|
|
703
|
+
// 禁用 / 启用预览
|
|
704
|
+
this.root._setData(this.opts[7] + '.' + i + '.attrs.ignore', !node.attrs.ignore)
|
|
705
|
+
uni.showToast({
|
|
706
|
+
title: '成功'
|
|
707
|
+
})
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
})
|
|
711
|
+
this.root._lock = true
|
|
712
|
+
setTimeout(() => {
|
|
713
|
+
this.root._lock = false
|
|
714
|
+
}, 50)
|
|
715
|
+
}
|
|
716
|
+
},
|
|
717
|
+
/**
|
|
718
|
+
* @description 图片长按
|
|
719
|
+
*/
|
|
720
|
+
imgLongTap (e) {
|
|
721
|
+
// #ifdef APP-PLUS
|
|
722
|
+
const attrs = this.childs[e.currentTarget.dataset.i].attrs
|
|
723
|
+
if (this.opts[3] && !attrs.ignore) {
|
|
724
|
+
uni.showActionSheet({
|
|
725
|
+
itemList: ['保存图片'],
|
|
726
|
+
success: () => {
|
|
727
|
+
const save = path => {
|
|
728
|
+
uni.saveImageToPhotosAlbum({
|
|
729
|
+
filePath: path,
|
|
730
|
+
success () {
|
|
731
|
+
uni.showToast({
|
|
732
|
+
title: '保存成功'
|
|
733
|
+
})
|
|
734
|
+
}
|
|
735
|
+
})
|
|
736
|
+
}
|
|
737
|
+
if (this.root.imgList[attrs.i].startsWith('http')) {
|
|
738
|
+
uni.downloadFile({
|
|
739
|
+
url: this.root.imgList[attrs.i],
|
|
740
|
+
success: res => save(res.tempFilePath)
|
|
741
|
+
})
|
|
742
|
+
} else {
|
|
743
|
+
save(this.root.imgList[attrs.i])
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
})
|
|
747
|
+
}
|
|
748
|
+
// #endif
|
|
749
|
+
},
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* @description 图片加载完成事件
|
|
753
|
+
* @param {Event} e
|
|
754
|
+
*/
|
|
755
|
+
imgLoad(e) {
|
|
756
|
+
const i = e.currentTarget.dataset.i
|
|
757
|
+
if (i === undefined || !this.childs || !this.childs[i]) return
|
|
758
|
+
// #ifdef MP-WEIXIN || MP-QQ
|
|
759
|
+
if (this.opts[5])
|
|
760
|
+
this.$nextTick(() => {
|
|
761
|
+
const id = this.childs[i].attrs.id || ('n' + i)
|
|
762
|
+
uni.createSelectorQuery().in(this).select('#' + id).boundingClientRect().exec(res => {
|
|
763
|
+
this.$set(this.ctrl, 'h'+i, res[0]?.height)
|
|
764
|
+
})
|
|
765
|
+
})
|
|
766
|
+
// #endif
|
|
767
|
+
/* #ifndef H5 || (APP-PLUS && VUE2) */
|
|
768
|
+
if (!this.childs[i].w) {
|
|
769
|
+
this.$set(this.ctrl, i, e.detail.width)
|
|
770
|
+
if (this.opts[5]) {
|
|
771
|
+
const path = this.opts[7] + '.' + i + '.attrs.'
|
|
772
|
+
if (e.detail.width < 150)
|
|
773
|
+
this.root._setData(path + 'ignore', 'T')
|
|
774
|
+
this.root._setData(path + 'width', e.detail.width.toString())
|
|
775
|
+
}
|
|
776
|
+
} else /* #endif */ if ((this.opts[1] && !this.ctrl[i]) || this.ctrl[i] === -1) {
|
|
777
|
+
// 加载完毕,取消加载中占位图
|
|
778
|
+
this.$set(this.ctrl, i, 1)
|
|
779
|
+
}
|
|
780
|
+
this.checkReady()
|
|
781
|
+
},
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* @description 检查是否所有图片加载完毕
|
|
785
|
+
*/
|
|
786
|
+
checkReady () {
|
|
787
|
+
if (this.root && !this.root.lazyLoad) {
|
|
788
|
+
this.root._unloadimgs -= 1
|
|
789
|
+
if (!this.root._unloadimgs) {
|
|
790
|
+
setTimeout(() => {
|
|
791
|
+
this.root.getRect().then(rect => {
|
|
792
|
+
this.root.$emit('ready', rect)
|
|
793
|
+
}).catch(() => {
|
|
794
|
+
this.root.$emit('ready', {})
|
|
795
|
+
})
|
|
796
|
+
}, 350)
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
},
|
|
800
|
+
|
|
801
|
+
/**
|
|
802
|
+
* @description 链接点击事件
|
|
803
|
+
* @param {Event} e
|
|
804
|
+
*/
|
|
805
|
+
linkTap (e) {
|
|
806
|
+
if (!this.opts[5]) {
|
|
807
|
+
const node = e.currentTarget ? this.childs[e.currentTarget.dataset.i] : {}
|
|
808
|
+
const attrs = node.attrs || e
|
|
809
|
+
const href = attrs.href
|
|
810
|
+
this.root.$emit('linktap', Object.assign({
|
|
811
|
+
innerText: this.root.getText(node.children || []) // 链接内的文本内容
|
|
812
|
+
}, attrs))
|
|
813
|
+
if (href) {
|
|
814
|
+
if (href[0] === '#') {
|
|
815
|
+
// 跳转锚点
|
|
816
|
+
this.root.navigateTo(href.substring(1)).catch(() => { })
|
|
817
|
+
} else if (href.split('?')[0].includes('://')) {
|
|
818
|
+
// 复制外部链接
|
|
819
|
+
if (this.root.copyLink) {
|
|
820
|
+
// #ifdef H5
|
|
821
|
+
window.open(href)
|
|
822
|
+
// #endif
|
|
823
|
+
// #ifdef MP
|
|
824
|
+
uni.setClipboardData({
|
|
825
|
+
data: href,
|
|
826
|
+
success: () =>
|
|
827
|
+
uni.showToast({
|
|
828
|
+
title: '链接已复制'
|
|
829
|
+
})
|
|
830
|
+
})
|
|
831
|
+
// #endif
|
|
832
|
+
// #ifdef APP-PLUS
|
|
833
|
+
plus.runtime.openWeb(href)
|
|
834
|
+
// #endif
|
|
835
|
+
}
|
|
836
|
+
} else {
|
|
837
|
+
// 跳转页面
|
|
838
|
+
uni.navigateTo({
|
|
839
|
+
url: href,
|
|
840
|
+
fail () {
|
|
841
|
+
uni.switchTab({
|
|
842
|
+
url: href,
|
|
843
|
+
fail () { }
|
|
844
|
+
})
|
|
845
|
+
}
|
|
846
|
+
})
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
} else {
|
|
850
|
+
const i = e.currentTarget.dataset.i
|
|
851
|
+
const node = this.childs[i]
|
|
852
|
+
const items = this.root._getItem(node)
|
|
853
|
+
this.root._tooltip({
|
|
854
|
+
top: getTop(e),
|
|
855
|
+
items,
|
|
856
|
+
success: tapIndex => {
|
|
857
|
+
if (items[tapIndex] === '更换链接') {
|
|
858
|
+
this.root.getSrc('link', node.attrs.href).then(url => {
|
|
859
|
+
this.root._editVal(this.opts[7] + '.' + i + '.attrs.href', node.attrs.href, url, true)
|
|
860
|
+
uni.showToast({
|
|
861
|
+
title: '成功'
|
|
862
|
+
})
|
|
863
|
+
}).catch(() => { })
|
|
864
|
+
} else {
|
|
865
|
+
this.remove(i)
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
})
|
|
869
|
+
}
|
|
870
|
+
},
|
|
871
|
+
/**
|
|
872
|
+
* @description 错误事件
|
|
873
|
+
* @param {Event} e
|
|
874
|
+
*/
|
|
875
|
+
mediaError (e) {
|
|
876
|
+
const i = e.currentTarget.dataset.i
|
|
877
|
+
const node = this.childs[i]
|
|
878
|
+
// 加载其他源
|
|
879
|
+
if (node.name === 'video' || node.name === 'audio') {
|
|
880
|
+
let index = (this.ctrl[i] || 0) + 1
|
|
881
|
+
if (index > node.src.length) {
|
|
882
|
+
index = 0
|
|
883
|
+
}
|
|
884
|
+
if (index < node.src.length) {
|
|
885
|
+
this.$set(this.ctrl, i, index)
|
|
886
|
+
return
|
|
887
|
+
}
|
|
888
|
+
} else if (node.name === 'img') {
|
|
889
|
+
// #ifdef H5 && VUE3
|
|
890
|
+
if (this.opts[0] && !this.ctrl.load) return
|
|
891
|
+
// #endif
|
|
892
|
+
// 显示错误占位图
|
|
893
|
+
if (this.opts[2]) {
|
|
894
|
+
this.$set(this.ctrl, i, -1)
|
|
895
|
+
}
|
|
896
|
+
this.checkReady()
|
|
897
|
+
}
|
|
898
|
+
if (this.root) {
|
|
899
|
+
this.root.$emit('error', {
|
|
900
|
+
source: node.name,
|
|
901
|
+
attrs: node.attrs,
|
|
902
|
+
// #ifndef H5 && VUE3
|
|
903
|
+
errMsg: e.detail.errMsg
|
|
904
|
+
// #endif
|
|
905
|
+
})
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
</script>
|
|
911
|
+
<style>/deep/ .md-p {
|
|
912
|
+
margin-block-start: 1em;
|
|
913
|
+
margin-block-end: 1em;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
/deep/ .md-table,
|
|
917
|
+
/deep/ .md-blockquote {
|
|
918
|
+
margin-bottom: 16px;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
/deep/ .md-table {
|
|
922
|
+
box-sizing: border-box;
|
|
923
|
+
width: 100%;
|
|
924
|
+
overflow: auto;
|
|
925
|
+
border-spacing: 0;
|
|
926
|
+
border-collapse: collapse;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
/deep/ .md-tr {
|
|
930
|
+
background-color: #fff;
|
|
931
|
+
border-top: 1px solid #c6cbd1;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
.md-table .md-tr:nth-child(2n) {
|
|
935
|
+
background-color: #f6f8fa;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
/deep/ .md-th,
|
|
939
|
+
/deep/ .md-td {
|
|
940
|
+
padding: 6px 13px !important;
|
|
941
|
+
border: 1px solid #dfe2e5;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
/deep/ .md-th {
|
|
945
|
+
font-weight: 600;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
/deep/ .md-blockquote {
|
|
949
|
+
padding: 0 1em;
|
|
950
|
+
color: #6a737d;
|
|
951
|
+
border-left: 0.25em solid #dfe2e5;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
/deep/ .md-code {
|
|
955
|
+
padding: 0.2em 0.4em;
|
|
956
|
+
font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
|
|
957
|
+
font-size: 85%;
|
|
958
|
+
background-color: rgba(27, 31, 35, 0.05);
|
|
959
|
+
border-radius: 3px;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
/deep/ .md-pre .md-code {
|
|
963
|
+
padding: 0;
|
|
964
|
+
font-size: 100%;
|
|
965
|
+
background: transparent;
|
|
966
|
+
border: 0;
|
|
967
|
+
}/* #ifndef H5 || MP-ALIPAY || APP-PLUS */
|
|
968
|
+
/deep/ ._address,
|
|
969
|
+
/deep/ ._article,
|
|
970
|
+
/deep/ ._aside,
|
|
971
|
+
/deep/ ._body,
|
|
972
|
+
/deep/ ._caption,
|
|
973
|
+
/deep/ ._center,
|
|
974
|
+
/deep/ ._cite,
|
|
975
|
+
/deep/ ._footer,
|
|
976
|
+
/deep/ ._header,
|
|
977
|
+
/deep/ ._html,
|
|
978
|
+
/deep/ ._nav,
|
|
979
|
+
/deep/ ._pre,
|
|
980
|
+
/deep/ ._section {
|
|
981
|
+
display: block;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
/* #endif */
|
|
985
|
+
/deep/ ._video {
|
|
986
|
+
width: 300px;
|
|
987
|
+
height: 225px;
|
|
988
|
+
display: inline-block;
|
|
989
|
+
background-color: black;
|
|
990
|
+
}
|
|
991
|
+
/* a 标签默认效果 */
|
|
992
|
+
._a {
|
|
993
|
+
padding: 1.5px 0 1.5px 0;
|
|
994
|
+
color: #366092;
|
|
995
|
+
word-break: break-all;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
/* a 标签点击态效果 */
|
|
999
|
+
._hover {
|
|
1000
|
+
text-decoration: underline;
|
|
1001
|
+
opacity: 0.7;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
/* 图片默认效果 */
|
|
1005
|
+
._img {
|
|
1006
|
+
max-width: 100%;
|
|
1007
|
+
-webkit-touch-callout: none;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
/* 内部样式 */
|
|
1011
|
+
|
|
1012
|
+
._block {
|
|
1013
|
+
display: block;
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
._b,
|
|
1017
|
+
._strong {
|
|
1018
|
+
font-weight: bold;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
._code {
|
|
1022
|
+
font-family: monospace;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
._del {
|
|
1026
|
+
text-decoration: line-through;
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
._em,
|
|
1030
|
+
._i {
|
|
1031
|
+
font-style: italic;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
._h1 {
|
|
1035
|
+
font-size: 2em;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
._h2 {
|
|
1039
|
+
font-size: 1.5em;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
._h3 {
|
|
1043
|
+
font-size: 1.17em;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
._h5 {
|
|
1047
|
+
font-size: 0.83em;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
._h6 {
|
|
1051
|
+
font-size: 0.67em;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
._h1,
|
|
1055
|
+
._h2,
|
|
1056
|
+
._h3,
|
|
1057
|
+
._h4,
|
|
1058
|
+
._h5,
|
|
1059
|
+
._h6 {
|
|
1060
|
+
display: block;
|
|
1061
|
+
font-weight: bold;
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
._image {
|
|
1065
|
+
height: 1px;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
._ins {
|
|
1069
|
+
text-decoration: underline;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
._li {
|
|
1073
|
+
display: list-item;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
._ol {
|
|
1077
|
+
list-style-type: decimal;
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
._ol,
|
|
1081
|
+
._ul {
|
|
1082
|
+
display: block;
|
|
1083
|
+
padding-left: 40px;
|
|
1084
|
+
margin: 1em 0;
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
._q::before {
|
|
1088
|
+
content: '"';
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
._q::after {
|
|
1092
|
+
content: '"';
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
._sub {
|
|
1096
|
+
font-size: smaller;
|
|
1097
|
+
vertical-align: sub;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
._sup {
|
|
1101
|
+
font-size: smaller;
|
|
1102
|
+
vertical-align: super;
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
._thead,
|
|
1106
|
+
._tbody,
|
|
1107
|
+
._tfoot {
|
|
1108
|
+
display: table-row-group;
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
._tr {
|
|
1112
|
+
display: table-row;
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
._td,
|
|
1116
|
+
._th {
|
|
1117
|
+
display: table-cell;
|
|
1118
|
+
vertical-align: middle;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
._th {
|
|
1122
|
+
font-weight: bold;
|
|
1123
|
+
text-align: center;
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
._ul {
|
|
1127
|
+
list-style-type: disc;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
._ul ._ul {
|
|
1131
|
+
margin: 0;
|
|
1132
|
+
list-style-type: circle;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
._ul ._ul ._ul {
|
|
1136
|
+
list-style-type: square;
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
._abbr,
|
|
1140
|
+
._b,
|
|
1141
|
+
._code,
|
|
1142
|
+
._del,
|
|
1143
|
+
._em,
|
|
1144
|
+
._i,
|
|
1145
|
+
._ins,
|
|
1146
|
+
._label,
|
|
1147
|
+
._q,
|
|
1148
|
+
._span,
|
|
1149
|
+
._strong,
|
|
1150
|
+
._sub,
|
|
1151
|
+
._sup {
|
|
1152
|
+
display: inline;
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
/* #ifdef APP-PLUS */
|
|
1156
|
+
._video {
|
|
1157
|
+
width: 300px;
|
|
1158
|
+
height: 225px;
|
|
1159
|
+
}
|
|
1160
|
+
/* #endif */
|
|
1161
|
+
</style>
|