Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pipipi-pikachu/pptxtojson
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.1.0
Choose a base ref
...
head repository: pipipi-pikachu/pptxtojson
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 12 commits
  • 13 files changed
  • 2 contributors

Commits on Jan 11, 2025

  1. 添加元素order属性、文本框移除空富文本内容

    hy16657 committed Jan 11, 2025
    Copy the full SHA
    f3394dd View commit details
  2. update version

    pipipi-pikachu committed Jan 11, 2025
    Copy the full SHA
    27a1838 View commit details
  3. update

    pipipi-pikachu committed Jan 11, 2025
    Copy the full SHA
    c6ee766 View commit details

Commits on Jan 12, 2025

  1. fix: 仅检查文本框中的无效内容

    pipipi-pikachu committed Jan 12, 2025
    Copy the full SHA
    b2de617 View commit details

Commits on Mar 10, 2025

  1. Copy the full SHA
    65ba36c View commit details
  2. Copy the full SHA
    b85bae0 View commit details
  3. Copy the full SHA
    8da0807 View commit details

Commits on Mar 11, 2025

  1. 形状填充图片透明度

    hy16657 committed Mar 11, 2025
    Copy the full SHA
    a36d5dd View commit details
  2. 输出幻灯片主题色

    hy16657 committed Mar 11, 2025
    Copy the full SHA
    44b44e4 View commit details

Commits on Mar 12, 2025

  1. 图表颜色信息

    hy16657 committed Mar 12, 2025
    Copy the full SHA
    d2a53a8 View commit details
  2. Copy the full SHA
    4a68a8c View commit details
  3. version: 1.2.0

    hy16657 committed Mar 12, 2025
    Copy the full SHA
    b73ee58 View commit details
Showing with 388 additions and 264 deletions.
  1. +14 −10 README.md
  2. +45 −30 dist/index.d.ts
  3. +1 −1 dist/index.js
  4. +1 −1 dist/index.js.map
  5. +1 −1 dist/index.umd.js
  6. +1 −1 dist/index.umd.js.map
  7. +2 −2 package.json
  8. +41 −1 src/chart.js
  9. +72 −37 src/fill.js
  10. +187 −172 src/pptxtojson.js
  11. +8 −4 src/readXmlFile.js
  12. +6 −2 src/table.js
  13. +9 −2 src/utils.js
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -9,9 +9,9 @@

# 🎯 注意事项
### ⚒️ 使用场景
本仓库诞生于项目 [PPTist](https://github.com/pipipi-pikachu/PPTist) ,希望为其“导入 .pptx 文件功能”提供一个参考示例。不过就目前来说,解析出来的PPT信息与源文件在样式上还是存在不少差距,还不足以直接运用到生产环境中。
本仓库诞生于项目 [PPTist](https://github.com/pipipi-pikachu/PPTist) ,希望为其“导入 .pptx 文件功能”提供一个参考示例。不过就目前来说,解析出来的PPT信息与源文件在样式上还是存在差距,还不足以直接运用到生产环境中。

但如果你只是需要提取PPT文件的文本内容和媒体资源信息,对排版精准度/样式信息没有特别高的要求,那么 pptxtojson 可能会对你有一些帮助
但如果你只是需要提取PPT文件的文本内容、媒体资源信息、结构信息等,对排版/样式精准度没有特别高的要求,那么 pptxtojson 可能会对你有帮助

### 📏 长度值单位
输出的JSON中,所有数值长度值单位都为`pt`(point)
@@ -60,8 +60,11 @@ document.querySelector('input').addEventListener('change', evt => {
"borderWidth": 1,
"borderType": "solid",
"borderStrokeDasharray": 0,
"fillColor": "#5b9bd5",
"content": "<p style=\"text-align: center;\"><span style=\"font-size: 18pt;font-family: Calibri;\">TEST</span></p>",
"fill": {
"type": "color",
"value": "#FF0000"
},
"content": "<p style=\"text-align: center;\"><span style=\"font-size: 18px;font-family: Calibri;\">TEST</span></p>",
"isFlipV": false,
"isFlipH": false,
"rotate": 0,
@@ -83,18 +86,18 @@ document.querySelector('input').addEventListener('change', evt => {

# 📕 完整功能支持

### 幻灯片主题色 `themeColors`

### 幻灯片尺寸 `size`
- 幻灯片宽度 `width`
- 幻灯片高度 `height`

### 幻灯片页面 `slides`
#### 页面背景填充 `fill`
- 背景类型(颜色、图片、渐变) `type`
- 背景值 `value`
#### 页面背景填充(颜色、图片、渐变) `fill`

#### 页面备注 `note`

#### 页面内元素 `elements`
#### 页面内元素 `elements` / 母版元素 `layoutElements`
##### 文字
- 类型 `type='text'`
- 水平坐标 `left`
@@ -106,7 +109,7 @@ document.querySelector('input').addEventListener('change', evt => {
- 边框类型(实线、点线、虚线) `borderType`
- 非实线边框样式 `borderStrokeDasharray`
- 阴影 `shadow`
- 填充色 `fillColor`
- 填充(颜色、图片、渐变) `fill`
- 内容文字(HTML富文本) `content`
- 垂直翻转 `isFlipV`
- 水平翻转 `isFlipH`
@@ -135,7 +138,7 @@ document.querySelector('input').addEventListener('change', evt => {
- 边框类型(实线、点线、虚线) `borderType`
- 非实线边框样式 `borderStrokeDasharray`
- 阴影 `shadow`
- 填充色 `fillColor`
- 填充(颜色、图片、渐变) `fill`
- 内容文字(HTML富文本) `content`
- 垂直翻转 `isFlipV`
- 水平翻转 `isFlipH`
@@ -163,6 +166,7 @@ document.querySelector('input').addEventListener('change', evt => {
- 宽度 `width`
- 高度 `height`
- 图表数据 `data`
- 图表主题色 `colors`
- 图表类型 `chartType`
- 柱状图方向 `barDir`
- 是否带数据标记 `marker`
75 changes: 45 additions & 30 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -5,6 +5,32 @@ export interface Shadow {
color: string
}

export interface ColorFill {
type: 'color'
value: string
}

export interface ImageFill {
type: 'image'
value: {
picBase64: string
opacity: number
}
}

export interface GradientFill {
type: 'gradient'
value: {
rot: number
colors: {
pos: string
color: string
}[]
}
}

export type Fill = ColorFill | ImageFill | GradientFill

export interface Shape {
type: 'shape'
left: number
@@ -16,7 +42,7 @@ export interface Shape {
borderType: 'solid' | 'dashed' | 'dotted'
borderStrokeDasharray: string
shadow?: Shadow
fillColor: string
fill: Fill
content: string
isFlipV: boolean
isFlipH: boolean
@@ -25,6 +51,7 @@ export interface Shape {
vAlign: string
path?: string
name: string
order: number
}

export interface Text {
@@ -38,14 +65,15 @@ export interface Text {
borderType: 'solid' | 'dashed' | 'dotted'
borderStrokeDasharray: string
shadow?: Shadow
fillColor: string
fill: Fill
isFlipV: boolean
isFlipH: boolean
isVertical: boolean
rotate: number
content: string
vAlign: string
name: string
order: number
}

export interface Image {
@@ -58,6 +86,7 @@ export interface Image {
rotate: number
isFlipH: boolean
isFlipV: boolean
order: number
}

export interface TableCell {
@@ -80,6 +109,7 @@ export interface Table {
borderColor: string
borderWidth: number
borderType: 'solid' | 'dashed' | 'dotted'
order: number
}

export type ChartType = 'lineChart' |
@@ -118,21 +148,25 @@ export interface CommonChart {
width: number
height: number
data: ChartItem[]
colors: string[]
chartType: Exclude<ChartType, 'scatterChart' | 'bubbleChart'>
barDir?: 'bar' | 'col'
marker?: boolean
holeSize?: string
grouping?: string
style?: string
order: number
}
export interface ScatterChart {
type: 'chart'
left: number
top: number
width: number
height: number
data: ScatterChartData,
data: ScatterChartData
colors: string[]
chartType: 'scatterChart' | 'bubbleChart'
order: number
}
export type Chart = CommonChart | ScatterChart

@@ -144,6 +178,7 @@ export interface Video {
height: number
blob?: string
src?: string
order: number
}

export interface Audio {
@@ -153,6 +188,7 @@ export interface Audio {
width: number
height: number
blob: string
order: number
}

export interface Diagram {
@@ -162,6 +198,7 @@ export interface Diagram {
width: number
height: number
elements: (Shape | Text)[]
order: number
}

export interface Math {
@@ -171,6 +208,7 @@ export interface Math {
width: number
height: number
latex: string
order: number
}

export type BaseElement = Shape | Text | Image | Table | Chart | Video | Audio | Diagram | Math
@@ -183,38 +221,14 @@ export interface Group {
height: number
rotate: number
elements: BaseElement[]
order: number
}
export type Element = BaseElement | Group

export interface SlideColorFill {
type: 'color'
value: string
}

export interface SlideImageFill {
type: 'image'
value: {
picBase64: string
opacity: number
}
}

export interface SlideGradientFill {
type: 'gradient'
value: {
rot: number
colors: {
pos: string
color: string
}[]
}
}

export type SlideFill = SlideColorFill | SlideImageFill | SlideGradientFill

export interface Slide {
fill: SlideFill
fill: Fill
elements: Element[]
layoutElements: Element[]
note: string
}

@@ -225,6 +239,7 @@ export interface Options {

export const parse: (file: ArrayBuffer, options?: Options) => Promise<{
slides: Slide[]
themeColors: string[]
size: {
width: number
height: number
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.umd.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pptxtojson",
"version": "1.1.0",
"version": "1.2.0",
"description": "A javascript tool for parsing .pptx file",
"type": "module",
"main": "./dist/index.umd.js",
@@ -24,7 +24,7 @@
"homepage": "https://github.com/pipipi-pikachu/pptxtojson",
"license": "MIT",
"publishConfig": {
"registry": "https://registry.npmjs.org"
"registry": "https://registry.npmjs.com"
},
"dependencies": {
"jszip": "^3.10.1",
Loading