Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.2] Added link class selection to TinyMCE dialog #43260

Merged
merged 16 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 = [];
Quy marked this conversation as resolved.
Show resolved Hide resolved

// 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