Replies: 2 comments
-
I got the same problem as you. You can add listener in Controller for fix this problem temporarily. |
Beta Was this translation helpful? Give feedback.
0 replies
-
@phuongtinhbien So you mean i could save the current cursor position on text change and than reposition it on the listener after the text edit change happend? Im not sure if i understand this correctly, but it seems i only get 1 event, the one after the text is already changed. Or can you provide some sample ? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
My issue is about Mobile, i didn't try my code on any other Platform besides Android and IOS.
I tried to adjust the Editor behavior when editing links. The normal behavior when adding a letter inside the links seems to be that the link splits at the location of the letter and both parts of the link keep the Link to the old URL target.
Our customers don't like this behavior so tried to use custom rules to reevaluate the link when an letter is added. If the link is still valid i will create one new link and remove the old one. When the new target is invalid i will remove the old one and replace it with a text.
During this development i noticed that deleting and inserting into the same delta seems to result into a wrong cursor position. To be specific if i remove text the cursor wont move at all as long as there is still text remaining after the current position, so basically the index is identical to before. If i insert text afterwards the cursor does move resulting in a wrong position.
Sample Code
`import 'package:flutter_quill/flutter_quill.dart';
import 'package:flutter_quill/models/rules/insert.dart';
import 'package:moin/helper/helper.dart';
class QuillLinkCustomInsertRule extends InsertRule {
const QuillLinkCustomInsertRule();
@OverRide
Delta? applyRule(Delta document, int index, {int? len, Object? data, Attribute? attribute}) {
}
}`
Expectations:
I would expect the cursor to move only 1 place if only 1 character is inserted. Since i delete and insert nearly same number of letters.
Solutions:
I couldn't find a direct way to fix this issue, the fact that nearly all classes use private constructors makes it kind of hard to try solutions using inheritance. However i did try to overwrite the length of the insert operation with 0 which doesn't help. The order of operations for the delete and insert part doesn't seem to matter for this.
I have the same issue using my custom delete rule which basically does the same as the above code just for removing characters. I can add the code if it helps.
Beta Was this translation helpful? Give feedback.
All reactions