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 #3173

Closed
jgerman-bot opened this issue May 1, 2024 · 0 comments · Fixed by #3176
Closed

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

jgerman-bot opened this issue May 1, 2024 · 0 comments · Fixed by #3176

Comments

@jgerman-bot
Copy link

New language relevant PR in upstream repo: joomla/joomla-cms#43260 Here are the upstream changes:

Click to expand the diff!
diff --git a/administrator/language/en-GB/plg_editors_tinymce.ini b/administrator/language/en-GB/plg_editors_tinymce.ini
index 7359a2b846992..162458329c143 100644
--- a/administrator/language/en-GB/plg_editors_tinymce.ini
+++ b/administrator/language/en-GB/plg_editors_tinymce.ini
@@ -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"
diff --git a/plugins/editors/tinymce/forms/setoptions.xml b/plugins/editors/tinymce/forms/setoptions.xml
index 8179e5772e684..5ac9971c11688 100644
--- a/plugins/editors/tinymce/forms/setoptions.xml
+++ b/plugins/editors/tinymce/forms/setoptions.xml
@@ -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>
diff --git a/plugins/editors/tinymce/src/PluginTraits/DisplayTrait.php b/plugins/editors/tinymce/src/PluginTraits/DisplayTrait.php
index be10b339218d4..4686bd6905d59 100644
--- a/plugins/editors/tinymce/src/PluginTraits/DisplayTrait.php
+++ b/plugins/editors/tinymce/src/PluginTraits/DisplayTrait.php
@@ -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,
@@ -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,
 
tecpromotion added a commit to tecpromotion/joomla that referenced this issue May 1, 2024
add translation
@tecpromotion tecpromotion linked a pull request May 1, 2024 that will close this issue
zero-24 pushed a commit that referenced this issue Jun 9, 2024
* add new strings

* fix #3173

add translation

* Inverted commas
@zero-24 zero-24 closed this as completed Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

4 participants