| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<!-- |
| 4 |
Copyright 2010 The Closure Library Authors. All Rights Reserved. |
| 5 |
|
| 6 |
Use of this source code is governed by the Apache License, Version 2.0. |
| 7 |
See the COPYING file for details. |
| 8 |
--> |
| 9 |
<head> |
| 10 |
<title>goog.ui.RichTextSpellChecker</title> |
| 11 |
<meta charset="utf-8"> |
| 12 |
<script src="../base.js"></script> |
| 13 |
<script> |
| 14 |
goog.require('goog.ui.RichTextSpellChecker'); |
| 15 |
</script> |
| 16 |
<link rel="stylesheet" href="css/demo.css"> |
| 17 |
<style> |
| 18 |
.goog-menu { |
| 19 |
position: absolute; |
| 20 |
color: #000; |
| 21 |
border: 1px solid #B5B6B5; |
| 22 |
background-color: #F3F3F7; |
| 23 |
cursor: default; |
| 24 |
font: normal small arial, helvetica, sans-serif; |
| 25 |
width: 25ex; |
| 26 |
outline: 0; |
| 27 |
} |
| 28 |
|
| 29 |
.goog-menuitem { |
| 30 |
padding: 2px 5px; |
| 31 |
position: relative; |
| 32 |
} |
| 33 |
|
| 34 |
.goog-menuitem-highlight { |
| 35 |
background-color: #4279A5; |
| 36 |
color: #FFF; |
| 37 |
} |
| 38 |
|
| 39 |
.goog-menuitem-disabled { |
| 40 |
background-color: #F3F3F7; |
| 41 |
color: #999; |
| 42 |
} |
| 43 |
|
| 44 |
.goog-menu hr { |
| 45 |
background-color: #999; |
| 46 |
height: 1px; |
| 47 |
border: 0px; |
| 48 |
margin: 0px; |
| 49 |
} |
| 50 |
</style> |
| 51 |
</head> |
| 52 |
<body> |
| 53 |
<h1>goog.ui.RichTextSpellChecker</h1> |
| 54 |
<p> |
| 55 |
The words "test", "words", "a", and "few" are set to be valid words, all others are considered spelling mistakes. |
| 56 |
</p> |
| 57 |
<p> |
| 58 |
If keyboard navigation is enabled, then the following shortcuts can be used |
| 59 |
inside the editor: |
| 60 |
<ul> |
| 61 |
<li>Previous misspelled word: ctrl + left-arrow</li> |
| 62 |
<li>next misspelled word: ctrl + right-arrow</li> |
| 63 |
<li>Open suggestions menu: down arrow</li> |
| 64 |
</ul> |
| 65 |
</p> |
| 66 |
<p> |
| 67 |
<iframe id="rich" style="width: 50ex; height: 15em;"></iframe> |
| 68 |
</p> |
| 69 |
|
| 70 |
<button onclick="s.check();">check</button> |
| 71 |
<button onclick="s.resume();">done</button> |
| 72 |
|
| 73 |
<script> |
| 74 |
|
| 75 |
function localSpellCheckingFunction(words, spellChecker, callback) { |
| 76 |
var len = words.length; |
| 77 |
var results = []; |
| 78 |
for (var i = 0; i < len; i++) { |
| 79 |
var word = words[i]; |
| 80 |
if (word == 'test' || word == 'words' || word == 'a' || word == 'few') { |
| 81 |
results.push([word, goog.spell.SpellCheck.WordStatus.VALID]); |
| 82 |
} else { |
| 83 |
results.push([word, goog.spell.SpellCheck.WordStatus.INVALID, |
| 84 |
['suggestion1', 'suggestion2']]); |
| 85 |
} |
| 86 |
} |
| 87 |
callback.call(spellChecker, results); |
| 88 |
} |
| 89 |
|
| 90 |
var handler = new goog.spell.SpellCheck(localSpellCheckingFunction); |
| 91 |
var s = new goog.ui.RichTextSpellChecker(handler); |
| 92 |
var el = document.getElementById('rich'); |
| 93 |
var doc = el.contentDocument || el.contentWindow.document; |
| 94 |
doc.designMode = 'on'; |
| 95 |
|
| 96 |
window.setTimeout(function() { |
| 97 |
s.decorate(el); |
| 98 |
}, 0); |
| 99 |
</script> |
| 100 |
</body> |
| 101 |
</html> |