Skip to content

Commit

Permalink
add pytest and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler committed Sep 19, 2023
1 parent ebb6fa5 commit bdd94c8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nicegui/elements/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def __init__(self,
) -> None:
"""Editor
A code editor with syntax highlighting, based on `Quasar's QEditor <https://quasar.dev/vue-components/editor>`_.
A WYSIWYG editor based on `Quasar's QEditor <https://quasar.dev/vue-components/editor>`_.
The value is a string containing the formatted text as HTML code.
:param value: initial value
:param on_change: callback to be invoked when the value changes
Expand Down
14 changes: 14 additions & 0 deletions tests/test_editor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

from nicegui import ui

from .screen import Screen


def test_editor(screen: Screen):
editor = ui.editor(placeholder='Type something here')
ui.markdown().bind_content_from(editor, 'value', backward=lambda v: f'HTML code:\n```\n{v}\n```')

screen.open('/')
screen.find_by_class('q-editor__content').click()
screen.type('Hello\nworld!')
screen.should_contain('Hello<div>world!</div>')
1 change: 1 addition & 0 deletions website/documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def captions_and_overlays_demo():
load_demo(ui.scene)
load_demo(ui.tree)
load_demo(ui.log)
load_demo(ui.editor)
load_demo(ui.json_editor)

heading('Layout')
Expand Down
7 changes: 7 additions & 0 deletions website/more_documentation/editor_documentation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from nicegui import ui


def main_demo() -> None:
editor = ui.editor(placeholder='Type something here')
ui.markdown().bind_content_from(editor, 'value',
backward=lambda v: f'HTML code:\n```\n{v}\n```')

0 comments on commit bdd94c8

Please sign in to comment.