Commit fcdbc9fb authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Добавил spellCheck в документы

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47376 954022d7-b5bf-4e40-9824-e11837661b57
parent 2cf4b037
......@@ -709,6 +709,7 @@ var ASC_DOCS_API_USE_OPEN_SOURCE_FONTS_ONLY = false;
window.g_font_loader = new CGlobalFontLoader();
window.g_image_loader = new CGlobalImageLoader();
window.g_script_loader = new CGlobalScriptLoader();
window.g_script_loader2 = new CGlobalScriptLoader();
window.g_flow_anchor = new Image();
window.g_flow_anchor.asc_complete = false;
......
......@@ -12315,7 +12315,7 @@ CParaSpellChecker.prototype =
}
if ( 0 < usrWords.length )
spellCheck(editor, SpellCheck_CallBack, JSON.stringify({"type": "spell", "ParagraphId": this.ParaId, "RecalcId" : this.RecalcId, "ElementId" : 0, "usrWords" : usrWords, "usrLang" : usrLang }) );
spellCheck(editor, {"type": "spell", "ParagraphId": this.ParaId, "RecalcId" : this.RecalcId, "ElementId" : 0, "usrWords" : usrWords, "usrLang" : usrLang });
},
Check_CallBack : function(RecalcId, UsrCorrect)
......@@ -12413,7 +12413,7 @@ CParaSpellChecker.prototype =
if ( null === Variants )
{
spellCheck(editor, SpellCheck_CallBack, JSON.stringify({"type": "suggest", "ParagraphId": this.ParaId, "RecalcId" : this.RecalcId, "ElementId" : FoundIndex, "usrWords" : [Word], "usrLang" : [FoundElement.Lang] }) );
spellCheck(editor, {"type": "suggest", "ParagraphId": this.ParaId, "RecalcId" : this.RecalcId, "ElementId" : FoundIndex, "usrWords" : [Word], "usrLang" : [FoundElement.Lang] });
}
}
......
......@@ -24,6 +24,7 @@
<script type="text/javascript" src="../Common/3rdparty/Underscore/underscore-min.js"></script>
<script type="text/javascript" src="../Common/3rdparty/Sockjs/sockjs-0.3.min.js"></script>
<script type="text/javascript" src="../Common/docscoapi.js"></script>
<script type="text/javascript" src="../Common/spellcheckapi.js"></script>
<script type="text/javascript" src="../Common/wordcopypaste.js"></script>
<script type="text/javascript" src="../Common/CommonDefines.js"></script>
<script type="text/javascript" src="../Common/NumFormat.js"></script>
......
......@@ -506,6 +506,7 @@ function asc_docs_api(name)
this.FontLoader = window.g_font_loader;
this.ImageLoader = window.g_image_loader;
this.ScriptLoader = window.g_script_loader;
this.ScriptSpellCheckLoader = window.g_script_loader2;
this.FontLoader.put_Api(this);
this.ImageLoader.put_Api(this);
......@@ -534,6 +535,10 @@ function asc_docs_api(name)
this.User = undefined;
this.CoAuthoringApi = new CDocsCoApi();
this.isCoAuthoringEnable = true;
// Spell Checking
this.SpellCheckApi = new CSpellCheckApi();
this.isSpellCheckEnable = true;
/**************************************/
this.bInit_word_control = false;
......@@ -1350,6 +1355,44 @@ asc_docs_api.prototype.asc_coAuthoringDisconnect = function () {
this.CoAuthoringApi.disconnect();
}
/////////////////////////////////////////////////////////////////////////
//////////////////////////SpellChecking api//////////////////////////////
/////////////////////////////////////////////////////////////////////////
// Init SpellCheck
asc_docs_api.prototype._coSpellCheckInit = function(docId) {
if (!this.SpellCheckApi) {
return; // Error
}
this.SpellCheckApi.onSpellCheck = function (e) {
var incomeObject = JSON.parse(e);
SpellCheck_CallBack(incomeObject);
};
this.SpellCheckApi.init (docId);
};
// Set SpellCheck server url
asc_docs_api.prototype._coSpellCheckSetServerUrl = function(url) {
if (!this.SpellCheckApi)
return; // Error
this.SpellCheckApi.set_url(url);
};
asc_docs_api.prototype._spellCheckInitCallback = function(_this) {
if(undefined !== window['g_cAscSpellCheckUrl'])
window.g_cAscSpellCheckUrl = window['g_cAscSpellCheckUrl'];
if(undefined !== window.g_cAscSpellCheckUrl) {
//Turn off SpellCheck feature if it disabled
if(!_this.isSpellCheckEnable)
window.g_cAscSpellCheckUrl = "";
_this._coSpellCheckSetServerUrl(window.g_cAscSpellCheckUrl);
}
_this._coSpellCheckInit(documentId);
};
// get functions
// Возвращает
//{
......@@ -5208,10 +5251,14 @@ asc_docs_api.prototype.asyncServerIdStartLoaded = function()
//Загружаем скрипт с настройками, по окончанию инициализируем контрол для совместного редактирования
//TODO: Вынести шрифты в коммоны, SetFontPath заменить на SetCommonPath,
//пердаваемый путь использовать для загрузки шрифтов и настороек.
if(true == ASC_DOCS_API_LOAD_COAUTHORING_SETTINGS){
this.ScriptLoader.LoadScriptAsync( this.FontLoader.fontFilesPath + "../Common/docscoapisettings.js",
if(true == ASC_DOCS_API_LOAD_COAUTHORING_SETTINGS) {
// Загружаем для SpellCheck
this.ScriptSpellCheckLoader.LoadScriptAsync(this.FontLoader.fontFilesPath + "../Common/spellcheckapisettings.js",
this._spellCheckInitCallback, this);
this.ScriptLoader.LoadScriptAsync(this.FontLoader.fontFilesPath + "../Common/docscoapisettings.js",
this._coAuthoringInitCallBack, this);
}else{
} else {
this._coAuthoringInitCallBack(this);
}
}
......@@ -6136,9 +6183,19 @@ var cCharDelimiter = String.fromCharCode(5);
function getURLParameter(name) {
return (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1];
};
}
function spellCheck (editor, fCallback, rdata){
function spellCheck (editor, rdata) {
//console.log("start - " + rdata);
// ToDo проверка на подключение
switch (rdata.type) {
case "spell":
editor.SpellCheckApi.spellCheck(JSON.stringify(rdata));
break;
}
}
/*function spellCheck (editor, fCallback, rdata){
asc_ajax({
type: 'POST',
url: g_sSpellCheckServiceLocalUrl,
......@@ -6171,7 +6228,7 @@ function spellCheck (editor, fCallback, rdata){
}
}
})
};
};*/
function sendCommand(editor, fCallback, rdata){
asc_ajax({
type: 'POST',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment