-
-
Notifications
You must be signed in to change notification settings - Fork 742
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
HtmlReactPlugin serialize error: Cannot resolve a DOM point from Slate point: {"path":[0,0],"offset":1} #3553
Labels
bug
Something isn't working
Comments
I'm also facing this problem. I'm find many ways but still not any solution 😞 |
same here... |
I have same issue but I saw the issue which can solved #2804 |
Put editor.api.htmlReact.serialize({nodes:editor.children}) in a separate function. as it can't be use inside Plate's onChange handler. // PLATE COMPONENTS
import { Editor } from "@/components/plate-ui/Editor";
import { FixedToolbar } from "@/components/plate-ui/FixedToolbar";
import { FixedToolbarButtons } from "@/components/plate-ui/fixed-toolbar-buttons";
import { TooltipProvider } from "@/components/plate-ui/Tooltip";
import { useCreateEditor } from "@/hooks/useCreateEditor";
import { useEffect, useRef, useState } from "react";
import { Plate } from "@udecode/plate-common/react";
export const EditorComponent = () => {
const [content, setContent] = useState<any>("");
const [_html, setHTML] = useState<any>("");
const [isClicked, setIsClicked] = useState<boolean>(false);
const containerRef = useRef(null);
const editor = useCreateEditor();
useEffect(() => {
console.log("CONTENT", content);
}, [content, _html]);
const converToHtml = () => {
const html = editor.api.htmlReact.serialize({
nodes: content,
stripDataAttributes: false,
stripWhitespace: false,
// preserveClassNames: ["slate-h1", "slate-h2", "slate-h3"],
});
setHTML(html);
console.log("Serialized HTML:", html);
setIsClicked(true);
console.log("HTML", _html);
};
return (
<>
<Plate
editor={editor}
onChange={({ value }) => {
setContent(value);
}}
>
<FixedToolbar className="sticky">
<FixedToolbarButtons />
</FixedToolbar>
<TooltipProvider>
<Editor ref={containerRef} className="h-auto" />
</TooltipProvider>
</Plate>
<button
className="border bg-purple-900 text-white text-2xl rounded-md p-2"
onClick={converToHtml}
>
convert to HTML
</button>
{isClicked ? (
<div
className="w-full border border-black h-[100vh]"
dangerouslySetInnerHTML={{ __html: _html }}
/>
) : null}
</>
);
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
I Follow the doc and create a basic editor. Calling htmlReact.serialize causes a error: Cannot resolve a DOM point from Slate point: {"path":[0,0],"offset":1}
Reproduction URL
No response
Reproduction steps
Plate version
38.0.4
Slate React version
0.110.1
Screenshots
No response
Logs
No response
Browsers
Chrome
Funding
The text was updated successfully, but these errors were encountered: