Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text run background color (i.e. highlight) #857

Merged
merged 2 commits into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/core-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,12 @@ export interface TextBaseProps {
* @example 'pptxgen.SchemeColor.text1' // Text1 Theme Color
*/
color?: Color
/**
* Highlight color. background for text run.
* - `HexColor`
* @example 'FF0000' // red
*/
highlight?: HexColor;
/**
* Font face name
* @example 'Arial' // Arial font
Expand Down
3 changes: 2 additions & 1 deletion src/gen-xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -954,12 +954,13 @@ function genXmlTextRunProperties(opts: ObjectOptions | TextPropsOptions, isDefau
runProps += opts.subscript ? ' baseline="-40000"' : opts.superscript ? ' baseline="30000"' : ''
runProps += opts.charSpacing ? ' spc="' + opts.charSpacing * 100 + '" kern="0"' : '' // IMPORTANT: Also disable kerning; otherwise text won't actually expand
runProps += ' dirty="0">'
// Color / Font / Outline are children of <a:rPr>, so add them now before closing the runProperties tag
// Color / Highlight / Font / Outline are children of <a:rPr>, so add them now before closing the runProperties tag
if (opts.color || opts.fontFace || opts.outline) {
if (opts.outline && typeof opts.outline === 'object') {
runProps += `<a:ln w="${valToPts(opts.outline.size || 0.75)}">${genXmlColorSelection(opts.outline.color || 'FFFFFF')}</a:ln>`
}
if (opts.color) runProps += genXmlColorSelection(opts.color)
if (opts.highlight) runProps += `<a:highlight><a:srgbClr val="${opts.highlight}"/></a:highlight>`
if (opts.glow) runProps += `<a:effectLst>${createGlowElement(opts.glow, DEF_TEXT_GLOW)}</a:effectLst>`
if (opts.fontFace) {
// NOTE: 'cs' = Complex Script, 'ea' = East Asian (use "-120" instead of "0" - per Issue #174); ea must come first (Issue #174)
Expand Down
6 changes: 6 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,12 @@ declare namespace PptxGenJS {
* @example 'pptxgen.SchemeColor.text1' // Text1 Theme Color
*/
color?: Color
/**
* Highlight color. background for text run.
* - `HexColor`
* @example 'FF0000' // red
*/
highlight?: HexColor;
/**
* Font face name
* @example 'Arial' // Arial font
Expand Down