feat: support customizing link button (#1048)
This commit is contained in:
parent
5277d2ddd1
commit
b2672f297b
6 changed files with 7 additions and 5 deletions
|
|
@ -38,7 +38,7 @@ KeyEventResult _openInlineLink(
|
|||
}
|
||||
|
||||
if (linkText != null) {
|
||||
safeLaunchUrl(linkText);
|
||||
editorLaunchUrl(linkText);
|
||||
}
|
||||
|
||||
return KeyEventResult.handled;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ TextSpan defaultTextSpanDecoratorForAttribute(
|
|||
HardwareKeyboard.instance.isControlPressed ||
|
||||
HardwareKeyboard.instance.isMetaPressed) {
|
||||
tapCount = 0;
|
||||
safeLaunchUrl(href);
|
||||
editorLaunchUrl(href);
|
||||
return;
|
||||
}
|
||||
timer = Timer(const Duration(milliseconds: 200), () {
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ void showLinkMenu(
|
|||
linkText: linkText,
|
||||
editorState: editorState,
|
||||
onOpenLink: () async {
|
||||
await safeLaunchUrl(linkText);
|
||||
await editorLaunchUrl(linkText);
|
||||
},
|
||||
onSubmitted: (text) async {
|
||||
if (isUri(text)) {
|
||||
|
|
|
|||
|
|
@ -12,3 +12,5 @@ Future<bool> safeLaunchUrl(String? href) async {
|
|||
}
|
||||
return Future.value(true);
|
||||
}
|
||||
|
||||
Future<bool> Function(String? href) editorLaunchUrl = safeLaunchUrl;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import 'package:flutter_test/flutter_test.dart';
|
|||
void main() {
|
||||
test('safeLaunchUrl without href and scheme', () async {
|
||||
const href = null;
|
||||
final result = await safeLaunchUrl(href);
|
||||
final result = await editorLaunchUrl(href);
|
||||
expect(result, false);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ void main() {
|
|||
await widgetTester.pumpAndSettle();
|
||||
|
||||
// test the method only
|
||||
expect(() => safeLaunchUrl(address), returnsNormally);
|
||||
expect(() => editorLaunchUrl(address), returnsNormally);
|
||||
},
|
||||
);
|
||||
testWidgets(
|
||||
|
|
|
|||
Loading…
Reference in a new issue