diff --git a/frontend/app_flowy/assets/images/grid/field/url.svg b/frontend/app_flowy/assets/images/grid/field/url.svg
new file mode 100644
index 0000000000..f00f5c7aa2
--- /dev/null
+++ b/frontend/app_flowy/assets/images/grid/field/url.svg
@@ -0,0 +1,3 @@
+
diff --git a/frontend/app_flowy/assets/translations/en.json b/frontend/app_flowy/assets/translations/en.json
index 8fc9e90581..4e6c8f3420 100644
--- a/frontend/app_flowy/assets/translations/en.json
+++ b/frontend/app_flowy/assets/translations/en.json
@@ -160,6 +160,7 @@
"numberFieldName": "Numbers",
"singleSelectFieldName": "Select",
"multiSelectFieldName": "Multiselect",
+ "urlFieldName": "URL",
"numberFormat": " Number format",
"dateFormat": " Date format",
"includeTime": " Include time",
diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_service.dart b/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_service.dart
index 09b8bef584..68f8eada78 100644
--- a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_service.dart
+++ b/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/cell_service.dart
@@ -10,9 +10,9 @@ import 'package:flowy_sdk/protobuf/flowy-grid-data-model/grid.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-grid/cell_entities.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-grid/date_type_option.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-grid/selection_type_option.pb.dart';
+import 'package:flowy_sdk/protobuf/flowy-grid/url_type_option.pb.dart';
import 'package:flutter/foundation.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
-
import 'package:app_flowy/workspace/application/grid/cell/cell_listener.dart';
import 'package:app_flowy/workspace/application/grid/cell/select_option_service.dart';
import 'package:app_flowy/workspace/application/grid/field/field_service.dart';
diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/context_builder.dart b/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/context_builder.dart
index aad8137f2e..e4141c3e16 100644
--- a/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/context_builder.dart
+++ b/frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/context_builder.dart
@@ -3,6 +3,7 @@ part of 'cell_service.dart';
typedef GridCellContext = _GridCellContext;
typedef GridSelectOptionCellContext = _GridCellContext;
typedef GridDateCellContext = _GridCellContext;
+typedef GridURLCellContext = _GridCellContext;
class GridCellContextBuilder {
final GridCellCache _cellCache;
@@ -75,12 +76,25 @@ class GridCellContextBuilder {
cellDataLoader: cellDataLoader,
cellDataPersistence: CellDataPersistence(gridCell: _gridCell),
);
- default:
- throw UnimplementedError;
+
+ case FieldType.URL:
+ final cellDataLoader = GridCellDataLoader(
+ gridCell: _gridCell,
+ parser: URLCellDataParser(),
+ );
+ return GridURLCellContext(
+ gridCell: _gridCell,
+ cellCache: _cellCache,
+ cellDataLoader: cellDataLoader,
+ cellDataPersistence: CellDataPersistence(gridCell: _gridCell),
+ );
}
+ throw UnimplementedError;
}
}
+// T: the type of the CellData
+// D: the type of the data that will be save to disk
// ignore: must_be_immutable
class _GridCellContext extends Equatable {
final GridCell gridCell;
@@ -94,7 +108,8 @@ class _GridCellContext extends Equatable {
late final ValueNotifier _cellDataNotifier;
bool isListening = false;
VoidCallback? _onFieldChangedFn;
- Timer? _delayOperation;
+ Timer? _loadDataOperation;
+ Timer? _saveDataOperation;
_GridCellContext({
required this.gridCell,
@@ -124,7 +139,7 @@ class _GridCellContext extends Equatable {
FieldType get fieldType => gridCell.field.fieldType;
- VoidCallback? startListening({required void Function(T) onCellChanged}) {
+ VoidCallback? startListening({required void Function(T?) onCellChanged}) {
if (isListening) {
Log.error("Already started. It seems like you should call clone first");
return null;
@@ -148,7 +163,7 @@ class _GridCellContext extends Equatable {
}
onCellChangedFn() {
- onCellChanged(_cellDataNotifier.value as T);
+ onCellChanged(_cellDataNotifier.value);
if (cellDataLoader.config.reloadOnCellChanged) {
_loadData();
@@ -175,13 +190,26 @@ class _GridCellContext extends Equatable {
return _fieldService.getFieldTypeOptionData(fieldType: fieldType);
}
- Future