mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-19 15:06:53 +00:00

* feat: update editor * feat: integrate new editor * feat: integrate the document2 into folder2 * feat: integrate the new editor * chore: cargo fix * chore: active document feature for flowy-error * feat: convert the editor action to collab action * feat: migrate the grid and board * feat: migrate the callout block * feat: migrate the divider * chore: migrate the callout and math equation * feat: migrate the code block * feat: add shift + enter command in code block * feat: support tab and shift+tab in code block * fix: cursor error after inserting divider * feat: migrate the grid and board * feat: migrate the emoji picker * feat: migrate openai * feat: integrate floating toolbar * feat: migrate the smart editor * feat: migrate the cover * feat: add option block action * chore: implement block selection and delete option * feat: support background color * feat: dismiss color picker afer setting color * feat: migrate the cover block * feat: resize the font * chore: cutomsize the padding * chore: wrap the option button with ignore widget * feat: customize the heading style * chore: optimize the divider line height * fix: the option button can't dismiss * ci: rust test * chore: flutter analyze * fix: code block selection * fix: dismiss the emoji picker after selecting one * chore: optimize the transaction adapter * fix: can't save the new content * feat: show export page when some errors happen * feat: implement get_view_data for document --------- Co-authored-by: nathan <nathan@appflowy.io>
53 lines
1.7 KiB
Dart
53 lines
1.7 KiB
Dart
import 'package:dartz/dartz.dart';
|
|
import 'package:appflowy_backend/dispatch/dispatch.dart';
|
|
|
|
import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';
|
|
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
|
import 'package:appflowy_backend/protobuf/flowy-document2/entities.pb.dart';
|
|
|
|
class DocumentService {
|
|
// unused now.
|
|
Future<Either<FlowyError, Unit>> createDocument({
|
|
required ViewPB view,
|
|
}) async {
|
|
final canOpen = await openDocument(view: view);
|
|
if (canOpen.isRight()) {
|
|
return const Right(unit);
|
|
}
|
|
final payload = CreateDocumentPayloadPBV2()..documentId = view.id;
|
|
final result = await DocumentEvent2CreateDocument(payload).send();
|
|
return result.swap();
|
|
}
|
|
|
|
Future<Either<FlowyError, DocumentDataPB2>> openDocument({
|
|
required ViewPB view,
|
|
}) async {
|
|
// set the latest view
|
|
await FolderEventSetLatestView(ViewIdPB(value: view.id)).send();
|
|
|
|
final payload = OpenDocumentPayloadPBV2()..documentId = view.id;
|
|
final result = await DocumentEvent2OpenDocument(payload).send();
|
|
return result.swap();
|
|
}
|
|
|
|
Future<Either<FlowyError, Unit>> closeDocument({
|
|
required ViewPB view,
|
|
}) async {
|
|
final payload = CloseDocumentPayloadPBV2()..documentId = view.id;
|
|
final result = await DocumentEvent2CloseDocument(payload).send();
|
|
return result.swap();
|
|
}
|
|
|
|
Future<Either<FlowyError, Unit>> applyAction({
|
|
required String documentId,
|
|
required Iterable<BlockActionPB> actions,
|
|
}) async {
|
|
final payload = ApplyActionPayloadPBV2(
|
|
documentId: documentId,
|
|
actions: actions,
|
|
);
|
|
final result = await DocumentEvent2ApplyAction(payload).send();
|
|
return result.swap();
|
|
}
|
|
}
|