add 'remove authorcolors' button

pull/1/head
stoppegp 5 years ago
parent 45b5eb7cac
commit 8696ecc692

@ -300,6 +300,20 @@ define([
var previewPane = mkPreviewPane(editor, CodeMirror, framework, isPresentMode);
var markdownTb = mkMarkdownTb(editor, framework);
var $removeAuthorColorsButton = framework._.sfCommon.createButton('removeauthorcolors', true, {icon: 'fa-paint-brush', title: 'Autorenfarben entfernen'});
framework._.toolbar.$rightside.append($removeAuthorColorsButton);
$removeAuthorColorsButton.click(function() {
selfrom = editor.getCursor("from");
selto = editor.getCursor("to");
if (selfrom == selto) {
editor.getAllMarks().forEach(marker => marker.clear());
} else {
editor.findMarks(selfrom, selto).forEach(marker => marker.clear());
}
framework.localChange();
});
var authormarksLocal = [];
var authormarksUpdate = [];
var $print = $('#cp-app-code-print');
@ -352,7 +366,7 @@ define([
// author marks will be updated in onChange-Handler
authormarksUpdate = newContent.authormarks;
CodeMirror.contentUpdate(newContent);
CodeMirror.contentUpdate(newContent, authormarksUpdate, authormarksLocal);
previewPane.draw();
});
@ -372,6 +386,7 @@ define([
}
});
content.authormarks = authormarks;
authormarksLocal = authormarks.slice();
return content;
});

@ -418,12 +418,12 @@ define([
exp.contentUpdate = function (newContent) {
exp.contentUpdate = function (newContent, authormarksUpdate, authormarksLocal) {
var oldDoc = canonicalize(editor.getValue());
var remoteDoc = newContent.content;
// setValueAndCursor triggers onLocal, even if we don't make any change to the content
// and it may revert other changes (metadata)
if (oldDoc === remoteDoc) { return; }
if (oldDoc === remoteDoc && authormarksUpdate == authormarksLocal) { return; }
exp.setValueAndCursor(oldDoc, remoteDoc);
};

Loading…
Cancel
Save