There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
feat: select in grid
SaikaSakuracfe9d5a82d44
diff --git a/libs/components/editor-blocks/src/blocks/grid-item/index.ts b/libs/components/editor-blocks/src/blocks/grid-item/index.tsindex 88d5023cf8..7f51c47a05 100644--- a/libs/components/editor-blocks/src/blocks/grid-item/index.ts+++ b/libs/components/editor-blocks/src/blocks/grid-item/index.ts@@ -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);diff --git a/libs/components/editor-blocks/src/blocks/grid/index.ts b/libs/components/editor-blocks/src/blocks/grid/index.tsindex 984bd82710..ec6c363819 100644--- a/libs/components/editor-blocks/src/blocks/grid/index.ts+++ b/libs/components/editor-blocks/src/blocks/grid/index.ts@@ -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);diff --git a/libs/components/editor-core/src/editor/drag-drop/drag-drop.ts b/libs/components/editor-core/src/editor/drag-drop/drag-drop.tsindex e3da55fcb5..b8f602fb2c 100644--- a/libs/components/editor-core/src/editor/drag-drop/drag-drop.ts+++ b/libs/components/editor-core/src/editor/drag-drop/drag-drop.ts@@ -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 rightif (this.isEnabled()) {if (this.isDragBlock(event)) {diff --git a/libs/components/editor-core/src/editor/selection/selection.ts b/libs/components/editor-core/src/editor/selection/selection.tsindex 0b60b789b4..72ad0d9473 100644--- a/libs/components/editor-core/src/editor/selection/selection.ts+++ b/libs/components/editor-core/src/editor/selection/selection.ts@@ -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;}diff --git a/libs/utils/src/types/tools.ts b/libs/utils/src/types/tools.tsindex 1f2fe05285..73372b6787 100644--- a/libs/utils/src/types/tools.ts+++ b/libs/utils/src/types/tools.ts@@ -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]>* ```*/