How to use the draftail.ENTITY_TYPE.LINK function in draftail

To help you get started, we’ve selected a few draftail 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 mirumee / saleor-dashboard / src / components / RichTextEditor / RichTextEditor.tsx View on Github external
icon: ,
              type: INLINE_STYLE.ITALIC
            },
            {
              icon: ,
              type: INLINE_STYLE.STRIKETHROUGH
            }
          ]}
          enableLineBreak
          entityTypes={[
            {
              attributes: ["url"],
              decorator: LinkEntity,
              icon: ,
              source: LinkSource,
              type: ENTITY_TYPE.LINK
            }
            // {
            //   attributes: ["href"],
            //   decorator: ImageEntity,
            //   icon: ,
            //   source: ImageSource,
            //   type: ENTITY_TYPE.IMAGE
            // }
          ]}
        />
      
      {helperText && (
github mirumee / saleor / saleor / static / dashboard-next / components / RichTextEditor / RichTextEditor.tsx View on Github external
icon: ,
              type: INLINE_STYLE.ITALIC
            },
            {
              icon: ,
              type: INLINE_STYLE.STRIKETHROUGH
            }
          ]}
          enableLineBreak
          entityTypes={[
            {
              attributes: ["href"],
              decorator: LinkEntity,
              icon: ,
              source: LinkSource,
              type: ENTITY_TYPE.LINK
            }
            // {
            //   attributes: ["href"],
            //   decorator: ImageEntity,
            //   icon: ,
            //   source: ImageSource,
            //   type: ENTITY_TYPE.IMAGE
            // }
          ]}
        />
      
      {helperText && (
github medialab / website / admin / src / components / entities / link.js View on Github external
onClick={() => onRemove(entityKey)}>Remove
              
            
          
        
      }>
      <a role="button" rel="noopener noreferrer">
        <span>{props.children}</span>
      </a>
    
  );
}

// Entity
const LINK = {
  type: ENTITY_TYPE.LINK,
  icon: ,
  source: LinkSource,
  decorator: LinkDecorator,
  attributes: ['href', 'internal']
};

export default LINK;
github wagtail / wagtail / client / src / components / Draftail / sources / ModalWorkflowSource.js View on Github external
return {
      id: data.id,
      src: data.preview.url,
      alt: data.alt,
      format: data.format,
    };
  case EMBED:
    return {
      embedType: data.embedType,
      url: data.url,
      providerName: data.providerName,
      authorName: data.authorName,
      thumbnail: data.thumbnail,
      title: data.title,
    };
  case ENTITY_TYPE.LINK:
    if (data.id) {
      return {
        url: data.url,
        id: data.id,
        parentId: data.parentId,
      };
    }

    return {
      url: data.url,
    };
  case DOCUMENT:
    return {
      url: data.url,
      filename: data.filename,
      id: data.id,
github wagtail / wagtail / client / src / components / Draftail / sources / ModalWorkflowSource.js View on Github external
import PropTypes from 'prop-types';
import { Component } from 'react';
import { AtomicBlockUtils, Modifier, RichUtils, EditorState } from 'draft-js';
import { ENTITY_TYPE } from 'draftail';

import { STRINGS } from '../../../config/wagtailConfig';

const $ = global.jQuery;

const EMBED = 'EMBED';
const DOCUMENT = 'DOCUMENT';

const MUTABILITY = {};
MUTABILITY[ENTITY_TYPE.LINK] = 'MUTABLE';
MUTABILITY[DOCUMENT] = 'MUTABLE';
MUTABILITY[ENTITY_TYPE.IMAGE] = 'IMMUTABLE';
MUTABILITY[EMBED] = 'IMMUTABLE';

export const getChooserConfig = (entityType, entity) => {
  const chooserURL = {};
  chooserURL[ENTITY_TYPE.IMAGE] = `${global.chooserUrls.imageChooser}?select_format=true`;
  chooserURL[EMBED] = global.chooserUrls.embedsChooser;
  chooserURL[ENTITY_TYPE.LINK] = global.chooserUrls.pageChooser;
  chooserURL[DOCUMENT] = global.chooserUrls.documentChooser;

  let url = chooserURL[entityType.type];
  let urlParams = {};

  if (entityType.type === ENTITY_TYPE.LINK) {
    urlParams = {