自定义格式在 'wysiwyg additional options' 中不起作用
Custom Format not working in 'wysiwyg additional options'
我使用的是最新的 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 编辑器中得到的是格式下拉列表,里面没有任何自定义格式。
有人知道如何解决吗?我需要添加自定义格式以将 class 添加到文本中,例如。图片标题,body 文字等
在查看 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'}}
}
}, });
我希望如果其他人也面临这个问题,你可以看看这是否为你解决了。
我使用的是最新的 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 编辑器中得到的是格式下拉列表,里面没有任何自定义格式。
有人知道如何解决吗?我需要添加自定义格式以将 class 添加到文本中,例如。图片标题,body 文字等
在查看 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'}}
}
}, });
我希望如果其他人也面临这个问题,你可以看看这是否为你解决了。