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 @@ -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')
})
})

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 @@ -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}')

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 @@ -228,7 +228,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 @@ -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()
}
}

Expand Down
12 changes: 10 additions & 2 deletions src/plugins/links.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will also be in effect if you paste into an empty document. I can't think of any case where that's a problem. Just wanted to mention.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uuhh... what if you insert a link via the link picker on an empty document. Actually would be nice if that behaved exactly as in a doc that already contains some characters. Not so important - but still a bit inconsistent.

Oh... doesn't the initial load happen through the ydoc? That would be caught by the other conditions later on - wouldn't it?

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