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