chore: clean code

This commit is contained in:
lawvs 2022-08-24 18:58:53 +08:00
parent 797652d66c
commit d98e44bfc9
6 changed files with 12 additions and 13 deletions

View File

@ -10,13 +10,12 @@ import {
MuiClickAwayListener,
styled,
} from '@toeverything/components/ui';
import { useFlag } from '@toeverything/datasource/feature-flags';
import { useState, type MouseEvent } from 'react';
import { useRefPage } from './RefPage';
const CardContent = styled('div')(({ theme }) => ({
const CardContent = styled('div')({
margin: '20px',
}));
});
const CardActions = styled('div')({
cursor: 'pointer',
@ -86,7 +85,6 @@ export const CardItem = ({ block }: { block: KanbanCard['block'] }) => {
const { addSubItem } = useKanban();
const { openSubPage } = useRefPage();
const [editableBlock, setEditableBlock] = useState<string | null>(null);
const showKanbanRefPageFlag = useFlag('ShowKanbanRefPage', false);
const { editor } = useEditor();
const onAddItem = async () => {
@ -113,7 +111,7 @@ export const CardItem = ({ block }: { block: KanbanCard['block'] }) => {
activeBlock={editableBlock}
/>
</CardContent>
{showKanbanRefPageFlag && !editableBlock && (
{!editableBlock && (
<Overlay onClick={onClickCard}>
<IconButton backgroundColor="#fff" onClick={onClickPen}>
<PenIcon />

View File

@ -1,10 +1,10 @@
import type { PropsWithChildren } from 'react';
import { styled } from '@toeverything/components/ui';
import type { PropsWithChildren } from 'react';
import { useRef } from 'react';
import type { AsyncBlock } from '../editor';
import { getRecastItemValue, useRecastBlockMeta } from '../recast-block';
import { PendantPopover } from './pendant-popover';
import { PendantRender } from './pendant-render';
import { useRef } from 'react';
import { getRecastItemValue, useRecastBlockMeta } from '../recast-block';
/**
* @deprecated
*/

View File

@ -1,15 +1,15 @@
import { ComponentType, ReactElement } from 'react';
import type { Column } from '@toeverything/datasource/db-service';
import {
ArrayOperation,
BlockDecoration,
MapOperation,
} from '@toeverything/datasource/jwt';
import type { ComponentType, ReactElement } from 'react';
import type { EventData } from '../block';
import { AsyncBlock } from '../block';
import { HTML2BlockResult } from '../clipboard';
import type { Editor } from '../editor';
import { SelectBlock } from '../selection';
import { HTML2BlockResult } from '../clipboard';
export interface CreateView {
block: AsyncBlock;
editor: Editor;

View File

@ -358,6 +358,7 @@ export const useKanban = () => {
}
card.append(newBlock);
editor.selectionManager.activeNodeByNodeId(newBlock.id);
return newBlock;
},
[editor]
);

View File

@ -1,7 +1,7 @@
import { Protocol } from '@toeverything/datasource/db-service';
import type { AsyncBlock, BlockEditor } from '../editor';
import type { RecastBlock } from '.';
import { cloneRecastMetaTo, mergeRecastMeta } from './property';
import type { RecastBlock } from './types';
const mergeGroupProperties = async (...groups: RecastBlock[]) => {
const [headGroup, ...restGroups] = groups;

View File

@ -2,6 +2,7 @@ import { nanoid } from 'nanoid';
import { useCallback } from 'react';
import { AsyncBlock } from '../editor';
import { useRecastBlock } from './Context';
import { getHistory, removeHistory, setHistory } from './history';
import type { RecastBlock, RecastItem, StatusProperty } from './types';
import {
META_PROPERTIES_KEY,
@ -15,7 +16,6 @@ import {
SelectProperty,
TABLE_VALUES_KEY,
} from './types';
import { getHistory, removeHistory, setHistory } from './history';
/**
* Generate a unique id for a property
@ -275,7 +275,7 @@ const isSelectLikeProperty = (
metaProperty?: RecastMetaProperty
): metaProperty is SelectProperty | MultiSelectProperty | StatusProperty => {
return (
metaProperty &&
!!metaProperty &&
(metaProperty.type === PropertyType.Status ||
metaProperty.type === PropertyType.Select ||
metaProperty.type === PropertyType.MultiSelect)