Make WordPress Core

Opened 6 years ago

Closed 2 years ago

#50817 closed enhancement (wontfix)

TinyMCE: default_link_target is ignored

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

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 (5)

#1 in reply to: ↑ description @SergeyBiryukov
6 years 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
6 years 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
6 years 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.

#4 @azaozz
5 years ago

  • Milestone Awaiting ReviewFuture Release
  • Type defect (bug)enhancement
  • Version 5.5

The default_link_target setting for TinyMCE affects the built-in link dialog there. To use it you'll have to disable the WordPress link plugin (wplink) and enable the default link one.

It is possible to enhance the WordPress "Insert/edit link" dialog to use that setting if there is enough interest (somebody makes a patch and tests it).

#5 @azaozz
2 years ago

  • Milestone Future Release
  • Resolutionwontfix
  • Status newclosed

It's been three years with nothing new here. Closing as wontfix. Please feel free to reopen with a patch if still interested in adding this.

Note: See TracTickets for help on using tickets.