Skip to content
Open
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
1 change: 1 addition & 0 deletions custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ type FontStyleNames =
| 'fills'
| 'textStyleId'
| 'fillStyleId'
| 'hyperlink'
15 changes: 11 additions & 4 deletions src/helpers/parseTextStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const styleFonts: FontStyleNames[] = [
'lineHeight',
'fills',
'textStyleId',
'fillStyleId'
'fillStyleId',
'hyperlink'
]

/*
Expand All @@ -25,7 +26,7 @@ const styleFonts: FontStyleNames[] = [

Returns styles for the entire text:
parseTextStyle(textNode)

Returns text styles from the 100th to the last character:
parseTextStyle(textNode, 100)

Expand Down Expand Up @@ -65,7 +66,13 @@ function parseTextStyle(

// collection of styles
names.forEach((n, i) => {
letter[styleName[i]] = node['getRange' + n](startIndex, endIndex)
const rangeStyleValue = node['getRange' + n](startIndex, endIndex)
if (
n.toLowerCase() !== 'hyperlink' ||
(rangeStyleValue && rangeStyleValue.constructor === Object)
) {
letter[styleName[i]] = rangeStyleValue
}
})

if (textStyle) {
Expand Down Expand Up @@ -310,7 +317,7 @@ function changeCharactersTextStyle(textStyle: LetterStyle[], characters: string)
}

/*
Function for changing properties of TextStyle.
Function for changing properties of TextStyle.
The beforeValue parameter allows you to specify the value in which the property to be changed should be.
*/

Expand Down