增加sendText、sendKey参数,增加editor-footer插槽
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script>
|
||||
import { toEmojiName } from "utils";
|
||||
import { toEmojiName,useScopedSlot } from "utils";
|
||||
const exec = (val, command = "insertHTML") => {
|
||||
document.execCommand(command, false, val);
|
||||
};
|
||||
@@ -9,12 +9,30 @@ let emojiData = [];
|
||||
let isInitTool = false;
|
||||
export default {
|
||||
name: "LemonEditor",
|
||||
inject: {
|
||||
IMUI: {
|
||||
from:'IMUI',
|
||||
default (){
|
||||
return this;
|
||||
}
|
||||
}
|
||||
},
|
||||
components: {},
|
||||
props: {
|
||||
tools:{
|
||||
type:Array,
|
||||
default:()=>[],
|
||||
}
|
||||
},
|
||||
sendText:{
|
||||
type:String,
|
||||
default:'发 送'
|
||||
},
|
||||
sendKey:{
|
||||
type:Function,
|
||||
default(e){
|
||||
return e.keyCode == 13 && e.ctrlKey === true;
|
||||
}
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -82,13 +100,15 @@ export default {
|
||||
/>
|
||||
</div>
|
||||
<div class="lemon-editor__footer">
|
||||
<div class="lemon-editor__tip">使用 ctrl + enter 快捷发送消息</div>
|
||||
<div class="lemon-editor__tip">
|
||||
{useScopedSlot(this.IMUI.$scopedSlots['editor-footer'],"使用 ctrl + enter 快捷发送消息")}
|
||||
</div>
|
||||
<div class="lemon-editor__submit">
|
||||
<lemon-button
|
||||
disabled={this.submitDisabled}
|
||||
on-click={this._handleSend}
|
||||
>
|
||||
发 送
|
||||
{this.sendText}
|
||||
</lemon-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -218,8 +238,7 @@ export default {
|
||||
//this._checkSubmitDisabled();
|
||||
},
|
||||
_handleKeydown(e) {
|
||||
const { keyCode,ctrlKey } = e;
|
||||
if (keyCode == 13 && ctrlKey === true && this.submitDisabled == false) {
|
||||
if(this.submitDisabled == false && this.sendKey(e)){
|
||||
this._handleSend();
|
||||
}
|
||||
},
|
||||
|
||||
@@ -66,6 +66,8 @@ export default {
|
||||
* 是否隐藏消息列表内的发送时间
|
||||
*/
|
||||
hideMessageTime:Boolean,
|
||||
sendKey:Function,
|
||||
sendText:String,
|
||||
user: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
@@ -461,6 +463,8 @@ export default {
|
||||
<lemon-editor
|
||||
ref="editor"
|
||||
tools={this.editorTools}
|
||||
sendText={this.sendText}
|
||||
sendKey={this.sendKey}
|
||||
onSend={this._handleSend}
|
||||
onUpload={this._handleUpload}
|
||||
/>
|
||||
@@ -723,7 +727,7 @@ export default {
|
||||
* @param {Array<Contact>} data 联系人列表
|
||||
*/
|
||||
initContacts(data) {
|
||||
this.contacts.push(...data);
|
||||
this.contacts = data;
|
||||
this.sortContacts();
|
||||
},
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user