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

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.
@@ -2,7 +2,7 @@ import * as i0 from '@angular/core';
2
2
  import { Component, ChangeDetectionStrategy, NgModule, Directive, Input } from '@angular/core';
3
3
  import * as i2 from '@plait/core';
4
4
  import { distanceBetweenPointAndRectangle, PlaitElement, PlaitBoard, PlaitNode, NODE_TO_PARENT, Path, ELEMENT_TO_COMPONENT, Transforms, idCreator, isNullOrUndefined, clearSelectedElement, addSelectedElement, drawRoundRectangle, getRectangleByElements, RectangleClient, getSelectedElements, createG, drawAbstractRoundRectangle, PlaitPluginElementComponent, PlaitPointerType, NODE_TO_INDEX, createText, IS_TEXT_EDITABLE, MERGING, transformPoint, toPoint, depthFirstRecursion, PlaitModule, distanceBetweenPointAndPoint, CLIP_BOARD_FORMAT_KEY, BOARD_TO_HOST, removeSelectedElement, PlaitHistoryBoard, hotkeys } from '@plait/core';
5
- import { AbstractNode, isChildOfAbstract, isIndentedLayout, getAbstractLayout, MindLayoutType, isStandardLayout, isTopLayout, isLeftLayout, isHorizontalLogicLayout, isVerticalLogicLayout, isBottomLayout, isRightLayout, isHorizontalLayout, getCorrectStartEnd, ConnectingPosition, GlobalLayout } from '@plait/layouts';
5
+ import { AbstractNode, isChildOfAbstract, isIndentedLayout, getAbstractLayout, MindLayoutType, isStandardLayout, isTopLayout, isLeftLayout, isHorizontalLogicLayout, isVerticalLogicLayout, isBottomLayout, isRightLayout, isHorizontalLayout, getNonAbstractChildren, getCorrectStartEnd, ConnectingPosition, GlobalLayout } from '@plait/layouts';
6
6
  import { getSizeByText, ROOT_DEFAULT_HEIGHT, TEXT_DEFAULT_HEIGHT, drawRichtext, updateForeignObject, createForeignObject, updateRichText, setFullSelectionAndFocus, getRichtextContentSize, hasEditableTarget, RichtextModule } from '@plait/richtext';
7
7
  import { fromEvent, Subject, timer } from 'rxjs';
8
8
  import { take, takeUntil, filter, debounceTime } from 'rxjs/operators';
@@ -854,7 +854,7 @@ const getStrokeByMindElement = (board, element) => {
854
854
  ancestors.unshift(element);
855
855
  const ancestor = ancestors.find(value => value.strokeColor);
856
856
  if (ancestor && ancestor.strokeColor) {
857
- return ancestor.branchColor;
857
+ return ancestor.strokeColor;
858
858
  }
859
859
  const root = ancestors[ancestors.length - 1];
860
860
  const branch = ancestors[ancestors.length - 2];
@@ -1273,6 +1273,7 @@ const drawStraightDropNodeG = (board, targetRect, detectResult, targetComponent,
1273
1273
  }
1274
1274
  };
1275
1275
  const getHorizontalFakeY = (detectResult, targetIndex, parentNode, targetRect, layout, fakeY) => {
1276
+ const childrenLength = getNonAbstractChildren(parentNode).length;
1276
1277
  if (detectResult === 'top') {
1277
1278
  if (targetIndex === 0 && isTopLayout(layout)) {
1278
1279
  fakeY = targetRect.y + targetRect.height;
@@ -1286,13 +1287,13 @@ const getHorizontalFakeY = (detectResult, targetIndex, parentNode, targetRect, l
1286
1287
  }
1287
1288
  if (detectResult === 'bottom') {
1288
1289
  fakeY = targetRect.y + targetRect.height + 30;
1289
- if (targetIndex < parentNode.origin.children.length - 1) {
1290
+ if (targetIndex < childrenLength - 1) {
1290
1291
  const nextComponent = PlaitElement.getComponent(parentNode.origin.children[targetIndex + 1]);
1291
1292
  const nextRect = getRectangleByNode(nextComponent.node);
1292
1293
  const topY = targetRect.y + targetRect.height;
1293
1294
  fakeY = topY + (nextRect.y - topY) / 5;
1294
1295
  }
1295
- if (targetIndex === parentNode.origin.children.length - 1) {
1296
+ if (targetIndex === childrenLength - 1) {
1296
1297
  fakeY = targetRect.y + targetRect.height + 30;
1297
1298
  }
1298
1299
  }
@@ -1904,14 +1905,14 @@ function drawLogicLink(board, node, parent, isHorizontal) {
1904
1905
  function getEmojisRectangle(element) {
1905
1906
  const count = element.data.emojis.length;
1906
1907
  const fontSize = getEmojiFontSize(element);
1907
- return { width: fontSize * count, height: fontSize * 1.5 };
1908
+ return { width: fontSize * count + (count - 1) * 4, height: element.height };
1908
1909
  }
1909
1910
  function getEmojiFontSize(element) {
1910
1911
  if (PlaitMind.isMind(element)) {
1911
- return 18;
1912
+ return 18 + 2;
1912
1913
  }
1913
1914
  else {
1914
- return 14;
1915
+ return 14 + 2;
1915
1916
  }
1916
1917
  }
1917
1918
 
@@ -2080,8 +2081,8 @@ class EmojiDrawer {
2080
2081
  this.componentRef = this.viewContainerRef.createComponent(componentType);
2081
2082
  this.componentRef.instance.emojiItem = emoji;
2082
2083
  this.componentRef.instance.board = this.board;
2083
- const fontSize = PlaitMind.isMind(element) ? 18 : 14;
2084
- this.componentRef.instance.fontSize = fontSize;
2084
+ this.componentRef.instance.element = element;
2085
+ this.componentRef.instance.fontSize = getEmojiFontSize(element);
2085
2086
  }
2086
2087
  get nativeElement() {
2087
2088
  if (this.componentRef) {
@@ -2107,19 +2108,16 @@ class EmojisDrawer {
2107
2108
  drawEmojis(element) {
2108
2109
  this.destroy();
2109
2110
  if (MindElement.hasEmojis(element)) {
2110
- const node = MindElement.getNode(element);
2111
2111
  this.g = createG();
2112
2112
  this.g.classList.add('emojis');
2113
2113
  let { x, y } = getRectangleByNode(MindElement.getNode(element));
2114
2114
  x = x + NodeSpace.getEmojiHorizontalSpace(element);
2115
2115
  y = y + NodeSpace.getEmojiVerticalSpace(element);
2116
2116
  const { width, height } = getEmojisRectangle(element);
2117
- const fontSize = getEmojiFontSize(element);
2118
2117
  const foreignObject = createForeignObject(x, y, width, height);
2119
2118
  this.g.append(foreignObject);
2120
2119
  const container = document.createElement('div');
2121
2120
  container.classList.add('node-emojis-container');
2122
- container.classList.add(`emoji-font-size-${fontSize}`);
2123
2121
  foreignObject.append(container);
2124
2122
  this.emojiDrawers = element.data.emojis.map(emojiItem => {
2125
2123
  const drawer = new EmojiDrawer(this.board, this.viewContainerRef);
@@ -2549,10 +2547,10 @@ class MindNodeComponent extends PlaitPluginElementComponent {
2549
2547
  this.drawShape();
2550
2548
  this.drawLink();
2551
2549
  this.drawRichtext();
2552
- this.drawEmojis();
2553
2550
  this.drawActiveG();
2554
2551
  this.updateActiveClass();
2555
2552
  this.drawMaskG();
2553
+ this.drawEmojis();
2556
2554
  this.drawExtend();
2557
2555
  this.drawQuickInsert();
2558
2556
  }
@@ -3237,9 +3235,9 @@ const withDnd = (board) => {
3237
3235
  PlaitBoard.getHost(board).appendChild(fakeDragNodeG);
3238
3236
  }
3239
3237
  else {
3240
- fakeDragNodeG?.childNodes.forEach(node => {
3241
- node.remove();
3242
- });
3238
+ if (fakeDragNodeG) {
3239
+ fakeDragNodeG.innerHTML = '';
3240
+ }
3243
3241
  fakeDropNodeG?.childNodes.forEach(node => {
3244
3242
  node.remove();
3245
3243
  });
@@ -3556,6 +3554,7 @@ const withAbstract = (board) => {
3556
3554
  const endPoint = transformPoint(board, toPoint(event.x, event.y, host));
3557
3555
  touchedAbstract = handleTouchedAbstract(board, touchedAbstract, endPoint);
3558
3556
  if (abstractHandlePosition && activeAbstractElement) {
3557
+ event.preventDefault();
3559
3558
  const abstractComponent = PlaitElement.getComponent(activeAbstractElement);
3560
3559
  const element = abstractComponent.element;
3561
3560
  const nodeLayout = MindQueries.getCorrectLayoutByElement(activeAbstractElement);
@@ -3802,17 +3801,27 @@ class MindEmojiBaseComponent {
3802
3801
  this.elementRef = elementRef;
3803
3802
  this.fontSize = 14;
3804
3803
  }
3804
+ ngOnInit() {
3805
+ this.elementRef.nativeElement.style.fontSize = `${this.fontSize}px`;
3806
+ }
3805
3807
  }
3806
3808
  MindEmojiBaseComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: MindEmojiBaseComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
3807
- MindEmojiBaseComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: MindEmojiBaseComponent, inputs: { fontSize: "fontSize", emojiItem: "emojiItem", board: "board" }, ngImport: i0 });
3809
+ MindEmojiBaseComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: MindEmojiBaseComponent, inputs: { fontSize: "fontSize", emojiItem: "emojiItem", board: "board", element: "element" }, host: { classAttribute: "mind-node-emoji" }, ngImport: i0 });
3808
3810
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: MindEmojiBaseComponent, decorators: [{
3809
- type: Directive
3811
+ type: Directive,
3812
+ args: [{
3813
+ host: {
3814
+ class: 'mind-node-emoji'
3815
+ }
3816
+ }]
3810
3817
  }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { fontSize: [{
3811
3818
  type: Input
3812
3819
  }], emojiItem: [{
3813
3820
  type: Input
3814
3821
  }], board: [{
3815
3822
  type: Input
3823
+ }], element: [{
3824
+ type: Input
3816
3825
  }] } });
3817
3826
 
3818
3827
  /*