|
@@ -156,13 +156,11 @@ class PreserveInlineStylesRule extends InsertRule {
|
156
|
156
|
if (previous == null || previous.data.contains('\n')) return null;
|
157
|
157
|
|
158
|
158
|
final attributes = previous.attributes;
|
|
159
|
+ final hasHighLight = (attributes != null && attributes.containsKey(NotusAttribute.highlight.key));
|
|
160
|
+
|
159
|
161
|
final hasLink =
|
160
|
162
|
(attributes != null && attributes.containsKey(NotusAttribute.link.key));
|
161
|
|
- final hasHighLight = (attributes != null && attributes.containsKey(NotusAttribute.highlight.key));
|
162
|
|
- if (hasHighLight) {
|
163
|
|
- attributes.remove(NotusAttribute.highlight.key);
|
164
|
|
- }
|
165
|
|
- if (!hasLink) {
|
|
163
|
+ if (!hasLink && !hasHighLight) {
|
166
|
164
|
return Delta()
|
167
|
165
|
..retain(index)
|
168
|
166
|
..insert(text, attributes);
|
|
@@ -172,28 +170,32 @@ class PreserveInlineStylesRule extends InsertRule {
|
172
|
170
|
// Link style should NOT be preserved on the boundaries.
|
173
|
171
|
var noLinkAttributes = previous.attributes;
|
174
|
172
|
noLinkAttributes.remove(NotusAttribute.link.key);
|
|
173
|
+ noLinkAttributes.remove(NotusAttribute.highlight.key);
|
|
174
|
+
|
175
|
175
|
final noLinkResult = Delta()
|
176
|
176
|
..retain(index)
|
177
|
177
|
..insert(text, noLinkAttributes.isEmpty ? null : noLinkAttributes);
|
178
|
|
- final next = iter.next();
|
179
|
|
- if (next == null) {
|
180
|
|
- // Nothing after us, we are not inside link-styled fragment.
|
181
|
|
- return noLinkResult;
|
182
|
|
- }
|
183
|
|
- final nextAttributes = next.attributes ?? <String, dynamic>{};
|
184
|
|
- if (!nextAttributes.containsKey(NotusAttribute.link.key)) {
|
185
|
|
- // Next fragment is not styled as link.
|
186
|
|
- return noLinkResult;
|
187
|
|
- }
|
188
|
|
- // We must make sure links are identical in previous and next operations.
|
189
|
|
- if (attributes[NotusAttribute.link.key] ==
|
190
|
|
- nextAttributes[NotusAttribute.link.key]) {
|
191
|
|
- return Delta()
|
192
|
|
- ..retain(index)
|
193
|
|
- ..insert(text, attributes);
|
194
|
|
- } else {
|
195
|
|
- return noLinkResult;
|
196
|
|
- }
|
|
178
|
+ return noLinkResult;
|
|
179
|
+
|
|
180
|
+ // final next = iter.next();
|
|
181
|
+ // if (next == null) {
|
|
182
|
+ // // Nothing after us, we are not inside link-styled fragment.
|
|
183
|
+ // return noLinkResult;
|
|
184
|
+ // }
|
|
185
|
+ // final nextAttributes = next.attributes ?? <String, dynamic>{};
|
|
186
|
+ // if (!nextAttributes.containsKey(NotusAttribute.link.key)) {
|
|
187
|
+ // // Next fragment is not styled as link.
|
|
188
|
+ // return noLinkResult;
|
|
189
|
+ // }
|
|
190
|
+ // // We must make sure links are identical in previous and next operations.
|
|
191
|
+ // if (attributes[NotusAttribute.link.key] ==
|
|
192
|
+ // nextAttributes[NotusAttribute.link.key]) {
|
|
193
|
+ // return Delta()
|
|
194
|
+ // ..retain(index)
|
|
195
|
+ // ..insert(text, attributes);
|
|
196
|
+ // } else {
|
|
197
|
+ // return noLinkResult;
|
|
198
|
+ // }
|
197
|
199
|
}
|
198
|
200
|
}
|
199
|
201
|
|