mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
perf: 更新pptxtojson版本,更新导入PPTX demo
This commit is contained in:
parent
483547854a
commit
aeee2b25d2
14
package-lock.json
generated
14
package-lock.json
generated
@ -23,7 +23,7 @@
|
||||
"number-precision": "^1.6.0",
|
||||
"pinia": "^2.1.7",
|
||||
"pptxgenjs": "^3.12.0",
|
||||
"pptxtojson": "^0.1.2",
|
||||
"pptxtojson": "^0.1.3",
|
||||
"prosemirror-commands": "^1.5.2",
|
||||
"prosemirror-dropcursor": "^1.8.1",
|
||||
"prosemirror-gapcursor": "^1.3.2",
|
||||
@ -4011,9 +4011,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/pptxtojson": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmmirror.com/pptxtojson/-/pptxtojson-0.1.2.tgz",
|
||||
"integrity": "sha512-UvzEuCnspfZqc1Tf7TU6tSyXV+4OngkTfoAEZdPVW2i6wedU16wr8hkNzwQ77ePyfoyaODAFwS9cfJnnEhwfKQ==",
|
||||
"version": "0.1.3",
|
||||
"resolved": "https://registry.npmmirror.com/pptxtojson/-/pptxtojson-0.1.3.tgz",
|
||||
"integrity": "sha512-UKtoa9jiyMyZYHTiRTPjVdnByzGK0e7xcscpMTTBSUFVKvX1dnNGfYxqyY54RxppYm10ZVb4TJhmxBLnu+M0xw==",
|
||||
"dependencies": {
|
||||
"jszip": "^3.10.1",
|
||||
"tinycolor2": "1.6.0",
|
||||
@ -8098,9 +8098,9 @@
|
||||
}
|
||||
},
|
||||
"pptxtojson": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmmirror.com/pptxtojson/-/pptxtojson-0.1.2.tgz",
|
||||
"integrity": "sha512-UvzEuCnspfZqc1Tf7TU6tSyXV+4OngkTfoAEZdPVW2i6wedU16wr8hkNzwQ77ePyfoyaODAFwS9cfJnnEhwfKQ==",
|
||||
"version": "0.1.3",
|
||||
"resolved": "https://registry.npmmirror.com/pptxtojson/-/pptxtojson-0.1.3.tgz",
|
||||
"integrity": "sha512-UKtoa9jiyMyZYHTiRTPjVdnByzGK0e7xcscpMTTBSUFVKvX1dnNGfYxqyY54RxppYm10ZVb4TJhmxBLnu+M0xw==",
|
||||
"requires": {
|
||||
"jszip": "^3.10.1",
|
||||
"tinycolor2": "1.6.0",
|
||||
|
@ -28,7 +28,7 @@
|
||||
"number-precision": "^1.6.0",
|
||||
"pinia": "^2.1.7",
|
||||
"pptxgenjs": "^3.12.0",
|
||||
"pptxtojson": "^0.1.2",
|
||||
"pptxtojson": "^0.1.3",
|
||||
"prosemirror-commands": "^1.5.2",
|
||||
"prosemirror-dropcursor": "^1.8.1",
|
||||
"prosemirror-gapcursor": "^1.3.2",
|
||||
|
@ -138,6 +138,11 @@ export default () => {
|
||||
|
||||
const parseElements = (elements: Element[]) => {
|
||||
for (const el of elements) {
|
||||
const originWidth = el.width
|
||||
const originHeight = el.height
|
||||
const originLeft = el.left
|
||||
const originTop = el.top
|
||||
|
||||
el.width = el.width * scale
|
||||
el.height = el.height * scale
|
||||
el.left = el.left * scale
|
||||
@ -178,6 +183,8 @@ export default () => {
|
||||
top: el.top,
|
||||
fixedRatio: true,
|
||||
rotate: el.rotate,
|
||||
flipH: el.isFlipH,
|
||||
flipV: el.isFlipV,
|
||||
})
|
||||
}
|
||||
else if (el.type === 'audio') {
|
||||
@ -270,7 +277,7 @@ export default () => {
|
||||
if (el.shapType === 'custom') {
|
||||
element.special = true
|
||||
element.path = el.path!
|
||||
element.viewBox = [el.width, el.height]
|
||||
element.viewBox = [originWidth, originHeight]
|
||||
}
|
||||
|
||||
slide.elements.push(element)
|
||||
@ -289,13 +296,27 @@ export default () => {
|
||||
const rowCells: TableCell[] = []
|
||||
for (let j = 0; j < col; j++) {
|
||||
const cellData = el.data[i][j]
|
||||
|
||||
let textDiv: HTMLDivElement | null = document.createElement('div')
|
||||
textDiv.innerHTML = cellData.text
|
||||
const p = textDiv.querySelector('p')
|
||||
const align = p?.style.textAlign || 'left'
|
||||
const fontsize = p?.style.fontSize || ''
|
||||
const fontname = p?.style.fontFamily || ''
|
||||
|
||||
rowCells.push({
|
||||
id: nanoid(10),
|
||||
colspan: cellData.colSpan || 1,
|
||||
rowspan: cellData.rowSpan || 1,
|
||||
text: cellData.text,
|
||||
style,
|
||||
text: textDiv.innerText,
|
||||
style: {
|
||||
...style,
|
||||
align: ['left', 'right', 'center'].includes(align) ? (align as 'left' | 'right' | 'center') : 'left',
|
||||
fontsize,
|
||||
fontname,
|
||||
},
|
||||
})
|
||||
textDiv = null
|
||||
}
|
||||
data.push(rowCells)
|
||||
}
|
||||
@ -397,8 +418,8 @@ export default () => {
|
||||
else if (el.type === 'group' || el.type === 'diagram') {
|
||||
const elements = el.elements.map(_el => ({
|
||||
..._el,
|
||||
left: _el.left + el.left,
|
||||
top: _el.top + el.top,
|
||||
left: _el.left + originLeft,
|
||||
top: _el.top + originTop,
|
||||
}))
|
||||
parseElements(elements)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user