How to use the parchment.Attributor function in parchment

To help you get started, we’ve selected a few parchment 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 quilljs / quill / src / formats / attributor.js View on Github external
scope: Parchment.Scope.BLOCK,
  whitelist: ['right', 'center', 'justify']
});
let Direction = new Parchment.Attributor.Style('direction', 'direction', {
  scope: Parchment.Scope.BLOCK,
  whitelist: ['rtl']
});
let Indent = new Parchment.Attributor.Class('indent', 'ql-indent', {
  scope: Parchment.Scope.BLOCK,
  whitelist: [1, 2, 3, 4, 5, 6, 7, 8]
});

let Background = new Parchment.Attributor.Style('background', 'background-color', {
  scope: Parchment.Scope.INLINE
});
let Color = new Parchment.Attributor.Style('color', 'color', {
  scope: Parchment.Scope.INLINE
});
// let Font = new Parchment.Attributor.Style('font', 'font-family', {
//   scope: Parchment.Scope.INLINE
// });
// let Size = new Parchment.Attributor.Style('size', 'font-size', {
//   scope: Parchment.Scope.INLINE
// });

let Font = new Parchment.Attributor.Class('font', 'ql-font', {
  scope: Parchment.Scope.INLINE,
  whitelist: ['serif', 'monospace']
});

let Size = new Parchment.Attributor.Class('size', 'ql-size', {
  scope: Parchment.Scope.INLINE,
github quilljs / quill / src / formats / code-block.js View on Github external
import Block from '../blots/block';
import Delta from 'rich-text/lib/delta';
import Parchment from 'parchment';
import logger from '../lib/logger';


let debug = logger('quill:code-block');


class TokenAttributor extends Parchment.Attributor.Class {
  value(domNode) {
    return undefined;
  }
}

let CodeToken = new TokenAttributor('token', 'hljs', {
  scope: Parchment.Scope.INLINE
});


class CodeBlock extends Block {
  format(name, value) {
    // TODO allow changing language
    debug.warn(`format(${name}, ${value}) called on code block`);
  }
github quilljs / quill / formats / direction.js View on Github external
import Parchment from 'parchment';

let config = {
  scope: Parchment.Scope.BLOCK,
  whitelist: ['rtl']
};

let DirectionAttribute = new Parchment.Attributor.Attribute('direction', 'dir', config);
let DirectionClass = new Parchment.Attributor.Class('direction', 'ql-direction', config);
let DirectionStyle = new Parchment.Attributor.Style('direction', 'direction', config);

export { DirectionAttribute, DirectionClass, DirectionStyle };
github quilljs / quill / formats / align.js View on Github external
import Parchment from 'parchment';

let config = {
  scope: Parchment.Scope.BLOCK,
  whitelist: ['right', 'center', 'justify']
};

let AlignAttribute = new Parchment.Attributor.Attribute('align', 'align', config);
let AlignClass = new Parchment.Attributor.Class('align', 'ql-align', config);
let AlignStyle = new Parchment.Attributor.Style('align', 'text-align', config);

export { AlignAttribute, AlignClass, AlignStyle };
github quilljs / quill / formats / font.js View on Github external
import Parchment from 'parchment';

let config = {
  scope: Parchment.Scope.INLINE,
  whitelist: ['serif', 'monospace']
};

let FontClass = new Parchment.Attributor.Class('font', 'ql-font', config);

class FontStyleAttributor extends Parchment.Attributor.Style {
  value(node) {
    return super.value(node).replace(/["']/g, '');
  }
}

let FontStyle = new FontStyleAttributor('font', 'font-family', config);

export { FontStyle, FontClass };
github webiny / Webiny / Js / Webiny / Assets / node_modules / quill / formats / direction.js View on Github external
import Parchment from 'parchment';

let config = {
  scope: Parchment.Scope.BLOCK,
  whitelist: ['rtl']
};

let DirectionAttribute = new Parchment.Attributor.Attribute('direction', 'dir', config);
let DirectionClass = new Parchment.Attributor.Class('direction', 'ql-direction', config);
let DirectionStyle = new Parchment.Attributor.Style('direction', 'direction', config);

export { DirectionAttribute, DirectionClass, DirectionStyle };
github webiny / Webiny / Js / Webiny / Assets / node_modules / quill / formats / direction.js View on Github external
import Parchment from 'parchment';

let config = {
  scope: Parchment.Scope.BLOCK,
  whitelist: ['rtl']
};

let DirectionAttribute = new Parchment.Attributor.Attribute('direction', 'dir', config);
let DirectionClass = new Parchment.Attributor.Class('direction', 'ql-direction', config);
let DirectionStyle = new Parchment.Attributor.Style('direction', 'direction', config);

export { DirectionAttribute, DirectionClass, DirectionStyle };
github webiny / Webiny / Js / Webiny / Assets / node_modules / quill / modules / clipboard.js View on Github external
function matchAttributor(node, delta) {
  let attributes = Parchment.Attributor.Attribute.keys(node);
  let classes = Parchment.Attributor.Class.keys(node);
  let styles = Parchment.Attributor.Style.keys(node);
  let formats = {};
  attributes.concat(classes).concat(styles).forEach((name) => {
    let attr = Parchment.query(name, Parchment.Scope.ATTRIBUTE);
    if (attr != null) {
      formats[attr.attrName] = attr.value(node);
      if (formats[attr.attrName]) return;
    }
    if (ATTRIBUTE_ATTRIBUTORS[name] != null) {
      attr = ATTRIBUTE_ATTRIBUTORS[name];
      formats[attr.attrName] = attr.value(node);
    }
    if (STYLE_ATTRIBUTORS[name] != null) {
      attr = STYLE_ATTRIBUTORS[name];
      formats[attr.attrName] = attr.value(node);
    }
github webiny / Webiny / Js / Webiny / Assets / node_modules / quill / formats / font.js View on Github external
import Parchment from 'parchment';

let config = {
  scope: Parchment.Scope.INLINE,
  whitelist: ['serif', 'monospace']
};

let FontClass = new Parchment.Attributor.Class('font', 'ql-font', config);

class FontStyleAttributor extends Parchment.Attributor.Style {
  value(node) {
    return super.value(node).replace(/["']/g, '');
  }
}

let FontStyle = new FontStyleAttributor('font', 'font-family', config);

export { FontStyle, FontClass };
github quilljs / quill / formats / indent.js View on Github external
import Parchment from 'parchment';

class IndentAttributor extends Parchment.Attributor.Class {
  add(node, value) {
    if (value === '+1' || value === '-1') {
      let indent = this.value(node) || 0;
      value = (value === '+1' ? (indent + 1) : (indent - 1));
    }
    if (value === 0) {
      this.remove(node);
      return true;
    } else {
      return super.add(node, value);
    }
  }

  canAdd(node, value) {
    return super.canAdd(node, value) || super.canAdd(node, parseInt(value));
  }