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
4 changes: 2 additions & 2 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.

4 changes: 2 additions & 2 deletions js/text-files.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-public.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-text.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@nextcloud/text",
"description": "Collaborative document editing",
"version": "25.0.0-alpha.7",
"version": "25.0.0-alpha.8",
"authors": [
{
"name": "Julius Härtl",
Expand Down
17 changes: 17 additions & 0 deletions src/components/RichTextReader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default {
link: {
onClick: (event, attrs) => {
this.$emit('click-link', event, attrs)
return true
},
},
}),
Expand All @@ -57,6 +58,22 @@ export default {
},
},

mounted() {
this.$el.addEventListener('click', this.preventOpeningLinks, true)
},

unmounted() {
this.$el.removeEventListener('click', this.preventOpeningLinks, true)
},

methods: {
preventOpeningLinks(event) {
// We use custom onClick handler only for left clicks
if (event.target.closest('a') && event.button === 0 && !event.ctrlKey) {
event.preventDefault()
}
},
},
}
</script>

Expand Down
37 changes: 17 additions & 20 deletions src/helpers/links.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,25 @@ const parseHref = function(dom) {

const openLink = function(event, _attrs) {
const linkElement = event.target.closest('a')
event.stopPropagation()
const htmlHref = linkElement.href
if (event.button === 0 && !event.ctrlKey && htmlHref.startsWith(window.location.origin)) {
const query = OC.parseQueryString(htmlHref)
const fragment = OC.parseQueryString(htmlHref.split('#').pop())
if (query.dir && fragment.relPath) {
const filename = fragment.relPath.split('/').pop()
const path = `${query.dir}/${filename}`
document.title = `${filename} - ${OC.theme.title}`
if (window.location.pathname.match(/apps\/files\/$/)) {
// The files app still lacks a popState handler
// to allow for using the back button
// OC.Util.History.pushState('', htmlHref)
}
OCA.Viewer.open({ path })
return
}
if (query.fileId) {
// open the direct file link
window.open(generateUrl(`/f/${query.fileId}`))
return
const query = OC.parseQueryString(htmlHref)
const fragment = OC.parseQueryString(htmlHref.split('#').pop())
if (query.dir && fragment.relPath) {
const filename = fragment.relPath.split('/').pop()
const path = `${query.dir}/${filename}`
document.title = `${filename} - ${OC.theme.title}`
if (window.location.pathname.match(/apps\/files\/$/)) {
// The files app still lacks a popState handler
// to allow for using the back button
// OC.Util.History.pushState('', htmlHref)
}
OCA.Viewer.open({ path })
return
}
if (query.fileId) {
// open the direct file link
window.open(generateUrl(`/f/${query.fileId}`))
return
}
if (!markdownit.validateLink(htmlHref)) {
console.error('Invalid link', htmlHref)
Expand Down
7 changes: 6 additions & 1 deletion src/plugins/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ const clickHandler = ({ editor, type, onClick }) => {
console.debug(link)
return false
}
return onClick?.(event, link.attrs)

// We use custom onClick handler only for left clicks
if (event.button === 0 && !event.ctrlKey) {
event.stopPropagation()
return onClick?.(event, link.attrs)
}
},
},
})
Expand Down