edwh-editorjs 2.5.0a2__py3-none-any.whl → 2.5.0a4__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.5.0a2"
1
+ __version__ = "2.5.0a4"
editorjs/blocks.py CHANGED
@@ -15,6 +15,7 @@ from .exceptions import TODO, Unreachable
15
15
  from .types import EditorChildData, MDChildNode
16
16
  import html2markdown
17
17
 
18
+
18
19
  class EditorJSBlock(abc.ABC):
19
20
  @classmethod
20
21
  @abc.abstractmethod
@@ -53,6 +54,9 @@ 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
+
58
+ print('process_styled_content', _type)
59
+
56
60
  html_wrappers = {
57
61
  "text": "{value}",
58
62
  "html": "{value}",
@@ -82,9 +86,16 @@ def process_styled_content(item: MDChildNode, strict: bool = True) -> str:
82
86
 
83
87
 
84
88
  def default_to_text(node: MDChildNode):
85
- return "".join(
86
- process_styled_content(child) for child in node.get("children", [])
87
- ) or process_styled_content(node)
89
+ if node["type"] == "paragraph":
90
+ return "".join(
91
+ process_styled_content(child) for child in node.get("children", [])
92
+ )
93
+ else:
94
+ return process_styled_content(node)
95
+
96
+ # return "".join(
97
+ # process_styled_content(child) for child in node.get("children", [])
98
+ # ) or process_styled_content(node)
88
99
 
89
100
 
90
101
  @block("heading", "header")
@@ -99,9 +110,9 @@ class HeadingBlock(EditorJSBlock):
99
110
  raise ValueError("Header level must be between 1 and 6.")
100
111
 
101
112
  if (
102
- tunes.get("alignmentTune")
103
- and (alignment := tunes["alignmentTune"].get("alignment"))
104
- and (alignment != "left")
113
+ tunes.get("alignmentTune")
114
+ and (alignment := tunes["alignmentTune"].get("alignment"))
115
+ and (alignment != "left")
105
116
  ):
106
117
  # can't just return regular HTML because then it will turn into a raw block
107
118
  return AlignmentBlock.to_markdown(
@@ -161,9 +172,9 @@ class ParagraphBlock(EditorJSBlock):
161
172
  tunes = data.get("tunes", {})
162
173
 
163
174
  if (
164
- tunes.get("alignmentTune")
165
- and (alignment := tunes["alignmentTune"].get("alignment"))
166
- and (alignment != "left")
175
+ tunes.get("alignmentTune")
176
+ and (alignment := tunes["alignmentTune"].get("alignment"))
177
+ and (alignment != "left")
167
178
  ):
168
179
  return AlignmentBlock.to_markdown(
169
180
  {
@@ -205,7 +216,7 @@ class ParagraphBlock(EditorJSBlock):
205
216
  else:
206
217
  # <editorjs>something</editorjs> = 3 children
207
218
  result.extend(
208
- EditorJSCustom.to_json({"children": nodes[idx : idx + 2]})
219
+ EditorJSCustom.to_json({"children": nodes[idx: idx + 2]})
209
220
  )
210
221
 
211
222
  skip = 2
@@ -470,7 +481,7 @@ class QuoteBlock(EditorJSBlock):
470
481
  result = f"> {text}\n"
471
482
  if caption := data.get("caption", ""):
472
483
  result += f"> <cite>{caption}</cite>\n"
473
- return result
484
+ return result + "\n"
474
485
 
475
486
  @classmethod
476
487
  def to_json(cls, node: MDChildNode) -> list[dict]:
@@ -496,7 +507,9 @@ class QuoteBlock(EditorJSBlock):
496
507
 
497
508
  @classmethod
498
509
  def to_text(cls, node: MDChildNode) -> str:
499
- return default_to_text(node)
510
+ return "".join(
511
+ process_styled_content(child) for child in node.get("children", [])
512
+ )
500
513
 
501
514
 
502
515
  @block("raw", "html")
editorjs/core.py CHANGED
@@ -100,11 +100,13 @@ class EditorJS:
100
100
  try:
101
101
  blocks.extend(block.to_json(child))
102
102
  except Exception as e:
103
+
103
104
  warnings.warn(
104
105
  "to_json: Oh oh, unexpected block failure!",
105
106
  category=RuntimeWarning,
106
107
  source=e,
107
108
  )
109
+ raise e
108
110
  # if isinstance(e, TODO):
109
111
  # raise e
110
112
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: edwh-editorjs
3
- Version: 2.5.0a2
3
+ Version: 2.5.0a4
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=NsEXgGmZNz_m0FN93bP4ym1D0nmcEnCsVmXyWVDMaGI,24
2
+ editorjs/__init__.py,sha256=-OHUf7ZXfkbdFB1r85eIjpHRfql-GCNUCKuBEdEt2Rc,58
3
+ editorjs/blocks.py,sha256=Iq6JzxoD5a00ud3KsaUFacBD-zDf9wu1FL5ipxJI_h8,29140
4
+ editorjs/core.py,sha256=9qYmKHr-Wp8TqmMQNfmk0ZCgeARPo0QRS1IV_sLPRag,4535
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.0a4.dist-info/METADATA,sha256=iIPI5nHDiIjmqlXj3yhPe3AiEpIzGoIgxCGFr8oc3nk,1027
9
+ edwh_editorjs-2.5.0a4.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
10
+ edwh_editorjs-2.5.0a4.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- editorjs/__about__.py,sha256=O6yBsT7WZo17QYOgF3gqlE2IeQi3L0_e111Yrla6P-8,24
2
- editorjs/__init__.py,sha256=-OHUf7ZXfkbdFB1r85eIjpHRfql-GCNUCKuBEdEt2Rc,58
3
- editorjs/blocks.py,sha256=2E5H8fn92MNB8W8cHm6WGswBVJm9NO4O2zKuA-PdyMc,28776
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.0a2.dist-info/METADATA,sha256=lFBhrmXNrj0R4tyDCParEmEoGD1qHpvB3r8-p2-yPL4,1027
9
- edwh_editorjs-2.5.0a2.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
10
- edwh_editorjs-2.5.0a2.dist-info/RECORD,,