forked from SparkDevNetwork/Rock
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathraw.ts
More file actions
47 lines (38 loc) · 1.3 KB
/
raw.ts
File metadata and controls
47 lines (38 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { BlockToolConstructorOptions } from "@editorjs/editorjs";
import EditorRaw, { RawData } from "@editorjs/raw";
export class Raw extends EditorRaw {
constructor(config: BlockToolConstructorOptions<RawData, any>) {
super(config);
}
render() {
const container = super.render();
const textarea = container.querySelector("textarea");
if (textarea) {
textarea.spellcheck = false;
// Workaround for https://github.com/editor-js/raw/issues/16
if (navigator.userAgent.toLowerCase().includes("firefox")) {
const blockKeys = ["ArrowLeft", "ArrowUp", "Backspace"];
textarea.addEventListener("keydown", function (event) {
if (blockKeys.includes(event.key)) {
event.stopPropagation();
}
});
}
}
return container;
}
static get toolbox() {
const config = EditorRaw.toolbox;
if (Array.isArray(config)) {
for (const item of config) {
if (item.title === "Raw HTML") {
item.title = "Raw HTML/Lava";
}
}
}
else {
config.title = "Raw HTML/Lava";
}
return config;
}
}