2021-11-10 14:46:59 +08:00
|
|
|
import 'dart:async';
|
|
|
|
import 'package:dartz/dartz.dart';
|
|
|
|
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
2021-12-14 18:04:51 +08:00
|
|
|
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
|
2022-10-13 23:29:37 +08:00
|
|
|
import 'package:flowy_sdk/protobuf/flowy-document/protobuf.dart';
|
2022-10-22 21:57:44 +08:00
|
|
|
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
2021-11-10 14:46:59 +08:00
|
|
|
|
2022-02-28 23:45:17 -05:00
|
|
|
class ShareService {
|
2022-10-13 23:29:37 +08:00
|
|
|
Future<Either<ExportDataPB, FlowyError>> export(
|
2022-10-22 21:57:44 +08:00
|
|
|
ViewPB view, ExportType type) {
|
|
|
|
var payload = ExportPayloadPB.create()
|
|
|
|
..viewId = view.id
|
|
|
|
..exportType = type
|
|
|
|
..documentVersion = DocumentVersionPB.V1;
|
2021-11-10 14:46:59 +08:00
|
|
|
|
2022-10-22 21:57:44 +08:00
|
|
|
return DocumentEventExportDocument(payload).send();
|
2021-11-10 14:46:59 +08:00
|
|
|
}
|
2022-01-31 09:49:05 +08:00
|
|
|
|
2022-10-22 21:57:44 +08:00
|
|
|
Future<Either<ExportDataPB, FlowyError>> exportText(ViewPB view) {
|
|
|
|
return export(view, ExportType.Text);
|
2022-01-31 09:49:05 +08:00
|
|
|
}
|
|
|
|
|
2022-10-22 21:57:44 +08:00
|
|
|
Future<Either<ExportDataPB, FlowyError>> exportMarkdown(ViewPB view) {
|
|
|
|
return export(view, ExportType.Markdown);
|
2022-01-31 09:49:05 +08:00
|
|
|
}
|
|
|
|
|
2022-10-22 21:57:44 +08:00
|
|
|
Future<Either<ExportDataPB, FlowyError>> exportURL(ViewPB view) {
|
|
|
|
return export(view, ExportType.Link);
|
2022-01-31 09:49:05 +08:00
|
|
|
}
|
2021-11-10 14:46:59 +08:00
|
|
|
}
|