tinymce - 自定义格式在“所见即所得的附加选项”中不起作用
问题描述
我正在使用最新的 Keystone.js,以下是我的 Keystone.init
var keystone = require('keystone');
keystone.init({
'name': 'Dashboard',
'user model': 'User',
'auto update': true,
'auth': true,
'cookie secret': 'secure string goes here',
views: 'templates/views',
'view engine': 'pug',
'wysiwyg cloudinary images': true,
'wysiwyg additional plugins': 'example, autosave, charmap, table, '
+ 'advlist, anchor, wordcount, preview, fullscreen, importcss, '
+ 'paste',
'wysiwyg additional buttons' : 'undo redo charmap blockquote formatselect styleselect removeformat |'
+ 'example preview fullscreen bodytext',
'wysiwyg additional options': {
default_link_target: '_blank',
paste_as_text: true,
menubar: true, // added to test formats
'style_formats': [
{ title: 'Red text', inline: 'span', styles: { color: '#ff0000' } }
],
formats: {
bodytext: {block : 'p', attributes : {title : 'bodyText'}, styles : {color : 'grey'}}
}
}, });
keystone.set('routes', require('./routes'));
keystone.import('models');
keystone.set('nav', {
'projects': ['Projects', 'Keywords'],
});
keystone.start();
我在 TinyMCE 编辑器中得到的是格式下拉菜单,其中没有任何自定义格式。
有谁知道如何解决它?我需要添加一个自定义格式来为文本添加一个类,例如。图片标题,正文等
在查看 Keystone.js 文件后,我发现它使用的是 TinyMCE 版本 4.4.3,而 Keystone 版本是 4.0 RC。
解决方案
所以,我找到了解决方案,这是一个愚蠢的错误, style_formats: 应该出现在引号中:
'wysiwyg additional options': {
default_link_target: '_blank',
paste_as_text: true,
menubar: true, // added to test formats
style_formats: [
{ title: 'Red text', inline: 'span', styles: { color: '#ff0000' } }
],
formats: {
bodytext: {block : 'p', attributes : {title : 'bodyText'}, styles : {color : 'grey'}}
}
}, });
我希望如果其他人也面临这个问题,您可以检查这是否可以为您解决。
推荐阅读
- javascript - Javascript:在函数调用中传递有效参数,然后一转未定义
- angular - 在角度中使用“retrywhen”打印成功响应的最佳方法
- reactjs - 404 用于包含语言环境的所有路由 - NextJS 和 next-i18next
- python - while 循环:“无输出”问题
- python - 如何解决 pandas.to_datetime 与 python 内置日期时间的冲突?
- java - 如何从回收站视图和 Firebase 数据库中删除项目?
- android - EditText 不在布局编辑器中呈现
- javascript - ASP.NET - 将值从 JavaScript 发送到 Sql Server 数据库
- sql - 由于如果不存在,在创建表时缺少或无效的选项
- arduino - 代码上传导致“USB 设备出现故障”Windows 错误