我正在尝试查看我的tinyMCE在写作时是否有内容,如果是或不设置标志(我正在使用AngularJS)。所以这是我用于微小的代码:
$scope.tinyHasContent = false;
tinymce.init({
selector: "#elm1",
height: 400,
language:'it',
plugins: [
"advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
"searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
"save table contextmenu directionality emoticons template paste textcolor"
],
content_css: "css/partials/content.css",
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media fullpage",
style_formats: [
{title: 'Bold text', inline: 'b'},
{title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
{title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
{title: 'Example 1', inline: 'span', classes: 'example1'},
{title: 'Example 2', inline: 'span', classes: 'example2'},
{title: 'Table styles'},
{title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
],
setup : function(ed){
ed.on('NodeChange', function(e){
if(ed.getContent() != '' || ed.getContent() != undefined || ed.getContent() != null) {
$scope.tinyHasContent = true;
console.log('the content ' + ed.getContent() + " " + $scope.tinyHasContent);
} else {
$scope.tinyHasContent = false;
console.log('the content ' + ed.getContent() + " " + $scope.tinyHasContent);
}
});
}
});
简单地说,在输入时我可以看到日志我在写什么。但问题是,即使在init上也总是有内容,因为它在日志中总是返回$ scope.tinyHasContent = true。怎么可能?
总而言之,这就是我应该做的事情:
<div ng-if="tinyHasContent == false">
<p>Hello</p>
</div>
但实际上它不起作用
答案 0 :(得分:0)
即使你没有输入任何内容,public class Destroyable : MonoBehaviour
{
public void DestroyMe()
{
Destroy(gameObject);
}
}
也会返回 - 默认的根块元素(即段落)。这就是ed.getContent()
永远为真的原因。
要验证这一点,您可能需要将tinyHasContent
打印到控制台。