'),
- tableId = Math.floor(Math.random() * 99999),
- $table = $('
'),
- i, $row, z, $column;
-
- for (i = 0; i < rows; i++)
- {
- $row = $('
');
-
- for (z = 0; z < columns; z++)
- {
- $column = $('| ' + this.opts.invisibleSpace + ' | ');
-
- // set the focus to the first td
- if (i === 0 && z === 0)
- {
- $column.append(this.selection.getMarker());
- }
-
- $($row).append($column);
- }
-
- $table.append($row);
- }
-
- $tableBox.append($table);
- var html = $tableBox.html();
-
- this.modal.close();
- this.selection.restore();
-
- if (this.table.getTable()) return;
-
- this.buffer.set();
-
- var current = this.selection.getBlock() || this.selection.getCurrent();
- if (current && current.tagName != 'BODY')
- {
- if (current.tagName == 'LI') current = $(current).closest('ul, ol');
- $(current).after(html);
- }
- else
- {
- this.insert.html(html, false);
- }
-
- this.selection.restore();
-
- var table = this.$editor.find('#table' + tableId);
-
- if (!this.opts.linebreaks && (this.utils.browser('mozilla') || this.utils.browser('msie')))
- {
- var $next = table.next();
- if ($next.length === 0)
- {
- table.after(this.opts.emptyHtml);
- }
- }
-
- this.observe.buttons();
-
- table.find('span.redactor-selection-marker').remove();
- table.removeAttr('id');
-
- this.code.sync();
- this.core.setCallback('insertedTable', table);
- },
- getTable: function()
- {
- var $table = $(this.selection.getParent()).closest('table');
-
- if (!this.utils.isRedactorParent($table)) return false;
- if ($table.size() === 0) return false;
-
- return $table;
- },
- restoreAfterDelete: function($table)
- {
- this.selection.restore();
- $table.find('span.redactor-selection-marker').remove();
- this.code.sync();
- },
- deleteTable: function()
- {
- var $table = this.table.getTable();
- if (!$table) return;
-
- this.buffer.set();
-
-
- var $next = $table.next();
- if (!this.opts.linebreaks && $next.length !== 0)
- {
- this.caret.setStart($next);
- }
- else
- {
- this.caret.setAfter($table);
- }
-
-
- $table.remove();
-
- this.code.sync();
- },
- deleteRow: function()
- {
- var $table = this.table.getTable();
- if (!$table) return;
-
- var $current = $(this.selection.getCurrent());
-
- this.buffer.set();
-
- var $current_tr = $current.closest('tr');
- var $focus_tr = $current_tr.prev().length ? $current_tr.prev() : $current_tr.next();
- if ($focus_tr.length)
- {
- var $focus_td = $focus_tr.children('td, th').first();
- if ($focus_td.length) $focus_td.prepend(this.selection.getMarker());
- }
-
- $current_tr.remove();
- this.table.restoreAfterDelete($table);
- },
- deleteColumn: function()
- {
- var $table = this.table.getTable();
- if (!$table) return;
-
- this.buffer.set();
-
- var $current = $(this.selection.getCurrent());
- var $current_td = $current.closest('td, th');
- var index = $current_td[0].cellIndex;
-
- $table.find('tr').each($.proxy(function(i, elem)
- {
- var $elem = $(elem);
- var focusIndex = index - 1 < 0 ? index + 1 : index - 1;
- if (i === 0) $elem.find('td, th').eq(focusIndex).prepend(this.selection.getMarker());
-
- $elem.find('td, th').eq(index).remove();
-
- }, this));
-
- this.table.restoreAfterDelete($table);
- },
- addHead: function()
- {
- var $table = this.table.getTable();
- if (!$table) return;
-
- this.buffer.set();
-
- if ($table.find('thead').size() !== 0)
- {
- this.table.deleteHead();
- return;
- }
-
- var tr = $table.find('tr').first().clone();
- tr.find('td').replaceWith($.proxy(function()
- {
- return $('').html(this.opts.invisibleSpace);
- }, this));
-
- $thead = $('').append(tr);
- $table.prepend($thead);
-
- this.code.sync();
-
- },
- deleteHead: function()
- {
- var $table = this.table.getTable();
- if (!$table) return;
-
- var $thead = $table.find('thead');
- if ($thead.size() === 0) return;
-
- this.buffer.set();
-
- $thead.remove();
- this.code.sync();
- },
- addRowAbove: function()
- {
- this.table.addRow('before');
- },
- addRowBelow: function()
- {
- this.table.addRow('after');
- },
- addColumnLeft: function()
- {
- this.table.addColumn('before');
- },
- addColumnRight: function()
- {
- this.table.addColumn('after');
- },
- addRow: function(type)
- {
- var $table = this.table.getTable();
- if (!$table) return;
-
- this.buffer.set();
-
- var $current = $(this.selection.getCurrent());
- var $current_tr = $current.closest('tr');
- var new_tr = $current_tr.clone();
-
- new_tr.find('th').replaceWith(function()
- {
- var $td = $(' | ');
- $td[0].attributes = this.attributes;
-
- return $td.append($(this).contents());
- });
-
- new_tr.find('td').html(this.opts.invisibleSpace);
-
- if (type == 'after')
- {
- $current_tr.after(new_tr);
- }
- else
- {
- $current_tr.before(new_tr);
- }
-
- this.code.sync();
- },
- addColumn: function (type)
- {
- var $table = this.table.getTable();
- if (!$table) return;
-
- var index = 0;
- var current = $(this.selection.getCurrent());
-
- this.buffer.set();
-
- var $current_tr = current.closest('tr');
- var $current_td = current.closest('td, th');
-
- $current_tr.find('td, th').each($.proxy(function(i, elem)
- {
- if ($(elem)[0] === $current_td[0]) index = i;
-
- }, this));
-
- $table.find('tr').each($.proxy(function(i, elem)
- {
- var $current = $(elem).find('td, th').eq(index);
-
- var td = $current.clone();
- td.html(this.opts.invisibleSpace);
-
- if (type == 'after')
- {
- $current.after(td);
- }
- else
- {
- $current.before(td);
- }
-
- }, this));
-
- this.code.sync();
- }
- };
- };
-})(jQuery);
\ No newline at end of file
diff --git a/modules/backend/formwidgets/richeditor/assets/js/richeditor.js b/modules/backend/formwidgets/richeditor/assets/js/richeditor.js
index 22956ba52..55fbd0a0d 100755
--- a/modules/backend/formwidgets/richeditor/assets/js/richeditor.js
+++ b/modules/backend/formwidgets/richeditor/assets/js/richeditor.js
@@ -22,7 +22,6 @@
this.$el = $(element)
this.$textarea = this.$el.find('>textarea:first')
this.$form = this.$el.closest('form')
- this.$dataLocker = null
this.$editor = null
this.redactor = null
@@ -37,7 +36,6 @@
RichEditor.prototype.constructor = RichEditor
RichEditor.DEFAULTS = {
- dataLocker: null,
linksHandler: null,
stylesheet: null,
fullpage: false,
@@ -49,15 +47,6 @@
this.$el.one('dispose-control', this.proxy(this.dispose))
- /*
- * Sync all changes to a data locker, since fullscreen mode
- * will pull the textarea outside of the form element.
- */
- if (this.options.dataLocker) {
- this.$dataLocker = $(this.options.dataLocker)
- this.$textarea.val(this.$dataLocker.val())
- }
-
/*
* Textarea must have an identifier
*/
@@ -68,52 +57,66 @@
/*
* Initialize Redactor editor
*/
- var redactorOptions = {
- lang: this.options.editorLang,
- imageEditable: true,
- imageResizable: true,
- buttonSource: true,
- removeDataAttr: false,
- toolbarFixed: false,
- visualCallback: this.proxy(this.onVisualMode),
- syncBeforeCallback: this.proxy(this.onSyncBefore),
- focusCallback: this.proxy(this.onFocus),
- blurCallback: this.proxy(this.onBlur),
- keydownCallback: this.proxy(this.onKeydown),
- enterCallback: this.proxy(this.onEnter),
- changeCallback: this.proxy(this.onChange),
- pageLinksHandler: this.options.linksHandler,
- initCallback: function() { self.build(this) }
+ var froalaOptions = {
+ editorClass: 'control-richeditor',
+ height: Infinity // Height set via CSS, enable the scrollbars
}
- if (this.options.fullpage) {
- redactorOptions.fullpage = true
+ froalaOptions.toolbarButtons = [
+ 'fullscreen',
+ 'bold',
+ 'italic',
+ 'underline',
+ 'strikeThrough',
+ 'subscript',
+ 'superscript',
+ 'fontFamily',
+ 'fontSize',
+ 'color',
+ 'emoticons',
+ 'inlineStyle',
+ 'paragraphStyle',
+ 'paragraphFormat',
+ 'align',
+ 'formatOL',
+ 'formatUL',
+ 'outdent',
+ 'indent',
+ 'quote',
+ 'insertHR',
+ 'insertLink',
+ 'insertImage',
+ 'insertVideo',
+ 'insertFile',
+ 'insertTable',
+ 'undo',
+ 'redo',
+ 'clearFormatting',
+ 'selectAll',
+ 'html'
+ ]
+
+ froalaOptions.toolbarButtonsMD = froalaOptions.toolbarButtons
+ froalaOptions.toolbarButtonsSM = froalaOptions.toolbarButtons
+ froalaOptions.toolbarButtonsXS = froalaOptions.toolbarButtons
+ froalaOptions.htmlAllowedEmptyTags = ['figure', 'textarea', 'a', 'iframe', 'object', 'video', 'style', 'script']
+ froalaOptions.htmlDoNotWrapTags = ['figure', 'script', 'style']
+
+ $.FroalaEditor.ICON_TEMPLATES = {
+ font_awesome: '',
+ text: '[NAME]',
+ image: ' '
}
- redactorOptions.plugins = ['fullscreen', 'figure', 'table', 'pagelinks', 'mediamanager']
- redactorOptions.buttons = ['html', 'formatting', 'bold', 'italic', 'alignment', 'unorderedlist', 'orderedlist', 'link', 'horizontalrule'],
+ this.$textarea.on('froalaEditor.initialized', this.proxy(this.build))
- this.$textarea.redactor(redactorOptions)
-
- this.redactor = this.$textarea.redactor('core.getObject')
- this.$editor = this.redactor.$editor
+ this.$textarea.froalaEditor(froalaOptions)
}
RichEditor.prototype.dispose = function() {
this.unregisterHandlers()
- // Release clickedElement reference inside redactor.js
- $(document).trigger('mousedown')
-
- this.redactor.core.destroy()
-
- // The figure plugin keeps references to the editor,
- // DOM elements and event handlers. It was hacked and
- // extended with the destroy() method.
- if (this.redactor.figure) {
- this.redactor.figure.destroy()
- this.redactor.figure = null
- }
+ this.$textarea.froalaEditor('destroy')
this.$el.removeData('oc.richEditor')
@@ -121,14 +124,8 @@
this.$el = null
this.$textarea = null
this.$form = null
- this.$dataLocker = null
this.$editor = null
- this.redactor.$textarea = null
- this.redactor.$element = null
-
- this.redactor = null
-
BaseProto.dispose.call(this)
}
@@ -138,7 +135,7 @@
this.$el.off('dispose-control', this.proxy(this.dispose))
}
- RichEditor.prototype.build = function(redactor) {
+ RichEditor.prototype.build = function(event, editor) {
this.updateLayout()
$(window).on('resize', this.proxy(this.updateLayout))
@@ -148,12 +145,12 @@
this.initUiBlocks()
- var self = this
- redactor.default = {
- onShow: function($figure, $toolbar) {
- self.onShowFigureToolbar($figure, $toolbar)
- }
- }
+ // var self = this
+ // redactor.default = {
+ // onShow: function($figure, $toolbar) {
+ // self.onShowFigureToolbar($figure, $toolbar)
+ // }
+ // }
}
RichEditor.prototype.getElement = function() {
@@ -175,19 +172,24 @@
}
RichEditor.prototype.updateLayout = function() {
- var $editor = $('.redactor-editor', this.$el),
- $codeEditor = $('textarea', this.$el),
- $toolbar = $('.redactor-toolbar', this.$el)
+ var $editor = $('.fr-wrapper', this.$el),
+ $codeEditor = $('.fr-code', this.$el),
+ $toolbar = $('.fr-toolbar', this.$el),
+ $box = $('.fr-box', this.$el)
if (!$editor.length) {
return
}
- if (this.$el.hasClass('stretch')) {
+ if (this.$el.hasClass('stretch') && !$box.hasClass('fr-fullscreen')) {
var height = $toolbar.outerHeight(true)
$editor.css('top', height+1)
$codeEditor.css('top', height)
}
+ else {
+ $editor.css('top', '')
+ $codeEditor.css('top', '')
+ }
}
RichEditor.prototype.sanityCheckContent = function() {
@@ -289,7 +291,7 @@
}
RichEditor.prototype.initUiBlocks = function() {
- $('.redactor-editor [data-video], .redactor-editor [data-audio]', this.$el).each(function() {
+ $('.fr-wrapper [data-video], .fr-wrapper [data-audio]', this.$el).each(function() {
$(this).attr({
'data-ui-block': true,
'tabindex': '0'
@@ -436,10 +438,6 @@
this.sanityCheckContent()
this.$editor.trigger('mutate')
this.$form.trigger('change')
-
- if (this.$dataLocker) {
- this.$dataLocker.val(this.syncBefore(this.$editor.html()))
- }
}
// RICHEDITOR PLUGIN DEFINITION
diff --git a/modules/backend/formwidgets/richeditor/assets/less/richeditor.less b/modules/backend/formwidgets/richeditor/assets/less/richeditor.less
index d389e0a9e..6351edda3 100755
--- a/modules/backend/formwidgets/richeditor/assets/less/richeditor.less
+++ b/modules/backend/formwidgets/richeditor/assets/less/richeditor.less
@@ -10,8 +10,10 @@
@color-richeditor-toolbar-btn-bg-active: #404040;
@color-richeditor-toolbar-btn-color-hover: #ffffff;
-@import "_figures.less";
-@import "../vendor/redactor/redactor.less";
+@import "../vendor/froala_drm/less/plugins/code_view.less";
+@import "../vendor/froala/css/froala_editor.min.css";
+@import "../vendor/froala/css/froala_style.min.css";
+@import "../vendor/froala/css/plugins/fullscreen.css";
.field-flush .field-richeditor {
&, &.editor-focus {
@@ -19,107 +21,36 @@
}
}
+.richeditor-set-height(@size) {
+ .fr-wrapper {
+ height: @size;
+ .fr-view {
+ min-height: @size;
+ }
+ }
+}
+
.field-richeditor {
border: 1px solid @color-form-field-border;
.transition(@input-transition);
- &, .redactor-box {
- .border-radius(5px);
- }
- .redactor-toolbar {
- .border-top-radius(5px);
- }
-
&.editor-focus {
border-color: @color-form-field-border-focus;
}
- &.size-tiny .redactor-editor { height: (@size-tiny - @richeditor-toolbar-size) !important; }
- &.size-small .redactor-editor { height: (@size-small - @richeditor-toolbar-size) !important; }
- &.size-large .redactor-editor { height: (@size-large - @richeditor-toolbar-size) !important; }
- &.size-huge .redactor-editor { height: (@size-huge - @richeditor-toolbar-size) !important; }
- &.size-giant .redactor-editor { height: (@size-giant - @richeditor-toolbar-size) !important; }
+ &.size-tiny { .richeditor-set-height(@size-tiny); }
+ &.size-small { .richeditor-set-height(@size-small); }
+ &.size-large { .richeditor-set-height(@size-large); }
+ &.size-huge { .richeditor-set-height(@size-huge); }
+ &.size-giant { .richeditor-set-height(@size-giant); }
}
//
-// Override redactor defaults
+// Overrides
//
-.redactor-box {
- margin-bottom: 0;
- overflow: hidden;
-
- & iframe {
- border: none; // Oc
- }
-}
-
-.redactor-box-fullscreen {
- z-index: @richeditor-zindex + 115 !important;
-}
-
-.redactor-dropdown {
- z-index: @richeditor-zindex + 125 !important;
-}
-#redactor-modal-overlay,
-#redactor-modal-box,
-#redactor-modal {
- z-index: @richeditor-zindex + 120 !important;
-}
-
-.redactor-toolbar {
- background: @color-richeditor-toolbar;
- .box-shadow(none);
- z-index: 410 !important;
-
- li.redactor-btn-right {
- float: right;
- margin-right: 2px;
- }
-
- li a {
- color: @color-richeditor-toolbar-btn-color;
- font-size: 14px;
- width: 20px;
- line-height: 20px;
-
- .user-select(none);
-
- &:hover {
- background-color: @color-richeditor-toolbar-btn-bg-hover;
- color: @color-richeditor-toolbar-btn-color-hover;
- }
-
- &:active,
- &.redactor-act {
- background-color: @color-richeditor-toolbar-btn-bg-active;
- color: @color-richeditor-toolbar-btn-color-hover;
- }
-
- &.fa-redactor-btn {
- padding: 9px 10px;
- line-height: 20px;
- }
-
- &.oc-redactor-button i:before {
- font-size: 16px !important;
- }
-
- &.oc-autumn-button {
- color: #c03f31;
-
- &:hover {
- color: white !important;
- }
- }
- }
-}
-
-.redactor-editor {
- border: none;
- font-size: 13px;
- color: @input-color;
- padding: 15px;
+.fr-toolbar {
+ border-top: none;
}
//
@@ -127,7 +58,7 @@
//
.field-richeditor.stretch {
- .redactor-box {
+ .fr-box:not(.fr-fullscreen) {
display: block;
position: relative;
height: 100% !important;
@@ -135,17 +66,11 @@
.border-radius(0) !important;
overflow: hidden;
- .redactor-toolbar {
+ .fr-toolbar {
.border-radius(0) !important;
-
- display: block;
- border-bottom: none;
- position: absolute;
- width: 100%;
- top: 0;
}
- .redactor-editor, textarea {
+ .fr-wrapper {
width: 100% !important;
left: 0;
top: 0;
@@ -155,39 +80,23 @@
padding: 20px;
}
- .redactor-editor {
- height: auto !important;
+ .fr-view, textarea {
+ height: 100%;
+ padding: 0;
}
- textarea {
- padding: 10px;
+ .fr-placeholder {
+ top: 20px;
+ left: 20px;
}
}
}
-//
-// Full screen
-//
-
-body .redactor-box-fullscreen {
- background: @body-bg;
- overflow-y: scroll !important;
- width: 100% !important;
- .redactor-editor {
- background: #fff;
- max-width: 960px;
- padding: 50px 30px !important;
- margin: @richeditor-gutter auto !important;
- padding: @richeditor-gutter;
- top: 0 !important;
- }
-}
-
//
// Placeholders and snippets
//
-.redactor-editor {
+.control-richeditor {
.richeditor-snippet() {
display: block;
margin: 0 0 15px 0;
@@ -237,4 +146,4 @@ body .redactor-box-fullscreen {
.icon(@volume-up);
}
}
-}
\ No newline at end of file
+}
diff --git a/modules/backend/formwidgets/richeditor/partials/_richeditor.htm b/modules/backend/formwidgets/richeditor/partials/_richeditor.htm
index 18783a61a..41bf60c84 100755
--- a/modules/backend/formwidgets/richeditor/partials/_richeditor.htm
+++ b/modules/backend/formwidgets/richeditor/partials/_richeditor.htm
@@ -7,14 +7,8 @@
class="field-richeditor size-= $size ?> = $stretch?'layout-relative stretch':'' ?>"
data-editor-lang="= $editorLang ?>"
data-fullpage="true"
- data-data-locker="#= $this->getId('dataLocker') ?>"
data-links-handler="= $this->getEventHandler('onGetPageLinks') ?>"
data-control="richeditor">
-
-
-
-
-
-
+
|