tinymceのFAQは、カスタムファイルを参照してエディターのデフォルトのフォントスタイルを変更する方法を説明しています。content_css
ただし、プログラムでエディターのフォントスタイルをその場で変更したいと思います。何か案は?ありがとう。
これは可能ですが、ある程度の知識が必要です。
次のようなものを呼び出す必要があります
self.switchStyle(url, ed);
switchStyle はどこですか
// url is the url to the stylesheet file to be added to the editor iframes head
// ed is the editor object or editor id
switchStyle: function(url, ed) {
if (typeof ed != 'object') {
ed = tinymce.get(ed);
}
//replace the custom content_css if set
var url_to_replace = ed.getParam('content_css');
var doc = ed.getDoc();
var $doc = $(doc);
var sheets_urls = [];
if (url_to_replace){
sheets_urls.push(url_to_replace);
}
// remove all stylesheets from sheets_urls
$doc.find('link').each(function() {
if (tinymce.inArray(sheets_urls, $(this).attr('href').split('?')[0]) !== -1) {
$(this).remove();
}
});
var link = doc.createElement('link');
link.type = 'text/css';
link.rel = 'stylesheet';
link.href = url;
// setstylesheet
$doc.find('head:first').append(link);
},