mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-19 02:51:47 +08:00
Merge remote-tracking branch 'origin/develop' into fix/autofocus-board-editor
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
|||||||
import type { BlockEditor } from '@toeverything/components/editor-core';
|
import type { BlockEditor } from '@toeverything/components/editor-core';
|
||||||
import { MIN_PAGE_WIDTH } from '@toeverything/components/editor-core';
|
import { MIN_PAGE_WIDTH } from '@toeverything/components/editor-core';
|
||||||
import { styled } from '@toeverything/components/ui';
|
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 { memo, useCallback, useEffect, useRef } from 'react';
|
||||||
import {
|
import {
|
||||||
defaultTextStyle,
|
defaultTextStyle,
|
||||||
@@ -149,6 +149,15 @@ export class EditorUtil extends TDShapeUtil<T, E> {
|
|||||||
})();
|
})();
|
||||||
}, [isEditing]);
|
}, [isEditing]);
|
||||||
|
|
||||||
|
const onMouseDown = useCallback(
|
||||||
|
(e: MouseEvent) => {
|
||||||
|
if (e.detail === 2) {
|
||||||
|
app.setEditingText(shape.id);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[app, shape.id]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HTMLContainer ref={ref} {...events}>
|
<HTMLContainer ref={ref} {...events}>
|
||||||
<Container
|
<Container
|
||||||
@@ -157,6 +166,7 @@ export class EditorUtil extends TDShapeUtil<T, E> {
|
|||||||
onPointerDown={stopPropagation}
|
onPointerDown={stopPropagation}
|
||||||
onMouseEnter={activateIfEditing}
|
onMouseEnter={activateIfEditing}
|
||||||
onDragEnter={activateIfEditing}
|
onDragEnter={activateIfEditing}
|
||||||
|
onMouseDown={onMouseDown}
|
||||||
>
|
>
|
||||||
<MemoAffineEditor
|
<MemoAffineEditor
|
||||||
workspace={workspace}
|
workspace={workspace}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/* eslint-disable max-lines */
|
/* eslint-disable max-lines */
|
||||||
import HotKeys from 'hotkeys-js';
|
import HotKeys from 'hotkeys-js';
|
||||||
import LRUCache from 'lru-cache';
|
|
||||||
|
|
||||||
import type { PatchNode } from '@toeverything/components/ui';
|
import type { PatchNode } from '@toeverything/components/ui';
|
||||||
import type {
|
import type {
|
||||||
@@ -46,10 +45,7 @@ export interface EditorCtorProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Editor implements Virgo {
|
export class Editor implements Virgo {
|
||||||
private _cacheManager = new LRUCache<string, Promise<AsyncBlock | null>>({
|
private _cacheManager = new Map<string, Promise<AsyncBlock | null>>();
|
||||||
max: 8192,
|
|
||||||
ttl: 1000 * 60 * 30,
|
|
||||||
});
|
|
||||||
public mouseManager = new MouseManager(this);
|
public mouseManager = new MouseManager(this);
|
||||||
public selectionManager = new SelectionManager(this);
|
public selectionManager = new SelectionManager(this);
|
||||||
public keyboardManager = new KeyboardManager(this);
|
public keyboardManager = new KeyboardManager(this);
|
||||||
@@ -234,7 +230,12 @@ export class Editor implements Virgo {
|
|||||||
return await services.api.editorBlock.update(patches);
|
return await services.api.editorBlock.update(patches);
|
||||||
},
|
},
|
||||||
remove: async ({ workspace, id }: WorkspaceAndBlockId) => {
|
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 (
|
observe: async (
|
||||||
{ workspace, id }: WorkspaceAndBlockId,
|
{ workspace, id }: WorkspaceAndBlockId,
|
||||||
|
|||||||
Reference in New Issue
Block a user