파일마다 포맷 폭이 달라(≈80 대 100) 한 줄만 고쳐도 포맷터가 무관한 줄을 대량 재포맷했음. 사용자 지시로 전체를 한 번에 맞춤. 코드 동작 변경 없음 — 포맷만. - 프론트엔드 `.ts/.css/.html` → 저장소 prettier (`.prettierrc`, printWidth 100) - `B07_DesignDetail/openwebcad/**` → 자체 biome (tab 들여쓰기·single quote·lineWidth 100). `biome format` 만 사용 — `biome lint --write` 는 포맷 아닌 코드 수정까지 하므로 제외 - 파이썬 → `ruff format` (엔진 코드는 이미 정합, resources·scratch 스크립트 24개만 변경) 두 포맷터가 서로 되돌리지 않도록 `.prettierignore` 신규 — openwebcad 와 빌드·산출물 폴더를 prettier 대상에서 뺌. `.prettierrc` 에 `endOfLine: "auto"` 추가 — 기본값 `lf` 가 `core.autocrlf=true` 로 받은 CRLF 파일을 매번 전부 다시 써서 `--list-different` 가 실제 포맷 차이를 가리고 있었음. 검증: `tsc --noEmit` 통과(루트·openwebcad 둘 다), pytest 349 passed / 17 skipped / 0 failed, CAD vitest 87건 중 81 passed / 6 failed(laptop-sub 기준선과 동일, 회귀 없음). 포맷터 재실행 시 prettier·biome 모두 변경 0건. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
/**
|
|
* 내부 클립보드 — 잘라내기·복사·붙여넣기(기준점 포함).
|
|
* 시스템 클립보드는 도면 객체를 담을 수 없어 앱 안에서만 오간다.
|
|
*/
|
|
import { Point } from '@flatten-js/core';
|
|
import type { Entity } from '../entities/Entity';
|
|
import { getBoundingBoxOfMultipleEntities } from './get-bounding-box-of-multiple-entities';
|
|
|
|
interface ClipboardContent {
|
|
entities: Entity[];
|
|
/** 붙여넣기 기준점 — 지정하지 않으면 선택 영역의 좌하단 */
|
|
basePoint: Point;
|
|
}
|
|
|
|
let clipboard: ClipboardContent | null = null;
|
|
|
|
export const hasClipboardContent = (): boolean => !!clipboard?.entities.length;
|
|
|
|
export function copyToClipboard(entities: Entity[], basePoint?: Point): number {
|
|
if (!entities.length) return 0;
|
|
const box = getBoundingBoxOfMultipleEntities(entities);
|
|
clipboard = {
|
|
entities: entities.map((entity) => {
|
|
const copy = entity.clone();
|
|
copy.lineColor = entity.lineColor;
|
|
copy.lineWidth = entity.lineWidth;
|
|
copy.lineDash = entity.lineDash;
|
|
copy.layerId = entity.layerId;
|
|
return copy;
|
|
}),
|
|
basePoint: basePoint ?? new Point(box.minX, box.minY),
|
|
};
|
|
return clipboard.entities.length;
|
|
}
|
|
|
|
/**
|
|
* 클립보드 내용을 새 객체로 꺼낸다.
|
|
* target을 주면 기준점이 그 위치에 오도록 옮기고, 없으면 원래 좌표 그대로 둔다.
|
|
*/
|
|
export function pasteFromClipboard(target?: Point): Entity[] {
|
|
if (!clipboard) return [];
|
|
return clipboard.entities.map((entity) => {
|
|
const copy = entity.clone();
|
|
copy.lineColor = entity.lineColor;
|
|
copy.lineWidth = entity.lineWidth;
|
|
copy.lineDash = entity.lineDash;
|
|
copy.layerId = entity.layerId;
|
|
if (target) {
|
|
copy.move(
|
|
target.x - (clipboard as ClipboardContent).basePoint.x,
|
|
target.y - (clipboard as ClipboardContent).basePoint.y
|
|
);
|
|
}
|
|
return copy;
|
|
});
|
|
}
|