diff --git a/shared/editor/commands/table.ts b/shared/editor/commands/table.ts index 11355230f6..4c35f13810 100644 --- a/shared/editor/commands/table.ts +++ b/shared/editor/commands/table.ts @@ -17,6 +17,7 @@ import { mergeCells, splitCell, TableMap, + type TableRect, } from "prosemirror-tables"; import { ProsemirrorHelper } from "../../utils/ProsemirrorHelper"; import { CSVHelper } from "../../utils/csv"; @@ -103,7 +104,7 @@ export function createTableInner( const cells: Node[] = []; const rows: Node[] = []; - const createCell = (cellType: NodeType, attrs: Record | null) => + const createCell = (cellType: NodeType, attrs: Attrs | null) => cellContent ? cellType.createChecked(attrs, cellContent) : cellType.createAndFill(attrs); @@ -916,7 +917,7 @@ export function splitCellAndCollapse(): Command { */ function addRowWithAlignment( tr: Transaction, - rect: any, + rect: TableRect, index: number, copyFromRow: number | undefined, state: EditorState diff --git a/shared/editor/components/Mentions.tsx b/shared/editor/components/Mentions.tsx index 826b6f39e9..59e04feead 100644 --- a/shared/editor/components/Mentions.tsx +++ b/shared/editor/components/Mentions.tsx @@ -37,7 +37,7 @@ type Attrs = { } & Record; const getAttributesFromNode = (node: Node): Attrs => { - const spec = node.type.spec.toDOM?.(node) as any as Record< + const spec = node.type.spec.toDOM?.(node) as unknown as Record< string, JSONValue >[]; @@ -45,7 +45,9 @@ const getAttributesFromNode = (node: Node): Attrs => { return { className: className as Attrs["className"], - unfurl: unfurl ? (JSON.parse(unfurl as any) as Attrs["unfurl"]) : undefined, + unfurl: unfurl + ? (JSON.parse(unfurl as string) as Attrs["unfurl"]) + : undefined, ...attrs, }; }; diff --git a/shared/editor/lib/ExtensionManager.ts b/shared/editor/lib/ExtensionManager.ts index caf3e7f475..ce5bbb1366 100644 --- a/shared/editor/lib/ExtensionManager.ts +++ b/shared/editor/lib/ExtensionManager.ts @@ -8,7 +8,7 @@ import type { Primitive } from "utility-types"; import type { Editor } from "~/editor"; import type Mark from "../marks/Mark"; import type Node from "../nodes/Node"; -import type { CommandFactory } from "./Extension"; +import type { CommandFactory, WidgetProps } from "./Extension"; import type Extension from "./Extension"; import makeRules from "./markdown/rules"; import { MarkdownSerializer } from "./markdown/serializer"; @@ -67,7 +67,7 @@ export default class ExtensionManager { .reduce( (memo, node: Node) => ({ ...memo, - [node.name]: observer(node.widget as any), + [node.name]: observer(node.widget as React.FC), }), {} ); diff --git a/shared/editor/nodes/Heading.ts b/shared/editor/nodes/Heading.ts index ba9889ab4a..43e67886a4 100644 --- a/shared/editor/nodes/Heading.ts +++ b/shared/editor/nodes/Heading.ts @@ -1,4 +1,5 @@ import copy from "copy-to-clipboard"; +import type Token from "markdown-it/lib/token.mjs"; import { textblockTypeInputRule } from "prosemirror-inputrules"; import type { Node as ProsemirrorNode, @@ -80,7 +81,7 @@ export default class Heading extends Node { parseMarkdown() { return { block: "heading", - getAttrs: (token: Record) => ({ + getAttrs: (token: Token) => ({ level: +token.tag.slice(1), }), }; diff --git a/shared/utils/ProsemirrorHelper.ts b/shared/utils/ProsemirrorHelper.ts index bb502c5d42..92405019f3 100644 --- a/shared/utils/ProsemirrorHelper.ts +++ b/shared/utils/ProsemirrorHelper.ts @@ -219,7 +219,12 @@ export class ProsemirrorHelper { } }); - (node.attrs.marks ?? []).forEach((mark: any) => { + ( + (node.attrs.marks ?? []) as { + type: string; + attrs: Partial; + }[] + ).forEach((mark) => { if (mark.type === "comment") { comments.push({ ...mark.attrs, @@ -271,7 +276,9 @@ export class ProsemirrorHelper { const anchors: NodeAnchor[] = []; doc.descendants((node, pos) => { if (Array.isArray(node.attrs?.marks)) { - node.attrs.marks.forEach((mark: any) => { + ( + node.attrs.marks as { type?: string; attrs?: { id?: string } }[] + ).forEach((mark) => { if (mark?.type === "comment" && mark?.attrs?.id) { anchors.push({ pos, diff --git a/shared/utils/naturalSort.ts b/shared/utils/naturalSort.ts index d3cd4e255d..c7ca6fbf7e 100644 --- a/shared/utils/naturalSort.ts +++ b/shared/utils/naturalSort.ts @@ -14,18 +14,18 @@ const stripEmojis = (value: string) => value.replace(regex, ""); const cleanValue = (value: string) => stripEmojis(deburr(value)); -function getSortByField>( +function getSortByField( item: T, keyOrCallback: string | ((item: T) => string) ) { const field = typeof keyOrCallback === "string" - ? item[keyOrCallback] + ? (item as Record)[keyOrCallback] : keyOrCallback(item); - return cleanValue(field); + return cleanValue(typeof field === "string" ? field : ""); } -function naturalSortBy>( +function naturalSortBy( items: T[], key: string | ((item: T) => string), sortOptions?: NaturalSortOptions