edwh-editorjs 2.4.0__tar.gz → 2.5.0a2__tar.gz
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.
- {edwh_editorjs-2.4.0 → edwh_editorjs-2.5.0a2}/PKG-INFO +2 -1
- edwh_editorjs-2.5.0a2/editorjs/__about__.py +1 -0
- {edwh_editorjs-2.4.0 → edwh_editorjs-2.5.0a2}/editorjs/blocks.py +10 -7
- {edwh_editorjs-2.4.0 → edwh_editorjs-2.5.0a2}/editorjs/core.py +0 -1
- {edwh_editorjs-2.4.0 → edwh_editorjs-2.5.0a2}/pyproject.toml +3 -2
- {edwh_editorjs-2.4.0 → edwh_editorjs-2.5.0a2}/tests/test_core.py +21 -0
- edwh_editorjs-2.4.0/editorjs/__about__.py +0 -1
- {edwh_editorjs-2.4.0 → edwh_editorjs-2.5.0a2}/.gitignore +0 -0
- {edwh_editorjs-2.4.0 → edwh_editorjs-2.5.0a2}/CHANGELOG.md +0 -0
- {edwh_editorjs-2.4.0 → edwh_editorjs-2.5.0a2}/README.md +0 -0
- {edwh_editorjs-2.4.0 → edwh_editorjs-2.5.0a2}/editorjs/__init__.py +0 -0
- {edwh_editorjs-2.4.0 → edwh_editorjs-2.5.0a2}/editorjs/exceptions.py +0 -0
- {edwh_editorjs-2.4.0 → edwh_editorjs-2.5.0a2}/editorjs/helpers.py +0 -0
- {edwh_editorjs-2.4.0 → edwh_editorjs-2.5.0a2}/editorjs/types.py +0 -0
- {edwh_editorjs-2.4.0 → edwh_editorjs-2.5.0a2}/tests/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: edwh-editorjs
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.5.0a2
|
|
4
4
|
Summary: EditorJS.py
|
|
5
5
|
Project-URL: Homepage, https://github.com/educationwarehouse/edwh-EditorJS
|
|
6
6
|
Author-email: SKevo <skevo.cw@gmail.com>, Robin van der Noord <robin.vdn@educationwarehouse.nl>
|
|
@@ -13,6 +13,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.13
|
|
15
15
|
Requires-Python: >=3.10
|
|
16
|
+
Requires-Dist: html2markdown
|
|
16
17
|
Requires-Dist: humanize
|
|
17
18
|
Requires-Dist: markdown2
|
|
18
19
|
Requires-Dist: mdast
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.5.0a2"
|
|
@@ -13,7 +13,7 @@ import markdown2
|
|
|
13
13
|
|
|
14
14
|
from .exceptions import TODO, Unreachable
|
|
15
15
|
from .types import EditorChildData, MDChildNode
|
|
16
|
-
|
|
16
|
+
import html2markdown
|
|
17
17
|
|
|
18
18
|
class EditorJSBlock(abc.ABC):
|
|
19
19
|
@classmethod
|
|
@@ -173,6 +173,9 @@ class ParagraphBlock(EditorJSBlock):
|
|
|
173
173
|
}
|
|
174
174
|
)
|
|
175
175
|
|
|
176
|
+
# deal with bold etc:
|
|
177
|
+
text = html2markdown.convert(text)
|
|
178
|
+
|
|
176
179
|
return f"{text}\n\n"
|
|
177
180
|
|
|
178
181
|
@classmethod
|
|
@@ -411,11 +414,8 @@ class ImageBlock(EditorJSBlock):
|
|
|
411
414
|
with_background = "1" if data.get("withBackground") else ""
|
|
412
415
|
stretched = "1" if data.get("stretched") else ""
|
|
413
416
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
return f"""<editorjs type="image" caption="{caption}" border="{with_border}" background="{with_background}" stretched="{stretched}" url="{url}" />\n\n"""
|
|
417
|
-
else:
|
|
418
|
-
return f"""\n\n"""
|
|
417
|
+
# always custom type so we can render as <figure> instead of markdown2's default (simple <img>)
|
|
418
|
+
return f"""<editorjs type="image" caption="{caption}" border="{with_border}" background="{with_background}" stretched="{stretched}" url="{url}" />\n\n"""
|
|
419
419
|
|
|
420
420
|
@classmethod
|
|
421
421
|
def _caption(cls, node: MDChildNode):
|
|
@@ -450,7 +450,10 @@ class ImageBlock(EditorJSBlock):
|
|
|
450
450
|
<div class="ce-block__content">
|
|
451
451
|
<div class="cdx-block image-tool image-tool--filled {background and 'image-tool--withBackground'} {stretched and 'image-tool--stretched'} {border and 'image-tool--withBorder'}">
|
|
452
452
|
<div class="image-tool__image">
|
|
453
|
-
<
|
|
453
|
+
<figure>
|
|
454
|
+
<img class="image-tool__image-picture" src="{url}" title="{caption}" alt="{caption}">
|
|
455
|
+
<figcaption>{caption}</figcaption>
|
|
456
|
+
</figure>
|
|
454
457
|
</div>
|
|
455
458
|
</div>
|
|
456
459
|
</div>
|
|
@@ -256,3 +256,24 @@ def test_image_options():
|
|
|
256
256
|
print(e.to_markdown())
|
|
257
257
|
print(e.to_html())
|
|
258
258
|
print(e.to_json())
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def test_figcaption():
|
|
262
|
+
js = """{"time":1742471258492,"blocks":[{"id":"ZoA3rbc05C","type":"image","data":{"caption":"Party Time!","withBorder":false,"withBackground":false,"stretched":false,"file":{"url":"https://py4web.leiden.dockers.local/img/upload/23.png?hash=979795a433fc15cb94eccb3159f1f1e4054b1664"}}}],"version":"2.30.7"}"""
|
|
263
|
+
e = EditorJS.from_json(js)
|
|
264
|
+
|
|
265
|
+
html = e.to_html()
|
|
266
|
+
|
|
267
|
+
assert "figcaption" in html
|
|
268
|
+
|
|
269
|
+
def test_bold():
|
|
270
|
+
js = """{"time":1742475802066,"blocks":[{"id":"v_Kc51dnJH","type":"paragraph","data":{"text":"Deze tekst is <b>half bold</b> en half niet"},"tunes":{"alignmentTune":{"alignment":"left"}}},{"id":"q_fkuEFcY5","type":"paragraph","data":{"text":"<b>Deze tekst is heel bold</b>"},"tunes":{"alignmentTune":{"alignment":"left"}}}],"version":"2.30.7"}"""
|
|
271
|
+
|
|
272
|
+
e = EditorJS.from_json(js)
|
|
273
|
+
|
|
274
|
+
print(
|
|
275
|
+
e._mdast,
|
|
276
|
+
e.to_json(),
|
|
277
|
+
e.to_html(),
|
|
278
|
+
e.to_markdown(),
|
|
279
|
+
)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2.4.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|