zydx-plus 1.35.544 → 1.35.545

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.544",
3
+ "version": "1.35.545",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="docView" @mouseleave="mouseUpTest" @mouseup="mouseUpTest">
2
+ <div class="docView" @click="extendRightDel" @mouseleave="mouseUpTest" @mouseup="mouseUpTest">
3
3
  <div class="full-screen" v-if="false">
4
4
  <div class="full-screen-img" @click.stop="fullScreen">
5
5
  <!-- <div class="full-screen-title" style="" v-if="showText">全屏查看</div>-->
@@ -19,18 +19,30 @@
19
19
  </div>
20
20
  </div>
21
21
  <div>
22
- <div class="book" ref="book">
22
+ <div class="book" ref="book" @click.right="rightMenu($event)">
23
23
  <div class="pages">
24
24
  <div class="wrap-box" ref="wrap-box" v-show="doublePage">
25
25
  <div class="wrap wrap-block" :ref="`wrap-${item.id}`" v-for="(item,index) in pageInfoArr" :key="index">
26
26
  <div class="wrap-can" v-show="!loading" ref="wrapCanBox">
27
+ <div class="extend-right" v-if="rightMenuShow" :style="extendStyle">
28
+ <p @click.stop="extendRight(index)">链接扩展</p>
29
+ </div>
27
30
  <div class="textLayer" ref="textLayer">
28
31
  <span :dir="item2.dir" :style="styleText(item2,item.styles, item.id)" v-for="(item2) in item.items">{{ item2.str }}</span>
29
32
  </div>
30
33
  <div class="annotationLayer" ref="annotationLayer">
31
- <section tabindex="1000" @click="annotationTap(item2)" :style="styleAnnotation(item2)" v-for="(item2) in item.annotations">
32
- <a :href="item2.url" target="_blank"></a>
33
- </section>
34
+ <template v-for="(item,index) in annotations">
35
+ <div :style="styleAnnotation(item)" class="magnifier" v-if="item.type === 'tag'">
36
+ <img @click.stop="magnifierTap($event,item)" src="../img/fangdajing.png" alt="" />
37
+ <div class="magnifier-list" v-if="item.show" :style="item.style">
38
+ <div class="magnifier-list-item" @click="annotationTap(item2)" v-for="(item2,index2) in item.list">{{ index2+1 }}.{{ item2?.title }}</div>
39
+ <div class="magnifier-list-add" @click="annotationTap(item,'add')">添加扩展链接</div>
40
+ </div>
41
+ </div>
42
+ <section v-else tabindex="1000" @click="annotationTap(item,item.id)" :style="styleAnnotation(item)">
43
+ <a :href="item.url" target="_blank"></a>
44
+ </section>
45
+ </template>
34
46
  </div>
35
47
  <canvas @click.stop="turnText" class="wrap-can-one" :class="{isPointer: isPointer}" @mousedown.stop="mouseDown"
36
48
  @mousemove.stop="mouseMove" :id="item.id"></canvas>
@@ -55,13 +67,25 @@
55
67
  </div>
56
68
  <div class="wrap" ref="wrap" v-show="!doublePage">
57
69
  <div class="wrap-can" v-show="!loading" ref="wrapCan">
70
+ <div class="extend-right" v-if="rightMenuShow" :style="extendStyle">
71
+ <p @click.stop="extendRight(null)">链接扩展</p>
72
+ </div>
58
73
  <div class="textLayer" ref="textLayer">
59
74
  <span :dir="item.dir" :style="styleText(item,styles)" v-for="(item,index) in items">{{ item.str }}</span>
60
75
  </div>
61
76
  <div class="annotationLayer" ref="annotationLayer">
62
- <section tabindex="1000" @click="annotationTap(item)" :style="styleAnnotation(item)" v-for="(item,index) in annotations">
63
- <a :href="item.url" target="_blank"></a>
64
- </section>
77
+ <template v-for="(item,index) in annotations">
78
+ <div :style="styleAnnotation(item)" class="magnifier" v-if="item.type === 'tag'">
79
+ <img @click.stop="magnifierTap($event,item)" src="../img/fangdajing.png" alt="" />
80
+ <div class="magnifier-list" v-if="item.show" :style="item.style">
81
+ <div class="magnifier-list-item" @click="annotationTap(item2)" v-for="(item2,index2) in item.list">{{ index2+1 }}.{{ item2?.title }}</div>
82
+ <div class="magnifier-list-add" @click="annotationTap(item,'add')">添加扩展链接</div>
83
+ </div>
84
+ </div>
85
+ <section v-else tabindex="1000" @click="annotationTap(item)" :style="styleAnnotation(item)">
86
+ <a :href="item.url" target="_blank"></a>
87
+ </section>
88
+ </template>
65
89
  </div>
66
90
  <canvas @click.stop="turnText" class="wrap-can-one" :class="{isPointer: isPointer}" @mousedown.stop="mouseDown"
67
91
  @mousemove.stop="mouseMove" :id="`${id}`"></canvas>
@@ -121,7 +145,7 @@ import * as PdfJs from 'pdfjs-dist'
121
145
  import "pdfjs-dist/build/pdf.worker.mjs";
122
146
  import Range from "../../tagging/src/range";
123
147
 
124
- let pdfs = null;
148
+ let pdfs = {};
125
149
 
126
150
  export default {
127
151
  name: "zydx-flip",
@@ -195,7 +219,13 @@ export default {
195
219
  viewWidth: 0,
196
220
  viewHeight: 0,
197
221
  annotations: [],
198
- annotationsInit: []
222
+ annotationsInit: [],
223
+ extendStyle: {
224
+ left: '0px',
225
+ top: '0px'
226
+ },
227
+ rightMenuShow: false,
228
+ annData: {}
199
229
  }
200
230
  },
201
231
  props: {
@@ -253,9 +283,22 @@ export default {
253
283
  annotationsData: {
254
284
  handler: function (val) {
255
285
  if(typeof val === Object) {
256
- this.annotations.push(val)
286
+ this.annotations.push({
287
+ ...val,
288
+ show: false,
289
+ style: {},
290
+ type: "tag"
291
+ })
257
292
  }else {
258
- this.annotations = val.concat(this.annotationsInit)
293
+ const arr = val.map(x => {
294
+ return {
295
+ ...x,
296
+ show: false,
297
+ style: {},
298
+ type: "tag"
299
+ }
300
+ })
301
+ this.annotations = arr.concat(this.annotationsInit)
259
302
  }
260
303
  },
261
304
  deep: true,
@@ -333,7 +376,7 @@ export default {
333
376
  immediate: true
334
377
  }
335
378
  },
336
- emits: ['flip','annotationTap'],
379
+ emits: ['flip','annotationTap', 'annotationsSend'],
337
380
  mounted() {
338
381
  if (!this.doublePage) {
339
382
  this.id = 'canvas-wrap' + this.generateUniqueKey()
@@ -351,13 +394,86 @@ export default {
351
394
  this.cancelResizeObserver()
352
395
  },
353
396
  methods: {
354
- annotationTap(v) {
397
+ magnifierTap(e,v) {
398
+ if(!v.show) this.extendRightDel()
399
+ v.show = !v.show
400
+ setTimeout(() => {
401
+ const w = e.target.nextSibling.offsetWidth
402
+ const x = (v.rect[0] * this.scales / this.viewport?.width) * 100
403
+ const y = ((this.viewport?.height - (v.rect[1] * this.scales)) / this.viewport?.height) * 100
404
+ if(x > 50) {
405
+ v.style.left = `-${w?w + 5:0}px`
406
+ }else {
407
+ v.style.right = `-${w?w + 5:0}px`
408
+ }
409
+ if(y > 40) {
410
+ v.style.bottom = '0px'
411
+ }else {
412
+ v.style.top = '0px'
413
+ }
414
+ },20)
415
+ },
416
+ extendRightDel() {
417
+ this.rightMenuShow = false
418
+ this.annotations.map(x => {
419
+ x.show = false
420
+ return x
421
+ })
422
+ },
423
+ annotationTap(v, n ) {
355
424
  if(v.url) return
356
- this.$emit('annotationTap',v)
425
+ if(n === 'add') {
426
+ this.$emit('annotationsSend', {
427
+ id: v.id,
428
+ page: v.page,
429
+ borderColor: v.borderColor,
430
+ borderStyle: v.borderStyle,
431
+ rect: v.rect,
432
+ })
433
+ }else {
434
+ this.$emit('annotationTap',v)
435
+ }
436
+ },
437
+ // 扩展点击
438
+ extendRight(i) {
439
+ this.extendRightDel()
440
+ this.$emit('annotationsSend', {
441
+ ...this.annData,
442
+ id: new Date().getTime(),
443
+ page: i? i + 1 : this.pageIndex,
444
+ })
445
+ },
446
+ // 右键菜单
447
+ rightMenu(e) {
448
+ e.preventDefault()
449
+ if(this.doublePage) return;
450
+ if(e.target.nodeName === 'SPAN') {
451
+ const wid = this.$refs.wrap.offsetWidth - 10
452
+ const hei = this.$refs.wrap.offsetHeight - 10
453
+ const endOffset = this.getRange().endOffset
454
+ const style = e.target.attributes.style.value
455
+ const size = style.match(/font-size:\s*([^;]+)/)[1].trim().replace(/px/g, "")
456
+ const topMatch = style.match(/top:\s*([^;]+)/)[1].trim().replace(/%/g, "");
457
+ const x1 = this.viewport.width * (e.target.offsetLeft + (endOffset * Number(size)))/wid
458
+ const y1 = this.viewport.height * (1 - (Number(topMatch/100))) - 3
459
+ const x2 = x1 + 15
460
+ const y2 = y1 + 15
461
+ const left = e.target.offsetLeft + e.offsetX
462
+ this.rightMenuShow = true
463
+ this.extendStyle = {
464
+ left: left + 'px',
465
+ top: Number(topMatch) + ((size/hei)*100) + '%'
466
+ }
467
+ this.annData = {
468
+ rect: [x1/this.scales,y1/this.scales,x2/this.scales,y2/this.scales],
469
+ type: 'tag',
470
+ borderStyle: {width: 0},
471
+ borderColor: [0,0,0]
472
+ }
473
+ }
357
474
  },
358
475
  // 添加标注
359
476
  flipText(next) {
360
- if(this.doublePage) return;
361
477
  let timestamp = 'flip' + Math.random().toString(36).substr(2)
362
478
  this.replaceSelectedStrByEle(timestamp)
363
479
  const elements = document.querySelectorAll(`.${timestamp}`)[0];
@@ -427,6 +543,7 @@ export default {
427
543
  return range
428
544
  },
429
545
  styleAnnotation(v) {
546
+ if(!v) return {}
430
547
  const x1 = (v.rect[0] * this.scales / this.viewport?.width) * 100
431
548
  const y1 = ((this.viewport?.height - (v.rect[1] * this.scales)) / this.viewport?.height) * 100
432
549
  const x2 = (((v.rect[2] - v.rect[0]) * this.scales) / this.viewport?.width) * 100
@@ -440,6 +557,7 @@ export default {
440
557
  }
441
558
  },
442
559
  styleText(v,n, id) {
560
+ if(!v) return {}
443
561
  const textLayer = id? this.$refs[`wrap-${id}`][0] : this.$refs.textLayer;
444
562
  const actualWidth = textLayer.clientWidth
445
563
  const pageScale = actualWidth / this.viewWidth
@@ -545,7 +663,6 @@ export default {
545
663
  } else {
546
664
  this.points.pop()
547
665
  }
548
- this.$emit('drawEnd', this.points,'backward')
549
666
  this.clearRect()
550
667
  },
551
668
  // 鼠标
@@ -858,8 +975,6 @@ export default {
858
975
  i--
859
976
  }
860
977
  }
861
- console.log('delChart')
862
- this.$emit('drawEnd', this.points,'del')
863
978
  this.clearRect()
864
979
  },
865
980
  // 绘制
@@ -909,7 +1024,7 @@ export default {
909
1024
  turnText() {
910
1025
  if (this.textStart) return
911
1026
  if (this.state === 'text') {
912
- const text = this.$refs.textInput.innerText || '输入文字'
1027
+ const text = this.$refs.textInput.innerText
913
1028
  this.contenteditable = false
914
1029
  this.state = null
915
1030
  if (text === '') {
@@ -995,7 +1110,6 @@ export default {
995
1110
  color: obj.color,
996
1111
  size: obj.size,
997
1112
  })
998
- this.$emit('drawEnd', this.points)
999
1113
  },
1000
1114
  // 画箭头
1001
1115
  arrow(obj, type) {
@@ -1041,7 +1155,6 @@ export default {
1041
1155
  color: obj.color,
1042
1156
  border: obj.border,
1043
1157
  })
1044
- this.$emit('drawEnd', this.points)
1045
1158
  }
1046
1159
  },
1047
1160
  // 画直线
@@ -1073,7 +1186,6 @@ export default {
1073
1186
  color: obj.color,
1074
1187
  border: obj.border,
1075
1188
  })
1076
- this.$emit('drawEnd', this.points)
1077
1189
  }
1078
1190
  },
1079
1191
  // 画圆
@@ -1105,7 +1217,6 @@ export default {
1105
1217
  color: obj.color,
1106
1218
  border: obj.border,
1107
1219
  })
1108
- this.$emit('drawEnd', this.points)
1109
1220
  }
1110
1221
  },
1111
1222
  // 画矩形
@@ -1136,7 +1247,6 @@ export default {
1136
1247
  color: obj.color,
1137
1248
  border: obj.border,
1138
1249
  })
1139
- this.$emit('drawEnd', this.points)
1140
1250
  }
1141
1251
  },
1142
1252
  // 画线
@@ -1157,9 +1267,6 @@ export default {
1157
1267
  this.ctx.stroke()
1158
1268
  this.ctx.closePath()
1159
1269
  this.points.push(obj)
1160
- if(obj.start === 'end'){
1161
- this.$emit('drawEnd', this.points)
1162
- }
1163
1270
  },
1164
1271
  clearRect(v) {
1165
1272
  const width = this.canvasStyle.widthCanvas
@@ -1268,31 +1375,24 @@ export default {
1268
1375
  for (let i = 0; i < this.points.length; i++) {
1269
1376
  if (this.points[i].index === this.pageIndex) {
1270
1377
  if (this.points[i].type === 'line') {
1271
- console.log('type1',this.points[i].type)
1272
1378
  this.lineProcessing(this.points[i], this.points[i + 1], {x: 0, y: 0})
1273
1379
  }
1274
1380
  if (this.points[i].type === 'rectangle') {
1275
- console.log('type2',this.points[i].type)
1276
1381
  this.rectangleProcessing(this.points[i], {x: 0, y: 0})
1277
1382
  }
1278
1383
  if (this.points[i].type === 'circular') {
1279
- console.log('type3',this.points[i].type)
1280
1384
  this.circularProcessing(this.points[i], {x: 0, y: 0})
1281
1385
  }
1282
1386
  if (this.points[i].type === 'straight') {
1283
- console.log('type4',this.points[i].type)
1284
1387
  this.straightProcessing(this.points[i], {x: 0, y: 0})
1285
1388
  }
1286
1389
  if (this.points[i].type === 'arrow') {
1287
- console.log('type5',this.points[i].type)
1288
1390
  this.arrowProcessing(this.points[i], {x: 0, y: 0})
1289
1391
  }
1290
1392
  if (this.points[i].type === 'text') {
1291
- console.log('type6',this.points[i].type)
1292
1393
  this.textProcessing(this.points[i], {x: 0, y: 0})
1293
1394
  }
1294
1395
  if (this.points[i].type === 'sign') {
1295
- console.log('type7',this.points[i].type)
1296
1396
  this.signProcessing(this.points[i], {x: 0, y: 0})
1297
1397
  }
1298
1398
  }
@@ -1348,7 +1448,7 @@ export default {
1348
1448
  cMapPacked: true
1349
1449
  })
1350
1450
  loadingTask.promise.then((pdf) => {
1351
- pdfs = pdf
1451
+ pdfs[that.id] = pdf
1352
1452
  that.pdfPages = pdf.numPages // 获取pdf文件的总页数
1353
1453
  that.$nextTick(() => {
1354
1454
  if (that.doublePage) {
@@ -1373,7 +1473,7 @@ export default {
1373
1473
  let that = this
1374
1474
  that.mouse()
1375
1475
  that.$nextTick(() => {
1376
- pdfs.getPage(that.pageIndex).then(function (page) {
1476
+ pdfs[that.id].getPage(that.pageIndex).then(function (page) {
1377
1477
  that.doc = page
1378
1478
  that.viewWidth = page.view[2] - page.view[0]
1379
1479
  that.viewHeight = page.view[3] - page.view[1]
@@ -1422,7 +1522,15 @@ export default {
1422
1522
  })
1423
1523
  page.getAnnotations().then((res) => {
1424
1524
  that.annotationsInit = res
1425
- that.annotations = res.concat(that.annotationsData)
1525
+ const arr = that.annotationsData.map(x => {
1526
+ return {
1527
+ ...x,
1528
+ show: false,
1529
+ style: {},
1530
+ type: "tag"
1531
+ }
1532
+ })
1533
+ that.annotations = res.concat(arr)
1426
1534
  })
1427
1535
  that.loading = false
1428
1536
  if (that.oneIndex === 'right') {
@@ -1450,7 +1558,7 @@ export default {
1450
1558
  that.mouse()
1451
1559
  that.$nextTick(() => {
1452
1560
  that.pageInfoArr.forEach((item, index) => {
1453
- pdfs.getPage(index + 1).then(function (page) {
1561
+ pdfs[that.id].getPage(index + 1).then(function (page) {
1454
1562
  that.doc = page
1455
1563
  that.viewWidth = page.view[2] - page.view[0]
1456
1564
  that.viewHeight = page.view[3] - page.view[1]
@@ -1535,6 +1643,67 @@ export default {
1535
1643
  @import '../icon.css';
1536
1644
  @import '../annotationLayer.css';
1537
1645
  @import '../textLayer.css';
1646
+ .magnifier{
1647
+ position: absolute;
1648
+ text-align: initial;
1649
+ pointer-events: auto;
1650
+ box-sizing: border-box;
1651
+ transform-origin: 0 0;
1652
+ cursor: pointer;
1653
+ }
1654
+ .magnifier>img{
1655
+ width: 100%;
1656
+ height: 100%;
1657
+ display: block;
1658
+ }
1659
+ .magnifier-list{
1660
+ position: absolute;
1661
+ max-width: 300px;
1662
+ background-color: #fff;
1663
+ border-radius: 5px;
1664
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.25);
1665
+ padding: 10px 20px;
1666
+ font-size: 14px;
1667
+ z-index: 1;
1668
+ animation: linkDown .4s linear forwards;
1669
+ opacity: 0;
1670
+ }
1671
+ .magnifier-list-item{
1672
+ line-height: 24px;
1673
+ overflow: hidden;
1674
+ text-overflow: ellipsis;
1675
+ white-space: nowrap;
1676
+ }
1677
+ .magnifier-list-item:hover{
1678
+ color: #4B0C77 !important;
1679
+ }
1680
+ @keyframes linkDown {
1681
+ 0% {
1682
+ opacity: 0;
1683
+ }
1684
+ 50% {
1685
+ opacity: 0;
1686
+ }
1687
+ 100% {
1688
+ opacity: 1;
1689
+ }
1690
+ }
1691
+ .magnifier-list-add{
1692
+ color: #666;
1693
+ font-size: 12px;
1694
+ padding: 5px 0;
1695
+ }
1696
+ .extend-right{
1697
+ position: absolute;
1698
+ z-index: 5;
1699
+ background-color: #fff;
1700
+ border-radius: 5px;
1701
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.25);
1702
+ padding: 10px 20px;
1703
+ }
1704
+ .extend-right>p{
1705
+ cursor: pointer;
1706
+ }
1538
1707
  .isPointer{
1539
1708
  pointer-events: none;
1540
1709
  }
package/src/index.js CHANGED
@@ -89,7 +89,7 @@ function install(app) {
89
89
  }
90
90
 
91
91
  export default {
92
- version: '1.35.544',
92
+ version: '1.35.545',
93
93
  install,
94
94
  Calendar,
95
95
  Message,