diff --git a/src/json-crdt-peritext-ui/__demos__/main.tsx b/src/json-crdt-peritext-ui/__demos__/main.tsx index f895b7c0e4..a0b5c2aa7e 100644 --- a/src/json-crdt-peritext-ui/__demos__/main.tsx +++ b/src/json-crdt-peritext-ui/__demos__/main.tsx @@ -8,6 +8,6 @@ document.body.appendChild(div); const root = createRoot(div); root.render( // - + , // , ); diff --git a/src/json-crdt-peritext-ui/dom/DomController.ts b/src/json-crdt-peritext-ui/dom/DomController.ts index 28d54002c5..c2f40e3e92 100644 --- a/src/json-crdt-peritext-ui/dom/DomController.ts +++ b/src/json-crdt-peritext-ui/dom/DomController.ts @@ -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 { diff --git a/src/json-crdt-peritext-ui/dom/types.ts b/src/json-crdt-peritext-ui/dom/types.ts index d66290a202..918702912d 100644 --- a/src/json-crdt-peritext-ui/dom/types.ts +++ b/src/json-crdt-peritext-ui/dom/types.ts @@ -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; diff --git a/src/json-crdt-peritext-ui/events/index.ts b/src/json-crdt-peritext-ui/events/index.ts index 13979fea9f..c830e513bd 100644 --- a/src/json-crdt-peritext-ui/events/index.ts +++ b/src/json-crdt-peritext-ui/events/index.ts @@ -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(); diff --git a/src/json-crdt-peritext-ui/plugins/toolbar/CaretToolbar/index.tsx b/src/json-crdt-peritext-ui/plugins/toolbar/CaretToolbar/index.tsx index 374a129df9..67109b4d74 100644 --- a/src/json-crdt-peritext-ui/plugins/toolbar/CaretToolbar/index.tsx +++ b/src/json-crdt-peritext-ui/plugins/toolbar/CaretToolbar/index.tsx @@ -792,12 +792,9 @@ const blockClass = rule({ export type CaretToolbarProps = {}; export const CaretToolbar: React.FC = () => { - return ( //
- + //
); // return ( diff --git a/src/json-crdt-peritext-ui/plugins/toolbar/RenderCaret.tsx b/src/json-crdt-peritext-ui/plugins/toolbar/RenderCaret.tsx index c439c9febf..f89f2a97be 100644 --- a/src/json-crdt-peritext-ui/plugins/toolbar/RenderCaret.tsx +++ b/src/json-crdt-peritext-ui/plugins/toolbar/RenderCaret.tsx @@ -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; @@ -35,7 +35,8 @@ export interface RenderCaretProps extends CaretViewProps { export const RenderCaret: React.FC = ({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 ( diff --git a/src/json-crdt-peritext-ui/plugins/toolbar/RenderPeritext.tsx b/src/json-crdt-peritext-ui/plugins/toolbar/RenderPeritext.tsx index eb548dfef4..aaf93ec379 100644 --- a/src/json-crdt-peritext-ui/plugins/toolbar/RenderPeritext.tsx +++ b/src/json-crdt-peritext-ui/plugins/toolbar/RenderPeritext.tsx @@ -10,7 +10,10 @@ export interface RenderPeritextProps extends PeritextViewProps { } export const RenderPeritext: React.FC = ({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]); diff --git a/src/json-crdt-peritext-ui/plugins/toolbar/state.ts b/src/json-crdt-peritext-ui/plugins/toolbar/state.ts index 558eddd086..f716163125 100644 --- a/src/json-crdt-peritext-ui/plugins/toolbar/state.ts +++ b/src/json-crdt-peritext-ui/plugins/toolbar/state.ts @@ -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} */ diff --git a/src/json-crdt-peritext-ui/react/BlockView.tsx b/src/json-crdt-peritext-ui/react/BlockView.tsx index a370c7db91..f8a4658593 100644 --- a/src/json-crdt-peritext-ui/react/BlockView.tsx +++ b/src/json-crdt-peritext-ui/react/BlockView.tsx @@ -74,7 +74,9 @@ export const BlockView: React.FC = React.memo( } let children: React.ReactNode = ( -
el?.(element)} style={{position: 'relative'}}>{elements.length ? elements : Char.ZeroLengthSpace}
+
el?.(element)} style={{position: 'relative'}}> + {elements.length ? elements : Char.ZeroLengthSpace} +
); for (const map of plugins) children = map.block?.(props, children) ?? children; return children; diff --git a/src/json-crdt-peritext-ui/react/PeritextView.tsx b/src/json-crdt-peritext-ui/react/PeritextView.tsx index bfdf49d3b0..00cb36b7d8 100644 --- a/src/json-crdt-peritext-ui/react/PeritextView.tsx +++ b/src/json-crdt-peritext-ui/react/PeritextView.tsx @@ -46,7 +46,7 @@ export const PeritextView: React.FC = React.memo((props) => { const {peritext, plugins = [new CursorPlugin(), defaultPlugin], onRender} = props; const [, setTick] = React.useState(0); const [dom, setDom] = React.useState(undefined); - + // biome-ignore lint: lint/correctness/useExhaustiveDependencies const rerender = React.useCallback(() => { peritext.refresh(); diff --git a/src/json-crdt-peritext-ui/react/state.ts b/src/json-crdt-peritext-ui/react/state.ts index fc5568ef36..c743368e80 100644 --- a/src/json-crdt-peritext-ui/react/state.ts +++ b/src/json-crdt-peritext-ui/react/state.ts @@ -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, diff --git a/src/json-crdt-peritext-ui/react/types.ts b/src/json-crdt-peritext-ui/react/types.ts index 6504b21e8e..d6ba4ed362 100644 --- a/src/json-crdt-peritext-ui/react/types.ts +++ b/src/json-crdt-peritext-ui/react/types.ts @@ -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 diff --git a/src/json-crdt/__demos__/issue-801.ts b/src/json-crdt/__demos__/issue-801.ts index 62ff82c2cd..dbe0da902a 100644 --- a/src/json-crdt/__demos__/issue-801.ts +++ b/src/json-crdt/__demos__/issue-801.ts @@ -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 */ @@ -27,10 +27,9 @@ // function foo(_node: ObjApi) {} // 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('foo'), diff --git a/src/util/events/TypedEventTarget.ts b/src/util/events/TypedEventTarget.ts index 17c3565e0a..4950e8d704 100644 --- a/src/util/events/TypedEventTarget.ts +++ b/src/util/events/TypedEventTarget.ts @@ -59,7 +59,7 @@ export interface TypedEventTarget { } export class SubscriptionEventTarget extends TypedEventTarget { - public subscribe(type: K, listener: (ev: EventMap[K]) => void): (() => void) { + public subscribe(type: K, listener: (ev: EventMap[K]) => void): () => void { this.addEventListener(type, listener); return () => this.removeEventListener(type, listener); }