@plait/mind 0.17.0 → 0.19.0

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.
@@ -1,7 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Directive, Input, Component, ChangeDetectionStrategy, NgModule, NgZone, HostListener } from '@angular/core';
3
3
  import * as i2 from '@plait/core';
4
- import { DefaultThemeColor, ColorfulThemeColor, SoftThemeColor, RetroThemeColor, DarkThemeColor, StarryThemeColor, RectangleClient, PlaitElement, idCreator, isNullOrUndefined, Transforms, clearSelectedElement, addSelectedElement, PlaitNode, Path, PlaitBoard, depthFirstRecursion, drawLinearPath, drawBezierPath, createG, updateForeignObject, drawRoundRectangle, getRectangleByElements, getSelectedElements, NODE_TO_PARENT, distanceBetweenPointAndRectangle, createForeignObject, drawAbstractRoundRectangle, createText, PlaitPointerType, PlaitPluginElementComponent, NODE_TO_INDEX, PlaitModule, transformPoint, toPoint, getHitElements, distanceBetweenPointAndPoint, CLIP_BOARD_FORMAT_KEY, isMainPointer, BOARD_TO_HOST, PlaitPluginKey, throttleRAF, BoardTransforms, removeSelectedElement, PlaitHistoryBoard, hotkeys } from '@plait/core';
4
+ import { DefaultThemeColor, ColorfulThemeColor, SoftThemeColor, RetroThemeColor, DarkThemeColor, StarryThemeColor, RectangleClient, PlaitElement, idCreator, isNullOrUndefined, Transforms, clearSelectedElement, addSelectedElement, PlaitNode, Path, PlaitBoard, depthFirstRecursion, drawLinearPath, drawBezierPath, createG, updateForeignObject, drawRoundRectangle, getRectangleByElements, getSelectedElements, NODE_TO_PARENT, distanceBetweenPointAndRectangle, createForeignObject, createText, PlaitPointerType, PlaitPluginElementComponent, NODE_TO_INDEX, PlaitModule, transformPoint, toPoint, getHitElements, distanceBetweenPointAndPoint, CLIP_BOARD_FORMAT_KEY, isMainPointer, BOARD_TO_HOST, PlaitPluginKey, throttleRAF, BoardTransforms, removeSelectedElement, PlaitHistoryBoard, hotkeys } from '@plait/core';
5
5
  import { MindLayoutType, isIndentedLayout, AbstractNode, getNonAbstractChildren, isStandardLayout, isLeftLayout, isRightLayout, isVerticalLogicLayout, isHorizontalLogicLayout, isTopLayout, isBottomLayout, isHorizontalLayout, getCorrectStartEnd, getAbstractLayout, ConnectingPosition, GlobalLayout } from '@plait/layouts';
6
6
  import { TEXT_DEFAULT_HEIGHT, buildText, getTextSize, TextManage, ExitOrigin, TextModule, getTextFromClipboard } from '@plait/text';
7
7
  import { fromEvent, Subject } from 'rxjs';
@@ -659,15 +659,21 @@ const adjustNodeToRoot = (board, node) => {
659
659
  };
660
660
 
661
661
  const DefaultAbstractNodeStyle = {
662
- strokeColor: GRAY_COLOR,
663
- strokeWidth: 2,
664
- branchColor: GRAY_COLOR,
665
- branchWidth: 2
662
+ branch: { color: GRAY_COLOR, width: 2 },
663
+ shape: {
664
+ strokeColor: GRAY_COLOR,
665
+ strokeWidth: 2
666
+ }
666
667
  };
667
668
  const DefaultNodeStyle = {
668
- strokeWidth: 3,
669
- branchWidth: 3,
670
- fill: 'none'
669
+ branch: {
670
+ width: 3
671
+ },
672
+ shape: {
673
+ rectangleRadius: 4,
674
+ strokeWidth: 3,
675
+ fill: 'none'
676
+ }
671
677
  };
672
678
 
673
679
  const getAvailableProperty = (board, element, propertyKey) => {
@@ -863,13 +869,13 @@ const getAbstractBranchWidth = (board, element) => {
863
869
  if (!isNullOrUndefined(element.branchWidth)) {
864
870
  return element.branchWidth;
865
871
  }
866
- return DefaultAbstractNodeStyle.branchWidth;
872
+ return DefaultAbstractNodeStyle.branch.width;
867
873
  };
868
874
  const getAbstractBranchColor = (board, element) => {
869
875
  if (element.branchColor) {
870
876
  return element.branchColor;
871
877
  }
872
- return DefaultAbstractNodeStyle.branchColor;
878
+ return DefaultAbstractNodeStyle.branch.color;
873
879
  };
874
880
  const getNextBranchColor = (board, root) => {
875
881
  const index = root.children.length;
@@ -902,11 +908,22 @@ const getStrokeByMindElement = (board, element) => {
902
908
  return element.strokeColor || defaultRootStroke;
903
909
  }
904
910
  if (AbstractNode.isAbstract(element) || isChildOfAbstract(board, element)) {
905
- return element.strokeColor || DefaultAbstractNodeStyle.strokeColor;
906
- ;
911
+ return element.strokeColor || DefaultAbstractNodeStyle.shape.strokeColor;
907
912
  }
908
913
  return getAvailableProperty(board, element, 'strokeColor') || getDefaultBranchColor(board, element);
909
914
  };
915
+ const getStrokeWidthByElement = (board, element) => {
916
+ const strokeWidth = element.strokeWidth ||
917
+ (AbstractNode.isAbstract(element) ? DefaultAbstractNodeStyle.shape.strokeWidth : DefaultNodeStyle.shape.strokeWidth);
918
+ return strokeWidth;
919
+ };
920
+ const getFillByElement = (board, element) => {
921
+ if (element.fill) {
922
+ return element.fill;
923
+ }
924
+ const defaultRootFill = getMindThemeColor(board).rootFill;
925
+ return element.isRoot ? defaultRootFill : DefaultNodeStyle.shape.fill;
926
+ };
910
927
  const getShapeByElement = (board, element) => {
911
928
  const shape = getAvailableProperty(board, element, 'shape');
912
929
  return shape || MindElementShape.roundRectangle;
@@ -1345,7 +1362,7 @@ function drawLogicLink(board, parent, node, isHorizontal, defaultStroke = null,
1345
1362
  const branchWidth = defaultStrokeWidth || getBranchWidthByMindElement(board, parent.origin);
1346
1363
  const hasStraightLine = branchShape === BranchShape.polyline ? true : !parent.origin.isRoot;
1347
1364
  const parentShape = getShapeByElement(board, parent.origin);
1348
- const shape = node.origin.shape ? node.origin.shape : parentShape;
1365
+ const shape = getShapeByElement(board, node.origin);
1349
1366
  const hasUnderlineShape = shape === MindElementShape.underline;
1350
1367
  const hasUnderlineShapeOfParent = parentShape === MindElementShape.underline;
1351
1368
  const nodeClient = getRectangleByNode(node);
@@ -2034,16 +2051,15 @@ function drawRoundRectangleByNode(board, node) {
2034
2051
  return drawRoundRectangleByElement(board, rectangle, node.origin);
2035
2052
  }
2036
2053
  function drawRoundRectangleByElement(board, nodeRectangle, element) {
2037
- const defaultRootFill = getMindThemeColor(board).rootFill;
2038
- const fill = element.fill ? element.fill : element.isRoot ? defaultRootFill : DefaultNodeStyle.fill;
2054
+ const fill = getFillByElement(board, element);
2039
2055
  const stroke = getStrokeByMindElement(board, element);
2040
- const strokeWidth = element.strokeWidth ? element.strokeWidth : DefaultNodeStyle.strokeWidth;
2056
+ const strokeWidth = getStrokeWidthByElement(board, element);
2041
2057
  const nodeG = drawRoundRectangle(PlaitBoard.getRoughSVG(board), nodeRectangle.x, nodeRectangle.y, nodeRectangle.x + nodeRectangle.width, nodeRectangle.y + nodeRectangle.height, {
2042
2058
  stroke,
2043
2059
  strokeWidth,
2044
2060
  fill,
2045
2061
  fillStyle: 'solid'
2046
- });
2062
+ }, false, DefaultNodeStyle.shape.rectangleRadius);
2047
2063
  return nodeG;
2048
2064
  }
2049
2065
 
@@ -2216,8 +2232,8 @@ const setAbstractByElements = (board, groupParent, group) => {
2216
2232
  };
2217
2233
  const insertAbstractNode = (board, path, start, end) => {
2218
2234
  const mindElement = createMindElement('概要', 28, 20, {
2219
- strokeWidth: DefaultAbstractNodeStyle.branchWidth,
2220
- branchWidth: DefaultAbstractNodeStyle.branchWidth
2235
+ strokeWidth: DefaultAbstractNodeStyle.branch.width,
2236
+ branchWidth: DefaultAbstractNodeStyle.branch.width
2221
2237
  });
2222
2238
  mindElement.start = start;
2223
2239
  mindElement.end = end;
@@ -2561,6 +2577,48 @@ function handleBoardClass(board, activeHandlePosition, isHorizontal) {
2561
2577
  PlaitBoard.getBoardContainer(board).classList.remove('abstract-resizing-vertical');
2562
2578
  }
2563
2579
  }
2580
+ function drawAbstractRoundRectangle(rs, x1, y1, x2, y2, isHorizontal, options) {
2581
+ const width = Math.abs(x1 - x2);
2582
+ const height = Math.abs(y1 - y2);
2583
+ const radius = 5;
2584
+ const handleGap = 4;
2585
+ const handleLength = 10;
2586
+ const handleSpace = handleLength + handleGap * 2;
2587
+ if (isHorizontal) {
2588
+ const handleSideLine = (width - handleSpace - radius * 2) / 2;
2589
+ const sideLine = height - radius * 2;
2590
+ return rs.path(`M${x1 + radius},${y1}
2591
+ l${handleSideLine},0
2592
+ m${handleSpace},0
2593
+ l${handleSideLine},0
2594
+ a${radius},${radius},0,0,1,${radius},${radius}
2595
+ l0,${sideLine}
2596
+ a${radius},${radius},0,0,1,-${radius},${radius}
2597
+ l-${handleSideLine},0
2598
+ m-${handleSpace},0
2599
+ l-${handleSideLine},0
2600
+ a${radius},${radius},0,0,1,-${radius},-${radius}
2601
+ l0,-${sideLine}
2602
+ a${radius},${radius},0,0,1,${radius},-${radius}`, options);
2603
+ }
2604
+ else {
2605
+ const handleSideLine = (height - handleSpace - radius * 2) / 2;
2606
+ const sideLine = width - radius * 2;
2607
+ return rs.path(`M${x1 + radius},${y1}
2608
+ l${sideLine},0
2609
+ a${radius},${radius},0,0,1,${radius},${radius}
2610
+ l0,${handleSideLine}
2611
+ m0,${handleSpace}
2612
+ l0,${handleSideLine}
2613
+ a${radius},${radius},0,0,1,-${radius},${radius}
2614
+ l-${sideLine},0
2615
+ a${radius},${radius},0,0,1,-${radius},-${radius}
2616
+ l0,-${handleSideLine}
2617
+ m0,-${handleSpace}
2618
+ l0,-${handleSideLine}
2619
+ a${radius},${radius},0,0,1,${radius},-${radius}`, options);
2620
+ }
2621
+ }
2564
2622
 
2565
2623
  class NodeActiveDrawer extends BaseDrawer {
2566
2624
  canDraw(element, data) {
@@ -2579,14 +2637,13 @@ class NodeActiveDrawer extends BaseDrawer {
2579
2637
  activeG.append(this.abstractOutlineG);
2580
2638
  }
2581
2639
  const node = MindElement.getNode(element);
2582
- let { x, y, width, height } = getRectangleByNode(node);
2583
- const strokeG = drawRoundRectangle(PlaitBoard.getRoughSVG(this.board), x - 2, y - 2, x + width + 2, y + height + 2, { stroke: PRIMARY_COLOR, strokeWidth: 2, fill: '' }, true);
2640
+ const rectangle = getRectangleByNode(node);
2641
+ const activeStrokeWidth = 2;
2642
+ // add 0.1 to avoid white gap
2643
+ const offset = (getStrokeWidthByElement(this.board, element) + activeStrokeWidth) / 2 - 0.1;
2644
+ const activeRectangle = RectangleClient.getOutlineRectangle(rectangle, -offset);
2645
+ const strokeG = drawRoundRectangle(PlaitBoard.getRoughSVG(this.board), activeRectangle.x, activeRectangle.y, activeRectangle.x + activeRectangle.width, activeRectangle.y + activeRectangle.height, { stroke: PRIMARY_COLOR, strokeWidth: activeStrokeWidth, fill: '' }, true, DefaultNodeStyle.shape.rectangleRadius + offset);
2584
2646
  this.g.appendChild(strokeG);
2585
- if (!data.isEditing) {
2586
- const fillG = drawRoundRectangle(PlaitBoard.getRoughSVG(this.board), x - 2, y - 2, x + width + 2, y + height + 2, { stroke: PRIMARY_COLOR, fill: PRIMARY_COLOR, fillStyle: 'solid' }, true);
2587
- fillG.style.opacity = '0.15';
2588
- this.g.appendChild(fillG);
2589
- }
2590
2647
  return activeG;
2591
2648
  }
2592
2649
  updateAbstractOutline(element, activeHandlePosition, resizingLocation) {
@@ -3830,15 +3887,9 @@ const withMind = (board) => {
3830
3887
  board.applyTheme = (element) => {
3831
3888
  const mindElement = element;
3832
3889
  const shouldClearProperty = !PlaitBoard.isBoard(element) && (mindElement?.branchColor || mindElement?.fill || mindElement?.strokeColor);
3833
- const isAbstract = AbstractNode.isAbstract(element);
3834
3890
  if (shouldClearProperty) {
3835
3891
  const path = PlaitBoard.findPath(board, element);
3836
- if (isAbstract) {
3837
- Transforms.setNode(board, { fill: null, strokeColor: DefaultAbstractNodeStyle.strokeColor, branchColor: DefaultAbstractNodeStyle.branchColor }, path);
3838
- }
3839
- else {
3840
- Transforms.setNode(board, { fill: null, strokeColor: null, branchColor: null }, path);
3841
- }
3892
+ Transforms.setNode(board, { fill: null, strokeColor: null, branchColor: null }, path);
3842
3893
  }
3843
3894
  };
3844
3895
  board.getRectangle = element => {
@@ -3987,5 +4038,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
3987
4038
  * Generated bundle index. Do not edit.
3988
4039
  */
3989
4040
 
3990
- 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, NODE_MIN_WIDTH, 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, adjustAbstractToNode, adjustNodeToRoot, adjustRootToNode, 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, getEmojiForeignRectangle, getEmojiRectangle, getFirstLevelElement, getHitAbstractHandle, getImageForeignRectangle, getInCorrectLayoutDirection, getLayoutDirection$1 as getLayoutDirection, getLayoutReverseDirection, getLocationScope, getMindThemeColor, getNextBranchColor, getOverallAbstracts, getPathByDropTarget, getRectangleByElement, getRectangleByNode, getRectangleByResizingLocation, getRelativeStartEndByAbstractRef, getRootLayout, getShapeByElement, getStrokeByMindElement, getTopicRectangleByElement, getTopicRectangleByNode, getValidAbstractRefs, handleTouchedAbstract, hasAfterDraw, hasPreviousOrNextOfDropPath, insertElementHandleAbstract, insertElementHandleRightNodeCount, insertMindElement, isChildElement, isChildOfAbstract, isChildRight, isChildUp, isCorrectLayout, isDragging, isDropStandardRight, isHitEmojis, isHitImage, isHitMindElement, isInRightBranchOfStandardLayout, isMixedLayout, isSetAbstract, isValidTarget, isVirtualKey, removeActiveOnDragOrigin, separateChildren, setIsDragging, withMind, withMindExtend };
4041
+ 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, NODE_MIN_WIDTH, 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, adjustAbstractToNode, adjustNodeToRoot, adjustRootToNode, 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, getEmojiForeignRectangle, getEmojiRectangle, getFillByElement, getFirstLevelElement, getHitAbstractHandle, getImageForeignRectangle, getInCorrectLayoutDirection, getLayoutDirection$1 as getLayoutDirection, getLayoutReverseDirection, getLocationScope, getMindThemeColor, getNextBranchColor, getOverallAbstracts, getPathByDropTarget, getRectangleByElement, getRectangleByNode, getRectangleByResizingLocation, getRelativeStartEndByAbstractRef, getRootLayout, 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, isVirtualKey, removeActiveOnDragOrigin, separateChildren, setIsDragging, withMind, withMindExtend };
3991
4042
  //# sourceMappingURL=plait-mind.mjs.map