diff --git a/public/src/components/Editor/Editor.ts b/public/src/components/Editor/Editor.ts index e4f546b6..7a2ce951 100644 --- a/public/src/components/Editor/Editor.ts +++ b/public/src/components/Editor/Editor.ts @@ -11,6 +11,8 @@ import { import {AppUserStore} from "../../modules/stores/UserStore"; import {getCaretPosition} from "../../modules/utils"; import {debounce} from "../../utils/debauncer"; +import {AppNotesStore} from "../../modules/stores/NotesStore"; +import {AppNoteStore} from "../../modules/stores/NoteStore"; export class Editor { private readonly editable: HTMLElement; @@ -81,7 +83,7 @@ export class Editor { const scanTree = (node: HTMLElement) => { if (`cursor${AppUserStore.state.username}` in node.dataset) { - delete node.dataset[`cursor${AppUserStore.state.username}`]; + delete node.dataset[`cursor${AppUserStore.state.username}-${AppNotesStore.socket_id.toString()}`]; } node.childNodes.forEach(child => { @@ -106,7 +108,7 @@ export class Editor { scanTree(this.editable); - elem.dataset[`cursor${AppUserStore.state.username}`] = `${getCaretPosition(elem)}`; + elem.dataset[`cursor${AppUserStore.state.username}-${AppNotesStore.socket_id.toString()}`] = `${getCaretPosition(elem)}`; // TODO: отоброажать курсоры пользователей при редактировании одной заметки // const fakeCaret = document.createElement("div") @@ -208,7 +210,9 @@ export class Editor { const parentPlugin = defaultPlugins.find(plug => { return plug.checkPlugin(node.parentElement); }); - if ((parentPlugin.pluginName === 'div' || parentPlugin.pluginName === 'li' || parentPlugin.pluginName === 'li-todo') && node.textContent.startsWith('/') && `cursor${AppUserStore.state.username}` in node.parentElement.dataset) { + if ((parentPlugin.pluginName === 'div' || parentPlugin.pluginName === 'li' || parentPlugin.pluginName === 'li-todo') && + node.textContent.startsWith('/') && + `cursor${AppUserStore.state.username}-${AppNotesStore.socket_id.toString()}` in node.parentElement.dataset) { lastChosenElement.node = node; this.dropdownCallbacks.open(node.parentElement) } else { @@ -220,7 +224,7 @@ export class Editor { return plugin.pluginName === 'div'; })); defaultPlugins[divIndex].onInsert = (node: Node) => { - if (node.textContent.startsWith('/') && `cursor${AppUserStore.state.username}` in node.parentElement.dataset) { + if (node.textContent.startsWith('/') && `cursor${AppUserStore.state.username}-${AppNotesStore.socket_id.toString()}` in node.parentElement.dataset) { lastChosenElement.node = node; this.dropdownCallbacks.open(node as HTMLElement) } diff --git a/public/src/modules/stores/NotesStore.ts b/public/src/modules/stores/NotesStore.ts index a853aa29..5ba54b34 100644 --- a/public/src/modules/stores/NotesStore.ts +++ b/public/src/modules/stores/NotesStore.ts @@ -40,7 +40,7 @@ class NotesStore extends BaseStore { }; private ws - private socket_id + public socket_id constructor() { super();