flutter-quill
flutter-quill copied to clipboard
[Mobile] or [Desktop] Entering text in the amid link
It's currently possible to enter text amid link. For example, if there's a link "quill" to https://github.com/singerdmx/flutter-quill, then one can move the cursor after "qu", type something (e.g., "test"), and the link will be split to two identical links: "qu" and "ill" with the text "test" between them.
This behavior is not in line with other formatting options. For example, if "quill" word above were bold (not link), the whole "qutestill" word would also be bold.
Hi, is this still an issue?
Hi, That's a bit counterintuitive but obviously not a highest priority issue.
class EditLinkRule extends InsertRule {
const EditLinkRule();
@override
Delta? applyRule(
Delta document,
int index, {
int? len,
Object? data,
Attribute<dynamic>? attribute,
}) {
final delta = Delta();
final itr = DeltaIterator(document);
final before = itr.skip(index), after = itr.next();
if (before == null) return null;
if (before.hasAttribute(Attribute.link.key) &&
after.hasAttribute(Attribute.link.key)) {
delta
..retain(index + (len ?? 0))
..insert(data, before.attributes);
return delta;
}
return null;
}
}
and then
document.setCustomRules([
const EditLinkRule(),
]);