2014-10-27 181 views
0

我正在使用Tinymce 4x與現代主題。我允許個人擁有該編輯器的同一副本 ,但只允許其中一個編輯它。我需要禁用tinymce工具欄以防止這些用戶中的一個通過它們。我的編輯工具欄時,我初始化編輯器的樣子:禁用Tinymce工具欄oninit

toolbar1: "newdocument fullpage | bold italic underline strikethrough | alignleft aligncenter 
alignright alignjustify ", 
toolbar2: "cut copy paste | searchreplace | bullist numlist | outdent indent blockquoter", 
toolbar3: "table | hr removeformat | subscript superscript |charmap emoticons|print fullscreen " 

I need to disable toolbar1, toolbar2 and toolbar3 and I try to use : 

/*tinymce.ui.toolbar1.setDisabled = true; for all these bars but it does not work. It seems that 
this is only used for the user created toolbars. 

Also I tried to add listener and then stop the propagation when the toolbar is clicked but also 
it doesn't work 

toolbarElement.addEventListener("click", function(e){ 
     e.stopPropagation(); 
     }); 
     toolbarElement.style.pointerEvents = "none"; 
     } 

Please can someone help me. Thanks in advance for your suggestions. 

回答

0

設置上面<script type="text/javascript" src="tinymce.min.js"></script>它決定toolbar1:值的變量。 "null"可以填充任何不在TinyMCE工具欄名稱中的東西。

<script> 
var tbSet1 = "newdocument fullpage | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify"; 
if(true){tbSet1 = "null";} 
var tbSet2 = "cut copy paste | searchreplace | bullist numlist | outdent indent"; blockquoter"; 
if(true){tbSet2 = "null";} 
var tbSet3 = "table | hr removeformat | subscript superscript |charmap emoticons|print fullscreen "; 
if(true){tbSet3 = "null";} 
</script> 
<script type="text/javascript" src="tinymce.min.js"></script> 
<script type="text/javascript"> 

tinymce.init({ 
    toolbar1: tbSet1 , 
    toolbar2: tbSet2 , 
    toolbar3: tbSet3 

CMIIW

+0

謝謝您的回答「大盤雞」,但它不工作,因爲當我初始化編輯器所花費的空值並將其分配給工具欄。當我有oninit事件時,我需要改變這一點,而不是當init事件:/ – Rose 2014-10-28 09:47:16