jellies-draw 0.1.6 → 0.1.8

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.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "A drawer for jellies",
5
5
  "private": false,
6
6
  "main": "./src/index.js",
@@ -9,7 +9,7 @@ export default new Vue({
9
9
  strokeColorPicked: '#000000',
10
10
  fontSizeSelected: 20,
11
11
  strokeWidthSelected: 4,
12
- toolSelected: 'selector',
12
+ toolSelected: 'pen',
13
13
  isTextNodesSelected: false,
14
14
  isMassivelyAssigningProperties: false
15
15
  }
@@ -10,7 +10,14 @@ export default {
10
10
  disableTextareaHandler: null,
11
11
  handleTextareaTimer: null,
12
12
  show({ offsetX, offsetY }) {
13
- if (!Canvas.isEditingText) {
13
+ if (Canvas.isEditingText) {
14
+ return
15
+ }
16
+ clearTimeout(this.handleTextareaTimer)
17
+ this.handleTextareaTimer = setTimeout(() => {
18
+ if (Canvas.isEditingText) {
19
+ return
20
+ }
14
21
  const newText = this.generate({
15
22
  text: '',
16
23
  x: offsetX,
@@ -19,13 +26,10 @@ export default {
19
26
  width: 200,
20
27
  fill: Properties.strokeColor
21
28
  })
22
- this.temporalText = newText
23
- Canvas.layer.add(this.temporalText)
24
- clearTimeout(this.handleTextareaTimer)
25
- this.handleTextareaTimer = setTimeout(() => {
26
- this._handleEnableTextarea(newText)
27
- }, 200)
28
- }
29
+ this.temporalText = newText;
30
+ Canvas.layer.add(this.temporalText);
31
+ this._handleEnableTextarea(newText)
32
+ }, 200)
29
33
  },
30
34
  bindEvents(newText) {
31
35
  newText.off('dblclick dbltap')
@@ -123,11 +127,16 @@ export default {
123
127
  },
124
128
  _handleDisableTextarea(event) {
125
129
  if (event.target !== this.textarea) {
126
- this.temporalText.text(this.textarea.value)
127
- this.textarea.remove()
128
- window.removeEventListener('mousedown', this.disableTextareaHandler)
129
- this.temporalText.show()
130
+ if (this.textarea.value) {
131
+ this.temporalText.text(this.textarea.value)
132
+ this.temporalText.show()
133
+ this.textarea.remove()
134
+ } else {
135
+ this.textarea.remove()
136
+ this.temporalText.remove()
137
+ }
130
138
  Properties.tool = 'selector'
139
+ window.removeEventListener('mousedown', this.disableTextareaHandler)
131
140
  }
132
141
  },
133
142
  _handleTextareaEditing() {