<aside> 💡 This page is under construction.

</aside>

This page describes RichTextArray and its comprehension RichTextObject. First, prepare with the following code.

require "notion_ruby_mapping"
include NotionRubyMapping
NotionCache.instance.create_client ENV["NOTION_API_KEY"]

page = Page.find "7cf15acf858d40ee83a5eab78125a986" # page_id of this page

<aside> 📝 ↑ Table of Contents

</aside>

1. RichTextArray

1.1 how to create

In NotionRubyMapping, users do not directly create a RichTextArray. RichTextArray.rich_text_array is called internally when setting text in a block or property. The following script creates a To Do block with a plain text.

<aside> 💡 example code and the result

page.append_block_children ToDoBlock.new("A single text")

In the constructor of ToDoBlock(TodoBlock.new(text_info)), the RichTextArray creates by the following script. The first argument of rich_text_array is a keyword for creating JSON. These keywords (rich_text, caption, and so on) are determined by the location where the RichTextArray is used, so they are set automatically by the library.

@rich_text_array = RichTextArray.rich_text_array "rich_text", text_info

text_info can be used the following five patterns.

  1. A single text
  2. An array of texts