divタグをCKEditor(別の質問で質問されたように)にドラッグ&ドロップできるものに変換しようとしています。 誰かがスイッチをからの間で切り替えると、どのようにイベントがトリガーされるのか分かりますか?とWYSIWYGモード?CKEditorフック/イベントがソースビューとの切り替え時に起動する
おかげで、
-lony
divタグをCKEditor(別の質問で質問されたように)にドラッグ&ドロップできるものに変換しようとしています。 誰かがスイッチをからの間で切り替えると、どのようにイベントがトリガーされるのか分かりますか?とWYSIWYGモード?CKEditorフック/イベントがソースビューとの切り替え時に起動する
おかげで、
-lony
私はこれがあなたが探しているものだと思います:
CKEDITOR.on('instanceCreated', function(e) {
e.editor.on('mode', function(e){
// Do your stuff here
alert(e.editor.mode);
});
});
あなたが意味する場合は、ソースモードの変更を取得したいが、あなたはこのような何かを試みることができる:
//add this to your CKeditor’s config.js
$('textarea.cke_source').live('keyup', function() {
$(this)
.closest('.cke_wrapper')
.parent()
.parent()
.prev()
.ckeditorGet()
.fire('change');
});
この議論は、同様に役立つかもしれない:ckEditor を希望するものは
あなたはwysiwyg-viewのための偽の要素を作るためのプラグインを書くべきだと思います。
Ckeditorは、交換が必要な要素をfake-elements
で認識できます。
私はあなたのためのスタートを切った。
(function() {
CKEDITOR.plugins.add('myPlugin', {
requires : [ 'fakeobjects' ],
init: function(editor) {
var me = this;
var pluginName = 'myPlugin';
editor.addCommand(pluginName, new CKEDITOR.dialogCommand(pluginName));
editor.addCss(// your custom css for your placeholder here
'div.myPluginElement' +
'{' +
'border: 1px solid #a9a9a9;' +
'width: 70px;' +
'height: 50px;' +
'}'
);
},
afterInit : function(editor) {
var dataProcessor = editor.dataProcessor,
dataFilter = dataProcessor && dataProcessor.dataFilter;
if (dataFilter) {
dataFilter.addRules({
elements : {
div : function(element) {
if (typeof element.attributes['class'] !== 'undefined' && element.attributes['class'].indexOf('myPluginElement') != -1)
return editor.createFakeParserElement(element, 'myPluginElement', 'div', false);
else return;
}
}
});
}
}
});
})();
CKEditorバージョンのonChangeプラグイン:
CKEditorバージョンの内容が変更されるたびに通知(新しいイベント)を取得します。
申し訳ありませんが、多分私は少し正確ではありませんでした。ユーザーがビューを切り替えたときに「何かをする」ことはできません。タグ「
」は、サイズ変更や移動が可能な画像(iFrameなど)に変換する必要があります。そのために、私は "ハックイン"する場所を知る必要があります。 – lony