Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion packages/mind/src/generators/node-more.generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export const getNodeMoreKeyPosition = (board: PlaitBoard, element: MindElement)
const endPoint = moveXOfPoint(startPoint, NODE_MORE_LINE_DISTANCE, layoutDirection as unknown as Direction);
const hasCollapsedIcon = element.children?.length > 0 && !isMind && !element.isCollapsed;
const hasExpandedIcon = element.children?.length > 0 && !isMind && element.isCollapsed;
const hasAddIcon = !hasExpandedIcon;
const hasAddIcon = !hasExpandedIcon && !PlaitBoard.isReadonly(board);
const firstIconCenter = moveXOfPoint(endPoint, NODE_MORE_ICON_DIAMETER / 2, layoutDirection as unknown as Direction);
const collapsedIconCenter = hasCollapsedIcon ? firstIconCenter : null;
const expandedIconCenter = hasExpandedIcon ? firstIconCenter : null;
Expand All @@ -311,6 +311,16 @@ export const getNodeMoreKeyPosition = (board: PlaitBoard, element: MindElement)
moveYOfPoint(startPoint, -NODE_MORE_ICON_DIAMETER / 2, layoutDirection as unknown as Direction),
moveYOfPoint(expandedIconEndPoint, NODE_MORE_ICON_DIAMETER / 2, layoutDirection as unknown as Direction)
]);
} else if (hasCollapsedIcon) {
const collapsedIconEndPoint = moveXOfPoint(
collapsedIconCenter!,
NODE_MORE_ICON_DIAMETER / 2,
layoutDirection as unknown as Direction
);
awarenessRectangle = RectangleClient.getRectangleByPoints([
moveYOfPoint(startPoint, -NODE_MORE_ICON_DIAMETER / 2, layoutDirection as unknown as Direction),
moveYOfPoint(collapsedIconEndPoint, NODE_MORE_ICON_DIAMETER / 2, layoutDirection as unknown as Direction)
]);
}

let standardRef: { addCenter: Point; awarenessRectangle: RectangleClient } | null = null;
Expand Down
16 changes: 15 additions & 1 deletion packages/mind/src/plugins/with-node-more.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
createDebugGenerator,
depthFirstRecursion,
getElementById,
getIsRecursionFunc,
Expand Down Expand Up @@ -26,6 +27,9 @@ import { NODE_MORE_ICON_DIAMETER } from '../constants/default';
import { PlaitMindBoard } from './with-mind.board';
import { MindLayoutType } from '@plait/layouts';
import { setRightNodeCountByRefs } from '../transforms/node';
import { Node } from 'slate';

const debugGenerator = createDebugGenerator('debug:plait:node-more');

export interface NodeMoreRef {
target: MindElement;
Expand Down Expand Up @@ -251,7 +255,17 @@ const getNodeMoreRef = (board: PlaitBoard, x: number, y: number) => {
RectangleClient.getRectangleByPoints([point, point]),
RectangleClient.getRectangleByCenterPoint(standardRef.addCenter, NODE_MORE_ICON_DIAMETER, NODE_MORE_ICON_DIAMETER)
);

if (debugGenerator.isDebug()) {
debugGenerator.clear();
if (awarenessRectangle) {
debugGenerator.drawRectangle(board, awarenessRectangle);
}
const data = element.data.topic;
const string = Node.string(data);
if (string === 'xxxx') {
console.log('xxxx');
}
}
if (isHitElement || isHitAwarenessRectangleInternal || isHitStandardLeftAwarenessRectangleInternal) {
isHit = isHitElement;
target = element;
Expand Down
Loading