edwh-editorjs 2.0.0b5__py3-none-any.whl → 2.0.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.0.0-beta.5"
1
+ __version__ = "2.0.2"
editorjs/blocks.py CHANGED
@@ -130,6 +130,14 @@ class HeadingBlock(EditorJSBlock):
130
130
  return child.get("value", "")
131
131
 
132
132
 
133
+ def paragraph_block(text: str):
134
+ return {"type": "paragraph", "data": {"text": text}}
135
+
136
+
137
+ def raw_block(html: str):
138
+ return {"type": "raw", "data": {"html": html}}
139
+
140
+
133
141
  @block("paragraph")
134
142
  class ParagraphBlock(EditorJSBlock):
135
143
  @classmethod
@@ -144,6 +152,7 @@ class ParagraphBlock(EditorJSBlock):
144
152
 
145
153
  skip = 0
146
154
  nodes = node.get("children", [])
155
+ any_html = False
147
156
 
148
157
  for idx, child in enumerate(nodes):
149
158
  if skip:
@@ -151,6 +160,7 @@ class ParagraphBlock(EditorJSBlock):
151
160
  continue
152
161
 
153
162
  _type = child.get("type")
163
+ any_html |= _type == "html"
154
164
 
155
165
  # deal with custom types
156
166
  if _type == "html" and child.get("value", "").startswith("<editorjs"):
@@ -163,7 +173,7 @@ class ParagraphBlock(EditorJSBlock):
163
173
  else:
164
174
  # <editorjs>something</editorjs> = 3 children
165
175
  result.extend(
166
- EditorJSCustom.to_json({"children": nodes[idx : idx + 2]})
176
+ EditorJSCustom.to_json({"children": nodes[idx: idx + 2]})
167
177
  )
168
178
 
169
179
  skip = 2
@@ -171,8 +181,10 @@ class ParagraphBlock(EditorJSBlock):
171
181
 
172
182
  elif _type == "image":
173
183
  if current_text:
174
- result.append({"data": {"text": current_text}, "type": "paragraph"})
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))
175
186
  current_text = ""
187
+ any_html = False # reset
176
188
 
177
189
  result.extend(ImageBlock.to_json(child))
178
190
  else:
@@ -191,7 +203,7 @@ class ParagraphBlock(EditorJSBlock):
191
203
 
192
204
  # final text after image:
193
205
  if current_text:
194
- result.append({"data": {"text": current_text}, "type": "paragraph"})
206
+ result.append(raw_block(current_text) if any_html else paragraph_block(current_text))
195
207
 
196
208
  return result
197
209
 
@@ -493,8 +505,10 @@ class TableBlock(EditorJSBlock):
493
505
  return [
494
506
  {
495
507
  "type": "table",
496
- "content": table,
497
- "withHeadings": with_headings,
508
+ "data": {
509
+ "content": table,
510
+ "withHeadings": with_headings,
511
+ }
498
512
  }
499
513
  ]
500
514
 
@@ -585,7 +599,7 @@ class AttachmentBlock(EditorJSBlock):
585
599
  </div>
586
600
  </div>
587
601
  <div class="cdx-attaches__file-info">
588
- <div class="cdx-attaches__title" contenteditable="true" data-placeholder="File title" data-empty="false">
602
+ <div class="cdx-attaches__title" data-placeholder="File title" data-empty="false">
589
603
  {node.get("body", "")}
590
604
  </div>
591
605
  </div>
@@ -1,11 +1,9 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: edwh-editorjs
3
- Version: 2.0.0b5
3
+ Version: 2.0.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>
7
- License: MIT
8
- License-File: LICENSE
9
7
  Keywords: bleach,clean,editor,editor.js,html,javascript,json,parser,wysiwyg
10
8
  Classifier: Development Status :: 4 - Beta
11
9
  Classifier: Intended Audience :: Developers
@@ -0,0 +1,10 @@
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,,
@@ -1,11 +0,0 @@
1
- editorjs/__about__.py,sha256=iiD2kTPXmXAM5kRpno4Whrabsdag8WZSPimzcYKughY,29
2
- editorjs/__init__.py,sha256=-OHUf7ZXfkbdFB1r85eIjpHRfql-GCNUCKuBEdEt2Rc,58
3
- editorjs/blocks.py,sha256=RJw1uxROQOw_dRwHnwPFD2gFcXCZnlCUw55iulh8-70,21687
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.0b5.dist-info/METADATA,sha256=qjO0kFBb6OYFksbsWyZP7NOTJB8GraJI2L3GUmPPyrM,1009
9
- edwh_editorjs-2.0.0b5.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
10
- edwh_editorjs-2.0.0b5.dist-info/licenses/LICENSE,sha256=zzllbk0pvnmgzk31iq8Zkg0GkA8vVx_Zc3OHjVlTjxo,1101
11
- edwh_editorjs-2.0.0b5.dist-info/RECORD,,
@@ -1,22 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 SKevo
4
- Copyright (c) 2024 Education Warehouse
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in all
14
- copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- SOFTWARE.