Skip to content

Build your personal knowledge base with Trilium Notes

refactor(client): replace `MutableRef` with `RefObject` under Preact 11

Elian Doran429a3c6eefe5
diff --git a/apps/client/src/widgets/collections/dashboard/index.tsx b/apps/client/src/widgets/collections/dashboard/index.tsx
index 0fbcbb7530..d1d22c2374 100644
--- a/apps/client/src/widgets/collections/dashboard/index.tsx
+++ b/apps/client/src/widgets/collections/dashboard/index.tsx
@@ -5,7 +5,7 @@ import type { HighlightedTokenInfo } from "@triliumnext/commons";
import { clsx } from "clsx";
import { GridStack } from "gridstack";
import { RefObject, TargetedMouseEvent } from "preact";
-import { MutableRef, useEffect, useLayoutEffect, useRef, useState } from "preact/hooks";
+import { useEffect, useLayoutEffect, useRef, useState } from "preact/hooks";
import FNote from "../../../entities/fnote";
import branches from "../../../services/branches";
@@ -97,7 +97,7 @@ function useDashboardLayoutPersistence({ note, viewConfig, saveConfig, gridRef,
note: FNote;
viewConfig: DashboardViewConfig | undefined;
saveConfig: (config: DashboardViewConfig) => void;
- gridRef: MutableRef<GridStack | null>;
+ gridRef: RefObject<GridStack | null>;
containerRef: RefObject<HTMLDivElement | null>;
}) {
// Gridstack becomes the source of truth for geometry after init; capture the saved layout once
@@ -185,8 +185,8 @@ function useDashboardGrid({ note, notes, viewConfig, saveConfig, containerRef, g
viewConfig: DashboardViewConfig | undefined;
saveConfig: (config: DashboardViewConfig) => void;
containerRef: RefObject<HTMLDivElement | null>;
- gridRef: MutableRef<GridStack | null>;
- dropPositionsRef: MutableRef<WidgetLayouts>;
+ gridRef: RefObject<GridStack | null>;
+ dropPositionsRef: RefObject<WidgetLayouts>;
isCollapsed: boolean;
}) {
const { persistLayout, savedWidgetsRef } = useDashboardLayoutPersistence({ note, viewConfig, saveConfig, gridRef, containerRef });
diff --git a/apps/client/src/widgets/react/CKEditor.tsx b/apps/client/src/widgets/react/CKEditor.tsx
index c525efaed8..be95f5c316 100644
--- a/apps/client/src/widgets/react/CKEditor.tsx
+++ b/apps/client/src/widgets/react/CKEditor.tsx
@@ -1,7 +1,7 @@
import type { CKTextEditor, AttributeEditor, EditorConfig, ModelPosition } from "@triliumnext/ckeditor5";
import type { DISPLAYABLE_LOCALE_IDS } from "@triliumnext/commons";
+import { RefObject } from "preact";
import { useEffect, useImperativeHandle, useRef } from "preact/compat";
-import { MutableRef } from "preact/hooks";
export interface CKEditorApi {
focus(): void;
@@ -26,7 +26,7 @@ export interface CKEditorApi {
}
interface CKEditorOpts {
- apiRef: MutableRef<CKEditorApi | undefined>;
+ apiRef: RefObject<CKEditorApi | undefined>;
currentValue?: string;
className: string;
tabIndex?: number;
diff --git a/apps/client/src/widgets/react/Dropdown.tsx b/apps/client/src/widgets/react/Dropdown.tsx
index e6fcd312d5..b2d42d39dd 100644
--- a/apps/client/src/widgets/react/Dropdown.tsx
+++ b/apps/client/src/widgets/react/Dropdown.tsx
@@ -1,9 +1,9 @@
import type { Placement } from "@floating-ui/dom";
import type { Tooltip } from "bootstrap";
import clsx from "clsx";
-import { ComponentChildren, HTMLAttributes } from "preact";
+import { ComponentChildren, HTMLAttributes, RefObject } from "preact";
import { CSSProperties, HTMLProps } from "preact/compat";
-import { MutableRef, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "preact/hooks";
+import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "preact/hooks";
import { isMobile, isNarrowLayout, onNarrowLayoutChange } from "../../services/utils";
import { focusListItem } from "./FormList";
@@ -23,7 +23,7 @@ export interface DropdownProps extends Pick<HTMLProps<HTMLDivElement>, "id" | "c
title?: string;
dropdownContainerStyle?: CSSProperties;
dropdownContainerClassName?: string;
- dropdownContainerRef?: MutableRef<HTMLDivElement | null>;
+ dropdownContainerRef?: RefObject<HTMLDivElement | null>;
hideToggleArrow?: boolean;
/** If set to true, then the dropdown button will be considered an icon action (without normal border and sized for icons only). */
iconAction?: boolean;
@@ -41,7 +41,7 @@ export interface DropdownProps extends Pick<HTMLProps<HTMLDivElement>, "id" | "c
* keeps a menu open whatever this says.
*/
autoClose?: boolean | "inside" | "outside";
- dropdownRef?: MutableRef<DropdownHandle | null>;
+ dropdownRef?: RefObject<DropdownHandle | null>;
titlePosition?: "top" | "right" | "bottom" | "left";
titleOptions?: Partial<Tooltip.Options>;
mobileBackdrop?: boolean;
diff --git a/apps/client/src/widgets/react/FormAutocomplete.tsx b/apps/client/src/widgets/react/FormAutocomplete.tsx
index 771c969a85..e7cfc2de61 100644
--- a/apps/client/src/widgets/react/FormAutocomplete.tsx
+++ b/apps/client/src/widgets/react/FormAutocomplete.tsx
@@ -2,7 +2,7 @@ import "./FormAutocomplete.css";
import type { ReferenceElement } from "@floating-ui/dom";
import type { ComponentChildren, RefObject } from "preact";
-import { type MutableRef, useCallback, useEffect, useLayoutEffect, useRef, useState } from "preact/hooks";
+import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "preact/hooks";
import FormTextBox from "./FormTextBox";
import { useUniqueName } from "./hooks";
@@ -198,7 +198,7 @@ export function AutocompleteList({ query, source, anchor, renderItem, onPick, ha
anchor: DropdownAnchor;
renderItem?(item: string, query: string): ComponentChildren;
onPick(item: string): void;
- handleRef: MutableRef<AutocompleteListHandle | null>;
+ handleRef: RefObject<AutocompleteListHandle | null>;
elementRef?: PopupProps["elementRef"];
/** Called with the id of the highlighted entry's element, or `null` while none is highlighted. */
onActiveDescendant?(id: string | null): void;
@@ -231,7 +231,7 @@ export function AutocompleteList({ query, source, anchor, renderItem, onPick, ha
*/
export function useForwardedKeys<T>(
autocomplete: ReturnType<typeof useAutocomplete<T>>,
- handleRef: MutableRef<AutocompleteListHandle | null>,
+ handleRef: RefObject<AutocompleteListHandle | null>,
onActiveDescendant?: (id: string | null) => void
) {
const { isShown, activeIndex, itemId } = autocomplete;
diff --git a/apps/client/src/widgets/react/NoteAutocomplete.tsx b/apps/client/src/widgets/react/NoteAutocomplete.tsx
index fa6cf01858..8917bcda0e 100644
--- a/apps/client/src/widgets/react/NoteAutocomplete.tsx
+++ b/apps/client/src/widgets/react/NoteAutocomplete.tsx
@@ -6,7 +6,7 @@ import { NOTE_TYPE_ICONS } from "@triliumnext/commons";
import clsx from "clsx";
import { type ComponentChildren, type RefObject, render, type VNode } from "preact";
import { createPortal, type CSSProperties } from "preact/compat";
-import { type MutableRef, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "preact/hooks";
+import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "preact/hooks";
import appContext from "../../components/app_context";
import froca from "../../services/froca";
@@ -52,7 +52,7 @@ export interface NoteAutocompleteProps {
/** Places the input in the tab order of a host that orders its fields with `tabIndex`. */
tabIndex?: number;
/** Receives the functions that drive the field from outside it. */
- handleRef?: MutableRef<NoteAutocompleteHandle | null>;
+ handleRef?: RefObject<NoteAutocompleteHandle | null>;
/** The element the list hangs from and spans, in place of the field, for a host that frames it. */
anchorRef?: RefObject<HTMLElement | null>;
/**
@@ -448,7 +448,7 @@ export function NoteMentionList({ query, anchor, allowCreatingNotes, parentNoteP
/** Opens the list with an entry highlighted, so that Enter takes it. */
preselect?: boolean;
onPick(notePath: string | Promise<string | undefined>): void;
- handleRef: MutableRef<AutocompleteListHandle | null>;
+ handleRef: RefObject<AutocompleteListHandle | null>;
elementRef?: PopupProps["elementRef"];
/** Called with the id of the highlighted entry's element, or `null` while none is highlighted. */
onActiveDescendant?(id: string | null): void;
@@ -519,7 +519,7 @@ export function CommandMentionList<T extends CommandEntry>({ query, source, anch
/** Opens the list with the best match highlighted, so that Enter takes it. */
preselect?: boolean;
onPick(entry: T): void;
- handleRef: MutableRef<AutocompleteListHandle | null>;
+ handleRef: RefObject<AutocompleteListHandle | null>;
elementRef?: PopupProps["elementRef"];
/** Called with the id of the highlighted entry's element, or `null` while none is highlighted. */
onActiveDescendant?(id: string | null): void;
@@ -587,7 +587,7 @@ export function filterCommandEntries<T extends CommandEntry>(entries: T[], query
export interface HostedListProps {
/** At the caret, placed again each time the query changes. */
anchor: ReferenceElement;
- handleRef: MutableRef<AutocompleteListHandle | null>;
+ handleRef: RefObject<AutocompleteListHandle | null>;
elementRef(element: HTMLElement | null): void;
/** Points the editor at the highlighted entry, through the state's `setActiveDescendant()`. */
onActiveDescendant(id: string | null): void;
diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsx
index 9041cfeb5c..a136905ea1 100644
--- a/apps/client/src/widgets/react/hooks.tsx
+++ b/apps/client/src/widgets/react/hooks.tsx
@@ -4,7 +4,7 @@ import { Tooltip } from "bootstrap";
import Mark from "mark.js";
import { Ref, RefObject, VNode } from "preact";
import { CSSProperties, useSyncExternalStore } from "preact/compat";
-import { MutableRef, useCallback, useContext, useDebugValue, useEffect, useLayoutEffect, useMemo, useRef, useState } from "preact/hooks";
+import { useCallback, useContext, useDebugValue, useEffect, useLayoutEffect, useMemo, useRef, useState } from "preact/hooks";
import appContext, { EventData, EventNames } from "../../components/app_context";
import Component from "../../components/component";
@@ -1603,7 +1603,7 @@ export function useImperativeSearchHighlighlighting(
};
}
-export function useNoteTreeDrag(containerRef: MutableRef<HTMLElement | null | undefined>, { dragEnabled, dragNotEnabledMessage, callback }: {
+export function useNoteTreeDrag(containerRef: RefObject<HTMLElement | null | undefined>, { dragEnabled, dragNotEnabledMessage, callback }: {
dragEnabled: boolean,
dragNotEnabledMessage: Omit<ToastOptions, "id">;
callback: (data: DragData[], e: DragEvent) => void
@@ -1672,7 +1672,7 @@ export function useNoteTreeDrag(containerRef: MutableRef<HTMLElement | null | un
* The `callback` should return the IDs of the notes it actually added (cloned) to the collection so
* the warning only mentions newly-copied notes, not ones that were already present.
*/
-export function useCollectionTreeDrag(containerRef: MutableRef<HTMLElement | null | undefined>, { dragEnabled, includeArchived, callback }: {
+export function useCollectionTreeDrag(containerRef: RefObject<HTMLElement | null | undefined>, { dragEnabled, includeArchived, callback }: {
dragEnabled: boolean,
includeArchived: boolean,
callback: (data: DragData[], e: DragEvent) => string[] | Promise<string[]>
diff --git a/apps/client/src/widgets/ribbon/SearchStringEditor.tsx b/apps/client/src/widgets/ribbon/SearchStringEditor.tsx
index 3d6ebe2cd5..408cfebc10 100644
--- a/apps/client/src/widgets/ribbon/SearchStringEditor.tsx
+++ b/apps/client/src/widgets/ribbon/SearchStringEditor.tsx
@@ -1,6 +1,6 @@
import type { FieldEditor } from "@triliumnext/codemirror/src/field_editor";
import clsx from "clsx";
-import type { MutableRef } from "preact/hooks";
+import type { RefObject } from "preact";
import { useEffect, useRef } from "preact/hooks";
import { t } from "../../services/i18n";
@@ -29,7 +29,7 @@ interface SearchStringEditorProps {
*/
extraShortcutHints?: ShortcutHintDefinition;
/** Handed the editor once built, for a caller that has to focus or select what it holds. */
- editorRef?: MutableRef<FieldEditor | undefined>;
+ editorRef?: RefObject<FieldEditor | undefined>;
onChange(newValue: string): void;
/** Runs when Enter is pressed, which the editor treats as "run this search". */
onEnter(): void;
diff --git a/apps/client/src/widgets/ribbon/components/AttributeEditor.tsx b/apps/client/src/widgets/ribbon/components/AttributeEditor.tsx
index 25ac624f0e..92a1a93642 100644
--- a/apps/client/src/widgets/ribbon/components/AttributeEditor.tsx
+++ b/apps/client/src/widgets/ribbon/components/AttributeEditor.tsx
@@ -3,8 +3,9 @@ import "./AttributeEditor.css";
import type { AttributeEditor as CKEditorAttributeEditor, ModelElement, ModelNode, ModelPosition, MentionHostedFeed } from "@triliumnext/ckeditor5";
import { AttributeType } from "@triliumnext/commons";
import clsx from "clsx";
+import { RefObject } from "preact";
import { createPortal } from "preact/compat";
-import { MutableRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from "preact/hooks";
+import { useEffect, useImperativeHandle, useMemo, useRef, useState } from "preact/hooks";
import type { CommandData, FilteredCommandNames } from "../../../components/app_context";
import FAttribute from "../../../entities/fattribute";
@@ -37,7 +38,7 @@ type AttributeCommandNames = FilteredCommandNames<CommandData>;
const BLINK_DURATION = 300;
interface AttributeEditorProps {
- api: MutableRef<AttributeEditorImperativeHandlers | null>;
+ api: RefObject<AttributeEditorImperativeHandlers | null>;
note: FNote;
componentId: string;
notePath?: string | null;
diff --git a/apps/client/src/widgets/type_widgets/file/Audio.tsx b/apps/client/src/widgets/type_widgets/file/Audio.tsx
index ca52004c04..0320ef7ff3 100644
--- a/apps/client/src/widgets/type_widgets/file/Audio.tsx
+++ b/apps/client/src/widgets/type_widgets/file/Audio.tsx
@@ -1,4 +1,5 @@
-import { MutableRef, useCallback, useEffect, useRef, useState } from "preact/hooks";
+import { RefObject } from "preact";
+import { useCallback, useEffect, useRef, useState } from "preact/hooks";
import { t } from "../../../services/i18n";
import { isMobile } from "../../../services/utils";
@@ -128,7 +129,7 @@ function useWaveformPeaks(fullUrl: string): number[] | null {
return peaks;
}
-function useKeyboardShortcuts(audioRef: MutableRef<HTMLAudioElement | null>, togglePlayback: () => void) {
+function useKeyboardShortcuts(audioRef: RefObject<HTMLAudioElement | null>, togglePlayback: () => void) {
return useCallback((e: KeyboardEvent) => {
const audio = audioRef.current;
if (!audio || !claimsKeystroke(e)) return;
diff --git a/apps/client/src/widgets/type_widgets/file/Video.tsx b/apps/client/src/widgets/type_widgets/file/Video.tsx
index d5284d1a11..41a3e8cd22 100644
--- a/apps/client/src/widgets/type_widgets/file/Video.tsx
+++ b/apps/client/src/widgets/type_widgets/file/Video.tsx
@@ -1,7 +1,7 @@
import "./Video.css";
import { RefObject } from "preact";
-import { MutableRef, useCallback, useEffect, useRef, useState } from "preact/hooks";
+import { useCallback, useEffect, useRef, useState } from "preact/hooks";
import { t } from "../../../services/i18n";
import { isMobile } from "../../../services/utils";
@@ -138,7 +138,7 @@ export default function VideoPreview({ source, entity, environment, noteContext,
);
}
-function useKeyboardShortcuts(videoRef: MutableRef<HTMLVideoElement | null>, wrapperRef: MutableRef<HTMLDivElement | null>, togglePlayback: () => void, flashControls: () => void) {
+function useKeyboardShortcuts(videoRef: RefObject<HTMLVideoElement | null>, wrapperRef: RefObject<HTMLDivElement | null>, togglePlayback: () => void, flashControls: () => void) {
return useCallback((e: KeyboardEvent) => {
const video = videoRef.current;
if (!video || !claimsKeystroke(e)) return;
diff --git a/apps/client/src/widgets/type_widgets/spreadsheet/Spreadsheet.tsx b/apps/client/src/widgets/type_widgets/spreadsheet/Spreadsheet.tsx
index 25b5cd2646..cb8ea2ef90 100644
--- a/apps/client/src/widgets/type_widgets/spreadsheet/Spreadsheet.tsx
+++ b/apps/client/src/widgets/type_widgets/spreadsheet/Spreadsheet.tsx
@@ -23,7 +23,8 @@ import { createUniver, FUniver, mergeLocales } from '@univerjs/presets';
import { CalculationMode } from '@univerjs/sheets-formula';
import { IEditorBridgeService, SheetCellEditorResizeService } from '@univerjs/sheets-ui';
import { IDialogService, IShortcutService, ISidebarService } from '@univerjs/ui';
-import { MutableRef, useEffect, useRef, useState } from "preact/hooks";
+import { RefObject } from "preact";
+import { useEffect, useRef, useState } from "preact/hooks";
import type NoteContext from "../../../components/note_context";
import { t } from "../../../services/i18n";
@@ -167,7 +168,7 @@ interface ShortcutServiceLike {
* cell into its neighbour when a user presses Ctrl+R expecting a reload. The commands
* remain available via the toolbar/context menu and the fill handle.
*/
-function useReleaseFillShortcuts(apiRef: MutableRef<FUniver | undefined>) {
+function useReleaseFillShortcuts(apiRef: RefObject<FUniver | undefined>) {
useEffect(() => {
const univerAPI = apiRef.current;
if (!univerAPI) return;
@@ -225,7 +226,7 @@ function useReleaseFillShortcuts(apiRef: MutableRef<FUniver | undefined>) {
* stale origin and only resizes), and `fitTextSize()` pushes that layout to the overlay's DOM
* state, which is the same pair Univer runs when the editor first opens.
*/
-function useAnchorCellEditorOnScroll(apiRef: MutableRef<FUniver | undefined>) {
+function useAnchorCellEditorOnScroll(apiRef: RefObject<FUniver | undefined>) {
useEffect(() => {
const univerAPI = apiRef.current;
if (!univerAPI) return;
@@ -242,7 +243,7 @@ function useAnchorCellEditorOnScroll(apiRef: MutableRef<FUniver | undefined>) {
}, [ apiRef ]);
}
-function useInitializeSpreadsheet(containerRef: MutableRef<HTMLDivElement | null>, apiRef: MutableRef<FUniver | undefined>, readOnly: boolean, locale: UniverLocale) {
+function useInitializeSpreadsheet(containerRef: RefObject<HTMLDivElement | null>, apiRef: RefObject<FUniver | undefined>, readOnly: boolean, locale: UniverLocale) {
useEffect(() => {
if (!containerRef.current) return;
@@ -351,7 +352,7 @@ function toMobilePresets(presets: UniverPreset[]): UniverPreset[] {
}));
}
-function useDarkMode(apiRef: MutableRef<FUniver | undefined>) {
+function useDarkMode(apiRef: RefObject<FUniver | undefined>) {
const colorScheme = useColorScheme();
// React to dark mode.
@@ -362,7 +363,7 @@ function useDarkMode(apiRef: MutableRef<FUniver | undefined>) {
}, [ colorScheme, apiRef ]);
}
-function useSearchIntegration(apiRef: MutableRef<FUniver | undefined>, noteContext: NoteContext | undefined) {
+function useSearchIntegration(apiRef: RefObject<FUniver | undefined>, noteContext: NoteContext | undefined) {
useTriliumEvent("findInText", () => {
if (!noteContext?.isActive()) return;
@@ -374,7 +375,7 @@ function useSearchIntegration(apiRef: MutableRef<FUniver | undefined>, noteConte
});
}
-function useDismissDialogsOnNoteSwitch(apiRef: MutableRef<FUniver | undefined>) {
+function useDismissDialogsOnNoteSwitch(apiRef: RefObject<FUniver | undefined>) {
useTriliumEvents(["beforeNoteSwitch", "noteTypeMimeChanged"], () => {
const univerAPI = apiRef.current;
if (!univerAPI) return;
diff --git a/apps/client/src/widgets/type_widgets/spreadsheet/clipboard.ts b/apps/client/src/widgets/type_widgets/spreadsheet/clipboard.ts
index fd414692e8..08169767d4 100644
--- a/apps/client/src/widgets/type_widgets/spreadsheet/clipboard.ts
+++ b/apps/client/src/widgets/type_widgets/spreadsheet/clipboard.ts
@@ -1,7 +1,8 @@
import type { Injector, ITextStyle, ObjectMatrix } from "@univerjs/core";
import type { FUniver } from "@univerjs/presets";
import { type ICellDataWithSpanInfo, ISheetClipboardService } from "@univerjs/sheets-ui";
-import { type MutableRef, useEffect } from "preact/hooks";
+import type { RefObject } from "preact";
+import { useEffect } from "preact/hooks";
const STRIP_FONT_FAMILY_HOOK_ID = "trilium.strip-pasted-font-family";
@@ -14,7 +15,7 @@ const STRIP_FONT_FAMILY_HOOK_ID = "trilium.strip-pasted-font-family";
* cell matrix, so this hook runs first and edits the matrix before the default paste hook
* turns it into mutations.
*/
-export default function useStripPastedFontFamily(apiRef: MutableRef<FUniver | undefined>) {
+export default function useStripPastedFontFamily(apiRef: RefObject<FUniver | undefined>) {
useEffect(() => {
const univerAPI = apiRef.current;
if (!univerAPI) return;
diff --git a/apps/client/src/widgets/type_widgets/spreadsheet/export.tsx b/apps/client/src/widgets/type_widgets/spreadsheet/export.tsx
index 04408ce122..f8da95f0da 100644
--- a/apps/client/src/widgets/type_widgets/spreadsheet/export.tsx
+++ b/apps/client/src/widgets/type_widgets/spreadsheet/export.tsx
@@ -1,5 +1,5 @@
import { FUniver } from "@univerjs/presets";
-import { MutableRef } from "preact/hooks";
+import { RefObject } from "preact";
import NoteContext from "../../../components/note_context";
import FNote from "../../../entities/fnote";
@@ -24,7 +24,7 @@ const UTF8_BOM = "\uFEFF";
* `@triliumnext/commons`, dynamically imported so they are only fetched on export; XLSX is
* rendered by the backend, which keeps exceljs out of the client bundle entirely.
*/
-export default function useSpreadsheetExport(apiRef: MutableRef<FUniver | undefined>, note: FNote, noteContext: NoteContext | null | undefined, spacedUpdate: SpacedUpdate<SavedData | undefined>) {
+export default function useSpreadsheetExport(apiRef: RefObject<FUniver | undefined>, note: FNote, noteContext: NoteContext | null | undefined, spacedUpdate: SpacedUpdate<SavedData | undefined>) {
useTriliumEvent("exportXlsx", ({ ntxId }) => {
if (ntxId !== noteContext?.ntxId) return;
void exportToXlsx(note, spacedUpdate);
diff --git a/apps/client/src/widgets/type_widgets/spreadsheet/navigation.ts b/apps/client/src/widgets/type_widgets/spreadsheet/navigation.ts
index 806813b1a5..8c0e0a860c 100644
--- a/apps/client/src/widgets/type_widgets/spreadsheet/navigation.ts
+++ b/apps/client/src/widgets/type_widgets/spreadsheet/navigation.ts
@@ -1,6 +1,7 @@
import { Direction } from "@univerjs/core";
import type { FUniver } from "@univerjs/presets";
-import { type MutableRef, useEffect } from "preact/hooks";
+import type { RefObject } from "preact";
+import { useEffect } from "preact/hooks";
// Univer's plain arrow-key navigation (the "sheet.command.move-selection" command) is
// cyclic: pressing Up on the first row wraps the selection to the last row, Down on the
@@ -55,7 +56,7 @@ export function isOutOfBoundsMove(direction: NavigationDirection, bounds: Select
* before-command event and aborts the move command when the selection already sits against
* the boundary in the travel direction.
*/
-export default function useClampEdgeNavigation(apiRef: MutableRef<FUniver | undefined>) {
+export default function useClampEdgeNavigation(apiRef: RefObject<FUniver | undefined>) {
useEffect(() => {
const univerAPI = apiRef.current;
if (!univerAPI) return;
diff --git a/apps/client/src/widgets/type_widgets/spreadsheet/persistence.tsx b/apps/client/src/widgets/type_widgets/spreadsheet/persistence.tsx
index 4446f2b046..33dc23adbd 100644
--- a/apps/client/src/widgets/type_widgets/spreadsheet/persistence.tsx
+++ b/apps/client/src/widgets/type_widgets/spreadsheet/persistence.tsx
@@ -1,7 +1,8 @@
import { NOTE_TYPE_IMAGE_ATTACHMENTS } from "@triliumnext/commons";
import { SHEET_DRAWING_RESOURCE } from "@triliumnext/commons/src/lib/spreadsheet/workbook_model";
import { CommandType, FUniver, IDisposable, IWorkbookData, LocaleType } from "@univerjs/presets";
-import { MutableRef, useEffect, useRef } from "preact/hooks";
+import { RefObject } from "preact";
+import { useEffect, useRef } from "preact/hooks";
import NoteContext from "../../../components/note_context";
import FNote from "../../../entities/fnote";
@@ -22,7 +23,7 @@ interface SpreadsheetViewState {
scrollCol?: number;
}
-export default function usePersistence(note: FNote, noteContext: NoteContext | null | undefined, apiRef: MutableRef<FUniver | undefined>, containerRef: MutableRef<HTMLDivElement | null>) {
+export default function usePersistence(note: FNote, noteContext: NoteContext | null | undefined, apiRef: RefObject<FUniver | undefined>, containerRef: RefObject<HTMLDivElement | null>) {
const changeListener = useRef<IDisposable>(null);
const pendingContent = useRef<string | null>(null);
// Set when a value edit has been made whose formula recalculation hasn't been
diff --git a/apps/client/src/widgets/type_widgets/text/mobile_editor_toolbar.tsx b/apps/client/src/widgets/type_widgets/text/mobile_editor_toolbar.tsx
index 642e63c941..64e5dd5e07 100644
--- a/apps/client/src/widgets/type_widgets/text/mobile_editor_toolbar.tsx
+++ b/apps/client/src/widgets/type_widgets/text/mobile_editor_toolbar.tsx
@@ -1,7 +1,8 @@
import "./mobile_editor_toolbar.css";
import type { CKTextEditor, ClassicEditor } from "@triliumnext/ckeditor5";
-import { MutableRef, useCallback, useEffect, useRef, useState } from "preact/hooks";
+import { RefObject } from "preact";
+import { useCallback, useEffect, useRef, useState } from "preact/hooks";
import { isIOS } from "../../../services/utils";
import { useIsNoteReadOnly, useNoteContext, useNoteProperty, useTriliumEvent } from "../../react/hooks";
@@ -65,7 +66,7 @@ export default function MobileEditorToolbar({ inPopupEditor }: MobileEditorToolb
);
}
-function usePositioningOniOS(enabled: boolean, wrapperRef: MutableRef<HTMLDivElement | null>) {
+function usePositioningOniOS(enabled: boolean, wrapperRef: RefObject<HTMLDivElement | null>) {
// Fallback path for plain mobile Safari (no Capacitor): the WKWebView
// isn't resized when the keyboard opens, so visualViewport.height
// shrinks while window.innerHeight stays the same. Push the toolbar