1
0
Falko Schindler 1 жил өмнө
parent
commit
10c9ac4551

+ 4 - 6
nicegui/elements/json_editor.py

@@ -18,22 +18,20 @@ class JsonEditor(Element, component='json_editor.js', exposed_libraries=['lib/va
         After data has changed, call the `update` method to refresh the editor.
 
         :param properties: dictionary of JSONEditor properties
-        :param on_select: callback function that is called when the editor's content has been selected
-        :param on_change: callback function that is called when the editor's content has changed
+        :param on_select: callback function that is called when some of the content has been selected
+        :param on_change: callback function that is called when the content has changed
         """
         super().__init__()
         self._props['properties'] = properties
 
         if on_select:
             def handle_on_select(e: GenericEventArguments) -> None:
-                handle_event(on_select,
-                             JsonEditorSelectEventArguments(sender=self, client=self.client, **e.args))
+                handle_event(on_select, JsonEditorSelectEventArguments(sender=self, client=self.client, **e.args))
             self.on('select', handle_on_select, ['selection'])
 
         if on_change:
             def handle_on_change(e: GenericEventArguments) -> None:
-                handle_event(on_change,
-                             JsonEditorChangeEventArguments(sender=self, client=self.client, **e.args))
+                handle_event(on_change, JsonEditorChangeEventArguments(sender=self, client=self.client, **e.args))
             self.on('change', handle_on_change, ['content', 'errors'])
 
     @property

+ 1 - 0
nicegui/events.py

@@ -355,6 +355,7 @@ class ScrollEventArguments(UiEventArguments):
 class JsonEditorSelectEventArguments(UiEventArguments):
     selection: Dict
 
+
 @dataclass(**KWONLY_SLOTS)
 class JsonEditorChangeEventArguments(UiEventArguments):
     content: Dict

+ 5 - 2
website/more_documentation/json_editor_documentation.py

@@ -8,9 +8,12 @@ def main_demo() -> None:
         'color': '#82b92c',
         None: None,
         'number': 123,
-        'object': {'a': 'b', 'c': 'd'},
+        'object': {
+            'a': 'b',
+            'c': 'd',
+        },
         'time': 1575599819000,
-        'string': 'Hello World'
+        'string': 'Hello World',
     }
     ui.json_editor({'content': {'json': json}},
                    on_select=lambda e: ui.notify(f'Select: {e}'),