Live collaboration with Yjs over ActionCable
All editors now work on a server document at the same time instead of taking turns behind an edit lock. - The document's content is a sequence of Yjs updates (document_updates); DocumentChannel stores and relays them immediately, checks access on subscribe and again whenever links or memberships change. - app/frontend/collab/: the store stays position-based; a binding maps it to a Yjs form with stable row/column ids, so a row inserted by one person doesn't misplace what another is typing. Remote changes are applied only after pending local ones went into Yjs. - Per-person undo (Y.UndoManager), presence via awareness: the others' selections as coloured boxes with names, avatars in the toolbar. - Existing JSON documents convert on first open, deterministically, so two people opening one at once end up with the same Yjs state. - Editors compact the stored updates after 200 and keep a JSON snapshot current for export and duplicating. Edit lock and polling are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+12
-5
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.1].define(version: 2026_09_28_120300) do
|
||||
ActiveRecord::Schema[8.1].define(version: 2026_09_29_090000) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "citext"
|
||||
enable_extension "pg_catalog.plpgsql"
|
||||
@@ -31,16 +31,21 @@ ActiveRecord::Schema[8.1].define(version: 2026_09_28_120300) do
|
||||
t.index ["user_id"], name: "index_document_memberships_on_user_id"
|
||||
end
|
||||
|
||||
create_table "document_updates", force: :cascade do |t|
|
||||
t.uuid "document_id", null: false
|
||||
t.bigint "user_id"
|
||||
t.binary "data", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.index ["document_id"], name: "index_document_updates_on_document_id"
|
||||
t.index ["user_id"], name: "index_document_updates_on_user_id"
|
||||
end
|
||||
|
||||
create_table "documents", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.bigint "owner_id", null: false
|
||||
t.string "title", null: false
|
||||
t.text "content", null: false
|
||||
t.integer "version", default: 1, null: false
|
||||
t.bigint "updated_by_id"
|
||||
t.datetime "content_updated_at", null: false
|
||||
t.string "lock_holder"
|
||||
t.string "lock_holder_name"
|
||||
t.datetime "lock_expires_at"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["owner_id"], name: "index_documents_on_owner_id"
|
||||
@@ -273,6 +278,8 @@ ActiveRecord::Schema[8.1].define(version: 2026_09_28_120300) do
|
||||
add_foreign_key "document_memberships", "documents", on_delete: :cascade
|
||||
add_foreign_key "document_memberships", "share_links", on_delete: :cascade
|
||||
add_foreign_key "document_memberships", "users", on_delete: :cascade
|
||||
add_foreign_key "document_updates", "documents", on_delete: :cascade
|
||||
add_foreign_key "document_updates", "users", on_delete: :nullify
|
||||
add_foreign_key "documents", "users", column: "owner_id", on_delete: :cascade
|
||||
add_foreign_key "documents", "users", column: "updated_by_id", on_delete: :nullify
|
||||
add_foreign_key "magic_links", "documents", on_delete: :cascade
|
||||
|
||||
Reference in New Issue
Block a user