From f388d0d7958b62687b4ac4c80b9751c3d0c04b50 Mon Sep 17 00:00:00 2001 From: Elmar Ludwig <elmar.ludwig@uni-osnabrueck.de> Date: Thu, 9 Nov 2023 11:40:32 +0000 Subject: [PATCH] drop StudipBlockQuote from default toolbar, move text formatting, re #3213 Merge request studip/studip!2265 --- app/views/course/forum/index/_new_entry.php | 2 +- app/views/course/forum/index/_post.php | 2 +- app/views/course/scm/edit.php | 1 + resources/assets/javascripts/cke/builtin-plugins.js | 5 ----- resources/assets/javascripts/cke/classic-editor.js | 7 +++---- resources/assets/javascripts/lib/wysiwyg.js | 13 +++++-------- .../courseware/blocks/CoursewareTextBlock.vue | 2 ++ templates/wiki/edit.php | 3 +-- 8 files changed, 14 insertions(+), 21 deletions(-) diff --git a/app/views/course/forum/index/_new_entry.php b/app/views/course/forum/index/_new_entry.php index 62f0dc46751..54a920b5ac3 100644 --- a/app/views/course/forum/index/_new_entry.php +++ b/app/views/course/forum/index/_new_entry.php @@ -34,7 +34,7 @@ <? endif; ?> <label> - <textarea class="wysiwyg size-l" data-textarea="new_entry" name="content" required tabindex="3" + <textarea class="wysiwyg size-l" data-editor="extraPlugins=StudipBlockQuote" data-textarea="new_entry" name="content" required tabindex="3" placeholder="<?= _('Schreiben Sie hier Ihren Beitrag.') ?>"></textarea> </label> diff --git a/app/views/course/forum/index/_post.php b/app/views/course/forum/index/_post.php index f6e36962939..7b6aaa0faa4 100644 --- a/app/views/course/forum/index/_post.php +++ b/app/views/course/forum/index/_post.php @@ -86,7 +86,7 @@ <!-- Postinginhalt --> <div class="content"> <span data-edit-topic="<?= $post['topic_id'] ?>" <?= $edit_posting == $post['topic_id'] ? '' : 'style="display: none;"' ?>> - <textarea data-textarea="<?= $post['topic_id'] ?>" data-reset="<?= wysiwygReady($post['content_raw']) ?>" name="content" class="wysiwyg"><?= wysiwygReady($post['content_raw']) ?></textarea> + <textarea data-textarea="<?= $post['topic_id'] ?>" data-reset="<?= wysiwygReady($post['content_raw']) ?>" name="content" class="wysiwyg" data-editor="extraPlugins=StudipBlockQuote"><?= wysiwygReady($post['content_raw']) ?></textarea> </span> <span data-show-topic="<?= $post['topic_id'] ?>" data-topic-content="<?= $post['topic_id'] ?>" <?= $edit_posting != $post['topic_id'] ? '' : 'style="display: none;"' ?>> diff --git a/app/views/course/scm/edit.php b/app/views/course/scm/edit.php index 3146dffdec7..ea054c8332e 100644 --- a/app/views/course/scm/edit.php +++ b/app/views/course/scm/edit.php @@ -38,6 +38,7 @@ <?= _('Inhalt') ?> <?= I18N::textarea('content', $scm->content, [ 'class' => 'wysiwyg size-l', + 'data-editor' => 'extraPlugins=FindAndReplace', ]) ?> </label> </fieldset> diff --git a/resources/assets/javascripts/cke/builtin-plugins.js b/resources/assets/javascripts/cke/builtin-plugins.js index 3b285df7deb..71fc3428c2b 100644 --- a/resources/assets/javascripts/cke/builtin-plugins.js +++ b/resources/assets/javascripts/cke/builtin-plugins.js @@ -7,7 +7,6 @@ import CodeBlock from '@ckeditor/ckeditor5-code-block/src/codeblock'; import EasyImagePlugin from '@ckeditor/ckeditor5-easy-image/src/easyimage'; import EssentialsPlugin from '@ckeditor/ckeditor5-essentials/src/essentials'; import FileRepository from '@ckeditor/ckeditor5-upload/src/filerepository'; -import FindAndReplace from '@ckeditor/ckeditor5-find-and-replace/src/findandreplace'; import FontBackgroundColor from '@ckeditor/ckeditor5-font/src/fontbackgroundcolor.js'; import FontColor from '@ckeditor/ckeditor5-font/src/fontcolor.js'; import GeneralHtmlSupport from '@ckeditor/ckeditor5-html-support/src/generalhtmlsupport'; @@ -49,9 +48,7 @@ import Underline from '@ckeditor/ckeditor5-basic-styles/src/underline.js'; import Mathematics from 'ckeditor5-math/src/math'; /* ckeditor elan */ import StudipA11YDialog, { updateVoiceLabel } from '../cke/studip-a11y-dialog/a11y-dialog.js'; -import StudipBlockQuote from '../cke/studip-quote/StudipBlockQuote.js'; import StudipUpload from '../cke/StudipUpload.js'; -import StudipWikiLink from '../cke/wiki-link/wiki-link.js'; import SpecialCharactersSmiley from '../cke/special_characters/SpecialCharactersSmiley.js'; import SpecialCharactersGreek from '../cke/special_characters/SpecialCharactersGreek.js'; @@ -65,7 +62,6 @@ const builtinPlugins = [ BoldPlugin, CodeBlock, EssentialsPlugin, - FindAndReplace, FontColor, FontBackgroundColor, GeneralHtmlSupport, @@ -95,7 +91,6 @@ const builtinPlugins = [ SpecialCharactersMathematical, SpecialCharactersText, Strikethrough, - StudipBlockQuote, StudipUpload, Subscript, Superscript, diff --git a/resources/assets/javascripts/cke/classic-editor.js b/resources/assets/javascripts/cke/classic-editor.js index 0e21c0a21ab..09369f643c4 100644 --- a/resources/assets/javascripts/cke/classic-editor.js +++ b/resources/assets/javascripts/cke/classic-editor.js @@ -15,12 +15,15 @@ ClassicEditor.defaultConfig = { 'redo', 'findAndReplace', '|', + 'heading', 'bold', 'italic', 'underline', 'strikethrough', 'subscript', 'superscript', + 'fontColor', + 'fontBackgroundColor', '|', 'removeFormat', '|', @@ -34,10 +37,6 @@ ClassicEditor.defaultConfig = { 'alignment:right', 'alignment:center', 'alignment:justify', - '-', - 'heading', - 'fontColor', - 'fontBackgroundColor', '|', 'link', 'insertTable', diff --git a/resources/assets/javascripts/lib/wysiwyg.js b/resources/assets/javascripts/lib/wysiwyg.js index 978328bb050..00f453d59f0 100644 --- a/resources/assets/javascripts/lib/wysiwyg.js +++ b/resources/assets/javascripts/lib/wysiwyg.js @@ -2,6 +2,8 @@ * wysiwyg.js - Replace HTML textareas with WYSIWYG editor. */ import parseOptions from './parse_options.js'; +import FindAndReplace from '@ckeditor/ckeditor5-find-and-replace/src/findandreplace'; +import StudipBlockQuote from '../cke/studip-quote/StudipBlockQuote.js'; import WikiLink from '../cke/wiki-link/wiki-link.js'; const wysiwyg = { @@ -131,7 +133,7 @@ function parseEditorOptions(data) { } if (parsed.extraPlugins) { - const pluginMap = { WikiLink }; + const pluginMap = { FindAndReplace, StudipBlockQuote, WikiLink }; result.options.extraPlugins = parsed.extraPlugins.split(',').reduce((memo, plugin) => { return plugin in pluginMap ? [...memo, pluginMap[plugin]] : memo; }, []); @@ -153,12 +155,8 @@ function getToolbarOptions(parsed) { removeItems: [ 'undo', 'redo', - 'findAndReplace', 'strikethrough', 'horizontalLine', - 'insertBlockQuote', - 'splitBlockQuote', - 'removeBlockQuote', ], }; } else if (parsed.toolbar === 'minimal') { @@ -169,15 +167,14 @@ function getToolbarOptions(parsed) { 'underline', 'subscript', 'superscript', + 'fontColor', + 'fontBackgroundColor', '|', 'removeFormat', '|', 'bulletedList', 'numberedList', '|', - 'fontColor', - 'fontBackgroundColor', - '|', 'link', 'math', 'specialCharacters', diff --git a/resources/vue/components/courseware/blocks/CoursewareTextBlock.vue b/resources/vue/components/courseware/blocks/CoursewareTextBlock.vue index f8f18bcd86d..ef351092e29 100644 --- a/resources/vue/components/courseware/blocks/CoursewareTextBlock.vue +++ b/resources/vue/components/courseware/blocks/CoursewareTextBlock.vue @@ -24,6 +24,7 @@ <script> import BlockComponents from './block-components.js'; import blockMixin from '@/vue/mixins/courseware/block.js'; +import FindAndReplace from '@ckeditor/ckeditor5-find-and-replace/src/findandreplace'; import { ClassicEditor, BalloonEditor } from '@/assets/javascripts/chunks/wysiwyg'; import { mapActions } from 'vuex'; @@ -42,6 +43,7 @@ export default { editor: ClassicEditor, editorConfig: { // The configuration of the editor. + extraPlugins: [FindAndReplace], }, }; }, diff --git a/templates/wiki/edit.php b/templates/wiki/edit.php index fab85eb0a93..487c922dc1f 100644 --- a/templates/wiki/edit.php +++ b/templates/wiki/edit.php @@ -11,8 +11,7 @@ <input type="hidden" name="submit" value="true"> <input type="hidden" name="cmd" value="show"> - <br> - <textarea name="body" class="wiki-editor wysiwyg size-l" data-editor="extraPlugins=WikiLink" + <textarea name="body" class="wiki-editor wysiwyg size-l" data-editor="extraPlugins=FindAndReplace,WikiLink" ><?= wysiwygReady($body) ?></textarea> </fieldset> -- GitLab