notionary 0.2.21__py3-none-any.whl → 0.2.22__py3-none-any.whl
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.
- notionary/blocks/_bootstrap.py +9 -1
- notionary/blocks/audio/audio_element.py +53 -28
- notionary/blocks/audio/audio_markdown_node.py +10 -4
- notionary/blocks/base_block_element.py +15 -3
- notionary/blocks/bookmark/bookmark_element.py +39 -36
- notionary/blocks/bookmark/bookmark_markdown_node.py +16 -17
- notionary/blocks/breadcrumbs/breadcrumb_element.py +2 -2
- notionary/blocks/bulleted_list/bulleted_list_element.py +21 -4
- notionary/blocks/callout/callout_element.py +20 -4
- notionary/blocks/child_database/__init__.py +11 -4
- notionary/blocks/child_database/child_database_element.py +61 -0
- notionary/blocks/child_database/child_database_models.py +7 -14
- notionary/blocks/child_page/child_page_element.py +94 -0
- notionary/blocks/client.py +0 -1
- notionary/blocks/code/code_element.py +51 -2
- notionary/blocks/code/code_markdown_node.py +52 -1
- notionary/blocks/column/column_element.py +9 -3
- notionary/blocks/column/column_list_element.py +18 -3
- notionary/blocks/divider/divider_element.py +3 -11
- notionary/blocks/embed/embed_element.py +27 -6
- notionary/blocks/equation/equation_element.py +94 -41
- notionary/blocks/equation/equation_element_markdown_node.py +8 -9
- notionary/blocks/file/file_element.py +56 -37
- notionary/blocks/file/file_element_markdown_node.py +9 -7
- notionary/blocks/guards.py +22 -0
- notionary/blocks/heading/heading_element.py +23 -4
- notionary/blocks/image_block/image_element.py +43 -38
- notionary/blocks/image_block/image_markdown_node.py +10 -5
- notionary/blocks/mixins/captions/__init__.py +4 -0
- notionary/blocks/mixins/captions/caption_markdown_node_mixin.py +31 -0
- notionary/blocks/mixins/captions/caption_mixin.py +92 -0
- notionary/blocks/models.py +3 -1
- notionary/blocks/numbered_list/numbered_list_element.py +21 -4
- notionary/blocks/paragraph/paragraph_element.py +21 -5
- notionary/blocks/pdf/pdf_element.py +47 -41
- notionary/blocks/pdf/pdf_markdown_node.py +9 -7
- notionary/blocks/quote/quote_element.py +26 -9
- notionary/blocks/quote/quote_markdown_node.py +2 -2
- notionary/blocks/registry/block_registry.py +1 -46
- notionary/blocks/registry/block_registry_builder.py +8 -0
- notionary/blocks/rich_text/name_to_id_resolver.py +205 -0
- notionary/blocks/rich_text/rich_text_models.py +62 -29
- notionary/blocks/rich_text/text_inline_formatter.py +432 -101
- notionary/blocks/syntax_prompt_builder.py +137 -0
- notionary/blocks/table/table_element.py +110 -9
- notionary/blocks/table_of_contents/table_of_contents_element.py +19 -2
- notionary/blocks/todo/todo_element.py +21 -4
- notionary/blocks/toggle/toggle_element.py +19 -3
- notionary/blocks/toggle/toggle_markdown_node.py +1 -1
- notionary/blocks/toggleable_heading/toggleable_heading_element.py +19 -4
- notionary/blocks/types.py +69 -0
- notionary/blocks/video/video_element.py +44 -39
- notionary/blocks/video/video_markdown_node.py +10 -5
- notionary/database/client.py +23 -0
- notionary/file_upload/models.py +2 -2
- notionary/markdown/markdown_builder.py +34 -27
- notionary/page/client.py +26 -6
- notionary/page/notion_page.py +37 -6
- notionary/page/page_content_deleting_service.py +117 -0
- notionary/page/page_content_writer.py +89 -113
- notionary/page/page_context.py +65 -0
- notionary/page/reader/handler/__init__.py +2 -0
- notionary/page/reader/handler/base_block_renderer.py +4 -4
- notionary/page/reader/handler/block_rendering_context.py +5 -0
- notionary/page/reader/handler/line_renderer.py +16 -3
- notionary/page/reader/handler/numbered_list_renderer.py +85 -0
- notionary/page/reader/page_content_retriever.py +17 -5
- notionary/page/writer/handler/__init__.py +2 -0
- notionary/page/writer/handler/code_handler.py +12 -40
- notionary/page/writer/handler/column_handler.py +12 -12
- notionary/page/writer/handler/column_list_handler.py +13 -13
- notionary/page/writer/handler/equation_handler.py +74 -0
- notionary/page/writer/handler/line_handler.py +4 -4
- notionary/page/writer/handler/regular_line_handler.py +31 -37
- notionary/page/writer/handler/table_handler.py +8 -72
- notionary/page/writer/handler/toggle_handler.py +14 -12
- notionary/page/writer/handler/toggleable_heading_handler.py +22 -16
- notionary/page/writer/markdown_to_notion_converter.py +28 -9
- notionary/page/writer/markdown_to_notion_converter_context.py +30 -0
- notionary/page/writer/markdown_to_notion_formatting_post_processor.py +73 -0
- notionary/page/writer/markdown_to_notion_post_processor.py +0 -0
- notionary/page/writer/markdown_to_notion_text_length_post_processor.py +0 -0
- notionary/page/writer/notion_text_length_processor.py +150 -0
- notionary/telemetry/service.py +0 -1
- notionary/user/notion_user_manager.py +22 -95
- notionary/util/concurrency_limiter.py +0 -0
- notionary/workspace.py +4 -4
- notionary-0.2.22.dist-info/METADATA +237 -0
- {notionary-0.2.21.dist-info → notionary-0.2.22.dist-info}/RECORD +92 -77
- notionary/page/markdown_whitespace_processor.py +0 -80
- notionary/page/notion_text_length_utils.py +0 -119
- notionary/user/notion_user_provider.py +0 -1
- notionary-0.2.21.dist-info/METADATA +0 -229
- /notionary/page/reader/handler/{context.py → equation_renderer.py} +0 -0
- {notionary-0.2.21.dist-info → notionary-0.2.22.dist-info}/LICENSE +0 -0
- {notionary-0.2.21.dist-info → notionary-0.2.22.dist-info}/WHEEL +0 -0
@@ -1,9 +1,35 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
+
from enum import Enum
|
3
4
|
from typing import Optional
|
4
5
|
|
5
6
|
from pydantic import BaseModel
|
6
|
-
|
7
|
+
|
8
|
+
|
9
|
+
class RichTextType(str, Enum):
|
10
|
+
"""Types of rich text objects."""
|
11
|
+
|
12
|
+
TEXT = "text"
|
13
|
+
MENTION = "mention"
|
14
|
+
EQUATION = "equation"
|
15
|
+
|
16
|
+
|
17
|
+
class MentionType(str, Enum):
|
18
|
+
"""Types of mention objects."""
|
19
|
+
|
20
|
+
USER = "user"
|
21
|
+
PAGE = "page"
|
22
|
+
DATABASE = "database"
|
23
|
+
DATE = "date"
|
24
|
+
LINK_PREVIEW = "link_preview"
|
25
|
+
TEMPLATE_MENTION = "template_mention"
|
26
|
+
|
27
|
+
|
28
|
+
class TemplateMentionType(str, Enum):
|
29
|
+
"""Types of template mentions."""
|
30
|
+
|
31
|
+
USER = "template_mention_user"
|
32
|
+
DATE = "template_mention_date"
|
7
33
|
|
8
34
|
|
9
35
|
class TextAnnotations(BaseModel):
|
@@ -53,13 +79,11 @@ class MentionDate(BaseModel):
|
|
53
79
|
|
54
80
|
class MentionTemplateMention(BaseModel):
|
55
81
|
# Notion hat zwei Template-Mention-Typen
|
56
|
-
type:
|
82
|
+
type: TemplateMentionType
|
57
83
|
|
58
84
|
|
59
85
|
class MentionObject(BaseModel):
|
60
|
-
type:
|
61
|
-
"user", "page", "database", "date", "link_preview", "template_mention"
|
62
|
-
]
|
86
|
+
type: MentionType
|
63
87
|
user: Optional[MentionUserRef] = None
|
64
88
|
page: Optional[MentionPageRef] = None
|
65
89
|
database: Optional[MentionDatabaseRef] = None
|
@@ -69,7 +93,7 @@ class MentionObject(BaseModel):
|
|
69
93
|
|
70
94
|
|
71
95
|
class RichTextObject(BaseModel):
|
72
|
-
type:
|
96
|
+
type: RichTextType = RichTextType.TEXT
|
73
97
|
|
74
98
|
text: Optional[TextContent] = None
|
75
99
|
annotations: Optional[TextAnnotations] = None
|
@@ -83,26 +107,30 @@ class RichTextObject(BaseModel):
|
|
83
107
|
@classmethod
|
84
108
|
def from_plain_text(cls, content: str, **ann) -> RichTextObject:
|
85
109
|
return cls(
|
86
|
-
type=
|
110
|
+
type=RichTextType.TEXT,
|
87
111
|
text=TextContent(content=content),
|
88
112
|
annotations=TextAnnotations(**ann) if ann else TextAnnotations(),
|
89
113
|
plain_text=content,
|
90
114
|
)
|
91
115
|
|
92
116
|
@classmethod
|
93
|
-
def
|
94
|
-
# keine annotations setzen → Notion Code-Highlight bleibt an
|
117
|
+
def for_caption(cls, content: str) -> RichTextObject:
|
95
118
|
return cls(
|
96
|
-
type=
|
119
|
+
type=RichTextType.TEXT,
|
97
120
|
text=TextContent(content=content),
|
98
121
|
annotations=None,
|
99
122
|
plain_text=content,
|
100
123
|
)
|
101
124
|
|
125
|
+
@classmethod
|
126
|
+
def for_code_block(cls, content: str) -> RichTextObject:
|
127
|
+
# keine annotations setzen → Notion Code-Highlight bleibt an
|
128
|
+
return cls.for_caption(content)
|
129
|
+
|
102
130
|
@classmethod
|
103
131
|
def for_link(cls, content: str, url: str, **ann) -> RichTextObject:
|
104
132
|
return cls(
|
105
|
-
type=
|
133
|
+
type=RichTextType.TEXT,
|
106
134
|
text=TextContent(content=content, link=LinkObject(url=url)),
|
107
135
|
annotations=TextAnnotations(**ann) if ann else TextAnnotations(),
|
108
136
|
plain_text=content,
|
@@ -111,25 +139,29 @@ class RichTextObject(BaseModel):
|
|
111
139
|
@classmethod
|
112
140
|
def mention_user(cls, user_id: str) -> RichTextObject:
|
113
141
|
return cls(
|
114
|
-
type=
|
115
|
-
mention=MentionObject(
|
142
|
+
type=RichTextType.MENTION,
|
143
|
+
mention=MentionObject(
|
144
|
+
type=MentionType.USER, user=MentionUserRef(id=user_id)
|
145
|
+
),
|
116
146
|
annotations=TextAnnotations(),
|
117
147
|
)
|
118
148
|
|
119
149
|
@classmethod
|
120
150
|
def mention_page(cls, page_id: str) -> RichTextObject:
|
121
151
|
return cls(
|
122
|
-
type=
|
123
|
-
mention=MentionObject(
|
152
|
+
type=RichTextType.MENTION,
|
153
|
+
mention=MentionObject(
|
154
|
+
type=MentionType.PAGE, page=MentionPageRef(id=page_id)
|
155
|
+
),
|
124
156
|
annotations=TextAnnotations(),
|
125
157
|
)
|
126
158
|
|
127
159
|
@classmethod
|
128
160
|
def mention_database(cls, database_id: str) -> RichTextObject:
|
129
161
|
return cls(
|
130
|
-
type=
|
162
|
+
type=RichTextType.MENTION,
|
131
163
|
mention=MentionObject(
|
132
|
-
type=
|
164
|
+
type=MentionType.DATABASE, database=MentionDatabaseRef(id=database_id)
|
133
165
|
),
|
134
166
|
annotations=TextAnnotations(),
|
135
167
|
)
|
@@ -137,9 +169,9 @@ class RichTextObject(BaseModel):
|
|
137
169
|
@classmethod
|
138
170
|
def mention_link_preview(cls, url: str) -> RichTextObject:
|
139
171
|
return cls(
|
140
|
-
type=
|
172
|
+
type=RichTextType.MENTION,
|
141
173
|
mention=MentionObject(
|
142
|
-
type=
|
174
|
+
type=MentionType.LINK_PREVIEW, link_preview=MentionLinkPreview(url=url)
|
143
175
|
),
|
144
176
|
annotations=TextAnnotations(),
|
145
177
|
)
|
@@ -149,9 +181,10 @@ class RichTextObject(BaseModel):
|
|
149
181
|
cls, start: str, end: str | None = None, time_zone: str | None = None
|
150
182
|
) -> RichTextObject:
|
151
183
|
return cls(
|
152
|
-
type=
|
184
|
+
type=RichTextType.MENTION,
|
153
185
|
mention=MentionObject(
|
154
|
-
type=
|
186
|
+
type=MentionType.DATE,
|
187
|
+
date=MentionDate(start=start, end=end, time_zone=time_zone),
|
155
188
|
),
|
156
189
|
annotations=TextAnnotations(),
|
157
190
|
)
|
@@ -159,10 +192,10 @@ class RichTextObject(BaseModel):
|
|
159
192
|
@classmethod
|
160
193
|
def mention_template_user(cls) -> RichTextObject:
|
161
194
|
return cls(
|
162
|
-
type=
|
195
|
+
type=RichTextType.MENTION,
|
163
196
|
mention=MentionObject(
|
164
|
-
type=
|
165
|
-
template_mention=MentionTemplateMention(type=
|
197
|
+
type=MentionType.TEMPLATE_MENTION,
|
198
|
+
template_mention=MentionTemplateMention(type=TemplateMentionType.USER),
|
166
199
|
),
|
167
200
|
annotations=TextAnnotations(),
|
168
201
|
)
|
@@ -170,10 +203,10 @@ class RichTextObject(BaseModel):
|
|
170
203
|
@classmethod
|
171
204
|
def mention_template_date(cls) -> RichTextObject:
|
172
205
|
return cls(
|
173
|
-
type=
|
206
|
+
type=RichTextType.MENTION,
|
174
207
|
mention=MentionObject(
|
175
|
-
type=
|
176
|
-
template_mention=MentionTemplateMention(type=
|
208
|
+
type=MentionType.TEMPLATE_MENTION,
|
209
|
+
template_mention=MentionTemplateMention(type=TemplateMentionType.DATE),
|
177
210
|
),
|
178
211
|
annotations=TextAnnotations(),
|
179
212
|
)
|
@@ -181,8 +214,8 @@ class RichTextObject(BaseModel):
|
|
181
214
|
@classmethod
|
182
215
|
def equation_inline(cls, expression: str) -> RichTextObject:
|
183
216
|
return cls(
|
184
|
-
type=
|
217
|
+
type=RichTextType.EQUATION,
|
185
218
|
equation=EquationObject(expression=expression),
|
186
219
|
annotations=TextAnnotations(),
|
187
|
-
plain_text=expression,
|
220
|
+
plain_text=expression,
|
188
221
|
)
|