【发布时间】:2013-03-11 00:43:14
【问题描述】:
我在这里有点纠结。 我正在尝试在我的 MVC4 项目中使用 TinyMCE 作为文本编辑器。
目前为止很简单,我只需要能够正确显示编辑器即可。
我有 2 类重要性。
控制器:
public class RapportController : Controller
{
ImageHandler handler = ImageHandler.Instance;
IDictionary<string, System.Drawing.Image> pics = ImageHandler.Instance.SharedCollection.GetCollection();
public ActionResult Index()
{
return View(handler.SharedCollection.GetCollection().Values.ToList());
}
public void GetImage(string name)
{
using (MemoryStream s = new MemoryStream())
{
pics[name].Save(s, System.Drawing.Imaging.ImageFormat.Png);
System.Web.Helpers.WebImage webImg = new System.Web.Helpers.WebImage(s);
webImg.Write();
}
}
然后是视图,这是我试图让 TinyMCE 工作的地方:
@model IList<System.Drawing.Image>
@{ ViewBag.Title = "索引"; }
报告
tinyMCE.init({ 模式:“文本区域”, 主题:“高级”, 插件:“情绪,拼写检查,advhr,插入日期时间,预览”, // 主题选项 - 按钮# 仅指示行# theme_advanced_buttons1: "newdocument,|,bold,italic,underline,|,justifyleft,justifycenter,justifyright,fontselect,fontsizeselect,formatselect", theme_advanced_buttons2: "剪切,复制,粘贴,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,|,code,preview,|,forecolor,backcolor", theme_advanced_buttons3: "insertdate,inserttime,|,spellchecker,advhr,,removeformat,|,sub,sup,|,charmap,emotions", theme_advanced_toolbar_location: "顶部", theme_advanced_toolbar_align: "左", theme_advanced_statusbar_location: "底部", theme_advanced_resizing: true });
这是一些可以用 TinyMCE 编辑的内容。
<div class="float-right">
<ul id="images">
@foreach (System.Drawing.Image item in Model)
{
MemoryStream stream = new MemoryStream();
item.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
stream.Seek(0, SeekOrigin.Begin);
string base64 = Convert.ToBase64String(stream.ToArray());
<li>
<a href="JavaScript:newPopup('data:image/gif;base64,@base64');"><img height="100" width="200" src="data:image/gif;base64,@base64"/></a>
</li>
}
</ul>
</div>
// 弹窗代码 功能新弹出(网址){ popupWindow = window.open( url, 'popUpWindow', 'height=600,width=1100,left=10,top=10,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=yes ') }
由于某种原因,最终看起来像这样: How it looks
知道为什么我没有从 TinyMCE 获得任何功能吗?
提前谢谢你:)
【问题讨论】:
标签: html asp.net-mvc-4 tinymce