拦截 CKEditor 击键
我可以拦截 CKEditor 中的击键(tab 键)并替换默认行为吗?我想要 Tab 键插入一个带边距的 div。
Can I intercept a keystroke in CKEditor (the tab key) and replace the default behavior? I want the tab key to insert a div with margin.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我使用的是4.4.7版本。至少在这里,只需编辑
config.js
就可以更改 TAB 按键的行为。使用此代码 TAB 缩进和 SHIFT + TAB 减少缩进:I am using version 4.4.7. At least here it's possible to change behavior of TAB keystroke just by editing
config.js
. With this code TAB indents and SHIFT + TAB outdents:我用稍微不同的方式解决了这个问题。我希望选项卡在所有行上对齐,而不是插入固定宽度的跨度。因此,我插入一个具有“预”格式的制表符(& # 0 9)。我在使用 insertHtml() 时也遇到了困难,不得不使用 createFromHtml() 和 insertElement() 的组合。
这是我的解决方案:
I solved this a slightly different way. Instead of inserting a fixed width span, I wanted the tabs to line up over all lines. So, I insert a tab character (& # 0 9) with 'pre' formatting. I also had difficulties with insertHtml() and had to use a combination of createFromHtml() and insertElement() instead.
Here's my solution: