파일마다 포맷 폭이 달라(≈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>
96 lines
3.2 KiB
TypeScript
96 lines
3.2 KiB
TypeScript
/** 클립보드 명령 — 잘라내기·복사·붙여넣기 (조사표 3절 클립보드 패널) */
|
|
import { toast } from 'react-toastify';
|
|
import {
|
|
copyToClipboard,
|
|
hasClipboardContent,
|
|
pasteFromClipboard,
|
|
} from '../../helpers/cad-clipboard';
|
|
import {
|
|
addEntities,
|
|
deleteEntities,
|
|
getSelectedEntities,
|
|
setSelectedEntityIds,
|
|
} from '../../state';
|
|
import { Tool } from '../../tools';
|
|
import { createSequenceTool } from '../factories/sequence-tool';
|
|
|
|
/** COPYCLIP — 선택 객체를 클립보드로 복사 */
|
|
export function copySelectionToClipboard(): string {
|
|
const count = copyToClipboard(getSelectedEntities());
|
|
if (!count) {
|
|
toast.info('복사할 객체를 먼저 선택하십시오.');
|
|
return '선택 없음';
|
|
}
|
|
toast.success(`${count}개 객체를 복사했습니다.`);
|
|
return `복사 ${count}개`;
|
|
}
|
|
|
|
/** CUTCLIP — 선택 객체를 클립보드로 옮기고 도면에서 지운다 */
|
|
export function cutSelectionToClipboard(): string {
|
|
const selected = getSelectedEntities();
|
|
const count = copyToClipboard(selected);
|
|
if (!count) {
|
|
toast.info('잘라낼 객체를 먼저 선택하십시오.');
|
|
return '선택 없음';
|
|
}
|
|
deleteEntities(selected, true);
|
|
setSelectedEntityIds([]);
|
|
toast.success(`${count}개 객체를 잘라냈습니다.`);
|
|
return `잘라내기 ${count}개`;
|
|
}
|
|
|
|
/** PASTEORIG — 복사한 좌표 그대로 붙여넣기 */
|
|
export function pasteAtOriginalCoordinates(): string {
|
|
const pasted = pasteFromClipboard();
|
|
if (!pasted.length) {
|
|
toast.info('클립보드가 비어 있습니다.');
|
|
return '클립보드 비어 있음';
|
|
}
|
|
addEntities(pasted, true);
|
|
toast.success(`${pasted.length}개 객체를 원래 좌표에 붙여넣었습니다.`);
|
|
return `붙여넣기 ${pasted.length}개`;
|
|
}
|
|
|
|
/** PASTEBLOCK — 붙여넣으면서 하나의 그룹으로 묶는다 (블록 대체) */
|
|
export function pasteAsGroup(): string {
|
|
const pasted = pasteFromClipboard();
|
|
if (!pasted.length) {
|
|
toast.info('클립보드가 비어 있습니다.');
|
|
return '클립보드 비어 있음';
|
|
}
|
|
const groupId = crypto.randomUUID();
|
|
for (const entity of pasted) {
|
|
entity.groupId = groupId;
|
|
}
|
|
addEntities(pasted, true);
|
|
toast.success(`${pasted.length}개 객체를 그룹으로 붙여넣었습니다.`);
|
|
return `그룹 붙여넣기 ${pasted.length}개`;
|
|
}
|
|
|
|
export const copyBaseToolStateMachine = createSequenceTool({
|
|
tool: Tool.COPYBASE,
|
|
steps: [
|
|
{ kind: 'selection', instructions: '복사할 객체를 선택한 뒤 ENTER.' },
|
|
{ kind: 'point', instructions: '기준점을 지정하십시오.' },
|
|
],
|
|
commit: (input) => {
|
|
const count = copyToClipboard(input.entities(0), input.point(1));
|
|
setSelectedEntityIds([]);
|
|
toast.success(`기준점과 함께 ${count}개 객체를 복사했습니다.`);
|
|
},
|
|
});
|
|
|
|
export const pasteToolStateMachine = createSequenceTool({
|
|
tool: Tool.PASTECLIP,
|
|
steps: [{ kind: 'point', instructions: '붙여넣을 위치를 지정하십시오.' }],
|
|
preview: (input) => (hasClipboardContent() ? pasteFromClipboard(input.cursor) : []),
|
|
commit: (input) => {
|
|
const pasted = pasteFromClipboard(input.point(0));
|
|
if (!pasted.length) {
|
|
toast.info('클립보드가 비어 있습니다.');
|
|
return;
|
|
}
|
|
addEntities(pasted, true);
|
|
},
|
|
});
|