emoji-vue icon indicating copy to clipboard operation
emoji-vue copied to clipboard

emoji的位置问题

Open manpenghui opened this issue 6 years ago • 18 comments

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

manpenghui avatar Oct 31 '18 02:10 manpenghui

English please?

shershen08 avatar Oct 31 '18 06:10 shershen08

English please?

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

manpenghui avatar Nov 01 '18 03:11 manpenghui

可以参考这个:

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 avatar Jan 15 '19 06:01 koibi2

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

shershen08 avatar Jan 15 '19 09:01 shershen08

@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.

koibi2 avatar Jan 15 '19 09:01 koibi2

great, I'll try to apply that

shershen08 avatar Jan 15 '19 12:01 shershen08

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

shershen08 avatar Jan 24 '19 16:01 shershen08

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

liwen327 avatar Apr 04 '19 03:04 liwen327

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

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

koibi2 avatar Apr 04 '19 05:04 koibi2

可以参考这个:

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 不起作用。还是会被添加到首行。

liwen327 avatar Apr 08 '19 01:04 liwen327

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

bruceZJJ avatar Aug 30 '19 08:08 bruceZJJ

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

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

koibi2 avatar Aug 30 '19 08:08 koibi2

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

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

好的,谢谢你。

bruceZJJ avatar Aug 30 '19 08:08 bruceZJJ

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

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

好的,谢谢你。

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

问题解决了吗?

GuanLola avatar Oct 16 '19 05:10 GuanLola

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

问题解决了吗?

GuanLola avatar Oct 16 '19 05:10 GuanLola

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

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

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

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

bruceZJJ avatar Oct 16 '19 08:10 bruceZJJ

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

musanhuasi avatar May 12 '21 02:05 musanhuasi

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

musanhuasi avatar May 12 '21 02:05 musanhuasi