Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -267,19 +267,8 @@ def create_ui():
|
|
267 |
"""
|
268 |
|
269 |
|
270 |
-
def
|
271 |
-
return text
|
272 |
-
|
273 |
-
copy_js = """
|
274 |
-
async function copyToClipboard(text) {
|
275 |
-
try {
|
276 |
-
await navigator.clipboard.writeText(text);
|
277 |
-
console.log('Copying to clipboard was successful!');
|
278 |
-
} catch (err) {
|
279 |
-
console.error('Could not copy text: ', err);
|
280 |
-
}
|
281 |
-
}
|
282 |
-
"""
|
283 |
|
284 |
with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
285 |
gr.Markdown("# Mouse: HuggingFace")
|
@@ -295,22 +284,25 @@ def create_ui():
|
|
295 |
with gr.Row():
|
296 |
summary_output = gr.Markdown(label="요약 (3줄 이내)")
|
297 |
copy_summary = gr.Button("복사", elem_classes="copy-button")
|
|
|
298 |
|
299 |
with gr.Group(elem_classes="output-group scroll-lock"):
|
300 |
with gr.Row():
|
301 |
analysis_output = gr.Markdown(label="분석")
|
302 |
copy_analysis = gr.Button("복사", elem_classes="copy-button")
|
|
|
303 |
|
304 |
with gr.Group(elem_classes="output-group scroll-lock"):
|
305 |
with gr.Row():
|
306 |
usage_output = gr.Markdown(label="사용법")
|
307 |
copy_usage = gr.Button("복사", elem_classes="copy-button")
|
|
|
308 |
|
309 |
with gr.Group(elem_classes="output-group tree-view-scroll"):
|
310 |
with gr.Row():
|
311 |
tree_view_output = gr.Textbox(label="파일 구조 (Tree View)", lines=30)
|
312 |
copy_tree = gr.Button("복사", elem_classes="copy-button")
|
313 |
-
|
314 |
|
315 |
|
316 |
|
@@ -380,23 +372,14 @@ def create_ui():
|
|
380 |
inputs=[space_id_state],
|
381 |
outputs=[requirements_content]
|
382 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
383 |
|
384 |
-
# JavaScript 이벤트 연결
|
385 |
-
summary_output.change(None, None, None, _js="() => {copyToClipboard(document.querySelector('.summary_output textarea').value)}")
|
386 |
-
analysis_output.change(None, None, None, _js="() => {copyToClipboard(document.querySelector('.analysis_output textarea').value)}")
|
387 |
-
usage_output.change(None, None, None, _js="() => {copyToClipboard(document.querySelector('.usage_output textarea').value)}")
|
388 |
-
tree_view_output.change(None, None, None, _js="() => {copyToClipboard(document.querySelector('.tree_view_output textarea').value)}")
|
389 |
-
app_py_content.change(None, None, None, _js="() => {copyToClipboard(document.querySelector('.app_py_content textarea').value)}")
|
390 |
-
requirements_content.change(None, None, None, _js="() => {copyToClipboard(document.querySelector('.requirements_content textarea').value)}")
|
391 |
-
|
392 |
-
copy_summary.click(None, None, None, _js="() => {copyToClipboard(document.querySelector('.summary_output textarea').value)}")
|
393 |
-
copy_analysis.click(None, None, None, _js="() => {copyToClipboard(document.querySelector('.analysis_output textarea').value)}")
|
394 |
-
copy_usage.click(None, None, None, _js="() => {copyToClipboard(document.querySelector('.usage_output textarea').value)}")
|
395 |
-
copy_tree.click(None, None, None, _js="() => {copyToClipboard(document.querySelector('.tree_view_output textarea').value)}")
|
396 |
-
copy_app_py.click(None, None, None, _js="() => {copyToClipboard(document.querySelector('.app_py_content textarea').value)}")
|
397 |
-
copy_requirements.click(None, None, None, _js="() => {copyToClipboard(document.querySelector('.requirements_content textarea').value)}")
|
398 |
-
|
399 |
-
|
400 |
|
401 |
|
402 |
|
|
|
267 |
"""
|
268 |
|
269 |
|
270 |
+
def copy_text(text):
|
271 |
+
return text, f"'{text[:20]}...' 복사됨"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
|
273 |
with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
274 |
gr.Markdown("# Mouse: HuggingFace")
|
|
|
284 |
with gr.Row():
|
285 |
summary_output = gr.Markdown(label="요약 (3줄 이내)")
|
286 |
copy_summary = gr.Button("복사", elem_classes="copy-button")
|
287 |
+
copy_summary_output = gr.Textbox(label="복사된 내용", visible=False)
|
288 |
|
289 |
with gr.Group(elem_classes="output-group scroll-lock"):
|
290 |
with gr.Row():
|
291 |
analysis_output = gr.Markdown(label="분석")
|
292 |
copy_analysis = gr.Button("복사", elem_classes="copy-button")
|
293 |
+
copy_analysis_output = gr.Textbox(label="복사된 내용", visible=False)
|
294 |
|
295 |
with gr.Group(elem_classes="output-group scroll-lock"):
|
296 |
with gr.Row():
|
297 |
usage_output = gr.Markdown(label="사용법")
|
298 |
copy_usage = gr.Button("복사", elem_classes="copy-button")
|
299 |
+
copy_usage_output = gr.Textbox(label="복사된 내용", visible=False)
|
300 |
|
301 |
with gr.Group(elem_classes="output-group tree-view-scroll"):
|
302 |
with gr.Row():
|
303 |
tree_view_output = gr.Textbox(label="파일 구조 (Tree View)", lines=30)
|
304 |
copy_tree = gr.Button("복사", elem_classes="copy-button")
|
305 |
+
copy_tree_output = gr.Textbox(label="복사된 내용", visible=False)
|
306 |
|
307 |
|
308 |
|
|
|
372 |
inputs=[space_id_state],
|
373 |
outputs=[requirements_content]
|
374 |
)
|
375 |
+
# 복사 기능 연결
|
376 |
+
copy_summary.click(copy_text, inputs=[summary_output], outputs=[copy_summary_output, gr.Textbox(label="상태")])
|
377 |
+
copy_analysis.click(copy_text, inputs=[analysis_output], outputs=[copy_analysis_output, gr.Textbox(label="상태")])
|
378 |
+
copy_usage.click(copy_text, inputs=[usage_output], outputs=[copy_usage_output, gr.Textbox(label="상태")])
|
379 |
+
copy_tree.click(copy_text, inputs=[tree_view_output], outputs=[copy_tree_output, gr.Textbox(label="상태")])
|
380 |
+
copy_app_py.click(copy_text, inputs=[app_py_content], outputs=[gr.Textbox(label="복사된 내용", visible=False), gr.Textbox(label="상태")])
|
381 |
+
copy_requirements.click(copy_text, inputs=[requirements_content], outputs=[gr.Textbox(label="복사된 내용", visible=False), gr.Textbox(label="상태")])
|
382 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
383 |
|
384 |
|
385 |
|