From 2661a6a4ae441f999fb7a9faac41f8992e6e18c4 Mon Sep 17 00:00:00 2001 From: appflowy Date: Sun, 24 Jul 2022 10:14:51 +0800 Subject: [PATCH] chore: update operation documentation --- frontend/.vscode/settings.json | 10 ++++------ .../flowy_editor/lib/operation/transaction.dart | 12 ++++-------- .../lib/operation/transaction_builder.dart | 14 ++++---------- .../packages/flowy_editor/lib/undo_manager.dart | 2 +- 4 files changed, 13 insertions(+), 25 deletions(-) diff --git a/frontend/.vscode/settings.json b/frontend/.vscode/settings.json index 2f5e152d62..d1732c5231 100644 --- a/frontend/.vscode/settings.json +++ b/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" }, diff --git a/frontend/app_flowy/packages/flowy_editor/lib/operation/transaction.dart b/frontend/app_flowy/packages/flowy_editor/lib/operation/transaction.dart index 3de528e868..85bc43f537 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/operation/transaction.dart +++ b/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 operations; diff --git a/frontend/app_flowy/packages/flowy_editor/lib/operation/transaction_builder.dart b/frontend/app_flowy/packages/flowy_editor/lib/operation/transaction_builder.dart index 6fca48f230..319002bd45 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/operation/transaction_builder.dart +++ b/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 operations = []; EditorState state; diff --git a/frontend/app_flowy/packages/flowy_editor/lib/undo_manager.dart b/frontend/app_flowy/packages/flowy_editor/lib/undo_manager.dart index d47ec2359a..5b543f03a1 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/undo_manager.dart +++ b/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 {