json-joy
Version:
Collection of libraries for building collaborative editing apps.
43 lines (42 loc) • 1.57 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.MarkerOverlayPoint = void 0;
const printTree_1 = require("tree-dump/lib/printTree");
const OverlayPoint_1 = require("./OverlayPoint");
class MarkerOverlayPoint extends OverlayPoint_1.OverlayPoint {
constructor(rga, id, anchor, marker) {
super(rga, id, anchor);
this.rga = rga;
this.marker = marker;
/**
* Hash value of the following text contents, up until the next marker.
*/
this.textHash = 0;
}
type() {
return this.marker && this.marker.type;
}
data() {
return this.marker && this.marker.data();
}
// ---------------------------------------------------------------- Printable
toStringName() {
return 'MarkerOverlayPoint';
}
toStringHeader(tab, lite) {
const hash = lite ? '' : `#${this.textHash.toString(36).slice(-4)}`;
const tag = lite ? '' : `, type = ${JSON.stringify(this.type())}`;
return `${super.toStringHeader(tab, lite)}${lite ? '' : ' '}${hash}${tag}`;
}
toString(tab = '', lite) {
return (this.toStringHeader(tab, lite) +
(lite
? ''
: (0, printTree_1.printTree)(tab, [
(tab) => this.marker.toString(tab),
...this.layers.map((slice) => (tab) => slice.toString(tab)),
...this.markers.map((slice) => (tab) => slice.toString(tab)),
])));
}
}
exports.MarkerOverlayPoint = MarkerOverlayPoint;
;