Skip to content

Commit

Permalink
New improvemenets and documentation (#1443)
Browse files Browse the repository at this point in the history
  • Loading branch information
EchoEllet authored Oct 20, 2023
1 parent 81e3046 commit 7c5a12b
Show file tree
Hide file tree
Showing 19 changed files with 263 additions and 93 deletions.
10 changes: 9 additions & 1 deletion .github/ISSUE_TEMPLATE/issue-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ My issue is about [Web]
My issue is about [Mobile]
My issue is about [Desktop]

I have tried running `example` directory successfully before creating an issue here.
I have tried running `example` directory successfully before creating an issue here.

Please note that we are using <b>latest</b> flutter version in stable channel on branch master. If you are using beta or master channel, or you are not using <b>latest</b> flutter version in stable channel, you may experience error.

<!-- Please explain how to encounter the issue in details if possible -->

<!-- Don't forgot to mention the platform you are testing in -->

<!-- Insert your images here if possible -->
<!-- Images: -->

<!-- Add short video that showcase the problem will help -->
44 changes: 44 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Pull Request

## Description

Provide a brief description of your changes.

## Issues

<!-- Remove this if your pull request address changes other than existing issues -->
Closes #IssueNumber
(Replace "IssueNumber" with the actual issue number you are addressing.)

## Improvements
<!-- Please tell us the improvemenets you made in a list -->

<!-- Example: -->
- Improve code readability
- Improve peformance

## Features
<!-- Please tell us the features you added in a list if you add any -->

<!-- Example: -->
- Add a new feature
- Allow to custmize the widgets

<!-- Remove this if your pull request about other changes -->

## Additional notes
<!-- Optional -->

## Suggestions
<!-- Optional -->

## Checklist

<!-- Mark all that applies with `[x]` -->

- [ ] I have added/updated relevant documentation <!-- REQUIRED -->
- [ ] I have tested these changes locally. <!-- REQUIRED -->
- [ ] I have followed the code style and guidelines. <!-- REQUIRED -->
- [ ] I have updated `CHANGELOG.md` with my changes in the next section <!-- REQUIRED -->
- [ ] I have run "dart format ." on the project <!-- REQUIRED -->
- [ ] I have run `flutter test` and `flutter analyze` and it passed successfully <!-- REQUIRED -->
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# [7.4.14]
# [7.4.16]

- Update documentation and README.md

# [7.4.15]

- Custom style attrbuites for platforms other than mobile (alignment, margin, width, height)
- Improve performance by reducing the number of widgets rebuilt by listening to media query for only the needed things, for example instead of using `MediaQuery.of(context).size`, now we are using `MediaQuery.sizeOf(context)`
- Bug fixes and other improvemenets

# [7.4.14]

- Improve performance by reducing the number of widgets rebuilt by listening to media query for only the needed things, for example instead of using `MediaQuery.of(context).size`, now we are using `MediaQuery.sizeOf(context)`
- Add MediaButton for picking the images only since the video one is not ready
- A new feature which allows customizing the text selection in quill editor which is useful for custom theme design system for custom app widget

Expand Down
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,21 @@ QuillToolbar.basic(

> [!WARNING]
>
> This package uses [`gal`](https://github.com/natsuk4ze/) to save images.
> If you are using [flutter_quill_extensions](https://pub.dev/packages/flutter_quill_extensions) package to add support for images, videos and more
> The extensions package require additional configurations:
>
> 1. We are using [`gal`](https://github.com/natsuk4ze/) plugin to save images.
> For this to work, you need to add the appropriate permissions
> to your `Info.plist` and `AndroidManifest.xml` files.
>
> See <https://github.com/natsuk4ze/gal#-get-started> to add the needed lines.
>
> 2. We also use [`image_picker`](https://pub.dev/packages/image_picker) plugin for picking images so please make sure follow the instructions
>
> 3. For loading the image from the internet we need internet permission
> 1. For Android, you need to add some permissions in `AndroidManifest.xml`, Please follow this [link](https://developer.android.com/training/basics/network-ops/connecting) for more info, the internet permission included by default only for debugging so you need to follow this link to add it in the release version too. you should allow loading images and videos only for the `https` protocol but if you want http too then you need to configure your android application to accept `http` in the release mode, follow this [link](https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted) for more info.
> 2. for macOS you also need to include a key in your `Info.plist`, please follow this [link](https://stackoverflow.com/a/61201081/18519412) to add the required configurations
>
> The extensions package also use [image_picker](https://pub.dev/packages/image_picker) which also require some configurations, follow this [link](https://pub.dev/packages/image_picker#installation). It's needed for Android, iOS, macOS, we must inform you that you can't pick photo using camera in desktop so make sure to handle that if you plan on add support for desktop, this might changed in the future and for more info follow this [link](https://pub.dev/packages/image_picker#windows-macos-and-linux)
### Custom Size Image for Mobile

Expand All @@ -253,6 +263,21 @@ Define `mobileWidth`, `mobileHeight`, `mobileMargin`, `mobileAlignment` as follo
}
```

### Custom Size Image for other platforms (excluding web)

Define `width`, `height`, `margin`, `alignment` as follows:

```dart
{
"insert": {
"image": "https://user-images.githubusercontent.com/122956/72955931-ccc07900-3d52-11ea-89b1-d468a6e2aa2b.png"
},
"attributes":{
"style":"width: 50; height: 50; margin: 10; alignment: topLeft"
}
}
```

### Custom Embed Blocks

Sometimes you want to add some custom content inside your text, custom widgets inside of them. An example is adding notes to the text, or anything custom that you want to add in your text editor.
Expand Down
34 changes: 21 additions & 13 deletions flutter_quill_extensions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## 0.5.1

- Provide a way to use custom image provider for the image widgets
- Provide a way to handle different errors in image widgets
- Two bug fixes related to pick the image and capture it using the camera
Expand All @@ -12,42 +13,49 @@
- Add new custom style attrbuite for desktop and other platforms

## 0.5.0

- Migrated from `gallery_saver` to `gal` for saving images
- Added callbacks for greater control of editing images

## 0.4.1

- Updated dependencies to support image_picker 1.0

## 0.4.0

- Fix backspace around images [PR #1309](https://github.com/singerdmx/flutter-quill/pull/1309)
- Feat/link regexp [PR #1329](https://github.com/singerdmx/flutter-quill/pull/1329)

## 0.3.4
* Resolve deprecated method use in the `video_player` package

- Resolve deprecated method use in the `video_player` package

## 0.3.3
* Fix a prototype bug which was bring by [PR #1230](https://github.com/singerdmx/flutter-quill/pull/1230#issuecomment-1560597099)

- Fix a prototype bug which was bring by [PR #1230](https://github.com/singerdmx/flutter-quill/pull/1230#issuecomment-1560597099)

## 0.3.2
* Updated dependencies to support intl 0.18

- Updated dependencies to support intl 0.18

## 0.3.1
* Image embedding tweaks
* Add MediaButton which is intened to superseed the ImageButton and VideoButton. Only image selection is working.
* Implement image insert for web (image as base64)

- Image embedding tweaks
- Add MediaButton which is intened to superseed the ImageButton and VideoButton. Only image selection is working.
- Implement image insert for web (image as base64)

## 0.3.0

* Added support for adding custom tooltips to toolbar buttons
- Added support for adding custom tooltips to toolbar buttons

## 0.2.0

* Allow widgets to override widget span properties [b7951b0](https://github.com/singerdmx/flutter-quill/commit/b7951b02c9086ea42e7aad6d78e6c9b0297562e5)
* Remove tuples [3e9452e](https://github.com/singerdmx/flutter-quill/commit/3e9452e675e8734ff50364c5f7b5d34088d5ff05)
* Remove transparent color of ImageVideoUtils dialog [74544bd](https://github.com/singerdmx/flutter-quill/commit/74544bd945a9d212ca1e8d6b3053dbecee22b720)
* Migrate to `youtube_player_flutter` from `youtube_player_flutter_quill`
* Updates to forumla button [5228f38](https://github.com/singerdmx/flutter-quill/commit/5228f389ba6f37d61d445cfe138c19fcf8766d71)
- Allow widgets to override widget span properties [b7951b0](https://github.com/singerdmx/flutter-quill/commit/b7951b02c9086ea42e7aad6d78e6c9b0297562e5)
- Remove tuples [3e9452e](https://github.com/singerdmx/flutter-quill/commit/3e9452e675e8734ff50364c5f7b5d34088d5ff05)
- Remove transparent color of ImageVideoUtils dialog [74544bd](https://github.com/singerdmx/flutter-quill/commit/74544bd945a9d212ca1e8d6b3053dbecee22b720)
- Migrate to `youtube_player_flutter` from `youtube_player_flutter_quill`
- Updates to forumla button [5228f38](https://github.com/singerdmx/flutter-quill/commit/5228f389ba6f37d61d445cfe138c19fcf8766d71)

## 0.1.0

* Initial release
- Initial release
11 changes: 6 additions & 5 deletions flutter_quill_extensions/lib/embeds/toolbar/image_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class ImageButton extends StatelessWidget {
Future<void> _onPressedHandler(BuildContext context) async {
final onImagePickCallbackRef = onImagePickCallback;
if (onImagePickCallbackRef == null) {
_typeLink(context);
await _typeLink(context);
return;
}
final selector =
Expand All @@ -80,7 +80,7 @@ class ImageButton extends StatelessWidget {
_pickImage(context);
break;
case MediaPickSetting.Link:
_typeLink(context);
await _typeLink(context);
break;
case MediaPickSetting.Camera:
await ImageVideoUtils.handleImageButtonTap(
Expand Down Expand Up @@ -116,14 +116,15 @@ class ImageButton extends StatelessWidget {
webImagePickImpl: webImagePickImpl,
);

void _typeLink(BuildContext context) {
showDialog<String>(
Future<void> _typeLink(BuildContext context) async {
final value = await showDialog<String>(
context: context,
builder: (_) => LinkDialog(
dialogTheme: dialogTheme,
linkRegExp: linkRegExp,
),
).then(_linkSubmitted);
);
_linkSubmitted(value);
}

void _linkSubmitted(String? value) {
Expand Down
6 changes: 3 additions & 3 deletions flutter_quill_extensions/lib/embeds/toolbar/media_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class MediaButton extends StatelessWidget {
this.galleryButtonText,
this.linkButtonText,
this.autovalidateMode = AutovalidateMode.disabled,
this.dialogBarrierColor = Colors.black54,
Key? key,
this.validationMessage,
}) : assert(type == QuillMediaType.image,
Expand All @@ -55,6 +56,7 @@ class MediaButton extends StatelessWidget {
final String? tooltip;
final MediaFilePicker mediaFilePicker;
final MediaPickedCallback? onMediaPickedCallback;
final Color dialogBarrierColor;

/// The margin between child widgets in the dialog.
final double childrenSpacing;
Expand Down Expand Up @@ -344,10 +346,8 @@ class _MediaLinkDialogState extends State<MediaLinkDialog> {
void _submitLink() => Navigator.pop(context, _linkController.text);

String? _validateLink(String? value) {
// TODO: Use [AutoFormatMultipleLinksRule.oneLineRegExp]
// in the next update
if ((value?.isEmpty ?? false) ||
!AutoFormatMultipleLinksRule.linkRegExp.hasMatch(value!)) {
!AutoFormatMultipleLinksRule.oneLineRegExp.hasMatch(value!)) {
return widget.validationMessage ?? 'That is not a valid URL';
}

Expand Down
11 changes: 6 additions & 5 deletions flutter_quill_extensions/lib/embeds/toolbar/video_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ class VideoButton extends StatelessWidget {
if (source == MediaPickSetting.Gallery) {
_pickVideo(context);
} else {
_typeLink(context);
await _typeLink(context);
}
}
} else {
_typeLink(context);
await _typeLink(context);
}
}

Expand All @@ -91,11 +91,12 @@ class VideoButton extends StatelessWidget {
webVideoPickImpl: webVideoPickImpl,
);

void _typeLink(BuildContext context) {
showDialog<String>(
Future<void> _typeLink(BuildContext context) async {
final value = await showDialog<String>(
context: context,
builder: (_) => LinkDialog(dialogTheme: dialogTheme),
).then(_linkSubmitted);
);
_linkSubmitted(value);
}

void _linkSubmitted(String? value) {
Expand Down
2 changes: 1 addition & 1 deletion flutter_quill_extensions/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
flutter:
sdk: flutter

flutter_quill: ^7.4.14
flutter_quill: ^7.4.15
# In case you are working on changes for both libraries,
# flutter_quill:
# path: ~/development/playground/framework_based/flutter/flutter-quill
Expand Down
12 changes: 8 additions & 4 deletions lib/src/utils/platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/foundation.dart'
show kIsWeb, TargetPlatform, defaultTargetPlatform;

bool isWeb() {
return kIsWeb;
}

bool isMobile([TargetPlatform? targetPlatform]) {
if (kIsWeb) return false;
if (isWeb()) return false;
targetPlatform ??= defaultTargetPlatform;
return {TargetPlatform.iOS, TargetPlatform.android}.contains(targetPlatform);
}

bool isDesktop([TargetPlatform? targetPlatform]) {
if (kIsWeb) return false;
if (isWeb()) return false;
targetPlatform ??= defaultTargetPlatform;
return {TargetPlatform.macOS, TargetPlatform.linux, TargetPlatform.windows}
.contains(targetPlatform);
Expand All @@ -21,7 +25,7 @@ bool isKeyboardOS([TargetPlatform? targetPlatform]) {
}

bool isAppleOS([TargetPlatform? targetPlatform]) {
if (kIsWeb) return false;
if (isWeb()) return false;
targetPlatform ??= defaultTargetPlatform;
return {
TargetPlatform.macOS,
Expand All @@ -30,7 +34,7 @@ bool isAppleOS([TargetPlatform? targetPlatform]) {
}

bool isMacOS([TargetPlatform? targetPlatform]) {
if (kIsWeb) return false;
if (isWeb()) return false;
targetPlatform ??= defaultTargetPlatform;
return TargetPlatform.macOS == targetPlatform;
}
Expand Down
Loading

0 comments on commit 7c5a12b

Please sign in to comment.