mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-22 04:21:40 +08:00
d6e7039b7b
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Chores** - Updated package dependencies to reduce the number of direct dependencies for improved maintainability. No changes to user-facing features or functionality. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import {
|
|
FeatureFlagService,
|
|
TelemetryProvider,
|
|
} from '@blocksuite/affine-shared/services';
|
|
import {
|
|
type GfxInteractivityContext,
|
|
InteractivityExtension,
|
|
} from '@blocksuite/std/gfx';
|
|
|
|
import { insertEdgelessTextCommand } from './commands';
|
|
import { addText } from './edgeless-text-editor';
|
|
|
|
export class DblClickAddEdgelessText extends InteractivityExtension {
|
|
static override key = 'dbl-click-add-edgeless-text';
|
|
|
|
override mounted() {
|
|
this.event.on('dblclick', (ctx: GfxInteractivityContext) => {
|
|
const { event: e } = ctx;
|
|
const textFlag = this.std.store
|
|
.get(FeatureFlagService)
|
|
.getFlag('enable_edgeless_text');
|
|
const picked = this.gfx.getElementByPoint(
|
|
...this.gfx.viewport.toModelCoord(e.x, e.y)
|
|
);
|
|
|
|
if (picked) {
|
|
return;
|
|
}
|
|
|
|
if (textFlag) {
|
|
const [x, y] = this.gfx.viewport.toModelCoord(e.x, e.y);
|
|
this.std.command.exec(insertEdgelessTextCommand, { x, y });
|
|
} else {
|
|
const edgelessView = this.std.view.getBlock(
|
|
this.std.store.root?.id || ''
|
|
);
|
|
|
|
if (edgelessView) {
|
|
addText(edgelessView, e);
|
|
}
|
|
}
|
|
|
|
this.std.getOptional(TelemetryProvider)?.track('CanvasElementAdded', {
|
|
control: 'canvas:dbclick',
|
|
page: 'whiteboard editor',
|
|
module: 'toolbar',
|
|
segment: 'toolbar',
|
|
type: 'text',
|
|
});
|
|
});
|
|
}
|
|
}
|