json-joy
Version:
Collection of libraries for building collaborative editing apps.
26 lines (25 loc) • 750 B
JavaScript
import { NodeApi } from '../../json-crdt/model/api/nodes';
import { Peritext } from './Peritext';
import { printTree } from 'tree-dump/lib/printTree';
export class PeritextApi extends NodeApi {
node;
api;
txt;
editor;
constructor(node, api) {
super(node, api);
this.node = node;
this.api = api;
this.txt = new Peritext(api.model, node.text(), node.slices());
this.editor = this.txt.editor;
}
text() {
return this.api.wrap(this.node.text());
}
slices() {
return this.api.wrap(this.node.slices());
}
toString(tab) {
return ('PeritextApi' + printTree(tab, [(tab) => this.node.toString(tab), () => '', (tab) => this.txt.toString(tab)]));
}
}