Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server Endpoint for Converting HTML to Plate format #3177

Open
zbeyens opened this issue May 6, 2024 Discussed in #3005 · 1 comment
Open

Server Endpoint for Converting HTML to Plate format #3177

zbeyens opened this issue May 6, 2024 Discussed in #3005 · 1 comment
Labels

Comments

@zbeyens
Copy link
Member

zbeyens commented May 6, 2024

Discussed in #3005

Originally posted by mstelz February 29, 2024
Using NextJS I have an app/api/route.ts with the following:

export async function POST(request: Request) {
    const editor = createPlateEditor({ plugins });
    const json = deserializeHtml(editor, {element: request.body}
    
    return Response.json(json)
}

but when I try to run it I receive the error

TypeError: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component

What am I missing? I thought this was possible but correct me if I am wrong.

Thanks in advance!

Funding

  • You can sponsor this specific effort via a Polar.sh pledge below
  • We receive the pledge once the issue is completed & verified
Fund with Polar
@zbeyens
Copy link
Member Author

zbeyens commented May 6, 2024

This PR made progress on this issue: #3125. We now have a @udecode/plate-common/server entrypoint for createPlateEditor. In Plate 33, all serializers work server-side except the html one.

TODOs:

  • server bundle for each node plugin to be used with deserializeHtml
  • serializeHtml currently depends on React so this one will need a rework using the same pattern than deserializeHtml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant