From e2fc67cdaa2fbae73790d976df518a516f1bf0f0 Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal Date: Mon, 4 Aug 2025 17:29:03 +0530 Subject: [PATCH] chore: replace interfaces with types --- .../components/editors/editor-container.tsx | 6 ++-- .../components/editors/editor-content.tsx | 8 ++--- .../editors/link-view-container.tsx | 6 ++-- .../core/components/links/link-edit-view.tsx | 8 ++--- .../src/core/components/links/link-view.tsx | 4 +-- .../src/core/components/menus/block-menu.tsx | 8 ++--- .../components/menus/bubble-menu/root.tsx | 4 +-- .../src/core/extensions/code-inline/index.tsx | 8 ++--- .../extensions/code/code-block-lowlight.ts | 4 +-- .../extensions/code/code-block-node-view.tsx | 8 ++--- .../src/core/extensions/code/code-block.ts | 6 ++-- .../core/extensions/custom-link/extension.tsx | 10 +++---- .../emoji/components/emojis-list.tsx | 30 +++++++++---------- .../editor/src/core/extensions/emoji/emoji.ts | 4 +-- .../src/core/extensions/headings-list.ts | 9 ++---- .../src/core/extensions/horizontal-rule.ts | 6 ++-- .../src/core/extensions/table/table-cell.ts | 6 ++-- .../src/core/extensions/table/table-header.ts | 6 ++-- .../src/core/extensions/table/table-row.ts | 6 ++-- .../src/core/extensions/table/table/table.ts | 6 ++-- .../table/table/utilities/create-cell.ts | 2 +- .../table/utilities/delete-key-shortcut.ts | 10 +++---- .../table/table/utilities/helpers.ts | 4 ++- .../core/extensions/typography/inputRules.ts | 4 +-- .../editor/src/core/extensions/utility.ts | 4 +-- .../extensions/work-item-embed/extension.tsx | 4 +-- packages/editor/src/core/helpers/common.ts | 6 ++-- .../editor/src/core/helpers/scroll-to-node.ts | 11 ++----- packages/editor/src/core/types/editor.ts | 23 +++++++------- 29 files changed, 107 insertions(+), 114 deletions(-) diff --git a/packages/editor/src/core/components/editors/editor-container.tsx b/packages/editor/src/core/components/editors/editor-container.tsx index f189bde9850..cba90dd1890 100644 --- a/packages/editor/src/core/components/editors/editor-container.tsx +++ b/packages/editor/src/core/components/editors/editor-container.tsx @@ -10,15 +10,15 @@ import { TDisplayConfig } from "@/types"; // components import { LinkViewContainer } from "./link-view-container"; -interface EditorContainerProps { +type Props = { children: ReactNode; displayConfig: TDisplayConfig; editor: Editor; editorContainerClassName: string; id: string; -} +}; -export const EditorContainer: FC = (props) => { +export const EditorContainer: FC = (props) => { const { children, displayConfig, editor, editorContainerClassName, id } = props; const containerRef = useRef(null); diff --git a/packages/editor/src/core/components/editors/editor-content.tsx b/packages/editor/src/core/components/editors/editor-content.tsx index 89ebde53bcf..0de342ad368 100644 --- a/packages/editor/src/core/components/editors/editor-content.tsx +++ b/packages/editor/src/core/components/editors/editor-content.tsx @@ -1,14 +1,14 @@ -import { Editor, EditorContent } from "@tiptap/react"; +import { type Editor, EditorContent } from "@tiptap/react"; import { FC, ReactNode } from "react"; -interface EditorContentProps { +type Props = { children?: ReactNode; editor: Editor | null; id: string; tabIndex?: number; -} +}; -export const EditorContentWrapper: FC = (props) => { +export const EditorContentWrapper: FC = (props) => { const { editor, children, tabIndex, id } = props; return ( diff --git a/packages/editor/src/core/components/editors/link-view-container.tsx b/packages/editor/src/core/components/editors/link-view-container.tsx index 3d15de069b5..c686c33ab61 100644 --- a/packages/editor/src/core/components/editors/link-view-container.tsx +++ b/packages/editor/src/core/components/editors/link-view-container.tsx @@ -4,12 +4,12 @@ import { FC, useCallback, useEffect, useRef, useState } from "react"; // components import { LinkView, LinkViewProps } from "@/components/links"; -interface LinkViewContainerProps { +type Props = { editor: Editor; containerRef: React.RefObject; -} +}; -export const LinkViewContainer: FC = ({ editor, containerRef }) => { +export const LinkViewContainer: FC = ({ editor, containerRef }) => { const [linkViewProps, setLinkViewProps] = useState(); const [isOpen, setIsOpen] = useState(false); const [virtualElement, setVirtualElement] = useState(null); diff --git a/packages/editor/src/core/components/links/link-edit-view.tsx b/packages/editor/src/core/components/links/link-edit-view.tsx index db6ac3f5ca1..4446b7d331f 100644 --- a/packages/editor/src/core/components/links/link-edit-view.tsx +++ b/packages/editor/src/core/components/links/link-edit-view.tsx @@ -6,13 +6,13 @@ import { LinkViewProps, LinkViews } from "@/components/links"; // helpers import { isValidHttpUrl } from "@/helpers/common"; -interface InputViewProps { +type InputViewProps = { label: string; value: string; placeholder: string; onChange: (value: string) => void; autoFocus?: boolean; -} +}; const InputView = ({ label, value, placeholder, onChange, autoFocus }: InputViewProps) => (
@@ -28,10 +28,10 @@ const InputView = ({ label, value, placeholder, onChange, autoFocus }: InputView
); -interface LinkEditViewProps { +type LinkEditViewProps = { viewProps: LinkViewProps; switchView: (view: LinkViews) => void; -} +}; export const LinkEditView = ({ viewProps }: LinkEditViewProps) => { const { editor, from, to, url: initialUrl, text: initialText, closeLinkView } = viewProps; diff --git a/packages/editor/src/core/components/links/link-view.tsx b/packages/editor/src/core/components/links/link-view.tsx index 05d430df303..bd29071fadb 100644 --- a/packages/editor/src/core/components/links/link-view.tsx +++ b/packages/editor/src/core/components/links/link-view.tsx @@ -5,7 +5,7 @@ import { LinkEditView, LinkPreview } from "@/components/links"; export type LinkViews = "LinkPreview" | "LinkEditView"; -export interface LinkViewProps { +export type LinkViewProps = { view?: LinkViews; editor: Editor; from: number; @@ -13,7 +13,7 @@ export interface LinkViewProps { url: string; text?: string; closeLinkView: () => void; -} +}; export const LinkView = (props: LinkViewProps & { style: CSSProperties }) => { const [currentView, setCurrentView] = useState(props.view ?? "LinkPreview"); diff --git a/packages/editor/src/core/components/menus/block-menu.tsx b/packages/editor/src/core/components/menus/block-menu.tsx index bd86628cb32..4f4fb64ac69 100644 --- a/packages/editor/src/core/components/menus/block-menu.tsx +++ b/packages/editor/src/core/components/menus/block-menu.tsx @@ -1,15 +1,15 @@ -import { Editor } from "@tiptap/react"; +import type { Editor } from "@tiptap/react"; import { Copy, LucideIcon, Trash2 } from "lucide-react"; import { useCallback, useEffect, useRef } from "react"; import tippy, { Instance } from "tippy.js"; // constants import { CORE_EXTENSIONS } from "@/constants/extension"; -interface BlockMenuProps { +type Props = { editor: Editor; -} +}; -export const BlockMenu = (props: BlockMenuProps) => { +export const BlockMenu = (props: Props) => { const { editor } = props; const menuRef = useRef(null); const popup = useRef(null); diff --git a/packages/editor/src/core/components/menus/bubble-menu/root.tsx b/packages/editor/src/core/components/menus/bubble-menu/root.tsx index 05e8911491c..09b462e488b 100644 --- a/packages/editor/src/core/components/menus/bubble-menu/root.tsx +++ b/packages/editor/src/core/components/menus/bubble-menu/root.tsx @@ -29,7 +29,7 @@ import { TextAlignmentSelector } from "./alignment-selector"; type EditorBubbleMenuProps = Omit; -export interface EditorStateType { +export type EditorStateType = { code: boolean; bold: boolean; italic: boolean; @@ -47,7 +47,7 @@ export interface EditorStateType { backgroundColor: string; } | undefined; -} +}; export const EditorBubbleMenu: FC = (props: { editor: Editor }) => { const menuRef = useRef(null); diff --git a/packages/editor/src/core/extensions/code-inline/index.tsx b/packages/editor/src/core/extensions/code-inline/index.tsx index ae320cf6a29..690f92b9972 100644 --- a/packages/editor/src/core/extensions/code-inline/index.tsx +++ b/packages/editor/src/core/extensions/code-inline/index.tsx @@ -2,9 +2,9 @@ import { Mark, markInputRule, markPasteRule, mergeAttributes } from "@tiptap/cor // constants import { CORE_EXTENSIONS } from "@/constants/extension"; -export interface CodeOptions { - HTMLAttributes: Record; -} +type InlineCodeOptions = { + HTMLAttributes: Record; +}; declare module "@tiptap/core" { interface Commands { @@ -28,7 +28,7 @@ declare module "@tiptap/core" { export const inputRegex = /(?:^|\s)((?:`)((?:[^`]+))(?:`))$/; const pasteRegex = /(?:^|\s)((?:`)((?:[^`]+))(?:`))/g; -export const CustomCodeInlineExtension = Mark.create({ +export const CustomCodeInlineExtension = Mark.create({ name: CORE_EXTENSIONS.CODE_INLINE, addOptions() { diff --git a/packages/editor/src/core/extensions/code/code-block-lowlight.ts b/packages/editor/src/core/extensions/code/code-block-lowlight.ts index ae44d83d65f..cafad1f89f5 100644 --- a/packages/editor/src/core/extensions/code/code-block-lowlight.ts +++ b/packages/editor/src/core/extensions/code/code-block-lowlight.ts @@ -3,10 +3,10 @@ import { CodeBlockOptions, CodeBlock } from "./code-block"; import { LowlightPlugin } from "./lowlight-plugin"; -export interface CodeBlockLowlightOptions extends CodeBlockOptions { +type CodeBlockLowlightOptions = CodeBlockOptions & { lowlight: any; defaultLanguage: string | null | undefined; -} +}; export const CodeBlockLowlight = CodeBlock.extend({ addOptions() { diff --git a/packages/editor/src/core/extensions/code/code-block-node-view.tsx b/packages/editor/src/core/extensions/code/code-block-node-view.tsx index 7626031bc21..6e13924a1c5 100644 --- a/packages/editor/src/core/extensions/code/code-block-node-view.tsx +++ b/packages/editor/src/core/extensions/code/code-block-node-view.tsx @@ -1,6 +1,6 @@ "use client"; -import { Node as ProseMirrorNode } from "@tiptap/pm/model"; +import type { Node as ProseMirrorNode } from "@tiptap/pm/model"; import { NodeViewWrapper, NodeViewContent } from "@tiptap/react"; import ts from "highlight.js/lib/languages/typescript"; import { common, createLowlight } from "lowlight"; @@ -15,11 +15,11 @@ import { cn } from "@plane/utils"; const lowlight = createLowlight(common); lowlight.register("ts", ts); -interface CodeBlockComponentProps { +type Props = { node: ProseMirrorNode; -} +}; -export const CodeBlockComponent: React.FC = ({ node }) => { +export const CodeBlockComponent: React.FC = ({ node }) => { const [copied, setCopied] = useState(false); const copyToClipboard = async (e: React.MouseEvent) => { diff --git a/packages/editor/src/core/extensions/code/code-block.ts b/packages/editor/src/core/extensions/code/code-block.ts index 3b07617ca79..e3ae01033eb 100644 --- a/packages/editor/src/core/extensions/code/code-block.ts +++ b/packages/editor/src/core/extensions/code/code-block.ts @@ -3,7 +3,7 @@ import { Plugin, PluginKey } from "@tiptap/pm/state"; // constants import { CORE_EXTENSIONS } from "@/constants/extension"; -export interface CodeBlockOptions { +export type CodeBlockOptions = { /** * Adds a prefix to language classes that are applied to code tags. * Defaults to `'language-'`. @@ -22,8 +22,8 @@ export interface CodeBlockOptions { /** * Custom HTML attributes that should be added to the rendered HTML tag. */ - HTMLAttributes: Record; -} + HTMLAttributes: Record; +}; declare module "@tiptap/core" { interface Commands { diff --git a/packages/editor/src/core/extensions/custom-link/extension.tsx b/packages/editor/src/core/extensions/custom-link/extension.tsx index 9be125ce6b4..39c227b60f7 100644 --- a/packages/editor/src/core/extensions/custom-link/extension.tsx +++ b/packages/editor/src/core/extensions/custom-link/extension.tsx @@ -10,12 +10,12 @@ import { autolink } from "./helpers/autolink"; import { clickHandler } from "./helpers/clickHandler"; import { pasteHandler } from "./helpers/pasteHandler"; -export interface LinkProtocolOptions { +type LinkProtocolOptions = { scheme: string; optionalSlashes?: boolean; -} +}; -export interface LinkOptions { +type LinkOptions = { /** * If enabled, it adds links as you type. */ @@ -40,14 +40,14 @@ export interface LinkOptions { /** * A list of HTML attributes to be rendered. */ - HTMLAttributes: Record; + HTMLAttributes: Record; /** * A validation function that modifies link verification for the auto linker. * @param url - The url to be validated. * @returns - True if the url is valid, false otherwise. */ validate?: (url: string) => boolean; -} +}; declare module "@tiptap/core" { interface Commands { diff --git a/packages/editor/src/core/extensions/emoji/components/emojis-list.tsx b/packages/editor/src/core/extensions/emoji/components/emojis-list.tsx index 049d3b2d840..380186874e0 100644 --- a/packages/editor/src/core/extensions/emoji/components/emojis-list.tsx +++ b/packages/editor/src/core/extensions/emoji/components/emojis-list.tsx @@ -1,28 +1,17 @@ import { computePosition, flip, shift } from "@floating-ui/dom"; -import { Editor, posToDOMRect } from "@tiptap/react"; +import { type Editor, posToDOMRect } from "@tiptap/react"; import { SuggestionKeyDownProps } from "@tiptap/suggestion"; import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from "react"; // plane imports import { cn } from "@plane/utils"; -export interface EmojiItem { +export type EmojiItem = { name: string; emoji: string; shortcodes: string[]; tags: string[]; fallbackImage?: string; -} - -export interface EmojiListProps { - items: EmojiItem[]; - command: (item: { name: string }) => void; - editor: Editor; - query: string; -} - -export interface EmojiListRef { - onKeyDown: (props: SuggestionKeyDownProps) => boolean; -} +}; const updatePosition = (editor: Editor, element: HTMLElement) => { const virtualElement = { @@ -43,7 +32,18 @@ const updatePosition = (editor: Editor, element: HTMLElement) => { }); }; -export const EmojiList = forwardRef((props, ref) => { +export type EmojiListRef = { + onKeyDown: (props: SuggestionKeyDownProps) => boolean; +}; + +type Props = { + items: EmojiItem[]; + command: (item: { name: string }) => void; + editor: Editor; + query: string; +}; + +export const EmojiList = forwardRef((props, ref) => { const { items, command, editor, query } = props; const [selectedIndex, setSelectedIndex] = useState(0); const [isVisible, setIsVisible] = useState(false); diff --git a/packages/editor/src/core/extensions/emoji/emoji.ts b/packages/editor/src/core/extensions/emoji/emoji.ts index 581a094b8c9..4ad20136672 100644 --- a/packages/editor/src/core/extensions/emoji/emoji.ts +++ b/packages/editor/src/core/extensions/emoji/emoji.ts @@ -65,11 +65,11 @@ export type EmojiItem = { /** * Store some custom data */ - [key: string]: any; + [key: string]: unknown; }; export type EmojiOptions = { - HTMLAttributes: Record; + HTMLAttributes: Record; emojis: EmojiItem[]; enableEmoticons: boolean; forceFallbackImages: boolean; diff --git a/packages/editor/src/core/extensions/headings-list.ts b/packages/editor/src/core/extensions/headings-list.ts index 51a9aeedc26..323478cb178 100644 --- a/packages/editor/src/core/extensions/headings-list.ts +++ b/packages/editor/src/core/extensions/headings-list.ts @@ -2,13 +2,8 @@ import { Extension } from "@tiptap/core"; import { Plugin, PluginKey } from "@tiptap/pm/state"; // constants import { CORE_EXTENSIONS } from "@/constants/extension"; - -export interface IMarking { - type: "heading"; - level: number; - text: string; - sequence: number; -} +// types +import type { IMarking } from "@/types"; export type HeadingExtensionStorage = { headings: IMarking[]; diff --git a/packages/editor/src/core/extensions/horizontal-rule.ts b/packages/editor/src/core/extensions/horizontal-rule.ts index 4ffbcbb00fc..e5bb1f60b81 100644 --- a/packages/editor/src/core/extensions/horizontal-rule.ts +++ b/packages/editor/src/core/extensions/horizontal-rule.ts @@ -3,9 +3,9 @@ import { NodeSelection, TextSelection } from "@tiptap/pm/state"; // constants import { CORE_EXTENSIONS } from "@/constants/extension"; -export interface HorizontalRuleOptions { - HTMLAttributes: Record; -} +type HorizontalRuleOptions = { + HTMLAttributes: Record; +}; declare module "@tiptap/core" { interface Commands { diff --git a/packages/editor/src/core/extensions/table/table-cell.ts b/packages/editor/src/core/extensions/table/table-cell.ts index 42fd3c7df5b..fd6cc6bb04f 100644 --- a/packages/editor/src/core/extensions/table/table-cell.ts +++ b/packages/editor/src/core/extensions/table/table-cell.ts @@ -9,9 +9,9 @@ import { TableCellSelectionOutlinePlugin } from "./plugins/selection-outline/plu import { DEFAULT_COLUMN_WIDTH } from "./table"; import { isCellSelection } from "./table/utilities/helpers"; -export interface TableCellOptions { - HTMLAttributes: Record; -} +type TableCellOptions = { + HTMLAttributes: Record; +}; export const TableCell = Node.create({ name: CORE_EXTENSIONS.TABLE_CELL, diff --git a/packages/editor/src/core/extensions/table/table-header.ts b/packages/editor/src/core/extensions/table/table-header.ts index 315ada5ec90..9f7f90d02da 100644 --- a/packages/editor/src/core/extensions/table/table-header.ts +++ b/packages/editor/src/core/extensions/table/table-header.ts @@ -4,9 +4,9 @@ import { CORE_EXTENSIONS } from "@/constants/extension"; // local imports import { DEFAULT_COLUMN_WIDTH } from "./table"; -export interface TableHeaderOptions { - HTMLAttributes: Record; -} +type TableHeaderOptions = { + HTMLAttributes: Record; +}; export const TableHeader = Node.create({ name: CORE_EXTENSIONS.TABLE_HEADER, diff --git a/packages/editor/src/core/extensions/table/table-row.ts b/packages/editor/src/core/extensions/table/table-row.ts index 48f95a41c93..f01c3913832 100644 --- a/packages/editor/src/core/extensions/table/table-row.ts +++ b/packages/editor/src/core/extensions/table/table-row.ts @@ -2,9 +2,9 @@ import { mergeAttributes, Node } from "@tiptap/core"; // constants import { CORE_EXTENSIONS } from "@/constants/extension"; -export interface TableRowOptions { - HTMLAttributes: Record; -} +type TableRowOptions = { + HTMLAttributes: Record; +}; export const TableRow = Node.create({ name: CORE_EXTENSIONS.TABLE_ROW, diff --git a/packages/editor/src/core/extensions/table/table/table.ts b/packages/editor/src/core/extensions/table/table/table.ts index 0bdc4e8d1cf..bab16f7e723 100644 --- a/packages/editor/src/core/extensions/table/table/table.ts +++ b/packages/editor/src/core/extensions/table/table/table.ts @@ -32,14 +32,14 @@ import { insertLineAboveTableAction } from "./utilities/insert-line-above-table- import { insertLineBelowTableAction } from "./utilities/insert-line-below-table-action"; import { DEFAULT_COLUMN_WIDTH } from "."; -export interface TableOptions { - HTMLAttributes: Record; +type TableOptions = { + HTMLAttributes: Record; resizable: boolean; handleWidth: number; cellMinWidth: number; lastColumnResizable: boolean; allowTableNodeSelection: boolean; -} +}; declare module "@tiptap/core" { interface Commands { diff --git a/packages/editor/src/core/extensions/table/table/utilities/create-cell.ts b/packages/editor/src/core/extensions/table/table/utilities/create-cell.ts index 50fb376c0b7..275b7aa7836 100644 --- a/packages/editor/src/core/extensions/table/table/utilities/create-cell.ts +++ b/packages/editor/src/core/extensions/table/table/utilities/create-cell.ts @@ -3,7 +3,7 @@ import { Fragment, Node as ProsemirrorNode, NodeType } from "@tiptap/pm/model"; export function createCell( cellType: NodeType, cellContent?: Fragment | ProsemirrorNode | Array, - attrs?: Record + attrs?: Record ): ProsemirrorNode | null | undefined { if (cellContent) { return cellType.createChecked(attrs, cellContent); diff --git a/packages/editor/src/core/extensions/table/table/utilities/delete-key-shortcut.ts b/packages/editor/src/core/extensions/table/table/utilities/delete-key-shortcut.ts index 99f343651e1..d562bae2e50 100644 --- a/packages/editor/src/core/extensions/table/table/utilities/delete-key-shortcut.ts +++ b/packages/editor/src/core/extensions/table/table/utilities/delete-key-shortcut.ts @@ -1,4 +1,4 @@ -import { Editor, findParentNodeClosestToPos, KeyboardShortcutCommand } from "@tiptap/core"; +import { type Editor, findParentNodeClosestToPos, type KeyboardShortcutCommand } from "@tiptap/core"; import type { Node as ProseMirrorNode } from "@tiptap/pm/model"; import { CellSelection, TableMap } from "@tiptap/pm/tables"; // constants @@ -6,18 +6,18 @@ import { CORE_EXTENSIONS } from "@/constants/extension"; // extensions import { isCellEmpty, isCellSelection } from "@/extensions/table/table/utilities/helpers"; -interface CellCoord { +type CellCoord = { row: number; col: number; -} +}; -interface TableInfo { +type TableInfo = { node: ProseMirrorNode; pos: number; map: TableMap; totalColumns: number; totalRows: number; -} +}; export const handleDeleteKeyOnTable: KeyboardShortcutCommand = (props) => { const { editor } = props; diff --git a/packages/editor/src/core/extensions/table/table/utilities/helpers.ts b/packages/editor/src/core/extensions/table/table/utilities/helpers.ts index 4d72180609f..f90f1a294c5 100644 --- a/packages/editor/src/core/extensions/table/table/utilities/helpers.ts +++ b/packages/editor/src/core/extensions/table/table/utilities/helpers.ts @@ -1,6 +1,8 @@ import type { Node as ProseMirrorNode } from "@tiptap/pm/model"; import type { Selection } from "@tiptap/pm/state"; import { CellSelection } from "@tiptap/pm/tables"; +// constants +import { CORE_EXTENSIONS } from "@/constants/extension"; /** * @description Check if the selection is a cell selection @@ -22,7 +24,7 @@ export const isCellEmpty = (cell: ProseMirrorNode | null): boolean => { // Check if cell has any non-empty content let hasContent = false; cell.content.forEach((node) => { - if (node.type.name === "paragraph") { + if (node.type.name === CORE_EXTENSIONS.PARAGRAPH) { if (node.content.size > 0) { hasContent = true; } diff --git a/packages/editor/src/core/extensions/typography/inputRules.ts b/packages/editor/src/core/extensions/typography/inputRules.ts index f528e92426d..cc5fea0dc7f 100644 --- a/packages/editor/src/core/extensions/typography/inputRules.ts +++ b/packages/editor/src/core/extensions/typography/inputRules.ts @@ -1,6 +1,6 @@ import { textInputRule } from "@tiptap/core"; -export interface TypographyOptions { +export type TypographyOptions = { emDash: false | string; ellipsis: false | string; leftArrow: false | string; @@ -20,7 +20,7 @@ export interface TypographyOptions { oneQuarter: false | string; threeQuarters: false | string; impliesArrowRight: false | string; -} +}; export const emDash = (override?: string) => textInputRule({ diff --git a/packages/editor/src/core/extensions/utility.ts b/packages/editor/src/core/extensions/utility.ts index ba9e031b027..5f7d23dff64 100644 --- a/packages/editor/src/core/extensions/utility.ts +++ b/packages/editor/src/core/extensions/utility.ts @@ -30,12 +30,12 @@ declare module "@tiptap/core" { } } -export interface UtilityExtensionStorage { +export type UtilityExtensionStorage = { assetsList: TEditorAsset[]; assetsUploadStatus: TFileHandler["assetsUploadStatus"]; uploadInProgress: boolean; activeDropbarExtensions: TActiveDropbarExtensions[]; -} +}; type Props = Pick & { fileHandler: TFileHandler; diff --git a/packages/editor/src/core/extensions/work-item-embed/extension.tsx b/packages/editor/src/core/extensions/work-item-embed/extension.tsx index 64e655a4088..25418bdae11 100644 --- a/packages/editor/src/core/extensions/work-item-embed/extension.tsx +++ b/packages/editor/src/core/extensions/work-item-embed/extension.tsx @@ -1,4 +1,4 @@ -import { ReactNodeViewRenderer, NodeViewWrapper } from "@tiptap/react"; +import { ReactNodeViewRenderer, NodeViewWrapper, type NodeViewProps } from "@tiptap/react"; // local imports import { WorkItemEmbedExtensionConfig } from "./extension-config"; @@ -17,7 +17,7 @@ type Props = { export const WorkItemEmbedExtension = (props: Props) => WorkItemEmbedExtensionConfig.extend({ addNodeView() { - return ReactNodeViewRenderer((issueProps: any) => ( + return ReactNodeViewRenderer((issueProps: NodeViewProps) => ( {props.widgetCallback({ issueId: issueProps.node.attrs.entity_identifier, diff --git a/packages/editor/src/core/helpers/common.ts b/packages/editor/src/core/helpers/common.ts index 301d81917a3..2dce3f1b7fa 100644 --- a/packages/editor/src/core/helpers/common.ts +++ b/packages/editor/src/core/helpers/common.ts @@ -5,13 +5,13 @@ import { cn } from "@plane/utils"; // constants import { CORE_EXTENSIONS } from "@/constants/extension"; -interface EditorClassNames { +type EditorClassNameArgs = { noBorder?: boolean; borderOnFocus?: boolean; containerClassName?: string; -} +}; -export const getEditorClassNames = ({ noBorder, borderOnFocus, containerClassName }: EditorClassNames) => +export const getEditorClassNames = ({ noBorder, borderOnFocus, containerClassName }: EditorClassNameArgs) => cn( "w-full max-w-full sm:rounded-lg focus:outline-none focus:border-0", { diff --git a/packages/editor/src/core/helpers/scroll-to-node.ts b/packages/editor/src/core/helpers/scroll-to-node.ts index 7e5aa0979a0..06c781719f0 100644 --- a/packages/editor/src/core/helpers/scroll-to-node.ts +++ b/packages/editor/src/core/helpers/scroll-to-node.ts @@ -1,11 +1,6 @@ -import { Editor } from "@tiptap/react"; - -export interface IMarking { - type: "heading"; - level: number; - text: string; - sequence: number; -} +import type { Editor } from "@tiptap/react"; +// types +import type { IMarking } from "@/types"; function findNthH1(editor: Editor, n: number, level: number): number { let count = 0; diff --git a/packages/editor/src/core/types/editor.ts b/packages/editor/src/core/types/editor.ts index 39744b3abfe..0f3d7c2976e 100644 --- a/packages/editor/src/core/types/editor.ts +++ b/packages/editor/src/core/types/editor.ts @@ -2,10 +2,9 @@ import type { Content, Extensions, JSONContent } from "@tiptap/core"; import type { Selection } from "@tiptap/pm/state"; // extension types import type { TTextAlign } from "@/extensions"; -// helpers -import type { IMarking } from "@/helpers/scroll-to-node"; // types import type { + IMarking, TAIHandler, TDisplayConfig, TDocumentEventEmitter, @@ -113,7 +112,7 @@ export type EditorRefApi = { }; // editor props -export interface IEditorProps { +export type IEditorProps = { autofocus?: boolean; bubbleMenuEnabled?: boolean; containerClassName?: string; @@ -136,7 +135,7 @@ export interface IEditorProps { placeholder?: string | ((isFocused: boolean, value: string) => string); tabIndex?: number; value?: string | null; -} +}; export type ILiteTextEditorProps = IEditorProps; @@ -144,23 +143,25 @@ export type IRichTextEditorProps = IEditorProps & { dragDropEnabled?: boolean; }; -export interface ICollaborativeDocumentEditorProps - extends Omit { +export type ICollaborativeDocumentEditorProps = Omit< + IEditorProps, + "extensions" | "initialValue" | "onEnterKeyPress" | "value" +> & { aiHandler?: TAIHandler; embedHandler: TEmbedConfig; realtimeConfig: TRealtimeConfig; serverHandler?: TServerHandler; user: TUserDetails; -} +}; -export interface IDocumentEditorProps extends Omit { +export type IDocumentEditorProps = Omit & { aiHandler?: TAIHandler; embedHandler: TEmbedConfig; user?: TUserDetails; value: Content; -} +}; -export interface EditorEvents { +export type EditorEvents = { beforeCreate: never; create: never; update: never; @@ -170,4 +171,4 @@ export interface EditorEvents { blur: never; destroy: never; ready: { height: number }; -} +};