Some document stuff in progress
This commit is contained in:
+6
-1
@@ -1,9 +1,14 @@
|
||||
import { Editor } from "./editor";
|
||||
import { HttpRemoteSpace } from "./space";
|
||||
import { safeRun } from "./util";
|
||||
import { io } from "socket.io-client";
|
||||
|
||||
let socket = io("http://localhost:3000");
|
||||
|
||||
import { serverEvents } from "../../server/src/events";
|
||||
|
||||
let editor = new Editor(
|
||||
new HttpRemoteSpace(`http://${location.hostname}:3000/fs`),
|
||||
new HttpRemoteSpace(`http://${location.hostname}:3000/fs`, socket),
|
||||
document.getElementById("root")!
|
||||
);
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ import { slashCommandRegexp } from "./types";
|
||||
|
||||
import reducer from "./reducer";
|
||||
import { smartQuoteKeymap } from "./smart_quotes";
|
||||
import { Space } from "./space";
|
||||
import { HttpRemoteSpace } from "./space";
|
||||
import customMarkdownStyle from "./style";
|
||||
import dbSyscalls from "./syscalls/db.localstorage";
|
||||
import editorSyscalls from "./syscalls/editor.browser";
|
||||
@@ -78,14 +78,14 @@ export class Editor implements AppEventDispatcher {
|
||||
viewState: AppViewState;
|
||||
viewDispatch: React.Dispatch<Action>;
|
||||
openPages: Map<string, PageState>;
|
||||
space: Space;
|
||||
space: HttpRemoteSpace;
|
||||
editorCommands: Map<string, AppCommand>;
|
||||
plugs: Plug<NuggetHook>[];
|
||||
indexer: Indexer;
|
||||
navigationResolve?: (val: undefined) => void;
|
||||
pageNavigator: IPageNavigator;
|
||||
|
||||
constructor(space: Space, parent: Element) {
|
||||
constructor(space: HttpRemoteSpace, parent: Element) {
|
||||
this.editorCommands = new Map();
|
||||
this.openPages = new Map();
|
||||
this.plugs = [];
|
||||
|
||||
+17
-1
@@ -1,4 +1,7 @@
|
||||
import { PageMeta } from "./types";
|
||||
import { Socket } from "socket.io-client";
|
||||
import { serverEvents } from "../../server/src/events";
|
||||
import { EventEmitter } from "events";
|
||||
|
||||
export interface Space {
|
||||
listPages(): Promise<PageMeta[]>;
|
||||
@@ -10,9 +13,15 @@ export interface Space {
|
||||
|
||||
export class HttpRemoteSpace implements Space {
|
||||
url: string;
|
||||
socket: Socket;
|
||||
|
||||
constructor(url: string) {
|
||||
constructor(url: string, socket: Socket) {
|
||||
this.url = url;
|
||||
this.socket = socket;
|
||||
|
||||
socket.on("connect", () => {
|
||||
console.log("connected via SocketIO", serverEvents.pageText);
|
||||
});
|
||||
}
|
||||
|
||||
async listPages(): Promise<PageMeta[]> {
|
||||
@@ -26,6 +35,13 @@ export class HttpRemoteSpace implements Space {
|
||||
}));
|
||||
}
|
||||
|
||||
async openPage(name: string) {
|
||||
this.socket.on(serverEvents.pageText, (pageName, text) => {
|
||||
console.log("Got this", pageName, text);
|
||||
});
|
||||
this.socket.emit(serverEvents.openPage, "start");
|
||||
}
|
||||
|
||||
async readPage(name: string): Promise<{ text: string; meta: PageMeta }> {
|
||||
let req = await fetch(`${this.url}/${name}`, {
|
||||
method: "GET",
|
||||
|
||||
Reference in New Issue
Block a user