Skip to content

Commit 35940b5

Browse files
committed
style(json-crdt-peritext-ui): 💄 fix linter issues
1 parent 87c5a7a commit 35940b5

File tree

12 files changed

+39
-35
lines changed

12 files changed

+39
-35
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ export class UiHandle {
2828
public getPointRect(pos: number | Point<string>, right = true): Rect | undefined {
2929
const txt = this.txt;
3030
const point = typeof pos === 'number' ? txt.pointAt(pos) : pos.clone();
31-
if (right) point.refBefore(); else point.refAfter();
31+
if (right) point.refBefore();
32+
else point.refAfter();
3233
return this.api.getCharRect?.(point.id);
3334
}
3435

src/json-crdt-peritext-ui/plugins/cursor/CursorPlugin.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ const h = React.createElement;
1212
* Plugin which renders the main cursor and all other current user local
1313
* cursors.
1414
*/
15-
export class CursorPlugin implements PeritextPlugin {
15+
export class CursorPlugin implements PeritextPlugin {
1616
public readonly caret: PeritextPlugin['caret'] = (props, children) => h(RenderCaret, <any>props, children);
1717
public readonly focus: PeritextPlugin['focus'] = (props, children) => h(RenderFocus, <any>props, children);
1818
public readonly anchor: PeritextPlugin['anchor'] = (props, children) => h(RenderAnchor, <any>props, children);
1919
public readonly inline: PeritextPlugin['inline'] = (props, children) => h(RenderInline, props as any, children);
20-
public readonly peritext: PeritextPlugin['peritext'] = (children, ctx) =>
21-
h(RenderPeritext, {children, ctx});
20+
public readonly peritext: PeritextPlugin['peritext'] = (children, ctx) => h(RenderPeritext, {children, ctx});
2221
}

src/json-crdt-peritext-ui/plugins/cursor/RenderCaret.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ export const RenderCaret: React.FC<RenderCaretProps> = ({italic, point, children
7575
const focus = useSyncStoreOpt(dom?.cursor.focus) || false;
7676
const plugin = useCursorPlugin();
7777
const ref = React.useRef<HTMLSpanElement>(null);
78+
79+
// Place caret at the end of line wrap.
7880
React.useEffect(() => {
7981
const el = ref.current;
8082
if (!el) return;
@@ -85,7 +87,7 @@ export const RenderCaret: React.FC<RenderCaretProps> = ({italic, point, children
8587
if (point.isAbs()) return;
8688
const rect = ctx.dom.getCharRect(point.id);
8789
if (!rect) return;
88-
const nextPoint = point.copy(p => p.refBefore());
90+
const nextPoint = point.copy((p) => p.refBefore());
8991
if (nextPoint.isAbs()) return;
9092
const rect2 = ctx.dom.getCharRect(nextPoint.id);
9193
if (!rect2) return;
@@ -96,7 +98,7 @@ export const RenderCaret: React.FC<RenderCaretProps> = ({italic, point, children
9698
style.left = dx + 'px';
9799
}
98100
}
99-
}, [point]);
101+
}, [point, ctx.dom.getCharRect]);
100102

101103
const anchorForward = point.anchor === Anchor.Before;
102104

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import {CursorState} from './state';
2+
import type {CursorState} from './state';
33

44
export const context = React.createContext<CursorState>(null!);
55
export const useCursorPlugin = () => React.useContext(context);

src/json-crdt-peritext-ui/plugins/cursor/state.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ import type {PeritextSurfaceState, UiLifeCycles} from '../../web';
55
export class CursorState implements UiLifeCycles {
66
/** Current score. */
77
public readonly score: ValueSyncStore<number> = new ValueSyncStore(0);
8-
8+
99
/** By how much the score changed. */
1010
public readonly scoreDelta: ValueSyncStore<number> = new ValueSyncStore(0);
11-
11+
1212
/** The last score that was shown to the user. */
1313
public readonly lastVisScore: ValueSyncStore<number> = new ValueSyncStore(0);
14-
15-
constructor(
16-
public readonly ctx: PeritextSurfaceState,
17-
) {}
14+
15+
constructor(public readonly ctx: PeritextSurfaceState) {}
1816

1917
/** -------------------------------------------------- {@link UiLifeCycles} */
2018
public start(): () => void {

src/json-crdt-peritext-ui/plugins/toolbar/RenderPeritext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22
import {Chrome} from './Chrome';
33
import {context, type ToolbarPluginContextValue} from './context';
44
import {ToolbarState} from './state';
5-
import type {PeritextSurfaceState, } from '../../web';
5+
import type {PeritextSurfaceState} from '../../web';
66
import type {ToolbarPluginOpts} from './ToolbarPlugin';
77

88
export interface RenderPeritextProps {

src/json-crdt-peritext-ui/plugins/toolbar/ToolbarPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import {RenderInline} from './RenderInline';
3-
import {RenderPeritext, RenderPeritextProps} from './RenderPeritext';
3+
import {RenderPeritext, type RenderPeritextProps} from './RenderPeritext';
44
import {text} from '../minimal/text';
55
import {RenderBlock} from './RenderBlock';
66
import {RenderCaret} from './RenderCaret';

src/json-crdt-peritext-ui/web/dom/DomController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {printTree, type Printable} from 'tree-dump';
2-
import {AvlMap} from "sonic-forest/lib/avl/AvlMap";
2+
import {AvlMap} from 'sonic-forest/lib/avl/AvlMap';
33
import {InputController} from './InputController';
44
import {CursorController} from './CursorController';
55
import {RichTextController} from './RichTextController';

src/json-crdt-peritext-ui/web/dom/RichTextController.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export class RichTextController implements UiLifeCycles {
4747
el.addEventListener('keydown', onKeyDown);
4848
return () => {
4949
el.removeEventListener('keydown', onKeyDown);
50-
5150
};
5251
}
5352
}

src/json-crdt-peritext-ui/web/react/BlockView.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,18 @@ export const BlockView: React.FC<BlockViewProps> = React.memo(
7575
}
7676

7777
let children: React.ReactNode = (
78-
<span ref={(element) => {
79-
el?.(element);
80-
if (block instanceof LeafBlock) {
81-
const blockId = block.start.id;
82-
const blocks = dom.blocks;
83-
if (element) blocks.set(blockId, element);
84-
else blocks.del(blockId);
85-
}
86-
}} style={{position: 'relative', display: 'block'}}>
78+
<span
79+
ref={(element) => {
80+
el?.(element);
81+
if (block instanceof LeafBlock) {
82+
const blockId = block.start.id;
83+
const blocks = dom.blocks;
84+
if (element) blocks.set(blockId, element);
85+
else blocks.del(blockId);
86+
}
87+
}}
88+
style={{position: 'relative', display: 'block'}}
89+
>
8790
{elements.length ? elements : Char.ZeroLengthSpace}
8891
</span>
8992
);

0 commit comments

Comments
 (0)