Skip to content

Commit

Permalink
Major update 6 (#1461)
Browse files Browse the repository at this point in the history
  • Loading branch information
EchoEllet authored Oct 23, 2023
1 parent 94819c2 commit 45b43fa
Show file tree
Hide file tree
Showing 37 changed files with 1,525 additions and 1,092 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [7.10.0]
- **Breaking change**: `QuillToolbar.basic()` can be accessed from `QuillToolbar()` directly and the old `QuillToolbar` can be accessed from `QuillBaseToolbar`
- The Quill editor and toolbar configurations are now refactored in one single class for each one
- After changing one of the checkbox list values the controller will not request the keyboard focus by default
- We have moved the configurations of the toolbar and the editor directly into the widget but we are still using inherited widgets internally
- Fixes to some of the code after the refactoring

## [7.9.0]
- Buttons Improvemenets
- Refactor all the button configurations that used in `QuillToolbar.basic()` but there are still few lefts
Expand Down
164 changes: 91 additions & 73 deletions example/lib/pages/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: avoid_redundant_argument_values

import 'dart:async';
import 'dart:convert';
import 'dart:io' show File, Platform;
Expand Down Expand Up @@ -186,12 +188,47 @@ class _HomePageState extends State<HomePage> {
QuillEditor get quillEditor {
if (kIsWeb) {
return QuillEditor(
scrollController: ScrollController(),
scrollable: true,
focusNode: _focusNode,
scrollController: ScrollController(),
configurations: QuillEditorConfigurations(
placeholder: 'Add content',
readOnly: false,
scrollable: true,
autoFocus: false,
expands: false,
padding: EdgeInsets.zero,
onTapUp: (details, p1) {
return _onTripleClickSelection();
},
customStyles: const DefaultStyles(
h1: DefaultTextBlockStyle(
TextStyle(
fontSize: 32,
color: Colors.black,
height: 1.15,
fontWeight: FontWeight.w300,
),
VerticalSpacing(16, 0),
VerticalSpacing(0, 0),
null),
sizeSmall: TextStyle(fontSize: 9),
),
embedBuilders: [
...defaultEmbedBuildersWeb,
TimeStampEmbedBuilderWidget()
],
),
);
}
return QuillEditor(
configurations: QuillEditorConfigurations(
placeholder: 'Add content',
readOnly: false,
autoFocus: false,
enableSelectionToolbar: isMobile(),
expands: false,
padding: EdgeInsets.zero,
onImagePaste: _onImagePaste,
onTapUp: (details, p1) {
return _onTripleClickSelection();
},
Expand All @@ -207,87 +244,79 @@ class _HomePageState extends State<HomePage> {
VerticalSpacing(0, 0),
null),
sizeSmall: TextStyle(fontSize: 9),
subscript: TextStyle(
fontFamily: 'SF-UI-Display',
fontFeatures: [FontFeature.subscripts()],
),
superscript: TextStyle(
fontFamily: 'SF-UI-Display',
fontFeatures: [FontFeature.superscripts()],
),
),
embedBuilders: [
...defaultEmbedBuildersWeb,
...FlutterQuillEmbeds.builders(),
TimeStampEmbedBuilderWidget()
],
);
}
return QuillEditor(
),
scrollController: ScrollController(),
scrollable: true,
focusNode: _focusNode,
autoFocus: false,
enableSelectionToolbar: isMobile(),
expands: false,
padding: EdgeInsets.zero,
onImagePaste: _onImagePaste,
onTapUp: (details, p1) {
return _onTripleClickSelection();
},
customStyles: const DefaultStyles(
h1: DefaultTextBlockStyle(
TextStyle(
fontSize: 32,
color: Colors.black,
height: 1.15,
fontWeight: FontWeight.w300,
),
VerticalSpacing(16, 0),
VerticalSpacing(0, 0),
null),
sizeSmall: TextStyle(fontSize: 9),
subscript: TextStyle(
fontFamily: 'SF-UI-Display',
fontFeatures: [FontFeature.subscripts()],
),
superscript: TextStyle(
fontFamily: 'SF-UI-Display',
fontFeatures: [FontFeature.superscripts()],
),
),
embedBuilders: [
...FlutterQuillEmbeds.builders(),
TimeStampEmbedBuilderWidget()
],
);
}

QuillToolbar get quillToolbar {
if (kIsWeb) {
return QuillToolbar.basic(
embedButtons: FlutterQuillEmbeds.buttons(
onImagePickCallback: _onImagePickCallback,
webImagePickImpl: _webImagePickImpl,
return QuillToolbar(
configurations: QuillToolbarConfigurations(
embedButtons: FlutterQuillEmbeds.buttons(
onImagePickCallback: _onImagePickCallback,
webImagePickImpl: _webImagePickImpl,
),
buttonOptions: QuillToolbarButtonOptions(
base: QuillToolbarBaseButtonOptions(
afterButtonPressed: _focusNode.requestFocus,
),
),
),
showAlignmentButtons: true,
// afterButtonPressed: _focusNode.requestFocus,
);
}
if (_isDesktop()) {
return QuillToolbar.basic(
embedButtons: FlutterQuillEmbeds.buttons(
onImagePickCallback: _onImagePickCallback,
filePickImpl: openFileSystemPickerForDesktop,
return QuillToolbar(
configurations: QuillToolbarConfigurations(
embedButtons: FlutterQuillEmbeds.buttons(
onImagePickCallback: _onImagePickCallback,
filePickImpl: openFileSystemPickerForDesktop,
),
showAlignmentButtons: true,
buttonOptions: QuillToolbarButtonOptions(
base: QuillToolbarBaseButtonOptions(
afterButtonPressed: _focusNode.requestFocus,
),
),
),
showAlignmentButtons: true,
// afterButtonPressed: _focusNode.requestFocus,
);
}
return QuillToolbar.basic(
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,
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,
),
showAlignmentButtons: true,
buttonOptions: QuillToolbarButtonOptions(
base: QuillToolbarBaseButtonOptions(
afterButtonPressed: _focusNode.requestFocus,
),
),
),
showAlignmentButtons: true,
// afterButtonPressed: _focusNode.requestFocus,
);
}
Expand Down Expand Up @@ -320,17 +349,6 @@ class _HomePageState extends State<HomePage> {
return SafeArea(
child: QuillProvider(
configurations: QuillConfigurations(
toolbarConfigurations: QuillToolbarConfigurations(
buttonOptions: QuillToolbarButtonOptions(
base: QuillToolbarBaseButtonOptions(
afterButtonPressed: _focusNode.requestFocus,
),
)),
editorConfigurations: const QuillEditorConfigurations(
placeholder: 'Add content',
// ignore: avoid_redundant_argument_values
readOnly: false,
),
controller: _controller,
),
child: Column(
Expand Down
26 changes: 16 additions & 10 deletions example/lib/pages/read_only_page.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: avoid_redundant_argument_values

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_quill/extensions.dart';
Expand Down Expand Up @@ -35,24 +37,28 @@ class _ReadOnlyPageState extends State<ReadOnlyPage> {

Widget _buildContent(BuildContext context, QuillController? controller) {
var quillEditor = QuillEditor(
configurations: QuillEditorConfigurations(
expands: false,
padding: EdgeInsets.zero,
embedBuilders: FlutterQuillEmbeds.builders(),
scrollable: true,
autoFocus: true,
),
scrollController: ScrollController(),
scrollable: true,
focusNode: _focusNode,
autoFocus: true,
// readOnly: !_edit,
expands: false,
padding: EdgeInsets.zero,
embedBuilders: FlutterQuillEmbeds.builders(),
);
if (kIsWeb) {
quillEditor = QuillEditor(
configurations: QuillEditorConfigurations(
autoFocus: true,
expands: false,
padding: EdgeInsets.zero,
embedBuilders: defaultEmbedBuildersWeb,
scrollable: true,
),
scrollController: ScrollController(),
scrollable: true,
focusNode: _focusNode,
autoFocus: true,
expands: false,
padding: EdgeInsets.zero,
embedBuilders: defaultEmbedBuildersWeb,
);
}
return Padding(
Expand Down
14 changes: 9 additions & 5 deletions example/lib/widgets/demo_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,18 @@ class _DemoScaffoldState extends State<DemoScaffold> {

QuillToolbar get quillToolbar {
if (_isDesktop()) {
return QuillToolbar.basic(
embedButtons: FlutterQuillEmbeds.buttons(
filePickImpl: openFileSystemPickerForDesktop,
return QuillToolbar(
configurations: QuillToolbarConfigurations(
embedButtons: FlutterQuillEmbeds.buttons(
filePickImpl: openFileSystemPickerForDesktop,
),
),
);
}
return QuillToolbar.basic(
embedButtons: FlutterQuillEmbeds.buttons(),
return QuillToolbar(
configurations: QuillToolbarConfigurations(
embedButtons: FlutterQuillEmbeds.buttons(),
),
);
}

Expand Down
1 change: 1 addition & 0 deletions lib/flutter_quill.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export 'src/widgets/editor/editor.dart';
export 'src/widgets/embeds.dart';
export 'src/widgets/link.dart' show LinkActionPickerDelegate, LinkMenuAction;
export 'src/widgets/style_widgets/style_widgets.dart';
export 'src/widgets/toolbar/base_toolbar.dart';
export 'src/widgets/toolbar/enum.dart';
export 'src/widgets/toolbar/toolbar.dart';
export 'src/widgets/utils/provider.dart';
Loading

0 comments on commit 45b43fa

Please sign in to comment.