@tmagic/stage 1.2.0-beta.2 → 1.2.0-beta.20
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/README.md +62 -1
- package/dist/tmagic-stage.mjs +1437 -995
- package/dist/tmagic-stage.mjs.map +1 -1
- package/dist/tmagic-stage.umd.js +1435 -992
- package/dist/tmagic-stage.umd.js.map +1 -1
- package/package.json +4 -4
- package/src/ActionManager.ts +534 -0
- package/src/DragResizeHelper.ts +338 -0
- package/src/MoveableOptionsManager.ts +249 -0
- package/src/MoveableSelectParentAble.ts +76 -0
- package/src/Rule.ts +13 -9
- package/src/StageCore.ts +220 -260
- package/src/StageDragResize.ts +83 -339
- package/src/StageHighlight.ts +17 -16
- package/src/StageMask.ts +88 -140
- package/src/StageMultiDragResize.ts +97 -198
- package/src/StageRender.ts +90 -15
- package/src/TargetShadow.ts +120 -0
- package/src/const.ts +1 -1
- package/src/types.ts +97 -19
- package/src/util.ts +24 -11
- package/types/ActionManager.d.ts +141 -0
- package/types/DragResizeHelper.d.ts +70 -0
- package/types/MoveableOptionsManager.d.ts +86 -0
- package/types/MoveableSelectParentAble.d.ts +8 -0
- package/types/Rule.d.ts +4 -3
- package/types/StageCore.d.ts +65 -39
- package/types/StageDragResize.d.ts +11 -40
- package/types/StageHighlight.d.ts +3 -4
- package/types/StageMask.d.ts +23 -22
- package/types/StageMultiDragResize.d.ts +8 -24
- package/types/StageRender.d.ts +24 -6
- package/types/TargetShadow.d.ts +22 -0
- package/types/const.d.ts +1 -1
- package/types/types.d.ts +85 -18
- package/types/util.d.ts +9 -8
- package/src/TargetCalibrate.ts +0 -119
- package/types/TargetCalibrate.d.ts +0 -20
package/src/TargetCalibrate.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Tencent is pleased to support the open source community by making TMagicEditor available.
|
|
3
|
-
*
|
|
4
|
-
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this file except in compliance with the License.
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import { EventEmitter } from 'events';
|
|
20
|
-
|
|
21
|
-
import { Mode, ZIndex } from './const';
|
|
22
|
-
import StageCore from './StageCore';
|
|
23
|
-
import StageDragResize from './StageDragResize';
|
|
24
|
-
import StageMask from './StageMask';
|
|
25
|
-
import type { Offset, TargetCalibrateConfig } from './types';
|
|
26
|
-
import { getMode } from './util';
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* 将选中的节点修正定位后,添加一个操作节点到蒙层上
|
|
30
|
-
*/
|
|
31
|
-
export default class TargetCalibrate extends EventEmitter {
|
|
32
|
-
public parent: HTMLElement;
|
|
33
|
-
public mask: StageMask;
|
|
34
|
-
public dr: StageDragResize;
|
|
35
|
-
public core: StageCore;
|
|
36
|
-
public operationEl: HTMLDivElement;
|
|
37
|
-
|
|
38
|
-
constructor(config: TargetCalibrateConfig) {
|
|
39
|
-
super();
|
|
40
|
-
|
|
41
|
-
this.parent = config.parent;
|
|
42
|
-
this.mask = config.mask;
|
|
43
|
-
this.dr = config.dr;
|
|
44
|
-
this.core = config.core;
|
|
45
|
-
|
|
46
|
-
this.operationEl = globalThis.document.createElement('div');
|
|
47
|
-
this.parent.append(this.operationEl);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public update(el: HTMLElement, prefix: String): HTMLElement {
|
|
51
|
-
const { left, top } = this.getOffset(el);
|
|
52
|
-
const { transform } = getComputedStyle(el);
|
|
53
|
-
this.operationEl.style.cssText = `
|
|
54
|
-
position: absolute;
|
|
55
|
-
transform: ${transform};
|
|
56
|
-
left: ${left}px;
|
|
57
|
-
top: ${top}px;
|
|
58
|
-
width: ${el.clientWidth}px;
|
|
59
|
-
height: ${el.clientHeight}px;
|
|
60
|
-
z-index: ${ZIndex.HIGHLIGHT_EL};
|
|
61
|
-
`;
|
|
62
|
-
|
|
63
|
-
this.operationEl.id = `${prefix}${el.id}`;
|
|
64
|
-
|
|
65
|
-
if (typeof this.core.config.updateDragEl === 'function') {
|
|
66
|
-
this.core.config.updateDragEl(this.operationEl, el);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return this.operationEl;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
public destroy(): void {
|
|
73
|
-
this.operationEl?.remove();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
private getOffset(el: HTMLElement): Offset {
|
|
77
|
-
const { offsetParent } = el;
|
|
78
|
-
|
|
79
|
-
const left = el.offsetLeft;
|
|
80
|
-
const top = el.offsetTop;
|
|
81
|
-
|
|
82
|
-
if (offsetParent) {
|
|
83
|
-
const parentOffset = this.getOffset(offsetParent as HTMLElement);
|
|
84
|
-
return {
|
|
85
|
-
left: left + parentOffset.left,
|
|
86
|
-
top: top + parentOffset.top,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// 选中固定定位元素后editor-mask高度被置为视窗大小
|
|
91
|
-
if (this.dr.mode === Mode.FIXED) {
|
|
92
|
-
// 弹窗的情况
|
|
93
|
-
if (getMode(el) === Mode.FIXED) {
|
|
94
|
-
return {
|
|
95
|
-
left,
|
|
96
|
-
top,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return {
|
|
101
|
-
left: left - this.mask.scrollLeft,
|
|
102
|
-
top: top - this.mask.scrollTop,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// 无父元素的固定定位需按滚动值计算
|
|
107
|
-
if (getMode(el) === Mode.FIXED) {
|
|
108
|
-
return {
|
|
109
|
-
left: left + this.mask.scrollLeft,
|
|
110
|
-
top: top + this.mask.scrollTop,
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return {
|
|
115
|
-
left,
|
|
116
|
-
top,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
3
|
-
import StageCore from './StageCore';
|
|
4
|
-
import StageDragResize from './StageDragResize';
|
|
5
|
-
import StageMask from './StageMask';
|
|
6
|
-
import type { TargetCalibrateConfig } from './types';
|
|
7
|
-
/**
|
|
8
|
-
* 将选中的节点修正定位后,添加一个操作节点到蒙层上
|
|
9
|
-
*/
|
|
10
|
-
export default class TargetCalibrate extends EventEmitter {
|
|
11
|
-
parent: HTMLElement;
|
|
12
|
-
mask: StageMask;
|
|
13
|
-
dr: StageDragResize;
|
|
14
|
-
core: StageCore;
|
|
15
|
-
operationEl: HTMLDivElement;
|
|
16
|
-
constructor(config: TargetCalibrateConfig);
|
|
17
|
-
update(el: HTMLElement, prefix: String): HTMLElement;
|
|
18
|
-
destroy(): void;
|
|
19
|
-
private getOffset;
|
|
20
|
-
}
|