SuperEditor class

A rich text editor that displays a document in a single-column layout.

A SuperEditor brings together the key pieces needed to display a user-editable document:

  • document model
  • document editor
  • document layout
  • document interaction (tapping, dragging, typing, scrolling)
  • document composer (current selection, and styles to apply to next character)

A SuperEditor determines the visual styling by way of:

  • stylesheet, which applies styles throughout the document layout, including text styles and block padding.
  • componentStyles, which applies targeted styles to specific components in the document layout.
  • componentBuilders, which produce every visual component within the document layout.
  • selectionStyles, which dictates the color of the caret and the color of selected text and components

A SuperEditor determines how a physical keyboard interacts with the document by way of keyboardActions.

A SuperEditor works with software keyboards through the platform's Input Method Engine (IME). To customize how SuperEditor works with the IME, see imePolicies, imeConfiguration, and softwareKeyboardController.

Deeper explanation of core artifacts:

The document model is responsible for holding the content of a document in a structured and query-able manner.

The document editor is responsible for mutating the document structure.

Document layout is responsible for positioning and rendering the various visual components in the document. It's also responsible for linking logical document nodes to visual document components to facilitate user interactions like tapping and dragging.

Document interaction is responsible for taking appropriate actions in response to user taps, drags, and key presses.

Document composer is responsible for owning document selection and the current text entry mode.

Inheritance

Constructors

SuperEditor({Key? key, FocusNode? focusNode, required DocumentEditor editor, DocumentComposer? composer, ScrollController? scrollController, GlobalKey<State<StatefulWidget>>? documentLayoutKey, Stylesheet? stylesheet, List<SingleColumnLayoutStylePhase> customStylePhases = const [], List<ComponentBuilder>? componentBuilders, SelectionStyles? selectionStyle, SuperEditorSelectionPolicies selectionPolicies = const SuperEditorSelectionPolicies(), TextInputSource? inputSource, SoftwareKeyboardController? softwareKeyboardController, SuperEditorImePolicies imePolicies = const SuperEditorImePolicies(), SuperEditorImeConfiguration imeConfiguration = const SuperEditorImeConfiguration(), DeltaTextInputClientDecorator? imeOverrides, List<DocumentKeyboardAction>? keyboardActions, DocumentGestureMode? gestureMode, SuperEditorContentTapDelegateFactory? contentTapDelegateFactory = superEditorLaunchLinkTapHandlerFactory, Color? androidHandleColor, WidgetBuilder? androidToolbarBuilder, Color? iOSHandleColor, WidgetBuilder? iOSToolbarBuilder, CustomClipper<Rect> createOverlayControlsClipper(BuildContext overlayContext)?, List<DocumentLayerBuilder> documentOverlayBuilders = const [DefaultCaretOverlayBuilder()], DebugPaintConfig debugPaint = const DebugPaintConfig(), bool autofocus = false, MagnifierAndToolbarController? overlayController})
Creates a Super Editor with common (but configurable) defaults for visual components, text styles, and user interaction.

Properties

androidHandleColor Color?
Color of the text selection drag handles on Android.
final
androidToolbarBuilder WidgetBuilder?
Builder that creates a floating toolbar when running on Android.
final
autofocus bool
Whether or not the SuperEditor should autofocus
final
componentBuilders List<ComponentBuilder>
Priority list of widget factories that create instances of each visual component displayed in the document layout, e.g., paragraph component, image component, horizontal rule component, etc.
final
composer DocumentComposer?
Owns the editor's current selection, the current attributions for text input, and other transitive editor configurations.
final
contentTapDelegateFactory SuperEditorContentTapDelegateFactory?
Factory that creates a ContentTapDelegate, which is given an opportunity to respond to taps on content before the editor, itself.
final
createOverlayControlsClipper CustomClipper<Rect> Function(BuildContext overlayContext)?
Creates a clipper that applies to overlay controls, like drag handles, magnifiers, and popover toolbars, preventing the overlay controls from appearing outside the given clipping region.
final
customStylePhases List<SingleColumnLayoutStylePhase>
Custom style phases that are added to the standard style phases.
final
debugPaint DebugPaintConfig
Paints some extra visual ornamentation to help with debugging.
final
documentLayoutKey GlobalKey<State<StatefulWidget>>?
GlobalKey that's bound to the DocumentLayout within this SuperEditor.
final
documentOverlayBuilders List<DocumentLayerBuilder>
Layers that are displayed on top of the document layout, aligned with the location and size of the document layout.
final
editor DocumentEditor
Contains a Document and alters that document as desired.
final
focusNode FocusNode?
FocusNode for the entire SuperEditor.
final
gestureMode DocumentGestureMode?
The SuperEditor gesture mode, e.g., mouse or touch.
final
hashCode int
The hash code for this object.
no setterinherited
imeConfiguration SuperEditorImeConfiguration
Preferences for how the platform IME should look and behave during editing.
final
imeOverrides DeltaTextInputClientDecorator?
Overrides for IME actions.
final
imePolicies SuperEditorImePolicies
Policies that dictate when and how SuperEditor should interact with the platform IME, such as automatically opening the software keyboard when SuperEditor's selection changes.
final
inputSource TextInputSource?
The SuperEditor input source, e.g., keyboard or Input Method Engine.
final
iOSHandleColor Color?
Color of the text selection drag handles on iOS.
final
iOSToolbarBuilder WidgetBuilder?
Builder that creates a floating toolbar when running on iOS.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
keyboardActions List<DocumentKeyboardAction>
All actions that this editor takes in response to key events, e.g., text entry, newlines, character deletion, copy, paste, etc.
final
overlayController MagnifierAndToolbarController?
Shows, hides, and positions a floating toolbar and magnifier.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollController ScrollController?
The ScrollController that governs this SuperEditor's scroll offset.
final
selectionPolicies SuperEditorSelectionPolicies
Policies that determine how selection is modified by other factors, such as gaining or losing focus.
final
selectionStyles SelectionStyles
Styles applied to selected content.
final
softwareKeyboardController SoftwareKeyboardController?
Opens and closes the software keyboard.
final
stylesheet Stylesheet
Style rules applied through the document presentation.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() SuperEditorState
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

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