@plait/mind 0.19.0 → 0.21.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.
- package/base/base.drawer.d.ts +3 -3
- package/base/image-base.component.d.ts +5 -3
- package/constants/index.d.ts +0 -1
- package/drawer/node-image.drawer.d.ts +3 -5
- package/esm2020/base/base.drawer.mjs +1 -1
- package/esm2020/base/image-base.component.mjs +9 -5
- package/esm2020/constants/index.mjs +1 -2
- package/esm2020/drawer/node-image.drawer.mjs +34 -39
- package/esm2020/interfaces/element.mjs +1 -1
- package/esm2020/node.component.mjs +8 -9
- package/esm2020/plugins/with-abstract-resize.mjs +1 -2
- package/esm2020/plugins/with-mind-hotkey.mjs +3 -2
- package/esm2020/plugins/with-mind.mjs +9 -14
- package/esm2020/plugins/with-node-dnd.mjs +5 -5
- package/esm2020/plugins/with-node-hover.mjs +3 -10
- package/esm2020/plugins/with-node-image.mjs +46 -0
- package/esm2020/plugins/with-node-resize.mjs +119 -0
- package/esm2020/transforms/index.mjs +3 -2
- package/esm2020/transforms/node.mjs +19 -7
- package/esm2020/utils/clipboard.mjs +4 -4
- package/esm2020/utils/dnd/detector.mjs +3 -10
- package/esm2020/utils/mind.mjs +3 -3
- package/esm2020/utils/node/adjust-node.mjs +3 -3
- package/esm2020/utils/node/common.mjs +11 -2
- package/esm2020/utils/node/image.mjs +23 -0
- package/esm2020/utils/position/image.mjs +9 -4
- package/esm2020/utils/position/topic.mjs +3 -3
- package/esm2020/utils/space/node-space.mjs +59 -24
- package/fesm2015/plait-mind.mjs +312 -148
- package/fesm2015/plait-mind.mjs.map +1 -1
- package/fesm2020/plait-mind.mjs +312 -147
- package/fesm2020/plait-mind.mjs.map +1 -1
- package/interfaces/element.d.ts +1 -0
- package/node.component.d.ts +0 -1
- package/package.json +1 -1
- package/plugins/with-mind-hotkey.d.ts +2 -1
- package/plugins/with-mind.d.ts +1 -1
- package/plugins/with-node-image.d.ts +2 -0
- package/plugins/with-node-resize.d.ts +10 -0
- package/styles/styles.scss +9 -2
- package/transforms/index.d.ts +3 -2
- package/transforms/node.d.ts +4 -2
- package/utils/clipboard.d.ts +3 -2
- package/utils/mind.d.ts +3 -2
- package/utils/node/adjust-node.d.ts +2 -1
- package/utils/node/common.d.ts +2 -0
- package/utils/node/image.d.ts +6 -0
- package/utils/space/node-space.d.ts +9 -3
- package/constants/node-rule.d.ts +0 -1
- package/esm2020/constants/node-rule.mjs +0 -2
- package/esm2020/plugins/with-mind-image.mjs +0 -49
- package/plugins/with-mind-image.d.ts +0 -2
package/fesm2020/plait-mind.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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, createText, PlaitPointerType, PlaitPluginElementComponent, NODE_TO_INDEX, PlaitModule, transformPoint, toPoint, getHitElements, distanceBetweenPointAndPoint, CLIP_BOARD_FORMAT_KEY,
|
|
4
|
+
import { DefaultThemeColor, ColorfulThemeColor, SoftThemeColor, RetroThemeColor, DarkThemeColor, StarryThemeColor, RectangleClient, PlaitElement, PlaitPluginKey, idCreator, isNullOrUndefined, Transforms, clearSelectedElement, addSelectedElement, PlaitNode, Path, PlaitBoard, depthFirstRecursion, getIsRecursionFunc, drawLinearPath, drawBezierPath, createG, updateForeignObject, drawRoundRectangle, getRectangleByElements, getSelectedElements, NODE_TO_PARENT, distanceBetweenPointAndRectangle, createForeignObject, createText, PlaitPointerType, PlaitPluginElementComponent, NODE_TO_INDEX, PlaitModule, isMainPointer, transformPoint, toPoint, getHitElements, distanceBetweenPointAndPoint, CLIP_BOARD_FORMAT_KEY, BOARD_TO_HOST, throttleRAF, BoardTransforms, removeSelectedElement, PlaitHistoryBoard, hotkeys, PRESS_AND_MOVE_BUFFER, MERGING, ResizeCursorClass } 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
|
-
import { TEXT_DEFAULT_HEIGHT, buildText, getTextSize, TextManage, ExitOrigin, TextModule, getTextFromClipboard } from '@plait/text';
|
|
6
|
+
import { PlaitMarkEditor, MarkTypes, DEFAULT_FONT_SIZE, TEXT_DEFAULT_HEIGHT, buildText, getTextSize, TextManage, ExitOrigin, TextModule, getTextFromClipboard } from '@plait/text';
|
|
7
7
|
import { fromEvent, Subject } from 'rxjs';
|
|
8
8
|
import { Node, Path as Path$1 } from 'slate';
|
|
9
9
|
import { isKeyHotkey } from 'is-hotkey';
|
|
@@ -210,13 +210,21 @@ function getEmojiFontSize(element) {
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
+
const TOPIC_COLOR = '#333';
|
|
214
|
+
const TOPIC_FONT_SIZE = 14;
|
|
215
|
+
const ROOT_TOPIC_FONT_SIZE = 18;
|
|
216
|
+
const ROOT_TOPIC_HEIGHT = 25;
|
|
217
|
+
const TOPIC_DEFAULT_MAX_WORD_COUNT = 34;
|
|
218
|
+
const DEFAULT_FONT_FAMILY = 'PingFangSC-Regular, "PingFang SC"';
|
|
219
|
+
const BRANCH_FONT_FAMILY = 'PingFangSC-Medium, "PingFang SC"';
|
|
220
|
+
|
|
213
221
|
const NodeDefaultSpace = {
|
|
214
222
|
horizontal: {
|
|
215
|
-
nodeAndText: BASE *
|
|
223
|
+
nodeAndText: BASE * 2.5,
|
|
216
224
|
emojiAndText: BASE * 1.5
|
|
217
225
|
},
|
|
218
226
|
vertical: {
|
|
219
|
-
nodeAndText: BASE
|
|
227
|
+
nodeAndText: BASE,
|
|
220
228
|
nodeAndImage: BASE,
|
|
221
229
|
imageAndText: BASE * 1.5
|
|
222
230
|
}
|
|
@@ -233,12 +241,14 @@ const RootDefaultSpace = {
|
|
|
233
241
|
const getHorizontalSpaceBetweenNodeAndText = (board, element) => {
|
|
234
242
|
const isMind = PlaitMind.isMind(element);
|
|
235
243
|
const nodeAndText = isMind ? RootDefaultSpace.horizontal.nodeAndText : NodeDefaultSpace.horizontal.nodeAndText;
|
|
236
|
-
|
|
244
|
+
const strokeWidth = getStrokeWidthByElement(board, element);
|
|
245
|
+
return nodeAndText + strokeWidth / 2;
|
|
237
246
|
};
|
|
238
|
-
const getVerticalSpaceBetweenNodeAndText = (element) => {
|
|
247
|
+
const getVerticalSpaceBetweenNodeAndText = (board, element) => {
|
|
239
248
|
const isMind = PlaitMind.isMind(element);
|
|
249
|
+
const strokeWidth = getStrokeWidthByElement(board, element);
|
|
240
250
|
const nodeAndText = isMind ? RootDefaultSpace.vertical.nodeAndText : NodeDefaultSpace.vertical.nodeAndText;
|
|
241
|
-
return nodeAndText;
|
|
251
|
+
return nodeAndText + strokeWidth / 2;
|
|
242
252
|
};
|
|
243
253
|
const getSpaceEmojiAndText = (element) => {
|
|
244
254
|
const isMind = PlaitMind.isMind(element);
|
|
@@ -248,27 +258,43 @@ const getSpaceEmojiAndText = (element) => {
|
|
|
248
258
|
const NodeSpace = {
|
|
249
259
|
getNodeWidth(board, element) {
|
|
250
260
|
const nodeAndText = getHorizontalSpaceBetweenNodeAndText(board, element);
|
|
251
|
-
const imageWidth = MindElement.hasImage(element) ? element.data.image?.width : 0;
|
|
252
261
|
if (MindElement.hasEmojis(element)) {
|
|
253
262
|
return (NodeSpace.getEmojiLeftSpace(board, element) +
|
|
254
263
|
getEmojisWidthHeight(board, element).width +
|
|
255
264
|
getSpaceEmojiAndText(element) +
|
|
256
|
-
|
|
265
|
+
NodeSpace.getNodeResizableWidth(board, element) +
|
|
257
266
|
nodeAndText);
|
|
258
267
|
}
|
|
259
|
-
return nodeAndText +
|
|
268
|
+
return nodeAndText + NodeSpace.getNodeResizableWidth(board, element) + nodeAndText;
|
|
260
269
|
},
|
|
261
270
|
getNodeHeight(board, element) {
|
|
262
|
-
const nodeAndText = getVerticalSpaceBetweenNodeAndText(element);
|
|
271
|
+
const nodeAndText = getVerticalSpaceBetweenNodeAndText(board, element);
|
|
263
272
|
if (MindElement.hasImage(element)) {
|
|
264
|
-
return (
|
|
265
|
-
element.data.image.height +
|
|
266
|
-
NodeDefaultSpace.vertical.imageAndText +
|
|
267
|
-
element.height +
|
|
268
|
-
nodeAndText);
|
|
273
|
+
return NodeSpace.getTextTopSpace(board, element) + element.height + nodeAndText;
|
|
269
274
|
}
|
|
270
275
|
return nodeAndText + element.height + nodeAndText;
|
|
271
276
|
},
|
|
277
|
+
getNodeResizableWidth(board, element) {
|
|
278
|
+
const width = element.manualWidth || element.width;
|
|
279
|
+
const imageWidth = MindElement.hasImage(element) ? element.data.image?.width : 0;
|
|
280
|
+
return Math.max(width, imageWidth);
|
|
281
|
+
},
|
|
282
|
+
getNodeResizableMinWidth(board, element) {
|
|
283
|
+
const minTopicWidth = NodeSpace.getNodeTopicMinWidth(board, element);
|
|
284
|
+
if (MindElement.hasImage(element) && element.data.image.width > minTopicWidth) {
|
|
285
|
+
return element.data.image.width;
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
return minTopicWidth;
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
getNodeTopicMinWidth(board, element, isRoot = false) {
|
|
292
|
+
const defaultFontSize = getNodeDefaultFontSize(isRoot);
|
|
293
|
+
const editor = MindElement.getTextEditor(element);
|
|
294
|
+
const marks = PlaitMarkEditor.getMarks(editor);
|
|
295
|
+
const fontSize = marks[MarkTypes.fontSize] || defaultFontSize;
|
|
296
|
+
return fontSize;
|
|
297
|
+
},
|
|
272
298
|
getTextLeftSpace(board, element) {
|
|
273
299
|
const nodeAndText = getHorizontalSpaceBetweenNodeAndText(board, element);
|
|
274
300
|
if (MindElement.hasEmojis(element)) {
|
|
@@ -278,28 +304,43 @@ const NodeSpace = {
|
|
|
278
304
|
return nodeAndText;
|
|
279
305
|
}
|
|
280
306
|
},
|
|
281
|
-
getTextTopSpace(element) {
|
|
282
|
-
const nodeAndText = getVerticalSpaceBetweenNodeAndText(element);
|
|
307
|
+
getTextTopSpace(board, element) {
|
|
308
|
+
const nodeAndText = getVerticalSpaceBetweenNodeAndText(board, element);
|
|
283
309
|
if (MindElement.hasImage(element)) {
|
|
284
|
-
return element.data.image.height + NodeDefaultSpace.vertical.
|
|
310
|
+
return NodeSpace.getImageTopSpace(board, element) + element.data.image.height + NodeDefaultSpace.vertical.imageAndText;
|
|
285
311
|
}
|
|
286
312
|
else {
|
|
287
313
|
return nodeAndText;
|
|
288
314
|
}
|
|
289
315
|
},
|
|
290
|
-
getImageTopSpace(element) {
|
|
291
|
-
|
|
316
|
+
getImageTopSpace(board, element) {
|
|
317
|
+
const strokeWidth = getStrokeWidthByElement(board, element);
|
|
318
|
+
return strokeWidth / 2 + NodeDefaultSpace.vertical.nodeAndImage;
|
|
292
319
|
},
|
|
293
320
|
getEmojiLeftSpace(board, element) {
|
|
294
321
|
const options = board.getPluginOptions(WithMindPluginKey);
|
|
295
322
|
const nodeAndText = getHorizontalSpaceBetweenNodeAndText(board, element);
|
|
296
|
-
|
|
323
|
+
const strokeWidth = getStrokeWidthByElement(board, element);
|
|
324
|
+
return strokeWidth / 2 + nodeAndText - options.emojiPadding;
|
|
297
325
|
},
|
|
298
|
-
getEmojiTopSpace(element) {
|
|
299
|
-
const nodeAndText = getVerticalSpaceBetweenNodeAndText(element);
|
|
326
|
+
getEmojiTopSpace(board, element) {
|
|
327
|
+
const nodeAndText = getVerticalSpaceBetweenNodeAndText(board, element);
|
|
300
328
|
return nodeAndText;
|
|
301
329
|
}
|
|
302
330
|
};
|
|
331
|
+
const getFontSizeBySlateElement = (text) => {
|
|
332
|
+
const defaultFontSize = DEFAULT_FONT_SIZE;
|
|
333
|
+
if (typeof text === 'string') {
|
|
334
|
+
return defaultFontSize;
|
|
335
|
+
}
|
|
336
|
+
const marks = PlaitMarkEditor.getMarksByElement(text);
|
|
337
|
+
const fontSize = marks[MarkTypes.fontSize] || defaultFontSize;
|
|
338
|
+
return fontSize;
|
|
339
|
+
};
|
|
340
|
+
const getNodeDefaultFontSize = (isRoot = false) => {
|
|
341
|
+
const defaultFontSize = isRoot ? ROOT_TOPIC_FONT_SIZE : DEFAULT_FONT_SIZE;
|
|
342
|
+
return defaultFontSize;
|
|
343
|
+
};
|
|
303
344
|
|
|
304
345
|
function getEmojiRectangle(board, element) {
|
|
305
346
|
let { x, y } = getRectangleByNode(MindElement.getNode(element));
|
|
@@ -336,43 +377,47 @@ function getTopicRectangleByNode(board, node) {
|
|
|
336
377
|
}
|
|
337
378
|
function getTopicRectangleByElement(board, nodeRectangle, element) {
|
|
338
379
|
const x = nodeRectangle.x + NodeSpace.getTextLeftSpace(board, element);
|
|
339
|
-
const y = nodeRectangle.y + NodeSpace.getTextTopSpace(element);
|
|
340
|
-
const width =
|
|
380
|
+
const y = nodeRectangle.y + NodeSpace.getTextTopSpace(board, element);
|
|
381
|
+
const width = NodeSpace.getNodeResizableWidth(board, element);
|
|
341
382
|
const height = Math.ceil(element.height);
|
|
342
383
|
return { height, width, x, y };
|
|
343
384
|
}
|
|
344
385
|
|
|
345
386
|
function getImageForeignRectangle(board, element) {
|
|
346
387
|
let { x, y } = getRectangleByNode(MindElement.getNode(element));
|
|
347
|
-
|
|
348
|
-
|
|
388
|
+
const elementWidth = element.manualWidth || element.width;
|
|
389
|
+
x =
|
|
390
|
+
elementWidth > element.data.image.width
|
|
391
|
+
? x + NodeSpace.getTextLeftSpace(board, element) + (elementWidth - element.data.image.width) / 2
|
|
392
|
+
: x + NodeSpace.getTextLeftSpace(board, element);
|
|
393
|
+
y = NodeSpace.getImageTopSpace(board, element) + y;
|
|
349
394
|
const { width, height } = element.data.image;
|
|
350
|
-
|
|
395
|
+
const rectangle = {
|
|
351
396
|
x,
|
|
352
397
|
y,
|
|
353
398
|
width,
|
|
354
399
|
height
|
|
355
400
|
};
|
|
401
|
+
return RectangleClient.getOutlineRectangle(rectangle, -6);
|
|
356
402
|
}
|
|
357
403
|
const isHitImage = (board, element, range) => {
|
|
358
404
|
const client = getImageForeignRectangle(board, element);
|
|
359
405
|
return RectangleClient.isHit(RectangleClient.toRectangleClient([range.anchor, range.focus]), client);
|
|
360
406
|
};
|
|
361
407
|
|
|
362
|
-
const NODE_MIN_WIDTH = 18;
|
|
363
|
-
|
|
364
408
|
function editTopic(element) {
|
|
365
409
|
const component = PlaitElement.getComponent(element);
|
|
366
410
|
component?.editTopic();
|
|
367
411
|
}
|
|
368
|
-
|
|
369
|
-
const
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
412
|
+
const temporaryDisableSelection = (board) => {
|
|
413
|
+
const currentOptions = board.getPluginOptions(PlaitPluginKey.withSelection);
|
|
414
|
+
board.setPluginOptions(PlaitPluginKey.withSelection, {
|
|
415
|
+
isDisabledSelect: true
|
|
416
|
+
});
|
|
417
|
+
setTimeout(() => {
|
|
418
|
+
board.setPluginOptions(PlaitPluginKey.withSelection, { ...currentOptions });
|
|
419
|
+
}, 0);
|
|
420
|
+
};
|
|
376
421
|
|
|
377
422
|
const createEmptyMind = (point) => {
|
|
378
423
|
const element = createMindElement('思维导图', 72, ROOT_TOPIC_HEIGHT, { layout: MindLayoutType.right });
|
|
@@ -483,7 +528,7 @@ const insertMindElement = (board, inheritNode, path) => {
|
|
|
483
528
|
});
|
|
484
529
|
delete newNode.layout;
|
|
485
530
|
}
|
|
486
|
-
const newElement = createMindElement('',
|
|
531
|
+
const newElement = createMindElement('', getNodeDefaultFontSize(), TEXT_DEFAULT_HEIGHT, newNode);
|
|
487
532
|
Transforms.insertNode(board, newElement, path);
|
|
488
533
|
clearSelectedElement(board);
|
|
489
534
|
addSelectedElement(board, newElement);
|
|
@@ -648,7 +693,7 @@ const adjustNodeToRoot = (board, node) => {
|
|
|
648
693
|
fontSize: ROOT_TOPIC_FONT_SIZE,
|
|
649
694
|
fontFamily: BRANCH_FONT_FAMILY
|
|
650
695
|
});
|
|
651
|
-
newElement.width = Math.max(width,
|
|
696
|
+
newElement.width = Math.max(width, getNodeDefaultFontSize(true));
|
|
652
697
|
newElement.height = height;
|
|
653
698
|
return {
|
|
654
699
|
...newElement,
|
|
@@ -1069,14 +1114,7 @@ const detectDropTarget = (board, detectPoint, dropTarget, activeElements) => {
|
|
|
1069
1114
|
if (detectResult && isValid) {
|
|
1070
1115
|
dropTarget = { target: node.origin, detectResult: detectResult[0] };
|
|
1071
1116
|
}
|
|
1072
|
-
},
|
|
1073
|
-
if (PlaitBoard.isBoard(node) || board.isRecursion(node)) {
|
|
1074
|
-
return true;
|
|
1075
|
-
}
|
|
1076
|
-
else {
|
|
1077
|
-
return false;
|
|
1078
|
-
}
|
|
1079
|
-
});
|
|
1117
|
+
}, getIsRecursionFunc(board));
|
|
1080
1118
|
return dropTarget;
|
|
1081
1119
|
};
|
|
1082
1120
|
const directionDetector = (targetNode, centerPoint) => {
|
|
@@ -2265,24 +2303,36 @@ const correctLogicLayoutNode = (board, layout, path) => {
|
|
|
2265
2303
|
}
|
|
2266
2304
|
};
|
|
2267
2305
|
|
|
2268
|
-
const normalizeWidthAndHeight = (board, width, height) => {
|
|
2269
|
-
const
|
|
2306
|
+
const normalizeWidthAndHeight = (board, element, width, height) => {
|
|
2307
|
+
const minWidth = NodeSpace.getNodeTopicMinWidth(board, element, element.isRoot);
|
|
2308
|
+
const newWidth = width < minWidth * board.viewport.zoom ? minWidth : width / board.viewport.zoom;
|
|
2270
2309
|
const newHeight = height / board.viewport.zoom;
|
|
2271
2310
|
return { width: newWidth, height: newHeight };
|
|
2272
2311
|
};
|
|
2273
2312
|
const setTopic = (board, element, topic, width, height) => {
|
|
2274
2313
|
const newElement = {
|
|
2275
2314
|
data: { ...element.data, topic },
|
|
2276
|
-
...normalizeWidthAndHeight(board, width, height)
|
|
2315
|
+
...normalizeWidthAndHeight(board, element, width, height)
|
|
2277
2316
|
};
|
|
2278
2317
|
const path = PlaitBoard.findPath(board, element);
|
|
2279
2318
|
Transforms.setNode(board, newElement, path);
|
|
2280
2319
|
};
|
|
2320
|
+
const setNodeManualWidth = (board, element, width, height) => {
|
|
2321
|
+
const path = PlaitBoard.findPath(board, element);
|
|
2322
|
+
const { width: normalizedWidth, height: normalizedHeight } = normalizeWidthAndHeight(board, element, width, height);
|
|
2323
|
+
const newElement = { manualWidth: normalizedWidth, height: normalizedHeight };
|
|
2324
|
+
Transforms.setNode(board, newElement, path);
|
|
2325
|
+
};
|
|
2281
2326
|
const setTopicSize = (board, element, width, height) => {
|
|
2282
2327
|
const newElement = {
|
|
2283
|
-
...normalizeWidthAndHeight(board, width, height)
|
|
2328
|
+
...normalizeWidthAndHeight(board, element, width, height)
|
|
2284
2329
|
};
|
|
2285
|
-
|
|
2330
|
+
let isEqualWidth = Math.ceil(element.width) === Math.ceil(newElement.width);
|
|
2331
|
+
let isEqualHeight = Math.ceil(element.height) === Math.ceil(newElement.height);
|
|
2332
|
+
if (element.manualWidth) {
|
|
2333
|
+
isEqualWidth = true;
|
|
2334
|
+
}
|
|
2335
|
+
if (!isEqualWidth || !isEqualHeight) {
|
|
2286
2336
|
const path = PlaitBoard.findPath(board, element);
|
|
2287
2337
|
Transforms.setNode(board, newElement, path);
|
|
2288
2338
|
}
|
|
@@ -2379,6 +2429,7 @@ const MindTransforms = {
|
|
|
2379
2429
|
setLayout,
|
|
2380
2430
|
setTopic,
|
|
2381
2431
|
setTopicSize,
|
|
2432
|
+
setNodeManualWidth,
|
|
2382
2433
|
addEmoji,
|
|
2383
2434
|
removeEmoji,
|
|
2384
2435
|
replaceEmoji,
|
|
@@ -2753,13 +2804,15 @@ class MindImageBaseComponent {
|
|
|
2753
2804
|
get nativeElement() {
|
|
2754
2805
|
return this.elementRef.nativeElement;
|
|
2755
2806
|
}
|
|
2756
|
-
constructor(elementRef) {
|
|
2807
|
+
constructor(elementRef, cdr) {
|
|
2757
2808
|
this.elementRef = elementRef;
|
|
2809
|
+
this.cdr = cdr;
|
|
2810
|
+
this.isFocus = false;
|
|
2758
2811
|
}
|
|
2759
2812
|
ngOnInit() { }
|
|
2760
2813
|
}
|
|
2761
|
-
MindImageBaseComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: MindImageBaseComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2762
|
-
MindImageBaseComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: MindImageBaseComponent, inputs: { imageItem: "imageItem", board: "board", element: "element" }, host: { classAttribute: "mind-node-image" }, ngImport: i0 });
|
|
2814
|
+
MindImageBaseComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: MindImageBaseComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2815
|
+
MindImageBaseComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: MindImageBaseComponent, inputs: { imageItem: "imageItem", board: "board", element: "element", isFocus: "isFocus" }, host: { classAttribute: "mind-node-image" }, ngImport: i0 });
|
|
2763
2816
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: MindImageBaseComponent, decorators: [{
|
|
2764
2817
|
type: Directive,
|
|
2765
2818
|
args: [{
|
|
@@ -2767,12 +2820,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
|
|
|
2767
2820
|
class: 'mind-node-image'
|
|
2768
2821
|
}
|
|
2769
2822
|
}]
|
|
2770
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { imageItem: [{
|
|
2823
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { imageItem: [{
|
|
2771
2824
|
type: Input
|
|
2772
2825
|
}], board: [{
|
|
2773
2826
|
type: Input
|
|
2774
2827
|
}], element: [{
|
|
2775
2828
|
type: Input
|
|
2829
|
+
}], isFocus: [{
|
|
2830
|
+
type: Input
|
|
2776
2831
|
}] } });
|
|
2777
2832
|
|
|
2778
2833
|
class NodeImageDrawer {
|
|
@@ -2781,44 +2836,39 @@ class NodeImageDrawer {
|
|
|
2781
2836
|
this.viewContainerRef = viewContainerRef;
|
|
2782
2837
|
this.componentRef = null;
|
|
2783
2838
|
}
|
|
2784
|
-
drawImage(element) {
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
const foreignRectangle = getImageForeignRectangle(this.board, element);
|
|
2789
|
-
const foreignObject = createForeignObject(foreignRectangle.x, foreignRectangle.y, foreignRectangle.width, foreignRectangle.height);
|
|
2790
|
-
this.g.append(foreignObject);
|
|
2791
|
-
if (this.componentRef) {
|
|
2792
|
-
this.componentRef.destroy();
|
|
2793
|
-
this.componentRef = null;
|
|
2794
|
-
}
|
|
2795
|
-
const componentType = this.board.getPluginOptions(WithMindPluginKey).imageComponentType || MindImageBaseComponent;
|
|
2796
|
-
if (!componentType) {
|
|
2797
|
-
throw new Error('Not implement drawEmoji method error.');
|
|
2798
|
-
}
|
|
2799
|
-
this.componentRef = this.viewContainerRef.createComponent(componentType);
|
|
2800
|
-
this.componentRef.instance.board = this.board;
|
|
2801
|
-
this.componentRef.instance.element = element;
|
|
2802
|
-
this.componentRef.instance.imageItem = element.data.image;
|
|
2803
|
-
foreignObject.append(this.componentRef.instance.nativeElement);
|
|
2804
|
-
return this.g;
|
|
2839
|
+
drawImage(nodeG, element) {
|
|
2840
|
+
if (!MindElement.hasImage(element)) {
|
|
2841
|
+
this.destroy();
|
|
2842
|
+
return;
|
|
2805
2843
|
}
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
this.
|
|
2810
|
-
const
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
this.
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2844
|
+
this.g = createG();
|
|
2845
|
+
const foreignRectangle = getImageForeignRectangle(this.board, element);
|
|
2846
|
+
const foreignObject = createForeignObject(foreignRectangle.x, foreignRectangle.y, foreignRectangle.width, foreignRectangle.height);
|
|
2847
|
+
this.g.append(foreignObject);
|
|
2848
|
+
const componentType = this.board.getPluginOptions(WithMindPluginKey).imageComponentType || MindImageBaseComponent;
|
|
2849
|
+
if (!componentType) {
|
|
2850
|
+
throw new Error('Not implement drawEmoji method error.');
|
|
2851
|
+
}
|
|
2852
|
+
this.componentRef = this.viewContainerRef.createComponent(componentType);
|
|
2853
|
+
this.componentRef.instance.board = this.board;
|
|
2854
|
+
this.componentRef.instance.element = element;
|
|
2855
|
+
this.componentRef.instance.imageItem = element.data.image;
|
|
2856
|
+
this.componentRef.instance.cdr.markForCheck();
|
|
2857
|
+
foreignObject.append(this.componentRef.instance.nativeElement);
|
|
2858
|
+
nodeG.appendChild(this.g);
|
|
2859
|
+
}
|
|
2860
|
+
updateImage(nodeG, previous, current) {
|
|
2861
|
+
if (!MindElement.hasImage(previous) || !MindElement.hasImage(current)) {
|
|
2862
|
+
this.drawImage(nodeG, current);
|
|
2863
|
+
return;
|
|
2864
|
+
}
|
|
2865
|
+
if (previous !== current && this.componentRef) {
|
|
2866
|
+
this.componentRef.instance.element = current;
|
|
2867
|
+
this.componentRef.instance.imageItem = current.data.image;
|
|
2868
|
+
}
|
|
2869
|
+
const currentForeignObject = getImageForeignRectangle(this.board, current);
|
|
2870
|
+
updateForeignObject(this.g, currentForeignObject.width, currentForeignObject.height, currentForeignObject.x, currentForeignObject.y);
|
|
2871
|
+
this.componentRef?.instance.cdr.markForCheck();
|
|
2822
2872
|
}
|
|
2823
2873
|
destroy() {
|
|
2824
2874
|
if (this.g) {
|
|
@@ -2881,13 +2931,17 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2881
2931
|
this.activeDrawer.draw(this.element, this.g, { selected: this.selected, isEditing: this.textManage.isEditing });
|
|
2882
2932
|
this.drawEmojis();
|
|
2883
2933
|
this.drawExtend();
|
|
2884
|
-
this.drawImage();
|
|
2934
|
+
this.imageDrawer.drawImage(this.g, this.element);
|
|
2885
2935
|
if (PlaitMind.isMind(this.context.parent)) {
|
|
2886
2936
|
this.g.classList.add('branch');
|
|
2887
2937
|
}
|
|
2888
2938
|
}
|
|
2889
2939
|
editTopic() {
|
|
2890
2940
|
this.activeDrawer.draw(this.element, this.g, { selected: this.selected, isEditing: true });
|
|
2941
|
+
if (this.element.manualWidth) {
|
|
2942
|
+
const width = NodeSpace.getNodeResizableWidth(this.board, this.element);
|
|
2943
|
+
this.textManage.updateWidth(width);
|
|
2944
|
+
}
|
|
2891
2945
|
this.textManage.edit((origin) => {
|
|
2892
2946
|
if (origin === ExitOrigin.default) {
|
|
2893
2947
|
this.activeDrawer.draw(this.element, this.g, { selected: this.selected, isEditing: false });
|
|
@@ -2904,8 +2958,8 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2904
2958
|
this.drawShape();
|
|
2905
2959
|
this.drawLink();
|
|
2906
2960
|
this.drawEmojis();
|
|
2907
|
-
this.drawImage();
|
|
2908
2961
|
this.drawExtend();
|
|
2962
|
+
this.imageDrawer.updateImage(this.g, previous.element, value.element);
|
|
2909
2963
|
this.textManage.updateText(this.element.data.topic);
|
|
2910
2964
|
this.textManage.updateRectangle();
|
|
2911
2965
|
}
|
|
@@ -2926,12 +2980,6 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2926
2980
|
this.g.append(g);
|
|
2927
2981
|
}
|
|
2928
2982
|
}
|
|
2929
|
-
drawImage() {
|
|
2930
|
-
const image = this.imageDrawer.drawImage(this.element);
|
|
2931
|
-
if (image) {
|
|
2932
|
-
this.g.append(image);
|
|
2933
|
-
}
|
|
2934
|
-
}
|
|
2935
2983
|
drawShape() {
|
|
2936
2984
|
this.destroyShape();
|
|
2937
2985
|
const shape = getShapeByElement(this.board, this.node.origin);
|
|
@@ -3172,7 +3220,7 @@ const withNodeDnd = (board) => {
|
|
|
3172
3220
|
if (PlaitBoard.isReadonly(board) ||
|
|
3173
3221
|
PlaitBoard.hasBeenTextEditing(board) ||
|
|
3174
3222
|
!PlaitBoard.isPointer(board, PlaitPointerType.selection) ||
|
|
3175
|
-
event
|
|
3223
|
+
!isMainPointer(event)) {
|
|
3176
3224
|
mousedown(event);
|
|
3177
3225
|
return;
|
|
3178
3226
|
}
|
|
@@ -3196,11 +3244,11 @@ const withNodeDnd = (board) => {
|
|
|
3196
3244
|
activeElements = [targetElement];
|
|
3197
3245
|
startPoint = point;
|
|
3198
3246
|
}
|
|
3199
|
-
event.preventDefault();
|
|
3200
3247
|
}
|
|
3201
3248
|
if (activeElements.length) {
|
|
3202
|
-
|
|
3249
|
+
// prevent text from being selected
|
|
3203
3250
|
event.preventDefault();
|
|
3251
|
+
correspondingElements = getOverallAbstracts(board, activeElements);
|
|
3204
3252
|
}
|
|
3205
3253
|
mousedown(event);
|
|
3206
3254
|
};
|
|
@@ -3405,7 +3453,7 @@ const insertClipboardData = (board, elements, targetPoint) => {
|
|
|
3405
3453
|
newElement = adjustRootToNode(board, newElement);
|
|
3406
3454
|
const styles = PlaitMind.isMind(targetParent) ? { fontFamily: BRANCH_FONT_FAMILY } : { fontFamily: DEFAULT_FONT_FAMILY };
|
|
3407
3455
|
const { width, height } = getTextSize(board, newElement.data.topic, TOPIC_DEFAULT_MAX_WORD_COUNT, styles);
|
|
3408
|
-
newElement.width = Math.max(width,
|
|
3456
|
+
newElement.width = Math.max(width, getNodeDefaultFontSize());
|
|
3409
3457
|
newElement.height = height;
|
|
3410
3458
|
}
|
|
3411
3459
|
// handle abstract start and end
|
|
@@ -3435,7 +3483,7 @@ const insertClipboardData = (board, elements, targetPoint) => {
|
|
|
3435
3483
|
const insertClipboardText = (board, targetParent, text) => {
|
|
3436
3484
|
const styles = PlaitMind.isMind(targetParent) ? { fontFamily: BRANCH_FONT_FAMILY } : { fontFamily: DEFAULT_FONT_FAMILY };
|
|
3437
3485
|
const { width, height } = getTextSize(board, text, TOPIC_DEFAULT_MAX_WORD_COUNT, styles);
|
|
3438
|
-
const newElement = createMindElement(text, width, height, {});
|
|
3486
|
+
const newElement = createMindElement(text, Math.max(width, getFontSizeBySlateElement(text)), height, {});
|
|
3439
3487
|
Transforms.insertNode(board, newElement, findNewChildNodePath(board, targetParent));
|
|
3440
3488
|
return;
|
|
3441
3489
|
};
|
|
@@ -3475,7 +3523,6 @@ const withAbstract = (board) => {
|
|
|
3475
3523
|
const endPoint = transformPoint(board, toPoint(event.x, event.y, host));
|
|
3476
3524
|
touchedAbstract = handleTouchedAbstract(board, touchedAbstract, endPoint);
|
|
3477
3525
|
if (abstractHandlePosition && activeAbstractElement) {
|
|
3478
|
-
event.preventDefault();
|
|
3479
3526
|
const abstractComponent = PlaitElement.getComponent(activeAbstractElement);
|
|
3480
3527
|
const element = abstractComponent.element;
|
|
3481
3528
|
const nodeLayout = MindQueries.getCorrectLayoutByElement(board, activeAbstractElement);
|
|
@@ -3653,7 +3700,8 @@ const withCreateMind = (board) => {
|
|
|
3653
3700
|
return newBoard;
|
|
3654
3701
|
};
|
|
3655
3702
|
|
|
3656
|
-
const withMindHotkey = (
|
|
3703
|
+
const withMindHotkey = (baseBoard) => {
|
|
3704
|
+
const board = baseBoard;
|
|
3657
3705
|
const { keydown } = board;
|
|
3658
3706
|
board.keydown = (event) => {
|
|
3659
3707
|
const selectedElements = getSelectedElements(board);
|
|
@@ -3783,14 +3831,7 @@ const withNodeHover = (board) => {
|
|
|
3783
3831
|
if (isHitElement) {
|
|
3784
3832
|
target = element;
|
|
3785
3833
|
}
|
|
3786
|
-
},
|
|
3787
|
-
if (PlaitBoard.isBoard(node) || board.isRecursion(node)) {
|
|
3788
|
-
return true;
|
|
3789
|
-
}
|
|
3790
|
-
else {
|
|
3791
|
-
return false;
|
|
3792
|
-
}
|
|
3793
|
-
}, true);
|
|
3834
|
+
}, getIsRecursionFunc(board), true);
|
|
3794
3835
|
if (hoveredMindElement && target && hoveredMindElement === target) {
|
|
3795
3836
|
return;
|
|
3796
3837
|
}
|
|
@@ -3827,7 +3868,29 @@ const removeHovered = (element) => {
|
|
|
3827
3868
|
}
|
|
3828
3869
|
};
|
|
3829
3870
|
|
|
3830
|
-
const
|
|
3871
|
+
const BOARD_TO_SELECTED_IMAGE_ELEMENT = new WeakMap();
|
|
3872
|
+
const getSelectedImageElement = (board) => {
|
|
3873
|
+
return BOARD_TO_SELECTED_IMAGE_ELEMENT.get(board);
|
|
3874
|
+
};
|
|
3875
|
+
const addSelectedImageElement = (board, element) => {
|
|
3876
|
+
BOARD_TO_SELECTED_IMAGE_ELEMENT.set(board, element);
|
|
3877
|
+
};
|
|
3878
|
+
const removeSelectedImageElement = (board) => {
|
|
3879
|
+
BOARD_TO_SELECTED_IMAGE_ELEMENT.delete(board);
|
|
3880
|
+
};
|
|
3881
|
+
const setImageFocus = (board, element, isFocus) => {
|
|
3882
|
+
if (isFocus) {
|
|
3883
|
+
addSelectedImageElement(board, element);
|
|
3884
|
+
}
|
|
3885
|
+
else {
|
|
3886
|
+
removeSelectedImageElement(board);
|
|
3887
|
+
}
|
|
3888
|
+
const elementComponent = PlaitElement.getComponent(element);
|
|
3889
|
+
elementComponent.imageDrawer.componentRef.instance.isFocus = isFocus;
|
|
3890
|
+
elementComponent.imageDrawer.componentRef.instance.cdr.markForCheck();
|
|
3891
|
+
};
|
|
3892
|
+
|
|
3893
|
+
const withNodeImage = (board) => {
|
|
3831
3894
|
let selectedImageElement = null;
|
|
3832
3895
|
const { keydown, mousedown } = board;
|
|
3833
3896
|
board.mousedown = (event) => {
|
|
@@ -3840,26 +3903,21 @@ const withMindImage = (board) => {
|
|
|
3840
3903
|
const hitElements = getHitElements(board, { ranges: [range] });
|
|
3841
3904
|
const hasImage = hitElements.length && MindElement.hasImage(hitElements[0]);
|
|
3842
3905
|
const hitImage = hasImage && isHitImage(board, hitElements[0], range);
|
|
3906
|
+
if (selectedImageElement && hitImage && hitElements[0] === selectedImageElement) {
|
|
3907
|
+
temporaryDisableSelection(board);
|
|
3908
|
+
mousedown(event);
|
|
3909
|
+
return;
|
|
3910
|
+
}
|
|
3911
|
+
if (selectedImageElement) {
|
|
3912
|
+
setImageFocus(board, selectedImageElement, false);
|
|
3913
|
+
selectedImageElement = null;
|
|
3914
|
+
}
|
|
3843
3915
|
if (hitImage) {
|
|
3844
|
-
|
|
3845
|
-
board.setPluginOptions(PlaitPluginKey.withSelection, {
|
|
3846
|
-
isDisabledSelect: true
|
|
3847
|
-
});
|
|
3848
|
-
setTimeout(() => {
|
|
3849
|
-
board.setPluginOptions(PlaitPluginKey.withSelection, { ...currentOptions });
|
|
3850
|
-
}, 0);
|
|
3916
|
+
temporaryDisableSelection(board);
|
|
3851
3917
|
selectedImageElement = hitElements[0];
|
|
3852
|
-
|
|
3853
|
-
component.imageDrawer.drawActive(selectedImageElement);
|
|
3918
|
+
setImageFocus(board, selectedImageElement, true);
|
|
3854
3919
|
clearSelectedElement(board);
|
|
3855
3920
|
}
|
|
3856
|
-
else {
|
|
3857
|
-
if (selectedImageElement) {
|
|
3858
|
-
const component = PlaitElement.getComponent(selectedImageElement);
|
|
3859
|
-
component && component.imageDrawer.destroyActive();
|
|
3860
|
-
}
|
|
3861
|
-
selectedImageElement = null;
|
|
3862
|
-
}
|
|
3863
3921
|
mousedown(event);
|
|
3864
3922
|
};
|
|
3865
3923
|
board.keydown = (event) => {
|
|
@@ -3873,8 +3931,122 @@ const withMindImage = (board) => {
|
|
|
3873
3931
|
return board;
|
|
3874
3932
|
};
|
|
3875
3933
|
|
|
3876
|
-
const
|
|
3877
|
-
const {
|
|
3934
|
+
const withNodeResize = (board) => {
|
|
3935
|
+
const { mousedown, mousemove, globalMouseup } = board;
|
|
3936
|
+
let targetElement = null;
|
|
3937
|
+
let targetElementRef = null;
|
|
3938
|
+
let startPoint = null;
|
|
3939
|
+
board.mousedown = (event) => {
|
|
3940
|
+
if (targetElement) {
|
|
3941
|
+
startPoint = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
3942
|
+
// prevent text from being selected
|
|
3943
|
+
event.preventDefault();
|
|
3944
|
+
return;
|
|
3945
|
+
}
|
|
3946
|
+
mousedown(event);
|
|
3947
|
+
};
|
|
3948
|
+
board.mousemove = (event) => {
|
|
3949
|
+
if (PlaitBoard.isReadonly(board) || PlaitBoard.hasBeenTextEditing(board)) {
|
|
3950
|
+
mousemove(event);
|
|
3951
|
+
return;
|
|
3952
|
+
}
|
|
3953
|
+
if (startPoint && targetElement && !isMindNodeResizing(board)) {
|
|
3954
|
+
const endPoint = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
3955
|
+
const distance = distanceBetweenPointAndPoint(startPoint[0], startPoint[1], endPoint[0], endPoint[1]);
|
|
3956
|
+
if (distance > PRESS_AND_MOVE_BUFFER) {
|
|
3957
|
+
startPoint = endPoint;
|
|
3958
|
+
addResizing(board, targetElement);
|
|
3959
|
+
targetElementRef = {
|
|
3960
|
+
minWidth: NodeSpace.getNodeResizableMinWidth(board, targetElement),
|
|
3961
|
+
currentWidth: NodeSpace.getNodeResizableWidth(board, targetElement),
|
|
3962
|
+
path: PlaitBoard.findPath(board, targetElement),
|
|
3963
|
+
textManage: PlaitElement.getComponent(targetElement).textManage
|
|
3964
|
+
};
|
|
3965
|
+
MERGING.set(board, true);
|
|
3966
|
+
}
|
|
3967
|
+
}
|
|
3968
|
+
if (isMindNodeResizing(board) && startPoint && targetElementRef) {
|
|
3969
|
+
const endPoint = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
3970
|
+
const offsetX = endPoint[0] - startPoint[0];
|
|
3971
|
+
let resizedWidth = targetElementRef.currentWidth + offsetX;
|
|
3972
|
+
if (resizedWidth < targetElementRef.minWidth) {
|
|
3973
|
+
resizedWidth = targetElementRef.minWidth;
|
|
3974
|
+
}
|
|
3975
|
+
const newTarget = PlaitNode.get(board, targetElementRef.path);
|
|
3976
|
+
if (newTarget && NodeSpace.getNodeTopicMinWidth(board, newTarget) !== resizedWidth) {
|
|
3977
|
+
targetElementRef.textManage.updateWidth(resizedWidth);
|
|
3978
|
+
const { width, height } = targetElementRef.textManage.getSize();
|
|
3979
|
+
MindTransforms.setNodeManualWidth(board, newTarget, resizedWidth, height);
|
|
3980
|
+
}
|
|
3981
|
+
}
|
|
3982
|
+
else {
|
|
3983
|
+
// press and start drag when node is non selected
|
|
3984
|
+
if (!isDragging(board)) {
|
|
3985
|
+
const point = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
3986
|
+
const newTargetElement = getTargetElement(board, point);
|
|
3987
|
+
if (newTargetElement) {
|
|
3988
|
+
PlaitBoard.getBoardContainer(board).classList.add(ResizeCursorClass['ew-resize']);
|
|
3989
|
+
}
|
|
3990
|
+
else {
|
|
3991
|
+
PlaitBoard.getBoardContainer(board).classList.remove(ResizeCursorClass['ew-resize']);
|
|
3992
|
+
}
|
|
3993
|
+
targetElement = newTargetElement;
|
|
3994
|
+
}
|
|
3995
|
+
}
|
|
3996
|
+
mousemove(event);
|
|
3997
|
+
};
|
|
3998
|
+
board.globalMouseup = (event) => {
|
|
3999
|
+
globalMouseup(event);
|
|
4000
|
+
if (isMindNodeResizing(board) && targetElement) {
|
|
4001
|
+
removeResizing(board, targetElement);
|
|
4002
|
+
targetElementRef = null;
|
|
4003
|
+
targetElement = null;
|
|
4004
|
+
startPoint = null;
|
|
4005
|
+
MERGING.set(board, false);
|
|
4006
|
+
}
|
|
4007
|
+
};
|
|
4008
|
+
return board;
|
|
4009
|
+
};
|
|
4010
|
+
const IS_MIND_NODE_RESIZING = new WeakMap();
|
|
4011
|
+
const isMindNodeResizing = (board) => {
|
|
4012
|
+
return !!IS_MIND_NODE_RESIZING.get(board);
|
|
4013
|
+
};
|
|
4014
|
+
const addResizing = (board, element) => {
|
|
4015
|
+
PlaitBoard.getBoardContainer(board).classList.add('mind-node-resizing');
|
|
4016
|
+
const component = PlaitElement.getComponent(element);
|
|
4017
|
+
component.g.classList.add('resizing');
|
|
4018
|
+
IS_MIND_NODE_RESIZING.set(board, true);
|
|
4019
|
+
};
|
|
4020
|
+
const removeResizing = (board, element) => {
|
|
4021
|
+
PlaitBoard.getBoardContainer(board).classList.remove('mind-node-resizing');
|
|
4022
|
+
PlaitBoard.getBoardContainer(board).classList.remove(ResizeCursorClass['ew-resize']);
|
|
4023
|
+
const component = PlaitElement.getComponent(element);
|
|
4024
|
+
if (component && component.g) {
|
|
4025
|
+
component.g.classList.remove('resizing');
|
|
4026
|
+
}
|
|
4027
|
+
IS_MIND_NODE_RESIZING.set(board, false);
|
|
4028
|
+
};
|
|
4029
|
+
const getTargetElement = (board, point) => {
|
|
4030
|
+
const selectedElements = getSelectedElements(board).filter(value => MindElement.isMindElement(board, value));
|
|
4031
|
+
if (selectedElements.length > 0) {
|
|
4032
|
+
const target = selectedElements.find(value => {
|
|
4033
|
+
const rectangle = getResizeActiveRectangle(board, value);
|
|
4034
|
+
return distanceBetweenPointAndRectangle(point[0], point[1], rectangle) <= 0;
|
|
4035
|
+
});
|
|
4036
|
+
return target ? target : null;
|
|
4037
|
+
}
|
|
4038
|
+
return null;
|
|
4039
|
+
};
|
|
4040
|
+
const getResizeActiveRectangle = (board, element) => {
|
|
4041
|
+
const activeWidth = 20;
|
|
4042
|
+
const node = MindElement.getNode(element);
|
|
4043
|
+
const rectangle = getRectangleByNode(node);
|
|
4044
|
+
return { x: rectangle.x + rectangle.width - activeWidth / 2, y: rectangle.y, width: activeWidth, height: rectangle.height };
|
|
4045
|
+
};
|
|
4046
|
+
|
|
4047
|
+
const withMind = (baseBoard) => {
|
|
4048
|
+
const board = baseBoard;
|
|
4049
|
+
const { drawElement, dblclick, insertFragment, setFragment, deleteFragment, isHitSelection, getRectangle, isMovable, isRecursion } = board;
|
|
3878
4050
|
board.drawElement = (context) => {
|
|
3879
4051
|
if (PlaitMind.isMind(context.element)) {
|
|
3880
4052
|
return PlaitMindComponent;
|
|
@@ -3931,14 +4103,7 @@ const withMind = (board) => {
|
|
|
3931
4103
|
if (!PlaitBoard.hasBeenTextEditing(board) && isHitMindElement(board, point, node)) {
|
|
3932
4104
|
editTopic(node);
|
|
3933
4105
|
}
|
|
3934
|
-
},
|
|
3935
|
-
if (PlaitBoard.isBoard(node) || board.isRecursion(node)) {
|
|
3936
|
-
return true;
|
|
3937
|
-
}
|
|
3938
|
-
else {
|
|
3939
|
-
return false;
|
|
3940
|
-
}
|
|
3941
|
-
});
|
|
4106
|
+
}, getIsRecursionFunc(board));
|
|
3942
4107
|
});
|
|
3943
4108
|
if (PlaitBoard.hasBeenTextEditing(board)) {
|
|
3944
4109
|
return;
|
|
@@ -3984,7 +4149,7 @@ const withMind = (board) => {
|
|
|
3984
4149
|
MindTransforms.removeElements(board, selectedElements);
|
|
3985
4150
|
deleteFragment(data);
|
|
3986
4151
|
};
|
|
3987
|
-
return
|
|
4152
|
+
return withNodeResize(withNodeImage(withNodeHover(withMindHotkey(withMindExtend(withCreateMind(withAbstract(withNodeDnd(board))))))));
|
|
3988
4153
|
};
|
|
3989
4154
|
|
|
3990
4155
|
class MindEmojiBaseComponent {
|
|
@@ -4038,5 +4203,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
|
|
|
4038
4203
|
* Generated bundle index. Do not edit.
|
|
4039
4204
|
*/
|
|
4040
4205
|
|
|
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,
|
|
4206
|
+
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, 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, temporaryDisableSelection, withMind, withMindExtend };
|
|
4042
4207
|
//# sourceMappingURL=plait-mind.mjs.map
|