@@ -3,7 +3,6 @@ import {stringify} from '../../../json-text/stringify';
33import { SliceBehavior , SliceTypeName } from '../slice/constants' ;
44import { Range } from '../rga/Range' ;
55import { ChunkSlice } from '../util/ChunkSlice' ;
6- import { MarkerOverlayPoint } from '../overlay/MarkerOverlayPoint' ;
76import { Cursor } from '../editor/Cursor' ;
87import { hashId } from '../../../json-crdt/hash' ;
98import { formatType } from '../slice/util' ;
@@ -15,34 +14,70 @@ import type {Peritext} from '../Peritext';
1514import type { Slice } from '../slice/types' ;
1615import type { PeritextMlAttributes , PeritextMlNode } from './types' ;
1716
18- /** The attribute started before this inline and ends after this inline. */
19- export class InlineAttrPassing {
17+ export abstract class AbstractInlineAttr {
2018 constructor ( public slice : Slice ) { }
19+
20+ /** @returns Whether the attribute starts at the start of the inline. */
21+ isStart ( ) : boolean {
22+ return false ;
23+ }
24+
25+ /** @returns Whether the attribute ends at the end of the inline. */
26+ isEnd ( ) : boolean {
27+ return false ;
28+ }
29+
30+ /** @returns Whether the attribute is collapsed to a point. */
31+ isCollapsed ( ) : boolean {
32+ return false ;
33+ }
2134}
2235
36+ /** The attribute started before this inline and ends after this inline. */
37+ export class InlineAttrPassing extends AbstractInlineAttr { }
38+
2339/** The attribute starts at the beginning of this inline. */
24- export class InlineAttrStart {
25- constructor ( public slice : Slice ) { }
40+ export class InlineAttrStart extends AbstractInlineAttr {
41+ isStart ( ) : boolean {
42+ return true ;
43+ }
2644}
2745
2846/** The attribute ends at the end of this inline. */
29- export class InlineAttrEnd {
30- constructor ( public slice : Slice ) { }
47+ export class InlineAttrEnd extends AbstractInlineAttr {
48+ isEnd ( ) : boolean {
49+ return true ;
50+ }
3151}
3252
3353/** The attribute starts and ends in this inline, exactly contains it. */
34- export class InlineAttrContained {
35- constructor ( public slice : Slice ) { }
54+ export class InlineAttrContained extends AbstractInlineAttr {
55+ isStart ( ) : boolean {
56+ return true ;
57+ }
58+ isEnd ( ) : boolean {
59+ return true ;
60+ }
3661}
3762
3863/** The attribute is collapsed at start of this inline. */
39- export class InlineAttrStartPoint {
40- constructor ( public slice : Slice ) { }
64+ export class InlineAttrStartPoint extends AbstractInlineAttr {
65+ isStart ( ) : boolean {
66+ return true ;
67+ }
68+ isCollapsed ( ) : boolean {
69+ return true ;
70+ }
4171}
4272
4373/** The attribute is collapsed at end of this inline. */
44- export class InlineAttrEndPoint {
45- constructor ( public slice : Slice ) { }
74+ export class InlineAttrEndPoint extends AbstractInlineAttr {
75+ isEnd ( ) : boolean {
76+ return true ;
77+ }
78+ isCollapsed ( ) : boolean {
79+ return true ;
80+ }
4681}
4782
4883export type InlineAttr =
0 commit comments