@plait/mind 0.90.1 → 0.91.1

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.
@@ -1552,7 +1552,7 @@ function drawLogicLink(board, parent, node, isHorizontal, defaultStrokeColor = n
1552
1552
  }
1553
1553
 
1554
1554
  function drawLink(board, parentNode, node, isHorizontal, needDrawUnderline, defaultStrokeColor, defaultStrokeWidth, defaultStrokeStyle) {
1555
- return MindElement.isIndentedLayout(parentNode.origin)
1555
+ return MindElement.isIndentedLayout(board, parentNode.origin)
1556
1556
  ? drawIndentedLink(board, parentNode, node, needDrawUnderline, defaultStrokeColor, defaultStrokeWidth, defaultStrokeStyle)
1557
1557
  : drawLogicLink(board, parentNode, node, isHorizontal, defaultStrokeColor, defaultStrokeWidth, defaultStrokeStyle);
1558
1558
  }
@@ -1654,7 +1654,7 @@ const drawFakeDropNode = (board, dropTarget, path) => {
1654
1654
  const target = dropTarget.target;
1655
1655
  const fakeDropNodeG = createG();
1656
1656
  const parent = PlaitNode.get(board, Path.parent(path));
1657
- const layout = MindQueries.getLayoutByElement(parent);
1657
+ const layout = MindQueries.getCorrectLayoutByElement(board, parent);
1658
1658
  const isHorizontal = isHorizontalLayout(layout);
1659
1659
  const { hasNextNode, hasPreviousNode } = hasPreviousOrNextOfDropPath(parent, dropTarget, path);
1660
1660
  const width = 30;
@@ -1699,7 +1699,7 @@ const drawFakeDropNode = (board, dropTarget, path) => {
1699
1699
  const placement = [HorizontalPlacement.left, VerticalPlacement.top];
1700
1700
  transformPlacement(placement, linkDirection);
1701
1701
  let offset = -height;
1702
- if (MindElement.isIndentedLayout(parent)) {
1702
+ if (MindElement.isIndentedLayout(board, parent)) {
1703
1703
  offset = isTopLayout(layout) ? offset / 2 + basicNode.height - basicNode.vGap : 0;
1704
1704
  }
1705
1705
  centerPoint = getPointByPlacement(nextRect, placement);
@@ -1713,7 +1713,7 @@ const drawFakeDropNode = (board, dropTarget, path) => {
1713
1713
  const placement = [HorizontalPlacement.left, VerticalPlacement.bottom];
1714
1714
  transformPlacement(placement, linkDirection);
1715
1715
  let offset = height;
1716
- if (MindElement.isIndentedLayout(parent)) {
1716
+ if (MindElement.isIndentedLayout(board, parent)) {
1717
1717
  offset = isTopLayout(layout) ? -offset - (basicNode.height - basicNode.vGap) : offset;
1718
1718
  }
1719
1719
  centerPoint = getPointByPlacement(previousRect, placement);
@@ -1749,8 +1749,8 @@ const drawFakeDropNode = (board, dropTarget, path) => {
1749
1749
  y,
1750
1750
  width,
1751
1751
  height,
1752
- hGap: MindElement.isIndentedLayout(parent) ? BASE * 4 + (basicNode.origin.strokeWidth || STROKE_WIDTH) : 0,
1753
- vGap: MindElement.isIndentedLayout(parent) ? BASE : 0
1752
+ hGap: MindElement.isIndentedLayout(board, parent) ? BASE * 4 + (basicNode.origin.strokeWidth || STROKE_WIDTH) : 0,
1753
+ vGap: MindElement.isIndentedLayout(board, parent) ? BASE : 0
1754
1754
  };
1755
1755
  const fakeRectangleG = drawRoundRectangle(PlaitBoard.getRoughSVG(board), fakeNode.x, fakeNode.y, fakeNode.x + width, fakeNode.y + height, {
1756
1756
  stroke: PRIMARY_COLOR,
@@ -2240,25 +2240,9 @@ const getAvailableSubLayoutsByElement = (board, element) => {
2240
2240
  return undefined;
2241
2241
  };
2242
2242
 
2243
- const getLayoutByElement = (element) => {
2244
- const layout = element.layout;
2245
- if (layout) {
2246
- return layout;
2247
- }
2248
- const parent = !PlaitMind.isMind(element) && MindElement.getParent(element);
2249
- if (AbstractNode.isAbstract(element) && parent) {
2250
- return getAbstractLayout(getLayoutByElement(parent));
2251
- }
2252
- if (parent) {
2253
- return getLayoutByElement(parent);
2254
- }
2255
- return getDefaultLayout();
2256
- };
2257
-
2258
2243
  const MindQueries = {
2259
2244
  getAvailableSubLayoutsByElement,
2260
2245
  getBranchLayouts,
2261
- getLayoutByElement,
2262
2246
  getCorrectLayoutByElement
2263
2247
  };
2264
2248
 
@@ -2269,12 +2253,8 @@ const PlaitMind = {
2269
2253
  }
2270
2254
  };
2271
2255
  const MindElement = {
2272
- hasLayout(value, layout) {
2273
- const _layout = MindQueries.getLayoutByElement(value);
2274
- return _layout === layout;
2275
- },
2276
- isIndentedLayout(value) {
2277
- const _layout = MindQueries.getLayoutByElement(value);
2256
+ isIndentedLayout(board, value) {
2257
+ const _layout = MindQueries.getCorrectLayoutByElement(board, value);
2278
2258
  return isIndentedLayout(_layout);
2279
2259
  },
2280
2260
  isMindElement(board, element) {
@@ -2446,7 +2426,7 @@ const setAbstractByElements = (board, groupParent, group) => {
2446
2426
  const indexArray = group.map((child) => groupParent.children.indexOf(child)).sort((a, b) => a - b);
2447
2427
  const rightNodeCount = groupParent?.rightNodeCount;
2448
2428
  const start = indexArray[0], end = indexArray[indexArray.length - 1];
2449
- if (isStandardLayout(MindQueries.getLayoutByElement(groupParent)) &&
2429
+ if (isStandardLayout(MindQueries.getCorrectLayoutByElement(board, groupParent)) &&
2450
2430
  rightNodeCount &&
2451
2431
  start < rightNodeCount &&
2452
2432
  end >= rightNodeCount) {
@@ -2880,7 +2860,7 @@ const getNodeMoreKeyPosition = (board, element) => {
2880
2860
  };
2881
2861
  const getNodeMoreLayoutDirection = (board, element) => {
2882
2862
  const node = MindElement.getNode(element);
2883
- const layout = MindQueries.getLayoutByElement(element);
2863
+ const layout = MindQueries.getCorrectLayoutByElement(board, element);
2884
2864
  const isHorizontal = isHorizontalLayout(layout);
2885
2865
  let layoutDirection = getLayoutDirection(node, isHorizontal);
2886
2866
  if (isIndentedLayout(layout)) {
@@ -2898,8 +2878,7 @@ const getNodeMoreStartPoint = (board, element, linkLineDirection, isLeft = false
2898
2878
  }
2899
2879
  transformPlacement(placement, linkLineDirection);
2900
2880
  // underline shape and horizontal
2901
- const layout = MindQueries.getLayoutByElement(element);
2902
- const isHorizontal = isHorizontalLayout(layout);
2881
+ const isHorizontal = linkLineDirection === LayoutDirection.left || linkLineDirection === LayoutDirection.right;
2903
2882
  if (isHorizontal && isUnderlineShape && !PlaitMind.isMind(element)) {
2904
2883
  placement[1] = VerticalPlacement.bottom;
2905
2884
  }
@@ -3032,7 +3011,7 @@ class MindNodeComponent extends CommonElementFlavour {
3032
3011
  if (this.linkLineG) {
3033
3012
  this.linkLineG.remove();
3034
3013
  }
3035
- const layout = MindQueries.getLayoutByElement(parent);
3014
+ const layout = MindQueries.getCorrectLayoutByElement(this.board, parent);
3036
3015
  if (AbstractNode.isAbstract(this.node.origin)) {
3037
3016
  this.linkLineG = drawAbstractLink(this.board, this.node, isHorizontalLayout(layout));
3038
3017
  }
@@ -3293,7 +3272,7 @@ const withAbstract = (board) => {
3293
3272
  const isHorizontal = isHorizontalLayout(nodeLayout);
3294
3273
  const parentElement = MindElement.getParent(activeAbstractElement);
3295
3274
  let children = parentElement.children;
3296
- const parentLayout = MindQueries.getLayoutByElement(parentElement);
3275
+ const parentLayout = MindQueries.getCorrectLayoutByElement(board, parentElement);
3297
3276
  if (isStandardLayout(parentLayout)) {
3298
3277
  const rightNodeCount = parentElement.rightNodeCount;
3299
3278
  const { leftChildren, rightChildren } = separateChildren(parentElement);