{"size": 1407, "ext": "js", "max_stars_repo_path": "editor/plantuml.js", "max_stars_repo_name": "xudafeng/umlplot", "max_stars_repo_stars_event_min_datetime": "2018-01-16T04:37:47.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-14T00:06:53.000Z", "max_issues_repo_path": "editor/plantuml.js", "max_issues_repo_name": "xudafeng/umlplot", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "editor/plantuml.js", "max_forks_repo_name": "xudafeng/umlplot", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.6935483871, "max_line_length": 97, "alphanum_fraction": 0.5913290689}
'use strict';

import React from 'react';
import ReactDOM from 'react-dom';
import ForkmeonComponent from 'forkmeon.github.io';

import './plantuml.less';
import _ from './utils';
import pkg from '../package';

const data = _.getHashData();

class Page extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      text: data ? _.decode(data) : `class ${pkg.name.toUpperCase()}`
    };
  }

  textareaOnChange(e) {
    this.setState({
      text: e.target.value
    });
  }

  getEncoded() {
    const encoded = _.encode(this.state.text);
    const str = `#data=${encoded}`;
    history.replaceState({}, document.title, str);
    return encoded;
  }

  getForkmeonProps() {
    return {
      classPrefix: pkg.name,
      fixed: true,
      text: 'Fork me on Github',
      linkUrl: pkg.repository.url,
      onDemoUpdateDid: () => {},
      flat: true
    };
  }

  render() {
    return (
      <div className="container">
        <ForkmeonComponent {...this.getForkmeonProps()}/>
        <textarea onChange={this.textareaOnChange.bind(this)} value={this.state.text}></textarea>
        <p className="links">
          <a href="http://plantuml.com/">document</a>
        </p>
        <div>
          <img src={`http://www.plantuml.com/plantuml/svg/${this.getEncoded()}`} />
        </div>
      </div>
    );
  }
}

ReactDOM.render(<Page />, document.querySelector('#app'));
