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
6 changes: 5 additions & 1 deletion src/components/HelpModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@
<td>
<code>[Title](https://example.org)</code>
</td>
<td v-if="!isMobileCached" />
<td v-if="!isMobileCached">
<kbd>{{ ctrlOrModKey }}</kbd>
+
<kbd>K</kbd>
</td>
</tr>
<tr>
<td>{{ t('text', 'Insert emoji') }}</td>
Expand Down
17 changes: 16 additions & 1 deletion src/components/Link/LinkBubbleView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@

<!-- link edit form -->
<div v-if="isEditable && edit" class="link-view-bubble__edit">
<NcTextField name="newHref"
<NcTextField ref="hrefField"
name="newHref"
:label="t('text', 'URL')"
:value.sync="newHref"
@keypress.enter.prevent="updateLink" />
Expand Down Expand Up @@ -174,6 +175,7 @@ export default {
watch: {
key() {
this.resetBubble()
this.startEditIfEmpty()
},
},

Expand All @@ -184,6 +186,10 @@ export default {
})
},

mounted() {
this.startEditIfEmpty()
},

methods: {
t,

Expand All @@ -204,6 +210,15 @@ export default {
startEdit() {
this.edit = true
this.newHref = this.href
this.$nextTick(() => {
this.$refs.hrefField.focus()
})
},

startEditIfEmpty() {
if (this.isEditable && !this.href) {
this.startEdit()
}
},

stopEdit() {
Expand Down
2 changes: 2 additions & 0 deletions src/components/Menu/entries.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ export const MenuEntries = [
{
key: 'insert-link',
label: t('text', 'Insert link'),
keyChar: 'k',
keyModifiers: [MODIFIERS.Mod],
isActive: 'link',
icon: LinkIcon,
component: ActionInsertLink,
Expand Down
14 changes: 14 additions & 0 deletions src/marks/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ const Link = TipTapLink.extend({
]
},

addKeyboardShortcuts() {
return {
'Mod-k': () => {
const { empty } = this.editor.state.selection
if (empty) {
console.debug('empty selection')
return false
}
console.debug('toggle link for selection')
return this.editor.commands.toggleLink({ href: '' })
},
}
},

addProseMirrorPlugins() {
const plugins = this.parent()
// remove upstream link click handle plugin
Expand Down