如何将html元素放置在Ckeditor中的光标位置
How to place an html element at the cursor position in Ckeditor?
我有这样的困难,成功地放置一个html元素,我拖放到我的Ckeditor。到目前为止,我只能用setData"把它放在我的内容的最后。但是我想把它放在光标的位置
我的意思是,与其这样做:
<p>My content with <span>spans</span>, <a>links</a>, etc.</p><span>The html I am drag/droping</span>
我想这样做:
<p>My content with <span>spans</span>, <span>The html I am drag/droping</span>, <a>links</a>, etc.</p>
现在,我的代码看起来像这样:
CKEDITOR.instances['myContent'].insertHtml(' <span>The html I am drag/droping</span>');
- 我试过插入文本,但它从来没有工作。
- 然后我尝试了inserthhtml,但它只在IE中工作。
你知道怎么修理它吗?那可帮了大忙了!谢谢。
使用Ckeditor 'paste' (drop) events/methods代替native。
在你的插件editor.on('instanceReady'…假设CKEditor 4.x
粘贴和删除由同一个事件' Paste '处理。Ckeditor将datvalue的内容放在编辑器的光标位置。
editor.on('paste', function(e){
// get data from e.data.dataTransfer or wherever ...
e.data.dataValue = ' <span>The html I am drag/droping</span>';
});
相关文章:
- CKEditor Widget-阻止编辑可编辑元素本身
- Ckeditor-plugin:插入虚假元素add不情愿<p>标签前后
- CKEditor-我在editor.css中的风格是't
- CKeditor:更改对话框中的默认选择选项
- 自定义函数中的光标位置
- 删除CKEditor工具栏按钮,但不删除功能
- CKEditor v4:自制插件中对话框的动态标题
- 在Widget代码中使用javascript从左向右滑动光标图像
- 将文本插入光标所在的文本区域
- 收听ckeditor小部件事件
- CKEditor光标在Chrome中的焦点上不闪烁
- 在 CKEditor 中重新加载页面后保留光标位置
- 铬中的 CKEDITOR 在光标位置添加“?”标记,同时应用任何样式(粗体/斜体)而不选择
- 如何在ckeditor中将光标设置到当前行的末尾
- 将光标定位在ckeditor中的标签内
- 如何将html元素放置在Ckeditor中的光标位置
- 在CKEditor中设置光标到特定位置
- 在正确的光标位置重新聚焦CKEditor
- 在CKEDITOR中如何找到当前光标位置的下一个项目
- 检查光标是否在ckeditor对话框中的表内