Skip to content

Commit

Permalink
(FE) Incorrect Integration of CodeMirror and Yorkie Resulting in Docu…
Browse files Browse the repository at this point in the history
…ment Synchronization (#102)

* Fix doc synchronization when grab multi cursor

* Update env for docker-compose
  • Loading branch information
devleejb authored Jan 25, 2024
1 parent 86d9c46 commit 937c34f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions backend/docker/docker-compose-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ services:
GITHUB_CALLBACK_URL: "<BACKEND_BASE_URL>/auth/login/github"
JWT_AUTH_SECRET: "JWT_AUTH_SECRET"
FRONTEND_BASE_URL: "FRONTEND_BASE_URL"
YORKIE_API_ADDR: "YORKIE_API_ADDR"
YORKIE_PROJECT_NAME: "YORKIE_PROJECT_NAME"
YORKIE_PROJECT_SECRET_KEY: "YORKIE_PROJECT_SECRET_KEY"
ports:
- "3000:3000"
depends_on:
Expand Down
4 changes: 4 additions & 0 deletions backend/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ services:
build:
context: ../
environment:
# Environment variables need to be passed to the container
DATABASE_URL: "DATABASE_URL"
GITHUB_CLIENT_ID: "GITHUB_CLIENT_ID"
GITHUB_CLIENT_SECRET: "GITHUB_CLIENT_SECRET"
GITHUB_CALLBACK_URL: "<BACKEND_BASE_URL>/auth/login/github"
JWT_AUTH_SECRET: "JWT_AUTH_SECRET"
FRONTEND_BASE_URL: "FRONTEND_BASE_URL"
YORKIE_API_ADDR: "YORKIE_API_ADDR"
YORKIE_PROJECT_NAME: "YORKIE_PROJECT_NAME"
YORKIE_PROJECT_SECRET_KEY: "YORKIE_PROJECT_SECRET_KEY"
ports:
- "3000:3000"
restart: unless-stopped
4 changes: 3 additions & 1 deletion frontend/src/utils/yorkie/yorkieSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,15 @@ class YorkieSyncPluginValue implements cmView.PluginValue {
return;
}

let adj = 0;
this._doc.update((root, presence) => {
update.changes.iterChanges((fromA, toA, _fromB, _toB, insert) => {
if (!root.content) {
root.content = new yorkie.Text();
}
const insertText = insert.sliceString(0, insert.length, "\n");
const updatedIndexRange = root.content.edit(fromA, toA, insertText);
const updatedIndexRange = root.content.edit(fromA + adj, toA + adj, insertText);
adj += insertText.length - (toA - fromA);
if (updatedIndexRange) {
presence.set({
selection: root.content.indexRangeToPosRange(updatedIndexRange),
Expand Down

0 comments on commit 937c34f

Please sign in to comment.