replacedWidgetTextBlocks function

Set<String> replacedWidgetTextBlocks(
  1. ResolvedShape shape,
  2. Set<String> mountedWidgetSlotIds
)

Shared paint/accessibility/input projection of text replaced by mounted slots. Canonical stories and portable output retain every block.

Implementation

Set<String> replacedWidgetTextBlocks(
  ResolvedShape shape,
  Set<String> mountedWidgetSlotIds,
) {
  if (mountedWidgetSlotIds.isEmpty) return const {};
  final slots = <String>{
    for (final layer in shape.layers)
      if (mountedWidgetSlotIds.contains(layer.widgetSlotId))
        if (layer.definition case ShapeTextLayerDefinition(:final slotId))
          slotId,
  };
  return {
    for (final block in shape.source.textStory?.blocks ?? [])
      if (slots.contains(block.effectiveSlotId)) block.id,
  };
}