zydx-plus 1.32.258 → 1.32.259

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": "zydx-plus",
3
- "version": "1.32.258",
3
+ "version": "1.32.259",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -1,452 +1,510 @@
1
1
  <template>
2
- <div class="sketchpad">
3
- <canvas :id="id"></canvas>
4
- <div class="tool">
5
- <div class="tool-list" @click="set">
6
- <img src="./img/shezi.png" alt="" />
7
- <div v-if="setShow" class="set">
8
- <div class="set-list">
9
- <span>线条粗细</span>
10
- <em v-for="(item,index) in strokeData" @click="strokeTap(item)">{{ item }}</em>
11
- </div>
12
- <div class="set-list">
13
- <span>线条颜色</span>
14
- <i v-for="(item,index) in strokeColor" @click="strokeColTap(item)" :style="{'background-color': item}"></i>
15
- </div>
16
- </div>
17
- </div>
18
- <div class="tool-list" @click="brush">
19
- <img src="./img/huabi.png" alt="" />
20
- </div>
21
- <div class="tool-list" @click="rectangle">
22
- <img src="./img/juxing.png" alt="" />
23
- </div>
24
- <div class="tool-list" @click="addTextBox">
25
- <img src="./img/wenzi.png" alt="" />
26
- <div v-if="textShow" class="set">
27
- <div class="set-list">
28
- <span>字号</span>
29
- <em style="font-size: 13px;" v-for="(item,index) in textData" @click.stop="sizeTap(item)">{{ item }}</em>
30
- </div>
31
- <div class="set-list">
32
- <span>内容</span>
33
- <input type="text" v-model="text" @click.stop="false" />
34
- </div>
35
- <div class="set-list set-right">
36
- <button class="but" @click="textBox">确认</button>
37
- </div>
38
- </div>
39
- </div>
40
- <div class="tool-list" @click="rotundity">
41
- <img src="./img/yuan.png" alt="" />
42
- </div>
43
- <div class="tool-list" @click="addLine">
44
- <img src="./img/jian.png" alt="" />
45
- </div>
46
- <div class="tool-list" @click="arrow">
47
- <img src="./img/jiantou.png" alt="" />
48
- </div>
49
- <div class="tool-list" @click="save">
50
- <img src="./img/baocun.png" alt="" />
51
- </div>
52
- <div class="tool-list" @click="clear">
53
- <img src="./img/xiangpi.png" alt="" />
54
- </div>
2
+ <div class="sketchpad" ref="sketchpad">
3
+ <canvas :id="id"></canvas>
4
+ <div class="tool"
5
+ @mouseup.stop="mouseup"
6
+ @mousedown.stop="mousedown"
7
+ :style="{transform: `translate(${x}px, ${y}px)`}">
8
+ <div class="tool-list" @click.stop="set">
9
+ <img src="./img/shezi.png" alt=""/>
10
+ <div v-if="setShow" class="set">
11
+ <div class="set-list">
12
+ <span>线条粗细</span>
13
+ <em v-for="(item,index) in strokeData" @click="strokeTap(item)">{{ item }}</em>
14
+ </div>
15
+ <div class="set-list">
16
+ <span>线条颜色</span>
17
+ <i v-for="(item,index) in strokeColor" @click="strokeColTap(item)" :style="{'background-color': item}"></i>
18
+ </div>
55
19
  </div>
20
+ </div>
21
+ <div class="tool-list" @click.stop="brush">
22
+ <img src="./img/huabi.png" alt=""/>
23
+ </div>
24
+ <div class="tool-list" @click.stop="rectangle">
25
+ <img src="./img/juxing.png" alt=""/>
26
+ </div>
27
+ <div class="tool-list" @click.stop="addTextBox">
28
+ <img src="./img/wenzi.png" alt=""/>
29
+ <div v-if="textShow" class="set">
30
+ <div class="set-list">
31
+ <span>字号</span>
32
+ <em style="font-size: 13px;" v-for="(item,index) in textData" @click.stop="sizeTap(item)">{{ item }}</em>
33
+ </div>
34
+ <div class="set-list">
35
+ <span>内容</span>
36
+ <input type="text" v-model="text" @click.stop="false"/>
37
+ </div>
38
+ <div class="set-list set-right">
39
+ <button class="but" @click="textBox">确认</button>
40
+ </div>
41
+ </div>
42
+ </div>
43
+ <div class="tool-list" @click.stop="rotundity">
44
+ <img src="./img/yuan.png" alt=""/>
45
+ </div>
46
+ <div class="tool-list" @click.stop="addLine">
47
+ <img src="./img/jian.png" alt=""/>
48
+ </div>
49
+ <div class="tool-list" @click.stop="arrow">
50
+ <img src="./img/jiantou.png" alt=""/>
51
+ </div>
52
+ <div class="tool-list" @click.stop="save">
53
+ <img src="./img/baocun.png" alt=""/>
54
+ </div>
55
+ <div class="tool-list" @click.stop="clear">
56
+ <img src="./img/xiangpi.png" alt=""/>
57
+ </div>
56
58
  </div>
59
+ </div>
57
60
  </template>
58
61
 
59
62
  <script>
60
- import { fabric } from 'fabric'
63
+ import {fabric} from 'fabric'
64
+
61
65
  export default {
62
- name: "zydx-sketchpad",
63
- data() {
64
- return {
65
- canvas: null,
66
- strokeWidth: 2, // 线条粗细
67
- color: '#000', // 线条颜色
68
- line: null, // 线条
69
- isDown: false, // 是否按下
70
- state: null, // 状态
71
- rect: null, // 矩形
72
- circle: null, // 圆形
73
- fontSize: 14, // 字体大小
74
- setShow: false, // 设置
75
- strokeData: ['1','2','3','4','5','6','7'], // 画笔数据
76
- strokeColor: ['#000','#f00','#0f0','#00f','#f0f','#ff0','#0ff'], // 画笔颜色
77
- textShow: false, // 文本
78
- textData: ['14','16','18','20','22','24','28','30'], // 文本数据
79
- text: '',
80
- id: null
81
- }
66
+ name: "zydx-sketchpad",
67
+ data() {
68
+ return {
69
+ canvas: null,
70
+ strokeWidth: 2, // 线条粗细
71
+ color: '#000', // 线条颜色
72
+ line: null, // 线条
73
+ isDown: false, // 是否按下
74
+ state: null, // 状态
75
+ rect: null, // 矩形
76
+ circle: null, // 圆形
77
+ fontSize: 14, // 字体大小
78
+ setShow: false, // 设置
79
+ strokeData: ['1', '2', '3', '4', '5', '6', '7'], // 画笔数据
80
+ strokeColor: ['#000', '#f00', '#0f0', '#00f', '#f0f', '#ff0', '#0ff'], // 画笔颜色
81
+ textShow: false, // 文本
82
+ textData: ['14', '16', '18', '20', '22', '24', '28', '30'], // 文本数据
83
+ text: '',
84
+ id: null,
85
+ left: 0,
86
+ top: 0,
87
+ isMove: false,
88
+ x: -50,
89
+ y: 0,
90
+ offLeft: 0,
91
+ offTop: 0,
92
+ scrollTop: 0
93
+ }
94
+ },
95
+ props: {
96
+ data: {
97
+ type: Object,
98
+ default: () => {
99
+ }
82
100
  },
83
- props: {
84
- data: {
85
- type: Object,
86
- default: () => {}
87
- },
88
- width: {
89
- type: Number,
90
- default: 800
91
- },
92
- height: {
93
- type: Number,
94
- default: 800
95
- }
101
+ width: {
102
+ type: Number,
103
+ default: 800
96
104
  },
97
- emits: ['save'],
98
- watch: {
99
- data: {
100
- handler(val) {
101
- this.canvas.loadFromJSON(val)
102
- },
103
- deep: true
104
- }
105
+ height: {
106
+ type: Number,
107
+ default: 800
108
+ }
109
+ },
110
+ emits: ['save'],
111
+ watch: {
112
+ data: {
113
+ handler(val) {
114
+ this.canvas.loadFromJSON(val)
115
+ },
116
+ deep: true
117
+ }
118
+ },
119
+ mounted() {
120
+ // 生成随机id
121
+ this.id = Math.random().toString(36).substr(2)
122
+ setTimeout(() => {
123
+ this.init()
124
+ }, 0)
125
+ window.addEventListener('keydown', this.handleKeyEvent)
126
+ this.offLeft = this.$refs.sketchpad.offsetLeft
127
+ this.offTop = this.$refs.sketchpad.offsetTop
128
+ // 监听滚动
129
+ this.throttleHandleScroll()
130
+ window.addEventListener('scroll', this.throttleHandleScroll);
131
+ document.addEventListener('mousemove', (event) => {
132
+ if (!this.isMove) return
133
+ this.x = event.clientX - this.left;
134
+ this.y = event.clientY - this.top;
135
+ })
136
+ },
137
+ beforeDestroy() {
138
+ window.removeEventListener('keydown', this.handleKeyEvent)
139
+ },
140
+ methods: {
141
+ throttleHandleScroll() {
142
+ this.scrollTop = document.documentElement.scrollTop || document.body.scrollTop
143
+ },
144
+ mousedown(event) {
145
+ event.preventDefault()
146
+ //鼠标按下事件
147
+ this.left = event.offsetX + this.offLeft
148
+ this.top = event.offsetY + this.offTop - this.scrollTop
149
+ this.isMove = true
150
+ },
151
+ mouseup() {
152
+ //鼠标松开事件
153
+ this.isMove = false
105
154
  },
106
- mounted() {
107
- // 生成随机id
108
- this.id = Math.random().toString(36).substr(2)
109
- setTimeout(() => {
110
- this.init()
111
- },0)
112
- window.addEventListener('keydown', this.handleKeyEvent)
155
+ sizeTap(v) {
156
+ this.fontSize = Number(v)
113
157
  },
114
- beforeDestroy() {
115
- window.removeEventListener('keydown', this.handleKeyEvent)
158
+ addTextBox() {
159
+ this.state = 'text'
160
+ this.setShow = false
161
+ this.textShow = !this.textShow
116
162
  },
117
- methods: {
118
- sizeTap(v) {
119
- this.fontSize = Number(v)
120
- },
121
- addTextBox() {
122
- this.state = 'text'
123
- this.setShow = false
124
- this.textShow = !this.textShow
125
- },
126
- strokeColTap(v) {
127
- this.color = v
128
- },
129
- strokeTap(v) {
130
- this.strokeWidth = Number(v)
131
- },
132
- set() {
133
- this.textShow = false
134
- this.setShow = !this.setShow
135
- },
136
- init() {
137
- this.canvas = new fabric.Canvas(this.id, {
138
- isDrawingMode: false,
139
- width: this.width,
140
- height: this.height,
141
- });
142
- this.canvas.selectionColor = "rgba(255,255,255,0)";
143
- this.canvas.loadFromJSON(this.data)
144
- },
145
- // 画笔
146
- brush() {
147
- this.state = 'brush'
148
- this.canvas.isDrawingMode = !this.canvas.isDrawingMode
149
- this.canvas.freeDrawingBrush.width = this.strokeWidth
150
- this.canvas.freeDrawingBrush.color = this.color
151
- },
152
- // 直线
153
- addLine() {
154
- this.canvas.isDrawingMode = false
155
- this.state = 'line'
156
- const id = Date.now()
157
- this.canvas.on('mouse:down', (o) => {
158
- if(o.target !== null) return
159
- if(this.state !== 'line') return
160
- this.isDown = true
161
- const pointer = this.canvas.getPointer(o.e)
162
- const points = [pointer.x, pointer.y, pointer.x, pointer.y]
163
- this.line = new fabric.Line(points, {
164
- id: id,
165
- strokeWidth: this.strokeWidth,
166
- fill: this.color,
167
- stroke: this.color,
168
- originX: 'center',
169
- originY: 'center'
170
- })
171
- this.canvas.add(this.line)
172
- })
173
- this.canvas.on('mouse:move', (o) => {
174
- if(this.state !== 'line') return
175
- if (!this.isDown) return
176
- const pointer = this.canvas.getPointer(o.e)
177
- this.line.set({ x2: pointer.x, y2: pointer.y })
178
- this.canvas.renderAll()
179
- })
163
+ strokeColTap(v) {
164
+ this.color = v
165
+ },
166
+ strokeTap(v) {
167
+ this.strokeWidth = Number(v)
168
+ },
169
+ set() {
170
+ this.textShow = false
171
+ this.setShow = !this.setShow
172
+ },
173
+ init() {
174
+ this.canvas = new fabric.Canvas(this.id, {
175
+ isDrawingMode: false,
176
+ width: this.width,
177
+ height: this.height,
178
+ });
179
+ this.canvas.selectionColor = "rgba(255,255,255,0)";
180
+ this.canvas.loadFromJSON(this.data)
181
+ this.y = (this.height / 2) - 203
182
+ },
183
+ // 画笔
184
+ brush() {
185
+ this.state = 'brush'
186
+ this.canvas.isDrawingMode = !this.canvas.isDrawingMode
187
+ this.canvas.freeDrawingBrush.width = this.strokeWidth
188
+ this.canvas.freeDrawingBrush.color = this.color
189
+ },
190
+ // 直线
191
+ addLine() {
192
+ this.canvas.isDrawingMode = false
193
+ this.state = 'line'
194
+ const id = Date.now()
195
+ this.canvas.on('mouse:down', (o) => {
196
+ if (o.target !== null) return
197
+ if (this.state !== 'line') return
198
+ this.isDown = true
199
+ const pointer = this.canvas.getPointer(o.e)
200
+ const points = [pointer.x, pointer.y, pointer.x, pointer.y]
201
+ this.line = new fabric.Line(points, {
202
+ id: id,
203
+ strokeWidth: this.strokeWidth,
204
+ fill: this.color,
205
+ stroke: this.color,
206
+ originX: 'center',
207
+ originY: 'center'
208
+ })
209
+ this.canvas.add(this.line)
210
+ })
211
+ this.canvas.on('mouse:move', (o) => {
212
+ if (this.state !== 'line') return
213
+ if (!this.isDown) return
214
+ const pointer = this.canvas.getPointer(o.e)
215
+ this.line.set({x2: pointer.x, y2: pointer.y})
216
+ this.canvas.renderAll()
217
+ })
180
218
 
181
- this.canvas.on('mouse:up', (o) => {
182
- this.isDown = false
183
- this.line.setCoords()
184
- })
185
- },
186
- // 矩形
187
- rectangle() {
188
- this.canvas.isDrawingMode = false
189
- this.state = 'rectangle'
190
- const id = Date.now()
191
- let origX, origY
192
- this.canvas.on('mouse:down', (o) => {
193
- if(o.target !== null) return
194
- if(this.state !== 'rectangle') return
195
- this.isDown = true
196
- let pointer = this.canvas.getPointer(o.e)
197
- origX = pointer.x
198
- origY = pointer.y
199
- this.rect = new fabric.Rect({
200
- id: id,
201
- left: origX,
202
- top: origY,
203
- originX: 'left',
204
- originY: 'top',
205
- width: pointer.x - origX,
206
- height: pointer.y - origY,
207
- angle: 0,
208
- fill: '',
209
- stroke: this.color,
210
- strokeWidth: this.strokeWidth
211
- })
212
- this.canvas.add(this.rect)
213
- })
214
- this.canvas.on('mouse:move', (o) => {
215
- if(this.state !== 'rectangle') return
216
- if (!this.isDown) return
217
- let pointer = this.canvas.getPointer(o.e)
219
+ this.canvas.on('mouse:up', (o) => {
220
+ this.isDown = false
221
+ this.line.setCoords()
222
+ })
223
+ },
224
+ // 矩形
225
+ rectangle() {
226
+ this.canvas.isDrawingMode = false
227
+ this.state = 'rectangle'
228
+ const id = Date.now()
229
+ let origX, origY
230
+ this.canvas.on('mouse:down', (o) => {
231
+ if (o.target !== null) return
232
+ if (this.state !== 'rectangle') return
233
+ this.isDown = true
234
+ let pointer = this.canvas.getPointer(o.e)
235
+ origX = pointer.x
236
+ origY = pointer.y
237
+ this.rect = new fabric.Rect({
238
+ id: id,
239
+ left: origX,
240
+ top: origY,
241
+ originX: 'left',
242
+ originY: 'top',
243
+ width: pointer.x - origX,
244
+ height: pointer.y - origY,
245
+ angle: 0,
246
+ fill: '',
247
+ stroke: this.color,
248
+ strokeWidth: this.strokeWidth
249
+ })
250
+ this.canvas.add(this.rect)
251
+ })
252
+ this.canvas.on('mouse:move', (o) => {
253
+ if (this.state !== 'rectangle') return
254
+ if (!this.isDown) return
255
+ let pointer = this.canvas.getPointer(o.e)
218
256
 
219
- if (origX > pointer.x) {
220
- this.rect.set({ left: Math.abs(pointer.x) })
221
- }
222
- if (origY > pointer.y) {
223
- this.rect.set({ top: Math.abs(pointer.y) })
224
- }
225
- this.rect.set({ width: Math.abs(origX - pointer.x) })
226
- this.rect.set({ height: Math.abs(origY - pointer.y) })
227
- this.canvas.renderAll()
228
- })
229
- this.canvas.on('mouse:up', (o) => {
230
- this.isDown = false
231
- this.rect.setCoords()
232
- })
233
- },
234
- // 圆形
235
- rotundity() {
236
- this.canvas.isDrawingMode = false
237
- this.state = 'rotundity'
238
- let origX, origY
239
- this.canvas.on('mouse:down', (o) => {
240
- if(o.target !== null) return
241
- if(this.state !== 'rotundity') return
242
- this.isDown = true
243
- let pointer = this.canvas.getPointer(o.e)
244
- origX = pointer.x
245
- origY = pointer.y
246
- this.circle = new fabric.Circle({
247
- left: origX,
248
- top: origY,
249
- originX: 'left',
250
- originY: 'top',
251
- radius: pointer.x - origX,
252
- angle: 0,
253
- fill: '',
254
- stroke: this.color,
255
- strokeWidth: this.strokeWidth
256
- })
257
- this.canvas.add(this.circle)
258
- })
259
- this.canvas.on('mouse:move', (o) => {
260
- if(this.state !== 'rotundity') return
261
- if (!this.isDown) return
262
- let pointer = this.canvas.getPointer(o.e)
263
- let radius =
264
- Math.max(
265
- Math.abs(origY - pointer.y),
266
- Math.abs(origX - pointer.x)
267
- ) / 2
268
- if (radius > this.circle.strokeWidth) {
269
- radius -= this.circle.strokeWidth / 2
270
- }
271
- this.circle.set({ radius: radius })
257
+ if (origX > pointer.x) {
258
+ this.rect.set({left: Math.abs(pointer.x)})
259
+ }
260
+ if (origY > pointer.y) {
261
+ this.rect.set({top: Math.abs(pointer.y)})
262
+ }
263
+ this.rect.set({width: Math.abs(origX - pointer.x)})
264
+ this.rect.set({height: Math.abs(origY - pointer.y)})
265
+ this.canvas.renderAll()
266
+ })
267
+ this.canvas.on('mouse:up', (o) => {
268
+ this.isDown = false
269
+ this.rect.setCoords()
270
+ })
271
+ },
272
+ // 圆形
273
+ rotundity() {
274
+ this.canvas.isDrawingMode = false
275
+ this.state = 'rotundity'
276
+ let origX, origY
277
+ this.canvas.on('mouse:down', (o) => {
278
+ if (o.target !== null) return
279
+ if (this.state !== 'rotundity') return
280
+ this.isDown = true
281
+ let pointer = this.canvas.getPointer(o.e)
282
+ origX = pointer.x
283
+ origY = pointer.y
284
+ this.circle = new fabric.Circle({
285
+ left: origX,
286
+ top: origY,
287
+ originX: 'left',
288
+ originY: 'top',
289
+ radius: pointer.x - origX,
290
+ angle: 0,
291
+ fill: '',
292
+ stroke: this.color,
293
+ strokeWidth: this.strokeWidth
294
+ })
295
+ this.canvas.add(this.circle)
296
+ })
297
+ this.canvas.on('mouse:move', (o) => {
298
+ if (this.state !== 'rotundity') return
299
+ if (!this.isDown) return
300
+ let pointer = this.canvas.getPointer(o.e)
301
+ let radius =
302
+ Math.max(
303
+ Math.abs(origY - pointer.y),
304
+ Math.abs(origX - pointer.x)
305
+ ) / 2
306
+ if (radius > this.circle.strokeWidth) {
307
+ radius -= this.circle.strokeWidth / 2
308
+ }
309
+ this.circle.set({radius: radius})
272
310
 
273
- if (origX > pointer.x) {
274
- this.circle.set({ originX: 'right' })
275
- } else {
276
- this.circle.set({ originX: 'left' })
277
- }
278
- if (origY > pointer.y) {
279
- this.circle.set({ originY: 'bottom' })
280
- } else {
281
- this.circle.set({ originY: 'top' })
282
- }
283
- this.canvas.renderAll()
284
- })
285
- this.canvas.on('mouse:up', () => {
286
- this.isDown = false
287
- this.circle.setCoords()
288
- })
289
- },
290
- // 箭头
291
- arrow() {
292
- const id = Date.now()
293
- const triangle = new fabric.Triangle({
294
- width: 9,
295
- height: 15,
296
- fill: 'black',
297
- left: 150,
298
- top: 137,
299
- angle: 90
300
- })
301
- const line = new fabric.Rect({
302
- left: 100,
303
- top: 140,
304
- width: 40,
305
- height: 3,
306
- fill: 'black',
307
- originX: 'left',
308
- originY: 'top',
309
- centeredRotation: true
310
- })
311
- const arrow = new fabric.Group([line, triangle], {
312
- id: id,
313
- left: this.canvas.width / 2,
314
- top: this.canvas.height / 2,
315
- angle: 0
316
- })
317
- this.canvas.add(arrow)
318
- },
319
- // 文本框
320
- textBox() {
321
- const id = Date.now()
322
- this.textbox = new fabric.Textbox(this.text, {
323
- id: id,
324
- top: 200,
325
- left: 200,
326
- width: 10,
327
- fill: this.color,
328
- fontSize: this.fontSize,
329
- color: this.color,
330
- fontWeight: 400,
331
- lineHeight: 1.5,
332
- fontFamily: '微软雅黑',
333
- textDecoration: 'none',
334
- textAlign: 'left'
335
- })
336
- this.canvas.add(this.textbox)
337
- },
338
- save() {
339
- console.log(this.canvas.toJSON())
340
- this.$emit('save', this.canvas.toJSON())
341
- },
342
- clear() {
343
- this.canvas.clear()
344
- },
345
- handleKeyEvent (e) {
346
- const { key } = e
347
- if (key === 'Backspace' || key === 'Delete') {
348
- const el = this.canvas.getActiveObject()
349
- if(el) this.canvas.remove(el)
350
- }
311
+ if (origX > pointer.x) {
312
+ this.circle.set({originX: 'right'})
313
+ } else {
314
+ this.circle.set({originX: 'left'})
351
315
  }
316
+ if (origY > pointer.y) {
317
+ this.circle.set({originY: 'bottom'})
318
+ } else {
319
+ this.circle.set({originY: 'top'})
320
+ }
321
+ this.canvas.renderAll()
322
+ })
323
+ this.canvas.on('mouse:up', () => {
324
+ this.isDown = false
325
+ this.circle.setCoords()
326
+ })
327
+ },
328
+ // 箭头
329
+ arrow() {
330
+ const id = Date.now()
331
+ const triangle = new fabric.Triangle({
332
+ width: 9,
333
+ height: 15,
334
+ fill: 'black',
335
+ left: 150,
336
+ top: 137,
337
+ angle: 90
338
+ })
339
+ const line = new fabric.Rect({
340
+ left: 100,
341
+ top: 140,
342
+ width: 40,
343
+ height: 3,
344
+ fill: 'black',
345
+ originX: 'left',
346
+ originY: 'top',
347
+ centeredRotation: true
348
+ })
349
+ const arrow = new fabric.Group([line, triangle], {
350
+ id: id,
351
+ left: this.canvas.width / 2,
352
+ top: this.canvas.height / 2,
353
+ angle: 0
354
+ })
355
+ this.canvas.add(arrow)
356
+ },
357
+ // 文本框
358
+ textBox() {
359
+ const id = Date.now()
360
+ this.textbox = new fabric.Textbox(this.text, {
361
+ id: id,
362
+ top: 200,
363
+ left: 200,
364
+ width: 10,
365
+ fill: this.color,
366
+ fontSize: this.fontSize,
367
+ color: this.color,
368
+ fontWeight: 400,
369
+ lineHeight: 1.5,
370
+ fontFamily: '微软雅黑',
371
+ textDecoration: 'none',
372
+ textAlign: 'left'
373
+ })
374
+ this.canvas.add(this.textbox)
375
+ },
376
+ save() {
377
+ console.log(this.canvas.toJSON())
378
+ this.$emit('save', this.canvas.toJSON())
379
+ },
380
+ clear() {
381
+ this.canvas.clear()
382
+ },
383
+ handleKeyEvent(e) {
384
+ const {key} = e
385
+ if (key === 'Backspace' || key === 'Delete') {
386
+ const el = this.canvas.getActiveObject()
387
+ if (el) this.canvas.remove(el)
388
+ }
352
389
  }
390
+ }
353
391
  }
354
392
  </script>
355
393
 
356
394
  <style scoped>
357
- .sketchpad{
358
- position: relative;
395
+ .sketchpad {
396
+ position: relative;
359
397
  }
360
- .tool{
361
- position: absolute;
362
- top: 50%;
363
- left: -55px;
364
- z-index: 1;
365
- width: 50px;
366
- padding: 15px;
367
- border-radius: 10px;
368
- box-shadow: 0 0 5px 3px rgba(0,0,0,0.3);
369
- box-sizing: border-box;
370
- background: #fff;
371
- margin-top: -200px;
398
+
399
+ .tool {
400
+ position: absolute;
401
+ top: 0;
402
+ left: 0;
403
+ z-index: 1;
404
+ width: 50px;
405
+ padding: 15px;
406
+ border-radius: 10px;
407
+ box-shadow: 0 0 5px 3px rgba(0, 0, 0, 0.3);
408
+ box-sizing: border-box;
409
+ background: #fff;
410
+ transition-property: transform;
411
+ transition-duration: 0ms;
412
+ transition-timing-function: linear;
413
+ transition-delay: 0ms;
414
+ transform: translate(0px, 0px);
415
+ cursor: move;
416
+ user-select: none;
372
417
  }
373
- .tool-list{
374
- width: 100%;
375
- margin-bottom: 20px;
376
- cursor: pointer;
377
- position: relative;
418
+
419
+ .tool-list {
420
+ width: 100%;
421
+ margin-bottom: 20px;
422
+ cursor: pointer;
423
+ position: relative;
378
424
  }
379
- .tool-list:last-child{
380
- margin-bottom: 0;
425
+
426
+ .tool-list:last-child {
427
+ margin-bottom: 0;
381
428
  }
382
- .tool-list img{
383
- width: 100%;
429
+
430
+ .tool-list img {
431
+ width: 100%;
384
432
  }
385
- .set{
386
- position: absolute;
387
- top: 0;
388
- left: 40px;
389
- width: 280px;
390
- background-color: #fff;
391
- border-radius: 10px;
392
- box-shadow: 0 0 5px 3px rgba(0,0,0,0.3);
393
- padding: 10px;
394
- z-index: 1;
433
+
434
+ .set {
435
+ position: absolute;
436
+ top: 0;
437
+ left: 40px;
438
+ width: 280px;
439
+ background-color: #fff;
440
+ border-radius: 10px;
441
+ box-shadow: 0 0 5px 3px rgba(0, 0, 0, 0.3);
442
+ padding: 10px;
443
+ z-index: 1;
395
444
  }
396
- .set-list{
397
- padding: 5px 0;
398
- font-size: 15px;
445
+
446
+ .set-list {
447
+ padding: 5px 0;
448
+ font-size: 15px;
399
449
  }
400
- .set-list:after{
401
- content: '';
402
- display: block;
403
- clear: both;
450
+
451
+ .set-list:after {
452
+ content: '';
453
+ display: block;
454
+ clear: both;
404
455
  }
405
- .set-list span{
406
- margin-right: 10px;
407
- float: left;
456
+
457
+ .set-list span {
458
+ margin-right: 10px;
459
+ float: left;
408
460
  }
409
- .set-list em{
410
- font-style: normal;
411
- font-size: 15px;
412
- width: 16px;
413
- display: inline-block;
414
- margin-right: 10px;
415
- text-align: center;
461
+
462
+ .set-list em {
463
+ font-style: normal;
464
+ font-size: 15px;
465
+ width: 16px;
466
+ display: inline-block;
467
+ margin-right: 10px;
468
+ text-align: center;
416
469
  }
417
- .set-list em:hover{
418
- color: #5daf34;
470
+
471
+ .set-list em:hover {
472
+ color: #5daf34;
419
473
  }
420
- .set-list i{
421
- display: inline-block;
422
- width: 16px;
423
- height: 16px;
424
- background-color: #000;
425
- margin: 2px 10px 0 0;
426
- float: left;
474
+
475
+ .set-list i {
476
+ display: inline-block;
477
+ width: 16px;
478
+ height: 16px;
479
+ background-color: #000;
480
+ margin: 2px 10px 0 0;
481
+ float: left;
427
482
  }
428
- .set-list input{
429
- width: calc(100% - 60px);
430
- height: 22px;
431
- border: 1px solid #ccc;
432
- border-radius: 5px;
433
- padding: 0 10px;
434
- box-sizing: border-box;
435
- float: left;
483
+
484
+ .set-list input {
485
+ width: calc(100% - 60px);
486
+ height: 22px;
487
+ border: 1px solid #ccc;
488
+ border-radius: 5px;
489
+ padding: 0 10px;
490
+ box-sizing: border-box;
491
+ float: left;
436
492
  }
437
- .but{
438
- margin-left: 5px;
439
- font-size: 12px;
440
- background-color: transparent;
441
- border: 1px solid #000;
442
- border-radius: 3px;
443
- padding: 2px 5px;
444
- cursor: pointer;
445
- min-width: 60px;
446
- height: 21px;
447
- margin-right: 20px;
493
+
494
+ .but {
495
+ margin-left: 5px;
496
+ font-size: 12px;
497
+ background-color: transparent;
498
+ border: 1px solid #000;
499
+ border-radius: 3px;
500
+ padding: 2px 5px;
501
+ cursor: pointer;
502
+ min-width: 60px;
503
+ height: 21px;
504
+ margin-right: 20px;
448
505
  }
449
- .set-right{
450
- text-align: right;
506
+
507
+ .set-right {
508
+ text-align: right;
451
509
  }
452
510
  </style>
package/src/index.js CHANGED
@@ -79,7 +79,7 @@ function install(app) {
79
79
  }
80
80
 
81
81
  export default {
82
- version: '1.32.258',
82
+ version: '1.32.259',
83
83
  install,
84
84
  Calendar,
85
85
  Message,