@plait/mind 0.27.0-next.2 → 0.27.0-next.4

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.
Files changed (34) hide show
  1. package/base/emoji-base.component.d.ts +1 -1
  2. package/constants/node-topic-style.d.ts +1 -0
  3. package/esm2022/base/emoji-base.component.mjs +5 -5
  4. package/esm2022/constants/node-topic-style.mjs +2 -1
  5. package/esm2022/interfaces/element.mjs +1 -1
  6. package/esm2022/mind-node.component.mjs +234 -0
  7. package/esm2022/mind.component.mjs +2 -2
  8. package/esm2022/mind.module.mjs +2 -2
  9. package/esm2022/plugins/with-mind-create.mjs +22 -19
  10. package/esm2022/plugins/with-mind.mjs +2 -2
  11. package/esm2022/plugins/with-node-resize.mjs +2 -2
  12. package/esm2022/public-api.mjs +2 -2
  13. package/esm2022/transforms/node.mjs +2 -2
  14. package/esm2022/utils/abstract/resize.mjs +1 -1
  15. package/esm2022/utils/dnd/common.mjs +1 -1
  16. package/esm2022/utils/draw/abstract-outline.mjs +4 -4
  17. package/esm2022/utils/draw/node-dnd.mjs +1 -1
  18. package/esm2022/utils/node/common.mjs +1 -1
  19. package/esm2022/utils/node/create-node.mjs +9 -6
  20. package/esm2022/utils/node/dynamic-width.mjs +2 -5
  21. package/esm2022/utils/node/image.mjs +1 -1
  22. package/esm2022/utils/position/node.mjs +8 -6
  23. package/esm2022/utils/position/topic.mjs +2 -3
  24. package/fesm2022/plait-mind.mjs +223 -237
  25. package/fesm2022/plait-mind.mjs.map +1 -1
  26. package/mind.component.d.ts +1 -1
  27. package/mind.module.d.ts +1 -1
  28. package/package.json +1 -1
  29. package/public-api.d.ts +1 -1
  30. package/styles/styles.scss +0 -3
  31. package/utils/node/create-node.d.ts +4 -4
  32. package/utils/position/node.d.ts +1 -1
  33. package/esm2022/node.component.mjs +0 -251
  34. /package/{node.component.d.ts → mind-node.component.d.ts} +0 -0
@@ -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, throttleRAF, BoardTransforms, removeSelectedElement, PlaitHistoryBoard, hotkeys, setClipboardDataByMedia, getClipboardDataByMedia, ResizeCursorClass, preventTouchMove, PRESS_AND_MOVE_BUFFER, MERGING, getDataFromClipboard } from '@plait/core';
5
- import { MindLayoutType, isIndentedLayout, AbstractNode, isStandardLayout, isHorizontalLogicLayout, isVerticalLogicLayout, getNonAbstractChildren, isLeftLayout, isRightLayout, isTopLayout, isBottomLayout, isHorizontalLayout, getCorrectStartEnd, ConnectingPosition, getAbstractLayout, GlobalLayout } from '@plait/layouts';
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"';
@@ -385,8 +386,7 @@ const isHitEmojis = (board, element, point) => {
385
386
  function getTopicRectangleByNode(board, node) {
386
387
  let nodeRectangle = getRectangleByNode(node);
387
388
  const result = getTopicRectangleByElement(board, nodeRectangle, node.origin);
388
- // add buffer width to avoid unexpected text breaks in different scene
389
- result.width = result.width + 4;
389
+ result.width = result.width;
390
390
  return result;
391
391
  }
392
392
  function getTopicRectangleByElement(board, nodeRectangle, element) {
@@ -446,15 +446,187 @@ const getSelectedMindElements = (board) => {
446
446
  return selectedElements;
447
447
  };
448
448
 
449
- const createEmptyMind = (point) => {
450
- const element = createMindElement('思维导图', 72, ROOT_TOPIC_HEIGHT, { layout: MindLayoutType.right });
449
+ const getBranchDirectionsByLayouts = (branchLayouts) => {
450
+ const branchDirections = [];
451
+ branchLayouts.forEach(l => {
452
+ const directions = LayoutDirectionsMap[l];
453
+ directions.forEach(d => {
454
+ if (!branchDirections.includes(d) && !branchDirections.includes(getLayoutReverseDirection(d))) {
455
+ branchDirections.push(d);
456
+ }
457
+ });
458
+ });
459
+ return branchDirections;
460
+ };
461
+ const isCorrectLayout = (root, layout) => {
462
+ const rootLayout = root.layout || getDefaultLayout();
463
+ return !getInCorrectLayoutDirection(rootLayout, layout);
464
+ };
465
+ const isMixedLayout = (parentLayout, layout) => {
466
+ return (!isIndentedLayout(parentLayout) && isIndentedLayout(layout)) || (isIndentedLayout(parentLayout) && !isIndentedLayout(layout));
467
+ };
468
+ const getInCorrectLayoutDirection = (rootLayout, layout) => {
469
+ const directions = LayoutDirectionsMap[rootLayout];
470
+ const subLayoutDirections = LayoutDirectionsMap[layout];
471
+ if (!subLayoutDirections) {
472
+ throw new Error(`unexpected layout: ${layout} on correct layout`);
473
+ }
474
+ return subLayoutDirections.find(d => directions.includes(getLayoutReverseDirection(d)));
475
+ };
476
+ const correctLayoutByDirection = (layout, direction) => {
477
+ const isHorizontal = direction === LayoutDirection.left || direction === LayoutDirection.right ? true : false;
478
+ let inverseDirectionLayout = MindLayoutType.standard;
479
+ switch (layout) {
480
+ case MindLayoutType.left:
481
+ inverseDirectionLayout = MindLayoutType.right;
482
+ break;
483
+ case MindLayoutType.right:
484
+ inverseDirectionLayout = MindLayoutType.left;
485
+ break;
486
+ case MindLayoutType.downward:
487
+ inverseDirectionLayout = MindLayoutType.upward;
488
+ break;
489
+ case MindLayoutType.upward:
490
+ inverseDirectionLayout = MindLayoutType.downward;
491
+ break;
492
+ case MindLayoutType.rightBottomIndented:
493
+ inverseDirectionLayout = isHorizontal ? MindLayoutType.leftBottomIndented : MindLayoutType.rightTopIndented;
494
+ break;
495
+ case MindLayoutType.leftBottomIndented:
496
+ inverseDirectionLayout = isHorizontal ? MindLayoutType.rightBottomIndented : MindLayoutType.leftTopIndented;
497
+ break;
498
+ case MindLayoutType.rightTopIndented:
499
+ inverseDirectionLayout = isHorizontal ? MindLayoutType.leftTopIndented : MindLayoutType.rightBottomIndented;
500
+ break;
501
+ case MindLayoutType.leftTopIndented:
502
+ inverseDirectionLayout = isHorizontal ? MindLayoutType.rightTopIndented : MindLayoutType.leftBottomIndented;
503
+ break;
504
+ }
505
+ return inverseDirectionLayout;
506
+ };
507
+ const getLayoutDirection$1 = (root) => {
508
+ const layout = root.layout || getDefaultLayout();
509
+ return LayoutDirectionsMap[layout];
510
+ };
511
+ const getDefaultLayout = () => {
512
+ return MindLayoutType.standard;
513
+ };
514
+ const getAvailableSubLayoutsByLayoutDirections = (directions) => {
515
+ const result = [];
516
+ const reverseDirections = directions.map(getLayoutReverseDirection);
517
+ for (const key in MindLayoutType) {
518
+ const layout = MindLayoutType[key];
519
+ const layoutDirections = LayoutDirectionsMap[layout];
520
+ if (layoutDirections) {
521
+ const hasSameDirection = layoutDirections.some(d => directions.includes(d));
522
+ const hasReverseDirection = layoutDirections.some(r => reverseDirections.includes(r));
523
+ if (hasSameDirection && !hasReverseDirection) {
524
+ result.push(layout);
525
+ }
526
+ }
527
+ }
528
+ return result;
529
+ };
530
+ const getLayoutReverseDirection = (layoutDirection) => {
531
+ let reverseDirection = LayoutDirection.right;
532
+ switch (layoutDirection) {
533
+ case LayoutDirection.top:
534
+ reverseDirection = LayoutDirection.bottom;
535
+ break;
536
+ case LayoutDirection.bottom:
537
+ reverseDirection = LayoutDirection.top;
538
+ break;
539
+ case LayoutDirection.right:
540
+ reverseDirection = LayoutDirection.left;
541
+ break;
542
+ case LayoutDirection.left:
543
+ reverseDirection = LayoutDirection.right;
544
+ break;
545
+ }
546
+ return reverseDirection;
547
+ };
548
+ const getRootLayout = (root) => {
549
+ return root.layout || getDefaultLayout();
550
+ };
551
+
552
+ const getLayoutOptions = (board) => {
553
+ function getMainAxle(element, parent) {
554
+ const strokeWidth = element.strokeWidth || STROKE_WIDTH;
555
+ if (element.isRoot) {
556
+ return BASE * 12;
557
+ }
558
+ if (parent && parent.isRoot()) {
559
+ return BASE * 3 + strokeWidth / 2;
560
+ }
561
+ return BASE * 3 + strokeWidth / 2;
562
+ }
563
+ function getSecondAxle(element, parent) {
564
+ const strokeWidth = element.strokeWidth || STROKE_WIDTH;
565
+ if (element.isRoot) {
566
+ return BASE * 10 + strokeWidth / 2;
567
+ }
568
+ return BASE * 6 + strokeWidth / 2;
569
+ }
570
+ return {
571
+ getHeight(element) {
572
+ return NodeSpace.getNodeHeight(board, element);
573
+ },
574
+ getWidth(element) {
575
+ return NodeSpace.getNodeWidth(board, element);
576
+ },
577
+ getHorizontalGap(element, parent) {
578
+ const _layout = (parent && parent.layout) || getRootLayout(element);
579
+ const isHorizontal = isHorizontalLayout(_layout);
580
+ const strokeWidth = element.strokeWidth || STROKE_WIDTH;
581
+ if (isIndentedLayout(_layout)) {
582
+ return BASE * 4 + strokeWidth;
583
+ }
584
+ if (!isHorizontal) {
585
+ return getMainAxle(element, parent);
586
+ }
587
+ else {
588
+ return getSecondAxle(element, parent);
589
+ }
590
+ },
591
+ getVerticalGap(element, parent) {
592
+ const _layout = (parent && parent.layout) || getRootLayout(element);
593
+ if (isIndentedLayout(_layout)) {
594
+ return BASE;
595
+ }
596
+ const isHorizontal = isHorizontalLayout(_layout);
597
+ if (isHorizontal) {
598
+ return getMainAxle(element, parent);
599
+ }
600
+ else {
601
+ return getSecondAxle(element, parent);
602
+ }
603
+ },
604
+ getVerticalConnectingPosition(element, parent) {
605
+ if (element.shape === MindElementShape.underline && parent && isHorizontalLogicLayout(parent.layout)) {
606
+ return ConnectingPosition.bottom;
607
+ }
608
+ return undefined;
609
+ },
610
+ getExtendHeight(node) {
611
+ return BASE * 6;
612
+ },
613
+ getIndentedCrossLevelGap() {
614
+ return BASE * 2;
615
+ }
616
+ };
617
+ };
618
+
619
+ const createEmptyMind = (board, point) => {
620
+ const element = createMindElement('思维导图', ROOT_TOPIC_WIDTH, ROOT_TOPIC_HEIGHT, { layout: MindLayoutType.right });
451
621
  element.isRoot = true;
452
- element.points = [point];
453
622
  element.type = 'mindmap';
623
+ const width = NodeSpace.getNodeWidth(board, element);
624
+ const height = NodeSpace.getNodeHeight(board, element);
625
+ element.points = [[point[0] - width / 2, point[1] - height / 2]];
454
626
  return element;
455
627
  };
456
628
  const createDefaultMind = (point, rightNodeCount, layout) => {
457
- const root = createMindElement('思维导图', 72, ROOT_TOPIC_HEIGHT, { layout });
629
+ const root = createMindElement('思维导图', ROOT_TOPIC_WIDTH, ROOT_TOPIC_HEIGHT, { layout });
458
630
  root.rightNodeCount = rightNodeCount;
459
631
  root.isRoot = true;
460
632
  root.type = 'mindmap';
@@ -587,109 +759,6 @@ const divideElementByParent = (elements) => {
587
759
  return { parentElements, abstractIncludedGroups };
588
760
  };
589
761
 
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
762
  const adjustRootToNode = (board, node) => {
694
763
  const newNode = { ...node };
695
764
  delete newNode.isRoot;
@@ -1008,7 +1077,7 @@ const normalizeWidthAndHeight = (board, element, width, height) => {
1008
1077
  const minWidth = NodeSpace.getNodeTopicMinWidth(board, element, element.isRoot);
1009
1078
  const newWidth = width < minWidth * board.viewport.zoom ? minWidth : width / board.viewport.zoom;
1010
1079
  const newHeight = height / board.viewport.zoom;
1011
- return { width: newWidth, height: newHeight };
1080
+ return { width: Math.ceil(newWidth), height: newHeight };
1012
1081
  };
1013
1082
  const setTopic = (board, element, topic, width, height) => {
1014
1083
  const newElement = {
@@ -1127,11 +1196,8 @@ const replaceEmoji = (board, element, oldEmoji, newEmoji) => {
1127
1196
  const getNewNodeHeight = (board, element, newNodeDynamicWidth) => {
1128
1197
  const textManage = PlaitElement.getComponent(element).textManage;
1129
1198
  const { height } = textManage.getSize();
1130
- textManage.updateWidth(newNodeDynamicWidth);
1199
+ textManage.updateRectangleWidth(newNodeDynamicWidth);
1131
1200
  const { height: newHeight } = textManage.getSize();
1132
- if (!element.manualWidth) {
1133
- textManage.updateWidth(0);
1134
- }
1135
1201
  if (height !== newHeight) {
1136
1202
  return newHeight;
1137
1203
  }
@@ -2193,73 +2259,6 @@ const deleteElementsHandleRightNodeCount = (board, deletableElements, effectedRi
2193
2259
  return effectedRightNodeCount;
2194
2260
  };
2195
2261
 
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
2262
  /**
2264
2263
  * get correctly layout:
2265
2264
  * 1. root is standard -> left or right
@@ -2481,12 +2480,14 @@ function getRectangleByNode(node) {
2481
2480
  height
2482
2481
  };
2483
2482
  }
2484
- function getRectangleByElement(board, originPoint, element) {
2483
+ function getRectangleByElement(board, element) {
2484
+ const width = NodeSpace.getNodeWidth(board, element);
2485
+ const height = NodeSpace.getNodeHeight(board, element);
2485
2486
  const nodeRectangle = {
2486
- x: originPoint[0],
2487
- y: originPoint[1],
2488
- width: NodeSpace.getNodeWidth(board, element),
2489
- height: NodeSpace.getNodeHeight(board, element)
2487
+ x: element.points[0][0],
2488
+ y: element.points[0][1],
2489
+ width,
2490
+ height
2490
2491
  };
2491
2492
  return nodeRectangle;
2492
2493
  }
@@ -2784,8 +2785,8 @@ function drawAbstractIncludedOutline(board, roughSVG, element, activeHandlePosit
2784
2785
  const startHandle = roughSVG.line(startPoint1[0], startPoint1[1], startPoint2[0], startPoint2[1], getHandleOption(activeHandlePosition === AbstractHandlePosition.start));
2785
2786
  const endHandle = roughSVG.line(endPoint1[0], endPoint1[1], endPoint2[0], endPoint2[1], getHandleOption(activeHandlePosition === AbstractHandlePosition.end));
2786
2787
  handleBoardClass(board, activeHandlePosition, isHorizontal);
2787
- startHandle.setAttribute('stroke-linecap', 'round');
2788
- endHandle.setAttribute('stroke-linecap', 'round');
2788
+ setStrokeLinecap(startHandle, 'round');
2789
+ setStrokeLinecap(endHandle, 'round');
2789
2790
  abstractIncludedG.append(startHandle);
2790
2791
  abstractIncludedG.append(endHandle);
2791
2792
  abstractIncludedG.append(rectangle);
@@ -3045,9 +3046,6 @@ class NodeImageDrawer {
3045
3046
  }
3046
3047
  }
3047
3048
 
3048
- // 1. When the text at the end has an italic attribute, the text is partially covered
3049
- // 2. There will be some differences in the width measured by different browsers
3050
- const WIDTH_BUFFER = 4;
3051
3049
  class MindNodeComponent extends PlaitPluginElementComponent {
3052
3050
  constructor(viewContainerRef, cdr) {
3053
3051
  super(cdr);
@@ -3083,7 +3081,12 @@ class MindNodeComponent extends PlaitPluginElementComponent {
3083
3081
  },
3084
3082
  textPlugins: plugins,
3085
3083
  getMaxWidth: () => {
3086
- return NodeTopicThreshold.defaultTextMaxWidth;
3084
+ if (this.element.manualWidth) {
3085
+ return NodeSpace.getNodeDynamicWidth(this.board, this.element);
3086
+ }
3087
+ else {
3088
+ return Math.max(NodeSpace.getNodeDynamicWidth(this.board, this.element), NodeTopicThreshold.defaultTextMaxWidth);
3089
+ }
3087
3090
  }
3088
3091
  });
3089
3092
  }
@@ -3199,36 +3202,17 @@ class MindNodeComponent extends PlaitPluginElementComponent {
3199
3202
  drawTopic() {
3200
3203
  this.textManage.draw(this.element.data.topic);
3201
3204
  this.g.append(this.textManage.g);
3202
- if (this.element.manualWidth) {
3203
- const width = NodeSpace.getNodeDynamicWidth(this.board, this.element);
3204
- this.textManage.updateWidth(width);
3205
- }
3206
3205
  }
3207
3206
  updateTopic() {
3208
3207
  this.textManage.updateText(this.element.data.topic);
3209
3208
  this.textManage.updateRectangle();
3210
- if (this.element.manualWidth) {
3211
- const width = NodeSpace.getNodeDynamicWidth(this.board, this.element);
3212
- this.textManage.updateWidth(width);
3213
- }
3214
3209
  }
3215
3210
  editTopic() {
3216
3211
  this.activeDrawer.draw(this.element, this.g, { selected: this.selected, isEditing: true });
3217
- // update text max-width when image width greater than topic default max width to cover node topic default max width style
3218
- const defaultMaxWidth = TOPIC_DEFAULT_MAX_WORD_COUNT * (PlaitMind.isMind(this.element) ? ROOT_TOPIC_FONT_SIZE : TOPIC_FONT_SIZE);
3219
- let hasMaxWidth = false;
3220
- if (!this.element.manualWidth && MindElement.hasImage(this.element) && this.element.data.image.width > defaultMaxWidth) {
3221
- const width = NodeSpace.getNodeDynamicWidth(this.board, this.element);
3222
- this.textManage.updateWidth(width);
3223
- hasMaxWidth = true;
3224
- }
3225
3212
  this.textManage.edit((origin) => {
3226
3213
  if (origin === ExitOrigin.default) {
3227
3214
  this.activeDrawer.draw(this.element, this.g, { selected: this.selected, isEditing: false });
3228
3215
  }
3229
- if (hasMaxWidth) {
3230
- this.textManage.updateWidth(0);
3231
- }
3232
3216
  });
3233
3217
  }
3234
3218
  ngOnDestroy() {
@@ -3718,15 +3702,17 @@ const withCreateMind = (board) => {
3718
3702
  const newBoard = board;
3719
3703
  const { keydown, mousedown, mousemove, mouseup } = board;
3720
3704
  let fakeCreateNodeRef = null;
3705
+ let emptyMind = null;
3721
3706
  newBoard.mousedown = (event) => {
3722
- if (fakeCreateNodeRef && PlaitBoard.isPointer(board, MindPointerType.mind)) {
3723
- const currentOptions = board.getPluginOptions(PlaitPluginKey.withSelection);
3724
- board.setPluginOptions(PlaitPluginKey.withSelection, {
3725
- isDisabledSelect: true
3726
- });
3727
- setTimeout(() => {
3728
- board.setPluginOptions(PlaitPluginKey.withSelection, { ...currentOptions });
3729
- }, 0);
3707
+ const isMindPointer = PlaitBoard.isPointer(board, MindPointerType.mind);
3708
+ let movingPoint = PlaitBoard.getMovingPointInBoard(board);
3709
+ if (movingPoint && isDrawingMode(board) && isMindPointer) {
3710
+ movingPoint = transformPoint(board, toPoint(movingPoint[0], movingPoint[1], PlaitBoard.getHost(board)));
3711
+ const emptyMind = createEmptyMind(newBoard, movingPoint);
3712
+ Transforms.insertNode(board, emptyMind, [board.children.length]);
3713
+ clearSelectedElement(board);
3714
+ addSelectedElement(board, emptyMind);
3715
+ BoardTransforms.updatePointerType(board, PlaitPointerType.selection);
3730
3716
  }
3731
3717
  mousedown(event);
3732
3718
  };
@@ -3735,13 +3721,14 @@ const withCreateMind = (board) => {
3735
3721
  mousemove(event);
3736
3722
  return;
3737
3723
  }
3738
- if (PlaitBoard.isPointer(board, MindPointerType.mind)) {
3724
+ const isMindPointer = PlaitBoard.isPointer(board, MindPointerType.mind);
3725
+ if (isDndMode(board) && isMindPointer) {
3739
3726
  throttleRAF(() => {
3740
- const movingPoint = PlaitBoard.getMovingPointInBoard(board);
3727
+ let movingPoint = PlaitBoard.getMovingPointInBoard(board);
3741
3728
  if (movingPoint) {
3742
- const targetPoint = transformPoint(board, toPoint(movingPoint[0], movingPoint[1], PlaitBoard.getHost(board)));
3743
- const emptyMind = createEmptyMind(targetPoint);
3744
- const nodeRectangle = getRectangleByElement(newBoard, targetPoint, emptyMind);
3729
+ movingPoint = transformPoint(newBoard, toPoint(movingPoint[0], movingPoint[1], PlaitBoard.getHost(board)));
3730
+ emptyMind = createEmptyMind(newBoard, movingPoint);
3731
+ const nodeRectangle = getRectangleByElement(newBoard, emptyMind);
3745
3732
  const nodeG = drawRoundRectangleByElement(board, nodeRectangle, emptyMind);
3746
3733
  const topicRectangle = getTopicRectangleByElement(newBoard, nodeRectangle, emptyMind);
3747
3734
  if (!fakeCreateNodeRef) {
@@ -3781,14 +3768,12 @@ const withCreateMind = (board) => {
3781
3768
  mousemove(event);
3782
3769
  };
3783
3770
  newBoard.mouseup = (event) => {
3784
- const movingPoint = PlaitBoard.getMovingPointInBoard(board);
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);
3771
+ if (emptyMind) {
3788
3772
  Transforms.insertNode(board, emptyMind, [board.children.length]);
3789
3773
  clearSelectedElement(board);
3790
3774
  addSelectedElement(board, emptyMind);
3791
3775
  BoardTransforms.updatePointerType(board, PlaitPointerType.selection);
3776
+ emptyMind = null;
3792
3777
  }
3793
3778
  destroy();
3794
3779
  mouseup(event);
@@ -3800,6 +3785,7 @@ const withCreateMind = (board) => {
3800
3785
  }
3801
3786
  if (event.key === DefaultHotkey && !PlaitBoard.isPointer(board, MindPointerType.mind)) {
3802
3787
  BoardTransforms.updatePointerType(board, MindPointerType.mind);
3788
+ setCreationMode(board, BoardCreationMode.drawing);
3803
3789
  event.preventDefault();
3804
3790
  return;
3805
3791
  }
@@ -4124,7 +4110,7 @@ const withNodeResize = (board) => {
4124
4110
  }
4125
4111
  const newTarget = PlaitNode.get(board, targetElementRef.path);
4126
4112
  if (newTarget && NodeSpace.getNodeTopicMinWidth(board, newTarget) !== resizedWidth) {
4127
- targetElementRef.textManage.updateWidth(resizedWidth);
4113
+ targetElementRef.textManage.updateRectangleWidth(resizedWidth);
4128
4114
  const { height } = targetElementRef.textManage.getSize();
4129
4115
  MindTransforms.setNodeManualWidth(board, newTarget, resizedWidth * zoom, height);
4130
4116
  }
@@ -4338,7 +4324,7 @@ class MindEmojiBaseComponent {
4338
4324
  get nativeElement() {
4339
4325
  return this.elementRef.nativeElement;
4340
4326
  }
4341
- handleClick() {
4327
+ handlePointerDown() {
4342
4328
  const currentOptions = this.board.getPluginOptions(PlaitPluginKey.withSelection);
4343
4329
  this.board.setPluginOptions(PlaitPluginKey.withSelection, {
4344
4330
  isDisabledSelect: true
@@ -4355,7 +4341,7 @@ class MindEmojiBaseComponent {
4355
4341
  this.elementRef.nativeElement.style.fontSize = `${this.fontSize}px`;
4356
4342
  }
4357
4343
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: MindEmojiBaseComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
4358
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.3", type: MindEmojiBaseComponent, inputs: { fontSize: "fontSize", emojiItem: "emojiItem", board: "board", element: "element" }, host: { listeners: { "mousedown": "handleClick()" }, classAttribute: "mind-node-emoji" }, ngImport: i0 }); }
4344
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.3", type: MindEmojiBaseComponent, inputs: { fontSize: "fontSize", emojiItem: "emojiItem", board: "board", element: "element" }, host: { listeners: { "pointerdown": "handlePointerDown()" }, classAttribute: "mind-node-emoji" }, ngImport: i0 }); }
4359
4345
  }
4360
4346
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: MindEmojiBaseComponent, decorators: [{
4361
4347
  type: Directive,
@@ -4372,9 +4358,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImpor
4372
4358
  type: Input
4373
4359
  }], element: [{
4374
4360
  type: Input
4375
- }], handleClick: [{
4361
+ }], handlePointerDown: [{
4376
4362
  type: HostListener,
4377
- args: ['mousedown']
4363
+ args: ['pointerdown']
4378
4364
  }] } });
4379
4365
 
4380
4366
  class MindImageBaseComponent {
@@ -4455,5 +4441,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImpor
4455
4441
  * Generated bundle index. Do not edit.
4456
4442
  */
4457
4443
 
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 };
4444
+ 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
4445
  //# sourceMappingURL=plait-mind.mjs.map