|
@@ -144,28 +144,79 @@ class Command {
|
|
|
},
|
|
|
method: function(graph) {
|
|
|
const selectedItems = graph.get('selectedItems')
|
|
|
- console.log(selectedItems, 'items')
|
|
|
if (selectedItems && selectedItems.length > 0) {
|
|
|
const item = graph.findById(selectedItems[0])
|
|
|
- const itemStyles = item.getOriginStyle()
|
|
|
- console.log(item.getOriginStyle())
|
|
|
+ const itemModel = item.getModel()
|
|
|
item.updatePosition({
|
|
|
- x: itemStyles.x,
|
|
|
- y: itemStyles.y + 5
|
|
|
+ x: itemModel.x,
|
|
|
+ y: itemModel.y - 1
|
|
|
})
|
|
|
- // item.toFront()
|
|
|
- graph.paint()
|
|
|
+ item.toFront()
|
|
|
+ graph.refresh()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ cmdPlugin.registerCommand('toDown', {
|
|
|
+ queue: false,
|
|
|
+ enable: function(graph) {
|
|
|
+ const mode = graph.getCurrentMode()
|
|
|
+ const selectedItems = graph.get('selectedItems')
|
|
|
+ return mode === 'edit' && selectedItems && selectedItems.length > 0
|
|
|
+ },
|
|
|
+ method: function(graph) {
|
|
|
+ const selectedItems = graph.get('selectedItems')
|
|
|
+ if (selectedItems && selectedItems.length > 0) {
|
|
|
+ const item = graph.findById(selectedItems[0])
|
|
|
+ const itemModel = item.getModel()
|
|
|
+ item.updatePosition({
|
|
|
+ x: itemModel.x,
|
|
|
+ y: itemModel.y + 1
|
|
|
+ })
|
|
|
+ item.toFront()
|
|
|
+ graph.refresh()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ cmdPlugin.registerCommand('toLeft', {
|
|
|
+ queue: false,
|
|
|
+ enable: function(graph) {
|
|
|
+ const mode = graph.getCurrentMode()
|
|
|
+ const selectedItems = graph.get('selectedItems')
|
|
|
+ return mode === 'edit' && selectedItems && selectedItems.length > 0
|
|
|
+ },
|
|
|
+ method: function(graph) {
|
|
|
+ const selectedItems = graph.get('selectedItems')
|
|
|
+ if (selectedItems && selectedItems.length > 0) {
|
|
|
+ const item = graph.findById(selectedItems[0])
|
|
|
+ const itemModel = item.getModel()
|
|
|
+ item.updatePosition({
|
|
|
+ x: itemModel.x - 1,
|
|
|
+ y: itemModel.y
|
|
|
+ })
|
|
|
+ item.toFront()
|
|
|
+ graph.refresh()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ cmdPlugin.registerCommand('toRight', {
|
|
|
+ queue: false,
|
|
|
+ enable: function(graph) {
|
|
|
+ const mode = graph.getCurrentMode()
|
|
|
+ const selectedItems = graph.get('selectedItems')
|
|
|
+ return mode === 'edit' && selectedItems && selectedItems.length > 0
|
|
|
+ },
|
|
|
+ method: function(graph) {
|
|
|
+ const selectedItems = graph.get('selectedItems')
|
|
|
+ if (selectedItems && selectedItems.length > 0) {
|
|
|
+ const item = graph.findById(selectedItems[0])
|
|
|
+ const itemModel = item.getModel()
|
|
|
+ item.updatePosition({
|
|
|
+ x: itemModel.x + 1,
|
|
|
+ y: itemModel.y
|
|
|
+ })
|
|
|
+ item.toFront()
|
|
|
+ graph.refresh()
|
|
|
}
|
|
|
- // this.pasteData = clone(manager.clipboard[0])
|
|
|
- // const addModel = this.pasteData.model
|
|
|
- // addModel.x && (addModel.x += 10)
|
|
|
- // addModel.y && (addModel.y += 10)
|
|
|
- // const { clazz = 'userTask' } = addModel
|
|
|
- // const timestamp = new Date().getTime()
|
|
|
- // const id = clazz + timestamp
|
|
|
- // addModel.id = id
|
|
|
- // const item = graph.add(this.pasteData.type, addModel)
|
|
|
- // item.toFront()
|
|
|
}
|
|
|
})
|
|
|
cmdPlugin.registerCommand('redo', {
|