适用于 Windows 窗体的所见即所得 Markdown 控件?

发布于 2024-07-04 00:47:14 字数 724 浏览 8 评论 0原文

[我们有一个 Windows 窗体数据库前端应用程序,除其他外,可以用作 CMS; 客户端创建该结构,填充它,然后使用基于 ASP.NET WebForms 的站点在 Web 上公开显示结果。 为了增加灵活性,他们有时被迫将实际的 HTML 标记直接输入到文本字段中,然后最终以 varchar 形式存储在数据库中。 这是可行的,但它远非用户友好。]

因此......一些客户想要一个所见即所得的 HTML 编辑器。 我想说服他们,他们会从使用更简单的语言(即 Markdown)中受益。 理想情况下,我想要的是一个所见即所得的编辑器。 他们不需要桌子或类似的复杂东西。

粗略搜索后发现a .NET Markdown to HTML converter,然后我们有一个基于 Windows 窗体的文本编辑器,可输出 HTML,但显然没有任何东西可以将两者结合在一起。 因此,我们仍然会保留带有标记的 varchar,但至少它既易于人类阅读,又易于解析。

这——一个输出 Markdown 的所见即所得编辑器,然后在 ASP.NET 中解析为 HTML——可行吗? 还有其他建议吗?

[We have a Windows Forms database front-end application that, among other things, can be used as a CMS; clients create the structure, fill it, and then use a ASP.NET WebForms-based site to present the results to publicly on the Web. For added flexibility, they are sometimes forced to input actual HTML markup right into a text field, which then ends up as a varchar in the database. This works, but it's far from user-friendly.]

As such… some clients want a WYSIWYG editor for HTML. I'd like to convince them that they'd benefit from using simpler language (namely, Markdown). Ideally, what I'd like to have is a WYSIWYG editor for that. They don't need tables, or anything sophisticated like that.

A cursory search reveals a .NET Markdown to HTML converter, and then we have a Windows Forms-based text editor that outputs HTML, but apparently nothing that brings the two together. As a result, we'd still have our varchars with markup in there, but at least it would be both quite human-readable and still easily parseable.

Would this — a WYSIWYG editor that outputs Markdown, which is then later on parsed into HTML in ASP.NET — be feasible? Any alternative suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

淡淡の花香 2024-07-11 00:47:14

难道你不能使用我在 Stack Overflow 中使用的相同控件(我们都在其中输入)——WMD,并将 Markdown 存储在 VARCHAR 中吗? 然后,如您所提到的,使用 .NET Markdown 到 HTML 转换器来根据需要显示 HTML。 Jeff 在 StackOverflow 播客中更详细地讨论了这一点(不知道剧集编号)。

Can't you just use the same control I'm Stack Overflow uses (that we're all typing into)---WMD, and just store the Markdown in the VARCHAR. Then use the .NET Markdown to HTML converter, as you mentioned, to display the HTML as needed. Jeff talks about this in more detail in a StackOverflow podcast (don't know the episode number).

病女 2024-07-11 00:47:14

“WYSIWYG Markdown”确实是一个矛盾修辞法,因为 Markdown 的全部意义在于让您自然直观地编写标记语法,然后将其后处理为 html,除非您的意思是实际上以**为例例如,text** 并将其渲染为 **text** 。 这实际上有点酷,但是对于编号和项目符号列表之类的东西来说会变得非常困难,因为您必须完成所有定位,但要保持所有内容基于实际文本字符(例如“*”而不是项目符号符号) )并支持正确的文本输入定位、退格键等。

  • 例如,
  • 在此项目符号列表中,
  • 项目符号实际上必须是星号,
  • 并且间距实际上不会存在。

如果有人确实解决了这个问题,那肯定值得关注。

"WYSIWYG Markdown" is really an oxymoron since the whole point of Markdown is to allow you to write markup syntax naturally and intuitively which is then post-processed into html, unless you mean actually taking for example **text** and rendering it as **text** for example. That would actually be kind of cool, but it would get very difficult for things like numbered and bulleted lists, since you would have to do all the positioning, yet keep everything based on actual textual characters (e.g. '*' instead of the bullet symbol) and support proper textual input positioning, backspace, etc.

  • For example,
  • in this bullet list,
  • the bullets would actually have to be asterisks,
  • and the spacing would not really be there.

That would certainly be worth paying attention to, if someone did tackle it.

等待圉鍢 2024-07-11 00:47:14

@Soeren,

您绝对可以将 IE 与 Javascript Markdown 编辑器嵌入到 Windows 窗体应用程序中。

@Soeren,

You can most definitely embed IE with the Javascript Markdown editor inside a Windows Forms application.

浅唱々樱花落 2024-07-11 00:47:14

RichTextBox 控件

那么您想使用 Markdown 但希望用户不知道它? 这可能不是一个可以实现的目标。 我认为 Markdown 的要点在于,它面向那些愿意学习一点相当自然的语法并以纯文本编辑所有内容的作者(例如维基百科?有纯粹的所见即所得编辑器吗?可能......可能还有一些)其他维基百科编辑人员必须来清理生成的标记和格式...)。 如果您希望它对用户透明(如 MS Word),Markdown 可能不是您想要的,也不会为您提供它在这种情况下宣传的优势。

输入发生在 Windows 窗体中

糟糕! 现在我更好地理解你的问题了。 我想这取决于您的 Windows 窗体应用程序的外观,嵌入式 IE 控件是否突出。 如果您尝试一下,您可能会发现它可以工作。[1]

在你的位置,我会尝试这样的事情[2]:

如果您认为这种安排不适合您的用户(尤其是纯文本窗口中的所有编辑),那么我再次认为 Markdown 不是以下问题的答案您的具体应用。 如果您认为您的用户热衷于编辑纯文本的想法,那么我打赌我们可以找到解决方案。 请澄清?

贾里德.

[1] 我成功地将 IE HTML 控件放入项目中,严格将一些生成的结果显示为 PDF(使用 IE Reader 插件,如 Adob​​e Reader 或 Foxit)。 用户不知道 GUI 的那部分是 IE 控件,它只是显示 PDF,允许打印和保存等。

[2] ...但是删除边框并使两个拆分控件接触到 PDF 的所有四个边缘嵌入式 IE 控件,或者非常接近...例如,保持浅灰色或白色,并消除 IE 控件的任何边框,以便它融入周围的控件。 也许将其放在自己的标签页上,我会向非技术用户提出挑战,让他们判断/关心它是 HTML 控件还是本机控件。

我对这一切可能完全是错误的(人们必须看到它的实际效果才能确定它是否有效),但它可能比编写您自己的交互式 Markdown 编辑器更容易......

实际上实现您自己的 C# Markdown 编辑器,您可以在嵌入的 IE 控件旁边放置一个文本编辑框,并在单独的线程上通过 .NET Markdown->HTML 转换器运行当前的 Markdown,并替换 IE 控件中的 HTML(假设 Markdown->HTML)。 HTML 转换器非常自由且强大,不会引发任何异常)。

the RichTextBox control

So you want to use Markdown but you want the user not to know it? This might not be an achievable goal. I think the point of Markdown is that it is geared toward writers that are willing to learn a little bit of fairly natural syntax and edit everything in plain text (like Wikipedia? are there pure WYSIWYG editors for that? probably... and probably some other Wikipedia editor person has to come and clean up the resulting markup and formatting...). If you want it to be transparent to the user (like MS Word) Markdown may not be what you want or give you the advantages it advertises in that situation.

The input happens in Windows Forms

Oops! Now I understand better your question. I guess it depends on how your Windows Forms app looks whether the embedded IE control sticks out like a sore thumb. If you try it you might find that you can get it to work.[1]

In your position, I would try something like this [2]:

If you don't think that sort of arrangement will go over well with your users, (especially all the editing in the text-only window) then once again I don't think Markdown is the answer for your specific application. If you think your users are keen on the idea of editing pure text, then I bet we can find a solution. Please clarify?

Jared.

[1] I had success dropping an IE HTML control into a project strictly to display some generated results as a PDF (using an IE Reader plugin like Adobe Reader or Foxit). The user has no idea that that part of the GUI is an IE control, it just shows the PDF, allows printing and saving, etc.

[2] ...but remove the borders and make the two split controls touch all four edges of the embedded IE control, or get very close... keep it light grey or white, for example, and eliminate any borders of the IE control so it blends into the surrounding controls. Maybe put this on its own tab page and I challenge a non-technical user to tell/care if it's an HTML control or native.

I could totally be wrong about all this (one would have to see this in action to determine if it would work) but it might be easier than writing your own interactive Markdown editor...

...actually to implement your own C# Markdown editor, you could just put a text edit box next to an embedded IE control and run the current Markdown through the .NET Markdown->HTML converter on a separate thread, and replace the HTML in the IE control (assuming the Markdown->HTML converter is very liberal and robust against throwing ANY exceptions).

妄断弥空 2024-07-11 00:47:14

我认为最好的方法是将

  1. 将 Markdown 转换为 HTML
  2. 在 WinForms 中显示 HTML

最新的 Markdown 库似乎是 ma​​rkdig 您可以安装 通过 nuget

Nuget > Markdig

一个简单的实现可能是:

  1. SplitContainer 添加到 Form 控件,设置 Dock = Fill
  2. 添加一个 TextBox,设置 Dock = Fill 并设置为 Multiline = True
  3. 添加一个 WebBrowser code>,设置 Dock = Fill

然后处理 TextChanged 事件,将文本解析为 html 并设置为 DocumentText,如下所示:

private void textBox1_TextChanged(object sender, EventArgs e)
{
    var md = textBox1.Text;
    var html = Markdig.Markdown.ToHtml(md);
    webBrowser1.DocumentText = html;
}

这是录制的演示:

I think the best approach for this is to combine

  1. Converting Markdown to HTML &
  2. Displaying HTML in WinForms

The most up to date Markdown Library seems to be markdig which you can install via nuget

Nuget > Markdig

A simple implementation might be to:

  1. Add a SplitContainer to a Form control, set Dock = Fill
  2. Add a TextBox, set Dock = Fill and set to Multiline = True
  3. Add a WebBrowser, set Dock = Fill

Then handle the TextChanged event, parse the text into html and set to DocumentText like this:

private void textBox1_TextChanged(object sender, EventArgs e)
{
    var md = textBox1.Text;
    var html = Markdig.Markdown.ToHtml(md);
    webBrowser1.DocumentText = html;
}

Here's a recorded demo:

Demo screen share

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文