TinyMCE を使用しているため、CSS ファイルをメイン ページではなく TinyMCE iframes ヘッドにロードする必要があります。
これにはcontent_css設定を使用します。TinyMCE のデフォルト CSS を上書きする方法です。
更新: サーバー ファイルや TinyMCE 構成にアクセスしなくても、TinyMCE API にアクセスできます。このオプションを見て、必要な場所にCSS をロードしてください。アクセスできるインターネット/イントラネット上のどこかに CSS ファイルを配置する必要があります。
// Loads a CSS file dynamically into the current document
tinymce.DOM.loadCSS('somepath/some.css');
// Loads a CSS file into the currently active editor instance
tinyMCE.activeEditor.dom.loadCSS('somepath/some.css');
// Loads a CSS file into an editor instance by id
tinyMCE.get('someid').dom.loadCSS('somepath/some.css');
// Loads multiple CSS files into the current document
tinymce.DOM.loadCSS('somepath/some.css,somepath/someother.css');
Update2 : CSS 文字列を iframe ヘッドにロードすることが可能です。これには、次のuserscriptのようなものを使用します。
// ==UserScript==
// @name YOUR_SCRIPT_NAME
// @match http://YOUR_SERVER.COM/YOUR_PATH/*
// ==/UserScript==
var css_to_add = 'p { margin: 10 px; }'; // example
var iframe_id = 'your_editor_id' + '_ifr'; // place your editor id here+'_ifr'
with(document.getElementById(iframe_id).contentWindow) {
var h = document.getElementsByTagName("head");
if (!h.length) return;
var newStyleSheet = document.createElement("style");
newStyleSheet.type = "text/css";
h[0].appendChild (newStyleSheet);
try {
if ( typeof newStyleSheet.styleSheet !== "undefined" ) {
newStyleSheet.styleSheet.cssText = css_to_add;
}
else {
newStyleSheet.appendChild( document.createTextNode ( css_to_add ) );
newStyleSheet.innerHTML = css_to_add;
}
}
catch(e){}
}
コードを名前を付けて保存し、これらの手順に従ってMyCSSFix.user.js
Chrome にインストールします (指定された場所を詳細に編集した後)。