나중에 동적으로 바꿀 html 코드에 자리 표시자를 삽입하려고합니다. 지금까지 나는 코드를 삽입 할 수 있었고 TinyMCE는 태그를 인식하지만 id 속성을 추가하려고하면 알 수없는 이유로 속성이 제거됩니다. 나는 대부분의 추가 옵션을 시도했지만 아무 것도 작동하지 않는 것 같습니다.TinyMCE에서 사용자 정의 태그의 속성을 제거하는 중
현재 설정 :
extended_valid_elements : "module[id]",
valid_children : "module[img]",
custom_elements : "module",
(코드를 연속적 삽입) 버튼을 작성하는 코드 : 당신이 알 수 있듯이
setup : function(ed) {
// Add a custom button
ed.addButton("module", {
title : "Module",
image : "images/app-x-php-icon.png",
onclick : function() {
ed.focus();
var options = document.getElementById('rendermcemods').innerHTML+"";
var optionList = options.split('|');
var name=prompt("Please enter module name out of: "+options,optionList[0]);
for(var i=0;i<optionList.length;i++){
if(optionList[i] == name){
var patt=new RegExp('<module id="'+name+'">.*</module>','ig');
var content = '<module id="'+name+'"><img src="images/app-x-php-icon.png" /></module>';
//alert(content);
if(! patt.test(ed.getContent())){
ed.execCommand('mceInsertContent', false,content);
}
}
}
}
});
}
는, 내가 사용하는 삽입하기 전에 경고, 거기에 내용이 올바른지 확인하려면 ... 버튼을 사용하여 코드를 삽입 한 다음 html을 보면, 이것이 내가 얻은 것입니다.
<module><img src=images/app-x-php-icon.png" alt="" /></module>
누구든지이 문제를 해결하는 방법을 알고 있습니까?
업데이트 : TinyMCE에 대한
전체 설정 설정 :
// General options
mode : "none",
theme : "advanced",
plugins : "autolink,lists,spellchecker,pagebreak,style,layer,table,\n\
save,advhr,advimage,advlink,emotions,iespell,inlinepopups,\n\
insertdatetime,media,searchreplace,print,contextmenu,paste,\n\
directionality,fullscreen,noneditable,visualchars,\n\
nonbreaking,xhtmlxtras",
// Theme options
theme_advanced_buttons1 : "fullscreen,help,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect,|,module",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,code,|,insertdate,inserttime,|,forecolor,backcolor",
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,ltr,rtl,|,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,blockquote,|,insertfile,insertimage",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
// Skin options
skin : "o2k7",
skin_variant : "silver",
document_base_url : "http://www.example.com",
content_css : "content.css",
extended_valid_elements : "module[id]",
valid_children : "module[img]",
/*custom_elements : "module", */
// Drop lists for link/image/media/template dialogs
external_link_list_url : "js/generateList.php?A=link",
external_image_list_url : "js/generateList.php?A=image",
media_external_list_url : "js/generateList.php?A=media",
setup : function(ed) {
// Add a custom button
ed.addButton("module", {
title : "Module",
image : "images/app-x-php-icon.png",
onclick : function() {
ed.focus();
var options = document.getElementById('rendermcemods').innerHTML+"";
var optionList = options.split('|');
var name=prompt("Please enter module name out of: "+options,optionList[0]);
for(var i=0;i<optionList.length;i++){
if(optionList[i] == name){
var patt=new RegExp('<module id="'+name+'">.*</module>','ig');
var content = '<module id="'+name+'"><img src="images/app-x-php-icon.png" /></module>';
//alert(content);
if(! patt.test(ed.getContent())){
ed.execCommand('mceInsertContent', false,content);
}
}
}
}
});
}
또 다른 갱신 : 그것은 재미있을 (잘하면 해결하는 데 도움이) TinyMCE에 일 때 id 속성이 제거되지 않는다는 것을 알 수있다 이미로드되어 있으며 이미있는 속성에 대한 기존 코드를 정리해도 제거되지 않습니다.
이것은 작동해야합니다 (또한 로컬로 테스트했습니다). 'custom_elements' 줄없이 시도하십시오. 전체 구성을 게시 할 수 있습니까? –
@Madmartigan 코드가 cutom_elements 라인을 사용하지 않을 때 코드가 다음으로 바뀝니다. '
' – canihavesomecoffeeOK, 전체 구성 및 사용중인 TinyMCE 버전을 게시하십시오. 문제를 재현 할 수있는 방법을 제공 할 수 있다면 문제를 쉽게 해결할 수 있습니다. 내가 말했듯이, 이것은 이미 나에게 잘 작동한다. –