Custom format remover plugin for CKEditor.

This commit is contained in:
FinnStutzenstein 2018-02-13 12:05:20 +01:00 committed by Emanuel Schütze
parent 1d49121cb6
commit bbd3aa2ec8
3 changed files with 52 additions and 0 deletions

View File

@ -117,6 +117,7 @@ Core:
- Preparations for the SAML plugin; Fixed caching of main views [#3535].
- Removed unnecessary OPTIONS request in config [#3541].
- Added possibility to upload custom fonts for projector and pdf [#3568].
- Use custom format cleanup plugin for CKEditor [#3576].
Mediafiles:
- Fixed reloading of PDF on page change [#3274].

View File

@ -0,0 +1,50 @@
(function () {
'use strict';
angular.module('OpenSlidesApp.core.remove-format-plugin', [
'OpenSlidesApp.core',
])
/*
* Plugin for the CKEditor that hooks into the removeformat plugin
* which is a default plugin enabled by 'cleanup' in the config
* toolbar.
* We change the behavior of the removeformat command here:
* It should not remove any tags and styles, but only the
* 'DISALLOWED_STYLES'. Removeformat traverses through the DOM
* and calles for every element the custom filter down below.
* We change the element and return false, so the removeformat
* plugin does not clean it up.
*/
.factory('OSRemoveFormatPlugin', [
'Editor',
'gettextCatalog',
function (Editor, gettextCatalog) {
var DISALLOWED_STYLES = ['color', 'background-color'];
return {
getPlugin: function () {
return {
init: function (editor) {
editor.addRemoveFormatFilter(function (element) {
_.forEach(DISALLOWED_STYLES, function (style) {
element.removeStyle(style);
});
return false;
});
},
};
},
};
}
])
.run([
'Editor',
'OSRemoveFormatPlugin',
function (Editor, OSRemoveFormatPlugin, gettext) {
Editor.registerPlugin('OSRemoveFormat', OSRemoveFormatPlugin.getPlugin());
}
]);
}());

View File

@ -7,6 +7,7 @@ angular.module('OpenSlidesApp.core.site', [
'OpenSlidesApp.core',
'OpenSlidesApp.core.start',
'OpenSlidesApp.core.csv',
'OpenSlidesApp.core.remove-format-plugin',
'OpenSlidesApp.poll.majority',
'ui.router',
'colorpicker.module',