From 94a8d258f8cd4549de24d11e2d591ba4363250e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Le=20Ma=C3=AEtre?= Date: Thu, 7 Nov 2024 09:19:46 +0100 Subject: [PATCH] fix(vue-3): on editor destruction, transition smoothly (#5772) --- .changeset/five-flowers-eat.md | 5 ++ CONTRIBUTING.md | 2 +- .../src/Examples/Transition/Vue/Extension.js | 2 +- .../Transition/Vue/ParentComponent.vue | 36 +++++++++++++++ .../Vue/{Component.vue => VueComponent.vue} | 0 .../src/Examples/Transition/Vue/index.spec.js | 18 +++++--- demos/src/Examples/Transition/Vue/index.vue | 46 +++++++++++++++---- packages/vue-3/src/EditorContent.ts | 1 - packages/vue-3/src/useEditor.ts | 6 +++ 9 files changed, 98 insertions(+), 18 deletions(-) create mode 100644 .changeset/five-flowers-eat.md create mode 100644 demos/src/Examples/Transition/Vue/ParentComponent.vue rename demos/src/Examples/Transition/Vue/{Component.vue => VueComponent.vue} (100%) diff --git a/.changeset/five-flowers-eat.md b/.changeset/five-flowers-eat.md new file mode 100644 index 000000000..a44e7c58d --- /dev/null +++ b/.changeset/five-flowers-eat.md @@ -0,0 +1,5 @@ +--- +"@tiptap/vue-3": patch +--- + +Fix editor destruction before transition end if editor is nested diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5a7ab416a..e59b86f40 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,7 +36,7 @@ Before submitting a pull request: - Check the codebase to ensure that your feature doesn't already exist. - Check the pull requests to ensure that another person hasn't already submitted the feature or fix. -Before commiting: +Before committing: - Make sure to run the tests and linter before committing your changes. - If you are making changes to one of the packages, make sure to **always** include a [changeset](https://github.com/changesets/changesets) in your PR describing **what changed** with a **description** of the change. Those are responsible for changelog creation diff --git a/demos/src/Examples/Transition/Vue/Extension.js b/demos/src/Examples/Transition/Vue/Extension.js index 9dede7bb0..b83694ad7 100644 --- a/demos/src/Examples/Transition/Vue/Extension.js +++ b/demos/src/Examples/Transition/Vue/Extension.js @@ -1,7 +1,7 @@ import { mergeAttributes, Node } from '@tiptap/core' import { VueNodeViewRenderer } from '@tiptap/vue-3' -import Component from './Component.vue' +import Component from './VueComponent.vue' export default Node.create({ name: 'vueComponent', diff --git a/demos/src/Examples/Transition/Vue/ParentComponent.vue b/demos/src/Examples/Transition/Vue/ParentComponent.vue new file mode 100644 index 000000000..7cebbc9a9 --- /dev/null +++ b/demos/src/Examples/Transition/Vue/ParentComponent.vue @@ -0,0 +1,36 @@ + + + diff --git a/demos/src/Examples/Transition/Vue/Component.vue b/demos/src/Examples/Transition/Vue/VueComponent.vue similarity index 100% rename from demos/src/Examples/Transition/Vue/Component.vue rename to demos/src/Examples/Transition/Vue/VueComponent.vue diff --git a/demos/src/Examples/Transition/Vue/index.spec.js b/demos/src/Examples/Transition/Vue/index.spec.js index 5bceb87e1..39100317d 100644 --- a/demos/src/Examples/Transition/Vue/index.spec.js +++ b/demos/src/Examples/Transition/Vue/index.spec.js @@ -3,26 +3,30 @@ context('/src/Examples/Transition/Vue/', () => { cy.visit('/src/Examples/Transition/Vue/') }) - it('should not have an active tiptap instance but a button', () => { + it('should have two buttons and no active tiptap instance', () => { cy.get('.tiptap').should('not.exist') - cy.get('#toggle-editor').should('exist') + cy.get('#toggle-direct-editor').should('exist') + cy.get('#toggle-nested-editor').should('exist') }) - it('clicking the button should show the editor', () => { - cy.get('#toggle-editor').click() + it('clicking the buttons should show two editors', () => { + cy.get('#toggle-direct-editor').click() + cy.get('#toggle-nested-editor').click() cy.get('.tiptap').should('exist') cy.get('.tiptap').should('be.visible') }) - it('clicking the button again should hide the editor', () => { - cy.get('#toggle-editor').click() + it('clicking the buttons again should hide the editors', () => { + cy.get('#toggle-direct-editor').click() + cy.get('#toggle-nested-editor').click() cy.get('.tiptap').should('exist') cy.get('.tiptap').should('be.visible') - cy.get('#toggle-editor').click() + cy.get('#toggle-direct-editor').click() + cy.get('#toggle-nested-editor').click() cy.get('.tiptap').should('not.exist') }) diff --git a/demos/src/Examples/Transition/Vue/index.vue b/demos/src/Examples/Transition/Vue/index.vue index 46e65dc0c..6bd914949 100644 --- a/demos/src/Examples/Transition/Vue/index.vue +++ b/demos/src/Examples/Transition/Vue/index.vue @@ -1,12 +1,18 @@