|
@@ -1,6 +1,7 @@
|
|
import { CellIdentifier } from '$app/stores/effects/database/cell/cell_bd_svc';
|
|
import { CellIdentifier } from '$app/stores/effects/database/cell/cell_bd_svc';
|
|
import { CellCache } from '$app/stores/effects/database/cell/cell_cache';
|
|
import { CellCache } from '$app/stores/effects/database/cell/cell_cache';
|
|
import { FieldController } from '$app/stores/effects/database/field/field_controller';
|
|
import { FieldController } from '$app/stores/effects/database/field/field_controller';
|
|
|
|
+import { useEffect, useState } from 'react';
|
|
import { useCell } from '../_shared/database-hooks/useCell';
|
|
import { useCell } from '../_shared/database-hooks/useCell';
|
|
|
|
|
|
export const BoardTextCell = ({
|
|
export const BoardTextCell = ({
|
|
@@ -12,13 +13,26 @@ export const BoardTextCell = ({
|
|
cellCache: CellCache;
|
|
cellCache: CellCache;
|
|
fieldController: FieldController;
|
|
fieldController: FieldController;
|
|
}) => {
|
|
}) => {
|
|
- const { data } = useCell(cellIdentifier, cellCache, fieldController);
|
|
|
|
|
|
+ const { data, cellController } = useCell(cellIdentifier, cellCache, fieldController);
|
|
|
|
+
|
|
|
|
+ const [value, setValue] = useState((data as string) || '');
|
|
|
|
+
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ if (data) setValue(data as string);
|
|
|
|
+ }, [data]);
|
|
|
|
|
|
return (
|
|
return (
|
|
<div>
|
|
<div>
|
|
- {((data as string | undefined) || '').split('\n').map((line, index) => (
|
|
|
|
- <div key={index}>{line}</div>
|
|
|
|
- ))}
|
|
|
|
|
|
+ <input
|
|
|
|
+ value={value}
|
|
|
|
+ onChange={(e) => {
|
|
|
|
+ setValue(e.target.value);
|
|
|
|
+ }}
|
|
|
|
+ onBlur={async () => {
|
|
|
|
+ await cellController?.saveCellData(value);
|
|
|
|
+ }}
|
|
|
|
+ className='min-h-[32px] w-full p-2 focus:border focus:border-main-accent focus:outline-none '
|
|
|
|
+ />
|
|
</div>
|
|
</div>
|
|
);
|
|
);
|
|
};
|
|
};
|