Skip to content

Commit

Permalink
Add CO-Entrypoint for custom functions
Browse files Browse the repository at this point in the history
  • Loading branch information
iszmais committed Jan 15, 2025
1 parent a6cb349 commit 40644ac
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
******************************************************************** */
*********************************************************************/

const ACTIONS = {

Expand Down Expand Up @@ -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;
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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]());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
9 changes: 7 additions & 2 deletions components/ILIAS/COPage/classes/class.ilPageObjectGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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") . '<i class="mce-ico mce-i-link"></i>', "action" => $links];

if ($a_keywords) {
Expand Down Expand Up @@ -3184,4 +3184,9 @@ public function afterDeleteContents(): void
{
}

protected function getCustomFunctions(): array
{
return [];
}

}

0 comments on commit 40644ac

Please sign in to comment.