googleapis / googleapis/google-api-nodejs-client

Documents API: Format existing text to title in a document

Open
#3,180 0 comments 0 reactions 0 assignees View on GitHub
priority: p3 type: question
Dominant language
TypeScript
Stars
12.2k
Forks
2k
Avg merge
1d 9h
Merged PRs (30d)
24

Description

I am trying to format existing text in a document into a title using the API.
(Like Format > Paragraph style > Title > Apply 'Title')
Screenshot 2023-03-10 at 18 03 09

I tried using `batchUpdate` with `updateTextStyle ` and `updateParagraphStyle`
request examples.
```
updateParagraphStyle: {
range: {
startIndex:index,
endIndex: index + 1
},
paragraphStyle: {
namedStyledType: 'TITLE'
},
fields: 'namedStyleType',
}
```
```
updateTextStyle: {
range: {
startIndex: element.startIndex + textIndex,
endIndex: element.startIndex + textIndex + 'test'.length,
},
textStyle: {
namedStyledType: 'TITLE'
},
fields: 'namedStyleType',
}
```
I get an error `"Invalid JSON payload received. Unknown name \"namedStyledType\" at 'requests[0].update_paragraph_style.paragraph_style': Cannot find field."
` , and similar for `updateTextStyle`.

Is this even posible to do trough the api? I can't find anything helpfull in the docs or typescript docs.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.