@plait/mind 0.5.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/constants/node-style.d.ts +0 -6
- package/constants/theme.d.ts +6 -0
- package/esm2020/constants/node-style.mjs +4 -10
- package/esm2020/constants/theme.mjs +73 -0
- package/esm2020/drawer/emojis.drawer.mjs +2 -3
- package/esm2020/drawer/quick-insert.drawer.mjs +4 -2
- package/esm2020/interfaces/index.mjs +2 -1
- package/esm2020/interfaces/theme-color.mjs +57 -0
- package/esm2020/node.component.mjs +4 -3
- package/esm2020/plugins/with-mind-hotkey.mjs +28 -0
- package/esm2020/plugins/with-mind.mjs +18 -2
- package/esm2020/utils/draw/node-dnd.mjs +2 -3
- package/esm2020/utils/draw/node-link/indented-link.mjs +2 -2
- package/esm2020/utils/draw/node-link/logic-link.mjs +2 -2
- package/esm2020/utils/draw/node-shape.mjs +5 -3
- package/esm2020/utils/draw/node-topic.mjs +3 -3
- package/esm2020/utils/mind.mjs +8 -9
- package/esm2020/utils/node/create-node.mjs +19 -29
- package/esm2020/utils/node-style/branch.mjs +19 -8
- package/esm2020/utils/node-style/common.mjs +2 -11
- package/esm2020/utils/node-style/shape.mjs +6 -12
- package/fesm2015/plait-mind.mjs +199 -75
- package/fesm2015/plait-mind.mjs.map +1 -1
- package/fesm2020/plait-mind.mjs +229 -75
- package/fesm2020/plait-mind.mjs.map +1 -1
- package/interfaces/index.d.ts +1 -0
- package/interfaces/theme-color.d.ts +17 -0
- package/package.json +1 -1
- package/plugins/with-mind-hotkey.d.ts +3 -0
- package/plugins/with-mind.d.ts +1 -1
- package/styles/mixins.scss +31 -0
- package/styles/styles.scss +4 -0
- package/utils/mind.d.ts +5 -5
- package/utils/node/create-node.d.ts +6 -3
- package/utils/node-style/branch.d.ts +4 -2
- package/utils/node-style/shape.d.ts +1 -1
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DefaultRootStyle } from '../../constants/node-style';
|
|
1
|
+
import { MindElementShape, PlaitMind } from '../../interfaces/element';
|
|
3
2
|
import { getAvailableProperty } from './common';
|
|
4
|
-
import { getDefaultBranchColor } from './branch';
|
|
3
|
+
import { getDefaultBranchColor, getMindThemeColor } from './branch';
|
|
5
4
|
export const getStrokeByMindElement = (board, element) => {
|
|
6
5
|
if (PlaitMind.isMind(element)) {
|
|
7
|
-
|
|
6
|
+
const defaultRootStroke = getMindThemeColor(board).rootFill;
|
|
7
|
+
return element.strokeColor || defaultRootStroke;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
ancestors.unshift(element);
|
|
11
|
-
const ancestor = ancestors.find(value => value.strokeColor);
|
|
12
|
-
if (ancestor && ancestor.strokeColor && !PlaitMind.isMind(ancestor)) {
|
|
13
|
-
return ancestor.strokeColor;
|
|
14
|
-
}
|
|
15
|
-
return getDefaultBranchColor(board, element);
|
|
9
|
+
return getAvailableProperty(board, element, 'strokeColor') || getDefaultBranchColor(board, element);
|
|
16
10
|
};
|
|
17
11
|
export const getShapeByElement = (board, element) => {
|
|
18
12
|
const shape = getAvailableProperty(board, element, 'shape');
|
|
19
13
|
return shape || MindElementShape.roundRectangle;
|
|
20
14
|
};
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
15
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2hhcGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9taW5kL3NyYy91dGlscy9ub2RlLXN0eWxlL3NoYXBlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBZSxnQkFBZ0IsRUFBRSxTQUFTLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUNwRixPQUFPLEVBQUUsb0JBQW9CLEVBQUUsTUFBTSxVQUFVLENBQUM7QUFDaEQsT0FBTyxFQUFFLHFCQUFxQixFQUFFLGlCQUFpQixFQUFFLE1BQU0sVUFBVSxDQUFDO0FBRXBFLE1BQU0sQ0FBQyxNQUFNLHNCQUFzQixHQUFHLENBQUMsS0FBaUIsRUFBRSxPQUFvQixFQUFFLEVBQUU7SUFDOUUsSUFBSSxTQUFTLENBQUMsTUFBTSxDQUFDLE9BQU8sQ0FBQyxFQUFFO1FBQzNCLE1BQU0saUJBQWlCLEdBQUcsaUJBQWlCLENBQUMsS0FBSyxDQUFDLENBQUMsUUFBUSxDQUFDO1FBQzVELE9BQU8sT0FBTyxDQUFDLFdBQVcsSUFBSSxpQkFBaUIsQ0FBQztLQUNuRDtJQUVELE9BQU8sb0JBQW9CLENBQUMsS0FBSyxFQUFFLE9BQU8sRUFBRSxhQUFhLENBQUMsSUFBSSxxQkFBcUIsQ0FBQyxLQUFLLEVBQUUsT0FBTyxDQUFDLENBQUM7QUFDeEcsQ0FBQyxDQUFDO0FBRUYsTUFBTSxDQUFDLE1BQU0saUJBQWlCLEdBQUcsQ0FBQyxLQUFpQixFQUFFLE9BQW9CLEVBQW9CLEVBQUU7SUFDM0YsTUFBTSxLQUFLLEdBQUcsb0JBQW9CLENBQUMsS0FBSyxFQUFFLE9BQU8sRUFBRSxPQUFPLENBQUMsQ0FBQztJQUM1RCxPQUFPLEtBQUssSUFBSSxnQkFBZ0IsQ0FBQyxjQUFjLENBQUM7QUFDcEQsQ0FBQyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgUGxhaXRCb2FyZCB9IGZyb20gJ0BwbGFpdC9jb3JlJztcbmltcG9ydCB7IE1pbmRFbGVtZW50LCBNaW5kRWxlbWVudFNoYXBlLCBQbGFpdE1pbmQgfSBmcm9tICcuLi8uLi9pbnRlcmZhY2VzL2VsZW1lbnQnO1xuaW1wb3J0IHsgZ2V0QXZhaWxhYmxlUHJvcGVydHkgfSBmcm9tICcuL2NvbW1vbic7XG5pbXBvcnQgeyBnZXREZWZhdWx0QnJhbmNoQ29sb3IsIGdldE1pbmRUaGVtZUNvbG9yIH0gZnJvbSAnLi9icmFuY2gnO1xuXG5leHBvcnQgY29uc3QgZ2V0U3Ryb2tlQnlNaW5kRWxlbWVudCA9IChib2FyZDogUGxhaXRCb2FyZCwgZWxlbWVudDogTWluZEVsZW1lbnQpID0+IHtcbiAgICBpZiAoUGxhaXRNaW5kLmlzTWluZChlbGVtZW50KSkge1xuICAgICAgICBjb25zdCBkZWZhdWx0Um9vdFN0cm9rZSA9IGdldE1pbmRUaGVtZUNvbG9yKGJvYXJkKS5yb290RmlsbDtcbiAgICAgICAgcmV0dXJuIGVsZW1lbnQuc3Ryb2tlQ29sb3IgfHwgZGVmYXVsdFJvb3RTdHJva2U7XG4gICAgfVxuXG4gICAgcmV0dXJuIGdldEF2YWlsYWJsZVByb3BlcnR5KGJvYXJkLCBlbGVtZW50LCAnc3Ryb2tlQ29sb3InKSB8fCBnZXREZWZhdWx0QnJhbmNoQ29sb3IoYm9hcmQsIGVsZW1lbnQpO1xufTtcblxuZXhwb3J0IGNvbnN0IGdldFNoYXBlQnlFbGVtZW50ID0gKGJvYXJkOiBQbGFpdEJvYXJkLCBlbGVtZW50OiBNaW5kRWxlbWVudCk6IE1pbmRFbGVtZW50U2hhcGUgPT4ge1xuICAgIGNvbnN0IHNoYXBlID0gZ2V0QXZhaWxhYmxlUHJvcGVydHkoYm9hcmQsIGVsZW1lbnQsICdzaGFwZScpO1xuICAgIHJldHVybiBzaGFwZSB8fCBNaW5kRWxlbWVudFNoYXBlLnJvdW5kUmVjdGFuZ2xlO1xufTtcbiJdfQ==
|
package/fesm2015/plait-mind.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Component, ChangeDetectionStrategy, NgModule, Directive, Input, HostListener } from '@angular/core';
|
|
3
3
|
import * as i2 from '@plait/core';
|
|
4
|
-
import { distanceBetweenPointAndRectangle, RectangleClient, PlaitElement, PlaitBoard, idCreator, isNullOrUndefined, Transforms, clearSelectedElement, addSelectedElement, depthFirstRecursion, Path, drawRoundRectangle, drawLinearPath, createG, PlaitNode, getRectangleByElements, getSelectedElements, NODE_TO_PARENT, drawAbstractRoundRectangle, PlaitPluginElementComponent, PlaitPointerType, NODE_TO_INDEX, createText, IS_TEXT_EDITABLE, MERGING, transformPoint, toPoint, PlaitModule, distanceBetweenPointAndPoint, CLIP_BOARD_FORMAT_KEY, isMainPointer, BOARD_TO_HOST, PlaitPluginKey, throttleRAF,
|
|
4
|
+
import { DefaultThemeColor, ColorfulThemeColor, SoftThemeColor, RetroThemeColor, DarkThemeColor, StarryThemeColor, distanceBetweenPointAndRectangle, RectangleClient, PlaitElement, PlaitBoard, idCreator, isNullOrUndefined, Transforms, clearSelectedElement, addSelectedElement, depthFirstRecursion, Path, drawRoundRectangle, drawLinearPath, createG, updateForeignObject, PlaitNode, getRectangleByElements, getSelectedElements, NODE_TO_PARENT, createForeignObject, drawAbstractRoundRectangle, PlaitPluginElementComponent, PlaitPointerType, NODE_TO_INDEX, createText, IS_TEXT_EDITABLE, MERGING, transformPoint, toPoint, PlaitModule, distanceBetweenPointAndPoint, CLIP_BOARD_FORMAT_KEY, isMainPointer, BOARD_TO_HOST, PlaitPluginKey, throttleRAF, BoardTransforms, removeSelectedElement, PlaitHistoryBoard, hotkeys } from '@plait/core';
|
|
5
5
|
import { MindLayoutType, isIndentedLayout, getNonAbstractChildren, isStandardLayout, AbstractNode, isLeftLayout, isRightLayout, isVerticalLogicLayout, isHorizontalLogicLayout, isTopLayout, isBottomLayout, isHorizontalLayout, getCorrectStartEnd, getAbstractLayout, ConnectingPosition, GlobalLayout } from '@plait/layouts';
|
|
6
|
-
import { getSizeByText, ROOT_DEFAULT_HEIGHT, TEXT_DEFAULT_HEIGHT,
|
|
6
|
+
import { getSizeByText, ROOT_DEFAULT_HEIGHT, TEXT_DEFAULT_HEIGHT, drawRichtext, updateRichText, setFullSelectionAndFocus, getRichtextContentSize, hasEditableTarget, RichtextModule } from '@plait/richtext';
|
|
7
7
|
import { fromEvent, Subject, timer } from 'rxjs';
|
|
8
8
|
import { take, takeUntil, filter, debounceTime } from 'rxjs/operators';
|
|
9
9
|
import { Node, Path as Path$1, Editor, Operation } from 'slate';
|
|
@@ -30,19 +30,13 @@ const DefaultAbstractNodeStyle = {
|
|
|
30
30
|
strokeColor: GRAY_COLOR,
|
|
31
31
|
strokeWidth: 2,
|
|
32
32
|
branchColor: GRAY_COLOR,
|
|
33
|
-
branchWidth: 2
|
|
34
|
-
fill: '#FFFFFF'
|
|
33
|
+
branchWidth: 2
|
|
35
34
|
};
|
|
36
35
|
const DefaultNodeStyle = {
|
|
37
36
|
strokeWidth: 3,
|
|
38
37
|
branchWidth: 3,
|
|
39
|
-
fill: '
|
|
38
|
+
fill: 'none'
|
|
40
39
|
};
|
|
41
|
-
const DefaultRootStyle = {
|
|
42
|
-
fill: '#F5F5F5',
|
|
43
|
-
strokeColor: '#F5F5F5',
|
|
44
|
-
};
|
|
45
|
-
const BRANCH_COLORS = ['#A287E1', '#6F81DB', '#6EC4C4', '#DFB85D', '#B1C774', '#77C386', '#C28976', '#E48484', '#E482D4', '#69B1E4'];
|
|
46
40
|
|
|
47
41
|
const TOPIC_COLOR = '#333';
|
|
48
42
|
const TOPIC_FONT_SIZE = 14;
|
|
@@ -93,6 +87,104 @@ var MindPointerType;
|
|
|
93
87
|
MindPointerType["mind"] = "mind";
|
|
94
88
|
})(MindPointerType || (MindPointerType = {}));
|
|
95
89
|
|
|
90
|
+
const DEFAULT_BRANCH_COLORS = [
|
|
91
|
+
'#A287E0',
|
|
92
|
+
'#6E80DB',
|
|
93
|
+
'#6DC4C4',
|
|
94
|
+
'#E0B75E',
|
|
95
|
+
'#B1C675',
|
|
96
|
+
'#77C386',
|
|
97
|
+
'#C18976',
|
|
98
|
+
'#E48484',
|
|
99
|
+
'#E582D4',
|
|
100
|
+
'#6AB1E4'
|
|
101
|
+
];
|
|
102
|
+
const COLORFUL_BRANCH_COLORS = [
|
|
103
|
+
'#F94239',
|
|
104
|
+
'#FF8612',
|
|
105
|
+
'#F3D222',
|
|
106
|
+
'#B3D431',
|
|
107
|
+
'#00BC7B',
|
|
108
|
+
'#06ADBF',
|
|
109
|
+
'#476BFF',
|
|
110
|
+
'#4E49BE',
|
|
111
|
+
'#8957E5',
|
|
112
|
+
'#FE5DA1'
|
|
113
|
+
];
|
|
114
|
+
const SOFT_BRANCH_COLORS = [
|
|
115
|
+
'#6D89C1',
|
|
116
|
+
'#F2BDC7',
|
|
117
|
+
'#B796D9',
|
|
118
|
+
'#5BA683',
|
|
119
|
+
'#B3D431 ',
|
|
120
|
+
'#F2DC6C',
|
|
121
|
+
'#F7C98D',
|
|
122
|
+
'#60B4D1',
|
|
123
|
+
'#838F9E',
|
|
124
|
+
'#C1A381'
|
|
125
|
+
];
|
|
126
|
+
const RETRO_BRANCH_COLORS = [
|
|
127
|
+
'#459476',
|
|
128
|
+
'#9A894F',
|
|
129
|
+
'#D48444',
|
|
130
|
+
'#E9C358 ',
|
|
131
|
+
'#4B9D9D',
|
|
132
|
+
'#C14C41',
|
|
133
|
+
'#827086 ',
|
|
134
|
+
'#60718D',
|
|
135
|
+
'#D38183',
|
|
136
|
+
'#9DC19D'
|
|
137
|
+
];
|
|
138
|
+
const DARK_BRANCH_COLORS = [
|
|
139
|
+
'#3DD1AE',
|
|
140
|
+
'#F6C659',
|
|
141
|
+
'#A9E072',
|
|
142
|
+
'#FF877B ',
|
|
143
|
+
'#F693E7',
|
|
144
|
+
'#5DCFFF',
|
|
145
|
+
'#868AF6',
|
|
146
|
+
'#4C6DC7',
|
|
147
|
+
'#D97C26',
|
|
148
|
+
'#268FAC'
|
|
149
|
+
];
|
|
150
|
+
const STARRY_BRANCH_COLORS = [
|
|
151
|
+
'#E46C57',
|
|
152
|
+
'#579360',
|
|
153
|
+
'#B98339',
|
|
154
|
+
'#3A62D1 ',
|
|
155
|
+
'#B883B7',
|
|
156
|
+
'#42ABE5',
|
|
157
|
+
'#2B9D8F',
|
|
158
|
+
'#A4705E',
|
|
159
|
+
'#265833',
|
|
160
|
+
'#787865'
|
|
161
|
+
];
|
|
162
|
+
|
|
163
|
+
const MindDefaultThemeColor = Object.assign(Object.assign({}, DefaultThemeColor), { branchColors: DEFAULT_BRANCH_COLORS, rootFill: '#f5f5f5', rootTextColor: '#333333' });
|
|
164
|
+
const MindColorfulThemeColor = Object.assign(Object.assign({}, ColorfulThemeColor), { branchColors: COLORFUL_BRANCH_COLORS, rootFill: '#333333', rootTextColor: '#FFFFFF' });
|
|
165
|
+
const MindSoftThemeColor = Object.assign(Object.assign({}, SoftThemeColor), { branchColors: SOFT_BRANCH_COLORS, rootFill: '#FFFFFF', rootTextColor: '#333333' });
|
|
166
|
+
const MindRetroThemeColor = Object.assign(Object.assign({}, RetroThemeColor), { branchColors: RETRO_BRANCH_COLORS, rootFill: '#153D5D', rootTextColor: '#FFFFFF' });
|
|
167
|
+
const MindDarkThemeColor = Object.assign(Object.assign({}, DarkThemeColor), { branchColors: DARK_BRANCH_COLORS, rootFill: '#FFFFFF', rootTextColor: '#333333' });
|
|
168
|
+
const MindStarryThemeColor = Object.assign(Object.assign({}, StarryThemeColor), { branchColors: STARRY_BRANCH_COLORS, rootFill: '#FFFFFF', rootTextColor: '#333333' });
|
|
169
|
+
const MindThemeColors = [
|
|
170
|
+
MindDefaultThemeColor,
|
|
171
|
+
MindColorfulThemeColor,
|
|
172
|
+
MindSoftThemeColor,
|
|
173
|
+
MindRetroThemeColor,
|
|
174
|
+
MindDarkThemeColor,
|
|
175
|
+
MindStarryThemeColor
|
|
176
|
+
];
|
|
177
|
+
const MindThemeColor = {
|
|
178
|
+
isMindThemeColor(value) {
|
|
179
|
+
if (value.branchColors && value.rootFill && value.rootTextColor) {
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
96
188
|
function getRectangleByNode(node) {
|
|
97
189
|
const x = node.x + node.hGap;
|
|
98
190
|
let y = node.y + node.vGap;
|
|
@@ -218,13 +310,13 @@ const createEmptyMind = (board, point) => {
|
|
|
218
310
|
return rootElement;
|
|
219
311
|
};
|
|
220
312
|
const createDefaultMind = (point, rightNodeCount, layout) => {
|
|
221
|
-
const root = createMindElement('思维导图', 72, ROOT_DEFAULT_HEIGHT, {
|
|
313
|
+
const root = createMindElement('思维导图', 72, ROOT_DEFAULT_HEIGHT, { layout });
|
|
222
314
|
root.rightNodeCount = rightNodeCount;
|
|
223
315
|
root.isRoot = true;
|
|
224
316
|
root.type = 'mindmap';
|
|
225
317
|
root.points = [point];
|
|
226
318
|
const children = [1, 1, 1].map(() => {
|
|
227
|
-
return createMindElement('新建节点', 56, TEXT_DEFAULT_HEIGHT, {
|
|
319
|
+
return createMindElement('新建节点', 56, TEXT_DEFAULT_HEIGHT, {});
|
|
228
320
|
});
|
|
229
321
|
root.children = children;
|
|
230
322
|
return root;
|
|
@@ -237,35 +329,26 @@ const createMindElement = (text, width, height, options) => {
|
|
|
237
329
|
},
|
|
238
330
|
children: [],
|
|
239
331
|
width,
|
|
240
|
-
height
|
|
241
|
-
fill: options.fill,
|
|
242
|
-
strokeColor: options.strokeColor,
|
|
243
|
-
strokeWidth: options.strokeWidth,
|
|
244
|
-
shape: options.shape
|
|
332
|
+
height
|
|
245
333
|
};
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
if (!isNullOrUndefined(options.strokeWidth)) {
|
|
253
|
-
newElement.strokeWidth = options.strokeWidth;
|
|
254
|
-
}
|
|
255
|
-
if (options.shape) {
|
|
256
|
-
newElement.shape = options.shape;
|
|
257
|
-
}
|
|
258
|
-
if (options.layout) {
|
|
259
|
-
newElement.layout = options.layout;
|
|
260
|
-
}
|
|
261
|
-
if (options.branchColor) {
|
|
262
|
-
newElement.branchColor = options.branchColor;
|
|
263
|
-
}
|
|
264
|
-
if (!isNullOrUndefined(options.branchWidth)) {
|
|
265
|
-
newElement.branchWidth = options.branchWidth;
|
|
334
|
+
let key;
|
|
335
|
+
for (key in options) {
|
|
336
|
+
if (!isNullOrUndefined(options[key])) {
|
|
337
|
+
newElement[key] = options[key];
|
|
338
|
+
}
|
|
266
339
|
}
|
|
267
340
|
return newElement;
|
|
268
341
|
};
|
|
342
|
+
const INHERIT_ATTRIBUTE_KEYS = [
|
|
343
|
+
'fill',
|
|
344
|
+
'strokeColor',
|
|
345
|
+
'strokeWidth',
|
|
346
|
+
'shape',
|
|
347
|
+
'layout',
|
|
348
|
+
'branchColor',
|
|
349
|
+
'branchWidth',
|
|
350
|
+
'branchShape'
|
|
351
|
+
];
|
|
269
352
|
|
|
270
353
|
const getChildrenCount = (element) => {
|
|
271
354
|
const count = element.children.reduce((p, c) => {
|
|
@@ -322,14 +405,14 @@ const extractNodesText = (node) => {
|
|
|
322
405
|
};
|
|
323
406
|
// layoutLevel 用来表示插入兄弟节点还是子节点
|
|
324
407
|
const insertMindElement = (board, inheritNode, path) => {
|
|
325
|
-
|
|
408
|
+
const newNode = {};
|
|
326
409
|
if (!inheritNode.isRoot) {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
410
|
+
INHERIT_ATTRIBUTE_KEYS.forEach(attr => {
|
|
411
|
+
newNode[attr] = inheritNode[attr];
|
|
412
|
+
});
|
|
413
|
+
delete newNode.layout;
|
|
330
414
|
}
|
|
331
|
-
|
|
332
|
-
const newElement = createMindElement('', NODE_MIN_WIDTH, TEXT_DEFAULT_HEIGHT, { fill, strokeColor, strokeWidth, shape });
|
|
415
|
+
const newElement = createMindElement('', NODE_MIN_WIDTH, TEXT_DEFAULT_HEIGHT, newNode);
|
|
333
416
|
Transforms.insertNode(board, newElement, path);
|
|
334
417
|
clearSelectedElement(board);
|
|
335
418
|
addSelectedElement(board, newElement);
|
|
@@ -465,15 +548,7 @@ const getRootLayout = (root) => {
|
|
|
465
548
|
};
|
|
466
549
|
|
|
467
550
|
const getAvailableProperty = (board, element, propertyKey) => {
|
|
468
|
-
|
|
469
|
-
ancestors.unshift(element);
|
|
470
|
-
const ancestor = ancestors.find(value => value[propertyKey]);
|
|
471
|
-
if (ancestor) {
|
|
472
|
-
return ancestor[propertyKey];
|
|
473
|
-
}
|
|
474
|
-
else {
|
|
475
|
-
return undefined;
|
|
476
|
-
}
|
|
551
|
+
return element[propertyKey];
|
|
477
552
|
};
|
|
478
553
|
|
|
479
554
|
/**
|
|
@@ -505,31 +580,37 @@ const getAbstractBranchColor = (board, element) => {
|
|
|
505
580
|
}
|
|
506
581
|
return DefaultAbstractNodeStyle.branchColor;
|
|
507
582
|
};
|
|
508
|
-
const getNextBranchColor = (root) => {
|
|
583
|
+
const getNextBranchColor = (board, root) => {
|
|
509
584
|
const index = root.children.length;
|
|
510
|
-
return getDefaultBranchColorByIndex(index);
|
|
585
|
+
return getDefaultBranchColorByIndex(board, index);
|
|
511
586
|
};
|
|
512
587
|
const getDefaultBranchColor = (board, element) => {
|
|
513
588
|
const path = PlaitBoard.findPath(board, element);
|
|
514
|
-
return getDefaultBranchColorByIndex(path[1]);
|
|
589
|
+
return getDefaultBranchColorByIndex(board, path[1]);
|
|
515
590
|
};
|
|
516
|
-
const getDefaultBranchColorByIndex = (index) => {
|
|
517
|
-
const
|
|
591
|
+
const getDefaultBranchColorByIndex = (board, index) => {
|
|
592
|
+
const themeColor = getMindThemeColor(board);
|
|
593
|
+
const length = themeColor.branchColors.length;
|
|
518
594
|
const remainder = index % length;
|
|
519
|
-
return
|
|
595
|
+
return themeColor.branchColors[remainder];
|
|
596
|
+
};
|
|
597
|
+
const getMindThemeColor = (board) => {
|
|
598
|
+
const themeColors = PlaitBoard.getThemeColors(board);
|
|
599
|
+
const themeColor = themeColors.find(val => val.mode === board.theme.themeColorMode);
|
|
600
|
+
if (themeColor && MindThemeColor.isMindThemeColor(themeColor)) {
|
|
601
|
+
return themeColor;
|
|
602
|
+
}
|
|
603
|
+
else {
|
|
604
|
+
return MindDefaultThemeColor;
|
|
605
|
+
}
|
|
520
606
|
};
|
|
521
607
|
|
|
522
608
|
const getStrokeByMindElement = (board, element) => {
|
|
523
609
|
if (PlaitMind.isMind(element)) {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
const ancestors = MindElement.getAncestors(board, element);
|
|
527
|
-
ancestors.unshift(element);
|
|
528
|
-
const ancestor = ancestors.find(value => value.strokeColor);
|
|
529
|
-
if (ancestor && ancestor.strokeColor && !PlaitMind.isMind(ancestor)) {
|
|
530
|
-
return ancestor.strokeColor;
|
|
610
|
+
const defaultRootStroke = getMindThemeColor(board).rootFill;
|
|
611
|
+
return element.strokeColor || defaultRootStroke;
|
|
531
612
|
}
|
|
532
|
-
return getDefaultBranchColor(board, element);
|
|
613
|
+
return getAvailableProperty(board, element, 'strokeColor') || getDefaultBranchColor(board, element);
|
|
533
614
|
};
|
|
534
615
|
const getShapeByElement = (board, element) => {
|
|
535
616
|
const shape = getAvailableProperty(board, element, 'shape');
|
|
@@ -786,7 +867,8 @@ function drawRoundRectangleByNode(board, node) {
|
|
|
786
867
|
return drawRoundRectangleByElement(board, rectangle, node.origin);
|
|
787
868
|
}
|
|
788
869
|
function drawRoundRectangleByElement(board, nodeRectangle, element) {
|
|
789
|
-
const
|
|
870
|
+
const defaultRootFill = getMindThemeColor(board).rootFill;
|
|
871
|
+
const fill = element.fill ? element.fill : element.isRoot ? defaultRootFill : DefaultNodeStyle.fill;
|
|
790
872
|
const stroke = getStrokeByMindElement(board, element);
|
|
791
873
|
const strokeWidth = element.strokeWidth ? element.strokeWidth : DefaultNodeStyle.strokeWidth;
|
|
792
874
|
const nodeG = drawRoundRectangle(PlaitBoard.getRoughSVG(board), nodeRectangle.x, nodeRectangle.y, nodeRectangle.x + nodeRectangle.width, nodeRectangle.y + nodeRectangle.height, {
|
|
@@ -930,7 +1012,7 @@ const transformPlacement = (placement, direction) => {
|
|
|
930
1012
|
|
|
931
1013
|
function drawIndentedLink(board, node, child, defaultStroke = null, needDrawUnderline = true, defaultStrokeWidth) {
|
|
932
1014
|
const branchShape = getBranchShapeByMindElement(board, node.origin);
|
|
933
|
-
const branchWidth = defaultStrokeWidth || getBranchWidthByMindElement(board,
|
|
1015
|
+
const branchWidth = defaultStrokeWidth || getBranchWidthByMindElement(board, node.origin);
|
|
934
1016
|
const branchColor = defaultStroke || getBranchColorByMindElement(board, child.origin);
|
|
935
1017
|
const isUnderlineShape = getShapeByElement(board, child.origin) === MindElementShape.underline;
|
|
936
1018
|
let beginX, beginY, endX, endY, beginNode = node, endNode = child;
|
|
@@ -978,7 +1060,7 @@ function drawIndentedLink(board, node, child, defaultStroke = null, needDrawUnde
|
|
|
978
1060
|
function drawLogicLink(board, parent, node, isHorizontal, defaultStroke = null, defaultStrokeWidth) {
|
|
979
1061
|
const branchShape = getBranchShapeByMindElement(board, parent.origin);
|
|
980
1062
|
const branchColor = defaultStroke || getBranchColorByMindElement(board, node.origin);
|
|
981
|
-
const branchWidth = defaultStrokeWidth || getBranchWidthByMindElement(board,
|
|
1063
|
+
const branchWidth = defaultStrokeWidth || getBranchWidthByMindElement(board, parent.origin);
|
|
982
1064
|
const hasStraightLine = !parent.origin.isRoot;
|
|
983
1065
|
const parentShape = getShapeByElement(board, parent.origin);
|
|
984
1066
|
const shape = node.origin.shape ? node.origin.shape : parentShape;
|
|
@@ -2405,7 +2487,9 @@ class QuickInsertDrawer extends BaseDrawer {
|
|
|
2405
2487
|
underlineCoordinates[MindLayoutType.right].startY -= height * 0.5;
|
|
2406
2488
|
underlineCoordinates[MindLayoutType.right].endY -= height * 0.5;
|
|
2407
2489
|
}
|
|
2408
|
-
const branchColor = PlaitMind.isMind(element)
|
|
2490
|
+
const branchColor = PlaitMind.isMind(element)
|
|
2491
|
+
? getNextBranchColor(this.board, element)
|
|
2492
|
+
: getBranchColorByMindElement(this.board, element);
|
|
2409
2493
|
let nodeLayout = MindQueries.getCorrectLayoutByElement(this.board, element);
|
|
2410
2494
|
if (element.isRoot && isStandardLayout(nodeLayout)) {
|
|
2411
2495
|
const root = element;
|
|
@@ -2517,7 +2601,8 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2517
2601
|
}
|
|
2518
2602
|
const isEqualNode = RectangleClient.isEqual(this.node, newNode);
|
|
2519
2603
|
this.node = newNode;
|
|
2520
|
-
|
|
2604
|
+
const isChangeTheme = this.board.operations.find(op => op.type === 'set_theme');
|
|
2605
|
+
if (!isEqualNode || value.element !== previous.element || isChangeTheme) {
|
|
2521
2606
|
this.drawActiveG();
|
|
2522
2607
|
this.updateActiveClass();
|
|
2523
2608
|
this.drawShape();
|
|
@@ -2737,7 +2822,7 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2737
2822
|
}
|
|
2738
2823
|
// interactive
|
|
2739
2824
|
fromEvent(collapseG, 'mouseup')
|
|
2740
|
-
.pipe(filter(() => !this.handActive || PlaitBoard.isReadonly(this.board)), take(1))
|
|
2825
|
+
.pipe(filter(() => !this.handActive || !!PlaitBoard.isReadonly(this.board)), take(1))
|
|
2741
2826
|
.subscribe(() => {
|
|
2742
2827
|
const isCollapsed = !this.node.origin.isCollapsed;
|
|
2743
2828
|
const newElement = { isCollapsed };
|
|
@@ -3570,7 +3655,7 @@ const withCreateMind = (board) => {
|
|
|
3570
3655
|
fakeCreateNodeRef.nodeG = nodeG;
|
|
3571
3656
|
PlaitBoard.getHost(board).append(nodeG);
|
|
3572
3657
|
PlaitBoard.getHost(board).append(fakeCreateNodeRef.topicG);
|
|
3573
|
-
updateForeignObject
|
|
3658
|
+
updateForeignObject(fakeCreateNodeRef.topicG, topicRectangle.width, topicRectangle.height, topicRectangle.x, topicRectangle.y);
|
|
3574
3659
|
}
|
|
3575
3660
|
}
|
|
3576
3661
|
});
|
|
@@ -3615,6 +3700,31 @@ const withCreateMind = (board) => {
|
|
|
3615
3700
|
return newBoard;
|
|
3616
3701
|
};
|
|
3617
3702
|
|
|
3703
|
+
const withMindHotkey = (board) => {
|
|
3704
|
+
const { keydown } = board;
|
|
3705
|
+
board.keydown = (keyboardEvent) => {
|
|
3706
|
+
if (!PlaitBoard.getMovingPoint(board)) {
|
|
3707
|
+
return;
|
|
3708
|
+
}
|
|
3709
|
+
if (isExpandHotkey(keyboardEvent)) {
|
|
3710
|
+
const selectedMindElements = getSelectedElements(board).filter(element => MindElement.isMindElement(board, element));
|
|
3711
|
+
if (selectedMindElements.length === 1 &&
|
|
3712
|
+
!PlaitMind.isMind(selectedMindElements[0]) &&
|
|
3713
|
+
selectedMindElements[0].children &&
|
|
3714
|
+
selectedMindElements[0].children.length > 0) {
|
|
3715
|
+
const element = selectedMindElements[0];
|
|
3716
|
+
Transforms.setNode(board, { isCollapsed: element.isCollapsed ? false : true }, PlaitBoard.findPath(board, element));
|
|
3717
|
+
return;
|
|
3718
|
+
}
|
|
3719
|
+
}
|
|
3720
|
+
keydown(keyboardEvent);
|
|
3721
|
+
};
|
|
3722
|
+
return board;
|
|
3723
|
+
};
|
|
3724
|
+
const isExpandHotkey = (keyboardEvent) => {
|
|
3725
|
+
return isKeyHotkey('mod+/', keyboardEvent);
|
|
3726
|
+
};
|
|
3727
|
+
|
|
3618
3728
|
const withMind = (board) => {
|
|
3619
3729
|
const { drawElement, dblclick, keydown, insertFragment, setFragment, deleteFragment, isHitSelection, getRectangle, isMovable, isRecursion } = board;
|
|
3620
3730
|
board.drawElement = (context) => {
|
|
@@ -3626,6 +3736,20 @@ const withMind = (board) => {
|
|
|
3626
3736
|
}
|
|
3627
3737
|
return drawElement(context);
|
|
3628
3738
|
};
|
|
3739
|
+
board.applyTheme = (element) => {
|
|
3740
|
+
const mindElement = element;
|
|
3741
|
+
const shouldClearProperty = !PlaitBoard.isBoard(element) && ((mindElement === null || mindElement === void 0 ? void 0 : mindElement.branchColor) || (mindElement === null || mindElement === void 0 ? void 0 : mindElement.fill) || (mindElement === null || mindElement === void 0 ? void 0 : mindElement.strokeColor));
|
|
3742
|
+
const isAbstract = AbstractNode.isAbstract(element);
|
|
3743
|
+
if (shouldClearProperty) {
|
|
3744
|
+
const path = PlaitBoard.findPath(board, element);
|
|
3745
|
+
if (isAbstract) {
|
|
3746
|
+
Transforms.setNode(board, { fill: null, strokeColor: DefaultAbstractNodeStyle.strokeColor, branchColor: DefaultAbstractNodeStyle.branchColor }, path);
|
|
3747
|
+
}
|
|
3748
|
+
else {
|
|
3749
|
+
Transforms.setNode(board, { fill: null, strokeColor: null, branchColor: null }, path);
|
|
3750
|
+
}
|
|
3751
|
+
}
|
|
3752
|
+
};
|
|
3629
3753
|
board.getRectangle = element => {
|
|
3630
3754
|
if (MindElement.isMindElement(board, element)) {
|
|
3631
3755
|
return getRectangleByNode(MindElement.getNode(element));
|
|
@@ -3803,7 +3927,7 @@ const withMind = (board) => {
|
|
|
3803
3927
|
MindTransforms.removeElements(board, selectedElements);
|
|
3804
3928
|
deleteFragment(data);
|
|
3805
3929
|
};
|
|
3806
|
-
return withMindExtend(withCreateMind(withAbstract(withDnd(board))));
|
|
3930
|
+
return withMindHotkey(withMindExtend(withCreateMind(withAbstract(withDnd(board)))));
|
|
3807
3931
|
};
|
|
3808
3932
|
|
|
3809
3933
|
class MindEmojiBaseComponent {
|
|
@@ -3857,5 +3981,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
|
|
|
3857
3981
|
* Generated bundle index. Do not edit.
|
|
3858
3982
|
*/
|
|
3859
3983
|
|
|
3860
|
-
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE,
|
|
3984
|
+
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 };
|
|
3861
3985
|
//# sourceMappingURL=plait-mind.mjs.map
|