@plait/mind 0.27.0-next.3 → 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.
@@ -386,8 +386,7 @@ const isHitEmojis = (board, element, point) => {
386
386
  function getTopicRectangleByNode(board, node) {
387
387
  let nodeRectangle = getRectangleByNode(node);
388
388
  const result = getTopicRectangleByElement(board, nodeRectangle, node.origin);
389
- // add buffer width to avoid unexpected text breaks in different scene
390
- result.width = result.width + 4;
389
+ result.width = result.width;
391
390
  return result;
392
391
  }
393
392
  function getTopicRectangleByElement(board, nodeRectangle, element) {
@@ -1078,7 +1077,7 @@ const normalizeWidthAndHeight = (board, element, width, height) => {
1078
1077
  const minWidth = NodeSpace.getNodeTopicMinWidth(board, element, element.isRoot);
1079
1078
  const newWidth = width < minWidth * board.viewport.zoom ? minWidth : width / board.viewport.zoom;
1080
1079
  const newHeight = height / board.viewport.zoom;
1081
- return { width: newWidth, height: newHeight };
1080
+ return { width: Math.ceil(newWidth), height: newHeight };
1082
1081
  };
1083
1082
  const setTopic = (board, element, topic, width, height) => {
1084
1083
  const newElement = {
@@ -1197,11 +1196,8 @@ const replaceEmoji = (board, element, oldEmoji, newEmoji) => {
1197
1196
  const getNewNodeHeight = (board, element, newNodeDynamicWidth) => {
1198
1197
  const textManage = PlaitElement.getComponent(element).textManage;
1199
1198
  const { height } = textManage.getSize();
1200
- textManage.updateWidth(newNodeDynamicWidth);
1199
+ textManage.updateRectangleWidth(newNodeDynamicWidth);
1201
1200
  const { height: newHeight } = textManage.getSize();
1202
- if (!element.manualWidth) {
1203
- textManage.updateWidth(0);
1204
- }
1205
1201
  if (height !== newHeight) {
1206
1202
  return newHeight;
1207
1203
  }
@@ -3050,9 +3046,6 @@ class NodeImageDrawer {
3050
3046
  }
3051
3047
  }
3052
3048
 
3053
- // 1. When the text at the end has an italic attribute, the text is partially covered
3054
- // 2. There will be some differences in the width measured by different browsers
3055
- const WIDTH_BUFFER = 4;
3056
3049
  class MindNodeComponent extends PlaitPluginElementComponent {
3057
3050
  constructor(viewContainerRef, cdr) {
3058
3051
  super(cdr);
@@ -3088,7 +3081,12 @@ class MindNodeComponent extends PlaitPluginElementComponent {
3088
3081
  },
3089
3082
  textPlugins: plugins,
3090
3083
  getMaxWidth: () => {
3091
- 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
+ }
3092
3090
  }
3093
3091
  });
3094
3092
  }
@@ -3204,36 +3202,17 @@ class MindNodeComponent extends PlaitPluginElementComponent {
3204
3202
  drawTopic() {
3205
3203
  this.textManage.draw(this.element.data.topic);
3206
3204
  this.g.append(this.textManage.g);
3207
- if (this.element.manualWidth) {
3208
- const width = NodeSpace.getNodeDynamicWidth(this.board, this.element);
3209
- this.textManage.updateWidth(width);
3210
- }
3211
3205
  }
3212
3206
  updateTopic() {
3213
3207
  this.textManage.updateText(this.element.data.topic);
3214
3208
  this.textManage.updateRectangle();
3215
- if (this.element.manualWidth) {
3216
- const width = NodeSpace.getNodeDynamicWidth(this.board, this.element);
3217
- this.textManage.updateWidth(width);
3218
- }
3219
3209
  }
3220
3210
  editTopic() {
3221
3211
  this.activeDrawer.draw(this.element, this.g, { selected: this.selected, isEditing: true });
3222
- // update text max-width when image width greater than topic default max width to cover node topic default max width style
3223
- const defaultMaxWidth = TOPIC_DEFAULT_MAX_WORD_COUNT * (PlaitMind.isMind(this.element) ? ROOT_TOPIC_FONT_SIZE : TOPIC_FONT_SIZE);
3224
- let hasMaxWidth = false;
3225
- if (!this.element.manualWidth && MindElement.hasImage(this.element) && this.element.data.image.width > defaultMaxWidth) {
3226
- const width = NodeSpace.getNodeDynamicWidth(this.board, this.element);
3227
- this.textManage.updateWidth(width);
3228
- hasMaxWidth = true;
3229
- }
3230
3212
  this.textManage.edit((origin) => {
3231
3213
  if (origin === ExitOrigin.default) {
3232
3214
  this.activeDrawer.draw(this.element, this.g, { selected: this.selected, isEditing: false });
3233
3215
  }
3234
- if (hasMaxWidth) {
3235
- this.textManage.updateWidth(0);
3236
- }
3237
3216
  });
3238
3217
  }
3239
3218
  ngOnDestroy() {
@@ -4131,7 +4110,7 @@ const withNodeResize = (board) => {
4131
4110
  }
4132
4111
  const newTarget = PlaitNode.get(board, targetElementRef.path);
4133
4112
  if (newTarget && NodeSpace.getNodeTopicMinWidth(board, newTarget) !== resizedWidth) {
4134
- targetElementRef.textManage.updateWidth(resizedWidth);
4113
+ targetElementRef.textManage.updateRectangleWidth(resizedWidth);
4135
4114
  const { height } = targetElementRef.textManage.getSize();
4136
4115
  MindTransforms.setNodeManualWidth(board, newTarget, resizedWidth * zoom, height);
4137
4116
  }
@@ -4345,7 +4324,7 @@ class MindEmojiBaseComponent {
4345
4324
  get nativeElement() {
4346
4325
  return this.elementRef.nativeElement;
4347
4326
  }
4348
- handleClick() {
4327
+ handlePointerDown() {
4349
4328
  const currentOptions = this.board.getPluginOptions(PlaitPluginKey.withSelection);
4350
4329
  this.board.setPluginOptions(PlaitPluginKey.withSelection, {
4351
4330
  isDisabledSelect: true
@@ -4362,7 +4341,7 @@ class MindEmojiBaseComponent {
4362
4341
  this.elementRef.nativeElement.style.fontSize = `${this.fontSize}px`;
4363
4342
  }
4364
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 }); }
4365
- 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 }); }
4366
4345
  }
4367
4346
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: MindEmojiBaseComponent, decorators: [{
4368
4347
  type: Directive,
@@ -4379,9 +4358,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImpor
4379
4358
  type: Input
4380
4359
  }], element: [{
4381
4360
  type: Input
4382
- }], handleClick: [{
4361
+ }], handlePointerDown: [{
4383
4362
  type: HostListener,
4384
- args: ['mousedown']
4363
+ args: ['pointerdown']
4385
4364
  }] } });
4386
4365
 
4387
4366
  class MindImageBaseComponent {