Oto plugin Zrobiłem:
Przede wszystkim wewnątrz ckeditor/plugins/
utworzyć nowy folder o nazwie „htmlSource”, wewnątrz niego utworzyć plik o nazwie „plugin.js” i wewnątrz tego pliku wklej poniższy kod:
//-----------------------------Start Plugin Code-------------------------
plugInName = 'htmlSource';
CKEDITOR.plugins.add(plugInName,
{
init: function (editor) {
editor.addCommand('htmlDialog', new CKEDITOR.dialogCommand('htmlDialog'));
editor.ui.addButton(plugInName, {
label: 'Html Source',
icon: 'http://www.example.com/images/btn_html.png',
command: 'htmlDialog'
});
CKEDITOR.dialog.add('htmlDialog', function (editor) {
return {
title: 'Fuente Html',
minWidth: 600,
minHeight: 400,
contents: [
{
id: 'general',
label: 'Settings',
elements:
[
// UI elements of the Settings tab.
{
type: 'textarea',
id: 'contents',
rows: 25,
onShow: function() {
this.setValue(editor.container.$.innerHTML);
},
commit: function (data) { //--I get only the body part in case I paste a complete html
data.contents = this.getValue().replace(/^[\S\s]*<body[^>]*?>/i, "").replace(/<\/body[\S\s]*$/i, "");
}
}
]
}
],
onOk: function() {
var data = {};
this.commitContent(data);
$(editor.container.$).html(data.contents);
},
onCancel: function() {
// console.log('Cancel');
}
};
});
}
});
//--------------------Plugin Code Ends Here--------------------
Proszę zauważyć, że nie jest to parametr zwany ikona gdzie trzeba ustawić adres URL wtyczki przycisk Obraz, ja po prostu umieścić przykładowy adres URL („http://www.example.com/images/btn_html.png”) należy użyć ważnej jednego aby zobaczyć przycisk wtyczki.
Aby ustawić tę wtyczkę w pasku CKEditor, należy skonfigurować go w pliku config.js, na przykład:
CKEDITOR.editorConfig = function (config) {
config.plugins =
'htmlSource,' + //Here is the plugin
'about,' +
'a11yhelp,' +
'basicstyles,' +
'bidi,' +
.....;
config.toolbar = 'Full'; //Add the plugin to the full toolbar
config.toolbar_Full = //Note that our plugin will be the first button in the toolbar
[
['htmlSource', '-', 'Save', 'NewPage', 'Preview', '-', 'Templates'],
['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Print', 'SpellChecker', 'Scayt'],
['Undo', 'Redo', '-', 'Find', 'Replace', '-', 'SelectAll', 'RemoveFormat'],
['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
['BidiLtr', 'BidiRtl'],
'/',
['Bold', 'Italic', 'Underline', 'Strike', '-', 'Subscript', 'Superscript'],
['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote', 'CreateDiv'],
['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
['Link', 'Unlink', 'Anchor'],
['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak'],
'/',
['Styles', 'Format', 'Font', 'FontSize'],
['TextColor', 'BGColor'],
['Maximize', 'ShowBlocks', '-', 'About']
];
};
wiem, że to działa, więc jeśli masz jakieś problemy proszę mi powiedzieć.
Używam trybu inline, więc to było to. Masz pomysł, kiedy będzie dostępny? –
Prawdopodobnie w następnej większej wersji (4.1), czyli za około 3 miesiące. Istnieje jednak szansa, że dodamy go szybciej, jeśli zobaczymy, że społeczność naprawdę tego potrzebuje. Tutaj jest bilet: https://dev.ckeditor.com/ticket/9713 – Reinmar
4.1RC został zwolniony i potrzebujesz wtyczki Sourcedialog – jnoreiga