"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = modelToStyle;
// ignore height
var RULES = ['width', 'color', 'backgroundColor', 'padding', 'fontFamily', 'fontWeight', 'fontSize', 'lineHeight', 'letterSpacing', 'textDecoration', 'writingMode', 'textAlign', 'verticalAlign'];
var NEED_PX_RULES = ['width', 'fontSize', 'letterSpacing'];
/**
 * parse editor model properties to css style
 * @param  {EditorModel} model
 * @returns {Style}
 */

function modelToStyle(model) {
  var cssStyle = {};
  var scale = model.scale;
  RULES.forEach(function (rule) {
    if (model[rule] !== undefined) {
      cssStyle[rule] = model[rule];
    }
  });
  NEED_PX_RULES.forEach(function (key) {
    if (key === 'width' && scale) {
      cssStyle[key] = "".concat(cssStyle[key], "px");
    } else {
      cssStyle[key] += 'px';
    }
  });
  cssStyle.backgroundColor += '';

  if (model.type === 'text') {
    cssStyle.wordBreak = 'break-all';
  }

  return cssStyle;
}