diff --git a/cypress/e2e/initial.spec.js b/cypress/e2e/initial.spec.js index c9372c22ff7..aac7fd98c69 100644 --- a/cypress/e2e/initial.spec.js +++ b/cypress/e2e/initial.spec.js @@ -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') }) }) diff --git a/cypress/e2e/workspace.spec.js b/cypress/e2e/workspace.spec.js index c8fc6b0d177..b55b6ddfd18 100644 --- a/cypress/e2e/workspace.spec.js +++ b/cypress/e2e/workspace.spec.js @@ -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}') diff --git a/src/components/Link/LinkBubbleView.vue b/src/components/Link/LinkBubbleView.vue index 256cb98cf20..4d65279dd8b 100644 --- a/src/components/Link/LinkBubbleView.vue +++ b/src/components/Link/LinkBubbleView.vue @@ -223,7 +223,11 @@ export default { }, removeLink() { - this.editor.chain().unsetLink().focus().run() + this.editor.chain() + .hideLinkBubble() + .unsetLink() + .focus() + .run() this.stopEdit() }, }, diff --git a/src/plugins/LinkBubblePluginView.js b/src/plugins/LinkBubblePluginView.js index e20ae89413a..42c1c618a8d 100644 --- a/src/plugins/LinkBubblePluginView.js +++ b/src/plugins/LinkBubblePluginView.js @@ -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() } } diff --git a/src/plugins/links.js b/src/plugins/links.js index 201cb6034bc..82ff913ac1d 100644 --- a/src/plugins/links.js +++ b/src/plugins/links.js @@ -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 @@ -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)