Skip to content

Commit

Permalink
style(json-crdt-extensions): 💄 run Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Jun 8, 2024
1 parent 3db14b9 commit a914764
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
11 changes: 7 additions & 4 deletions src/json-crdt-extensions/peritext/block/Inline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,20 @@ export class Inline extends Range implements Printable {
return !range.start.cmp(range.end)
? InlineAttrPos.Collapsed
: !this.start.cmp(range.start)
? (!this.end.cmp(range.end) ? InlineAttrPos.Contained : InlineAttrPos.Start)
? !this.end.cmp(range.end)
? InlineAttrPos.Contained
: InlineAttrPos.Start
: !this.end.cmp(range.end)
? InlineAttrPos.End : InlineAttrPos.Passing;
? InlineAttrPos.End
: InlineAttrPos.Passing;
}

protected stackAttr(attr: InlineAttrs, type: string | number, data: unknown, slice: Range<any>): void {
let item: InlineAttrStack | undefined = attr[type] as InlineAttrStack | undefined;
if (!item) attr[type] = item = [[], this.getAttrPos(slice)];
const dataList: unknown[] = item[0] instanceof Array ? item[0] as unknown[] : [];
const dataList: unknown[] = item[0] instanceof Array ? (item[0] as unknown[]) : [];
dataList.push(data);
};
}

/**
* @returns Returns the attributes of the inline, which are the slice
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ const runStrTests = (setup: () => Kit) => {
peritext.editor.cursor.setAt(1, 8);
peritext.refresh();
const str = peritext.strApi().view();
const [inline1, inline2, inline3, inline4, inline5, inline6, inline7] = peritext.blocks.root.children[0]!.texts();
const [inline1, inline2, inline3, inline4, inline5, inline6, inline7] =
peritext.blocks.root.children[0]!.texts();
expect(inline1.text()).toBe(str.slice(0, 1));
expect(inline2.text()).toBe(str.slice(1, 2));
expect(inline2.attr()).toEqual({
Expand Down Expand Up @@ -221,7 +222,7 @@ const runStrTests = (setup: () => Kit) => {
});
expect(inline3.text()).toBe(str.slice(8));
});

test('correctly reports *Collapsed* positions', () => {
const {peritext} = setup();
peritext.editor.cursor.setAt(5);
Expand All @@ -234,7 +235,7 @@ const runStrTests = (setup: () => Kit) => {
[SliceTypes.Cursor]: [[[CursorAnchor.Start]], InlineAttrPos.Collapsed],
});
});

test('correctly reports *Collapsed* at start of block marker', () => {
const {peritext} = setup();
peritext.editor.cursor.setAt(5);
Expand Down

0 comments on commit a914764

Please sign in to comment.