task(A3): pilot v2 tools select+line
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* 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],
|
||||
};
|
||||
Reference in New Issue
Block a user