Skip to content

Commit c87f9d9

Browse files
committed
chore: update pptxtojson v1.3.0
1 parent 58c1ca0 commit c87f9d9

File tree

5 files changed

+38
-26
lines changed

5 files changed

+38
-26
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,9 @@ If you wish to use this project for commercial gain, I hope you will respect ope
198198
- 你给本项目提交过重要的 PR 并且被合并(由作者主观判断);
199199
- 你长期参与到本项目的维护/推进工作中,如为本项目:提供了有效的周边工具、制作了大量模板等(由作者主观判断);
200200
3. [邮件联系作者](mailto:[email protected])付费获取独立的商业授权。独立授权价格:
201-
- 一年1999(无发票)
202-
- 三年2999(无发票)
203-
- 永久5499(无发票)
204-
- 永久6999(可开电子发票)
201+
- 一年1999(2599可开具电子发票)
202+
- 三年2999(3999可开具电子发票)
203+
- 永久5499(7499可开具电子发票)
205204
- 如需付费获取独立的商业授权,请注意:
206205
- 独立商业授权的意思是:单独授权您将代码用于商业行为,且不必执行 AGPL-3.0 协议;
207206
- 不提供额外的“高级版本”和技术支持,也不提供可直接交付的产品;

README_zh.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,9 @@ npm run dev
182182
- 你给本项目提交过重要的 PR 并且被合并(由作者主观判断);
183183
- 你长期参与到本项目的维护/推进工作中,如为本项目:提供了有效的周边工具、制作了大量模板等(由作者主观判断);
184184
3. [邮件联系作者](mailto:[email protected])付费获取独立的商业授权。独立授权价格:
185-
- 一年1999(无发票)
186-
- 三年2999(无发票)
187-
- 永久5499(无发票)
188-
- 永久6999(可开电子发票)
185+
- 一年1999(2599可开具电子发票)
186+
- 三年2999(3999可开具电子发票)
187+
- 永久5499(7499可开具电子发票)
189188
- 如需付费获取独立的商业授权,请注意:
190189
- 独立商业授权的意思是:单独授权您将代码用于商业行为,且不必执行 AGPL-3.0 协议;
191190
- 不提供额外的“高级版本”和技术支持,也不提供可直接交付的产品;

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"number-precision": "^1.6.0",
3030
"pinia": "^2.1.7",
3131
"pptxgenjs": "^3.12.0",
32-
"pptxtojson": "^1.2.2",
32+
"pptxtojson": "^1.3.0",
3333
"prosemirror-commands": "^1.6.0",
3434
"prosemirror-dropcursor": "^1.8.1",
3535
"prosemirror-gapcursor": "^1.3.2",

src/hooks/useImport.ts

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default () => {
6666
reader.readAsText(file)
6767
}
6868

69-
const parseLineElement = (el: Shape) => {
69+
const parseLineElement = (el: Shape, ratio: number) => {
7070
let start: [number, number] = [0, 0]
7171
let end: [number, number] = [0, 0]
7272

@@ -90,7 +90,7 @@ export default () => {
9090
const data: PPTLineElement = {
9191
type: 'line',
9292
id: nanoid(10),
93-
width: el.borderWidth || 1,
93+
width: +((el.borderWidth || 1) * ratio).toFixed(2),
9494
left: el.left,
9595
top: el.top,
9696
start,
@@ -242,7 +242,7 @@ export default () => {
242242
lineHeight: 1,
243243
outline: {
244244
color: el.borderColor,
245-
width: el.borderWidth,
245+
width: +(el.borderWidth * ratio).toFixed(2),
246246
style: el.borderType,
247247
},
248248
fill: el.fill.type === 'color' ? el.fill.value : '',
@@ -317,7 +317,7 @@ export default () => {
317317
}
318318
else if (el.type === 'shape') {
319319
if (el.shapType === 'line' || /Connector/.test(el.shapType)) {
320-
const lineElement = parseLineElement(el)
320+
const lineElement = parseLineElement(el, ratio)
321321
slide.elements.push(lineElement)
322322
}
323323
else {
@@ -358,7 +358,7 @@ export default () => {
358358
rotate: el.rotate,
359359
outline: {
360360
color: el.borderColor,
361-
width: el.borderWidth,
361+
width: +(el.borderWidth * ratio).toFixed(2),
362362
style: el.borderType,
363363
},
364364
text: {
@@ -453,7 +453,21 @@ export default () => {
453453
data.push(rowCells)
454454
}
455455

456-
const colWidths: number[] = new Array(col).fill(1 / col)
456+
const allWidth = el.colWidths.reduce((a, b) => a + b, 0)
457+
const colWidths: number[] = el.colWidths.map(item => item / allWidth)
458+
459+
const firstCell = el.data[0][0]
460+
const border = firstCell.borders.top ||
461+
firstCell.borders.bottom ||
462+
el.borders.top ||
463+
el.borders.bottom ||
464+
firstCell.borders.left ||
465+
firstCell.borders.right ||
466+
el.borders.left ||
467+
el.borders.right
468+
const borderWidth = border?.borderWidth || 0
469+
const borderStyle = border?.borderType || 'solid'
470+
const borderColor = border?.borderColor || '#eeece1'
457471

458472
slide.elements.push({
459473
type: 'table',
@@ -466,11 +480,11 @@ export default () => {
466480
rotate: 0,
467481
data,
468482
outline: {
469-
width: el.borderWidth || 2,
470-
style: el.borderType,
471-
color: el.borderColor || '#eeece1',
483+
width: +(borderWidth * ratio || 2).toFixed(2),
484+
style: borderStyle,
485+
color: borderColor,
472486
},
473-
cellMinHeight: 36,
487+
cellMinHeight: el.rowHeights[0] ? el.rowHeights[0] * ratio : 36,
474488
})
475489
}
476490
else if (el.type === 'chart') {

0 commit comments

Comments
 (0)