mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-02 09:59:55 +08:00
Merge pull request #381 from toeverything/develop
Fix/group select (#378)
This commit is contained in:
@@ -6,7 +6,10 @@ import {
|
|||||||
} from '@toeverything/components/common';
|
} from '@toeverything/components/common';
|
||||||
import { useOnSelectActive } from '@toeverything/components/editor-core';
|
import { useOnSelectActive } from '@toeverything/components/editor-core';
|
||||||
import { styled } from '@toeverything/components/ui';
|
import { styled } from '@toeverything/components/ui';
|
||||||
import { ContentColumnValue } from '@toeverything/datasource/db-service';
|
import {
|
||||||
|
ContentColumnValue,
|
||||||
|
Protocol,
|
||||||
|
} from '@toeverything/datasource/db-service';
|
||||||
import {
|
import {
|
||||||
AsyncBlock,
|
AsyncBlock,
|
||||||
BlockEditor,
|
BlockEditor,
|
||||||
@@ -377,9 +380,36 @@ export const TextManage = forwardRef<ExtendedTextUtils, CreateTextView>(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const onSelectAll = () => {
|
const selectGroupBlocks = async (isSelectAll: boolean) => {
|
||||||
|
if (editor.selectionManager.currentSelectInfo.anchorNode) {
|
||||||
|
const block = await editor.getBlockById(
|
||||||
|
editor.selectionManager.currentSelectInfo.anchorNode.id
|
||||||
|
);
|
||||||
|
if (isSelectAll) {
|
||||||
|
if (
|
||||||
|
Protocol.Block.Type.group !== block.type &&
|
||||||
|
Protocol.Block.Type.page !== block.type
|
||||||
|
) {
|
||||||
|
const paths = await editor.getBlockPath(block.id);
|
||||||
|
paths &&
|
||||||
|
paths[1] &&
|
||||||
|
editor.selectionManager.setSelectedNodesIds([
|
||||||
|
paths[1].id,
|
||||||
|
]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const onSelectAll = async () => {
|
||||||
const isSelectAll =
|
const isSelectAll =
|
||||||
textRef.current.isEmpty() || textRef.current.isSelectAll();
|
textRef.current.isEmpty() || textRef.current.isSelectAll();
|
||||||
|
|
||||||
|
const ifSelectGroup = await selectGroupBlocks(isSelectAll);
|
||||||
|
if (ifSelectGroup) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (isSelectAll) {
|
if (isSelectAll) {
|
||||||
editor.selectionManager.selectAllBlocks();
|
editor.selectionManager.selectAllBlocks();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -256,6 +256,7 @@ export class SelectionManager implements VirgoSelection {
|
|||||||
const rootBlockId = this._editor.getRootBlockId();
|
const rootBlockId = this._editor.getRootBlockId();
|
||||||
const rootBlock = await this._editor.getBlockById(rootBlockId);
|
const rootBlock = await this._editor.getBlockById(rootBlockId);
|
||||||
const children = await rootBlock?.children();
|
const children = await rootBlock?.children();
|
||||||
|
|
||||||
if (children) {
|
if (children) {
|
||||||
this.setSelectedNodesIds(children.map(({ id }) => id));
|
this.setSelectedNodesIds(children.map(({ id }) => id));
|
||||||
// blur focused element and blur it
|
// blur focused element and blur it
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ import { Tooltip } from '@toeverything/components/ui';
|
|||||||
import { uaHelper } from '@toeverything/utils';
|
import { uaHelper } from '@toeverything/utils';
|
||||||
import React, { useCallback } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import style9 from 'style9';
|
import style9 from 'style9';
|
||||||
import { inlineMenuNamesKeys, WinInlineMenuShortcuts } from '../config';
|
import {
|
||||||
|
inlineMenuNamesKeys,
|
||||||
|
MacInlineMenuShortcuts,
|
||||||
|
WinInlineMenuShortcuts,
|
||||||
|
} from '../config';
|
||||||
import type { IconItemType, WithEditorSelectionType } from '../types';
|
import type { IconItemType, WithEditorSelectionType } from '../types';
|
||||||
|
|
||||||
type MenuIconItemProps = IconItemType & WithEditorSelectionType;
|
type MenuIconItemProps = IconItemType & WithEditorSelectionType;
|
||||||
|
|||||||
Reference in New Issue
Block a user