- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我想在我的 GWT 应用程序中添加富文本编辑器。 TinyMCE 是其中之一,SmartGWT 中的富文本编辑器也是如此。对于在两者之间进行选择,您有什么建议吗?
最佳答案
我不会这么快就放弃 TinyMCE - 它比 GWT 的富文本编辑器有很多优势 - 对我来说,它是插件 - 我需要一个可以生成 bbcode 而不是 html 的富文本编辑器 - 不能不幸的是,用 GWT 的组件来做到这一点。所以我扩展了 TinyMCE 的标准 bbcode 插件以满足我的需要,瞧 :)
下面是我用来将 TinyMCE 集成到 GWT 中的类(Aaron Watkins 对原始类稍作修改,以解决拖放问题和其他一些问题;)):
编辑:稍作修改以包含 suggestions by David
/**
* Created on 20/08/2007
*
* Wrapper for TinyMCE
* NOTE: Expects Javascript includes to be in enclosing HTML
*
* Author: Aaron Watkins (aaronDOTjDOTwatkinsATgmailDOTcom)
* Website: http://www.goannatravel.com
* Home Page for initial release of this widget: http://consult.goannatravel.com/code/gwt/tinymce.php
*
* Copyright [Aaron Watkins]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.VerticalPanel;
/**
* TinyMCE -
*
* A wrapper widget for using TinyMCE. It contains a number of JSNI methods that
* I have found useful during development
*
* @author Aaron Watkins
*/
public class TinyMCE extends Composite implements HasText {
private TextArea ta;
private String id;
public TinyMCE(int width, int height) {
super();
VerticalPanel panel = new VerticalPanel();
initWidget(panel);
panel.setWidth("100%");
id = HTMLPanel.createUniqueId();
ta = new TextArea();
ta.setCharacterWidth(width);
ta.setVisibleLines(height);
DOM.setElementAttribute(ta.getElement(), "id", id);
DOM.setStyleAttribute(ta.getElement(), "width", "100%");
panel.add(ta);
}
/**
* getID() -
*
* @return the MCE element's ID
*/
public String getID() {
return id;
}
protected static native String getEditorContents(
String elementId) /*-{
return $wnd.tinyMCE.get(elementId).getContent();
}-*/;
protected static native void setEditorContents(
String elementId, String html) /*-{
$wnd.tinyMCE.execInstanceCommand(
elementId, 'mceSetContent', false, html, false);
}-*/;
public void setText(String text) {
setEditorContents(id, text);
}
public String getText() {
return getEditorContents(id);
}
public void setEnabled(boolean enabled) {
ta.setEnabled(enabled);
}
/**
* @see com.google.gwt.user.client.ui.Widget#onLoad()
*/
protected void onLoad() {
super.onLoad();
DeferredCommand.addCommand(new Command() {
public void execute() {
setWidth("100%");
setTextAreaToTinyMCE(id);
focusMCE(id);
}
});
}
/**
* focusMCE() -
*
* Use this to set the focus to the MCE area
* @param id - the element's ID
*/
protected native void focusMCE(String id) /*-{
$wnd.tinyMCE.execCommand('mceFocus', true, id);
}-*/;
/**
* resetMCE() -
*
* Use this if reusing the same MCE element, but losing focus
*/
public native void resetMCE() /*-{
$wnd.tinyMCE.execCommand('mceResetDesignMode', true);
}-*/;
/**
* unload() -
*
* Unload this MCE editor instance from active memory.
* I use this in the onHide function of the containing widget. This helps
* to avoid problems, especially when using tabs.
*/
public void unload() {
unloadMCE(id);
}
/**
* unloadMCE() -
*
* @param id - The element's ID
* JSNI method to implement unloading the MCE editor instance from memory
*/
protected native void unloadMCE(String id) /*-{
$wnd.tinyMCE.execCommand('mceFocus', false, id);
$wnd.tinyMCE.execCommand('mceRemoveControl', false, id);
}-*/;
/**
* updateContent() -
*
* Update the internal referenced content. Use this if you programatically change
* the original text area's content (eg. do a clear)
* @param id - the ID of the text area that contains the content you wish to copy
*/
protected native void updateContent(String id) /*-{
$wnd.tinyMCE.activeEditor = $wnd.tinyMCE.get(id);
$wnd.tinyMCE.activeEditor.setContent($wnd.document.getElementById(id).value);
}-*/;
/**
* getTextArea() -
*
*/
protected native void getTextData(String id) /*-{
$wnd.tinyMCE.activeEditor = $wnd.tinyMCE.get(id);
$wnd.tinyMCE.activeEditor.save();
$wnd.tinyMCE.triggerSave();
}-*/;
/**
* encodeURIComponent() -
*
* Wrapper for the native URL encoding methods
* @param text - the text to encode
* @return the encoded text
*/
protected native String encodeURIComponent(String text) /*-{
return encodeURIComponent(text);
}-*/;
/**
* setTextAreaToTinyMCE() -
*
* Change a text area to a tiny MCE editing field
* @param id - the text area's ID
*/
protected native void setTextAreaToTinyMCE(String id) /*-{
$wnd.tinyMCE.execCommand('mceAddControl', true, id);
}-*/;
/**
* removeMCE() -
*
* Remove a tiny MCE editing field from a text area
* @param id - the text area's ID
*/
public native void removeMCE(String id) /*-{
$wnd.tinyMCE.execCommand('mceRemoveControl', true, id);
}-*/;
}
请记住在您的 html 文件中初始化 TinyMCE,例如(关键设置是 mode : "textareas"
,其余的应该可以安全更改):
<script type="text/javascript" src="js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
theme : "advanced",
skin : "default",
mode : "textareas",
plugins : "bbcode",
theme_advanced_buttons1 : "bold,italic,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,sup,sub,|,undo,redo,separator,cut,copy,paste,|,fontsizeselect,forecolor,backcolor",
theme_advanced_buttons2 : "blockquote,link,unlink,image,styleselect,removeformat,|,charmap,code",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "bottom",
theme_advanced_toolbar_align : "center",
theme_advanced_styles : "Code=codeStyle;Quote=quoteStyle;PHP Code=phpCodeStyle",
entity_encoding : "raw",
add_unload_trigger : false,
remove_linebreaks : false,
button_tile_map : true
});
</script>
您还可以尝试其他一些包装器,例如 http://www.ohloh.net/p/tinymce-gwt
关于java - 我的 GWT 应用程序的 TinyMCE 或 SmartGWT 富文本编辑器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1419390/
因为没有更多的 Tinymce 论坛,如果我可以问有没有办法通过在源代码中添加 style="width: or height:"来关闭表格功能。 谢谢 最佳答案 我通过将以下内容添加到 tinymc
我的页面加载了 5 个 div,可以使用 Tinymce 内联编辑器进行编辑。通过单击一个按钮(如此动态),我可以安心地使用 Jquery 加载 5 个新的。但是当然新的不会受到 Tinymce 的影
我想以相同的形式使用 2 个不同的 textareas 和 tinyMCE。第一个效果很好,但是每当我添加第二个时,第二个都会被禁用(当我从右下角手动放大时它会启用)。它们的字段名称和 id 是不同的
我不确定我是否理解正确,但我相信有一个免费的“基本”版本,如果您需要一些高级插件和技术支持,您只需付费。 情况真的是这样吗? 最佳答案 是 . 请查看 this link和 this link想要查询
我的一位用户对tinyMCE 中的撤消功能感到非常沮丧。它不是撤消最后一个微小的更改,而是撤消许多更改。这是每隔几秒拍摄一次快照的计时问题吗?这是可配置的吗? 其他信息:用户正在将信息从 Word 复
我有最新版本的 TinyMCE 编辑器,当我像那样传递图像链接时 http://www.w3schools.com/css/trolltunga.jpg它会自动转换为 .我试图捕获 paste_pr
如果编辑器当前内容的长度加上要粘贴的单词的长度超过指定的限制,我需要阻止tinyMCE的粘贴事件。我该怎么做?谢谢。 最佳答案 我错了。我不需要阻止或禁用 tinyMCE 中的粘贴来执行此操作。我使用
我正在使用 TinyMCE 插件并将 valid_elements 选项设置为: "a[href|target:_blank],strong/b,em/i,br,p,ul,ol,li" 即使没有列出数
我似乎无法在互联网上找到有关此的任何信息,但是 TinyMCE 4 中的图标如何工作? 我知道我可以按名称为按钮指定图标并为我的自定义按钮指定自定义图标,但是如果我想采用标准图标之一,在图像编辑应用程
每次我向 tinyMCE 添加图像时,它都会将图像 URL 转换为愚蠢的内容(删除主机名并添加 ../或任何它需要的内容),因此我将无法在任何其他级别使用 tinymce 创建的图像地点 ! 这可以以
我有一个包含多个文本区域的页面,可以用 TinyMCE 替换。 一些 Textareas 采用阿拉伯语文本,一些英语文本。 textareas 根据他们应该接收的输入正确设置了 dir -属性。 如何
我正在使用最新的 TinyMCE,它很棒,但我遇到的唯一问题是人们发布代码示例时。他们以 PRE 格式发布还是正常发布都没有关系。 TinyMCE 去掉了所有的缩进(Tabs)并使其难以阅读,这里有没
我一直在寻找几个小时来找到一个可以在图像中添加诸如“填充:5px”之类的东西的插件。每个人都通过纯 html 做到这一点吗?我们的客户需要一种方法来简单地使用按钮或右键单击上下文菜单来添加它。有什么建
我想要 tinymce 工具栏中的按钮。单击该按钮后,无论光标在哪里,“HELLO”都应出现在编辑器中。 版本:3.3.7 但我无法添加该按钮。 我试过添加这样的按钮 setup: function
我刚开始使用 TinyMCE 作为 WYSIWYG 编辑器,我想知道是否有人看到我的问题使用过这个不错的编辑器可以帮助我,这是我的脚本: tinyMCE.init({ mode :
我正在尝试从 ltr 设置 TinyMCE(版本 4.0.12)中的默认内容方向至 rtl . 我正在使用 directionality配置: directionality: 'rtl', ...但编
如何为粗体、下划线和删除线等基本内容覆盖 TinyMCE 的默认格式?目前生成的 HTML 使用样式化的跨度,这通常很好。不幸的是,在这种情况下,我需要做一些简单的解析并且需要元素是旧样式的 、 和
如何在 TinyMCE 中设置默认字体大小和背景颜色? 谢谢, 伊甸园 最佳答案 您也可以使用 Javascript 更改 css。 将此添加到您的 init 函数中: oninit : "postI
当我使用 TinyMCE 添加新表格时,表格几乎不可见,因为初始宽度只有几个像素。 有什么办法可以改变这种情况吗? 最佳答案 打开 table.js,转到第 30 行有内容 width = formO
我正在 TinyMCE 工具栏上制作一个额外的按钮(它用于 Wordpress,但我认为这并不重要)。 按下按钮并显示一个表单,我在配置它时完全不知所措,以便在表单上输入的值实际上传输到tinyMce
我是一名优秀的程序员,十分优秀!