-
Notifications
You must be signed in to change notification settings - Fork 1
/
plugin.js
54 lines (47 loc) · 1.38 KB
/
plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
* plugin.js
*
* Copyright 2013 Web Power, www.webpower.nl
* @author Arjan Haverkamp
*/
/*jshint unused:false */
/*global tinymce:true */
tinymce.PluginManager.requireLangPack('codemirror');
tinymce.PluginManager.add('codemirror', function(editor, url) {
function showSourceEditor() {
// Insert caret marker
editor.focus();
editor.selection.collapse(true);
editor.selection.setContent('<span class="CmCaReT" style="display:none">�</span>');
// Open editor window
var win = editor.windowManager.open({
title: 'HTML source code',
url: url + '/source.html',
width: editor.getParam("code_dialog_width", Math.max(Math.min(tinymce.DOM.getViewPort().w - 50, 800),450)),
height: editor.getParam("code_dialog_height", Math.min(tinymce.DOM.getViewPort().h - 200, 550)),
resizable : true,
maximizable : true,
buttons: [
{ text: 'Ok', subtype: 'primary', onclick: function(){
var doc = document.querySelectorAll('.mce-container-body>iframe')[0];
doc.contentWindow.submit();
win.close();
}},
{ text: 'Cancel', onclick: 'close' }
]
});
};
// Add a button to the button bar
editor.addButton('code', {
title: 'Source code',
icon: 'code',
onclick: showSourceEditor
});
// Add a menu item to the tools menu
editor.addMenuItem('code', {
icon: 'code',
text: 'Source code',
context: 'tools',
onclick: showSourceEditor
});
});