zotero/resource/tinymce/plugins/code/plugin.js
Dan Stillman dc04a1231c Upgrade to TinyMCE 4.5.1
- New flat theme (with padding tightened a bit from the default to fit
  in right-hand pane)
- Adds search/replace within notes
- Adds URL autolinking
- Image pasting/dragging is now properly disallowed (though TinyMCE 4
  has hooks that may allow us to actually support this by automatically
  creating attachments)
- New blockquote style with color bar
- Replaces custom context menu on link click with built-in version

 To-do:

- Fix display of pop-ups, which are now modal dialogs within the note
  frame instead of pop-up windows, to stay fully within the frame
- Localize (more important now that there are tooltips)
- Support image dragging
- Update elements list for HTML5, for better drag-and-drop?
- Move directionality control to context menu instead of taking up
  toolbar space?
- Evaluate other plugins for potential inclusion
- Show additional controls in separate note window?
- Fix opacity of text in tooltips

Closes #451, closes #421
2016-12-25 23:19:49 -05:00

60 lines
No EOL
1.5 KiB
JavaScript

/**
* plugin.js
*
* Released under LGPL License.
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
*
* License: http://www.tinymce.com/license
* Contributing: http://www.tinymce.com/contributing
*/
/*global tinymce:true */
tinymce.PluginManager.add('code', function(editor) {
function showDialog() {
var win = editor.windowManager.open({
title: "Source code",
body: {
type: 'textbox',
name: 'code',
multiline: true,
minWidth: editor.getParam("code_dialog_width", 600),
minHeight: editor.getParam("code_dialog_height", Math.min(tinymce.DOM.getViewPort().h - 200, 500)),
spellcheck: false,
style: 'direction: ltr; text-align: left'
},
onSubmit: function(e) {
// We get a lovely "Wrong document" error in IE 11 if we
// don't move the focus to the editor before creating an undo
// transation since it tries to make a bookmark for the current selection
editor.focus();
editor.undoManager.transact(function() {
editor.setContent(e.data.code);
});
editor.selection.setCursorLocation();
editor.nodeChanged();
}
});
// Gecko has a major performance issue with textarea
// contents so we need to set it when all reflows are done
win.find('#code').value(editor.getContent({source_view: true}));
}
editor.addCommand("mceCodeEditor", showDialog);
editor.addButton('code', {
icon: 'code',
tooltip: 'Source code',
onclick: showDialog
});
editor.addMenuItem('code', {
icon: 'code',
text: 'Source code',
context: 'tools',
onclick: showDialog
});
});