notion_ruby_mapping 0.8.9 → 1.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/.rubocop.yml +12 -1
- data/lib/notion_ruby_mapping/blocks/base.rb +33 -33
- data/lib/notion_ruby_mapping/blocks/block.rb +48 -47
- 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 +6 -6
- 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 +2 -2
- data/lib/notion_ruby_mapping/blocks/file_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/heading1_block.rb +4 -4
- 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 +1 -1
- 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 -20
- data/lib/notion_ruby_mapping/blocks/numbered_list_item_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/page.rb +9 -10
- 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/discussion_thread.rb +1 -1
- data/lib/notion_ruby_mapping/controllers/mermaid_database.rb +34 -34
- data/lib/notion_ruby_mapping/controllers/notion_cache.rb +6 -8
- data/lib/notion_ruby_mapping/controllers/payload.rb +11 -11
- data/lib/notion_ruby_mapping/controllers/property_cache.rb +8 -7
- data/lib/notion_ruby_mapping/controllers/query.rb +10 -10
- data/lib/notion_ruby_mapping/controllers/search.rb +5 -6
- 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 +9 -9
- 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 +4 -4
- 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 +14 -13
- data/lib/notion_ruby_mapping/properties/date_property.rb +17 -17
- data/lib/notion_ruby_mapping/properties/email_property.rb +3 -3
- data/lib/notion_ruby_mapping/properties/files_property.rb +16 -13
- data/lib/notion_ruby_mapping/properties/formula_property.rb +7 -7
- data/lib/notion_ruby_mapping/properties/last_edited_by_property.rb +2 -2
- 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 +6 -6
- data/lib/notion_ruby_mapping/properties/phone_number_property.rb +4 -4
- data/lib/notion_ruby_mapping/properties/property.rb +78 -75
- data/lib/notion_ruby_mapping/properties/relation_property.rb +18 -17
- 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 +6 -6
- data/lib/notion_ruby_mapping/properties/unique_id_property.rb +3 -3
- 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/notion_ruby_mapping.gemspec +1 -2
- metadata +4 -22
- data/sig/notion_ruby_mapping.rbs +0 -4
@@ -8,7 +8,7 @@ module NotionRubyMapping
|
|
8
8
|
def initialize(expression = nil, json: nil, id: nil, parent: nil)
|
9
9
|
super(json: json, id: id, parent: parent)
|
10
10
|
@equation_object = if @json
|
11
|
-
EquationObject.equation_object @json[type][
|
11
|
+
EquationObject.equation_object @json[type][:expression]
|
12
12
|
else
|
13
13
|
EquationObject.equation_object expression
|
14
14
|
end
|
@@ -18,7 +18,7 @@ module NotionRubyMapping
|
|
18
18
|
# @return [Hash{String (frozen)->Hash}]
|
19
19
|
def block_json(not_update: true)
|
20
20
|
ans = super
|
21
|
-
ans[type] = {
|
21
|
+
ans[type] = {expression: @equation_object.expression}
|
22
22
|
ans
|
23
23
|
end
|
24
24
|
|
@@ -32,12 +32,12 @@ module NotionRubyMapping
|
|
32
32
|
# @see https://www.notion.so/hkob/EquationBlock-df0f823dc5ac41b798052f161dd6540c#f05e3b2c82914cea9f05e9e6644647e1
|
33
33
|
def expression=(new_expression)
|
34
34
|
@equation_object = EquationObject.equation_object new_expression
|
35
|
-
@payload.add_update_block_key
|
35
|
+
@payload.add_update_block_key :expression
|
36
36
|
end
|
37
37
|
|
38
|
-
# @return [
|
38
|
+
# @return [Symbol]
|
39
39
|
def type
|
40
|
-
|
40
|
+
:equation
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -15,7 +15,7 @@ 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
|
|
@@ -44,7 +44,7 @@ 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
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -10,16 +10,16 @@ module NotionRubyMapping
|
|
10
10
|
@can_have_children = false
|
11
11
|
end
|
12
12
|
|
13
|
-
# @return [
|
13
|
+
# @return [Symbol]
|
14
14
|
def type
|
15
|
-
|
15
|
+
:heading_1
|
16
16
|
end
|
17
17
|
|
18
18
|
# @param [Boolean] not_update false when update
|
19
|
-
# @return [Hash{
|
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 [Symbol]
|
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(*%i[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
|
-
{
|
28
|
+
{type: :page_id, page_id: Base.page_id(@page_id)}
|
29
29
|
else
|
30
|
-
{
|
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 [Symbol]
|
36
36
|
def type
|
37
|
-
|
37
|
+
:link_to_page
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -7,10 +7,10 @@ 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
|
13
|
+
case type.to_sym
|
14
14
|
when :comment_parent
|
15
15
|
@comment_parent = value
|
16
16
|
when :database
|
@@ -20,7 +20,7 @@ module NotionRubyMapping
|
|
20
20
|
when :property
|
21
21
|
@property = value
|
22
22
|
when :user_object
|
23
|
-
@user_object =
|
23
|
+
@user_object = value
|
24
24
|
when :search
|
25
25
|
@search = value
|
26
26
|
end
|
@@ -34,6 +34,7 @@ module NotionRubyMapping
|
|
34
34
|
# @see https://www.notion.so/hkob/List-9a0b32335e0d48849a785ce5e162c760#12e1c261a0944a4095776b7515bef4a1
|
35
35
|
def each(&block)
|
36
36
|
return enum_for(:each) if block.nil?
|
37
|
+
|
37
38
|
if @parent
|
38
39
|
each_sub base: @page,
|
39
40
|
query: -> { @parent.children @query },
|
@@ -46,25 +47,25 @@ module NotionRubyMapping
|
|
46
47
|
&block
|
47
48
|
elsif @property
|
48
49
|
each_sub base: @property,
|
49
|
-
query:
|
50
|
+
query: lambda {
|
50
51
|
@nc.page_property_request @property.property_cache.page_id,
|
51
52
|
@property.property_id,
|
52
53
|
@query.query_json
|
53
|
-
|
54
|
-
create_object:
|
55
|
-
case json[
|
56
|
-
when
|
57
|
-
UserObject.new json: json[
|
58
|
-
when
|
59
|
-
json[
|
60
|
-
when
|
61
|
-
RichTextObject.create_from_json json[
|
62
|
-
when
|
63
|
-
RichTextObject.create_from_json json[
|
54
|
+
},
|
55
|
+
create_object: lambda { |json|
|
56
|
+
case json[:type]&.to_sym
|
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]
|
64
65
|
else
|
65
66
|
json
|
66
67
|
end
|
67
|
-
|
68
|
+
},
|
68
69
|
&block
|
69
70
|
elsif @comment_parent
|
70
71
|
each_sub base: @comment_parent,
|
@@ -96,7 +97,7 @@ module NotionRubyMapping
|
|
96
97
|
unless @load_all_contents
|
97
98
|
@query.start_cursor = nil
|
98
99
|
@json = query.call
|
99
|
-
@has_more = @json[
|
100
|
+
@has_more = @json[:has_more]
|
100
101
|
end
|
101
102
|
@index = 0
|
102
103
|
@has_content = true
|
@@ -109,10 +110,10 @@ module NotionRubyMapping
|
|
109
110
|
block.call object
|
110
111
|
elsif @has_more
|
111
112
|
if base
|
112
|
-
@query.start_cursor = @json[
|
113
|
+
@query.start_cursor = @json[:next_cursor]
|
113
114
|
@json = query.call
|
114
115
|
@index = 0
|
115
|
-
@has_more = @json[
|
116
|
+
@has_more = @json[:has_more]
|
116
117
|
else
|
117
118
|
@has_content = false
|
118
119
|
end
|
@@ -124,7 +125,7 @@ module NotionRubyMapping
|
|
124
125
|
|
125
126
|
# @return [Hash]
|
126
127
|
def results
|
127
|
-
@json[
|
128
|
+
@json[:results]
|
128
129
|
end
|
129
130
|
end
|
130
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({
|
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: {
|
45
|
-
assign: assigns, parent: {
|
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,27 +53,27 @@ 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: {
|
57
|
-
assign: assigns, parent: {
|
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
|
68
68
|
# @see https://www.notion.so/hkob/Page-d359650e3ca94424af8359a24147b9a0#2ff7209055f346fbbda454cdbb40b1c8
|
69
69
|
def title
|
70
|
-
tp = properties.select { |p| p.is_a?(TitleProperty) || (p.is_a?(Property) && p.property_id ==
|
70
|
+
tp = properties.select { |p| p.is_a?(TitleProperty) || (p.is_a?(Property) && p.property_id == :title) }
|
71
71
|
tp.map(&:full_text).join ""
|
72
72
|
end
|
73
73
|
|
74
74
|
# @return [String] URL
|
75
75
|
def url
|
76
|
-
@json[
|
76
|
+
@json[:url]
|
77
77
|
end
|
78
78
|
|
79
79
|
protected
|
@@ -103,6 +103,5 @@ module NotionRubyMapping
|
|
103
103
|
update_json @nc.update_page_request(@id, property_values_json)
|
104
104
|
end
|
105
105
|
end
|
106
|
-
|
107
106
|
end
|
108
107
|
end
|
@@ -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] = {
|
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
|
-
|
38
|
-
|
39
|
-
|
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] = {
|
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] = {
|
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
|