From 16072240e003ef81138afd8617f45fa641b4b567 Mon Sep 17 00:00:00 2001 From: DiamondThree Date: Mon, 15 Aug 2022 23:07:35 +0800 Subject: [PATCH 1/2] fix undo redo point err --- .../src/components/text-manage/TextManage.tsx | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/libs/components/editor-blocks/src/components/text-manage/TextManage.tsx b/libs/components/editor-blocks/src/components/text-manage/TextManage.tsx index f433c1fba9..6b4acfbb44 100644 --- a/libs/components/editor-blocks/src/components/text-manage/TextManage.tsx +++ b/libs/components/editor-blocks/src/components/text-manage/TextManage.tsx @@ -4,10 +4,7 @@ import { type SlateUtils, type TextProps, } from '@toeverything/components/common'; -import { - useOnSelectActive, - useOnSelectSetSelection, -} from '@toeverything/components/editor-core'; +import { useOnSelectActive } from '@toeverything/components/editor-core'; import { styled } from '@toeverything/components/ui'; import { ContentColumnValue } from '@toeverything/datasource/db-service'; import { @@ -119,13 +116,14 @@ export const TextManage = forwardRef( const properties = block.getProperties(); - const onTextViewSetSelection = (selection: Range | Point) => { - if (selection instanceof Point) { - //do some thing - } else { - textRef.current.setSelection(selection); - } - }; + // const onTextViewSetSelection = (selection: Range | Point) => { + // console.log('selection: ', selection); + // if (selection instanceof Point) { + // //do some thing + // } else { + // // textRef.current.setSelection(selection); + // } + // }; // block = await editor.commands.blockCommands.createNextBlock(block.id,) const onTextViewActive = useCallback( @@ -209,7 +207,8 @@ export const TextManage = forwardRef( ); useOnSelectActive(block.id, onTextViewActive); - useOnSelectSetSelection<'Range'>(block.id, onTextViewSetSelection); + // TODO undo dont reset selection + // useOnSelectSetSelection<'Range'>(block.id, onTextViewSetSelection); useEffect(() => { if (textRef.current) { From 81345ffcba7866abfc0d4499e5889231767c335d Mon Sep 17 00:00:00 2001 From: DiamondThree Date: Tue, 16 Aug 2022 10:59:13 +0800 Subject: [PATCH 2/2] fix lint --- .../src/components/text-manage/TextManage.tsx | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/libs/components/editor-blocks/src/components/text-manage/TextManage.tsx b/libs/components/editor-blocks/src/components/text-manage/TextManage.tsx index 6b4acfbb44..e42a85c5ed 100644 --- a/libs/components/editor-blocks/src/components/text-manage/TextManage.tsx +++ b/libs/components/editor-blocks/src/components/text-manage/TextManage.tsx @@ -116,16 +116,6 @@ export const TextManage = forwardRef( const properties = block.getProperties(); - // const onTextViewSetSelection = (selection: Range | Point) => { - // console.log('selection: ', selection); - // if (selection instanceof Point) { - // //do some thing - // } else { - // // textRef.current.setSelection(selection); - // } - // }; - - // block = await editor.commands.blockCommands.createNextBlock(block.id,) const onTextViewActive = useCallback( (point: CursorTypes) => { // TODO code to be optimized @@ -207,8 +197,6 @@ export const TextManage = forwardRef( ); useOnSelectActive(block.id, onTextViewActive); - // TODO undo dont reset selection - // useOnSelectSetSelection<'Range'>(block.id, onTextViewSetSelection); useEffect(() => { if (textRef.current) {