move "send to" button to current place
parent
a9381afebc
commit
e89e068228
|
|
@ -19,7 +19,7 @@
|
||||||
globalThis.canvasEditor.import = async () => {
|
globalThis.canvasEditor.import = async () => {
|
||||||
const polotno = await import(`${base_path}/polotno.bundle.js`);
|
const polotno = await import(`${base_path}/polotno.bundle.js`);
|
||||||
|
|
||||||
return { polotno };
|
return {polotno};
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!globalThis.canvasEditor.imports) {
|
if (!globalThis.canvasEditor.imports) {
|
||||||
|
|
@ -38,5 +38,21 @@
|
||||||
onUiLoaded(function () {
|
onUiLoaded(function () {
|
||||||
canvasEditorImport = gradioApp().querySelector('#canvas-editor-import');
|
canvasEditorImport = gradioApp().querySelector('#canvas-editor-import');
|
||||||
load(canvasEditorImport);
|
load(canvasEditorImport);
|
||||||
|
|
||||||
|
createSendToCanvasEditorButton("image_buttons_txt2img", window.txt2img_gallery);
|
||||||
|
createSendToCanvasEditorButton("image_buttons_img2img", window.img2img_gallery);
|
||||||
|
createSendToCanvasEditorButton("image_buttons_extras", window.extras_gallery);
|
||||||
|
|
||||||
|
function createSendToCanvasEditorButton(queryId, gallery) {
|
||||||
|
const existingButton = gradioApp().querySelector(`#${queryId} button`);
|
||||||
|
const newButton = existingButton.cloneNode(true);
|
||||||
|
newButton.style.display = "flex";
|
||||||
|
newButton.id = `${queryId}_send_to_canvasEditor`;
|
||||||
|
newButton.textContent = "Send to CanvasEditor";
|
||||||
|
newButton.addEventListener("click", () => sendImageToCanvasEditor(gallery));
|
||||||
|
gradioApp().querySelector(`#${queryId}`).appendChild(newButton);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
@ -112,12 +112,8 @@ let _r = 0;
|
||||||
return !(displayValue === 'none');
|
return !(displayValue === 'none');
|
||||||
}
|
}
|
||||||
|
|
||||||
window.sendImageToCanvasEditor = function () {
|
window.sendImageToCanvasEditor = function (gallery) {
|
||||||
const gallerySelector = isTxt2Img() ? '#txt2img_gallery' : '#img2img_gallery';
|
const img = gallery.querySelector(".preview img");
|
||||||
|
|
||||||
const txt2imgGallery = gradioApp().querySelector(gallerySelector);
|
|
||||||
|
|
||||||
const img = txt2imgGallery.querySelector(".preview img");
|
|
||||||
|
|
||||||
if (img) {
|
if (img) {
|
||||||
const tabIndex = getCanvasEditorTabIndex();
|
const tabIndex = getCanvasEditorTabIndex();
|
||||||
|
|
|
||||||
|
|
@ -74,11 +74,7 @@ class Script(scripts.Script):
|
||||||
return scripts.AlwaysVisible
|
return scripts.AlwaysVisible
|
||||||
|
|
||||||
def ui(self, is_img2img):
|
def ui(self, is_img2img):
|
||||||
send_canvas_editor = gr.Button(value="Send to Canvas Editor")
|
return []
|
||||||
|
|
||||||
send_canvas_editor.click(None, send_canvas_editor, None, _js="sendImageToCanvasEditor")
|
|
||||||
|
|
||||||
return [send_canvas_editor]
|
|
||||||
|
|
||||||
|
|
||||||
def wrap_api(fn):
|
def wrap_api(fn):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue