fix undo redo point err

This commit is contained in:
DiamondThree
2022-08-15 23:07:35 +08:00
parent 5e97efab3a
commit 16072240e0

View File

@@ -4,10 +4,7 @@ import {
type SlateUtils, type SlateUtils,
type TextProps, type TextProps,
} from '@toeverything/components/common'; } from '@toeverything/components/common';
import { import { useOnSelectActive } from '@toeverything/components/editor-core';
useOnSelectActive,
useOnSelectSetSelection,
} from '@toeverything/components/editor-core';
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
import { ContentColumnValue } from '@toeverything/datasource/db-service'; import { ContentColumnValue } from '@toeverything/datasource/db-service';
import { import {
@@ -119,13 +116,14 @@ export const TextManage = forwardRef<ExtendedTextUtils, CreateTextView>(
const properties = block.getProperties(); const properties = block.getProperties();
const onTextViewSetSelection = (selection: Range | Point) => { // const onTextViewSetSelection = (selection: Range | Point) => {
if (selection instanceof Point) { // console.log('selection: ', selection);
//do some thing // if (selection instanceof Point) {
} else { // //do some thing
textRef.current.setSelection(selection); // } else {
} // // textRef.current.setSelection(selection);
}; // }
// };
// block = await editor.commands.blockCommands.createNextBlock(block.id,) // block = await editor.commands.blockCommands.createNextBlock(block.id,)
const onTextViewActive = useCallback( const onTextViewActive = useCallback(
@@ -209,7 +207,8 @@ export const TextManage = forwardRef<ExtendedTextUtils, CreateTextView>(
); );
useOnSelectActive(block.id, onTextViewActive); useOnSelectActive(block.id, onTextViewActive);
useOnSelectSetSelection<'Range'>(block.id, onTextViewSetSelection); // TODO undo dont reset selection
// useOnSelectSetSelection<'Range'>(block.id, onTextViewSetSelection);
useEffect(() => { useEffect(() => {
if (textRef.current) { if (textRef.current) {