-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from NoteSpaceTeam/canitworkdunno
Branch merge into main
- Loading branch information
Showing
33 changed files
with
288 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { MarkdownConnector } from '@domain/editor/connectors/markdown/types'; | ||
import { ServiceConnector } from '@domain/editor/connectors/service/connector'; | ||
import { InputConnector } from '@domain/editor/connectors/input/types'; | ||
import { HistoryConnector } from '@domain/editor/connectors/history/types'; | ||
import { Fugue } from '@domain/editor/fugue/Fugue'; | ||
import { Communication } from '@services/communication/communication'; | ||
import inputConnector from '@domain/editor/connectors/input/connector'; | ||
import markdownConnector from '@domain/editor/connectors/markdown/connector'; | ||
import historyConnector from '@domain/editor/connectors/history/connector'; | ||
import serviceConnector from '@domain/editor/connectors/service/connector'; | ||
|
||
export class Connectors { | ||
private readonly inputConnector: InputConnector; | ||
private readonly markdownConnector: MarkdownConnector; | ||
private readonly historyConnector: HistoryConnector; | ||
private readonly serviceConnector: ServiceConnector; | ||
|
||
constructor(fugue: Fugue, communication: Communication) { | ||
this.serviceConnector = serviceConnector(fugue, communication); | ||
this.inputConnector = inputConnector(fugue, this.serviceConnector); | ||
this.markdownConnector = markdownConnector(fugue, this.serviceConnector); | ||
this.historyConnector = historyConnector(fugue, this.serviceConnector); | ||
} | ||
|
||
get input(): InputConnector { | ||
return this.inputConnector; | ||
} | ||
|
||
get markdown(): MarkdownConnector { | ||
return this.markdownConnector; | ||
} | ||
|
||
get history(): HistoryConnector { | ||
return this.historyConnector; | ||
} | ||
|
||
get service(): ServiceConnector { | ||
return this.serviceConnector; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { HistoryOperation } from '@domain/editor/slate/operations/history/types'; | ||
|
||
export type HistoryConnector = { | ||
applyHistoryOperation: ApplyHistory; | ||
}; | ||
|
||
export type ApplyHistory = (operations: HistoryOperation[]) => void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
.../editor/fugue/operations/input/types.d.ts → ...domain/editor/connectors/input/types.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...itor/fugue/operations/markdown/types.d.ts → ...ain/editor/connectors/markdown/types.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
48 changes: 48 additions & 0 deletions
48
code/client/src/domain/editor/connectors/service/connector.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Communication } from '@services/communication/communication'; | ||
import { Fugue } from '@domain/editor/fugue/Fugue'; | ||
import { Operation } from '@notespace/shared/src/document/types/operations'; | ||
import { InlineStyle } from '@notespace/shared/src/document/types/styles'; | ||
import { BaseSelection } from 'slate'; | ||
import { SocketEventHandlers } from '@services/communication/socket/socketCommunication'; | ||
|
||
export type ServiceConnector = { | ||
communication: Communication; | ||
applyFugueOperations: (operations: Operation[]) => void; | ||
emitOperations: (operations: Operation[]) => void; | ||
emitCursorChange({ range, styles }: { range: BaseSelection; styles: InlineStyle[] }): void; | ||
on(name: string, handler: (...args: any[]) => void): void; | ||
getEvents(): SocketEventHandlers; | ||
}; | ||
|
||
export default (fugue: Fugue, communication: Communication): ServiceConnector => { | ||
const events: SocketEventHandlers = {}; | ||
|
||
function applyFugueOperations(operations: Operation[]) { | ||
fugue.applyOperations(operations); | ||
} | ||
|
||
function emitOperations(operations: Operation[]) { | ||
communication.socket.emit('operations', operations); | ||
} | ||
|
||
function emitCursorChange({ range, styles }: { range: BaseSelection; styles: InlineStyle[] }) { | ||
communication.socket.emit('cursorChange', { range, styles }); | ||
} | ||
|
||
function on(name: string, handler: (...args: any[]) => void) { | ||
events[name] = handler; | ||
} | ||
|
||
function getEvents() { | ||
return events; | ||
} | ||
|
||
return { | ||
communication, | ||
applyFugueOperations, | ||
emitOperations, | ||
emitCursorChange, | ||
on, | ||
getEvents, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { useMemo } from 'react'; | ||
import { Connectors } from '@domain/editor/connectors/Connectors'; | ||
import { Fugue } from '@domain/editor/fugue/Fugue'; | ||
import { Communication } from '@services/communication/communication'; | ||
|
||
export default function (fugue: Fugue, communication: Communication) { | ||
return useMemo(() => new Connectors(fugue, communication), [communication, fugue]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
code/client/src/domain/editor/fugue/operations/fugue/operations.ts
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
code/client/src/domain/editor/fugue/operations/fugue/types.d.ts
This file was deleted.
Oops, something went wrong.
25 changes: 9 additions & 16 deletions
25
code/client/src/domain/editor/slate/operations/getEventHandlers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.