Implementation should ideally been straightforward. As I could simply have made a client adapter that modifies an internal string.
class HeadlessAdapter implements IEditorAdapter {
protected _content: string;
constructor() {
this._content = "";
}
on(): void {
return;
}
off(): void {
return;
}
registerUndo(): void {
return;
}
registerRedo(): void {
return;
}
deregisterUndo(): void {
return;
}
deregisterRedo(): void {
return;
}
getCursor(): ICursor | null {
return null;
}
setCursor(): void {
return;
}
setOtherCursor(): IDisposable {
return {
dispose: () => {
return;
},
};
}
getText(): string {
return this._content;
}
setText(text: string): void {
this._content = text;
}
setInitiated(): void {
return;
}
applyOperation(operation: IPlainTextOperation): void {
if (!operation.isNoop()) {
return;
}
this._content = operation.apply(this._content);
}
invertOperation(operation: IPlainTextOperation): IPlainTextOperation {
return operation.invert(this._content);
}
dispose(): void {
return;
}
}
const headlessAdapter = new HeadlessAdapter();
const firebaseAdapter = new FirebaseAdapter(dbRef, 0, "#000000", "Admin");
const opts = <IFirepadConstructorOptions> {
userId: 0,
userColor: "#000000",
userName: "Admin"
};
const firepad = new Firepad(firebaseAdapter, headlessAdapter, opts);
Unfortunately this errors out with the following
ReferenceError: self is not defined
at Object.call (/workspace/template-typescript-node/node_modules/@hackerrank/firepad/dist/webpack:/node_modules/@operational-transformation/plaintext-editor/lib/index.js:1:515)
at require (/workspace/template-typescript-node/node_modules/@hackerrank/firepad/dist/webpack:/webpack/bootstrap:19:32)
at /workspace/template-typescript-node/node_modules/@hackerrank/firepad/dist/webpack:/lib/firepad-classic.js:3:26
at /workspace/template-typescript-node/node_modules/@hackerrank/firepad/dist/firepad.min.js:1:69312
Looks like its bundled with webpack, and the global object is set to self.
Implementation should ideally been straightforward. As I could simply have made a client adapter that modifies an internal string.
Unfortunately this errors out with the following
ReferenceError: self is not defined at Object.call (/workspace/template-typescript-node/node_modules/@hackerrank/firepad/dist/webpack:/node_modules/@operational-transformation/plaintext-editor/lib/index.js:1:515) at require (/workspace/template-typescript-node/node_modules/@hackerrank/firepad/dist/webpack:/webpack/bootstrap:19:32) at /workspace/template-typescript-node/node_modules/@hackerrank/firepad/dist/webpack:/lib/firepad-classic.js:3:26 at /workspace/template-typescript-node/node_modules/@hackerrank/firepad/dist/firepad.min.js:1:69312Looks like its bundled with webpack, and the global object is set to self.