Skip to content

Commit

Permalink
Item14288: fixed editor initialization
Browse files Browse the repository at this point in the history
- implemented highlighting of toolbar based on cursor position
  • Loading branch information
MichaelDaum committed Dec 4, 2017
1 parent 6126dec commit cc3f3c5
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 174 deletions.
1 change: 1 addition & 0 deletions NatEditPlugin/lib/Foswiki/Plugins/NatEditPlugin/NATEDIT.pm
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ sub init {
}
}</script>
HERE

}

# SMELL: see for Foswiki::Plugins::TinyMCEPLugin::_notAvailable
Expand Down
4 changes: 2 additions & 2 deletions NatEditPlugin/locale/NatEditPlugin/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ msgstr "Datum"

#: templates/edit.natedit.tmpl:116 templates/edit.natedit.tmpl:152
msgid "Default"
msgstr "Default"
msgstr "Standard"

#: data/System/NatEditWordHelpText.txt:16
msgid "Documentation"
Expand Down Expand Up @@ -561,7 +561,7 @@ msgstr "kennzeichnet Pflichtfelder"

#: templates/edit.natedit.tmpl:10
msgid "new"
msgstr "Neu"
msgstr "neu"

#: templates/edit.natedit.tmpl:119
msgid "public view access"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ CodemirrorEngine.prototype.parent = BaseEngine.prototype;
function CodemirrorEngine(shell, opts) {
var self = this;

self.shell = shell;
self.shell = self.parent.shell = shell; // SMELL
self.searchState = undefined;
self.opts = $.extend({}, CodemirrorEngine.defaults, self.shell.opts.codemirror, opts);
}
Expand All @@ -51,6 +51,7 @@ CodemirrorEngine.prototype.init = function() {
editorPath = pubUrlPath+'/'+systemWeb+'/CodeMirrorContrib',
dfd = $.Deferred();


$('<link>')
.appendTo('head')
.attr({type : 'text/css', rel : 'stylesheet'})
Expand All @@ -75,6 +76,7 @@ CodemirrorEngine.prototype.init = function() {
CodeMirror.modeURL = editorPath+'/'+'/mode/%N/%N.js';

$.when(
self.parent.init(),
self.shell.getScript(editorPath+"/addon/mode/loadmode.js"),
self.shell.getScript(editorPath+"/addon/fold/foldcode.js"),
self.shell.getScript(editorPath+"/addon/fold/foldgutter.js"),
Expand All @@ -85,7 +87,7 @@ CodemirrorEngine.prototype.init = function() {
self.shell.getScript(editorPath+"/addon/dialog/dialog.js"),
self.shell.getScript(editorPath+"/widgets/widgets.js"),
self.shell.getScript(editorPath+"/keymap/vim.js"),
self.shell.preloadDialog("searchdialog")
self.shell.preloadTemplate("editdialog", "searchdialog")
).done(function() {

// extend vim mode to make :w and :x work
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,11 @@ RawEngine.prototype.init = function() {
}
});

dfd.resolve(self);
$.when(
self.parent.init()
).done(function() {
dfd.resolve(self);
});

return dfd.promise();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ TinyMCEEngine.prototype.init = function() {
.attr({type : 'text/css', rel : 'stylesheet'})
.attr('href', editorPath + '/wysiwyg.css');

self.shell.getScript(editorPath+'/tinymce/js/tinymce/tinymce.min.js').done(function() {
$.when(
self.parent.init(),
self.shell.getScript(editorPath+'/tinymce/js/tinymce/tinymce.min.js')
).done(function() {

self.opts.tinymce.init_instance_callback = function(editor) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function TinyMCENativeEngine(shell, opts) {
self.shell = shell;
self.opts = $.extend({}, TinyMCENativeEngine.defaults, opts);
self.opts.natedit.showToolbar = false;
self.editor = tinymce.editors[0];
self.editor = tinymce.editors[0]; // SMELL

$.extend(self.shell.opts, self.opts.natedit);
}
Expand All @@ -40,9 +40,8 @@ TinyMCENativeEngine.prototype.initGui = function() {
var self = this, $txtarea = $(self.shell.txtarea);

$txtarea.on("fwSwitchToRaw", function(/*ev, editor*/) {
self.shell.showToolbar().then(function() {
self.shell.toolbar.find(".ui-natedit-switch-to-wysiwyg").show();
});
self.shell.showToolbar();
self.shell.toolbar.find(".ui-natedit-switch-to-wysiwyg").show();
}).on("fwSwitchToWYSIWYG", function() {
self.shell.hideToolbar();
$(document).trigger("resize");
Expand Down
Loading

0 comments on commit cc3f3c5

Please sign in to comment.