linkMobileToolbarItem top-level property

MobileToolbarItem linkMobileToolbarItem
final

Implementation

final linkMobileToolbarItem = MobileToolbarItem.withMenu(
  itemIconBuilder: (context, __, ___) => AFMobileIcon(
    afMobileIcons: AFMobileIcons.link,
    color: MobileToolbarTheme.of(context).iconColor,
  ),
  itemMenuBuilder: (_, editorState, itemMenuService) {
    final selection = editorState.selection;
    if (selection == null) {
      return const SizedBox.shrink();
    }
    final String? linkText = editorState.getDeltaAttributeValueInSelection(
      AppFlowyRichTextKeys.href,
      selection,
    );

    return MobileLinkMenu(
      editorState: editorState,
      linkText: linkText,
      onSubmitted: (value) async {
        if (value.isNotEmpty) {
          await editorState.formatDelta(selection, {
            AppFlowyRichTextKeys.href: value,
          });
        }
        itemMenuService.closeItemMenu();
        editorState.service.keyboardService?.closeKeyboard();
      },
      onCancel: () => itemMenuService.closeItemMenu(),
    );
  },
);