我正在尝试将 tinymce 从 4 移动到版本 5,并创建了一个新文件,用于向 tinymce 添加工具栏和插件,称为文件管理器。
所以在移动时我在文件管理器的插件文件中做了这个改变
tinymce.PluginManager.add('filemanager', function(editor, url) {
if (typeof fileManager != 'undefined') {
var fileManager = editor.settings.fileManager_path;
} else {
var fileManager = editor.settings.url_converter_scope.baseURI.directory + '/plugins/filemanager/index.cfm'
}
// Add a button that opens a window
editor.ui.registry.addButton('filemanager', {
tooltip: 'Insert From My Files',
icon: 'browse',
onclick: showDialog
});
function showDialog() {
editor.windowManager.open({
url: fileManager,
title: 'My Files Home',
width: Number($(window).innerWidth()) - 40,
height: Number($(window).innerHeight()) - 80
});
}
// Adds a menu item to the tools menu
editor.ui.registry.addMenuItem('filemanager', {
text: 'My Files',
context: 'insert',
icon: 'browse',
onclick: showDialog
});
});
并在 theme.min.js 中出现此错误
Uncaught Error: Errors:
Failed path: (toolbarbutton)
Could not find valid *strict* value for "onAction" in {
"tooltip": "Insert From My Files",
"icon": "browse",
"type": "button"
}
Input object: {
"tooltip": "Insert From My Files",
"icon": "browse",
"type": "button"
}
更新#1
做了一些更改,但仍然是一个错误
tinymce.PluginManager.add('filemanager', function(editor, url) {
var openDialog = function () {
return editor.windowManager.open({
title: 'My Files',
width: Number($(window).innerWidth()) - 40,
height: Number($(window).innerHeight()) - 80,
onSubmit: function (api) {
var data = api.getData();
// Insert content when the window form is submitted
editor.insertContent('Title: ' + data.title);
api.close();
}
});
};
// Add a button that opens a window
editor.ui.registry.addButton('filemanager', {
tooltip: 'Insert From My Files',
icon: 'browse',
onAction: function () {
openDialog();
}
});
// Adds a menu item to the tools menu
editor.ui.registry.addMenuItem('filemanager', {
text: 'My Files',
context: 'insert',
icon: 'browse',
onAction: function() {
openDialog();
}
});
return {
getMetadata: function () {
if (typeof fileManager != 'undefined') {
var fileManager = editor.settings.fileManager_path;
} else {
var fileManager = editor.settings.url_converter_scope.baseURI.directory + '/plugins/filemanager/index.cfm'
}
return {
name: "Upload Files",
url: filemanager
};
}
};
});
我现在得到的错误是这个
Uncaught Error: Errors:
Failed path: (dialog)
Could not find valid *strict* value for "body" in {
"title": "My Files",
"width": 1543,
"height": 302
}
Failed path: (dialog)
Could not find valid *strict* value for "buttons" in {
"title": "My Files",
"width": 1543,
"height": 302
}
Input object: {
"title": "My Files",
"width": 1543,
"height": 302
}