diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/_shared/database-hooks/useCell.ts b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/database-hooks/useCell.ts index e04f9a8fdb..2fde53c206 100644 --- a/frontend/appflowy_tauri/src/appflowy_app/components/_shared/database-hooks/useCell.ts +++ b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/database-hooks/useCell.ts @@ -4,28 +4,32 @@ import { FieldController } from '$app/stores/effects/database/field/field_contro import { CellControllerBuilder } from '$app/stores/effects/database/cell/controller_builder'; import { DateCellDataPB, SelectOptionCellDataPB, URLCellDataPB } from '$app/../services/backend'; import { useEffect, useState } from 'react'; +import { CellController } from '$app/stores/effects/database/cell/cell_controller'; export const useCell = (cellIdentifier: CellIdentifier, cellCache: CellCache, fieldController: FieldController) => { const [data, setData] = useState(); + const [cellController, setCellController] = useState>(); useEffect(() => { if (!cellIdentifier || !cellCache || !fieldController) return; const builder = new CellControllerBuilder(cellIdentifier, cellCache, fieldController); - const cellController = builder.build(); + const c = builder.build(); + setCellController(c); void (async () => { - const cellData = await cellController.getCellData(); + const cellData = await c.getCellData(); if (cellData.some) { setData(cellData.unwrap()); } })(); return () => { - void cellController.dispose(); + void c.dispose(); }; }, [cellIdentifier, cellCache, fieldController]); return { + cellController, data, }; }; diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/_shared/database-hooks/useRow.ts b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/database-hooks/useRow.ts index caed55ffeb..8f634009ff 100644 --- a/frontend/appflowy_tauri/src/appflowy_app/components/_shared/database-hooks/useRow.ts +++ b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/database-hooks/useRow.ts @@ -3,6 +3,8 @@ import { RowController } from '$app/stores/effects/database/row/row_controller'; import { RowInfo } from '$app/stores/effects/database/row/row_cache'; import { CellIdentifier } from '$app/stores/effects/database/cell/cell_bd_svc'; import { useEffect, useState } from 'react'; +import { TypeOptionController } from '$app/stores/effects/database/field/type_option/type_option_controller'; +import { None } from 'ts-results'; export const useRow = (viewId: string, databaseController: DatabaseController, rowInfo: RowInfo) => { const [cells, setCells] = useState<{ fieldId: string; cellIdentifier: CellIdentifier }[]>([]); @@ -38,7 +40,14 @@ export const useRow = (viewId: string, databaseController: DatabaseController, r })(); }, [rowController]); + const onNewColumnClick = async () => { + if (!databaseController) return; + const controller = new TypeOptionController(viewId, None); + await controller.initialize(); + }; + return { - cells: cells, + cells, + onNewColumnClick, }; }; diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/_shared/svg/CheckboxSvg.tsx b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/svg/CheckboxSvg.tsx new file mode 100644 index 0000000000..862badd2a2 --- /dev/null +++ b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/svg/CheckboxSvg.tsx @@ -0,0 +1,13 @@ +export const CheckboxSvg = () => { + return ( + + + + + ); +}; diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/_shared/svg/EditorCheckSvg.tsx b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/svg/EditorCheckSvg.tsx new file mode 100644 index 0000000000..72b7f5a3eb --- /dev/null +++ b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/svg/EditorCheckSvg.tsx @@ -0,0 +1,8 @@ +export const EditorCheckSvg = () => { + return ( + + + + + ); +}; diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/_shared/svg/EditorUncheckSvg.tsx b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/svg/EditorUncheckSvg.tsx new file mode 100644 index 0000000000..7615d69a72 --- /dev/null +++ b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/svg/EditorUncheckSvg.tsx @@ -0,0 +1,7 @@ +export const EditorUncheckSvg = () => { + return ( + + + + ); +}; diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/board/Board.tsx b/frontend/appflowy_tauri/src/appflowy_app/components/board/Board.tsx index f492e1bd16..4a90c5f81c 100644 --- a/frontend/appflowy_tauri/src/appflowy_app/components/board/Board.tsx +++ b/frontend/appflowy_tauri/src/appflowy_app/components/board/Board.tsx @@ -7,6 +7,7 @@ import { ViewLayoutTypePB } from '@/services/backend'; import { DragDropContext } from 'react-beautiful-dnd'; import { useState } from 'react'; import { RowInfo } from '$app/stores/effects/database/row/row_cache'; +import { EditRow } from '$app/components/board/EditBoardRow/EditRow'; export const Board = ({ viewId }: { viewId: string }) => { const { controller, rows, groups, onNewRowClick, onDragEnd } = useDatabase(viewId, ViewLayoutTypePB.Board); @@ -39,7 +40,7 @@ export const Board = ({ viewId }: { viewId: string }) => { groups && groups.map((group, index) => ( { - + {controller && showBoardRow && boardRowInfo && ( + setShowBoardRow(false)} + viewId={viewId} + controller={controller} + rowInfo={boardRowInfo} + > + )} ); }; diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/board/BoardBlock.tsx b/frontend/appflowy_tauri/src/appflowy_app/components/board/BoardBlock.tsx index fa3acf65c1..0a3b20e597 100644 --- a/frontend/appflowy_tauri/src/appflowy_app/components/board/BoardBlock.tsx +++ b/frontend/appflowy_tauri/src/appflowy_app/components/board/BoardBlock.tsx @@ -51,7 +51,7 @@ export const BoardBlock = ({ viewId={viewId} controller={controller} index={index} - key={index} + key={row.row.id} rowInfo={row} onOpenRow={onOpenRow} > diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/board/BoardTextCell.tsx b/frontend/appflowy_tauri/src/appflowy_app/components/board/BoardTextCell.tsx index def0f1cd3a..dd9c517dee 100644 --- a/frontend/appflowy_tauri/src/appflowy_app/components/board/BoardTextCell.tsx +++ b/frontend/appflowy_tauri/src/appflowy_app/components/board/BoardTextCell.tsx @@ -14,5 +14,11 @@ export const BoardTextCell = ({ }) => { const { data } = useCell(cellIdentifier, cellCache, fieldController); - return
{(data as string | undefined) || ''}
; + return ( +
+ {((data as string | undefined) || '').split('\n').map((line, index) => ( +
{line}
+ ))} +
+ ); }; diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/board/EditBoardRow/EditCellText.tsx b/frontend/appflowy_tauri/src/appflowy_app/components/board/EditBoardRow/EditCellText.tsx new file mode 100644 index 0000000000..d7813f8bb7 --- /dev/null +++ b/frontend/appflowy_tauri/src/appflowy_app/components/board/EditBoardRow/EditCellText.tsx @@ -0,0 +1,33 @@ +import { CellController } from '$app/stores/effects/database/cell/cell_controller'; +import { useEffect, useState, KeyboardEvent, useMemo } from 'react'; + +export const EditCellText = ({ data, cellController }: { data: string; cellController: CellController }) => { + const [value, setValue] = useState(''); + const [contentRows, setContentRows] = useState(1); + useEffect(() => { + setValue(data); + }, [data]); + + useEffect(() => { + setContentRows(Math.max(1, value.split('\n').length)); + }, [value]); + + const onTextFieldChange = async (v: string) => { + setValue(v); + }; + + const save = async () => { + await cellController?.saveCellData(value); + }; + + return ( +
+