@tencentcloud/ai-desk-customer-vue 0.1.3 → 0.1.4

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