@plait/mind 0.27.0-next.2 → 0.27.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constants/node-topic-style.d.ts +1 -0
- package/esm2022/constants/node-topic-style.mjs +2 -1
- package/esm2022/plugins/with-mind-create.mjs +22 -19
- package/esm2022/utils/draw/abstract-outline.mjs +4 -4
- package/esm2022/utils/node/create-node.mjs +9 -6
- package/esm2022/utils/position/node.mjs +8 -6
- package/fesm2022/plait-mind.mjs +209 -202
- package/fesm2022/plait-mind.mjs.map +1 -1
- package/package.json +1 -1
- package/utils/node/create-node.d.ts +4 -4
- package/utils/position/node.d.ts +1 -1
package/fesm2022/plait-mind.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Component, ChangeDetectionStrategy, NgModule, NgZone, Directive, Input, HostListener } from '@angular/core';
|
|
3
3
|
import * as i2 from '@plait/core';
|
|
4
|
-
import { DefaultThemeColor, ColorfulThemeColor, SoftThemeColor, RetroThemeColor, DarkThemeColor, StarryThemeColor, RectangleClient, PlaitElement, PlaitPluginKey, getSelectedElements, idCreator, isNullOrUndefined, Transforms, clearSelectedElement, addSelectedElement, PlaitBoard, Path, PlaitNode, PlaitContextService, depthFirstRecursion, getIsRecursionFunc, drawLinearPath, drawBezierPath, createG, updateForeignObject, drawRoundRectangle, getRectangleByElements, NODE_TO_PARENT, distanceBetweenPointAndRectangle, createForeignObject, createText, PlaitPointerType, PlaitPluginElementComponent, NODE_TO_INDEX, PlaitModule, isMainPointer, transformPoint, toPoint, getHitElements, distanceBetweenPointAndPoint, setClipboardData, setClipboardDataByText, BOARD_TO_HOST,
|
|
5
|
-
import { MindLayoutType, isIndentedLayout, AbstractNode, isStandardLayout,
|
|
4
|
+
import { DefaultThemeColor, ColorfulThemeColor, SoftThemeColor, RetroThemeColor, DarkThemeColor, StarryThemeColor, RectangleClient, PlaitElement, PlaitPluginKey, getSelectedElements, idCreator, isNullOrUndefined, Transforms, clearSelectedElement, addSelectedElement, PlaitBoard, Path, PlaitNode, PlaitContextService, depthFirstRecursion, getIsRecursionFunc, drawLinearPath, drawBezierPath, createG, updateForeignObject, drawRoundRectangle, getRectangleByElements, NODE_TO_PARENT, distanceBetweenPointAndRectangle, createForeignObject, setStrokeLinecap, createText, PlaitPointerType, PlaitPluginElementComponent, NODE_TO_INDEX, PlaitModule, isMainPointer, transformPoint, toPoint, getHitElements, distanceBetweenPointAndPoint, setClipboardData, setClipboardDataByText, BOARD_TO_HOST, BoardTransforms, throttleRAF, removeSelectedElement, PlaitHistoryBoard, hotkeys, setClipboardDataByMedia, getClipboardDataByMedia, ResizeCursorClass, preventTouchMove, PRESS_AND_MOVE_BUFFER, MERGING, getDataFromClipboard } from '@plait/core';
|
|
5
|
+
import { MindLayoutType, isIndentedLayout, isHorizontalLayout, isHorizontalLogicLayout, ConnectingPosition, AbstractNode, isStandardLayout, isVerticalLogicLayout, getNonAbstractChildren, isLeftLayout, isRightLayout, isTopLayout, isBottomLayout, getCorrectStartEnd, getAbstractLayout, GlobalLayout } from '@plait/layouts';
|
|
6
6
|
import { PlaitMarkEditor, MarkTypes, DEFAULT_FONT_SIZE, TEXT_DEFAULT_HEIGHT, buildText, getTextSize, TextManage, ExitOrigin, TextModule, getTextFromClipboard } from '@plait/text';
|
|
7
7
|
import { fromEvent, Subject } from 'rxjs';
|
|
8
|
-
import { RESIZE_HANDLE_DIAMETER, getRectangleResizeHandleRefs, isExpandHotkey, isTabHotkey, isEnterHotkey, isVirtualKey, isSpaceHotkey, MediaKeys, ResizeHandle, withResize, ActiveGenerator } from '@plait/common';
|
|
8
|
+
import { RESIZE_HANDLE_DIAMETER, getRectangleResizeHandleRefs, isDrawingMode, isDndMode, setCreationMode, BoardCreationMode, isExpandHotkey, isTabHotkey, isEnterHotkey, isVirtualKey, isSpaceHotkey, MediaKeys, ResizeHandle, withResize, ActiveGenerator } from '@plait/common';
|
|
9
9
|
import { Node as Node$1, Path as Path$1 } from 'slate';
|
|
10
10
|
import { pointsOnBezierCurves } from 'points-on-curve';
|
|
11
11
|
import { take, filter } from 'rxjs/operators';
|
|
@@ -214,6 +214,7 @@ const TOPIC_COLOR = '#333';
|
|
|
214
214
|
const TOPIC_FONT_SIZE = 14;
|
|
215
215
|
const ROOT_TOPIC_FONT_SIZE = 18;
|
|
216
216
|
const ROOT_TOPIC_HEIGHT = 25;
|
|
217
|
+
const ROOT_TOPIC_WIDTH = 72;
|
|
217
218
|
const TOPIC_DEFAULT_MAX_WORD_COUNT = 34;
|
|
218
219
|
const DEFAULT_FONT_FAMILY = 'PingFangSC-Regular, "PingFang SC"';
|
|
219
220
|
const BRANCH_FONT_FAMILY = 'PingFangSC-Medium, "PingFang SC"';
|
|
@@ -446,15 +447,187 @@ const getSelectedMindElements = (board) => {
|
|
|
446
447
|
return selectedElements;
|
|
447
448
|
};
|
|
448
449
|
|
|
449
|
-
const
|
|
450
|
-
const
|
|
450
|
+
const getBranchDirectionsByLayouts = (branchLayouts) => {
|
|
451
|
+
const branchDirections = [];
|
|
452
|
+
branchLayouts.forEach(l => {
|
|
453
|
+
const directions = LayoutDirectionsMap[l];
|
|
454
|
+
directions.forEach(d => {
|
|
455
|
+
if (!branchDirections.includes(d) && !branchDirections.includes(getLayoutReverseDirection(d))) {
|
|
456
|
+
branchDirections.push(d);
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
});
|
|
460
|
+
return branchDirections;
|
|
461
|
+
};
|
|
462
|
+
const isCorrectLayout = (root, layout) => {
|
|
463
|
+
const rootLayout = root.layout || getDefaultLayout();
|
|
464
|
+
return !getInCorrectLayoutDirection(rootLayout, layout);
|
|
465
|
+
};
|
|
466
|
+
const isMixedLayout = (parentLayout, layout) => {
|
|
467
|
+
return (!isIndentedLayout(parentLayout) && isIndentedLayout(layout)) || (isIndentedLayout(parentLayout) && !isIndentedLayout(layout));
|
|
468
|
+
};
|
|
469
|
+
const getInCorrectLayoutDirection = (rootLayout, layout) => {
|
|
470
|
+
const directions = LayoutDirectionsMap[rootLayout];
|
|
471
|
+
const subLayoutDirections = LayoutDirectionsMap[layout];
|
|
472
|
+
if (!subLayoutDirections) {
|
|
473
|
+
throw new Error(`unexpected layout: ${layout} on correct layout`);
|
|
474
|
+
}
|
|
475
|
+
return subLayoutDirections.find(d => directions.includes(getLayoutReverseDirection(d)));
|
|
476
|
+
};
|
|
477
|
+
const correctLayoutByDirection = (layout, direction) => {
|
|
478
|
+
const isHorizontal = direction === LayoutDirection.left || direction === LayoutDirection.right ? true : false;
|
|
479
|
+
let inverseDirectionLayout = MindLayoutType.standard;
|
|
480
|
+
switch (layout) {
|
|
481
|
+
case MindLayoutType.left:
|
|
482
|
+
inverseDirectionLayout = MindLayoutType.right;
|
|
483
|
+
break;
|
|
484
|
+
case MindLayoutType.right:
|
|
485
|
+
inverseDirectionLayout = MindLayoutType.left;
|
|
486
|
+
break;
|
|
487
|
+
case MindLayoutType.downward:
|
|
488
|
+
inverseDirectionLayout = MindLayoutType.upward;
|
|
489
|
+
break;
|
|
490
|
+
case MindLayoutType.upward:
|
|
491
|
+
inverseDirectionLayout = MindLayoutType.downward;
|
|
492
|
+
break;
|
|
493
|
+
case MindLayoutType.rightBottomIndented:
|
|
494
|
+
inverseDirectionLayout = isHorizontal ? MindLayoutType.leftBottomIndented : MindLayoutType.rightTopIndented;
|
|
495
|
+
break;
|
|
496
|
+
case MindLayoutType.leftBottomIndented:
|
|
497
|
+
inverseDirectionLayout = isHorizontal ? MindLayoutType.rightBottomIndented : MindLayoutType.leftTopIndented;
|
|
498
|
+
break;
|
|
499
|
+
case MindLayoutType.rightTopIndented:
|
|
500
|
+
inverseDirectionLayout = isHorizontal ? MindLayoutType.leftTopIndented : MindLayoutType.rightBottomIndented;
|
|
501
|
+
break;
|
|
502
|
+
case MindLayoutType.leftTopIndented:
|
|
503
|
+
inverseDirectionLayout = isHorizontal ? MindLayoutType.rightTopIndented : MindLayoutType.leftBottomIndented;
|
|
504
|
+
break;
|
|
505
|
+
}
|
|
506
|
+
return inverseDirectionLayout;
|
|
507
|
+
};
|
|
508
|
+
const getLayoutDirection$1 = (root) => {
|
|
509
|
+
const layout = root.layout || getDefaultLayout();
|
|
510
|
+
return LayoutDirectionsMap[layout];
|
|
511
|
+
};
|
|
512
|
+
const getDefaultLayout = () => {
|
|
513
|
+
return MindLayoutType.standard;
|
|
514
|
+
};
|
|
515
|
+
const getAvailableSubLayoutsByLayoutDirections = (directions) => {
|
|
516
|
+
const result = [];
|
|
517
|
+
const reverseDirections = directions.map(getLayoutReverseDirection);
|
|
518
|
+
for (const key in MindLayoutType) {
|
|
519
|
+
const layout = MindLayoutType[key];
|
|
520
|
+
const layoutDirections = LayoutDirectionsMap[layout];
|
|
521
|
+
if (layoutDirections) {
|
|
522
|
+
const hasSameDirection = layoutDirections.some(d => directions.includes(d));
|
|
523
|
+
const hasReverseDirection = layoutDirections.some(r => reverseDirections.includes(r));
|
|
524
|
+
if (hasSameDirection && !hasReverseDirection) {
|
|
525
|
+
result.push(layout);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
return result;
|
|
530
|
+
};
|
|
531
|
+
const getLayoutReverseDirection = (layoutDirection) => {
|
|
532
|
+
let reverseDirection = LayoutDirection.right;
|
|
533
|
+
switch (layoutDirection) {
|
|
534
|
+
case LayoutDirection.top:
|
|
535
|
+
reverseDirection = LayoutDirection.bottom;
|
|
536
|
+
break;
|
|
537
|
+
case LayoutDirection.bottom:
|
|
538
|
+
reverseDirection = LayoutDirection.top;
|
|
539
|
+
break;
|
|
540
|
+
case LayoutDirection.right:
|
|
541
|
+
reverseDirection = LayoutDirection.left;
|
|
542
|
+
break;
|
|
543
|
+
case LayoutDirection.left:
|
|
544
|
+
reverseDirection = LayoutDirection.right;
|
|
545
|
+
break;
|
|
546
|
+
}
|
|
547
|
+
return reverseDirection;
|
|
548
|
+
};
|
|
549
|
+
const getRootLayout = (root) => {
|
|
550
|
+
return root.layout || getDefaultLayout();
|
|
551
|
+
};
|
|
552
|
+
|
|
553
|
+
const getLayoutOptions = (board) => {
|
|
554
|
+
function getMainAxle(element, parent) {
|
|
555
|
+
const strokeWidth = element.strokeWidth || STROKE_WIDTH;
|
|
556
|
+
if (element.isRoot) {
|
|
557
|
+
return BASE * 12;
|
|
558
|
+
}
|
|
559
|
+
if (parent && parent.isRoot()) {
|
|
560
|
+
return BASE * 3 + strokeWidth / 2;
|
|
561
|
+
}
|
|
562
|
+
return BASE * 3 + strokeWidth / 2;
|
|
563
|
+
}
|
|
564
|
+
function getSecondAxle(element, parent) {
|
|
565
|
+
const strokeWidth = element.strokeWidth || STROKE_WIDTH;
|
|
566
|
+
if (element.isRoot) {
|
|
567
|
+
return BASE * 10 + strokeWidth / 2;
|
|
568
|
+
}
|
|
569
|
+
return BASE * 6 + strokeWidth / 2;
|
|
570
|
+
}
|
|
571
|
+
return {
|
|
572
|
+
getHeight(element) {
|
|
573
|
+
return NodeSpace.getNodeHeight(board, element);
|
|
574
|
+
},
|
|
575
|
+
getWidth(element) {
|
|
576
|
+
return NodeSpace.getNodeWidth(board, element);
|
|
577
|
+
},
|
|
578
|
+
getHorizontalGap(element, parent) {
|
|
579
|
+
const _layout = (parent && parent.layout) || getRootLayout(element);
|
|
580
|
+
const isHorizontal = isHorizontalLayout(_layout);
|
|
581
|
+
const strokeWidth = element.strokeWidth || STROKE_WIDTH;
|
|
582
|
+
if (isIndentedLayout(_layout)) {
|
|
583
|
+
return BASE * 4 + strokeWidth;
|
|
584
|
+
}
|
|
585
|
+
if (!isHorizontal) {
|
|
586
|
+
return getMainAxle(element, parent);
|
|
587
|
+
}
|
|
588
|
+
else {
|
|
589
|
+
return getSecondAxle(element, parent);
|
|
590
|
+
}
|
|
591
|
+
},
|
|
592
|
+
getVerticalGap(element, parent) {
|
|
593
|
+
const _layout = (parent && parent.layout) || getRootLayout(element);
|
|
594
|
+
if (isIndentedLayout(_layout)) {
|
|
595
|
+
return BASE;
|
|
596
|
+
}
|
|
597
|
+
const isHorizontal = isHorizontalLayout(_layout);
|
|
598
|
+
if (isHorizontal) {
|
|
599
|
+
return getMainAxle(element, parent);
|
|
600
|
+
}
|
|
601
|
+
else {
|
|
602
|
+
return getSecondAxle(element, parent);
|
|
603
|
+
}
|
|
604
|
+
},
|
|
605
|
+
getVerticalConnectingPosition(element, parent) {
|
|
606
|
+
if (element.shape === MindElementShape.underline && parent && isHorizontalLogicLayout(parent.layout)) {
|
|
607
|
+
return ConnectingPosition.bottom;
|
|
608
|
+
}
|
|
609
|
+
return undefined;
|
|
610
|
+
},
|
|
611
|
+
getExtendHeight(node) {
|
|
612
|
+
return BASE * 6;
|
|
613
|
+
},
|
|
614
|
+
getIndentedCrossLevelGap() {
|
|
615
|
+
return BASE * 2;
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
const createEmptyMind = (board, point) => {
|
|
621
|
+
const element = createMindElement('思维导图', ROOT_TOPIC_WIDTH, ROOT_TOPIC_HEIGHT, { layout: MindLayoutType.right });
|
|
451
622
|
element.isRoot = true;
|
|
452
|
-
element.points = [point];
|
|
453
623
|
element.type = 'mindmap';
|
|
624
|
+
const width = NodeSpace.getNodeWidth(board, element);
|
|
625
|
+
const height = NodeSpace.getNodeHeight(board, element);
|
|
626
|
+
element.points = [[point[0] - width / 2, point[1] - height / 2]];
|
|
454
627
|
return element;
|
|
455
628
|
};
|
|
456
629
|
const createDefaultMind = (point, rightNodeCount, layout) => {
|
|
457
|
-
const root = createMindElement('思维导图',
|
|
630
|
+
const root = createMindElement('思维导图', ROOT_TOPIC_WIDTH, ROOT_TOPIC_HEIGHT, { layout });
|
|
458
631
|
root.rightNodeCount = rightNodeCount;
|
|
459
632
|
root.isRoot = true;
|
|
460
633
|
root.type = 'mindmap';
|
|
@@ -587,109 +760,6 @@ const divideElementByParent = (elements) => {
|
|
|
587
760
|
return { parentElements, abstractIncludedGroups };
|
|
588
761
|
};
|
|
589
762
|
|
|
590
|
-
const getBranchDirectionsByLayouts = (branchLayouts) => {
|
|
591
|
-
const branchDirections = [];
|
|
592
|
-
branchLayouts.forEach(l => {
|
|
593
|
-
const directions = LayoutDirectionsMap[l];
|
|
594
|
-
directions.forEach(d => {
|
|
595
|
-
if (!branchDirections.includes(d) && !branchDirections.includes(getLayoutReverseDirection(d))) {
|
|
596
|
-
branchDirections.push(d);
|
|
597
|
-
}
|
|
598
|
-
});
|
|
599
|
-
});
|
|
600
|
-
return branchDirections;
|
|
601
|
-
};
|
|
602
|
-
const isCorrectLayout = (root, layout) => {
|
|
603
|
-
const rootLayout = root.layout || getDefaultLayout();
|
|
604
|
-
return !getInCorrectLayoutDirection(rootLayout, layout);
|
|
605
|
-
};
|
|
606
|
-
const isMixedLayout = (parentLayout, layout) => {
|
|
607
|
-
return (!isIndentedLayout(parentLayout) && isIndentedLayout(layout)) || (isIndentedLayout(parentLayout) && !isIndentedLayout(layout));
|
|
608
|
-
};
|
|
609
|
-
const getInCorrectLayoutDirection = (rootLayout, layout) => {
|
|
610
|
-
const directions = LayoutDirectionsMap[rootLayout];
|
|
611
|
-
const subLayoutDirections = LayoutDirectionsMap[layout];
|
|
612
|
-
if (!subLayoutDirections) {
|
|
613
|
-
throw new Error(`unexpected layout: ${layout} on correct layout`);
|
|
614
|
-
}
|
|
615
|
-
return subLayoutDirections.find(d => directions.includes(getLayoutReverseDirection(d)));
|
|
616
|
-
};
|
|
617
|
-
const correctLayoutByDirection = (layout, direction) => {
|
|
618
|
-
const isHorizontal = direction === LayoutDirection.left || direction === LayoutDirection.right ? true : false;
|
|
619
|
-
let inverseDirectionLayout = MindLayoutType.standard;
|
|
620
|
-
switch (layout) {
|
|
621
|
-
case MindLayoutType.left:
|
|
622
|
-
inverseDirectionLayout = MindLayoutType.right;
|
|
623
|
-
break;
|
|
624
|
-
case MindLayoutType.right:
|
|
625
|
-
inverseDirectionLayout = MindLayoutType.left;
|
|
626
|
-
break;
|
|
627
|
-
case MindLayoutType.downward:
|
|
628
|
-
inverseDirectionLayout = MindLayoutType.upward;
|
|
629
|
-
break;
|
|
630
|
-
case MindLayoutType.upward:
|
|
631
|
-
inverseDirectionLayout = MindLayoutType.downward;
|
|
632
|
-
break;
|
|
633
|
-
case MindLayoutType.rightBottomIndented:
|
|
634
|
-
inverseDirectionLayout = isHorizontal ? MindLayoutType.leftBottomIndented : MindLayoutType.rightTopIndented;
|
|
635
|
-
break;
|
|
636
|
-
case MindLayoutType.leftBottomIndented:
|
|
637
|
-
inverseDirectionLayout = isHorizontal ? MindLayoutType.rightBottomIndented : MindLayoutType.leftTopIndented;
|
|
638
|
-
break;
|
|
639
|
-
case MindLayoutType.rightTopIndented:
|
|
640
|
-
inverseDirectionLayout = isHorizontal ? MindLayoutType.leftTopIndented : MindLayoutType.rightBottomIndented;
|
|
641
|
-
break;
|
|
642
|
-
case MindLayoutType.leftTopIndented:
|
|
643
|
-
inverseDirectionLayout = isHorizontal ? MindLayoutType.rightTopIndented : MindLayoutType.leftBottomIndented;
|
|
644
|
-
break;
|
|
645
|
-
}
|
|
646
|
-
return inverseDirectionLayout;
|
|
647
|
-
};
|
|
648
|
-
const getLayoutDirection$1 = (root) => {
|
|
649
|
-
const layout = root.layout || getDefaultLayout();
|
|
650
|
-
return LayoutDirectionsMap[layout];
|
|
651
|
-
};
|
|
652
|
-
const getDefaultLayout = () => {
|
|
653
|
-
return MindLayoutType.standard;
|
|
654
|
-
};
|
|
655
|
-
const getAvailableSubLayoutsByLayoutDirections = (directions) => {
|
|
656
|
-
const result = [];
|
|
657
|
-
const reverseDirections = directions.map(getLayoutReverseDirection);
|
|
658
|
-
for (const key in MindLayoutType) {
|
|
659
|
-
const layout = MindLayoutType[key];
|
|
660
|
-
const layoutDirections = LayoutDirectionsMap[layout];
|
|
661
|
-
if (layoutDirections) {
|
|
662
|
-
const hasSameDirection = layoutDirections.some(d => directions.includes(d));
|
|
663
|
-
const hasReverseDirection = layoutDirections.some(r => reverseDirections.includes(r));
|
|
664
|
-
if (hasSameDirection && !hasReverseDirection) {
|
|
665
|
-
result.push(layout);
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
return result;
|
|
670
|
-
};
|
|
671
|
-
const getLayoutReverseDirection = (layoutDirection) => {
|
|
672
|
-
let reverseDirection = LayoutDirection.right;
|
|
673
|
-
switch (layoutDirection) {
|
|
674
|
-
case LayoutDirection.top:
|
|
675
|
-
reverseDirection = LayoutDirection.bottom;
|
|
676
|
-
break;
|
|
677
|
-
case LayoutDirection.bottom:
|
|
678
|
-
reverseDirection = LayoutDirection.top;
|
|
679
|
-
break;
|
|
680
|
-
case LayoutDirection.right:
|
|
681
|
-
reverseDirection = LayoutDirection.left;
|
|
682
|
-
break;
|
|
683
|
-
case LayoutDirection.left:
|
|
684
|
-
reverseDirection = LayoutDirection.right;
|
|
685
|
-
break;
|
|
686
|
-
}
|
|
687
|
-
return reverseDirection;
|
|
688
|
-
};
|
|
689
|
-
const getRootLayout = (root) => {
|
|
690
|
-
return root.layout || getDefaultLayout();
|
|
691
|
-
};
|
|
692
|
-
|
|
693
763
|
const adjustRootToNode = (board, node) => {
|
|
694
764
|
const newNode = { ...node };
|
|
695
765
|
delete newNode.isRoot;
|
|
@@ -2193,73 +2263,6 @@ const deleteElementsHandleRightNodeCount = (board, deletableElements, effectedRi
|
|
|
2193
2263
|
return effectedRightNodeCount;
|
|
2194
2264
|
};
|
|
2195
2265
|
|
|
2196
|
-
const getLayoutOptions = (board) => {
|
|
2197
|
-
function getMainAxle(element, parent) {
|
|
2198
|
-
const strokeWidth = element.strokeWidth || STROKE_WIDTH;
|
|
2199
|
-
if (element.isRoot) {
|
|
2200
|
-
return BASE * 12;
|
|
2201
|
-
}
|
|
2202
|
-
if (parent && parent.isRoot()) {
|
|
2203
|
-
return BASE * 3 + strokeWidth / 2;
|
|
2204
|
-
}
|
|
2205
|
-
return BASE * 3 + strokeWidth / 2;
|
|
2206
|
-
}
|
|
2207
|
-
function getSecondAxle(element, parent) {
|
|
2208
|
-
const strokeWidth = element.strokeWidth || STROKE_WIDTH;
|
|
2209
|
-
if (element.isRoot) {
|
|
2210
|
-
return BASE * 10 + strokeWidth / 2;
|
|
2211
|
-
}
|
|
2212
|
-
return BASE * 6 + strokeWidth / 2;
|
|
2213
|
-
}
|
|
2214
|
-
return {
|
|
2215
|
-
getHeight(element) {
|
|
2216
|
-
return NodeSpace.getNodeHeight(board, element);
|
|
2217
|
-
},
|
|
2218
|
-
getWidth(element) {
|
|
2219
|
-
return NodeSpace.getNodeWidth(board, element);
|
|
2220
|
-
},
|
|
2221
|
-
getHorizontalGap(element, parent) {
|
|
2222
|
-
const _layout = (parent && parent.layout) || getRootLayout(element);
|
|
2223
|
-
const isHorizontal = isHorizontalLayout(_layout);
|
|
2224
|
-
const strokeWidth = element.strokeWidth || STROKE_WIDTH;
|
|
2225
|
-
if (isIndentedLayout(_layout)) {
|
|
2226
|
-
return BASE * 4 + strokeWidth;
|
|
2227
|
-
}
|
|
2228
|
-
if (!isHorizontal) {
|
|
2229
|
-
return getMainAxle(element, parent);
|
|
2230
|
-
}
|
|
2231
|
-
else {
|
|
2232
|
-
return getSecondAxle(element, parent);
|
|
2233
|
-
}
|
|
2234
|
-
},
|
|
2235
|
-
getVerticalGap(element, parent) {
|
|
2236
|
-
const _layout = (parent && parent.layout) || getRootLayout(element);
|
|
2237
|
-
if (isIndentedLayout(_layout)) {
|
|
2238
|
-
return BASE;
|
|
2239
|
-
}
|
|
2240
|
-
const isHorizontal = isHorizontalLayout(_layout);
|
|
2241
|
-
if (isHorizontal) {
|
|
2242
|
-
return getMainAxle(element, parent);
|
|
2243
|
-
}
|
|
2244
|
-
else {
|
|
2245
|
-
return getSecondAxle(element, parent);
|
|
2246
|
-
}
|
|
2247
|
-
},
|
|
2248
|
-
getVerticalConnectingPosition(element, parent) {
|
|
2249
|
-
if (element.shape === MindElementShape.underline && parent && isHorizontalLogicLayout(parent.layout)) {
|
|
2250
|
-
return ConnectingPosition.bottom;
|
|
2251
|
-
}
|
|
2252
|
-
return undefined;
|
|
2253
|
-
},
|
|
2254
|
-
getExtendHeight(node) {
|
|
2255
|
-
return BASE * 6;
|
|
2256
|
-
},
|
|
2257
|
-
getIndentedCrossLevelGap() {
|
|
2258
|
-
return BASE * 2;
|
|
2259
|
-
}
|
|
2260
|
-
};
|
|
2261
|
-
};
|
|
2262
|
-
|
|
2263
2266
|
/**
|
|
2264
2267
|
* get correctly layout:
|
|
2265
2268
|
* 1. root is standard -> left or right
|
|
@@ -2481,12 +2484,14 @@ function getRectangleByNode(node) {
|
|
|
2481
2484
|
height
|
|
2482
2485
|
};
|
|
2483
2486
|
}
|
|
2484
|
-
function getRectangleByElement(board,
|
|
2487
|
+
function getRectangleByElement(board, element) {
|
|
2488
|
+
const width = NodeSpace.getNodeWidth(board, element);
|
|
2489
|
+
const height = NodeSpace.getNodeHeight(board, element);
|
|
2485
2490
|
const nodeRectangle = {
|
|
2486
|
-
x:
|
|
2487
|
-
y:
|
|
2488
|
-
width
|
|
2489
|
-
height
|
|
2491
|
+
x: element.points[0][0],
|
|
2492
|
+
y: element.points[0][1],
|
|
2493
|
+
width,
|
|
2494
|
+
height
|
|
2490
2495
|
};
|
|
2491
2496
|
return nodeRectangle;
|
|
2492
2497
|
}
|
|
@@ -2784,8 +2789,8 @@ function drawAbstractIncludedOutline(board, roughSVG, element, activeHandlePosit
|
|
|
2784
2789
|
const startHandle = roughSVG.line(startPoint1[0], startPoint1[1], startPoint2[0], startPoint2[1], getHandleOption(activeHandlePosition === AbstractHandlePosition.start));
|
|
2785
2790
|
const endHandle = roughSVG.line(endPoint1[0], endPoint1[1], endPoint2[0], endPoint2[1], getHandleOption(activeHandlePosition === AbstractHandlePosition.end));
|
|
2786
2791
|
handleBoardClass(board, activeHandlePosition, isHorizontal);
|
|
2787
|
-
startHandle
|
|
2788
|
-
endHandle
|
|
2792
|
+
setStrokeLinecap(startHandle, 'round');
|
|
2793
|
+
setStrokeLinecap(endHandle, 'round');
|
|
2789
2794
|
abstractIncludedG.append(startHandle);
|
|
2790
2795
|
abstractIncludedG.append(endHandle);
|
|
2791
2796
|
abstractIncludedG.append(rectangle);
|
|
@@ -3718,15 +3723,17 @@ const withCreateMind = (board) => {
|
|
|
3718
3723
|
const newBoard = board;
|
|
3719
3724
|
const { keydown, mousedown, mousemove, mouseup } = board;
|
|
3720
3725
|
let fakeCreateNodeRef = null;
|
|
3726
|
+
let emptyMind = null;
|
|
3721
3727
|
newBoard.mousedown = (event) => {
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3728
|
+
const isMindPointer = PlaitBoard.isPointer(board, MindPointerType.mind);
|
|
3729
|
+
let movingPoint = PlaitBoard.getMovingPointInBoard(board);
|
|
3730
|
+
if (movingPoint && isDrawingMode(board) && isMindPointer) {
|
|
3731
|
+
movingPoint = transformPoint(board, toPoint(movingPoint[0], movingPoint[1], PlaitBoard.getHost(board)));
|
|
3732
|
+
const emptyMind = createEmptyMind(newBoard, movingPoint);
|
|
3733
|
+
Transforms.insertNode(board, emptyMind, [board.children.length]);
|
|
3734
|
+
clearSelectedElement(board);
|
|
3735
|
+
addSelectedElement(board, emptyMind);
|
|
3736
|
+
BoardTransforms.updatePointerType(board, PlaitPointerType.selection);
|
|
3730
3737
|
}
|
|
3731
3738
|
mousedown(event);
|
|
3732
3739
|
};
|
|
@@ -3735,13 +3742,14 @@ const withCreateMind = (board) => {
|
|
|
3735
3742
|
mousemove(event);
|
|
3736
3743
|
return;
|
|
3737
3744
|
}
|
|
3738
|
-
|
|
3745
|
+
const isMindPointer = PlaitBoard.isPointer(board, MindPointerType.mind);
|
|
3746
|
+
if (isDndMode(board) && isMindPointer) {
|
|
3739
3747
|
throttleRAF(() => {
|
|
3740
|
-
|
|
3748
|
+
let movingPoint = PlaitBoard.getMovingPointInBoard(board);
|
|
3741
3749
|
if (movingPoint) {
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
const nodeRectangle = getRectangleByElement(newBoard,
|
|
3750
|
+
movingPoint = transformPoint(newBoard, toPoint(movingPoint[0], movingPoint[1], PlaitBoard.getHost(board)));
|
|
3751
|
+
emptyMind = createEmptyMind(newBoard, movingPoint);
|
|
3752
|
+
const nodeRectangle = getRectangleByElement(newBoard, emptyMind);
|
|
3745
3753
|
const nodeG = drawRoundRectangleByElement(board, nodeRectangle, emptyMind);
|
|
3746
3754
|
const topicRectangle = getTopicRectangleByElement(newBoard, nodeRectangle, emptyMind);
|
|
3747
3755
|
if (!fakeCreateNodeRef) {
|
|
@@ -3781,14 +3789,12 @@ const withCreateMind = (board) => {
|
|
|
3781
3789
|
mousemove(event);
|
|
3782
3790
|
};
|
|
3783
3791
|
newBoard.mouseup = (event) => {
|
|
3784
|
-
|
|
3785
|
-
if (movingPoint && fakeCreateNodeRef && PlaitBoard.isPointer(board, MindPointerType.mind)) {
|
|
3786
|
-
const targetPoint = transformPoint(board, toPoint(movingPoint[0], movingPoint[1], PlaitBoard.getHost(board)));
|
|
3787
|
-
const emptyMind = createEmptyMind(targetPoint);
|
|
3792
|
+
if (emptyMind) {
|
|
3788
3793
|
Transforms.insertNode(board, emptyMind, [board.children.length]);
|
|
3789
3794
|
clearSelectedElement(board);
|
|
3790
3795
|
addSelectedElement(board, emptyMind);
|
|
3791
3796
|
BoardTransforms.updatePointerType(board, PlaitPointerType.selection);
|
|
3797
|
+
emptyMind = null;
|
|
3792
3798
|
}
|
|
3793
3799
|
destroy();
|
|
3794
3800
|
mouseup(event);
|
|
@@ -3800,6 +3806,7 @@ const withCreateMind = (board) => {
|
|
|
3800
3806
|
}
|
|
3801
3807
|
if (event.key === DefaultHotkey && !PlaitBoard.isPointer(board, MindPointerType.mind)) {
|
|
3802
3808
|
BoardTransforms.updatePointerType(board, MindPointerType.mind);
|
|
3809
|
+
setCreationMode(board, BoardCreationMode.drawing);
|
|
3803
3810
|
event.preventDefault();
|
|
3804
3811
|
return;
|
|
3805
3812
|
}
|
|
@@ -4455,5 +4462,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImpor
|
|
|
4455
4462
|
* Generated bundle index. Do not edit.
|
|
4456
4463
|
*/
|
|
4457
4464
|
|
|
4458
|
-
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE, BRANCH_FONT_FAMILY, BRANCH_WIDTH, BaseDrawer, BranchShape, DEFAULT_FONT_FAMILY, DefaultAbstractNodeStyle, DefaultNodeStyle, ELEMENT_TO_NODE, EXTEND_DIAMETER, EXTEND_OFFSET, GRAY_COLOR, INHERIT_ATTRIBUTE_KEYS, IS_DRAGGING, LayoutDirection, LayoutDirectionsMap, MindColorfulThemeColor, MindDarkThemeColor, MindDefaultThemeColor, MindElement, MindElementShape, MindEmojiBaseComponent, MindImageBaseComponent, MindModule, MindNode, MindNodeComponent, MindPointerType, MindQueries, MindRetroThemeColor, MindSoftThemeColor, MindStarryThemeColor, MindThemeColor, MindThemeColors, MindTransforms, NodeSpace, NodeTopicThreshold, PRIMARY_COLOR, PlaitMind, PlaitMindComponent, QUICK_INSERT_CIRCLE_COLOR, QUICK_INSERT_CIRCLE_OFFSET, QUICK_INSERT_INNER_CROSS_COLOR, ROOT_TOPIC_FONT_SIZE, ROOT_TOPIC_HEIGHT, STROKE_WIDTH, TOPIC_COLOR, TOPIC_DEFAULT_MAX_WORD_COUNT, TOPIC_FONT_SIZE, TRANSPARENT, WithMindPluginKey, addActiveOnDragOrigin, addSelectedImageElement, adjustAbstractToNode, adjustNodeToRoot, adjustRootToNode, buildImage, canSetAbstract, copyNewNode, correctLayoutByDirection, createDefaultMind, createEmptyMind, createMindElement, deleteElementHandleAbstract, deleteElementsHandleRightNodeCount, detectDropTarget, directionCorrector, directionDetector, divideElementByParent, drawFakeDragNode, drawFakeDropNode, editTopic, extractNodesText, findLastChild, findLocationLeftIndex, getAbstractBranchColor, getAbstractBranchWidth, getAbstractHandleRectangle, getAllowedDirection, getAvailableSubLayoutsByLayoutDirections, getBehindAbstracts, getBranchColorByMindElement, getBranchDirectionsByLayouts, getBranchShapeByMindElement, getBranchWidthByMindElement, getChildrenCount, getCorrespondingAbstract, getDefaultBranchColor, getDefaultBranchColorByIndex, getDefaultLayout, getEmojiFontSize, getEmojiForeignRectangle, getEmojiRectangle, getEmojisWidthHeight, getFillByElement, getFirstLevelElement, getFontSizeBySlateElement, getHitAbstractHandle, getHitImageResizeHandleDirection, getImageForeignRectangle, getInCorrectLayoutDirection, getLayoutDirection$1 as getLayoutDirection, getLayoutOptions, getLayoutReverseDirection, getLocationScope, getMindThemeColor, getNewNodeHeight, getNextBranchColor, getNodeDefaultFontSize, getOverallAbstracts, getPathByDropTarget, getRectangleByElement, getRectangleByNode, getRectangleByResizingLocation, getRelativeStartEndByAbstractRef, getRootLayout, getSelectedImageElement, getSelectedMindElements, getShapeByElement, getStrokeByMindElement, getStrokeWidthByElement, getTopicRectangleByElement, getTopicRectangleByNode, getValidAbstractRefs, handleTouchedAbstract, hasAfterDraw, hasPreviousOrNextOfDropPath, insertElementHandleAbstract, insertElementHandleRightNodeCount, insertMindElement, isChildElement, isChildOfAbstract, isChildRight, isChildUp, isCorrectLayout, isDragging, isDropStandardRight, isHitEmojis, isHitImage, isHitMindElement, isInRightBranchOfStandardLayout, isMixedLayout, isSetAbstract, isValidTarget, removeActiveOnDragOrigin, removeSelectedImageElement, selectImage, separateChildren, setImageFocus, setIsDragging, temporaryDisableSelection, withMind, withMindExtend };
|
|
4465
|
+
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE, BRANCH_FONT_FAMILY, BRANCH_WIDTH, BaseDrawer, BranchShape, DEFAULT_FONT_FAMILY, DefaultAbstractNodeStyle, DefaultNodeStyle, ELEMENT_TO_NODE, EXTEND_DIAMETER, EXTEND_OFFSET, GRAY_COLOR, INHERIT_ATTRIBUTE_KEYS, IS_DRAGGING, LayoutDirection, LayoutDirectionsMap, MindColorfulThemeColor, MindDarkThemeColor, MindDefaultThemeColor, MindElement, MindElementShape, MindEmojiBaseComponent, MindImageBaseComponent, MindModule, MindNode, MindNodeComponent, MindPointerType, MindQueries, MindRetroThemeColor, MindSoftThemeColor, MindStarryThemeColor, MindThemeColor, MindThemeColors, MindTransforms, NodeSpace, NodeTopicThreshold, PRIMARY_COLOR, PlaitMind, PlaitMindComponent, QUICK_INSERT_CIRCLE_COLOR, QUICK_INSERT_CIRCLE_OFFSET, QUICK_INSERT_INNER_CROSS_COLOR, ROOT_TOPIC_FONT_SIZE, ROOT_TOPIC_HEIGHT, ROOT_TOPIC_WIDTH, STROKE_WIDTH, TOPIC_COLOR, TOPIC_DEFAULT_MAX_WORD_COUNT, TOPIC_FONT_SIZE, TRANSPARENT, WithMindPluginKey, addActiveOnDragOrigin, addSelectedImageElement, adjustAbstractToNode, adjustNodeToRoot, adjustRootToNode, buildImage, canSetAbstract, copyNewNode, correctLayoutByDirection, createDefaultMind, createEmptyMind, createMindElement, deleteElementHandleAbstract, deleteElementsHandleRightNodeCount, detectDropTarget, directionCorrector, directionDetector, divideElementByParent, drawFakeDragNode, drawFakeDropNode, editTopic, extractNodesText, findLastChild, findLocationLeftIndex, getAbstractBranchColor, getAbstractBranchWidth, getAbstractHandleRectangle, getAllowedDirection, getAvailableSubLayoutsByLayoutDirections, getBehindAbstracts, getBranchColorByMindElement, getBranchDirectionsByLayouts, getBranchShapeByMindElement, getBranchWidthByMindElement, getChildrenCount, getCorrespondingAbstract, getDefaultBranchColor, getDefaultBranchColorByIndex, getDefaultLayout, getEmojiFontSize, getEmojiForeignRectangle, getEmojiRectangle, getEmojisWidthHeight, getFillByElement, getFirstLevelElement, getFontSizeBySlateElement, getHitAbstractHandle, getHitImageResizeHandleDirection, getImageForeignRectangle, getInCorrectLayoutDirection, getLayoutDirection$1 as getLayoutDirection, getLayoutOptions, getLayoutReverseDirection, getLocationScope, getMindThemeColor, getNewNodeHeight, getNextBranchColor, getNodeDefaultFontSize, getOverallAbstracts, getPathByDropTarget, getRectangleByElement, getRectangleByNode, getRectangleByResizingLocation, getRelativeStartEndByAbstractRef, getRootLayout, getSelectedImageElement, getSelectedMindElements, getShapeByElement, getStrokeByMindElement, getStrokeWidthByElement, getTopicRectangleByElement, getTopicRectangleByNode, getValidAbstractRefs, handleTouchedAbstract, hasAfterDraw, hasPreviousOrNextOfDropPath, insertElementHandleAbstract, insertElementHandleRightNodeCount, insertMindElement, isChildElement, isChildOfAbstract, isChildRight, isChildUp, isCorrectLayout, isDragging, isDropStandardRight, isHitEmojis, isHitImage, isHitMindElement, isInRightBranchOfStandardLayout, isMixedLayout, isSetAbstract, isValidTarget, removeActiveOnDragOrigin, removeSelectedImageElement, selectImage, separateChildren, setImageFocus, setIsDragging, temporaryDisableSelection, withMind, withMindExtend };
|
|
4459
4466
|
//# sourceMappingURL=plait-mind.mjs.map
|