vitest-prosemirror 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -702,14 +702,14 @@ function type(view, text) {
|
|
|
702
702
|
...modifiers,
|
|
703
703
|
shiftKey
|
|
704
704
|
};
|
|
705
|
-
const keydownEvent =
|
|
705
|
+
const keydownEvent = keyboardEvent("keydown", eventInit);
|
|
706
706
|
view.dispatchEvent(keydownEvent);
|
|
707
707
|
if (!keydownEvent.defaultPrevented) {
|
|
708
708
|
const action = keyAction(character, modifiers);
|
|
709
709
|
if (action.type === "delete") deleteText(view, action.direction);
|
|
710
710
|
else if (action.type === "moveCaret") moveCaret(view, action.direction, action.extend);
|
|
711
711
|
else if (action.type === "type") {
|
|
712
|
-
view.dispatchEvent(
|
|
712
|
+
view.dispatchEvent(keyboardEvent("keypress", {
|
|
713
713
|
...eventInit,
|
|
714
714
|
charCode: identity.charCode,
|
|
715
715
|
keyCode: identity.charCode
|
|
@@ -717,7 +717,7 @@ function type(view, text) {
|
|
|
717
717
|
typeCharacter(view, action.character);
|
|
718
718
|
}
|
|
719
719
|
}
|
|
720
|
-
view.dispatchEvent(
|
|
720
|
+
view.dispatchEvent(keyboardEvent("keyup", eventInit));
|
|
721
721
|
}
|
|
722
722
|
}
|
|
723
723
|
function keyAction(key, modifiers) {
|
|
@@ -752,6 +752,14 @@ function keyAction(key, modifiers) {
|
|
|
752
752
|
}
|
|
753
753
|
throw new Error(`Cannot simulate the "${key}" key`);
|
|
754
754
|
}
|
|
755
|
+
function keyboardEvent(eventType, init) {
|
|
756
|
+
const event = new KeyboardEvent(eventType, { ...init });
|
|
757
|
+
if (!Object.hasOwn(event, "charCode")) Object.defineProperty(event, "charCode", {
|
|
758
|
+
configurable: true,
|
|
759
|
+
value: init.charCode
|
|
760
|
+
});
|
|
761
|
+
return event;
|
|
762
|
+
}
|
|
755
763
|
//#endregion
|
|
756
764
|
//#region src/renderProseMirror.ts
|
|
757
765
|
var originalMutationObserver = global.MutationObserver;
|
package/dist/setup.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as resolveSelection, i as containsRTL, n as cleanupEditors, t as ProseMirrorEditorImpl } from "./renderProseMirror-
|
|
1
|
+
import { a as resolveSelection, i as containsRTL, n as cleanupEditors, t as ProseMirrorEditorImpl } from "./renderProseMirror-8i2GClvD.js";
|
|
2
2
|
import { afterEach, expect } from "vitest";
|
|
3
3
|
import stringifyObject from "stringify-object";
|
|
4
4
|
//#region src/isProseMirrorNode.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest-prosemirror",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A plugin for Vitest that enables you to write tests using the ProseMirror editor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vitest",
|
|
@@ -52,7 +52,9 @@
|
|
|
52
52
|
"lint:ts:typecheck": "tsc --noEmit",
|
|
53
53
|
"prepack": "npm run build",
|
|
54
54
|
"start": "vite build --watch",
|
|
55
|
-
"test": "
|
|
55
|
+
"test": "run-s test:*",
|
|
56
|
+
"test:happy-dom": "VITEST_ENVIRONMENT=happy-dom vitest run",
|
|
57
|
+
"test:jsdom": "vitest run --coverage",
|
|
56
58
|
"test-watch": "vitest"
|
|
57
59
|
},
|
|
58
60
|
"dependencies": {
|
|
@@ -80,6 +82,7 @@
|
|
|
80
82
|
"eslint-plugin-perfectionist": "^5.0.0",
|
|
81
83
|
"eslint-plugin-prefer-arrow-functions": "^3.9.1",
|
|
82
84
|
"eslint-plugin-prettier": "^5.1.3",
|
|
85
|
+
"happy-dom": "^20.14.3",
|
|
83
86
|
"jiti": "^2.7.0",
|
|
84
87
|
"jsdom": "^30.0.0",
|
|
85
88
|
"npm-run-all2": "^9.0.3",
|