@tencentcloud/ai-desk-customer-vue 0.1.0
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/.code.yml +17 -0
- package/.eslintignore +6 -0
- package/.stylelintrc.json +40 -0
- package/CHANGELOG.md +5 -0
- package/README.md +12 -0
- package/adapter-vue-web.ts +73 -0
- package/adapter-vue.ts +10 -0
- package/assets/audio-before-delete.svg +4 -0
- package/assets/audio-blue.png +0 -0
- package/assets/audio-bubble-blue.svg +3 -0
- package/assets/audio-bubble-red.svg +3 -0
- package/assets/audio-delete.svg +10 -0
- package/assets/audio.svg +6 -0
- package/assets/back.svg +16 -0
- package/assets/background_mobile.png +0 -0
- package/assets/camera-uni.png +0 -0
- package/assets/close-quote-icon.svg +3 -0
- package/assets/customer_avatar.png +0 -0
- package/assets/customer_avatar_mobile.png +0 -0
- package/assets/dialog-close.png +0 -0
- package/assets/double-arrow.svg +1 -0
- package/assets/download.svg +6 -0
- package/assets/emoji.png +0 -0
- package/assets/face-uni.png +0 -0
- package/assets/face.png +0 -0
- package/assets/file-h5.png +0 -0
- package/assets/files.png +0 -0
- package/assets/form-dialog-bg.png +0 -0
- package/assets/icon-arrow-left.svg +7 -0
- package/assets/icon-close.svg +6 -0
- package/assets/iconRight.svg +3 -0
- package/assets/icon_form.png +0 -0
- package/assets/icon_form_filled.png +0 -0
- package/assets/icon_question.png +0 -0
- package/assets/icon_refresh.png +0 -0
- package/assets/icon_success.png +0 -0
- package/assets/imRobotGuess.svg +4 -0
- package/assets/image-uni.png +0 -0
- package/assets/image.png +0 -0
- package/assets/keyboard_icon.png +0 -0
- package/assets/loading.png +0 -0
- package/assets/more-uni.png +0 -0
- package/assets/more_tools.png +0 -0
- package/assets/msg-audio.svg +1 -0
- package/assets/msg-copy.svg +30 -0
- package/assets/msg-del.svg +33 -0
- package/assets/msg-quote.svg +8 -0
- package/assets/msg-revoke.svg +29 -0
- package/assets/radio-check.png +0 -0
- package/assets/radio-uncheck.png +0 -0
- package/assets/radio.svg +6 -0
- package/assets/refresh.svg +4 -0
- package/assets/rotate-left.svg +7 -0
- package/assets/rotate-right.svg +7 -0
- package/assets/star.png +0 -0
- package/assets/starLine.png +0 -0
- package/assets/translate.svg +12 -0
- package/assets/video-play.png +0 -0
- package/assets/video-uni.png +0 -0
- package/assets/video.png +0 -0
- package/assets/zoom-in.svg +9 -0
- package/assets/zoom-out.svg +9 -0
- package/components/CustomerServiceChat/chat-header/index-web.vue +141 -0
- package/components/CustomerServiceChat/emoji-config/custom-emoji.ts +15 -0
- package/components/CustomerServiceChat/emoji-config/default-emoji.ts +114 -0
- package/components/CustomerServiceChat/emoji-config/index.ts +140 -0
- package/components/CustomerServiceChat/emoji-config/locales/en.ts +66 -0
- package/components/CustomerServiceChat/emoji-config/locales/zh_cn.ts +66 -0
- package/components/CustomerServiceChat/index-web.vue +250 -0
- package/components/CustomerServiceChat/message-input/index-web.vue +214 -0
- package/components/CustomerServiceChat/message-input/index.ts +2 -0
- package/components/CustomerServiceChat/message-input/message-input-button.vue +95 -0
- package/components/CustomerServiceChat/message-input/message-input-editor-web.vue +884 -0
- package/components/CustomerServiceChat/message-input/message-input-file-web.ts +38 -0
- package/components/CustomerServiceChat/message-input/message-input-quote/index.vue +204 -0
- package/components/CustomerServiceChat/message-input-toolbar/emoji-dialog-mobile/emoji-dialog-mobile.vue +145 -0
- package/components/CustomerServiceChat/message-input-toolbar/emoji-picker/emoji-picker-dialog.vue +180 -0
- package/components/CustomerServiceChat/message-input-toolbar/emoji-picker/index.ts +2 -0
- package/components/CustomerServiceChat/message-input-toolbar/emoji-picker/index.vue +90 -0
- package/components/CustomerServiceChat/message-input-toolbar/emoji-picker/style/h5.scss +26 -0
- package/components/CustomerServiceChat/message-input-toolbar/emoji-picker/style/index.scss +4 -0
- package/components/CustomerServiceChat/message-input-toolbar/emoji-picker/style/web.scss +55 -0
- package/components/CustomerServiceChat/message-input-toolbar/file-upload/index.ts +2 -0
- package/components/CustomerServiceChat/message-input-toolbar/file-upload/index.vue +77 -0
- package/components/CustomerServiceChat/message-input-toolbar/image-upload/index.ts +2 -0
- package/components/CustomerServiceChat/message-input-toolbar/image-upload/index.vue +185 -0
- package/components/CustomerServiceChat/message-input-toolbar/index-web.vue +191 -0
- package/components/CustomerServiceChat/message-input-toolbar/index.ts +2 -0
- package/components/CustomerServiceChat/message-input-toolbar/style/uni.scss +111 -0
- package/components/CustomerServiceChat/message-input-toolbar/toolbar-item-container/index.vue +149 -0
- package/components/CustomerServiceChat/message-input-toolbar/toolbar-item-container/style/color.scss +6 -0
- package/components/CustomerServiceChat/message-input-toolbar/toolbar-item-container/style/h5.scss +20 -0
- package/components/CustomerServiceChat/message-input-toolbar/toolbar-item-container/style/index.scss +5 -0
- package/components/CustomerServiceChat/message-input-toolbar/toolbar-item-container/style/uni.scss +36 -0
- package/components/CustomerServiceChat/message-input-toolbar/toolbar-item-container/style/web.scss +19 -0
- package/components/CustomerServiceChat/message-input-toolbar/video-upload/index.ts +2 -0
- package/components/CustomerServiceChat/message-input-toolbar/video-upload/index.vue +146 -0
- package/components/CustomerServiceChat/message-list/index-web.vue +712 -0
- package/components/CustomerServiceChat/message-list/link/index.ts +23 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-audio-web.vue +223 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-bubble-web.vue +504 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-custom.vue +5 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-face.vue +45 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-file.vue +151 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-image-web.vue +97 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-location.vue +34 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-quote/index-web.vue +286 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-quote/interface.ts +60 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-record/index.vue +139 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-text.vue +94 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-timestamp.vue +76 -0
- package/components/CustomerServiceChat/message-list/message-elements/message-video-web.vue +319 -0
- package/components/CustomerServiceChat/message-list/message-elements/plugins/plugin-components/index.ts +9 -0
- package/components/CustomerServiceChat/message-list/message-elements/plugins/plugin-components/message-customer/index.ts +5 -0
- package/components/CustomerServiceChat/message-list/message-elements/plugins/plugin-components/message-customer/message-customer-service.vue +22 -0
- package/components/CustomerServiceChat/message-list/message-elements/plugins/plugin-components/message-plugin-layout-web.vue +133 -0
- package/components/CustomerServiceChat/message-list/message-elements/plugins/plugin-components/message-plugin-web.vue +83 -0
- package/components/CustomerServiceChat/message-list/message-elements/read-status/index.vue +193 -0
- package/components/CustomerServiceChat/message-list/message-elements/simple-message-list/index.vue +462 -0
- package/components/CustomerServiceChat/message-list/message-elements/simple-message-list/message-container.vue +105 -0
- package/components/CustomerServiceChat/message-list/message-elements/video-play.vue +59 -0
- package/components/CustomerServiceChat/message-list/message-tool/index-web.vue +312 -0
- package/components/CustomerServiceChat/message-list/message-tool/message-revoked.vue +63 -0
- package/components/CustomerServiceChat/message-list/scroll-button/index.vue +201 -0
- package/components/CustomerServiceChat/message-list/style/color.scss +32 -0
- package/components/CustomerServiceChat/message-list/style/h5.scss +16 -0
- package/components/CustomerServiceChat/message-list/style/index.scss +11 -0
- package/components/CustomerServiceChat/message-list/style/web.scss +180 -0
- package/components/CustomerServiceChat/style/common.scss +59 -0
- package/components/CustomerServiceChat/style/h5.scss +51 -0
- package/components/CustomerServiceChat/style/index.scss +12 -0
- package/components/CustomerServiceChat/style/uni.scss +13 -0
- package/components/CustomerServiceChat/style/web.scss +46 -0
- package/components/CustomerServiceChat/style/wx.scss +5 -0
- package/components/CustomerServiceChat/utils/conversationDraft.ts +86 -0
- package/components/CustomerServiceChat/utils/sendMessage.ts +140 -0
- package/components/common/Avatar/index.vue +148 -0
- package/components/common/BottomPopup/index.ts +3 -0
- package/components/common/BottomPopup/index.vue +160 -0
- package/components/common/BottomPopup/style/h5.scss +62 -0
- package/components/common/BottomPopup/style/index.scss +3 -0
- package/components/common/BottomPopup/style/modal.scss +5 -0
- package/components/common/Dialog/index.ts +3 -0
- package/components/common/Dialog/index.vue +120 -0
- package/components/common/Dialog/style/color.scss +43 -0
- package/components/common/Dialog/style/dialog.scss +4 -0
- package/components/common/Dialog/style/h5.scss +56 -0
- package/components/common/Dialog/style/web.scss +61 -0
- package/components/common/Drawer/index.vue +164 -0
- package/components/common/Icon.vue +83 -0
- package/components/common/ImagePreviewer/image-item-web.vue +42 -0
- package/components/common/ImagePreviewer/index-web.vue +682 -0
- package/components/common/ImagePreviewer/index.ts +3 -0
- package/components/common/Overlay/index.vue +126 -0
- package/components/common/ProgressMessage/index.vue +95 -0
- package/components/common/RadioSelect/index.vue +59 -0
- package/components/common/RichText/LICENSE +21 -0
- package/components/common/RichText/README.md +244 -0
- package/components/common/RichText/dist/mp-alipay/index.acss +1 -0
- package/components/common/RichText/dist/mp-alipay/index.axml +1 -0
- package/components/common/RichText/dist/mp-alipay/index.js +8 -0
- package/components/common/RichText/dist/mp-alipay/index.json +1 -0
- package/components/common/RichText/dist/mp-alipay/node/node.acss +1 -0
- package/components/common/RichText/dist/mp-alipay/node/node.axml +1 -0
- package/components/common/RichText/dist/mp-alipay/node/node.js +1 -0
- package/components/common/RichText/dist/mp-alipay/node/node.json +1 -0
- package/components/common/RichText/dist/mp-alipay/parser.js +1 -0
- package/components/common/RichText/dist/mp-baidu/index.css +1 -0
- package/components/common/RichText/dist/mp-baidu/index.js +8 -0
- package/components/common/RichText/dist/mp-baidu/index.json +1 -0
- package/components/common/RichText/dist/mp-baidu/index.swan +1 -0
- package/components/common/RichText/dist/mp-baidu/node/node.css +1 -0
- package/components/common/RichText/dist/mp-baidu/node/node.js +1 -0
- package/components/common/RichText/dist/mp-baidu/node/node.json +1 -0
- package/components/common/RichText/dist/mp-baidu/node/node.swan +1 -0
- package/components/common/RichText/dist/mp-baidu/parser.js +1 -0
- package/components/common/RichText/dist/mp-qq/index.js +8 -0
- package/components/common/RichText/dist/mp-qq/index.json +1 -0
- package/components/common/RichText/dist/mp-qq/index.qml +1 -0
- package/components/common/RichText/dist/mp-qq/index.qss +1 -0
- package/components/common/RichText/dist/mp-qq/node/node.js +1 -0
- package/components/common/RichText/dist/mp-qq/node/node.json +1 -0
- package/components/common/RichText/dist/mp-qq/node/node.qml +1 -0
- package/components/common/RichText/dist/mp-qq/node/node.qss +1 -0
- package/components/common/RichText/dist/mp-qq/parser.js +1 -0
- package/components/common/RichText/dist/mp-toutiao/index.js +8 -0
- package/components/common/RichText/dist/mp-toutiao/index.json +1 -0
- package/components/common/RichText/dist/mp-toutiao/index.ttml +1 -0
- package/components/common/RichText/dist/mp-toutiao/index.ttss +1 -0
- package/components/common/RichText/dist/mp-toutiao/node/node.js +1 -0
- package/components/common/RichText/dist/mp-toutiao/node/node.json +1 -0
- package/components/common/RichText/dist/mp-toutiao/node/node.ttml +1 -0
- package/components/common/RichText/dist/mp-toutiao/node/node.ttss +1 -0
- package/components/common/RichText/dist/mp-toutiao/parser.js +1 -0
- package/components/common/RichText/dist/mp-weixin/index.js +8 -0
- package/components/common/RichText/dist/mp-weixin/index.json +1 -0
- package/components/common/RichText/dist/mp-weixin/index.wxml +1 -0
- package/components/common/RichText/dist/mp-weixin/index.wxss +1 -0
- package/components/common/RichText/dist/mp-weixin/node/node.js +1 -0
- package/components/common/RichText/dist/mp-weixin/node/node.json +1 -0
- package/components/common/RichText/dist/mp-weixin/node/node.wxml +1 -0
- package/components/common/RichText/dist/mp-weixin/node/node.wxss +1 -0
- package/components/common/RichText/dist/mp-weixin/parser.js +1 -0
- package/components/common/RichText/dist/uni-app/components/mp-html/mp-html.vue +498 -0
- package/components/common/RichText/dist/uni-app/components/mp-html/node/node.vue +587 -0
- package/components/common/RichText/dist/uni-app/components/mp-html/parser.js +1393 -0
- package/components/common/RichText/dist/uni-app/static/app-plus/mp-html/js/handler.js +1 -0
- package/components/common/RichText/dist/uni-app/static/app-plus/mp-html/js/uni.webview.min.js +1 -0
- package/components/common/RichText/dist/uni-app/static/app-plus/mp-html/local.html +1 -0
- package/components/common/RichText/docs/.nojekyll +0 -0
- package/components/common/RichText/docs/index.html +50 -0
- package/components/common/RichText/docs/lib/docsify.min.js +1 -0
- package/components/common/RichText/docs/lib/prism-bash.min.js +1 -0
- package/components/common/RichText/docs/lib/search.min.js +1 -0
- package/components/common/RichText/docs/lib/vue.css +858 -0
- package/components/common/RichText/gulpfile.js +113 -0
- package/components/common/RichText/lint.js +63 -0
- package/components/common/RichText/package.json +74 -0
- package/components/common/RichText/plugins/README.md +2 -0
- package/components/common/RichText/plugins/audio/README.md +25 -0
- package/components/common/RichText/plugins/audio/build.js +11 -0
- package/components/common/RichText/plugins/audio/context.js +7 -0
- package/components/common/RichText/plugins/audio/index.js +34 -0
- package/components/common/RichText/plugins/audio/miniprogram/audio.js +189 -0
- package/components/common/RichText/plugins/audio/miniprogram/audio.json +3 -0
- package/components/common/RichText/plugins/audio/miniprogram/audio.wxml +17 -0
- package/components/common/RichText/plugins/audio/miniprogram/audio.wxss +127 -0
- package/components/common/RichText/plugins/audio/miniprogram/build.js +3 -0
- package/components/common/RichText/plugins/audio/uni-app/audio.vue +269 -0
- package/components/common/RichText/plugins/audio/uni-app/build.js +3 -0
- package/components/common/RichText/plugins/card/README.md +30 -0
- package/components/common/RichText/plugins/card/build.js +14 -0
- package/components/common/RichText/plugins/card/index.js +7 -0
- package/components/common/RichText/plugins/card/miniprogram/build.js +3 -0
- package/components/common/RichText/plugins/card/miniprogram/card.js +26 -0
- package/components/common/RichText/plugins/card/miniprogram/card.json +3 -0
- package/components/common/RichText/plugins/card/miniprogram/card.wxml +9 -0
- package/components/common/RichText/plugins/card/miniprogram/card.wxss +55 -0
- package/components/common/RichText/plugins/card/uni-app/build.js +3 -0
- package/components/common/RichText/plugins/card/uni-app/card.vue +122 -0
- package/components/common/RichText/plugins/editable/README.md +137 -0
- package/components/common/RichText/plugins/editable/config.js +15 -0
- package/components/common/RichText/plugins/editable/miniprogram/build.js +813 -0
- package/components/common/RichText/plugins/editable/miniprogram/index.js +551 -0
- package/components/common/RichText/plugins/editable/uni-app/build.js +744 -0
- package/components/common/RichText/plugins/editable/uni-app/index.js +553 -0
- package/components/common/RichText/plugins/emoji/README.md +15 -0
- package/components/common/RichText/plugins/emoji/index.js +203 -0
- package/components/common/RichText/plugins/highlight/README.md +26 -0
- package/components/common/RichText/plugins/highlight/config.js +5 -0
- package/components/common/RichText/plugins/highlight/index.js +96 -0
- package/components/common/RichText/plugins/highlight/miniprogram/build.js +88 -0
- package/components/common/RichText/plugins/highlight/prism.css +125 -0
- package/components/common/RichText/plugins/highlight/prism.min.js +7 -0
- package/components/common/RichText/plugins/highlight/uni-app/build.js +88 -0
- package/components/common/RichText/plugins/img-cache/README.md +24 -0
- package/components/common/RichText/plugins/img-cache/build.js +16 -0
- package/components/common/RichText/plugins/img-cache/index.js +138 -0
- package/components/common/RichText/plugins/latex/README.md +16 -0
- package/components/common/RichText/plugins/latex/build.js +14 -0
- package/components/common/RichText/plugins/latex/index.js +77 -0
- package/components/common/RichText/plugins/latex/katex.css +1070 -0
- package/components/common/RichText/plugins/latex/katex.min.js +1 -0
- package/components/common/RichText/plugins/markdown/README.md +17 -0
- package/components/common/RichText/plugins/markdown/index.js +34 -0
- package/components/common/RichText/plugins/markdown/marked.min.js +6 -0
- package/components/common/RichText/plugins/markdown/miniprogram/build.js +70 -0
- package/components/common/RichText/plugins/markdown/uni-app/build.js +68 -0
- package/components/common/RichText/plugins/search/README.md +46 -0
- package/components/common/RichText/plugins/search/miniprogram/index.js +137 -0
- package/components/common/RichText/plugins/search/uni-app/index.js +132 -0
- package/components/common/RichText/plugins/style/README.md +30 -0
- package/components/common/RichText/plugins/style/index.js +129 -0
- package/components/common/RichText/plugins/style/parser.js +175 -0
- package/components/common/RichText/plugins/template/README.md +2 -0
- package/components/common/RichText/plugins/template/build.js +65 -0
- package/components/common/RichText/plugins/template/index.js +67 -0
- package/components/common/RichText/plugins/txv-video/README.md +18 -0
- package/components/common/RichText/plugins/txv-video/build.js +3 -0
- package/components/common/RichText/plugins/txv-video/index.js +46 -0
- package/components/common/RichText/plugins/txv-video/miniprogram/build.js +6 -0
- package/components/common/RichText/plugins/txv-video/uni-app/build.js +3 -0
- package/components/common/RichText/src/miniprogram/index.js +396 -0
- package/components/common/RichText/src/miniprogram/index.json +6 -0
- package/components/common/RichText/src/miniprogram/index.wxml +7 -0
- package/components/common/RichText/src/miniprogram/index.wxss +13 -0
- package/components/common/RichText/src/miniprogram/node/node.js +247 -0
- package/components/common/RichText/src/miniprogram/node/node.json +6 -0
- package/components/common/RichText/src/miniprogram/node/node.wxml +112 -0
- package/components/common/RichText/src/miniprogram/node/node.wxss +164 -0
- package/components/common/RichText/src/miniprogram/parser.js +1269 -0
- package/components/common/RichText/src/uni-app/components/mp-html/mp-html.vue +498 -0
- package/components/common/RichText/src/uni-app/components/mp-html/node/node.vue +585 -0
- package/components/common/RichText/src/uni-app/components/mp-html/parser.js +1393 -0
- package/components/common/RichText/src/uni-app/static/app-plus/mp-html/js/handler.js +254 -0
- package/components/common/RichText/src/uni-app/static/app-plus/mp-html/js/uni.webview.min.js +1 -0
- package/components/common/RichText/src/uni-app/static/app-plus/mp-html/local.html +33 -0
- package/components/common/RichText/tools/config.js +82 -0
- package/components/common/RichText/tools/converter.js +205 -0
- package/components/common/RichText/tools/ifdef.js +115 -0
- package/components/common/RichText/tools/minifier.js +40 -0
- package/components/common/RichText/tools/plugin.js +248 -0
- package/components/common/Toast/index-web.ts +122 -0
- package/components/common/Toast/index-web.vue +178 -0
- package/components/common/Toast/type.ts +8 -0
- package/components/common/common.scss +59 -0
- package/components/customer-icon.vue +56 -0
- package/components/message-branch.vue +120 -0
- package/components/message-customer-service.vue +114 -0
- package/components/message-form/form-branch.vue +68 -0
- package/components/message-form/form-input.vue +242 -0
- package/components/message-form/index.vue +80 -0
- package/components/message-multi-branch/branch-pc.vue +79 -0
- package/components/message-multi-branch/index.vue +60 -0
- package/components/message-multi-form/component-mobile/form-popup.vue +37 -0
- package/components/message-multi-form/component-mobile/input-mobile.vue +102 -0
- package/components/message-multi-form/component-mobile/label-mobile.vue +32 -0
- package/components/message-multi-form/component-mobile/radios-mobile.vue +161 -0
- package/components/message-multi-form/component-pc/input-pc.vue +93 -0
- package/components/message-multi-form/component-pc/label-pc.vue +33 -0
- package/components/message-multi-form/component-pc/radio-pc.vue +98 -0
- package/components/message-multi-form/form-mobile.vue +385 -0
- package/components/message-multi-form/form-pc.vue +184 -0
- package/components/message-multi-form/index.vue +61 -0
- package/components/message-product-card.vue +129 -0
- package/components/message-rating/index.vue +56 -0
- package/components/message-rating/message-rating-number.vue +247 -0
- package/components/message-rating/message-rating-star.vue +237 -0
- package/components/message-rich-text.vue +155 -0
- package/components/message-robot-welcome.vue +181 -0
- package/components/message-stream.vue +109 -0
- package/constant.ts +122 -0
- package/excluded-list.txt +6 -0
- package/index.ts +30 -0
- package/index.vue +60 -0
- package/interface.ts +176 -0
- package/logger/index.ts +12 -0
- package/logger/main.ts +120 -0
- package/package.json +62 -0
- package/script/fileCopy.js +60 -0
- package/script/syncVersion.js +35 -0
- package/server.ts +128 -0
- package/styles/common.scss +116 -0
- package/tsconfig.json +34 -0
- package/typings.d.ts +20 -0
- package/utils/chatStorage.ts +70 -0
- package/utils/copy-web.ts +141 -0
- package/utils/enableSampleTaskStatus.ts +8 -0
- package/utils/env.ts +15 -0
- package/utils/index.ts +59 -0
- package/utils/utils.ts +162 -0
|
@@ -0,0 +1,813 @@
|
|
|
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
|
+
}
|