Skip to content

Commit

Permalink
[F] Redactor has font colors and SimpleTable has white background option
Browse files Browse the repository at this point in the history
 - fontcolors available in TextBlock, SimpleTable, and ComplexTable
  • Loading branch information
Blake Mason committed Aug 5, 2022
1 parent 31c0755 commit d6aa77c
Show file tree
Hide file tree
Showing 7 changed files with 244 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ searchable: true
settings:
availableTransforms: '*'
availableVolumes: '*'
cleanupHtml: true
columnType: text
configSelectionMode: choose
defaultTransform: ''
manualConfig: ''
purifierConfig: ''
purifyHtml: '1'
redactorConfig: ''
redactorConfig: TextContentBlock.json
removeEmptyTags: '1'
removeInlineStyles: '1'
removeInlineStyles: ''
removeNbsp: '1'
showHtmlButtonForNonAdmins: ''
showUnpermittedFiles: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ fields:
settings:
availableTransforms: '*'
availableVolumes: '*'
cleanupHtml: true
columnType: text
configSelectionMode: choose
defaultTransform: ''
Expand All @@ -54,7 +53,7 @@ fields:
purifyHtml: '1'
redactorConfig: TableCellContent.json
removeEmptyTags: '1'
removeInlineStyles: '1'
removeInlineStyles: ''
removeNbsp: '1'
showHtmlButtonForNonAdmins: ''
showUnpermittedFiles: false
Expand All @@ -73,9 +72,9 @@ fields:
searchable: false
settings:
decimals: 0
defaultValue: '1'
defaultValue: 1
max: null
min: '1'
min: 1
prefix: null
previewCurrency: ''
previewFormat: decimal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,15 @@ fields:
settings:
availableTransforms: '*'
availableVolumes: '*'
cleanupHtml: true
columnType: text
configSelectionMode: choose
defaultTransform: ''
manualConfig: ''
purifierConfig: ''
purifyHtml: '1'
redactorConfig: Basic.json
redactorConfig: TableCellContent.json
removeEmptyTags: '1'
removeInlineStyles: '1'
removeInlineStyles: ''
removeNbsp: '1'
showHtmlButtonForNonAdmins: ''
showUnpermittedFiles: false
Expand All @@ -74,6 +73,17 @@ fields:
settings:
optgroups: true
options:
-
__assoc__:
-
- label
- None
-
- value
- none
-
- default
- '1'
-
__assoc__:
-
Expand Down Expand Up @@ -132,16 +142,15 @@ fields:
settings:
availableTransforms: '*'
availableVolumes: '*'
cleanupHtml: true
columnType: text
configSelectionMode: choose
defaultTransform: ''
manualConfig: ''
purifierConfig: ''
purifyHtml: '1'
redactorConfig: Basic.json
redactorConfig: TableCellContent.json
removeEmptyTags: '1'
removeInlineStyles: '1'
removeInlineStyles: ''
removeNbsp: '1'
showHtmlButtonForNonAdmins: ''
showUnpermittedFiles: false
Expand Down
2 changes: 1 addition & 1 deletion api/config/project/project.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dateModified: 1658273486
dateModified: 1658513569
email:
fromEmail: $EMAIL_FROM_ADDRESS
fromName: $EMAIL_SENDER_NAME
Expand Down
8 changes: 5 additions & 3 deletions api/config/redactor/TableCellContent.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"buttons": ["bold", "italic", "link"],
"toolbarFixed": true,
"plugins": ["alignment"]
"buttons": ["bold", "italic", "lists", "link"],
"plugins": ["alignment", "textcolor"],
"enforceButtonOrder": ["alignment", "fontcolor", "bold", "italic", "lists", "link"],
"fontcolors": ["#2B8000", "#A85A00", "#1C55E6"],
"toolbarFixed": true
}
9 changes: 9 additions & 0 deletions api/config/redactor/TextContentBlock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

{
"buttons": ["html", "format", "bold", "italic", "deleted", "lists", "image", "file", "link"],
"plugins": ["textcolor", "fullscreen"],
"enforceButtonOrder": ["html", "format", "fontcolor", "bold", "italic", "deleted", "lists", "image", "file", "link", "fullscreen"],
"fontcolors": ["#2B8000", "#A85A00", "#1C55E6"],
"linkNewTab": true,
"toolbarFixed": true
}
209 changes: 209 additions & 0 deletions api/config/redactor/plugins/textcolor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
(function ($R) {
$R.add('plugin', 'textcolor', {
translations: {
en: {
fontcolor: 'Text Color',
text: 'Text',
highlight: 'Highlight',
},
},
init: function (app) {
this.app = app;
this.opts = app.opts;
this.lang = app.lang;
this.inline = app.inline;
this.toolbar = app.toolbar;
this.selection = app.selection;

// local
this.colors = this.opts.fontcolors
? this.opts.fontcolors
: [
'#ffffff',
'#000000',
'#eeece1',
'#1f497d',
'#4f81bd',
'#c0504d',
'#9bbb59',
'#8064a2',
'#4bacc6',
'#f79646',
'#ffff00',
'#f2f2f2',
'#7f7f7f',
'#ddd9c3',
'#c6d9f0',
'#dbe5f1',
'#f2dcdb',
'#ebf1dd',
'#e5e0ec',
'#dbeef3',
'#fdeada',
'#fff2ca',
'#d8d8d8',
'#595959',
'#c4bd97',
'#8db3e2',
'#b8cce4',
'#e5b9b7',
'#d7e3bc',
'#ccc1d9',
'#b7dde8',
'#fbd5b5',
'#ffe694',
'#bfbfbf',
'#3f3f3f',
'#938953',
'#548dd4',
'#95b3d7',
'#d99694',
'#c3d69b',
'#b2a2c7',
'#b7dde8',
'#fac08f',
'#f2c314',
'#a5a5a5',
'#262626',
'#494429',
'#17365d',
'#366092',
'#953734',
'#76923c',
'#5f497a',
'#92cddc',
'#e36c09',
'#c09100',
'#7f7f7f',
'#0c0c0c',
'#1d1b10',
'#0f243e',
'#244061',
'#632423',
'#4f6128',
'#3f3151',
'#31859b',
'#974806',
'#7f6000',
];
},
// messages
onfontcolor: {
set: function (rule, value) {
this._set(rule, value);
},
remove: function (rule) {
this._remove(rule);
},
},

// public
start: function () {
var btnObj = {
title: this.lang.get('fontcolor'),
};

var $dropdown = this._buildDropdown();

this.$button = this.toolbar.addButton('fontcolor', btnObj);
this.$button.setIcon('<i class="re-icon-fontcolor"></i>');
this.$button.setDropdown($dropdown);
},

// private
_buildDropdown: function () {
var $dropdown = $R.dom('<div class="redactor-dropdown-cells">');

this.$selector = this._buildSelector();

this.$pickerText = this._buildPicker('textcolor');

$dropdown.append(this.$selector);
$dropdown.append(this.$pickerText);

$dropdown.width(242);

return $dropdown;
},
_buildSelector: function () {
var $selector = $R.dom('<div>');
$selector.addClass('redactor-dropdown-selector');

return $selector;
},
_buildSelectorItem: function (name, title) {
var $item = $R.dom('<span>');
$item.attr('rel', name).html(title);
$item.addClass('redactor-dropdown-not-close');

return $item;
},
_buildPicker: function (name) {
var $box = $R.dom('<div class="re-dropdown-box-' + name + '">');
var rule = name == 'backcolor' ? 'background-color' : 'color';
var len = this.colors.length;
var self = this;
var func = function (e) {
e.preventDefault();

var $el = $R.dom(e.target);
self._set($el.data('rule'), $el.attr('rel'));
};

for (var z = 0; z < len; z++) {
var color = this.colors[z];

var $swatch = $R.dom('<span>');
$swatch.attr({rel: color, 'data-rule': rule});
$swatch.css({
'background-color': color,
'font-size': 0,
border: '2px solid #fff',
width: '22px',
height: '22px',
});
$swatch.on('mousedown', func);

$box.append($swatch);
}

var $el = $R.dom('<a>');
$el.attr({href: '#'});
$el.css({
display: 'block',
clear: 'both',
padding: '8px 5px',
'font-size': '12px',
'line-height': 1,
});
$el.html(this.lang.get('none'));

$el.on('click', function (e) {
e.preventDefault();
self._remove(rule);
});

$box.append($el);

if (name == 'backcolor') $box.hide();

return $box;
},
_set: function (rule, value) {
var style = {};
style[rule] = value;

var args = {
tag: 'span',
style: style,
type: 'toggle',
};

this.inline.format(args);
},
_remove: function (rule) {
this.inline.remove({style: rule});
this.app.broadcast('hardsync');
},
});
})(Redactor);

0 comments on commit d6aa77c

Please sign in to comment.