@tmagic/stage 1.3.0-alpha.15 → 1.3.0-alpha.16
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/dist/tmagic-stage.js +40 -55
- package/dist/tmagic-stage.js.map +1 -1
- package/dist/tmagic-stage.umd.cjs +40 -55
- package/dist/tmagic-stage.umd.cjs.map +1 -1
- package/package.json +7 -7
- package/src/MoveableActionsAble.ts +36 -54
- package/src/MoveableOptionsManager.ts +2 -1
- package/src/moveable-able.css +108 -0
- package/types/MoveableActionsAble.d.ts +2 -4
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.3.0-alpha.
|
|
2
|
+
"version": "1.3.0-alpha.16",
|
|
3
3
|
"name": "@tmagic/stage",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"url": "https://github.com/Tencent/tmagic-editor.git"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@scena/guides": "^0.
|
|
33
|
-
"@tmagic/core": "1.3.0-alpha.
|
|
34
|
-
"@tmagic/schema": "1.3.0-alpha.
|
|
35
|
-
"@tmagic/utils": "1.3.0-alpha.
|
|
32
|
+
"@scena/guides": "^0.29.1",
|
|
33
|
+
"@tmagic/core": "1.3.0-alpha.16",
|
|
34
|
+
"@tmagic/schema": "1.3.0-alpha.16",
|
|
35
|
+
"@tmagic/utils": "1.3.0-alpha.16",
|
|
36
36
|
"events": "^3.3.0",
|
|
37
|
-
"keycon": "^1.
|
|
37
|
+
"keycon": "^1.4.0",
|
|
38
38
|
"lodash-es": "^4.17.21",
|
|
39
|
-
"moveable": "^0.
|
|
39
|
+
"moveable": "^0.51.1",
|
|
40
40
|
"moveable-helper": "^0.4.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { MoveableManagerInterface, Renderer } from 'moveable';
|
|
2
2
|
|
|
3
|
+
import ableCss from './moveable-able.css?raw';
|
|
3
4
|
import { AbleActionEventType } from './types';
|
|
4
5
|
|
|
5
6
|
export default (handler: (type: AbleActionEventType) => void) => ({
|
|
6
7
|
name: 'actions',
|
|
7
|
-
props:
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
-
events: {},
|
|
8
|
+
props: [],
|
|
9
|
+
events: [],
|
|
11
10
|
render(moveable: MoveableManagerInterface<any, any>, React: Renderer) {
|
|
12
11
|
const rect = moveable.getRect();
|
|
13
12
|
const { pos2 } = moveable.state;
|
|
@@ -24,34 +23,7 @@ export default (handler: (type: AbleActionEventType) => void) => ({
|
|
|
24
23
|
transform-origin: 0px 0px;
|
|
25
24
|
display: flex;
|
|
26
25
|
}
|
|
27
|
-
|
|
28
|
-
width: 20px;
|
|
29
|
-
height: 20px;
|
|
30
|
-
background: #4af;
|
|
31
|
-
border-radius: 4px;
|
|
32
|
-
appearance: none;
|
|
33
|
-
border: 0;
|
|
34
|
-
color: white;
|
|
35
|
-
font-size: 12px;
|
|
36
|
-
font-weight: bold;
|
|
37
|
-
margin-left: 2px;
|
|
38
|
-
position: relative;
|
|
39
|
-
}
|
|
40
|
-
.moveable-remove-button:before, .moveable-remove-button:after {
|
|
41
|
-
content: "";
|
|
42
|
-
position: absolute;
|
|
43
|
-
left: 50%;
|
|
44
|
-
top: 50%;
|
|
45
|
-
transform: translate(-50%, -50%) rotate(45deg);
|
|
46
|
-
width: 14px;
|
|
47
|
-
height: 2px;
|
|
48
|
-
background: #fff;
|
|
49
|
-
border-radius: 1px;
|
|
50
|
-
cursor: pointer;
|
|
51
|
-
}
|
|
52
|
-
.moveable-remove-button:after {
|
|
53
|
-
transform: translate(-50%, -50%) rotate(-45deg);
|
|
54
|
-
}
|
|
26
|
+
${ableCss}
|
|
55
27
|
`,
|
|
56
28
|
);
|
|
57
29
|
// Add key (required)
|
|
@@ -61,7 +33,7 @@ export default (handler: (type: AbleActionEventType) => void) => ({
|
|
|
61
33
|
{
|
|
62
34
|
className: 'moveable-editable',
|
|
63
35
|
style: {
|
|
64
|
-
transform: `translate(${pos2[0] -
|
|
36
|
+
transform: `translate(${pos2[0] - 60}px, ${pos2[1] - 28}px) rotate(${rect.rotation}deg)`,
|
|
65
37
|
},
|
|
66
38
|
},
|
|
67
39
|
[
|
|
@@ -74,27 +46,12 @@ export default (handler: (type: AbleActionEventType) => void) => ({
|
|
|
74
46
|
handler(AbleActionEventType.SELECT_PARENT);
|
|
75
47
|
},
|
|
76
48
|
},
|
|
77
|
-
React.createElement(
|
|
78
|
-
'
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
fill: 'none',
|
|
84
|
-
xmlns: 'http://www.w3.org/2000/svg',
|
|
85
|
-
style: {
|
|
86
|
-
transform: 'rotate(90deg)',
|
|
87
|
-
position: 'absolute',
|
|
88
|
-
left: 0,
|
|
89
|
-
top: 0,
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
React.createElement('path', {
|
|
93
|
-
d: 'M13.0001 4V10H4.20718L5.85363 8.35355L5.14652 7.64645L2.64652 10.1464C2.45126 10.3417 2.45126 10.6583 2.64652 10.8536L5.14652 13.3536L5.85363 12.6464L4.20718 11H13.0001C13.5524 11 14.0001 10.5523 14.0001 10V4H13.0001Z',
|
|
94
|
-
fill: 'currentColor',
|
|
95
|
-
fillOpacity: '0.9',
|
|
96
|
-
}),
|
|
97
|
-
),
|
|
49
|
+
React.createElement('div', {
|
|
50
|
+
className: 'moveable-select-parent-arrow-top-icon',
|
|
51
|
+
}),
|
|
52
|
+
React.createElement('div', {
|
|
53
|
+
className: 'moveable-select-parent-arrow-body-icon',
|
|
54
|
+
}),
|
|
98
55
|
),
|
|
99
56
|
React.createElement('button', {
|
|
100
57
|
className: 'moveable-button moveable-remove-button',
|
|
@@ -103,6 +60,31 @@ export default (handler: (type: AbleActionEventType) => void) => ({
|
|
|
103
60
|
handler(AbleActionEventType.REMOVE);
|
|
104
61
|
},
|
|
105
62
|
}),
|
|
63
|
+
React.createElement(
|
|
64
|
+
'button',
|
|
65
|
+
{
|
|
66
|
+
className: 'moveable-button moveable-drag-area-button',
|
|
67
|
+
title: '拖动',
|
|
68
|
+
},
|
|
69
|
+
React.createElement('div', {
|
|
70
|
+
className: 'moveable-select-parent-arrow-top-icon moveable-select-parent-arrow-top-icon-top',
|
|
71
|
+
}),
|
|
72
|
+
React.createElement('div', {
|
|
73
|
+
className: 'moveable-select-parent-arrow-top-icon moveable-select-parent-arrow-top-icon-bottom',
|
|
74
|
+
}),
|
|
75
|
+
React.createElement('div', {
|
|
76
|
+
className: 'moveable-select-parent-arrow-top-icon moveable-select-parent-arrow-top-icon-left',
|
|
77
|
+
}),
|
|
78
|
+
React.createElement('div', {
|
|
79
|
+
className: ' moveable-select-parent-arrow-top-icon moveable-select-parent-arrow-top-icon-right',
|
|
80
|
+
}),
|
|
81
|
+
React.createElement('div', {
|
|
82
|
+
className: 'moveable-select-parent-arrow-body-icon-horizontal',
|
|
83
|
+
}),
|
|
84
|
+
React.createElement('div', {
|
|
85
|
+
className: 'moveable-select-parent-arrow-body-icon-vertical',
|
|
86
|
+
}),
|
|
87
|
+
),
|
|
106
88
|
],
|
|
107
89
|
);
|
|
108
90
|
},
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
.moveable-button {
|
|
2
|
+
width: 20px;
|
|
3
|
+
height: 20px;
|
|
4
|
+
background: #4af;
|
|
5
|
+
border-radius: 4px;
|
|
6
|
+
appearance: none;
|
|
7
|
+
border: 0;
|
|
8
|
+
color: white;
|
|
9
|
+
font-size: 12px;
|
|
10
|
+
font-weight: bold;
|
|
11
|
+
margin-left: 2px;
|
|
12
|
+
position: relative;
|
|
13
|
+
}
|
|
14
|
+
.moveable-remove-button:before, .moveable-remove-button:after {
|
|
15
|
+
content: "";
|
|
16
|
+
position: absolute;
|
|
17
|
+
left: 50%;
|
|
18
|
+
top: 50%;
|
|
19
|
+
transform: translate(-50%, -50%) rotate(45deg);
|
|
20
|
+
width: 14px;
|
|
21
|
+
height: 2px;
|
|
22
|
+
background: #fff;
|
|
23
|
+
border-radius: 1px;
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
}
|
|
26
|
+
.moveable-remove-button:after {
|
|
27
|
+
transform: translate(-50%, -50%) rotate(-45deg);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.moveable-select-parent-arrow-top-icon {
|
|
31
|
+
transform: rotateZ(-45deg);
|
|
32
|
+
width: 4px;
|
|
33
|
+
height: 4px;
|
|
34
|
+
border-color: #fff;
|
|
35
|
+
border-width: 2px 2px 0 0;
|
|
36
|
+
border-style: solid;
|
|
37
|
+
position: absolute;
|
|
38
|
+
left: 4px;
|
|
39
|
+
top: 4px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.moveable-select-parent-arrow-body-icon {
|
|
43
|
+
width: 7px;
|
|
44
|
+
height: 11px;
|
|
45
|
+
border-color: #fff;
|
|
46
|
+
border-width: 0 0 2px 2px;
|
|
47
|
+
border-style: solid;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.moveable-drag-area-button {
|
|
51
|
+
cursor: move;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.moveable-drag-area-button .moveable-select-parent-arrow-top-icon {
|
|
55
|
+
width: 2px;
|
|
56
|
+
height: 2px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.moveable-drag-area-button .moveable-select-parent-arrow-top-icon-top {
|
|
60
|
+
transform: rotateZ(-45deg) translateX(-50%);
|
|
61
|
+
left: 50%;
|
|
62
|
+
top: 3px;
|
|
63
|
+
transform-origin: left;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.moveable-drag-area-button .moveable-select-parent-arrow-top-icon-bottom {
|
|
67
|
+
transform: rotateZ(135deg) translateX(-50%);
|
|
68
|
+
transform-origin: left;
|
|
69
|
+
left: 50%;
|
|
70
|
+
top: auto;
|
|
71
|
+
bottom: 3px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.moveable-drag-area-button .moveable-select-parent-arrow-top-icon-right {
|
|
75
|
+
transform: rotateZ(45deg) translateY(-50%);
|
|
76
|
+
transform-origin: top;
|
|
77
|
+
right: 3px;
|
|
78
|
+
left: auto;
|
|
79
|
+
top: 50%;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.moveable-drag-area-button .moveable-select-parent-arrow-top-icon-left {
|
|
83
|
+
transform: rotateZ(235deg) translateY(-50%);
|
|
84
|
+
transform-origin: top;
|
|
85
|
+
left: 3px;
|
|
86
|
+
top: 50%;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.moveable-drag-area-button .moveable-select-parent-arrow-body-icon-horizontal {
|
|
90
|
+
width: 2px;
|
|
91
|
+
height: 11px;
|
|
92
|
+
background-color: #fff;
|
|
93
|
+
position: absolute;
|
|
94
|
+
transform: translateX(-50%);
|
|
95
|
+
left: 50%;
|
|
96
|
+
top: 4px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.moveable-drag-area-button .moveable-select-parent-arrow-body-icon-vertical {
|
|
100
|
+
width: 11px;
|
|
101
|
+
height: 2px;
|
|
102
|
+
background-color: #fff;
|
|
103
|
+
position: absolute;
|
|
104
|
+
transform: translateY(-50%);
|
|
105
|
+
left: 4px;
|
|
106
|
+
top: 50%;;
|
|
107
|
+
}
|
|
108
|
+
|
|
@@ -2,10 +2,8 @@ import { MoveableManagerInterface, Renderer } from 'moveable';
|
|
|
2
2
|
import { AbleActionEventType } from './types';
|
|
3
3
|
declare const _default: (handler: (type: AbleActionEventType) => void) => {
|
|
4
4
|
name: string;
|
|
5
|
-
props:
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
events: {};
|
|
5
|
+
props: never[];
|
|
6
|
+
events: never[];
|
|
9
7
|
render(moveable: MoveableManagerInterface<any, any>, React: Renderer): any;
|
|
10
8
|
};
|
|
11
9
|
export default _default;
|