Refactoring and fixes

This commit is contained in:
barsdeveloper
2022-02-14 21:58:57 +01:00
parent a0fcc23e31
commit a877809538
8 changed files with 261 additions and 183 deletions

View File

@@ -3,23 +3,22 @@ import ObjectSerializer from "../../serialization/ObjectSerializer"
export default class Copy extends Context {
#copyHandler
constructor(target, blueprint, options = {}) {
options.wantsFocusCallback = true
super(target, blueprint, options)
this.serializer = new ObjectSerializer()
let self = this
this.copyHandler = _ => {
self.copied()
return true
}
this.#copyHandler = _ => self.copied()
}
listenEvents() {
document.body.addEventListener("copy", this.copyHandler)
document.body.addEventListener("copy", this.#copyHandler)
}
unlistenEvents() {
document.body.removeEventListener("copy", this.copyHandler)
document.body.removeEventListener("copy", this.#copyHandler)
}
copied() {

View File

@@ -4,20 +4,22 @@ import Context from "../Context"
export default class Paste extends Context {
#pasteHandle
constructor(target, blueprint, options = {}) {
options.wantsFocusCallback = true
super(target, blueprint, options)
this.serializer = new ObjectSerializer()
let self = this
this.pasteHandle = e => self.pasted(e.clipboardData.getData("Text"))
this.#pasteHandle = e => self.pasted(e.clipboardData.getData("Text"))
}
listenEvents() {
document.body.addEventListener("paste", this.pasteHandle)
document.body.addEventListener("paste", this.#pasteHandle)
}
unlistenEvents() {
document.body.removeEventListener("paste", this.pasteHandle)
document.body.removeEventListener("paste", this.#pasteHandle)
}
pasted(value) {