shershen08 / emoji-vue

Add emoji keyboard to your vuejs project
MIT License
141 stars 24 forks source link

emoji的位置问题 #4

Open manpenghui opened 5 years ago

manpenghui commented 5 years ago

为什添加emoji的时候,会被添加到首行啊

shershen08 commented 5 years ago

English please?

manpenghui commented 5 years ago

English please?

when i insert a emoji, the emoji was insert into this first place ,why?

koibi2 commented 5 years ago

可以参考这个:

let tc = document.getElementById('comment_text');
tc.focus();
//开始插入
let tclen = tc.value.length;
//计算表情长度。
var emoji_length = emoji.length;
if (typeof document.selection != "undefined") {
    document.selection.createRange().text = emoji;
}
else {
    //记录光标的起始位置
    var position = tc.selectionStart;
    //计算表情长度。
    var emoji_length = emoji.length;
    position = position + emoji_length;
    tc.value = tc.value.substr(0, tc.selectionStart) + emoji + tc.value.substring(tc.selectionStart, tclen);
    this.insert_comment.comment_text = tc.value;
    tc.selectionStart = tc.selectionEnd = position;
}
shershen08 commented 5 years ago

@koibi2 is it a solution block of code ? or a source of an issue?

koibi2 commented 5 years ago

@koibi2 is it a solution block of code ? or a source of an issue?

this is a solution block of code:

search where is the cursor, then let new string replace old string.

shershen08 commented 5 years ago

great, I'll try to apply that

shershen08 commented 5 years ago

I've been testing it now and can't confirm the issue

liwen327 commented 5 years ago

@koibi2 这段代码是添加到哪里的?我添加到源码里也不起作用啊,报错。 image

koibi2 commented 5 years ago

@koibi2 这段代码是添加到哪里的?我添加到源码里也不起作用啊,报错。 image

[汗]我这是其他代码片的示例。具体就是“获取光标位置”那几行代码,加进去就行了。

liwen327 commented 5 years ago

可以参考这个:

let tc = document.getElementById('comment_text');
tc.focus();
//开始插入
let tclen = tc.value.length;
//计算表情长度。
var emoji_length = emoji.length;
if (typeof document.selection != "undefined") {
  document.selection.createRange().text = emoji;
}
else {
  //记录光标的起始位置
  var position = tc.selectionStart;
  //计算表情长度。
  var emoji_length = emoji.length;
  position = position + emoji_length;
  tc.value = tc.value.substr(0, tc.selectionStart) + emoji + tc.value.substring(tc.selectionStart, tclen);
  this.insert_comment.comment_text = tc.value;
  tc.selectionStart = tc.selectionEnd = position;
}

@koibi2 不起作用。还是会被添加到首行。

bruceZJJ commented 5 years ago

@koibi2 你好,请问一下你知道怎么在jsp中使用这个emoji组件吗?

koibi2 commented 5 years ago

@koibi2 你好,请问一下你知道怎么在jsp中使用这个emoji组件吗?

我放弃用这个组件了。帮不上你的忙。

bruceZJJ commented 5 years ago

@koibi2 你好,请问一下你知道怎么在jsp中使用这个emoji组件吗?

我放弃用这个组件了。帮不上你的忙。

好的,谢谢你。

GuanLola commented 5 years ago

@koibi2 你好,请问一下你知道怎么在jsp中使用这个emoji组件吗?

我放弃用这个组件了。帮不上你的忙。

好的,谢谢你。

为什添加emoji的时候,会被添加到首行啊

问题解决了吗?

GuanLola commented 5 years ago

为什添加emoji的时候,会被添加到首行啊

问题解决了吗?

bruceZJJ commented 5 years ago

虽然我后来已经用了另一个方案了,不过还是非常感谢您帮忙解答!

------------------ 原始邮件 ------------------ 发件人: "guanym"notifications@github.com; 发送时间: 2019年10月16日(星期三) 中午1:43 收件人: "shershen08/emoji-vue"emoji-vue@noreply.github.com; 抄送: "展佳俊"zjj510855282@qq.com;"Comment"comment@noreply.github.com; 主题: Re: [shershen08/emoji-vue] emoji的位置问题 (#4)

把这个地方注释掉就可以了

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

musanhuasi commented 3 years ago

为什添加emoji的时候,会被添加到首行啊 为啥不清楚,只知道绑定了value值会出现这个情况,只需要不填:value属性就行,然后清空就调用clearTextarea()方法

musanhuasi commented 3 years ago

作者可以再开放几个属性吗?比如点击输入框高亮得颜色,以及表情得边框颜色