Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emoji的位置问题 #4

Open
manpenghui opened this issue Oct 31, 2018 · 18 comments
Open

emoji的位置问题 #4

manpenghui opened this issue Oct 31, 2018 · 18 comments

Comments

@manpenghui
Copy link

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

@shershen08
Copy link
Owner

English please?

@manpenghui
Copy link
Author

English please?

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

@koibi2
Copy link

koibi2 commented Jan 15, 2019

可以参考这个:

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
Copy link
Owner

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

@koibi2
Copy link

koibi2 commented Jan 15, 2019

@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
Copy link
Owner

great, I'll try to apply that

@shershen08
Copy link
Owner

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

@liwen327
Copy link

liwen327 commented Apr 4, 2019

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

@koibi2
Copy link

koibi2 commented Apr 4, 2019

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

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

@liwen327
Copy link

liwen327 commented Apr 8, 2019

可以参考这个:

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
Copy link

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

@koibi2
Copy link

koibi2 commented Aug 30, 2019

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

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

@bruceZJJ
Copy link

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

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

好的,谢谢你。

@GuanLola
Copy link

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

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

好的,谢谢你。

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

问题解决了吗?

@GuanLola
Copy link

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

问题解决了吗?

@bruceZJJ
Copy link

bruceZJJ commented Oct 16, 2019 via email

@musanhuasi
Copy link

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

@musanhuasi
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants