be4 traversing mod
This commit is contained in:
parent
e370d77f15
commit
f7119040b1
9 changed files with 123 additions and 64 deletions
|
|
@ -58,12 +58,18 @@ var handleClick = function(event) {
|
|||
|
||||
if (parent !== widgetManager) {
|
||||
|
||||
if (event.target.tagName !== 'LI') actions.push({
|
||||
label: icon('project-diagram') + ' ' + locales('editor_show_in_tree'),
|
||||
action: ()=>{
|
||||
editor.widgetTree.showWidget(editor.selectedWidgets[0])
|
||||
}
|
||||
})
|
||||
if (event.target.tagName !== 'LI') {
|
||||
actions.push({
|
||||
label: icon('project-diagram') + ' ' + locales('editor_show_in_tree'),
|
||||
action: ()=>{
|
||||
editor.widgetTree.showWidget(editor.selectedWidgets[0])
|
||||
}
|
||||
})
|
||||
actions.push({
|
||||
separator: true
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
actions.push({
|
||||
label: icon('copy') + ' ' + locales('editor_copy'),
|
||||
|
|
|
|||
|
|
@ -10,12 +10,13 @@ var {updateWidget, incrementWidget} = require('./data-workers'),
|
|||
UiTree = require('../ui/ui-tree'),
|
||||
UiDragResize = require('../ui/ui-dragresize'),
|
||||
sidepanel = require('../ui/ui-sidepanel'),
|
||||
ipc = require('../ipc'),
|
||||
html = require('nanohtml'),
|
||||
sessionManager
|
||||
|
||||
const HISTORY_SIZE = 50
|
||||
|
||||
var Editor = class Editor {
|
||||
class Editor {
|
||||
|
||||
constructor() {
|
||||
|
||||
|
|
@ -88,6 +89,11 @@ var Editor = class Editor {
|
|||
|
||||
this.clipboard = null
|
||||
this.idClipboard = null
|
||||
ipc.on('clipboard', (data)=>{
|
||||
this.clipboard = data.clipboard
|
||||
this.idClipboard = data.idClipboard
|
||||
})
|
||||
|
||||
|
||||
this.enabled = false
|
||||
this.grid = true
|
||||
|
|
@ -102,8 +108,9 @@ var Editor = class Editor {
|
|||
this.historyState = -1
|
||||
this.historySession = null
|
||||
|
||||
this.mousePosition = {x:0, y:0}
|
||||
this.mousePosition = {}
|
||||
this.mouveMoveHandler = this.mouseMove.bind(this)
|
||||
this.mouveLeaveHandler = this.mouseLeave.bind(this)
|
||||
|
||||
keyboardJS.withContext('editing', ()=>{
|
||||
|
||||
|
|
@ -331,7 +338,8 @@ var Editor = class Editor {
|
|||
|
||||
keyboardJS.setContext('editing')
|
||||
|
||||
document.body.addEventListener('mousemove', this.mouveMoveHandler)
|
||||
this.oscContainer.addEventListener('mousemove', this.mouveMoveHandler)
|
||||
this.oscContainer.addEventListener('mouseleave', this.mouveLeaveHandler)
|
||||
|
||||
this.selectarea.enable()
|
||||
|
||||
|
|
@ -349,7 +357,8 @@ var Editor = class Editor {
|
|||
|
||||
keyboardJS.setContext('global')
|
||||
|
||||
document.body.removeEventListener('mousemove', this.mouveMoveHandler)
|
||||
this.oscContainer.removeEventListener('mousemove', this.mouveMoveHandler)
|
||||
this.oscContainer.removeEventListener('mouseleave', this.mouveLeaveHandler)
|
||||
|
||||
sidepanel.left.disable()
|
||||
sidepanel.right.disable()
|
||||
|
|
@ -444,19 +453,23 @@ var Editor = class Editor {
|
|||
|
||||
}
|
||||
|
||||
mouseLeave(e) {
|
||||
|
||||
this.mousePosition = {}
|
||||
|
||||
}
|
||||
|
||||
copyWidget() {
|
||||
|
||||
if (!this.selectedWidgets.length) return
|
||||
|
||||
var data = this.selectedWidgets.map((w)=>w.props)
|
||||
this.clipboard = deepCopy(this.selectedWidgets.map((w)=>w.props))
|
||||
this.idClipboard = this.selectedWidgets[0].getProp('id')
|
||||
|
||||
this.clipboard = deepCopy(data)
|
||||
|
||||
if (data.length == 1) {
|
||||
this.idClipboard = this.selectedWidgets[0].getProp('id')
|
||||
} else {
|
||||
this.idClipboard = null
|
||||
}
|
||||
ipc.send('clipboard', {
|
||||
clipboard: this.clipboard,
|
||||
idClipboard: this.idClipboard
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -464,19 +477,13 @@ var Editor = class Editor {
|
|||
|
||||
if (!this.selectedWidgets.length) return
|
||||
|
||||
this.copyWidget()
|
||||
|
||||
var parent = this.selectedWidgets[0].parent,
|
||||
index = this.selectedWidgets.map(w => parent.children.indexOf(w)).sort((a,b)=>{return b-a}),
|
||||
data = this.selectedWidgets.map((w)=>w.props),
|
||||
removedIndexes = []
|
||||
|
||||
this.clipboard = deepCopy(data)
|
||||
|
||||
if (data.length == 1) {
|
||||
this.idClipboard = this.selectedWidgets[0].getProp('id')
|
||||
} else {
|
||||
this.idClipboard = null
|
||||
}
|
||||
|
||||
for (var i of index) {
|
||||
removedIndexes.push(i)
|
||||
parent.props.widgets.splice(i,1)
|
||||
|
|
@ -499,39 +506,53 @@ var Editor = class Editor {
|
|||
this.clipboard[0].type !== 'tab' && this.selectedWidgets[0].childrenType === 'tab'
|
||||
) return
|
||||
|
||||
|
||||
var data = this.selectedWidgets.map((w)=>w.props)
|
||||
|
||||
var pastedData = deepCopy(this.clipboard),
|
||||
minTop = Infinity,
|
||||
minLeft = Infinity,
|
||||
store = this.clipboard[0].type === 'tab' ? 'tabs' : 'widgets'
|
||||
minLeft = Infinity
|
||||
|
||||
for (let i in pastedData) {
|
||||
if (increment) pastedData[i] = incrementWidget(pastedData[i])
|
||||
if (!isNaN(pastedData[i]).top && pastedData[i].top < minTop) {
|
||||
minTop = pastedData[i].top
|
||||
}
|
||||
if (!isNaN(pastedData[i]).left && pastedData[i].left < minLeft) {
|
||||
minLeft = pastedData[i].left
|
||||
}
|
||||
if (increment) {
|
||||
pastedData = pastedData.map(x=>incrementWidget(x))
|
||||
}
|
||||
|
||||
for (let i in pastedData) {
|
||||
|
||||
if (!isNaN(pastedData[i].left)) pastedData[i].left = pastedData[i].left - minLeft + x
|
||||
if (!isNaN(pastedData[i].top)) pastedData[i].top = pastedData[i].top - minTop + y
|
||||
if (x !== undefined) {
|
||||
|
||||
for (let i in pastedData) {
|
||||
|
||||
if (!isNaN(pastedData[i]).top && pastedData[i].top < minTop) {
|
||||
minTop = pastedData[i].top
|
||||
}
|
||||
|
||||
if (!isNaN(pastedData[i]).left && pastedData[i].left < minLeft) {
|
||||
minLeft = pastedData[i].left
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (let i in pastedData) {
|
||||
|
||||
if (!isNaN(pastedData[i].left)) pastedData[i].left = pastedData[i].left - minLeft + x
|
||||
if (!isNaN(pastedData[i].top)) pastedData[i].top = pastedData[i].top - minTop + y
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
data[0][store] = data[0][store] || []
|
||||
data[0][store] = data[0][store].concat(pastedData)
|
||||
|
||||
// paste data
|
||||
|
||||
var store = this.clipboard[0].type === 'tab' ? 'tabs' : 'widgets'
|
||||
|
||||
this.selectedWidgets[0].props[store] = this.selectedWidgets[0].props[store] || []
|
||||
this.selectedWidgets[0].props[store] = this.selectedWidgets[0].props[store].concat(pastedData)
|
||||
|
||||
var indexes = {addedIndexes: []}
|
||||
for (let i = 0; i < pastedData.length; i++) {
|
||||
indexes.addedIndexes.push(data[0][store].length - 1 - i )
|
||||
indexes.addedIndexes.push(this.selectedWidgets[0].props[store].length - 1 - i )
|
||||
}
|
||||
|
||||
updateWidget(this.selectedWidgets[0], indexes)
|
||||
|
||||
this.pushHistory(indexes)
|
||||
|
||||
}
|
||||
|
|
@ -547,23 +568,25 @@ var Editor = class Editor {
|
|||
this.clipboard[0].type !== 'tab' && this.selectedWidgets[0].childrenType === 'tab'
|
||||
) return
|
||||
|
||||
var data = this.selectedWidgets.map((w)=>w.props)
|
||||
|
||||
var clone = {type: 'clone', widgetId: this.idClipboard},
|
||||
pastedData = deepCopy(this.clipboard)
|
||||
|
||||
clone.width = pastedData.width
|
||||
clone.height = pastedData.height
|
||||
clone.css = pastedData.css
|
||||
clone.width = pastedData[0].width
|
||||
clone.height = pastedData[0].height
|
||||
|
||||
|
||||
clone.left = x
|
||||
clone.top = y
|
||||
if (x !== undefined) {
|
||||
|
||||
data[0].widgets = data[0].widgets || []
|
||||
data[0].widgets.push(clone)
|
||||
clone.left = x
|
||||
clone.top = y
|
||||
|
||||
}
|
||||
|
||||
this.selectedWidgets[0].props.widgets = this.selectedWidgets[0].props.widgets || []
|
||||
this.selectedWidgets[0].props.widgets.push(clone)
|
||||
|
||||
var indexes = {addedIndexes: [this.selectedWidgets[0].props.widgets.length -1]}
|
||||
|
||||
var indexes = {addedIndexes: [data[0].widgets.length -1]}
|
||||
updateWidget(this.selectedWidgets[0], indexes)
|
||||
this.pushHistory(indexes)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@ var Panel = require('./panel'),
|
|||
StaticProperties = require('../mixins/static_properties'),
|
||||
parser = require('../../parser'),
|
||||
{deepCopy} = require('../../utils'),
|
||||
html = require('nanohtml'),
|
||||
{enableTraversingGestures, disableTraversingGestures} = require('../../events/drag')
|
||||
|
||||
html = require('nanohtml')
|
||||
|
||||
|
||||
class Matrix extends StaticProperties(Panel, {scroll: false}) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ $line-height: 30rem;
|
|||
--alpha-fill: 0.75;
|
||||
|
||||
position:fixed;
|
||||
z-index: 999999999;
|
||||
z-index: 9999999;
|
||||
background: var(--color-context-menu);
|
||||
box-shadow: 0 0 0 0.5rem rgba(0, 0, 0, 0.15) inset;
|
||||
text-transform: none;
|
||||
|
|
|
|||
22
src/scss/ui/grid.scss
Normal file
22
src/scss/ui/grid.scss
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
.editor-enabled {
|
||||
&:not(.no-grid) {
|
||||
.root-container,
|
||||
.tab-container,
|
||||
.modal-container,
|
||||
.panel-container {
|
||||
> inner {
|
||||
background-image: linear-gradient(to bottom, var(--color-grid) 1rem, transparent 1rem),
|
||||
linear-gradient(to right, var(--color-grid) 1rem, transparent 1rem);
|
||||
--size: calc(var(--grid-width) * 1rem);
|
||||
background-size: var(--size) var(--size);
|
||||
background-attachment: local;
|
||||
background-position: 0rem 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.widget:not(.not-editable) {
|
||||
pointer-events: initial!important;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -15,8 +15,8 @@ $padding: 8rem;
|
|||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
background: white;
|
||||
opacity: .03;
|
||||
background: black;
|
||||
opacity: .3;
|
||||
pointer-events: none;
|
||||
// animation: popup-backdrop-fade-in .25s forwards;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ osc-toolbar {
|
|||
max-width:var(--size);
|
||||
min-width:var(--size);
|
||||
text-align: center;
|
||||
z-index: 999999999;
|
||||
z-index: 99999999;
|
||||
cursor: pointer;
|
||||
&:after {
|
||||
transition: text-shadow .1s, color .1s;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ var path = require('path'),
|
|||
theme = require('./theme')
|
||||
|
||||
var widgetHashTable = {},
|
||||
sessionBackups = {}
|
||||
sessionBackups = {},
|
||||
clipboard = {clipboard: null, idClipboard: null}
|
||||
|
||||
module.exports = {
|
||||
|
||||
|
|
@ -16,7 +17,9 @@ module.exports = {
|
|||
ipc.send('connected')
|
||||
|
||||
var recentSessions = settings.read('recentSessions')
|
||||
|
||||
ipc.send('sessionList', recentSessions, clientId)
|
||||
ipc.send('clipboard', clipboard, clientId)
|
||||
|
||||
if (settings.read('readOnly')) {
|
||||
ipc.send('readOnly')
|
||||
|
|
@ -458,6 +461,13 @@ module.exports = {
|
|||
})
|
||||
|
||||
|
||||
},
|
||||
|
||||
clipboard: function(data, clientId) {
|
||||
|
||||
clipboard = data
|
||||
ipc.send('clipboard', data, null, clientId)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ module.exports = function(options={}) {
|
|||
window.reload()
|
||||
})
|
||||
|
||||
shortcut.register(window,'F11',function(){
|
||||
if (options.fullscreen) shortcut.register(window,'F11',function(){
|
||||
window.setFullScreen(!window.isFullScreen())
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue