2017-03-02 19:51:57 +03:00
|
|
|
import set from 'ember-metal/set';
|
2017-02-27 07:44:15 +03:00
|
|
|
|
|
|
|
export default function (editor, toolbar) {
|
|
|
|
return [
|
|
|
|
{
|
2017-02-27 15:05:31 +03:00
|
|
|
name: 'H1',
|
|
|
|
class: 'h1',
|
|
|
|
icon: '',
|
|
|
|
label: 'Heading One',
|
2017-02-27 07:44:15 +03:00
|
|
|
visibility: 'primary',
|
|
|
|
selected: false,
|
|
|
|
type: 'block',
|
2017-02-27 15:05:31 +03:00
|
|
|
toolbar: true,
|
2017-02-27 07:44:15 +03:00
|
|
|
onClick: (editor) => {
|
2017-03-01 10:28:46 +03:00
|
|
|
editor.run((postEditor) => {
|
2017-02-27 07:44:15 +03:00
|
|
|
postEditor.toggleSection('h1');
|
|
|
|
});
|
|
|
|
},
|
2017-03-02 19:51:57 +03:00
|
|
|
checkElements(elements) {
|
|
|
|
set(this, 'selected', elements.filter((element) => element.tagName === 'h1').length > 0);
|
2017-02-27 07:44:15 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2017-02-27 15:05:31 +03:00
|
|
|
name: 'H2',
|
2017-03-02 19:51:57 +03:00
|
|
|
class: 'h2',
|
2017-02-27 15:05:31 +03:00
|
|
|
label: 'Heading Two',
|
|
|
|
icon: '',
|
2017-02-27 07:44:15 +03:00
|
|
|
selected: false,
|
|
|
|
type: 'block',
|
|
|
|
visibility: 'primary',
|
2017-02-27 15:05:31 +03:00
|
|
|
toolbar: true,
|
2017-02-27 07:44:15 +03:00
|
|
|
onClick: (editor) => {
|
2017-03-01 10:28:46 +03:00
|
|
|
editor.run((postEditor) => {
|
2017-02-27 07:44:15 +03:00
|
|
|
postEditor.toggleSection('h2');
|
|
|
|
});
|
|
|
|
},
|
2017-03-02 19:51:57 +03:00
|
|
|
checkElements(elements) {
|
|
|
|
set(this, 'selected', elements.filter((element) => element.tagName === 'h2').length > 0);
|
2017-02-27 07:44:15 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2017-02-27 15:05:31 +03:00
|
|
|
name: 'H3',
|
|
|
|
label: 'Heading Three',
|
|
|
|
icon: '',
|
2017-02-27 07:44:15 +03:00
|
|
|
selected: false,
|
|
|
|
type: 'block',
|
|
|
|
visibility: 'primary',
|
|
|
|
onClick: (editor) => {
|
2017-03-01 10:28:46 +03:00
|
|
|
editor.run((postEditor) => {
|
2017-02-27 07:44:15 +03:00
|
|
|
postEditor.toggleSection('h3');
|
|
|
|
});
|
|
|
|
},
|
2017-03-02 19:51:57 +03:00
|
|
|
checkElements(elements) {
|
|
|
|
set(this, 'selected', elements.filter((element) => element.tagName === 'h3').length > 0);
|
2017-02-27 07:44:15 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2017-02-27 15:05:31 +03:00
|
|
|
name: 'p',
|
2017-03-14 14:59:34 +03:00
|
|
|
label: 'Text',
|
|
|
|
icon: 'text.svg',
|
2017-02-27 07:44:15 +03:00
|
|
|
selected: false,
|
|
|
|
type: 'block',
|
2017-03-14 14:59:34 +03:00
|
|
|
order: 0,
|
|
|
|
cardMenu: true,
|
2017-02-27 07:44:15 +03:00
|
|
|
onClick: (editor) => {
|
2017-03-01 10:28:46 +03:00
|
|
|
editor.run((postEditor) => {
|
2017-02-27 07:44:15 +03:00
|
|
|
postEditor.toggleSection('p');
|
|
|
|
});
|
|
|
|
},
|
2017-03-02 19:51:57 +03:00
|
|
|
checkElements(elements) {
|
|
|
|
set(this, 'selected', elements.filter((element) => element.tagName === 'p').length > 0);
|
2017-02-27 07:44:15 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2017-02-27 15:05:31 +03:00
|
|
|
name: '“',
|
|
|
|
label: 'Quote',
|
|
|
|
class: 'quote',
|
|
|
|
icon: 'quote.svg',
|
2017-02-27 07:44:15 +03:00
|
|
|
selected: false,
|
|
|
|
type: 'block',
|
2017-02-27 15:05:31 +03:00
|
|
|
toolbar: true,
|
2017-02-27 07:44:15 +03:00
|
|
|
onClick: (editor) => {
|
2017-03-01 10:28:46 +03:00
|
|
|
editor.run((postEditor) => {
|
2017-02-27 07:44:15 +03:00
|
|
|
postEditor.toggleSection('blockquote');
|
|
|
|
});
|
|
|
|
},
|
2017-03-02 19:51:57 +03:00
|
|
|
checkElements(elements) {
|
|
|
|
set(this, 'selected', elements.filter((element) => element.tagName === 'blockquote').length > 0);
|
2017-02-27 07:44:15 +03:00
|
|
|
}
|
|
|
|
},
|
2017-03-02 19:51:57 +03:00
|
|
|
{
|
2017-02-27 15:05:31 +03:00
|
|
|
name: 'ul',
|
2017-03-14 14:59:34 +03:00
|
|
|
label: 'Bullet List',
|
|
|
|
icon: 'list-bullet.svg',
|
2017-02-27 07:44:15 +03:00
|
|
|
selected: false,
|
|
|
|
type: 'block',
|
2017-03-14 14:59:34 +03:00
|
|
|
order: 5,
|
|
|
|
cardMenu: true,
|
2017-02-27 07:44:15 +03:00
|
|
|
onClick: (editor) => {
|
2017-03-01 10:28:46 +03:00
|
|
|
editor.run((postEditor) => {
|
2017-02-27 07:44:15 +03:00
|
|
|
postEditor.toggleSection('ul');
|
|
|
|
});
|
|
|
|
},
|
2017-03-02 19:51:57 +03:00
|
|
|
checkElements(elements) {
|
|
|
|
set(this, 'selected', elements.filter((element) => element.tagName === 'ul').length > 0);
|
2017-02-27 07:44:15 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2017-02-27 15:05:31 +03:00
|
|
|
name: 'ol',
|
2017-03-14 14:59:34 +03:00
|
|
|
label: 'Number List',
|
2017-02-27 15:05:31 +03:00
|
|
|
icon: 'list-number.svg',
|
2017-02-27 07:44:15 +03:00
|
|
|
selected: false,
|
|
|
|
type: 'block',
|
2017-03-14 14:59:34 +03:00
|
|
|
order: 6,
|
|
|
|
cardMenu: true,
|
2017-02-27 07:44:15 +03:00
|
|
|
onClick: (editor) => {
|
2017-03-01 10:28:46 +03:00
|
|
|
editor.run((postEditor) => {
|
2017-02-27 07:44:15 +03:00
|
|
|
postEditor.toggleSection('ol');
|
|
|
|
});
|
|
|
|
},
|
2017-03-02 19:51:57 +03:00
|
|
|
checkElements(elements) {
|
|
|
|
set(this, 'selected', elements.filter((element) => element.tagName === 'ol').length > 0);
|
2017-02-27 07:44:15 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2017-02-27 15:05:31 +03:00
|
|
|
name: 'B',
|
|
|
|
label: 'Bold',
|
|
|
|
class: 'bold',
|
|
|
|
icon: 'bold.svg',
|
2017-02-27 07:44:15 +03:00
|
|
|
selected: false,
|
|
|
|
type: 'markup',
|
|
|
|
visibility: 'primary',
|
|
|
|
onClick: (editor) => {
|
2017-03-01 10:28:46 +03:00
|
|
|
editor.run((postEditor) => {
|
2017-02-27 07:44:15 +03:00
|
|
|
postEditor.toggleMarkup('strong');
|
|
|
|
});
|
|
|
|
},
|
2017-03-14 14:59:34 +03:00
|
|
|
checkElements(/* elements */) {
|
|
|
|
set(this, 'selected', true);
|
|
|
|
// set(this, 'selected', elements.filter((element) => element.tagName === 'strong').length > 0);
|
2017-02-27 07:44:15 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2017-02-27 15:05:31 +03:00
|
|
|
name: 'I',
|
|
|
|
label: 'Italic',
|
|
|
|
class: 'italic',
|
|
|
|
icon: 'italic.svg',
|
2017-02-27 07:44:15 +03:00
|
|
|
selected: false,
|
|
|
|
type: 'markup',
|
|
|
|
visibility: 'primary',
|
|
|
|
onClick: (editor) => {
|
2017-03-01 10:28:46 +03:00
|
|
|
editor.run((postEditor) => {
|
2017-02-27 07:44:15 +03:00
|
|
|
postEditor.toggleMarkup('em');
|
|
|
|
});
|
|
|
|
},
|
2017-03-02 19:51:57 +03:00
|
|
|
checkElements(elements) {
|
|
|
|
set(this, 'selected', elements.filter((element) => element.tagName === 'em').length > 0);
|
2017-02-27 07:44:15 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2017-02-27 15:05:31 +03:00
|
|
|
name: 'S',
|
|
|
|
label: 'Strike',
|
|
|
|
class: 'strike',
|
|
|
|
icon: 'strikethrough.svg',
|
2017-02-27 07:44:15 +03:00
|
|
|
selected: false,
|
|
|
|
type: 'markup',
|
|
|
|
onClick: (editor) => {
|
2017-03-01 10:28:46 +03:00
|
|
|
editor.run((postEditor) => {
|
2017-02-27 07:44:15 +03:00
|
|
|
postEditor.toggleMarkup('s');
|
|
|
|
});
|
|
|
|
},
|
2017-03-02 19:51:57 +03:00
|
|
|
checkElements(elements) {
|
|
|
|
set(this, 'selected', elements.filter((element) => element.tagName === 's').length > 0);
|
2017-02-27 07:44:15 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2017-03-08 16:08:20 +03:00
|
|
|
name: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><g stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" fill="none"><path d="M14.5 12.5l.086.086c.781.781 2.047.781 2.828 0l3.965-3.964c1.166-1.167 1.166-3.075 0-4.243l-1.758-1.757c-1.166-1.167-3.076-1.167-4.242 0l-3.965 3.964c-.781.781-.781 2.047 0 2.829l.086.085M9.5 11.5l-.086-.085c-.781-.781-2.047-.781-2.828 0l-3.965 3.964c-1.166 1.167-1.166 3.076 0 4.243l1.758 1.757c1.166 1.167 3.076 1.167 4.242 0l3.965-3.964c.781-.781.781-2.047 0-2.829l-.086-.086M8.111 15.889l7.778-7.778"/></g></svg>',
|
2017-02-27 15:05:31 +03:00
|
|
|
label: 'Link',
|
|
|
|
class: 'link',
|
|
|
|
icon: 'link.svg',
|
2017-02-27 07:44:15 +03:00
|
|
|
selected: false,
|
|
|
|
type: 'markup',
|
2017-02-27 15:05:31 +03:00
|
|
|
visibility: 'primary',
|
2017-02-27 07:44:15 +03:00
|
|
|
onClick: (editor) => {
|
2017-03-21 16:52:47 +03:00
|
|
|
toolbar.send('doLink', editor.range);
|
2017-02-27 07:44:15 +03:00
|
|
|
},
|
2017-03-02 19:51:57 +03:00
|
|
|
checkElements(elements) {
|
|
|
|
set(this, 'selected', elements.filter((element) => element.tagName === 'a').length > 0);
|
2017-02-27 07:44:15 +03:00
|
|
|
}
|
2017-02-27 15:05:31 +03:00
|
|
|
},
|
2017-02-27 07:44:15 +03:00
|
|
|
{
|
2017-02-27 15:05:31 +03:00
|
|
|
name: 'img',
|
|
|
|
label: 'Image',
|
2017-02-27 07:44:15 +03:00
|
|
|
selected: false,
|
|
|
|
type: 'card',
|
2017-03-14 14:59:34 +03:00
|
|
|
icon: 'photos.svg',
|
2017-02-27 15:05:31 +03:00
|
|
|
visibility: 'primary',
|
2017-03-14 14:59:34 +03:00
|
|
|
order: 2,
|
|
|
|
cardMenu: true,
|
2017-02-27 07:44:15 +03:00
|
|
|
onClick: (editor) => {
|
2017-04-05 10:00:01 +03:00
|
|
|
editor.run((postEditor, section) => {
|
2017-04-05 14:32:39 +03:00
|
|
|
let thisSection = section || editor.range.headSection;
|
2017-03-24 13:03:52 +03:00
|
|
|
let card = postEditor.builder.createCardSection('card-image', {pos: 'top'});
|
2017-04-05 14:32:39 +03:00
|
|
|
if (thisSection.text.length) {
|
2017-04-05 10:00:01 +03:00
|
|
|
postEditor.insertSection(card);
|
|
|
|
} else {
|
2017-04-05 14:32:39 +03:00
|
|
|
postEditor.replaceSection(thisSection, card);
|
|
|
|
}
|
|
|
|
// insert empty paragraph after card if it's the last element.
|
2017-04-06 15:10:54 +03:00
|
|
|
if (!thisSection.next) {
|
2017-04-05 14:32:39 +03:00
|
|
|
let newSection = editor.builder.createMarkupSection('p');
|
|
|
|
postEditor.insertSectionAtEnd(newSection);
|
2017-04-05 10:00:01 +03:00
|
|
|
}
|
2017-02-27 07:44:15 +03:00
|
|
|
});
|
|
|
|
},
|
2017-03-02 19:51:57 +03:00
|
|
|
checkElements(elements) {
|
|
|
|
set(this, 'selected', elements.filter((element) => element.tagName === 'sup').length > 0);
|
2017-02-27 07:44:15 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2017-02-27 15:05:31 +03:00
|
|
|
name: 'html',
|
2017-03-14 14:59:34 +03:00
|
|
|
label: 'Embed',
|
2017-02-27 07:44:15 +03:00
|
|
|
selected: false,
|
|
|
|
type: 'card',
|
2017-03-14 14:59:34 +03:00
|
|
|
icon: 'brackets.svg',
|
2017-02-27 15:05:31 +03:00
|
|
|
visibility: 'primary',
|
2017-03-14 14:59:34 +03:00
|
|
|
order: 3,
|
|
|
|
cardMenu: true,
|
|
|
|
onClick: (editor, section) => {
|
2017-03-01 10:28:46 +03:00
|
|
|
editor.run((postEditor) => {
|
2017-04-05 14:32:39 +03:00
|
|
|
let thisSection = section || editor.range.headSection;
|
|
|
|
let card = postEditor.builder.createCardSection('card-html', {pos: 'top', html: thisSection.text});
|
2017-03-15 13:29:10 +03:00
|
|
|
// we can't replace a list item so we insert a card after it and then delete it.
|
2017-04-05 14:32:39 +03:00
|
|
|
if (thisSection.isListItem) {
|
2017-03-24 13:03:52 +03:00
|
|
|
editor.insertCard('card-html');
|
2017-03-15 13:29:10 +03:00
|
|
|
} else {
|
2017-04-05 14:32:39 +03:00
|
|
|
postEditor.replaceSection(thisSection, card);
|
|
|
|
}
|
|
|
|
|
2017-04-06 15:10:54 +03:00
|
|
|
if (!thisSection.next) {
|
2017-04-05 14:32:39 +03:00
|
|
|
let newSection = editor.builder.createMarkupSection('p');
|
|
|
|
postEditor.insertSectionAtEnd(newSection);
|
2017-03-15 13:29:10 +03:00
|
|
|
}
|
2017-02-27 07:44:15 +03:00
|
|
|
});
|
|
|
|
},
|
2017-03-02 19:51:57 +03:00
|
|
|
checkElements() {
|
2017-02-27 07:44:15 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2017-03-14 14:59:34 +03:00
|
|
|
name: 'hr',
|
|
|
|
label: 'Divider',
|
2017-02-27 07:44:15 +03:00
|
|
|
selected: false,
|
|
|
|
type: 'card',
|
2017-03-14 14:59:34 +03:00
|
|
|
icon: 'line.svg',
|
2017-02-27 15:05:31 +03:00
|
|
|
visibility: 'primary',
|
2017-03-14 14:59:34 +03:00
|
|
|
order: 4,
|
|
|
|
cardMenu: true,
|
2017-04-05 14:32:39 +03:00
|
|
|
onClick: (editor, section) => {
|
2017-03-01 10:28:46 +03:00
|
|
|
editor.run((postEditor) => {
|
2017-04-05 14:32:39 +03:00
|
|
|
let thisSection = section || editor.range.headSection;
|
2017-03-24 13:03:52 +03:00
|
|
|
let card = postEditor.builder.createCardSection('card-hr', {pos: 'top'});
|
2017-03-14 14:59:34 +03:00
|
|
|
postEditor.insertSection(card);
|
2017-04-05 14:32:39 +03:00
|
|
|
|
2017-04-06 15:10:54 +03:00
|
|
|
if (!thisSection.next) {
|
2017-04-05 14:32:39 +03:00
|
|
|
let newSection = editor.builder.createMarkupSection('p');
|
|
|
|
postEditor.insertSectionAtEnd(newSection);
|
|
|
|
}
|
2017-03-14 14:59:34 +03:00
|
|
|
});
|
|
|
|
},
|
|
|
|
checkElements() {
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'md',
|
|
|
|
label: 'Markdown',
|
|
|
|
selected: false,
|
|
|
|
type: 'card',
|
|
|
|
visibility: 'primary',
|
|
|
|
icon: 'markdown.svg',
|
|
|
|
order: 1,
|
|
|
|
cardMenu: true,
|
|
|
|
onClick: (editor, section) => {
|
|
|
|
editor.run((postEditor) => {
|
2017-04-05 14:32:39 +03:00
|
|
|
let thisSection = section || editor.range.headSection;
|
|
|
|
let card = postEditor.builder.createCardSection('card-markdown', {pos: 'top', markdown: thisSection.text, newlyCreated: true});
|
2017-03-15 13:29:10 +03:00
|
|
|
// we can't replace a list item so we insert a card after it and then delete it.
|
2017-04-05 14:32:39 +03:00
|
|
|
if (thisSection.isListItem) {
|
2017-03-24 13:03:52 +03:00
|
|
|
editor.insertCard('card-markdown');
|
2017-03-15 13:29:10 +03:00
|
|
|
} else {
|
2017-04-05 14:32:39 +03:00
|
|
|
postEditor.replaceSection(thisSection, card);
|
|
|
|
}
|
|
|
|
// if this is the last element then insert a paragraph after the card
|
2017-04-06 15:10:54 +03:00
|
|
|
if (!thisSection.next) {
|
2017-04-05 14:32:39 +03:00
|
|
|
let newSection = editor.builder.createMarkupSection('p');
|
|
|
|
postEditor.insertSectionAtEnd(newSection);
|
2017-03-15 13:29:10 +03:00
|
|
|
}
|
2017-02-27 07:44:15 +03:00
|
|
|
});
|
|
|
|
},
|
2017-03-02 19:51:57 +03:00
|
|
|
checkElements() {
|
2017-02-27 07:44:15 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|