Skip to content

Commit

Permalink
Merge pull request #80 from stckme/SupportDocDataAttributes
Browse files Browse the repository at this point in the history
Support doc - Data Attributes
  • Loading branch information
gauravr authored Jan 18, 2024
2 parents 614c745 + 2121b58 commit 5b5d8cf
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.16.0
current_version = 0.17.0
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name="tiptapy",
version='0.16.0', # TODO: why bumpversion works only for single quotes?
version='0.17.0', # TODO: why bumpversion works only for single quotes?
url="https://github.com/scrolltech/tiptapy",
description="Library that generates HTML output from JSON export of tiptap editor",
long_description=open("README.md").read(),
Expand Down
1 change: 1 addition & 0 deletions tests/data/html/data_attributes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div data-show-gap="true" data-type="imageStrip"><figure><picture><source srcset="https://placekitten.com/200/301" type="image"/><source srcset="https://placekitten.com/200/301" type="image"/><img src="https://placekitten.com/200/301" alt="Sleepy Kitten"width="300" height="400"/></picture><figcaption>Cute Kitty</figcaption></figure><figure><picture><source srcset="https://placekitten.com/200/301" type="image"/><source srcset="https://placekitten.com/200/301" type="image"/><img src="https://placekitten.com/200/301" alt="Happy Kitten"width="300" height="400"/></picture><figcaption>New Kitty</figcaption></figure></div>
26 changes: 26 additions & 0 deletions tests/data/json/data_attributes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"type": "doc",
"attrs": {"data": {"show-gap": "true", "type": "imageStrip"}},
"content": [
{
"type": "image",
"attrs": {
"src": { "image": "https://placekitten.com/200/301", "fallback": "https://placekitten.com/200/301" },
"alt": "Sleepy Kitten",
"caption": "Cute Kitty",
"height": 400,
"width": 300
}
},
{
"type": "image",
"attrs": {
"src": { "image": "https://placekitten.com/200/301", "fallback": "https://placekitten.com/200/301" },
"alt": "Happy Kitten",
"caption": "New Kitty",
"height": 400,
"width": 300
}
}
]
}
3 changes: 2 additions & 1 deletion tests/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"document-pdf",
"document-is_renderable",
"document-sketch",
"camel-case"
"camel-case",
"data_attributes"
)


Expand Down
2 changes: 1 addition & 1 deletion tiptapy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
get_audio_player_block, get_doc_block)


__version__ = '0.16.0'
__version__ = '0.17.0'

renderers: Dict = {}

Expand Down
6 changes: 6 additions & 0 deletions tiptapy/templates/doc.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{%- if node.attrs and node.attrs.data -%}
<div{% for attr, value in node.attrs.data.items() %} data-{{attr}}="{{value}}"{% endfor %}>
{%- endif -%}
{%- for item in node.content -%}
{%- with template=item.type + '.html', node=item -%}
{%- include template -%}
{%- endwith -%}
{%- endfor -%}
{%- if node.attrs and node.attrs.data -%}
</div>
{%- endif -%}

0 comments on commit 5b5d8cf

Please sign in to comment.