BUG: Can not get inline css code. how to use this?
Question
When I runCommand for inline CSS, It's giving me a warning and undefined.
Answers (1)
There is no built-in command to get inlined CSS, but you can find how it was implemented in the newsletter plugin here: https://github.com/artf/grapesjs-preset-newsletter/blob/master/src/openExportCommand.js
The core functionality is a few lines of code by using the juice package
import juice from 'juice';
// ...
const getInlined = (editor) => {
const html = editor.getHtml();
const css = editor.getCss();
return juice(`${html}<style>${css}</style>`, { /* juice options */ });
}
How and where to put that function, is up to you
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1633
[Bug]: editor.runCommand('gjs-get-inlined-html') returns undefined (preset-webpage)
Hi, Artur I'm using grapesjs-preset-webpage v0.1.10, grapesjs v0.14.29 I'm trying to save templates with inline css rather than having clas...
Issue #6152
BUG: CSS added via custom code persists after custom code component is removed
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? any Reproducible demo link https://grapesj...
Issue #4503
BUG: Missing inline styles used by CKEditor when adding raw html components
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chromium v96 Reproducible demo link https:...
Issue #3347
How can I get Uncompressed JS code for me to edit?
Hi, thank you for reviewing my problem. I want to use my own JSEditor to edit html、css and js. 1、First, I use getHtml, getCss, getJs to dis...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.