mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-03-03 05:27:31 +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 BlueprintTemplate from "./template/BlueprintTemplate"
|
||||||
|
import Copy from "./input/Copy"
|
||||||
import DragScroll from "./input/DragScroll"
|
import DragScroll from "./input/DragScroll"
|
||||||
import GraphElement from "./graph/GraphElement"
|
import GraphElement from "./graph/GraphElement"
|
||||||
import GraphSelector from "./graph/GraphSelector"
|
import GraphSelector from "./graph/GraphSelector"
|
||||||
|
import KeyboardCanc from "./input/KeyboardCanc"
|
||||||
import MouseTracking from "./input/MouseTracking"
|
import MouseTracking from "./input/MouseTracking"
|
||||||
import Paste from "./input/Paste"
|
import Paste from "./input/Paste"
|
||||||
import Select from "./input/Select"
|
import Select from "./input/Select"
|
||||||
import Unfocus from "./input/Unfocus"
|
import Unfocus from "./input/Unfocus"
|
||||||
import Utility from "./Utility"
|
import Utility from "./Utility"
|
||||||
import Zoom from "./input/Zoom"
|
import Zoom from "./input/Zoom"
|
||||||
import Copy from "./input/Copy"
|
|
||||||
|
|
||||||
/** @typedef {import("./graph/GraphNode").default} GraphNode */
|
/** @typedef {import("./graph/GraphNode").default} GraphNode */
|
||||||
export default class Blueprint extends GraphElement {
|
export default class Blueprint extends GraphElement {
|
||||||
@@ -18,7 +19,7 @@ export default class Blueprint extends GraphElement {
|
|||||||
/** @type {BlueprintTemplate} */
|
/** @type {BlueprintTemplate} */
|
||||||
this.template
|
this.template
|
||||||
/** @type {GraphNode[]}" */
|
/** @type {GraphNode[]}" */
|
||||||
this.nodes = new Array()
|
this.nodes = []
|
||||||
this.expandGridSize = 400
|
this.expandGridSize = 400
|
||||||
/** @type {number[]} */
|
/** @type {number[]} */
|
||||||
this.additional = /*[2 * this.expandGridSize, 2 * this.expandGridSize]*/[0, 0]
|
this.additional = /*[2 * this.expandGridSize, 2 * this.expandGridSize]*/[0, 0]
|
||||||
@@ -36,8 +37,6 @@ export default class Blueprint extends GraphElement {
|
|||||||
this.selectorElement = null
|
this.selectorElement = null
|
||||||
/** @type {HTMLElement} */
|
/** @type {HTMLElement} */
|
||||||
this.nodesContainerElement = null
|
this.nodesContainerElement = null
|
||||||
this.dragObject = null
|
|
||||||
this.selectObject = null
|
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
this.zoom = 0
|
this.zoom = 0
|
||||||
/** @type {HTMLElement} */
|
/** @type {HTMLElement} */
|
||||||
@@ -67,22 +66,21 @@ export default class Blueprint extends GraphElement {
|
|||||||
|
|
||||||
this.copyObject = new Copy(this.getGridDOMElement(), this)
|
this.copyObject = new Copy(this.getGridDOMElement(), this)
|
||||||
this.pasteObject = new Paste(this.getGridDOMElement(), this)
|
this.pasteObject = new Paste(this.getGridDOMElement(), this)
|
||||||
|
this.cancObject = new KeyboardCanc(this.getGridDOMElement(), this)
|
||||||
this.dragObject = new DragScroll(this.getGridDOMElement(), this, {
|
|
||||||
clickButton: 2,
|
|
||||||
moveEverywhere: true,
|
|
||||||
exitAnyButton: false
|
|
||||||
})
|
|
||||||
|
|
||||||
this.zoomObject = new Zoom(this.getGridDOMElement(), this, {
|
this.zoomObject = new Zoom(this.getGridDOMElement(), this, {
|
||||||
looseTarget: true
|
looseTarget: true
|
||||||
})
|
})
|
||||||
|
|
||||||
this.selectObject = new Select(this.getGridDOMElement(), this, {
|
this.selectObject = new Select(this.getGridDOMElement(), this, {
|
||||||
clickButton: 0,
|
clickButton: 0,
|
||||||
moveEverywhere: true,
|
moveEverywhere: true,
|
||||||
exitAnyButton: true
|
exitAnyButton: true
|
||||||
})
|
})
|
||||||
|
this.dragObject = new DragScroll(this.getGridDOMElement(), this, {
|
||||||
|
clickButton: 2,
|
||||||
|
moveEverywhere: true,
|
||||||
|
exitAnyButton: false
|
||||||
|
})
|
||||||
|
|
||||||
this.unfocusObject = new Unfocus(this.getGridDOMElement(), this)
|
this.unfocusObject = new Unfocus(this.getGridDOMElement(), this)
|
||||||
this.mouseTrackingObject = new MouseTracking(this.getGridDOMElement(), this)
|
this.mouseTrackingObject = new MouseTracking(this.getGridDOMElement(), this)
|
||||||
@@ -308,12 +306,32 @@ export default class Blueprint extends GraphElement {
|
|||||||
[...graphNodes].reduce(
|
[...graphNodes].reduce(
|
||||||
(s, e) => {
|
(s, e) => {
|
||||||
s.push(e)
|
s.push(e)
|
||||||
|
if (this.nodesContainerElement) {
|
||||||
|
this.nodesContainerElement.appendChild(e)
|
||||||
|
}
|
||||||
return s
|
return s
|
||||||
},
|
},
|
||||||
this.nodes)
|
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) {
|
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 {
|
export default class KeyboardShortcut extends Context {
|
||||||
|
|
||||||
constructor(target, blueprint, options) {
|
constructor(target, blueprint, options = {}) {
|
||||||
options.wantsFocusCallback = true
|
options.wantsFocusCallback = true
|
||||||
super(target, blueprint, options)
|
super(target, blueprint, options)
|
||||||
|
|
||||||
@@ -15,7 +15,6 @@ export default class KeyboardShortcut extends Context {
|
|||||||
|
|
||||||
let self = this
|
let self = this
|
||||||
this.keyDownHandler = e => {
|
this.keyDownHandler = e => {
|
||||||
e.preventDefault()
|
|
||||||
if (
|
if (
|
||||||
e.code == self.key
|
e.code == self.key
|
||||||
&& e.ctrlKey === self.ctrlKey
|
&& e.ctrlKey === self.ctrlKey
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ export default class MouseClickDrag extends Pointing {
|
|||||||
this.target.removeEventListener("mousedown", this.mouseDownHandler)
|
this.target.removeEventListener("mousedown", this.mouseDownHandler)
|
||||||
if (this.clickButton == 2) {
|
if (this.clickButton == 2) {
|
||||||
this.target.removeEventListener("contextmenu", this.preventDefault)
|
this.target.removeEventListener("contextmenu", this.preventDefault)
|
||||||
} blueprintunfocusHandler
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Subclasses will override the following methods */
|
/* Subclasses will override the following methods */
|
||||||
|
|||||||
Reference in New Issue
Block a user