diff --git a/src/json-crdt-extensions/peritext/overlay/MarkerOverlayPoint.ts b/src/json-crdt-extensions/peritext/overlay/MarkerOverlayPoint.ts index 7edf952807..341914c8e8 100644 --- a/src/json-crdt-extensions/peritext/overlay/MarkerOverlayPoint.ts +++ b/src/json-crdt-extensions/peritext/overlay/MarkerOverlayPoint.ts @@ -4,6 +4,7 @@ import type {Anchor} from '../rga/constants'; import type {AbstractRga} from '../../../json-crdt/nodes/rga'; import type {ITimestampStruct} from '../../../json-crdt-patch/clock'; import type {MarkerSlice} from '../slice/MarkerSlice'; +import {printTree} from 'sonic-forest/lib/print/printTree'; export class MarkerOverlayPoint extends OverlayPoint { /** @@ -23,21 +24,23 @@ export class MarkerOverlayPoint extends OverlayPoint { return this.marker ? this.marker.hash : 0; } - public tag(): SliceType | 0 { - if (!this.marker) return 0; - return this.marker.type; + public type(): SliceType { + return this.marker && this.marker.type; } public data(): unknown { - if (!this.marker) return undefined; - return this.marker.data(); + return this.marker && this.marker.data(); } // ---------------------------------------------------------------- Printable public toStringName(tab: string, lite?: boolean): string { const hash = lite ? '' : `#${this.textHash.toString(36).slice(-4)}`; - const tag = lite ? '' : `, ${JSON.stringify((this.tag() as any)[1])}`; + const tag = lite ? '' : `, type = ${JSON.stringify((this.type() as any))}`; return `${super.toStringName(tab, lite)}${lite ? '' : ' '}${hash}${tag}`; } + + public toString(tab: string = '', lite?: boolean): string { + return super.toString(tab, lite) + (lite ? '' : printTree(tab, [tab => this.marker.toString(tab)])); + } }