mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
refactor(editor): use lodash (#10657)
This commit is contained in:
@@ -12,7 +12,6 @@ import {
|
||||
} from '@blocksuite/block-std/gfx';
|
||||
import type { IVec, PointLocation } from '@blocksuite/global/gfx';
|
||||
import { Bound, linePolygonIntersects } from '@blocksuite/global/gfx';
|
||||
import { keys } from '@blocksuite/global/utils';
|
||||
import * as Y from 'yjs';
|
||||
|
||||
type GroupElementProps = BaseElementProps & {
|
||||
@@ -44,7 +43,7 @@ export class GroupElementModel extends GfxGroupLikeElementModel<GroupElementProp
|
||||
if (props.children && !(props.children instanceof Y.Map)) {
|
||||
const children = new Y.Map() as Y.Map<boolean>;
|
||||
|
||||
keys(props.children).forEach(key => {
|
||||
Object.keys(props.children).forEach(key => {
|
||||
children.set(key as string, true);
|
||||
});
|
||||
|
||||
|
||||
@@ -14,8 +14,10 @@ import {
|
||||
} from '@blocksuite/block-std/gfx';
|
||||
import type { Bound, SerializedXYWH, XYWH } from '@blocksuite/global/gfx';
|
||||
import { deserializeXYWH } from '@blocksuite/global/gfx';
|
||||
import { assertType, keys, last, noop, pick } from '@blocksuite/global/utils';
|
||||
import { assertType, noop } from '@blocksuite/global/utils';
|
||||
import { generateKeyBetween } from 'fractional-indexing';
|
||||
import last from 'lodash-es/last';
|
||||
import pick from 'lodash-es/pick';
|
||||
import * as Y from 'yjs';
|
||||
import { z } from 'zod';
|
||||
|
||||
@@ -182,11 +184,11 @@ export class MindmapElementModel extends GfxGroupLikeElementModel<MindmapElement
|
||||
) {
|
||||
const children: Y.Map<NodeDetail> = new Y.Map();
|
||||
|
||||
keys(props.children).forEach(key => {
|
||||
const detail = pick<Record<string, unknown>, keyof NodeDetail>(
|
||||
props.children![key],
|
||||
['index', 'parent']
|
||||
);
|
||||
Object.entries(props.children).forEach(([key, value]) => {
|
||||
const detail = pick<Record<string, unknown>, keyof NodeDetail>(value, [
|
||||
'index',
|
||||
'parent',
|
||||
]);
|
||||
children.set(key as string, detail as NodeDetail);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { isEqual, last } from '@blocksuite/global/utils';
|
||||
import isEqual from 'lodash-es/isEqual';
|
||||
import last from 'lodash-es/last';
|
||||
|
||||
import { ConnectorMode } from '../../consts/connector.js';
|
||||
import { MindmapStyle } from '../../consts/mindmap.js';
|
||||
|
||||
Reference in New Issue
Block a user