2013-03-21 43 views
1

我在這裏遇到了一些問題。 我想在我的MVC4項目中使用TinyMCE作爲文本編輯器。TinyMCE在MVC4中無法正常工作

到目前爲止,這非常簡單,我只需要能夠正確顯示編輯器。

我有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,insertdatetime,預覽「, //主題選項 - 按鈕#僅指示行# theme_advanced_buttons1:」newdocument,|,bold,italic,underline,|,justifyleft,justifycent呃,justifyright,fontselect,fontsizeselect,formatselect「, theme_advanced_buttons2:」剪切,複製,粘貼,|,bullist,numlist,|,outdent,縮進,|撤銷,重做,|,鏈接,取消鏈接,錨點,圖像| ,代碼,預覽,|,forecolor,backcolor「, theme_advanced_buttons3:」insertdate,inserttime,|,spellchecker,advhr ,, removeformat,| sub,sup,|,charmap,emotions「, theme_advanced_toolbar_location:」top「, theme_advanced_toolbar_align:「left」, theme_advanced_statusbar_location:「bottom」, 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> 

//彈出窗口代碼 函數newPopup(URL){ popupWindow = window.open( URL, 'popUpWindow',「身高= 600,寬度= 1100,左= 10,top = 10,resizable = no,scrollbars = no,toolbar = no,menubar = no,location = no,directories = no,status = yes') }

由於某種原因,像這樣: How it looks

任何想法,爲什麼我沒有從TinyMCE獲得任何功能?

預先感謝您:)

回答

1

想通了。定義TinyMCE的位置時,不允許使用本地路徑。