jellies-draw 0.3.3 → 0.3.5

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jellies-draw",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "A drawer for jellies",
5
5
  "private": false,
6
6
  "main": "./src/index.js",
package/src/App.vue CHANGED
@@ -8,11 +8,6 @@
8
8
  <div class="demo-entry">
9
9
  <input type="checkbox" v-model="isCanvasEnabled"/> Enable Canvas
10
10
  </div>
11
- <div class="penetration-test">
12
- <p>底下可选中的文字:The quick brown fox jumps over the lazy dog. 在 laser 模式下拖一下,应该不选中。</p>
13
- <button @click="testClickCount++" id="test-button">点我(穿透 click 计数:{{ testClickCount }})</button>
14
- <p>当前选中字符数:{{ selectionLength }}</p>
15
- </div>
16
11
  <drawing-canvas
17
12
  ref="drawingCanvas"
18
13
  v-if="isCanvasCreated"
@@ -34,16 +29,8 @@ export default {
34
29
  },
35
30
  data: () => ({
36
31
  isCanvasCreated: false,
37
- isCanvasVisible: false,
38
- testClickCount: 0,
39
- selectionLength: 0
32
+ isCanvasVisible: false
40
33
  }),
41
- mounted() {
42
- document.addEventListener('selectionchange', () => {
43
- const sel = window.getSelection()
44
- this.selectionLength = sel ? sel.toString().length : 0
45
- })
46
- },
47
34
  computed: {
48
35
  isCanvasEnabled: {
49
36
  get() {
@@ -103,18 +90,4 @@ body {
103
90
  right: 0;
104
91
  z-index: 2;
105
92
  }
106
- .penetration-test {
107
- position: absolute;
108
- top: 60px;
109
- left: 20px;
110
- z-index: 1;
111
- text-align: left;
112
- font-size: 18px;
113
- line-height: 1.7;
114
- max-width: 600px;
115
- }
116
- .penetration-test button {
117
- font-size: 16px;
118
- padding: 8px 16px;
119
- }
120
93
  </style>
@@ -110,10 +110,7 @@ export default {
110
110
  }
111
111
  },
112
112
  _handleKeydown(event) {
113
- if (!this.hasShortCuts) {
114
- return
115
- }
116
- if (Properties.isCanvasPenetrable && !event.shiftKey) {
113
+ if (!this.hasShortCuts || Properties.isCanvasPenetrable) {
117
114
  return
118
115
  }
119
116
  if (event.key === 'Escape') {
@@ -125,7 +122,7 @@ export default {
125
122
  this._handleNodesShortCuts(event);
126
123
  }
127
124
  } else if (event.shiftKey) {
128
- if (!this.isEditingText) {
125
+ if (!this.isEditingText && Properties.isUsingDrawingTool) {
129
126
  this._handlePropertiesShortCuts(event);
130
127
  }
131
128
  } else if (event.altKey) {
@@ -121,6 +121,10 @@ export default {
121
121
  this.startY = pt.y;
122
122
  this.lastX = pt.x;
123
123
  this.lastY = pt.y;
124
+ this._downClientX = e.clientX;
125
+ this._downClientY = e.clientY;
126
+ e.stopPropagation();
127
+ e.preventDefault();
124
128
  },
125
129
 
126
130
  _handleMouseMove(e) {
@@ -134,7 +138,11 @@ export default {
134
138
  if (!this.hasDragged) {
135
139
  const dx = pt.x - this.startX;
136
140
  const dy = pt.y - this.startY;
137
- if (dx * dx + dy * dy < DRAG_THRESHOLD * DRAG_THRESHOLD) return;
141
+ if (dx * dx + dy * dy < DRAG_THRESHOLD * DRAG_THRESHOLD) {
142
+ e.stopPropagation();
143
+ e.preventDefault();
144
+ return;
145
+ }
138
146
  this.hasDragged = true;
139
147
  this.segments.push({
140
148
  x1: this.startX, y1: this.startY,
@@ -155,12 +163,20 @@ export default {
155
163
  },
156
164
 
157
165
  _handleMouseUp(e) {
158
- if (this.hasDragged) {
159
- e.stopPropagation();
160
- e.preventDefault();
161
- }
166
+ if (!this.isPressed) return;
167
+ const wasClick = !this.hasDragged && e.type === 'pointerup';
168
+ const downX = this._downClientX;
169
+ const downY = this._downClientY;
162
170
  this.isPressed = false;
163
171
  this.hasDragged = false;
172
+ e.stopPropagation();
173
+ e.preventDefault();
174
+ if (wasClick) {
175
+ const target = document.elementFromPoint(downX, downY);
176
+ if (target && typeof target.click === 'function') {
177
+ target.click();
178
+ }
179
+ }
164
180
  },
165
181
 
166
182
  _handleSelectStart(e) {