** Warning this cube is not intended for use in production currently **
Summary
Add editorjs format for RichString. This cube adds the application/vnd.cubicweb.editorjs mimetype to the available formats for RichStrings. It also adds a widget which allows to edit the RichString using the EditorJS library (a WYSIWYG editor).
Status of this project
This project has been initiated as a POC to test integration of EditorJS in CubicWeb.
Features:
- setting the format of a RichString to application/vnd.cubicweb.editorjs
- edition on an already existing RichString attribute with EditorJS
- rendering a RichString using this mime type in some conditions (see below)
- RQL plugin allowing to edit and execute RQL queries
Known bugs:
- when switching to application/vnd.cubicweb.editorjs the editor is not loaded which means that only already saved attributes can be edited with EditorJS
- the rich string is not rendered when it is asynchroneously loaded (after the page's scripts have run). This happens with CubicWeb web in tab views.
- the breadcrumb displays the json instead of a rendered version of the RichString
- it makes automatic tests of client cubes fail
Implementation flaws:
- the implementation use monkeypatches to
- add the application/vnd.cubicweb.editorjs format to the known format list
- override some views
- override entities
printable_valuemethod (might not be the best place to add the widget)
- missing mttransforms for application/vnd.cubicweb.editorjs to html
- images uploads are not supported
Usage in react applications
React applications don't suffer most of the problems seen above as they handle the rendering themselves. Displaying an EditorJS is as easy as:
function Edit() {
const instanceRef = React.useRef<EditorJS | null>(null);
async function handleSave() {
if (instanceRef.current !== null) {
const savedData = await instanceRef.current.save();
rqlClient.queryRows(
`Set X content %(content)s Where X is BlogEntry, X eid ${eid}`,
{ content: JSON.stringify(savedData) }
);
}
}
return (
<>
<EditorJs
instanceRef={(instance) => (instanceRef.current = instance)}
data={JSON.parse(blogEntry.content)}
/>
<button onClick={handleSave}>Save</button>
</>
)
}
For rendering, a library like https://github.com/jeremyrajan/editorjs2html can be used.
if (contentFormat === "application/vnd.cubicweb.editorjs") {
const edjsParser = EditorJsToHTML();
const html = edjsParser.parse(JSON.parse(blogEntry.content)).join("");
return <div dangerouslySetInnerHTML={{ __html: html }} />;
}
Metadata
Release files for cubicweb-editorjs 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cubicweb_editorjs-0.3.0.tar.gz | 7.8 kB | Without provenance | Details for cubicweb_editorjs-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cubicweb_editorjs-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for cubicweb_editorjs-0.3.0-py3-none-any.whl |
Total release size: 15.0 kB
Release files / cubicweb_editorjs-0.3.0.tar.gz
| Download URL | cubicweb_editorjs-0.3.0.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
af5b7473bc63e8774916cdc6f1e337b2b1c3790b773327f84739d2d17d022c11
|
|
BLAKE2b-256 checksum How to use checksums |
27215aa260de19c2d475336d7a35bda333b66076b9c1bab7124783ed289b44f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / cubicweb_editorjs-0.3.0-py3-none-any.whl
| Download URL | cubicweb_editorjs-0.3.0-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c6f3f6be838383f577230029ffd1995b8e1b6d12d61a63341f4a0f2784f80603
|
|
BLAKE2b-256 checksum How to use checksums |
b0ad1e03b5e3fa6ad431dcbd1b72064cf637ac71a7d0e9d4baa985d8c10b33c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Security for cubicweb-editorjs 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.