mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-28 20:45:00 +03:00
Доработка компонента Editor
* Код оформлен в виде виджетов jQuery * Управление разными редакторами сделано через один виджет lsEditor * Обновлен TinyMCE до последней версии * Адаптация TinyMCE в процессе
This commit is contained in:
parent
a0b83b9534
commit
e643a48fe8
|
@ -521,7 +521,7 @@ $config['head']['default']['js'] = array(
|
|||
"___path.application.web___/frontend/common/js/favourite_topic.js",
|
||||
"___path.application.web___/frontend/common/js/blocks.js",
|
||||
"___path.application.web___/frontend/common/js/pagination.js",
|
||||
"___path.application.web___/frontend/common/js/editor.js",
|
||||
"___path.skin.web___/components/editor/js/editor.js",
|
||||
"___path.application.web___/frontend/common/js/talk.js",
|
||||
"___path.application.web___/frontend/common/js/vote.js",
|
||||
"___path.application.web___/frontend/common/js/poll.js",
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
/**
|
||||
* Вспомгательные функции для текстового редактора
|
||||
*
|
||||
* @module ls/editor
|
||||
*
|
||||
* @license GNU General Public License, version 2
|
||||
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
|
||||
* @author Denis Shakhov <denis.shakhov@gmail.com>
|
||||
*/
|
||||
|
||||
var ls = ls || {};
|
||||
|
||||
ls.editor = (function($) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Инициализация
|
||||
*/
|
||||
this.init = function(selector) {
|
||||
var _this = this;
|
||||
|
||||
$(selector).each(function () {
|
||||
var editor = $(this),
|
||||
type = editor.data('editor-type'),
|
||||
set = editor.data('editor-set') || 'default';
|
||||
|
||||
ls.editor[type].init(editor, set);
|
||||
})
|
||||
};
|
||||
|
||||
return this;
|
||||
}).call(ls.editor || {},jQuery);
|
|
@ -1,126 +0,0 @@
|
|||
/**
|
||||
* Markup редактор
|
||||
*
|
||||
* @module ls/editor
|
||||
*
|
||||
* @license GNU General Public License, version 2
|
||||
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
|
||||
* @author Denis Shakhov <denis.shakhov@gmail.com>
|
||||
*/
|
||||
|
||||
var ls = ls || {};
|
||||
ls.editor = ls.editor || {};
|
||||
|
||||
ls.editor.markup = (function($) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Дефолтные опции
|
||||
*/
|
||||
var defaults = {
|
||||
sets: {
|
||||
default: {
|
||||
onShiftEnter: {keepDefault:false, replaceWith:'<br />\n'},
|
||||
onCtrlEnter: {keepDefault:false, openWith:'\n<p>', closeWith:'</p>'},
|
||||
onTab: {keepDefault:false, replaceWith:' '},
|
||||
markupSet: [
|
||||
{name:'H4', className:'editor-h4', openWith:'<h4>', closeWith:'</h4>' },
|
||||
{name:'H5', className:'editor-h5', openWith:'<h5>', closeWith:'</h5>' },
|
||||
{name:'H6', className:'editor-h6', openWith:'<h6>', closeWith:'</h6>' },
|
||||
{separator:'---------------' },
|
||||
{name: ls.lang.get('panel_b'), className:'editor-bold', key:'B', openWith:'(!(<strong>|!|<b>)!)', closeWith:'(!(</strong>|!|</b>)!)' },
|
||||
{name: ls.lang.get('panel_i'), className:'editor-italic', key:'I', openWith:'(!(<em>|!|<i>)!)', closeWith:'(!(</em>|!|</i>)!)' },
|
||||
{name: ls.lang.get('panel_s'), className:'editor-stroke', key:'S', openWith:'<s>', closeWith:'</s>' },
|
||||
{name: ls.lang.get('panel_u'), className:'editor-underline', key:'U', openWith:'<u>', closeWith:'</u>' },
|
||||
{name: ls.lang.get('panel_quote'), className:'editor-quote', key:'Q', replaceWith: function(m) { if (m.selectionOuter) return '<blockquote>'+m.selectionOuter+'</blockquote>'; else if (m.selection) return '<blockquote>'+m.selection+'</blockquote>'; else return '<blockquote></blockquote>' } },
|
||||
{name: ls.lang.get('panel_code'), className:'editor-code', openWith:'<(!(code|!|codeline)!)>', closeWith:'</(!(code|!|codeline)!)>' },
|
||||
{separator:'---------------' },
|
||||
{name: ls.lang.get('panel_list'), className:'editor-ul', openWith:' <li>', closeWith:'</li>', multiline: true, openBlockWith:'<ul>\n', closeBlockWith:'\n</ul>' },
|
||||
{name: ls.lang.get('panel_list'), className:'editor-ol', openWith:' <li>', closeWith:'</li>', multiline: true, openBlockWith:'<ol>\n', closeBlockWith:'\n</ol>' },
|
||||
{name: ls.lang.get('panel_list_li'), className:'editor-li', openWith:'<li>', closeWith:'</li>' },
|
||||
{separator:'---------------' },
|
||||
{name: ls.lang.get('panel_image'), className:'editor-picture', key:'P', beforeInsert: function(h) { jQuery('#modal-image-upload').modal('show'); } },
|
||||
{name: ls.lang.get('panel_video'), className:'editor-video', replaceWith:'<video>[!['+ls.lang.get('panel_video_promt')+':!:http://]!]</video>' },
|
||||
{name: ls.lang.get('panel_url'), className:'editor-link', key:'L', openWith:'<a href="[!['+ls.lang.get('panel_url_promt')+':!:http://]!]"(!( title="[![Title]!]")!)>', closeWith:'</a>', placeHolder:'Your text to link...' },
|
||||
{name: ls.lang.get('panel_user'), className:'editor-user', replaceWith:'<ls user="[!['+ls.lang.get('panel_user_promt')+']!]" />' },
|
||||
{separator:'---------------' },
|
||||
{name: ls.lang.get('panel_clear_tags'), className:'editor-clean', replaceWith: function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") } },
|
||||
{name: ls.lang.get('panel_cut'), className:'editor-cut', replaceWith: function(markitup) { if (markitup.selection) return '<cut name="'+markitup.selection+'">'; else return '<cut>' }}
|
||||
]
|
||||
},
|
||||
light: {
|
||||
onShiftEnter: {keepDefault:false, replaceWith:'<br />\n'},
|
||||
onTab: {keepDefault:false, replaceWith:' '},
|
||||
markupSet: [
|
||||
{name: ls.lang.get('panel_b'), className:'editor-bold', key:'B', openWith:'(!(<strong>|!|<b>)!)', closeWith:'(!(</strong>|!|</b>)!)' },
|
||||
{name: ls.lang.get('panel_i'), className:'editor-italic', key:'I', openWith:'(!(<em>|!|<i>)!)', closeWith:'(!(</em>|!|</i>)!)' },
|
||||
{name: ls.lang.get('panel_s'), className:'editor-stroke', key:'S', openWith:'<s>', closeWith:'</s>' },
|
||||
{name: ls.lang.get('panel_u'), className:'editor-underline', key:'U', openWith:'<u>', closeWith:'</u>' },
|
||||
{separator:'---------------' },
|
||||
{name: ls.lang.get('panel_quote'), className:'editor-quote', key:'Q', replaceWith: function(m) { if (m.selectionOuter) return '<blockquote>'+m.selectionOuter+'</blockquote>'; else if (m.selection) return '<blockquote>'+m.selection+'</blockquote>'; else return '<blockquote></blockquote>' } },
|
||||
{name: ls.lang.get('panel_code'), className:'editor-code', openWith:'<(!(code|!|codeline)!)>', closeWith:'</(!(code|!|codeline)!)>' },
|
||||
{name: ls.lang.get('panel_image'), className:'editor-picture', key:'P', beforeInsert: function(h) { jQuery('#modal-image-upload').modal('show'); } },
|
||||
{name: ls.lang.get('panel_url'), className:'editor-link', key:'L', openWith:'<a href="[!['+ls.lang.get('panel_url_promt')+':!:http://]!]"(!( title="[![Title]!]")!)>', closeWith:'</a>', placeHolder:'Your text to link...' },
|
||||
{name: ls.lang.get('panel_user'), className:'editor-user', replaceWith:'<ls user="[!['+ls.lang.get('panel_user_promt')+']!]" />' },
|
||||
{separator:'---------------' },
|
||||
{name: ls.lang.get('panel_clear_tags'), className:'editor-clean', replaceWith: function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") } }
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Инициализация
|
||||
*
|
||||
*/
|
||||
this.init = function(element, set) {
|
||||
var self = this;
|
||||
|
||||
this.options = $.extend({}, defaults);
|
||||
|
||||
element.markItUp(this.options.sets[set]);
|
||||
|
||||
// Справка по разметке редактора
|
||||
$('.js-editor-help-toggle').on('click', function (e) {
|
||||
$(this).parent().next().toggle();
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$('.js-editor-help').each(function () {
|
||||
var oEditorHelp = $(this),
|
||||
oTargetForm = $('#' + oEditorHelp.data('form-id'));
|
||||
|
||||
oEditorHelp.find('.js-tags-help-link').on('click', function (e) {
|
||||
if ($(this).data('insert')) {
|
||||
var sTag = $(this).data('insert');
|
||||
} else {
|
||||
var sTag = $(this).text();
|
||||
}
|
||||
|
||||
$.markItUp({
|
||||
target: oTargetForm,
|
||||
replaceWith: sTag
|
||||
});
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Вставка ссылки загруженного изображения в редактор
|
||||
*
|
||||
* @param {String} sUrl Ссылка
|
||||
* @param {String} sAlign Выравнивание
|
||||
* @param {String} sTitle Описание
|
||||
*/
|
||||
this.insertImageUrlToEditor = function(sUrl, sAlign, sTitle) {
|
||||
sAlign = sAlign == 'center' ? 'class="image-center"' : 'align="' + sAlign + '"';
|
||||
|
||||
$.markItUp({
|
||||
replaceWith: '<img src="' + sUrl + '" title="' + sTitle + '" ' + sAlign + ' />'
|
||||
});
|
||||
};
|
||||
|
||||
return this;
|
||||
}).call(ls.editor.markup || {},jQuery);
|
|
@ -1,115 +0,0 @@
|
|||
/**
|
||||
* Визуальный редактор
|
||||
*
|
||||
* @module ls/editor
|
||||
*
|
||||
* @license GNU General Public License, version 2
|
||||
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
|
||||
* @author Denis Shakhov <denis.shakhov@gmail.com>
|
||||
*/
|
||||
|
||||
var ls = ls || {};
|
||||
ls.editor = ls.editor || {};
|
||||
|
||||
ls.editor.visual = (function($) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Дефолтные опции
|
||||
*/
|
||||
var defaults = {
|
||||
sets: {
|
||||
default: {
|
||||
mode : "specific_textareas",
|
||||
editor_selector : "js-editor",
|
||||
theme : "advanced",
|
||||
skin : "livestreet",
|
||||
width : "100%",
|
||||
theme_advanced_toolbar_location : "top",
|
||||
theme_advanced_toolbar_align : "left",
|
||||
theme_advanced_buttons1 : "lshselect,bold,italic,underline,strikethrough,|,bullist,numlist,|,undo,redo,|,lslink,unlink,lsvideo,lsimage,pagebreak,code",
|
||||
theme_advanced_buttons2 : "",
|
||||
theme_advanced_buttons3 : "",
|
||||
theme_advanced_statusbar_location : "bottom",
|
||||
theme_advanced_resizing : true,
|
||||
theme_advanced_resize_horizontal : 0,
|
||||
theme_advanced_resizing_use_cookie : 0,
|
||||
theme_advanced_path : false,
|
||||
object_resizing : true,
|
||||
force_br_newlines : true,
|
||||
forced_root_block : '', // Needed for 3.x
|
||||
force_p_newlines : false,
|
||||
plugins : "lseditor,safari,inlinepopups,media,pagebreak,autoresize",
|
||||
convert_urls : false,
|
||||
extended_valid_elements : "embed[src|type|allowscriptaccess|allowfullscreen|width|height]",
|
||||
pagebreak_separator : "<cut>",
|
||||
media_strict : false,
|
||||
language : LANGUAGE,
|
||||
inline_styles: false,
|
||||
formats : {
|
||||
underline : {inline : 'u', exact : true},
|
||||
strikethrough : {inline : 's', exact : true}
|
||||
}
|
||||
},
|
||||
light: {
|
||||
mode : "textareas",
|
||||
theme : "advanced",
|
||||
skin : "livestreet",
|
||||
width : "100%",
|
||||
theme_advanced_toolbar_location : "top",
|
||||
theme_advanced_toolbar_align : "left",
|
||||
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,lslink,lsquote",
|
||||
theme_advanced_buttons2 : "",
|
||||
theme_advanced_buttons3 : "",
|
||||
theme_advanced_statusbar_location : "bottom",
|
||||
theme_advanced_resizing : true,
|
||||
theme_advanced_resize_horizontal : 0,
|
||||
theme_advanced_resizing_use_cookie : 0,
|
||||
theme_advanced_path : false,
|
||||
object_resizing : true,
|
||||
force_br_newlines : true,
|
||||
forced_root_block : '', // Needed for 3.x
|
||||
force_p_newlines : false,
|
||||
plugins : "lseditor,safari,inlinepopups,media,pagebreak,autoresize",
|
||||
convert_urls : false,
|
||||
extended_valid_elements : "embed[src|type|allowscriptaccess|allowfullscreen|width|height]",
|
||||
pagebreak_separator : "<cut>",
|
||||
media_strict : false,
|
||||
language : 'ru',
|
||||
inline_styles: false,
|
||||
formats : {
|
||||
underline : {inline : 'u', exact : true},
|
||||
strikethrough : {inline : 's', exact : true}
|
||||
},
|
||||
setup : function(ed) {
|
||||
// Display an alert onclick
|
||||
ed.onKeyPress.add(function(ed, e) {
|
||||
key = e.keyCode || e.which;
|
||||
if(e.ctrlKey && (key == 13)) {
|
||||
$('#comment-button-submit').click();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Инициализация
|
||||
*/
|
||||
this.init = function(element, set) {
|
||||
this.options = $.extend({}, defaults);
|
||||
|
||||
// Т.к. тини не принимает jquery элементы в качестве селектора
|
||||
// пишем небольшой костыль который генерит рандомный класс и используем его как селектор
|
||||
var selector = 'tinymce' + Math.floor(Math.random() * 10e10);
|
||||
|
||||
element.addClass(selector);
|
||||
|
||||
this.options.sets[set].editor_selector = selector;
|
||||
tinyMCE.init(this.options.sets[set]);
|
||||
};
|
||||
|
||||
return this;
|
||||
}).call(ls.editor.visual || {},jQuery);
|
|
@ -232,7 +232,7 @@ jQuery(document).ready(function($){
|
|||
/**
|
||||
* Editor
|
||||
*/
|
||||
ls.editor.init('.js-editor');
|
||||
$( '.js-editor' ).lsEditor();
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,17 +3,17 @@
|
|||
*}
|
||||
|
||||
{* Название компонента *}
|
||||
{$_sComponentName = 'editor'}
|
||||
{$component = 'editor'}
|
||||
|
||||
{* Получаем тип редактора *}
|
||||
{$_sType = ( Config::Get('view.wysiwyg') ) ? 'visual' : 'markup'}
|
||||
{$_sSet = $smarty.local.sSet|default:'default'}
|
||||
{$type = ( ( $smarty.local.type ) ? $smarty.local.type : ( Config::Get('view.wysiwyg') ) ? 'visual' : 'markup' )}
|
||||
{$set = $smarty.local.sSet|default:'default'}
|
||||
|
||||
{* Уникальный ID *}
|
||||
{$_uid = $smarty.local.sId|default:($_sComponentName|cat:rand(0, 10e10))}
|
||||
{$_uid = $smarty.local.sId|default:($component|cat:rand(0, 10e10))}
|
||||
|
||||
{* Класс на который вешается обработчик редактора *}
|
||||
{$_sBindClass = $smarty.local.sBindClass|default:"js-{$_sComponentName}"}
|
||||
{$_sBindClass = $smarty.local.sBindClass|default:"js-{$component}"}
|
||||
|
||||
{**
|
||||
* Textarea
|
||||
|
@ -31,16 +31,17 @@
|
|||
sEntityField = $smarty.local.sEntityField
|
||||
sEntity = $smarty.local.sEntity
|
||||
sInputClasses = "$_sBindClass {$smarty.local.sInputClasses}"
|
||||
sInputAttributes = "{$smarty.local.sAttributes} data-editor-type=\"{$_sType}\" data-editor-set=\"{$_sSet}\""
|
||||
sInputAttributes = "{$smarty.local.sAttributes} data-editor-type=\"{$type}\" data-editor-set=\"{$set}\""
|
||||
sNote = $smarty.local.sNote
|
||||
iRows = $smarty.local.iRows|default:10}
|
||||
{/function}
|
||||
|
||||
{* Визуальный редактор *}
|
||||
{if Config::Get('view.wysiwyg')}
|
||||
{if $type == 'visual'}
|
||||
{hookb run='editor_visual'}
|
||||
{asset type='js' name='editor_visual' file="{Config::Get('path.framework.frontend.web')}/js/vendor/tinymce/tiny_mce.js"}
|
||||
{asset type='js' name='editor_visual_options' file="{Config::Get('path.application.web')}/frontend/common/js/editor.visual.js"}
|
||||
{asset type='js' name='editor_visual' file="{Config::Get('path.skin.web')}/components/editor/vendor/tinymce/js/tinymce/tinymce.min.js"}
|
||||
{asset type='js' name='editor_visual_1' file="{Config::Get('path.skin.web')}/components/editor/vendor/tinymce/js/tinymce/jquery.tinymce.min.js"}
|
||||
{asset type='js' name='editor_visual_2' file="{Config::Get('path.skin.web')}/components/editor/js/editor.visual.js"}
|
||||
|
||||
{editor_textarea}
|
||||
{/hookb}
|
||||
|
@ -48,12 +49,12 @@
|
|||
{* Markup редактор *}
|
||||
{else}
|
||||
{hookb run='editor_markup'}
|
||||
{asset type='js' name='editor_markup' file="{Config::Get('path.framework.frontend.web')}/js/vendor/markitup/jquery.markitup.js"}
|
||||
{asset type='js' name='editor_markup_options' file="{Config::Get('path.application.web')}/frontend/common/js/editor.markup.js"}
|
||||
{asset type='js' name='editor_markup' file="{Config::Get('path.skin.web')}/components/editor/vendor/markitup/jquery.markitup.js"}
|
||||
{asset type='js' name='editor_markup_options' file="{Config::Get('path.skin.web')}/components/editor/js/editor.markup.js"}
|
||||
|
||||
{asset type='css' name='editor_markup' file="{Config::Get('path.framework.frontend.web')}/js/vendor/markitup/skins/synio/style.css"}
|
||||
{asset type='css' name='editor_markup_set' file="{Config::Get('path.framework.frontend.web')}/js/vendor/markitup/sets/synio/style.css"}
|
||||
{asset type='css' name='editor_markup_component' file="{Config::Get('path.skin.assets.web')}/css/components/editor.css"}
|
||||
{asset type='css' name='editor_markup' file="{Config::Get('path.skin.web')}/components/editor/vendor/markitup/skins/livestreet/style.css"}
|
||||
{asset type='css' name='editor_markup_set' file="{Config::Get('path.skin.web')}/components/editor/vendor/markitup/sets/livestreet/style.css"}
|
||||
{asset type='css' name='editor_markup_help' file="{Config::Get('path.skin.web')}/components/editor/css/editor.css"}
|
||||
|
||||
{editor_textarea}
|
||||
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* Editor
|
||||
*
|
||||
* @module editor
|
||||
*
|
||||
* @license GNU General Public License, version 2
|
||||
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
|
||||
* @author Denis Shakhov <denis.shakhov@gmail.com>
|
||||
*/
|
||||
|
||||
$.widget( "livestreet.lsEditor", {
|
||||
/**
|
||||
* Дефолтные опции
|
||||
*/
|
||||
options: {
|
||||
type: null,
|
||||
set: 'default'
|
||||
},
|
||||
|
||||
/**
|
||||
* Конструктор
|
||||
*
|
||||
* @constructor
|
||||
* @private
|
||||
*/
|
||||
_create: function() {
|
||||
this.strategy = this.element.data( 'editor-type' ) == 'visual' ? 'lsEditorVisual' : 'lsEditorMarkup';
|
||||
this.option( 'set', this.element.data('editor-set') || this.option( 'set' ) );
|
||||
|
||||
this.element[ this.strategy ]( this.options );
|
||||
},
|
||||
|
||||
/**
|
||||
* Вставка текста
|
||||
*
|
||||
* @param {String} text Текст для вставки
|
||||
*/
|
||||
insert: function ( text ) {
|
||||
this.element[ this.strategy ]( 'insert', text );
|
||||
}
|
||||
});
|
|
@ -0,0 +1,85 @@
|
|||
/**
|
||||
* Markup editor
|
||||
*
|
||||
* @module ls/editor/markup
|
||||
*
|
||||
* @license GNU General Public License, version 2
|
||||
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
|
||||
* @author Denis Shakhov <denis.shakhov@gmail.com>
|
||||
*/
|
||||
|
||||
$.widget( "livestreet.lsEditorMarkup", {
|
||||
/**
|
||||
* Дефолтные опции
|
||||
*/
|
||||
options: {
|
||||
sets: {
|
||||
default: {
|
||||
onShiftEnter: { keepDefault:false, replaceWith: '<br />\n' },
|
||||
onCtrlEnter: { keepDefault:false, openWith: '\n<p>', closeWith: '</p>' },
|
||||
onTab: { keepDefault:false, replaceWith: ' ' },
|
||||
markupSet: [
|
||||
{ name: 'H4', className: 'editor-h4', openWith: '<h4>', closeWith: '</h4>' },
|
||||
{ name: 'H5', className: 'editor-h5', openWith: '<h5>', closeWith: '</h5>' },
|
||||
{ name: 'H6', className: 'editor-h6', openWith: '<h6>', closeWith: '</h6>' },
|
||||
{ separator: '---------------' },
|
||||
{ name: ls.lang.get('panel_b'), className: 'editor-bold', key: 'B', openWith: '(!(<strong>|!|<b>)!)', closeWith: '(!(</strong>|!|</b>)!)' },
|
||||
{ name: ls.lang.get('panel_i'), className: 'editor-italic', key: 'I', openWith: '(!(<em>|!|<i>)!)', closeWith: '(!(</em>|!|</i>)!)' },
|
||||
{ name: ls.lang.get('panel_s'), className: 'editor-stroke', key: 'S', openWith: '<s>', closeWith: '</s>' },
|
||||
{ name: ls.lang.get('panel_u'), className: 'editor-underline', key: 'U', openWith: '<u>', closeWith: '</u>' },
|
||||
{ name: ls.lang.get('panel_quote'), className: 'editor-quote', key: 'Q', replaceWith: function( m ) { if ( m.selectionOuter ) return '<blockquote>' + m.selectionOuter + '</blockquote>'; else if (m.selection) return '<blockquote>' + m.selection + '</blockquote>'; else return '<blockquote></blockquote>' }},
|
||||
{ name: ls.lang.get('panel_code'), className: 'editor-code', openWith: '<(!(code|!|codeline)!)>', closeWith: '</(!(code|!|codeline)!)>' },
|
||||
{ separator: '---------------' },
|
||||
{ name: ls.lang.get('panel_list'), className: 'editor-ul', openWith: ' <li>', closeWith: '</li>', multiline: true, openBlockWith: '<ul>\n', closeBlockWith: '\n</ul>' },
|
||||
{ name: ls.lang.get('panel_list'), className: 'editor-ol', openWith: ' <li>', closeWith: '</li>', multiline: true, openBlockWith: '<ol>\n', closeBlockWith: '\n</ol>' },
|
||||
{ name: ls.lang.get('panel_list_li'), className: 'editor-li', openWith: '<li>', closeWith: '</li>' },
|
||||
{ separator: '---------------' },
|
||||
{ name: ls.lang.get('panel_image'), className: 'editor-picture', key: 'P', beforeInsert: function(h) { jQuery('#modal-image-upload').modal('show'); } },
|
||||
{ name: ls.lang.get('panel_video'), className: 'editor-video', replaceWith: '<video>[![' + ls.lang.get('panel_video_promt') + ':!:http://]!]</video>' },
|
||||
{ name: ls.lang.get('panel_url'), className: 'editor-link', key: 'L', openWith: '<a href="[![' + ls.lang.get('panel_url_promt') + ':!:http://]!]"(!( title="[![Title]!]")!)>', closeWith: '</a>', placeHolder: 'Your text to link...' },
|
||||
{ name: ls.lang.get('panel_user'), className: 'editor-user', replaceWith: '<ls user="[![' + ls.lang.get('panel_user_promt') + ']!]" />' },
|
||||
{ separator: '---------------' },
|
||||
{ name: ls.lang.get('panel_clear_tags'), className: 'editor-clean', replaceWith: function( markitup ) { return markitup.selection.replace(/<(.*?)>/g, ""); }},
|
||||
{ name: ls.lang.get('panel_cut'), className: 'editor-cut', replaceWith: function( markitup ) { if ( markitup.selection ) return '<cut name="' + markitup.selection + '">'; else return '<cut>' }}
|
||||
]
|
||||
},
|
||||
light: {
|
||||
onShiftEnter: { keepDefault: false, replaceWith: '<br />\n' },
|
||||
onTab: { keepDefault: false, replaceWith: ' ' },
|
||||
markupSet: [
|
||||
{ name: ls.lang.get('panel_b'), className: 'editor-bold', key: 'B', openWith: '(!(<strong>|!|<b>)!)', closeWith: '(!(</strong>|!|</b>)!)' },
|
||||
{ name: ls.lang.get('panel_i'), className: 'editor-italic', key: 'I', openWith: '(!(<em>|!|<i>)!)', closeWith: '(!(</em>|!|</i>)!)' },
|
||||
{ name: ls.lang.get('panel_s'), className: 'editor-stroke', key: 'S', openWith: '<s>', closeWith: '</s>' },
|
||||
{ name: ls.lang.get('panel_u'), className: 'editor-underline', key: 'U', openWith: '<u>', closeWith: '</u>' },
|
||||
{ separator: '---------------' },
|
||||
{ name: ls.lang.get('panel_quote'), className: 'editor-quote', key: 'Q', replaceWith: function(m) { if (m.selectionOuter) return '<blockquote>' + m.selectionOuter + '</blockquote>'; else if (m.selection) return '<blockquote>' + m.selection + '</blockquote>'; else return '<blockquote></blockquote>' } },
|
||||
{ name: ls.lang.get('panel_code'), className: 'editor-code', openWith: '<(!(code|!|codeline)!)>', closeWith: '</(!(code|!|codeline)!)>' },
|
||||
{ name: ls.lang.get('panel_image'), className: 'editor-picture', key: 'P', beforeInsert: function(h) { jQuery('#modal-image-upload').modal('show'); } },
|
||||
{ name: ls.lang.get('panel_url'), className: 'editor-link', key: 'L', openWith: '<a href="[![' + ls.lang.get('panel_url_promt') + ':!:http://]!]"(!( title="[![Title]!]")!)>', closeWith: '</a>', placeHolder: 'Your text to link...' },
|
||||
{ name: ls.lang.get('panel_user'), className: 'editor-user', replaceWith: '<ls user="[![' + ls.lang.get('panel_user_promt') + ']!]" />' },
|
||||
{ separator: '---------------' },
|
||||
{ name: ls.lang.get('panel_clear_tags'), className: 'editor-clean', replaceWith: function( markitup ) { return markitup.selection.replace(/<(.*?)>/g, "") } }
|
||||
]
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Конструктор
|
||||
*
|
||||
* @constructor
|
||||
* @private
|
||||
*/
|
||||
_create: function () {
|
||||
this.element.markItUp( this.option( 'sets.' + this.option( 'set' ) ) );
|
||||
},
|
||||
|
||||
/**
|
||||
* Вставка текста
|
||||
*
|
||||
* @param {String} text Текст для вставки
|
||||
*/
|
||||
insert: function ( text ) {
|
||||
$.markItUp({ target: this.element, replaceWith: text });
|
||||
}
|
||||
});
|
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
* Visual editor
|
||||
*
|
||||
* @module ls/editor/visual
|
||||
*
|
||||
* @license GNU General Public License, version 2
|
||||
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
|
||||
* @author Denis Shakhov <denis.shakhov@gmail.com>
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
"use strict";
|
||||
|
||||
$.widget( "livestreet.lsEditorVisual", {
|
||||
/**
|
||||
* Дефолтные опции
|
||||
*/
|
||||
options: {
|
||||
sets: {
|
||||
default: {
|
||||
language: LANGUAGE,
|
||||
plugins: 'pagebreak code autoresize',
|
||||
toolbar: 'undo redo | bold italic strikethrough underline blockquote | bullist numlist | removeformat pagebreak code',
|
||||
menubar: false,
|
||||
statusbar: false,
|
||||
pagebreak_separator: '<cut>'
|
||||
},
|
||||
light: {
|
||||
language: LANGUAGE,
|
||||
plugins: 'pagebreak code autoresize',
|
||||
toolbar: 'undo redo | bold italic strikethrough underline blockquote | bullist numlist | removeformat pagebreak code',
|
||||
menubar: false,
|
||||
statusbar: false,
|
||||
pagebreak_separator: '<cut>'
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Конструктор
|
||||
*
|
||||
* @constructor
|
||||
* @private
|
||||
*/
|
||||
_create: function () {
|
||||
this.element.tinymce( this.option( 'sets.' + this.option( 'set' ) ) );
|
||||
},
|
||||
|
||||
/**
|
||||
* Вставка текста
|
||||
*
|
||||
* @param {String} text Текст для вставки
|
||||
*/
|
||||
insert: function ( text ) {
|
||||
this.element.tinymce().insertContent( text );
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
Loading…
Reference in a new issue