Skip to content

Commit a642482

Browse files
committed
style(json-crdt-peritext-ui): 💄 run formatter
1 parent ca8b147 commit a642482

File tree

4 files changed

+46
-26
lines changed

4 files changed

+46
-26
lines changed

src/json-crdt-extensions/peritext/editor/Editor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,7 @@ export class Editor<T = string> implements Printable {
11481148
const txt = this.txt;
11491149
if (pos2 === undefined) {
11501150
p1.refAfter();
1151-
return [txt.range(p1), CursorAnchor.End]
1151+
return [txt.range(p1), CursorAnchor.End];
11521152
}
11531153
const p2 = this.pos2point(pos2);
11541154
const range = txt.rangeFromPoints(p1, p2);

src/json-crdt-peritext-ui/events/__tests__/cursor.spec.ts

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const testSuite = (getKit: () => Kit) => {
8383

8484
test('can set selection at the document start using Point instance', () => {
8585
const kit = setup();
86-
kit.et.cursor({at: [kit.peritext.pointStart()!, kit.peritext.pointStart()?.copy(p => p.step(5))]});
86+
kit.et.cursor({at: [kit.peritext.pointStart()!, kit.peritext.pointStart()?.copy((p) => p.step(5))]});
8787
expect(kit.editor.cursor.start.viewPos()).toBe(0);
8888
expect(kit.editor.cursor.isCollapsed()).toBe(false);
8989
expect(kit.editor.cursor.text()).toBe('abcde');
@@ -123,7 +123,7 @@ const testSuite = (getKit: () => Kit) => {
123123
const lengths = [1, 2, 3, 5, 7, 13, 19];
124124
for (const length of lengths) {
125125
for (let i = length; i < view.length; i++) {
126-
kit.et.cursor({at: [i, i-length]});
126+
kit.et.cursor({at: [i, i - length]});
127127
expect(kit.editor.cursor.text()).toBe(view.slice(i - length, i));
128128
}
129129
}
@@ -386,10 +386,12 @@ const testSuite = (getKit: () => Kit) => {
386386
kit.et.cursor({at: [5]});
387387
kit.et.insert(' ');
388388
kit.et.cursor({at: [4]});
389-
kit.et.cursor({move: [
390-
['start', 'word', -1],
391-
['end', 'word', 1],
392-
]});
389+
kit.et.cursor({
390+
move: [
391+
['start', 'word', -1],
392+
['end', 'word', 1],
393+
],
394+
});
393395
expect(kit.editor.cursor.text()).toBe('cd');
394396
});
395397

@@ -399,10 +401,13 @@ const testSuite = (getKit: () => Kit) => {
399401
kit.et.insert(' ');
400402
kit.et.cursor({at: [5]});
401403
kit.et.insert(' ');
402-
kit.et.cursor({at: [4], move: [
403-
['start', 'word', -1],
404-
['end', 'word', 1],
405-
]});
404+
kit.et.cursor({
405+
at: [4],
406+
move: [
407+
['start', 'word', -1],
408+
['end', 'word', 1],
409+
],
410+
});
406411
expect(kit.editor.cursor.text()).toBe('cd');
407412
});
408413

@@ -413,10 +418,12 @@ const testSuite = (getKit: () => Kit) => {
413418
kit.et.cursor({at: [5]});
414419
kit.et.insert('\n');
415420
kit.et.cursor({at: [4]});
416-
kit.et.cursor({move: [
417-
['start', 'line', -1],
418-
['end', 'line', 1],
419-
]});
421+
kit.et.cursor({
422+
move: [
423+
['start', 'line', -1],
424+
['end', 'line', 1],
425+
],
426+
});
420427
expect(kit.editor.cursor.text()).toBe('cd');
421428
});
422429

@@ -426,10 +433,13 @@ const testSuite = (getKit: () => Kit) => {
426433
kit.et.insert('\n');
427434
kit.et.cursor({at: [5]});
428435
kit.et.insert('\n');
429-
kit.et.cursor({at: [4],move: [
430-
['start', 'line', -1],
431-
['end', 'line', 1],
432-
]});
436+
kit.et.cursor({
437+
at: [4],
438+
move: [
439+
['start', 'line', -1],
440+
['end', 'line', 1],
441+
],
442+
});
433443
expect(kit.editor.cursor.text()).toBe('cd');
434444
});
435445
});

src/json-crdt-peritext-ui/events/__tests__/delete.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,11 @@ const testSuite = (getKit: () => Kit) => {
155155
kit.et.insert(' ');
156156
kit.editor.cursor.setAt(8);
157157
expect(kit.editor.text()).toBe('abcde fghij klmnopqrstuvwxyz');
158-
kit.et.delete({
159-
move: [
160-
['start', 'word', -1],
161-
['end', 'word', 1],
162-
],
158+
kit.et.delete({
159+
move: [
160+
['start', 'word', -1],
161+
['end', 'word', 1],
162+
],
163163
});
164164
expect(kit.editor.text()).toBe('abcde klmnopqrstuvwxyz');
165165
});

src/json-crdt-peritext-ui/events/defaults/PeritextEventDefaults.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,12 @@ export class PeritextEventDefaults implements PeritextEventHandlerMap {
8484
return at ? [editor.sel2range(at)[0]] : editor.cursors();
8585
}
8686

87-
protected moveRange(start: Point, end: Point, anchor: CursorAnchor, move?: events.SelectionMoveInstruction[]): [start: Point, end: Point, anchor: CursorAnchor] {
87+
protected moveRange(
88+
start: Point,
89+
end: Point,
90+
anchor: CursorAnchor,
91+
move?: events.SelectionMoveInstruction[],
92+
): [start: Point, end: Point, anchor: CursorAnchor] {
8893
if (!move) return [start, end, anchor];
8994
const {txt, editorUi} = this;
9095
const start0 = start;
@@ -116,7 +121,12 @@ export class PeritextEventDefaults implements PeritextEventHandlerMap {
116121
protected moveSelSet(set: events.SelectionSet, {move}: events.SelectionMoveDetailPart): void {
117122
if (!move) return;
118123
for (const selection of set) {
119-
const [start, end, anchor] = this.moveRange(selection.start, selection.end, selection instanceof Cursor ? selection.anchorSide : CursorAnchor.End, move);
124+
const [start, end, anchor] = this.moveRange(
125+
selection.start,
126+
selection.end,
127+
selection instanceof Cursor ? selection.anchorSide : CursorAnchor.End,
128+
move,
129+
);
120130
if (selection instanceof Cursor) selection.set(start, end, anchor);
121131
else selection.set(start, end);
122132
}

0 commit comments

Comments
 (0)