@plait/mind 0.6.0 → 0.7.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/esm2020/interfaces/theme-color.mjs +11 -1
- package/esm2020/utils/mind.mjs +3 -4
- package/esm2020/utils/node/create-node.mjs +14 -9
- package/esm2020/utils/node-style/branch.mjs +9 -3
- package/esm2020/utils/node-style/common.mjs +2 -11
- package/esm2020/utils/node-style/shape.mjs +3 -9
- package/fesm2015/plait-mind.mjs +34 -27
- package/fesm2015/plait-mind.mjs.map +1 -1
- package/fesm2020/plait-mind.mjs +34 -27
- package/fesm2020/plait-mind.mjs.map +1 -1
- package/interfaces/theme-color.d.ts +3 -0
- package/package.json +1 -1
- package/utils/node/create-node.d.ts +1 -0
- package/utils/node-style/shape.d.ts +1 -1
package/fesm2020/plait-mind.mjs
CHANGED
|
@@ -204,6 +204,16 @@ const MindThemeColors = [
|
|
|
204
204
|
MindDarkThemeColor,
|
|
205
205
|
MindStarryThemeColor
|
|
206
206
|
];
|
|
207
|
+
const MindThemeColor = {
|
|
208
|
+
isMindThemeColor(value) {
|
|
209
|
+
if (value.branchColors && value.rootFill && value.rootTextColor) {
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
};
|
|
207
217
|
|
|
208
218
|
function getRectangleByNode(node) {
|
|
209
219
|
const x = node.x + node.hGap;
|
|
@@ -335,13 +345,13 @@ const createEmptyMind = (board, point) => {
|
|
|
335
345
|
return rootElement;
|
|
336
346
|
};
|
|
337
347
|
const createDefaultMind = (point, rightNodeCount, layout) => {
|
|
338
|
-
const root = createMindElement('思维导图', 72, ROOT_DEFAULT_HEIGHT, {
|
|
348
|
+
const root = createMindElement('思维导图', 72, ROOT_DEFAULT_HEIGHT, { layout });
|
|
339
349
|
root.rightNodeCount = rightNodeCount;
|
|
340
350
|
root.isRoot = true;
|
|
341
351
|
root.type = 'mindmap';
|
|
342
352
|
root.points = [point];
|
|
343
353
|
const children = [1, 1, 1].map(() => {
|
|
344
|
-
return createMindElement('新建节点', 56, TEXT_DEFAULT_HEIGHT, {
|
|
354
|
+
return createMindElement('新建节点', 56, TEXT_DEFAULT_HEIGHT, {});
|
|
345
355
|
});
|
|
346
356
|
root.children = children;
|
|
347
357
|
return root;
|
|
@@ -354,11 +364,7 @@ const createMindElement = (text, width, height, options) => {
|
|
|
354
364
|
},
|
|
355
365
|
children: [],
|
|
356
366
|
width,
|
|
357
|
-
height
|
|
358
|
-
fill: options.fill,
|
|
359
|
-
strokeColor: options.strokeColor,
|
|
360
|
-
strokeWidth: options.strokeWidth,
|
|
361
|
-
shape: options.shape
|
|
367
|
+
height
|
|
362
368
|
};
|
|
363
369
|
let key;
|
|
364
370
|
for (key in options) {
|
|
@@ -368,6 +374,16 @@ const createMindElement = (text, width, height, options) => {
|
|
|
368
374
|
}
|
|
369
375
|
return newElement;
|
|
370
376
|
};
|
|
377
|
+
const INHERIT_ATTRIBUTE_KEYS = [
|
|
378
|
+
'fill',
|
|
379
|
+
'strokeColor',
|
|
380
|
+
'strokeWidth',
|
|
381
|
+
'shape',
|
|
382
|
+
'layout',
|
|
383
|
+
'branchColor',
|
|
384
|
+
'branchWidth',
|
|
385
|
+
'branchShape'
|
|
386
|
+
];
|
|
371
387
|
|
|
372
388
|
const getChildrenCount = (element) => {
|
|
373
389
|
const count = element.children.reduce((p, c) => {
|
|
@@ -424,10 +440,9 @@ const extractNodesText = (node) => {
|
|
|
424
440
|
};
|
|
425
441
|
// layoutLevel 用来表示插入兄弟节点还是子节点
|
|
426
442
|
const insertMindElement = (board, inheritNode, path) => {
|
|
427
|
-
const inheritAttributeKeys = Object.keys({});
|
|
428
443
|
const newNode = {};
|
|
429
444
|
if (!inheritNode.isRoot) {
|
|
430
|
-
|
|
445
|
+
INHERIT_ATTRIBUTE_KEYS.forEach(attr => {
|
|
431
446
|
newNode[attr] = inheritNode[attr];
|
|
432
447
|
});
|
|
433
448
|
delete newNode.layout;
|
|
@@ -568,15 +583,7 @@ const getRootLayout = (root) => {
|
|
|
568
583
|
};
|
|
569
584
|
|
|
570
585
|
const getAvailableProperty = (board, element, propertyKey) => {
|
|
571
|
-
|
|
572
|
-
ancestors.unshift(element);
|
|
573
|
-
const ancestor = ancestors.find(value => value[propertyKey]);
|
|
574
|
-
if (ancestor) {
|
|
575
|
-
return ancestor[propertyKey];
|
|
576
|
-
}
|
|
577
|
-
else {
|
|
578
|
-
return undefined;
|
|
579
|
-
}
|
|
586
|
+
return element[propertyKey];
|
|
580
587
|
};
|
|
581
588
|
|
|
582
589
|
/**
|
|
@@ -623,7 +630,13 @@ const getDefaultBranchColorByIndex = (board, index) => {
|
|
|
623
630
|
};
|
|
624
631
|
const getMindThemeColor = (board) => {
|
|
625
632
|
const themeColors = PlaitBoard.getThemeColors(board);
|
|
626
|
-
|
|
633
|
+
const themeColor = themeColors.find(val => val.mode === board.theme.themeColorMode);
|
|
634
|
+
if (themeColor && MindThemeColor.isMindThemeColor(themeColor)) {
|
|
635
|
+
return themeColor;
|
|
636
|
+
}
|
|
637
|
+
else {
|
|
638
|
+
return MindDefaultThemeColor;
|
|
639
|
+
}
|
|
627
640
|
};
|
|
628
641
|
|
|
629
642
|
const getStrokeByMindElement = (board, element) => {
|
|
@@ -631,13 +644,7 @@ const getStrokeByMindElement = (board, element) => {
|
|
|
631
644
|
const defaultRootStroke = getMindThemeColor(board).rootFill;
|
|
632
645
|
return element.strokeColor || defaultRootStroke;
|
|
633
646
|
}
|
|
634
|
-
|
|
635
|
-
ancestors.unshift(element);
|
|
636
|
-
const ancestor = ancestors.find(value => value.strokeColor);
|
|
637
|
-
if (ancestor && ancestor.strokeColor && !PlaitMind.isMind(ancestor)) {
|
|
638
|
-
return ancestor.strokeColor;
|
|
639
|
-
}
|
|
640
|
-
return getDefaultBranchColor(board, element);
|
|
647
|
+
return getAvailableProperty(board, element, 'strokeColor') || getDefaultBranchColor(board, element);
|
|
641
648
|
};
|
|
642
649
|
const getShapeByElement = (board, element) => {
|
|
643
650
|
const shape = getAvailableProperty(board, element, 'shape');
|
|
@@ -4032,5 +4039,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
|
|
|
4032
4039
|
* Generated bundle index. Do not edit.
|
|
4033
4040
|
*/
|
|
4034
4041
|
|
|
4035
|
-
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE, BRANCH_WIDTH, BaseDrawer, BranchShape, DefaultAbstractNodeStyle, DefaultNodeStyle, ELEMENT_TO_NODE, EXTEND_OFFSET, EXTEND_RADIUS, GRAY_COLOR, IS_DRAGGING, LayoutDirection, LayoutDirectionsMap, MindColorfulThemeColor, MindDarkThemeColor, MindDefaultThemeColor, MindElement, MindElementShape, MindEmojiBaseComponent, MindModule, MindNode, MindNodeComponent, MindPointerType, MindQueries, MindRetroThemeColor, MindSoftThemeColor, MindStarryThemeColor, MindThemeColors, MindTransforms, NODE_MIN_WIDTH, PRIMARY_COLOR, PlaitMind, PlaitMindComponent, QUICK_INSERT_CIRCLE_COLOR, QUICK_INSERT_CIRCLE_OFFSET, QUICK_INSERT_INNER_CROSS_COLOR, ROOT_TOPIC_FONT_SIZE, STROKE_WIDTH, TOPIC_COLOR, TOPIC_DEFAULT_MAX_WORD_COUNT, TOPIC_FONT_SIZE, TRANSPARENT, addActiveOnDragOrigin, adjustAbstractToNode, adjustNodeToRoot, adjustRootToNode, canSetAbstract, copyNewNode, correctLayoutByDirection, createDefaultMind, createEmptyMind, createMindElement, deleteElementHandleAbstract, deleteElementsHandleRightNodeCount, detectDropTarget, directionCorrector, directionDetector, divideElementByParent, drawFakeDragNode, drawFakeDropNode, enterNodeEditing, extractNodesText, findLastChild, findLocationLeftIndex, getAbstractBranchColor, getAbstractBranchWidth, getAbstractHandleRectangle, getAllowedDirection, getAvailableSubLayoutsByLayoutDirections, getBehindAbstracts, getBranchColorByMindElement, getBranchDirectionsByLayouts, getBranchShapeByMindElement, getBranchWidthByMindElement, getChildrenCount, getCorrespondingAbstract, getDefaultBranchColor, getDefaultBranchColorByIndex, getDefaultLayout, getEmojiForeignRectangle, getEmojiRectangle, getFirstLevelElement, getHitAbstractHandle, getInCorrectLayoutDirection, getLayoutDirection$1 as getLayoutDirection, getLayoutReverseDirection, getLocationScope, getMindThemeColor, getNextBranchColor, getOverallAbstracts, getPathByDropTarget, getRectangleByElement, getRectangleByNode, getRectangleByResizingLocation, getRelativeStartEndByAbstractRef, getRootLayout, getShapeByElement, getStrokeByMindElement, getTopicRectangleByElement, getTopicRectangleByNode, getValidAbstractRefs, handleTouchedAbstract, hasAfterDraw, hasPreviousOrNextOfDropPath, insertElementHandleAbstract, insertElementHandleRightNodeCount, insertMindElement, isChildElement, isChildRight, isChildUp, isCorrectLayout, isDragging, isDropStandardRight, isHitEmojis, isHitMindElement, isInRightBranchOfStandardLayout, isMixedLayout, isSetAbstract, isValidTarget, isVirtualKey, removeActiveOnDragOrigin, separateChildren, setIsDragging, withMind, withMindExtend };
|
|
4042
|
+
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE, BRANCH_WIDTH, BaseDrawer, BranchShape, DefaultAbstractNodeStyle, DefaultNodeStyle, ELEMENT_TO_NODE, EXTEND_OFFSET, EXTEND_RADIUS, GRAY_COLOR, INHERIT_ATTRIBUTE_KEYS, IS_DRAGGING, LayoutDirection, LayoutDirectionsMap, MindColorfulThemeColor, MindDarkThemeColor, MindDefaultThemeColor, MindElement, MindElementShape, MindEmojiBaseComponent, MindModule, MindNode, MindNodeComponent, MindPointerType, MindQueries, MindRetroThemeColor, MindSoftThemeColor, MindStarryThemeColor, MindThemeColor, MindThemeColors, MindTransforms, NODE_MIN_WIDTH, PRIMARY_COLOR, PlaitMind, PlaitMindComponent, QUICK_INSERT_CIRCLE_COLOR, QUICK_INSERT_CIRCLE_OFFSET, QUICK_INSERT_INNER_CROSS_COLOR, ROOT_TOPIC_FONT_SIZE, STROKE_WIDTH, TOPIC_COLOR, TOPIC_DEFAULT_MAX_WORD_COUNT, TOPIC_FONT_SIZE, TRANSPARENT, addActiveOnDragOrigin, adjustAbstractToNode, adjustNodeToRoot, adjustRootToNode, canSetAbstract, copyNewNode, correctLayoutByDirection, createDefaultMind, createEmptyMind, createMindElement, deleteElementHandleAbstract, deleteElementsHandleRightNodeCount, detectDropTarget, directionCorrector, directionDetector, divideElementByParent, drawFakeDragNode, drawFakeDropNode, enterNodeEditing, extractNodesText, findLastChild, findLocationLeftIndex, getAbstractBranchColor, getAbstractBranchWidth, getAbstractHandleRectangle, getAllowedDirection, getAvailableSubLayoutsByLayoutDirections, getBehindAbstracts, getBranchColorByMindElement, getBranchDirectionsByLayouts, getBranchShapeByMindElement, getBranchWidthByMindElement, getChildrenCount, getCorrespondingAbstract, getDefaultBranchColor, getDefaultBranchColorByIndex, getDefaultLayout, getEmojiForeignRectangle, getEmojiRectangle, getFirstLevelElement, getHitAbstractHandle, getInCorrectLayoutDirection, getLayoutDirection$1 as getLayoutDirection, getLayoutReverseDirection, getLocationScope, getMindThemeColor, getNextBranchColor, getOverallAbstracts, getPathByDropTarget, getRectangleByElement, getRectangleByNode, getRectangleByResizingLocation, getRelativeStartEndByAbstractRef, getRootLayout, getShapeByElement, getStrokeByMindElement, getTopicRectangleByElement, getTopicRectangleByNode, getValidAbstractRefs, handleTouchedAbstract, hasAfterDraw, hasPreviousOrNextOfDropPath, insertElementHandleAbstract, insertElementHandleRightNodeCount, insertMindElement, isChildElement, isChildRight, isChildUp, isCorrectLayout, isDragging, isDropStandardRight, isHitEmojis, isHitMindElement, isInRightBranchOfStandardLayout, isMixedLayout, isSetAbstract, isValidTarget, isVirtualKey, removeActiveOnDragOrigin, separateChildren, setIsDragging, withMind, withMindExtend };
|
|
4036
4043
|
//# sourceMappingURL=plait-mind.mjs.map
|