GWT TinyMCE 拼写检查

发布于 2024-11-29 08:21:33 字数 4799 浏览 1 评论 0原文

我正在尝试使用 TinyMCE 和拼写检查启动并运行 GWT 应用程序。我想要对拼写错误的单词进行内联突出显示,并使用一个按钮进行拼写检查。我尝试过 iespell 和拼写检查器,但效果不佳。这是我到目前为止所遵循的步骤
1.使用 Eclipse Indigo 下载最新的 GWT
2。下载的 GWT TinyMCE 插件 http://code.google.com/p/tinymce-gwt /wiki/教程
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("最后修改时间:" .gmdate("D, d MYH:i:s") ." GMT"); header("缓存控制:无存储、无缓存、必须重新验证"); header("Cache-Control: 后检查=0, 预检查=0", false); header("Pragma: 无缓存"); $原始=“”; // 尝试参数 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://输入"); } // 没有输入数据 if (!$raw) die('{"result":null,"id":null,"error":{"errstr":"无法获取原始发布数据。","errfile" :"","errline":null,"errcontext":"","level":"致命"}}'); // 向远程服务器传递请求 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['主机'] 。 “\r\n”; $req .= "内容长度:" . strlen($raw) 。 “\r\n”; $req .= "\r\n" 。 $原始; if (!isset($url['端口']) || !$url['端口']) $url['端口'] = 80; $errno = $errstr = ""; $socket = fsockopen($url['主机'], intval($url['端口']), $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 拼写检查器工作。

I'm trying to get a GWT application up and running with TinyMCE and spell checking. I want to have inline highlighting for incorrectly spelled words and a button to do spell checking. I've tried both iespell and spellchecker with poor results. Here are the steps I've followed so far

1. Downloaded newest GWT with Eclipse Indigo

2. Downloaded GWT TinyMCE plugin http://code.google.com/p/tinymce-gwt/wiki/Tutorial

3. Downloaded latest TinyMCE

4. Downloaded the latest SpellChecker http://www.tinymce.com/wiki.php/Plugin:spellchecker

5. Replaced the tiny_mce_editor directory in the jar directory I downloaded in step 2 with step 3.

6. Replaced the tiny_mce_editor\plugins\spellchecker directory with the directory I downloaded in step 4.

7. Generated the following code for 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);
}
}

Now when I use this in Chrome or Firefox the inline spelling doesn't work, and the spell check icon gives a very long error reproduced at the end of this question. In Internet Explorer the iespell icon comes up but doesn't do anything other than ask to install iespell. However, when I change

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

to

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

In both Chrome and Firefox, inline spell checking now works, but the whole toolbar associated with TinyMCE disappears.

Can anyone help me figure out both of my problems?

Thanks

  • Long PHP error
    Error response: ?php
    /** * $Id: rpc.php 915 2008-09-03 08:45:28Z spocke $ * * @package MCManager.includes * @author Moxiecode * @copyright Copyright � 2004-2007, Moxiecode Systems AB, All rights reserved. */ require_once("./includes/general.php"); // Set RPC response headers header('Content-Type: text/plain'); header('Content-Encoding: UTF-8'); header("Expires: Mon, 26 Jul 1997 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"); $raw = ""; // Try param if (isset($_POST["json_data"])) $raw = getRequestParam("json_data"); // Try globals array if (!$raw && isset($_GLOBALS) && isset($_GLOBALS["HTTP_RAW_POST_DATA"])) $raw = $_GLOBALS["HTTP_RAW_POST_DATA"]; // Try globals variable if (!$raw && isset($HTTP_RAW_POST_DATA)) $raw = $HTTP_RAW_POST_DATA; // Try stream if (!$raw) { if (!function_exists('file_get_contents')) { $fp = fopen("php://input", "r"); if ($fp) { $raw = ""; while (!feof($fp)) $raw = fread($fp, 1024); fclose($fp); } } else $raw = "" . file_get_contents("php://input"); } // No input data if (!$raw) die('{"result":null,"id":null,"error":{"errstr":"Could not get raw post data.","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}'); // Passthrough request to remote server if (isset($config['general.remote_rpc_url'])) { $url = parse_url($config['general.remote_rpc_url']); // Setup request $req = "POST " . $url["path"] . " HTTP/1.0\r\n"; $req .= "Connection: close\r\n"; $req .= "Host: " . $url['host'] . "\r\n"; $req .= "Content-Length: " . strlen($raw) . "\r\n"; $req .= "\r\n" . $raw; if (!isset($url['port']) || !$url['port']) $url['port'] = 80; $errno = $errstr = ""; $socket = fsockopen($url['host'], intval($url['port']), $errno, $errstr, 30); if ($socket) { // Send request headers fputs($socket, $req); // Read response headers and data $resp = ""; while (!feof($socket)) $resp .= fgets($socket, 4096); fclose($socket); // Split response header/data $resp = explode("\r\n\r\n", $resp); echo $resp[1]; // Output body } die(); } // Get JSON data $json = new Moxiecode_JSON(); $input = $json->decode($raw); // Execute 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":"You must choose an spellchecker engine in the config.php file.","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}'); // Request and response id should always be the same $output = array( "id" => $input->id, "result" => $result, "error" => null ); // Return JSON encoded string echo $json->encode($output); ?>

Edit:
I have figured out how to get the browser spell checking. You just have to include the gecko_spellcheck element. However I am still lost how to get the TinyMCE spell checker to work.

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

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

发布评论

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

评论(1

一刻暧昧 2024-12-06 08:21:33

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

// 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,

There is a tinymce init parameter you need to set in order to get the gecko spellchecker engine activated in tinymces iframe box. You need to set it like this in your init

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