Bug 875965 - RFE: [WebTrans] enable visible white space in source
Summary: RFE: [WebTrans] enable visible white space in source
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Zanata
Classification: Retired
Component: Usability
Version: development
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
: 3.6
Assignee: Luke Brooker
QA Contact: Damian Jansen
URL:
Whiteboard:
Depends On:
Blocks: Zanata-3.6.1
TreeView+ depends on / blocked
 
Reported: 2012-11-12 23:26 UTC by Patrick Huang
Modified: 2016-04-18 09:37 UTC (History)
7 users (show)

Fixed In Version: 3.6.1-SNAPSHOT (git-jenkins-zanata-server-github-pull-requests-3111)
Doc Type: Bug Fix
Doc Text:
Story Points: 1
Clone Of:
: 880444 (view as bug list)
Environment:
Last Closed: 2015-04-20 01:06:33 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 872384 0 unspecified CLOSED Editor option to toggle the usage of CodeMirror 2021-02-22 00:41:40 UTC
Red Hat Bugzilla 880444 0 unspecified CLOSED RFE: [WebTrans] enable spell check in code mirror editor for Firefox 2021-02-22 00:41:40 UTC

Internal Links: 872384 880444

Description Patrick Huang 2012-11-12 23:26:13 UTC
Description of problem:
With the newly released Zanata version 2.0 Firefox's spell check does not seem to work anymore. I experienced this on FF 3.6, Leticia confirmed this for her FF 10.0.6. The spell-check used to work on both versions with Zanata 1.7.x

Version-Release number of selected component (if applicable):
2.0

Additional info:
Original bug is 872384. We introduced an option to switch between Code mirror editor and plain textarea editor as short term solution.
This bug is for permanently enable spell check in code mirror editor.

Comment 1 Patrick Huang 2012-11-12 23:28:50 UTC
Comment copied from bug 872384:
Patrick Huang 2012-11-08 23:12:13 EST
did some research and below options seems promising:

library: http://code.google.com/p/google-api-spelling-java/ 
description: This is a simple Java API that makes it very easy to call Google's spell checker service from Java applications.
pros: simple and easy to use
cons: calling google api means external network traffic

library: https://github.com/dren-dk/HunspellJNA
description: Hunspell is the spell checker of LibreOffice, OpenOffice.org, Mozilla Firefox 3 & Thunderbird, Google Chrome.
pros: lots of dictionaries
cons: written in c++ and required a JNA binding

library: http://jazzy.sourceforge.net/
description: pure java based spellchecker and based on most of the algorithms that aspell has
pros: pure java implementation
cons: no update since 2005 and sourceforge only have English dictionary


[reply] [-] Comment 8 Sean Flanigan 2012-11-09 02:22:43 EST
Hmm, Hunspell sounds good, but deploying Zanata could become a real nightmare if we start using JNA.

I still think a toggle is the only option that makes sense for a short-term solution, but just for completeness, I did spot these quick and dirty Hunspell ports too:

Javascript: http://code.google.com/p/bjspell/

Java: http://code.google.com/p/lucene-hunspell/ (tied to Lucene for some reason)

Comment 2 Runa Bhattacharjee 2012-11-26 18:17:47 UTC
Hi, can we try to squeeze this in for the upcoming release? Thanks.

Comment 3 Sean Flanigan 2012-11-27 01:17:49 UTC
This (ie syntax highlighting editor with spell-checking) isn't the sort of thing we can squeeze in, if we want to implement it properly, and test it properly.  It's far too big.  

If we want to cover a decent number of languages in our own spell-checker, we pretty much have to have Hunspell, but there only seems to be one Java port of Hunspell, but it is designed for a different use case, and it is only a prototype.  From what I can tell, it's quite a mess, and doesn't even have a build file.

Even if we get Hunspell working, we'll have a fair bit of UI work to integrate a spell-checker into CodeMirror.  Especially if we want a pop-up suggestions features?


Alternatively, we could look for an alternative to CodeMirror.  According to http://en.wikipedia.org/wiki/Comparison_of_JavaScript-based_source_code_editors these support browser-based spell-checking:

http://codepress.sourceforge.net/
http://www.cdolivet.com/editarea/

But they could turn out to have show-stopping problems (eg focus/event problems) when integrated into Zanata.  Or cross-platform bugs.  And I can't get spell-checking to work in Chrome for either of them so far...

Comment 4 Patrick Huang 2012-11-27 01:45:54 UTC
I've got spell check working in codemirror in firefox only. It's NOT cross platform (uses firefox only attributes) and doesn't (seems to) support pop up suggestion/add to dictionary etc. BUT it highlights the word in red and it uses firefox build-in spell check facility.

We can definitely squeeze this in :)

Comment 5 Sean Flanigan 2012-11-27 02:14:42 UTC
Okay, that's good.  I suggest creating another bz for the Firefox-only implementation.  We should provide a user option to turn it off.  (Partly so that the user can turn off spell-check, and partly in case of unexpected problems.)

Comment 6 Patrick Huang 2012-11-30 01:23:00 UTC
I submitted issues both to Code Mirror and Chrome. Looks like Chrome is doing something differently on elements with attribute "contenteditable=true". Bug 880444 is working in Firefox.

Comment 7 Sean Flanigan 2012-11-30 01:37:58 UTC
Could you please link to the Chrome and CodeMirror bugs here?

Comment 8 Patrick Huang 2012-11-30 01:42:57 UTC
CodeMirror issue raised at: https://bugzilla.redhat.com/show_bug.cgi?id=875965
Chrome issue is raised using Chrome's build in (menu->About Google Chrome->Report an Issue). I don't have any URL.

Comment 9 Patrick Huang 2012-11-30 01:44:41 UTC
(In reply to comment #8)
> CodeMirror issue raised at:
> https://bugzilla.redhat.com/show_bug.cgi?id=875965
> Chrome issue is raised using Chrome's build in (menu->About Google
> Chrome->Report an Issue). I don't have any URL.
Wrong url: https://github.com/marijnh/CodeMirror/issues/1017

Comment 10 Sean Flanigan 2012-12-03 05:13:13 UTC
Found a bit more information about the Hunspell situation:

According to http://wiki.apache.org/solr/Hunspell the Lucene-Hunspell code was contributed to Solr.  Lucene-Hunspell seems to be a bit dead, but it sounds as if the Solr team is maintaining a fork.

This seems to be it:

http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/

http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22lucene-analyzers-common%22


It looks like it's targeted more at spelling suggestions than spell checking per se, but it may be possible to modify it for spell checking.

Comment 11 Sean Flanigan 2012-12-03 06:27:38 UTC
To modify it for spell checking will probably require re-implementing Hunspell::spell() in Java: http://hunspell.cvs.sourceforge.net/viewvc/hunspell/hunspell/src/hunspell/hunspell.cxx?view=markup

Comment 12 Sean Flanigan 2012-12-07 04:47:34 UTC
Apparently the next version of ACE (a rival to CodeMirror, used by Skynet) will have some sort of spell-checking (not sure if it will have all of Hunspell's languages):

https://groups.google.com/forum/?fromgroups=#!topic/ace-discuss/-dwNC_rX7R0


I also spotted a link to a Hunspell implementation in JavaScript:

https://github.com/cfinke/Typo.js/blob/master/typo/typo.js

I wonder if it would run inside Rhino?  But I'm sure it could be ported to Java, if it's any good.

Given the size of Hunspell dictionaries, I'm not sure whether it would be better to load the dictionary in the client (one dictionary for every editor instance) or in the server (one dictionary per language).

Comment 13 Michelle Kim 2015-03-10 05:35:14 UTC
Technical Issue to be discussed. We may take a look at some alternatives.

Comment 14 Patrick Huang 2015-03-11 00:30:26 UTC
The problem with codemirror spellcheck is:
I used to hack it and enabled spellchecking. But when you correct the word using browser's built-in function, codemirror doesn't receive a change event which result in translation unsaved.
From the issue I put in codemirror, they will never support spellcheck. Integrate third party javascript library is possible. But then you have to keep track of updating the dictionary yourself instead of relying on browser's. Not a viable option either.
The best we can get for the old editor is to keep codemirror to just do syntax highlighting. And use plain text for spellcheck. There is already a shortcut ctrl+alt+h to toggle between the two.

Comment 15 Michelle Kim 2015-03-17 00:10:29 UTC
As we discussed with translators, we agreed upon the solutions as follows:

1. Enable codemirror (syntax highlighting) in source , so that translators will be able to view spacing highlight etc

2. Disable codemirror in target by default, so that spellcheck is available. If translator wants, they can use either a shortcut ctrl + alt + h to toggle, or use the editor setting option for consistent change.

Long term:

New Text Editor with both syntax highlighting and spellcheck enabled.

Comment 16 Sean Flanigan 2015-03-17 04:25:14 UTC
The short term plan sounds fine.

Long term, the new text editor probably won't make the problems which Patrick mentioned any easier to solve.  There aren't any components out there which solve the problem for us.  Ace and CodeMirror do live highlighting, but they don't do spell-check.  

There are possible solutions, but they all involve a fair bit of engineering (and maintenance), and may amount to re-implementing the browser's multilingual spell-check ourselves.  Or convincing the browser makers to expose spellcheck as an API we can call...

Comment 17 Luke Brooker 2015-03-17 04:41:44 UTC
This is not entirely true. There are options to "overlay" highlighting and other enhancements over text areas. I have some browser extensions that do this already. There are also options with contenteditable.

Basically, going back to a plain text editor and only implementing the basic features we need, should make it *easier* to maintain and add new features as we don't need to deal with the complexity of codemirror and all it's features we don't use.

Comment 18 Michelle Kim 2015-03-17 06:02:36 UTC
Thanks guys for your input. I will narrow down the scope of this bug to enable syntax highlighting / CodeMirror in source,  so that we can meet the short term goals first.

For the long term goals, we shall track with new editor RFE.

Comment 19 Michelle Kim 2015-03-18 01:34:41 UTC
Syntax highlighting is already active in Source, so this bug is to make sure white space highlighting is always on in source.
 - standard copy (Ctrl + C) should not copy the visible white space characters

Comment 20 Alex Eng 2015-03-24 05:19:47 UTC
Pull request for zanata-server:
https://github.com/zanata/zanata-server/pull/742

Comment 21 Damian Jansen 2015-03-25 05:51:47 UTC
Verified (release) at 90df3ec5fe4a3e441a8aafe77be5367246ecad1c


Note You need to log in before you can comment on or make changes to this bug.