Skip to content
Merged
Show file tree
Hide file tree
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
Validate link before opening
Signed-off-by: Julius Härtl <[email protected]>
Signed-off-by: npmbuildbot-nextcloud[bot] <npmbuildbot-nextcloud[bot]@users.noreply.github.com>
  • Loading branch information
juliusknorr authored and npmbuildbot-nextcloud[bot] committed Nov 12, 2020
commit 08dac20cec7ed0b1f01dee1ece5ee705313053a2
4 changes: 2 additions & 2 deletions js/editor-collab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/editor-collab.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/editor-rich.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/editor-rich.js.map

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions js/editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/editor.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions js/files-modal.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/files-modal.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/files.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/files.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/public.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions js/vendors~editor-collab~editor-guest.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/vendors~editor-collab~editor-guest.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions js/vendors~editor-rich.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/vendors~editor-rich.js.map

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions js/vendors~editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/vendors~editor.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/vendors~editor~files-modal.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/vendors~editor~files-modal.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/viewer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/viewer.js.map

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions src/marks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
*
*/

import { Plugin } from 'tiptap'
import { getMarkAttrs } from 'tiptap-utils'
import { Bold, Italic as TipTapItalic, Strike as TipTapStrike, Link as TipTapLink } from 'tiptap-extensions'
import { markdownit } from '../EditorFactory'

/**
* This file maps prosemirror mark names to tiptap classes,
Expand Down Expand Up @@ -100,6 +103,35 @@ class Link extends TipTapLink {
}
}

get plugins() {
if (!this.options.openOnClick) {
return []
}

return [
new Plugin({
props: {
handleClick: (view, pos, event) => {
const { schema } = view.state
const attrs = getMarkAttrs(view.state, schema.marks.link)

if (attrs.href && event.target instanceof HTMLAnchorElement) {
event.stopPropagation()
const htmlHref = event.target.href

if (!markdownit.validateLink(htmlHref)) {
console.error('Invalid link', htmlHref)
return
}

window.open(htmlHref)
}
},
},
}),
]
}

}

/** Strike is currently unsupported by prosemirror-markdown */
Expand Down