edwh-editorjs 2.0.2__py3-none-any.whl → 2.1.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 CHANGED
@@ -1 +1 @@
1
- __version__ = "2.0.2"
1
+ __version__ = "2.1.0"
editorjs/blocks.py CHANGED
@@ -143,7 +143,7 @@ class ParagraphBlock(EditorJSBlock):
143
143
  @classmethod
144
144
  def to_markdown(cls, data: EditorChildData) -> str:
145
145
  text = data.get("text", "")
146
- return f"{text}\n"
146
+ return f"{text}\n\n"
147
147
 
148
148
  @classmethod
149
149
  def to_json(cls, node: MDChildNode) -> list[dict]:
@@ -173,7 +173,7 @@ class ParagraphBlock(EditorJSBlock):
173
173
  else:
174
174
  # <editorjs>something</editorjs> = 3 children
175
175
  result.extend(
176
- EditorJSCustom.to_json({"children": nodes[idx: idx + 2]})
176
+ EditorJSCustom.to_json({"children": nodes[idx : idx + 2]})
177
177
  )
178
178
 
179
179
  skip = 2
@@ -182,7 +182,11 @@ class ParagraphBlock(EditorJSBlock):
182
182
  elif _type == "image":
183
183
  if current_text:
184
184
  # {"id":"zksvpxQTDD","type":"raw","data":{"html":"<marquee> raw </marquee>"}}
185
- result.append(raw_block(current_text) if any_html else paragraph_block(current_text))
185
+ result.append(
186
+ raw_block(current_text)
187
+ if any_html
188
+ else paragraph_block(current_text)
189
+ )
186
190
  current_text = ""
187
191
  any_html = False # reset
188
192
 
@@ -203,7 +207,9 @@ class ParagraphBlock(EditorJSBlock):
203
207
 
204
208
  # final text after image:
205
209
  if current_text:
206
- result.append(raw_block(current_text) if any_html else paragraph_block(current_text))
210
+ result.append(
211
+ raw_block(current_text) if any_html else paragraph_block(current_text)
212
+ )
207
213
 
208
214
  return result
209
215
 
@@ -439,7 +445,8 @@ class RawBlock(EditorJSBlock):
439
445
 
440
446
  @classmethod
441
447
  def to_markdown(cls, data: EditorChildData) -> str:
442
- return data.get("html", "")
448
+ text = data.get("html", "")
449
+ return f"{text}\n\n"
443
450
 
444
451
  @classmethod
445
452
  def to_json(cls, node: MDChildNode) -> list[dict]:
@@ -508,7 +515,7 @@ class TableBlock(EditorJSBlock):
508
515
  "data": {
509
516
  "content": table,
510
517
  "withHeadings": with_headings,
511
- }
518
+ },
512
519
  }
513
520
  ]
514
521
 
editorjs/core.py CHANGED
@@ -31,13 +31,14 @@ class EditorJS:
31
31
  self._md = markdown2.Markdown(extras=extras) # todo: striketrough, ?
32
32
 
33
33
  @classmethod
34
- def from_json(cls, data: str | dict) -> Self:
34
+ def from_json(cls, data: str | dict | list) -> Self:
35
35
  """
36
36
  Load from EditorJS JSON Blocks
37
37
  """
38
- data = data if isinstance(data, dict) else json.loads(data)
38
+ data = data if isinstance(data, (dict, list)) else json.loads(data)
39
+ blocks = data["blocks"] if isinstance(data, dict) else data
39
40
  markdown_items = []
40
- for child in data["blocks"]:
41
+ for child in blocks:
41
42
  _type = child["type"]
42
43
  if not (block := BLOCKS.get(_type)):
43
44
  raise TypeError(f"Unsupported block type `{_type}`")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: edwh-editorjs
3
- Version: 2.0.2
3
+ Version: 2.1.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>
@@ -0,0 +1,10 @@
1
+ editorjs/__about__.py,sha256=Xybt2skBZamGMNlLuOX1IG-h4uIxqUDGAO8MIGWrJac,22
2
+ editorjs/__init__.py,sha256=-OHUf7ZXfkbdFB1r85eIjpHRfql-GCNUCKuBEdEt2Rc,58
3
+ editorjs/blocks.py,sha256=kQxmx8QDDVhb1YP6JTFOCKGTYHfcbGswtkryorp1Cn8,22285
4
+ editorjs/core.py,sha256=T_7pOzLp7dBxxFSgfG0-ogZShVKaUBd5h_PEEuuSzdQ,3406
5
+ editorjs/exceptions.py,sha256=TyfHvk2Z5RbKxTDK7lrjgwAgVgInXIuDW63eO5jzVFw,106
6
+ editorjs/helpers.py,sha256=q861o5liNibMTp-Ozay17taF7CTNsRe901lYhhxdwHg,73
7
+ editorjs/types.py,sha256=W7IZWMWgzJaQulybIt0Gx5N63rVj4mEy73VJWo4VAQA,1029
8
+ edwh_editorjs-2.1.0.dist-info/METADATA,sha256=DmCP8FVdXpma3tupQeNLLTOKMSVpt6qYZTIAxaRo6qY,972
9
+ edwh_editorjs-2.1.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
10
+ edwh_editorjs-2.1.0.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- editorjs/__about__.py,sha256=tATvJM5shAzfspHYjdVwpV2w3-gDA119NlEYi5X2lFY,22
2
- editorjs/__init__.py,sha256=-OHUf7ZXfkbdFB1r85eIjpHRfql-GCNUCKuBEdEt2Rc,58
3
- editorjs/blocks.py,sha256=LN7u3p_VT5kYn5FL_IW2MHoHDh_9JjcnlDPbf_0d4M8,22128
4
- editorjs/core.py,sha256=CdZnprX-vkjFJATxPfG1acDqGKkHa3mDfbMEeXiR6eI,3331
5
- editorjs/exceptions.py,sha256=TyfHvk2Z5RbKxTDK7lrjgwAgVgInXIuDW63eO5jzVFw,106
6
- editorjs/helpers.py,sha256=q861o5liNibMTp-Ozay17taF7CTNsRe901lYhhxdwHg,73
7
- editorjs/types.py,sha256=W7IZWMWgzJaQulybIt0Gx5N63rVj4mEy73VJWo4VAQA,1029
8
- edwh_editorjs-2.0.2.dist-info/METADATA,sha256=kZ1FReSETMZKdmVEPAzh_Vk0Te7I3d4G5Edc8fd5TRE,972
9
- edwh_editorjs-2.0.2.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
10
- edwh_editorjs-2.0.2.dist-info/RECORD,,