Skip to content

Commit

Permalink
Merge branch 'master' into master-1
Browse files Browse the repository at this point in the history
  • Loading branch information
BastiennM authored Oct 13, 2023
2 parents d5cecd1 + f239f43 commit 8a1e823
Show file tree
Hide file tree
Showing 9 changed files with 195 additions and 177 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [2.3.0] - 2023/03/24

* Add support for custom action buttons
* Add dialog mode on pictures
* Remove Google dependency

## [2.2.0] - 2023/01/02

* Change the way of adding links to the input. Now, you need to select the text you want to be the label, then click the link button.
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ MarkdownEditableTextInput is a TextField Widget that allow you to convert easily
- [x] Convert to Code, Quote, Links
- [x] Convert to Heading (H1, H2, H3, H4, H5, H6) and Links
- [x] Support text direction
- [x] Dialog mode to enter link and picture
- [x] Possibility to add custom buttons to the action bar

## Demo
![](pictures/test_edition.gif)
Expand All @@ -37,6 +39,10 @@ The color of the MarkdownTextInput is defined by the color set in your Theme :
| TextEditingController controller | TextEditingController() | Pass your own controller. Can be used to clear the input for example |
| TextStyle textStyle | Theme.of(context).textTheme.bodyText2 | Overrides input text style |
| bool insertLinksByDialog; | true | Choose to use dialog or not to insert link |
| bool insertImageByDialog; | true | Choose to use dialog or not to insert an image |
| bool insertImageByDialog; | true | Choose to use dialog or not to insert an image |
| bool customCancelDialogText; | String? | Text used by dialog for close dialog action |
| bool customSubmitDialogText; | String? | Text used by dialog for validate dialog action |

### Example
You can see an example of how to use this package [here](https://github.com/playmoweb/markdown-editable-textinput/tree/master/example)
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
3 changes: 3 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class _MyAppState extends State<MyApp> {
actions: MarkdownType.values,
controller: controller,
textStyle: TextStyle(fontSize: 16),
optionnalActionButtons: [
ActionButton(widget: Icon(Icons.add), action: () => controller.text = '${controller.text} test ')
],
),
TextButton(
onPressed: () {
Expand Down
23 changes: 1 addition & 22 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
http:
dependency: transitive
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.5"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.2"
markdown:
dependency: transitive
description:
Expand All @@ -122,7 +108,7 @@ packages:
path: ".."
relative: true
source: path
version: "3.0.0"
version: "2.3.0"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -191,13 +177,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.3"
translator:
dependency: transitive
description:
name: translator
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.7"
typed_data:
dependency: transitive
description:
Expand Down
13 changes: 12 additions & 1 deletion lib/format_markdown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class FormatMarkdown {
replaceCursorIndex = 0;
break;
case MarkdownType.image:
changedData = '![${data.substring(fromIndex, toIndex)}](${data.substring(fromIndex, toIndex)})';
changedData = '![$selectedText](${link ?? selectedText})';
replaceCursorIndex = 3;
break;
}
Expand Down Expand Up @@ -132,6 +132,17 @@ enum MarkdownType {
image,
}
/// Custom button object
class ActionButton {
/// [widget] is the icon in the action bar
final Widget widget;
/// Action to perform when button is pressed
final Function() action;
/// return [ActionButton]
ActionButton({required this.widget, required this.action});
}
/// Add data to [MarkdownType] enum
extension MarkownTypeExtension on MarkdownType {
/// Get String used in widget's key
Expand Down
Loading

0 comments on commit 8a1e823

Please sign in to comment.