适用于 Windows 窗体的所见即所得 Markdown 控件?
[我们有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
难道你不能使用我在 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).
“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.
That would certainly be worth paying attention to, if someone did tackle it.
@Soeren,
您绝对可以将 IE 与 Javascript Markdown 编辑器嵌入到 Windows 窗体应用程序中。
@Soeren,
You can most definitely embed IE with the Javascript Markdown editor inside a Windows Forms application.
那么您想使用 Markdown 但希望用户不知道它? 这可能不是一个可以实现的目标。 我认为 Markdown 的要点在于,它面向那些愿意学习一点相当自然的语法并以纯文本编辑所有内容的作者(例如维基百科?有纯粹的所见即所得编辑器吗?可能......可能还有一些)其他维基百科编辑人员必须来清理生成的标记和格式...)。 如果您希望它对用户透明(如 MS Word),Markdown 可能不是您想要的,也不会为您提供它在这种情况下宣传的优势。
糟糕! 现在我更好地理解你的问题了。 我想这取决于您的 Windows 窗体应用程序的外观,嵌入式 IE 控件是否突出。 如果您尝试一下,您可能会发现它可以工作。[1]
在你的位置,我会尝试这样的事情[2]:
如果您认为这种安排不适合您的用户(尤其是纯文本窗口中的所有编辑),那么我再次认为 Markdown 不是以下问题的答案您的具体应用。 如果您认为您的用户热衷于编辑纯文本的想法,那么我打赌我们可以找到解决方案。 请澄清?
贾里德.
[1] 我成功地将 IE HTML 控件放入项目中,严格将一些生成的结果显示为 PDF(使用 IE Reader 插件,如 Adobe Reader 或 Foxit)。 用户不知道 GUI 的那部分是 IE 控件,它只是显示 PDF,允许打印和保存等。
[2] ...但是删除边框并使两个拆分控件接触到 PDF 的所有四个边缘嵌入式 IE 控件,或者非常接近...例如,保持浅灰色或白色,并消除 IE 控件的任何边框,以便它融入周围的控件。 也许将其放在自己的标签页上,我会向非技术用户提出挑战,让他们判断/关心它是 HTML 控件还是本机控件。
我对这一切可能完全是错误的(人们必须看到它的实际效果才能确定它是否有效),但它可能比编写您自己的交互式 Markdown 编辑器更容易......
实际上实现您自己的 C# Markdown 编辑器,您可以在嵌入的 IE 控件旁边放置一个文本编辑框,并在单独的线程上通过 .NET Markdown->HTML 转换器运行当前的 Markdown,并替换 IE 控件中的 HTML(假设 Markdown->HTML)。 HTML 转换器非常自由且强大,不会引发任何异常)。
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.
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).
我认为最好的方法是将
最新的 Markdown 库似乎是 markdig 您可以安装 通过 nuget
一个简单的实现可能是:
SplitContainer
添加到Form
控件,设置Dock = Fill
TextBox
,设置Dock = Fill
并设置为Multiline = True
WebBrowser
code>,设置Dock = Fill
然后处理
TextChanged
事件,将文本解析为 html 并设置为DocumentText
,如下所示:这是录制的演示:
I think the best approach for this is to combine
The most up to date Markdown Library seems to be markdig which you can install via nuget
A simple implementation might be to:
SplitContainer
to aForm
control, setDock = Fill
TextBox
, setDock = Fill
and set toMultiline = True
WebBrowser
, setDock = Fill
Then handle the
TextChanged
event, parse the text into html and set toDocumentText
like this:Here's a recorded demo: