Skip to content

Commit

Permalink
style: 💄 fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Jan 18, 2025
1 parent d022015 commit 9c29f06
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/json-crdt-peritext-ui/__demos__/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ document.body.appendChild(div);
const root = createRoot(div);
root.render(
// <React.StrictMode>
<App />
<App />,
// </React.StrictMode>,
);
4 changes: 2 additions & 2 deletions src/json-crdt-peritext-ui/dom/DomController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import {printTree, type Printable} from 'tree-dump';
import {InputController} from '../dom/InputController';
import {CursorController} from '../dom/CursorController';
import {RichTextController} from '../dom/RichTextController';
import {PeritextEventDefaults} from '../events/PeritextEventDefaults';
import {PeritextEventTarget} from '../events/PeritextEventTarget';
import {KeyController} from '../dom/KeyController';
import {CompositionController} from '../dom/CompositionController';
import type {PeritextEventDefaults} from '../events/PeritextEventDefaults';
import type {PeritextEventTarget} from '../events/PeritextEventTarget';
import type {UiLifeCycles} from '../dom/types';

export interface DomControllerOpts {
Expand Down
2 changes: 1 addition & 1 deletion src/json-crdt-peritext-ui/dom/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface UiLifeCyclesRender {
* Called when UI component is mounted. Returns a function to be called when
* the component is removed from the screen.
*/
start(): (() => void);
start(): () => void;
}

export type Rect = Pick<DOMRect, 'x' | 'y' | 'width' | 'height'>;
6 changes: 3 additions & 3 deletions src/json-crdt-peritext-ui/events/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {PeritextEventDefaults} from "./PeritextEventDefaults";
import {PeritextEventTarget} from "./PeritextEventTarget";
import type {Peritext} from "../../json-crdt-extensions";
import {PeritextEventDefaults} from './PeritextEventDefaults';
import {PeritextEventTarget} from './PeritextEventTarget';
import type {Peritext} from '../../json-crdt-extensions';

export const create = (txt: Peritext) => {
const et = new PeritextEventTarget();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,12 +792,9 @@ const blockClass = rule({
export type CaretToolbarProps = {};

export const CaretToolbar: React.FC<CaretToolbarProps> = () => {

return (
// <div style={{transform: 'translate(-50%,0)'}}>
<ToolbarMenu
menu={inlineText}
/>
<ToolbarMenu menu={inlineText} />
// </div>
);
// return (
Expand Down
5 changes: 3 additions & 2 deletions src/json-crdt-peritext-ui/plugins/toolbar/RenderCaret.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {rule} from 'nano-theme';
import {CaretToolbar} from './CaretToolbar';
import type {CaretViewProps} from '../../react/cursor/CaretView';
import {useToolbarPlugin} from './context';
import {PeritextEventDetailMap} from '../../events/types';
import type {PeritextEventDetailMap} from '../../events/types';

const height = 1.9;

Expand Down Expand Up @@ -35,7 +35,8 @@ export interface RenderCaretProps extends CaretViewProps {
export const RenderCaret: React.FC<RenderCaretProps> = ({children}) => {
const {toolbar} = useToolbarPlugin()!;

const lastEventIsCaretPositionChange = toolbar.lastEvent?.type === 'cursor' &&
const lastEventIsCaretPositionChange =
toolbar.lastEvent?.type === 'cursor' &&
typeof (toolbar.lastEvent?.detail as PeritextEventDetailMap['cursor']).at === 'number';

return (
Expand Down
5 changes: 4 additions & 1 deletion src/json-crdt-peritext-ui/plugins/toolbar/RenderPeritext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export interface RenderPeritextProps extends PeritextViewProps {
}

export const RenderPeritext: React.FC<RenderPeritextProps> = ({surface, children}) => {
const value: ToolbarPluginContextValue = React.useMemo(() => ({surface, toolbar: new ToolbarState(surface)}), [surface]);
const value: ToolbarPluginContextValue = React.useMemo(
() => ({surface, toolbar: new ToolbarState(surface)}),
[surface],
);
const toolbar = value.toolbar;

React.useLayoutEffect(() => toolbar.start(), [toolbar]);
Expand Down
6 changes: 3 additions & 3 deletions src/json-crdt-peritext-ui/plugins/toolbar/state.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type {UiLifeCyclesRender} from '../../dom/types';
import {PeritextEventDetailMap} from '../../events/types';
import type {PeritextSurfaceState} from "../../react";
import type {PeritextEventDetailMap} from '../../events/types';
import type {PeritextSurfaceState} from '../../react';

export class ToolbarState implements UiLifeCyclesRender {
public lastEvent: PeritextEventDetailMap['change']['ev'] | undefined = void 0;

constructor (public readonly surface: PeritextSurfaceState) {}
constructor(public readonly surface: PeritextSurfaceState) {}

/** -------------------------------------------------- {@link UiLifeCyclesRender} */

Expand Down
4 changes: 3 additions & 1 deletion src/json-crdt-peritext-ui/react/BlockView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export const BlockView: React.FC<BlockViewProps> = React.memo(
}

let children: React.ReactNode = (
<div ref={(element) => el?.(element)} style={{position: 'relative'}}>{elements.length ? elements : Char.ZeroLengthSpace}</div>
<div ref={(element) => el?.(element)} style={{position: 'relative'}}>
{elements.length ? elements : Char.ZeroLengthSpace}
</div>
);
for (const map of plugins) children = map.block?.(props, children) ?? children;
return children;
Expand Down
2 changes: 1 addition & 1 deletion src/json-crdt-peritext-ui/react/PeritextView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const PeritextView: React.FC<PeritextViewProps> = React.memo((props) => {
const {peritext, plugins = [new CursorPlugin(), defaultPlugin], onRender} = props;
const [, setTick] = React.useState(0);
const [dom, setDom] = React.useState<DomController | undefined>(undefined);

// biome-ignore lint: lint/correctness/useExhaustiveDependencies
const rerender = React.useCallback(() => {
peritext.refresh();
Expand Down
2 changes: 1 addition & 1 deletion src/json-crdt-peritext-ui/react/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {PeritextEventDefaults} from '../events/PeritextEventDefaults';
export class PeritextSurfaceState {
public dom?: DomController = void 0;

constructor (
constructor(
public readonly peritext: Peritext,
public readonly events: PeritextEventDefaults,
public readonly rerender: () => void,
Expand Down
6 changes: 1 addition & 5 deletions src/json-crdt-peritext-ui/react/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ import type {Inline} from '../../json-crdt-extensions/peritext/block/Inline';
export interface PeritextPlugin {
// --------------------------------------------------- Block-level formatting

peritext?: (
props: PeritextViewProps,
children: React.ReactNode,
surface: PeritextSurfaceState,
) => React.ReactNode;
peritext?: (props: PeritextViewProps, children: React.ReactNode, surface: PeritextSurfaceState) => React.ReactNode;
block?: (props: BlockViewProps, children: React.ReactNode) => React.ReactNode;

// -------------------------------------------------------- Inline formatting
Expand Down
7 changes: 3 additions & 4 deletions src/json-crdt/__demos__/issue-801.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Run this demo with:
*
* npx nodemon -q -x ts-node src/json-crdt/__demos__/issue-801.ts
*
*
* @see issue: https://github.com/streamich/json-joy/issues/801
*/

Expand All @@ -27,10 +27,9 @@
// function foo(_node: ObjApi<SimpleObjectNodeType>) {}
// foo(model.api.node)


import {JsonNodeView, Model} from '..';
import {type JsonNodeView, Model} from '..';
import {s} from '../../json-crdt-patch';
import {SchemaToJsonNode} from '../schema/types';
import type {SchemaToJsonNode} from '../schema/types';

const SimpleObjectSchema = s.obj({
text: s.con<string>('foo'),
Expand Down
2 changes: 1 addition & 1 deletion src/util/events/TypedEventTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export interface TypedEventTarget<EventMap> {
}

export class SubscriptionEventTarget<EventMap> extends TypedEventTarget<EventMap> {
public subscribe<K extends keyof EventMap>(type: K, listener: (ev: EventMap[K]) => void): (() => void) {
public subscribe<K extends keyof EventMap>(type: K, listener: (ev: EventMap[K]) => void): () => void {
this.addEventListener(type, listener);
return () => this.removeEventListener(type, listener);
}
Expand Down

0 comments on commit 9c29f06

Please sign in to comment.