mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-16 08:04:45 -04:00
fix(commons): extract name of markdown content yjs channel into the commons package
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
329a4d4e55
commit
11c2f57e4b
6 changed files with 22 additions and 13 deletions
|
@ -3,7 +3,10 @@
|
|||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { encodeDocumentUpdateMessage } from '@hedgedoc/commons';
|
||||
import {
|
||||
encodeDocumentUpdateMessage,
|
||||
MARKDOWN_CONTENT_CHANNEL_NAME,
|
||||
} from '@hedgedoc/commons';
|
||||
import { Doc } from 'yjs';
|
||||
|
||||
import { RealtimeNote } from './realtime-note';
|
||||
|
@ -13,8 +16,6 @@ import { WebsocketConnection } from './websocket-connection';
|
|||
* This is the implementation of {@link Doc YDoc} which includes additional handlers for message sending and receiving.
|
||||
*/
|
||||
export class WebsocketDoc extends Doc {
|
||||
private static readonly channelName = 'markdownContent';
|
||||
|
||||
/**
|
||||
* Creates a new WebsocketDoc instance.
|
||||
*
|
||||
|
@ -55,7 +56,7 @@ export class WebsocketDoc extends Doc {
|
|||
* @private
|
||||
*/
|
||||
private initializeContent(initialContent: string): void {
|
||||
this.getText(WebsocketDoc.channelName).insert(0, initialContent);
|
||||
this.getText(MARKDOWN_CONTENT_CHANNEL_NAME).insert(0, initialContent);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,6 +67,6 @@ export class WebsocketDoc extends Doc {
|
|||
* @return The current note content.
|
||||
*/
|
||||
public getCurrentContent(): string {
|
||||
return this.getText(WebsocketDoc.channelName).toString();
|
||||
return this.getText(MARKDOWN_CONTENT_CHANNEL_NAME).toString();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue