WordPress.org

Make WordPress Core

Opened 10 days ago

Last modified 9 days ago

#50817 new defect (bug)

TinyMCE: default_link_target is ignored

Reported by: utoppo Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version: trunk
Component: TinyMCE Keywords: needs-patch
Focuses: javascript Cc:

Description

I use the following filter, to set the default_link_target for TinyMCE to _blank:

<?php
function default_link_target_blank($opt) {
        $opt['default_link_target'] = "_blank";
        return $opt;
}

add_filter( 'tiny_mce_before_init', 'default_link_target_blank');

The setting itself works. I can access the setting inside a TinyMCE plugin via the follwing JavaScript-Code:

editor.on('init', () => {
  console.log(editor.getParam('default_link_target'))
})
// output is: ‘_blank’

The problem is, that the default_link_target-setting is never taken into account inside the wplink-Plugin of WordPress:

src/wp-includes/js/tinymce/plugins/wplink/plugin.js

I have a Bugfix ready on a cloned repository of https://github.com/WordPress/wordpress-develop

Unfortunately there is the following inside the .gitignore-file of the repository:

/src/wp-includes/js

Is there any other place, where I could commit changes to the JavaScript code? Did I miss something? How could I create a pull-request on the github-repository with changed JS-Code?

Change History (3)

#1 in reply to: ↑ description @SergeyBiryukov
10 days ago

Hi there, welcome to WordPress Trac! Thanks for the report.

Unfortunately there is the following inside the .gitignore-file of the repository:

/src/wp-includes/js

Is there any other place, where I could commit changes to the JavaScript code? Did I miss something?

You can find the wplink plugin at this location:
https://github.com/WordPress/wordpress-develop/tree/master/src/js/_enqueues/vendor/tinymce/plugins/wplink

It is moved to wp-includes/js as part of the build process.

#2 follow-up: @utoppo
9 days ago

Hey Sergey,

thank you very much for pointing me in the right direction!

Unfortunately my time is a bit short right now, so it will take a little time until the pull-request is ready.

I still have a question regarding tests:
There seems to be one tinymce-related test

tests/qunit/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js

However, there seems to be no tests for the wplink-plugin. Am I right? Is it necessary to create tests in order for a pull-request to be accepted?

#3 in reply to: ↑ 2 @SergeyBiryukov
9 days ago

Replying to utoppo:

There seems to be one tinymce-related test

tests/qunit/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js

However, there seems to be no tests for the wplink-plugin. Am I right? Is it necessary to create tests in order for a pull-request to be accepted?

Adding some tests would be nice, but I don't think that should block the bug fix here, assuming the fix can be tested manually and works as expected.

Note: See TracTickets for help on using tickets.