Skip to content

Commit b3d4cee

Browse files
committed
refactor(json-crdt-extensions): 💡 rename SplitSlice to MarkerSlice
1 parent 4612bd4 commit b3d4cee

File tree

6 files changed

+18
-19
lines changed

6 files changed

+18
-19
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {Point} from '../rga/Point';
22
import {compare} from '../../../json-crdt-patch/clock';
33
import {OverlayRef, OverlayRefSliceEnd, OverlayRefSliceStart} from './refs';
44
import {printTree} from 'sonic-forest/lib/print/printTree';
5-
import type {SplitSlice} from '../slice/SplitSlice';
5+
import type {MarkerSlice} from '../slice/MarkerSlice';
66
import type {HeadlessNode} from 'sonic-forest/lib/types';
77
import type {Printable} from '../../../util/print/types';
88
import type {Slice} from '../slice/types';
@@ -157,7 +157,7 @@ export class OverlayPoint extends Point implements Printable, HeadlessNode {
157157
*
158158
* @param slice A marker (split slice).
159159
*/
160-
public addMarkerRef(slice: SplitSlice): void {
160+
public addMarkerRef(slice: MarkerSlice): void {
161161
this.refs.push(slice);
162162
this.addMarker(slice);
163163
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {SplitSlice} from '../slice/SplitSlice';
1+
import type {MarkerSlice} from '../slice/MarkerSlice';
22
import type {Slice} from '../slice/types';
33

44
/**
@@ -8,7 +8,7 @@ import type {Slice} from '../slice/types';
88
* and one to the end slice.
99
*/
1010
export type OverlayRef =
11-
| SplitSlice // Ref to a *marker* slice
11+
| MarkerSlice // Ref to a *marker*
1212
| OverlayRefSliceStart // Ref to the start of an annotation slice
1313
| OverlayRefSliceEnd; // Ref to the end of an annotation slice
1414

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {PersistedSlice} from './PersistedSlice';
2+
3+
/**
4+
* Represents a block split in the text, i.e. it is a *marker* that shows
5+
* where a block was split.
6+
*
7+
* @deprecated
8+
*/
9+
export class MarkerSlice extends PersistedSlice {}

src/json-crdt-extensions/peritext/slice/PersistedSlice.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {VecNode} from '../../../json-crdt/nodes';
1010
import {prettyOneLine} from '../../../json-pretty';
1111
import {validateType} from './util';
1212
import {s} from '../../../json-crdt-patch';
13-
import type {JsonNode} from '../../../json-crdt/nodes';
1413
import type {ITimestampStruct} from '../../../json-crdt-patch/clock';
1514
import type {ArrChunk} from '../../../json-crdt/nodes';
1615
import type {MutableSlice, SliceUpdateParams} from './types';

src/json-crdt-extensions/peritext/slice/Slices.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {updateRga} from '../../../json-crdt/hash';
55
import {CONST, updateNum} from '../../../json-hash';
66
import {printTree} from '../../../util/print/printTree';
77
import {SliceBehavior, SliceHeaderShift, SliceTupleIndex} from './constants';
8-
import {SplitSlice} from './SplitSlice';
8+
import {MarkerSlice} from './MarkerSlice';
99
import {VecNode} from '../../../json-crdt/nodes';
1010
import {AvlMap} from 'sonic-forest/lib/avl/AvlMap';
1111
import type {Slice} from './types';
@@ -56,14 +56,14 @@ export class Slices implements Stateful, Printable {
5656
const txt = this.txt;
5757
const slice =
5858
behavior === SliceBehavior.Split
59-
? new SplitSlice(txt, txt.str, chunk, tuple, behavior, type, start, end)
59+
? new MarkerSlice(txt, txt.str, chunk, tuple, behavior, type, start, end)
6060
: new PersistedSlice(txt, txt.str, chunk, tuple, behavior, type, start, end);
6161
this.list.set(chunk.id, slice);
6262
return slice;
6363
}
6464

65-
public insSplit(range: Range, type: SliceType, data?: unknown): SplitSlice {
66-
return this.ins(range, SliceBehavior.Split, type, data) as SplitSlice;
65+
public insSplit(range: Range, type: SliceType, data?: unknown): MarkerSlice {
66+
return this.ins(range, SliceBehavior.Split, type, data) as MarkerSlice;
6767
}
6868

6969
public insStack(range: Range, type: SliceType, data?: unknown): PersistedSlice {
@@ -89,7 +89,7 @@ export class Slices implements Stateful, Printable {
8989
let slice = PersistedSlice.deserialize(txt, rga, chunk, tuple);
9090
// TODO: Simplify, remove `SplitSlice` class.
9191
if (slice.isSplit())
92-
slice = new SplitSlice(txt, rga, chunk, tuple, slice.behavior, slice.type, slice.start, slice.end);
92+
slice = new MarkerSlice(txt, rga, chunk, tuple, slice.behavior, slice.type, slice.start, slice.end);
9393
return slice;
9494
}
9595

src/json-crdt-extensions/peritext/slice/SplitSlice.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)