Tinymce(副文本控件)当中的上传本地图片 jbimages 无法正常工作

qq_36065408 2017-07-18 09:09:21


@model String

@using Nop.Admin.Helpers
@using Nop.Core
@using Nop.Core.Domain.Common
@using Nop.Services.Security
@using Nop.Web.Framework.UI

@{
//we do not bundle this script file (does not work for some reasons in bundle)
Html.AddScriptParts("~/Administration/Content/tinymce/tinymce.min.js", true);

var permissionService = EngineContext.Current.Resolve<IPermissionService>();

// tinyMCE language
var language = TinyMceHelper.GetTinyMceLanguage();

var allowJbimages = false;
var allowRoxyFileman = permissionService.Authorize(StandardPermissionProvider.HtmlEditorManagePictures);
//TinyMCE picture browser does not work in a virtual category
//so if you're running in a virtual directory, then uncomment the code below:
allowJbimages = true;
//allowRoxyFileman = false;

var random = CommonHelper.GenerateRandomInteger();

//extend editor with additional settings
//Sample setting value (below):
//settings.plugins.push('print'); settings.toolbar += ' | print';
var additionalEditorSettings = EngineContext.Current.Resolve<AdminAreaSettings>().RichEditorAdditionalSettings;
//is java-script supported?
var allowJavaScript = EngineContext.Current.Resolve<AdminAreaSettings>().RichEditorAllowJavaScript;

//allow HTML body? Full page? - http://www.tinymce.com/wiki.php/Plugin:fullpage
//false by default
var enableFullPage = Convert.ToBoolean(ViewData["nop.RichEditor.EnableFullPage"] ?? false);
}

<script>
$(document).ready(function() {
@* wooncherk contribution *@
function RoxyFileBrowser@(random)(field_name, url, type, win) {
var roxyFileman = '@Url.Content("~/Administration/Content/Roxy_Fileman/index.html")';
if (roxyFileman.indexOf("?") < 0) {
roxyFileman += "?type=" + type;
} else {
roxyFileman += "&type=" + type;
}
roxyFileman += '&input=' + field_name + '&value=' + document.getElementById(field_name).value;
tinyMCE.activeEditor.windowManager.open({
file: roxyFileman,
title: 'Roxy Fileman',
width: 850,
height: 650,
resizable: "yes",
plugins: "media",
inline: "yes",
close_previous: "no"
}, { window: win, input: field_name });
return false;
}

var defaultEditorSettings@(random) = {
selector: "#@ViewData.TemplateInfo.GetFullHtmlFieldId(string.Empty)",
//upload_path: ,
fontsize_formats: "8pt 9pt 10pt 11pt 12pt 26pt 36pt",
height: 200,
width: '100%',
autoresize_min_height: 200,
autoresize_max_height: 200,
plugins: [
"advlist autolink autoresize directionality lists link image charmap preview anchor",
"searchreplace visualblocks code fullscreen textcolor",
"insertdatetime media table contextmenu paste@(allowJbimages ? " jbimages" : null)@(enableFullPage ? " fullpage" : null)"
],
toolbar: "ltr rtl | insertfile undo redo | styleselect | fontselect | fontsizeselect | bold italic | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image@(allowJbimages ? " jbimages" : null)",
//"relative_urls" required by jbimages plugin to be set to "false"
relative_urls: false,
language: 'zh_CN', //randy 上传图片汉化
@if (allowJavaScript)
{
<text>
valid_elements: "*
  • ",
    </text>
    }
    @if
  • (allowRoxyFileman)
    {
    <text>
    //picture manager
    file_browser_callback: RoxyFileBrowser@(random),
    </text>
    }
    @if (!string.IsNullOrEmpty(language))
    {
    <text>
    //language
    language: "@language",
    </text>
    }
    //we should set "convert_urls" set to "false" (because of "relative_urls" requirement)
    //otherwise, it'll break existing links when editing message template
    convert_urls: false,
    //ensure that special chars are not encoded. For example, ä, ö and ü should NOT become "ä", "ö" and "ü"
    //Otherwise, database searches become impossible when words contain a character of this kind
    entity_encoding: "raw"
    };

    function getAdditionalEditorSettings@(random)(settings) {
    @Html.Raw(additionalEditorSettings)
    return settings;
    }

    tinyMCE.init(getAdditionalEditorSettings@(random)(defaultEditorSettings@(random)));
    });
    </script>

    @Html.TextArea(string.Empty, /* Name suffix */
    ViewData.TemplateInfo.FormattedModelValue /* Initial value */
    )






...全文
362 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
这个控件没用过,uediter、ckediter 都不错啊

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧