diff --git a/app/assets/javascripts/legacy/controllers/posts/edit.js b/app/assets/javascripts/legacy/controllers/posts/edit.js
index c73141c7e..18cbaa1bf 100644
--- a/app/assets/javascripts/legacy/controllers/posts/edit.js
+++ b/app/assets/javascripts/legacy/controllers/posts/edit.js
@@ -55,7 +55,7 @@ angular.module('cortex.controllers.posts.edit', [
ImageFitService.initRedactorImageFitPlugin();
$scope.redactorOptions = {
- plugins: ['media', 'imageFit'],
+ plugins: ['media', 'imageFit', 'inlinestyle'],
minHeight: 800,
buttonSource: true,
deniedTags: ['html', 'head', 'link', 'body', 'applet'] // Allow script, style
diff --git a/app/assets/javascripts/legacy/vendor/redactor.js b/app/assets/javascripts/legacy/vendor/redactor.js
index 2ac60a744..fe045dbe3 100644
--- a/app/assets/javascripts/legacy/vendor/redactor.js
+++ b/app/assets/javascripts/legacy/vendor/redactor.js
@@ -1,6 +1,6 @@
/*
- Redactor v10.0.6
- Updated: January 7, 2015
+ Redactor 10.2.1
+ Updated: July 6, 2015
http://imperavi.com/redactor/
@@ -12,6 +12,7 @@
(function($)
{
+
'use strict';
if (!Function.prototype.bind)
@@ -28,9 +29,6 @@
var uuid = 0;
- var reUrlYoutube = /https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com\S*[^\w\-\s])([\w\-]{11})(?=[^\w\-]|$)(?![?=&+%\w.\-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/ig;
- var reUrlVimeo = /https?:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/;
-
// Plugin
$.fn.redactor = function(options)
{
@@ -94,11 +92,11 @@
// Functionality
$.Redactor = Redactor;
- $.Redactor.VERSION = '10.0.6';
+ $.Redactor.VERSION = '10.2.2';
$.Redactor.modules = ['alignment', 'autosave', 'block', 'buffer', 'build', 'button',
'caret', 'clean', 'code', 'core', 'dropdown', 'file', 'focus',
'image', 'indent', 'inline', 'insert', 'keydown', 'keyup',
- 'lang', 'line', 'link', 'list', 'modal', 'observe', 'paragraphize',
+ 'lang', 'line', 'link', 'linkify', 'list', 'modal', 'observe', 'paragraphize',
'paste', 'placeholder', 'progress', 'selection', 'shortcuts',
'tabifier', 'tidy', 'toolbar', 'upload', 'utils'];
@@ -135,6 +133,7 @@
autosaveName: false,
autosaveInterval: 60, // seconds
autosaveOnChange: false,
+ autosaveFields: false,
linkTooltip: true,
linkProtocol: 'http',
@@ -147,14 +146,14 @@
imageFloatMargin: '10px',
imageResizable: true,
- imageUpload: false,
+ imageUpload: null,
imageUploadParam: 'file',
uploadImageField: false,
dragImageUpload: true,
- fileUpload: false,
+ fileUpload: null,
fileUploadParam: 'file',
dragFileUpload: true,
@@ -173,15 +172,18 @@
scrollTarget: false,
toolbar: true,
- toolbarFixed: true,
+ /* concrete5 */
+ /*toolbarFixed: true,*/
+ toolbarFixed: false,
+ /* end concrete5 */
toolbarFixedTarget: document,
toolbarFixedTopOffset: 0, // pixels
toolbarExternal: false, // ID selector
toolbarOverflow: false,
- buttonSource: false,
+ source: true,
buttons: ['html', 'formatting', 'bold', 'italic', 'deleted', 'unorderedlist', 'orderedlist',
- 'outdent', 'indent', 'image', 'file', 'link', 'alignment', 'horizontalrule'], // + 'underline'
+ 'outdent', 'indent', 'image', /* concrete5 'file', */ 'link', 'alignment', 'horizontalrule'], // + 'underline'
buttonsHide: [],
buttonsHideOnMobile: [],
@@ -191,12 +193,17 @@
tabifier: true,
- deniedTags: ['html', 'head', 'link', 'body', 'meta', 'script', 'style', 'applet'],
+ deniedTags: ['script', 'style'],
allowedTags: false, // or array
+ paragraphizeBlocks: ['table', 'div', 'pre', 'form', 'ul', 'ol', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'dl', 'blockquote', 'figcaption',
+ 'address', 'section', 'header', 'footer', 'aside', 'article', 'object', 'style', 'script', 'iframe', 'select', 'input', 'textarea',
+ 'button', 'option', 'map', 'area', 'math', 'hr', 'fieldset', 'legend', 'hgroup', 'nav', 'figure', 'details', 'menu', 'summary', 'p'],
+
removeComments: false,
replaceTags: [
- ['strike', 'del']
+ ['strike', 'del'],
+ ['b', 'strong']
],
replaceStyles: [
['font-weight:\\s?bold', "strong"],
@@ -238,6 +245,12 @@
},
shortcutsAdd: false,
+ concrete5: {
+ filemanager: false,
+ sitemap: false,
+ lightbox: false
+ },
+
// private
buffer: [],
rebuffer: [],
@@ -249,7 +262,10 @@
inlineTags: ['strong', 'b', 'u', 'em', 'i', 'code', 'del', 'ins', 'samp', 'kbd', 'sup', 'sub', 'mark', 'var', 'cite', 'small'],
alignmentTags: ['P', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'DL', 'DT', 'DD', 'DIV', 'TD', 'BLOCKQUOTE', 'OUTPUT', 'FIGCAPTION', 'ADDRESS', 'SECTION', 'HEADER', 'FOOTER', 'ASIDE', 'ARTICLE'],
blockLevelElements: ['PRE', 'UL', 'OL', 'LI'],
-
+ highContrast: false,
+ observe: {
+ dropdowns: []
+ },
// lang
langs: {
@@ -295,7 +311,7 @@
columns: 'Columns',
add_head: 'Add Head',
delete_head: 'Delete Head',
- title: 'Title',
+ alt: 'Alt',
image_position: 'Position',
none: 'None',
left: 'Left',
@@ -320,12 +336,45 @@
deleted: 'Deleted',
anchor: 'Anchor',
link_new_tab: 'Open link in new tab',
+ /* concrete5 */
+ link_same_window: 'Open link in same window',
+ in_lightbox: 'Open link in Lightbox',
+ lightbox_link_type: 'Link Type',
+ lightbox_link_type_iframe: 'Web Page',
+ lightbox_link_type_image: 'Image',
+ lightbox_link_type_iframe_options: 'Frame Options',
+ lightbox_link_type_iframe_width: 'Width',
+ lightbox_link_type_iframe_height: 'Height',
+ customStyles: 'Custom Styles',
+ remove_font: 'Remove font',
+ change_font_family: 'Change font family',
+ remove_font_size: 'Remove font size',
+ change_font_size: 'Change font size',
+ remove_style: 'Remove Style',
+ insert_character: 'Insert Character',
+ undo: 'Undo',
+ redo: 'Redo',
+ remove_font_family: 'Remove Font Family',
+ // Remember to add new strings also in in /concrete/controllers/frontend/assets_localization.php, function getRedactorJavascript
+ /* end concrete5 */
underline: 'Underline',
alignment: 'Alignment',
filename: 'Name (optional)',
- edit: 'Edit'
+ edit: 'Edit',
+ upload_label: 'Drop file here or '
}
- }
+ },
+
+ linkify: {
+ regexps: {
+ youtube: /https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com\S*[^\w\-\s])([\w\-]{11})(?=[^\w\-]|$)(?![?=&+%\w.\-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/ig,
+ vimeo: /https?:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/,
+ image: /((https?|www)[^\s]+\.)(jpe?g|png|gif)(\?[^\s-]+)?/ig,
+ url: /(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/ig,
+ }
+ },
+
+ codemirror: false
};
// Functionality
@@ -334,6 +383,7 @@
keyCode: {
BACKSPACE: 8,
DELETE: 46,
+ UP: 38,
DOWN: 40,
ENTER: 13,
SPACE: 32,
@@ -371,6 +421,16 @@
// setup allowed and denied tags
this.tidy.setupAllowed();
+ // setup denied tags
+ if (this.opts.deniedTags !== false)
+ {
+ var tags = ['html', 'head', 'link', 'body', 'meta', 'applet'];
+ for (var i = 0; i < tags.length; i++)
+ {
+ this.opts.deniedTags.push(tags[i]);
+ }
+ }
+
// load lang
this.lang.load();
@@ -425,7 +485,6 @@
this[module][methods[z]] = this[module][methods[z]].bind(this);
}
},
-
alignment: function()
{
return {
@@ -447,92 +506,129 @@
},
set: function(type)
{
+ // focus
if (!this.utils.browser('msie')) this.$editor.focus();
this.buffer.set();
this.selection.save();
+ // get blocks
this.alignment.blocks = this.selection.getBlocks();
- if (this.opts.linebreaks && this.alignment.blocks[0] === false)
+ this.alignment.type = type;
+
+ // set alignment
+ if (this.alignment.isLinebreaksOrNoBlocks())
{
- this.alignment.setText(type);
+ this.alignment.setText();
}
else
{
- this.alignment.setBlocks(type);
+ this.alignment.setBlocks();
}
+ // sync
this.selection.restore();
this.code.sync();
},
- setText: function(type)
+ setText: function()
{
var wrapper = this.selection.wrap('div');
- $(wrapper).attr('data-tagblock', 'redactor');
- $(wrapper).css('text-align', type);
+ $(wrapper).attr('data-tagblock', 'redactor').css('text-align', this.alignment.type);
},
- setBlocks: function(type)
+ setBlocks: function()
{
$.each(this.alignment.blocks, $.proxy(function(i, el)
{
var $el = this.utils.getAlignmentElement(el);
-
if (!$el) return;
- if (type === '' && typeof($el.data('tagblock')) !== 'undefined')
+ if (this.alignment.isNeedReplaceElement($el))
{
- $el.replaceWith($el.html());
+ this.alignment.replaceElement($el);
}
else
{
- $el.css('text-align', type);
- this.utils.removeEmptyAttr($el, 'style');
+ this.alignment.alignElement($el);
}
-
}, this));
+ },
+ isLinebreaksOrNoBlocks: function()
+ {
+ return (this.opts.linebreaks && this.alignment.blocks[0] === false);
+ },
+ isNeedReplaceElement: function($el)
+ {
+ return (this.alignment.type === '' && typeof($el.data('tagblock')) !== 'undefined');
+ },
+ replaceElement: function($el)
+ {
+ $el.replaceWith($el.html());
+ },
+ alignElement: function($el)
+ {
+ $el.css('text-align', this.alignment.type);
+ this.utils.removeEmptyAttr($el, 'style');
}
};
},
autosave: function()
{
return {
+ html: false,
enable: function()
{
if (!this.opts.autosave) return;
- this.autosave.html = false;
this.autosave.name = (this.opts.autosaveName) ? this.opts.autosaveName : this.$textarea.attr('name');
- if (!this.opts.autosaveOnChange)
- {
- this.autosaveInterval = setInterval($.proxy(this.autosave.load, this), this.opts.autosaveInterval * 1000);
- }
+ if (this.opts.autosaveOnChange) return;
+ this.autosaveInterval = setInterval(this.autosave.load, this.opts.autosaveInterval * 1000);
},
onChange: function()
{
if (!this.opts.autosaveOnChange) return;
-
this.autosave.load();
},
load: function()
{
- var html = this.code.get();
- if (this.autosave.html === html) return;
- if (this.utils.isEmpty(html)) return;
+ this.autosave.source = this.code.get();
- $.ajax({
+ if (this.autosave.html === this.autosave.source) return;
+
+ // data
+ var data = {};
+ data['name'] = this.autosave.name;
+ data[this.autosave.name] = this.autosave.source;
+ data = this.autosave.getHiddenFields(data);
+
+ // ajax
+ var jsxhr = $.ajax({
url: this.opts.autosave,
type: 'post',
- data: 'name=' + this.autosave.name + '&' + this.autosave.name + '=' + escape(encodeURIComponent(html)),
- success: $.proxy(function(data)
- {
- this.autosave.success(data, html);
-
- }, this)
+ data: data
});
+
+ jsxhr.done(this.autosave.success);
+ },
+ getHiddenFields: function(data)
+ {
+ if (this.opts.autosaveFields === false || typeof this.opts.autosaveFields !== 'object')
+ {
+ return data;
+ }
+
+ $.each(this.opts.autosaveFields, $.proxy(function(k, v)
+ {
+ if (v !== null && v.toString().indexOf('#') === 0) v = $(v).val();
+ data[k] = v;
+
+ }, this));
+
+ return data;
+
},
- success: function(data, html)
+ success: function(data)
{
var json;
try
@@ -548,7 +644,7 @@
var callbackName = (typeof json.error == 'undefined') ? 'autosave' : 'autosaveError';
this.core.setCallback(callbackName, this.autosave.name, json);
- this.autosave.html = html;
+ this.autosave.html = this.autosave.source;
},
disable: function()
{
@@ -566,7 +662,7 @@
if (typeof this.formatting[name].data != 'undefined') type = 'data';
else if (typeof this.formatting[name].attr != 'undefined') type = 'attr';
- else if (typeof this.formatting[name].class != 'undefined') type = 'class';
+ else if (typeof this.formatting[name]['class'] != 'undefined') type = 'class';
if (typeof this.formatting[name].clear != 'undefined')
{
@@ -590,6 +686,23 @@
// focus
if (!this.utils.browser('msie')) this.$editor.focus();
+ var html = $.trim(this.$editor.html());
+ this.block.isEmpty = this.utils.isEmpty(html);
+
+ // FF focus
+ if (this.utils.browser('mozilla') && !this.focus.isFocused())
+ {
+ if (this.block.isEmpty)
+ {
+ var $first;
+ if (!this.opts.linebreaks)
+ {
+ $first = this.$editor.children().first();
+ this.caret.setEnd($first);
+ }
+ }
+ }
+
this.block.blocks = this.selection.getBlocks();
this.block.blocksSize = this.block.blocks.length;
@@ -603,10 +716,12 @@
this.selection.restore();
this.code.sync();
+ this.observe.load();
},
set: function(tag)
{
+
this.selection.get();
this.block.containerTag = this.range.commonAncestorContainer.tagName;
@@ -621,6 +736,16 @@
},
setCollapsed: function(tag)
{
+ if (this.opts.linebreaks && this.block.isEmpty && tag != 'p')
+ {
+ var node = document.createElement(tag);
+ this.$editor.html(node);
+ this.caret.setEnd(node);
+
+ return;
+ }
+
+
var block = this.block.blocks[0];
if (block === false) return;
@@ -635,7 +760,6 @@
var isContainerTable = (this.block.containerTag == 'TD' || this.block.containerTag == 'TH');
if (isContainerTable && !this.opts.linebreaks)
{
-
document.execCommand('formatblock', false, '<' + tag + '>');
block = this.selection.getBlock();
@@ -646,7 +770,7 @@
{
if (this.opts.linebreaks && tag == 'p')
{
- $(block).prepend('
').append('
');
+ $(block).append('
');
this.utils.replaceWithContents(block);
}
else
@@ -667,7 +791,7 @@
// blockquote off
if (this.opts.linebreaks)
{
- $(block).prepend('
').append('
');
+ $(block).append('
');
this.utils.replaceWithContents(block);
}
else
@@ -681,6 +805,13 @@
this.block.toggle($(block));
}
+
+
+ if (typeof this.block.type == 'undefined' && typeof this.block.value == 'undefined')
+ {
+ $(block).removeAttr('class').removeAttr('style');
+ }
+
},
setMultiple: function(tag)
{
@@ -694,7 +825,7 @@
// blockquote off
if (this.opts.linebreaks)
{
- $(block).prepend('
').append('
');
+ $(block).append('
');
this.utils.replaceWithContents(block);
}
else
@@ -756,14 +887,20 @@
{
$.each(this.block.blocks, $.proxy(function(i,s)
{
+ var $formatted = false;
if (this.opts.linebreaks)
{
$(s).prepend('
').append('
');
- this.utils.replaceWithContents(s);
+ $formatted = this.utils.replaceWithContents(s);
}
else
{
- this.utils.replaceToTag(s, 'p');
+ $formatted = this.utils.replaceToTag(s, 'p');
+ }
+
+ if ($formatted && typeof this.block.type == 'undefined' && typeof this.block.value == 'undefined')
+ {
+ $formatted.removeAttr('class').removeAttr('style');
}
}, this));
@@ -782,7 +919,7 @@
if (this.block.type == 'class')
{
toggleType = 'toggle';
- classSize = $(this.block.blocks).filter('.' + this.block.value).size();
+ classSize = $(this.block.blocks).filter('.' + this.block.value).length;
if (this.block.blocksSize == classSize) toggleType = 'toggle';
else if (this.block.blocksSize > classSize) toggleType = 'set';
@@ -809,6 +946,11 @@
if (this.block.isRemoveInline) this.utils.removeInlineTags($formatted);
if (tag == 'p' || this.block.headTag) $formatted.find('p').contents().unwrap();
+ if (typeof this.block.type == 'undefined' && typeof this.block.value == 'undefined')
+ {
+ $formatted.removeAttr('class').removeAttr('style');
+ }
+
}, this));
}
@@ -871,7 +1013,7 @@
},
formatListToBlockquote: function()
{
- var block = $(this.block.blocks[0]).closest('ul, ol');
+ var block = $(this.block.blocks[0]).closest('ul, ol', this.$editor[0]);
$(block).find('ul, ol').contents().unwrap();
$(block).find('li').append($('
')).contents().unwrap();
@@ -930,11 +1072,6 @@
var $elements = $formatted.find(this.opts.blockLevelElements.join(',') + ', td, table, thead, tbody, tfoot, th, tr');
- if ((this.opts.linebreaks && tag == 'p') || tag == 'pre' || tag == 'blockquote')
- {
- $elements.append('
');
- }
-
$elements.contents().unwrap();
if (tag != 'p' && tag != 'blockquote') $formatted.find('img').remove();
@@ -961,13 +1098,24 @@
this.utils.replaceWithContents($formatted);
}
+ if (this.opts.linebreaks)
+ {
+ var $next = $formatted.next().next();
+ if ($next.size() != 0 && $next[0].tagName === 'BR')
+ {
+ $next.remove();
+ }
+ }
+
+
+
},
formatTableWrapping: function($formatted)
{
- if ($formatted.closest('table').size() === 0) return;
+ if ($formatted.closest('table', this.$editor[0]).length === 0) return;
- if ($formatted.closest('tr').size() === 0) $formatted.wrap('