milwright commited on
Commit
58cbe65
·
1 Parent(s): 9bf60ea

remove keyboard shortcuts to comply with huggingface csp policy

Browse files
Files changed (2) hide show
  1. app.py +4 -35
  2. space_template.py +4 -35
app.py CHANGED
@@ -152,40 +152,9 @@ class SpaceGenerator:
152
  # Documentation Tab
153
  with gr.Tab("Documentation"):
154
  self._create_documentation_tab()
155
-
156
- # Add keyboard shortcuts
157
- demo.load(
158
- None,
159
- None,
160
- None,
161
- js="""
162
- () => {
163
- // Focus on message input when page loads
164
- setTimeout(() => {
165
- const msgInput = document.querySelector('textarea');
166
- if (msgInput) msgInput.focus();
167
- }, 100);
168
-
169
- // Keyboard shortcuts
170
- document.addEventListener('keydown', function(e) {
171
- // Ctrl+L to clear chat
172
- if (e.ctrlKey && e.key === 'l') {
173
- e.preventDefault();
174
- const buttons = Array.from(document.querySelectorAll('button'));
175
- const clearBtn = buttons.find(btn => btn.textContent.includes('Clear'));
176
- if (clearBtn) clearBtn.click();
177
- }
178
- // Ctrl+E to export
179
- else if (e.ctrlKey && e.key === 'e') {
180
- e.preventDefault();
181
- const buttons = Array.from(document.querySelectorAll('button'));
182
- const exportBtn = buttons.find(btn => btn.textContent.includes('Export'));
183
- if (exportBtn) exportBtn.click();
184
- }
185
- });
186
- }
187
- """
188
- )
189
 
190
  return demo
191
 
@@ -538,7 +507,7 @@ class SpaceGenerator:
538
 
539
  # Message input
540
  msg = gr.Textbox(
541
- label="Message (Shift+Enter to send)",
542
  placeholder="Type your message here...",
543
  lines=2
544
  )
 
152
  # Documentation Tab
153
  with gr.Tab("Documentation"):
154
  self._create_documentation_tab()
155
+
156
+ # Note: Keyboard shortcuts removed for consistency with HF Spaces deployment
157
+ # (HF Spaces CSP blocks inline JavaScript)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
 
159
  return demo
160
 
 
507
 
508
  # Message input
509
  msg = gr.Textbox(
510
+ label="Message",
511
  placeholder="Type your message here...",
512
  lines=2
513
  )
space_template.py CHANGED
@@ -598,7 +598,7 @@ def create_interface():
598
  # Create chat interface
599
  chatbot = gr.Chatbot(type="messages", height=400)
600
  msg = gr.Textbox(
601
- label="Message (Shift+Enter to send)",
602
  placeholder="Type your message here...",
603
  lines=2
604
  )
@@ -1067,40 +1067,9 @@ def create_interface():
1067
  outputs=[access_panel, main_panel, access_status, access_granted]
1068
  )
1069
 
1070
-
1071
- # Add keyboard shortcuts
1072
- demo.load(
1073
- None,
1074
- None,
1075
- None,
1076
- js="""
1077
- () => {{
1078
- // Focus on message input when page loads
1079
- setTimeout(() => {{
1080
- const msgInput = document.querySelector('textarea');
1081
- if (msgInput) msgInput.focus();
1082
- }}, 100);
1083
-
1084
- // Keyboard shortcuts
1085
- document.addEventListener('keydown', function(e) {{
1086
- // Ctrl+L to clear chat
1087
- if (e.ctrlKey && e.key === 'l') {{
1088
- e.preventDefault();
1089
- const buttons = Array.from(document.querySelectorAll('button'));
1090
- const clearBtn = buttons.find(btn => btn.textContent.includes('Clear'));
1091
- if (clearBtn) clearBtn.click();
1092
- }}
1093
- // Ctrl+E to export
1094
- else if (e.ctrlKey && e.key === 'e') {{
1095
- e.preventDefault();
1096
- const buttons = Array.from(document.querySelectorAll('button'));
1097
- const exportBtn = buttons.find(btn => btn.textContent.includes('Export'));
1098
- if (exportBtn) exportBtn.click();
1099
- }}
1100
- }});
1101
- }}
1102
- """
1103
- )
1104
 
1105
  return demo
1106
 
 
598
  # Create chat interface
599
  chatbot = gr.Chatbot(type="messages", height=400)
600
  msg = gr.Textbox(
601
+ label="Message",
602
  placeholder="Type your message here...",
603
  lines=2
604
  )
 
1067
  outputs=[access_panel, main_panel, access_status, access_granted]
1068
  )
1069
 
1070
+
1071
+ # Note: Keyboard shortcuts removed due to HuggingFace CSP restrictions
1072
+ # HF Spaces block inline JavaScript for security
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1073
 
1074
  return demo
1075