zydx-plus 1.32.298 → 1.32.300

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.298",
3
+ "version": "1.32.300",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -9,13 +9,13 @@ export function butJson (editor,data) {
9
9
  menuKeys: []
10
10
  },
11
11
  titleMenu: {
12
- name: '添加标题',
12
+ name: '字体',
13
13
  key: 'titleMenu',
14
14
  menuKeys: [
15
- {name: '(中)黑体小4号', key: 'blackCenter4'},
16
- {name: '(左)黑体小4号', key: 'blackLeft4'},
17
- {name: '(中)黑体5号', key: 'blackCenter5'},
18
- {name: '(左)黑体5号', key: 'blackLeft5'},
15
+ {name: '微软雅黑', key: 'Microsoft Yahei'},
16
+ {name: '楷体', key: 'Kaiti'},
17
+ {name: '仿宋', key: 'FangSong'},
18
+ {name: '黑体', key: 'SimHei'},
19
19
  ],
20
20
  html: {
21
21
  blackCenter4: `<p data-signId="title-1" class="title ${randomId()}" style="text-align: center;"><span style="font-weight: 700;color: rgb(0, 0, 0);font-size: 16px;font-family: SimHei">${menusData(data,'titleMenu').text}</span></p>`,
@@ -25,17 +25,38 @@ export function butJson (editor,data) {
25
25
  }
26
26
  },
27
27
  textMenu: {
28
- name: '添加正文',
28
+ name: '字号',
29
29
  key: 'textMenu',
30
30
  menuKeys: [
31
- {name: '宋体5号', key: 'Song5'},
32
- {name: '楷体5号', key: 'regular5'},
31
+ {name: '12', key: '12px'},
32
+ {name: '14', key: '14px'},
33
+ {name: '16', key: '16px'},
34
+ {name: '18', key: '18px'},
35
+ {name: '20', key: '20px'},
36
+ {name: '22', key: '22px'},
37
+ {name: '24', key: '24px'},
38
+ {name: '26', key: '26px'},
39
+ {name: '28', key: '28px'},
40
+ {name: '30', key: '30px'},
41
+ {name: '32', key: '32px'}
33
42
  ],
34
43
  html: {
35
44
  Song5: `<p class="text" style="text-align: left;"><span style="color: rgb(0, 0, 0);font-size: 14px;font-family: SimSun">请输入正文</span></p>`,
36
45
  regular5: `<p class="text" style="text-align: left;"><span style="color: rgb(0, 0, 0);font-size: 14px;font-family: KaiTi">请输入正文</span></p>`,
37
46
  }
38
47
  },
48
+ outlineMenu: {
49
+ name: '大纲级别',
50
+ key: 'outlineMenu',
51
+ menuKeys: [
52
+ {name: '一级标题', key: 'title-1'},
53
+ {name: '二级标题', key: 'title-2'},
54
+ {name: '三级标题', key: 'title-3'},
55
+ {name: '四级标题', key: 'title-4'},
56
+ {name: '正文文本', key: 'text'},
57
+ ],
58
+ html: {}
59
+ },
39
60
  redMenu: {
40
61
  name: '添加红头',
41
62
  key: 'redMenu',
@@ -130,7 +130,8 @@ export default {
130
130
  menusStyle: {
131
131
  top: '0px',
132
132
  left: '0px'
133
- }
133
+ },
134
+ menuStast: null
134
135
  }
135
136
  },
136
137
  props: {
@@ -236,7 +237,7 @@ export default {
236
237
  Superscript, // 上标
237
238
  titleId, // 标题id
238
239
  dataUrl,
239
- BubbleMenu.configure({
240
+ BubbleMenu.configure({ // 气泡菜单
240
241
  element: document.querySelector('.menu'),
241
242
  shouldShow: ({editor, view, state, oldState, from, to}) => {
242
243
  _this.encIndex = state.selection.$from.parent.attrs
@@ -277,23 +278,66 @@ export default {
277
278
  HTMLAttributes: {
278
279
  class: 'editor-img'
279
280
  }
280
- }),
281
+ })
281
282
  ],
282
- injectCSS: true
283
- })
284
- document.addEventListener('keydown', function (e) {
285
- if (e.keyCode === 13) {
286
- // 禁止标题回车
287
- const sid = _this.editor.state.selection.$anchor.path[3].attrs.signId
288
- const ca = _this.editor.state.selection.$anchor.path[3].attrs.titleId
289
- if (sid?.split('-')[0] === 'title') {
290
- const json = _this.editor.getJSON()
291
- for (let i = 0; i < json.content.length; i++) {
292
- if (json.content[i].attrs?.titleId === ca) {
293
- json.content.splice(i + 1, 1)
294
- _this.editor?.commands.setContent(json)
295
- break
283
+ injectCSS: true,
284
+ onBlur: () => {
285
+ _this.menuStast = null
286
+ _this.butDataName('outlineMenu','大纲级别')
287
+ _this.butDataName('textMenu','字号')
288
+ _this.butDataName('titleMenu','字体')
289
+ },
290
+ onTransaction: () => {
291
+ const index = _this.editor.state.selection.$anchor.path[1]
292
+ const json = _this.editor.getJSON()
293
+ for (let i = 0; i < json.content.length; i++) {
294
+ if(index === i) {
295
+ if(json.content[i].content === undefined) break
296
+ const attrs = json.content[i].attrs
297
+ if(attrs.titleId === 'text') {
298
+ _this.butDataName('正文文本')
296
299
  }
300
+ if(attrs.signId !== null) {
301
+ _this.butData.map(x => {
302
+ if(x.key === 'outlineMenu') {
303
+ x.name = '大纲级别'
304
+ if(attrs.signId === 'title-1') x.name = '一级标题'
305
+ if(attrs.signId === 'title-2') x.name = '二级标题'
306
+ if(attrs.signId === 'title-3') x.name = '三级标题'
307
+ if(attrs.signId === 'title-4') x.name = '四级标题'
308
+ }
309
+ })
310
+ }
311
+ if(json.content[i].content[0].marks === undefined) break
312
+ const style = json.content[i].content[0].marks
313
+ style.forEach(x => {
314
+ if(x.type === 'textStyle') {
315
+ if(x.attrs.fontSize !== null) {
316
+ if(_this.menuStast !== 'textMenu') {
317
+ _this.butData.map(y => {
318
+ if(y.key === 'textMenu') {
319
+ y.name = '字号'
320
+ y.name = '字号 ' + x.attrs.fontSize.replace(/px/g, '')
321
+ }
322
+ })
323
+ }
324
+ }
325
+ if(x.attrs.fontFamily !== null) {
326
+ if(_this.menuStast !== 'titleMenu') {
327
+ _this.butData.map(y => {
328
+ if(y.key === 'titleMenu') {
329
+ y.name = '字体'
330
+ if(x.attrs.fontFamily === 'Microsoft Yahei') y.name = '字体 雅黑'
331
+ if(x.attrs.fontFamily === 'Kaiti') y.name = '字体 楷体'
332
+ if(x.attrs.fontFamily === 'FangSong') y.name = '字体 仿宋'
333
+ if(x.attrs.fontFamily === 'SimHei') y.name = '字体 黑体'
334
+ }
335
+ })
336
+ }
337
+ }
338
+ }
339
+ })
340
+ break
297
341
  }
298
342
  }
299
343
  }
@@ -302,6 +346,11 @@ export default {
302
346
  },
303
347
  emits: ['confirm', 'enclosure', 'enlDownload', 'enlSee'],
304
348
  methods: {
349
+ butDataName(n,v) {
350
+ this.butData.map(x => {
351
+ if(x.key === n) x.name = v
352
+ })
353
+ },
305
354
  // 粘贴文本处理
306
355
  preventPaste(event) {
307
356
  const text = event.clipboardData.getData('text/plain');
@@ -790,13 +839,32 @@ export default {
790
839
  }
791
840
  // 标题
792
841
  if (data.key === 'titleMenu') {
793
- const html = butJson(this.editor, this.menusText)[data.key].html[key.key]
794
- this.editor.chain().focus().insertContentAt(this.selection(), html).run()
842
+ this.menuStast = 'titleMenu'
843
+ if(key.key === 'Microsoft Yahei') {
844
+ this.butDataName('titleMenu','字体 雅黑')
845
+ }else {
846
+ this.butDataName('titleMenu',`字体 ${key.name}`)
847
+ }
848
+ this.editor.commands.setFontFamily(key.key)
795
849
  }
796
850
  // 正文
797
851
  if (data.key === 'textMenu') {
798
- const html = butJson(this.editor, this.menusText)[data.key].html[key.key]
799
- this.editor.chain().focus().insertContentAt(this.selection(), html).run()
852
+ this.menuStast = 'textMenu'
853
+ this.butDataName('textMenu',`字号 ${key.name}`)
854
+ this.editor.commands.setFontSize(key.key)
855
+ }
856
+ // 大纲级别
857
+ if (data.key === 'outlineMenu') {
858
+ if (key.key === 'text') {
859
+ this.editor.commands.setTitleId(key.key)
860
+ this.editor.commands.unsetSignId()
861
+ this.editor.chain().focus().unsetBold().run()
862
+ }else {
863
+ const t = key.key.split('-')[0]
864
+ this.editor.commands.setSignId(key.key)
865
+ this.editor.commands.setTitleId(`${t} ${this.randomId()}`)
866
+ this.editor.chain().focus().setBold().run()
867
+ }
800
868
  }
801
869
  // 作者
802
870
  if (data.key === 'authorMenu') {
@@ -902,6 +970,9 @@ export default {
902
970
  this.imgPop = true
903
971
  }
904
972
  }
973
+ setTimeout(() => {
974
+ this.menuStast = null
975
+ },1000)
905
976
  },
906
977
  cursorPosition(data, index) {
907
978
  let num = 0
@@ -1135,7 +1206,7 @@ label {
1135
1206
  }
1136
1207
 
1137
1208
  .editing-cont :deep(p) {
1138
- line-height: 24px;
1209
+ line-height: 1.7;
1139
1210
  }
1140
1211
 
1141
1212
  .editing-cont :deep(img) {
@@ -46,4 +46,4 @@ export const FontSize = Extension.create({
46
46
  },
47
47
  }
48
48
  },
49
- })
49
+ })
@@ -29,5 +29,15 @@ export const signId = Extension.create({
29
29
  },
30
30
  },
31
31
  ]
32
- }
33
- })
32
+ },
33
+ addCommands() {
34
+ return {
35
+ setSignId: (alignment) => ({ commands }) => {
36
+ return commands.updateAttributes('paragraph', { signId: alignment })
37
+ },
38
+ unsetSignId: () => ({ commands }) => {
39
+ return commands.resetAttributes('paragraph', 'signId')
40
+ },
41
+ }
42
+ },
43
+ })
@@ -1,4 +1,4 @@
1
- import { Extension } from '@tiptap/core'
1
+ import { Extension, nodeInputRule } from '@tiptap/core'
2
2
 
3
3
  export const titleId = Extension.create({
4
4
  name: 'titleId',
@@ -29,5 +29,15 @@ export const titleId = Extension.create({
29
29
  },
30
30
  },
31
31
  ]
32
- }
33
- })
32
+ },
33
+ addCommands() {
34
+ return {
35
+ setTitleId: (alignment) => ({ commands }) => {
36
+ return commands.updateAttributes('paragraph', { titleId: alignment })
37
+ },
38
+ unsetTitleId: () => ({ commands }) => {
39
+ return commands.resetAttributes('paragraph', 'titleId')
40
+ },
41
+ }
42
+ },
43
+ })
@@ -131,6 +131,8 @@ import * as PdfJs from 'pdfjs-dist/legacy/build/pdf.js' // 注意导入的写法
131
131
  PdfJs.GlobalWorkerOptions.workerSrc = require('pdfjs-dist/build/pdf.worker.entry')
132
132
  const jsdelivr = '/zydx/static/cmaps/'
133
133
 
134
+ let pdfs = null
135
+
134
136
  export default {
135
137
  name: "zydx-flip",
136
138
  data() {
@@ -188,7 +190,7 @@ export default {
188
190
  textHeight: 0,
189
191
  textDownX: 0,
190
192
  textDownY: 0,
191
- textMoveStart: false,
193
+ textMoveStart: false
192
194
  }
193
195
  },
194
196
  props: {
@@ -241,7 +243,7 @@ export default {
241
243
  },
242
244
  source: {
243
245
  handler: function () {
244
- this.readPdf()
246
+ this.sourceUrl()
245
247
  },
246
248
  deep: true,
247
249
  immediate: true
@@ -936,6 +938,7 @@ export default {
936
938
  }
937
939
  },
938
940
  flipLeft(e, v) {
941
+ console.log(e)
939
942
  if (e > this.pdfPages) {
940
943
  this.pageIndex = this.pdfPages
941
944
  return
@@ -952,6 +955,7 @@ export default {
952
955
  }
953
956
  },
954
957
  flipRight(e, v) {
958
+ console.log(e)
955
959
  if (e < 1) {
956
960
  this.pageIndex = 1
957
961
  return
@@ -967,65 +971,67 @@ export default {
967
971
  })
968
972
  }
969
973
  },
970
- readPdf(n) {
971
- this.mouse()
974
+ sourceUrl() {
972
975
  if (this.source === '' || this.source === undefined || this.source === null) return
973
976
  let that = this
974
- if(n !== 1) that.loading = true
975
- if (that.imgArr[that.pageIndex - 1] !== undefined) {
976
- that.oneShow = that.pageIndex !== 1
977
- }
977
+ that.loading = true
978
978
  const loadingTask = PdfJs.getDocument({
979
- url: this.source,
979
+ url: that.source,
980
980
  cMapUrl: jsdelivr,
981
981
  cMapPacked: true
982
982
  })
983
983
  loadingTask.promise.then((pdf) => {
984
+ pdfs = pdf
984
985
  that.pdfPages = pdf.numPages // 获取pdf文件的总页数
985
- pdf.getPage(that.pageIndex).then(function (page) {
986
- let canvas = document.getElementById(that.id)
987
- let canvas2 = document.getElementById(`${that.id}2`)
988
- that.ctx = canvas.getContext('2d');
989
- let ctx2 = canvas2.getContext('2d');
990
- let viewport = page.getViewport({scale: that.scales})
991
- canvas.width = viewport.width * that.sratio
992
- canvas.height = viewport.height * that.sratio
993
- canvas.style.width = viewport.width + 'px'
994
- canvas.style.height = viewport.height + 'px'
995
- canvas2.width = viewport.width * that.sratio
996
- canvas2.height = viewport.height * that.sratio
997
- canvas2.style.width = viewport.width + 'px'
998
- canvas2.style.height = viewport.height + 'px'
999
- that.canvasStyle = {
1000
- width: viewport.width + 'px',
1001
- height: viewport.height + 'px',
1002
- marginLeft: -(viewport.width / 2) + 'px',
1003
- widthCanvas: viewport.width * that.sratio,
1004
- heightCanvas: viewport.height * that.sratio
1005
- }
1006
- let renderContext = {
1007
- canvasContext: ctx2,
1008
- viewport: viewport,
1009
- transform: [2, 0, 0, 2, 0, 0] //这里会进行放大,解决模糊问题
1010
- }
1011
- page.render(renderContext)
1012
- that.loading = false
1013
- if (that.oneIndex === 'right') {
1014
- that.flipRights = true
1015
- that.flipLefts = false
1016
- } else {
1017
- that.flipRights = false
1018
- that.flipLefts = true
1019
- }
1020
- // 获取canvas的base64数据
1021
- setTimeout(() => {
1022
- that.flipRights = false
1023
- that.flipLefts = false
1024
- that.oneShow = false
1025
- that.imgArr[that.pageIndex] = canvas2.toDataURL('image/jpeg', 1)
1026
- that.processing()
1027
- }, 1000)
1028
- })
986
+ that.readPdf(pdf)
987
+ })
988
+ },
989
+ readPdf() {
990
+ let that = this
991
+ this.mouse()
992
+ pdfs.getPage(that.pageIndex).then(function (page) {
993
+ let canvas = document.getElementById(that.id)
994
+ let canvas2 = document.getElementById(`${that.id}2`)
995
+ that.ctx = canvas.getContext('2d');
996
+ let ctx2 = canvas2.getContext('2d');
997
+ let viewport = page.getViewport({scale: that.scales})
998
+ canvas.width = viewport.width * that.sratio
999
+ canvas.height = viewport.height * that.sratio
1000
+ canvas.style.width = viewport.width + 'px'
1001
+ canvas.style.height = viewport.height + 'px'
1002
+ canvas2.width = viewport.width * that.sratio
1003
+ canvas2.height = viewport.height * that.sratio
1004
+ canvas2.style.width = viewport.width + 'px'
1005
+ canvas2.style.height = viewport.height + 'px'
1006
+ that.canvasStyle = {
1007
+ width: viewport.width + 'px',
1008
+ height: viewport.height + 'px',
1009
+ marginLeft: -(viewport.width / 2) + 'px',
1010
+ widthCanvas: viewport.width * that.sratio,
1011
+ heightCanvas: viewport.height * that.sratio
1012
+ }
1013
+ let renderContext = {
1014
+ canvasContext: ctx2,
1015
+ viewport: viewport,
1016
+ transform: [2, 0, 0, 2, 0, 0] //这里会进行放大,解决模糊问题
1017
+ }
1018
+ page.render(renderContext)
1019
+ that.loading = false
1020
+ if (that.oneIndex === 'right') {
1021
+ that.flipRights = true
1022
+ that.flipLefts = false
1023
+ } else {
1024
+ that.flipRights = false
1025
+ that.flipLefts = true
1026
+ }
1027
+ // 获取canvas的base64数据
1028
+ setTimeout(() => {
1029
+ that.flipRights = false
1030
+ that.flipLefts = false
1031
+ that.oneShow = false
1032
+ that.imgArr[that.pageIndex] = canvas2.toDataURL('image/jpeg', 1)
1033
+ that.processing()
1034
+ }, 1000)
1029
1035
  })
1030
1036
  }
1031
1037
  }
@@ -1251,7 +1257,7 @@ export default {
1251
1257
  display: inline-block;
1252
1258
  margin: 0 auto;
1253
1259
  position: relative;
1254
- //cursor: none;
1260
+ //cursor: none;
1255
1261
  }
1256
1262
 
1257
1263
  .but-wrap {
package/src/index.js CHANGED
@@ -81,7 +81,7 @@ function install(app) {
81
81
  }
82
82
 
83
83
  export default {
84
- version: '1.32.298',
84
+ version: '1.32.300',
85
85
  install,
86
86
  Calendar,
87
87
  Message,