Skip to content

Commit

Permalink
Bring all the changes from fresh_quill_extensions (#1495)
Browse files Browse the repository at this point in the history
* Bring all the changes from fresh_quill_extensions

* Update pubspec.yaml

* Update pubspec.yaml and export new file

* Update pubspec.yaml

* Update CHANGELOG.md

* Update README.md
  • Loading branch information
EchoEllet authored Nov 4, 2023
1 parent ba4a416 commit bffae92
Show file tree
Hide file tree
Showing 50 changed files with 2,573 additions and 1,548 deletions.
53 changes: 31 additions & 22 deletions example/lib/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_quill/extensions.dart';
import 'package:flutter_quill/flutter_quill.dart';
import 'package:flutter_quill_extensions/flutter_quill_extensions.dart';
import 'package:flutter_quill_extensions/presentation/models/config/toolbar/buttons/video.dart';
import 'package:path/path.dart' as path;
import 'package:path_provider/path_provider.dart';

Expand Down Expand Up @@ -102,7 +103,7 @@ class _HomePageState extends State<HomePage> {
context: context,
builder: (context) => AlertDialog(
content: Text(_controller.document.toPlainText([
...FlutterQuillEmbeds.builders(),
...FlutterQuillEmbeds.editorBuilders(),
TimeStampEmbedBuilderWidget()
])),
),
Expand Down Expand Up @@ -254,7 +255,7 @@ class _HomePageState extends State<HomePage> {
),
),
embedBuilders: [
...FlutterQuillEmbeds.builders(),
...FlutterQuillEmbeds.editorBuilders(),
TimeStampEmbedBuilderWidget()
],
),
Expand All @@ -267,9 +268,11 @@ class _HomePageState extends State<HomePage> {
if (kIsWeb) {
return QuillToolbar(
configurations: QuillToolbarConfigurations(
embedButtons: FlutterQuillEmbeds.buttons(
onImagePickCallback: _onImagePickCallback,
webImagePickImpl: _webImagePickImpl,
embedButtons: FlutterQuillEmbeds.toolbarButtons(
imageButtonOptions: QuillToolbarImageButtonOptions(
onImagePickCallback: _onImagePickCallback,
webImagePickImpl: _webImagePickImpl,
),
),
buttonOptions: QuillToolbarButtonOptions(
base: QuillToolbarBaseButtonOptions(
Expand All @@ -283,9 +286,11 @@ class _HomePageState extends State<HomePage> {
if (_isDesktop()) {
return QuillToolbar(
configurations: QuillToolbarConfigurations(
embedButtons: FlutterQuillEmbeds.buttons(
onImagePickCallback: _onImagePickCallback,
filePickImpl: openFileSystemPickerForDesktop,
embedButtons: FlutterQuillEmbeds.toolbarButtons(
imageButtonOptions: QuillToolbarImageButtonOptions(
onImagePickCallback: _onImagePickCallback,
filePickImpl: openFileSystemPickerForDesktop,
),
),
showAlignmentButtons: true,
buttonOptions: QuillToolbarButtonOptions(
Expand All @@ -299,16 +304,20 @@ class _HomePageState extends State<HomePage> {
}
return QuillToolbar(
configurations: QuillToolbarConfigurations(
embedButtons: FlutterQuillEmbeds.buttons(
// provide a callback to enable picking images from device.
// if omit, "image" button only allows adding images from url.
// same goes for videos.
onImagePickCallback: _onImagePickCallback,
onVideoPickCallback: _onVideoPickCallback,
// uncomment to provide a custom "pick from" dialog.
// mediaPickSettingSelector: _selectMediaPickSetting,
// uncomment to provide a custom "pick from" dialog.
// cameraPickSettingSelector: _selectCameraPickSetting,
embedButtons: FlutterQuillEmbeds.toolbarButtons(
imageButtonOptions: QuillToolbarImageButtonOptions(
// provide a callback to enable picking images from device.
// if omit, "image" button only allows adding images from url.
// same goes for videos.
onImagePickCallback: _onImagePickCallback,
// uncomment to provide a custom "pick from" dialog.
// mediaPickSettingSelector: _selectMediaPickSetting,
// uncomment to provide a custom "pick from" dialog.
// cameraPickSettingSelector: _selectCameraPickSetting,
),
videoButtonOptions: QuillToolbarVideoButtonOptions(
onVideoPickCallback: _onVideoPickCallback,
),
),
showAlignmentButtons: true,
buttonOptions: QuillToolbarButtonOptions(
Expand Down Expand Up @@ -437,12 +446,12 @@ class _HomePageState extends State<HomePage> {
TextButton.icon(
icon: const Icon(Icons.collections),
label: const Text('Gallery'),
onPressed: () => Navigator.pop(ctx, MediaPickSetting.Gallery),
onPressed: () => Navigator.pop(ctx, MediaPickSetting.gallery),
),
TextButton.icon(
icon: const Icon(Icons.link),
label: const Text('Link'),
onPressed: () => Navigator.pop(ctx, MediaPickSetting.Link),
onPressed: () => Navigator.pop(ctx, MediaPickSetting.link),
)
],
),
Expand All @@ -461,12 +470,12 @@ class _HomePageState extends State<HomePage> {
TextButton.icon(
icon: const Icon(Icons.camera),
label: const Text('Capture a photo'),
onPressed: () => Navigator.pop(ctx, MediaPickSetting.Camera),
onPressed: () => Navigator.pop(ctx, MediaPickSetting.camera),
),
TextButton.icon(
icon: const Icon(Icons.video_call),
label: const Text('Capture a video'),
onPressed: () => Navigator.pop(ctx, MediaPickSetting.Video),
onPressed: () => Navigator.pop(ctx, MediaPickSetting.video),
)
],
),
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/read_only_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class _ReadOnlyPageState extends State<ReadOnlyPage> {
configurations: QuillEditorConfigurations(
expands: false,
padding: EdgeInsets.zero,
embedBuilders: FlutterQuillEmbeds.builders(),
embedBuilders: FlutterQuillEmbeds.editorBuilders(),
scrollable: true,
autoFocus: true,
),
Expand Down
8 changes: 5 additions & 3 deletions example/lib/widgets/demo_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,17 @@ class _DemoScaffoldState extends State<DemoScaffold> {
if (_isDesktop()) {
return QuillToolbar(
configurations: QuillToolbarConfigurations(
embedButtons: FlutterQuillEmbeds.buttons(
filePickImpl: openFileSystemPickerForDesktop,
embedButtons: FlutterQuillEmbeds.toolbarButtons(
imageButtonOptions: QuillToolbarImageButtonOptions(
filePickImpl: openFileSystemPickerForDesktop,
),
),
),
);
}
return QuillToolbar(
configurations: QuillToolbarConfigurations(
embedButtons: FlutterQuillEmbeds.buttons(),
embedButtons: FlutterQuillEmbeds.toolbarButtons(),
),
);
}
Expand Down
3 changes: 3 additions & 0 deletions flutter_quill_extensions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.6.0-dev.1
- Breaking Changes, we have refactored most of the functions and it got renamed

## 0.5.1

- Provide a way to use custom image provider for the image widgets
Expand Down
152 changes: 142 additions & 10 deletions flutter_quill_extensions/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,154 @@
# Flutter Quill Extensions

Helpers to support embed widgets in flutter_quill. See [Flutter Quill](https://pub.dev/packages/flutter_quill) for details of use.
A extensions for [flutter_quill](https://pub.dev/packages/flutter_quill)
to support embed widgets like image, formula, video and more.

Currently the support for **Web** is limitied.

Check [Flutter Quill](https://github.com/singerdmx/flutter-quill) for details of use.

## Table of Contents

- [Flutter Quill Extensions](#flutter-quill-extensions)
- [Table of Contents](#table-of-contents)
- [About](#about)
- [Installation](#installation)
- [Platform Spesefic Configurations](#platform-spesefic-configurations)
- [Usage](#usage)
- [Features](#features)
- [Contributing](#contributing)
- [License](#license)
- [Acknowledgments](#acknowledgments)


## About
Flutter quill is a rich editor text and it's allow you to customize a lot of things, it has custom embed builders which allow you to render custom widgets in the editor <br>
this is a extensions to extends it functionallities by adding more features like images, videos, and more

## Installation

Before start using this package, please make sure to install
[flutter_quill](https://github.com/singerdmx/flutter-quill) package first and follow it's usage instructions.

```yaml
dependencies:
flutter_quill_extensions: ^<latest-version-here>
```
## Platform Spesefic 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) <br>
>

## Usage

Set the `embedBuilders` and `embedToolbar` params in `QuillEditor` and `QuillToolbar` with the
Before starting using this package you must follow the setup

Set the `embedBuilders` and `embedToolbar` params in configurations of `QuillEditor` and `QuillToolbar` with the
values provided by this repository.

**Quill toolbar**:
```dart
QuillToolbar(
configurations: QuillToolbarConfigurations(
embedButtons: FlutterQuillEmbeds.toolbarButtons(
imageButtonOptions: QuillToolbarImageButtonOptions(
onImagePickCallback: (file) async {
return file.path;
},
),
),
),
),
```
QuillEditor.basic(
controller: controller,
embedBuilders: FlutterQuillEmbeds.builders(),
);

**Quill Editor**
```dart
Expanded(
child: QuillEditor.basic(
configurations: QuillEditorConfigurations(
readOnly: true,
embedBuilders: FlutterQuillEmbeds.editorBuilders(
imageEmbedConfigurations:
const QuillEditorImageEmbedConfigurations(
forceUseMobileOptionMenuForImageClick: true,
),
),
),
),
)
```

They both should be have a parent `QuillProvider` in the widget tree and setup properly <br>
Example:

```dart
QuillProvider(
configurations: QuillConfigurations(
controller: _controller,
sharedConfigurations: const QuillSharedConfigurations(),
),
child: Column(
children: [
QuillToolbar(
configurations: QuillToolbarConfigurations(
embedButtons: FlutterQuillEmbeds.toolbarButtons(
imageButtonOptions: QuillToolbarImageButtonOptions(),
),
),
),
Expanded(
child: QuillEditor.basic(
configurations: QuillEditorConfigurations(
padding: const EdgeInsets.all(16),
embedBuilders: FlutterQuillEmbeds.editorBuilders(),
),
),
)
],
),
)
```
QuillToolbar.basic(
controller: controller,
embedButtons: FlutterQuillEmbeds.buttons(),
);

For web, use:
```dart
FlutterQuillEmbeds.editorsWebBuilders()
```

## Features

```markdown
## Features
- Easy to use and customizable
- Has the option to use custom image provider for the images
- Usefull utilities and widgets
- Handle different errors
```

## Contributing

We welcome contributions!

Please follow these guidelines when contributing to our project. See [CONTRIBUTING.md](CONTRIBUTING.md) for more details.

## License

This project is licensed under the [MIT License](LICENSE) - see the [LICENSE](LICENSE) file for details.

## Acknowledgments

- Thanks to the [Flutter Team](https://flutter.dev/)
- Thanks to [flutter_quill](https://pub.dev/packages/flutter_quill)
12 changes: 12 additions & 0 deletions flutter_quill_extensions/lib/core/exceptions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// import 'package:meta/meta.dart';

// @immutable
// class NetworkException implements Exception {
// const NetworkException({required this.message});

// final String message;

// @override
// String toString() =>
// 'Error while loading something from the network: $message';
// }
Loading

0 comments on commit bffae92

Please sign in to comment.