From 82eae0fe999c92711776fbd03a432bb08ba86df5 Mon Sep 17 00:00:00 2001 From: iszmais Date: Fri, 17 Jan 2025 15:37:22 +0100 Subject: [PATCH] Add CO-Entrypoint for custom functions --- .../actions/paragraph-action-types.js | 3 ++- .../components/paragraph/ui/paragraph-ui.js | 20 ++++++++++++------- .../class.ilPCParagraphEditorGUI.php | 2 +- .../COPage/classes/class.ilPageObjectGUI.php | 8 ++++++-- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/components/ILIAS/COPage/Editor/js/src/components/paragraph/actions/paragraph-action-types.js b/components/ILIAS/COPage/Editor/js/src/components/paragraph/actions/paragraph-action-types.js index 5f405f262beb..0120caed1c0c 100755 --- a/components/ILIAS/COPage/Editor/js/src/components/paragraph/actions/paragraph-action-types.js +++ b/components/ILIAS/COPage/Editor/js/src/components/paragraph/actions/paragraph-action-types.js @@ -12,7 +12,7 @@ * https://www.ilias.de * https://github.com/ILIAS-eLearning * - ******************************************************************** */ + *********************************************************************/ const ACTIONS = { @@ -57,5 +57,6 @@ const ACTIONS = { SPLIT_PARAGRAPH: 'par.split', MERGE_PREVIOUS: 'merge.previous', SECTION_CLASS: 'sec.class', // section format + CUSTOM: 'custom', }; export default ACTIONS; diff --git a/components/ILIAS/COPage/Editor/js/src/components/paragraph/ui/paragraph-ui.js b/components/ILIAS/COPage/Editor/js/src/components/paragraph/ui/paragraph-ui.js index 66ea4a6a4f64..a8998d8cae70 100755 --- a/components/ILIAS/COPage/Editor/js/src/components/paragraph/ui/paragraph-ui.js +++ b/components/ILIAS/COPage/Editor/js/src/components/paragraph/ui/paragraph-ui.js @@ -1,9 +1,3 @@ -import ACTIONS from '../actions/paragraph-action-types.js'; -import PAGE_ACTIONS from '../../page/actions/page-action-types.js'; -import TinyWrapper from './tiny-wrapper.js'; -import TINY_CB from './tiny-wrapper-cb-types.js'; -import AutoSave from './auto-save.js'; - /** * This file is part of ILIAS, a powerful learning management system * published by ILIAS open source e-Learning e.V. @@ -18,7 +12,13 @@ import AutoSave from './auto-save.js'; * https://www.ilias.de * https://github.com/ILIAS-eLearning * - ******************************************************************** */ + *********************************************************************/ + +import ACTIONS from '../actions/paragraph-action-types.js'; +import PAGE_ACTIONS from '../../page/actions/page-action-types.js'; +import TinyWrapper from './tiny-wrapper.js'; +import TINY_CB from './tiny-wrapper-cb-types.js'; +import AutoSave from './auto-save.js'; /** * paragraph ui @@ -1001,6 +1001,12 @@ export default class ParagraphUI { }); break; + case ACTIONS.CUSTOM: + char_button.addEventListener('click', (event) => { + this.addBBCode(char_button.dataset.copgEdParContent, '') + }); + break; + default: char_button.addEventListener('click', (event) => { dispatch.dispatch(map[actionType]()); diff --git a/components/ILIAS/COPage/PC/Paragraph/class.ilPCParagraphEditorGUI.php b/components/ILIAS/COPage/PC/Paragraph/class.ilPCParagraphEditorGUI.php index 9f02aa2d1355..06151fe0091f 100755 --- a/components/ILIAS/COPage/PC/Paragraph/class.ilPCParagraphEditorGUI.php +++ b/components/ILIAS/COPage/PC/Paragraph/class.ilPCParagraphEditorGUI.php @@ -30,7 +30,7 @@ public function getEditorElements( int $style_id ): array { $cfg = $page_gui->getPageConfig(); - $menu = ilPageObjectGUI::getTinyMenu( + $menu = $page_gui->getTinyMenu( $page_type, $cfg->getEnableInternalLinks(), $cfg->getEnableWikiLinks(), diff --git a/components/ILIAS/COPage/classes/class.ilPageObjectGUI.php b/components/ILIAS/COPage/classes/class.ilPageObjectGUI.php index 41d99091266d..10ce35ebf26f 100755 --- a/components/ILIAS/COPage/classes/class.ilPageObjectGUI.php +++ b/components/ILIAS/COPage/classes/class.ilPageObjectGUI.php @@ -1705,7 +1705,7 @@ public function setEditMode(): void /** * Get Tiny Menu */ - public static function getTinyMenu( + public function getTinyMenu( string $a_par_type, bool $a_int_links = false, bool $a_wiki_links = false, @@ -1962,7 +1962,7 @@ public static function getTinyMenu( // more - $menu["cont_more_functions"] = []; + $menu["cont_more_functions"] = $this->getCustomFunctions(); $menu["cont_more_functions"][] = ["text" => $lng->txt("cont_link") . '', "action" => $links]; if ($a_keywords) { @@ -3184,4 +3184,8 @@ public function afterDeleteContents(): void { } + protected function getCustomFunctions(): array + { + return []; + } }