A Rich Text object represents styled text content in Notion. Rich text can include annotations like bold, italic, and color, as well as links and mentions of other Notion objects.
This model accepts additional fields of type Object.
RichText
| Name | Type | Tags | Description | Getter | Setter |
|---|---|---|---|---|---|
Type |
Type2 |
Required | The type of this rich text object. | Type2 getType() | setType(Type2 type) |
Text |
Text |
Optional | Text content and optional link. Present when type is "text". | Text getText() | setText(Text text) |
Mention |
Object |
Optional | Mention content. Present when type is "mention". Can reference users, pages, databases, dates, or link previews. | Object getMention() | setMention(Object mention) |
Equation |
Equation |
Optional | Equation content in KaTeX format. Present when type is "equation". | Equation getEquation() | setEquation(Equation equation) |
Annotations |
Annotations |
Optional | Styling annotations applied to the text. | Annotations getAnnotations() | setAnnotations(Annotations annotations) |
PlainText |
String |
Required | The plain text content without annotations. | String getPlainText() | setPlainText(String plainText) |
Href |
String |
Optional | The URL of any link in the text, or null. | String getHref() | setHref(String href) |
AdditionalProperties |
Map<String, Object> |
Optional | - | Object getAdditionalProperty(String key) | additionalProperty(String key, Object value) |
import com.notion.api.ApiHelper;
import com.notion.api.models.Annotations;
import com.notion.api.models.Equation;
import com.notion.api.models.Link;
import com.notion.api.models.RichText;
import com.notion.api.models.Text;
import com.notion.api.models.Type2;
import java.io.IOException;
RichText richText = new RichText.Builder(
Type2.TEXT,
"plain_text4"
)
.text(new Text.Builder()
.content("content4")
.link(new Link.Builder()
.url("url4")
.additionalProperty("exampleAdditionalProperty", ApiHelper.deserialize("{\"key1\":\"val1\",\"key2\":\"val2\"}"))
.build())
.additionalProperty("exampleAdditionalProperty", ApiHelper.deserialize("{\"key1\":\"val1\",\"key2\":\"val2\"}"))
.build())
.mention(ApiHelper.deserialize("{\"key1\":\"val1\",\"key2\":\"val2\"}"))
.equation(new Equation.Builder()
.expression("expression2")
.additionalProperty("exampleAdditionalProperty", ApiHelper.deserialize("{\"key1\":\"val1\",\"key2\":\"val2\"}"))
.build())
.annotations(new Annotations.Builder()
.bold(false)
.italic(false)
.strikethrough(false)
.underline(false)
.code(false)
.additionalProperty("exampleAdditionalProperty", ApiHelper.deserialize("{\"key1\":\"val1\",\"key2\":\"val2\"}"))
.build())
.href("href4")
.additionalProperty("exampleAdditionalProperty", ApiHelper.deserialize("{\"key1\":\"val1\",\"key2\":\"val2\"}"))
.build();