',
'
' + this.lang.color.background + '
',
'
',
'',
'
',
'
',
'
',
'',
'',
'
',
'
',
'
',
].join('') : '') +
(foreColor ? [
'',
'
' + this.lang.color.foreground + '
',
'
',
'',
'
',
'
',
'
',
'',
'',
'
', // Fix missing Div, Commented to find easily if it's wrong
'
',
'
',
].join('') : ''),
callback: ($dropdown) => {
$dropdown.find('.note-holder').each((idx, item) => {
const $holder = $(item);
$holder.append(this.ui.palette({
colors: this.options.colors,
colorsName: this.options.colorsName,
eventName: $holder.data('event'),
container: this.options.container,
tooltip: this.options.tooltip,
}).render());
});
/* TODO: do we have to record recent custom colors within cookies? */
var customColors = [
['#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF'],
];
$dropdown.find('.note-holder-custom').each((idx, item) => {
const $holder = $(item);
$holder.append(this.ui.palette({
colors: customColors,
colorsName: customColors,
eventName: $holder.data('event'),
container: this.options.container,
tooltip: this.options.tooltip,
}).render());
});
$dropdown.find('input[type=color]').each((idx, item) => {
$(item).change(function() {
const $chip = $dropdown.find('#' + $(this).data('event')).find('.note-color-btn').first();
const color = this.value.toUpperCase();
$chip.css('background-color', color)
.attr('aria-label', color)
.attr('data-value', color)
.attr('data-original-title', color);
$chip.click();
});
});
},
click: (event) => {
event.stopPropagation();
const $parent = $('.' + className).find('.note-dropdown-menu');
const $button = $(event.target);
const eventName = $button.data('event');
const value = $button.attr('data-value');
if (eventName === 'openPalette') {
const $picker = $parent.find('#' + value);
const $palette = $($parent.find('#' + $picker.data('event')).find('.note-color-row')[0]);
// Shift palette chips
const $chip = $palette.find('.note-color-btn').last().detach();
// Set chip attributes
const color = $picker.val();
$chip.css('background-color', color)
.attr('aria-label', color)
.attr('data-value', color)
.attr('data-original-title', color);
$palette.prepend($chip);
$picker.click();
} else {
if (lists.contains(['backColor', 'foreColor'], eventName)) {
const key = eventName === 'backColor' ? 'background-color' : 'color';
const $color = $button.closest('.note-color').find('.note-recent-color');
const $currentButton = $button.closest('.note-color').find('.note-current-color-button');
$color.css(key, value);
$currentButton.attr('data-' + eventName, value);
}
this.context.invoke('editor.' + eventName, value);
}
},
}),
],
}).render();
}
addToolbarButtons() {
this.context.memo('button.style', () => {
return this.ui.buttonGroup([
this.button({
className: 'dropdown-toggle',
contents: this.ui.dropdownButtonContents(
this.ui.icon(this.options.icons.magic), this.options
),
tooltip: this.lang.style.style,
data: {
toggle: 'dropdown',
},
}),
this.ui.dropdown({
className: 'dropdown-style',
items: this.options.styleTags,
title: this.lang.style.style,
template: (item) => {
// TBD: need to be simplified
if (typeof item === 'string') {
item = {
tag: item,
title: (Object.prototype.hasOwnProperty.call(this.lang.style, item) ? this.lang.style[item] : item),
};
}
const tag = item.tag;
const title = item.title;
const style = item.style ? ' style="' + item.style + '" ' : '';
const className = item.className ? ' class="' + item.className + '"' : '';
return '<' + tag + style + className + '>' + title + '' + tag + '>';
},
click: this.context.createInvokeHandler('editor.formatBlock'),
}),
]).render();
});
for (let styleIdx = 0, styleLen = this.options.styleTags.length; styleIdx < styleLen; styleIdx++) {
const item = this.options.styleTags[styleIdx];
this.context.memo('button.style.' + item, () => {
return this.button({
className: 'note-btn-style-' + item,
contents: '