mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-04 08:28:17 +08:00
Make elements default constructible, testing wip
This commit is contained in:
@@ -17,11 +17,11 @@ export default class Copy extends IInput {
|
||||
}
|
||||
|
||||
listenEvents() {
|
||||
document.body.addEventListener("copy", this.#copyHandler)
|
||||
window.addEventListener("copy", this.#copyHandler)
|
||||
}
|
||||
|
||||
unlistenEvents() {
|
||||
document.body.removeEventListener("copy", this.#copyHandler)
|
||||
window.removeEventListener("copy", this.#copyHandler)
|
||||
}
|
||||
|
||||
copied() {
|
||||
|
||||
@@ -2,7 +2,10 @@ import ElementFactory from "../../element/ElementFactory"
|
||||
import IInput from "../IInput"
|
||||
import ObjectSerializer from "../../serialization/ObjectSerializer"
|
||||
|
||||
/** @typedef {import("../../element/NodeElement").default} NodeElement */
|
||||
/**
|
||||
* @typedef {import("../../element/NodeElement").default} NodeElement
|
||||
* @typedef {import("../../element/NodeElement").NodeElementConstructor} NodeElementConstructor
|
||||
*/
|
||||
|
||||
export default class Paste extends IInput {
|
||||
|
||||
@@ -20,11 +23,11 @@ export default class Paste extends IInput {
|
||||
}
|
||||
|
||||
listenEvents() {
|
||||
document.body.addEventListener("paste", this.#pasteHandle)
|
||||
window.addEventListener("paste", this.#pasteHandle)
|
||||
}
|
||||
|
||||
unlistenEvents() {
|
||||
document.body.removeEventListener("paste", this.#pasteHandle)
|
||||
window.removeEventListener("paste", this.#pasteHandle)
|
||||
}
|
||||
|
||||
pasted(value) {
|
||||
@@ -33,8 +36,8 @@ export default class Paste extends IInput {
|
||||
let count = 0
|
||||
let nodes = Paste.#serializer.readMultiple(value).map(entity => {
|
||||
/** @type {NodeElement} */
|
||||
// @ts-expect-error
|
||||
let node = new (ElementFactory.getConstructor("ueb-node"))(entity)
|
||||
let node = /** @type {NodeElementConstructor} */(ElementFactory.getConstructor("ueb-node"))
|
||||
.newObject(entity)
|
||||
top += node.locationY
|
||||
left += node.locationX
|
||||
++count
|
||||
|
||||
@@ -3,8 +3,9 @@ import ElementFactory from "../../element/ElementFactory"
|
||||
import IMouseClickDrag from "./IMouseClickDrag"
|
||||
|
||||
/**
|
||||
* @typedef {import("../../element/PinElement").default} PinElement
|
||||
* @typedef {import("../../element/LinkElement").default} LinkElement
|
||||
* @typedef {import("../../element/LinkElement").LinkElementConstructor} LinkElementConstructor
|
||||
* @typedef {import("../../element/PinElement").default} PinElement
|
||||
* @typedef {import("../../template/node/KnotNodeTemplate").default} KnotNodeTemplate
|
||||
*/
|
||||
|
||||
@@ -71,8 +72,8 @@ export default class MouseCreateLink extends IMouseClickDrag {
|
||||
this.#knotPin = this.target
|
||||
}
|
||||
/** @type {LinkElement} */
|
||||
// @ts-expect-error
|
||||
this.link = new (ElementFactory.getConstructor("ueb-link"))(this.target, null)
|
||||
this.link = /** @type {LinkElementConstructor} */(ElementFactory.getConstructor("ueb-link"))
|
||||
.newObject(this.target, null)
|
||||
this.blueprint.linksContainerElement.prepend(this.link)
|
||||
this.link.setMessagePlaceNode()
|
||||
this.#listenedPins = this.blueprint.querySelectorAll("ueb-pin")
|
||||
|
||||
Reference in New Issue
Block a user