64 lines
1.8 KiB
TypeScript
64 lines
1.8 KiB
TypeScript
|
|
/**
|
|||
|
|
* core-modify – Built-in V2-Plugin (Task A3 Pilot).
|
|||
|
|
*
|
|||
|
|
* Werkzeuge: select (Pilotportierung aus Legacy handleSelectDown).
|
|||
|
|
* Pilot-Scope: Klick-Auswahl inkl. Group-Bewusstheit via SelectionBridge;
|
|||
|
|
* Marquee/Box-Auswahl Migration folgt in A4 (Legacy bleibt parallel aktiv).
|
|||
|
|
*/
|
|||
|
|
import type { PluginV2, ToolExtensionV2 } from '../../types';
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* select-Werkzeug: Klick wählt Element direkt (Shift=additiv, Ctrl=subtraktiv).
|
|||
|
|
*/
|
|||
|
|
export const selectTool: ToolExtensionV2 = {
|
|||
|
|
manifest: {
|
|||
|
|
id: 'select',
|
|||
|
|
label: 'Auswahl',
|
|||
|
|
icon: '\u2196',
|
|||
|
|
ribbonTab: 'canvas',
|
|||
|
|
tags: ['basic'],
|
|||
|
|
description: 'Elemente anklicken zum Auswählen',
|
|||
|
|
},
|
|||
|
|
optionsSchema: [],
|
|||
|
|
handlers: {
|
|||
|
|
down(e, ctx) {
|
|||
|
|
const bridge = (ctx as import('../../types').FullToolContext).selection;
|
|||
|
|
if (!bridge) return;
|
|||
|
|
|
|||
|
|
const additive = e.shift;
|
|||
|
|
const subtractive = e.ctrl;
|
|||
|
|
const hit = bridge.hitTest(e.world.x, e.world.y, 5);
|
|||
|
|
|
|||
|
|
if (!hit) {
|
|||
|
|
// Leerer Klick: Selektion leeren (außer additiv)
|
|||
|
|
if (!additive && !subtractive) bridge.setIds([]);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
let ids = new Set(bridge.getIds());
|
|||
|
|
if (subtractive) {
|
|||
|
|
ids.delete(hit.id);
|
|||
|
|
} else {
|
|||
|
|
ids.add(hit.id);
|
|||
|
|
if (!additive) ids = new Set([hit.id]); // ohne Shift: nur das getroffene
|
|||
|
|
}
|
|||
|
|
bridge.setIds(Array.from(ids));
|
|||
|
|
ctx.setStatus(`Selektion: ${ids.size} Element(e)`);
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
/** V2-Plugin: Kern-Bearbeitungswerkzeuge (Pilot: nur select). */
|
|||
|
|
export const coreModifyPlugin: PluginV2 = {
|
|||
|
|
manifest: {
|
|||
|
|
id: 'core-modify',
|
|||
|
|
name: 'Bearbeiten (Kern)',
|
|||
|
|
version: '1.0.0',
|
|||
|
|
author: 'web-cad team',
|
|||
|
|
description: 'Auswahl und Bearbeitung (V2-Pilot: Selektion).',
|
|||
|
|
category: 'tools',
|
|||
|
|
enabledByDefault: true,
|
|||
|
|
},
|
|||
|
|
tools: [selectTool],
|
|||
|
|
};
|