Skip to content

Provide a JsonCompatible adapter for RichTextValue objects - #1584

Open
erral wants to merge 1 commit into
mainfrom
erral-issue-1583
Open

Provide a JsonCompatible adapter for RichTextValue objects#1584
erral wants to merge 1 commit into
mainfrom
erral-issue-1583

Conversation

@erral

@erral erral commented Feb 13, 2023

Copy link
Copy Markdown
Member

Fixes #1583

@mister-roboto

Copy link
Copy Markdown

@erral thanks for creating this Pull Request and helping to improve Plone!

TL;DR: Finish pushing changes, pass all other checks, then paste a comment:

@jenkins-plone-org please run jobs

To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically.

Happy hacking!

@netlify

netlify Bot commented Feb 13, 2023

Copy link
Copy Markdown

Deploy Preview for plone-restapi canceled.

Name Link
🔨 Latest commit 29d679a
🔍 Latest deploy log https://app.netlify.com/sites/plone-restapi/deploys/63ea6980242d520008290caa

@netlify

netlify Bot commented Feb 13, 2023

Copy link
Copy Markdown

Deploy Preview for plone-restapi canceled.

Name Link
🔨 Latest commit 127d596
🔍 Latest deploy log https://app.netlify.com/sites/plone-restapi/deploys/63ea693863815c000827eb05

@jensens

jensens commented Feb 14, 2023

Copy link
Copy Markdown
Member

Your solution provides only the rendered safe-HTML. But what if we want to get the raw data from the field, for an editor or alike? This could be any content type as raw, i.e. markdown. I do not think this implementation is enough. I would expect something like a dict with output, raw and its configured types, i.e something like:

{
    "output": {
        "data": "<p>foo<p>",
        "type": "text/safe-html",
    "raw": {
        "data": "foo",
        "data": "text/plain",
}

@erral

erral commented Feb 14, 2023

Copy link
Copy Markdown
Member Author

This is the initial draft.

I first checked what happens when you add a simple HTML as a default value of the RichText field. I will test further with some other values.

@jensens

jensens commented Feb 14, 2023

Copy link
Copy Markdown
Member

OK! Since this is not a draft PR nor labels were applied, my understanding was like it is ready for review.

@erral erral changed the title Provide a JsonCompatible adapter for RichTextValue objects [draft] Provide a JsonCompatible adapter for RichTextValue objects Jan 16, 2025
@erral erral changed the title [draft] Provide a JsonCompatible adapter for RichTextValue objects Provide a JsonCompatible adapter for RichTextValue objects Jul 30, 2026
@erral
erral force-pushed the erral-issue-1583 branch from c6f6994 to 2c0cf64 Compare July 30, 2026 11:07
@erral

erral commented Jul 30, 2026

Copy link
Copy Markdown
Member Author

I have updated the PR to implement the more generic fallback mechanism discussed in issue #1583.

Instead of adding a new global adapter, I improved the json_compatible helper to fall back to the Plone site (getSite()) when no context is provided. This allows the existing context-aware converter for RichTextValue to work in all scenarios (nested, schema defaults, etc.) while keeping the output format consistent with standard fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide IJsonCompatible adapter for RichTextValue objects

4 participants