@mastergo/html-mastergo
Convert HTML to Mastergo code
895
60
| Install | |
|---|---|
npm install @mastergo/html-mastergo |
|
| Latest Version: | 1.10.0 |
| Vue: | 3 |
| License: | MIT |
| Last Updated: | Jul 12, 2024 |
| Links: | GitHub · npm |
Maintainer: mastergo-admin
html-mastergo
中文 | English
A library can convert html into MasterGo plugin data structures.
Install
yarn add @mastergo/html-mastergo | npm install @mastergo/html-mastergo
Usage
-
Install MasterGo client and init a plugin project.
-
Build UI(Click here MasterGo-Plugin if having trouble in how to develop plugins in MasterGo)
-
Use the library
/** UI side **/ import { htmlToMG, postProcess } from '@mastergo/html-mastergo'; // any dom element const convert = async () => { const layerJson = await htmlToMG(document.body); // Not necessary, you can do anything you want to do with json processed by the function htmlToMG. This is just one way to do it. const processedJson = await postProcess(layerJson) // post data to plugin parent.postMessage({ type: 'generate', data: processedJson }, '*') } /** Plugin side **/ import { renderToMasterGo } from '@mastergo/html-mastergo'; mg.ui.onmessage = (msg) => { const { data, type } = msg if (type === 'generate') { // traverse renderToMasterGo(data).then(root => { console.log('root node', root) }) } }
Limitations
A few known limitations:
- Not all element types are supported (e.g. iframes)
- 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
Related Packages
prettier-plugin-organize-attributes
Organize your HTML attributes autmatically with Prettier 🧼
7,614,373
241
squidex-prettier-plugin-organize-attributes
Organize your HTML attributes autmatically with Prettier 🧼
4,439
241
@nikolastojicic/prettier-plugin-organize-attributes
Organize your HTML attributes autmatically with Prettier 🧼
1,449
241
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 1.10.0 | ^3.2.31 | MIT | |
| 1.9.1 | ^3.2.31 | MIT | |
| 1.9.0 | ^3.2.31 | MIT | |
| 1.8.1 | ^3.2.31 | MIT | |
| 1.8.0 | ^3.2.31 | MIT | |
| 1.7.0 | ^3.2.31 | MIT | |
| 1.6.3 | ^3.2.31 | MIT | |
| 1.6.2 | ^3.2.31 | MIT | |
| 1.6.1 | ^3.2.31 | MIT | |
| 1.6.0 | ^3.2.31 | MIT | |
| 1.5.1 | ^3.2.31 | MIT | |
| 1.5.0 | ^3.2.31 | MIT | |
| 1.4.0 | ^3.2.31 | MIT | |
| 1.3.2 | ^3.2.31 | MIT | |
| 1.3.1 | ^3.2.31 | MIT | |
| 1.3.0 | ^3.2.31 | MIT | |
| 1.2.0 | ^3.2.31 | MIT | |
| 1.1.0 | ^3.2.31 | MIT | |
| 1.0.3 | ^3.2.31 | MIT | |
| 1.0.2 | ^3.2.31 | MIT | |
| 1.0.1 | ^3.2.31 | MIT | |
| 1.0.0 | ^3.2.38 | MIT |