@plait/mind 0.59.0 → 0.62.0-next.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/emoji/emoji-base.component.d.ts +11 -0
- package/{base → emoji}/index.d.ts +1 -0
- package/emoji/with-emoji.d.ts +15 -0
- package/esm2022/constants/node-topic-style.mjs +1 -1
- package/esm2022/emoji/emoji-base.component.mjs +21 -0
- package/esm2022/emoji/index.mjs +3 -0
- package/esm2022/emoji/with-emoji.mjs +8 -0
- package/esm2022/generators/node-emojis.generator.mjs +17 -33
- package/esm2022/interfaces/element-data.mjs +1 -1
- package/esm2022/interfaces/options.mjs +1 -1
- package/esm2022/mind-node.component.mjs +13 -14
- package/esm2022/plugins/with-abstract-resize.mjs +1 -3
- package/esm2022/plugins/with-mind-create.mjs +4 -10
- package/esm2022/plugins/with-mind-fragment.mjs +2 -3
- package/esm2022/plugins/with-mind.mjs +3 -2
- package/esm2022/plugins/with-node-dnd.mjs +1 -4
- package/esm2022/plugins/with-node-resize.mjs +1 -1
- package/esm2022/public-api.mjs +2 -2
- package/esm2022/transforms/node.mjs +3 -4
- package/esm2022/utils/clipboard.mjs +25 -11
- package/esm2022/utils/mind.mjs +2 -2
- package/esm2022/utils/node/adjust-node.mjs +1 -10
- package/esm2022/utils/node/common.mjs +2 -6
- package/esm2022/utils/node/create-node.mjs +3 -2
- package/esm2022/utils/node/image.mjs +3 -5
- package/esm2022/utils/space/node-space.mjs +3 -3
- package/fesm2022/plait-mind.mjs +84 -123
- package/fesm2022/plait-mind.mjs.map +1 -1
- package/generators/node-emojis.generator.d.ts +6 -9
- package/interfaces/element-data.d.ts +1 -2
- package/interfaces/options.d.ts +1 -3
- package/mind-node.component.d.ts +1 -2
- package/package.json +1 -1
- package/plugins/with-mind-create.d.ts +1 -1
- package/plugins/with-mind.d.ts +1 -1
- package/public-api.d.ts +1 -1
- package/styles/mixins.scss +4 -4
- package/styles/styles.scss +2 -2
- package/utils/clipboard.d.ts +9 -0
- package/utils/mind.d.ts +1 -1
- package/base/emoji-base.component.d.ts +0 -18
- package/esm2022/base/emoji-base.component.mjs +0 -46
- package/esm2022/base/index.mjs +0 -2
package/fesm2022/plait-mind.mjs
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { DefaultThemeColor, ColorfulThemeColor, SoftThemeColor, RetroThemeColor, DarkThemeColor, StarryThemeColor, PlaitElement, PlaitNode, Path, isNullOrUndefined, PlaitBoard, getSelectedElements, idCreator, Transforms, clearSelectedElement, addSelectedElement, distanceBetweenPointAndRectangle, RectangleClient, depthFirstRecursion, getIsRecursionFunc, drawRoundRectangle, drawLinearPath, drawBezierPath, createG, createForeignObject, updateForeignObject, getRectangleByElements, setStrokeLinecap, ACTIVE_STROKE_WIDTH, NODE_TO_PARENT, removeSelectedElement, PlaitHistoryBoard, createText, PlaitPointerType, NODE_TO_INDEX, isMainPointer, toViewBoxPoint, toHostPoint, getHitElementByPoint, distanceBetweenPointAndPoint, CoreTransforms, BOARD_TO_HOST, BoardTransforms, throttleRAF, isContextmenu, temporaryDisableSelection, hotkeys, createClipboardContext, WritableClipboardType, ResizeCursorClass, Point, WritableClipboardOperationType, addClipboardContext
|
|
1
|
+
import { DefaultThemeColor, ColorfulThemeColor, SoftThemeColor, RetroThemeColor, DarkThemeColor, StarryThemeColor, PlaitElement, PlaitNode, Path, isNullOrUndefined, PlaitBoard, getSelectedElements, idCreator, Transforms, clearSelectedElement, addSelectedElement, distanceBetweenPointAndRectangle, RectangleClient, depthFirstRecursion, getIsRecursionFunc, drawRoundRectangle, drawLinearPath, drawBezierPath, createG, createForeignObject, updateForeignObject, getRectangleByElements, setStrokeLinecap, ACTIVE_STROKE_WIDTH, NODE_TO_PARENT, removeSelectedElement, PlaitHistoryBoard, createText, PlaitPointerType, NODE_TO_INDEX, isMainPointer, toViewBoxPoint, toHostPoint, getHitElementByPoint, distanceBetweenPointAndPoint, CoreTransforms, BOARD_TO_HOST, BoardTransforms, throttleRAF, isContextmenu, temporaryDisableSelection, hotkeys, createClipboardContext, WritableClipboardType, ResizeCursorClass, Point, WritableClipboardOperationType, addClipboardContext } from '@plait/core';
|
|
2
2
|
import { MindLayoutType, AbstractNode, isIndentedLayout, isHorizontalLayout, isHorizontalLogicLayout, ConnectingPosition, getNonAbstractChildren, isStandardLayout, isLeftLayout, isRightLayout, isVerticalLogicLayout, isTopLayout, isBottomLayout, getCorrectStartEnd, getAbstractLayout, GlobalLayout } from '@plait/layouts';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { getFirstTextManage, buildText, getFirstTextEditor, RESIZE_HANDLE_DIAMETER, getRectangleResizeHandleRefs, addElementOfFocusedImage, ImageGenerator, removeElementOfFocusedImage, Generator, PropertyTransforms, CommonElementFlavour, WithTextPluginKey, TextManage, isDrawingMode, isDndMode, setCreationMode, BoardCreationMode, isExpandHotkey, isTabHotkey, isEnterHotkey, isVirtualKey, isDelete, isSpaceHotkey, getElementOfFocusedImage, acceptImageTypes, buildImage, withResize, measureElement, getElementsText } from '@plait/common';
|
|
4
|
+
import { TEXT_DEFAULT_HEIGHT, PlaitMarkEditor, MarkTypes, DEFAULT_FONT_SIZE } from '@plait/text-plugins';
|
|
5
5
|
import { Node as Node$1, Path as Path$1 } from 'slate';
|
|
6
6
|
import { pointsOnBezierCurves } from 'points-on-curve';
|
|
7
7
|
import { fromEvent } from 'rxjs';
|
|
8
8
|
import { take, filter } from 'rxjs/operators';
|
|
9
|
-
import * as i0 from '@angular/core';
|
|
10
|
-
import { NgZone, Directive, Input, HostListener } from '@angular/core';
|
|
11
9
|
|
|
12
10
|
const ELEMENT_TO_NODE = new WeakMap();
|
|
13
11
|
|
|
@@ -480,10 +478,7 @@ const getShapeByElement = (board, element) => {
|
|
|
480
478
|
|
|
481
479
|
function editTopic(element) {
|
|
482
480
|
const textManage = getFirstTextManage(element);
|
|
483
|
-
textManage?.edit((
|
|
484
|
-
if (origin === ExitOrigin.default) {
|
|
485
|
-
}
|
|
486
|
-
});
|
|
481
|
+
textManage?.edit(() => { });
|
|
487
482
|
}
|
|
488
483
|
const getSelectedMindElements = (board, elements) => {
|
|
489
484
|
const selectedElements = elements?.length ? elements : getSelectedElements(board);
|
|
@@ -1067,13 +1062,6 @@ const adjustNodeToRoot = (board, node) => {
|
|
|
1067
1062
|
delete newElement?.shape;
|
|
1068
1063
|
delete newElement?.strokeWidth;
|
|
1069
1064
|
delete newElement?.isCollapsed;
|
|
1070
|
-
const { width, height } = getTextSize(board, newElement.data.topic, TOPIC_DEFAULT_MAX_WORD_COUNT, {
|
|
1071
|
-
fontSize: ROOT_TOPIC_FONT_SIZE,
|
|
1072
|
-
fontFamily: BRANCH_FONT_FAMILY,
|
|
1073
|
-
width: node.manualWidth ? node.manualWidth : undefined
|
|
1074
|
-
});
|
|
1075
|
-
newElement.width = Math.max(width, ROOT_TOPIC_FONT_SIZE);
|
|
1076
|
-
newElement.height = height;
|
|
1077
1065
|
return {
|
|
1078
1066
|
...newElement,
|
|
1079
1067
|
layout: newElement.layout ?? MindLayoutType.right,
|
|
@@ -1086,15 +1074,13 @@ const addImageFocus = (board, element) => {
|
|
|
1086
1074
|
addElementOfFocusedImage(board, element);
|
|
1087
1075
|
const commonElementRef = PlaitElement.getElementRef(element);
|
|
1088
1076
|
const imageGenerator = commonElementRef.getGenerator(ImageGenerator.key);
|
|
1089
|
-
imageGenerator.
|
|
1090
|
-
imageGenerator.componentRef.instance.cdr.markForCheck();
|
|
1077
|
+
imageGenerator.setFocus(element, true);
|
|
1091
1078
|
};
|
|
1092
1079
|
const removeImageFocus = (board, element) => {
|
|
1093
1080
|
removeElementOfFocusedImage(board);
|
|
1094
1081
|
const commonElementRef = PlaitElement.getElementRef(element);
|
|
1095
1082
|
const imageGenerator = commonElementRef.getGenerator(ImageGenerator.key);
|
|
1096
|
-
imageGenerator.
|
|
1097
|
-
imageGenerator.componentRef.instance.cdr.markForCheck();
|
|
1083
|
+
imageGenerator.setFocus(element, false);
|
|
1098
1084
|
};
|
|
1099
1085
|
|
|
1100
1086
|
/**
|
|
@@ -1599,43 +1585,31 @@ function drawLink(board, parentNode, node, isHorizontal, needDrawUnderline, defa
|
|
|
1599
1585
|
}
|
|
1600
1586
|
|
|
1601
1587
|
class EmojiGenerator {
|
|
1602
|
-
constructor(board
|
|
1588
|
+
constructor(board) {
|
|
1603
1589
|
this.board = board;
|
|
1604
|
-
this.
|
|
1605
|
-
this.componentRef = null;
|
|
1590
|
+
this.emojiComponentRef = null;
|
|
1606
1591
|
}
|
|
1607
|
-
draw(emoji, element) {
|
|
1592
|
+
draw(container, emoji, element) {
|
|
1608
1593
|
this.destroy();
|
|
1609
|
-
const
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
this.
|
|
1616
|
-
this.componentRef.instance.element = element;
|
|
1617
|
-
this.componentRef.instance.fontSize = getEmojiFontSize(element);
|
|
1618
|
-
}
|
|
1619
|
-
get nativeElement() {
|
|
1620
|
-
if (this.componentRef) {
|
|
1621
|
-
return this.componentRef.instance.nativeElement;
|
|
1622
|
-
}
|
|
1623
|
-
else {
|
|
1624
|
-
return null;
|
|
1625
|
-
}
|
|
1594
|
+
const props = {
|
|
1595
|
+
board: this.board,
|
|
1596
|
+
emojiItem: emoji,
|
|
1597
|
+
element,
|
|
1598
|
+
fontSize: getEmojiFontSize(element)
|
|
1599
|
+
};
|
|
1600
|
+
this.emojiComponentRef = this.board.renderEmoji(container, props);
|
|
1626
1601
|
}
|
|
1627
1602
|
destroy() {
|
|
1628
|
-
if (this.
|
|
1629
|
-
this.
|
|
1630
|
-
this.
|
|
1603
|
+
if (this.emojiComponentRef) {
|
|
1604
|
+
this.emojiComponentRef.destroy();
|
|
1605
|
+
this.emojiComponentRef = null;
|
|
1631
1606
|
}
|
|
1632
1607
|
}
|
|
1633
1608
|
}
|
|
1634
1609
|
class NodeEmojisGenerator {
|
|
1635
1610
|
static { this.key = 'node-emojis-generator'; }
|
|
1636
|
-
constructor(board
|
|
1611
|
+
constructor(board) {
|
|
1637
1612
|
this.board = board;
|
|
1638
|
-
this.viewContainerRef = viewContainerRef;
|
|
1639
1613
|
this.emojiGenerators = [];
|
|
1640
1614
|
}
|
|
1641
1615
|
drawEmojis(element) {
|
|
@@ -1650,13 +1624,10 @@ class NodeEmojisGenerator {
|
|
|
1650
1624
|
container.classList.add('node-emojis-container');
|
|
1651
1625
|
foreignObject.append(container);
|
|
1652
1626
|
this.emojiGenerators = element.data.emojis.map(emojiItem => {
|
|
1653
|
-
const drawer = new EmojiGenerator(this.board
|
|
1654
|
-
drawer.draw(emojiItem, element);
|
|
1627
|
+
const drawer = new EmojiGenerator(this.board);
|
|
1628
|
+
drawer.draw(container, emojiItem, element);
|
|
1655
1629
|
return drawer;
|
|
1656
1630
|
});
|
|
1657
|
-
this.emojiGenerators.forEach(drawer => {
|
|
1658
|
-
container.append(drawer.nativeElement);
|
|
1659
|
-
});
|
|
1660
1631
|
return this.g;
|
|
1661
1632
|
}
|
|
1662
1633
|
return undefined;
|
|
@@ -2519,9 +2490,8 @@ const insertAbstractNode = (board, path, start, end) => {
|
|
|
2519
2490
|
|
|
2520
2491
|
const normalizeWidthAndHeight = (board, element, width, height) => {
|
|
2521
2492
|
const minWidth = NodeSpace.getNodeTopicMinWidth(board, element);
|
|
2522
|
-
const newWidth = width < minWidth
|
|
2523
|
-
|
|
2524
|
-
return { width: Math.ceil(newWidth), height: newHeight };
|
|
2493
|
+
const newWidth = width < minWidth ? minWidth : width;
|
|
2494
|
+
return { width: Math.ceil(newWidth), height };
|
|
2525
2495
|
};
|
|
2526
2496
|
const setTopic = (board, element, topic, width, height) => {
|
|
2527
2497
|
const newElement = {
|
|
@@ -2950,7 +2920,7 @@ class MindNodeComponent extends CommonElementFlavour {
|
|
|
2950
2920
|
}
|
|
2951
2921
|
initializeGenerator() {
|
|
2952
2922
|
this.nodeShapeGenerator = new NodeShapeGenerator(this.board);
|
|
2953
|
-
this.nodeEmojisGenerator = new NodeEmojisGenerator(this.board
|
|
2923
|
+
this.nodeEmojisGenerator = new NodeEmojisGenerator(this.board);
|
|
2954
2924
|
this.activeGenerator = new NodeActiveGenerator(this.board);
|
|
2955
2925
|
this.nodePlusGenerator = new NodePlusGenerator(this.board);
|
|
2956
2926
|
this.collapseGenerator = new CollapseGenerator(this.board);
|
|
@@ -2963,22 +2933,21 @@ class MindNodeComponent extends CommonElementFlavour {
|
|
|
2963
2933
|
}
|
|
2964
2934
|
});
|
|
2965
2935
|
const plugins = (this.board.getPluginOptions(WithTextPluginKey) || {}).textPlugins;
|
|
2966
|
-
const textManage = new TextManage(this.board,
|
|
2936
|
+
const textManage = new TextManage(this.board, {
|
|
2967
2937
|
getRectangle: () => {
|
|
2968
2938
|
const rect = getTopicRectangleByNode(this.board, this.node);
|
|
2969
2939
|
return rect;
|
|
2970
2940
|
},
|
|
2971
|
-
|
|
2972
|
-
const width =
|
|
2973
|
-
const height =
|
|
2974
|
-
if (
|
|
2975
|
-
MindTransforms.setTopic(this.board, this.element,
|
|
2941
|
+
onChange: (data) => {
|
|
2942
|
+
const width = data.width;
|
|
2943
|
+
const height = data.height;
|
|
2944
|
+
if (data.newText) {
|
|
2945
|
+
MindTransforms.setTopic(this.board, this.element, data.newText, width, height);
|
|
2976
2946
|
}
|
|
2977
2947
|
else {
|
|
2978
2948
|
MindTransforms.setTopicSize(this.board, this.element, width, height);
|
|
2979
2949
|
}
|
|
2980
2950
|
},
|
|
2981
|
-
textPlugins: plugins,
|
|
2982
2951
|
getMaxWidth: () => {
|
|
2983
2952
|
if (this.element.manualWidth) {
|
|
2984
2953
|
return NodeSpace.getNodeDynamicWidth(this.board, this.element);
|
|
@@ -2986,7 +2955,8 @@ class MindNodeComponent extends CommonElementFlavour {
|
|
|
2986
2955
|
else {
|
|
2987
2956
|
return Math.max(NodeSpace.getNodeDynamicWidth(this.board, this.element), NodeTopicThreshold.defaultTextMaxWidth);
|
|
2988
2957
|
}
|
|
2989
|
-
}
|
|
2958
|
+
},
|
|
2959
|
+
textPlugins: plugins || []
|
|
2990
2960
|
});
|
|
2991
2961
|
this.initializeTextManages([textManage]);
|
|
2992
2962
|
this.getRef().addGenerator(NodeActiveGenerator.key, this.activeGenerator);
|
|
@@ -3007,7 +2977,7 @@ class MindNodeComponent extends CommonElementFlavour {
|
|
|
3007
2977
|
});
|
|
3008
2978
|
this.drawEmojis();
|
|
3009
2979
|
this.drawExtend();
|
|
3010
|
-
this.imageGenerator.processDrawing(this.element, this.getElementG()
|
|
2980
|
+
this.imageGenerator.processDrawing(this.element, this.getElementG());
|
|
3011
2981
|
if (PlaitMind.isMind(this.context.parent)) {
|
|
3012
2982
|
this.getElementG().classList.add('branch');
|
|
3013
2983
|
}
|
|
@@ -3027,7 +2997,7 @@ class MindNodeComponent extends CommonElementFlavour {
|
|
|
3027
2997
|
this.drawEmojis();
|
|
3028
2998
|
this.drawExtend();
|
|
3029
2999
|
if (!MindElement.hasImage(previous.element) && MindElement.hasImage(this.element)) {
|
|
3030
|
-
this.imageGenerator.processDrawing(this.element, this.getElementG()
|
|
3000
|
+
this.imageGenerator.processDrawing(this.element, this.getElementG());
|
|
3031
3001
|
}
|
|
3032
3002
|
if (MindElement.hasImage(previous.element) && MindElement.hasImage(this.element)) {
|
|
3033
3003
|
this.imageGenerator.updateImage(this.getElementG(), previous.element, value.element);
|
|
@@ -3179,10 +3149,7 @@ const withNodeDnd = (board) => {
|
|
|
3179
3149
|
pointerDown(event);
|
|
3180
3150
|
};
|
|
3181
3151
|
board.pointerMove = (event) => {
|
|
3182
|
-
// const xx = activeElements.
|
|
3183
3152
|
if (!board.options.readonly && activeElements.length && startPoint) {
|
|
3184
|
-
// prevent text from being selected
|
|
3185
|
-
event.preventDefault();
|
|
3186
3153
|
const endPoint = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
|
|
3187
3154
|
const distance = distanceBetweenPointAndPoint(startPoint[0], startPoint[1], endPoint[0], endPoint[1]);
|
|
3188
3155
|
if (distance < DRAG_MOVE_BUFFER) {
|
|
@@ -3340,8 +3307,6 @@ const withAbstract = (board) => {
|
|
|
3340
3307
|
const endPoint = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
|
|
3341
3308
|
touchedAbstract = handleTouchedAbstract(board, touchedAbstract, endPoint);
|
|
3342
3309
|
if (abstractHandlePosition && activeAbstractElement) {
|
|
3343
|
-
// prevent text from being selected
|
|
3344
|
-
event.preventDefault();
|
|
3345
3310
|
const nodeLayout = MindQueries.getCorrectLayoutByElement(board, activeAbstractElement);
|
|
3346
3311
|
const isHorizontal = isHorizontalLayout(nodeLayout);
|
|
3347
3312
|
const parentElement = MindElement.getParent(activeAbstractElement);
|
|
@@ -3451,16 +3416,12 @@ const withCreateMind = (board) => {
|
|
|
3451
3416
|
const nodeG = drawRoundRectangleByElement(board, nodeRectangle, emptyMind);
|
|
3452
3417
|
const topicRectangle = getTopicRectangleByElement(newBoard, nodeRectangle, emptyMind);
|
|
3453
3418
|
if (!fakeCreateNodeRef) {
|
|
3454
|
-
const textManage = new TextManage(board,
|
|
3419
|
+
const textManage = new TextManage(board, {
|
|
3455
3420
|
getRectangle: () => {
|
|
3456
3421
|
return topicRectangle;
|
|
3457
3422
|
}
|
|
3458
3423
|
});
|
|
3459
|
-
|
|
3460
|
-
.viewContainerRef.injector.get(NgZone)
|
|
3461
|
-
.run(() => {
|
|
3462
|
-
textManage.draw(emptyMind.data.topic);
|
|
3463
|
-
});
|
|
3424
|
+
textManage.draw(emptyMind.data.topic);
|
|
3464
3425
|
fakeCreateNodeRef = {
|
|
3465
3426
|
g: createG(),
|
|
3466
3427
|
nodeG,
|
|
@@ -3881,12 +3842,8 @@ const insertClipboardData = (board, elements, targetPoint, operationType) => {
|
|
|
3881
3842
|
if (hasTargetParent && operationType !== WritableClipboardOperationType.duplicate) {
|
|
3882
3843
|
if (item.isRoot) {
|
|
3883
3844
|
newElement = adjustRootToNode(board, newElement);
|
|
3884
|
-
const
|
|
3885
|
-
|
|
3886
|
-
...styles,
|
|
3887
|
-
width: newElement.manualWidth ? newElement.manualWidth : undefined
|
|
3888
|
-
});
|
|
3889
|
-
newElement.width = Math.max(width, ROOT_TOPIC_FONT_SIZE);
|
|
3845
|
+
const { width, height } = getTopicSizeByElement(newElement, targetParent);
|
|
3846
|
+
newElement.width = width;
|
|
3890
3847
|
newElement.height = height;
|
|
3891
3848
|
}
|
|
3892
3849
|
// handle abstract start and end
|
|
@@ -3904,6 +3861,9 @@ const insertClipboardData = (board, elements, targetPoint, operationType) => {
|
|
|
3904
3861
|
}
|
|
3905
3862
|
if (!item.isRoot) {
|
|
3906
3863
|
newElement = adjustNodeToRoot(board, newElement);
|
|
3864
|
+
const { width, height } = getTopicSizeByElement(newElement);
|
|
3865
|
+
newElement.width = width;
|
|
3866
|
+
newElement.height = height;
|
|
3907
3867
|
}
|
|
3908
3868
|
path = [board.children.length];
|
|
3909
3869
|
}
|
|
@@ -3914,12 +3874,27 @@ const insertClipboardData = (board, elements, targetPoint, operationType) => {
|
|
|
3914
3874
|
Transforms.addSelectionWithTemporaryElements(board, newELements);
|
|
3915
3875
|
};
|
|
3916
3876
|
const insertClipboardText = (board, targetParent, text) => {
|
|
3917
|
-
const
|
|
3918
|
-
const { width, height } = getTextSize(board, text, TOPIC_DEFAULT_MAX_WORD_COUNT, styles);
|
|
3877
|
+
const { width, height } = getTopicSize(false, PlaitMind.isMind(targetParent), buildText(text));
|
|
3919
3878
|
const newElement = createMindElement(text, Math.max(width, getFontSizeBySlateElement(text)), height, {});
|
|
3920
3879
|
Transforms.insertNode(board, newElement, findNewChildNodePath(board, targetParent));
|
|
3921
3880
|
Transforms.addSelectionWithTemporaryElements(board, [newElement]);
|
|
3922
3881
|
};
|
|
3882
|
+
const getTopicSizeByElement = (element, parentElement) => {
|
|
3883
|
+
return getTopicSize(PlaitMind.isMind(element), (parentElement && PlaitMind.isMind(parentElement)) || false, element.data.topic, element.manualWidth);
|
|
3884
|
+
};
|
|
3885
|
+
const getTopicSize = (isRoot, isBranch, topic, manualWidth) => {
|
|
3886
|
+
let fontFamily = DEFAULT_FONT_FAMILY;
|
|
3887
|
+
let fontSize = TOPIC_FONT_SIZE;
|
|
3888
|
+
if (isRoot) {
|
|
3889
|
+
fontFamily = BRANCH_FONT_FAMILY;
|
|
3890
|
+
fontSize = ROOT_TOPIC_FONT_SIZE;
|
|
3891
|
+
}
|
|
3892
|
+
else if (isBranch) {
|
|
3893
|
+
fontFamily = BRANCH_FONT_FAMILY;
|
|
3894
|
+
}
|
|
3895
|
+
const maxWidth = fontSize * TOPIC_DEFAULT_MAX_WORD_COUNT;
|
|
3896
|
+
return measureElement(topic, { fontSize, fontFamily }, manualWidth ? manualWidth : maxWidth);
|
|
3897
|
+
};
|
|
3923
3898
|
|
|
3924
3899
|
const withMindFragment = (baseBoard) => {
|
|
3925
3900
|
const board = baseBoard;
|
|
@@ -4016,6 +3991,14 @@ const getNextSelectedElement = (board, firstLevelElements) => {
|
|
|
4016
3991
|
return activeElement;
|
|
4017
3992
|
};
|
|
4018
3993
|
|
|
3994
|
+
const withEmoji = (board) => {
|
|
3995
|
+
const newBoard = board;
|
|
3996
|
+
newBoard.renderEmoji = (container, props) => {
|
|
3997
|
+
throw new Error('No implementation for renderEmoji method.');
|
|
3998
|
+
};
|
|
3999
|
+
return newBoard;
|
|
4000
|
+
};
|
|
4001
|
+
|
|
4019
4002
|
const withMind = (baseBoard) => {
|
|
4020
4003
|
const board = baseBoard;
|
|
4021
4004
|
const { drawElement, dblClick, isRectangleHit, isHit, getRectangle, isMovable, isRecursion, isAlign, isImageBindingAllowed, canAddToGroup, canSetZIndex, isExpanded } = board;
|
|
@@ -4123,51 +4106,29 @@ const withMind = (baseBoard) => {
|
|
|
4123
4106
|
}
|
|
4124
4107
|
dblClick(event);
|
|
4125
4108
|
};
|
|
4126
|
-
return withNodeResize(withNodeImageResize(withNodeImage(withNodeHoverHitTest(withMindFragment(withMindHotkey(withMindExtend(withCreateMind(withAbstract(withNodeDnd(board))))))))));
|
|
4109
|
+
return withEmoji(withNodeResize(withNodeImageResize(withNodeImage(withNodeHoverHitTest(withMindFragment(withMindHotkey(withMindExtend(withCreateMind(withAbstract(withNodeDnd(board)))))))))));
|
|
4127
4110
|
};
|
|
4128
4111
|
|
|
4129
4112
|
class MindEmojiBaseComponent {
|
|
4130
|
-
|
|
4131
|
-
return this.elementRef.nativeElement;
|
|
4132
|
-
}
|
|
4133
|
-
handlePointerDown() {
|
|
4134
|
-
const currentOptions = this.board.getPluginOptions(PlaitPluginKey.withSelection);
|
|
4135
|
-
this.board.setPluginOptions(PlaitPluginKey.withSelection, {
|
|
4136
|
-
isDisabledSelect: true
|
|
4137
|
-
});
|
|
4138
|
-
setTimeout(() => {
|
|
4139
|
-
this.board.setPluginOptions(PlaitPluginKey.withSelection, { ...currentOptions });
|
|
4140
|
-
}, 0);
|
|
4141
|
-
}
|
|
4142
|
-
constructor(elementRef) {
|
|
4143
|
-
this.elementRef = elementRef;
|
|
4113
|
+
constructor() {
|
|
4144
4114
|
this.fontSize = 14;
|
|
4145
4115
|
}
|
|
4146
|
-
|
|
4147
|
-
|
|
4116
|
+
// TODO
|
|
4117
|
+
// @HostListener('pointerdown')
|
|
4118
|
+
// handlePointerDown() {
|
|
4119
|
+
// const currentOptions = (this.board as PlaitOptionsBoard).getPluginOptions(PlaitPluginKey.withSelection);
|
|
4120
|
+
// (this.board as PlaitOptionsBoard).setPluginOptions<WithPluginOptions>(PlaitPluginKey.withSelection, {
|
|
4121
|
+
// isDisabledSelect: true
|
|
4122
|
+
// });
|
|
4123
|
+
// setTimeout(() => {
|
|
4124
|
+
// (this.board as PlaitOptionsBoard).setPluginOptions<WithPluginOptions>(PlaitPluginKey.withSelection, { ...currentOptions });
|
|
4125
|
+
// }, 0);
|
|
4126
|
+
// }
|
|
4127
|
+
initialize() {
|
|
4128
|
+
this.nativeElement().style.fontSize = `${this.fontSize}px`;
|
|
4129
|
+
this.nativeElement().classList.add('mind-node-emoji');
|
|
4148
4130
|
}
|
|
4149
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: MindEmojiBaseComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
4150
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.4", type: MindEmojiBaseComponent, inputs: { fontSize: "fontSize", emojiItem: "emojiItem", board: "board", element: "element" }, host: { listeners: { "pointerdown": "handlePointerDown()" }, classAttribute: "mind-node-emoji" }, ngImport: i0 }); }
|
|
4151
4131
|
}
|
|
4152
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: MindEmojiBaseComponent, decorators: [{
|
|
4153
|
-
type: Directive,
|
|
4154
|
-
args: [{
|
|
4155
|
-
host: {
|
|
4156
|
-
class: 'mind-node-emoji'
|
|
4157
|
-
}
|
|
4158
|
-
}]
|
|
4159
|
-
}], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { fontSize: [{
|
|
4160
|
-
type: Input
|
|
4161
|
-
}], emojiItem: [{
|
|
4162
|
-
type: Input
|
|
4163
|
-
}], board: [{
|
|
4164
|
-
type: Input
|
|
4165
|
-
}], element: [{
|
|
4166
|
-
type: Input
|
|
4167
|
-
}], handlePointerDown: [{
|
|
4168
|
-
type: HostListener,
|
|
4169
|
-
args: ['pointerdown']
|
|
4170
|
-
}] } });
|
|
4171
4132
|
|
|
4172
4133
|
/*
|
|
4173
4134
|
* Public API Surface of mind
|
|
@@ -4177,5 +4138,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImpor
|
|
|
4177
4138
|
* Generated bundle index. Do not edit.
|
|
4178
4139
|
*/
|
|
4179
4140
|
|
|
4180
|
-
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE, BRANCH_FONT_FAMILY, BRANCH_WIDTH, BranchShape, DEFAULT_FONT_FAMILY, DEFAULT_MIND_IMAGE_WIDTH, DefaultAbstractNodeStyle, DefaultNodeStyle, ELEMENT_TO_NODE, EXTEND_DIAMETER, EXTEND_OFFSET, GRAY_COLOR, INHERIT_ATTRIBUTE_KEYS, IS_DRAGGING, LayoutDirection, LayoutDirectionsMap, MindColorfulThemeColor, MindDarkThemeColor, MindDefaultThemeColor, MindElement, MindElementShape, MindEmojiBaseComponent, MindNode, MindNodeComponent, MindPointerType, MindQueries, MindRetroThemeColor, MindSoftThemeColor, MindStarryThemeColor, MindThemeColor, MindThemeColors, MindTransforms, NodeSpace, NodeTopicThreshold, PRIMARY_COLOR, PlaitMind, PlaitMindComponent, QUICK_INSERT_CIRCLE_COLOR, QUICK_INSERT_CIRCLE_OFFSET, QUICK_INSERT_INNER_CROSS_COLOR, ROOT_TOPIC_FONT_SIZE, ROOT_TOPIC_HEIGHT, ROOT_TOPIC_WIDTH, STROKE_WIDTH, TOPIC_COLOR, TOPIC_DEFAULT_MAX_WORD_COUNT, TOPIC_FONT_SIZE, WithMindPluginKey, addActiveOnDragOrigin, addImageFocus, adjustAbstractToNode, adjustNodeToRoot, adjustRootToNode, canSetAbstract, copyNewNode, correctLayoutByDirection, createDefaultMind, createEmptyMind, createMindElement, deleteElementHandleAbstract, deleteElementsHandleRightNodeCount, detectDropTarget, directionCorrector, directionDetector, divideElementByParent, drawFakeDragNode, drawFakeDropNode, editTopic, findLastChild, findLocationLeftIndex, findNewChildNodePath, findNewSiblingNodePath, getAbstractBranchColor, getAbstractBranchWidth, getAbstractHandleRectangle, getAllowedDirection, getAvailableSubLayoutsByLayoutDirections, getBehindAbstracts, getBranchColorByMindElement, getBranchDirectionsByLayouts, getBranchShapeByMindElement, getBranchWidthByMindElement, getChildrenCount, getCorrespondingAbstract, getDefaultBranchColor, getDefaultBranchColorByIndex, getDefaultLayout, getDefaultMindElementFontSize, getEmojiFontSize, getEmojiForeignRectangle, getEmojiRectangle, getEmojisWidthHeight, getFillByElement, getFirstLevelElement, getFontSizeBySlateElement, getHitAbstractHandle, getHitImageResizeHandleDirection, getImageForeignRectangle, getInCorrectLayoutDirection, getLayoutDirection$1 as getLayoutDirection, getLayoutOptions, getLayoutReverseDirection, getLocationScope, getMindThemeColor, getNewNodeHeight, getNextBranchColor, getOverallAbstracts, getPathByDropTarget, getRectangleByElement, getRectangleByNode, getRectangleByResizingLocation, getRelativeStartEndByAbstractRef, getRootLayout, getSelectedMindElements, getShapeByElement, getStrokeByMindElement, getStrokeWidthByElement, getTopicRectangleByElement, getTopicRectangleByNode, getValidAbstractRefs, handleTouchedAbstract, hasPreviousOrNextOfDropPath, insertElementHandleAbstract, insertElementHandleRightNodeCount, insertMindElement, isChildElement, isChildOfAbstract, isChildRight, isChildUp, isCorrectLayout, isDragging, isDropStandardRight, isHitEmojis, isHitImage, isHitMindElement, isInRightBranchOfStandardLayout, isMixedLayout, isSetAbstract, isValidTarget, removeActiveOnDragOrigin, removeImageFocus, separateChildren, setIsDragging, withMind, withMindExtend };
|
|
4141
|
+
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE, BRANCH_FONT_FAMILY, BRANCH_WIDTH, BranchShape, DEFAULT_FONT_FAMILY, DEFAULT_MIND_IMAGE_WIDTH, DefaultAbstractNodeStyle, DefaultNodeStyle, ELEMENT_TO_NODE, EXTEND_DIAMETER, EXTEND_OFFSET, GRAY_COLOR, INHERIT_ATTRIBUTE_KEYS, IS_DRAGGING, LayoutDirection, LayoutDirectionsMap, MindColorfulThemeColor, MindDarkThemeColor, MindDefaultThemeColor, MindElement, MindElementShape, MindEmojiBaseComponent, MindNode, MindNodeComponent, MindPointerType, MindQueries, MindRetroThemeColor, MindSoftThemeColor, MindStarryThemeColor, MindThemeColor, MindThemeColors, MindTransforms, NodeSpace, NodeTopicThreshold, PRIMARY_COLOR, PlaitMind, PlaitMindComponent, QUICK_INSERT_CIRCLE_COLOR, QUICK_INSERT_CIRCLE_OFFSET, QUICK_INSERT_INNER_CROSS_COLOR, ROOT_TOPIC_FONT_SIZE, ROOT_TOPIC_HEIGHT, ROOT_TOPIC_WIDTH, STROKE_WIDTH, TOPIC_COLOR, TOPIC_DEFAULT_MAX_WORD_COUNT, TOPIC_FONT_SIZE, WithMindPluginKey, addActiveOnDragOrigin, addImageFocus, adjustAbstractToNode, adjustNodeToRoot, adjustRootToNode, canSetAbstract, copyNewNode, correctLayoutByDirection, createDefaultMind, createEmptyMind, createMindElement, deleteElementHandleAbstract, deleteElementsHandleRightNodeCount, detectDropTarget, directionCorrector, directionDetector, divideElementByParent, drawFakeDragNode, drawFakeDropNode, editTopic, findLastChild, findLocationLeftIndex, findNewChildNodePath, findNewSiblingNodePath, getAbstractBranchColor, getAbstractBranchWidth, getAbstractHandleRectangle, getAllowedDirection, getAvailableSubLayoutsByLayoutDirections, getBehindAbstracts, getBranchColorByMindElement, getBranchDirectionsByLayouts, getBranchShapeByMindElement, getBranchWidthByMindElement, getChildrenCount, getCorrespondingAbstract, getDefaultBranchColor, getDefaultBranchColorByIndex, getDefaultLayout, getDefaultMindElementFontSize, getEmojiFontSize, getEmojiForeignRectangle, getEmojiRectangle, getEmojisWidthHeight, getFillByElement, getFirstLevelElement, getFontSizeBySlateElement, getHitAbstractHandle, getHitImageResizeHandleDirection, getImageForeignRectangle, getInCorrectLayoutDirection, getLayoutDirection$1 as getLayoutDirection, getLayoutOptions, getLayoutReverseDirection, getLocationScope, getMindThemeColor, getNewNodeHeight, getNextBranchColor, getOverallAbstracts, getPathByDropTarget, getRectangleByElement, getRectangleByNode, getRectangleByResizingLocation, getRelativeStartEndByAbstractRef, getRootLayout, getSelectedMindElements, getShapeByElement, getStrokeByMindElement, getStrokeWidthByElement, getTopicRectangleByElement, getTopicRectangleByNode, getValidAbstractRefs, handleTouchedAbstract, hasPreviousOrNextOfDropPath, insertElementHandleAbstract, insertElementHandleRightNodeCount, insertMindElement, isChildElement, isChildOfAbstract, isChildRight, isChildUp, isCorrectLayout, isDragging, isDropStandardRight, isHitEmojis, isHitImage, isHitMindElement, isInRightBranchOfStandardLayout, isMixedLayout, isSetAbstract, isValidTarget, removeActiveOnDragOrigin, removeImageFocus, separateChildren, setIsDragging, withEmoji, withMind, withMindExtend };
|
|
4181
4142
|
//# sourceMappingURL=plait-mind.mjs.map
|