Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@mastergo/html-mastergo

Package Overview
Dependencies
Maintainers
6
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mastergo/html-mastergo

Convert HTML to Mastergo code

latest
Source
npmnpm
Version
1.10.0
Version published
Weekly downloads
35
-56.25%
Maintainers
6
Weekly downloads
 
Created
Source

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

Example

Keywords

mastergo

FAQs

Package last updated on 13 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts