zydx-plus 1.32.193 → 1.32.195
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
|
@@ -355,7 +355,7 @@ export default {
|
|
|
355
355
|
this.htmlArr = []
|
|
356
356
|
const data = document.querySelectorAll('.editing-cont')[0].childNodes[0].childNodes
|
|
357
357
|
this.wit = document.getElementsByClassName('editor-content')[0].offsetWidth
|
|
358
|
-
let max = this.wit * 1.4
|
|
358
|
+
let max = this.wit * 1.4
|
|
359
359
|
let pHeight = 0
|
|
360
360
|
let html = ''
|
|
361
361
|
for (let i = 0; i < data.length; i++) {
|
|
@@ -401,8 +401,7 @@ export default {
|
|
|
401
401
|
let height = data.offsetHeight
|
|
402
402
|
let rows = Math.round(num / line) // 行数
|
|
403
403
|
let text = data.innerText
|
|
404
|
-
let
|
|
405
|
-
let textLen = Math.round((width / (len/text.length)) * rows) // 文本长度
|
|
404
|
+
let textLen = this.measureText(text,size,width * rows)
|
|
406
405
|
let start = text.slice(0, textLen)
|
|
407
406
|
let end = text.slice(textLen)
|
|
408
407
|
return {
|
|
@@ -410,31 +409,46 @@ export default {
|
|
|
410
409
|
end: {data: end, size: height - num}
|
|
411
410
|
}
|
|
412
411
|
},
|
|
413
|
-
measureText (text, fontSize=10) {
|
|
412
|
+
measureText (text, fontSize=10, max=0) {
|
|
414
413
|
text = String(text);
|
|
415
414
|
text = text.split('');
|
|
415
|
+
let num = 0
|
|
416
416
|
let width = 0;
|
|
417
|
-
text.
|
|
418
|
-
if
|
|
417
|
+
for (let i = 0; i< text.length; i++) {
|
|
418
|
+
if(max !== 0) {
|
|
419
|
+
if(width * fontSize / 10 >= max) {
|
|
420
|
+
return num
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
if (/[a-zA-Z]/.test(text[i])) { // 英文匹配
|
|
419
424
|
width += 7;
|
|
420
|
-
|
|
425
|
+
num += 1
|
|
426
|
+
} else if (/[0-9]/.test(text[i])) { // 数字匹配
|
|
421
427
|
width += 5.5;
|
|
422
|
-
|
|
428
|
+
num += 1
|
|
429
|
+
} else if (/\./.test(text[i])) { // 英文句点匹配
|
|
423
430
|
width += 2.7;
|
|
424
|
-
|
|
431
|
+
num += 1
|
|
432
|
+
} else if (/-/.test(text[i])) { // 英文减号匹配
|
|
425
433
|
width += 3.25;
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
434
|
+
num += 1
|
|
435
|
+
} else if (/[\u4e00-\u9fa5]/.test(text[i])) { //中文匹配
|
|
436
|
+
width += 10.105;
|
|
437
|
+
num += 1
|
|
438
|
+
} else if (/\(|\)/.test(text[i])) { // 括号匹配
|
|
429
439
|
width += 3.73;
|
|
430
|
-
|
|
440
|
+
num += 1
|
|
441
|
+
} else if (/\s/.test(text[i])) { // 空格匹配
|
|
431
442
|
width += 2.5;
|
|
432
|
-
|
|
443
|
+
num += 1
|
|
444
|
+
} else if (/[`!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/.test(text[i])) { // 英文符号匹配
|
|
433
445
|
width += 8;
|
|
446
|
+
num += 1
|
|
434
447
|
} else {
|
|
435
448
|
width += 10;
|
|
449
|
+
num += 1
|
|
436
450
|
}
|
|
437
|
-
}
|
|
451
|
+
}
|
|
438
452
|
return width * fontSize / 10;
|
|
439
453
|
},
|
|
440
454
|
confirm() {
|
|
@@ -516,7 +530,7 @@ export default {
|
|
|
516
530
|
const cla = this.randomId()
|
|
517
531
|
const html = `<p class="imgCont ${cla}"><img src="${data}" alt="" /></p>`
|
|
518
532
|
this.editor.chain().focus().insertContentAt(this.selection(), html).run()
|
|
519
|
-
if(this.selection() <= 6) this.selectionClass2(cla)
|
|
533
|
+
if(this.selection() <= 6 && this.selection() > 2) this.selectionClass2(cla)
|
|
520
534
|
if(this.selectionClass(cla)) {
|
|
521
535
|
this.editor.chain().focus().insertContentAt(this.selection(), '<p></p>').run()
|
|
522
536
|
}
|
|
@@ -562,7 +576,7 @@ export default {
|
|
|
562
576
|
const cla = this.randomId()
|
|
563
577
|
const html = `<p class="imgCont ${cla}"><img src="${this.imgUrl}" alt="" /></p>`
|
|
564
578
|
this.editor.chain().focus().insertContentAt(this.selection(), html).run()
|
|
565
|
-
if(this.selection() <= 6) this.selectionClass2(cla)
|
|
579
|
+
if(this.selection() <= 6 && this.selection() > 2) this.selectionClass2(cla)
|
|
566
580
|
if(this.selectionClass(cla)) {
|
|
567
581
|
this.editor.chain().focus().insertContentAt(this.selection(), '<p></p>').run()
|
|
568
582
|
}
|
|
@@ -832,6 +846,7 @@ export default {
|
|
|
832
846
|
|
|
833
847
|
:deep(.read-only-p p) {
|
|
834
848
|
line-height: 25px;
|
|
849
|
+
text-align: justify;
|
|
835
850
|
}
|
|
836
851
|
|
|
837
852
|
.read-only-a {
|
|
@@ -347,7 +347,7 @@ export default {
|
|
|
347
347
|
const html = `<p class="imgCont ${cla}"><img src="${url}" alt="" /></p>`
|
|
348
348
|
this.editor.chain().focus().insertContentAt(this.selection(),html).run()
|
|
349
349
|
console.log(this.selection())
|
|
350
|
-
if(this.selection() <= 6) this.selectionClass2(cla)
|
|
350
|
+
if(this.selection() <= 6 && this.selection() > 2) this.selectionClass2(cla)
|
|
351
351
|
if(this.selectionClass(cla)) {
|
|
352
352
|
this.editor.chain().focus().insertContentAt(this.selection(), '<p></p>').run()
|
|
353
353
|
}
|