edwh-editorjs 2.5.0a3__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.0a3"
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
@@ -248,8 +259,7 @@ class ParagraphBlock(EditorJSBlock):
248
259
 
249
260
  @classmethod
250
261
  def to_text(cls, node: MDChildNode) -> str:
251
- return process_styled_content(node)
252
- # return default_to_text(node)
262
+ return default_to_text(node)
253
263
 
254
264
 
255
265
  @block("list")
@@ -471,7 +481,7 @@ class QuoteBlock(EditorJSBlock):
471
481
  result = f"> {text}\n"
472
482
  if caption := data.get("caption", ""):
473
483
  result += f"> <cite>{caption}</cite>\n"
474
- return result
484
+ return result + "\n"
475
485
 
476
486
  @classmethod
477
487
  def to_json(cls, node: MDChildNode) -> list[dict]:
@@ -497,7 +507,9 @@ class QuoteBlock(EditorJSBlock):
497
507
 
498
508
  @classmethod
499
509
  def to_text(cls, node: MDChildNode) -> str:
500
- return default_to_text(node)
510
+ return "".join(
511
+ process_styled_content(child) for child in node.get("children", [])
512
+ )
501
513
 
502
514
 
503
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.0a3
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=_Fi21vxW1-XrA5cHGBb0PFyoSSWodIDwtSp_YSMc2l8,24
2
- editorjs/__init__.py,sha256=-OHUf7ZXfkbdFB1r85eIjpHRfql-GCNUCKuBEdEt2Rc,58
3
- editorjs/blocks.py,sha256=g8doq2Fykv78Z8Vytgz5IT0cdhTDvadaSDUTAq97iRA,28822
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.0a3.dist-info/METADATA,sha256=6uJqNbhmqS6w0Y50xPOCA1J2lVJUDvOvs6yNDsY7tSE,1027
9
- edwh_editorjs-2.5.0a3.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
10
- edwh_editorjs-2.5.0a3.dist-info/RECORD,,