mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-02-03 03:59:20 +01:00
Allow plugin buttons for image overlay to decide whether they should be displayed or not
This commit is contained in:
parent
5fa3a7ca44
commit
af05d94198
@ -381,18 +381,25 @@ function showImages(reqBody, res, outputContainer, livePreview) {
|
|||||||
Object.assign(buttons, PLUGINS['IMAGE_INFO_BUTTONS'])
|
Object.assign(buttons, PLUGINS['IMAGE_INFO_BUTTONS'])
|
||||||
|
|
||||||
const imgItemInfo = imageItemElem.querySelector('.imgItemInfo')
|
const imgItemInfo = imageItemElem.querySelector('.imgItemInfo')
|
||||||
|
const img = imageItemElem.querySelector('img')
|
||||||
const createButton = function(name, btnInfo) {
|
const createButton = function(name, btnInfo) {
|
||||||
const newButton = document.createElement('button')
|
const newButton = document.createElement('button')
|
||||||
newButton.classList.add(name)
|
newButton.classList.add(name)
|
||||||
newButton.classList.add('tasksBtns')
|
newButton.classList.add('tasksBtns')
|
||||||
newButton.innerText = btnInfo.text
|
newButton.innerText = btnInfo.text
|
||||||
newButton.addEventListener('click', function() {
|
newButton.addEventListener('click', function() {
|
||||||
let img = imageItemElem.querySelector('img')
|
|
||||||
btnInfo.on_click(req, img)
|
btnInfo.on_click(req, img)
|
||||||
})
|
})
|
||||||
imgItemInfo.appendChild(newButton)
|
imgItemInfo.appendChild(newButton)
|
||||||
}
|
}
|
||||||
Object.keys(buttons).forEach((name) => createButton(name, buttons[name]))
|
Object.keys(buttons).forEach((name) => {
|
||||||
|
const btn = buttons[name]
|
||||||
|
if (btn.filter && btn.filter(req, img) === false) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
createButton(name, btn)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,11 @@ const PLUGINS = {
|
|||||||
* })
|
* })
|
||||||
* newTaskRequest.seed = newTaskRequest.reqBody.seed
|
* newTaskRequest.seed = newTaskRequest.reqBody.seed
|
||||||
* createTask(newTaskRequest)
|
* createTask(newTaskRequest)
|
||||||
|
* },
|
||||||
|
* filter: function(origRequest, image) {
|
||||||
|
* // this is an optional function. return true/false to show/hide the button
|
||||||
|
* // if this function isn't set, the button will always be visible
|
||||||
|
* return true
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user