TinyMCE 中的自定义 URL 转换器逻辑

发布于 2024-11-30 05:12:38 字数 632 浏览 2 评论 0原文

使用 TinyMCE 可以定义自定义 URL 转换器逻辑,如本页中所定义。使用 url_converter 回调,您可以定义一个处理 URL 转换的 JavaScript 函数。该文档提到,在自定义代码中,您可以调用默认的 ConvertURL 函数,以在某些情况下依靠默认逻辑。但是,调用此函数似乎会依次创建对自定义函数的调用并创建无限循环。要么文档错误,要么我实施不正确,有什么想法吗?

这是我目前正在使用的部分内容:

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"
});

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 calls 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"
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘虞初梦 2024-12-07 05:12:38

解决方案似乎是对 ConvertURL 函数的破解:

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);
    ......
}

现在,当您对convertURL进行自定义调用时,您可以为
最后一个(添加的)参数“x”。这会阻止您的自定义方法
当进程起源时被调用。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文