chore(editor): merge clamp functions (#10577)

Closes: [BS-2625](https://linear.app/affine-design/issue/BS-2625/合并clamp函数)
This commit is contained in:
Saul-Mirone
2025-03-03 10:33:38 +00:00
parent 899a957fab
commit 4c3c953a36
16 changed files with 21 additions and 34 deletions

View File

@@ -1,11 +1,10 @@
import { NoteBlockModel, RootBlockModel } from '@blocksuite/affine-model';
import { BLOCK_ID_ATTR, type BlockComponent } from '@blocksuite/block-std';
import { SurfaceBlockModel } from '@blocksuite/block-std/gfx';
import type { Point, Rect } from '@blocksuite/global/utils';
import { clamp, type Point, type Rect } from '@blocksuite/global/utils';
import type { BlockModel } from '@blocksuite/store';
import { BLOCK_CHILDREN_CONTAINER_PADDING_LEFT } from '../../consts/index.js';
import { clamp } from '../math.js';
import { matchModels } from '../model/checker.js';
const ATTR_SELECTOR = `[${BLOCK_ID_ATTR}]`;

View File

@@ -2,12 +2,6 @@ export function almostEqual(a: number, b: number, epsilon = 0.0001) {
return Math.abs(a - b) < epsilon;
}
export function clamp(value: number, min: number, max: number): number {
if (value < min) return min;
if (value > max) return max;
return value;
}
export function rangeWrap(n: number, min: number, max: number) {
max = max - min;
n = (n - min + max) % max;