add 'remove authorcolors' button
This commit is contained in:
parent
45b5eb7cac
commit
8696ecc692
@ -300,6 +300,20 @@ define([
|
|||||||
var previewPane = mkPreviewPane(editor, CodeMirror, framework, isPresentMode);
|
var previewPane = mkPreviewPane(editor, CodeMirror, framework, isPresentMode);
|
||||||
var markdownTb = mkMarkdownTb(editor, framework);
|
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 authormarksUpdate = [];
|
||||||
|
|
||||||
var $print = $('#cp-app-code-print');
|
var $print = $('#cp-app-code-print');
|
||||||
@ -352,7 +366,7 @@ define([
|
|||||||
// author marks will be updated in onChange-Handler
|
// author marks will be updated in onChange-Handler
|
||||||
authormarksUpdate = newContent.authormarks;
|
authormarksUpdate = newContent.authormarks;
|
||||||
|
|
||||||
CodeMirror.contentUpdate(newContent);
|
CodeMirror.contentUpdate(newContent, authormarksUpdate, authormarksLocal);
|
||||||
previewPane.draw();
|
previewPane.draw();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -372,6 +386,7 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
content.authormarks = authormarks;
|
content.authormarks = authormarks;
|
||||||
|
authormarksLocal = authormarks.slice();
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -418,12 +418,12 @@ define([
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
exp.contentUpdate = function (newContent) {
|
exp.contentUpdate = function (newContent, authormarksUpdate, authormarksLocal) {
|
||||||
var oldDoc = canonicalize(editor.getValue());
|
var oldDoc = canonicalize(editor.getValue());
|
||||||
var remoteDoc = newContent.content;
|
var remoteDoc = newContent.content;
|
||||||
// setValueAndCursor triggers onLocal, even if we don't make any change to the content
|
// setValueAndCursor triggers onLocal, even if we don't make any change to the content
|
||||||
// and it may revert other changes (metadata)
|
// and it may revert other changes (metadata)
|
||||||
if (oldDoc === remoteDoc) { return; }
|
if (oldDoc === remoteDoc && authormarksUpdate == authormarksLocal) { return; }
|
||||||
exp.setValueAndCursor(oldDoc, remoteDoc);
|
exp.setValueAndCursor(oldDoc, remoteDoc);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user