From b12c6952e29978cbaa721c0ebe72ad6045178c31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Jablo=C3=B1ski?= <43938777+GermanJablo@users.noreply.github.com> Date: Thu, 17 Oct 2024 09:29:40 -0300 Subject: [PATCH 1/4] save --- .../features/blocks/client/component/BlockContent.tsx | 6 +++--- .../src/features/blocks/client/component/index.tsx | 2 +- .../features/experimental_table/client/utils/debounce.ts | 3 +++ .../richtext-lexical/src/lexical/LexicalProvider.tsx | 9 ++++++++- .../plugins/handles/AddBlockHandlePlugin/index.tsx | 3 ++- .../plugins/handles/DraggableBlockPlugin/debounce.ts | 8 ++++---- .../src/utilities/fieldsDrawer/DrawerContent.tsx | 2 +- .../richtext-lexical/src/utilities/generateImportMap.tsx | 2 ++ .../src/utilities/migrateSlateToLexical/index.ts | 7 ++++--- packages/richtext-lexical/src/validate/index.ts | 4 ++-- 10 files changed, 30 insertions(+), 16 deletions(-) diff --git a/packages/richtext-lexical/src/features/blocks/client/component/BlockContent.tsx b/packages/richtext-lexical/src/features/blocks/client/component/BlockContent.tsx index 4d3af4a0ffd..ddaad1c26c8 100644 --- a/packages/richtext-lexical/src/features/blocks/client/component/BlockContent.tsx +++ b/packages/richtext-lexical/src/features/blocks/client/component/BlockContent.tsx @@ -43,13 +43,13 @@ type Props = { // Inside of fields.data however, that sub-blocks blockName property does not exist at all. function removeUndefinedAndNullAndEmptyArraysRecursively(obj: object) { for (const key in obj) { - const value = obj[key] + const value = obj[key as keyof object] as unknown if (Array.isArray(value) && !value?.length) { - delete obj[key] + delete obj[key as keyof object] } else if (value && typeof value === 'object') { removeUndefinedAndNullAndEmptyArraysRecursively(value) } else if (value === undefined || value === null) { - delete obj[key] + delete obj[key as keyof object] } } } diff --git a/packages/richtext-lexical/src/features/blocks/client/component/index.tsx b/packages/richtext-lexical/src/features/blocks/client/component/index.tsx index 1f826e7ae31..f5123ec57f3 100644 --- a/packages/richtext-lexical/src/features/blocks/client/component/index.tsx +++ b/packages/richtext-lexical/src/features/blocks/client/component/index.tsx @@ -86,7 +86,7 @@ export const BlockComponent: React.FC = (props) => { }, [config.routes.api, config.serverURL, schemaFieldsPath, id]) // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing. const onChange = useCallback( - async ({ formState: prevFormState }) => { + async ({ formState: prevFormState }: { formState: FormState }) => { const { state: formState } = await getFormState({ apiRoute: config.routes.api, body: { diff --git a/packages/richtext-lexical/src/features/experimental_table/client/utils/debounce.ts b/packages/richtext-lexical/src/features/experimental_table/client/utils/debounce.ts index 11b3d99ae2a..7a17717832e 100644 --- a/packages/richtext-lexical/src/features/experimental_table/client/utils/debounce.ts +++ b/packages/richtext-lexical/src/features/experimental_table/client/utils/debounce.ts @@ -1,3 +1,5 @@ +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck - not worth it migrate jsdoc to tsdoc 'use client' // Copied & modified from https://github.com/lodash/lodash/blob/main/src/debounce.ts /* @@ -242,4 +244,5 @@ function debounce(func, wait, options) { return debounced } +// eslint-disable-next-line no-restricted-exports export default debounce diff --git a/packages/richtext-lexical/src/lexical/LexicalProvider.tsx b/packages/richtext-lexical/src/lexical/LexicalProvider.tsx index 177464696a2..2e28c73bab6 100644 --- a/packages/richtext-lexical/src/lexical/LexicalProvider.tsx +++ b/packages/richtext-lexical/src/lexical/LexicalProvider.tsx @@ -25,7 +25,14 @@ export type LexicalProviderProps = { value: SerializedEditorState } -const NestProviders = ({ children, providers }) => { +const NestProviders = ({ + children, + providers, +}: { + children: React.ReactNode + // eslint-disable-next-line @typescript-eslint/no-explicit-any + providers: any[] +}) => { if (!providers?.length) { return children } diff --git a/packages/richtext-lexical/src/lexical/plugins/handles/AddBlockHandlePlugin/index.tsx b/packages/richtext-lexical/src/lexical/plugins/handles/AddBlockHandlePlugin/index.tsx index 8017c24a18f..84c830291da 100644 --- a/packages/richtext-lexical/src/lexical/plugins/handles/AddBlockHandlePlugin/index.tsx +++ b/packages/richtext-lexical/src/lexical/plugins/handles/AddBlockHandlePlugin/index.tsx @@ -126,7 +126,7 @@ function useAddBlockHandle( }, [anchorElem, hoveredElement, blockHandleHorizontalOffset]) const handleAddClick = useCallback( - (event) => { + (event: React.MouseEvent) => { let hoveredElementToUse = hoveredElement if (!hoveredElementToUse?.node) { return @@ -189,6 +189,7 @@ function useAddBlockHandle( return createPortal(