-
DescriptionWhen using the Reproduction URLNo response Reproduction steps1. Create a table
2. Setup a button to serialize to html
3. Error is thrown in the `overriddenColSizes` part of `useTableColSizes` Plate version49.0.3 Slate React version0.117.1 ScreenshotsBrowsersChrome |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Hi @aw1875! I'm Dosu and I’m helping the plate team. This error happens because the table column sizing logic ( To work around this, you can try wrapping your static table renderer with To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
@dosu The const editor = useMemo(() => createPlateEditor({ plugins: [ToolbarKit] }), []);
const contentRef = useRef<HTMLDivElement | null>(null);
useImperativeHandle(ref, () => ({
get htmlContent() {
return (async () => {
const html = await serializeHtml(editor, {
stripDataAttributes: true,
stripClassNames: true,
});
console.log(html);
return html;
})();
},
}));
return (
<Plate editor={editor}>
<PlateContent
ref={contentRef}
placeholder="Write text here..."
{...props}
/>
</Plate>
); |
Beta Was this translation helpful? Give feedback.
-
The error happens because To fix the crash, update const colSizeOverrides = useTableValue?.('colSizeOverrides') ?? new Map(); or, inside the selector: if (!tableNode) return []; This matches defensive patterns used elsewhere in Plate and will prevent the crash during serialization. You don't need to add To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
@dosu The answer is to use static components. Link the docs to static rendering. |
Beta Was this translation helpful? Give feedback.
To avoid context-related errors when serializing to HTML, use Plate's static components instead of interactive ones. Static rendering is designed for server-side and HTML export—these components don't rely on React context like TableProvider, so you won't hit issues with hooks such as useTableColSizes.
You can find more details and examples in the Plate static rendering guide:
https://platejs.org/docs/guides/static-rendering
This approach is also reflected in the codebase, where components like PlateStatic and SlateElement are used for static output and HTML serialization (see PR #3744).
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | …