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

serializeHtml throws Invalid hook call error #13

Open
VanThuan76 opened this issue Nov 2, 2024 · 1 comment
Open

serializeHtml throws Invalid hook call error #13

VanThuan76 opened this issue Nov 2, 2024 · 1 comment

Comments

@VanThuan76
Copy link

Issue: serializeHtml from "@udecode/plate-html/react" not Including Styles

Description

I’m facing an issue with serializeHtml from @udecode/plate-html/react. The code I've used to approach this is as follows:

const plugins = [ ... ] //Same template
const excludedSelectionPlugin = plugins?.filter(plugin => plugin?.key !== 'toggle' && plugin?.key !== 'blockSelection' && plugin?.key === "ai" ); //Ignore invalid hook call
const html = serializeHtml(createPlateEditor({ plugins: excludedSelectionPlugin }), { nodes: editor?.children, data, dndWrapper: props => <DndProvider backend={HTML5Backend} {...props} />, })
console.log(html)

When I log the html value to the console, it returns the following without the expected @udecode/plate styles:
<div>Playground</div><div style="position: relative;">A rich-text editor with AI capabilities. Try the AI commands or use Cmd+J to open the AI menu.</div>

Expected Behavior

I expected serializeHtml to include the @udecode/plate styles in the generated HTML so that it could be used either directly on the client side or saved to a database with formatting intact.

Environment

  • OS: macOS 14.5
  • Node.js version: 21.5.0
  • npm version: 10.2.4

Library

  • "next": "14.2.1"
  • ...use the same library as in the template

Steps to Reproduce

Set up the plugins array as per the template and filter out unnecessary plugins.
Use serializeHtml to serialize the editor content.
Check the console log to see the HTML output.

Actual Behavior

The output HTML lacks the expected styles from @udecode/plate, resulting in plain HTML without the styling or formatting applied in the editor.

Additional Context

Assistance on how to ensure serializeHtml includes the necessary styles for client use or storage in a database would be greatly appreciated!

Thanks, @zbeyens 's template is extremely interesting!

@VanThuan76
Copy link
Author

In addition, I have reached this udecode/plate#2804 issue but I cannt figure out

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

No branches or pull requests

1 participant