mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-29 08:09:52 +08:00
chore: optimisation code
This commit is contained in:
+18
-33
@@ -1,11 +1,10 @@
|
||||
import React, { ReactNode, useRef, useState } from 'react';
|
||||
import React, { ReactNode, useRef } from 'react';
|
||||
import { getLatestPropertyValue } from '../utils';
|
||||
import {
|
||||
getRecastItemValue,
|
||||
RecastMetaProperty,
|
||||
useRecastBlock,
|
||||
useRecastBlockMeta,
|
||||
RecastBlockValue,
|
||||
} from '../../recast-block';
|
||||
import { AsyncBlock } from '../../editor';
|
||||
import { Popover, PopperHandler, styled } from '@toeverything/components/ui';
|
||||
@@ -19,10 +18,6 @@ export const PendantHistoryPanel = ({
|
||||
block: AsyncBlock;
|
||||
endElement?: ReactNode;
|
||||
}) => {
|
||||
const [propertyWithValue, setPropertyWithValue] = useState<{
|
||||
value: RecastBlockValue;
|
||||
property: RecastMetaProperty;
|
||||
}>();
|
||||
const popoverHandlerRef = useRef<{ [key: string]: PopperHandler }>({});
|
||||
|
||||
const { getProperty } = useRecastBlockMeta();
|
||||
@@ -53,25 +48,23 @@ export const PendantHistoryPanel = ({
|
||||
}}
|
||||
placement="bottom-start"
|
||||
content={
|
||||
propertyWithValue && (
|
||||
<UpdatePendantPanel
|
||||
block={block}
|
||||
value={propertyWithValue.value}
|
||||
property={propertyWithValue.property}
|
||||
hasDelete={false}
|
||||
onSure={() => {
|
||||
popoverHandlerRef.current[
|
||||
item.id
|
||||
].setVisible(false);
|
||||
}}
|
||||
onCancel={() => {
|
||||
popoverHandlerRef.current[
|
||||
item.id
|
||||
].setVisible(false);
|
||||
}}
|
||||
titleEditable={false}
|
||||
/>
|
||||
)
|
||||
<UpdatePendantPanel
|
||||
block={block}
|
||||
value={item}
|
||||
property={property}
|
||||
hasDelete={false}
|
||||
onSure={() => {
|
||||
popoverHandlerRef.current[
|
||||
item.id
|
||||
].setVisible(false);
|
||||
}}
|
||||
onCancel={() => {
|
||||
popoverHandlerRef.current[
|
||||
item.id
|
||||
].setVisible(false);
|
||||
}}
|
||||
titleEditable={false}
|
||||
/>
|
||||
}
|
||||
trigger="click"
|
||||
>
|
||||
@@ -84,14 +77,6 @@ export const PendantHistoryPanel = ({
|
||||
}}
|
||||
property={property as RecastMetaProperty}
|
||||
value={item}
|
||||
onClick={e => {
|
||||
if (property) {
|
||||
setPropertyWithValue({
|
||||
property,
|
||||
value: item,
|
||||
});
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Popover>
|
||||
);
|
||||
|
||||
+5
-9
@@ -3,7 +3,7 @@ import { Input, Option, Select, Tooltip } from '@toeverything/components/ui';
|
||||
import { HelpCenterIcon } from '@toeverything/components/icons';
|
||||
import { AsyncBlock } from '../../editor';
|
||||
|
||||
import { pendantOptions, IconMap } from '../config';
|
||||
import { IconMap, pendantOptions } from '../config';
|
||||
import { OptionType, PendantOptions, PendantTypes } from '../types';
|
||||
import { PendantModifyPanel } from '../pendant-modify-panel';
|
||||
import {
|
||||
@@ -15,12 +15,11 @@ import {
|
||||
StyledPopoverWrapper,
|
||||
} from '../StyledComponent';
|
||||
import {
|
||||
PropertyType,
|
||||
genSelectOptionId,
|
||||
InformationProperty,
|
||||
useRecastBlock,
|
||||
useRecastBlockMeta,
|
||||
useSelectProperty,
|
||||
genSelectOptionId,
|
||||
InformationProperty,
|
||||
} from '../../recast-block';
|
||||
import {
|
||||
genInitialOptions,
|
||||
@@ -103,9 +102,7 @@ export const CreatePendantPanel = ({
|
||||
selectedOption.type,
|
||||
getPendantConfigByType(selectedOption.type)
|
||||
)}
|
||||
iconConfig={getPendantConfigByType(
|
||||
selectedOption.type
|
||||
)}
|
||||
iconConfig={getPendantConfigByType(selectedOption.type)}
|
||||
// isStatusSelect={selectedOption.name === 'Status'}
|
||||
onSure={async (type, newPropertyItem, newValue) => {
|
||||
if (!fieldName) {
|
||||
@@ -177,8 +174,7 @@ export const CreatePendantPanel = ({
|
||||
});
|
||||
} else {
|
||||
// TODO: Color and background should use pendant config, but ui is not design now
|
||||
const iconConfig =
|
||||
getPendantConfigByType(type);
|
||||
const iconConfig = getPendantConfigByType(type);
|
||||
// TODO: Color and background should be choose by user in the future
|
||||
const newProperty = await addProperty({
|
||||
type: type,
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import React, { useRef, useState } from 'react';
|
||||
import { AsyncBlock } from '../../editor';
|
||||
import {
|
||||
getRecastItemValue,
|
||||
RecastBlockValue,
|
||||
RecastMetaProperty,
|
||||
useRecastBlockMeta,
|
||||
} from '../../recast-block';
|
||||
import { getRecastItemValue, useRecastBlockMeta } from '../../recast-block';
|
||||
import {
|
||||
MuiZoom,
|
||||
Popover,
|
||||
|
||||
Reference in New Issue
Block a user