diff --git a/www/code/inner.js b/www/code/inner.js index e3e939a9a..545d954e4 100644 --- a/www/code/inner.js +++ b/www/code/inner.js @@ -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; }); diff --git a/www/common/sframe-common-codemirror.js b/www/common/sframe-common-codemirror.js index 5ae5a4246..bedaa9191 100644 --- a/www/common/sframe-common-codemirror.js +++ b/www/common/sframe-common-codemirror.js @@ -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); };