Collab Selection

Highlights text or cell ranges selected by other users.

python 4 params

Preview

selected textAda Lovelaceanother selectionGrace Hopper
Arguments
collab_selection(users=[{'name': 'Ada Lovelace', 'color': '#3b82f6', 'start': 10, 'end': 25, 'text': 'selected text'}, {'name': 'Grace Hopper', 'color': '#ef4444', 'start': 40, 'end': 55, 'text': 'another selection'}])

Draws other users' selections over your content through a client hook djust does not ship — see below.

Usage

views.py
python
from djust import LiveView
from djust.components import CollabSelection


class MyView(LiveView):
    template_name = "my_template.html"

    def mount(self, request, **kwargs):
        self.component = CollabSelection(users=[{'name': 'Ada Lovelace', 'color': '#3b82f6', 'start': 10, 'end': 25, 'text': 'selected text'}, {'name': 'Grace Hopper', 'color': '#ef4444', 'start': 40, 'end': 55, 'text': 'another selection'}])
my_template.html
django
{{ component }}

Needs its script on the page: <script src="{% static 'djust_components/collab-selection.js' %}"></script>. djust ships it; without it the markup renders but does not update in the browser.

Parameters

NameTypeDefaultDescription
usersList[Union[dict, object]] | NoneNoneList of user dicts with name, color, and selection data.
custom_classstr''Additional CSS classes.
targetstr''CSS selector of the element whose text the offsets index (optional).
**kwargs— passed to `Component.__init__`: `name=` identifies the instance in the events it sends, `id=` sets `component.id`, and any other keyword is kept as state——
Source & styles
FilePathNotes
moduledjust.components.components.collab_selectionSubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components.cssDefines 4 of this component's classes at line 2314, 2315, 2316, 2317. Override those rules, or the custom properties they read, in a stylesheet loaded after it.