Closed CatHood0 closed 3 months ago
Rules are a mysterious black box that do things that are useful but work in mysterious ways (I am trying to be polite here as I usually end-up scratching my head to figure out what they are doing!). Also, rules may interact in unexpected ways, so you may want to try to isolate your rule by disabling all the other rules - or calling your rule first and not return null (null return allows the other rules to execute).
..insert('\n', {"align":"center","indent": 2})
This might be causing a problem. Indenting does not appear to be working correctly. Indenting is correct for left-align. Indenting has no effect on right aligned text (BUG?). Indenting center alignment appears to shift in a way that is not obvious and might be buggy. Can you avoid the indenting and see if it solves the problem?
document compose has a big warning
/// Composes [change] Delta into this document.
///
/// Use this method with caution as it does not apply heuristic rules to the
/// [change].
///
/// It is callers responsibility to ensure that the [change] conforms to
/// the document model semantics and can be composed with the current state
/// of this document.
///
/// In case the [change] is invalid, behavior of this method is unspecified.
The assert at line 418 indicates compose failed, presumably you are trying to do something that the document model semantics does not like.
In these situations, I usually take the example app with the empty option and use hard coding to pre-stuff the empty document with the deltas that I want to end up with. I can then see how it is rendered. This would confirm that the deltas are valid.
You could also place a breakpoint on Line 414 where compose is called and then step into the code to see why the compose fails. What is weird is that the catch is not triggered so the call to compose is returning something other than the root deltas.
I will try to take another look at the details of your rule, but I wanted to give you some feedback quickly.
This might be causing a problem. Indenting does not appear to be working correctly. Indenting is correct for left-align. Indenting has no effect on right aligned text (BUG?). Indenting center alignment appears to shift in a way that is not obvious and might be buggy. Can you avoid the indenting and see if it solves the problem?
I will take a look about it. And yeah, i saw that indent works weird when alignment attribute is applied to the line.
In these situations, I usually take the example app with the empty option and use hard coding to pre-stuff the empty document with the deltas that I want to end up with. I can then see how it is rendered. This would confirm that the deltas are valid.
Thanks, that was useful. I'll try your suggestion.
@AtlasAutocode i already notice what is the issue.
This part of the code has a relevant issue: a nullable value.
formatterDelta.insert('\n', {
'align': sceneScriptElement.paragraph.alignment,
'line-height': _getLineHeight(sceneScriptElement.paragraph.lineSpacing),
'indent': sceneScriptElement.paragraph.spaceBefore == 0 ? null : sceneScriptElement.paragraph.spaceBefore,
});
If you pass a null value to any key into the attributes map, compose operation will failure. But, if you put a non null value, or directly remove null values from the map, compose operation will end successfully. Thanks for take care about my issue.
Sounds good and makes sense. null value attributes seem to be used internally to flag that an attribute should be removed. Which suggests that quill does not want null value attributes in the actual deltas.
I looked at the indenting issue. On Microsoft Word, center aligned indenting appears to be half the spacing of left alignment. Right aligned text does NOT indent. So, I am calling flutter-quill behavior correct and not a bug (even though is does seem weird). I am not going to touch RTL!
Is there an existing issue for this?
Short description
I'm trying to create a rule that is quite similar to
AutoFormatMultipleLinksRule
, however, it needs the whole line to be able to correctly match the regex pattern and allow me to apply any custom implementation on my part. However, there seems to be a problem when composing theDocument
with the newly generatedDelta
.The problem
When I try to insert my new line now formatted (this is something that already comes in another implementation of my project) with some block styles.
Initially, I use a Delta like this for testing:
The
Rule
should (when inserting the following data) format the insert with the text: "INT. SCENE - DA" with some attributes in block and add the last text.Such that:
However, no matter what I do, I am not able to solve an error when
composing
theDocument
.@AtlasAutocode since you know how
Rules
work much better than me, how could I solve this, or do you have any suggestions? This would help me a lot as it would also allow me to understand more about this part and add more documentation to the project.This is the
Test
that i using for:In any case, here is the rule I am using:
Rule
class:BaseScriptRule
class: