Skip to content

Commit 7c778ec

Browse files
committed
added textDirection for text/table cells
1 parent 8c697bb commit 7c778ec

File tree

6 files changed

+29
-7
lines changed

6 files changed

+29
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
## [3.13.0] - 2023-0?-0?
1111

12+
- Added `textDirection` property for text and table cells to allow vertical rotation of text ([gitbrent](https://github.com/gitbrent))
13+
1214
## [3.12.0] - 2023-03-19
1315

1416
### Added

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pptxgenjs",
3-
"version": "3.13.0-beta",
3+
"version": "3.13.0-beta.0",
44
"author": {
55
"name": "Brent Ely",
66
"url": "https://github.com/gitbrent/"

src/core-interfaces.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,15 @@ export interface TextBaseProps {
391391
* @example [{ position:1 }, { position:3 }] // Set first tab stop to 1 inch, set second tab stop to 3 inches
392392
*/
393393
tabStops?: Array<{ position: number, alignment?: 'l' | 'r' | 'ctr' | 'dec' }>
394+
/**
395+
* text direction
396+
* `horz` = horizontal
397+
* `vert` = rotate 90^
398+
* `vert270` = rotate 270^
399+
* `wordArtVert` = stacked
400+
* @default 'horz'
401+
*/
402+
textDirection?: 'horz' | 'vert' | 'vert270' | 'wordArtVert'
394403
/**
395404
* Transparency (percent)
396405
* - MS-PPT > Format Shape > Text Options > Text Fill & Outline > Text Fill > Transparency

src/gen-xml.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,13 +299,15 @@ function slideObjectToXml (slide: PresSlide | SlideLayout): string {
299299

300300
// B: Inherit some options from table when cell options dont exist
301301
// @see: http://officeopenxml.com/drwTableCellProperties-alignment.php
302-
;['align', 'bold', 'border', 'color', 'fill', 'fontFace', 'fontSize', 'margin', 'underline', 'valign'].forEach(name => {
302+
;['align', 'bold', 'border', 'color', 'fill', 'fontFace', 'fontSize', 'margin', 'textDirection', 'underline', 'valign'].forEach(name => {
303303
if (objTabOpts[name] && !cellOpts[name] && cellOpts[name] !== 0) cellOpts[name] = objTabOpts[name]
304304
})
305305

306306
const cellValign = cellOpts.valign
307307
? ` anchor="${cellOpts.valign.replace(/^c$/i, 'ctr').replace(/^m$/i, 'ctr').replace('center', 'ctr').replace('middle', 'ctr').replace('top', 't').replace('btm', 'b').replace('bottom', 'b')}"`
308308
: ''
309+
const cellTextDir = (cellOpts.textDirection && cellOpts.textDirection !== 'horz') ? ` vert="${cellOpts.textDirection}"` : ''
310+
309311
let fillColor =
310312
cell._optImp?.fill?.color
311313
? cell._optImp.fill.color
@@ -335,7 +337,7 @@ function slideObjectToXml (slide: PresSlide | SlideLayout): string {
335337
// FUTURE: Cell NOWRAP property (textwrap: add to a:tcPr (horzOverflow="overflow" or whatever options exist)
336338

337339
// 4: Set CELL content and properties ==================================
338-
strXml += `<a:tc${cellSpanAttrStr}>${genXmlTextBody(cell)}<a:tcPr${cellMarginXml}${cellValign}>`
340+
strXml += `<a:tc${cellSpanAttrStr}>${genXmlTextBody(cell)}<a:tcPr${cellMarginXml}${cellValign}${cellTextDir}>`
339341
// strXml += `<a:tc${cellColspan}${cellRowspan}>${genXmlTextBody(cell)}<a:tcPr${cellMarginXml}${cellValign}${cellTextDir}>`
340342
// FIXME: 20200525: ^^^
341343
// <a:tcPr marL="38100" marR="38100" marT="38100" marB="38100" vert="vert270">

src/pptxgen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ import * as genMedia from './gen-media'
9898
import * as genTable from './gen-tables'
9999
import * as genXml from './gen-xml'
100100

101-
const VERSION = '3.13.0-beta-20230415-2112'
101+
const VERSION = '3.13.0-beta.0-20230416-2140'
102102

103103
export default class PptxGenJS implements IPresentationProps {
104104
// Property getters/setters

types/index.d.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ declare namespace PptxGenJS {
906906
* @deprecated v3.6.0 - use `DataOrPathProps` instead - remove in v4.0.0
907907
*/
908908
src?: string
909-
}
909+
}
910910
/**
911911
* Color in Hex format
912912
* @example 'FF3399'
@@ -1220,6 +1220,15 @@ declare namespace PptxGenJS {
12201220
* @example [{ position:1 }, { position:3 }] // Set first tab stop to 1 inch, set second tab stop to 3 inches
12211221
*/
12221222
tabStops?: Array<{ position: number, alignment?: 'l' | 'r' | 'ctr' | 'dec' }>
1223+
/**
1224+
* text direction
1225+
* `horz` = horizontal
1226+
* `vert` = rotate 90^
1227+
* `vert270` = rotate 270^
1228+
* `wordArtVert` = stacked
1229+
* @default 'horz'
1230+
*/
1231+
textDirection?: 'horz' | 'vert' | 'vert270' | 'wordArtVert'
12231232
/**
12241233
* Transparency (percent)
12251234
* - MS-PPT > Format Shape > Text Options > Text Fill & Outline > Text Fill > Transparency
@@ -2486,7 +2495,7 @@ declare namespace PptxGenJS {
24862495
background?: BackgroundProps
24872496
margin?: Margin
24882497
slideNumber?: SlideNumberProps
2489-
objects?: Array< | { chart: IChartOpts }
2498+
objects?: Array<| { chart: IChartOpts }
24902499
| { image: ImageProps }
24912500
| { line: ShapeProps }
24922501
| { rect: ShapeProps }
@@ -2500,7 +2509,7 @@ declare namespace PptxGenJS {
25002509
*/
25012510
text?: string
25022511
}
2503-
}>
2512+
}>
25042513

25052514
/**
25062515
* @deprecated v3.3.0 - use `background`

0 commit comments

Comments
 (0)