applyFormat method

void applyFormat(
  1. SmartButtonType format,
  2. dynamic value
)

Applies a specific format to the current selection.

Implementation

void applyFormat(SmartButtonType format, dynamic value) {
  final blockIndex = _editorWidgetState?.focusedBlockIndex ?? 0;
  final selection = _editorWidgetState?.selection;
  if (selection == null || selection.isCollapsed) return;

  final start = selection.start;
  final end = selection.end;

  final info = focusedTableInfo;
  if (info != null) {
    _documentController.applyCellFormat(
        info.blockIndex, info.row, info.col, start, end, format, value);
  } else {
    _documentController.applyFormat(blockIndex, start, end, format, value);
  }
  _editorWidgetState?.rebuild();
}