1
0

mermaid_documentation.py 563 B

123456789101112131415161718192021222324252627
  1. from nicegui import ui
  2. from . import doc
  3. @doc.demo(ui.mermaid)
  4. def main_demo() -> None:
  5. ui.mermaid('''
  6. graph LR;
  7. A --> B;
  8. A --> C;
  9. ''')
  10. @doc.demo('Handle errors', '''
  11. You can handle errors by listening to the `error` event.
  12. The event `args` contain the properties `hash`, `message`, `str` and an `error` object with additional information.
  13. ''')
  14. def error_demo() -> None:
  15. ui.mermaid('''
  16. graph LR;
  17. A --> B;
  18. A -> C;
  19. ''').on('error', lambda e: print(e.args['message']))
  20. doc.reference(ui.mermaid)