Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -433,6 +433,7 @@ with gr.Blocks(css=css) as demo:
|
|
433 |
selector = gr.HTML(value="""<div id='select_cursor' style='width:1px;height:1px;position:absolute;border:1px dotted #ffffff;'></div>
|
434 |
<a href='#' id='selector' onclick='this.style.fontWeight=\"bold\";
|
435 |
document.body.appendChild(document.getElementById(\"select_cursor\"));
|
|
|
436 |
document.getElementById(\"image_edit\").getElementsByTagName(\"canvas\")[0].ondrag = function(e){e.preventDefault();}
|
437 |
|
438 |
document.getElementById(\"image_edit\").getElementsByTagName(\"canvas\")[0].onclick = function(e) {
|
@@ -448,8 +449,8 @@ with gr.Blocks(css=css) as demo:
|
|
448 |
evt.initEvent(\"input\", true, false);
|
449 |
document.getElementById(\"mouse\").getElementsByTagName(\"textarea\")[0].dispatchEvent(evt);
|
450 |
|
451 |
-
document.getElementById(\"select_cursor\").style.left = e.clientX + \"px\";
|
452 |
-
document.getElementById(\"select_cursor\").style.top = e.clientY + \"px\";
|
453 |
}
|
454 |
document.getElementById(\"image_edit\").getElementsByTagName(\"canvas\")[0].onpointermove = function(e) {
|
455 |
if (document.getElementById(\"select_cursor\").style.borderColor != \"#ffffff\") {
|
@@ -465,17 +466,23 @@ with gr.Blocks(css=css) as demo:
|
|
465 |
}
|
466 |
document.getElementById(\"mouse\").getElementsByTagName(\"textarea\")[0].value = \"[\" + p + \"]\";
|
467 |
|
468 |
-
document.getElementById(\"select_cursor\").style.left = e.clientX + \"px\";
|
469 |
-
document.getElementById(\"select_cursor\").style.top = e.clientY + \"px\";
|
470 |
}
|
471 |
}
|
472 |
-
document.getElementById(\"image_edit\").getElementsByTagName(\"canvas\")[0].
|
473 |
e.preventDefault();
|
474 |
document.getElementById(\"mouse\").getElementsByTagName(\"textarea\")[0].value = \"[]\";
|
475 |
|
476 |
document.getElementById(\"select_cursor\").style.left = 0;
|
477 |
document.getElementById(\"select_cursor\").style.top = 0;
|
478 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
479 |
document.getElementById(\"image_edit\").getElementsByTagName(\"canvas\")[0].onpointerdown = function(e) {
|
480 |
document.getElementById(\"select_cursor\").style.borderColor = \"#808080\";
|
481 |
}
|
|
|
433 |
selector = gr.HTML(value="""<div id='select_cursor' style='width:1px;height:1px;position:absolute;border:1px dotted #ffffff;'></div>
|
434 |
<a href='#' id='selector' onclick='this.style.fontWeight=\"bold\";
|
435 |
document.body.appendChild(document.getElementById(\"select_cursor\"));
|
436 |
+
document.getElementById(\"image_edit\").getElementsByTagName(\"canvas\")[0].oncontextmenu = function(e){e.preventDefault();}
|
437 |
document.getElementById(\"image_edit\").getElementsByTagName(\"canvas\")[0].ondrag = function(e){e.preventDefault();}
|
438 |
|
439 |
document.getElementById(\"image_edit\").getElementsByTagName(\"canvas\")[0].onclick = function(e) {
|
|
|
449 |
evt.initEvent(\"input\", true, false);
|
450 |
document.getElementById(\"mouse\").getElementsByTagName(\"textarea\")[0].dispatchEvent(evt);
|
451 |
|
452 |
+
document.getElementById(\"select_cursor\").style.left = e.clientX-1 + \"px\";
|
453 |
+
document.getElementById(\"select_cursor\").style.top = e.clientY-1 + \"px\";
|
454 |
}
|
455 |
document.getElementById(\"image_edit\").getElementsByTagName(\"canvas\")[0].onpointermove = function(e) {
|
456 |
if (document.getElementById(\"select_cursor\").style.borderColor != \"#ffffff\") {
|
|
|
466 |
}
|
467 |
document.getElementById(\"mouse\").getElementsByTagName(\"textarea\")[0].value = \"[\" + p + \"]\";
|
468 |
|
469 |
+
document.getElementById(\"select_cursor\").style.left = e.clientX-1 + \"px\";
|
470 |
+
document.getElementById(\"select_cursor\").style.top = e.clientY-1 + \"px\";
|
471 |
}
|
472 |
}
|
473 |
+
document.getElementById(\"image_edit\").getElementsByTagName(\"canvas\")[0].ondblclick = function(e) {
|
474 |
e.preventDefault();
|
475 |
document.getElementById(\"mouse\").getElementsByTagName(\"textarea\")[0].value = \"[]\";
|
476 |
|
477 |
document.getElementById(\"select_cursor\").style.left = 0;
|
478 |
document.getElementById(\"select_cursor\").style.top = 0;
|
479 |
}
|
480 |
+
document.getElementById(\"image_edit\").getElementsByTagName(\"canvas\")[0].onpointerleave = function(e) {
|
481 |
+
document.getElementById(\"mouse\").getElementsByTagName(\"textarea\")[0].value = \"[]\";
|
482 |
+
|
483 |
+
document.getElementById(\"select_cursor\").style.left = 0;
|
484 |
+
document.getElementById(\"select_cursor\").style.top = 0;
|
485 |
+
}
|
486 |
document.getElementById(\"image_edit\").getElementsByTagName(\"canvas\")[0].onpointerdown = function(e) {
|
487 |
document.getElementById(\"select_cursor\").style.borderColor = \"#808080\";
|
488 |
}
|