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
7 changes: 4 additions & 3 deletions cypress/e2e/initial.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ describe('Test state loading of documents', function() {
.find('h2').should('contain', 'Hello world')

cy.getMenu().should('be.visible')
cy.getActionEntry('undo').should('be.visible').click()
cy.getActionEntry('undo').should('be.disabled')

cy.getContent()
.should('contain', 'Hello world')
.find('h2').should('contain', 'Hello world')
.type('New content')
cy.getActionEntry('undo').should('not.be.disabled')
})
})

Expand Down
3 changes: 0 additions & 3 deletions cypress/e2e/workspace.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,6 @@ describe('Workspace', function() {
cy.get('.file-picker [data-filename="test.md"]').click()
cy.get('.dialog__actions button.button-vue--vue-primary').click()

cy.getEditor()
.find('a')

cy.getContent()
.type('{leftArrow}')

Expand Down
6 changes: 5 additions & 1 deletion src/components/Link/LinkBubbleView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ export default {
},

removeLink() {
this.editor.chain().unsetLink().focus().run()
this.editor.chain()
.hideLinkBubble()
.unsetLink()
.focus()
.run()
this.stopEdit()
},
},
Expand Down
10 changes: 4 additions & 6 deletions src/plugins/LinkBubblePluginView.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,19 @@ class LinkBubblePluginView {

update(view, oldState) {
const { active } = this.plugin.getState(view.state)
const { active: oldActive } = this.plugin.getState(oldState)
if (view.composing) {
return
}
if (active === oldActive) {
return
}
this.createTooltip()
if (active?.mark) {
this.updateTooltip(view, active)
setTimeout(() => {
this.updateTooltip(view, active)
}, 100)
} else {
this.removeEventListeners()
setTimeout(() => {
this.tippy?.hide()
}, 100)
this.removeEventListeners()
}
}

Expand Down
12 changes: 10 additions & 2 deletions src/plugins/links.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function linkBubble(options) {
init: () => ({ active: null }),
apply: (tr, cur) => {
const meta = tr.getMeta(linkBubbleKey)
if (meta && meta.active !== cur.active) {
if (meta) {
return { ...cur, active: meta.active }
} else {
return cur
Expand All @@ -86,9 +86,17 @@ export function linkBubble(options) {
}),

appendTransaction: (transactions, oldState, state) => {
// Don't open bubble at editor initialisation
if (oldState?.doc.content.size === 2) {
return
}

// Don't open bubble if neither selection nor doc changed
const sameSelection = oldState?.selection.eq(state.selection)
const sameDoc = oldState?.doc.eq(state.doc)
if (sameSelection && sameDoc) {
// Don't open bubble on changes by other session members
const noHistory = !transactions.some(tr => tr.meta.addToHistory)
if (sameSelection && (noHistory || sameDoc)) {
return
}
const active = activeLinkFromSelection(state)
Expand Down