mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-06 18:21:39 +09:00
Fix #1335 support autoinsert option by file type
This commit is contained in:
parent
2802c59889
commit
8d05a674f5
8 changed files with 50 additions and 31 deletions
|
|
@ -151,13 +151,13 @@
|
|||
}
|
||||
|
||||
if(result.error == 0) {
|
||||
if(/\.(gif|jpe?g|png|webp)$/i.test(result.source_filename)) {
|
||||
if(/\.(gif|jpe?g|png|webp)$/i.test(result.source_filename) && opt.autoinsertTypes.image) {
|
||||
temp_code += '<img src="' + result.download_url + '" alt="' + result.source_filename + '" editor_component="image_link" data-file-srl="' + result.file_srl + '" />';
|
||||
}
|
||||
else if(/\.(mp3|wav|ogg|flac|aac)$/i.test(result.source_filename)) {
|
||||
else if(/\.(mp3|wav|ogg|flac|aac)$/i.test(result.source_filename) && opt.autoinsertTypes.audio) {
|
||||
temp_code += '<audio src="' + result.download_url + '" controls data-file-srl="' + result.file_srl + '" />';
|
||||
}
|
||||
else if(/\.(mp4|webm|ogv)$/i.test(result.source_filename)) {
|
||||
else if(/\.(mp4|webm|ogv)$/i.test(result.source_filename) && opt.autoinsertTypes.video) {
|
||||
if(result.original_type === 'image/gif') {
|
||||
temp_code += '<video src="' + result.download_url + '" autoplay loop muted data-file-srl="' + result.file_srl + '" />';
|
||||
} else {
|
||||
|
|
@ -166,15 +166,13 @@
|
|||
}
|
||||
|
||||
if(temp_code !== '') {
|
||||
if (opt.autoinsertImage === 'paragraph') {
|
||||
if (opt.autoinsertPosition === 'paragraph') {
|
||||
temp_code = "<p>" + temp_code + "</p>\n";
|
||||
}
|
||||
if (opt.autoinsertImage !== 'none') {
|
||||
try {
|
||||
_getCkeInstance(settings.formData.editor_sequence).insertHtml(temp_code, "unfiltered_html");
|
||||
}
|
||||
catch(err) {}
|
||||
try {
|
||||
_getCkeInstance(settings.formData.editor_sequence).insertHtml(temp_code, "unfiltered_html");
|
||||
}
|
||||
catch(err) {}
|
||||
}
|
||||
} else if (result.message) {
|
||||
alert(result.message);
|
||||
|
|
@ -326,13 +324,13 @@
|
|||
if(!result) return;
|
||||
var temp_code = '';
|
||||
|
||||
if(/\.(gif|jpe?g|png|webp)$/i.test(result.source_filename)) {
|
||||
if(/\.(gif|jpe?g|png|webp)$/i.test(result.source_filename) && data.settings.autoinsertTypes.image) {
|
||||
temp_code += '<img src="' + result.download_url + '" alt="' + result.source_filename + '" editor_component="image_link" data-file-srl="' + result.file_srl + '" />';
|
||||
}
|
||||
else if(/\.(mp3|wav|ogg|flac|aac)$/i.test(result.source_filename)) {
|
||||
else if(/\.(mp3|wav|ogg|flac|aac)$/i.test(result.source_filename) && data.settings.autoinsertTypes.audio) {
|
||||
temp_code += '<audio src="' + result.download_url + '" controls data-file-srl="' + result.file_srl + '" />';
|
||||
}
|
||||
else if(/\.(mp4|webm|ogv)$/i.test(result.source_filename)) {
|
||||
else if(/\.(mp4|webm|ogv)$/i.test(result.source_filename) && data.settings.autoinsertTypes.video) {
|
||||
if(result.original_type === 'image/gif') {
|
||||
temp_code += '<video src="' + result.download_url + '" autoplay loop muted data-file-srl="' + result.file_srl + '" />';
|
||||
} else {
|
||||
|
|
@ -341,7 +339,7 @@
|
|||
}
|
||||
|
||||
if(temp_code !== '') {
|
||||
if (data.settings.autoinsertImage === 'paragraph') {
|
||||
if (data.settings.autoinsertPosition === 'paragraph') {
|
||||
temp_code = "<p>" + temp_code + "</p>\n";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -228,8 +228,12 @@ class editorAdminController extends editor
|
|||
$config->content_word_break = in_array($config->content_word_break, array('normal', 'keep-all', 'break-all', 'none')) ? $config->content_word_break : 'normal';
|
||||
$config->enable_autosave = $configVars->enable_autosave ?: 'Y';
|
||||
$config->allow_html = $configVars->allow_html ?: 'Y';
|
||||
$config->autoinsert_image = $configVars->autoinsert_image;
|
||||
$config->autoinsert_image = in_array($config->autoinsert_image, array('paragraph', 'inline', 'none')) ? $config->autoinsert_image : 'paragraph';
|
||||
$config->autoinsert_types = array();
|
||||
foreach ($configVars->autoinsert_types as $type)
|
||||
{
|
||||
$config->autoinsert_types[$type] = true;
|
||||
}
|
||||
$config->autoinsert_position = in_array($configVars->autoinsert_position, array('paragraph', 'inline')) ? $configVars->autoinsert_position : 'paragraph';
|
||||
|
||||
$oModuleController->insertModuleConfig('editor', $config);
|
||||
$this->setRedirectUrl(Context::get('error_return_url'));
|
||||
|
|
|
|||
|
|
@ -46,7 +46,8 @@ class editor extends ModuleObject
|
|||
'enable_autosave' => 'Y',
|
||||
'allow_html' => 'Y',
|
||||
'editor_focus' => 'N',
|
||||
'autoinsert_image' => 'paragraph',
|
||||
'autoinsert_types' => array('image' => true, 'audio' => true, 'video' => true),
|
||||
'autoinsert_position' => 'paragraph',
|
||||
'additional_css' => array(),
|
||||
'additional_mobile_css' => array(),
|
||||
'additional_plugins' => array(),
|
||||
|
|
|
|||
|
|
@ -148,7 +148,8 @@ class editorModel extends editor
|
|||
Context::set('content_line_height', $option->content_line_height);
|
||||
Context::set('content_paragraph_spacing', $option->content_paragraph_spacing);
|
||||
Context::set('content_word_break', $option->content_word_break);
|
||||
Context::set('editor_autoinsert_image', $option->autoinsert_image);
|
||||
Context::set('editor_autoinsert_types', $option->autoinsert_types ?? ($option->autoinsert_image !== 'none' ? self::$default_editor_config['autoinsert_types'] : []));
|
||||
Context::set('editor_autoinsert_position', $option->autoinsert_position ?? $option->autoinsert_image);
|
||||
Context::set('editor_additional_css', $option->additional_css);
|
||||
Context::set('editor_additional_plugins', $option->additional_plugins);
|
||||
Context::set('editor_remove_plugins', $option->remove_plugins);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,12 @@ $lang->word_break_normal = 'Wrap Asian scripts at character boundary and Latin s
|
|||
$lang->word_break_keep_all = 'Wrap at word boundary';
|
||||
$lang->word_break_break_all = 'Wrap at character boundary';
|
||||
$lang->word_break_none = 'Do not wrap long lines';
|
||||
$lang->guide_choose_autoinsert_image = 'Auto-insert images';
|
||||
$lang->guide_choose_autoinsert_types = 'Auto-insert';
|
||||
$lang->autoinsert_types['image'] = 'Images';
|
||||
$lang->autoinsert_types['audio'] = 'Audio';
|
||||
$lang->autoinsert_types['video'] = 'Video';
|
||||
$lang->autoinsert_paragraph = 'New paragraph';
|
||||
$lang->autoinsert_inline = 'Inline';
|
||||
$lang->autoinsert_image_paragraph = 'Automatically insert images into editor (after line break at cursor position)';
|
||||
$lang->autoinsert_image_inline = 'Automatically insert images into editor (directly at cursor position)';
|
||||
$lang->autoinsert_image_none = 'Do not auto-insert images into editor';
|
||||
|
|
|
|||
|
|
@ -30,10 +30,12 @@ $lang->word_break_normal = '한글은 글자 단위로 줄바꿈, 영문은 단
|
|||
$lang->word_break_keep_all = '모든 언어를 단어 단위로 줄바꿈';
|
||||
$lang->word_break_break_all = '모든 언어를 글자 단위로 줄바꿈';
|
||||
$lang->word_break_none = '줄을 바꾸지 않음';
|
||||
$lang->guide_choose_autoinsert_image = '이미지 자동 삽입';
|
||||
$lang->autoinsert_image_paragraph = '이미지 첨부시 본문에 자동 삽입 (커서 위치에서 줄을 바꾸고 삽입)';
|
||||
$lang->autoinsert_image_inline = '이미지 첨부시 본문에 자동 삽입 (커서 위치에 직접 삽입)';
|
||||
$lang->autoinsert_image_none = '이미지 첨부시 본문에 자동 삽입하지 않음';
|
||||
$lang->guide_choose_autoinsert_types = '본문 자동 삽입';
|
||||
$lang->autoinsert_types['image'] = '이미지';
|
||||
$lang->autoinsert_types['audio'] = '오디오';
|
||||
$lang->autoinsert_types['video'] = '동영상';
|
||||
$lang->autoinsert_paragraph = '커서 위치에서 줄을 바꾸어 삽입';
|
||||
$lang->autoinsert_inline = '커서 위치에 직접 삽입';
|
||||
$lang->about_additional_plugins = '추가 플러그인 로딩을 지원하는 에디터에서만 적용됩니다.';
|
||||
$lang->about_remove_plugins = '플러그인 제거를 지원하는 에디터에서만 적용됩니다.';
|
||||
$lang->about_unit_default_px = '단위를 지정하지 않을 경우 px 단위를 사용합니다.';
|
||||
|
|
|
|||
|
|
@ -60,7 +60,8 @@
|
|||
var setting = {
|
||||
maxFileSize: {$logged_info->is_admin === 'Y' ? 0 : $file_config->allowed_filesize},
|
||||
maxChunkSize: {$file_config->allowed_chunk_size ?: 0},
|
||||
autoinsertImage: {json_encode($editor_autoinsert_image ?: 'paragraph')},
|
||||
autoinsertTypes: {json_encode($editor_autoinsert_types)},
|
||||
autoinsertPosition: {json_encode($editor_autoinsert_position ?: 'paragraph')},
|
||||
singleFileUploads: true
|
||||
};
|
||||
$container = $('#xefu-container-{$editor_sequence}');
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@
|
|||
<div class="x_controls">
|
||||
<label class="x_inline"><input type="radio" name="enable_autosave" value="Y" checked="checked"|cond="$editor_config->enable_autosave != 'N'" /> {$lang->cmd_yes}</label>
|
||||
<label class="x_inline"><input type="radio" name="enable_autosave" value="N" checked="checked"|cond="$editor_config->enable_autosave == 'N'" /> {$lang->cmd_no}</label>
|
||||
<p class="x_help-inline">{$lang->about_enable_autosave}</p>
|
||||
<p class="x_help-block">{$lang->about_enable_autosave}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
|
|
@ -225,16 +225,23 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label">{$lang->guide_choose_autoinsert_image}</label>
|
||||
<label class="x_control-label">{$lang->guide_choose_autoinsert_types}</label>
|
||||
<div class="x_controls">
|
||||
<label for="autoinsert_image_paragraph">
|
||||
<input type="radio" name="autoinsert_image" id="autoinsert_image_paragraph" value="paragraph" checked="checked"|cond="$editor_config->autoinsert_image == 'paragraph' || !$editor_config->autoinsert_image" /> {$lang->autoinsert_image_paragraph}
|
||||
<label class="x_inline">
|
||||
<input type="checkbox" name="autoinsert_types[]" value="image" checked="checked"|cond="$editor_config->autoinsert_image !== 'none' && (!isset($editor_config->autoinsert_types) || isset($editor_config->autoinsert_types['image']))" /> {$lang->autoinsert_types['image']}
|
||||
</label>
|
||||
<label for="autoinsert_image_inline">
|
||||
<input type="radio" name="autoinsert_image" id="autoinsert_image_inline" value="inline" checked="checked"|cond="$editor_config->autoinsert_image == 'inline'" /> {$lang->autoinsert_image_inline}
|
||||
<label class="x_inline">
|
||||
<input type="checkbox" name="autoinsert_types[]" value="audio" checked="checked"|cond="$editor_config->autoinsert_image !== 'none' && (!isset($editor_config->autoinsert_types) || isset($editor_config->autoinsert_types['audio']))" /> {$lang->autoinsert_types['audio']}
|
||||
</label>
|
||||
<label for="autoinsert_image_none">
|
||||
<input type="radio" name="autoinsert_image" id="autoinsert_image_none" value="none" checked="checked"|cond="$editor_config->autoinsert_image == 'none'" /> {$lang->autoinsert_image_none}
|
||||
<label class="x_inline">
|
||||
<input type="checkbox" name="autoinsert_types[]" value="video" checked="checked"|cond="$editor_config->autoinsert_image !== 'none' && (!isset($editor_config->autoinsert_types) || isset($editor_config->autoinsert_types['video']))" /> {$lang->autoinsert_types['video']}
|
||||
</label>
|
||||
<br />
|
||||
<label for="autoinsert_paragraph">
|
||||
<input type="radio" name="autoinsert_position" id="autoinsert_paragraph" value="paragraph" checked="checked"|cond="$editor_config->autoinsert_position == 'paragraph' || !$editor_config->autoinsert_position" /> {$lang->autoinsert_paragraph}
|
||||
</label>
|
||||
<label for="autoinsert_inline">
|
||||
<input type="radio" name="autoinsert_position" id="autoinsert_inline" value="inline" checked="checked"|cond="$editor_config->autoinsert_position == 'inline'" /> {$lang->autoinsert_inline}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue