MarkdownEditorController class

Controller for Markdown source editing.

The controller wraps a TextEditingController, keeps a synchronized MarkdownDocumentEditor, and adds Markdown-aware editing commands used by SmoothMarkdownEditor.

Inheritance

Constructors

MarkdownEditorController({String text = '', TextEditingController? textController, ParserPluginRegistry? plugins, int historyLimit = _defaultHistoryLimit})
Creates a Markdown editor controller.

Properties

canRedo bool
Whether a redo step is available.
no setter
canUndo bool
Whether an undo step is available.
no setter
document MarkdownDocument
Current semantic Markdown document.
getter/setter pair
documentEditor MarkdownDocumentEditor
Semantic editable document state synchronized with textController.
latefinal
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
isDirty bool
Whether the current source differs from savedText.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
savedText String
Source text snapshot last marked as persisted by host code.
no setter
selectedText String
Currently selected Markdown source text.
no setter
selection TextSelection
Current text selection.
no setter
text String
Current Markdown source text.
getter/setter pair
textController TextEditingController
The underlying text editing controller.
final

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
applyBlockCommand(String blockId, MarkdownEditorCommand command) → void
Applies a semantic block command to blockId.
applyBlockCommandToDocumentSelection(MarkdownDocumentSelection selection, MarkdownEditorCommand command) bool
Applies a block command to a semantic document selection.
applyCommand(MarkdownEditorCommand command, {String? argument}) → void
Applies a Markdown editing command.
applyInlineCommand(String blockId, TextRange range, MarkdownEditorCommand command, {String? argument}) → void
Applies a semantic inline command to range inside blockId.
applyInlineCommandToDocumentSelection(MarkdownDocumentSelection selection, MarkdownEditorCommand command, {String? argument}) bool
Applies an inline command to a semantic document selection.
applyInlineCommandToListItemSelection(MarkdownListItemSelection selection, MarkdownEditorCommand command, {String? argument}) bool
Applies a basic inline command to a semantic list item selection.
applyInlineCommandToTableSelection(MarkdownTableCellSelection selection, MarkdownEditorCommand command, {String? argument}) bool
Applies a basic inline command to a semantic table cell selection.
canMoveBlock(String blockId, {required bool upward}) bool
Whether the top-level block containing blockId can move up or down.
canMoveBlockToIndex(String blockId, {required int targetIndex}) bool
Whether the top-level block containing blockId can move to targetIndex.
clearHistory() → void
Clears source undo and redo history.
clearTableSelection(MarkdownTableCellSelection selection) bool
Clears a semantic table cell selection without deleting rows or columns.
copyDocumentSelectionAsMarkdown(MarkdownDocumentSelection selection) String?
Serializes a semantic document selection as Markdown.
copyListItemSelectionAsMarkdown(MarkdownListItemSelection selection) String?
Serializes a semantic list item selection as Markdown.
copyTableSelectionAsTsv(MarkdownTableCellSelection selection) String?
Serializes a semantic table cell selection as TSV.
deleteDocumentSelection(MarkdownDocumentSelection selection) MarkdownSelectionTransactionResult?
Deletes a semantic document selection.
deleteListItemSelection(MarkdownListItemSelection selection) MarkdownSelectionTransactionResult?
Deletes a semantic list item selection.
deleteTable(String tableId) bool
Deletes a table block.
deleteTableColumn(String tableId, int columnIndex) bool
Deletes a table column.
deleteTableRow(String tableId, int rowIndex) bool
Deletes a table row.
dispose() → void
Discards any resources used by the object.
override
findMatches(String query, {bool caseSensitive = false}) List<TextRange>
Finds all text ranges matching query.
getSelectionMarkdown() String?
Returns the selected Markdown source, or null when the selection is empty.
insertMarkdown(String markdown) → void
Inserts markdown at the current selection.
insertMarkdownBlock(String markdown) → void
Inserts markdown as a separated block at the current selection.
insertTable({int rows = 3, int columns = 3}) → void
Inserts a table at the current source selection.
insertTableColumnAfter(String tableId, int columnIndex) bool
Inserts a table column after columnIndex.
insertTableColumnBefore(String tableId, int columnIndex) bool
Inserts a table column before columnIndex.
insertTableRowAfter(String tableId, int rowIndex) bool
Inserts a table row after rowIndex.
insertTableRowBefore(String tableId, int rowIndex) bool
Inserts a table row before rowIndex.
markSaved([String? savedText]) → void
Marks the current source, or savedText when provided, as persisted.
moveBlock(String blockId, {required bool upward, int selectionOffset = 0}) MarkdownSelectionTransactionResult?
Moves the top-level block containing blockId up or down.
moveBlockToIndex(String blockId, {required int targetIndex, int selectionOffset = 0}) MarkdownSelectionTransactionResult?
Moves the top-level block containing blockId to targetIndex.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
redo() bool
Reapplies the most recently undone source snapshot.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
replaceBlockWithMarkdown(String blockId, String markdown) MarkdownDocument?
Replaces a block with parsed Markdown blocks.
replaceDocumentSelectionWithMarkdown(MarkdownDocumentSelection selection, String markdown) MarkdownSelectionTransactionResult?
Replaces a semantic document selection with parsed Markdown.
replaceRange(TextRange range, String replacement, {TextSelection? selection}) → void
Replaces an arbitrary source range with replacement.
replaceSelection(String replacement, {int? selectionStart, int? selectionEnd}) → void
Replaces the current selection with replacement.
replaceTableCellText({required String tableId, required int rowIndex, required int columnIndex, required String text}) bool
Replaces a table cell's plain text.
runTransaction<T>(T transaction()) → T
Runs several source edits as one undoable transaction.
selectNextMatch(String query, {bool caseSensitive = false}) TextRange?
Selects the next match for query and returns it.
setTableColumnAlignment({required String tableId, required int columnIndex, required MarkdownTableAlignment? alignment}) bool
Sets a table column alignment.
toggleTableHeaderColumn(String tableId) bool
Toggles whether the first table column is a header.
toggleTableHeaderRow(String tableId) bool
Toggles whether the first table row is a header.
toString() String
A string representation of this object.
inherited
undo() bool
Restores the previous source snapshot.

Operators

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