Skip to content

Commit

Permalink
поправил курсоры
Browse files Browse the repository at this point in the history
  • Loading branch information
veglem committed May 17, 2024
1 parent f449263 commit 73e7863
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion public/src/components/Editor/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class Editor {
}

const scanTree = (node: HTMLElement) => {
if (`cursor${AppUserStore.state.username}` in node.dataset) {
if (`cursor${AppUserStore.state.username}-${AppNotesStore.socket_id.toString()}` in node.dataset) {
delete node.dataset[`cursor${AppUserStore.state.username}-${AppNotesStore.socket_id.toString()}`];
}

Expand Down
6 changes: 3 additions & 3 deletions public/src/components/Editor/Plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,12 +846,12 @@ export const fromJson = (props: PluginProps) => {
}
}

if (`cursor${AppUserStore.state.username}` in props) {
if (`cursor${AppUserStore.state.username}-${AppNotesStore.socket_id.toString()}` in props) {
// const regex = /([a-zA]+)-([\d]+)/;
// const matches = regex.exec(props.cursor as string);


if (props[`cursor${AppUserStore.state.username}`] === '0') {
if (props[`cursor${AppUserStore.state.username}-${AppNotesStore.socket_id.toString()}`] === '0') {
setTimeout(() => {
setCursorAtNodePosition(node, 0);
// (node as HTMLElement).click();
Expand All @@ -860,7 +860,7 @@ export const fromJson = (props: PluginProps) => {

} else {
setTimeout(() => {
setCursorAtNodePosition(node, Number(props[`cursor${AppUserStore.state.username}`]));
setCursorAtNodePosition(node, Number(props[`cursor${AppUserStore.state.username}-${AppNotesStore.socket_id.toString()}`]));
// (node as HTMLElement).click();
// document.getSelection().setPosition(node.firstChild, Number(props[`cursor${AppUserStore.state.username}`]));
})
Expand Down

0 comments on commit 73e7863

Please sign in to comment.