admin 管理员组文章数量: 1086019
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.
/
Thanks
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/
Thanks
Share Improve this question asked Jul 16, 2016 at 18:20 Zach PZach P 57010 silver badges30 bronze badges5 Answers
Reset to default 4I 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;
Go to the summernote.js file and find
$openInNewWindow.prop('checked', linkInfo.isNewWindow);
Set this forcefully true by replacing the linkInfo.isNewWindow.
$openInNewWindow.prop('checked', true);
Hopefully it will resolve your issue.
You can use linkTargetBlank: false
option to disable default checked on the checkbox.
Like this:
$('.wysiwyg').summernote({
linkTargetBlank: false
});
See the pull request on github: https://github./summernote/summernote/pull/2195
When you're using Summernote v0.8.11 just go to the summernote.js file and set isNewWindow: true
to true instead of $openInNewWindow.is(':checked')
. It's around line 6219.
$openInNewWindow.prop('checked', isNewWindowChecked);
$linkBtn.one('click', function (event) {
event.preventDefault();
deferred.resolve({
range: linkInfo.range,
url: $linkUrl.val(),
text: $linkText.val(),
isNewWindow: $openInNewWindow.is(':checked') // change this
});
_this.ui.hideDialog(_this.$dialog);
});
You can just set the class .sn-checkbox-open-in-new-window with pointer events set to none. by default it is set to open in new window, so you just make the checkbox unclickable
.sn-checkbox-open-in-new-window{
pointer-events:none !important
}
本文标签: javascriptSummernote always open link in new tabStack Overflow
版权声明:本文标题:javascript - Summernote always open link in new tab - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744030796a2521464.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论