@tencentcloud/ai-desk-customer-vue 0.1.3 → 0.1.5
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/components/CustomerServiceChat/index-web.vue +6 -14
- package/components/CustomerServiceChat/message-input/message-input-quote/index.vue +3 -14
- package/components/CustomerServiceChat/message-input-toolbar/emoji-dialog-mobile/emoji-dialog-mobile.vue +2 -5
- package/components/CustomerServiceChat/message-input-toolbar/emoji-picker/emoji-picker-dialog.vue +8 -15
- package/components/CustomerServiceChat/message-input-toolbar/file-upload/index.vue +3 -7
- package/components/CustomerServiceChat/message-input-toolbar/image-upload/index.vue +6 -44
- package/components/CustomerServiceChat/message-input-toolbar/index-web.vue +1 -14
- package/components/CustomerServiceChat/message-input-toolbar/style/uni.scss +0 -56
- package/components/CustomerServiceChat/message-input-toolbar/toolbar-item-container/index.vue +4 -7
- package/components/CustomerServiceChat/message-input-toolbar/toolbar-item-container/style/index.scss +0 -1
- package/components/CustomerServiceChat/message-input-toolbar/video-upload/index.vue +7 -50
- package/components/CustomerServiceChat/message-list/index-web.vue +3 -7
- package/components/CustomerServiceChat/message-list/message-elements/{plugins/plugin-components → message-desk}/index.ts +1 -1
- package/components/{customer-icon.vue → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/customer-icon.vue} +0 -9
- package/components/CustomerServiceChat/message-list/message-elements/{plugins/plugin-components/message-customer → message-desk/message-desk-elements}/index.ts +1 -1
- package/components/{message-branch.vue → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-branch.vue} +4 -4
- package/components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-desk.vue +126 -0
- package/components/{message-multi-branch → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-branch}/branch-pc.vue +1 -1
- package/components/{message-multi-branch → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-branch}/index.vue +2 -3
- package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/component-mobile/form-popup.vue +2 -3
- package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/component-mobile/input-mobile.vue +1 -1
- package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/component-mobile/radios-mobile.vue +7 -7
- package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/component-pc/input-pc.vue +1 -1
- package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/component-pc/radio-pc.vue +4 -5
- package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/form-mobile.vue +8 -7
- package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/form-pc.vue +5 -5
- package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/index.vue +3 -3
- package/components/{message-product-card.vue → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-product-card.vue} +2 -2
- package/components/{message-rating → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-rating}/index.vue +4 -4
- package/components/{message-rating → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-rating}/message-rating-number.vue +3 -3
- package/components/{message-rating → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-rating}/message-rating-star.vue +5 -5
- package/components/{message-rich-text.vue → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-rich-text.vue} +5 -17
- package/components/{message-robot-welcome.vue → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-robot-welcome.vue} +7 -7
- package/components/{message-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-single-form}/form-input.vue +5 -5
- package/components/{message-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-single-form}/index.vue +1 -1
- package/components/{message-stream.vue → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-stream.vue} +2 -2
- package/{styles → components/CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/styles}/common.scss +1 -1
- package/components/CustomerServiceChat/message-list/message-elements/{plugins/plugin-components → message-desk}/message-plugin-layout-web.vue +2 -9
- package/components/CustomerServiceChat/message-list/message-elements/{plugins/plugin-components → message-desk}/message-plugin-web.vue +5 -5
- package/components/CustomerServiceChat/message-list/message-elements/message-quote/index-web.vue +2 -4
- package/components/CustomerServiceChat/message-list/message-elements/message-record/index.vue +3 -6
- package/components/CustomerServiceChat/message-list/message-elements/simple-message-list/index.vue +3 -29
- package/components/CustomerServiceChat/style/index.scss +0 -2
- package/components/common/Avatar/index.vue +2 -23
- package/components/common/BottomPopup/index.vue +2 -3
- package/components/common/Dialog/index.vue +2 -2
- package/components/common/ImagePreviewer/index-web.vue +2 -84
- package/components/common/ProgressMessage/index.vue +0 -8
- package/excluded-list.txt +3 -4
- package/index.ts +4 -13
- package/index.vue +1 -60
- package/package.json +9 -19
- package/server.ts +2 -12
- package/utils/chatStorage.ts +2 -11
- package/utils/index.ts +2 -1
- package/assets/audio-before-delete.svg +0 -4
- package/assets/audio-blue.png +0 -0
- package/assets/audio-bubble-blue.svg +0 -3
- package/assets/audio-bubble-red.svg +0 -3
- package/assets/audio-delete.svg +0 -10
- package/assets/audio.svg +0 -6
- package/assets/camera-uni.png +0 -0
- package/assets/face-uni.png +0 -0
- package/assets/more-uni.png +0 -0
- package/assets/translate.svg +0 -12
- package/assets/video-uni.png +0 -0
- package/components/CustomerServiceChat/message-input-toolbar/toolbar-item-container/style/uni.scss +0 -36
- package/components/CustomerServiceChat/message-list/link/index.ts +0 -23
- package/components/CustomerServiceChat/message-list/message-elements/plugins/plugin-components/message-customer/message-customer-service.vue +0 -22
- package/components/CustomerServiceChat/style/uni.scss +0 -12
- package/components/CustomerServiceChat/style/wx.scss +0 -5
- package/components/common/RichText/LICENSE +0 -21
- package/components/common/RichText/README.md +0 -244
- package/components/common/RichText/dist/mp-alipay/index.acss +0 -1
- package/components/common/RichText/dist/mp-alipay/index.axml +0 -1
- package/components/common/RichText/dist/mp-alipay/index.js +0 -8
- package/components/common/RichText/dist/mp-alipay/index.json +0 -1
- package/components/common/RichText/dist/mp-alipay/node/node.acss +0 -1
- package/components/common/RichText/dist/mp-alipay/node/node.axml +0 -1
- package/components/common/RichText/dist/mp-alipay/node/node.js +0 -1
- package/components/common/RichText/dist/mp-alipay/node/node.json +0 -1
- package/components/common/RichText/dist/mp-alipay/parser.js +0 -1
- package/components/common/RichText/dist/mp-baidu/index.css +0 -1
- package/components/common/RichText/dist/mp-baidu/index.js +0 -8
- package/components/common/RichText/dist/mp-baidu/index.json +0 -1
- package/components/common/RichText/dist/mp-baidu/index.swan +0 -1
- package/components/common/RichText/dist/mp-baidu/node/node.css +0 -1
- package/components/common/RichText/dist/mp-baidu/node/node.js +0 -1
- package/components/common/RichText/dist/mp-baidu/node/node.json +0 -1
- package/components/common/RichText/dist/mp-baidu/node/node.swan +0 -1
- package/components/common/RichText/dist/mp-baidu/parser.js +0 -1
- package/components/common/RichText/dist/mp-qq/index.js +0 -8
- package/components/common/RichText/dist/mp-qq/index.json +0 -1
- package/components/common/RichText/dist/mp-qq/index.qml +0 -1
- package/components/common/RichText/dist/mp-qq/index.qss +0 -1
- package/components/common/RichText/dist/mp-qq/node/node.js +0 -1
- package/components/common/RichText/dist/mp-qq/node/node.json +0 -1
- package/components/common/RichText/dist/mp-qq/node/node.qml +0 -1
- package/components/common/RichText/dist/mp-qq/node/node.qss +0 -1
- package/components/common/RichText/dist/mp-qq/parser.js +0 -1
- package/components/common/RichText/dist/mp-toutiao/index.js +0 -8
- package/components/common/RichText/dist/mp-toutiao/index.json +0 -1
- package/components/common/RichText/dist/mp-toutiao/index.ttml +0 -1
- package/components/common/RichText/dist/mp-toutiao/index.ttss +0 -1
- package/components/common/RichText/dist/mp-toutiao/node/node.js +0 -1
- package/components/common/RichText/dist/mp-toutiao/node/node.json +0 -1
- package/components/common/RichText/dist/mp-toutiao/node/node.ttml +0 -1
- package/components/common/RichText/dist/mp-toutiao/node/node.ttss +0 -1
- package/components/common/RichText/dist/mp-toutiao/parser.js +0 -1
- package/components/common/RichText/dist/mp-weixin/index.js +0 -8
- package/components/common/RichText/dist/mp-weixin/index.json +0 -1
- package/components/common/RichText/dist/mp-weixin/index.wxml +0 -1
- package/components/common/RichText/dist/mp-weixin/index.wxss +0 -1
- package/components/common/RichText/dist/mp-weixin/node/node.js +0 -1
- package/components/common/RichText/dist/mp-weixin/node/node.json +0 -1
- package/components/common/RichText/dist/mp-weixin/node/node.wxml +0 -1
- package/components/common/RichText/dist/mp-weixin/node/node.wxss +0 -1
- package/components/common/RichText/dist/mp-weixin/parser.js +0 -1
- package/components/common/RichText/dist/uni-app/components/mp-html/mp-html.vue +0 -498
- package/components/common/RichText/dist/uni-app/components/mp-html/node/node.vue +0 -587
- package/components/common/RichText/dist/uni-app/components/mp-html/parser.js +0 -1393
- package/components/common/RichText/dist/uni-app/static/app-plus/mp-html/js/handler.js +0 -1
- package/components/common/RichText/dist/uni-app/static/app-plus/mp-html/js/uni.webview.min.js +0 -1
- package/components/common/RichText/dist/uni-app/static/app-plus/mp-html/local.html +0 -1
- package/components/common/RichText/docs/.nojekyll +0 -0
- package/components/common/RichText/docs/index.html +0 -50
- package/components/common/RichText/docs/lib/docsify.min.js +0 -1
- package/components/common/RichText/docs/lib/prism-bash.min.js +0 -1
- package/components/common/RichText/docs/lib/search.min.js +0 -1
- package/components/common/RichText/docs/lib/vue.css +0 -858
- package/components/common/RichText/gulpfile.js +0 -113
- package/components/common/RichText/lint.js +0 -63
- package/components/common/RichText/package.json +0 -74
- package/components/common/RichText/plugins/README.md +0 -2
- package/components/common/RichText/plugins/audio/README.md +0 -25
- package/components/common/RichText/plugins/audio/build.js +0 -11
- package/components/common/RichText/plugins/audio/context.js +0 -7
- package/components/common/RichText/plugins/audio/index.js +0 -34
- package/components/common/RichText/plugins/audio/miniprogram/audio.js +0 -189
- package/components/common/RichText/plugins/audio/miniprogram/audio.json +0 -3
- package/components/common/RichText/plugins/audio/miniprogram/audio.wxml +0 -17
- package/components/common/RichText/plugins/audio/miniprogram/audio.wxss +0 -127
- package/components/common/RichText/plugins/audio/miniprogram/build.js +0 -3
- package/components/common/RichText/plugins/audio/uni-app/audio.vue +0 -269
- package/components/common/RichText/plugins/audio/uni-app/build.js +0 -3
- package/components/common/RichText/plugins/card/README.md +0 -30
- package/components/common/RichText/plugins/card/build.js +0 -14
- package/components/common/RichText/plugins/card/index.js +0 -7
- package/components/common/RichText/plugins/card/miniprogram/build.js +0 -3
- package/components/common/RichText/plugins/card/miniprogram/card.js +0 -26
- package/components/common/RichText/plugins/card/miniprogram/card.json +0 -3
- package/components/common/RichText/plugins/card/miniprogram/card.wxml +0 -9
- package/components/common/RichText/plugins/card/miniprogram/card.wxss +0 -55
- package/components/common/RichText/plugins/card/uni-app/build.js +0 -3
- package/components/common/RichText/plugins/card/uni-app/card.vue +0 -122
- package/components/common/RichText/plugins/editable/README.md +0 -137
- package/components/common/RichText/plugins/editable/config.js +0 -15
- package/components/common/RichText/plugins/editable/miniprogram/build.js +0 -813
- package/components/common/RichText/plugins/editable/miniprogram/index.js +0 -551
- package/components/common/RichText/plugins/editable/uni-app/build.js +0 -744
- package/components/common/RichText/plugins/editable/uni-app/index.js +0 -553
- package/components/common/RichText/plugins/emoji/README.md +0 -15
- package/components/common/RichText/plugins/emoji/index.js +0 -203
- package/components/common/RichText/plugins/highlight/README.md +0 -26
- package/components/common/RichText/plugins/highlight/config.js +0 -5
- package/components/common/RichText/plugins/highlight/index.js +0 -96
- package/components/common/RichText/plugins/highlight/miniprogram/build.js +0 -88
- package/components/common/RichText/plugins/highlight/prism.css +0 -125
- package/components/common/RichText/plugins/highlight/prism.min.js +0 -7
- package/components/common/RichText/plugins/highlight/uni-app/build.js +0 -88
- package/components/common/RichText/plugins/img-cache/README.md +0 -24
- package/components/common/RichText/plugins/img-cache/build.js +0 -16
- package/components/common/RichText/plugins/img-cache/index.js +0 -138
- package/components/common/RichText/plugins/latex/README.md +0 -16
- package/components/common/RichText/plugins/latex/build.js +0 -14
- package/components/common/RichText/plugins/latex/index.js +0 -77
- package/components/common/RichText/plugins/latex/katex.css +0 -1070
- package/components/common/RichText/plugins/latex/katex.min.js +0 -1
- package/components/common/RichText/plugins/markdown/README.md +0 -17
- package/components/common/RichText/plugins/markdown/index.js +0 -34
- package/components/common/RichText/plugins/markdown/marked.min.js +0 -6
- package/components/common/RichText/plugins/markdown/miniprogram/build.js +0 -70
- package/components/common/RichText/plugins/markdown/uni-app/build.js +0 -68
- package/components/common/RichText/plugins/search/README.md +0 -46
- package/components/common/RichText/plugins/search/miniprogram/index.js +0 -137
- package/components/common/RichText/plugins/search/uni-app/index.js +0 -132
- package/components/common/RichText/plugins/style/README.md +0 -30
- package/components/common/RichText/plugins/style/index.js +0 -129
- package/components/common/RichText/plugins/style/parser.js +0 -175
- package/components/common/RichText/plugins/template/README.md +0 -2
- package/components/common/RichText/plugins/template/build.js +0 -65
- package/components/common/RichText/plugins/template/index.js +0 -67
- package/components/common/RichText/plugins/txv-video/README.md +0 -18
- package/components/common/RichText/plugins/txv-video/build.js +0 -3
- package/components/common/RichText/plugins/txv-video/index.js +0 -46
- package/components/common/RichText/plugins/txv-video/miniprogram/build.js +0 -6
- package/components/common/RichText/plugins/txv-video/uni-app/build.js +0 -3
- package/components/common/RichText/src/miniprogram/index.js +0 -396
- package/components/common/RichText/src/miniprogram/index.json +0 -6
- package/components/common/RichText/src/miniprogram/index.wxml +0 -7
- package/components/common/RichText/src/miniprogram/index.wxss +0 -13
- package/components/common/RichText/src/miniprogram/node/node.js +0 -247
- package/components/common/RichText/src/miniprogram/node/node.json +0 -6
- package/components/common/RichText/src/miniprogram/node/node.wxml +0 -112
- package/components/common/RichText/src/miniprogram/node/node.wxss +0 -164
- package/components/common/RichText/src/miniprogram/parser.js +0 -1269
- package/components/common/RichText/src/uni-app/components/mp-html/mp-html.vue +0 -498
- package/components/common/RichText/src/uni-app/components/mp-html/node/node.vue +0 -585
- package/components/common/RichText/src/uni-app/components/mp-html/parser.js +0 -1393
- package/components/common/RichText/src/uni-app/static/app-plus/mp-html/js/handler.js +0 -254
- package/components/common/RichText/src/uni-app/static/app-plus/mp-html/js/uni.webview.min.js +0 -1
- package/components/common/RichText/src/uni-app/static/app-plus/mp-html/local.html +0 -33
- package/components/common/RichText/tools/config.js +0 -82
- package/components/common/RichText/tools/converter.js +0 -205
- package/components/common/RichText/tools/ifdef.js +0 -115
- package/components/common/RichText/tools/minifier.js +0 -40
- package/components/common/RichText/tools/plugin.js +0 -248
- package/components/message-customer-service.vue +0 -114
- package/script/fileCopy.js +0 -60
- package/script/syncVersion.js +0 -35
- /package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/component-mobile/label-mobile.vue +0 -0
- /package/components/{message-multi-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-multi-form}/component-pc/label-pc.vue +0 -0
- /package/components/{message-form → CustomerServiceChat/message-list/message-elements/message-desk/message-desk-elements/message-single-form}/form-branch.vue +0 -0
|
@@ -1,744 +0,0 @@
|
|
|
1
|
-
/* global getTop */
|
|
2
|
-
module.exports = {
|
|
3
|
-
style: `/* #ifndef H5 || MP-ALIPAY || APP-PLUS */
|
|
4
|
-
._address,
|
|
5
|
-
._article,
|
|
6
|
-
._aside,
|
|
7
|
-
._body,
|
|
8
|
-
._caption,
|
|
9
|
-
._center,
|
|
10
|
-
._cite,
|
|
11
|
-
._footer,
|
|
12
|
-
._header,
|
|
13
|
-
._html,
|
|
14
|
-
._nav,
|
|
15
|
-
._pre,
|
|
16
|
-
._section {
|
|
17
|
-
display: block;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/* #endif */
|
|
21
|
-
._video {
|
|
22
|
-
width: 300px;
|
|
23
|
-
height: 225px;
|
|
24
|
-
display: inline-block;
|
|
25
|
-
background-color: black;
|
|
26
|
-
}`,
|
|
27
|
-
methods: {
|
|
28
|
-
/**
|
|
29
|
-
* @description 开始编辑文本
|
|
30
|
-
* @param {Event} e
|
|
31
|
-
*/
|
|
32
|
-
editStart (e) {
|
|
33
|
-
if (this.opts[5]) {
|
|
34
|
-
const i = e.currentTarget.dataset.i
|
|
35
|
-
if (!this.ctrl['e' + i] && this.opts[5] !== 'simple') {
|
|
36
|
-
// 显示虚线框
|
|
37
|
-
this.$set(this.ctrl, 'e' + i, 1)
|
|
38
|
-
setTimeout(() => {
|
|
39
|
-
this.root._mask.push(() => this.$set(this.ctrl, 'e' + i, 0))
|
|
40
|
-
}, 50)
|
|
41
|
-
this.root._edit = this
|
|
42
|
-
this.i = i
|
|
43
|
-
this.cursor = this.childs[i].text.length
|
|
44
|
-
} else {
|
|
45
|
-
if (this.opts[5] === 'simple') {
|
|
46
|
-
this.root._edit = this
|
|
47
|
-
this.i = i
|
|
48
|
-
this.cursor = this.childs[i].text.length
|
|
49
|
-
}
|
|
50
|
-
this.root._mask.pop()
|
|
51
|
-
this.root._maskTap()
|
|
52
|
-
// 将 text 转为 textarea
|
|
53
|
-
this.$set(this.ctrl, 'e' + i, 2)
|
|
54
|
-
// 延时对焦,避免高度错误
|
|
55
|
-
setTimeout(() => {
|
|
56
|
-
this.$set(this.ctrl, 'e' + i, 3)
|
|
57
|
-
}, 50)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
/**
|
|
62
|
-
* @description 输入文本
|
|
63
|
-
* @param {Event} e
|
|
64
|
-
*/
|
|
65
|
-
editInput (e) {
|
|
66
|
-
const i = e.target.dataset.i
|
|
67
|
-
// 替换连续空格
|
|
68
|
-
const value = e.detail.value.replace(/ {2,}/, $ => {
|
|
69
|
-
let res = '\xa0'
|
|
70
|
-
for (let i = 1; i < $.length; i++) {
|
|
71
|
-
res += '\xa0'
|
|
72
|
-
}
|
|
73
|
-
return res
|
|
74
|
-
})
|
|
75
|
-
this.root._editVal(`${this.opts[7]}.${i}.text`, this.childs[i].text, value) // 记录编辑历史
|
|
76
|
-
this.cursor = e.detail.cursor
|
|
77
|
-
},
|
|
78
|
-
/**
|
|
79
|
-
* @description 完成编辑文本
|
|
80
|
-
* @param {Event} e
|
|
81
|
-
*/
|
|
82
|
-
editEnd (e) {
|
|
83
|
-
const i = e.target.dataset.i
|
|
84
|
-
this.$set(this.ctrl, 'e' + i, 0)
|
|
85
|
-
// 更新到视图
|
|
86
|
-
this.root._setData(`${this.opts[7]}.${i}.text`, e.detail.value.replace(/ {2}/g, '\xa0 '))
|
|
87
|
-
if (e.detail.cursor !== undefined) {
|
|
88
|
-
this.cursor = e.detail.cursor
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
/**
|
|
92
|
-
* @description 插入一个标签
|
|
93
|
-
* @param {Object} node 要插入的标签
|
|
94
|
-
*/
|
|
95
|
-
insert (node) {
|
|
96
|
-
setTimeout(() => {
|
|
97
|
-
const childs = this.childs.slice(0)
|
|
98
|
-
if (!childs[this.i]) {
|
|
99
|
-
childs.push(node)
|
|
100
|
-
} else if (childs[this.i].text) {
|
|
101
|
-
// 在文本中插入
|
|
102
|
-
const text = childs[this.i].text
|
|
103
|
-
if (node.type === 'text') {
|
|
104
|
-
if (this.cursor) {
|
|
105
|
-
childs[this.i].text = text.substring(0, this.cursor) + node.text + text.substring(this.cursor)
|
|
106
|
-
} else {
|
|
107
|
-
childs[this.i].text += node.text
|
|
108
|
-
}
|
|
109
|
-
} else {
|
|
110
|
-
const list = []
|
|
111
|
-
if (this.cursor) {
|
|
112
|
-
list.push({
|
|
113
|
-
type: 'text',
|
|
114
|
-
text: text.substring(0, this.cursor)
|
|
115
|
-
})
|
|
116
|
-
}
|
|
117
|
-
list.push(node)
|
|
118
|
-
if (this.cursor < text.length) {
|
|
119
|
-
list.push({
|
|
120
|
-
type: 'text',
|
|
121
|
-
text: text.substring(this.cursor)
|
|
122
|
-
})
|
|
123
|
-
}
|
|
124
|
-
childs.splice(this.i, 1, ...list)
|
|
125
|
-
}
|
|
126
|
-
} else {
|
|
127
|
-
childs.splice(parseInt(this.i) + 1, 0, node)
|
|
128
|
-
}
|
|
129
|
-
this.root._editVal(this.opts[7], this.childs, childs, true)
|
|
130
|
-
this.i = parseInt(this.i) + 1
|
|
131
|
-
}, 200)
|
|
132
|
-
},
|
|
133
|
-
/**
|
|
134
|
-
* @description 移除第 i 个标签
|
|
135
|
-
* @param {Number} i
|
|
136
|
-
*/
|
|
137
|
-
remove (i) {
|
|
138
|
-
const arr = this.childs.slice(0)
|
|
139
|
-
const delEle = arr.splice(i, 1)[0]
|
|
140
|
-
if (delEle.name === 'img' || delEle.name === 'video' || delEle.name === 'audio') {
|
|
141
|
-
let src = delEle.attrs.src
|
|
142
|
-
if (delEle.src) {
|
|
143
|
-
src = delEle.src.length === 1 ? delEle.src[0] : delEle.src
|
|
144
|
-
}
|
|
145
|
-
this.root.$emit('remove', {
|
|
146
|
-
type: delEle.name,
|
|
147
|
-
src
|
|
148
|
-
})
|
|
149
|
-
}
|
|
150
|
-
this.root._edit = undefined
|
|
151
|
-
this.root._maskTap()
|
|
152
|
-
this.root._editVal(this.opts[7], this.childs, arr, true)
|
|
153
|
-
},
|
|
154
|
-
/**
|
|
155
|
-
* @description 标签被点击
|
|
156
|
-
* @param {Event} e
|
|
157
|
-
*/
|
|
158
|
-
nodeTap (e) {
|
|
159
|
-
if (this.opts[5]) {
|
|
160
|
-
if (this.root._lock) return
|
|
161
|
-
this.root._lock = true
|
|
162
|
-
setTimeout(() => {
|
|
163
|
-
this.root._lock = false
|
|
164
|
-
}, 50)
|
|
165
|
-
if (this.ctrl['e' + this.i] === 3) return
|
|
166
|
-
this.root._maskTap()
|
|
167
|
-
this.root._edit = this
|
|
168
|
-
if (this.opts[5] === 'simple') return
|
|
169
|
-
let start = this.opts[7].lastIndexOf('children.')
|
|
170
|
-
if (start !== -1) {
|
|
171
|
-
start += 9
|
|
172
|
-
} else {
|
|
173
|
-
start = 6
|
|
174
|
-
}
|
|
175
|
-
const i = parseInt(this.opts[7].substring(start, this.opts[7].lastIndexOf('.children')))
|
|
176
|
-
let parent = this.$parent
|
|
177
|
-
while (parent && parent.$options.name !== 'node') {
|
|
178
|
-
parent = parent.$parent
|
|
179
|
-
}
|
|
180
|
-
let remove = () => {
|
|
181
|
-
parent.remove(i)
|
|
182
|
-
}
|
|
183
|
-
if (this.opts[7].length - parent.opts[7].length > 15) {
|
|
184
|
-
const parts = this.opts[7].split('.')
|
|
185
|
-
let childs = parent.childs
|
|
186
|
-
const i = parseInt(parts[parent.opts[7].split('.').length])
|
|
187
|
-
const oldParent = parent
|
|
188
|
-
// 删除整个表格
|
|
189
|
-
remove = () => {
|
|
190
|
-
oldParent.remove(i)
|
|
191
|
-
}
|
|
192
|
-
for (let i = parent.opts[7].split('.').length; i < parts.length - 2; i++) {
|
|
193
|
-
childs = childs[parts[i]]
|
|
194
|
-
}
|
|
195
|
-
const that = this
|
|
196
|
-
parent = {
|
|
197
|
-
childs,
|
|
198
|
-
opts: [undefined, undefined, undefined, undefined, undefined, undefined, undefined, parts.slice(0, parts.length - 2).join('.')],
|
|
199
|
-
changeStyle (name, i, value, oldVal) {
|
|
200
|
-
let style = this.childs[i].attrs.style || ''
|
|
201
|
-
if (style.includes(';' + name + ':' + oldVal)) {
|
|
202
|
-
style = style.replace(';' + name + ':' + oldVal, ';' + name + ':' + value)
|
|
203
|
-
} else {
|
|
204
|
-
style += ';' + name + ':' + value
|
|
205
|
-
}
|
|
206
|
-
that.root._setData(`${this.opts[7]}.${i}.attrs.style`, style)
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
if (!parent) return
|
|
211
|
-
// 显示实线框
|
|
212
|
-
this.$set(this.ctrl, 'root', 1)
|
|
213
|
-
this.root._mask.push(() => this.$set(this.ctrl, 'root', 0))
|
|
214
|
-
if (this.childs.length === 1 && this.childs[0].type === 'text' && !this.ctrl.e0) {
|
|
215
|
-
this.$set(this.ctrl, 'e0', 1)
|
|
216
|
-
this.root._mask.push(() => this.$set(this.ctrl, 'e0', 0))
|
|
217
|
-
this.i = 0
|
|
218
|
-
this.cursor = this.childs[0].text.length
|
|
219
|
-
}
|
|
220
|
-
const items = this.root._getItem(parent.childs[i], i !== 0, i !== parent.childs.length - 1)
|
|
221
|
-
this.root._tooltip({
|
|
222
|
-
top: getTop(e),
|
|
223
|
-
items,
|
|
224
|
-
success: tapIndex => {
|
|
225
|
-
if (items[tapIndex] === '大小') {
|
|
226
|
-
// 改变字体大小
|
|
227
|
-
const style = parent.childs[i].attrs.style || ''
|
|
228
|
-
let value = style.match(/;font-size:([0-9]+)px/)
|
|
229
|
-
if (value) {
|
|
230
|
-
value = parseInt(value[1])
|
|
231
|
-
} else {
|
|
232
|
-
value = 16
|
|
233
|
-
}
|
|
234
|
-
this.root._slider({
|
|
235
|
-
min: 10,
|
|
236
|
-
max: 30,
|
|
237
|
-
value,
|
|
238
|
-
top: getTop(e),
|
|
239
|
-
changing: val => {
|
|
240
|
-
if (Math.abs(val - value) > 2) {
|
|
241
|
-
// 字号变换超过 2 时更新到视图
|
|
242
|
-
parent.changeStyle('font-size', i, val + 'px', value + 'px')
|
|
243
|
-
value = e.detail.value
|
|
244
|
-
}
|
|
245
|
-
},
|
|
246
|
-
change: val => {
|
|
247
|
-
if (val !== value) {
|
|
248
|
-
parent.changeStyle('font-size', i, val + 'px', value + 'px')
|
|
249
|
-
}
|
|
250
|
-
this.root._editVal(`${parent.opts[7]}.${i}.attrs.style`, style, parent.childs[i].attrs.style)
|
|
251
|
-
}
|
|
252
|
-
})
|
|
253
|
-
} else if (items[tapIndex] === '颜色') {
|
|
254
|
-
// 改变文字颜色
|
|
255
|
-
const items = this.root._getItem('color')
|
|
256
|
-
this.root._color({
|
|
257
|
-
top: getTop(e),
|
|
258
|
-
items,
|
|
259
|
-
success: tapIndex => {
|
|
260
|
-
const style = parent.childs[i].attrs.style || ''
|
|
261
|
-
const value = style.match(/;color:([^;]+)/)
|
|
262
|
-
parent.changeStyle('color', i, items[tapIndex], value ? value[1] : undefined)
|
|
263
|
-
this.root._editVal(`${parent.opts[7]}.${i}.attrs.style`, style, parent.childs[i].attrs.style)
|
|
264
|
-
}
|
|
265
|
-
})
|
|
266
|
-
} else if (items[tapIndex] === '上移' || items[tapIndex] === '下移') {
|
|
267
|
-
const arr = parent.childs.slice(0)
|
|
268
|
-
const item = arr[i]
|
|
269
|
-
if (items[tapIndex] === '上移') {
|
|
270
|
-
arr[i] = arr[i - 1]
|
|
271
|
-
arr[i - 1] = item
|
|
272
|
-
} else {
|
|
273
|
-
arr[i] = arr[i + 1]
|
|
274
|
-
arr[i + 1] = item
|
|
275
|
-
}
|
|
276
|
-
this.root._editVal(parent.opts[7], parent.childs, arr, true)
|
|
277
|
-
} else if (items[tapIndex] === '删除') {
|
|
278
|
-
remove()
|
|
279
|
-
} else {
|
|
280
|
-
const style = parent.childs[i].attrs.style || ''
|
|
281
|
-
let newStyle = ''
|
|
282
|
-
const item = items[tapIndex]
|
|
283
|
-
let name
|
|
284
|
-
let value
|
|
285
|
-
if (item === '斜体') {
|
|
286
|
-
name = 'font-style'
|
|
287
|
-
value = 'italic'
|
|
288
|
-
} else if (item === '粗体') {
|
|
289
|
-
name = 'font-weight'
|
|
290
|
-
value = 'bold'
|
|
291
|
-
} else if (item === '下划线') {
|
|
292
|
-
name = 'text-decoration'
|
|
293
|
-
value = 'underline'
|
|
294
|
-
} else if (item === '居中') {
|
|
295
|
-
name = 'text-align'
|
|
296
|
-
value = 'center'
|
|
297
|
-
} else if (item === '缩进') {
|
|
298
|
-
name = 'text-indent'
|
|
299
|
-
value = '2em'
|
|
300
|
-
}
|
|
301
|
-
if (style.includes(name + ':')) {
|
|
302
|
-
// 已有则取消
|
|
303
|
-
newStyle = style.replace(new RegExp(name + ':[^;]+'), '')
|
|
304
|
-
} else {
|
|
305
|
-
// 没有则添加
|
|
306
|
-
newStyle = style + ';' + name + ':' + value
|
|
307
|
-
}
|
|
308
|
-
this.root._editVal(`${parent.opts[7]}.${i}.attrs.style`, style, newStyle, true)
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
})
|
|
312
|
-
}
|
|
313
|
-
},
|
|
314
|
-
/**
|
|
315
|
-
* @description 音视频被点击
|
|
316
|
-
* @param {Event} e
|
|
317
|
-
*/
|
|
318
|
-
mediaTap (e, index) {
|
|
319
|
-
if (this.opts[5]) {
|
|
320
|
-
const i = e.target.dataset.i || index
|
|
321
|
-
const node = this.childs[i]
|
|
322
|
-
const items = this.root._getItem(node)
|
|
323
|
-
this.root._maskTap()
|
|
324
|
-
this.root._edit = this
|
|
325
|
-
this.i = i
|
|
326
|
-
this.root._tooltip({
|
|
327
|
-
top: e.currentTarget.offsetTop - 30,
|
|
328
|
-
items,
|
|
329
|
-
success: tapIndex => {
|
|
330
|
-
switch (items[tapIndex]) {
|
|
331
|
-
case '封面':
|
|
332
|
-
// 设置封面
|
|
333
|
-
this.root.getSrc('img', node.attrs.poster || '').then(url => {
|
|
334
|
-
this.root._editVal(`${this.opts[7]}.${i}.attrs.poster`, node.attrs.poster, url instanceof Array ? url[0] : url, true)
|
|
335
|
-
}).catch(() => { })
|
|
336
|
-
break
|
|
337
|
-
case '删除':
|
|
338
|
-
this.remove(i)
|
|
339
|
-
break
|
|
340
|
-
case '循环':
|
|
341
|
-
case '不循环':
|
|
342
|
-
// 切换循环播放
|
|
343
|
-
this.root._setData(`${this.opts[7]}.${i}.attrs.loop`, !node.attrs.loop)
|
|
344
|
-
uni.showToast({
|
|
345
|
-
title: '成功'
|
|
346
|
-
})
|
|
347
|
-
break
|
|
348
|
-
case '自动播放':
|
|
349
|
-
case '不自动播放':
|
|
350
|
-
// 切换自动播放播放
|
|
351
|
-
this.root._setData(`${this.opts[7]}.${i}.attrs.autoplay`, !node.attrs.autoplay)
|
|
352
|
-
uni.showToast({
|
|
353
|
-
title: '成功'
|
|
354
|
-
})
|
|
355
|
-
break
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
})
|
|
359
|
-
// 避免上层出现点击态
|
|
360
|
-
this.root._lock = true
|
|
361
|
-
setTimeout(() => {
|
|
362
|
-
this.root._lock = false
|
|
363
|
-
}, 50)
|
|
364
|
-
}
|
|
365
|
-
},
|
|
366
|
-
/**
|
|
367
|
-
* 改变样式
|
|
368
|
-
* @param {String} name 属性名
|
|
369
|
-
* @param {Number} i 第几个标签
|
|
370
|
-
* @param {String} value 新值
|
|
371
|
-
* @param {String} oldVal 旧值
|
|
372
|
-
*/
|
|
373
|
-
changeStyle (name, i, value, oldVal) {
|
|
374
|
-
let style = this.childs[i].attrs.style || ''
|
|
375
|
-
if (style.includes(';' + name + ':' + oldVal)) {
|
|
376
|
-
// style 中已经有
|
|
377
|
-
style = style.replace(';' + name + ':' + oldVal, ';' + name + ':' + value)
|
|
378
|
-
} else {
|
|
379
|
-
// 没有则新增
|
|
380
|
-
style += ';' + name + ':' + value
|
|
381
|
-
}
|
|
382
|
-
this.root._setData(`${this.opts[7]}.${i}.attrs.style`, style)
|
|
383
|
-
}
|
|
384
|
-
},
|
|
385
|
-
handler (file) {
|
|
386
|
-
if (file.isBuffer()) {
|
|
387
|
-
let content = file.contents.toString()
|
|
388
|
-
if (file.path.includes('mp-html.vue')) {
|
|
389
|
-
// 传递 editable 属性和路径
|
|
390
|
-
content = content.replace(/opts\s*=\s*"\[([^\]]+)\]"/, 'opts="[$1,editable,placeholder,\'nodes\']"')
|
|
391
|
-
.replace(/<view(.*?):style\s*=\s*"containerStyle"/, '<view$1:style="(editable?\'min-height:200px;\':\'\')+containerStyle" @tap="_containTap"')
|
|
392
|
-
// 工具弹窗
|
|
393
|
-
.replace(/<\/view>\s*<\/template>/, ` <view v-if="tooltip" class="_tooltip_contain" :style="'top:'+tooltip.top+'px'">
|
|
394
|
-
<view class="_tooltip">
|
|
395
|
-
<view v-for="(item, index) in tooltip.items" v-bind:key="index" class="_tooltip_item" :data-i="index" @tap="_tooltipTap">{{item}}</view>
|
|
396
|
-
</view>
|
|
397
|
-
</view>
|
|
398
|
-
<view v-if="slider" class="_slider" :style="'top:'+slider.top+'px'">
|
|
399
|
-
<slider :value="slider.value" :min="slider.min" :max="slider.max" handle-size="14" block-size="14" show-value activeColor="white" style="padding:3px" @changing="_sliderChanging" @change="_sliderChange" />
|
|
400
|
-
</view>
|
|
401
|
-
<view v-if="color" class="_tooltip_contain" :style="'top:'+color.top+'px'">
|
|
402
|
-
<view class="_tooltip" style="overflow-y: hidden;">
|
|
403
|
-
<view v-for="(item, index) in color.items" v-bind:key="index" class="_color_item" :style="'background-color:'+item" :data-i="index" @tap="_colorTap"></view>
|
|
404
|
-
</view>
|
|
405
|
-
</view>
|
|
406
|
-
</view>
|
|
407
|
-
</template>`)
|
|
408
|
-
// 添加 data
|
|
409
|
-
.replace(/data\s*\(\)\s*{\s*return\s*{/, `data() {
|
|
410
|
-
return {
|
|
411
|
-
tooltip: null,
|
|
412
|
-
slider: null,
|
|
413
|
-
color: null,`)
|
|
414
|
-
// 添加 editable 属性
|
|
415
|
-
.replace(/props\s*:\s*{/, `props: {
|
|
416
|
-
editable: [Boolean, String],
|
|
417
|
-
placeholder: String,`)
|
|
418
|
-
// 添加 watch
|
|
419
|
-
.replace(/watch\s*:\s*{/, `watch: {
|
|
420
|
-
editable(val) {
|
|
421
|
-
this.setContent(val ? this.content : this.getContent())
|
|
422
|
-
if (!val)
|
|
423
|
-
this._maskTap()
|
|
424
|
-
},`)
|
|
425
|
-
.replace(/if\s*\(this.content/, 'if ((this.content || this.editable)')
|
|
426
|
-
// 处理各类弹窗的事件
|
|
427
|
-
.replace(/methods\s*:\s*{/, `methods: {
|
|
428
|
-
_containTap() {
|
|
429
|
-
if (!this._lock && !this.slider && !this.color) {
|
|
430
|
-
this._edit = undefined
|
|
431
|
-
this._maskTap()
|
|
432
|
-
}
|
|
433
|
-
},
|
|
434
|
-
_tooltipTap(e) {
|
|
435
|
-
this._tooltipcb(e.currentTarget.dataset.i)
|
|
436
|
-
this.$set(this, 'tooltip', null)
|
|
437
|
-
},
|
|
438
|
-
_sliderChanging(e) {
|
|
439
|
-
this._slideringcb(e.detail.value)
|
|
440
|
-
},
|
|
441
|
-
_sliderChange(e) {
|
|
442
|
-
this._slidercb(e.detail.value)
|
|
443
|
-
},
|
|
444
|
-
_colorTap(e) {
|
|
445
|
-
this._colorcb(e.currentTarget.dataset.i)
|
|
446
|
-
this.$set(this, 'color', null)
|
|
447
|
-
},`)
|
|
448
|
-
// 工具弹窗的样式
|
|
449
|
-
.replace('</style>', `
|
|
450
|
-
/* 提示条 */
|
|
451
|
-
._tooltip_contain {
|
|
452
|
-
position: absolute;
|
|
453
|
-
right: 20px;
|
|
454
|
-
left: 20px;
|
|
455
|
-
text-align: center;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
._tooltip {
|
|
459
|
-
box-sizing: border-box;
|
|
460
|
-
display: inline-block;
|
|
461
|
-
width: auto;
|
|
462
|
-
max-width: 100%;
|
|
463
|
-
height: 30px;
|
|
464
|
-
padding: 0 3px;
|
|
465
|
-
overflow: scroll;
|
|
466
|
-
font-size: 14px;
|
|
467
|
-
line-height: 30px;
|
|
468
|
-
white-space: nowrap;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
._tooltip_item {
|
|
472
|
-
display: inline-block;
|
|
473
|
-
width: auto;
|
|
474
|
-
padding: 0 2vw;
|
|
475
|
-
line-height: 30px;
|
|
476
|
-
background-color: black;
|
|
477
|
-
color: white;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
._color_item {
|
|
481
|
-
display: inline-block;
|
|
482
|
-
width: 18px;
|
|
483
|
-
height: 18px;
|
|
484
|
-
margin: 5px 2vw;
|
|
485
|
-
border:1px solid #dfe2e5;
|
|
486
|
-
border-radius: 50%;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
/* 图片宽度滚动条 */
|
|
490
|
-
._slider {
|
|
491
|
-
position: absolute;
|
|
492
|
-
left: 20px;
|
|
493
|
-
width: 220px;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
._tooltip,
|
|
497
|
-
._slider {
|
|
498
|
-
background-color: black;
|
|
499
|
-
border-radius: 3px;
|
|
500
|
-
opacity: 0.75;
|
|
501
|
-
}
|
|
502
|
-
</style>`)
|
|
503
|
-
} else if (file.path.includes('parser.js')) {
|
|
504
|
-
// 不做 expose 处理
|
|
505
|
-
content = content.replace(/parser.prototype.expose\s*=\s*function\s*\(\)\s*{/, `parser.prototype.expose = function () {
|
|
506
|
-
if (this.options.editable) return`)
|
|
507
|
-
.replace(/popNode\s*=\s*function\s*\(\)\s*{/, 'popNode = function () {\n const editable = this.options.editable')
|
|
508
|
-
// 不转换标签名
|
|
509
|
-
.replace(/if\s*\(config.blockTags\[node.name\]\)\s*{[\s\S]+?}/, `if (config.blockTags[node.name]) {
|
|
510
|
-
if (!editable) {
|
|
511
|
-
node.name = 'div'
|
|
512
|
-
}
|
|
513
|
-
}`)
|
|
514
|
-
// 转换表格和列表
|
|
515
|
-
.replace(/else\s*if\s*\(node.c\)/, 'else if (!editable && node.c )')
|
|
516
|
-
.replace(/node.c(\)|\s*&&|\s*\n)/g, '(node.c || editable)$1')
|
|
517
|
-
.replace(/while\s*\(map\[row\s*\+\s*'.'\s*\+\s*col\]\)\s*{[\s\S]+?}/, `while (map[row + '.' + col]) {
|
|
518
|
-
col++
|
|
519
|
-
}
|
|
520
|
-
if (editable) {
|
|
521
|
-
td.r = row
|
|
522
|
-
}`)
|
|
523
|
-
.replace(/let\s+str\s*=\s*'<video style="width:100%;height:100%"'/, `let str = '<video style="width:100%;height:100%"'
|
|
524
|
-
if (editable) {
|
|
525
|
-
attrs.controls = ''
|
|
526
|
-
}`)
|
|
527
|
-
} else if (file.path.includes('node.vue')) {
|
|
528
|
-
content =
|
|
529
|
-
// 传递 opts
|
|
530
|
-
content.replace(/:childs\s*=\s*"tbody.children"\s*:opts="opts"/, ':childs="tbody.children" :opts="[opts[0],opts[1],opts[2],opts[3],opts[4],opts[5],opts[6],opts[7]+\'.\'+i+\'.children.\'+x+\'.children\']"')
|
|
531
|
-
.replace(/:childs\s*=\s*"n2.children"\s*:opts="opts"/, ':childs="n2.children" :opts="[opts[0],opts[1],opts[2],opts[3],opts[4],opts[5],opts[6],opts[7]+\'.\'+i+\'.children.\'+j+\'.children\']"')
|
|
532
|
-
.replace(/:childs\s*=\s*"tr.children"\s*:opts="opts"/, ':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\']"')
|
|
533
|
-
.replace(/:childs\s*=\s*"td.children"\s*:opts="opts"/, ':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\']"')
|
|
534
|
-
.replace(/opts\s*=\s*"opts"/g, 'opts="[opts[0],opts[1],opts[2],opts[3],opts[4],opts[5],opts[6],opts[7]+\'.\'+i+\'.children\']"')
|
|
535
|
-
// 不使用 rich-text
|
|
536
|
-
.replace(/!n.c/g, '!opts[5]&&!n.c').replace('&&n.c', '&&(n.c||opts[5])')
|
|
537
|
-
// 修改普通标签
|
|
538
|
-
.replace(/<view\s+:id(.+?)style="/, '<view @tap="nodeTap" :id$1style="(ctrl.root&&opts[5]!==\'simple\'?\'border:1px solid black;padding:5px;display:block;\':\'\')+')
|
|
539
|
-
// 修改文本块
|
|
540
|
-
.replace(/<!--\s*文本\s*-->[\s\S]+?<!--\s*链接\s*-->/,
|
|
541
|
-
`<!-- 文本 -->
|
|
542
|
-
<text v-else-if="n.type==='text'&&!ctrl['e'+i]" :data-i="i" :user-select="opts[4]" :decode="!opts[5]" @tap="editStart">{{n.text}}
|
|
543
|
-
<text v-if="!n.text" style="color:gray">{{opts[6]||'请输入'}}</text>
|
|
544
|
-
</text>
|
|
545
|
-
<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}}
|
|
546
|
-
<text v-if="!n.text" style="color:gray">{{opts[6]||'请输入'}}</text>
|
|
547
|
-
</text>
|
|
548
|
-
<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" />
|
|
549
|
-
<text v-else-if="n.name==='br'">\\n</text>
|
|
550
|
-
<!-- 链接 -->`)
|
|
551
|
-
// 修改图片
|
|
552
|
-
.replace(/<image(.+?)id="n.attrs.id/, '<image$1id="n.attrs.id||(\'n\'+i)')
|
|
553
|
-
.replace('height:1px', "height:'+(ctrl['h'+i]||1)+'px")
|
|
554
|
-
.replace(/:style\s*=\s*"\(ctrl\[i\]/g, ':style="(ctrl[\'e\'+i]&&opts[5]!==\'simple\'?\'border:1px dashed black;padding:3px;\':\'\')+(ctrl[i]')
|
|
555
|
-
.replace(/show-menu-by-longpress\s*=\s*"(\S+?)"\s*:image-menu-prevent\s*=\s*"(\S+?)"/, 'show-menu-by-longpress="!opts[5]&&$1" :image-menu-prevent="opts[5]||$2"')
|
|
556
|
-
// 修改音视频
|
|
557
|
-
.replace('v-else-if="n.html"', 'v-else-if="n.html" :data-i="i" @tap="mediaTap"')
|
|
558
|
-
.replace('<video', '<video :show-center-play-btn="!opts[5]" @tap="mediaTap"')
|
|
559
|
-
.replace('<audio ', '<audio @tap="mediaTap" ')
|
|
560
|
-
.replace('<my-audio ', '<my-audio @onClick="mediaTap($event, i)" ')
|
|
561
|
-
.replace('card ', 'card @click="mediaTap($event, i)" ')
|
|
562
|
-
.replace('<script>',
|
|
563
|
-
`<script>
|
|
564
|
-
import Parser from '../parser'
|
|
565
|
-
function getTop(e) {
|
|
566
|
-
let top
|
|
567
|
-
// #ifdef H5 && VUE3
|
|
568
|
-
top = e.pageY
|
|
569
|
-
// #endif
|
|
570
|
-
// #ifdef (H5 && VUE2) || APP-PLUS
|
|
571
|
-
top = e.touches[0].pageY
|
|
572
|
-
// #endif
|
|
573
|
-
// #ifdef MP-ALIPAY
|
|
574
|
-
top = e.detail.pageY
|
|
575
|
-
// #endif
|
|
576
|
-
// #ifndef H5 || MP-ALIPAY || APP-PLUS
|
|
577
|
-
top = e.detail.y
|
|
578
|
-
// #endif
|
|
579
|
-
if (top - e.currentTarget.offsetTop < 150 || top < 600) {
|
|
580
|
-
top = e.currentTarget.offsetTop
|
|
581
|
-
}
|
|
582
|
-
if (top < 30) {
|
|
583
|
-
top += 70
|
|
584
|
-
}
|
|
585
|
-
return top - 30
|
|
586
|
-
}`)
|
|
587
|
-
// 周期处理
|
|
588
|
-
.replace(/beforeDestroy\s*\(\)\s*{/, `beforeDestroy () {
|
|
589
|
-
if (this.root && this.root._edit === this) {
|
|
590
|
-
this.root._edit = undefined
|
|
591
|
-
}`)
|
|
592
|
-
// 记录图片宽度
|
|
593
|
-
.replace(/imgLoad\s*\(e\)\s*{/, `imgLoad(e) {
|
|
594
|
-
// #ifdef MP-WEIXIN || MP-QQ
|
|
595
|
-
if (this.opts[5])
|
|
596
|
-
this.$nextTick(() => {
|
|
597
|
-
const id = this.childs[i].attrs.id || ('n' + i)
|
|
598
|
-
uni.createSelectorQuery().in(this).select('#' + id).boundingClientRect().exec(res => {
|
|
599
|
-
this.$set(this.ctrl, 'h'+i, res[0].height)
|
|
600
|
-
})
|
|
601
|
-
})
|
|
602
|
-
// #endif`)
|
|
603
|
-
.replace(/if\s*\(!this.childs\[i\].w\)\s*{[\s\S]+?}/,
|
|
604
|
-
`if (!this.childs[i].w) {
|
|
605
|
-
this.$set(this.ctrl, i, e.detail.width)
|
|
606
|
-
if (this.opts[5]) {
|
|
607
|
-
const path = this.opts[7] + '.' + i + '.attrs.'
|
|
608
|
-
if (e.detail.width < 150)
|
|
609
|
-
this.root._setData(path + 'ignore', 'T')
|
|
610
|
-
this.root._setData(path + 'width', e.detail.width.toString())
|
|
611
|
-
}
|
|
612
|
-
}`)
|
|
613
|
-
// 处理图片长按
|
|
614
|
-
.replace(/imgLongTap\s*\(\)\s*{/, `imgLongTap() {
|
|
615
|
-
if (this.opts[5]) return`)
|
|
616
|
-
// 处理图片点击
|
|
617
|
-
.replace(/imgTap\s*\(e\)\s*{([\s\S]+?)},\s*\/\*/,
|
|
618
|
-
`imgTap (e) {
|
|
619
|
-
if (!this.opts[5]) {$1} else {
|
|
620
|
-
const i = e.currentTarget.dataset.i
|
|
621
|
-
const node = this.childs[i]
|
|
622
|
-
const items = this.root._getItem(node)
|
|
623
|
-
const parser = new Parser(this.root)
|
|
624
|
-
this.root._edit = this
|
|
625
|
-
this.i = i
|
|
626
|
-
this.root._maskTap()
|
|
627
|
-
this.$set(this.ctrl, 'e' + i, 1)
|
|
628
|
-
this.root._mask.push(() => this.$set(this.ctrl, 'e' + i, 0))
|
|
629
|
-
this.root._tooltip({
|
|
630
|
-
top: getTop(e),
|
|
631
|
-
items,
|
|
632
|
-
success: tapIndex => {
|
|
633
|
-
if (items[tapIndex] === '换图') {
|
|
634
|
-
// 换图
|
|
635
|
-
this.root.getSrc('img', node.attrs.src || '').then(url => {
|
|
636
|
-
this.root._editVal(this.opts[7] + '.' + i + '.attrs.src', node.attrs.src, parser.getUrl(url instanceof Array ? url[0] : url), true)
|
|
637
|
-
}).catch(() => { })
|
|
638
|
-
} else if (items[tapIndex] === '宽度') {
|
|
639
|
-
// 更改宽度
|
|
640
|
-
const style = node.attrs.style || ''
|
|
641
|
-
let value = style.match(/max-width:([0-9]+)%/)
|
|
642
|
-
if (value) {
|
|
643
|
-
value = parseInt(value[1])
|
|
644
|
-
} else {
|
|
645
|
-
value = 100
|
|
646
|
-
}
|
|
647
|
-
this.root._slider({
|
|
648
|
-
min: 0,
|
|
649
|
-
max: 100,
|
|
650
|
-
value,
|
|
651
|
-
top: getTop(e),
|
|
652
|
-
changing: val => {
|
|
653
|
-
// 变化超过 5% 更新时视图
|
|
654
|
-
if (Math.abs(val - value) > 5) {
|
|
655
|
-
this.changeStyle('max-width', i, val + '%', value + '%')
|
|
656
|
-
value = val
|
|
657
|
-
}
|
|
658
|
-
},
|
|
659
|
-
change: val => {
|
|
660
|
-
if (val !== value) {
|
|
661
|
-
this.changeStyle('max-width', i, val + '%', value + '%')
|
|
662
|
-
value = val
|
|
663
|
-
}
|
|
664
|
-
this.root._editVal(this.opts[7] + '.' + i + '.attrs.style', style, this.childs[i].attrs.style)
|
|
665
|
-
}
|
|
666
|
-
})
|
|
667
|
-
} else if (items[tapIndex] === '超链接') {
|
|
668
|
-
// 将图片设置为链接
|
|
669
|
-
this.root.getSrc('link', node.a ? node.a.href : '').then(url => {
|
|
670
|
-
// 如果有 a 标签则替换 href
|
|
671
|
-
if (node.a) {
|
|
672
|
-
this.root._editVal(this.opts[7] + '.' + i + '.a.href', node.a.href, parser.getUrl(url), true)
|
|
673
|
-
} else {
|
|
674
|
-
const link = {
|
|
675
|
-
name: 'a',
|
|
676
|
-
attrs: {
|
|
677
|
-
href: parser.getUrl(url)
|
|
678
|
-
},
|
|
679
|
-
children: [node]
|
|
680
|
-
}
|
|
681
|
-
node.a = link.attrs
|
|
682
|
-
this.root._editVal(this.opts[7] + '.' + i, node, link, true)
|
|
683
|
-
}
|
|
684
|
-
wx.showToast({
|
|
685
|
-
title: '成功'
|
|
686
|
-
})
|
|
687
|
-
}).catch(() => { })
|
|
688
|
-
} else if (items[tapIndex] === '预览图') {
|
|
689
|
-
// 设置预览图链接
|
|
690
|
-
this.root.getSrc('img', node.attrs['original-src'] || '').then(url => {
|
|
691
|
-
this.root._editVal(this.opts[7] + '.' + i + '.attrs.original-src', node.attrs['original-src'], parser.getUrl(url instanceof Array ? url[0] : url), true)
|
|
692
|
-
uni.showToast({
|
|
693
|
-
title: '成功'
|
|
694
|
-
})
|
|
695
|
-
}).catch(() => { })
|
|
696
|
-
} else if (items[tapIndex] === '删除') {
|
|
697
|
-
this.remove(i)
|
|
698
|
-
} else {
|
|
699
|
-
// 禁用 / 启用预览
|
|
700
|
-
this.root._setData(this.opts[7] + '.' + i + '.attrs.ignore', !node.attrs.ignore)
|
|
701
|
-
uni.showToast({
|
|
702
|
-
title: '成功'
|
|
703
|
-
})
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
})
|
|
707
|
-
this.root._lock = true
|
|
708
|
-
setTimeout(() => {
|
|
709
|
-
this.root._lock = false
|
|
710
|
-
}, 50)
|
|
711
|
-
}
|
|
712
|
-
},
|
|
713
|
-
/*`)
|
|
714
|
-
// 处理链接点击
|
|
715
|
-
.replace(/linkTap\s*\(e\)\s*{([\s\S]+?)},\s*\/\*/,
|
|
716
|
-
`linkTap (e) {
|
|
717
|
-
if (!this.opts[5]) {$1} else {
|
|
718
|
-
const i = e.currentTarget.dataset.i
|
|
719
|
-
const node = this.childs[i]
|
|
720
|
-
const items = this.root._getItem(node)
|
|
721
|
-
this.root._tooltip({
|
|
722
|
-
top: getTop(e),
|
|
723
|
-
items,
|
|
724
|
-
success: tapIndex => {
|
|
725
|
-
if (items[tapIndex] === '更换链接') {
|
|
726
|
-
this.root.getSrc('link', node.attrs.href).then(url => {
|
|
727
|
-
this.root._editVal(this.opts[7] + '.' + i + '.attrs.href', node.attrs.href, url, true)
|
|
728
|
-
uni.showToast({
|
|
729
|
-
title: '成功'
|
|
730
|
-
})
|
|
731
|
-
}).catch(() => { })
|
|
732
|
-
} else {
|
|
733
|
-
this.remove(i)
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
})
|
|
737
|
-
}
|
|
738
|
-
},
|
|
739
|
-
/*`)
|
|
740
|
-
}
|
|
741
|
-
file.contents = Buffer.from(content)
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
}
|