init: the first public commit for AFFiNE

This commit is contained in:
DarkSky
2022-07-22 15:49:21 +08:00
commit e3e3741393
1451 changed files with 108124 additions and 0 deletions
@@ -0,0 +1,45 @@
import { Utils, TLPointerEventHandler } from '@tldraw/core';
import Vec from '@tldraw/vec';
import { Arrow } from '@toeverything/components/board-shapes';
import { SessionType, TDShapeType } from '@toeverything/components/board-types';
import { BaseTool, BaseToolStatus } from '@toeverything/components/board-state';
import { services } from '@toeverything/datasource/db-service';
export class ArrowTool extends BaseTool {
override type = TDShapeType.Arrow as const;
/* ----------------- Event Handlers ----------------- */
override onPointerDown: TLPointerEventHandler = () => {
if (this.status !== BaseToolStatus.Idle) return;
const {
currentPoint,
currentGrid,
settings: { showGrid },
appState: { currentPageId, currentStyle },
document: { id: workspace },
} = this.app;
const childIndex = this.getNextChildIndex();
const id = Utils.uniqueId();
const newShape = Arrow.create({
id,
parentId: currentPageId,
childIndex,
point: showGrid
? Vec.snap(currentPoint, currentGrid)
: currentPoint,
style: { ...currentStyle },
workspace,
});
this.app.patchCreate([newShape]);
this.app.startSession(SessionType.Arrow, newShape.id, 'end', true);
this.set_status(BaseToolStatus.Creating);
};
}
@@ -0,0 +1 @@
export * from './arrow-tool';