Search code examples
javascripthtmlcsssummernote

Summernote always open link in new tab


When users are inserting a link with Summernote, it gives them the option of whether the link should open in a new tab or not. How can I force the user to always choose open a link in a new tab? Even just being able to hide that option would be useful becuase I could add in target="_blank" on the server side. Either way, I have been trying many things but I haven't been able to find an answer.

http://summernote.org/

Thanks


Solution

  • I am not familiar with Summernote, there should be an option in the API to disable that but if you're looking for a quick solution, you can target the option through CSS and hide it.

    CSS hiding:

    .note-editor .link-dialog .checkbox { display: none; }
    

    However I think it will remain the default state (unchecked), to force it to be checked you'll need JavaScript.

    Force check with JavaScript:

    document.querySelector('.note-editor .link-dialog .checkbox input').checked = true;