mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-03 23:55:04 +08:00
Ability to cancel nodes implemented
This commit is contained in:
1294
dist/ueblueprint.js
vendored
1294
dist/ueblueprint.js
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,14 +1,15 @@
|
||||
import BlueprintTemplate from "./template/BlueprintTemplate"
|
||||
import Copy from "./input/Copy"
|
||||
import DragScroll from "./input/DragScroll"
|
||||
import GraphElement from "./graph/GraphElement"
|
||||
import GraphSelector from "./graph/GraphSelector"
|
||||
import KeyboardCanc from "./input/KeyboardCanc"
|
||||
import MouseTracking from "./input/MouseTracking"
|
||||
import Paste from "./input/Paste"
|
||||
import Select from "./input/Select"
|
||||
import Unfocus from "./input/Unfocus"
|
||||
import Utility from "./Utility"
|
||||
import Zoom from "./input/Zoom"
|
||||
import Copy from "./input/Copy"
|
||||
|
||||
/** @typedef {import("./graph/GraphNode").default} GraphNode */
|
||||
export default class Blueprint extends GraphElement {
|
||||
@@ -18,7 +19,7 @@ export default class Blueprint extends GraphElement {
|
||||
/** @type {BlueprintTemplate} */
|
||||
this.template
|
||||
/** @type {GraphNode[]}" */
|
||||
this.nodes = new Array()
|
||||
this.nodes = []
|
||||
this.expandGridSize = 400
|
||||
/** @type {number[]} */
|
||||
this.additional = /*[2 * this.expandGridSize, 2 * this.expandGridSize]*/[0, 0]
|
||||
@@ -36,8 +37,6 @@ export default class Blueprint extends GraphElement {
|
||||
this.selectorElement = null
|
||||
/** @type {HTMLElement} */
|
||||
this.nodesContainerElement = null
|
||||
this.dragObject = null
|
||||
this.selectObject = null
|
||||
/** @type {number} */
|
||||
this.zoom = 0
|
||||
/** @type {HTMLElement} */
|
||||
@@ -67,22 +66,21 @@ export default class Blueprint extends GraphElement {
|
||||
|
||||
this.copyObject = new Copy(this.getGridDOMElement(), this)
|
||||
this.pasteObject = new Paste(this.getGridDOMElement(), this)
|
||||
|
||||
this.dragObject = new DragScroll(this.getGridDOMElement(), this, {
|
||||
clickButton: 2,
|
||||
moveEverywhere: true,
|
||||
exitAnyButton: false
|
||||
})
|
||||
this.cancObject = new KeyboardCanc(this.getGridDOMElement(), this)
|
||||
|
||||
this.zoomObject = new Zoom(this.getGridDOMElement(), this, {
|
||||
looseTarget: true
|
||||
})
|
||||
|
||||
this.selectObject = new Select(this.getGridDOMElement(), this, {
|
||||
clickButton: 0,
|
||||
moveEverywhere: true,
|
||||
exitAnyButton: true
|
||||
})
|
||||
this.dragObject = new DragScroll(this.getGridDOMElement(), this, {
|
||||
clickButton: 2,
|
||||
moveEverywhere: true,
|
||||
exitAnyButton: false
|
||||
})
|
||||
|
||||
this.unfocusObject = new Unfocus(this.getGridDOMElement(), this)
|
||||
this.mouseTrackingObject = new MouseTracking(this.getGridDOMElement(), this)
|
||||
@@ -308,12 +306,32 @@ export default class Blueprint extends GraphElement {
|
||||
[...graphNodes].reduce(
|
||||
(s, e) => {
|
||||
s.push(e)
|
||||
if (this.nodesContainerElement) {
|
||||
this.nodesContainerElement.appendChild(e)
|
||||
}
|
||||
return s
|
||||
},
|
||||
this.nodes)
|
||||
if (this.nodesContainerElement) {
|
||||
this.nodesContainerElement.append(...graphNodes)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {...GraphNode} graphNodes
|
||||
*/
|
||||
deleteNode(...graphNodes) {
|
||||
let deleteNodes = [...graphNodes]
|
||||
if (deleteNodes.length == 0) {
|
||||
return
|
||||
}
|
||||
let currentDeleteI = 0
|
||||
this.nodes = this.nodes.filter(v => {
|
||||
if (v == deleteNodes[currentDeleteI]) {
|
||||
++currentDeleteI
|
||||
v.remove()
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
setFocused(value = true) {
|
||||
|
||||
14
js/input/KeyboardCanc.js
Normal file
14
js/input/KeyboardCanc.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import KeyboardShortcut from "./KeyboardShortcut";
|
||||
|
||||
|
||||
export default class KeyvoardCanc extends KeyboardShortcut {
|
||||
|
||||
constructor(target, blueprint, options = {}) {
|
||||
options.key = "Delete"
|
||||
super(target, blueprint, options)
|
||||
}
|
||||
|
||||
fire() {
|
||||
this.blueprint.deleteNode(...this.blueprint.getNodes(true))
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import Context from "./Context"
|
||||
|
||||
export default class KeyboardShortcut extends Context {
|
||||
|
||||
constructor(target, blueprint, options) {
|
||||
constructor(target, blueprint, options = {}) {
|
||||
options.wantsFocusCallback = true
|
||||
super(target, blueprint, options)
|
||||
|
||||
@@ -15,7 +15,6 @@ export default class KeyboardShortcut extends Context {
|
||||
|
||||
let self = this
|
||||
this.keyDownHandler = e => {
|
||||
e.preventDefault()
|
||||
if (
|
||||
e.code == self.key
|
||||
&& e.ctrlKey === self.ctrlKey
|
||||
|
||||
@@ -86,7 +86,7 @@ export default class MouseClickDrag extends Pointing {
|
||||
this.target.removeEventListener("mousedown", this.mouseDownHandler)
|
||||
if (this.clickButton == 2) {
|
||||
this.target.removeEventListener("contextmenu", this.preventDefault)
|
||||
} blueprintunfocusHandler
|
||||
}
|
||||
}
|
||||
|
||||
/* Subclasses will override the following methods */
|
||||
|
||||
Reference in New Issue
Block a user