chore: update operation documentation

This commit is contained in:
appflowy 2022-07-24 10:14:51 +08:00
parent d71d954330
commit 2661a6a4ae
4 changed files with 13 additions and 25 deletions

View File

@ -2,23 +2,21 @@
"[dart]": { "[dart]": {
"editor.formatOnSave": true, "editor.formatOnSave": true,
"editor.formatOnType": true, "editor.formatOnType": true,
"editor.rulers": [ "editor.rulers": [80],
120
],
"editor.selectionHighlight": false, "editor.selectionHighlight": false,
"editor.suggest.snippetsPreventQuickSuggestions": false, "editor.suggest.snippetsPreventQuickSuggestions": false,
"editor.suggestSelection": "first", "editor.suggestSelection": "first",
"editor.tabCompletion": "onlySnippets", "editor.tabCompletion": "onlySnippets",
"editor.wordBasedSuggestions": false "editor.wordBasedSuggestions": false,
}, },
"svgviewer.enableautopreview": true, "svgviewer.enableautopreview": true,
"svgviewer.previewcolumn": "Active", "svgviewer.previewcolumn": "Active",
"svgviewer.showzoominout": true, "svgviewer.showzoominout": true,
"editor.wordWrapColumn": 120, "editor.wordWrapColumn": 80,
"editor.minimap.maxColumn": 140, "editor.minimap.maxColumn": 140,
"prettier.printWidth": 140, "prettier.printWidth": 140,
"editor.wordWrap": "wordWrapColumn", "editor.wordWrap": "wordWrapColumn",
"dart.lineLength": 120, "dart.lineLength": 80,
"files.associations": { "files.associations": {
"*.log.*": "log" "*.log.*": "log"
}, },

View File

@ -3,19 +3,15 @@ import 'package:flutter/material.dart';
import 'package:flowy_editor/document/selection.dart'; import 'package:flowy_editor/document/selection.dart';
import './operation.dart'; import './operation.dart';
/// This class to use to store the **changes** /// A [Transaction] has a list of [Operation] objects that will be applied
/// will be applied to the editor. /// to the editor. It is an immutable class and used to store and transmit.
/// ///
/// This class is immutable version the the class /// If you want to build a new [Transaction], use [TransactionBuilder] directly.
/// [[Transaction]]. Is used to stored and
/// transmit. If you want to build the transaction,
/// use [[Transaction]] directly.
/// ///
/// There will be several ways to consume the transaction: /// There will be several ways to consume the transaction:
/// 1. Apply to the state to update the UI. /// 1. Apply to the state to update the UI.
/// 2. Send to the backend to store and do operation transforming. /// 2. Send to the backend to store and do operation transforming.
/// 3. Stored by the UndoManager to implement redo/undo. /// 3. Used by the UndoManager to implement redo/undo.
///
@immutable @immutable
class Transaction { class Transaction {
final UnmodifiableListView<Operation> operations; final UnmodifiableListView<Operation> operations;

View File

@ -11,16 +11,10 @@ import 'package:flowy_editor/document/selection.dart';
import './operation.dart'; import './operation.dart';
import './transaction.dart'; import './transaction.dart';
/// /// A [TransactionBuilder] is used to build the transaction from the state.
/// This class is used to /// It will save make a snapshot of the cursor selection state automatically.
/// build the transaction from the state. /// The cursor can be resoted if the transaction is undo.
///
/// This class automatically save the
/// cursor from the state.
///
/// When the transaction is undo, the
/// cursor can be restored.
///
class TransactionBuilder { class TransactionBuilder {
final List<Operation> operations = []; final List<Operation> operations = [];
EditorState state; EditorState state;

View File

@ -7,7 +7,7 @@ import 'package:flowy_editor/operation/transaction.dart';
import 'package:flowy_editor/editor_state.dart'; import 'package:flowy_editor/editor_state.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
/// This class contains operations committed by users. /// A [HistoryItem] contains list of operations committed by users.
/// If a [HistoryItem] is not sealed, operations can be added sequentially. /// If a [HistoryItem] is not sealed, operations can be added sequentially.
/// Otherwise, the operations should be added to a new [HistoryItem]. /// Otherwise, the operations should be added to a new [HistoryItem].
class HistoryItem extends LinkedListEntry<HistoryItem> { class HistoryItem extends LinkedListEntry<HistoryItem> {