Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(FE) Incorrect Integration of CodeMirror and Yorkie Resulting in Document Synchronization #102

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading