How to use the tinode-sdk.Drafty.attrValue function in tinode-sdk

To help you get started, we’ve selected a few tinode-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tinode / webapp / src / widgets / chat-message.jsx View on Github external
function draftyFormatter(style, data, values, key) {
  let el = Drafty.tagName(style);
  if (el) {
    let attr = Drafty.attrValue(style, data) || {};
    attr.key = key;
    switch (style) {
      case 'IM':
        // Additional processing for images
        if (data) {
          attr.className = 'inline-image';
          let dim = fitImageSize(data.width, data.height,
            Math.min(this.props.viewportWidth - REM_SIZE * 4, REM_SIZE * 36), REM_SIZE * 24, false);
          dim = dim || {dstWidth: BROKEN_IMAGE_SIZE, dstHeight: BROKEN_IMAGE_SIZE};
          attr.style = { width: dim.dstWidth + 'px', height: dim.dstHeight + 'px' };
          attr.src = sanitizeImageUrl(attr.src);
          if (attr.src) {
            attr.onClick = this.handlePreviewImage;
            attr.className += ' image-clickable';
          } else {
            attr.src = 'img/broken_image.png';