@@ -23,16 +23,19 @@ import type {SliceSchema, SliceType} from './slice/types';
23
23
import type { SchemaToJsonNode } from '../../json-crdt/schema/types' ;
24
24
import type { AbstractRga } from '../../json-crdt/nodes/rga' ;
25
25
import type { ChunkSlice } from './util/ChunkSlice' ;
26
+ import type { Stateful } from './types' ;
26
27
27
28
const EXTRA_SLICES_SCHEMA = s . vec ( s . arr < SliceSchema > ( [ ] ) ) ;
29
+ const LOCAL_DATA_SCHEMA = EXTRA_SLICES_SCHEMA ;
28
30
29
- type SlicesModel = Model < SchemaToJsonNode < typeof EXTRA_SLICES_SCHEMA > > ;
31
+ export type ExtraSlicesModel = Model < SchemaToJsonNode < typeof EXTRA_SLICES_SCHEMA > > ;
32
+ export type LocalModel = Model < SchemaToJsonNode < typeof LOCAL_DATA_SCHEMA > > ;
30
33
31
34
/**
32
35
* Context for a Peritext instance. Contains all the data and methods needed to
33
36
* interact with the text.
34
37
*/
35
- export class Peritext < T = string > implements Printable {
38
+ export class Peritext < T = string > implements Printable , Stateful {
36
39
/**
37
40
* *Slices* are rich-text annotations that appear in the text. The "saved"
38
41
* slices are the ones that are persisted in the document.
@@ -76,8 +79,8 @@ export class Peritext<T = string> implements Printable {
76
79
public readonly str : AbstractRga < T > ,
77
80
slices : ArrNode ,
78
81
// TODO: Add test that verifies that SIDs are different across all three models.
79
- extraSlicesModel : SlicesModel = Model . create ( EXTRA_SLICES_SCHEMA , model . clock . sid - 1 ) ,
80
- localSlicesModel : SlicesModel = Model . create ( EXTRA_SLICES_SCHEMA , SESSION . LOCAL ) ,
82
+ extraSlicesModel : ExtraSlicesModel = Model . create ( EXTRA_SLICES_SCHEMA , model . clock . sid - 1 ) ,
83
+ localSlicesModel : LocalModel = Model . create ( LOCAL_DATA_SCHEMA , SESSION . LOCAL ) ,
81
84
) {
82
85
this . savedSlices = new Slices ( this , slices ) ;
83
86
this . extraSlices = new ExtraSlices ( this , extraSlicesModel . root . node ( ) . get ( 0 ) ! ) ;
@@ -327,7 +330,7 @@ export class Peritext<T = string> implements Printable {
327
330
api . apply ( ) ;
328
331
}
329
332
330
- // ---------------------------------------------------------------- Printable
333
+ /** ----------------------------------------------------- { @link Printable} */
331
334
332
335
public toString ( tab : string = '' ) : string {
333
336
const nl = ( ) => '' ;
@@ -348,7 +351,7 @@ export class Peritext<T = string> implements Printable {
348
351
) ;
349
352
}
350
353
351
- // ----------------------------------------------------------------- Stateful
354
+ /** ------------------------------------------------------ { @link Stateful} */
352
355
353
356
public hash : number = 0 ;
354
357
0 commit comments