This commit is contained in:
STEINNI
2026-04-10 13:32:00 +00:00
+24 -12
View File
@@ -109,24 +109,32 @@ class BZgraflow extends Buildoz{
}
async loadFlow(source){
let buf
let buf, flowObj
if(source instanceof Blob){
buf = await source.text()
} else {
const url = source
const fetchUrl = (typeof url === 'string' && !url.startsWith('blob:') && !url.startsWith('data:'))
? (url + '?' + crypto.randomUUID())
: url
const res = await fetch(fetchUrl)
buf = await res.text()
}
let flowObj
try{
flowObj = JSON.parse(buf)
} catch(err){
this.error('Could not parse flow JSON!?', err)
return
}
} else if(typeof source == 'string') {
const url = source
const fetchUrl = (typeof url === 'string' && !url.startsWith('blob:') && !url.startsWith('data:'))
? (url + '?' + crypto.randomUUID())
: url
const res = await fetch(fetchUrl)
buf = await res.text()
try{
flowObj = JSON.parse(buf)
} catch(err){
this.error('Could not parse flow JSON!?', err)
return
}
} else if(typeof source == 'object') {
flowObj = source
}
if(!flowObj.nodesFile){
this.error('No nodesFile in JSON!?')
return
@@ -264,7 +272,7 @@ class BZgraflow extends Buildoz{
}
}
childEl.autoPlace(this.currentOrientation, 60, 60)
childEl.autoPlace(this.currentOrientation, parseInt(this.getBZAttribute('gapx')) || 80, parseInt(this.getBZAttribute('gapy')) || 80)
}, { once:true })
// Fade out the current (host) graflow while the child scales up
@@ -442,11 +450,15 @@ class BZgraflow extends Buildoz{
this.addWire(link)
}
if(!this.currentOrientation) {
if(this.getBZAttribute('orientation')) {
this.currentOrientation = this.getBZAttribute('orientation')
} else {
const bb=this.getBoundingClientRect()
if(bb.width > bb.height) this.currentOrientation = 'horizontal'
else this.currentOrientation = 'vertical'
}
if(forceAutoplace) this.autoPlace(this.currentOrientation)
}
if(forceAutoplace) this.autoPlace(this.currentOrientation, parseInt(this.getBZAttribute('gapx')) || 80, parseInt(this.getBZAttribute('gapy')) || 80)
this.fireEvent('refreshed', { })
}