Add ability to default open in new window to on

Created on 24 March 2016, almost 9 years ago
Updated 24 June 2023, over 1 year ago

This is a really helpful module, but particularly on file links, some sites want/need to have all their files open in a new window/tab. It would be really helpful to be able to make that the default setting for all new links of a given type.

✨ Feature request
Status

Closed: won't fix

Version

1.0

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States acrosman South Carolina, US

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States bkline Virginia

    Our users just asked for this feature. Can you provide a clue as to what that one line of JS would be?

  • πŸ‡ΊπŸ‡ΈUnited States hockey2112

    I also need a default setting for "open in new window"... in fact, it would be best (at least for me) if I could set that as default for all links and then disallow the end user from modifying that setting.

  • πŸ‡ΊπŸ‡¦Ukraine dench0
    /**
     * Implements hook_editor_js_settings_alter().
     */
    function <module_name>_editor_js_settings_alter(array &$settings) {
      foreach ($settings['editor']['formats'] as &$format) {
        if (!empty($format['editorSettings']['config']['link']['decorators'])) {
          foreach ($format['editorSettings']['config']['link']['decorators'] as &$decorator) {
            $target = $decorator['attributes']['target'] ?? FALSE;
            if ($target === '_blank') {
              $decorator['defaultValue'] = TRUE;
            }
          }
        }
      }
    }
    
Production build 0.71.5 2024