You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use "draft-convert" package on Node.js servide side. When I call convertFromHTML(html) , I got the following error:
ReferenceError: document is not defined
at fallback (/node_modules/draft-convert/lib/util/parseHTML.js:9:13)
at parseHTML (/node_modules/draft-convert/lib/util/parseHTML.js:25:11)
at getChunkForHTML (/node_modules/draft-convert/lib/convertFromHTML.js:458:18)
I followed some online posts to pass DOMBuilder function as a second parameter to convertFromHTML() like the following:
// Define the DOMBuilder function
function DOMBuilder(html) {
const dom = new JSDOM(<!DOCTYPE html><body>${html}</body>);
return dom.window.document.body;
}
// Call convertFromHTML with the DOMBuilder function and required classes
const html = 'Hello Text';
const contentState = convertFromHTML(html, DOMBuilder);
However, I still got the same "document is not defined" error.
Does anyone have the same problem when using this package on Node.js? I am using the latest version of "draft-convert".
The text was updated successfully, but these errors were encountered:
Hi,
I am trying to use "draft-convert" package on Node.js servide side. When I call convertFromHTML(html) , I got the following error:
ReferenceError: document is not defined
at fallback (/node_modules/draft-convert/lib/util/parseHTML.js:9:13)
at parseHTML (/node_modules/draft-convert/lib/util/parseHTML.js:25:11)
at getChunkForHTML (/node_modules/draft-convert/lib/convertFromHTML.js:458:18)
I followed some online posts to pass DOMBuilder function as a second parameter to convertFromHTML() like the following:
// Define the DOMBuilder function
function DOMBuilder(html) {
const dom = new JSDOM(
<!DOCTYPE html><body>${html}</body>
);return dom.window.document.body;
}
// Call convertFromHTML with the DOMBuilder function and required classes
const html = 'Hello Text';
const contentState = convertFromHTML(html, DOMBuilder);
However, I still got the same "document is not defined" error.
Does anyone have the same problem when using this package on Node.js? I am using the latest version of "draft-convert".
The text was updated successfully, but these errors were encountered: