@plait/mind 0.2.0-next.7 → 0.2.0-next.8

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.
@@ -1885,10 +1885,14 @@ function drawLogicLink(board, node, parent, isHorizontal) {
1885
1885
  return PlaitBoard.getRoughSVG(board).curve(points, { stroke: branchColor, strokeWidth });
1886
1886
  }
1887
1887
 
1888
- function getEmojisRectangle(element) {
1888
+ function getEmojisRectangle(board, element) {
1889
+ const options = board.getMindOptions();
1889
1890
  const count = element.data.emojis.length;
1890
1891
  const fontSize = getEmojiFontSize(element);
1891
- return { width: fontSize * count + (count - 1) * 4, height: element.height };
1892
+ return {
1893
+ width: fontSize * count + count * 2 * options.emojiPadding + (count - 1) * options.spaceBetweenEmojis,
1894
+ height: element.height
1895
+ };
1892
1896
  }
1893
1897
  function getEmojiFontSize(element) {
1894
1898
  if (PlaitMind.isMind(element)) {
@@ -1933,10 +1937,10 @@ const getVerticalSpaceBetweenNodeAndText = (element) => {
1933
1937
  return nodeAndText;
1934
1938
  };
1935
1939
  const NodeSpace = {
1936
- getNodeWidth(element) {
1940
+ getNodeWidth(board, element) {
1937
1941
  const nodeAndText = getHorizontalSpaceBetweenNodeAndText(element);
1938
1942
  if (MindElement.hasEmojis(element)) {
1939
- return nodeAndText + getEmojisRectangle(element).width + getHorizontalSpaceEmojiAndText(element) + element.width + nodeAndText;
1943
+ return nodeAndText + getEmojisRectangle(board, element).width + getHorizontalSpaceEmojiAndText(element) + element.width + nodeAndText;
1940
1944
  }
1941
1945
  return nodeAndText + element.width + nodeAndText;
1942
1946
  },
@@ -1944,10 +1948,10 @@ const NodeSpace = {
1944
1948
  const nodeAndText = getVerticalSpaceBetweenNodeAndText(element);
1945
1949
  return nodeAndText + element.height + nodeAndText;
1946
1950
  },
1947
- getTextHorizontalSpace(element) {
1951
+ getTextHorizontalSpace(board, element) {
1948
1952
  const nodeAndText = getHorizontalSpaceBetweenNodeAndText(element);
1949
1953
  if (MindElement.hasEmojis(element)) {
1950
- return nodeAndText + getEmojisRectangle(element).width + getHorizontalSpaceEmojiAndText(element);
1954
+ return nodeAndText + getEmojisRectangle(board, element).width + getHorizontalSpaceEmojiAndText(element);
1951
1955
  }
1952
1956
  else {
1953
1957
  return nodeAndText;
@@ -1967,9 +1971,9 @@ const NodeSpace = {
1967
1971
  }
1968
1972
  };
1969
1973
 
1970
- function drawMindNodeRichtext(node, viewContainerRef) {
1974
+ function drawMindNodeRichtext(board, node, viewContainerRef) {
1971
1975
  var _a, _b;
1972
- const { x, y } = getRichtextRectangleByNode(node);
1976
+ const { x, y } = getRichtextRectangleByNode(board, node);
1973
1977
  const classList = [];
1974
1978
  if (node.origin.isRoot) {
1975
1979
  classList.push('root-node');
@@ -1984,8 +1988,8 @@ function drawMindNodeRichtext(node, viewContainerRef) {
1984
1988
  // COMPAT: last character can not show in safari browser
1985
1989
  return drawRichtext(x, y, Math.ceil(node.origin.width), Math.ceil(node.origin.height), node.origin.data.topic, viewContainerRef, classList);
1986
1990
  }
1987
- function updateMindNodeTopicSize(node, g, isEditable) {
1988
- const { x, y, width, height } = getRichtextRectangleByNode(node);
1991
+ function updateMindNodeTopicSize(board, node, g, isEditable) {
1992
+ const { x, y, width, height } = getRichtextRectangleByNode(board, node);
1989
1993
  if (isEditable) {
1990
1994
  // add 999, avoid changing lines when paste more text
1991
1995
  updateForeignObject(g, width + 999, height + 999, x, y);
@@ -1995,9 +1999,9 @@ function updateMindNodeTopicSize(node, g, isEditable) {
1995
1999
  updateForeignObject(g, Math.ceil(node.origin.width), Math.ceil(node.origin.height), x, y);
1996
2000
  }
1997
2001
  }
1998
- function getRichtextRectangleByNode(node) {
2002
+ function getRichtextRectangleByNode(board, node) {
1999
2003
  let { x, y, width, height } = getRectangleByNode(node);
2000
- x = x + NodeSpace.getTextHorizontalSpace(node.origin);
2004
+ x = x + NodeSpace.getTextHorizontalSpace(board, node.origin);
2001
2005
  y = y + NodeSpace.getTextVerticalSpace(node.origin);
2002
2006
  return { width, height, x, y };
2003
2007
  }
@@ -2096,9 +2100,8 @@ class EmojisDrawer {
2096
2100
  this.g.classList.add('emojis');
2097
2101
  let { x, y } = getRectangleByNode(MindElement.getNode(element));
2098
2102
  x = x + NodeSpace.getEmojiHorizontalSpace(element);
2099
- y = y + NodeSpace.getEmojiVerticalSpace(element);
2100
- const { width, height } = getEmojisRectangle(element);
2101
- const foreignObject = createForeignObject(x, y, width, height);
2103
+ const { width, height } = getEmojisRectangle(this.board, element);
2104
+ const foreignObject = createForeignObject(x, y, width, height + NodeSpace.getEmojiVerticalSpace(element) * 2);
2102
2105
  this.g.append(foreignObject);
2103
2106
  const container = document.createElement('div');
2104
2107
  container.classList.add('node-emojis-container');
@@ -2745,7 +2748,7 @@ class MindNodeComponent extends PlaitPluginElementComponent {
2745
2748
  }
2746
2749
  }
2747
2750
  drawRichtext() {
2748
- const { richtextG, richtextComponentRef, foreignObject } = drawMindNodeRichtext(this.node, this.viewContainerRef);
2751
+ const { richtextG, richtextComponentRef, foreignObject } = drawMindNodeRichtext(this.board, this.node, this.viewContainerRef);
2749
2752
  this.richtextComponentRef = richtextComponentRef;
2750
2753
  this.richtextG = richtextG;
2751
2754
  this.foreignObject = foreignObject;
@@ -2888,7 +2891,7 @@ class MindNodeComponent extends PlaitPluginElementComponent {
2888
2891
  }
2889
2892
  updateRichtext() {
2890
2893
  updateRichText(this.node.origin.data.topic, this.richtextComponentRef);
2891
- updateMindNodeTopicSize(this.node, this.richtextG, this.isEditable);
2894
+ updateMindNodeTopicSize(this.board, this.node, this.richtextG, this.isEditable);
2892
2895
  }
2893
2896
  startEditText(isEnd, isClear) {
2894
2897
  if (!this.richtextComponentRef) {
@@ -2898,7 +2901,7 @@ class MindNodeComponent extends PlaitPluginElementComponent {
2898
2901
  this.isEditable = true;
2899
2902
  IS_TEXT_EDITABLE.set(this.board, true);
2900
2903
  this.disabledMaskG();
2901
- updateMindNodeTopicSize(this.node, this.richtextG, this.isEditable);
2904
+ updateMindNodeTopicSize(this.board, this.node, this.richtextG, this.isEditable);
2902
2905
  if (richtextInstance.plaitReadonly) {
2903
2906
  richtextInstance.plaitReadonly = false;
2904
2907
  this.richtextComponentRef.changeDetectorRef.detectChanges();
@@ -3002,7 +3005,7 @@ class MindNodeComponent extends PlaitPluginElementComponent {
3002
3005
  richtextInstance.plaitReadonly = true;
3003
3006
  (_a = this.richtextComponentRef) === null || _a === void 0 ? void 0 : _a.changeDetectorRef.markForCheck();
3004
3007
  this.isEditable = false;
3005
- updateMindNodeTopicSize(this.node, this.richtextG, this.isEditable);
3008
+ updateMindNodeTopicSize(this.board, this.node, this.richtextG, this.isEditable);
3006
3009
  IS_TEXT_EDITABLE.set(this.board, false);
3007
3010
  };
3008
3011
  }
@@ -3045,7 +3048,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
3045
3048
  }]
3046
3049
  }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.ChangeDetectorRef }, { type: i0.Renderer2 }]; } });
3047
3050
 
3048
- const getLayoutOptions = () => {
3051
+ const getLayoutOptions = (board) => {
3049
3052
  function getMainAxle(element, parent) {
3050
3053
  const strokeWidth = element.strokeWidth || STROKE_WIDTH;
3051
3054
  if (element.isRoot) {
@@ -3068,7 +3071,7 @@ const getLayoutOptions = () => {
3068
3071
  return NodeSpace.getNodeHeight(element);
3069
3072
  },
3070
3073
  getWidth(element) {
3071
- return NodeSpace.getNodeWidth(element);
3074
+ return NodeSpace.getNodeWidth(board, element);
3072
3075
  },
3073
3076
  getHorizontalGap(element, parent) {
3074
3077
  const _layout = (parent && parent.layout) || getRootLayout(element);
@@ -3124,7 +3127,7 @@ class PlaitMindComponent extends MindNodeComponent {
3124
3127
  }
3125
3128
  updateMindLayout(element = this.element) {
3126
3129
  const mindLayoutType = element.layout || getDefaultLayout();
3127
- this.root = GlobalLayout.layout(element, getLayoutOptions(), mindLayoutType);
3130
+ this.root = GlobalLayout.layout(element, getLayoutOptions(this.board), mindLayoutType);
3128
3131
  this.updateMindNodeLocation(element);
3129
3132
  }
3130
3133
  updateMindNodeLocation(element) {
@@ -3241,7 +3244,7 @@ const withDnd = (board) => {
3241
3244
  const activeComponent = PlaitElement.getComponent(activeElement);
3242
3245
  const roughSVG = PlaitBoard.getRoughSVG(board);
3243
3246
  const fakeDraggingNode = Object.assign(Object.assign({}, activeComponent.node), { children: [], x: activeComponent.node.x + offsetX, y: activeComponent.node.y + offsetY });
3244
- const textRectangle = getRichtextRectangleByNode(activeComponent.node);
3247
+ const textRectangle = getRichtextRectangleByNode(board, activeComponent.node);
3245
3248
  const fakeNodeG = drawRectangleNode(board, fakeDraggingNode);
3246
3249
  const richtextG = (_a = activeComponent.richtextG) === null || _a === void 0 ? void 0 : _a.cloneNode(true);
3247
3250
  updateForeignObject(richtextG, textRectangle.width + BASE * 10, textRectangle.height, textRectangle.x + offsetX, textRectangle.y + offsetY);
@@ -3501,14 +3504,6 @@ const insertClipboardText = (board, parentElement, text, width, height) => {
3501
3504
  return;
3502
3505
  };
3503
3506
 
3504
- const withEmoji = (board) => {
3505
- const newBoard = board;
3506
- newBoard.drawEmoji = (emoji, element) => {
3507
- throw new Error('Not implement drawEmoji method error.');
3508
- };
3509
- return newBoard;
3510
- };
3511
-
3512
3507
  const withAbstract = (board) => {
3513
3508
  const newBoard = board;
3514
3509
  const { mousedown, mousemove, mouseup } = board;
@@ -3609,6 +3604,17 @@ const withAbstract = (board) => {
3609
3604
  return board;
3610
3605
  };
3611
3606
 
3607
+ const withExtendMind = (board) => {
3608
+ const newBoard = board;
3609
+ newBoard.drawEmoji = (emoji, element) => {
3610
+ throw new Error('Not implement drawEmoji method error.');
3611
+ };
3612
+ newBoard.getMindOptions = () => {
3613
+ return { spaceBetweenEmojis: 4, emojiPadding: 0 };
3614
+ };
3615
+ return newBoard;
3616
+ };
3617
+
3612
3618
  const withMind = (board) => {
3613
3619
  const { drawElement, dblclick, keydown, insertFragment, setFragment, deleteFragment, isHitSelection, getRectangle, isMovable, isRecursion } = board;
3614
3620
  board.drawElement = (context) => {
@@ -3777,7 +3783,7 @@ const withMind = (board) => {
3777
3783
  deleteSelectedELements(board, selectedElements);
3778
3784
  deleteFragment(data);
3779
3785
  };
3780
- return withEmoji(withAbstract(withDnd(board)));
3786
+ return withExtendMind(withAbstract(withDnd(board)));
3781
3787
  };
3782
3788
 
3783
3789
  class MindEmojiBaseComponent {
@@ -3819,5 +3825,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
3819
3825
  * Generated bundle index. Do not edit.
3820
3826
  */
3821
3827
 
3822
- export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE, COLORS, ELEMENT_TO_NODE, EXTEND_OFFSET, EXTEND_RADIUS, GRAY_COLOR, LayoutDirection, LayoutDirectionsMap, MAX_RADIUS, MINDMAP_KEY, MindElement, MindEmojiBaseComponent, MindModule, MindNode, MindNodeComponent, MindNodeShape, MindQueries, MindTransforms, NODE_FILL, NODE_MIN_WIDTH, PRIMARY_COLOR, PlaitMind, PlaitMindComponent, QUICK_INSERT_CIRCLE_COLOR, QUICK_INSERT_CIRCLE_OFFSET, QUICK_INSERT_INNER_CROSS_COLOR, ROOT_NODE_FILL, ROOT_NODE_STROKE, ROOT_TOPIC_FONT_SIZE, STROKE_WIDTH, TOPIC_COLOR, TOPIC_DEFAULT_MAX_WORD_COUNT, TOPIC_FONT_SIZE, TRANSPARENT, canSetAbstract, changeRightNodeCount, copyNewNode, correctLayoutByDirection, createDefaultMindMapElement, createMindElement, deleteSelectedELements, directionCorrector, directionDetector, divideElementByParent, drawCurvePlaceholderDropNodeG, drawIndentNodeG, drawPlaceholderDropNodeG, drawStraightDropNodeG, extractNodesText, filterChildElement, findLastChild, findLocationLeftIndex, findParentElement, findUpElement, getAbstractHandleRectangle, getAllowedDirection, getAvailableSubLayoutsByLayoutDirections, getBehindAbstracts, getBranchColorByMindElement, getBranchDirectionsByLayouts, getChildrenCount, getCorrespondingAbstract, getDefaultLayout, getEmojiFontSize, getEmojisRectangle, getHitAbstractHandle, getHorizontalFakeY, getInCorrectLayoutDirection, getIndentedFakePoint, getLayoutDirection$1 as getLayoutDirection, getLayoutReverseDirection, getLocationScope, getNextBranchColor, getNodeShapeByElement, getRectangleByNode, getRectangleByResizingLocation, getRootLayout, getStrokeByMindElement, handleAbstractIncluded, handleTouchedAbstract, hitMindElement, insertAbstractNode, insertMindElement, insertSiblingElementHandleAbstract, isChildElement, isChildRight, isChildUp, isCorrectLayout, isMixedLayout, isSetAbstract, isVirtualKey, moveAbstractPosition, readjustmentDropTarget, separateChildren, setAbstract, setAbstractByElements, shouldChangeRightNodeCount, transformAbstractToNode, transformNodeToRoot, transformRootToNode, withEmoji, withMind };
3828
+ export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE, COLORS, ELEMENT_TO_NODE, EXTEND_OFFSET, EXTEND_RADIUS, GRAY_COLOR, LayoutDirection, LayoutDirectionsMap, MAX_RADIUS, MINDMAP_KEY, MindElement, MindEmojiBaseComponent, MindModule, MindNode, MindNodeComponent, MindNodeShape, MindQueries, MindTransforms, NODE_FILL, NODE_MIN_WIDTH, PRIMARY_COLOR, PlaitMind, PlaitMindComponent, QUICK_INSERT_CIRCLE_COLOR, QUICK_INSERT_CIRCLE_OFFSET, QUICK_INSERT_INNER_CROSS_COLOR, ROOT_NODE_FILL, ROOT_NODE_STROKE, ROOT_TOPIC_FONT_SIZE, STROKE_WIDTH, TOPIC_COLOR, TOPIC_DEFAULT_MAX_WORD_COUNT, TOPIC_FONT_SIZE, TRANSPARENT, canSetAbstract, changeRightNodeCount, copyNewNode, correctLayoutByDirection, createDefaultMindMapElement, createMindElement, deleteSelectedELements, directionCorrector, directionDetector, divideElementByParent, drawCurvePlaceholderDropNodeG, drawIndentNodeG, drawPlaceholderDropNodeG, drawStraightDropNodeG, extractNodesText, filterChildElement, findLastChild, findLocationLeftIndex, findParentElement, findUpElement, getAbstractHandleRectangle, getAllowedDirection, getAvailableSubLayoutsByLayoutDirections, getBehindAbstracts, getBranchColorByMindElement, getBranchDirectionsByLayouts, getChildrenCount, getCorrespondingAbstract, getDefaultLayout, getEmojiFontSize, getEmojisRectangle, getHitAbstractHandle, getHorizontalFakeY, getInCorrectLayoutDirection, getIndentedFakePoint, getLayoutDirection$1 as getLayoutDirection, getLayoutReverseDirection, getLocationScope, getNextBranchColor, getNodeShapeByElement, getRectangleByNode, getRectangleByResizingLocation, getRootLayout, getStrokeByMindElement, handleAbstractIncluded, handleTouchedAbstract, hitMindElement, insertAbstractNode, insertMindElement, insertSiblingElementHandleAbstract, isChildElement, isChildRight, isChildUp, isCorrectLayout, isMixedLayout, isSetAbstract, isVirtualKey, moveAbstractPosition, readjustmentDropTarget, separateChildren, setAbstract, setAbstractByElements, shouldChangeRightNodeCount, transformAbstractToNode, transformNodeToRoot, transformRootToNode, withExtendMind, withMind };
3823
3829
  //# sourceMappingURL=plait-mind.mjs.map