linkItem top-level property

ToolbarItem linkItem
final

Implementation

final linkItem = ToolbarItem(
  id: 'editor.link',
  group: 4,
  isActive: onlyShowInSingleSelectionAndTextType,
  builder: (context, editorState, highlightColor, iconColor) {
    final selection = editorState.selection!;
    final nodes = editorState.getNodesInSelection(selection);
    final isHref = nodes.allSatisfyInSelection(selection, (delta) {
      return delta.everyAttributes(
        (attributes) => attributes[AppFlowyRichTextKeys.href] != null,
      );
    });

    return SVGIconItemWidget(
      iconName: 'toolbar/link',
      isHighlight: isHref,
      highlightColor: highlightColor,
      iconColor: iconColor,
      tooltip: AppFlowyEditorL10n.current.link,
      onPressed: () {
        showLinkMenu(context, editorState, selection, isHref);
      },
    );
  },
);