Kalana commited on
Commit
f911765
1 Parent(s): 9906dbd

Add copy-to-clipboard button for transliteration output (FR5)

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -104,7 +104,20 @@ if st.button("Transliterate", type="primary", use_container_width=True) and inpu
104
 
105
  st.success("Transliteration Complete")
106
  st.markdown(f"### {result}")
107
- st.caption(f"Mode: {decode_mode} 路 Time: {round(elapsed, 2)}s")
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
  with st.expander("Scoring Breakdown", expanded=True):
110
  st.caption(
 
104
 
105
  st.success("Transliteration Complete")
106
  st.markdown(f"### {result}")
107
+
108
+ col1, col2 = st.columns([3, 1])
109
+ with col1:
110
+ st.caption(f"Mode: {decode_mode} 路 Time: {round(elapsed, 2)}s")
111
+ with col2:
112
+ if st.button("馃搵 Copy", key="copy_result"):
113
+ st.session_state["copied"] = True
114
+ if st.session_state.get("copied"):
115
+ st.components.v1.html(
116
+ f"""<script>navigator.clipboard.writeText(`{result}`);</script>""",
117
+ height=0,
118
+ )
119
+ st.toast("Copied to clipboard!")
120
+ st.session_state["copied"] = False
121
 
122
  with st.expander("Scoring Breakdown", expanded=True):
123
  st.caption(