Skip to content

Commit

Permalink
Merge branch 'singerdmx:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
oligazar authored Apr 16, 2024
2 parents 8b14bad + b547e28 commit 6da1481
Show file tree
Hide file tree
Showing 19 changed files with 67 additions and 34 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## 9.3.7
* Fix for keyboard jumping when switching focus from a TextField
* Toolbar button styling to reflect cursor position when running on desktops with keyboard to move care

## 9.3.6
* Add SK and update CS locales [#1796](https://github.com/singerdmx/flutter-quill/pull/1796)
* Fixes:
Expand Down
4 changes: 4 additions & 0 deletions dart_quill_delta/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## 9.3.7
* Fix for keyboard jumping when switching focus from a TextField
* Toolbar button styling to reflect cursor position when running on desktops with keyboard to move care

## 9.3.6
* Add SK and update CS locales [#1796](https://github.com/singerdmx/flutter-quill/pull/1796)
* Fixes:
Expand Down
2 changes: 1 addition & 1 deletion dart_quill_delta/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: dart_quill_delta
description: A port of quill-js-delta from typescript to dart
version: 9.3.6
version: 9.3.7
homepage: https://github.com/singerdmx/flutter-quill/tree/master/dart_quill_delta/
repository: https://github.com/singerdmx/flutter-quill/tree/master/dart_quill_delta/
issue_tracker: https://github.com/singerdmx/flutter-quill/issues/
Expand Down
4 changes: 4 additions & 0 deletions flutter_quill_extensions/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## 9.3.7
* Fix for keyboard jumping when switching focus from a TextField
* Toolbar button styling to reflect cursor position when running on desktops with keyboard to move care

## 9.3.6
* Add SK and update CS locales [#1796](https://github.com/singerdmx/flutter-quill/pull/1796)
* Fixes:
Expand Down
2 changes: 1 addition & 1 deletion flutter_quill_extensions/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_quill_extensions
description: Embed extensions for flutter_quill including image, video, formula and etc.
version: 9.3.6
version: 9.3.7
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/
Expand Down
4 changes: 4 additions & 0 deletions flutter_quill_test/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## 9.3.7
* Fix for keyboard jumping when switching focus from a TextField
* Toolbar button styling to reflect cursor position when running on desktops with keyboard to move care

## 9.3.6
* Add SK and update CS locales [#1796](https://github.com/singerdmx/flutter-quill/pull/1796)
* Fixes:
Expand Down
2 changes: 1 addition & 1 deletion flutter_quill_test/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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.3.6
version: 9.3.7
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/
Expand Down
6 changes: 1 addition & 5 deletions lib/src/models/documents/document.dart
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,7 @@ class Document {
return (res.node as Line).collectStyle(res.offset, len);
}
if (res.offset == 0) {
rangeStyle = (res.node as Line).collectStyle(res.offset, len);
return rangeStyle.removeAll({
for (final attr in rangeStyle.values)
if (attr.isInline) attr
});
return rangeStyle = (res.node as Line).collectStyle(res.offset, len);
}
rangeStyle = (res.node as Line).collectStyle(res.offset - 1, len);
final linkAttribute = rangeStyle.attributes[Attribute.link.key];
Expand Down
9 changes: 6 additions & 3 deletions lib/src/models/rules/insert.dart
Original file line number Diff line number Diff line change
Expand Up @@ -559,10 +559,13 @@ class PreserveInlineStylesRule extends InsertRule {
}

final itr = DeltaIterator(document);
final prev = itr.skip(len == 0 ? index : index + 1);
var prev = itr.skip(len == 0 ? index : index + 1);
if (prev == null ||
prev.data is! String ||
(prev.data as String).contains('\n')) {
(prev.data is String && (prev.data as String).endsWith('\n'))) {
prev = itr.next();
}

if (prev.data is! String) {
return null;
}

Expand Down
36 changes: 20 additions & 16 deletions lib/src/widgets/quill/quill_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -327,20 +327,19 @@ class QuillController extends ChangeNotifier {

if (textSelection != null) {
if (delta == null || delta.isEmpty) {
_updateSelection(textSelection, ChangeSource.local);
_updateSelection(textSelection);
} else {
final user = Delta()
..retain(index)
..insert(data)
..delete(len);
final positionDelta = getPositionDelta(user, delta);
_updateSelection(
textSelection.copyWith(
baseOffset: textSelection.baseOffset + positionDelta,
extentOffset: textSelection.extentOffset + positionDelta,
),
ChangeSource.local,
);
textSelection.copyWith(
baseOffset: textSelection.baseOffset + positionDelta,
extentOffset: textSelection.extentOffset + positionDelta,
),
insertNewline: data == '\n');
}
}

Expand Down Expand Up @@ -389,7 +388,7 @@ class QuillController extends ChangeNotifier {
baseOffset: change.transformPosition(selection.baseOffset),
extentOffset: change.transformPosition(selection.extentOffset));
if (selection != adjustedSelection) {
_updateSelection(adjustedSelection, ChangeSource.local);
_updateSelection(adjustedSelection);
}
if (shouldNotifyListeners) {
notifyListeners();
Expand Down Expand Up @@ -428,7 +427,7 @@ class QuillController extends ChangeNotifier {
}

void updateSelection(TextSelection textSelection, ChangeSource source) {
_updateSelection(textSelection, source);
_updateSelection(textSelection);
notifyListeners();
}

Expand All @@ -445,7 +444,7 @@ class QuillController extends ChangeNotifier {
),
);
if (selection != textSelection) {
_updateSelection(textSelection, source);
_updateSelection(textSelection);
}

notifyListeners();
Expand Down Expand Up @@ -479,18 +478,23 @@ class QuillController extends ChangeNotifier {
super.dispose();
}

void _updateSelection(TextSelection textSelection, ChangeSource source) {
void _updateSelection(TextSelection textSelection,
{bool insertNewline = false}) {
_selection = textSelection;
final end = document.length - 1;
_selection = selection.copyWith(
baseOffset: math.min(selection.baseOffset, end),
extentOffset: math.min(selection.extentOffset, end));
if (keepStyleOnNewLine) {
final style = getSelectionStyle();
final ignoredStyles = style.attributes.values.where(
(s) => !s.isInline || s.key == Attribute.link.key,
);
toggledStyle = style.removeAll(ignoredStyles.toSet());
if (insertNewline && selection.start > 0) {
final style = document.collectStyle(selection.start - 1, 0);
final ignoredStyles = style.attributes.values.where(
(s) => !s.isInline || s.key == Attribute.link.key,
);
toggledStyle = style.removeAll(ignoredStyles.toSet());
} else {
toggledStyle = const Style();
}
} else {
toggledStyle = const Style();
}
Expand Down
1 change: 1 addition & 0 deletions lib/src/widgets/toolbar/buttons/color/color_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ class QuillToolbarColorButtonState extends State<QuillToolbarColorButton> {
size: iconSize * iconButtonFactor,
),
onPressed: _showColorPicker,
afterPressed: afterButtonPressed,
);
}

Expand Down
7 changes: 6 additions & 1 deletion lib/src/widgets/toolbar/buttons/quill_icon_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ class QuillToolbarIconButton extends StatelessWidget {
if (isSelected) {
return IconButton.filled(
tooltip: tooltip,
onPressed: onPressed,
onPressed: onPressed != null
? () {
onPressed?.call();
afterPressed?.call();
}
: null,
icon: icon,
style: iconTheme?.iconButtonSelectedData?.style,
visualDensity: iconTheme?.iconButtonSelectedData?.visualDensity,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/widgets/toolbar/buttons/toggle_style_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class QuillToolbarToggleStyleButtonState

void _onPressed() {
_toggleAttribute();
options.afterButtonPressed?.call();
afterButtonPressed?.call();
}

@override
Expand All @@ -175,7 +175,7 @@ class QuillToolbarToggleStyleButtonState
options.fillColor,
_isToggled,
_toggleAttribute,
options.afterButtonPressed,
afterButtonPressed,
iconSize,
iconButtonFactor,
iconTheme,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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.3.6
version: 9.3.7
homepage: https://1o24bbs.com/c/bulletjournal/108/
repository: https://github.com/singerdmx/flutter-quill/
issue_tracker: https://github.com/singerdmx/flutter-quill/issues/
Expand Down
4 changes: 4 additions & 0 deletions quill_html_converter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## 9.3.7
* Fix for keyboard jumping when switching focus from a TextField
* Toolbar button styling to reflect cursor position when running on desktops with keyboard to move care

## 9.3.6
* Add SK and update CS locales [#1796](https://github.com/singerdmx/flutter-quill/pull/1796)
* Fixes:
Expand Down
2 changes: 1 addition & 1 deletion quill_html_converter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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.3.6
version: 9.3.7
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/
Expand Down
4 changes: 4 additions & 0 deletions quill_pdf_converter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## 9.3.7
* Fix for keyboard jumping when switching focus from a TextField
* Toolbar button styling to reflect cursor position when running on desktops with keyboard to move care

## 9.3.6
* Add SK and update CS locales [#1796](https://github.com/singerdmx/flutter-quill/pull/1796)
* Fixes:
Expand Down
2 changes: 1 addition & 1 deletion quill_pdf_converter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: quill_pdf_converter
description: A extension for flutter_quill package to add support for dealing with conversion to pdf
version: 9.3.6
version: 9.3.7
homepage: https://github.com/singerdmx/flutter-quill/tree/master/quill_pdf_converter/
repository: https://github.com/singerdmx/flutter-quill/tree/master/quill_pdf_converter/
issue_tracker: https://github.com/singerdmx/flutter-quill/issues/
Expand Down
2 changes: 1 addition & 1 deletion version.dart
Original file line number Diff line number Diff line change
@@ -1 +1 @@
const version = '9.3.6';
const version = '9.3.7';

0 comments on commit 6da1481

Please sign in to comment.