notion_ruby_mapping 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/notion_ruby_mapping/blocks/base.rb +51 -37
- data/lib/notion_ruby_mapping/blocks/block.rb +13 -13
- data/lib/notion_ruby_mapping/blocks/bookmark_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/breadcrumb_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/bulleted_list_item_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/callout_block.rb +10 -10
- data/lib/notion_ruby_mapping/blocks/child_base_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/child_database_block.rb +3 -3
- data/lib/notion_ruby_mapping/blocks/child_page_block.rb +3 -3
- data/lib/notion_ruby_mapping/blocks/code_block.rb +7 -7
- data/lib/notion_ruby_mapping/blocks/column_block.rb +3 -3
- data/lib/notion_ruby_mapping/blocks/column_list_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/database.rb +5 -5
- data/lib/notion_ruby_mapping/blocks/divider_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/embed_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/equation_block.rb +5 -5
- data/lib/notion_ruby_mapping/blocks/file_base_block.rb +15 -3
- data/lib/notion_ruby_mapping/blocks/file_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/heading1_block.rb +3 -3
- data/lib/notion_ruby_mapping/blocks/heading2_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/heading3_block.rb +3 -3
- data/lib/notion_ruby_mapping/blocks/image_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/link_preview_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/link_to_page_block.rb +5 -5
- data/lib/notion_ruby_mapping/blocks/list.rb +21 -21
- data/lib/notion_ruby_mapping/blocks/numbered_list_item_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/page.rb +8 -8
- data/lib/notion_ruby_mapping/blocks/paragraph_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/pdf_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/quote_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/synced_block.rb +5 -5
- data/lib/notion_ruby_mapping/blocks/table_block.rb +8 -8
- data/lib/notion_ruby_mapping/blocks/table_of_contents_block.rb +3 -3
- data/lib/notion_ruby_mapping/blocks/table_row_block.rb +3 -3
- data/lib/notion_ruby_mapping/blocks/template_block.rb +3 -3
- data/lib/notion_ruby_mapping/blocks/text_sub_block_color_base_block.rb +4 -4
- data/lib/notion_ruby_mapping/blocks/to_do_block.rb +4 -4
- data/lib/notion_ruby_mapping/blocks/toggle_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/toggle_heading1_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/toggle_heading2_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/toggle_heading3_block.rb +3 -3
- data/lib/notion_ruby_mapping/blocks/url_base_block.rb +3 -3
- data/lib/notion_ruby_mapping/blocks/url_caption_base_block.rb +4 -4
- data/lib/notion_ruby_mapping/blocks/video_block.rb +2 -2
- data/lib/notion_ruby_mapping/controllers/mermaid.rb +2 -5
- data/lib/notion_ruby_mapping/controllers/mermaid_database.rb +29 -32
- data/lib/notion_ruby_mapping/controllers/notion_cache.rb +68 -2
- data/lib/notion_ruby_mapping/controllers/payload.rb +29 -11
- data/lib/notion_ruby_mapping/controllers/property_cache.rb +8 -9
- data/lib/notion_ruby_mapping/controllers/query.rb +14 -14
- data/lib/notion_ruby_mapping/controllers/search.rb +5 -5
- data/lib/notion_ruby_mapping/objects/comment_object.rb +2 -2
- data/lib/notion_ruby_mapping/objects/emoji_object.rb +3 -3
- data/lib/notion_ruby_mapping/objects/equation_object.rb +3 -3
- data/lib/notion_ruby_mapping/objects/file_object.rb +44 -21
- data/lib/notion_ruby_mapping/objects/file_upload_object.rb +78 -0
- data/lib/notion_ruby_mapping/objects/mention_object.rb +43 -43
- data/lib/notion_ruby_mapping/objects/rich_text_object.rb +43 -43
- data/lib/notion_ruby_mapping/objects/text_object.rb +5 -5
- data/lib/notion_ruby_mapping/objects/user_object.rb +4 -4
- data/lib/notion_ruby_mapping/properties/button_property.rb +3 -3
- data/lib/notion_ruby_mapping/properties/checkbox_property.rb +3 -3
- data/lib/notion_ruby_mapping/properties/created_by_property.rb +3 -3
- data/lib/notion_ruby_mapping/properties/created_time_property.rb +2 -2
- data/lib/notion_ruby_mapping/properties/date_base_property.rb +15 -14
- data/lib/notion_ruby_mapping/properties/date_property.rb +16 -16
- data/lib/notion_ruby_mapping/properties/email_property.rb +3 -3
- data/lib/notion_ruby_mapping/properties/files_property.rb +14 -12
- data/lib/notion_ruby_mapping/properties/formula_property.rb +7 -7
- data/lib/notion_ruby_mapping/properties/last_edited_by_property.rb +4 -3
- data/lib/notion_ruby_mapping/properties/last_edited_time_property.rb +2 -2
- data/lib/notion_ruby_mapping/properties/multi_select_property.rb +15 -15
- data/lib/notion_ruby_mapping/properties/number_property.rb +9 -9
- data/lib/notion_ruby_mapping/properties/people_property.rb +7 -7
- data/lib/notion_ruby_mapping/properties/phone_number_property.rb +3 -3
- data/lib/notion_ruby_mapping/properties/property.rb +55 -56
- data/lib/notion_ruby_mapping/properties/relation_property.rb +17 -18
- data/lib/notion_ruby_mapping/properties/rich_text_property.rb +5 -5
- data/lib/notion_ruby_mapping/properties/rollup_property.rb +15 -15
- data/lib/notion_ruby_mapping/properties/select_property.rb +14 -14
- data/lib/notion_ruby_mapping/properties/status_property.rb +5 -5
- data/lib/notion_ruby_mapping/properties/text_property.rb +1 -1
- data/lib/notion_ruby_mapping/properties/title_property.rb +7 -7
- data/lib/notion_ruby_mapping/properties/unique_id_property.rb +4 -4
- data/lib/notion_ruby_mapping/properties/url_property.rb +3 -3
- data/lib/notion_ruby_mapping/properties/verification_property.rb +3 -3
- data/lib/notion_ruby_mapping/version.rb +1 -1
- data/lib/notion_ruby_mapping.rb +1 -1
- data/notion_ruby_mapping.gemspec +2 -0
- metadata +35 -3
@@ -15,13 +15,13 @@ module NotionRubyMapping
|
|
15
15
|
@can_append = @file_object.external?
|
16
16
|
else
|
17
17
|
@file_object = FileObject.file_object url
|
18
|
-
@caption = RichTextArray.rich_text_array
|
18
|
+
@caption = RichTextArray.rich_text_array "caption", caption
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
# @see https://www.notion.so/hkob/FileBlock-08f2aa6948364d00b92beacaac9a619c#158487a7e1644fae8778dcff59869356
|
23
23
|
# @see https://www.notion.so/hkob/ImageBlock-806b3d2a9a2c4bf5a5aca6e3fbc8a7e2#19a4aa3e06514bbe84be9d3b8a45a20f
|
24
|
-
attr_reader :caption
|
24
|
+
attr_reader :caption, :file_object
|
25
25
|
|
26
26
|
# @param [Boolean] not_update false when update
|
27
27
|
# @return [Hash{String (frozen)->Hash}]
|
@@ -44,7 +44,19 @@ module NotionRubyMapping
|
|
44
44
|
# @see https://www.notion.so/hkob/ImageBlock-806b3d2a9a2c4bf5a5aca6e3fbc8a7e2#61598d260b6140f2a359f7d22ea2548a
|
45
45
|
def url=(url)
|
46
46
|
@file_object.url = url
|
47
|
-
@payload.add_update_block_key
|
47
|
+
@payload.add_update_block_key "external"
|
48
|
+
end
|
49
|
+
|
50
|
+
# @param [FileUploadObject] fuo
|
51
|
+
def file_upload_object=(fuo)
|
52
|
+
@file_object.file_upload_object = fuo
|
53
|
+
@payload.add_update_block_key "file_upload"
|
54
|
+
end
|
55
|
+
|
56
|
+
def update_file_object_from_json(json)
|
57
|
+
@file_object = FileObject.new json: json[type]
|
58
|
+
decode_block_caption
|
59
|
+
@can_append = @file_object.external?
|
48
60
|
end
|
49
61
|
end
|
50
62
|
end
|
@@ -10,16 +10,16 @@ module NotionRubyMapping
|
|
10
10
|
@can_have_children = false
|
11
11
|
end
|
12
12
|
|
13
|
-
# @return [
|
13
|
+
# @return [String]
|
14
14
|
def type
|
15
|
-
|
15
|
+
"heading_1"
|
16
16
|
end
|
17
17
|
|
18
18
|
# @param [Boolean] not_update false when update
|
19
19
|
# @return [Hash{Symbol->Hash}]
|
20
20
|
def block_json(not_update: true)
|
21
21
|
ans = super
|
22
|
-
ans[type][
|
22
|
+
ans[type]["is_toggleable"] = false
|
23
23
|
ans
|
24
24
|
end
|
25
25
|
end
|
@@ -12,14 +12,14 @@ module NotionRubyMapping
|
|
12
12
|
|
13
13
|
# @return [String (frozen)]
|
14
14
|
def type
|
15
|
-
|
15
|
+
"heading_2"
|
16
16
|
end
|
17
17
|
|
18
18
|
# @param [Boolean] not_update false when update
|
19
19
|
# @return [Hash{String (frozen)->Hash}]
|
20
20
|
def block_json(not_update: true)
|
21
21
|
ans = super
|
22
|
-
ans[type][
|
22
|
+
ans[type]["is_toggleable"] = false
|
23
23
|
ans
|
24
24
|
end
|
25
25
|
end
|
@@ -10,16 +10,16 @@ module NotionRubyMapping
|
|
10
10
|
@can_have_children = false
|
11
11
|
end
|
12
12
|
|
13
|
-
# @return [
|
13
|
+
# @return [String]
|
14
14
|
def type
|
15
|
-
|
15
|
+
"heading_3"
|
16
16
|
end
|
17
17
|
|
18
18
|
# @param [Boolean] not_update false when update
|
19
19
|
# @return [Hash{String (frozen)->Hash}]
|
20
20
|
def block_json(not_update: true)
|
21
21
|
ans = super
|
22
|
-
ans[type][
|
22
|
+
ans[type]["is_toggleable"] = false
|
23
23
|
ans
|
24
24
|
end
|
25
25
|
end
|
@@ -9,7 +9,7 @@ module NotionRubyMapping
|
|
9
9
|
def initialize(page_id: nil, database_id: nil, json: nil, id: nil, parent: nil)
|
10
10
|
super(json: json, id: id, parent: parent)
|
11
11
|
if @json
|
12
|
-
@page_id, @database_id = @json[type].values_at(*%
|
12
|
+
@page_id, @database_id = @json[type].values_at(*%w[page_id database_id])
|
13
13
|
else
|
14
14
|
@page_id = page_id
|
15
15
|
@database_id = database_id
|
@@ -25,16 +25,16 @@ module NotionRubyMapping
|
|
25
25
|
def block_json(not_update: true)
|
26
26
|
ans = super
|
27
27
|
ans[type] = if @page_id
|
28
|
-
{type
|
28
|
+
{"type" => "page_id", "page_id" => Base.page_id(@page_id)}
|
29
29
|
else
|
30
|
-
{type
|
30
|
+
{"type" => "database_id", "database_id" => Base.database_id(@database_id)}
|
31
31
|
end
|
32
32
|
ans
|
33
33
|
end
|
34
34
|
|
35
|
-
# @return [
|
35
|
+
# @return [String]
|
36
36
|
def type
|
37
|
-
|
37
|
+
"link_to_page"
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -7,21 +7,21 @@ module NotionRubyMapping
|
|
7
7
|
|
8
8
|
def initialize(json: nil, id: nil, type: nil, value: nil, query: nil)
|
9
9
|
super(json: json, id: id)
|
10
|
-
@has_more = @json[
|
10
|
+
@has_more = @json["has_more"]
|
11
11
|
@load_all_contents = !@has_more
|
12
12
|
|
13
|
-
case type
|
14
|
-
when
|
13
|
+
case type
|
14
|
+
when "comment_parent"
|
15
15
|
@comment_parent = value
|
16
|
-
when
|
16
|
+
when "database"
|
17
17
|
@database = value
|
18
|
-
when
|
18
|
+
when "parent"
|
19
19
|
@parent = value
|
20
|
-
when
|
20
|
+
when "property"
|
21
21
|
@property = value
|
22
|
-
when
|
22
|
+
when "user_object"
|
23
23
|
@user_object = value
|
24
|
-
when
|
24
|
+
when "search"
|
25
25
|
@search = value
|
26
26
|
end
|
27
27
|
@query = query
|
@@ -53,15 +53,15 @@ module NotionRubyMapping
|
|
53
53
|
@query.query_json
|
54
54
|
},
|
55
55
|
create_object: lambda { |json|
|
56
|
-
case json[
|
57
|
-
when
|
58
|
-
UserObject.new json: json[
|
59
|
-
when
|
60
|
-
json[
|
61
|
-
when
|
62
|
-
RichTextObject.create_from_json json[
|
63
|
-
when
|
64
|
-
RichTextObject.create_from_json json[
|
56
|
+
case json["type"]
|
57
|
+
when "people"
|
58
|
+
UserObject.new json: json["people"]
|
59
|
+
when "relation"
|
60
|
+
json["relation"]["id"]
|
61
|
+
when "rich_text"
|
62
|
+
RichTextObject.create_from_json json["rich_text"]
|
63
|
+
when "title"
|
64
|
+
RichTextObject.create_from_json json["title"]
|
65
65
|
else
|
66
66
|
json
|
67
67
|
end
|
@@ -97,7 +97,7 @@ module NotionRubyMapping
|
|
97
97
|
unless @load_all_contents
|
98
98
|
@query.start_cursor = nil
|
99
99
|
@json = query.call
|
100
|
-
@has_more = @json[
|
100
|
+
@has_more = @json["has_more"]
|
101
101
|
end
|
102
102
|
@index = 0
|
103
103
|
@has_content = true
|
@@ -110,10 +110,10 @@ module NotionRubyMapping
|
|
110
110
|
block.call object
|
111
111
|
elsif @has_more
|
112
112
|
if base
|
113
|
-
@query.start_cursor = @json[
|
113
|
+
@query.start_cursor = @json["next_cursor"]
|
114
114
|
@json = query.call
|
115
115
|
@index = 0
|
116
|
-
@has_more = @json[
|
116
|
+
@has_more = @json["has_more"]
|
117
117
|
else
|
118
118
|
@has_content = false
|
119
119
|
end
|
@@ -125,7 +125,7 @@ module NotionRubyMapping
|
|
125
125
|
|
126
126
|
# @return [Hash]
|
127
127
|
def results
|
128
|
-
@json[
|
128
|
+
@json["results"]
|
129
129
|
end
|
130
130
|
end
|
131
131
|
end
|
@@ -27,8 +27,8 @@ module NotionRubyMapping
|
|
27
27
|
|
28
28
|
# @param [Boolean] dry_run true if dry_run
|
29
29
|
def append_comment(text_objects, dry_run: false)
|
30
|
-
rto = RichTextArray.new
|
31
|
-
json = rto.property_schema_json.merge({parent
|
30
|
+
rto = RichTextArray.new "rich_text", text_objects: text_objects, will_update: true
|
31
|
+
json = rto.property_schema_json.merge({"parent" => {"page_id" => @id}})
|
32
32
|
if dry_run
|
33
33
|
self.class.dry_run_script :post, @nc.comments_path, json
|
34
34
|
else
|
@@ -41,8 +41,8 @@ module NotionRubyMapping
|
|
41
41
|
# @return [NotionRubyMapping::Database]
|
42
42
|
# @see https://www.notion.so/hkob/Page-d359650e3ca94424af8359a24147b9a0#71f680d59b874930bf9f488a7cd6a49e
|
43
43
|
def build_child_database(title, *assigns)
|
44
|
-
db = Database.new json: {title
|
45
|
-
assign: assigns, parent: {type
|
44
|
+
db = Database.new json: {"title" => [TextObject.new(title).property_values_json]},
|
45
|
+
assign: assigns, parent: {"type" => "page_id", "page_id" => @id}
|
46
46
|
yield db, db.properties if block_given?
|
47
47
|
db
|
48
48
|
end
|
@@ -53,15 +53,15 @@ module NotionRubyMapping
|
|
53
53
|
# @return [NotionRubyMapping::Database, String]
|
54
54
|
# @see https://www.notion.so/hkob/Page-d359650e3ca94424af8359a24147b9a0#e3f1d21e0f724f589e48431468772eed
|
55
55
|
def create_child_database(title, *assigns, dry_run: false)
|
56
|
-
db = Database.new json: {title
|
57
|
-
assign: assigns, parent: {type
|
56
|
+
db = Database.new json: {"title" => [TextObject.new(title).property_values_json]},
|
57
|
+
assign: assigns, parent: {"type" => "page_id", "page_id" => @id}
|
58
58
|
yield db, db.properties if block_given?
|
59
59
|
db.save dry_run: dry_run
|
60
60
|
end
|
61
61
|
|
62
62
|
# @return [String] 公開URL
|
63
63
|
def public_url
|
64
|
-
@json[
|
64
|
+
@json["public_url"]
|
65
65
|
end
|
66
66
|
|
67
67
|
# @return [String] title
|
@@ -73,7 +73,7 @@ module NotionRubyMapping
|
|
73
73
|
|
74
74
|
# @return [String] URL
|
75
75
|
def url
|
76
|
-
@json[
|
76
|
+
@json["url"]
|
77
77
|
end
|
78
78
|
|
79
79
|
protected
|
@@ -8,8 +8,8 @@ module NotionRubyMapping
|
|
8
8
|
def initialize(block_id: nil, sub_blocks: nil, json: nil, id: nil, parent: nil)
|
9
9
|
super json: json, id: id, parent: parent
|
10
10
|
if @json
|
11
|
-
synced_from = @json[type][
|
12
|
-
@block_id = synced_from && @nc.hex_id(synced_from[
|
11
|
+
synced_from = @json[type]["synced_from"]
|
12
|
+
@block_id = synced_from && @nc.hex_id(synced_from["block_id"])
|
13
13
|
else
|
14
14
|
@block_id = Base.block_id block_id
|
15
15
|
add_sub_blocks sub_blocks
|
@@ -21,8 +21,8 @@ module NotionRubyMapping
|
|
21
21
|
|
22
22
|
def block_json(not_update: true)
|
23
23
|
ans = super
|
24
|
-
ans[type] = {synced_from
|
25
|
-
ans[type][
|
24
|
+
ans[type] = {"synced_from" => @block_id ? {"type" => "block_id", "block_id" => @nc.hex_id(@block_id)} : nil}
|
25
|
+
ans[type]["children"] = @sub_blocks.map(&:block_json) if @sub_blocks
|
26
26
|
ans
|
27
27
|
end
|
28
28
|
|
@@ -43,7 +43,7 @@ module NotionRubyMapping
|
|
43
43
|
|
44
44
|
# @return [String (frozen)]
|
45
45
|
def type
|
46
|
-
|
46
|
+
"synced_block"
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -15,9 +15,9 @@ module NotionRubyMapping
|
|
15
15
|
super json: json, id: id, parent: parent
|
16
16
|
if @json
|
17
17
|
sub_json = @json[type]
|
18
|
-
@has_column_header = sub_json[
|
19
|
-
@has_row_header = sub_json[
|
20
|
-
@table_width = sub_json[
|
18
|
+
@has_column_header = sub_json["has_column_header"]
|
19
|
+
@has_row_header = sub_json["has_row_header"]
|
20
|
+
@table_width = sub_json["table_width"]
|
21
21
|
else
|
22
22
|
@table_width = table_width
|
23
23
|
@has_column_header = has_column_header
|
@@ -34,17 +34,17 @@ module NotionRubyMapping
|
|
34
34
|
def block_json(not_update: true)
|
35
35
|
ans = super
|
36
36
|
ans[type] = {
|
37
|
-
has_column_header
|
38
|
-
has_row_header
|
39
|
-
table_width
|
37
|
+
"has_column_header" => @has_column_header,
|
38
|
+
"has_row_header" => @has_row_header,
|
39
|
+
"table_width" => @table_width,
|
40
40
|
}
|
41
|
-
ans[type][
|
41
|
+
ans[type]["children"] = @table_rows.map(&:block_json) if @table_rows
|
42
42
|
ans
|
43
43
|
end
|
44
44
|
|
45
45
|
# @return [String (frozen)]
|
46
46
|
def type
|
47
|
-
|
47
|
+
"table"
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -15,19 +15,19 @@ module NotionRubyMapping
|
|
15
15
|
|
16
16
|
def color=(new_color)
|
17
17
|
@color = new_color
|
18
|
-
@payload.add_update_block_key
|
18
|
+
@payload.add_update_block_key "color"
|
19
19
|
end
|
20
20
|
|
21
21
|
# @return [String (frozen)]
|
22
22
|
def type
|
23
|
-
|
23
|
+
"table_of_contents"
|
24
24
|
end
|
25
25
|
|
26
26
|
# @param [Boolean] not_update false when update
|
27
27
|
# @return [Hash{String (frozen)->Hash}]
|
28
28
|
def block_json(not_update: true)
|
29
29
|
ans = super
|
30
|
-
ans[type] = {color
|
30
|
+
ans[type] = {"color" => @color}
|
31
31
|
ans
|
32
32
|
end
|
33
33
|
end
|
@@ -8,7 +8,7 @@ module NotionRubyMapping
|
|
8
8
|
def initialize(array_array_of_text_objects = [], table_width = 3, json: nil, id: nil, parent: nil)
|
9
9
|
super json: json, id: id, parent: parent
|
10
10
|
if @json
|
11
|
-
@cells = @json[type][
|
11
|
+
@cells = @json[type]["cells"].map { |cell| cell.map { |to| RichTextObject.create_from_json to } }
|
12
12
|
else
|
13
13
|
cc = array_array_of_text_objects.count
|
14
14
|
raise StandardError, "table width must be #{table_width} (given array size is #{cc}" unless table_width == cc
|
@@ -22,13 +22,13 @@ module NotionRubyMapping
|
|
22
22
|
|
23
23
|
def block_json(not_update: true)
|
24
24
|
ans = super
|
25
|
-
ans[type] = {cells
|
25
|
+
ans[type] = {"cells" => @cells.map { |cell| Array(cell).map(&:property_values_json) }}
|
26
26
|
ans
|
27
27
|
end
|
28
28
|
|
29
29
|
# @return [String (frozen)]
|
30
30
|
def type
|
31
|
-
|
31
|
+
"table_row"
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -10,7 +10,7 @@ module NotionRubyMapping
|
|
10
10
|
if @json
|
11
11
|
decode_block_rich_text_array
|
12
12
|
else
|
13
|
-
rich_text_array_and_color
|
13
|
+
rich_text_array_and_color "rich_text", text_info, nil
|
14
14
|
add_sub_blocks sub_blocks
|
15
15
|
end
|
16
16
|
@can_have_children = true
|
@@ -23,12 +23,12 @@ module NotionRubyMapping
|
|
23
23
|
def block_json(not_update: true)
|
24
24
|
ans = super
|
25
25
|
ans[type] = @rich_text_array.update_property_schema_json not_update
|
26
|
-
ans[type][
|
26
|
+
ans[type]["children"] = @sub_blocks.map(&:block_json) if @sub_blocks
|
27
27
|
ans
|
28
28
|
end
|
29
29
|
|
30
30
|
def type
|
31
|
-
|
31
|
+
"template"
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -14,7 +14,7 @@ module NotionRubyMapping
|
|
14
14
|
decode_block_rich_text_array
|
15
15
|
decode_color
|
16
16
|
else
|
17
|
-
rich_text_array_and_color
|
17
|
+
rich_text_array_and_color "rich_text", text_info, color
|
18
18
|
add_sub_blocks sub_blocks
|
19
19
|
end
|
20
20
|
@can_have_children = true
|
@@ -28,7 +28,7 @@ module NotionRubyMapping
|
|
28
28
|
# @see https://www.notion.so/hkob/BulletedListItemBlock-ac4978f4efbb40109f0fb3bd00f43476#2d59111c9e434dfa99d294cc9a74e468
|
29
29
|
def color=(new_color)
|
30
30
|
@color = new_color
|
31
|
-
@payload.add_update_block_key
|
31
|
+
@payload.add_update_block_key "color"
|
32
32
|
@rich_text_array.will_update = true
|
33
33
|
end
|
34
34
|
|
@@ -37,8 +37,8 @@ module NotionRubyMapping
|
|
37
37
|
def block_json(not_update: true)
|
38
38
|
ans = super
|
39
39
|
ans[type] = @rich_text_array.update_property_schema_json not_update
|
40
|
-
ans[type][
|
41
|
-
ans[type][
|
40
|
+
ans[type]["color"] = @color
|
41
|
+
ans[type]["children"] = @sub_blocks.map(&:block_json) if @sub_blocks
|
42
42
|
ans
|
43
43
|
end
|
44
44
|
end
|
@@ -10,7 +10,7 @@ module NotionRubyMapping
|
|
10
10
|
def initialize(text_info = nil, checked = false, sub_blocks: nil, color: "default", json: nil, id: nil, parent: nil)
|
11
11
|
super(text_info, sub_blocks: sub_blocks, color: color, json: json, id: id, parent: parent)
|
12
12
|
@checked = if @json
|
13
|
-
@json[type][
|
13
|
+
@json[type]["checked"]
|
14
14
|
else
|
15
15
|
checked
|
16
16
|
end
|
@@ -23,7 +23,7 @@ module NotionRubyMapping
|
|
23
23
|
# @return [Hash{String (frozen)->Hash}]
|
24
24
|
def block_json(not_update: true)
|
25
25
|
ans = super
|
26
|
-
ans[type][
|
26
|
+
ans[type]["checked"] = @checked
|
27
27
|
ans
|
28
28
|
end
|
29
29
|
|
@@ -31,12 +31,12 @@ module NotionRubyMapping
|
|
31
31
|
# @see https://www.notion.so/hkob/ToDoBlock-9e4d863244b541869d91c84620e190d4#8ef8b12721914cccb17790879bdc2fbf
|
32
32
|
def checked=(new_checked)
|
33
33
|
@checked = new_checked
|
34
|
-
@payload.add_update_block_key
|
34
|
+
@payload.add_update_block_key "checked"
|
35
35
|
end
|
36
36
|
|
37
37
|
# @return [String (frozen)]
|
38
38
|
def type
|
39
|
-
|
39
|
+
"to_do"
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -5,14 +5,14 @@ module NotionRubyMapping
|
|
5
5
|
class ToggleHeading1Block < TextSubBlockColorBaseBlock
|
6
6
|
# @return [String (frozen)]
|
7
7
|
def type
|
8
|
-
|
8
|
+
"heading_1"
|
9
9
|
end
|
10
10
|
|
11
11
|
# @param [Boolean] not_update false when update
|
12
12
|
# @return [Hash{String (frozen)->Hash}]
|
13
13
|
def block_json(not_update: true)
|
14
14
|
ans = super
|
15
|
-
ans[type][
|
15
|
+
ans[type]["is_toggleable"] = true
|
16
16
|
ans
|
17
17
|
end
|
18
18
|
end
|
@@ -5,14 +5,14 @@ module NotionRubyMapping
|
|
5
5
|
class ToggleHeading2Block < TextSubBlockColorBaseBlock
|
6
6
|
# @return [String (frozen)]
|
7
7
|
def type
|
8
|
-
|
8
|
+
"heading_2"
|
9
9
|
end
|
10
10
|
|
11
11
|
# @param [Boolean] not_update false when update
|
12
12
|
# @return [Hash{String (frozen)->Hash}]
|
13
13
|
def block_json(not_update: true)
|
14
14
|
ans = super
|
15
|
-
ans[type][
|
15
|
+
ans[type]["is_toggleable"] = true
|
16
16
|
ans
|
17
17
|
end
|
18
18
|
end
|
@@ -3,16 +3,16 @@
|
|
3
3
|
module NotionRubyMapping
|
4
4
|
# Notion block
|
5
5
|
class ToggleHeading3Block < TextSubBlockColorBaseBlock
|
6
|
-
# @return [
|
6
|
+
# @return [String]
|
7
7
|
def type
|
8
|
-
|
8
|
+
"heading_3"
|
9
9
|
end
|
10
10
|
|
11
11
|
# @param [Boolean] not_update false when update
|
12
12
|
# @return [Hash{String (frozen)->Hash}]
|
13
13
|
def block_json(not_update: true)
|
14
14
|
ans = super
|
15
|
-
ans[type][
|
15
|
+
ans[type]["is_toggleable"] = true
|
16
16
|
ans
|
17
17
|
end
|
18
18
|
end
|
@@ -9,7 +9,7 @@ module NotionRubyMapping
|
|
9
9
|
|
10
10
|
super(json: json, id: id, parent: parent)
|
11
11
|
@url = if @json
|
12
|
-
@json[type][
|
12
|
+
@json[type]["url"]
|
13
13
|
else
|
14
14
|
url
|
15
15
|
end
|
@@ -21,14 +21,14 @@ module NotionRubyMapping
|
|
21
21
|
# @return [Hash{String (frozen)->Hash}]
|
22
22
|
def block_json(not_update: true)
|
23
23
|
ans = super
|
24
|
-
ans[type] = {url
|
24
|
+
ans[type] = {"url" => @url}
|
25
25
|
ans
|
26
26
|
end
|
27
27
|
|
28
28
|
# @param [String] str
|
29
29
|
def url=(str)
|
30
30
|
@url = str
|
31
|
-
@payload.add_update_block_key
|
31
|
+
@payload.add_update_block_key "url"
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|