Skip to content

Commit aaf1236

Browse files
RickR2HbrianteemanQuyTon
authored
[5.2] Added link class selection to TinyMCE dialog (#43260)
* Added link list * Fix indentation * Fix missing space * Update plugins/editors/tinymce/tinymce.xml Co-authored-by: Brian Teeman <[email protected]> * Update administrator/language/en-GB/plg_editors_tinymce.ini Co-authored-by: Brian Teeman <[email protected]> * Update plugins/editors/tinymce/tinymce.xml Co-authored-by: Brian Teeman <[email protected]> * Move parameters to Plugin tab * Update plugins/editors/tinymce/forms/setoptions.xml Co-authored-by: Quy <[email protected]> * Update plugins/editors/tinymce/src/PluginTraits/DisplayTrait.php Co-authored-by: Quy <[email protected]> * Update plugins/editors/tinymce/tinymce.xml Co-authored-by: Quy <[email protected]> * Make CI happy * Remove empty line * Update plugins/editors/tinymce/src/PluginTraits/DisplayTrait.php --------- Co-authored-by: Brian Teeman <[email protected]> Co-authored-by: Quy <[email protected]>
1 parent 5b21db6 commit aaf1236

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

administrator/language/en-GB/plg_editors_tinymce.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ PLG_TINY_FIELD_HTMLWIDTH_LABEL="HTML Width"
4444
PLG_TINY_FIELD_LABEL_ADVANCEDPARAMS="Advanced"
4545
PLG_TINY_FIELD_LANGCODE_LABEL="Language Code"
4646
PLG_TINY_FIELD_LANGSELECT_LABEL="Automatic Language Selection"
47+
PLG_TINY_FIELD_LINK_CLASS_LIST_LABEL="Class List"
48+
PLG_TINY_FIELD_LINK_CLASS_NAME_LABEL="Name"
49+
PLG_TINY_FIELD_LINK_CLASS_NONE="None"
50+
PLG_TINY_FIELD_LINK_CLASSES_LIST_DESC="Add default classes to the class dropdown in the create link dialog."
51+
PLG_TINY_FIELD_LINK_CLASSES_LIST_LABEL="Link Classes List"
4752
PLG_TINY_FIELD_NEWLINES_LABEL="New Lines"
4853
PLG_TINY_FIELD_NUMBER_OF_SETS_LABEL="Number of Sets"
4954
PLG_TINY_FIELD_PASTE_AS_TEXT_LABEL="Paste As Text"

plugins/editors/tinymce/forms/setoptions.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,5 +403,33 @@
403403
</form>
404404
</field>
405405

406+
<field
407+
name="link_classes_list"
408+
type="subform"
409+
label="PLG_TINY_FIELD_LINK_CLASSES_LIST_LABEL"
410+
description="PLG_TINY_FIELD_LINK_CLASSES_LIST_DESC"
411+
layout="joomla.form.field.subform.repeatable-table"
412+
required="false"
413+
multiple="true">
414+
<form>
415+
<field
416+
name="class_name"
417+
type="text"
418+
label="PLG_TINY_FIELD_LINK_CLASS_NAME_LABEL"
419+
required="true"
420+
filter="string"
421+
default=""
422+
/>
423+
<field
424+
name="class_list"
425+
type="text"
426+
label="PLG_TINY_FIELD_LINK_CLASS_LIST_LABEL"
427+
required="true"
428+
filter="string"
429+
validate="CssIdentifier"
430+
default=""
431+
/>
432+
</form>
433+
</field>
406434
</fieldset>
407435
</form>

plugins/editors/tinymce/src/PluginTraits/DisplayTrait.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,23 @@ public function display(string $name, string $content = '', array $attributes =
382382
// Merge the two toolbars for backwards compatibility
383383
$toolbar = array_merge($toolbar1, $toolbar2);
384384

385+
// Set default classes to empty
386+
$linkClasses = [];
387+
388+
// Load the link classes list
389+
if (isset($extraOptions->link_classes_list) && $extraOptions->link_classes_list) {
390+
$linksClassesList = $extraOptions->link_classes_list;
391+
392+
if ($linksClassesList) {
393+
$linkClasses = [['title' => TEXT::_('PLG_TINY_FIELD_LINK_CLASS_NONE'), 'value' => '']];
394+
395+
// Create an array for the link classes
396+
foreach ($linksClassesList as $linksClassList) {
397+
array_push($linkClasses, ['title' => $linksClassList->class_name, 'value' => $linksClassList->class_list]);
398+
}
399+
}
400+
}
401+
385402
// Build the final options set
386403
$scriptOptions = array_merge(
387404
$scriptOptions,
@@ -424,6 +441,9 @@ public function display(string $name, string $content = '', array $attributes =
424441
'relative_urls' => (bool) $levelParams->get('relative_urls', true),
425442
'remove_script_host' => false,
426443

444+
// Link classes
445+
'link_class_list' => $linkClasses,
446+
427447
// Drag and drop Images always FALSE, reverting this allows for inlining the images
428448
'paste_data_images' => false,
429449

0 commit comments

Comments
 (0)