winforms html editor의 코드를 C#에 적용했습니다 (아래 참조). 대신 CKEditor를 사용할 수 있습니까?(X) HTML 편집을 위해 WinForms 응용 프로그램에서 CKEditor를 사용할 수 있습니까?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WebEditorTest
{
/// <summary>
/// https://stackoverflow.com/questions/214124/winforms-html-editor
/// </summary>
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("about:blank");
Application.DoEvents();
webBrowser1.Document.OpenNew(false).Write("<html><body><div id=\"editable\">Edit this text</div></body></html>");
foreach (HtmlElement el in webBrowser1.Document.All)
{
el.SetAttribute("unselectable", "on");
el.SetAttribute("contenteditable", "false");
}
foreach (HtmlElement el in webBrowser1.Document.All.GetElementsByName("editable"))
{
el.SetAttribute("width", webBrowser1.Width + "px");
el.SetAttribute("height", "100%");
el.SetAttribute("contenteditable", "true");
}
webBrowser1.Document.DomDocument.GetType().GetProperty("designMode").SetValue(webBrowser1.Document.DomDocument, "on", null);
webBrowser1.IsWebBrowserContextMenuEnabled = false;
}
private void button1_Click(object sender, EventArgs e)
{
textBoxMarkup.Text = webBrowser1.DocumentText;
}
}
}
실제로 웹 브라우저 컨트롤에 스크립트를로드하는 것을 막을 수있는 권한이 거부되었습니다. – Constantin
어떻게 그렇게? 그가 페이지를 즉석에서 작성하기 때문에 여기에 교차 도메인 또는 동일한 출처 문제는 없습니다. SO에 대한 몇 가지 예 : http://stackoverflow.com/questions/153748/how-to-inject-javascript-in-webbrowser-control. – LouD
모든 예제는 js 코드 스 니펫을 페이지에 삽입하는 방법을 보여줍니다. 하지만 CKEditor는 단지 j 조각 일 뿐이며 포함되어야하는 많은 외부 j가 있으며 여기서 거부 된 권한은 다음과 같습니다. – Constantin