-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix order of executed plugins, fix #1547
- Loading branch information
1 parent
dc868b3
commit f8efdf7
Showing
2 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/// <reference types="cypress" /> | ||
|
||
import { Editor, Extension } from '@tiptap/core' | ||
import Document from '@tiptap/extension-document' | ||
import Paragraph from '@tiptap/extension-paragraph' | ||
import Text from '@tiptap/extension-text' | ||
|
||
describe('pluginOrder', () => { | ||
it('should run keyboard shortcuts in correct order', () => { | ||
const order: number[] = [] | ||
|
||
cy.window().then(({ document }) => { | ||
const element = document.createElement('div') | ||
|
||
document.body.append(element) | ||
|
||
const editor = new Editor({ | ||
element, | ||
extensions: [ | ||
Document, | ||
Paragraph, | ||
Text, | ||
Extension.create({ | ||
priority: 1000, | ||
addKeyboardShortcuts() { | ||
return { | ||
a: () => { | ||
order.push(1) | ||
|
||
return false | ||
}, | ||
} | ||
}, | ||
}), | ||
Extension.create({ | ||
addKeyboardShortcuts() { | ||
return { | ||
a: () => { | ||
order.push(3) | ||
|
||
return false | ||
}, | ||
} | ||
}, | ||
}), | ||
Extension.create({ | ||
addKeyboardShortcuts() { | ||
return { | ||
a: () => { | ||
order.push(2) | ||
|
||
return false | ||
}, | ||
} | ||
}, | ||
}), | ||
], | ||
}) | ||
|
||
cy.get('.ProseMirror') | ||
.type('a') | ||
.wait(100).then(() => { | ||
expect(order).to.deep.eq([1, 2, 3]) | ||
|
||
editor.destroy() | ||
}) | ||
}) | ||
}) | ||
}) |