Locks and capabilities
Loading interactive example…Open in new tab ↗
The regular rectangle supports standard transforms. Lock it, select it and try Move regular or Delete selection: the command reports rejection without changing the document. Unlock it to resume editing; lock changes are undoable.
The fixed-size card has no resize handles and does not rotate because its registered definition declares those limits. Resize fixed demonstrates the same rejection through the API. It remains selectable and movable. Instance unlocking does not override definition capabilities.
Locking is an editing constraint, not authentication. Application permissions belong in the host admission hook; see events and permissions.
Source
dart
DrawingSession createCapabilitiesExample() {
final registry = ShapeRegistry.withStandard([
ShapeDefinition(
type: 'example.fixed-card',
displayName: 'Fixed-size card',
outline: const ShapeOutlineDefinition.rectangle(),
textBounds: const ShapeBoundsDefinition.inset(12),
capabilities: ShapeCapabilities(resizeHandles: [], rotatable: false),
),
]);
final seed = DrawingSession(
configuration: DrawingConfiguration(),
document: DiagramDocument.empty('capabilities'),
shapeRegistry: registry,
);
try {
for (final (id, type, x, caption) in [
('regular', Shapes.rectangle, -160.0, 'Lock and unlock me'),
('fixed', 'example.fixed-card', 160.0, 'Move me; size stays fixed'),
]) {
seed.createShape(
id: id,
type: type,
worldCenter: DiagramPoint(x, 0),
size: const DiagramSize(240, 140),
select: false,
textStory: TextStory.paragraph(
id: '$id-story',
blockId: '$id-body',
text: caption,
),
);
}
return DrawingSession(
configuration: DrawingConfiguration(),
document: seed.document,
shapeRegistry: registry,
);
} finally {
seed.dispose();
}
}See Shapes for the capability grammar and Session for lock, selection and transform method contracts.