html-mastergo
中文 | English
A library can convert html into MasterGo plugin data structures.
Install
yarn add html-mastergo | npm install html-mastergo
Usage
-
Install MasterGo client and init a plugin project.
-
Build UI
-
Use the library
import { htmlToMG, postProcess } from 'html-mastergo';
const convert = async () => {
const layerJson = await htmlToMG(document.body);
const processedJson = await postProcess(layerJson)
parent.postMessage({
type: 'generate',
data: processedJson
}, '*')
}
import { renderToMasterGo } from 'html-mastergo';
mg.ui.onmessage = (msg) => {
const { data, type } = msg
if (type === 'generate') {
renderToMasterGo(data).then(root => {
console.log('root node', root)
})
}
}
Limitations
A few known limitations:
- Not all element types are supported (e.g. iframes, pseudo-elements)
- Not all CSS properties are supported or fully supported
- Not all types of media are supported (video, animated gifs, etc)
- All fonts must be uploaded to MasterGo, otherwise the default fonts will be used for rendering
If you find any problems or have any feedback, please Ask a Question
Example
Example