Spaces:
Runtime error
Runtime error
Update code_editor.py
Browse files- code_editor.py +3 -2
code_editor.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import json
|
2 |
|
3 |
-
def code_editor(value: str = "", issue_num: int = 0, elem_id: str = None) -> str:
|
4 |
"""
|
5 |
Returns an HTML snippet for a CodeMirror-based code editor.
|
6 |
|
@@ -8,6 +8,7 @@ def code_editor(value: str = "", issue_num: int = 0, elem_id: str = None) -> str
|
|
8 |
value (str): Initial content for the code editor.
|
9 |
issue_num (int): The issue number to identify the editor instance.
|
10 |
elem_id (str, optional): ID for the HTML element.
|
|
|
11 |
|
12 |
Returns:
|
13 |
str: HTML string that embeds a CodeMirror editor.
|
@@ -52,7 +53,7 @@ def code_editor(value: str = "", issue_num: int = 0, elem_id: str = None) -> str
|
|
52 |
}});
|
53 |
|
54 |
// Expose the editor globally so we can interact with it elsewhere if needed
|
55 |
-
window
|
56 |
|
57 |
// Handle changes and send updates to the server
|
58 |
editor.on("change", function() {{
|
|
|
1 |
import json
|
2 |
|
3 |
+
def code_editor(value: str = "", issue_num: int = 0, elem_id: str = None, key: str = None) -> str:
|
4 |
"""
|
5 |
Returns an HTML snippet for a CodeMirror-based code editor.
|
6 |
|
|
|
8 |
value (str): Initial content for the code editor.
|
9 |
issue_num (int): The issue number to identify the editor instance.
|
10 |
elem_id (str, optional): ID for the HTML element.
|
11 |
+
key (str, optional): Unique key for the component.
|
12 |
|
13 |
Returns:
|
14 |
str: HTML string that embeds a CodeMirror editor.
|
|
|
53 |
}});
|
54 |
|
55 |
// Expose the editor globally so we can interact with it elsewhere if needed
|
56 |
+
window._codeEditorInstance{issue_num} = editor;
|
57 |
|
58 |
// Handle changes and send updates to the server
|
59 |
editor.on("change", function() {{
|