blob: 1161cde9c681e3937a6c697aaf8bb758b43d6a7d (
plain) (
blame)
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
48
49
50
51
52
53
54
55
56
57
58
|
import tinymce, { Editor } from 'tinymce';
import 'tinymce/icons/default';
import 'tinymce/themes/silver';
import 'tinymce/skins/ui/oxide/skin.css';
import Chit from './Chit';
export default class WYSiWYG {
#id = 'tinymce'
#bSave: HTMLButtonElement
#bCancel: HTMLButtonElement
constructor() {
tinymce.init({
selector: this.idAsSel,
});
const s = document.getElementsByClassName("tox-statusbar__branding")[0] as HTMLSpanElement;
const t = document.getElementsByClassName("tox-tinymce")[0] as HTMLDivElement;
const tf = s.parentElement as HTMLDivElement
const tfp = tf.parentElement as HTMLDivElement
tf.removeChild(s)
t.id = "wysiwyg"
tfp.id = "tfp";
this.#bSave = document.createElement("button")
this.#bCancel = document.createElement("button")
this.#bSave.id = "save"
this.#bCancel.id = "cancel"
tf.append(this.#bSave, this.#bCancel)
this.#bSave.onclick = () => this.setContent(this.content + "asd");
this.#bCancel.onclick = () => this.hide();
this.hide()
}
get #tmce(): Editor {
return tinymce.get(this.#id);
}
show(c: Chit) {
console.log(c.txt)
this.#tmce.show();
this.setContent(c.txt)
}
hide() {
this.#tmce.hide();
}
setContent(c: string) {
this.#tmce.setContent(c);
}
get content(): string {
return this.#tmce.getContent()
}
get idAsSel() {
return '#' + this.#id;
}
}
|