expose api
parent
e89e068228
commit
108fa0edf1
|
|
@ -88,7 +88,7 @@ let _r = 0;
|
|||
updateGradioImage(imageElems[0], dt);
|
||||
}
|
||||
|
||||
function getCanvasEditorTabIndex() {
|
||||
window.getCanvasEditorTabIndex = function () {
|
||||
const tabCanvasEditorDiv = document.getElementById('tab_canvas_editor');
|
||||
const parent = tabCanvasEditorDiv.parentNode;
|
||||
const siblings = parent.childNodes;
|
||||
|
|
@ -112,13 +112,10 @@ let _r = 0;
|
|||
return !(displayValue === 'none');
|
||||
}
|
||||
|
||||
window.sendImageToCanvasEditor = function (gallery) {
|
||||
const img = gallery.querySelector(".preview img");
|
||||
|
||||
if (img) {
|
||||
window.sendImageToCanvasEditorDirect = function (img) {
|
||||
const tabIndex = getCanvasEditorTabIndex();
|
||||
|
||||
const width = img.naturalWidth; // 获取图片的原始宽度
|
||||
const width = img.naturalWidth;
|
||||
const height = img.naturalHeight;
|
||||
|
||||
gradioApp().querySelector('#tabs').querySelectorAll('button')[tabIndex - 1].click();
|
||||
|
|
@ -136,6 +133,13 @@ let _r = 0;
|
|||
removable: true,
|
||||
resizable: true,
|
||||
});
|
||||
}
|
||||
|
||||
window.sendImageToCanvasEditor = function (gallery) {
|
||||
const img = gallery.querySelector(".preview img");
|
||||
|
||||
if (img) {
|
||||
sendImageToCanvasEditorDirect(img);
|
||||
} else {
|
||||
alert("No image selected");
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue