zydx-plus 1.35.542 → 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,8 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div :style="heightStyle" class="edit">
|
|
3
3
|
<div :class="{'ed-head': !titleVertical, 'ed-head-vertical': titleVertical}">
|
|
4
|
-
<div v-if="titleShow && titleVertical"
|
|
5
|
-
|
|
4
|
+
<div v-if="titleShow && titleVertical">
|
|
5
|
+
<div :style="titleStyle" v-html="title"></div>
|
|
6
|
+
<slot name='titleSuffix'></slot>
|
|
7
|
+
</div>
|
|
8
|
+
<div class="ed-title" v-if="titleShow && !titleVertical">
|
|
9
|
+
<span :style="titleStyle" v-html="title"></span>
|
|
10
|
+
<slot name='titleSuffix'></slot>
|
|
11
|
+
</div>
|
|
6
12
|
<div class="ed-but" v-if="readOnly">
|
|
7
13
|
<div class="ed-head-but" v-for="(item,index) in toolbar">
|
|
8
14
|
<button v-if="item.key === 'but'" class="buts" @click="item.onClick(item,info)"
|
|
@@ -20,6 +26,7 @@
|
|
|
20
26
|
:style="{color: (voiceStatus)? '#4B0C77' :'#000'}">{{ voiceStatus ? '关闭语音' : '语音输入' }}
|
|
21
27
|
</button>
|
|
22
28
|
<button v-if='isShowAiTool' class="buts" @click="showAi">AI助手</button>
|
|
29
|
+
<slot name='toolBtn'></slot>
|
|
23
30
|
</div>
|
|
24
31
|
</div>
|
|
25
32
|
<zydx-chat v-model='isShowAi'></zydx-chat>
|
|
@@ -520,6 +527,10 @@ export default {
|
|
|
520
527
|
const text2 = text.replace(/[\r\n]/g, '').replace(/\s*/g, '')
|
|
521
528
|
this.editor.chain().focus().insertContentAt(this.selection(), text2).run()
|
|
522
529
|
},
|
|
530
|
+
addContent(text) {
|
|
531
|
+
const text2 = text.replace(/[\r\n]/g, '').replace(/\s*/g, '')
|
|
532
|
+
this.editor.chain().focus().insertContentAt(this.selection(), text2).run()
|
|
533
|
+
},
|
|
523
534
|
to16kHz(audioData, sampleRate = 44100) {
|
|
524
535
|
const data = new Float32Array(audioData);
|
|
525
536
|
const fitCount = Math.round(data.length * (16000 / sampleRate));
|
|
@@ -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>
|
|
@@ -194,7 +194,8 @@ export default {
|
|
|
194
194
|
doc: null,
|
|
195
195
|
viewWidth: 0,
|
|
196
196
|
viewHeight: 0,
|
|
197
|
-
annotations: []
|
|
197
|
+
annotations: [],
|
|
198
|
+
annotationsInit: []
|
|
198
199
|
}
|
|
199
200
|
},
|
|
200
201
|
props: {
|
|
@@ -249,6 +250,17 @@ export default {
|
|
|
249
250
|
}
|
|
250
251
|
},
|
|
251
252
|
watch: {
|
|
253
|
+
annotationsData: {
|
|
254
|
+
handler: function (val) {
|
|
255
|
+
if(typeof val === Object) {
|
|
256
|
+
this.annotations.push(val)
|
|
257
|
+
}else {
|
|
258
|
+
this.annotations = val.concat(this.annotationsInit)
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
deep: true,
|
|
262
|
+
immediate: true
|
|
263
|
+
},
|
|
252
264
|
pointsData: {
|
|
253
265
|
handler: function (val) {
|
|
254
266
|
if (!val) return
|
|
@@ -340,6 +352,7 @@ export default {
|
|
|
340
352
|
},
|
|
341
353
|
methods: {
|
|
342
354
|
annotationTap(v) {
|
|
355
|
+
if(v.url) return
|
|
343
356
|
this.$emit('annotationTap',v)
|
|
344
357
|
},
|
|
345
358
|
// 添加标注
|
|
@@ -348,7 +361,7 @@ export default {
|
|
|
348
361
|
let timestamp = 'flip' + Math.random().toString(36).substr(2)
|
|
349
362
|
this.replaceSelectedStrByEle(timestamp)
|
|
350
363
|
const elements = document.querySelectorAll(`.${timestamp}`)[0];
|
|
351
|
-
if(!elements) return
|
|
364
|
+
if(!elements) return next(false)
|
|
352
365
|
const wid = this.$refs.wrap.offsetWidth - 10
|
|
353
366
|
const hei = this.$refs.wrap.offsetHeight - 10
|
|
354
367
|
const hei2 = elements.offsetHeight - 8
|
|
@@ -414,10 +427,10 @@ export default {
|
|
|
414
427
|
return range
|
|
415
428
|
},
|
|
416
429
|
styleAnnotation(v) {
|
|
417
|
-
const x1 = (v.rect[0] * this.scales / this.viewport
|
|
418
|
-
const y1 = ((this.viewport
|
|
419
|
-
const x2 = (((v.rect[2] - v.rect[0]) * this.scales) / this.viewport
|
|
420
|
-
const y2 = (((v.rect[3] - v.rect[1]) * this.scales) / this.viewport
|
|
430
|
+
const x1 = (v.rect[0] * this.scales / this.viewport?.width) * 100
|
|
431
|
+
const y1 = ((this.viewport?.height - (v.rect[1] * this.scales)) / this.viewport?.height) * 100
|
|
432
|
+
const x2 = (((v.rect[2] - v.rect[0]) * this.scales) / this.viewport?.width) * 100
|
|
433
|
+
const y2 = (((v.rect[3] - v.rect[1]) * this.scales) / this.viewport?.height) * 100
|
|
421
434
|
return {
|
|
422
435
|
'left': x1 - 0.2 + '%',
|
|
423
436
|
'top': (y1 - y2) - 0.2 + '%',
|
|
@@ -532,6 +545,7 @@ export default {
|
|
|
532
545
|
} else {
|
|
533
546
|
this.points.pop()
|
|
534
547
|
}
|
|
548
|
+
this.$emit('drawEnd', this.points,'backward')
|
|
535
549
|
this.clearRect()
|
|
536
550
|
},
|
|
537
551
|
// 鼠标
|
|
@@ -844,6 +858,8 @@ export default {
|
|
|
844
858
|
i--
|
|
845
859
|
}
|
|
846
860
|
}
|
|
861
|
+
console.log('delChart')
|
|
862
|
+
this.$emit('drawEnd', this.points,'del')
|
|
847
863
|
this.clearRect()
|
|
848
864
|
},
|
|
849
865
|
// 绘制
|
|
@@ -893,7 +909,7 @@ export default {
|
|
|
893
909
|
turnText() {
|
|
894
910
|
if (this.textStart) return
|
|
895
911
|
if (this.state === 'text') {
|
|
896
|
-
const text = this.$refs.textInput.innerText
|
|
912
|
+
const text = this.$refs.textInput.innerText || '输入文字'
|
|
897
913
|
this.contenteditable = false
|
|
898
914
|
this.state = null
|
|
899
915
|
if (text === '') {
|
|
@@ -979,6 +995,7 @@ export default {
|
|
|
979
995
|
color: obj.color,
|
|
980
996
|
size: obj.size,
|
|
981
997
|
})
|
|
998
|
+
this.$emit('drawEnd', this.points)
|
|
982
999
|
},
|
|
983
1000
|
// 画箭头
|
|
984
1001
|
arrow(obj, type) {
|
|
@@ -1024,6 +1041,7 @@ export default {
|
|
|
1024
1041
|
color: obj.color,
|
|
1025
1042
|
border: obj.border,
|
|
1026
1043
|
})
|
|
1044
|
+
this.$emit('drawEnd', this.points)
|
|
1027
1045
|
}
|
|
1028
1046
|
},
|
|
1029
1047
|
// 画直线
|
|
@@ -1055,6 +1073,7 @@ export default {
|
|
|
1055
1073
|
color: obj.color,
|
|
1056
1074
|
border: obj.border,
|
|
1057
1075
|
})
|
|
1076
|
+
this.$emit('drawEnd', this.points)
|
|
1058
1077
|
}
|
|
1059
1078
|
},
|
|
1060
1079
|
// 画圆
|
|
@@ -1086,6 +1105,7 @@ export default {
|
|
|
1086
1105
|
color: obj.color,
|
|
1087
1106
|
border: obj.border,
|
|
1088
1107
|
})
|
|
1108
|
+
this.$emit('drawEnd', this.points)
|
|
1089
1109
|
}
|
|
1090
1110
|
},
|
|
1091
1111
|
// 画矩形
|
|
@@ -1116,6 +1136,7 @@ export default {
|
|
|
1116
1136
|
color: obj.color,
|
|
1117
1137
|
border: obj.border,
|
|
1118
1138
|
})
|
|
1139
|
+
this.$emit('drawEnd', this.points)
|
|
1119
1140
|
}
|
|
1120
1141
|
},
|
|
1121
1142
|
// 画线
|
|
@@ -1136,6 +1157,9 @@ export default {
|
|
|
1136
1157
|
this.ctx.stroke()
|
|
1137
1158
|
this.ctx.closePath()
|
|
1138
1159
|
this.points.push(obj)
|
|
1160
|
+
if(obj.start === 'end'){
|
|
1161
|
+
this.$emit('drawEnd', this.points)
|
|
1162
|
+
}
|
|
1139
1163
|
},
|
|
1140
1164
|
clearRect(v) {
|
|
1141
1165
|
const width = this.canvasStyle.widthCanvas
|
|
@@ -1244,24 +1268,31 @@ export default {
|
|
|
1244
1268
|
for (let i = 0; i < this.points.length; i++) {
|
|
1245
1269
|
if (this.points[i].index === this.pageIndex) {
|
|
1246
1270
|
if (this.points[i].type === 'line') {
|
|
1271
|
+
console.log('type1',this.points[i].type)
|
|
1247
1272
|
this.lineProcessing(this.points[i], this.points[i + 1], {x: 0, y: 0})
|
|
1248
1273
|
}
|
|
1249
1274
|
if (this.points[i].type === 'rectangle') {
|
|
1275
|
+
console.log('type2',this.points[i].type)
|
|
1250
1276
|
this.rectangleProcessing(this.points[i], {x: 0, y: 0})
|
|
1251
1277
|
}
|
|
1252
1278
|
if (this.points[i].type === 'circular') {
|
|
1279
|
+
console.log('type3',this.points[i].type)
|
|
1253
1280
|
this.circularProcessing(this.points[i], {x: 0, y: 0})
|
|
1254
1281
|
}
|
|
1255
1282
|
if (this.points[i].type === 'straight') {
|
|
1283
|
+
console.log('type4',this.points[i].type)
|
|
1256
1284
|
this.straightProcessing(this.points[i], {x: 0, y: 0})
|
|
1257
1285
|
}
|
|
1258
1286
|
if (this.points[i].type === 'arrow') {
|
|
1287
|
+
console.log('type5',this.points[i].type)
|
|
1259
1288
|
this.arrowProcessing(this.points[i], {x: 0, y: 0})
|
|
1260
1289
|
}
|
|
1261
1290
|
if (this.points[i].type === 'text') {
|
|
1291
|
+
console.log('type6',this.points[i].type)
|
|
1262
1292
|
this.textProcessing(this.points[i], {x: 0, y: 0})
|
|
1263
1293
|
}
|
|
1264
1294
|
if (this.points[i].type === 'sign') {
|
|
1295
|
+
console.log('type7',this.points[i].type)
|
|
1265
1296
|
this.signProcessing(this.points[i], {x: 0, y: 0})
|
|
1266
1297
|
}
|
|
1267
1298
|
}
|
|
@@ -1362,7 +1393,7 @@ export default {
|
|
|
1362
1393
|
let viewport = page.getViewport({scale: that.scales})
|
|
1363
1394
|
that.viewport = viewport
|
|
1364
1395
|
const sc = (viewport.width / viewport.height).toFixed(2)
|
|
1365
|
-
const wid = that.$refs.wrap
|
|
1396
|
+
const wid = that.$refs.wrap?.offsetWidth - 10
|
|
1366
1397
|
const hei = wid / sc
|
|
1367
1398
|
canvas.width = wid * that.sratio
|
|
1368
1399
|
canvas.height = hei * that.sratio
|
|
@@ -1390,6 +1421,7 @@ export default {
|
|
|
1390
1421
|
that.styles = res.styles
|
|
1391
1422
|
})
|
|
1392
1423
|
page.getAnnotations().then((res) => {
|
|
1424
|
+
that.annotationsInit = res
|
|
1393
1425
|
that.annotations = res.concat(that.annotationsData)
|
|
1394
1426
|
})
|
|
1395
1427
|
that.loading = false
|
|
@@ -1466,7 +1498,8 @@ export default {
|
|
|
1466
1498
|
item.styles = res.styles
|
|
1467
1499
|
})
|
|
1468
1500
|
page.getAnnotations().then((res) => {
|
|
1469
|
-
|
|
1501
|
+
that.annotationsInit = res
|
|
1502
|
+
that.annotations = res.concat(that.annotationsData)
|
|
1470
1503
|
})
|
|
1471
1504
|
that.loading = false
|
|
1472
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
|
|
9
|
+
import {AssetRecordType,createShapeId, Tldraw} from 'tldraw'
|
|
10
10
|
import 'tldraw/tldraw.css'
|
|
11
|
-
import * as buffer from "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
|
-
|
|
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
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
}
|