|  | @@ -101,17 +101,6 @@ pub(crate) async fn update_field_handler(
 | 
											
												
													
														|  |      Ok(())
 |  |      Ok(())
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -#[tracing::instrument(level = "trace", skip(data, manager), err)]
 |  | 
 | 
											
												
													
														|  | -pub(crate) async fn insert_field_handler(
 |  | 
 | 
											
												
													
														|  | -    data: Data<InsertFieldPayloadPB>,
 |  | 
 | 
											
												
													
														|  | -    manager: AppData<Arc<GridManager>>,
 |  | 
 | 
											
												
													
														|  | -) -> Result<(), FlowyError> {
 |  | 
 | 
											
												
													
														|  | -    let params: InsertFieldParams = data.into_inner().try_into()?;
 |  | 
 | 
											
												
													
														|  | -    let editor = manager.get_grid_editor(¶ms.grid_id)?;
 |  | 
 | 
											
												
													
														|  | -    let _ = editor.insert_field(params).await?;
 |  | 
 | 
											
												
													
														|  | -    Ok(())
 |  | 
 | 
											
												
													
														|  | -}
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |  #[tracing::instrument(level = "trace", skip(data, manager), err)]
 |  |  #[tracing::instrument(level = "trace", skip(data, manager), err)]
 | 
											
												
													
														|  |  pub(crate) async fn update_field_type_option_handler(
 |  |  pub(crate) async fn update_field_type_option_handler(
 | 
											
												
													
														|  |      data: Data<UpdateFieldTypeOptionPayloadPB>,
 |  |      data: Data<UpdateFieldTypeOptionPayloadPB>,
 | 
											
										
											
												
													
														|  | @@ -140,27 +129,25 @@ pub(crate) async fn delete_field_handler(
 | 
											
												
													
														|  |  pub(crate) async fn switch_to_field_handler(
 |  |  pub(crate) async fn switch_to_field_handler(
 | 
											
												
													
														|  |      data: Data<EditFieldPayloadPB>,
 |  |      data: Data<EditFieldPayloadPB>,
 | 
											
												
													
														|  |      manager: AppData<Arc<GridManager>>,
 |  |      manager: AppData<Arc<GridManager>>,
 | 
											
												
													
														|  | -) -> DataResult<FieldTypeOptionDataPB, FlowyError> {
 |  | 
 | 
											
												
													
														|  | 
 |  | +) -> Result<(), FlowyError> {
 | 
											
												
													
														|  |      let params: EditFieldParams = data.into_inner().try_into()?;
 |  |      let params: EditFieldParams = data.into_inner().try_into()?;
 | 
											
												
													
														|  |      let editor = manager.get_grid_editor(¶ms.grid_id)?;
 |  |      let editor = manager.get_grid_editor(¶ms.grid_id)?;
 | 
											
												
													
														|  |      editor
 |  |      editor
 | 
											
												
													
														|  |          .switch_to_field_type(¶ms.field_id, ¶ms.field_type)
 |  |          .switch_to_field_type(¶ms.field_id, ¶ms.field_type)
 | 
											
												
													
														|  |          .await?;
 |  |          .await?;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    // Get the FieldMeta with field_id, if it doesn't exist, we create the default FieldMeta from the FieldType.
 |  | 
 | 
											
												
													
														|  | 
 |  | +    // Get the field_rev with field_id, if it doesn't exist, we create the default FieldMeta from the FieldType.
 | 
											
												
													
														|  |      let field_rev = editor
 |  |      let field_rev = editor
 | 
											
												
													
														|  |          .get_field_rev(¶ms.field_id)
 |  |          .get_field_rev(¶ms.field_id)
 | 
											
												
													
														|  |          .await
 |  |          .await
 | 
											
												
													
														|  |          .unwrap_or(Arc::new(editor.next_field_rev(¶ms.field_type).await?));
 |  |          .unwrap_or(Arc::new(editor.next_field_rev(¶ms.field_type).await?));
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      let type_option_data = get_type_option_data(&field_rev, ¶ms.field_type).await?;
 |  |      let type_option_data = get_type_option_data(&field_rev, ¶ms.field_type).await?;
 | 
											
												
													
														|  | -    let data = FieldTypeOptionDataPB {
 |  | 
 | 
											
												
													
														|  | -        grid_id: params.grid_id,
 |  | 
 | 
											
												
													
														|  | -        field: field_rev.into(),
 |  | 
 | 
											
												
													
														|  | -        type_option_data,
 |  | 
 | 
											
												
													
														|  | -    };
 |  | 
 | 
											
												
													
														|  | 
 |  | +    let _ = editor
 | 
											
												
													
														|  | 
 |  | +        .update_field_type_option(¶ms.grid_id, &field_rev.id, type_option_data)
 | 
											
												
													
														|  | 
 |  | +        .await?;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    data_result(data)
 |  | 
 | 
											
												
													
														|  | 
 |  | +    Ok(())
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  #[tracing::instrument(level = "trace", skip(data, manager), err)]
 |  |  #[tracing::instrument(level = "trace", skip(data, manager), err)]
 | 
											
										
											
												
													
														|  | @@ -227,7 +214,7 @@ pub(crate) async fn move_field_handler(
 | 
											
												
													
														|  |      Ok(())
 |  |      Ok(())
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -/// The FieldMeta contains multiple data, each of them belongs to a specific FieldType.
 |  | 
 | 
											
												
													
														|  | 
 |  | +/// The [FieldRevision] contains multiple data, each of them belongs to a specific FieldType.
 | 
											
												
													
														|  |  async fn get_type_option_data(field_rev: &FieldRevision, field_type: &FieldType) -> FlowyResult<Vec<u8>> {
 |  |  async fn get_type_option_data(field_rev: &FieldRevision, field_type: &FieldType) -> FlowyResult<Vec<u8>> {
 | 
											
												
													
														|  |      let s = field_rev.get_type_option_str(field_type).unwrap_or_else(|| {
 |  |      let s = field_rev.get_type_option_str(field_type).unwrap_or_else(|| {
 | 
											
												
													
														|  |          default_type_option_builder_from_type(field_type)
 |  |          default_type_option_builder_from_type(field_type)
 |