@meta2d/core 1.0.68 → 1.0.69
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/package.json +1 -1
- package/src/canvas/canvas.d.ts +1 -0
- package/src/canvas/canvas.js +34 -10
- package/src/canvas/canvas.js.map +1 -1
- package/src/canvas/canvasImage.js +1 -1
- package/src/canvas/canvasImage.js.map +1 -1
- package/src/canvas/canvasTemplate.js +2 -1
- package/src/canvas/canvasTemplate.js.map +1 -1
- package/src/core.js +20 -14
- package/src/core.js.map +1 -1
- package/src/pen/render.d.ts +1 -1
- package/src/pen/render.js +33 -35
- package/src/pen/render.js.map +1 -1
- package/src/store/store.d.ts +1 -0
- package/src/store/store.js +1 -1
- package/src/store/store.js.map +1 -1
- package/src/theme.js +2 -0
- package/src/theme.js.map +1 -1
- package/src/utils/url.d.ts +6 -0
- package/src/utils/url.js +21 -5
- package/src/utils/url.js.map +1 -1
package/package.json
CHANGED
package/src/canvas/canvas.d.ts
CHANGED
package/src/canvas/canvas.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { KeydownType } from '../options';
|
|
2
|
-
import { addLineAnchor, calcIconRect, calcTextRect, calcWorldAnchors, calcWorldRects, LockState, nearestAnchor, PenType, pushPenAnchor, removePenAnchor, renderPen, scalePen, translateLine, deleteTempAnchor, connectLine, disconnectLine, getAnchor, calcAnchorDock, calcMoveDock, calcTextLines, setNodeAnimate, setLineAnimate, calcPenRect, setChildrenActive, getParent, setHover, randomId, getPensLock, getToAnchor, getFromAnchor, calcPadding, getPensDisableRotate, getPensDisableResize, needCalcTextRectProps, calcResizeDock, needPatchFlagsPenRectProps, needCalcIconRectProps, isDomShapes, renderPenRaw, needSetPenProps, getAllChildren, calcInView, isShowChild, getTextColor,
|
|
2
|
+
import { addLineAnchor, calcIconRect, calcTextRect, calcWorldAnchors, calcWorldRects, LockState, nearestAnchor, PenType, pushPenAnchor, removePenAnchor, renderPen, scalePen, translateLine, deleteTempAnchor, connectLine, disconnectLine, getAnchor, calcAnchorDock, calcMoveDock, calcTextLines, setNodeAnimate, setLineAnimate, calcPenRect, setChildrenActive, getParent, setHover, randomId, getPensLock, getToAnchor, getFromAnchor, calcPadding, getPensDisableRotate, getPensDisableResize, needCalcTextRectProps, calcResizeDock, needPatchFlagsPenRectProps, needCalcIconRectProps, isDomShapes, renderPenRaw, needSetPenProps, getAllChildren, calcInView, isShowChild, getTextColor, clearLifeCycle, rotatePen, calcTextAutoWidth, getGradientAnimatePath, CanvasLayer, ctxFlip, ctxRotate, setGlobalAlpha, drawImage, setElemPosition, getAllFollowers, calcChildrenInitRect, } from '../pen';
|
|
3
3
|
import { calcRotate, distance, getDistance, hitPoint, PointType, PrevNextType, rotatePoint, samePoint, scalePoint, translatePoint, TwoWay, } from '../point';
|
|
4
4
|
import { calcCenter, calcRightBottom, calcRelativePoint, getRect, getRectOfPoints, pointInRect, pointInSimpleRect, rectInRect, rectToPoints, resizeRect, translateRect, pointInPolygon } from '../rect';
|
|
5
5
|
import { EditType, globalStore, } from '../store';
|
|
@@ -19,6 +19,7 @@ import { Title } from '../title';
|
|
|
19
19
|
import { CanvasTemplate } from './canvasTemplate';
|
|
20
20
|
import { getLinePoints } from '../diagrams/line';
|
|
21
21
|
import { Popconfirm } from '../popconfirm';
|
|
22
|
+
import { themeKeys } from '../theme';
|
|
22
23
|
export const movingSuffix = '-moving';
|
|
23
24
|
export class Canvas {
|
|
24
25
|
parent;
|
|
@@ -4027,6 +4028,27 @@ export class Canvas {
|
|
|
4027
4028
|
pen.calculative.gradientTimer = undefined;
|
|
4028
4029
|
}, 50);
|
|
4029
4030
|
}
|
|
4031
|
+
initGlobalStyle() {
|
|
4032
|
+
const options = {};
|
|
4033
|
+
const data = {};
|
|
4034
|
+
const theme = {};
|
|
4035
|
+
themeKeys.forEach(key => {
|
|
4036
|
+
if (this.store.options[key] !== undefined) {
|
|
4037
|
+
options[key] = this.store.options[key];
|
|
4038
|
+
}
|
|
4039
|
+
if (this.store.data[key] !== undefined) {
|
|
4040
|
+
data[key] = this.store.data[key];
|
|
4041
|
+
}
|
|
4042
|
+
if (this.store.data.theme) {
|
|
4043
|
+
const value = this.store.theme[this.store.data.theme]?.[key];
|
|
4044
|
+
if (value !== undefined) {
|
|
4045
|
+
theme[key] = value;
|
|
4046
|
+
}
|
|
4047
|
+
}
|
|
4048
|
+
});
|
|
4049
|
+
this.store.globalStyle = {};
|
|
4050
|
+
Object.assign(this.store.globalStyle, options, data, theme);
|
|
4051
|
+
}
|
|
4030
4052
|
render = (patchFlags) => {
|
|
4031
4053
|
if (patchFlags) {
|
|
4032
4054
|
this.opening = false;
|
|
@@ -4078,7 +4100,7 @@ export class Canvas {
|
|
|
4078
4100
|
};
|
|
4079
4101
|
renderPens = () => {
|
|
4080
4102
|
const ctx = this.offscreen.getContext('2d');
|
|
4081
|
-
ctx.strokeStyle = getGlobalColor(this.store);
|
|
4103
|
+
ctx.strokeStyle = this.store.globalStyle.color; //getGlobalColor(this.store);
|
|
4082
4104
|
for (const pen of this.store.data.pens) {
|
|
4083
4105
|
if (!isFinite(pen.x)) {
|
|
4084
4106
|
continue;
|
|
@@ -4145,7 +4167,7 @@ export class Canvas {
|
|
|
4145
4167
|
ctx.rotate((this.activeRect.rotate * Math.PI) / 180);
|
|
4146
4168
|
ctx.translate(-pivot.x, -pivot.y);
|
|
4147
4169
|
}
|
|
4148
|
-
ctx.strokeStyle = this.store.
|
|
4170
|
+
ctx.strokeStyle = this.store.globalStyle.activeColor;
|
|
4149
4171
|
ctx.globalAlpha = this.store.options.activeGlobalAlpha === undefined ? 0.3 : this.store.options.activeGlobalAlpha;
|
|
4150
4172
|
ctx.beginPath();
|
|
4151
4173
|
ctx.lineWidth = this.store.options.activeLineWidth || 1;
|
|
@@ -4167,7 +4189,7 @@ export class Canvas {
|
|
|
4167
4189
|
ctx.stroke();
|
|
4168
4190
|
// Draw rotate control points.
|
|
4169
4191
|
ctx.beginPath();
|
|
4170
|
-
ctx.strokeStyle = this.store.
|
|
4192
|
+
ctx.strokeStyle = this.store.globalStyle.activeColor;
|
|
4171
4193
|
ctx.fillStyle = '#ffffff';
|
|
4172
4194
|
ctx.arc(this.activeRect.center.x, this.activeRect.y - 30, 5, 0, Math.PI * 2);
|
|
4173
4195
|
ctx.fill();
|
|
@@ -4195,7 +4217,7 @@ export class Canvas {
|
|
|
4195
4217
|
}
|
|
4196
4218
|
if (anchors) {
|
|
4197
4219
|
ctx.strokeStyle =
|
|
4198
|
-
this.store.hover.anchorColor || this.store.
|
|
4220
|
+
this.store.hover.anchorColor || this.store.globalStyle.anchorColor;
|
|
4199
4221
|
ctx.fillStyle =
|
|
4200
4222
|
this.store.hover.anchorBackground ||
|
|
4201
4223
|
this.store.options.anchorBackground;
|
|
@@ -4251,7 +4273,7 @@ export class Canvas {
|
|
|
4251
4273
|
if (this.store.hover.type && this.store.hoverAnchor === anchor) {
|
|
4252
4274
|
ctx.save();
|
|
4253
4275
|
ctx.strokeStyle =
|
|
4254
|
-
this.store.hover.activeColor || this.store.
|
|
4276
|
+
this.store.hover.activeColor || this.store.globalStyle.activeColor;
|
|
4255
4277
|
ctx.fillStyle = ctx.strokeStyle;
|
|
4256
4278
|
}
|
|
4257
4279
|
else if (anchor.color || anchor.background) {
|
|
@@ -4299,7 +4321,7 @@ export class Canvas {
|
|
|
4299
4321
|
if (!getPensLock(this.store.active) &&
|
|
4300
4322
|
!getPensDisableResize(this.store.active) &&
|
|
4301
4323
|
!this.store.options.disableSize) {
|
|
4302
|
-
ctx.strokeStyle = this.store.
|
|
4324
|
+
ctx.strokeStyle = this.store.globalStyle.activeColor;
|
|
4303
4325
|
ctx.fillStyle = '#ffffff';
|
|
4304
4326
|
this.sizeCPs.forEach((pt, i) => {
|
|
4305
4327
|
if (this.activeRect.rotate) {
|
|
@@ -5796,7 +5818,7 @@ export class Canvas {
|
|
|
5796
5818
|
offset && (this.store.clipboard.offset = offset);
|
|
5797
5819
|
pos && (this.store.clipboard.pos = pos);
|
|
5798
5820
|
}
|
|
5799
|
-
if (!this.keyOptions
|
|
5821
|
+
if (!this.keyOptions?.F) {
|
|
5800
5822
|
this.store.clipboard.pens.forEach((pen) => {
|
|
5801
5823
|
delete pen.copyIndex;
|
|
5802
5824
|
});
|
|
@@ -7074,7 +7096,8 @@ export class Canvas {
|
|
|
7074
7096
|
// }
|
|
7075
7097
|
ctx.textBaseline = 'middle'; // 默认垂直居中
|
|
7076
7098
|
ctx.scale(scale, scale);
|
|
7077
|
-
const background = this.store.
|
|
7099
|
+
const background = this.store.globalStyle.background;
|
|
7100
|
+
// this.store.data.background || this.store.options.background;
|
|
7078
7101
|
if (background && isV) {
|
|
7079
7102
|
// 绘制背景颜色
|
|
7080
7103
|
ctx.save();
|
|
@@ -7183,7 +7206,8 @@ export class Canvas {
|
|
|
7183
7206
|
const ctx = canvas.getContext('2d');
|
|
7184
7207
|
ctx.textBaseline = 'middle'; // 默认垂直居中
|
|
7185
7208
|
ctx.scale(scale, scale);
|
|
7186
|
-
const background = this.store.
|
|
7209
|
+
const background = this.store.globalStyle.background;
|
|
7210
|
+
// this.store.data.background || this.store.options.background;
|
|
7187
7211
|
if (background) {
|
|
7188
7212
|
// 绘制背景颜色
|
|
7189
7213
|
ctx.save();
|