GWT TinyMCE 拼写检查

Posted

技术标签:

【中文标题】GWT TinyMCE 拼写检查【英文标题】:GWT TinyMCE spellchecking 【发布时间】:2011-10-24 11:07:13 【问题描述】:

我正在尝试使用 TinyMCE 和拼写检查来启动和运行 GWT 应用程序。我想对拼写错误的单词进行内联突出显示,并使用一个按钮来进行拼写检查。我已经尝试过 iespell 和拼写检查,但结果很差。这是我到目前为止所遵循的步骤 1。使用 Eclipse Indigo 下载最新的 GWT 2。已下载 GWT TinyMCE 插件http://code.google.com/p/tinymce-gwt/wiki/Tutorial 3。下载了最新的 TinyMCE 4。下载了最新的拼写检查器http://www.tinymce.com/wiki.php/Plugin:spellchecker 5。将我在第2步下载的jar目录中的tiny_mce_editor目录替换为第3步。 6。将 tiny_mce_editor\plugins\spellchecker 目录替换为我在第 4 步中下载的目录。 7。为 GWT 生成了以下代码。

package com.test.reporting.client;

import gr.open.client.TinyMCE;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Reporting implements EntryPoint 
private TinyMCE tinyMCEEditor = new TinyMCE();

private final VerticalPanel verticalPanel = new VerticalPanel();
/**
 * This is the entry point method.
 */
public void onModuleLoad() 

    // Add the nameField and sendButton to the RootPanel
    // Use RootPanel.get() to get the entire body element
    RootPanel rootPanel = RootPanel.get();
    String[] plugins = tinyMCEEditor.getConfig().getPlugins().split(", ");
    String[] newPlugins = new String[plugins.length+1];
    System.arraycopy(plugins, 0, newPlugins, 0, plugins.length);
    newPlugins[plugins.length] = "spellchecker"; 

    tinyMCEEditor.getConfig().setPlugins(newPlugins);
    tinyMCEEditor.getConfig().setThemeAdvancedButtons3(new String[]"spellchecker","iespell");

    rootPanel.add(verticalPanel, 0, 0);
    verticalPanel.add(tinyMCEEditor);


现在,当我在 Chrome 或 Firefox 中使用此功能时,内联拼写不起作用,并且拼写检查图标会在此问题的末尾重现一个很长的错误。在 Internet Explorer 中会出现 iespell 图标,但除了要求安装 iespell 之外什么也没做。但是,当我改变时

tinyMCEEditor.getConfig().setThemeAdvancedButtons3(new String[]"spellchecker","iespell");

tinyMCEEditor.getConfig().setThemeAdvancedButtons3(new String[]"iespell");

在 Chrome 和 Firefox 中,内联拼写检查现在都有效,但与 TinyMCE 关联的整个工具栏都消失了。

谁能帮我解决这两个问题?

谢谢

长 PHP 错误 错误响应:?php /** * $Id: rpc.php 915 2008-09-03 08:45:28Z spocke $ * * @package MCManager.includes * @author Moxiecode * @copyright 版权所有 © 2004-2007,Moxiecode Systems AB,保留所有权利. */ require_once("./includes/general.php"); // 设置 RPC 响应头 header('Content-Type: text/plain'); header('内容编码:UTF-8'); header("过期时间:星期一,1997 年 7 月 26 日 05:00:00 GMT"); header("Last-Modified:" .gmdate("D, d M Y H:i:s") ." GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); $原始 = ""; // 尝试参数 if (isset($_POST["json_data"])) $raw = getRequestParam("json_data"); // 尝试全局数组 if (!$raw && isset($_GLOBALS) && isset($_GLOBALS["HTTP_RAW_POST_DATA"])) $raw = $_GLOBALS["HTTP_RAW_POST_DATA"]; // 尝试全局变量 if (!$raw && isset($HTTP_RAW_POST_DATA)) $raw = $HTTP_RAW_POST_DATA; // 尝试流 if (!$raw) if (!function_exists('file_get_contents')) $fp = fopen("php://input", "r");如果 ($fp) $raw = "";而 (!feof($fp)) $raw = fread($fp, 1024); fclose($fp); 其他 $raw = "" 。 file_get_contents("php://input"); // 没有输入数据 if (!$raw) die('"result":null,"id":null,"error":"errstr":"Could not get raw post data.","errfile" :"","errline":null,"errcontext":"","level":"FATAL"'); // 向远程服务器传递请求 if (isset($config['general.remote_rpc_url'])) $url = parse_url($config['general.remote_rpc_url']); // 设置请求 $req = "POST" . $url[“路径”] 。 " HTTP/1.0\r\n"; $req .= "连接:关闭\r\n"; $req .= "主机:" 。 $url['host'] 。 "\r\n"; $req .= "内容长度:" 。 strlen($raw) 。 "\r\n"; $req .= "\r\n" 。 $原始; if (!isset($url['port']) || !$url['port']) $url['port'] = 80; $errno = $errstr = ""; $socket = fsockopen($url['host'], intval($url['port']), $errno, $errstr, 30); if ($socket) // 发送请求头 fputs($socket, $req); // 读取响应头和数据 $resp = ""; while (!feof($socket)) $resp .= fgets($socket, 4096); fclose($socket); // 拆分响应头/数据 $resp = explode("\r\n\r\n", $resp);回声 $resp[1]; // 输出体 die(); // 获取 JSON 数据 $json = new Moxiecode_JSON(); $input = $json->decode($raw); // 执行 RPC if (isset($config['general.engine'])) $spellchecker = new $config'general.engine'; $result = call_user_func_array(array($spellchecker, $input['method']), $input['params']); else die('"result":null,"id":null,"error":"errstr":"您必须在 config.php 文件中选择一个拼写检查引擎。","errfile":"", "errline":null,"errcontext":"","level":"FATAL"'); // 请求和响应 id 应该始终相同 $output = array( "id" => $input->id, "result" => $result, "error" => null ); // 返回 JSON 编码字符串 echo $json->encode($output); ?>

编辑: 我已经弄清楚如何进行浏览器拼写检查。您只需要包含 gecko_spellcheck 元素。但是我仍然不知道如何让 TinyMCE 拼写检查器工作。

【问题讨论】:

【参考方案1】:

您需要设置一个 tinymce 初始化参数,以便在 tinymces iframe 框中激活 gecko 拼写检查引擎。你需要在你的初始化中这样设置它

// This option enables you toggling the internal Gecko/Firefox spellchecker logic. 
// This option is set to false by default and will then remove the spellchecker from TinyMCE. 
gecko_spellcheck: true,

【讨论】:

我已经弄清楚了这部分,并添加了适当的编辑。你知道如何让 TinyMCE 拼写检查器工作吗? 所有你需要的拼写检查是安装一个Firefox字典(插件) 对 Firefox 有效,但我也想将 TinyMCE 的拼写器用于其他浏览器(尤其是 Internet Explorer) 在这种情况下,您可能需要其他解决方案(即 iespell)。对于 IE 看​​看这里:tinymce.com/wiki.php/Plugin:iespell

以上是关于GWT TinyMCE 拼写检查的主要内容,如果未能解决你的问题,请参考以下文章

VS Code:启用内联拼写检查,但在“问题”面板中禁用拼写检查

MindManager中的拼写检查功能如何用

Libre office 拼写检查不工作,给出“拼写检查完成”但不标记错误

Textarea 2 语言拼写检查

技巧118 对你的工作进行拼写检查

Eclipse 拼写检查平台字典