Update flutter quill extensions

pull/1582/head
Ellet 1 year ago
parent 5d69c14557
commit 380ea15643
No known key found for this signature in database
GPG Key ID: C488CC70BBCEF0D1
  1. 7
      CHANGELOG.md
  2. 7
      flutter_quill_extensions/CHANGELOG.md
  3. 6
      flutter_quill_extensions/lib/extensions/controller_ext.dart
  4. 96
      flutter_quill_extensions/lib/utils/quill_image_utils.dart
  5. 2
      flutter_quill_extensions/pubspec.yaml
  6. 7
      flutter_quill_test/CHANGELOG.md
  7. 2
      flutter_quill_test/pubspec.yaml
  8. 2
      pubspec.yaml
  9. 7
      quill_html_converter/CHANGELOG.md
  10. 2
      quill_html_converter/pubspec.yaml
  11. 2
      version.dart

@ -2,6 +2,13 @@
All notable changes to this project will be documented in this file.
## 9.0.0
* This version is quite stable but it's not how we wanted to be, because the lack of time and there are not too many maintainers active, we decided to publish it, we might make a new breaking changes verion
## 9.0.1-dev.1
* Flutter Quill Extensions:
* Update `QuillImageUtilities` and fixining some bugs
## 9.0.1-dev
* Test new GitHub workflows

@ -2,6 +2,13 @@
All notable changes to this project will be documented in this file.
## 9.0.0
* This version is quite stable but it's not how we wanted to be, because the lack of time and there are not too many maintainers active, we decided to publish it, we might make a new breaking changes verion
## 9.0.1-dev.1
* Flutter Quill Extensions:
* Update `QuillImageUtilities` and fixining some bugs
## 9.0.1-dev
* Test new GitHub workflows

@ -43,10 +43,4 @@ extension QuillControllerExt on QuillController {
..skipRequestKeyboard = true
..replaceText(index, length, BlockEmbed.video(videoUrl), null);
}
QuillImageUtilities get imageUtilities {
return QuillImageUtilities(
controller: this,
);
}
}

@ -2,10 +2,9 @@ import 'dart:io' show Directory, File, Platform;
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter_quill/flutter_quill.dart' as quill;
import 'package:flutter_quill/quill_delta.dart';
import 'package:path/path.dart' as path;
import 'utils.dart';
typedef OnGenerateNewFileNameCallback = String Function(
String currentFileName,
String fileExt,
@ -13,10 +12,10 @@ typedef OnGenerateNewFileNameCallback = String Function(
class QuillImageUtilities {
const QuillImageUtilities({
required this.controller,
required this.document,
});
final quill.QuillController controller;
final quill.Document document;
/// Private function that is throw an error if the platform is web
static void _webIsNotSupported(String functionName) {
@ -172,31 +171,49 @@ class QuillImageUtilities {
required bool onlyLocalImages,
}) {
_webIsNotSupported('getImagesPathsFromDocument');
final images = controller.document.root.children
.whereType<quill.Line>()
.where((node) {
if (node.isEmpty) {
return false;
}
final firstNode = node.children.first;
if (firstNode is! quill.Embed) {
return false;
}
// final images = document.root.children
// .whereType<quill.Line>()
// .where((node) {
// if (node.isEmpty) {
// return false;
// }
// final firstNode = node.children.first;
// if (firstNode is! quill.Embed) {
// return false;
// }
// if (firstNode.value.type != quill.BlockEmbed.imageType) {
// return false;
// }
// final imageSource = firstNode.value.data;
// if (imageSource is! String) {
// return false;
// }
// if (onlyLocalImages && isHttpBasedUrl(imageSource)) {
// return false;
// }
// return imageSource.trim().isNotEmpty;
// })
// .toList()
// .map((e) => (e.children.first as quill.Embed).value.data as String);
final images = <String>[];
for (final item in document.toDelta().toJson()) {
if (item is! Map) {
return [];
}
if (!item.containsKey(Operation.insertKey)) {
return [];
}
final insertValue = item[Operation.insertKey];
if (firstNode.value.type != quill.BlockEmbed.imageType) {
return false;
}
final imageSource = firstNode.value.data;
if (imageSource is! String) {
return false;
}
if (onlyLocalImages && isHttpBasedUrl(imageSource)) {
return false;
}
return imageSource.trim().isNotEmpty;
})
.toList()
.map((e) => (e.children.first as quill.Embed).value.data as String);
// Check if the insert value is a map with the "image" key
if (insertValue is Map &&
insertValue.containsKey(quill.BlockEmbed.imageType)) {
final String imageUrl = insertValue[quill.BlockEmbed.imageType];
images.add(imageUrl);
}
}
return images;
}
@ -249,9 +266,9 @@ class QuillImageUtilities {
///
/// Returns a list of cached image paths found in the document.
/// On non-mobile platforms, this function returns an empty list.
Future<Iterable<String>> getCachedImagePathsFromDocument({
Iterable<String> getCachedImagePathsFromDocument({
String? replaceUnexistentImagesWith,
}) async {
}) {
_webIsNotSupported('getCachedImagePathsFromDocument');
final imagePaths = getImagesPathsFromDocument(
onlyLocalImages: true,
@ -262,25 +279,6 @@ class QuillImageUtilities {
final isCurrentImageCached = isImageCached(imagePath);
return isCurrentImageCached;
}).toList();
// Remove all the images that doesn't exists
for (final imagePath in cachesImagePaths) {
final file = File(imagePath);
final exists = await file.exists();
if (!exists) {
final index = cachesImagePaths.indexOf(imagePath);
if (index == -1) {
continue;
}
cachesImagePaths.removeAt(index);
if (replaceUnexistentImagesWith != null) {
cachesImagePaths.insert(
index,
replaceUnexistentImagesWith,
);
}
}
}
return cachesImagePaths;
}
}

@ -1,6 +1,6 @@
name: flutter_quill_extensions
description: Embed extensions for flutter_quill including image, video, formula and etc.
version: 9.0.1-dev
version: 9.0.0
homepage: https://github.com/singerdmx/flutter-quill/tree/master/flutter_quill_extensions/
repository: https://github.com/singerdmx/flutter-quill/tree/master/flutter_quill_extensions/
issue_tracker: https://github.com/singerdmx/flutter-quill/issues/

@ -2,6 +2,13 @@
All notable changes to this project will be documented in this file.
## 9.0.0
* This version is quite stable but it's not how we wanted to be, because the lack of time and there are not too many maintainers active, we decided to publish it, we might make a new breaking changes verion
## 9.0.1-dev.1
* Flutter Quill Extensions:
* Update `QuillImageUtilities` and fixining some bugs
## 9.0.1-dev
* Test new GitHub workflows

@ -1,6 +1,6 @@
name: flutter_quill_test
description: Test utilities for flutter_quill which includes methods to simplify interacting with the editor in test cases.
version: 9.0.1-dev
version: 9.0.0
homepage: https://github.com/singerdmx/flutter-quill/tree/master/flutter_quill_test/
repository: https://github.com/singerdmx/flutter-quill/tree/master/flutter_quill_test/
issue_tracker: https://github.com/singerdmx/flutter-quill/issues/

@ -1,6 +1,6 @@
name: flutter_quill
description: A rich text editor built for the modern Android, iOS, web and desktop platforms. It is the WYSIWYG editor and a Quill component for Flutter.
version: 9.0.1-dev
version: 9.0.0
homepage: https://1o24bbs.com/c/bulletjournal/108/
repository: https://github.com/singerdmx/flutter-quill/
issue_tracker: https://github.com/singerdmx/flutter-quill/issues/

@ -2,6 +2,13 @@
All notable changes to this project will be documented in this file.
## 9.0.0
* This version is quite stable but it's not how we wanted to be, because the lack of time and there are not too many maintainers active, we decided to publish it, we might make a new breaking changes verion
## 9.0.1-dev.1
* Flutter Quill Extensions:
* Update `QuillImageUtilities` and fixining some bugs
## 9.0.1-dev
* Test new GitHub workflows

@ -1,6 +1,6 @@
name: quill_html_converter
description: A extension for flutter_quill package to add support for dealing with conversion to/from html
version: 9.0.1-dev
version: 9.0.0
homepage: https://github.com/singerdmx/flutter-quill/tree/master/quill_html_converter/
repository: https://github.com/singerdmx/flutter-quill/tree/master/quill_html_converter/
issue_tracker: https://github.com/singerdmx/flutter-quill/issues/

@ -1 +1 @@
const version = '9.0.1-dev';
const version = '9.0.0';

Loading…
Cancel
Save