-
Notifications
You must be signed in to change notification settings - Fork 343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[QUESTION] Translate #69
Comments
Not directly through the plugin at the moment, but you can use the If you'd like an example let me know and I can cook something up this evening. |
Here's an example: HtmlEditor(
controller: controller,
htmlToolbarOptions: HtmlToolbarOptions(
onButtonPressed: (ButtonType type, bool? status,
Function()? updateStatus) async {
if (type == ButtonType.link) {
final text = TextEditingController();
final url = TextEditingController();
final textFocus = FocusNode();
final urlFocus = FocusNode();
final formKey = GlobalKey<FormState>();
var openNewTab = false;
await showDialog(
context: context,
builder: (BuildContext context) {
return StatefulBuilder(builder:
(BuildContext context, StateSetter setState) {
return AlertDialog(
title: Text('Insert Link'),
scrollable: true,
content: Form(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Text to display',
style: TextStyle(
fontWeight: FontWeight.bold)),
SizedBox(height: 10),
TextField(
controller: text,
focusNode: textFocus,
textInputAction: TextInputAction.next,
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'Text',
),
onSubmitted: (_) {
urlFocus.requestFocus();
},
),
SizedBox(height: 20),
Text('URL',
style: TextStyle(
fontWeight: FontWeight.bold)),
SizedBox(height: 10),
TextFormField(
controller: url,
focusNode: urlFocus,
textInputAction: TextInputAction.done,
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'URL',
),
validator: (String? value) {
if (value == null || value.isEmpty) {
return 'Please enter a URL!';
}
return null;
},
),
Row(
children: <Widget>[
SizedBox(
height: 48.0,
width: 24.0,
child: Checkbox(
value: openNewTab,
activeColor: Color(0xFF827250),
onChanged: (bool? value) {
setState(() {
openNewTab = value!;
});
},
),
),
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Theme.of(context)
.dialogBackgroundColor,
padding: EdgeInsets.only(
left: 5, right: 5),
elevation: 0.0),
onPressed: () {
setState(() {
openNewTab = !openNewTab;
});
},
child: Text('Open in new window',
style: TextStyle(
color: Theme.of(context)
.textTheme
.bodyText1
?.color)),
),
],
),
]),
),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text('Cancel'),
),
TextButton(
onPressed: () async {
if (formKey.currentState!.validate()) {
controller.insertLink(
text.text.isEmpty ? url.text : text.text,
url.text,
openNewTab,
);
Navigator.of(context).pop();
}
},
child: Text('OK'),
)
],
);
});
});
return false;
}
return true;
},
),
), So that overrides the default dialog and then you can customize it however you want - if you just want to translate then you can edit the strings in the example. |
Closing for now, hope it helped. |
Hi, nice plugin!
There is any way to translate the text on link functionality, pictures...dialogs?
The text was updated successfully, but these errors were encountered: