Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Allow javascript: type hrefs for links #173

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/plugins/link.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
event.preventDefault()

link = urlInput.val()
dialog.dialog('close')
widget.options.editable.restoreSelection(widget.lastSelection)
if isEmptyLink link
# link is empty, remove it. Make sure the link is selected
Expand All @@ -56,16 +57,15 @@
window.getSelection().addRange(widget.lastSelection)
document.execCommand "unlink", null, ""
else
# link does not have ://, add http:// as default protocol
if !(/:\/\//.test link) && !(/^mailto:/.test link)
# link does not have :// or javascript:, add http:// as default protocol
if !(/:\/\//.test link) && !(/^(mailto|javascript):/.test link)
link = 'http://' + link
if widget.lastSelection.startContainer.parentNode.href is undefined
document.execCommand "createLink", null, link
else
widget.lastSelection.startContainer.parentNode.href = link
widget.options.editable.element.trigger('change')
widget.options.editable.removeAllSelections()
dialog.dialog('close')
return false

dialog.find("input[type=submit]").click dialogSubmitCb
Expand Down