Closed mmasdivins closed 5 days ago
Same problem with ordered. node-quill-converter. I have delta generated by this lib:
[
{
"insert": "asd as dasd asd\nasd asd "
},
{
"insert": "dfg",
"attributes": {
"bold": true
}
},
{
"insert": " dsfg sdfg sdfg \ngsdfg sdfg "
},
{
"insert": "dfgdfg",
"attributes": {
"link": "https://singularity-app.com/"
}
},
{
"insert": "\ndf\n\n"
},
{
"insert": "sgdf gdsf gsdfg sd\nfg \ndsfg sdfg \ndsfg\n sdf\ng sdfg\n",
"attributes": {
"list": "ordered"
}
}
]
And when I try to insert it to flutter-quill I receive error:
'package:flutter_quill/src/models/documents/nodes/leaf.dart': Failed assertion: line 30 pos 12: 'value.isInline || value.isIgnored || value.isEmpty': Unable to apply Style to leaf: {Attribute{key: list, scope: AttributeScope.BLOCK, value: ordered}}
Hi @freshtechtips Is there any news for this issue?
any fixes for this issue ? (doc.last.data as String).endsWith('\n')': is not true
Indeed there is a problem with version 10.0.0, I have the stable version of flutter 3.24.0, I didn't try too hard to understand. I did this in document.dart in line 419 :
before :
assert((doc.last.data as String).endsWith('\n'));
After :
try { assert((doc.last.data as String).endsWith('\n')); } catch (Ex) { print("Problème : $Ex"); }
The essential works on my side
I can make a couple of comments:
{
"attributes":{
"list":"ordered", <- causes problem - remove this line, it is applied in the next delta
"italic":true,
"color":"#800080"
},
"insert":"llista numerada 1"
},
{
"attributes":{
"list":"ordered"
},
"insert":"\n"
},
I think a basic question is: When should errors be reported by assert and when should errors simply be ignored?
In this case, deltas are being generated by an outside source that is not generating the deltas correctly for flutter-quill.
I am not an expert in deltas but reading: Quill delta format
To solve this, Quill "adds" a newline to all documents and always ends Deltas with "\n".
// Hello World on two lines
const content = [
{ text: "Hello" },
{ text: "\n", attributes: { align: "center" } },
{ text: "World" },
{ text: "\n", attributes: { align: "right" } } // Deltas must end with newline
];
and other parts of the document show that applying block attributes to inline text causes problems.
Hello, I was trying to load a delta to the document. The delta is generated using node-quill-converter that converts an HTML to delta. I have two problems loading the delta generated. The first one:
Failed assertion: line 357 pos 12: '(doc.last.data as String).endsWith('\n')': is not true.
It expects that the last operation of the delta is '\n' if I add it, it works fine, but I don't know why it have to end with a '\n' to work.
The second error:
Failed assertion: line 30 pos 12: 'value.isInline || value.isIgnored || value.isEmpty': Unable to apply Style to leaf: {Attribute{key: list, scope: AttributeScope.BLOCK, value: ordered}, Attribute{key: color, scope: AttributeScope.INLINE, value: #800080}}
On leaf.dart if I comment the lines on the applyStyle function:Works fine and the document is loaded without a problem. It throws an error because the attribute scope is BLOCK, why does only assert if is INLINE?
Here is the delta that I was using:
Note that I added the last '\n'.