QuillKitController class

The editing brain of a QuillKit editor: a Document plus a TextSelection, with commands that funnel every edit through the document's rules and history.

The controller owns no clipboard logic and no widget references; those live in the injected services on scope and in the widget layer. It notifies its listeners exactly once per public operation.

Document ownership. The controller adopts the document it is given: it builds its own Document instance from the passed document's content, registry and rules (extended with what EditorScope.extensions contribute) and a controller-owned History. Edit through the controller API — edits made directly on the originally passed instance are not seen by this controller.

Inheritance

Constructors

QuillKitController({Document? document, List<EditorExtension> extensions = const <EditorExtension>[], TextSelection selection = const TextSelection.collapsed(offset: 0), bool readOnly = false})
Creates a controller over document (or a new empty document), registering every extension's attributes, rules and typing shortcuts, then attaching the extensions to the freshly built scope.

Properties

changes Stream<DocumentChange>
Broadcast stream of every change applied to the current document.
no setter
document Document
The document being edited. Replaceable; see the class docs for the adoption semantics of the setter.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
hasRedo bool
Whether redo would change the document.
no setter
hasUndo bool
Whether undo would change the document.
no setter
readOnly bool
Whether editing is disabled. The controller itself does not enforce this — widgets and actions consult it before mutating.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scope EditorScope
The per-instance services and registries of this editor.
latefinal
selection TextSelection
The current selection, always clamped to the document's bounds.
no setter
selectionDelta Delta
The current selection's content as an insert-only Delta fragment — what a rich copy should put on the clipboard. Interior newlines (and their line attributes) are included; the trailing newline of the last touched line only when the selection extends across it, so pasting the fragment back reproduces exactly what was selected. Empty when the selection is collapsed.
no setter
selectionStyle Style
The formatting shared by the whole selection, merged with any pending toggled style — what a toolbar should highlight.
no setter
typingShortcuts TypingShortcutEngine
The typing-autoformat engine ('# ' → header, 'x' → bold, ...). The registered extensions define the shortcut set (in registration order); a controller constructed with no extensions falls back to the full built-in default set so a bare controller stays usable on its own. The input layer invokes the engine after each committed insertion.
latefinal

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
breakHistoryGroup() → void
Forces the next local edit to start a new undo group, even when it happens within the history's merge interval.
clear() → void
Replaces the whole content with an empty document. The wipe goes through replaceText, so it is a single undoable operation.
dispose() → void
Detaches the extensions and closes the document. The controller must not be used afterwards.
override
format(int index, int len, Attribute<Object?> attribute) → void
Applies attribute to len positions starting at index, keeping the selection stable across changes the rules make. Notifies exactly once.
formatSelection(Attribute<Object?> attribute) → void
Toggles attribute on the current selection.
indentSelection({required bool increase}) → void
Increases (increase: true) or decreases the indent of every line touched by the selection by one level; level 0 removes the indent attribute. Notifies exactly once.
insert(Object data) → void
Inserts data (a String or an Embeddable) at the current selection, replacing it, and moves the caret after the insertion. Any pending toggled style is applied to the inserted text.
insertDelta(Delta fragment) → void
Pastes the insert-only fragment (may be multi-op and contain newlines and embeds) over the current selection as a single isolated history group, then puts the caret after the pasted content.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
redo() → void
Re-applies the most recently undone change group and restores the selection that followed it. Does nothing (and does not notify) when there is no redo.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
replaceText(int index, int len, Object data, TextSelection? selection) → void
Replaces len positions starting at index with data (a String or an Embeddable), applies any pending toggled style to inserted text, and moves the selection to selection (adjusted when the edit rules alter the change, clamped to the new bounds). Notifies exactly once.
runAsHistoryGroup(VoidCallback body) → void
Runs body as one isolated undo group: a single undo afterwards reverts everything body did — and nothing typed before it. Typing shortcuts use this so an autoformat reverts back to the plain text in one step.
toString() String
A string representation of this object.
inherited
undo() → void
Undoes the most recent change group and restores the selection that preceded it. Does nothing (and does not notify) when there is no undo.
updateSelection(TextSelection selection, ChangeSource source) → void
Moves the selection (clamped to the document bounds) and discards any pending toggled style. Notifies exactly once.

Operators

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