refactor(editor): add gfx entry in bs global package (#10612)

This commit is contained in:
Saul-Mirone
2025-03-04 12:46:50 +00:00
parent 5ad3d3c94a
commit 66d9d576e0
216 changed files with 341 additions and 397 deletions

View File

@@ -26,7 +26,7 @@ import {
type SerializedXYWH,
transformPointsToNewBound,
Vec,
} from '@blocksuite/global/utils';
} from '@blocksuite/global/gfx';
import { type Color, DefaultTheme } from '../../themes/index';

View File

@@ -9,7 +9,7 @@ import {
GfxPrimitiveElementModel,
local,
} from '@blocksuite/block-std/gfx';
import type { IVec, SerializedXYWH, XYWH } from '@blocksuite/global/utils';
import type { IVec, SerializedXYWH, XYWH } from '@blocksuite/global/gfx';
import {
Bound,
curveIntersects,
@@ -22,7 +22,7 @@ import {
Polyline,
polyLineNearestPoint,
Vec,
} from '@blocksuite/global/utils';
} from '@blocksuite/global/gfx';
import * as Y from 'yjs';
import {
@@ -293,6 +293,10 @@ export class ConnectorElementModel extends GfxPrimitiveElementModel<ConnectorEle
? getBezierNearestPoint(getBezierParameters(path), currentPoint)
: polyLineNearestPoint(path, currentPoint);
if (!point) {
return false;
}
return (
Vec.dist(point, currentPoint) <
(options?.hitThreshold ? strokeWidth / 2 : 0) + 8

View File

@@ -1,5 +1,5 @@
import { GfxLocalElementModel } from '@blocksuite/block-std/gfx';
import type { PointLocation } from '@blocksuite/global/utils';
import type { PointLocation } from '@blocksuite/global/gfx';
import {
ConnectorMode,

View File

@@ -10,8 +10,9 @@ import {
local,
observe,
} from '@blocksuite/block-std/gfx';
import type { IVec, PointLocation } from '@blocksuite/global/utils';
import { Bound, keys, linePolygonIntersects } from '@blocksuite/global/utils';
import type { IVec, PointLocation } from '@blocksuite/global/gfx';
import { Bound, linePolygonIntersects } from '@blocksuite/global/gfx';
import { keys } from '@blocksuite/global/utils';
import * as Y from 'yjs';
type GroupElementProps = BaseElementProps & {

View File

@@ -12,15 +12,9 @@ import {
observe,
watch,
} from '@blocksuite/block-std/gfx';
import type { Bound, SerializedXYWH, XYWH } from '@blocksuite/global/utils';
import {
assertType,
deserializeXYWH,
keys,
last,
noop,
pick,
} from '@blocksuite/global/utils';
import type { Bound, SerializedXYWH, XYWH } from '@blocksuite/global/gfx';
import { deserializeXYWH } from '@blocksuite/global/gfx';
import { assertType, keys, last, noop, pick } from '@blocksuite/global/utils';
import { generateKeyBetween } from 'fractional-indexing';
import * as Y from 'yjs';
import { z } from 'zod';

View File

@@ -1,5 +1,5 @@
import type { PointTestOptions } from '@blocksuite/block-std/gfx';
import type { IBound, IVec } from '@blocksuite/global/utils';
import type { IBound, IVec } from '@blocksuite/global/gfx';
import {
Bound,
getCenterAreaBounds,
@@ -11,7 +11,7 @@ import {
polygonGetPointTangent,
polygonNearestPoint,
rotatePoints,
} from '@blocksuite/global/utils';
} from '@blocksuite/global/gfx';
import { DEFAULT_CENTRAL_AREA_RATIO } from '../../../consts/index.js';
import type { ShapeElementModel } from '../shape.js';

View File

@@ -12,7 +12,7 @@ import {
rotatePoints,
toRadian,
Vec,
} from '@blocksuite/global/utils';
} from '@blocksuite/global/gfx';
import { DEFAULT_CENTRAL_AREA_RATIO } from '../../../consts/index.js';
import type { ShapeElementModel } from '../shape.js';

View File

@@ -1,5 +1,5 @@
import type { PointTestOptions } from '@blocksuite/block-std/gfx';
import type { IBound, IVec } from '@blocksuite/global/utils';
import type { IBound, IVec } from '@blocksuite/global/gfx';
import {
Bound,
getCenterAreaBounds,
@@ -11,7 +11,7 @@ import {
polygonGetPointTangent,
polygonNearestPoint,
rotatePoints,
} from '@blocksuite/global/utils';
} from '@blocksuite/global/gfx';
import { DEFAULT_CENTRAL_AREA_RATIO } from '../../../consts/index.js';
import type { ShapeElementModel } from '../shape.js';

View File

@@ -1,5 +1,5 @@
import type { PointTestOptions } from '@blocksuite/block-std/gfx';
import type { IBound, IVec } from '@blocksuite/global/utils';
import type { IBound, IVec } from '@blocksuite/global/gfx';
import {
Bound,
getCenterAreaBounds,
@@ -11,7 +11,7 @@ import {
polygonGetPointTangent,
polygonNearestPoint,
rotatePoints,
} from '@blocksuite/global/utils';
} from '@blocksuite/global/gfx';
import { DEFAULT_CENTRAL_AREA_RATIO } from '../../../consts/index.js';
import type { ShapeElementModel } from '../shape.js';

View File

@@ -15,7 +15,7 @@ import type {
IVec,
PointLocation,
SerializedXYWH,
} from '@blocksuite/global/utils';
} from '@blocksuite/global/gfx';
import * as Y from 'yjs';
import {

View File

@@ -1,13 +1,13 @@
import type { BaseElementProps } from '@blocksuite/block-std/gfx';
import { field, GfxPrimitiveElementModel } from '@blocksuite/block-std/gfx';
import type { IVec, SerializedXYWH } from '@blocksuite/global/utils';
import type { IVec, SerializedXYWH } from '@blocksuite/global/gfx';
import {
Bound,
getPointsFromBoundWithRotation,
linePolygonIntersects,
pointInPolygon,
polygonNearestPoint,
} from '@blocksuite/global/utils';
} from '@blocksuite/global/gfx';
import * as Y from 'yjs';
import {