acecalisto3 commited on
Commit
fa06ba0
·
verified ·
1 Parent(s): d5fb735

Update code_editor.py

Browse files
Files changed (1) hide show
  1. code_editor.py +3 -4
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, **kwargs) -> str:
4
  """
5
  Returns an HTML snippet for a CodeMirror-based code editor.
6
 
@@ -8,7 +8,6 @@ def code_editor(value: str = "", issue_num: int = 0, elem_id: str = None, **kwar
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
- **kwargs: Additional keyword arguments (ignored).
12
 
13
  Returns:
14
  str: HTML string that embeds a CodeMirror editor.
@@ -46,14 +45,14 @@ def code_editor(value: str = "", issue_num: int = 0, elem_id: str = None, **kwar
46
  // Initialize CodeMirror on the textarea after it is loaded
47
  document.addEventListener("DOMContentLoaded", function() {{
48
  var editor = CodeMirror.fromTextArea(document.getElementById("code-editor-{issue_num}"), {{
49
- lineNumbers : true,
50
  mode: "python", // Change this to "javascript" or any other mode as needed
51
  theme: "material-darker",
52
  tabSize: 4
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() {{
 
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
  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.
 
45
  // Initialize CodeMirror on the textarea after it is loaded
46
  document.addEventListener("DOMContentLoaded", function() {{
47
  var editor = CodeMirror.fromTextArea(document.getElementById("code-editor-{issue_num}"), {{
48
+ lineNumbers: true,
49
  mode: "python", // Change this to "javascript" or any other mode as needed
50
  theme: "material-darker",
51
  tabSize: 4
52
  }});
53
 
54
  // Expose the editor globally so we can interact with it elsewhere if needed
55
+ window ._codeEditorInstance{issue_num} = editor;
56
 
57
  // Handle changes and send updates to the server
58
  editor.on("change", function() {{