【发布时间】:2016-04-25 03:43:21
【问题描述】:
我正在使用 Clojurescript 开发单页应用程序,并且我想将 TinyMCE 用作某些领域的 WYSIWYG 编辑器。为了空间效率,我想最终在高级模式下使用 google clojure 编译器来缩小项目。由于 tinymce dev javascript 文件似乎不适合用作外部文件,因此我不得不自己编写。
有一个特定的函数调用我无法开始工作。在clojurescript中,我调用:
(.setContent (.get js/tinymce id) cont)
我想它会编译成这样的:
tinymce.get(id).setContent(cont);
我在我的 externs 中尝试了许多不同的函数定义,但我一直收到错误:
TypeError: tinymce.get(...).Tl is not a function
这告诉我 setContent 被编译器掩盖了。我当前的外部文件如下所示:
//all seems to be well here...
var tinymce;
tinymce.get = function(name){};
tinymce.remove = function(node){};
tinymce.init = function(editor){};
tinymce.on = function(name, callback, prepend, extra){};
//tinymce setContent attempts
var tinymce.Editor;
tinymce.Editor.prototype.setContent = function(content){};
tinymce.Editor.setContent = function(content){};
tinymce.get(name).setContent = function(content){};
tinymce.get(name).prototype.setContent = function(content){};
var Editor;
Editor.prototype.setContent = function(content){};
Editor.setContent = function(content){};
目前这是一种将所有东西都扔到墙上然后看什么东西的尝试。 get(name) 返回的对象应该在命名空间 tinymce.Editor 中。
是否有适当的方法来编写外部函数来捕获这些链式函数调用?或者有没有办法重写第一个代码 sn-p 以便我的外部人员正确保留函数名称?提前致谢。
【问题讨论】:
标签: javascript interop clojurescript