diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 7f0dd7a6..22771ef8 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -32,6 +32,7 @@ "codemirror-toolbar": "^0.0.3", "color": "^4.2.3", "lib0": "^0.2.88", + "lodash": "^4.17.21", "moment": "^2.30.1", "notistack": "^2.0.8", "randomcolor": "^0.6.2", @@ -50,6 +51,7 @@ }, "devDependencies": { "@types/color": "^3.0.6", + "@types/lodash": "^4.14.202", "@types/randomcolor": "^0.5.9", "@types/react": "^18.2.43", "@types/react-dom": "^18.2.17", @@ -2122,6 +2124,12 @@ "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", "dev": true }, + "node_modules/@types/lodash": { + "version": "4.14.202", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.202.tgz", + "integrity": "sha512-OvlIYQK9tNneDlS0VN54LLd5uiPCBOp7gS5Z0f1mjoJYBrtStzgmJBxONW3U6OZqdtNzZPmn9BS/7WI7BFFcFQ==", + "dev": true + }, "node_modules/@types/long": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz", @@ -4572,6 +4580,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", diff --git a/frontend/package.json b/frontend/package.json index c7a9668b..85b002c1 100755 --- a/frontend/package.json +++ b/frontend/package.json @@ -36,6 +36,7 @@ "codemirror-toolbar": "^0.0.3", "color": "^4.2.3", "lib0": "^0.2.88", + "lodash": "^4.17.21", "moment": "^2.30.1", "notistack": "^2.0.8", "randomcolor": "^0.6.2", @@ -54,6 +55,7 @@ }, "devDependencies": { "@types/color": "^3.0.6", + "@types/lodash": "^4.14.202", "@types/randomcolor": "^0.5.9", "@types/react": "^18.2.43", "@types/react-dom": "^18.2.17", diff --git a/frontend/src/utils/yorkie/remoteSelection.ts b/frontend/src/utils/yorkie/remoteSelection.ts index 553c0b78..b4e62cbd 100644 --- a/frontend/src/utils/yorkie/remoteSelection.ts +++ b/frontend/src/utils/yorkie/remoteSelection.ts @@ -11,6 +11,7 @@ import { YorkieCodeMirrorPresenceType, yorkieSyncFacet, } from "./yorkieSync.js"; +import _ from "lodash"; export const yorkieRemoteSelectionsTheme = cmView.EditorView.baseTheme({ ".cm-ySelection": {}, @@ -150,9 +151,12 @@ export class YorkieRemoteSelectionsPluginValue { if (sel && root.content) { const selection = root.content.indexRangeToPosRange([sel.anchor, sel.head]); - presence.set({ - selection, - }); + + if (!_.isEqual(selection, presence.get("selection"))) { + presence.set({ + selection, + }); + } } else if (presence.get("selection")) { presence.set({ selection: null,