zydx-plus 1.32.194 → 1.32.196

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.194",
3
+ "version": "1.32.196",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -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 - 200
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 len = this.measureText(text,size) // 文本宽度
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.forEach(function(item) {
418
- if (/[a-zA-Z]/.test(item)) { // 英文匹配
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
- } else if (/[0-9]/.test(item)) { // 数字匹配
425
+ num += 1
426
+ } else if (/[0-9]/.test(text[i])) { // 数字匹配
421
427
  width += 5.5;
422
- } else if (/\./.test(item)) { // 英文句点匹配
428
+ num += 1
429
+ } else if (/\./.test(text[i])) { // 英文句点匹配
423
430
  width += 2.7;
424
- } else if (/-/.test(item)) { // 英文减号匹配
431
+ num += 1
432
+ } else if (/-/.test(text[i])) { // 英文减号匹配
425
433
  width += 3.25;
426
- } else if (/[\u4e00-\u9fa5]/.test(item)) { //中文匹配
427
- width += 10;
428
- } else if (/\(|\)/.test(item)) { // 括号匹配
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
- } else if (/\s/.test(item)) { // 空格匹配
440
+ num += 1
441
+ } else if (/\s/.test(text[i])) { // 空格匹配
431
442
  width += 2.5;
432
- } else if (/[`!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/.test(item)) { // 英文符号匹配
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
  }
@@ -831,7 +845,8 @@ export default {
831
845
  }
832
846
 
833
847
  :deep(.read-only-p p) {
834
- line-height: 25px;
848
+ line-height: 26px;
849
+ text-align: justify;
835
850
  }
836
851
 
837
852
  .read-only-a {
@@ -939,7 +954,7 @@ label {
939
954
  }
940
955
 
941
956
  .editing-cont :deep(p) {
942
- line-height: 30px;
957
+ line-height: 26px;
943
958
  }
944
959
  .editing-cont :deep(img) {
945
960
  padding: 5px 0;
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div :style="heightStyle">
2
+ <div :style="heightStyle" class="edit">
3
3
  <div class="ed-head">
4
4
  <div class="ed-title" v-if="titleShow" :style="titleStyle" v-html="title"></div>
5
5
  <div class="ed-but" v-if="readOnly">
@@ -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
  }
@@ -437,6 +437,9 @@ export default {
437
437
  </script>
438
438
 
439
439
  <style scoped>
440
+ .edit{
441
+ margin-bottom: 14px;
442
+ }
440
443
  :deep(.imgCont) {
441
444
  line-height: 0 !important;
442
445
  }
@@ -444,20 +447,20 @@ export default {
444
447
  display: none !important;
445
448
  }
446
449
  .editor :deep(h1) {
447
- line-height: 30px;
450
+ line-height: 26px;
448
451
  font-size: 18px;
449
452
  }
450
453
  .editor :deep(h2) {
451
- line-height: 30px;
454
+ line-height: 26px;
452
455
  font-size: 16px;
453
456
  }
454
457
  .editor :deep(h3) {
455
- line-height: 30px;
458
+ line-height: 26px;
456
459
  font-size: 14px;
457
460
  }
458
461
  .editor :deep(p) {
459
462
  font-size: 14px;
460
- line-height: 30px;
463
+ line-height: 26px;
461
464
  }
462
465
  :deep(.ProseMirror) p.is-editor-empty:first-child::before {
463
466
  content: attr(data-placeholder);
@@ -533,7 +536,7 @@ export default {
533
536
  padding: 5px 0;
534
537
  }
535
538
  .ed-cont{
536
- padding: 5px 0 0;
539
+ padding-top: 6px;
537
540
  }
538
541
  .editor{
539
542
  border-radius: 3px;
@@ -0,0 +1,7 @@
1
+ import main from './src/tagging';
2
+
3
+ main.install = function(Vue) {
4
+ Vue.component(main.name, main);
5
+ };
6
+
7
+ export default main;
@@ -0,0 +1,243 @@
1
+ export let agent = navigator.userAgent.toLowerCase()
2
+ export let opera = window.opera
3
+ export let browser = {
4
+ /**
5
+ * @property {boolean} ie 检测当前浏览器是否为IE
6
+ * @example
7
+ * ```javascript
8
+ * if ( UE.browser.ie ) {
9
+ * console.log( '当前浏览器是IE' );
10
+ * }
11
+ * ```
12
+ */
13
+ ie: /(msie\s|trident.*rv:)([\w.]+)/i.test(agent),
14
+
15
+ /**
16
+ * @property {boolean} opera 检测当前浏览器是否为Opera
17
+ * @example
18
+ * ```javascript
19
+ * if ( UE.browser.opera ) {
20
+ * console.log( '当前浏览器是Opera' );
21
+ * }
22
+ * ```
23
+ */
24
+ opera: !!opera && opera.version,
25
+
26
+ /**
27
+ * @property {boolean} webkit 检测当前浏览器是否是webkit内核的浏览器
28
+ * @example
29
+ * ```javascript
30
+ * if ( UE.browser.webkit ) {
31
+ * console.log( '当前浏览器是webkit内核浏览器' );
32
+ * }
33
+ * ```
34
+ */
35
+ webkit: agent.indexOf(" applewebkit/") > -1,
36
+
37
+ /**
38
+ * @property {boolean} mac 检测当前浏览器是否是运行在mac平台下
39
+ * @example
40
+ * ```javascript
41
+ * if ( UE.browser.mac ) {
42
+ * console.log( '当前浏览器运行在mac平台下' );
43
+ * }
44
+ * ```
45
+ */
46
+ mac: agent.indexOf("macintosh") > -1,
47
+
48
+ /**
49
+ * @property {boolean} quirks 检测当前浏览器是否处于“怪异模式”下
50
+ * @example
51
+ * ```javascript
52
+ * if ( UE.browser.quirks ) {
53
+ * console.log( '当前浏览器运行处于“怪异模式”' );
54
+ * }
55
+ * ```
56
+ */
57
+ quirks: document.compatMode == "BackCompat"
58
+ };
59
+
60
+ /**
61
+ * @property {boolean} gecko 检测当前浏览器内核是否是gecko内核
62
+ * @example
63
+ * ```javascript
64
+ * if ( UE.browser.gecko ) {
65
+ * console.log( '当前浏览器内核是gecko内核' );
66
+ * }
67
+ * ```
68
+ */
69
+ browser.gecko =
70
+ navigator.product == "Gecko" &&
71
+ !browser.webkit &&
72
+ !browser.opera &&
73
+ !browser.ie;
74
+
75
+ var version = 0;
76
+
77
+ // Internet Explorer 6.0+
78
+ if (browser.ie) {
79
+ var v1 = agent.match(/(?:msie\s([\w.]+))/);
80
+ var v2 = agent.match(/(?:trident.*rv:([\w.]+))/);
81
+ if (v1 && v2 && v1[1] && v2[1]) {
82
+ version = Math.max(v1[1] * 1, v2[1] * 1);
83
+ } else if (v1 && v1[1]) {
84
+ version = v1[1] * 1;
85
+ } else if (v2 && v2[1]) {
86
+ version = v2[1] * 1;
87
+ } else {
88
+ version = 0;
89
+ }
90
+
91
+ browser.ie11Compat = document.documentMode == 11;
92
+ /**
93
+ * @property { boolean } ie9Compat 检测浏览器模式是否为 IE9 兼容模式
94
+ * @warning 如果浏览器不是IE, 则该值为undefined
95
+ * @example
96
+ * ```javascript
97
+ * if ( UE.browser.ie9Compat ) {
98
+ * console.log( '当前浏览器运行在IE9兼容模式下' );
99
+ * }
100
+ * ```
101
+ */
102
+ browser.ie9Compat = document.documentMode == 9;
103
+
104
+ /**
105
+ * @property { boolean } ie8 检测浏览器是否是IE8浏览器
106
+ * @warning 如果浏览器不是IE, 则该值为undefined
107
+ * @example
108
+ * ```javascript
109
+ * if ( UE.browser.ie8 ) {
110
+ * console.log( '当前浏览器是IE8浏览器' );
111
+ * }
112
+ * ```
113
+ */
114
+ browser.ie8 = !!document.documentMode;
115
+
116
+ /**
117
+ * @property { boolean } ie8Compat 检测浏览器模式是否为 IE8 兼容模式
118
+ * @warning 如果浏览器不是IE, 则该值为undefined
119
+ * @example
120
+ * ```javascript
121
+ * if ( UE.browser.ie8Compat ) {
122
+ * console.log( '当前浏览器运行在IE8兼容模式下' );
123
+ * }
124
+ * ```
125
+ */
126
+ browser.ie8Compat = document.documentMode == 8;
127
+
128
+ /**
129
+ * @property { boolean } ie7Compat 检测浏览器模式是否为 IE7 兼容模式
130
+ * @warning 如果浏览器不是IE, 则该值为undefined
131
+ * @example
132
+ * ```javascript
133
+ * if ( UE.browser.ie7Compat ) {
134
+ * console.log( '当前浏览器运行在IE7兼容模式下' );
135
+ * }
136
+ * ```
137
+ */
138
+ browser.ie7Compat =
139
+ (version == 7 && !document.documentMode) || document.documentMode == 7;
140
+
141
+ /**
142
+ * @property { boolean } ie6Compat 检测浏览器模式是否为 IE6 模式 或者怪异模式
143
+ * @warning 如果浏览器不是IE, 则该值为undefined
144
+ * @example
145
+ * ```javascript
146
+ * if ( UE.browser.ie6Compat ) {
147
+ * console.log( '当前浏览器运行在IE6模式或者怪异模式下' );
148
+ * }
149
+ * ```
150
+ */
151
+ browser.ie6Compat = version < 7 || browser.quirks;
152
+
153
+ browser.ie9above = version > 8;
154
+
155
+ browser.ie9below = version < 9;
156
+
157
+ browser.ie11above = version > 10;
158
+
159
+ browser.ie11below = version < 11;
160
+ }
161
+
162
+ // Gecko.
163
+ if (browser.gecko) {
164
+ var geckoRelease = agent.match(/rv:([\d\.]+)/);
165
+ if (geckoRelease) {
166
+ geckoRelease = geckoRelease[1].split(".");
167
+ version =
168
+ geckoRelease[0] * 10000 +
169
+ (geckoRelease[1] || 0) * 100 +
170
+ (geckoRelease[2] || 0) * 1;
171
+ }
172
+ }
173
+
174
+ /**
175
+ * @property { Number } chrome 检测当前浏览器是否为Chrome, 如果是,则返回Chrome的大版本号
176
+ * @warning 如果浏览器不是chrome, 则该值为undefined
177
+ * @example
178
+ * ```javascript
179
+ * if ( UE.browser.chrome ) {
180
+ * console.log( '当前浏览器是Chrome' );
181
+ * }
182
+ * ```
183
+ */
184
+ if (/chrome\/(\d+\.\d)/i.test(agent)) {
185
+ browser.chrome = +RegExp["\x241"];
186
+ }
187
+
188
+ /**
189
+ * @property { Number } safari 检测当前浏览器是否为Safari, 如果是,则返回Safari的大版本号
190
+ * @warning 如果浏览器不是safari, 则该值为undefined
191
+ * @example
192
+ * ```javascript
193
+ * if ( UE.browser.safari ) {
194
+ * console.log( '当前浏览器是Safari' );
195
+ * }
196
+ * ```
197
+ */
198
+ if (
199
+ /(\d+\.\d)?(?:\.\d)?\s+safari\/?(\d+\.\d+)?/i.test(agent) &&
200
+ !/chrome/i.test(agent)
201
+ ) {
202
+ browser.safari = +(RegExp["\x241"] || RegExp["\x242"]);
203
+ }
204
+
205
+ // Opera 9.50+
206
+ if (browser.opera) version = parseFloat(opera.version());
207
+
208
+ // WebKit 522+ (Safari 3+)
209
+ if (browser.webkit)
210
+ version = parseFloat(agent.match(/ applewebkit\/(\d+)/)[1]);
211
+
212
+ /**
213
+ * @property { Number } version 检测当前浏览器版本号
214
+ * @remind
215
+ * <ul>
216
+ * <li>IE系列返回值为5,6,7,8,9,10等</li>
217
+ * <li>gecko系列会返回10900,158900等</li>
218
+ * <li>webkit系列会返回其build号 (如 522等)</li>
219
+ * </ul>
220
+ * @example
221
+ * ```javascript
222
+ * console.log( '当前浏览器版本号是: ' + UE.browser.version );
223
+ * ```
224
+ */
225
+ browser.version = version;
226
+
227
+ /**
228
+ * @property { boolean } isCompatible 检测当前浏览器是否能够与UEditor良好兼容
229
+ * @example
230
+ * ```javascript
231
+ * if ( UE.browser.isCompatible ) {
232
+ * console.log( '浏览器与UEditor能够良好兼容' );
233
+ * }
234
+ * ```
235
+ */
236
+ browser.isCompatible =
237
+ !browser.mobile &&
238
+ ((browser.ie && version >= 6) ||
239
+ (browser.gecko && version >= 10801) ||
240
+ (browser.opera && version >= 9.5) ||
241
+ (browser.air && version >= 1) ||
242
+ (browser.webkit && version >= 522) ||
243
+ false);