From 5959c088737fd521fba71b9cb2a32a50abc27975 Mon Sep 17 00:00:00 2001 From: alt0 Date: Thu, 18 Aug 2022 12:16:12 +0800 Subject: [PATCH 1/3] fix: remove asyncBlock cache --- libs/components/editor-core/src/editor/editor.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libs/components/editor-core/src/editor/editor.ts b/libs/components/editor-core/src/editor/editor.ts index 1d1cc95684..2cd379bb26 100644 --- a/libs/components/editor-core/src/editor/editor.ts +++ b/libs/components/editor-core/src/editor/editor.ts @@ -1,6 +1,5 @@ /* eslint-disable max-lines */ import HotKeys from 'hotkeys-js'; -import LRUCache from 'lru-cache'; import type { PatchNode } from '@toeverything/components/ui'; import type { @@ -46,10 +45,7 @@ export interface EditorCtorProps { } export class Editor implements Virgo { - private _cacheManager = new LRUCache>({ - max: 8192, - ttl: 1000 * 60 * 30, - }); + private _cacheManager = new Map>(); public mouseManager = new MouseManager(this); public selectionManager = new SelectionManager(this); public keyboardManager = new KeyboardManager(this); From 68cadca5ca84ad5d7d0b5b90c26aa1508ea8ccf7 Mon Sep 17 00:00:00 2001 From: alt0 Date: Thu, 18 Aug 2022 14:29:44 +0800 Subject: [PATCH 2/3] fix: if delete block, clear cache --- libs/components/editor-core/src/editor/editor.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/components/editor-core/src/editor/editor.ts b/libs/components/editor-core/src/editor/editor.ts index 2cd379bb26..e85db2ba65 100644 --- a/libs/components/editor-core/src/editor/editor.ts +++ b/libs/components/editor-core/src/editor/editor.ts @@ -230,7 +230,12 @@ export class Editor implements Virgo { return await services.api.editorBlock.update(patches); }, remove: async ({ workspace, id }: WorkspaceAndBlockId) => { - return await services.api.editorBlock.delete({ workspace, id }); + const ret = await services.api.editorBlock.delete({ + workspace, + id, + }); + this._cacheManager.delete(id); + return ret; }, observe: async ( { workspace, id }: WorkspaceAndBlockId, From a5289844790a002de4c9a374ff75800540570649 Mon Sep 17 00:00:00 2001 From: austaras Date: Wed, 17 Aug 2022 18:56:18 +0800 Subject: [PATCH 3/3] feat(whiteboard): activate text on dblclick --- .../board-shapes/src/editor-util/EditorUtil.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libs/components/board-shapes/src/editor-util/EditorUtil.tsx b/libs/components/board-shapes/src/editor-util/EditorUtil.tsx index 6e6f123a72..cb6e56275a 100644 --- a/libs/components/board-shapes/src/editor-util/EditorUtil.tsx +++ b/libs/components/board-shapes/src/editor-util/EditorUtil.tsx @@ -10,7 +10,7 @@ import { } from '@toeverything/components/board-types'; import { MIN_PAGE_WIDTH } from '@toeverything/components/editor-core'; import { styled } from '@toeverything/components/ui'; -import type { SyntheticEvent } from 'react'; +import type { MouseEvent, SyntheticEvent } from 'react'; import { memo, useCallback, useEffect, useRef } from 'react'; import { defaultTextStyle, @@ -135,6 +135,15 @@ export class EditorUtil extends TDShapeUtil { } }, [app, state, shape.id, editingText, editingId]); + const onMouseDown = useCallback( + (e: MouseEvent) => { + if (e.detail === 2) { + app.setEditingText(shape.id); + } + }, + [app, shape.id] + ); + return ( { onPointerDown={stopPropagation} onMouseEnter={activateIfEditing} onDragEnter={activateIfEditing} + onMouseDown={onMouseDown} >