edwh-editorjs 1.0.1__tar.gz → 1.1.0__tar.gz
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.
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/CHANGELOG.md +12 -4
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/PKG-INFO +37 -6
- edwh_editorjs-1.1.0/README.md +79 -0
- edwh_editorjs-1.1.0/pyeditorjs/__about__.py +1 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/pyeditorjs/__init__.py +3 -1
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/pyeditorjs/blocks.py +4 -0
- edwh_editorjs-1.0.1/README.md +0 -48
- edwh_editorjs-1.0.1/pyeditorjs/__about__.py +0 -1
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/.github/workflows/build_documentation.yml +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/.github/workflows/publish_to_pypi.yml +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/.github/workflows/pytest.yml +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/.gitignore +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/LICENSE +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/htmlcov/.gitignore +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/htmlcov/class_index.html +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/htmlcov/favicon_32_cb_58284776.png +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/htmlcov/function_index.html +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/htmlcov/index.html +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/htmlcov/keybd_closed_cb_ce680311.png +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/htmlcov/status.json +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/htmlcov/style_cb_8e611ae1.css +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/htmlcov/z_a93c8aeb4b8fa1f9___init___py.html +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/htmlcov/z_a93c8aeb4b8fa1f9_blocks_py.html +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/htmlcov/z_a93c8aeb4b8fa1f9_exceptions_py.html +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/htmlcov/z_a93c8aeb4b8fa1f9_parser_py.html +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/pyeditorjs/exceptions.py +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/pyeditorjs/parser.py +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/pyproject.toml +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/requirements.txt +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/scripts/build_documentation.sh +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/scripts/compile_everything.sh +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/scripts/compile_for_pypi.sh +0 -0
- {edwh_editorjs-1.0.1 → edwh_editorjs-1.1.0}/tests/test_parser.py +0 -0
|
@@ -2,9 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
<!--next-version-placeholder-->
|
|
4
4
|
|
|
5
|
+
## v1.1.0 (2024-10-31)
|
|
6
|
+
|
|
7
|
+
### Feature
|
|
8
|
+
|
|
9
|
+
* Expose _sanitize via EditorJSBlock.sanitize for external usage ([`7daa67c`](https://github.com/educationwarehouse/edwh-editorjs/commit/7daa67c90440510c83b573c22edf377cc2fd801f))
|
|
10
|
+
|
|
11
|
+
### Documentation
|
|
12
|
+
|
|
13
|
+
* Added section on defining new custom blocks ([`51d7720`](https://github.com/educationwarehouse/edwh-editorjs/commit/51d77208d4f8156e895de914f41bdeb882a508c0))
|
|
14
|
+
|
|
5
15
|
## v1.0.1 (2024-10-31)
|
|
6
16
|
|
|
17
|
+
### Documentation
|
|
7
18
|
|
|
19
|
+
* Updated README ([`18d0216`](https://github.com/educationwarehouse/edwh-editorjs/commit/18d021629bcb223b89a9731e9ad8c574248f75c7))
|
|
8
20
|
|
|
9
21
|
## v1.0.0 (2024-10-31)
|
|
10
22
|
|
|
@@ -12,7 +24,3 @@
|
|
|
12
24
|
|
|
13
25
|
* Implemented more blocks (raw, warning, code, table, quote) ([`fb93bd9`](https://github.com/educationwarehouse/edwh-editorjs/commit/fb93bd959f06fa86bc23c9bfc51a8b7fddfc65f2))
|
|
14
26
|
* Refactor to Registry Pattern so new block can be easily added ([`b06c86d`](https://github.com/educationwarehouse/edwh-editorjs/commit/b06c86da623dd2a2d92f7c48353a1f3208fb5749))
|
|
15
|
-
|
|
16
|
-
### Documentation
|
|
17
|
-
|
|
18
|
-
* Updated README ([`18d0216`](https://github.com/educationwarehouse/edwh-editorjs/commit/18d021629bcb223b89a9731e9ad8c574248f75c7))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: edwh-editorjs
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: pyEditorJS
|
|
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>
|
|
@@ -25,7 +25,7 @@ Description-Content-Type: text/markdown
|
|
|
25
25
|
|
|
26
26
|
# edwh-editorjs
|
|
27
27
|
|
|
28
|
-
A minimal, fast Python 3.10+ package for parsing [Editor.js](https://editorjs.io) content.
|
|
28
|
+
A minimal, fast Python 3.10+ package for parsing [Editor.js](https://editorjs.io) content.
|
|
29
29
|
This package is a fork of [pyEditorJS by SKevo](https://github.com/SKevo18/pyEditorJS) with additional capabilities.
|
|
30
30
|
|
|
31
31
|
## New Features
|
|
@@ -46,7 +46,7 @@ pip install edwh-editorjs
|
|
|
46
46
|
### Quickstart
|
|
47
47
|
|
|
48
48
|
```python
|
|
49
|
-
from
|
|
49
|
+
from pyeditorjs import EditorJsParser
|
|
50
50
|
|
|
51
51
|
editor_js_data = ... # your Editor.js JSON data
|
|
52
52
|
parser = EditorJsParser(editor_js_data) # initialize the parser
|
|
@@ -58,15 +58,46 @@ print(html) # your clean HTML
|
|
|
58
58
|
### Enforcing Strict Block Types
|
|
59
59
|
|
|
60
60
|
```python
|
|
61
|
-
from
|
|
61
|
+
from pyeditorjs import EditorJsParser, EditorJSUnsupportedBlock
|
|
62
|
+
|
|
63
|
+
editor_js_data: dict = ...
|
|
64
|
+
parser = EditorJsParser(editor_js_data)
|
|
62
65
|
|
|
63
66
|
try:
|
|
64
|
-
|
|
65
|
-
html = parser.html()
|
|
67
|
+
html = parser.html(strict=True)
|
|
66
68
|
except EditorJSUnsupportedBlock as e:
|
|
67
69
|
print(f"Unsupported block type encountered: {e}")
|
|
68
70
|
```
|
|
69
71
|
|
|
72
|
+
### Adding a Custom Block
|
|
73
|
+
|
|
74
|
+
To add a custom block type, create a new class that subclasses `EditorJsBlock` and decorates it with `@block("name")`,
|
|
75
|
+
where `"name"` is the custom block type. Implement an `html` method to define how the block’s content should be
|
|
76
|
+
rendered. This method should accept a `sanitize` parameter and can access block data via `self.data`.
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from pyeditorjs import EditorJsParser, EditorJsBlock, block
|
|
80
|
+
|
|
81
|
+
@block("custom")
|
|
82
|
+
class CustomBlock(EditorJsBlock):
|
|
83
|
+
def html(self, sanitize: bool = False) -> str:
|
|
84
|
+
# Access data with self.data and return the rendered HTML
|
|
85
|
+
content = self.data.get("something", "")
|
|
86
|
+
if sanitize:
|
|
87
|
+
content = self.sanitize(content)
|
|
88
|
+
|
|
89
|
+
return f"<div class='custom-block'>{content}</div>"
|
|
90
|
+
|
|
91
|
+
# Usage
|
|
92
|
+
class CustomEditorJsParser(EditorJsParser):
|
|
93
|
+
pass # Custom blocks are automatically detected
|
|
94
|
+
|
|
95
|
+
editor_js_data = ... # Editor.js JSON data with a "customBlock" type
|
|
96
|
+
parser = CustomEditorJsParser(editor_js_data)
|
|
97
|
+
html = parser.html()
|
|
98
|
+
print(html) # Includes rendered custom blocks
|
|
99
|
+
```
|
|
100
|
+
|
|
70
101
|
## Disclaimer
|
|
71
102
|
|
|
72
103
|
This is a community-provided project and is not affiliated with the Editor.js team.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# edwh-editorjs
|
|
2
|
+
|
|
3
|
+
A minimal, fast Python 3.10+ package for parsing [Editor.js](https://editorjs.io) content.
|
|
4
|
+
This package is a fork of [pyEditorJS by SKevo](https://github.com/SKevo18/pyEditorJS) with additional capabilities.
|
|
5
|
+
|
|
6
|
+
## New Features
|
|
7
|
+
|
|
8
|
+
- Expanded support for additional block types: Quote, Table, Code, Warning, and Raw blocks
|
|
9
|
+
- Issues a warning if an unknown block type is encountered, rather than ignoring it
|
|
10
|
+
- Adds a `strict` mode, raising an `EditorJSUnsupportedBlock` exception for unknown block types when `strict=True`
|
|
11
|
+
- Allows adding new blocks by decorating a subclass of `EditorJsParser` with `@block("name")`
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install edwh-editorjs
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Quickstart
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from pyeditorjs import EditorJsParser
|
|
25
|
+
|
|
26
|
+
editor_js_data = ... # your Editor.js JSON data
|
|
27
|
+
parser = EditorJsParser(editor_js_data) # initialize the parser
|
|
28
|
+
|
|
29
|
+
html = parser.html(sanitize=True) # `sanitize=True` uses the included `bleach` dependency
|
|
30
|
+
print(html) # your clean HTML
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Enforcing Strict Block Types
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from pyeditorjs import EditorJsParser, EditorJSUnsupportedBlock
|
|
37
|
+
|
|
38
|
+
editor_js_data: dict = ...
|
|
39
|
+
parser = EditorJsParser(editor_js_data)
|
|
40
|
+
|
|
41
|
+
try:
|
|
42
|
+
html = parser.html(strict=True)
|
|
43
|
+
except EditorJSUnsupportedBlock as e:
|
|
44
|
+
print(f"Unsupported block type encountered: {e}")
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Adding a Custom Block
|
|
48
|
+
|
|
49
|
+
To add a custom block type, create a new class that subclasses `EditorJsBlock` and decorates it with `@block("name")`,
|
|
50
|
+
where `"name"` is the custom block type. Implement an `html` method to define how the block’s content should be
|
|
51
|
+
rendered. This method should accept a `sanitize` parameter and can access block data via `self.data`.
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from pyeditorjs import EditorJsParser, EditorJsBlock, block
|
|
55
|
+
|
|
56
|
+
@block("custom")
|
|
57
|
+
class CustomBlock(EditorJsBlock):
|
|
58
|
+
def html(self, sanitize: bool = False) -> str:
|
|
59
|
+
# Access data with self.data and return the rendered HTML
|
|
60
|
+
content = self.data.get("something", "")
|
|
61
|
+
if sanitize:
|
|
62
|
+
content = self.sanitize(content)
|
|
63
|
+
|
|
64
|
+
return f"<div class='custom-block'>{content}</div>"
|
|
65
|
+
|
|
66
|
+
# Usage
|
|
67
|
+
class CustomEditorJsParser(EditorJsParser):
|
|
68
|
+
pass # Custom blocks are automatically detected
|
|
69
|
+
|
|
70
|
+
editor_js_data = ... # Editor.js JSON data with a "customBlock" type
|
|
71
|
+
parser = CustomEditorJsParser(editor_js_data)
|
|
72
|
+
html = parser.html()
|
|
73
|
+
print(html) # Includes rendered custom blocks
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Disclaimer
|
|
77
|
+
|
|
78
|
+
This is a community-provided project and is not affiliated with the Editor.js team.
|
|
79
|
+
Contributions, bug reports, and suggestions are welcome!
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.1.0"
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
|
|
3
3
|
from .blocks import BLOCKS_MAP, EditorJsBlock, block
|
|
4
|
-
from .exceptions import EditorJsParseError
|
|
4
|
+
from .exceptions import EditorJsException, EditorJsParseError, EditorJSUnsupportedBlock
|
|
5
5
|
from .parser import EditorJsParser
|
|
6
6
|
|
|
7
7
|
__all__ = [
|
|
8
8
|
"EditorJsParser",
|
|
9
9
|
"EditorJsParseError",
|
|
10
|
+
"EditorJsException",
|
|
11
|
+
"EditorJSUnsupportedBlock",
|
|
10
12
|
"EditorJsBlock",
|
|
11
13
|
"block",
|
|
12
14
|
"BLOCKS_MAP",
|
edwh_editorjs-1.0.1/README.md
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# edwh-editorjs
|
|
2
|
-
|
|
3
|
-
A minimal, fast Python 3.10+ package for parsing [Editor.js](https://editorjs.io) content.
|
|
4
|
-
This package is a fork of [pyEditorJS by SKevo](https://github.com/SKevo18/pyEditorJS) with additional capabilities.
|
|
5
|
-
|
|
6
|
-
## New Features
|
|
7
|
-
|
|
8
|
-
- Expanded support for additional block types: Quote, Table, Code, Warning, and Raw blocks
|
|
9
|
-
- Issues a warning if an unknown block type is encountered, rather than ignoring it
|
|
10
|
-
- Adds a `strict` mode, raising an `EditorJSUnsupportedBlock` exception for unknown block types when `strict=True`
|
|
11
|
-
- Allows adding new blocks by decorating a subclass of `EditorJsParser` with `@block("name")`
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
pip install edwh-editorjs
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Usage
|
|
20
|
-
|
|
21
|
-
### Quickstart
|
|
22
|
-
|
|
23
|
-
```python
|
|
24
|
-
from edwh_editorjs import EditorJsParser
|
|
25
|
-
|
|
26
|
-
editor_js_data = ... # your Editor.js JSON data
|
|
27
|
-
parser = EditorJsParser(editor_js_data) # initialize the parser
|
|
28
|
-
|
|
29
|
-
html = parser.html(sanitize=True) # `sanitize=True` uses the included `bleach` dependency
|
|
30
|
-
print(html) # your clean HTML
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### Enforcing Strict Block Types
|
|
34
|
-
|
|
35
|
-
```python
|
|
36
|
-
from edwh_editorjs import EditorJsParser, EditorJSUnsupportedBlock
|
|
37
|
-
|
|
38
|
-
try:
|
|
39
|
-
parser = EditorJsParser(editor_js_data, strict=True)
|
|
40
|
-
html = parser.html()
|
|
41
|
-
except EditorJSUnsupportedBlock as e:
|
|
42
|
-
print(f"Unsupported block type encountered: {e}")
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## Disclaimer
|
|
46
|
-
|
|
47
|
-
This is a community-provided project and is not affiliated with the Editor.js team.
|
|
48
|
-
Contributions, bug reports, and suggestions are welcome!
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "1.0.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|