Skip to content

Commit

Permalink
Added shapeName to shapes (Issue #724)
Browse files Browse the repository at this point in the history
  • Loading branch information
gitbrent committed Jun 28, 2020
1 parent 6c602a9 commit 3e48f55
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ jsdoc details for everything other than charts (maybe next time...)
- Lots of poorly named options have been deprecated and new, much better names created
- Unfotunately, `fill` no longer accepts a plain string and there was no smooth way to make that backwards compatible (sorry!)

## [3.3.0] - 2020-06-??
## [3.3.0] - 2020-07-??
### BREAKING CHANGES
- **TypeScript users**: `fill` property no longer accepts strings, only `ShapeFill` type now (sorry!)
- **All Users**: table and textbox text may break differently after a major rewrite to correct long-standing issues with alignment/breakLine, etc.
### Added
- Added: Auto-Paging finally comes to `addTable()` [\#262](https://github.com/gitbrent/PptxGenJS/issues/262) ([okaiyong](https://github.com/okaiyong))
- Added: Chart DataTable formatting `dataTableFormatCode` and `valLabelFormatCode` [\#489](https://github.com/gitbrent/PptxGenJS/issues/489)[phobos7000](https://github.com/phobos7000)) [\#684](https://github.com/gitbrent/PptxGenJS/pull/684)[hanzi](https://github.com/hanzi))
- Added: Background image for slides (deprecated `bkgd:string` with `background:BkgdOpts`) [\#610](https://github.com/gitbrent/PptxGenJS/pull/610) ([thomasowow](https://github.com/thomasowow))
- Added: `shapeName` to objects instead of default [\#724](https://github.com/gitbrent/PptxGenJS/issues/724)[Offbeatmammal](https://github.com/Offbeatmammal))
- Added: valAxisDisplayUnitLabel Option [\#765](https://github.com/gitbrent/PptxGenJS/pull/765)[hysh](https://github.com/hysh))
### Changed
- Aded: Set a hyperlink on a shape [\#767](https://github.com/gitbrent/PptxGenJS/issues/767)[CroniD](https://github.com/CroniD))
Expand Down
2 changes: 1 addition & 1 deletion demos/common/demos.js
Original file line number Diff line number Diff line change
Expand Up @@ -2644,7 +2644,7 @@ function genSlides_Shape(pptx) {
slide.addShape(pptx.shapes.LINE, { x: 4.2, y: 5.6, w: 5.0, h: 0.0, line: { color: 'FF0000', width: 4, beginArrowType: 'diamond', endArrowType: 'oval' } });
slide.addShape(pptx.shapes.LINE, { x: 5.7, y: 3.3, w: 2.5, h: 0.0, line: { width: 1 }, rotate: (360 - 45) }); // DIAGONAL Line // TEST:no line.color
//
slide.addShape(pptx.shapes.RIGHT_TRIANGLE, { x: 0.4, y: 4.3, w: 6.0, h: 3.0, fill: { color: '0088CC' }, line: { color: '000000', width: 3 } });
slide.addShape(pptx.shapes.RIGHT_TRIANGLE, { x: 0.4, y: 4.3, w: 6.0, h: 3.0, fill: { color: '0088CC' }, line: { color: '000000', width: 3 }, shapeName:'First Right Triangle' });
slide.addShape(pptx.shapes.RIGHT_TRIANGLE, { x: 7.0, y: 4.3, w: 6.0, h: 3.0, fill: { color: '0088CC' }, line: { color: '000000', width: 2 }, flipH: true });

// SLIDE 2: Misc Shape Types with Text
Expand Down
7 changes: 7 additions & 0 deletions src/core-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,13 @@ export interface ShapeOptions extends PositionOptions {
* TODO: need new demo.js entry for shape shadow
*/
shadow?: ShadowOptions
/**
* Shape name
* - used instead of default "Shape N" name
* @since v3.3.0
* @example 'Antenna Design 9'
*/
shapeName?: string

/**
* @depreacted v3.3.0
Expand Down
4 changes: 3 additions & 1 deletion src/gen-xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ function slideObjectToXml(slide: ISlideLib | ISlideLayout): string {

case SLIDE_OBJECT_TYPES.text:
case SLIDE_OBJECT_TYPES.placeholder:
let shapeName = slideItemObj.options.shapeName ? encodeXmlEntities(slideItemObj.options.shapeName) : `Object${idx + 1}`

// Lines can have zero cy, but text should not
if (!slideItemObj.options.line && cy === 0) cy = EMU * 0.3

Expand All @@ -438,7 +440,7 @@ function slideObjectToXml(slide: ISlideLib | ISlideLayout): string {
strSlideXml += '<p:sp>'

// B: The addition of the "txBox" attribute is the sole determiner of if an object is a shape or textbox
strSlideXml += `<p:nvSpPr><p:cNvPr id="${idx + 2}" name="Object${idx + 1}">`
strSlideXml += `<p:nvSpPr><p:cNvPr id="${idx + 2}" name="${shapeName}">`
// <Hyperlink>
if (slideItemObj.options.hyperlink && slideItemObj.options.hyperlink.url)
strSlideXml +=
Expand Down

0 comments on commit 3e48f55

Please sign in to comment.