Skip to content

Commit 5bef0ad

Browse files
committed
Add boundary type 'none' and apply lint
1 parent 482e252 commit 5bef0ad

File tree

7 files changed

+44
-10
lines changed

7 files changed

+44
-10
lines changed

src/api/converter.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,18 @@ function toTextNodeBoundary(
277277
switch (boundary?.getType()) {
278278
case BoundaryType.Before:
279279
pbTextNodeBoundary.setType(PbBoundaryType.BOUNDARY_TYPE_BEFORE);
280+
break;
280281
case BoundaryType.After:
281282
pbTextNodeBoundary.setType(PbBoundaryType.BOUNDARY_TYPE_AFTER);
283+
break;
282284
case BoundaryType.Start:
283285
pbTextNodeBoundary.setType(PbBoundaryType.BOUNDARY_TYPE_START);
286+
break;
284287
case BoundaryType.End:
285288
pbTextNodeBoundary.setType(PbBoundaryType.BOUNDARY_TYPE_END);
289+
break;
290+
case BoundaryType.None:
291+
pbTextNodeBoundary.setType(PbBoundaryType.BOUNDARY_TYPE_NONE);
286292
}
287293
return pbTextNodeBoundary;
288294
}
@@ -929,14 +935,18 @@ function fromTextNodeBoundary(
929935
switch (pbTextNodeBoundary.getType()) {
930936
case PbBoundaryType.BOUNDARY_TYPE_BEFORE:
931937
boundaryType = BoundaryType.Before;
938+
break;
932939
case PbBoundaryType.BOUNDARY_TYPE_AFTER:
933940
boundaryType = BoundaryType.After;
941+
break;
934942
case PbBoundaryType.BOUNDARY_TYPE_START:
935943
boundaryType = BoundaryType.Start;
944+
break;
936945
case PbBoundaryType.BOUNDARY_TYPE_END:
937946
boundaryType = BoundaryType.End;
938-
default:
939-
boundaryType = undefined;
947+
break;
948+
case PbBoundaryType.BOUNDARY_TYPE_NONE:
949+
boundaryType = BoundaryType.None;
940950
}
941951
return RGATreeSplitBoundary.of(
942952
RGATreeSplitNodeID.of(

src/api/yorkie/v1/resources.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ enum BoundaryType {
336336
BOUNDARY_TYPE_AFTER = 1;
337337
BOUNDARY_TYPE_START = 2;
338338
BOUNDARY_TYPE_END = 3;
339+
BOUNDARY_TYPE_NONE = 4;
339340
}
340341

341342
message TextNodeBoundary {

src/api/yorkie/v1/resources_pb.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,6 +1619,7 @@ export enum BoundaryType {
16191619
BOUNDARY_TYPE_AFTER = 1,
16201620
BOUNDARY_TYPE_START = 2,
16211621
BOUNDARY_TYPE_END = 3,
1622+
BOUNDARY_TYPE_NONE = 4,
16221623
}
16231624
export enum ValueType {
16241625
VALUE_TYPE_NULL = 0,

src/api/yorkie/v1/resources_pb.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13407,7 +13407,8 @@ proto.yorkie.v1.BoundaryType = {
1340713407
BOUNDARY_TYPE_BEFORE: 0,
1340813408
BOUNDARY_TYPE_AFTER: 1,
1340913409
BOUNDARY_TYPE_START: 2,
13410-
BOUNDARY_TYPE_END: 3
13410+
BOUNDARY_TYPE_END: 3,
13411+
BOUNDARY_TYPE_NONE: 4
1341113412
};
1341213413

1341313414
/**

src/document/crdt/rga_tree_split.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ export enum BoundaryType {
6363
After = 'after',
6464
Start = 'start',
6565
End = 'end',
66+
// TODO(MoonGyu1): 'None' type can be deleted after replacing existing logic with mark
67+
None = 'none',
6668
}
6769

6870
/**
@@ -415,10 +417,16 @@ export class RGATreeSplitNode<
415417
return this.insPrev!.getID();
416418
}
417419

420+
/**
421+
* `getStyleOpsBefore` returns a styleOpsBefore of this node.
422+
*/
418423
public getStyleOpsBefore(): Set<StyleOperation> | undefined {
419424
return this.styleOpsBefore;
420425
}
421426

427+
/**
428+
* `getStyleOpsAfter` returns a styleOpsAfter of this node.
429+
*/
422430
public getStyleOpsAfter(): Set<StyleOperation> | undefined {
423431
return this.styleOpsAfter;
424432
}
@@ -463,10 +471,16 @@ export class RGATreeSplitNode<
463471
}
464472
}
465473

474+
/**
475+
* `setStyleOpsBefore` sets styleOpsBefore of this node.
476+
*/
466477
public setStyleOpsBefore(operations: Set<StyleOperation>): void {
467478
this.styleOpsBefore = operations;
468479
}
469480

481+
/**
482+
* `setStyleOpsAfter` sets styleOpsAfter of this node.
483+
*/
470484
public setStyleOpsAfter(operations: Set<StyleOperation>): void {
471485
this.styleOpsAfter = operations;
472486
}
@@ -844,7 +858,7 @@ export class RGATreeSplit<T extends RGATreeSplitValue> {
844858
public splitNodeByBoundary(boundary: RGATreeSplitBoundary): void {
845859
const absoluteID = boundary.getID();
846860
if (absoluteID?.getCreatedAt()) {
847-
let node = this.findFloorNodePreferToLeft(absoluteID);
861+
const node = this.findFloorNodePreferToLeft(absoluteID);
848862
const relativeOffset = absoluteID.getOffset() - node.getID().getOffset();
849863

850864
this.splitNode(node, relativeOffset);

src/document/crdt/text.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export type AttributeSpec = {
7171
export type MarkSpec = {
7272
expand: 'before' | 'after' | 'both' | 'none';
7373
allowMultiple: boolean;
74-
excludes?: string[];
74+
excludes?: Array<string>;
7575
attributes?: { [key: string]: AttributeSpec };
7676
};
7777

@@ -272,7 +272,10 @@ export class CRDTText<A extends Indexable = Indexable> extends CRDTGCElement {
272272
const fromBoundary = range[0];
273273
const toBoundary = range[1];
274274
// 02-1. Update styleOpsBefore and styleOpsAfter if it is a bold type
275-
if (fromBoundary.getType() && toBoundary?.getType()) {
275+
if (
276+
fromBoundary.getType() != BoundaryType.None &&
277+
toBoundary?.getType() != BoundaryType.None
278+
) {
276279
// TODO(MoonGyu1): Peritext 2. Update styleOpsBefore/styleOpsAfter of fromRight/toRight nodes
277280

278281
const createdAtMapByActor = new Map<string, TimeTicket>();
@@ -405,8 +408,8 @@ export class CRDTText<A extends Indexable = Indexable> extends CRDTGCElement {
405408
);
406409

407410
return [
408-
RGATreeSplitBoundary.of(fromRight.getID()),
409-
RGATreeSplitBoundary.of(toRight?.getID()),
411+
RGATreeSplitBoundary.of(fromRight.getID(), BoundaryType.None),
412+
RGATreeSplitBoundary.of(toRight?.getID(), BoundaryType.None),
410413
];
411414
}
412415

src/document/json/text.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,12 @@ export class Text<A extends Indexable = Indexable> {
234234
return true;
235235
}
236236

237-
// TODO(MoonGyu1): Peritext 1. Add removeStyle method
238-
removeStyle(fromIdx: number, toIdx: number, attributes: A) {}
237+
/**
238+
* `removeStyle` remove styles from text with the given attributes.
239+
*/
240+
removeStyle(fromIdx: number, toIdx: number, attributes: A) {
241+
// TODO(MoonGyu1): Peritext 1. Add removeStyle method
242+
}
239243

240244
/**
241245
* `indexRangeToPosRange` returns TextRangeStruct of the given index range.

0 commit comments

Comments
 (0)