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) {
|
if (linkText != null) {
|
||||||
safeLaunchUrl(linkText);
|
editorLaunchUrl(linkText);
|
||||||
}
|
}
|
||||||
|
|
||||||
return KeyEventResult.handled;
|
return KeyEventResult.handled;
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ TextSpan defaultTextSpanDecoratorForAttribute(
|
||||||
HardwareKeyboard.instance.isControlPressed ||
|
HardwareKeyboard.instance.isControlPressed ||
|
||||||
HardwareKeyboard.instance.isMetaPressed) {
|
HardwareKeyboard.instance.isMetaPressed) {
|
||||||
tapCount = 0;
|
tapCount = 0;
|
||||||
safeLaunchUrl(href);
|
editorLaunchUrl(href);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
timer = Timer(const Duration(milliseconds: 200), () {
|
timer = Timer(const Duration(milliseconds: 200), () {
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ void showLinkMenu(
|
||||||
linkText: linkText,
|
linkText: linkText,
|
||||||
editorState: editorState,
|
editorState: editorState,
|
||||||
onOpenLink: () async {
|
onOpenLink: () async {
|
||||||
await safeLaunchUrl(linkText);
|
await editorLaunchUrl(linkText);
|
||||||
},
|
},
|
||||||
onSubmitted: (text) async {
|
onSubmitted: (text) async {
|
||||||
if (isUri(text)) {
|
if (isUri(text)) {
|
||||||
|
|
|
||||||
|
|
@ -12,3 +12,5 @@ Future<bool> safeLaunchUrl(String? href) async {
|
||||||
}
|
}
|
||||||
return Future.value(true);
|
return Future.value(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> Function(String? href) editorLaunchUrl = safeLaunchUrl;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||||
void main() {
|
void main() {
|
||||||
test('safeLaunchUrl without href and scheme', () async {
|
test('safeLaunchUrl without href and scheme', () async {
|
||||||
const href = null;
|
const href = null;
|
||||||
final result = await safeLaunchUrl(href);
|
final result = await editorLaunchUrl(href);
|
||||||
expect(result, false);
|
expect(result, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ void main() {
|
||||||
await widgetTester.pumpAndSettle();
|
await widgetTester.pumpAndSettle();
|
||||||
|
|
||||||
// test the method only
|
// test the method only
|
||||||
expect(() => safeLaunchUrl(address), returnsNormally);
|
expect(() => editorLaunchUrl(address), returnsNormally);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
testWidgets(
|
testWidgets(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue