zydx-plus 1.35.543 → 1.35.544

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.35.543",
3
+ "version": "1.35.544",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -59,7 +59,7 @@
59
59
  <span :dir="item.dir" :style="styleText(item,styles)" v-for="(item,index) in items">{{ item.str }}</span>
60
60
  </div>
61
61
  <div class="annotationLayer" ref="annotationLayer">
62
- <section tabindex="1000" :style="styleAnnotation(item)" v-for="(item,index) in annotations">
62
+ <section tabindex="1000" @click="annotationTap(item)" :style="styleAnnotation(item)" v-for="(item,index) in annotations">
63
63
  <a :href="item.url" target="_blank"></a>
64
64
  </section>
65
65
  </div>
@@ -195,7 +195,7 @@ export default {
195
195
  viewWidth: 0,
196
196
  viewHeight: 0,
197
197
  annotations: [],
198
- inits: true
198
+ annotationsInit: []
199
199
  }
200
200
  },
201
201
  props: {
@@ -252,11 +252,10 @@ export default {
252
252
  watch: {
253
253
  annotationsData: {
254
254
  handler: function (val) {
255
- console.log(val)
256
255
  if(typeof val === Object) {
257
256
  this.annotations.push(val)
258
257
  }else {
259
- this.annotations = val.concat(this.annotations)
258
+ this.annotations = val.concat(this.annotationsInit)
260
259
  }
261
260
  },
262
261
  deep: true,
@@ -336,7 +335,6 @@ export default {
336
335
  },
337
336
  emits: ['flip','annotationTap'],
338
337
  mounted() {
339
- this.inits = true
340
338
  if (!this.doublePage) {
341
339
  this.id = 'canvas-wrap' + this.generateUniqueKey()
342
340
  }
@@ -354,6 +352,7 @@ export default {
354
352
  },
355
353
  methods: {
356
354
  annotationTap(v) {
355
+ if(v.url) return
357
356
  this.$emit('annotationTap',v)
358
357
  },
359
358
  // 添加标注
@@ -546,6 +545,7 @@ export default {
546
545
  } else {
547
546
  this.points.pop()
548
547
  }
548
+ this.$emit('drawEnd', this.points,'backward')
549
549
  this.clearRect()
550
550
  },
551
551
  // 鼠标
@@ -858,6 +858,8 @@ export default {
858
858
  i--
859
859
  }
860
860
  }
861
+ console.log('delChart')
862
+ this.$emit('drawEnd', this.points,'del')
861
863
  this.clearRect()
862
864
  },
863
865
  // 绘制
@@ -907,7 +909,7 @@ export default {
907
909
  turnText() {
908
910
  if (this.textStart) return
909
911
  if (this.state === 'text') {
910
- const text = this.$refs.textInput.innerText
912
+ const text = this.$refs.textInput.innerText || '输入文字'
911
913
  this.contenteditable = false
912
914
  this.state = null
913
915
  if (text === '') {
@@ -993,6 +995,7 @@ export default {
993
995
  color: obj.color,
994
996
  size: obj.size,
995
997
  })
998
+ this.$emit('drawEnd', this.points)
996
999
  },
997
1000
  // 画箭头
998
1001
  arrow(obj, type) {
@@ -1038,6 +1041,7 @@ export default {
1038
1041
  color: obj.color,
1039
1042
  border: obj.border,
1040
1043
  })
1044
+ this.$emit('drawEnd', this.points)
1041
1045
  }
1042
1046
  },
1043
1047
  // 画直线
@@ -1069,6 +1073,7 @@ export default {
1069
1073
  color: obj.color,
1070
1074
  border: obj.border,
1071
1075
  })
1076
+ this.$emit('drawEnd', this.points)
1072
1077
  }
1073
1078
  },
1074
1079
  // 画圆
@@ -1100,6 +1105,7 @@ export default {
1100
1105
  color: obj.color,
1101
1106
  border: obj.border,
1102
1107
  })
1108
+ this.$emit('drawEnd', this.points)
1103
1109
  }
1104
1110
  },
1105
1111
  // 画矩形
@@ -1130,6 +1136,7 @@ export default {
1130
1136
  color: obj.color,
1131
1137
  border: obj.border,
1132
1138
  })
1139
+ this.$emit('drawEnd', this.points)
1133
1140
  }
1134
1141
  },
1135
1142
  // 画线
@@ -1150,6 +1157,9 @@ export default {
1150
1157
  this.ctx.stroke()
1151
1158
  this.ctx.closePath()
1152
1159
  this.points.push(obj)
1160
+ if(obj.start === 'end'){
1161
+ this.$emit('drawEnd', this.points)
1162
+ }
1153
1163
  },
1154
1164
  clearRect(v) {
1155
1165
  const width = this.canvasStyle.widthCanvas
@@ -1258,24 +1268,31 @@ export default {
1258
1268
  for (let i = 0; i < this.points.length; i++) {
1259
1269
  if (this.points[i].index === this.pageIndex) {
1260
1270
  if (this.points[i].type === 'line') {
1271
+ console.log('type1',this.points[i].type)
1261
1272
  this.lineProcessing(this.points[i], this.points[i + 1], {x: 0, y: 0})
1262
1273
  }
1263
1274
  if (this.points[i].type === 'rectangle') {
1275
+ console.log('type2',this.points[i].type)
1264
1276
  this.rectangleProcessing(this.points[i], {x: 0, y: 0})
1265
1277
  }
1266
1278
  if (this.points[i].type === 'circular') {
1279
+ console.log('type3',this.points[i].type)
1267
1280
  this.circularProcessing(this.points[i], {x: 0, y: 0})
1268
1281
  }
1269
1282
  if (this.points[i].type === 'straight') {
1283
+ console.log('type4',this.points[i].type)
1270
1284
  this.straightProcessing(this.points[i], {x: 0, y: 0})
1271
1285
  }
1272
1286
  if (this.points[i].type === 'arrow') {
1287
+ console.log('type5',this.points[i].type)
1273
1288
  this.arrowProcessing(this.points[i], {x: 0, y: 0})
1274
1289
  }
1275
1290
  if (this.points[i].type === 'text') {
1291
+ console.log('type6',this.points[i].type)
1276
1292
  this.textProcessing(this.points[i], {x: 0, y: 0})
1277
1293
  }
1278
1294
  if (this.points[i].type === 'sign') {
1295
+ console.log('type7',this.points[i].type)
1279
1296
  this.signProcessing(this.points[i], {x: 0, y: 0})
1280
1297
  }
1281
1298
  }
@@ -1404,15 +1421,8 @@ export default {
1404
1421
  that.styles = res.styles
1405
1422
  })
1406
1423
  page.getAnnotations().then((res) => {
1407
- console.log(that.inits)
1408
- if(that.inits) {
1409
- that.annotations = res.concat(that.annotationsData)
1410
- setTimeout(() => {
1411
- that.inits = false
1412
- },1000)
1413
- }else {
1414
- that.annotations = res
1415
- }
1424
+ that.annotationsInit = res
1425
+ that.annotations = res.concat(that.annotationsData)
1416
1426
  })
1417
1427
  that.loading = false
1418
1428
  if (that.oneIndex === 'right') {
@@ -1488,14 +1498,8 @@ export default {
1488
1498
  item.styles = res.styles
1489
1499
  })
1490
1500
  page.getAnnotations().then((res) => {
1491
- if(that.inits) {
1492
- item.annotations = res.concat(that.annotationsData)
1493
- setTimeout(() => {
1494
- that.inits = false
1495
- },1000)
1496
- }else {
1497
- item.annotations = res
1498
- }
1501
+ that.annotationsInit = res
1502
+ that.annotations = res.concat(that.annotationsData)
1499
1503
  })
1500
1504
  that.loading = false
1501
1505
  if (that.oneIndex === 'right') {
@@ -6,9 +6,10 @@
6
6
  <script>
7
7
  import {createElement} from 'react'
8
8
  import {createRoot} from 'react-dom/client'
9
- import {AssetRecordType,createShapeId, Tldraw, FileHelpers} from 'tldraw'
9
+ import {AssetRecordType,createShapeId, Tldraw} from 'tldraw'
10
10
  import 'tldraw/tldraw.css'
11
- import * as buffer from "buffer"; //引入buffer
11
+ import * as buffer from "buffer";
12
+ import {debounce} from "../../utils"; //引入buffer
12
13
 
13
14
  if (typeof window.Buffer === "undefined") { // 判断当前环境是否有Buffer对象
14
15
  window.Buffer = buffer.Buffer; // Buffer对象不存在则创建导入的buffer
@@ -153,7 +154,14 @@ export default {
153
154
  },
154
155
  handleMountedEditor(editor) {
155
156
  editorAPP = editor
156
- // console.log('editorAPP',editorAPP);
157
+ editorAPP.sideEffects.registerAfterChangeHandler('shape', debounce((next)=> {
158
+ // there can only be one red shape at a time:
159
+ this.$emit('shapeChangeHandler', next);
160
+ },300))
161
+ editorAPP.sideEffects.registerAfterDeleteHandler('shape', (shape) => {
162
+ // if the last shape in a frame is deleted, delete the frame too:
163
+ this.$emit('shapeDeleteHandler', shape);
164
+ })
157
165
  editorAPP.setCameraOptions({ isLocked: this.cameraIsLocked })
158
166
  editorAPP.updateInstanceState({ isToolLocked: this.isToolLocked })
159
167
  if (this.top) {
@@ -174,12 +182,13 @@ export default {
174
182
  // 清空
175
183
  clear() {
176
184
  // editorAPP.store.loadSnapshot(clearJson)
177
- let graphicIds = []
178
- for(let key in editorAPP.store.query.atoms.current) {
179
- if(key.split(':')[0]==='shape') {
180
- graphicIds.push(key)
181
- }
182
- }
185
+ editorAPP.selectAll()
186
+ let graphicIds = editorAPP.getSelectedShapeIds()
187
+ // for(let key in editorAPP.store.query.atoms.current) {
188
+ // if(key.split(':')[0]==='shape') {
189
+ // graphicIds.push(key)
190
+ // }
191
+ // }
183
192
  editorAPP.deleteShapes(graphicIds)
184
193
  },
185
194
  // 添加快照
@@ -10,4 +10,16 @@ export function debounce(fn, delay = debounceTimer) {
10
10
  fn.apply(that, args)
11
11
  }, delay)
12
12
  }
13
+ }
14
+ export function throttle(fn, limit=debounceTimer) {
15
+ let inThrottle;
16
+ return function() {
17
+ const args = arguments;
18
+ const context = this;
19
+ if (!inThrottle) {
20
+ fn.apply(context, args);
21
+ inThrottle = true;
22
+ setTimeout(() => { inThrottle = false; }, limit);
23
+ }
24
+ };
13
25
  }
package/src/index.js CHANGED
@@ -89,7 +89,7 @@ function install(app) {
89
89
  }
90
90
 
91
91
  export default {
92
- version: '1.35.543',
92
+ version: '1.35.544',
93
93
  install,
94
94
  Calendar,
95
95
  Message,