Skip to content

Commit b6b6521

Browse files
committed
feat(json-crdt-extensions): 🎸 improve MarkerOverlayPoint presentation
1 parent 5847c75 commit b6b6521

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/json-crdt-extensions/peritext/overlay/MarkerOverlayPoint.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type {Anchor} from '../rga/constants';
44
import type {AbstractRga} from '../../../json-crdt/nodes/rga';
55
import type {ITimestampStruct} from '../../../json-crdt-patch/clock';
66
import type {MarkerSlice} from '../slice/MarkerSlice';
7+
import {printTree} from 'sonic-forest/lib/print/printTree';
78

89
export class MarkerOverlayPoint extends OverlayPoint {
910
/**
@@ -23,21 +24,23 @@ export class MarkerOverlayPoint extends OverlayPoint {
2324
return this.marker ? this.marker.hash : 0;
2425
}
2526

26-
public tag(): SliceType | 0 {
27-
if (!this.marker) return 0;
28-
return this.marker.type;
27+
public type(): SliceType {
28+
return this.marker && this.marker.type;
2929
}
3030

3131
public data(): unknown {
32-
if (!this.marker) return undefined;
33-
return this.marker.data();
32+
return this.marker && this.marker.data();
3433
}
3534

3635
// ---------------------------------------------------------------- Printable
3736

3837
public toStringName(tab: string, lite?: boolean): string {
3938
const hash = lite ? '' : `#${this.textHash.toString(36).slice(-4)}`;
40-
const tag = lite ? '' : `, ${JSON.stringify((this.tag() as any)[1])}`;
39+
const tag = lite ? '' : `, type = ${JSON.stringify((this.type() as any))}`;
4140
return `${super.toStringName(tab, lite)}${lite ? '' : ' '}${hash}${tag}`;
4241
}
42+
43+
public toString(tab: string = '', lite?: boolean): string {
44+
return super.toString(tab, lite) + (lite ? '' : printTree(tab, [tab => this.marker.toString(tab)]));
45+
}
4346
}

0 commit comments

Comments
 (0)