Custom URL converter logic in TinyMCE
Its possible with TinyMCE to define custom URL converter logic as defined in this page. Using the url_converter
callback you can define a JavaScript function that will handle URL conversions. The documentation mentions that within your custom code you are able to make c开发者_运维百科alls to the default convertURL function to fall back on the default logic in certain cases. However, it appears that making calls to this function in turn creates calls to the custom function and creates an infinite loop. Either the documentation is wrong or I'm implementing incorrectly, any ideas?
This is a partial of what i'm using at the moment:
function myCustomURLConverter(url, node, on_save) {
// just calls myCustomURLConverter again
var url = tinyMCE.activeEditor.Editor.prototype.convertURL(url, node, on_save);
}
tinyMCE.init({
urlconverter_callback : "myCustomURLConverter"
});
It seemes the solution is a hack onto the convertURL function:
convertURL : function(u, n, e, x) {
var t = this, s = t.settings;
// Use callback instead
if (!x && s.urlconverter_callback)
return t.execCallback('urlconverter_callback', u, e, true, n);
......
}
Now, when you make your custom call to convertURL, you supply true for the last (added) parameter, 'x'. This stops your custom method from getting called when it was where the process originated.
精彩评论