FluentDocument class

Inheritance

Constructors

FluentDocument({Root? content, FluentPluginRegistry? registry})
FluentDocument.fromJson(Map<String, dynamic> json, {FluentPluginRegistry? registry})
Creates a FluentDocument from a JSON map (result of jsonDecode). Supports both the new format (with "nodes" and "settings") and the legacy format (Root JSON directly).
factory

Properties

allStyleHooks List<RenderStyleHook>
All rendering style hooks active on this document, combining document-level styleHooks and registered plugin hooks (including suggestion rendering provided by FluentSuggestionPlugin via its styleHook override).
no setter
authorName String
getter/setter pair
cachedCursorContainerId String?
O(1) when pre-computed, falls back to O(1) cache-miss otherwise.
no setter
cachedSelection ↔ dynamic
getter/setter pair
cachedSelectionKey String?
Cached resolved selection keyed by cursor state. Populated by resolveSelectionFromCursor in handler_helpers.dart so multiple widgets (toolbar, font selector, font size selector) reuse the same ResolvedSelection instead of re-resolving O(n) each time.
getter/setter pair
canRedo bool
Checks if redo is possible
no setter
canUndo bool
Checks if undo is possible
no setter
caretStops List<CaretStop>
no setter
clipboardPayload String?
Internal clipboard payload (JSON serialized) with preserved formatting.
getter/setter pair
commentProvider CommentProvider?
Optional comment plugin. When set, the editor will display comment highlights, a sidebar, and allow adding / managing comments.
getter/setter pair
containerOrder List<String>
no setter
content Root
no setter
contentVersion int
no setter
cursor Cursor
no setter
cursorOnlyChange bool
True while listeners are being notified for a cursor-only change. Widgets that do expensive work on every document change can check this flag and skip irrelevant updates (e.g. toolbar style scan, full tree rebuild) when the document text / structure did not change.
no setter
dialogPresenter DialogPresenter
no setter
documentLanguage String
Document-level language (BCP-47 code). Defaults to the language selected in DocumentLanguageController or the system locale.
getter/setter pair
editorFocusNode FocusNode
FocusNode for the editing area. The toolbar can request focus after an interaction (e.g., font selection) by calling requestEditorFocus.
final
eventHandler EventHandler
no setter
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
imeHandler FluentTextInputHandler
final
isFullDocumentDirty bool
Returns true if all nodes are considered dirty (e.g. full document refresh).
no setter
isResizingImage bool
True when an image resize handle is being dragged. Used to prevent text selection from interfering with image resize.
getter/setter pair
isResizingTable bool
True when a table column/row/table resize handle is being dragged. Used to prevent text selection from interfering with table resize.
getter/setter pair
labels FluentEditorLabels?
Localization labels for the user interface.
getter/setter pair
logicalLines List<LogicalLine>
no setter
paragraphRegistry ParagraphRegistry
no setter
pendingColor String?
Active text color for collapsed cursor. Null = auto.
getter/setter pair
pendingFontFamily String
Active font family for collapsed cursor (persistent like Word). When the user types, new text inherits this font.
getter/setter pair
pendingFontSize double
Active font size for collapsed cursor.
getter/setter pair
pendingHighlightColor String?
Active highlight color for collapsed cursor. Null = none.
getter/setter pair
pendingIndent int
Active indentation for collapsed cursor. Used when creating a new paragraph.
getter/setter pair
pendingLineHeight double
Active line height for collapsed cursor.
getter/setter pair
pendingSpacingAfter double
Spacing after paragraph in points.
getter/setter pair
pendingSpacingBefore double
Spacing before paragraph in points.
getter/setter pair
pendingStyle ParagraphStyle
Active style for collapsed cursor. Used when creating a new paragraph.
getter/setter pair
pendingStyles List<String>
Active inline styles for collapsed cursor (bold, italic, underline).
getter/setter pair
pendingTextAlign String
Active text alignment for collapsed cursor (left, center, right). Used when creating a new paragraph.
getter/setter pair
registry FluentPluginRegistry
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selectionManager SelectionManager
no setter
stopsByContainer Map<String, List<CaretStop>>
no setter
styleHooks List<RenderStyleHook>
Active document-level rendering style hooks.
no setter
suggestionProvider SuggestionProvider?
Optional suggestion plugin / tracked changes provider.
getter/setter pair
suggestionStyleHook SuggestionStyleHook
Hook configuration for suggestion addition and deletion styles.
getter/setter pair
undoRedoManager UndoRedoManager
no setter

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
addStyleHook(RenderStyleHook hook) → void
Registers a rendering styleHook on this document.
clearUndoRedo() → void
Clears undo/redo stacks
cursorOnlyUpdate() → void
Notifies listeners for a cursor/selection-only change that does NOT mutate the document structure or text. Crucially it does NOT invalidate the content-derived caches (node index, caret-stop rail), so repeated arrow navigation reuses them instead of rebuilding O(n) on every press.
dispose() → void
Discards any resources used by the object.
inherited
findLogicalContainerCached(String fragmentId) InlineContainerNode?
Returns the inline container node for fragmentId using the cached container-id + node index. O(1) on cache hit, O(n) on first lookup. Handlers should prefer this over findLogicalContainer(root, fragmentId).
findLogicalContainerId(String fragmentId) String?
Returns the id of the inline container that directly contains the fragment (Paragraph inside a ListItem/Cell, or standalone Paragraph).
findParentCached(String childId) String?
O(1) lookup of the parent id of childId. Returns null if childId is the root or not found.
flattenContainer(FNode container) List<(Fragment, int, int)>
Returns the flattened fragment list for container with global offsets, using the document cache when available.
forceNewAction({String description = 'New action'}) → void
Forces creation of a new action (not grouped)
getGlobalOffsetInParagraph(String paragraphId, String fragmentId, int localOffset) int?
Calculates the global offset within paragraphId for a local (fragmentId, localOffset) pair. Returns null if the fragment is not found.
getKeyForNode(String nodeId) GlobalKey<State<StatefulWidget>>
getSelectionRangeForNode(String nodeId) → ({String endFrag, int endOff, String startFrag, int startOff})?
invalidateNodeIndex() → void
Marks the id→node index as stale so it gets rebuilt on next lookup.
isNodeDirty(String nodeId) bool
Returns true if nodeId was marked dirty by the last notifyDocumentChanged or updateContent call. If no specific dirty nodes were set, returns true for all IDs (backward-compatible behaviour).
isNodeSelected(String nodeId) bool
load(List<FNode> data) → void
loadContent(Root newContent) → void
Loads new content into the document, resetting cursor and selection.
manageEvent(KeyEvent event) bool
nodeById(String id) FNode?
Returns the node with the given id in O(1) using a cached index. The index is rebuilt lazily (single tree walk) only when the document has changed since the last lookup.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyDocumentChanged({Set<String>? affectedIds}) → void
Notifies document listeners that the content changed. Use this after undo/redo where updateContent must NOT be called (it would create a new undo record).
notifyListeners() → void
Call all the registered listeners.
inherited
notifyTextMutation(String paragraphId, int fromOffset, int delta) → void
Notifies the comment provider and registered plugins that text in paragraphId was mutated.
redo() bool
Executes redo of the last undone action
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
removeStyleHook(RenderStyleHook hook) → void
Unregisters a rendering styleHook from this document.
replaceRegistry(FluentPluginRegistry registry) → void
Replaces the plugin registry with registry.
requestEditorFocus() → void
requestMobileKeyboardFocus(BuildContext context) → void
Opens the virtual keyboard via the IME handler.
resolveCaretX(CaretStop stop) double
Caret coordinate resolver for vertical navigation.
resolveCaretY(CaretStop stop) double
saveState({String description = 'Document change', bool forceNewAction = false}) → void
Begins capturing the old document state for a delta-based undo. The delta is committed automatically by updateContent after the mutation, producing a minimal undo record that stores only the changed top-level nodes (50-100x smaller than a full snapshot).
syncPendingFontWithCursor() → void
toJson() String
topLevelIndexOf(String fragmentOrNodeId) int
O(1) lookup of the top-level index for a node id, or -1 if not found. Uses findLogicalContainerId to resolve fragments to their container.
toString() String
A string representation of this object.
inherited
undo() bool
Executes undo of the last action
updateContent({Set<String>? affectedIds, String? targetNodeId}) → void
updateParentCache(String childId, String? parentId) → void
Manually update the parent cache for a newly inserted node/fragment.

Operators

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