问题描述
限时送ChatGPT账号..TinyMCE4 文档目前令人沮丧.我有一个与 Ruby on Rails 兼容的插入图像插件,但它依赖于已弃用的 tiny_mce_popup.js.没有关于我应该如何更新插件以规避使用该文件的信息.
TinyMCE4 documentation is currently dismal. I have an insert image plugin compatible with Ruby on Rails but it relies on the deprecated tiny_mce_popup.js. There's no information for how I should update a plugin to circumvent use of that file.
推荐答案
TinyMCE 3 依赖 tiny_mce_popup.js 在父级和对话之间交换变量.TinyMCE 4 取消了 dialog.htm 和 tiny_mce_popup.js
TinyMCE 3 was reliant on tiny_mce_popup.js for exchanging variables between the parent and dialogue. TinyMCE 4 does away with dialog.htm and with tiny_mce_popup.js
如果你看看 图片插件,下面editor.windowManager.open
可以看到对话框是单独通过JS创建的.这消除了通过 opener
对父变量进行愚蠢访问的需要.如果可以,请坚持使用此模板方法.
If you have a look at the image plugin, following editor.windowManager.open
you can see the dialogue is created through JS alone. This eliminates the need for goofy access to parent variables through opener
. If you can, stick with this template method.
我选择坚持使用 dialog.htm,但我是从 rails 提供的,所以我不会处理与 JS 交换表单 auth_token 的问题.如果你这样做,请记住插入你的内容应该来自插件而不是你的对话.这是我的简单图片上传器:
I chose to stick with dialog.htm but I served it from rails so I wouldn't have deal with exchanging the form auth_token with JS. If you do this, remember that inserting your content should come from the plugin and not from your dialogue. This is my simple image uploader :
tinymce.PluginManager.add('railsupload', function(editor, url) {
var win, data, dom = editor.dom
// Add a button that opens a window
editor.addButton('railsupload', {
icon: 'image',
tooltip: 'Insert image',
onclick: showDialog
});
function showDialog() {
win = editor.windowManager.open({
title: 'Insert image',
name: 'railsupload',
url: '/attachments/tinymce?owner_type=' + editor.settings.owner_type + '&owner_id=' + editor.settings.owner_id,
width: 200,
height: 220,
bodyType: 'tabpanel',
buttons: [{
text: 'Insert',
onclick: submitForm
}]
});
}
function submitForm() {
editor.insertContent("<img src=\"" + self.frames[1].document.img_url + "\" />")
win.close()
}
});
您需要一个 rails 附件控制器,并且需要通过 url 传递您的附件初始化参数.如果我在 gem 中构建它,它将与 tinymce-rails 兼容,我会更新此答案.
You'll need a rails attachments controller and you'll need to pass your attachment init params through the url. If I build this out in a gem, it will be compatible with tinymce-rails and I'll update this answer.
更新:TinyMCE 现在有关于从 3.x 迁移的页面:http://www.tinymce/wiki.php/Tutorial:Migration_guide_from_3.x
Update: TinyMCE now has this page on migrating from 3.x: http://www.tinymce/wiki.php/Tutorial:Migration_guide_from_3.x
这篇关于我应该如何使用 tiny_mce_popup.js 为版本 4 更新 TinyMCE 插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论