diff --git a/cypress/e2e/initial.spec.js b/cypress/e2e/initial.spec.js index 75495a4d17..8c765591d4 100644 --- a/cypress/e2e/initial.spec.js +++ b/cypress/e2e/initial.spec.js @@ -32,10 +32,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 827e86c8e1..db1b914d6b 100644 --- a/cypress/e2e/workspace.spec.js +++ b/cypress/e2e/workspace.spec.js @@ -160,9 +160,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 06960b54e8..147db1811b 100644 --- a/src/components/Link/LinkBubbleView.vue +++ b/src/components/Link/LinkBubbleView.vue @@ -228,7 +228,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 d7da1558c0..84d148329a 100644 --- a/src/plugins/LinkBubblePluginView.js +++ b/src/plugins/LinkBubblePluginView.js @@ -92,21 +92,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 ce3fe5d44f..dec19f47f6 100644 --- a/src/plugins/links.js +++ b/src/plugins/links.js @@ -54,7 +54,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 @@ -69,9 +69,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)