如何防止 CKEditor 将 URL 括在引号中?
How can I prevent CKEditor from enclosing URLs in quotes?
由于非常具体的要求,我需要防止 CKEditor 重写 URL 周围带有引号的链接。例如,如果我输入:
<a href=TEST123>TEST123</a>
CKEditor 将其重写为:
<a href="TEST123">TEST123</a>
我目前在我的发行版中有以下插件,尽管添加或删除不同的插件来满足此要求不会有问题:
basicstyles, button, clipboard, dialog, dialogui, enterkey,
entities, fakeobjects, floatingspace, indent, indentlist,
link, list, resize, sourcearea, toolbar, undo, wysiwygarea
在我被告知这是一个多么糟糕的想法之前(你在这里向合唱团布道),请知道这是对 Keyora 网络平台的非常具体的实现的要求。我无法绕过这个要求,因为它已经被编译成其他人的代码。我只需要以某种方式让它工作。有什么办法可以用 CKEditor 做到这一点吗?
谢谢!
我知道怎么做了。诀窍是将 basicWriter 函数(位于 /ckeditor/core/htmlparser/basicwriter.js)复制到您的 /config.js 文件中并对其应用一个小的自定义,如下所示:
原创
CKEDITOR.htmlParser.basicWriter = CKEDITOR.tools.createClass( {
...
this._.output.push( ' ', attName, '="', attValue, '"' );
...
} );
自定义
CKEDITOR.htmlParser.basicWriter = CKEDITOR.tools.createClass( {
...
if ( attName == 'href' ) {
this._.output.push( ' ', attName, '=', attValue, '' );
} else {
this._.output.push( ' ', attName, '="', attValue, '"' );
}
...
} );
这可以防止自动环绕 URL 时使用引号。同样,这会破坏几乎所有有用的应用程序的 CKEditor,因此我强烈建议在 几乎 任何情况下都不要这样做。
尽管这是不好的做法,但将其添加到 config.js 而不是自定义核心 CKEditor 代码本身至少可以让您轻松回滚自定义。
由于非常具体的要求,我需要防止 CKEditor 重写 URL 周围带有引号的链接。例如,如果我输入:
<a href=TEST123>TEST123</a>
CKEditor 将其重写为:
<a href="TEST123">TEST123</a>
我目前在我的发行版中有以下插件,尽管添加或删除不同的插件来满足此要求不会有问题:
basicstyles, button, clipboard, dialog, dialogui, enterkey,
entities, fakeobjects, floatingspace, indent, indentlist,
link, list, resize, sourcearea, toolbar, undo, wysiwygarea
在我被告知这是一个多么糟糕的想法之前(你在这里向合唱团布道),请知道这是对 Keyora 网络平台的非常具体的实现的要求。我无法绕过这个要求,因为它已经被编译成其他人的代码。我只需要以某种方式让它工作。有什么办法可以用 CKEditor 做到这一点吗?
谢谢!
我知道怎么做了。诀窍是将 basicWriter 函数(位于 /ckeditor/core/htmlparser/basicwriter.js)复制到您的 /config.js 文件中并对其应用一个小的自定义,如下所示:
原创
CKEDITOR.htmlParser.basicWriter = CKEDITOR.tools.createClass( {
...
this._.output.push( ' ', attName, '="', attValue, '"' );
...
} );
自定义
CKEDITOR.htmlParser.basicWriter = CKEDITOR.tools.createClass( {
...
if ( attName == 'href' ) {
this._.output.push( ' ', attName, '=', attValue, '' );
} else {
this._.output.push( ' ', attName, '="', attValue, '"' );
}
...
} );
这可以防止自动环绕 URL 时使用引号。同样,这会破坏几乎所有有用的应用程序的 CKEditor,因此我强烈建议在 几乎 任何情况下都不要这样做。
尽管这是不好的做法,但将其添加到 config.js 而不是自定义核心 CKEditor 代码本身至少可以让您轻松回滚自定义。