From 40644ac871fb2a877184337aaa888adf9026a798 Mon Sep 17 00:00:00 2001 From: iszmais Date: Wed, 15 Jan 2025 17:26:32 +0100 Subject: [PATCH] Add CO-Entrypoint for custom functions --- .../actions/paragraph-action-types.js | 3 ++- .../components/paragraph/ui/paragraph-ui.js | 26 ++++++++++++++----- .../class.ilPCParagraphEditorGUI.php | 2 +- .../COPage/classes/class.ilPageObjectGUI.php | 9 +++++-- 4 files changed, 29 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..07c8f400020d 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,18 @@ export default class ParagraphUI { }); break; + case ACTIONS.CUSTOM: + char_button.addEventListener('click', (event) => { + let keys = ''; + for( var index in char_button.dataset) { + if (index.startsWith('copgEdPar')) { + keys += ' ' + index.replace('copgEdPar', '').toLowerCase() + '="' + char_button.dataset[index] + '"'; + } + } + this.addBBCode('[' + ACTIONS.CUSTOM + keys + ']', '') + }); + 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..1dce669d617f 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,9 @@ public function afterDeleteContents(): void { } + protected function getCustomFunctions(): array + { + return []; + } + }