Mercurial > libervia-web
view libervia/web/pages/_browser/popup.py @ 1635:332822ceae85
browser (chat): Add rich editor, forward and extra recipients:
A new "extra" menu is now available next to input field, allowing to toggle to rich
editor. Rich editors allows message styling using bold, italic, underline, (un)numbered
list and link. Other features will probably follow with time.
An extra menu item allows to add recipients, with `to`, `cc` or `bcc` flag like for
emails.
Messages can now be forwarded to any entity with a new item in the 3 dots menu.
rel 461
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 04 Jul 2025 17:47:37 +0200 |
parents | a2cd4222c702 |
children |
line wrap: on
line source
from browser import document, timer from js_modules.tippy_js import tippy as tippy_ori from javascript import pyobj2jsobj # FIXME: workaround for https://github.com/brython-dev/brython/issues/2542 def tippy(target, data): return tippy_ori(target, pyobj2jsobj(data)) def create_popup( target, content_elt, focus_class="has-popup-focus", focus_elt=None, placement="bottom", **kwargs ): """Create a popup and show a popup next to a target The popup is created and destroyed on each call, this can be used for dynamic content. @param target: element where the popup will appear, or a selector @param content_elt: HTML element to show in the popup @param focus_class: class added to target element when popup is shown @param focus_elt: element where focus_class is added. If None, target will be used. @param placement: where the popup must be located. @param kwargs: arguments used to override tippy options """ if focus_elt is None: focus_elt = target def on_hide(__): focus_elt.classList.remove(focus_class) timer.set_timeout(tippy_instance.destroy, 0) tippy_opts = { "trigger": "click", "content": content_elt, "appendTo": document.body, "placement": placement, "interactive": True, "trigger": "manual", "theme": "light", "onShow": lambda __: focus_elt.classList.add(focus_class), "onHide": on_hide } tippy_opts.update(kwargs) tippy_instance = tippy( target, tippy_opts ) tippy_instance.show() return tippy_instance