generated from qq15725/starter-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
339 additions
and
375 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Pptx } from '../../src' | ||
|
||
const input = document.createElement('input') | ||
document.body.appendChild(input) | ||
input.accept = '.pptx' | ||
input.type = 'file' | ||
input.onchange = async () => { | ||
const file = input.files?.[0] | ||
|
||
const pptx = Pptx.parse(new Uint8Array(await file?.arrayBuffer())) | ||
|
||
console.log(pptx.slides[0].elements) | ||
|
||
console.log(pptx) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { defineProperty, XmlObject } from '../../core' | ||
|
||
export class Default extends XmlObject { | ||
readonly tag = 'Default' | ||
|
||
@defineProperty('ContentType', 'string') declare contentType: string | ||
@defineProperty('Extension', 'string') declare extension: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { defineProperty, XmlObject } from '../../core' | ||
|
||
export class Override extends XmlObject { | ||
readonly tag = 'Override' | ||
|
||
@defineProperty('ContentType', 'string') declare contentType: string | ||
@defineProperty('PartName', 'string') declare partName: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,9 @@ | ||
import { defineProperty, XmlObject } from '../../core' | ||
|
||
const RELATIONSHIP = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships' | ||
|
||
export interface RelationshipProperties { | ||
id: string | ||
type: string | ||
target: string | ||
} | ||
|
||
export class Relationship extends XmlObject { | ||
readonly tag = 'Relationship' | ||
|
||
@defineProperty('Id', 'string') declare id: string | ||
@defineProperty('Type', 'string') declare type: string | ||
@defineProperty('Target', 'string') declare target: string | ||
|
||
constructor(properties: Partial<RelationshipProperties> = {}) { | ||
super() | ||
this.setProperties(properties) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,36 @@ | ||
import type { RelationshipProperties } from './Relationship' | ||
import { XmlObject } from '../../core' | ||
import { defineChild, XmlObject } from '../../core' | ||
import { Relationship } from './Relationship' | ||
|
||
export class Relationships extends XmlObject { | ||
static officeDocument = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships' | ||
static package = 'http://schemas.openxmlformats.org/package/2006/relationships' | ||
static types = { | ||
presentation: `${this.officeDocument}/officeDocument`, | ||
app: `${this.officeDocument}/extended-properties`, | ||
core: `${this.package}/metadata/core-properties`, | ||
custom: `${this.officeDocument}/custom-properties`, | ||
slide: `${this.officeDocument}/slide`, | ||
slideLayout: `${this.officeDocument}/slideLayout`, | ||
slideMaster: `${this.officeDocument}/slideMaster`, | ||
theme: `${this.officeDocument}/theme`, | ||
tags: `${this.officeDocument}/tags`, | ||
tableStyles: `${this.officeDocument}/tableStyles`, | ||
presProps: `${this.officeDocument}/presProps`, | ||
viewProps: `${this.officeDocument}/viewProps`, | ||
notesMaster: `${this.officeDocument}/notesMaster`, | ||
handoutMaster: `${this.officeDocument}/handoutMaster`, | ||
commentAuthors: `${this.officeDocument}/commentAuthors`, | ||
} | ||
|
||
readonly tag = 'Relationships' | ||
|
||
attrs = { | ||
xmlns: 'http://schemas.openxmlformats.org/package/2006/relationships', | ||
} | ||
|
||
relationships: Relationship[] | ||
@defineChild('Relationship', Relationship, true) declare children: Relationship[] | ||
|
||
constructor(relationships: Partial<RelationshipProperties>[] = []) { | ||
super() | ||
this.relationships = relationships.map((v, index) => { | ||
return new Relationship({ id: `rId${index + 1}`, ...v }) | ||
}) | ||
get value(): { id: string, type: string, target: string }[] { | ||
return this.children.map(v => ({ id: v.id, type: v.type, target: v.target })) | ||
} | ||
} |
Oops, something went wrong.