From 900d0f2489ed2c731b52ae8594af80da617df1a4 Mon Sep 17 00:00:00 2001 From: Xin Yao Date: Thu, 22 Apr 2021 22:40:01 -0700 Subject: [PATCH] Fix: Indented position not holding while editing --- CHANGELOG.md | 3 +++ lib/models/documents/nodes/line.dart | 17 +++++++++++------ pubspec.yaml | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8937de42..d96c8386 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [1.2.1] +* Indented position not holding while editing. + ## [1.2.0] * Fix image button cancel causes crash. diff --git a/lib/models/documents/nodes/line.dart b/lib/models/documents/nodes/line.dart index ec933b52..c34a8ed8 100644 --- a/lib/models/documents/nodes/line.dart +++ b/lib/models/documents/nodes/line.dart @@ -208,18 +208,23 @@ class Line extends Container { _unwrap(); } else if (blockStyle != parentStyle) { _unwrap(); - final block = Block()..applyAttribute(blockStyle); - _wrap(block); - block.adjust(); + _applyBlockStyles(newStyle); } // else the same style, no-op. } else if (blockStyle.value != null) { // Only wrap with a new block if this is not an unset - final block = Block()..applyAttribute(blockStyle); - _wrap(block); - block.adjust(); + _applyBlockStyles(newStyle); } } + void _applyBlockStyles(Style newStyle) { + var block = Block(); + for (final style in newStyle.getBlocksExceptHeader().values) { + block = block..applyAttribute(style); + } + _wrap(block); + block.adjust(); + } + /// Wraps this line with new parent [block]. /// /// This line can not be in a [Block] when this method is called. diff --git a/pubspec.yaml b/pubspec.yaml index 93bf71be..5e87f6d7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_quill description: A rich text editor supporting mobile and web (Demo App @ bulletjournal.us) -version: 1.2.0 +version: 1.2.1 #author: bulletjournal homepage: https://bulletjournal.us/home/index.html repository: https://github.com/singerdmx/flutter-quill