简体   繁体   English

TinyMCE插件大厦

[英]TinyMCE Plugin building

I am working on modifying an existing spell check plugin for TinyMCE. 我正在为TinyMCE修改现有的拼写检查插件。

This is what is supposed to happen: 1. User hits "space" and the spell check runs. 这是应该发生的情况:1.用户单击“空格”,然后运行拼写检查。 2. If the word is spelled wrong the word gets wrapped with a span and gets a red underline 2.如果该单词拼写错误,则该单词将被一个跨距包裹并带有红色下划线

what I find happening is that when the user hits space bar the word does get spell checked but the cursor pops back to the end of the word just typed (instead of to where the space is) (you can see this in action at http://mail.solidhouse.com/webmail2/test.html ) 我发现发生的事情是,当用户点击空格键时,确实对该单词进行了拼写检查,但光标弹出回到了刚键入的单词的末尾(而不是空格所在的位置)(您可以在http://www.microsoft.com/zh-cn/ //mail.solidhouse.com/webmail2/test.html

here is my pseudcode: var b = this.editor.selection.getBookmark(); 这是我的伪代码:var b = this.editor.selection.getBookmark(); //for each node node.nodeValue.replace(r5, '$1$2'); //对于每个节点node.nodeValue.replace(r5,'$ 1 $ 2'); this.editor.selection.moveToBookmark(b); this.editor.selection.moveToBookmark(b)中;

what I am suspecting is that moveToBookmark keeps the cursor within the element but I have no idea what to do to remedy this. 我怀疑的是moveToBookmark将光标保留在元素中,但是我不知道该怎么做以解决此问题。

(I have tried incrementing b.start and b.end but that did not work) (我曾尝试增加b.start和b.end,但这没有用)

I know this is hard to explain. 我知道这很难解释。 Any thoughts on this are greatly appreciated. 任何对此的想法都将不胜感激。

try incrementing the bookmark start/end by 2 instead of 1 if you haven't already. 如果还没有,请尝试将书签的开始/结尾增加2,而不是1。 since the underline adds a tag around the mispelled words, that's an additional 2 places that need to be accounted for in the bookmark: 1 for each side of the span. 由于下划线在拼写错误的单词周围添加了标签,因此在书签中需要考虑另外2个位置:跨度的每一侧为1。

Can you get yourself out of the element by grabbing its parent? 您能否通过抓住它的父元素来摆脱困境?

this.parentNode.moveToBookmark(b);

Or something like that. 或类似的东西。

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

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