PhoenixKit.Modules.Publishing.Web.Editor.Collaborative (phoenix_kit v1.7.71)
Copy Markdown View SourceCollaborative editing functionality for the publishing editor.
Handles presence tracking, lock management, spectator mode, real-time form sync, and lock expiration.
Summary
Functions
Apply remote form changes (for spectators receiving updates).
Apply remote form state (for spectators receiving initial sync).
Assigns default editing state when collaborative editing is not available.
Assigns the editing role (owner or spectator) based on presence.
Broadcast editor activity to group listing (for showing who's editing).
Broadcast editor left for a specific post slug (used when we've already switched posts).
Broadcast form changes to spectators (only owners broadcast).
Build user info for broadcasts.
Cancel lock expiration timer.
Check if lock should expire or warn user.
Used when we know the old form_key (e.g., when switching languages/versions).
Only broadcast editor_joined if user is the owner (not a spectator).
Conditionally start lock expiration timer after role assignment.
Release lock due to inactivity.
Sets up collaborative editing for initial load. old_form_key and old_post_slug should be captured BEFORE the socket is updated.
Start lock expiration timer (only for owners).
Update activity timestamp on user interactions.
Attempts to reclaim the editing lock after it was released due to inactivity.
Unsubscribe from current post's topics (used in terminate when LiveView closes).
Functions
Apply remote form changes (for spectators receiving updates).
Apply remote form state (for spectators receiving initial sync).
Assigns default editing state when collaborative editing is not available.
Assigns the editing role (owner or spectator) based on presence.
Broadcast editor activity to group listing (for showing who's editing).
Broadcast editor left for a specific post slug (used when we've already switched posts).
Broadcast form changes to spectators (only owners broadcast).
Build user info for broadcasts.
Cancel lock expiration timer.
Check if lock should expire or warn user.
Used when we know the old form_key (e.g., when switching languages/versions).
Only broadcast editor_joined if user is the owner (not a spectator).
Conditionally start lock expiration timer after role assignment.
Release lock due to inactivity.
Sets up collaborative editing for initial load. old_form_key and old_post_slug should be captured BEFORE the socket is updated.
Start lock expiration timer (only for owners).
Update activity timestamp on user interactions.
Attempts to reclaim the editing lock after it was released due to inactivity.
Called on user interaction when lock_released_by_timeout is true.
Re-tracks presence, reclaims ownership if no other user holds the lock,
and restarts the expiration timer.
Unsubscribe from current post's topics (used in terminate when LiveView closes).