Json TinyMCE模板不';行不通
我已经按照中所述配置了TinyMCE编辑器 我希望他们能展示出来。但我收到一条消息,其中包含“未定义模板” 当我指定与对象相同的项时,模板插入工作正常:Json TinyMCE模板不';行不通,json,tinymce,angular-ui,Json,Tinymce,Angular Ui,我已经按照中所述配置了TinyMCE编辑器 我希望他们能展示出来。但我收到一条消息,其中包含“未定义模板” 当我指定与对象相同的项时,模板插入工作正常: $scope.tinymceOptions = { plugins: 'template', templates: [ {title: 'test', description: 'test', content: 'test'}, {title: 'test 2', description: 'te
$scope.tinymceOptions = {
plugins: 'template',
templates: [
{title: 'test', description: 'test', content: 'test'},
{title: 'test 2', description: 'test', content: 'test 2'}
]
}
从远程URL加载TinyMCE模板的正确方法是什么
UPD.我在JSON.parse()中发现了一个异常(在Google Chrome中)
EvalError:拒绝将字符串作为JavaScript求值,因为'safe-eval'
不是以下内容安全策略指令中允许的脚本源:脚本src'self'
。ateval
(本机)atObject.parse
您的不允许JS评估,因为它不安全。您可以将'safe-eval'
添加到您的CSP中,模板加载将起作用:
<!-- Chrome 25+; FireFox 23+; Safari 7+ -->
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-eval'"/>
<!-- FireFox 4+; IE 10+ (not fully) -->
<meta http-equiv="X-Content-Security-Policy" content="xhr-src 'self' 'unsafe-eval'"/>
<!-- Chrome 14+; Safari 6+ -->
<meta http-equiv="X-WebKit-CSP" content="script-src 'self' 'unsafe-eval'"/>
您不允许JS评估,因为它不安全。您可以将'safe-eval'
添加到您的CSP中,模板加载将起作用:
<!-- Chrome 25+; FireFox 23+; Safari 7+ -->
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-eval'"/>
<!-- FireFox 4+; IE 10+ (not fully) -->
<meta http-equiv="X-Content-Security-Policy" content="xhr-src 'self' 'unsafe-eval'"/>
<!-- Chrome 14+; Safari 6+ -->
<meta http-equiv="X-WebKit-CSP" content="script-src 'self' 'unsafe-eval'"/>
您使用哪个版本?勾选@BasvanStein I use TinyMCE 4.2.8您使用哪个版本?在BasvanStein检查时,我使用TinyMCE 4.2.8
$scope.tinymceOptions = {
plugins: 'template',
templates: [
{title: 'test', description: 'test', content: 'test'},
{title: 'test 2', description: 'test', content: 'test 2'}
]
}
<!-- Chrome 25+; FireFox 23+; Safari 7+ -->
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-eval'"/>
<!-- FireFox 4+; IE 10+ (not fully) -->
<meta http-equiv="X-Content-Security-Policy" content="xhr-src 'self' 'unsafe-eval'"/>
<!-- Chrome 14+; Safari 6+ -->
<meta http-equiv="X-WebKit-CSP" content="script-src 'self' 'unsafe-eval'"/>