PreserveInlineStylesRule class

Makes typed text adopt the inline formatting around the caret, the way Quill (and every word processor) behaves: type after bold text and the new text is bold.

For a plain text insert (no newline in the data) the rule copies the inline-scope attributes of the character immediately before the insert position. At the start of a non-empty line it copies from the character after the caret instead, and on an empty line it borrows from the text preceding the blank line. The link attribute is never carried across a link's edge — typing at the boundary of a link must not extend it — while typing inside a link keeps the link intact.

When the insert replaces a range, the copied style comes from the first replaced character (including its link, matching Quill.js).

Attributes are classified through the document's AttributeRegistry, so third-party inline formats propagate exactly like the built-in ones. Inserts with nothing to copy return null and fall through to CatchAllInsertRule-style fallbacks.

Note that a controller's pending-toggle style is composed on top of what this rule produces, so an explicit toggle always wins for its own attribute while the other copied attributes remain.

Inheritance

Constructors

PreserveInlineStylesRule()
Creates the rule.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type RuleType
Which kind of edit intent this rule participates in.
no setteroverride

Methods

apply(Delta document, int index, {int? length, Object? data, Attribute<Object?>? attribute, required AttributeRegistry registry}) Delta?
Produces the change delta for the edit intent, or null when this rule does not apply.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited