@tencentcloud/ai-desk-customer-wechat
Version:
AI Desk customer UIKit for wechat mini program
3 lines (2 loc) • 2.44 kB
JavaScript
;const n=require("../../../../common/vendor.js"),j=require("../../../adapter-vue.js"),u=require("../../../@aidesk/uikit-engine/index.js"),d=require("../utils/conversationDraft.js"),w=require("../emoji-config/index.js"),B=require("../../../utils/env.js"),K=n.defineComponent({__name:"message-input-editor-uniapp",props:{placeholder:{type:String,default:""},replayOrReferenceMessage:{type:Object,default:()=>({}),required:!1},isMuted:{type:Boolean,default:!0},muteText:{type:String,default:""},enableInput:{type:Boolean,default:!0},enableTyping:{type:Boolean,default:!0}},emits:["onTyping","onFocus","isInputNotEmpty","sendMessage"],setup(g,{expose:y,emit:h}){const{ref:s,watch:M,onMounted:x,onUnmounted:D}=j.vue,p=g,r=h,t=s("");s();const i=s(!0),l=s(!0),m=s(),a=s(""),c=s();x(()=>{u.Kt.watch(u.a.CONV,{currentConversation:C}),u.Kt.watch(u.a.CHAT,{quoteMessage:_}),n.index.$on("insert-emoji",e=>{t.value+=e.emoji.name,r("isInputNotEmpty",!0)})}),D(()=>{a.value&&d.DraftManager.setStore(a.value,t.value,t.value,c.value),n.index.$off("insert-emoji"),u.Kt.unwatch(u.a.CONV,{currentConversation:C}),u.Kt.unwatch(u.a.CHAT,{quoteMessage:_}),U()});const E=()=>{r("sendMessage")},I=()=>{let e=t.value;return e=w.transformTextWithEmojiNamesToKeys(e),[{type:"text",payload:{text:e}}]},v=()=>{t.value="",l.value=!0,r("isInputNotEmpty",!1)},f=e=>{t.value=e},T=()=>{i.value=!0},k=e=>{var o;i.value=!1,r("onFocus",(o=e==null?void 0:e.detail)==null?void 0:o.height)},q=()=>{var e;l.value=!((e=t==null?void 0:t.value)!=null&&e.length),r("isInputNotEmpty",!l.value)},S=()=>{q()};M(()=>[l.value,i.value],(e,o)=>{e!==o&&r("onTyping",l.value,i.value)},{immediate:!0,deep:!0});function C(e){const o=a.value;m.value=e,a.value=e==null?void 0:e.conversationID,o!==a.value&&(o&&d.DraftManager.setStore(o,t.value,t.value,c.value),v(),a.value&&d.DraftManager.getStore(a.value,f))}function _(e){c.value=e}function U(){i.value=!0,m.value=null,a.value="",c.value=null,v()}return y({resetEditor:v,setEditorContent:f,getEditorContent:I}),(e,o)=>n.e$1({a:p.isMuted},p.isMuted?{b:n.t(p.muteText)}:{},{c:n.o(E),d:n.o([N=>n.isRef(t)?t.value=N.detail.value:null,S]),e:n.o(T),f:n.o(k),g:n.unref(t),h:n.unref(B.isTikTok)?1:""})}}),b=n._export_sfc(K,[["__scopeId","data-v-c560662d"]]);wx.createComponent(b);
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/ai-desk-customer-uniapp/components/CustomerServiceChat/message-input/message-input-editor-uniapp.js.map