edwh-editorjs 2.4.0__py3-none-any.whl → 2.5.0__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.
- editorjs/__about__.py +1 -1
- editorjs/blocks.py +29 -19
- editorjs/core.py +0 -1
- {edwh_editorjs-2.4.0.dist-info → edwh_editorjs-2.5.0.dist-info}/METADATA +2 -1
- edwh_editorjs-2.5.0.dist-info/RECORD +10 -0
- edwh_editorjs-2.4.0.dist-info/RECORD +0 -10
- {edwh_editorjs-2.4.0.dist-info → edwh_editorjs-2.5.0.dist-info}/WHEEL +0 -0
editorjs/__about__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "2.
|
|
1
|
+
__version__ = "2.5.0"
|
editorjs/blocks.py
CHANGED
|
@@ -8,6 +8,7 @@ import typing as t
|
|
|
8
8
|
from html.parser import HTMLParser
|
|
9
9
|
from urllib.parse import urlparse
|
|
10
10
|
|
|
11
|
+
import html2markdown
|
|
11
12
|
import humanize
|
|
12
13
|
import markdown2
|
|
13
14
|
|
|
@@ -53,6 +54,7 @@ def process_styled_content(item: MDChildNode, strict: bool = True) -> str:
|
|
|
53
54
|
A formatted HTML string based on the item type.
|
|
54
55
|
"""
|
|
55
56
|
_type = item.get("type")
|
|
57
|
+
|
|
56
58
|
html_wrappers = {
|
|
57
59
|
"text": "{value}",
|
|
58
60
|
"html": "{value}",
|
|
@@ -82,9 +84,16 @@ def process_styled_content(item: MDChildNode, strict: bool = True) -> str:
|
|
|
82
84
|
|
|
83
85
|
|
|
84
86
|
def default_to_text(node: MDChildNode):
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
if node["type"] == "paragraph":
|
|
88
|
+
return "".join(
|
|
89
|
+
process_styled_content(child) for child in node.get("children", [])
|
|
90
|
+
)
|
|
91
|
+
else:
|
|
92
|
+
return process_styled_content(node)
|
|
93
|
+
|
|
94
|
+
# return "".join(
|
|
95
|
+
# process_styled_content(child) for child in node.get("children", [])
|
|
96
|
+
# ) or process_styled_content(node)
|
|
88
97
|
|
|
89
98
|
|
|
90
99
|
@block("heading", "header")
|
|
@@ -173,6 +182,9 @@ class ParagraphBlock(EditorJSBlock):
|
|
|
173
182
|
}
|
|
174
183
|
)
|
|
175
184
|
|
|
185
|
+
# deal with bold etc:
|
|
186
|
+
text = html2markdown.convert(text)
|
|
187
|
+
|
|
176
188
|
return f"{text}\n\n"
|
|
177
189
|
|
|
178
190
|
@classmethod
|
|
@@ -384,7 +396,7 @@ class CodeBlock(EditorJSBlock):
|
|
|
384
396
|
@classmethod
|
|
385
397
|
def to_markdown(cls, data: EditorChildData) -> str:
|
|
386
398
|
code = data.get("code", "")
|
|
387
|
-
return f"```\n
|
|
399
|
+
return f"```\n{code}\n```\n"
|
|
388
400
|
|
|
389
401
|
@classmethod
|
|
390
402
|
def to_json(cls, node: MDChildNode) -> list[dict]:
|
|
@@ -411,11 +423,8 @@ class ImageBlock(EditorJSBlock):
|
|
|
411
423
|
with_background = "1" if data.get("withBackground") else ""
|
|
412
424
|
stretched = "1" if data.get("stretched") else ""
|
|
413
425
|
|
|
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"""
|
|
426
|
+
# always custom type so we can render as <figure> instead of markdown2's default (simple <img>)
|
|
427
|
+
return f"""<editorjs type="image" caption="{caption}" border="{with_border}" background="{with_background}" stretched="{stretched}" url="{url}" />\n\n"""
|
|
419
428
|
|
|
420
429
|
@classmethod
|
|
421
430
|
def _caption(cls, node: MDChildNode):
|
|
@@ -446,11 +455,14 @@ class ImageBlock(EditorJSBlock):
|
|
|
446
455
|
border = node.get("border") or ""
|
|
447
456
|
|
|
448
457
|
return f"""
|
|
449
|
-
<div class="ce-block {stretched and
|
|
458
|
+
<div class="ce-block {stretched and "ce-block--stretched"}">
|
|
450
459
|
<div class="ce-block__content">
|
|
451
|
-
<div class="cdx-block image-tool image-tool--filled {background and
|
|
460
|
+
<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
461
|
<div class="image-tool__image">
|
|
453
|
-
<
|
|
462
|
+
<figure>
|
|
463
|
+
<img class="image-tool__image-picture" src="{url}" title="{caption}" alt="{caption}">
|
|
464
|
+
<figcaption>{caption}</figcaption>
|
|
465
|
+
</figure>
|
|
454
466
|
</div>
|
|
455
467
|
</div>
|
|
456
468
|
</div>
|
|
@@ -467,7 +479,7 @@ class QuoteBlock(EditorJSBlock):
|
|
|
467
479
|
result = f"> {text}\n"
|
|
468
480
|
if caption := data.get("caption", ""):
|
|
469
481
|
result += f"> <cite>{caption}</cite>\n"
|
|
470
|
-
return result
|
|
482
|
+
return result + "\n"
|
|
471
483
|
|
|
472
484
|
@classmethod
|
|
473
485
|
def to_json(cls, node: MDChildNode) -> list[dict]:
|
|
@@ -493,12 +505,13 @@ class QuoteBlock(EditorJSBlock):
|
|
|
493
505
|
|
|
494
506
|
@classmethod
|
|
495
507
|
def to_text(cls, node: MDChildNode) -> str:
|
|
496
|
-
return
|
|
508
|
+
return "".join(
|
|
509
|
+
process_styled_content(child) for child in node.get("children", [])
|
|
510
|
+
)
|
|
497
511
|
|
|
498
512
|
|
|
499
513
|
@block("raw", "html")
|
|
500
514
|
class RawBlock(EditorJSBlock):
|
|
501
|
-
|
|
502
515
|
@classmethod
|
|
503
516
|
def to_markdown(cls, data: EditorChildData) -> str:
|
|
504
517
|
text = data.get("html", "")
|
|
@@ -521,7 +534,6 @@ class RawBlock(EditorJSBlock):
|
|
|
521
534
|
|
|
522
535
|
@block("table")
|
|
523
536
|
class TableBlock(EditorJSBlock):
|
|
524
|
-
|
|
525
537
|
@classmethod
|
|
526
538
|
def to_markdown(cls, data: EditorChildData) -> str:
|
|
527
539
|
"""
|
|
@@ -640,7 +652,6 @@ class LinkBlock(EditorJSBlock):
|
|
|
640
652
|
|
|
641
653
|
@block("attaches")
|
|
642
654
|
class AttachmentBlock(EditorJSBlock):
|
|
643
|
-
|
|
644
655
|
@classmethod
|
|
645
656
|
def to_markdown(cls, data: EditorChildData) -> str:
|
|
646
657
|
title = data.get("title", "")
|
|
@@ -705,7 +716,7 @@ class AttachmentBlock(EditorJSBlock):
|
|
|
705
716
|
</div>
|
|
706
717
|
{file_size}
|
|
707
718
|
</div>
|
|
708
|
-
<a class="cdx-attaches__download-button" href="{node.get(
|
|
719
|
+
<a class="cdx-attaches__download-button" href="{node.get("file", "")}" target="_blank" rel="nofollow noindex noreferrer" title="{node.get("name", "")}">
|
|
709
720
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M7 10L11.8586 14.8586C11.9367 14.9367 12.0633 14.9367 12.1414 14.8586L17 10"></path></svg>
|
|
710
721
|
</a>
|
|
711
722
|
</div>
|
|
@@ -757,7 +768,6 @@ class AlignmentBlock(EditorJSBlock):
|
|
|
757
768
|
|
|
758
769
|
@block("embed")
|
|
759
770
|
class EmbedBlock(EditorJSBlock):
|
|
760
|
-
|
|
761
771
|
@classmethod
|
|
762
772
|
def to_markdown(cls, data: EditorChildData) -> str:
|
|
763
773
|
service = data.get("service", "")
|
editorjs/core.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: edwh-editorjs
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.5.0
|
|
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,10 @@
|
|
|
1
|
+
editorjs/__about__.py,sha256=fMbNgIJqxiZEaSBLadLBt4rZpCHqarzb4Okt-aWsp2E,22
|
|
2
|
+
editorjs/__init__.py,sha256=-OHUf7ZXfkbdFB1r85eIjpHRfql-GCNUCKuBEdEt2Rc,58
|
|
3
|
+
editorjs/blocks.py,sha256=e46ZTxx4M_t2K3o3-bSDjhOfj9OWvSwTTQLK4r_7fv4,29061
|
|
4
|
+
editorjs/core.py,sha256=4igv2l8Rm1S92kxKrIXGIUlNHh6pnjq8F28XQr91I9o,4510
|
|
5
|
+
editorjs/exceptions.py,sha256=oKuWqi4CSnFGZfVZWtTZ2XZeHXm5xF-nAtX_1YLm6sI,230
|
|
6
|
+
editorjs/helpers.py,sha256=q861o5liNibMTp-Ozay17taF7CTNsRe901lYhhxdwHg,73
|
|
7
|
+
editorjs/types.py,sha256=W7IZWMWgzJaQulybIt0Gx5N63rVj4mEy73VJWo4VAQA,1029
|
|
8
|
+
edwh_editorjs-2.5.0.dist-info/METADATA,sha256=Qv3LORc9vuDoS8Z_1yVms5DZOyhP8tMuiuVzcE7nPGE,1025
|
|
9
|
+
edwh_editorjs-2.5.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
10
|
+
edwh_editorjs-2.5.0.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
editorjs/__about__.py,sha256=yLaFvd-K80rs_ClRVYULStijkok4RfYSaanIt_E-aKM,22
|
|
2
|
-
editorjs/__init__.py,sha256=-OHUf7ZXfkbdFB1r85eIjpHRfql-GCNUCKuBEdEt2Rc,58
|
|
3
|
-
editorjs/blocks.py,sha256=QDUJ55UmDDZxZOxkigGHZ-JC7CP_sDH94Y_z-PRVXf8,28648
|
|
4
|
-
editorjs/core.py,sha256=ra1LADSPiZpbzeAZaVzsJ8aGc3m3xYUO4bpyQLPV3h0,4576
|
|
5
|
-
editorjs/exceptions.py,sha256=oKuWqi4CSnFGZfVZWtTZ2XZeHXm5xF-nAtX_1YLm6sI,230
|
|
6
|
-
editorjs/helpers.py,sha256=q861o5liNibMTp-Ozay17taF7CTNsRe901lYhhxdwHg,73
|
|
7
|
-
editorjs/types.py,sha256=W7IZWMWgzJaQulybIt0Gx5N63rVj4mEy73VJWo4VAQA,1029
|
|
8
|
-
edwh_editorjs-2.4.0.dist-info/METADATA,sha256=Jwtr4YkhOPCssoqI4pLpvl7kpvHMFgpU74tHPQyG7Gc,996
|
|
9
|
-
edwh_editorjs-2.4.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
10
|
-
edwh_editorjs-2.4.0.dist-info/RECORD,,
|
|
File without changes
|