简体   繁体   English

如何从Javascript / Redactor中的OS X角色查看器和iOS表情符号键盘中检测到表情符号插入事件?

[英]How can I detect an emoji insert event from the OS X character viewer and iOS emoji keyboard in Javascript/Redactor?

I'm having trouble getting Redactor (a WYSIWYG contenteditable web editor by Imperavi) to recognize the character insert event that results from the OS X Character Viewer and inline emoji palettes, as well as the iOS emoji palette. 我无法使用Redactor(Imperavi的一个所见即所得的网页编辑器)来识别由OS X角色查看器和内联表情符号调色板以及iOS表情符号调色板产生的字符插入事件

Redactor doesn't sync the change until I add, say, a space or trigger a paste event. 在我添加空格或触发粘贴事件之前,Redactor不会同步更改。 Then it gets picked up and saved as one would expect. 然后它被拾取并保存为人们所期望的。 Forcing a sync before submitting the form doesn't appear to pick the character up either (or I'm doing it wrong). 在提交表单之前强制同步似乎也没有选择字符(或者我做错了)。

Is there a particular event associated with the insert triggered by these OS X/iOS palettes, or would you have some workaround ideas for getting Redactor to notice the character? 是否存在与这些OS X / iOS调色板触发的插入相关联的特定事件,或者您是否有一些解决方法想法让Redactor注意到该角色?

Try it at http://imperavi.com/redactor/examples/placeholder/ ; 请访问http://imperavi.com/redactor/examples/placeholder/ ; click inside the text entry area, invoke the emoji palette using - ctrl - space and click an emoji to insert it. 单击文本输入区域内部,使用 - ctrl - space调用表情符号调色板,然后单击表情符号将其插入。 The placeholder not disappearing is one indicator that the insert didn't register. 占位符未消失是插入未注册的一个指示符。

The DOMCharacterDataModified event notices the insert and can be used to trigger a .redactor('code.sync'). DOMCharacterDataModified事件通知插入,可用于触发.redactor('code.sync')。

So I set this up as an event listener in initCallback and use it when the underlying textarea used by Redactor appears empty; 所以我将它设置为initCallback中的事件监听器,并在Redactor使用的底层t​​extarea显示为空时使用它; this because even after the sync, content consisting solely of emoji doesn't necessarily get synced going forward. 这是因为即使在同步之后,仅由表情符号组成的内容也不一定会同步。 (When the textarea has content, syncing appears to include emoji). (当textarea有内容时,同步似乎包括表情符号)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM