Character style 'strong' for TextRun
See original GitHub issueI have a paragraph block which has two TextRun
s in it, for example:
new Paragraph ({
children: [
new TextRun({
text: "First Word",
bold: true
}),
new TextRun(" - This text was created using heading 3 paragraph style. It has a slight left indentation for lines except the first one.")
]
})
Currently I am using the bold parameter but I want to use the “strong” character style. This is because styles can be manipulated from Design > Quick Parts > Field
. Any way to do this?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Editing and styling text | Apps Script - Google Developers
A text run is a segment of text where all the characters have the same text style. Text styling. Text style determines the...
Read more >Retain italics & bold using paragraph styles
The italics and bold etc. don't have a character style - that's why when you apply the paragraph style it overrides the italics...
Read more >Text-related objects — python-docx 0.8.11 documentation
Append a run to this paragraph containing text and having character style identified by style ID style. text can contain tab ( \t...
Read more >How can I create a character style so that it will only have a
In an interesting thread I just read about character styles, Suzanne S. Barnhill ... Those are the Strong and Emphasis character styles.
Read more >docx/styling-with-js.md at master · dolanmiu/docx - GitHub
Characters : Attributes that can change within a paragraph. e.g., bold, italics, etc. Paragraphs: Attributes like indent, text alignment, line spacing, etc.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
in
5.5.0
in the next releasemaybe in a few weeks time
That’s difficult to implement because last element of the array may not be the last element of the page. On every page, headers should reflect word heading of that particular page only. If you download and check the doc file I previously posted you’ll notice that the headers are dynamic. They are different for every page and only correspond to words in that particular page.
Word provides this feature. To place dynamic components like these in word, I can simply go to
Design > Quick Parts > Field >> StyleRef > strong
. This will automatically select the firststrong
styled phrase of the page (there’s another option to select laststrong
styled phrase as well).However,
StyleRef
requires paragraph or header styles. Butbold
is not a style and hence is not selectable. We need astrong
style, which is the reason for this thread.In the word file I posted, you’ll find that the paragraph style is
Normal
but the first word has character stylestrong
. This is why I am able to create the dynamic headers.With docx plugin, I am not able to set character style to strong. I created a docx file using version 5.5.0 and the following code for the first word from here:
Once the doc is created, If i select the word and check the style, it still shows
Normal
notStrong
. If I can set character style toStrong
that would solve first part of the problem for now at least.