我有表情符号列表。他们每个人都有自己的unicode。使用 Modifier.insertText(),我想将它们插入到文本中。
_addEmoji(text) {
const { editorState } = this.state;
const selection = editorState.getSelection();
const contentState = editorState.getCurrentContent();
const txt = '&#x' + text + ';';
let nextEditorState = EditorState.createEmpty();
if (selection.isCollapsed()) {
const nextContentState = Modifier.insertText(contentState, selection, txt);
nextEditorState = EditorState.push(
editorState,
nextContentState,
'insert-characters'
);
} else {
const nextContentState = Modifier.replaceText(contentState, selection, text);
nextEditorState = EditorState.push(
editorState,
nextContentState,
'insert-characters'
);
}
this.onChange(nextEditorState);
}
Run Code Online (Sandbox Code Playgroud)
我希望看到
我想用两边的空格填充每个多字节字符.我可以将它们剥离出来,但是我想把它们放进去并填充它们.
例如: to .
使用下划线表示空格: to ______
当我使用标准 jQuery 将 unicode 表情符号插入到<span>Chrome (v48) 中时,它们不会出现,但会出现在 Firefox (v43) 和 Safari (v9) 中。比较这些屏幕截图:
铬合金:
火狐浏览器:
这里有什么解释吗?
我正在使用Emojione Area JavaScript 插件。但是,我只显示文本区域,没有表情符号窗格。
这是我的 HTML 文件:
<html>
<head>
<link rel="stylesheet" href="https://cdn.rawgit.com/mervick/emojionearea/master/dist/emojionearea.min.css">
<script type="text/javascript" src="https://cdn.rawgit.com/mervick/emojionearea/master/dist/emojionearea.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<link rel="stylesheet" href="stylesheet.css">
</head>
<body>
<script>
$(document).ready(function() {
$("#emojionearea1").emojioneArea({
pickerPosition: "left",
tonesStyle: "bullet"
});
</script>
<div class="row">
<div class="span6">
<textarea id="emojionearea1">Default :smile:</textarea>
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我有一个关于反应的聊天应用程序.
我需要以下内容:
:smile:应该转换成emojione,而不是unicode.<div contentEditable
styles={this.state.messageInputStyle}
className="message-input">
</div>
Run Code Online (Sandbox Code Playgroud) 如何在javascript中将其转换为此1f600
''.charCodeAt(0);
Run Code Online (Sandbox Code Playgroud)
这将返回Unicode 55357,但如何从中获取1f600