Ejemplo n.º 1
0
class FileBlock(UploadBlock):
    """
    File Block.
    """

    _type = "file"

    size = property_map("size")
    title = property_map("title")
Ejemplo n.º 2
0
class FileBlock(UploadBlock):
    """
    File Block.
    """

    _type = "file"

    size = property_map("size")
    title = property_map("title")

    def upload_file(self, path: str):
        super().upload_file(path)
        self.size = human_size(path)
Ejemplo n.º 3
0
class TextBlock(TB):
    title_plaintext = property_map(
        "title",
        python_to_api=plaintext_to_notion,
        api_to_python=notion_to_plaintext,
        markdown=True,
    )
Ejemplo n.º 4
0
class BookmarkBlock(EmbedBlock):
    """
    Bookmark Block.
    """

    _type = "bookmark"

    bookmark_cover = field_map("format.bookmark_cover")
    bookmark_icon = field_map("format.bookmark_icon")
    description = property_map("description")
    link = property_map("link")
    title = property_map("title")

    def set_new_link(self, link: str):
        data = {"blockId": self.id, "url": link}
        self._client.post("setBookmarkMetadata", data)
        self.refresh()
Ejemplo n.º 5
0
class BasicBlock(Block):

    _type = "block"
    _str_fields = "title"

    title = property_map("title")
    title_plaintext = plaintext_property_map("title")
    color = field_map("format.block_color")
Ejemplo n.º 6
0
class MediaBlock(Block):
    """
    Media block.
    """

    _type = "media"
    _str_fields = "caption"

    caption = property_map("caption")
Ejemplo n.º 7
0
class CodeBlock(BasicBlock):

    _type = "code"

    language = property_map("language")
    wrap = field_map("format.code_wrap")