Spaces:
Sleeping
Sleeping
def render_mind_map():
Browse files
app.py
CHANGED
|
@@ -3231,6 +3231,7 @@ function createGradioAnimation() {
|
|
| 3231 |
|
| 3232 |
return 'Animation created';
|
| 3233 |
}
|
|
|
|
| 3234 |
"""
|
| 3235 |
|
| 3236 |
CSS = """
|
|
@@ -3437,9 +3438,30 @@ def create_app():
|
|
| 3437 |
with gr.Tab("重點摘要"):
|
| 3438 |
with gr.Row():
|
| 3439 |
df_summarise = gr.Markdown(show_label=False, latex_delimiters = [{"left": "$", "right": "$", "display": False}])
|
| 3440 |
-
|
|
|
|
|
|
|
| 3441 |
with gr.Row():
|
| 3442 |
mind_map_html = gr.HTML()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3443 |
with gr.Tab("關鍵時刻"):
|
| 3444 |
with gr.Row():
|
| 3445 |
key_moments_html = gr.HTML(value="")
|
|
|
|
| 3231 |
|
| 3232 |
return 'Animation created';
|
| 3233 |
}
|
| 3234 |
+
|
| 3235 |
"""
|
| 3236 |
|
| 3237 |
CSS = """
|
|
|
|
| 3438 |
with gr.Tab("重點摘要"):
|
| 3439 |
with gr.Row():
|
| 3440 |
df_summarise = gr.Markdown(show_label=False, latex_delimiters = [{"left": "$", "right": "$", "display": False}])
|
| 3441 |
+
|
| 3442 |
+
mind_map_tab = gr.Tab("心智圖", elem_id="mind_map_tab")
|
| 3443 |
+
with mind_map_tab:
|
| 3444 |
with gr.Row():
|
| 3445 |
mind_map_html = gr.HTML()
|
| 3446 |
+
|
| 3447 |
+
def render_mind_map():
|
| 3448 |
+
# 這個函數會返回一個 JavaScript 代碼,該代碼將在前端執行
|
| 3449 |
+
js_code = """
|
| 3450 |
+
function() {
|
| 3451 |
+
if (document.querySelector('.markmap svg') === null) {
|
| 3452 |
+
console.log('No markmap SVG found, rendering now...');
|
| 3453 |
+
markmap.autoLoader.renderAll();
|
| 3454 |
+
} else {
|
| 3455 |
+
console.log('Markmap SVG already exists, skipping render');
|
| 3456 |
+
}
|
| 3457 |
+
return true; // 可以返回任何值,這裡返回 true 表示操作成功
|
| 3458 |
+
}
|
| 3459 |
+
"""
|
| 3460 |
+
return js_code
|
| 3461 |
+
|
| 3462 |
+
mind_map_tab.select(fn=None, inputs=None, outputs=None, js=render_mind_map())
|
| 3463 |
+
|
| 3464 |
+
|
| 3465 |
with gr.Tab("關鍵時刻"):
|
| 3466 |
with gr.Row():
|
| 3467 |
key_moments_html = gr.HTML(value="")
|