Java 中的 WYSIWYG 文本编辑器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/853071/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WYSIWYG text editor in Java
提问by Aaron Digulla
I'd like to collect all WYSIWYG text editors for Java here.
我想在这里收集所有适用于 Java 的 WYSIWYG 文本编辑器。
Some rules for entries:
一些条目规则:
- There must be a link to the project/product
- You must state whether it's open source or commercial
- Is it possible to extend the editor (add new features like a "violet centered sudoku")? Is that simple or complex?
- Does it come with lots of features (fancy character and paragraph styles with online spell checking for several languages in the same document) or just the basics (bold, italics, no underline)?
- List important dependencies (does it run on bare Java with Swing? SWT? MacOS?)
- Your personal opinion
- 必须有项目/产品的链接
- 你必须说明它是开源的还是商业的
- 是否可以扩展编辑器(添加新功能,例如“以紫色为中心的数独”)?那是简单的还是复杂的?
- 它是否具有许多功能(花哨的字符和段落样式,可对同一文档中的多种语言进行在线拼写检查)还是仅具有基础功能(粗体、斜体、无下划线)?
- 列出重要的依赖项(它是否在带有 Swing 的裸 Java 上运行?SWT?MacOS?)
- 您的个人意见
This list should help developers determine which editor to choose. I'm not looking for "the best" but more "what's there".
此列表应帮助开发人员确定选择哪个编辑器。我不是在寻找“最好的”,而是更多的“那里有什么”。
回答by Aaron Digulla
OpenOffice's Writer
OpenOffice的编写器
Can be embedded in Java using the OOoBean. The original code runs under Swing but you can make it work under SWT, too, using the AWT/SWT Bridge (example code).
可以使用OOoBean嵌入到 Java 中。原始代码在 Swing 下运行,但您也可以使用 AWT/SWT Bridge(示例代码)使其在 SWT 下运行。
The project is open source (LGPL). The code is OS dependent but there are versions available for all major OSs (Windows, Linux, MacOS and Solaris are supported on the project's site but you can download the source and compile it for others, as well).
该项目是开源的(LGPL)。代码依赖于操作系统,但有适用于所有主要操作系统的版本(项目站点支持 Windows、Linux、MacOS 和 Solaris,但您也可以下载源代码并为其他人编译)。
Since the underlying product is a full blown office application, it offers all the features you might want (fancy styles, online spell checking in different languages, embedding pictures, flow text around pictures, you name it).
由于底层产品是一个成熟的办公应用程序,它提供了您可能需要的所有功能(花哨的样式、不同语言的在线拼写检查、嵌入图片、图片周围的流动文本,等等)。
The drawback is that you must have OpenOffice installed; in fact, the editor is not part of Java but it's a remote process which just renders in your Java app's window. This means that start up time is quite noticeable and performance can be sluggish. Also handling is sometimes "odd". It takes some configuration to get rid of additional borders and unwanted document pagination.
缺点是您必须安装 OpenOffice;事实上,编辑器不是 Java 的一部分,而是一个远程进程,它只是在您的 Java 应用程序的窗口中呈现。这意味着启动时间非常明显,性能可能会很慢。处理有时也很“奇怪”。需要一些配置才能摆脱额外的边框和不需要的文档分页。
Because of this, the editor is not really extendable from Java. You will either have to write code in C++ or using OOo's own built-in language. What you can do is you can register listeners in the document and you have full access to the underlying model for the document. This way, you can hook into the important parts and modify the behavior but this often feels like performing keyhole surgery.
因此,编辑器不能真正从 Java 扩展。您要么必须用 C++ 编写代码,要么使用 OOo 自己的内置语言。您可以做的是,您可以在文档中注册侦听器,并且您可以完全访问文档的底层模型。通过这种方式,您可以连接到重要的部分并修改行为,但这通常感觉就像进行锁孔手术一样。
My conclusion: If OO has the features you need, this might be the most simple way to get what you need. If you need a lot of customization, you'll fight an upstream battle against the framework's defaults.
我的结论:如果 OO 具有您需要的功能,这可能是获得所需功能的最简单方法。如果您需要大量自定义,您将与框架的默认设置进行上游战斗。
回答by jb.
Simply HTML
简单的 HTML
- its GPLed
- have no idea how easy it is to extend it
- doesn't support spell checking, but has tables, lists.
- Based on Swing, needs Java 1.4 and optionally Java Help
- I didn't used it as a programmer - just as an end user, it has some quirks - like no multilevel list's or tables that are less than great but is OK.
- Plus is it gives you HTML, so its is easy to embed results of processing into other components.
- Now on SourceForge
- 它的 GPL
- 不知道扩展它是多么容易
- 不支持拼写检查,但有表格、列表。
- 基于 Swing,需要 Java 1.4 和可选的 Java 帮助
- 我没有将它用作程序员 - 就像最终用户一样,它有一些怪癖 - 就像没有多级列表或表格不太好但还可以。
- 另外,它为您提供 HTML,因此很容易将处理结果嵌入到其他组件中。
- 现在在SourceForge
回答by adrian.tarau
I've used this component and it works well. It is LGPL and it is based on javax.swing.text package (javax.swing.text.EditorKit). Since it is a Swing component it can be integrated in your application in a few lines of code :
我已经使用过这个组件,它运行良好。它是 LGPL,它基于 javax.swing.text 包 (javax.swing.text.EditorKit)。由于它是一个 Swing 组件,因此可以通过几行代码将其集成到您的应用程序中:
RSyntaxTextArea textArea = new RSyntaxTextArea();
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
RTextScrollPane sp = new RTextScrollPane(textArea);
回答by Aaron Digulla
Using an HTML WYSIWYG editor and the SWT browser component(see the snippets for examples). Options:
使用 HTML WYSIWYG 编辑器和SWT 浏览器组件(请参阅示例代码段)。选项:
- SWT Composer
- EPF Rich Text
- richhtml4eclipse(based on TinyMCE)
- SWT Browser Widget to render a TinyMCE WYSIWYG editor
Pro:
亲:
- Lots of options due to HTML
- Supports HTML as the native format (so no unusual problems when you need to save the documents somewhere or modify them, unlike, say, the native Word format).
- Working with fonts, colors, images is simple since you don't have to manage the resources yourself. The browser component will do it for you
- 由于 HTML 有很多选择
- 支持 HTML 作为本机格式(因此,当您需要将文档保存在某处或修改它们时,不会出现异常问题,例如,与本机 Word 格式不同)。
- 使用字体、颜色、图像很简单,因为您不必自己管理资源。浏览器组件将为您完成
Contra:
反对:
- The solution is platform dependent. Tests with richhtml4eclipse showed a different behavior on Windows XP (IE) and Mac OSX (Safari)
- If there is a problem, users will have to switch to the HTML code view and fix it themselves.
- Good luck with content assist, code completion, spell checking, folding or annotations.
- Adding special features will either force you to do keyhole surgery through the pretty simply API
- With many of these editors, performance isn't that great, especially with large documents.
- Depends on SWT.
- 该解决方案取决于平台。使用richhtml4eclipse 进行的测试在Windows XP (IE) 和Mac OSX (Safari) 上显示出不同的行为
- 如果出现问题,用户将不得不切换到 HTML 代码视图并自行修复。
- 祝您在内容辅助、代码完成、拼写检查、折叠或注释方面好运。
- 添加特殊功能将迫使您通过非常简单的 API 进行锁孔手术
- 对于这些编辑器中的许多,性能并不是那么好,尤其是对于大型文档。
- 取决于 SWT。
回答by Aaron Digulla
回答by JasonPlutext
docx4all
docx4all
docx4all is a cross platform WYSIWYG editor for docx files, using Java Swing and JavaFX Script. Runs as an applet or application. See http://dev.plutext.org/trac/docx4all/wiki/FeatureSet
docx4all 是 docx 文件的跨平台 WYSIWYG 编辑器,使用 Java Swing 和 JavaFX Script。作为小程序或应用程序运行。见http://dev.plutext.org/trac/docx4all/wiki/FeatureSet
open source or commercial? See http://dev.plutext.org/forums/viewtopic.php?f=7&t=209
开源还是商业?见http://dev.plutext.org/forums/viewtopic.php?f=7&t=209
Requires Java 6.
需要 Java 6。
回答by Horcrux7
JWebEngine
JWeb引擎
I recommend JWebEngine. It is the only one that I know that passes the ACID1 browser test and the mail-acid test. Most other Java HTML editors are based on the javax.swing.text.html.HTMLDocument and have all the same bugs. The support of CSS is very poor with HTMLDocument. JWebEngine has very good support for viewing HTML with CSS.
我推荐JWebEngine。它是我所知道的唯一一个通过 ACID1 浏览器测试和 mail-acid 测试的。大多数其他 Java HTML 编辑器都基于 javax.swing.text.html.HTMLDocument 并且具有所有相同的错误。HTMLDocument 对 CSS 的支持很差。JWebEngine 对用 CSS 查看 HTML 有很好的支持。
- Link to the website. There are also online samples.
- Commercial license
- It is very simple to extend. The vendor is using it for many different things like editor, HTML printing engine, showing custom placeholders, etc. There is no problem with the visibility of classes like with the Sun HTMDocument.
- It based on javax.swing.text.JEditorPane or javax.swing.text.JTextPane and you can use it together with third party tools like the spell checker JOrtho.
- It is pure Java and runs on all platform with Java SE 5 or higher. It also run in non-signed applets.
- 链接到网站。也有在线示例。
- 营业执照
- 扩展非常简单。供应商将它用于许多不同的事情,例如编辑器、HTML 打印引擎、显示自定义占位符等。类的可见性没有问题,例如 Sun HTMDocument。
- 它基于 javax.swing.text.JEditorPane 或 javax.swing.text.JTextPane,您可以将其与拼写检查器 JOrtho 等第三方工具一起使用。
- 它是纯 Java 并在所有带有 Java SE 5 或更高版本的平台上运行。它还在未签名的小程序中运行。
回答by sbjo
Have a look at JWord
看看JWord
- It's commercial
- Lots of features (tables, paging, H/F, columns layout, wmf, svg, copy-paste, RTF, ODT, HTML export)
- royalty-free
- pure Java-Swing (1.6)
- extensible (based on Swing Text API)
- 这是商业的
- 许多功能(表格、分页、H/F、列布局、wmf、svg、复制粘贴、RTF、ODT、HTML 导出)
- 免版税
- 纯 Java-Swing (1.6)
- 可扩展(基于 Swing Text API)
回答by Tiberiu
I needed the same thing for our application, did a research and found two more products EKitand Metaphase Editor, based on Charles Bell's HTMLDocumentEditor
, both under LGPL license and looking good.
我的应用程序需要同样的东西,做了研究,发现了另外两个产品EKit和Metaphase Editor,基于 Charles Bell 的HTMLDocumentEditor
,都在 LGPL 许可下,看起来不错。
But I did not test them. These days we shall see what we choose.
但我没有测试它们。这些天我们将看到我们的选择。
回答by Aaron Digulla
The Eclipse project has resurrected Vex (Visual Editor for XML)
Eclipse 项目复活了Vex(Visual Editor for XML)
From the wiki page:
从维基页面:
- Vex leverages many of the mature plug-ins that make up the Eclipse Java IDE such as the CVSinterface, document searchingand bookmarkingfacilities, and searchable help system.
- The Eclipse platform implements a sophisticated plug-in architecture, allowing Vex to be extended with third-party or custom, in-house plug-ins.
- Vex is available with native look-and-feel for many platforms, including Windows, Linux/GTK, and Macintosh OS-X/Carbon.
- Java developers using the Eclipse IDE can instal Vex into their IDE as a plug-in, making it easy to maintain software documentation or other XML fileswith Vex.
- Vex is reusable: The Vex editor widget is available as a pure Java, cross-platform component with bindings SWT. Developers can re-use this widget, for example as an RCP application.
- Vex 利用了许多构成 Eclipse Java IDE 的成熟插件,例如CVS界面、文档搜索和书签功能以及可搜索的帮助系统。
- Eclipse 平台实现了一个复杂的插件架构,允许使用第三方或自定义的内部插件扩展Vex 。
- Vex 具有适用于许多平台的原生外观,包括 Windows、Linux/GTK 和 Macintosh OS-X/Carbon。
- 使用 Eclipse IDE 的 Java 开发人员可以将 Vex 作为插件安装到他们的 IDE 中,从而可以轻松地使用 Vex维护软件文档或其他 XML 文件。
- Vex 是可重用的:Vex 编辑器小部件可作为带有绑定 SWT 的纯 Java 跨平台组件提供。开发人员可以重复使用这个小部件,例如作为 RCP 应用程序。
Version 1.0 has been released in 2012, an 1.1 is planned for 2013.
1.0 版已于 2012 年发布,1.1 版计划于 2013 年发布。