Ejemplo n.º 1
1
import Quill from 'quill'
let Delta = Quill.import('delta')
let Break = Quill.import('blots/break')
let Embed = Quill.import('blots/embed')
let Link = Quill.import('formats/link')

/*
* Support for shift enter
* @see https://github.com/quilljs/quill/issues/252
* @see https://codepen.io/mackermedia/pen/gmNwZP
*/
const lineBreak = {
  blotName: 'break',
  tagName: 'BR'
}

class SmartBreak extends Break {
  length () {
    return 1
  }

  value () {
    return '\n'
  }

  insertInto (parent, ref) {
    Embed.prototype.insertInto.call(this, parent, ref)
  }
}

SmartBreak.blotName = lineBreak.blotName
Ejemplo n.º 2
1
import Quill from 'quill';

// replace <p> tag with <div>
const Block = Quill.import('blots/block');
Block.tagName = 'DIV';
Quill.register(Block, true);

const CodeBlockContainer = Quill.import('formats/code-block-container');
CodeBlockContainer.tagName = 'PRE';
Quill.register(CodeBlockContainer, true);

// table
const Table = Quill.import('formats/table-container');
const superCreate = Table.create.bind(Table);
Table.create = (value) => {
	const node = superCreate(value);
	node.classList.add('table');
	node.classList.add('table-bordered');
	return node;
}
Quill.register(Table, true);

// link without href
var Link = Quill.import('formats/link');

class MyLink extends Link {
	static create(value) {
		let node = super.create(value);
		value = this.sanitize(value);
		node.setAttribute('href', value);
		if(value.startsWith('/') || value.indexOf(window.location.host)) {
Ejemplo n.º 3
1
/*
React-Quill v0.4.1
https://github.com/zenoamaro/react-quill
*/
module.exports = require('./component');
module.exports.Mixin = require('./mixin');
module.exports.Toolbar = require('./toolbar');
var quill = require('quill')
var Parchment = quill.import('parchment');
var FontStyle = new Parchment.Attributor.Style('size', 'font-size', { scope: Parchment.Scope.INLINE });
var FontFamilyStyle = new Parchment.Attributor.Style('font', 'font-family', { scope: Parchment.Scope.INLINE });
quill.register(FontStyle, true);
quill.register(FontFamilyStyle, true);
module.exports.Quill = quill;
Ejemplo n.º 4
1
import Quill from 'quill'

var Delta = Quill.import('delta');
let Break = Quill.import('blots/break');
let Embed = Quill.import('blots/embed');

function lineBreakMatcher() {
    var newDelta = new Delta();
    newDelta.insert({'break': ''});
    return newDelta;
}

class SmartBreak extends Break {
    length () {
        return 1
    }
    value () {
        return '\n'
    }
    insertInto(parent, ref) {
        Embed.prototype.insertInto.call(this, parent, ref)
    }
}

SmartBreak.blotName = 'break';
SmartBreak.tagName = 'BR'

Quill.register(SmartBreak)

var options = {
    modules: {
Ejemplo n.º 5
1
import React, { Component, PropTypes } from 'react';
import ReactQuill from 'react-quill';
import Quill from 'quill';

// Change <p> tags to <div> tags as empty lines are rendered as <p><br></p> which is two spaces, <div><br></div> is one
// Adapted from https://codepen.io/alexkrolick/pen/PWrKdx?editors=0010 and https://codepen.io/quill/pen/VjgorV
const Block = Quill.import('blots/block');
Block.tagName = 'DIV';
Quill.register(Block, true);

const HTML_MODULE = {
  toolbar: [
    ['bold', 'italic', 'underline', 'strike'],        // toggled buttons
    ['blockquote', 'code-block'],

    [{ 'header': 1 }, { 'header': 2 }],               // custom button values
    [{ 'list': 'ordered'}, { 'list': 'bullet' }],
    [{ 'script': 'sub'}, { 'script': 'super' }],      // superscript/subscript
    [{ 'indent': '-1'}, { 'indent': '+1' }],          // outdent/indent
    [{ 'direction': 'rtl' }],                         // text direction

    [{ 'size': ['small', false, 'large', 'huge'] }],  // custom dropdown
    [{ 'header': [1, 2, 3, 4, 5, 6, false] }],

    [{ 'color': [] }, { 'background': [] }],          // dropdown with defaults from theme
    [{ 'font': [] }],
    [{ 'align': [] }],

    ['clean']                                         // remove formatting button
  ]
};
Ejemplo n.º 6
1
import Quill from 'quill';

const InlineEmbed = Quill.import('blots/embed');

class Shortcode extends InlineEmbed {
  static create(value) {
    const node = super.create(value);
    node.setAttribute('class', 'ql-shortcode');
    node.innerHTML = value;

    return node;
  }
}
Shortcode.blotName = 'shortcode';
Shortcode.tagName = 'span';


export default Shortcode;
Ejemplo n.º 7
0
import React, { Component } from 'react'
import Quill from 'quill'
import TextButton from './tool/text'
import BaikeButton from './tool/bk'
import DocButton from './tool/doc'
import WxButton from './tool/wx'
import ImageButton from './tool/image'
import AudioButton from './tool/audio'
import VideoButton from './tool/video'
import { videoUrlConvert } from '../../utils'
import './index.css'

const BlockEmbed = Quill.import('blots/block/embed')

class MCBlot extends BlockEmbed {
    static create(value) {
        const node = super.create()
        const div = document.createElement('div')
        div.innerText = value.title
        const span = document.createElement('span')
        span.innerText = value.descript
        node.appendChild(div)
        node.appendChild(span)
        return node
    }
    static value(node) {
        return {
            title: node.childNodes[0].innerText,
            descript: node.childNodes[1].innerText
        }
    }
Ejemplo n.º 8
0
import Quill from 'quill';

const Embed = Quill.import('blots/embed');

class EmojiBlot extends Embed {
    static create(value) {
        let node = super.create();
        if (typeof value === 'object') {
            node.classList.add("emoji");
            node.classList.add("ap");
            node.classList.add("ap-"+value.name);
            let dataUrl = 'data:image/png;base64,R0lGODlhAQABAAAAACwAAAAAAQABAAA=';
            node.setAttribute('src',dataUrl);
            node.setAttribute('data-resize', 'no');
        }
        else if(typeof value === 'string'){
            node.setAttribute('src',value);
        }
        return node;
      }

    static formats(node) {
        // We still need to report unregistered src formats
        let format = {};
        if (node.hasAttribute('class')) {
          format.class = node.getAttribute('class');
        }
        if (node.hasAttribute('alt')) {
          format.width = node.getAttribute('alt');
        }
        return format;