Merge branch 'master' of github.com:singerdmx/flutter-quill into rebuild-editor-when-keyboard-is-already-open

pull/111/head
Till Friebe 4 years ago
commit 1268f14054
  1. 3
      CHANGELOG.md
  2. 6
      README.md
  3. 3
      analysis_options.yaml
  4. 3
      example/lib/pages/home_page.dart
  5. 2
      example/lib/widgets/field.dart
  6. 5
      example/test/widget_test.dart
  7. 1
      lib/models/rules/rule.dart
  8. 36
      lib/widgets/controller.dart
  9. 69
      lib/widgets/toolbar.dart
  10. 4
      pubspec.yaml

@ -1,3 +1,6 @@
## [1.1.3]
* Update example folder.
## [1.1.2] ## [1.1.2]
* Add pedantic. * Add pedantic.

@ -74,6 +74,10 @@ The `QuillToolbar` class lets you customise which formatting options are availab
For web development, use `flutter config --enable-web` for flutter and use [ReactQuill] for React. For web development, use `flutter config --enable-web` for flutter and use [ReactQuill] for React.
## Migrate Zefyr Data
Check out [code](https://github.com/jwehrle/zefyr_quill_convert) and [doc](https://docs.google.com/document/d/1FUSrpbarHnilb7uDN5J5DDahaI0v1RMXBjj4fFSpSuY/edit?usp=sharing).
--- ---
<img width="484" alt="1" src="https://user-images.githubusercontent.com/122956/103142422-9bb19c80-46b7-11eb-83e4-dd0538a9236e.png"> <img width="484" alt="1" src="https://user-images.githubusercontent.com/122956/103142422-9bb19c80-46b7-11eb-83e4-dd0538a9236e.png">
@ -86,4 +90,4 @@ For web development, use `flutter config --enable-web` for flutter and use [Reac
[FlutterQuill]: https://pub.dev/packages/flutter_quill [FlutterQuill]: https://pub.dev/packages/flutter_quill
[ReactQuill]: https://github.com/zenoamaro/react-quill [ReactQuill]: https://github.com/zenoamaro/react-quill
[Slack Group]: https://join.slack.com/t/bulletjournal1024/shared_invite/zt-fys7t9hi-ITVU5PGDen1rNRyCjdcQ2g [Slack Group]: https://join.slack.com/t/bulletjournal1024/shared_invite/zt-fys7t9hi-ITVU5PGDen1rNRyCjdcQ2g
[Sample Page]: https://github.com/singerdmx/flutter-quill/blob/master/app/lib/pages/home_page.dart [Sample Page]: https://github.com/singerdmx/flutter-quill/blob/master/example/lib/pages/home_page.dart

@ -5,3 +5,6 @@ analyzer:
undefined_prefixed_name: ignore undefined_prefixed_name: ignore
omit_local_variable_types: ignore omit_local_variable_types: ignore
unsafe_html: ignore unsafe_html: ignore
linter:
rules:
- avoid_print

@ -79,12 +79,11 @@ class _HomePageState extends State<HomePage> {
.getSelectionStyle() .getSelectionStyle()
.attributes .attributes
.keys .keys
.contains("bold")) { .contains('bold')) {
_controller! _controller!
.formatSelection(Attribute.clone(Attribute.bold, null)); .formatSelection(Attribute.clone(Attribute.bold, null));
} else { } else {
_controller!.formatSelection(Attribute.bold); _controller!.formatSelection(Attribute.bold);
print("not bold");
} }
} }
}, },

@ -105,11 +105,11 @@ class _QuillFieldState extends State<QuillField> {
children: [ children: [
child, child,
Visibility( Visibility(
child: widget.toolbar!,
visible: _focused, visible: _focused,
maintainSize: true, maintainSize: true,
maintainAnimation: true, maintainAnimation: true,
maintainState: true, maintainState: true,
child: widget.toolbar!,
), ),
], ],
); );

@ -7,10 +7,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:app/main.dart';
import '../lib/main.dart';
// import 'package:app/main.dart';
void main() { void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async { testWidgets('Counter increments smoke test', (WidgetTester tester) async {

@ -61,7 +61,6 @@ class Rules {
final result = rule.apply(delta, index, final result = rule.apply(delta, index,
len: len, data: data, attribute: attribute); len: len, data: data, attribute: attribute);
if (result != null) { if (result != null) {
print('Rule $rule applied');
return result..trim(); return result..trim();
} }
} catch (e) { } catch (e) {

@ -78,12 +78,7 @@ class QuillController extends ChangeNotifier {
Delta? delta; Delta? delta;
if (len > 0 || data is! String || data.isNotEmpty) { if (len > 0 || data is! String || data.isNotEmpty) {
try { delta = document.replace(index, len, data);
delta = document.replace(index, len, data);
} catch (e) {
print('document.replace failed: $e');
rethrow;
}
bool shouldRetainDelta = toggledStyle.isNotEmpty && bool shouldRetainDelta = toggledStyle.isNotEmpty &&
delta.isNotEmpty && delta.isNotEmpty &&
delta.length <= 2 && delta.length <= 2 &&
@ -112,23 +107,18 @@ class QuillController extends ChangeNotifier {
if (delta == null || delta.isEmpty) { if (delta == null || delta.isEmpty) {
_updateSelection(textSelection, ChangeSource.LOCAL); _updateSelection(textSelection, ChangeSource.LOCAL);
} else { } else {
try { Delta user = Delta()
Delta user = Delta() ..retain(index)
..retain(index) ..insert(data)
..insert(data) ..delete(len);
..delete(len); int positionDelta = getPositionDelta(user, delta);
int positionDelta = getPositionDelta(user, delta); _updateSelection(
_updateSelection( textSelection.copyWith(
textSelection.copyWith( baseOffset: textSelection.baseOffset + positionDelta,
baseOffset: textSelection.baseOffset + positionDelta, extentOffset: textSelection.extentOffset + positionDelta,
extentOffset: textSelection.extentOffset + positionDelta, ),
), ChangeSource.LOCAL,
ChangeSource.LOCAL, );
);
} catch (e) {
print('getPositionDelta or getPositionDelta error: $e');
rethrow;
}
} }
} }
notifyListeners(); notifyListeners();

@ -4,7 +4,6 @@ import 'package:file_picker/file_picker.dart';
import 'package:filesystem_picker/filesystem_picker.dart'; import 'package:filesystem_picker/filesystem_picker.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_colorpicker/flutter_colorpicker.dart'; import 'package:flutter_colorpicker/flutter_colorpicker.dart';
import 'package:flutter_quill/models/documents/attribute.dart'; import 'package:flutter_quill/models/documents/attribute.dart';
import 'package:flutter_quill/models/documents/nodes/embed.dart'; import 'package:flutter_quill/models/documents/nodes/embed.dart';
@ -520,46 +519,25 @@ class _ImageButtonState extends State<ImageButton> {
final File file = File(pickedFile.path); final File file = File(pickedFile.path);
// We simply return the absolute path to selected file. return widget.onImagePickCallback!(file);
try {
String url = await widget.onImagePickCallback!(file);
print('Image uploaded and its url is $url');
return url;
} catch (error) {
print('Upload image error $error');
}
return null;
} }
Future<String?> _pickImageWeb() async { Future<String?> _pickImageWeb() async {
try { _paths = (await FilePicker.platform.pickFiles(
_paths = (await FilePicker.platform.pickFiles( type: _pickingType,
type: _pickingType, allowMultiple: false,
allowMultiple: false, allowedExtensions: (_extension?.isNotEmpty ?? false)
allowedExtensions: (_extension?.isNotEmpty ?? false) ? _extension?.replaceAll(' ', '').split(',')
? _extension?.replaceAll(' ', '').split(',') : null,
: null, ))
)) ?.files;
?.files;
} on PlatformException catch (e) {
print('Unsupported operation' + e.toString());
} catch (ex) {
print(ex);
}
var _fileName = var _fileName =
_paths != null ? _paths!.map((e) => e.name).toString() : '...'; _paths != null ? _paths!.map((e) => e.name).toString() : '...';
if (_paths != null) { if (_paths != null) {
File file = File(_fileName); File file = File(_fileName);
// We simply return the absolute path to selected file. // We simply return the absolute path to selected file.
try { return widget.onImagePickCallback!(file);
String url = await widget.onImagePickCallback!(file);
print('Image uploaded and its url is $url');
return url;
} catch (error) {
print('Upload image error $error');
}
return null;
} else { } else {
// User canceled the picker // User canceled the picker
} }
@ -567,23 +545,16 @@ class _ImageButtonState extends State<ImageButton> {
} }
Future<String> _pickImageDesktop() async { Future<String> _pickImageDesktop() async {
try { var filePath = await FilesystemPicker.open(
var filePath = await FilesystemPicker.open( context: context,
context: context, rootDirectory: await getApplicationDocumentsDirectory(),
rootDirectory: await getApplicationDocumentsDirectory(), fsType: FilesystemType.file,
fsType: FilesystemType.file, fileTileSelectMode: FileTileSelectMode.wholeTile,
fileTileSelectMode: FileTileSelectMode.wholeTile, );
); if (filePath != null && filePath.isEmpty) return '';
if (filePath != null && filePath.isEmpty) return '';
final File file = File(filePath!);
final File file = File(filePath!); return widget.onImagePickCallback!(file);
String url = await widget.onImagePickCallback!(file);
print('Image uploaded and its url is $url');
return url;
} catch (error) {
print('Upload image error $error');
}
return '';
} }
@override @override

@ -1,6 +1,6 @@
name: flutter_quill name: flutter_quill
description: A rich text editor description: A rich text editor supporting mobile and web
version: 1.1.2 version: 1.1.3
#author: bulletjournal #author: bulletjournal
homepage: https://bulletjournal.us/home/index.html homepage: https://bulletjournal.us/home/index.html
repository: https://github.com/singerdmx/flutter-quill repository: https://github.com/singerdmx/flutter-quill

Loading…
Cancel
Save