edwh-editorjs 2.6.0__py3-none-any.whl → 2.6.2__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
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "2.6.
|
|
1
|
+
__version__ = "2.6.2"
|
editorjs/blocks.py
CHANGED
|
@@ -187,6 +187,18 @@ class ParagraphBlock(EditorJSBlock):
|
|
|
187
187
|
|
|
188
188
|
return f"{text}\n\n"
|
|
189
189
|
|
|
190
|
+
@staticmethod
|
|
191
|
+
def _find_closing_editorjs_tag(nodes: list, start_idx: int) -> int | None:
|
|
192
|
+
"""Find index of closing </editorjs> tag."""
|
|
193
|
+
for idx, node in enumerate(nodes[start_idx:], start=start_idx):
|
|
194
|
+
if (
|
|
195
|
+
node.get("type") == "html"
|
|
196
|
+
and node.get("value", "").strip() == "</editorjs>"
|
|
197
|
+
):
|
|
198
|
+
return idx
|
|
199
|
+
|
|
200
|
+
return None
|
|
201
|
+
|
|
190
202
|
@classmethod
|
|
191
203
|
def to_json(cls, node: MDChildNode) -> list[dict]:
|
|
192
204
|
result = []
|
|
@@ -210,14 +222,17 @@ class ParagraphBlock(EditorJSBlock):
|
|
|
210
222
|
|
|
211
223
|
if child.get("value", "").endswith("/>"):
|
|
212
224
|
# self-closing
|
|
213
|
-
result.append(EditorJSCustom.to_json(
|
|
225
|
+
result.append(EditorJSCustom.to_json({"children": [child]}))
|
|
214
226
|
else:
|
|
215
|
-
# <editorjs
|
|
216
|
-
|
|
217
|
-
|
|
227
|
+
# <editorjs>...</editorjs> may include nested HTML; find the closing tag
|
|
228
|
+
end_idx = cls._find_closing_editorjs_tag(nodes, idx + 1)
|
|
229
|
+
children_slice = (
|
|
230
|
+
nodes[idx : idx + 2]
|
|
231
|
+
if end_idx is None
|
|
232
|
+
else nodes[idx : end_idx + 1]
|
|
218
233
|
)
|
|
219
|
-
|
|
220
|
-
|
|
234
|
+
skip = 2 if end_idx is None else end_idx - idx
|
|
235
|
+
result.extend(EditorJSCustom.to_json({"children": children_slice}))
|
|
221
236
|
|
|
222
237
|
continue
|
|
223
238
|
|
|
@@ -826,8 +841,11 @@ class EditorJSCustom(EditorJSBlock, markdown2.Extra):
|
|
|
826
841
|
root = lxml.html.fromstring(html)
|
|
827
842
|
|
|
828
843
|
attributes = dict(root.attrib)
|
|
829
|
-
|
|
830
|
-
|
|
844
|
+
|
|
845
|
+
# support both innerText + innerHTML:
|
|
846
|
+
inner_html = (root.text or "") + "".join(
|
|
847
|
+
lxml.html.tostring(child, encoding="unicode", with_tail=True)
|
|
848
|
+
for child in root
|
|
831
849
|
)
|
|
832
850
|
|
|
833
851
|
return attributes, inner_html
|
|
@@ -845,7 +863,6 @@ class EditorJSCustom(EditorJSBlock, markdown2.Extra):
|
|
|
845
863
|
handler = BLOCKS.get(_type)
|
|
846
864
|
|
|
847
865
|
if not handler:
|
|
848
|
-
raise ValueError(f"debug: {attrs = } {body = }") # fixme
|
|
849
866
|
raise ValueError(f"Unknown custom type {_type}")
|
|
850
867
|
|
|
851
868
|
return handler, attrs
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: edwh-editorjs
|
|
3
|
-
Version: 2.6.
|
|
3
|
+
Version: 2.6.2
|
|
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>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
editorjs/__about__.py,sha256=
|
|
1
|
+
editorjs/__about__.py,sha256=53Sii4w6BIWn-1RhaTyqUO46gDe4nDCRQDAcpsWFH24,22
|
|
2
2
|
editorjs/__init__.py,sha256=-OHUf7ZXfkbdFB1r85eIjpHRfql-GCNUCKuBEdEt2Rc,58
|
|
3
|
-
editorjs/blocks.py,sha256=
|
|
3
|
+
editorjs/blocks.py,sha256=0tBuIHmDlAL_G4-SZ_zmJ9gGLabWjqAixKV2yjxbkPM,30201
|
|
4
4
|
editorjs/core.py,sha256=4igv2l8Rm1S92kxKrIXGIUlNHh6pnjq8F28XQr91I9o,4510
|
|
5
5
|
editorjs/exceptions.py,sha256=oKuWqi4CSnFGZfVZWtTZ2XZeHXm5xF-nAtX_1YLm6sI,230
|
|
6
6
|
editorjs/helpers.py,sha256=q861o5liNibMTp-Ozay17taF7CTNsRe901lYhhxdwHg,73
|
|
7
7
|
editorjs/types.py,sha256=W7IZWMWgzJaQulybIt0Gx5N63rVj4mEy73VJWo4VAQA,1029
|
|
8
|
-
edwh_editorjs-2.6.
|
|
9
|
-
edwh_editorjs-2.6.
|
|
10
|
-
edwh_editorjs-2.6.
|
|
8
|
+
edwh_editorjs-2.6.2.dist-info/METADATA,sha256=x6iZwk2IpCW6QRcLfbnUURH-0B3eTpSY5QBjw-NXBxQ,1045
|
|
9
|
+
edwh_editorjs-2.6.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
10
|
+
edwh_editorjs-2.6.2.dist-info/RECORD,,
|
|
File without changes
|