Skip to content

Commit

Permalink
[5.2] Added link class selection to TinyMCE dialog (#43260)
Browse files Browse the repository at this point in the history
* Added link list

* Fix indentation

* Fix missing space

* Update plugins/editors/tinymce/tinymce.xml

Co-authored-by: Brian Teeman <brian@teeman.net>

* Update administrator/language/en-GB/plg_editors_tinymce.ini

Co-authored-by: Brian Teeman <brian@teeman.net>

* Update plugins/editors/tinymce/tinymce.xml

Co-authored-by: Brian Teeman <brian@teeman.net>

* Move parameters to Plugin tab

* Update plugins/editors/tinymce/forms/setoptions.xml

Co-authored-by: Quy <quy@nomonkeybiz.com>

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

Co-authored-by: Quy <quy@nomonkeybiz.com>

* Update plugins/editors/tinymce/tinymce.xml

Co-authored-by: Quy <quy@nomonkeybiz.com>

* Make CI happy

* Remove empty line

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

---------

Co-authored-by: Brian Teeman <brian@teeman.net>
Co-authored-by: Quy <quy@nomonkeybiz.com>
  • Loading branch information
3 people committed Apr 30, 2024
1 parent 5b21db6 commit aaf1236
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
5 changes: 5 additions & 0 deletions administrator/language/en-GB/plg_editors_tinymce.ini
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ PLG_TINY_FIELD_HTMLWIDTH_LABEL="HTML Width"
PLG_TINY_FIELD_LABEL_ADVANCEDPARAMS="Advanced"
PLG_TINY_FIELD_LANGCODE_LABEL="Language Code"
PLG_TINY_FIELD_LANGSELECT_LABEL="Automatic Language Selection"
PLG_TINY_FIELD_LINK_CLASS_LIST_LABEL="Class List"
PLG_TINY_FIELD_LINK_CLASS_NAME_LABEL="Name"
PLG_TINY_FIELD_LINK_CLASS_NONE="None"
PLG_TINY_FIELD_LINK_CLASSES_LIST_DESC="Add default classes to the class dropdown in the create link dialog."
PLG_TINY_FIELD_LINK_CLASSES_LIST_LABEL="Link Classes List"
PLG_TINY_FIELD_NEWLINES_LABEL="New Lines"
PLG_TINY_FIELD_NUMBER_OF_SETS_LABEL="Number of Sets"
PLG_TINY_FIELD_PASTE_AS_TEXT_LABEL="Paste As Text"
Expand Down
28 changes: 28 additions & 0 deletions plugins/editors/tinymce/forms/setoptions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -403,5 +403,33 @@
</form>
</field>

<field
name="link_classes_list"
type="subform"
label="PLG_TINY_FIELD_LINK_CLASSES_LIST_LABEL"
description="PLG_TINY_FIELD_LINK_CLASSES_LIST_DESC"
layout="joomla.form.field.subform.repeatable-table"
required="false"
multiple="true">
<form>
<field
name="class_name"
type="text"
label="PLG_TINY_FIELD_LINK_CLASS_NAME_LABEL"
required="true"
filter="string"
default=""
/>
<field
name="class_list"
type="text"
label="PLG_TINY_FIELD_LINK_CLASS_LIST_LABEL"
required="true"
filter="string"
validate="CssIdentifier"
default=""
/>
</form>
</field>
</fieldset>
</form>
20 changes: 20 additions & 0 deletions plugins/editors/tinymce/src/PluginTraits/DisplayTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,23 @@ public function display(string $name, string $content = '', array $attributes =
// Merge the two toolbars for backwards compatibility
$toolbar = array_merge($toolbar1, $toolbar2);

// Set default classes to empty
$linkClasses = [];

// Load the link classes list
if (isset($extraOptions->link_classes_list) && $extraOptions->link_classes_list) {
$linksClassesList = $extraOptions->link_classes_list;

if ($linksClassesList) {
$linkClasses = [['title' => TEXT::_('PLG_TINY_FIELD_LINK_CLASS_NONE'), 'value' => '']];

// Create an array for the link classes
foreach ($linksClassesList as $linksClassList) {
array_push($linkClasses, ['title' => $linksClassList->class_name, 'value' => $linksClassList->class_list]);
}
}
}

// Build the final options set
$scriptOptions = array_merge(
$scriptOptions,
Expand Down Expand Up @@ -424,6 +441,9 @@ public function display(string $name, string $content = '', array $attributes =
'relative_urls' => (bool) $levelParams->get('relative_urls', true),
'remove_script_host' => false,

// Link classes
'link_class_list' => $linkClasses,

// Drag and drop Images always FALSE, reverting this allows for inlining the images
'paste_data_images' => false,

Expand Down

0 comments on commit aaf1236

Please sign in to comment.