mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
feat: select in grid
This commit is contained in:
@@ -8,6 +8,7 @@ export class GridItemBlock extends BaseView {
|
||||
public override selectable = false;
|
||||
public override activatable = false;
|
||||
public override allowPendant = false;
|
||||
public override layoutOnly = true;
|
||||
|
||||
type = Protocol.Block.Type.grid;
|
||||
View = GridItemRender(GridItem);
|
||||
|
||||
@@ -9,6 +9,7 @@ export class GridBlock extends BaseView {
|
||||
public override selectable = false;
|
||||
public override activatable = false;
|
||||
public override allowPendant = false;
|
||||
public override layoutOnly = true;
|
||||
|
||||
type = Protocol.Block.Type.grid;
|
||||
View = GridRender(Grid);
|
||||
|
||||
@@ -252,6 +252,7 @@ export class DragDropManager {
|
||||
}
|
||||
|
||||
public handlerEditorDrop(event: React.DragEvent<Element>) {
|
||||
event.preventDefault();
|
||||
// IMP: can not use Decorators now may use decorators is right
|
||||
if (this.isEnabled()) {
|
||||
if (this.isDragBlock(event)) {
|
||||
|
||||
@@ -324,9 +324,21 @@ export class SelectionManager implements VirgoSelection {
|
||||
}
|
||||
if (block && block.dom) {
|
||||
if (selectionRect.isIntersect(domToRect(block.dom))) {
|
||||
const selectableChildren = await (
|
||||
await block.children()
|
||||
).filter(childBlock => {
|
||||
const childrenBlocks = await block.children();
|
||||
// should check directly in structured block
|
||||
const structuredChildrenBlocks: Array<AsyncBlock> =
|
||||
childrenBlocks.filter(childBlock => {
|
||||
return this._editor.getView(childBlock.type).layoutOnly;
|
||||
});
|
||||
for await (const childBlock of structuredChildrenBlocks) {
|
||||
const childSelectedNodes =
|
||||
await this.calcRenderBlockIntersect(
|
||||
selectionRect,
|
||||
childBlock
|
||||
);
|
||||
selectedNodes.push(...childSelectedNodes);
|
||||
}
|
||||
const selectableChildren = childrenBlocks.filter(childBlock => {
|
||||
return this._editor.getView(childBlock.type).selectable;
|
||||
});
|
||||
for await (const childBlock of selectableChildren) {
|
||||
@@ -350,6 +362,7 @@ export class SelectionManager implements VirgoSelection {
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log({ selectedNodes });
|
||||
return selectedNodes;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // except: type Values = 1 | '2'
|
||||
* except: type Values = 1 | '2'
|
||||
* type Values = ValueOf<{a: 1, b: '2'}>
|
||||
* ```
|
||||
*/
|
||||
@@ -14,7 +14,7 @@ export type ValueOf<X extends Record<string, unknown>> = X[keyof X];
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // except: type FirstType = string;
|
||||
* except: type FirstType = string;
|
||||
* type FirstType = First<[string], 0>
|
||||
* ```
|
||||
*/
|
||||
@@ -25,7 +25,7 @@ export type IndexOf<X extends unknown[], I extends number> = X[I];
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // except: type FirstType = string;
|
||||
* except: type FirstType = string;
|
||||
* type FirstType = First<[string]>
|
||||
* ```
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user