From 8151c24638d2509d061e35082604bb0a3b424921 Mon Sep 17 00:00:00 2001 From: Gaurav Date: Thu, 14 Sep 2023 12:22:58 +0530 Subject: [PATCH 01/12] Support doc - Data Attributes --- setup.cfg | 2 +- setup.py | 2 +- tests/data/html/data_attributes.html | 1 + tests/data/json/data_attributes.json | 26 ++++++++++++++++++++++++++ tests/test_transform.py | 3 ++- tiptapy/__init__.py | 2 +- tiptapy/templates/doc.html | 6 ++++++ 7 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 tests/data/html/data_attributes.html create mode 100644 tests/data/json/data_attributes.json diff --git a/setup.cfg b/setup.cfg index ead005b..9bdfaf0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.16.0 +current_version = 0.17.0 commit = True tag = True diff --git a/setup.py b/setup.py index 99b1c78..b084b57 100644 --- a/setup.py +++ b/setup.py @@ -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(), diff --git a/tests/data/html/data_attributes.html b/tests/data/html/data_attributes.html new file mode 100644 index 0000000..96b2849 --- /dev/null +++ b/tests/data/html/data_attributes.html @@ -0,0 +1 @@ +
Sleepy Kitten
Cute Kitty
Happy Kitten
New Kitty
\ No newline at end of file diff --git a/tests/data/json/data_attributes.json b/tests/data/json/data_attributes.json new file mode 100644 index 0000000..aa78142 --- /dev/null +++ b/tests/data/json/data_attributes.json @@ -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 + } + } + ] +} diff --git a/tests/test_transform.py b/tests/test_transform.py index 221a1b3..bccf3a3 100644 --- a/tests/test_transform.py +++ b/tests/test_transform.py @@ -40,7 +40,8 @@ "document-pdf", "document-is_renderable", "document-sketch", - "camel-case" + "camel-case", + "data_attributes" ) diff --git a/tiptapy/__init__.py b/tiptapy/__init__.py index 62c81d4..4562159 100644 --- a/tiptapy/__init__.py +++ b/tiptapy/__init__.py @@ -9,7 +9,7 @@ get_audio_player_block, get_doc_block) -__version__ = '0.16.0' +__version__ = '0.17.0' renderers: Dict = {} diff --git a/tiptapy/templates/doc.html b/tiptapy/templates/doc.html index 548b2f8..cf3019f 100644 --- a/tiptapy/templates/doc.html +++ b/tiptapy/templates/doc.html @@ -1,5 +1,11 @@ +{%- if node.get("attrs", {}).data -%} + +{%- endif -%} {%- for item in node.content -%} {%- with template=item.type + '.html', node=item -%} {%- include template -%} {%- endwith -%} {%- endfor -%} +{%- if node.get("attrs", {}).data -%} + +{%- endif -%} \ No newline at end of file From 83446c6af2fded665d9272f8221c4a9920b04c40 Mon Sep 17 00:00:00 2001 From: Ujjwal Mishra Date: Wed, 4 Oct 2023 12:52:50 +0530 Subject: [PATCH 02/12] Small change in attribute structure --- tiptapy/templates/doc.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tiptapy/templates/doc.html b/tiptapy/templates/doc.html index cf3019f..eb0ed6c 100644 --- a/tiptapy/templates/doc.html +++ b/tiptapy/templates/doc.html @@ -1,5 +1,5 @@ {%- if node.get("attrs", {}).data -%} - + {%- endif -%} {%- for item in node.content -%} {%- with template=item.type + '.html', node=item -%} @@ -8,4 +8,4 @@ {%- endfor -%} {%- if node.get("attrs", {}).data -%} -{%- endif -%} \ No newline at end of file +{%- endif -%} From 6d4c53159f288f60a43b96c859d050aab8d7d0af Mon Sep 17 00:00:00 2001 From: Ujjwal Mishra Date: Wed, 4 Oct 2023 12:59:39 +0530 Subject: [PATCH 03/12] Attr check --- tiptapy/templates/doc.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tiptapy/templates/doc.html b/tiptapy/templates/doc.html index eb0ed6c..e8a3ecb 100644 --- a/tiptapy/templates/doc.html +++ b/tiptapy/templates/doc.html @@ -1,4 +1,4 @@ -{%- if node.get("attrs", {}).data -%} +{%- if node.get("attrs", Null) -%} {%- endif -%} {%- for item in node.content -%} @@ -6,6 +6,6 @@ {%- include template -%} {%- endwith -%} {%- endfor -%} -{%- if node.get("attrs", {}).data -%} +{%- if node.get("attrs", Null) -%} {%- endif -%} From 4858f1a7c2ce5453886d976100fc1826d3d8dc78 Mon Sep 17 00:00:00 2001 From: Ujjwal Mishra Date: Wed, 4 Oct 2023 13:00:27 +0530 Subject: [PATCH 04/12] Update data_attributes.json --- tests/data/json/data_attributes.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data/json/data_attributes.json b/tests/data/json/data_attributes.json index aa78142..39d7d35 100644 --- a/tests/data/json/data_attributes.json +++ b/tests/data/json/data_attributes.json @@ -1,6 +1,6 @@ { "type": "doc", - "attrs": {"data": {"show-gap": "true", "type": "imageStrip"}}, + "attrs": {"show-gap": "true", "type": "imageStrip"}, "content": [ { "type": "image", From 25a9f29e20e991dcd07f5fc4a6704c848467656c Mon Sep 17 00:00:00 2001 From: Ujjwal Mishra Date: Wed, 4 Oct 2023 13:26:48 +0530 Subject: [PATCH 05/12] Add creator_note renderer --- tiptapy/templates/extras/creator_note | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tiptapy/templates/extras/creator_note diff --git a/tiptapy/templates/extras/creator_note b/tiptapy/templates/extras/creator_note new file mode 100644 index 0000000..4af6e1c --- /dev/null +++ b/tiptapy/templates/extras/creator_note @@ -0,0 +1,15 @@ +
+
+ + Creator’s note +
+
+ {%- if node -%} + {%- for item in node.content %} + {%- with template=item.type + '.html', node=item %} + {% include template %} + {%- endwith %} + {%- endfor %} + {%- endif %} +
+
From b2c8f51d07b57584b4cbef53862809f0923949a1 Mon Sep 17 00:00:00 2001 From: Ujjwal Mishra Date: Wed, 4 Oct 2023 14:59:49 +0530 Subject: [PATCH 06/12] Rename creator_note to creator_note.html --- tiptapy/templates/extras/{creator_note => creator_note.html} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tiptapy/templates/extras/{creator_note => creator_note.html} (100%) diff --git a/tiptapy/templates/extras/creator_note b/tiptapy/templates/extras/creator_note.html similarity index 100% rename from tiptapy/templates/extras/creator_note rename to tiptapy/templates/extras/creator_note.html From 6f362031c4c22a317389a976ec9f9a917fc7f76f Mon Sep 17 00:00:00 2001 From: Ujjwal Mishra Date: Tue, 17 Oct 2023 15:56:59 +0530 Subject: [PATCH 07/12] Revert "Rename creator_note to creator_note.html" This reverts commit b2c8f51d07b57584b4cbef53862809f0923949a1. --- tiptapy/templates/extras/{creator_note.html => creator_note} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tiptapy/templates/extras/{creator_note.html => creator_note} (100%) diff --git a/tiptapy/templates/extras/creator_note.html b/tiptapy/templates/extras/creator_note similarity index 100% rename from tiptapy/templates/extras/creator_note.html rename to tiptapy/templates/extras/creator_note From b138282db18912984633df796949df7b5af84b84 Mon Sep 17 00:00:00 2001 From: Ujjwal Mishra Date: Tue, 17 Oct 2023 15:57:36 +0530 Subject: [PATCH 08/12] Revert "Add creator_note renderer" This reverts commit 25a9f29e20e991dcd07f5fc4a6704c848467656c. --- tiptapy/templates/extras/creator_note | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 tiptapy/templates/extras/creator_note diff --git a/tiptapy/templates/extras/creator_note b/tiptapy/templates/extras/creator_note deleted file mode 100644 index 4af6e1c..0000000 --- a/tiptapy/templates/extras/creator_note +++ /dev/null @@ -1,15 +0,0 @@ -
-
- - Creator’s note -
-
- {%- if node -%} - {%- for item in node.content %} - {%- with template=item.type + '.html', node=item %} - {% include template %} - {%- endwith %} - {%- endfor %} - {%- endif %} -
-
From 5e535d34accab1d61340d7b1de58f56e50e90d20 Mon Sep 17 00:00:00 2001 From: Ujjwal Mishra Date: Tue, 17 Oct 2023 15:57:45 +0530 Subject: [PATCH 09/12] Revert "Update data_attributes.json" This reverts commit 4858f1a7c2ce5453886d976100fc1826d3d8dc78. --- tests/data/json/data_attributes.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data/json/data_attributes.json b/tests/data/json/data_attributes.json index 39d7d35..aa78142 100644 --- a/tests/data/json/data_attributes.json +++ b/tests/data/json/data_attributes.json @@ -1,6 +1,6 @@ { "type": "doc", - "attrs": {"show-gap": "true", "type": "imageStrip"}, + "attrs": {"data": {"show-gap": "true", "type": "imageStrip"}}, "content": [ { "type": "image", From 8400437da19c3ef6afcde3d046b71c23d9499078 Mon Sep 17 00:00:00 2001 From: Ujjwal Mishra Date: Tue, 17 Oct 2023 15:57:55 +0530 Subject: [PATCH 10/12] Revert "Attr check" This reverts commit 6d4c53159f288f60a43b96c859d050aab8d7d0af. --- tiptapy/templates/doc.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tiptapy/templates/doc.html b/tiptapy/templates/doc.html index e8a3ecb..eb0ed6c 100644 --- a/tiptapy/templates/doc.html +++ b/tiptapy/templates/doc.html @@ -1,4 +1,4 @@ -{%- if node.get("attrs", Null) -%} +{%- if node.get("attrs", {}).data -%} {%- endif -%} {%- for item in node.content -%} @@ -6,6 +6,6 @@ {%- include template -%} {%- endwith -%} {%- endfor -%} -{%- if node.get("attrs", Null) -%} +{%- if node.get("attrs", {}).data -%} {%- endif -%} From 5e68fa959829445e2ee617614f7aae001eedf477 Mon Sep 17 00:00:00 2001 From: Ujjwal Mishra Date: Tue, 17 Oct 2023 15:58:01 +0530 Subject: [PATCH 11/12] Revert "Small change in attribute structure" This reverts commit 83446c6af2fded665d9272f8221c4a9920b04c40. --- tiptapy/templates/doc.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tiptapy/templates/doc.html b/tiptapy/templates/doc.html index eb0ed6c..cf3019f 100644 --- a/tiptapy/templates/doc.html +++ b/tiptapy/templates/doc.html @@ -1,5 +1,5 @@ {%- if node.get("attrs", {}).data -%} - + {%- endif -%} {%- for item in node.content -%} {%- with template=item.type + '.html', node=item -%} @@ -8,4 +8,4 @@ {%- endfor -%} {%- if node.get("attrs", {}).data -%} -{%- endif -%} +{%- endif -%} \ No newline at end of file From 2121b5878ac41b63962fc277ce0c63ed60cf7e35 Mon Sep 17 00:00:00 2001 From: Jitendra Sandbhor Date: Thu, 26 Oct 2023 14:53:49 +0530 Subject: [PATCH 12/12] updating if condition in doc.html --- tiptapy/templates/doc.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tiptapy/templates/doc.html b/tiptapy/templates/doc.html index cf3019f..518e72e 100644 --- a/tiptapy/templates/doc.html +++ b/tiptapy/templates/doc.html @@ -1,4 +1,4 @@ -{%- if node.get("attrs", {}).data -%} +{%- if node.attrs and node.attrs.data -%} {%- endif -%} {%- for item in node.content -%} @@ -6,6 +6,6 @@ {%- include template -%} {%- endwith -%} {%- endfor -%} -{%- if node.get("attrs", {}).data -%} +{%- if node.attrs and node.attrs.data -%} {%- endif -%} \ No newline at end of file