fix: Inline links in card title
Signed-off-by: Julius Knorr <jus@bitgrid.net>
This commit is contained in:
@@ -19,10 +19,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<CardCover v-if="showCardCover" :card-id="card.id" />
|
<CardCover v-if="showCardCover" :card-id="card.id" />
|
||||||
<div class="card-upper">
|
<div class="card-upper">
|
||||||
<h4 v-if="!editingTitle" dir="auto">
|
<h4 v-if="editingTitle === 0" key="title-view" dir="auto">
|
||||||
<span v-auto-link class="dragDisabled">{{ displayTitle }}</span>
|
<span class="dragDisabled" contenteditable="false">{{ displayTitle }}</span>
|
||||||
</h4>
|
</h4>
|
||||||
<h4 v-else
|
<h4 v-if="editingTitle >= 1"
|
||||||
|
key="title-edit"
|
||||||
dir="auto"
|
dir="auto"
|
||||||
class="editable dragDisabled"
|
class="editable dragDisabled"
|
||||||
:aria-label="t('deck', 'Edit card title')">
|
:aria-label="t('deck', 'Edit card title')">
|
||||||
@@ -33,7 +34,8 @@
|
|||||||
@focus="onTitleFocus"
|
@focus="onTitleFocus"
|
||||||
@blur="onTitleBlur"
|
@blur="onTitleBlur"
|
||||||
@click.stop
|
@click.stop
|
||||||
@keyup.esc="cancelEdit"
|
@keyup.esc="onTitleBlur"
|
||||||
|
@keyup.enter="onTitleBlur"
|
||||||
@keyup.stop>{{ card.title }}</span>
|
@keyup.stop>{{ card.title }}</span>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
@@ -152,7 +154,7 @@ export default {
|
|||||||
return this.item ? this.item : this.$store.getters.cardById(this.id)
|
return this.item ? this.item : this.$store.getters.cardById(this.id)
|
||||||
},
|
},
|
||||||
displayTitle() {
|
displayTitle() {
|
||||||
const reference = this.card.referenceData
|
const reference = this.card?.referenceData
|
||||||
return reference ? reference.openGraphObject.name : this.card.title
|
return reference ? reference.openGraphObject.name : this.card.title
|
||||||
},
|
},
|
||||||
currentCard() {
|
currentCard() {
|
||||||
@@ -198,12 +200,6 @@ export default {
|
|||||||
this.$nextTick(() => this.$el.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'center' }))
|
this.$nextTick(() => this.$el.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'center' }))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'card.title'(value) {
|
|
||||||
if (document.activeElement === this.$refs.titleContentEditable || this.$refs.titleContentEditable.textContent === value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.$refs.titleContentEditable.textContent = value
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
hasSelection() {
|
hasSelection() {
|
||||||
@@ -217,7 +213,10 @@ export default {
|
|||||||
card = this.$refs[`card${card}`]
|
card = this.$refs[`card${card}`]
|
||||||
card.focus()
|
card.focus()
|
||||||
},
|
},
|
||||||
openCard() {
|
openCard(event) {
|
||||||
|
if (event.target.tagName.toLowerCase() === 'a') {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (this.dragging || this.hasSelection()) {
|
if (this.dragging || this.hasSelection()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -234,19 +233,22 @@ export default {
|
|||||||
this.editingTitle = TITLE_EDITING_STATE.PENDING
|
this.editingTitle = TITLE_EDITING_STATE.PENDING
|
||||||
this.$store.dispatch('toggleShortcutLock', true)
|
this.$store.dispatch('toggleShortcutLock', true)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.$refs.titleContentEditable.focus()
|
const sel = window.getSelection()
|
||||||
|
sel.selectAllChildren(this.$refs.titleContentEditable)
|
||||||
|
sel.collapseToEnd()
|
||||||
this.editingTitle = TITLE_EDITING_STATE.ON
|
this.editingTitle = TITLE_EDITING_STATE.ON
|
||||||
}, 0)
|
}, 0)
|
||||||
},
|
},
|
||||||
onTitleBlur(e) {
|
onTitleBlur(e) {
|
||||||
if (this.editingTitle !== TITLE_EDITING_STATE.ON || e.target.innerText === '') {
|
const value = e.target.innerText.trim().replace(/\n$/, '')
|
||||||
|
if (this.editingTitle !== TITLE_EDITING_STATE.ON || value === '') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.editingTitle = TITLE_EDITING_STATE.OFF
|
this.editingTitle = TITLE_EDITING_STATE.OFF
|
||||||
if (e.target.innerText !== this.card.title) {
|
if (value !== this.card.title) {
|
||||||
this.$store.dispatch('updateCardTitle', {
|
this.$store.dispatch('updateCardTitle', {
|
||||||
...this.card,
|
...this.card,
|
||||||
title: e.target.innerText,
|
title: value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.$store.dispatch('toggleShortcutLock', false)
|
this.$store.dispatch('toggleShortcutLock', false)
|
||||||
@@ -254,10 +256,6 @@ export default {
|
|||||||
onTitleFocus() {
|
onTitleFocus() {
|
||||||
this.$store.dispatch('toggleShortcutLock', true)
|
this.$store.dispatch('toggleShortcutLock', true)
|
||||||
},
|
},
|
||||||
cancelEdit() {
|
|
||||||
this.$refs.titleContentEditable.textContent = this.card.title
|
|
||||||
this.$store.dispatch('toggleShortcutLock', false)
|
|
||||||
},
|
|
||||||
handleCardKeyboardShortcut(key) {
|
handleCardKeyboardShortcut(key) {
|
||||||
if (OCP.Accessibility.disableKeyboardShortcuts()) {
|
if (OCP.Accessibility.disableKeyboardShortcuts()) {
|
||||||
return
|
return
|
||||||
@@ -269,7 +267,7 @@ export default {
|
|||||||
|
|
||||||
switch (key.code) {
|
switch (key.code) {
|
||||||
case 'KeyE':
|
case 'KeyE':
|
||||||
this.$refs.titleContentEditable?.focus()
|
this.triggerEditTitle()
|
||||||
break
|
break
|
||||||
case 'KeyA':
|
case 'KeyA':
|
||||||
this.$store.dispatch('archiveUnarchiveCard', { ...this.card, archived: !this.card.archived })
|
this.$store.dispatch('archiveUnarchiveCard', { ...this.card, archived: !this.card.archived })
|
||||||
@@ -368,6 +366,11 @@ export default {
|
|||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
padding-left: 4px;
|
padding-left: 4px;
|
||||||
align-self: center;
|
align-self: center;
|
||||||
|
|
||||||
|
:deep(a) {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
&.editable {
|
&.editable {
|
||||||
span {
|
span {
|
||||||
cursor: text;
|
cursor: text;
|
||||||
|
|||||||
Reference in New Issue
Block a user