@kerebron/editor 0.4.28 → 0.4.29
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/esm/CoreEditor.js +1 -0
- package/esm/CoreEditor.js.map +1 -0
- package/esm/DummyEditorView.js +1 -0
- package/esm/DummyEditorView.js.map +1 -0
- package/esm/Extension.js +1 -0
- package/esm/Extension.js.map +1 -0
- package/esm/ExtensionManager.js +1 -0
- package/esm/ExtensionManager.js.map +1 -0
- package/esm/Mark.js +1 -0
- package/esm/Mark.js.map +1 -0
- package/esm/Node.js +1 -0
- package/esm/Node.js.map +1 -0
- package/esm/commands/CommandManager.js +1 -0
- package/esm/commands/CommandManager.js.map +1 -0
- package/esm/commands/baseCommandFactories.js +1 -0
- package/esm/commands/baseCommandFactories.js.map +1 -0
- package/esm/commands/createChainableState.js +1 -0
- package/esm/commands/createChainableState.js.map +1 -0
- package/esm/commands/keyCommandFactories.js +1 -0
- package/esm/commands/keyCommandFactories.js.map +1 -0
- package/esm/commands/mod.js +1 -0
- package/esm/commands/mod.js.map +1 -0
- package/esm/commands/replaceCommandFactories.js +1 -0
- package/esm/commands/replaceCommandFactories.js.map +1 -0
- package/esm/commands/types.js +1 -0
- package/esm/commands/types.js.map +1 -0
- package/esm/mod.js +1 -0
- package/esm/mod.js.map +1 -0
- package/esm/nodeToTreeString.js +1 -0
- package/esm/nodeToTreeString.js.map +1 -0
- package/esm/plugins/TrackSelecionPlugin.js +1 -0
- package/esm/plugins/TrackSelecionPlugin.js.map +1 -0
- package/esm/plugins/input-rules/InputRulesPlugin.js +1 -0
- package/esm/plugins/input-rules/InputRulesPlugin.js.map +1 -0
- package/esm/plugins/input-rules/mod.js +1 -0
- package/esm/plugins/input-rules/mod.js.map +1 -0
- package/esm/plugins/input-rules/rulebuilders.js +1 -0
- package/esm/plugins/input-rules/rulebuilders.js.map +1 -0
- package/esm/plugins/keymap/keymap.js +1 -0
- package/esm/plugins/keymap/keymap.js.map +1 -0
- package/esm/plugins/keymap/mod.js +1 -0
- package/esm/plugins/keymap/mod.js.map +1 -0
- package/esm/plugins/keymap/w3c-keyname.js +1 -0
- package/esm/plugins/keymap/w3c-keyname.js.map +1 -0
- package/esm/search/mod.js +1 -0
- package/esm/search/mod.js.map +1 -0
- package/esm/search/query.js +1 -0
- package/esm/search/query.js.map +1 -0
- package/esm/search/search.js +1 -0
- package/esm/search/search.js.map +1 -0
- package/esm/types.js +1 -0
- package/esm/types.js.map +1 -0
- package/esm/ui.js +1 -0
- package/esm/ui.js.map +1 -0
- package/esm/utilities/SmartOutput.js +1 -0
- package/esm/utilities/SmartOutput.js.map +1 -0
- package/esm/utilities/createNodeFromContent.js +1 -0
- package/esm/utilities/createNodeFromContent.js.map +1 -0
- package/esm/utilities/getHtmlAttributes.js +1 -0
- package/esm/utilities/getHtmlAttributes.js.map +1 -0
- package/esm/utilities/getShadowRoot.js +1 -0
- package/esm/utilities/getShadowRoot.js.map +1 -0
- package/esm/utilities/mod.js +1 -0
- package/esm/utilities/mod.js.map +1 -0
- package/esm/utilities/toRawTextResult.js +1 -0
- package/esm/utilities/toRawTextResult.js.map +1 -0
- package/package.json +5 -1
- package/src/CoreEditor.ts +277 -0
- package/src/DummyEditorView.ts +403 -0
- package/src/Extension.ts +63 -0
- package/src/ExtensionManager.ts +328 -0
- package/src/Mark.ts +47 -0
- package/src/Node.ts +66 -0
- package/src/commands/CommandManager.ts +145 -0
- package/src/commands/baseCommandFactories.ts +1103 -0
- package/src/commands/createChainableState.ts +36 -0
- package/src/commands/keyCommandFactories.ts +26 -0
- package/src/commands/mod.ts +104 -0
- package/src/commands/replaceCommandFactories.ts +129 -0
- package/src/commands/types.ts +30 -0
- package/src/mod.ts +8 -0
- package/src/nodeToTreeString.ts +100 -0
- package/src/plugins/TrackSelecionPlugin.ts +27 -0
- package/src/plugins/input-rules/InputRulesPlugin.ts +242 -0
- package/src/plugins/input-rules/mod.ts +2 -0
- package/src/plugins/input-rules/rulebuilders.ts +88 -0
- package/src/plugins/keymap/keymap.ts +117 -0
- package/src/plugins/keymap/mod.ts +1 -0
- package/src/plugins/keymap/w3c-keyname.ts +123 -0
- package/src/search/mod.ts +2 -0
- package/src/search/query.ts +412 -0
- package/src/search/search.ts +284 -0
- package/src/types.ts +71 -0
- package/src/ui.ts +35 -0
- package/src/utilities/SmartOutput.ts +284 -0
- package/src/utilities/createNodeFromContent.ts +66 -0
- package/src/utilities/getHtmlAttributes.ts +68 -0
- package/src/utilities/getShadowRoot.ts +18 -0
- package/src/utilities/mod.ts +5 -0
- package/src/utilities/toRawTextResult.ts +27 -0
- package/assets/base.css +0 -114
- package/assets/content.css +0 -35
- package/assets/gapcursor.css +0 -25
- package/assets/index.css +0 -2
- package/assets/main.css +0 -8
- package/assets/mobile.css +0 -33
- package/assets/prosemirror.css +0 -20
- package/assets/search.css +0 -6
- package/assets/vars.css +0 -110
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { canJoin, findWrapping } from 'prosemirror-transform';
|
|
2
|
+
import { Attrs, Fragment, Node, NodeType, Slice } from 'prosemirror-model';
|
|
3
|
+
|
|
4
|
+
import { InputRule } from './InputRulesPlugin.js';
|
|
5
|
+
|
|
6
|
+
/// Build an input rule for automatically wrapping a textblock when a
|
|
7
|
+
/// given string is typed. The `regexp` argument is
|
|
8
|
+
/// directly passed through to the `InputRule` constructor. You'll
|
|
9
|
+
/// probably want the regexp to start with `^`, so that the pattern can
|
|
10
|
+
/// only occur at the start of a textblock.
|
|
11
|
+
///
|
|
12
|
+
/// `nodeType` is the type of node to wrap in. If it needs attributes,
|
|
13
|
+
/// you can either pass them directly, or pass a function that will
|
|
14
|
+
/// compute them from the regular expression match.
|
|
15
|
+
///
|
|
16
|
+
/// By default, if there's a node with the same type above the newly
|
|
17
|
+
/// wrapped node, the rule will try to [join](#transform.Transform.join) those
|
|
18
|
+
/// two nodes. You can pass a join predicate, which takes a regular
|
|
19
|
+
/// expression match and the node before the wrapped node, and can
|
|
20
|
+
/// return a boolean to indicate whether a join should happen.
|
|
21
|
+
export function wrappingInputRule(
|
|
22
|
+
regexp: RegExp,
|
|
23
|
+
nodeType: NodeType,
|
|
24
|
+
getAttrs: Attrs | null | ((matches: RegExpMatchArray) => Attrs | null) = null,
|
|
25
|
+
joinPredicate?: (match: RegExpMatchArray, node: Node) => boolean,
|
|
26
|
+
) {
|
|
27
|
+
return new InputRule(regexp, (state, match, start, end) => {
|
|
28
|
+
const attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
|
|
29
|
+
const tr = state.tr.delete(start, end);
|
|
30
|
+
const $start = tr.doc.resolve(start);
|
|
31
|
+
const range = $start.blockRange();
|
|
32
|
+
const wrapping = range && findWrapping(range, nodeType, attrs);
|
|
33
|
+
if (!wrapping) return null;
|
|
34
|
+
tr.wrap(range!, wrapping);
|
|
35
|
+
const before = tr.doc.resolve(start - 1).nodeBefore;
|
|
36
|
+
if (
|
|
37
|
+
before && before.type == nodeType && canJoin(tr.doc, start - 1) &&
|
|
38
|
+
(!joinPredicate || joinPredicate(match, before))
|
|
39
|
+
) {
|
|
40
|
+
tr.join(start - 1);
|
|
41
|
+
}
|
|
42
|
+
return tr;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/// Build an input rule that changes the type of a textblock when the
|
|
47
|
+
/// matched text is typed into it. You'll usually want to start your
|
|
48
|
+
/// regexp with `^` to that it is only matched at the start of a
|
|
49
|
+
/// textblock. The optional `getAttrs` parameter can be used to compute
|
|
50
|
+
/// the new node's attributes, and works the same as in the
|
|
51
|
+
/// `wrappingInputRule` function.
|
|
52
|
+
export function textblockTypeInputRule(
|
|
53
|
+
regexp: RegExp,
|
|
54
|
+
nodeType: NodeType,
|
|
55
|
+
getAttrs: Attrs | null | ((match: RegExpMatchArray) => Attrs | null) = null,
|
|
56
|
+
) {
|
|
57
|
+
return new InputRule(regexp, (state, match, start, end) => {
|
|
58
|
+
const $start = state.doc.resolve(start);
|
|
59
|
+
const attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
|
|
60
|
+
if (
|
|
61
|
+
!$start.node(-1).canReplaceWith(
|
|
62
|
+
$start.index(-1),
|
|
63
|
+
$start.indexAfter(-1),
|
|
64
|
+
nodeType,
|
|
65
|
+
)
|
|
66
|
+
) return null;
|
|
67
|
+
return state.tr
|
|
68
|
+
.delete(start, end)
|
|
69
|
+
.setBlockType(start, start, nodeType, attrs);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function replaceInlineNode(
|
|
74
|
+
regexp: RegExp,
|
|
75
|
+
nodeType: NodeType,
|
|
76
|
+
getAttrs: Attrs | null | ((matches: RegExpMatchArray) => Attrs | null) = null,
|
|
77
|
+
) {
|
|
78
|
+
return new InputRule(regexp, (state, match, start, end) => {
|
|
79
|
+
const attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
|
|
80
|
+
const node = nodeType.createAndFill(attrs);
|
|
81
|
+
const slice = new Slice(Fragment.from(node), 0, 0);
|
|
82
|
+
|
|
83
|
+
const tr = state.tr;
|
|
84
|
+
const from = tr.mapping.map(start);
|
|
85
|
+
const to = tr.mapping.map(end);
|
|
86
|
+
return tr.replace(from, to, slice);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Plugin } from 'prosemirror-state';
|
|
2
|
+
import { EditorView } from 'prosemirror-view';
|
|
3
|
+
|
|
4
|
+
import type { Command } from '../../commands/types.js';
|
|
5
|
+
import { base, keyName } from './w3c-keyname.js';
|
|
6
|
+
|
|
7
|
+
const mac = typeof navigator != 'undefined' &&
|
|
8
|
+
/Mac|iP(hone|[oa]d)/.test(navigator?.platform);
|
|
9
|
+
const windows = typeof navigator != 'undefined' &&
|
|
10
|
+
/Win/.test(navigator?.platform);
|
|
11
|
+
|
|
12
|
+
function normalizeKeyName(name: string) {
|
|
13
|
+
let parts = name.split(/-(?!$)/), result = parts[parts.length - 1];
|
|
14
|
+
if (result == 'Space') result = ' ';
|
|
15
|
+
let alt, ctrl, shift, meta;
|
|
16
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
17
|
+
let mod = parts[i];
|
|
18
|
+
if (/^(cmd|meta|m)$/i.test(mod)) meta = true;
|
|
19
|
+
else if (/^a(lt)?$/i.test(mod)) alt = true;
|
|
20
|
+
else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true;
|
|
21
|
+
else if (/^s(hift)?$/i.test(mod)) shift = true;
|
|
22
|
+
else if (/^mod$/i.test(mod)) {
|
|
23
|
+
if (mac) meta = true;
|
|
24
|
+
else ctrl = true;
|
|
25
|
+
} else throw new Error('Unrecognized modifier name: ' + mod);
|
|
26
|
+
}
|
|
27
|
+
if (alt) result = 'Alt-' + result;
|
|
28
|
+
if (ctrl) result = 'Ctrl-' + result;
|
|
29
|
+
if (meta) result = 'Meta-' + result;
|
|
30
|
+
if (shift) result = 'Shift-' + result;
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function normalize(map: { [key: string]: Command }) {
|
|
35
|
+
let copy: { [key: string]: Command } = Object.create(null);
|
|
36
|
+
for (let prop in map) copy[normalizeKeyName(prop)] = map[prop];
|
|
37
|
+
return copy;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function modifiers(name: string, event: KeyboardEvent, shift = true) {
|
|
41
|
+
if (event.altKey) name = 'Alt-' + name;
|
|
42
|
+
if (event.ctrlKey) name = 'Ctrl-' + name;
|
|
43
|
+
if (event.metaKey) name = 'Meta-' + name;
|
|
44
|
+
if (shift && event.shiftKey) name = 'Shift-' + name;
|
|
45
|
+
return name;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/// Create a keymap plugin for the given set of bindings.
|
|
49
|
+
///
|
|
50
|
+
/// Bindings should map key names to [command](#commands)-style
|
|
51
|
+
/// functions, which will be called with `(EditorState, dispatch,
|
|
52
|
+
/// EditorView)` arguments, and should return true when they've handled
|
|
53
|
+
/// the key. Note that the view argument isn't part of the command
|
|
54
|
+
/// protocol, but can be used as an escape hatch if a binding needs to
|
|
55
|
+
/// directly interact with the UI.
|
|
56
|
+
///
|
|
57
|
+
/// Key names may be strings like `"Shift-Ctrl-Enter"`—a key
|
|
58
|
+
/// identifier prefixed with zero or more modifiers. Key identifiers
|
|
59
|
+
/// are based on the strings that can appear in
|
|
60
|
+
/// [`KeyEvent.key`](https:///developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key).
|
|
61
|
+
/// Use lowercase letters to refer to letter keys (or uppercase letters
|
|
62
|
+
/// if you want shift to be held). You may use `"Space"` as an alias
|
|
63
|
+
/// for the `" "` name.
|
|
64
|
+
///
|
|
65
|
+
/// Modifiers can be given in any order. `Shift-` (or `s-`), `Alt-` (or
|
|
66
|
+
/// `a-`), `Ctrl-` (or `c-` or `Control-`) and `Cmd-` (or `m-` or
|
|
67
|
+
/// `Meta-`) are recognized. For characters that are created by holding
|
|
68
|
+
/// shift, the `Shift-` prefix is implied, and should not be added
|
|
69
|
+
/// explicitly.
|
|
70
|
+
///
|
|
71
|
+
/// You can use `Mod-` as a shorthand for `Cmd-` on Mac and `Ctrl-` on
|
|
72
|
+
/// other platforms.
|
|
73
|
+
///
|
|
74
|
+
/// You can add multiple keymap plugins to an editor. The order in
|
|
75
|
+
/// which they appear determines their precedence (the ones early in
|
|
76
|
+
/// the array get to dispatch first).
|
|
77
|
+
export class KeymapPlugin extends Plugin {
|
|
78
|
+
constructor(bindings: { [key: string]: Command }) {
|
|
79
|
+
super({ props: { handleKeyDown: keydownHandler(bindings) } });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/// Given a set of bindings (using the same format as
|
|
84
|
+
/// [`keymap`](#keymap.keymap)), return a [keydown
|
|
85
|
+
/// handler](#view.EditorProps.handleKeyDown) that handles them.
|
|
86
|
+
export function keydownHandler(
|
|
87
|
+
bindings: { [key: string]: Command },
|
|
88
|
+
): (view: EditorView, event: KeyboardEvent) => boolean {
|
|
89
|
+
let map = normalize(bindings);
|
|
90
|
+
return function (view, event) {
|
|
91
|
+
let name = keyName(event), baseName, direct = map[modifiers(name, event)];
|
|
92
|
+
if (direct && direct(view.state, view.dispatch, view)) return true;
|
|
93
|
+
// A character key
|
|
94
|
+
if (name.length == 1 && name != ' ') {
|
|
95
|
+
if (event.shiftKey) {
|
|
96
|
+
// In case the name was already modified by shift, try looking
|
|
97
|
+
// it up without its shift modifier
|
|
98
|
+
let noShift = map[modifiers(name, event, false)];
|
|
99
|
+
if (noShift && noShift(view.state, view.dispatch, view)) return true;
|
|
100
|
+
}
|
|
101
|
+
if (
|
|
102
|
+
(event.altKey || event.metaKey || event.ctrlKey) &&
|
|
103
|
+
// Ctrl-Alt may be used for AltGr on Windows
|
|
104
|
+
!(windows && event.ctrlKey && event.altKey) &&
|
|
105
|
+
(baseName = base[event.keyCode]) && baseName != name
|
|
106
|
+
) {
|
|
107
|
+
// Try falling back to the keyCode when there's a modifier
|
|
108
|
+
// active or the character produced isn't ASCII, and our table
|
|
109
|
+
// produces a different name from the the keyCode. See #668,
|
|
110
|
+
// #1060, #1529.
|
|
111
|
+
let fromCode = map[modifiers(baseName, event)];
|
|
112
|
+
if (fromCode && fromCode(view.state, view.dispatch, view)) return true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return false;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './keymap.js';
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
export const base: Record<number, string> = {
|
|
2
|
+
8: 'Backspace',
|
|
3
|
+
9: 'Tab',
|
|
4
|
+
10: 'Enter',
|
|
5
|
+
12: 'NumLock',
|
|
6
|
+
13: 'Enter',
|
|
7
|
+
16: 'Shift',
|
|
8
|
+
17: 'Control',
|
|
9
|
+
18: 'Alt',
|
|
10
|
+
20: 'CapsLock',
|
|
11
|
+
27: 'Escape',
|
|
12
|
+
32: ' ',
|
|
13
|
+
33: 'PageUp',
|
|
14
|
+
34: 'PageDown',
|
|
15
|
+
35: 'End',
|
|
16
|
+
36: 'Home',
|
|
17
|
+
37: 'ArrowLeft',
|
|
18
|
+
38: 'ArrowUp',
|
|
19
|
+
39: 'ArrowRight',
|
|
20
|
+
40: 'ArrowDown',
|
|
21
|
+
44: 'PrintScreen',
|
|
22
|
+
45: 'Insert',
|
|
23
|
+
46: 'Delete',
|
|
24
|
+
59: ';',
|
|
25
|
+
61: '=',
|
|
26
|
+
91: 'Meta',
|
|
27
|
+
92: 'Meta',
|
|
28
|
+
106: '*',
|
|
29
|
+
107: '+',
|
|
30
|
+
108: ',',
|
|
31
|
+
109: '-',
|
|
32
|
+
110: '.',
|
|
33
|
+
111: '/',
|
|
34
|
+
144: 'NumLock',
|
|
35
|
+
145: 'ScrollLock',
|
|
36
|
+
160: 'Shift',
|
|
37
|
+
161: 'Shift',
|
|
38
|
+
162: 'Control',
|
|
39
|
+
163: 'Control',
|
|
40
|
+
164: 'Alt',
|
|
41
|
+
165: 'Alt',
|
|
42
|
+
173: '-',
|
|
43
|
+
186: ';',
|
|
44
|
+
187: '=',
|
|
45
|
+
188: ',',
|
|
46
|
+
189: '-',
|
|
47
|
+
190: '.',
|
|
48
|
+
191: '/',
|
|
49
|
+
192: '`',
|
|
50
|
+
219: '[',
|
|
51
|
+
220: '\\',
|
|
52
|
+
221: ']',
|
|
53
|
+
222: "'",
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const shift: Record<number, string> = {
|
|
57
|
+
48: ')',
|
|
58
|
+
49: '!',
|
|
59
|
+
50: '@',
|
|
60
|
+
51: '#',
|
|
61
|
+
52: '$',
|
|
62
|
+
53: '%',
|
|
63
|
+
54: '^',
|
|
64
|
+
55: '&',
|
|
65
|
+
56: '*',
|
|
66
|
+
57: '(',
|
|
67
|
+
59: ':',
|
|
68
|
+
61: '+',
|
|
69
|
+
173: '_',
|
|
70
|
+
186: ':',
|
|
71
|
+
187: '+',
|
|
72
|
+
188: '<',
|
|
73
|
+
189: '_',
|
|
74
|
+
190: '>',
|
|
75
|
+
191: '?',
|
|
76
|
+
192: '~',
|
|
77
|
+
219: '{',
|
|
78
|
+
220: '|',
|
|
79
|
+
221: '}',
|
|
80
|
+
222: '"',
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const mac = typeof navigator != 'undefined' && /Mac/.test(navigator.platform);
|
|
84
|
+
const ie = typeof navigator != 'undefined' &&
|
|
85
|
+
/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
|
|
86
|
+
|
|
87
|
+
// Fill in the digit keys
|
|
88
|
+
for (let i = 0; i < 10; i++) base[48 + i] = base[96 + i] = String(i);
|
|
89
|
+
|
|
90
|
+
// The function keys
|
|
91
|
+
for (let i = 1; i <= 24; i++) base[i + 111] = 'F' + i;
|
|
92
|
+
|
|
93
|
+
// And the alphabetic keys
|
|
94
|
+
for (let i = 65; i <= 90; i++) {
|
|
95
|
+
base[i] = String.fromCharCode(i + 32);
|
|
96
|
+
shift[i] = String.fromCharCode(i);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// For each code that doesn't have a shift-equivalent, copy the base name
|
|
100
|
+
for (const code in base) {
|
|
101
|
+
if (!shift.hasOwnProperty(code)) shift[code] = base[code];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function keyName(event: KeyboardEvent) {
|
|
105
|
+
// On macOS, keys held with Shift and Cmd don't reflect the effect of Shift in `.key`.
|
|
106
|
+
// On IE, shift effect is never included in `.key`.
|
|
107
|
+
const ignoreKey =
|
|
108
|
+
mac && event.metaKey && event.shiftKey && !event.ctrlKey && !event.altKey ||
|
|
109
|
+
ie && event.shiftKey && event.key && event.key.length == 1 ||
|
|
110
|
+
event.key == 'Unidentified';
|
|
111
|
+
let name: string = (!ignoreKey && event.key) ||
|
|
112
|
+
(event.shiftKey ? shift : base)[event.keyCode] ||
|
|
113
|
+
event.key || 'Unidentified';
|
|
114
|
+
// Edge sometimes produces wrong names (Issue #3)
|
|
115
|
+
if (name == 'Esc') name = 'Escape';
|
|
116
|
+
if (name == 'Del') name = 'Delete';
|
|
117
|
+
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8860571/
|
|
118
|
+
if (name == 'Left') name = 'ArrowLeft';
|
|
119
|
+
if (name == 'Up') name = 'ArrowUp';
|
|
120
|
+
if (name == 'Right') name = 'ArrowRight';
|
|
121
|
+
if (name == 'Down') name = 'ArrowDown';
|
|
122
|
+
return name;
|
|
123
|
+
}
|