Prechádzať zdrojové kódy

chore: update operation documentation

appflowy 2 rokov pred
rodič
commit
2661a6a4ae

+ 4 - 6
frontend/.vscode/settings.json

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

+ 4 - 8
frontend/app_flowy/packages/flowy_editor/lib/operation/transaction.dart

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

+ 4 - 10
frontend/app_flowy/packages/flowy_editor/lib/operation/transaction_builder.dart

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

+ 1 - 1
frontend/app_flowy/packages/flowy_editor/lib/undo_manager.dart

@@ -7,7 +7,7 @@ import 'package:flowy_editor/operation/transaction.dart';
 import 'package:flowy_editor/editor_state.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.
 /// Otherwise, the operations should be added to a new [HistoryItem].
 class HistoryItem extends LinkedListEntry<HistoryItem> {