jellies-draw 0.1.9 → 0.1.11
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
CHANGED
|
@@ -78,8 +78,6 @@ export default {
|
|
|
78
78
|
.container {
|
|
79
79
|
width: 100%;
|
|
80
80
|
height: 100%;
|
|
81
|
-
position: relative;
|
|
82
|
-
z-index: 9999; /* 确保画板在最上层 */
|
|
83
81
|
}
|
|
84
82
|
.container-penetrable {
|
|
85
83
|
pointer-events: none;
|
|
@@ -87,4 +85,8 @@ export default {
|
|
|
87
85
|
.cursor-crosshair {
|
|
88
86
|
cursor: crosshair;
|
|
89
87
|
}
|
|
88
|
+
.whiteboard {
|
|
89
|
+
position: relative;
|
|
90
|
+
z-index: 9999; /* 确保画板在最上层 */
|
|
91
|
+
}
|
|
90
92
|
</style>
|
|
@@ -59,23 +59,13 @@
|
|
|
59
59
|
import Properties from './functions/properties';
|
|
60
60
|
export default {
|
|
61
61
|
name: 'PropertiesPicker',
|
|
62
|
-
data() {
|
|
63
|
-
return {
|
|
64
|
-
fontSizeOptions: {
|
|
65
|
-
15: 'S',
|
|
66
|
-
20: 'M',
|
|
67
|
-
35: 'L',
|
|
68
|
-
50: 'XL'
|
|
69
|
-
},
|
|
70
|
-
strokeWidthOptions: {
|
|
71
|
-
3: 'H',
|
|
72
|
-
4: 'HB',
|
|
73
|
-
5: 'B',
|
|
74
|
-
6: '2B'
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
62
|
computed: {
|
|
63
|
+
fontSizeOptions() {
|
|
64
|
+
return Properties.fontSizeOptions
|
|
65
|
+
},
|
|
66
|
+
strokeWidthOptions() {
|
|
67
|
+
return Properties.strokeWidthOptions
|
|
68
|
+
},
|
|
79
69
|
fillColor: {
|
|
80
70
|
get() {
|
|
81
71
|
return Properties.fillColor
|
|
@@ -63,7 +63,7 @@ export default {
|
|
|
63
63
|
window.removeEventListener('resize', this.resizeHandler);
|
|
64
64
|
},
|
|
65
65
|
_handleResize() {
|
|
66
|
-
if (this.stage) {
|
|
66
|
+
if (this.stage && this.container.offsetWidth > 0 && this.container.offsetHeight > 0) {
|
|
67
67
|
this.stage.width(this.container.offsetWidth);
|
|
68
68
|
this.stage.height(this.container.offsetHeight);
|
|
69
69
|
this.stage.batchDraw();
|
|
@@ -79,7 +79,11 @@ export default {
|
|
|
79
79
|
Transformer.removeSelectedNodes();
|
|
80
80
|
} else if (event.ctrlKey || event.metaKey) {
|
|
81
81
|
if (!this.isEditingText) {
|
|
82
|
-
this.
|
|
82
|
+
this._handleNodesShortCuts(event);
|
|
83
|
+
}
|
|
84
|
+
} else if (event.shiftKey) {
|
|
85
|
+
if (!this.isEditingText) {
|
|
86
|
+
this._handlePropertiesShortCuts(event);
|
|
83
87
|
}
|
|
84
88
|
} else if (event.altKey) {
|
|
85
89
|
Properties.isCanvasPenetrable = true;
|
|
@@ -93,11 +97,32 @@ export default {
|
|
|
93
97
|
Properties.latestTool = {
|
|
94
98
|
'tool': 'selector',
|
|
95
99
|
'isToolLocked': false
|
|
96
|
-
}
|
|
100
|
+
};
|
|
97
101
|
}
|
|
98
102
|
}
|
|
99
103
|
},
|
|
100
|
-
|
|
104
|
+
_handlePropertiesShortCuts(event) {
|
|
105
|
+
event.preventDefault();
|
|
106
|
+
const colorsKeyMap = {
|
|
107
|
+
'Digit1': '#f33b29',
|
|
108
|
+
'Digit2': '#4ec53d',
|
|
109
|
+
'Digit3': '#ffb020',
|
|
110
|
+
'Digit4': '#399af4',
|
|
111
|
+
'Digit5': '#ffcaff',
|
|
112
|
+
'Digit6': '#ffde00',
|
|
113
|
+
'Digit7': '#ce82ff',
|
|
114
|
+
'Digit8': '#eeeeee',
|
|
115
|
+
'Digit9': '#333333'
|
|
116
|
+
};
|
|
117
|
+
if (event.code in colorsKeyMap) {
|
|
118
|
+
Properties.strokeColor = colorsKeyMap[event.code];
|
|
119
|
+
} else if (event.code === 'Equal') {
|
|
120
|
+
Properties.scalePropertyUp();
|
|
121
|
+
} else if (event.code === 'Minus') {
|
|
122
|
+
Properties.scalePropertyDown();
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
_handleNodesShortCuts(event) {
|
|
101
126
|
event.preventDefault();
|
|
102
127
|
if (event.key === 'c') {
|
|
103
128
|
Clipboard.copy();
|
|
@@ -109,9 +134,9 @@ export default {
|
|
|
109
134
|
Transformer.selectAllNodes();
|
|
110
135
|
} else if (event.key === 'z' || event.key === 'Z') {
|
|
111
136
|
if (event.shiftKey) {
|
|
112
|
-
Histories.redo()
|
|
137
|
+
Histories.redo();
|
|
113
138
|
} else {
|
|
114
|
-
Histories.undo()
|
|
139
|
+
Histories.undo();
|
|
115
140
|
}
|
|
116
141
|
}
|
|
117
142
|
},
|
|
@@ -121,20 +146,20 @@ export default {
|
|
|
121
146
|
return;
|
|
122
147
|
}
|
|
123
148
|
}
|
|
124
|
-
Tools[Properties.tool].show(event.evt)
|
|
149
|
+
Tools[Properties.tool].show(event.evt);
|
|
125
150
|
},
|
|
126
151
|
handlePointerMove(event) {
|
|
127
152
|
if (Properties.tool !== 'clear') {
|
|
128
|
-
Tools[Properties.tool].change(event.evt)
|
|
153
|
+
Tools[Properties.tool].change(event.evt);
|
|
129
154
|
}
|
|
130
155
|
},
|
|
131
156
|
handlePointerUp(event) {
|
|
132
|
-
Tools[Properties.tool].finish()
|
|
157
|
+
Tools[Properties.tool].finish();
|
|
133
158
|
if (this.isDrawing || this.isEditingText) {
|
|
134
|
-
Histories.record()
|
|
159
|
+
Histories.record();
|
|
135
160
|
}
|
|
136
|
-
this.isDrawing = false
|
|
137
|
-
this.isEditingText = false
|
|
161
|
+
this.isDrawing = false;
|
|
162
|
+
this.isEditingText = false;
|
|
138
163
|
},
|
|
139
164
|
handleClick(event) {
|
|
140
165
|
const metaPressed = event.evt.shiftKey || event.evt.ctrlKey || event.evt.metaKey;
|
|
@@ -6,9 +6,9 @@ export default new Vue({
|
|
|
6
6
|
data() {
|
|
7
7
|
return {
|
|
8
8
|
fillColorPicked: 'transparent',
|
|
9
|
-
strokeColorPicked: '#
|
|
9
|
+
strokeColorPicked: '#f33b29',
|
|
10
10
|
fontSizeSelected: 20,
|
|
11
|
-
strokeWidthSelected:
|
|
11
|
+
strokeWidthSelected: 3,
|
|
12
12
|
toolSelected: 'pen',
|
|
13
13
|
toolLatestSelected: {
|
|
14
14
|
'tool': 'pen',
|
|
@@ -17,7 +17,19 @@ export default new Vue({
|
|
|
17
17
|
isTextNodesSelected: false,
|
|
18
18
|
isMassivelyAssigningProperties: false,
|
|
19
19
|
isToolLocked: false,
|
|
20
|
-
isCanvasPenetrable: false
|
|
20
|
+
isCanvasPenetrable: false,
|
|
21
|
+
fontSizeOptions: {
|
|
22
|
+
15: 'S',
|
|
23
|
+
20: 'M',
|
|
24
|
+
35: 'L',
|
|
25
|
+
50: 'XL'
|
|
26
|
+
},
|
|
27
|
+
strokeWidthOptions: {
|
|
28
|
+
3: 'H',
|
|
29
|
+
4: 'HB',
|
|
30
|
+
5: 'B',
|
|
31
|
+
6: '2B'
|
|
32
|
+
}
|
|
21
33
|
}
|
|
22
34
|
},
|
|
23
35
|
computed: {
|
|
@@ -120,6 +132,29 @@ export default new Vue({
|
|
|
120
132
|
handleClearMoveCursor(){
|
|
121
133
|
Canvas.stage.container().style.cursor = null;
|
|
122
134
|
},
|
|
135
|
+
scaleProperty(direction) {
|
|
136
|
+
if (this.isUsingText) {
|
|
137
|
+
this.fontSize = this.setPropertyToScale(this.fontSize, this.fontSizeOptions, direction);
|
|
138
|
+
} else {
|
|
139
|
+
this.strokeWidth = this.setPropertyToScale(this.strokeWidth, this.strokeWidthOptions, direction);
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
setPropertyToScale(currentValue, options, direction) {
|
|
143
|
+
const optionsKeys = Object.keys(options);
|
|
144
|
+
const currentIndex = optionsKeys.indexOf(currentValue.toString());
|
|
145
|
+
if (direction === 'down' && currentIndex > 0) {
|
|
146
|
+
return parseInt(optionsKeys[currentIndex - 1]);
|
|
147
|
+
} else if (direction === 'up' && currentIndex < optionsKeys.length - 1) {
|
|
148
|
+
return parseInt(optionsKeys[currentIndex + 1]);
|
|
149
|
+
}
|
|
150
|
+
return currentValue;
|
|
151
|
+
},
|
|
152
|
+
scalePropertyUp() {
|
|
153
|
+
this.scaleProperty('up');
|
|
154
|
+
},
|
|
155
|
+
scalePropertyDown() {
|
|
156
|
+
this.scaleProperty('down');
|
|
157
|
+
},
|
|
123
158
|
setProperties(properties) {
|
|
124
159
|
this.isMassivelyAssigningProperties = true;
|
|
125
160
|
Object.keys(properties).forEach(property => {
|