Merge branch hotfix/v5.6.0 into master

This commit is contained in:
papacarlo
2020-07-28 13:39:00 +00:00
11 changed files with 377 additions and 13 deletions

View File

@ -1,10 +1,10 @@
# Thesaurus plugin
## Overview
Thesaurus plugin allows finding synonyms for selected words and inserting them into ONLYOFFICE documents, spreadsheets, and presentations.
Find synonyms for selected words.
The plugin uses [Big Huge Thesaurus](https://words.bighugelabs.com/).
The plugin is pre-installed in ONLYOFFICE Enterprise Edition, Community Edition (Document Server + Community Server), ONLYOFFICE Integration Edition, ONLYOFFICE cloud service, and ONLYOFFICE Personal.
It is called Thesaurus in the interface and is installed by default in cloud, [self-hosted](https://github.com/ONLYOFFICE/DocumentServer) and [desktop version](https://github.com/ONLYOFFICE/DesktopEditors) of ONLYOFFICE editors.
## How to use
@ -13,13 +13,3 @@ The plugin is pre-installed in ONLYOFFICE Enterprise Edition, Community Edition
3. If you want to replace your word with one of the synonyms, click on the one you prefer.
Another way to use it: open the plugin and type the word in the field. Press Lookup to search for synonyms.
## Documentation
Plugins structure and installation https://api.onlyoffice.com/plugin/basic.
Plugins code and methods https://api.onlyoffice.com/docbuilder/basic.
## User feedback and support
To ask questions and share feedback, use Issues in this repository.

40
config.json Normal file
View File

@ -0,0 +1,40 @@
{
"name": "Thesaurus",
"nameLocale": {
"ru": "Синонимы",
"fr": "Thésaurus",
"es": "Tesauro",
"de": "Thesaurus"
},
"guid": "asc.{BE5CBF95-C0AD-4842-B157-AC40FEDD9840}",
"variations": [
{
"description": "Thesaurus",
"descriptionLocale": {
"ru": "Синонимы",
"fr": "Thésaurus",
"es": "Tesauro",
"de": "Thesaurus"
},
"url": "index.html",
"icons": [ "icon.png", "icon@2x.png", "icon.png", "icon@2x.png" ],
"isViewer": true,
"EditorsSupport": [ "word", "cell", "slide" ],
"isVisual": true,
"isModal": false,
"isInsideMode": true,
"initDataType": "text",
"initData": "",
"isUpdateOleOnResize": false,
"buttons": [],
"initOnSelectionChanged": true
}
]
}

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

BIN
icon@2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 335 B

25
index.html Normal file
View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>synonim</title>
<script type="text/javascript" src="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.js"></script>
<script type="text/javascript" src="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins-ui.js"></script>
<link rel="stylesheet" href="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script src="synonim.js"></script>
<link rel="stylesheet" href="plugin_style.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
</head>
<body class='body'>
<div id="synonimresult_id" class = "input-field">
<input type="text" class = "input-synonim" name="q" id = "inp_search" placeholder="Search" autocomplete="off">
<button class = "button" id ="btn_search">Lookup</button>
</div>
<div id="scrollable-container-id" class='content-items'>
<div id = "global" class="global"></div>
</div>
</body>
</html>

95
plugin_style.css Normal file
View File

@ -0,0 +1,95 @@
html, body {
width: 98%;
height: 98%;
};
.noselect {
-khtml-user-select: none;
user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
}
.combo {
background: #fff;
border: 1px solid #cfcfcf;
border-radius: 2px;
color: #444444;
font-size: 11px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
height: 22px;
cursor: pointer;
margin: 0px 0px 10px 0px;
box-sizing: border-box;
}
div::selection {
background: #a8d1ff;
}
.button {
color: #fff;
background-color: #7d858c;
border: 1px solid #cfcfcf;
border-radius: 2px;
outline: none;
font-size: 11px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
height: 22px;
cursor: pointer;
}
.input-synonim {
outline-color: #7d858c;
flex: 1;
height: 18px;
border: 1px solid #cfcfcf;
}
.input-synonim::selection {
background: #D8DADC; /* WebKit/Blink Browsers */
}
.input-synonim::-moz-selection {
background: #D8DADC; /* Gecko Browsers */
}
.input-field {
display: flex;
align-content: center;
}
.not-found {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
padding-left: 5px;
}
.div-words {
width: 100%;
display: flex;
flex-wrap: wrap;
}
.label-selected {
background: rgba(200, 200, 200, 0.5);
}
.label-words {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
margin-left: 10px;
margin-top: 10px;
cursor: pointer;
}
.global {
height: 99%;
display: flex;
width: 96%;
flex-flow: column;
line-height: 90%;
-moz-user-select: none;
}
.label-syn {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 11px;
}
.content-items {
width: 98%;
height: 95%;
position: relative;
overflow: hidden;
flex: 1;
user-select: none;
}
div::-moz-selection {
background: #a8d1ff;
}

178
synonim.js Normal file
View File

@ -0,0 +1,178 @@
(function(window, undefined){
window.oncontextmenu = function(e)
{
if (e.preventDefault)
e.preventDefault();
if (e.stopPropagation)
e.stopPropagation();
return false;
};
var ApiKey = "34aacef03e39ff2e622f10d1fc5313f3", // generated APi key on bighugelabs.com
SynonimFormat = "json",
version = 2,
synonim_data = "",
inputSerch,
isInit = false,
isInitp = false,
predata = "";
$(document).ready(function () {
//event mouseout label
$('body').on('mouseout', '.label-words', function() {
$(this).removeClass('label-selected');
});
//event mouseover label
$('body').on('mouseover', '.label-words', function() {
$(this).addClass('label-selected');
});
//event click label
$('body').on('click', '.label-words', function() {
var _htmlPaste = "<span >" + $(this).text() +" "+ "</span>";
window.Asc.plugin.executeMethod("PasteText", [$(this).text() +" "]);
});
//event button click
button = document.getElementById("btn_search");
button.onclick = function() {
synonim_data = inputSerch.value;
if ((null!=synonim_data) && (predata != synonim_data))
{
$('#global').empty(); // cleared global div
synonim();
}
};
});
function synonim() {
if (!isInit)
{
var container = document.getElementById('scrollable-container-id');
Ps = new PerfectScrollbar('#' + container.id, {});
updateScroll();
updateScroll();
isInit = true;
}
predata = synonim_data;
var xhr = new XMLHttpRequest();
var req_text = decodeURIComponent(synonim_data.replace('%0D%0A', ' ').replace(/%/g, "$")).trim();
var _url = "https://words.bighugelabs.com/api/";
_url += version + "/";
_url += ApiKey + "/";
_url += req_text + "/";
_url += SynonimFormat;
xhr.open('GET', _url, true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onreadystatechange = function()
{
if (this.readyState == 4 && this.status == 404)
{
$('#global').append("<h3 id = \"not_found\" class = \"not-found\">This word not found</h3>"); //if synonym not found
updateScroll();
updateScroll();
}
if (this.readyState == 4 && this.status == 200 && !closed)
{
try
{
var _obj = JSON.parse(this.responseText);
if (_obj.noun) //if noun exist
{
drawWords(_obj.noun,"Noun");
}
if(_obj.adjective) //if andjective exist
{
drawWords(_obj.adjective,"Adjective")
}
if(_obj.verb) //if verb exist
{
drawWords(_obj.verb,"Verb")
}
updateScroll();
updateScroll();
}
catch (err)
{}
}else if (401 == this.readyState || 500 == this.readyState || 403 == this.status)
synonim();
};
xhr.send(null);
};
window.Asc.plugin.init = function(text) {
if (!isInitp)
{
inputSerch = document.getElementById("inp_search");
inputSerch.value = text;
synonim_data = text;
if (null != synonim_data && synonim_data != "")
synonim();
}else{
inputSerch.value = text;
synonim_data = text;
if (null == synonim_data)
{
synonim();
}else if (predata == synonim_data)
{
return;
}else {
$('#global').empty(); // cleared global div
synonim();
}
}
isInitp = true;
};
window.Asc.plugin.button = function(id)
{
this.executeCommand("close", "");
};
window.onresize = function() {
updateScroll();
updateScroll();
};
window.Asc.plugin.onExternalMouseUp = function() {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("mouseup", true, true, window, 1, 0, 0, 0, 0,
false, false, false, false, 0, null);
document.dispatchEvent(evt);
};
//draws the structure of the plugin
function drawWords(response, type) {
$('#global').append("<h3 class = \"not-found\">" + type + "</h3>");
$('#global').append("<div id = " + type + " ></div>");
if (response.syn && response.syn.length)
{
$("#"+type).append("<div id =\""+ type +"-synonims\" class = \"div-words\"></div>");
for (let i=0; i<response.syn.length; i++)
$('#'+ type +'-synonims').append("<label class =\"label-words\">"+ response.syn[i] +"</label>");
}
if(response.ant && response.ant.length)
{
$("#"+type).append("<h4 class = \"not-found\">Antonyms</h4>");
$("#"+type).append("<div id =\""+ type +"-antonyms\" class = \"div-words\"></div>");
for (let i=0; i<response.ant.length; i++)
$('#'+ type +'-antonyms').append("<label class =\"label-words\">"+ response.ant[i] +"</label>");
}
};
function updateScroll()
{
Ps && Ps.update();
};
window.Asc.plugin.onTranslate = function()
{
var btn_search = document.getElementById("btn_search");
if (btn_search)
btn_search.innerHTML = window.Asc.plugin.tr("Lookup");
var inp_search = document.getElementById("inp_search");
if (inp_search)
inp_search.placeholder = window.Asc.plugin.tr("Search");
};
})(window, undefined);

9
translations/de-DE.json Normal file
View File

@ -0,0 +1,9 @@
{
"Synonym": "Synonym",
"Lookup": "Suche",
"This word not found": "Dieses Wort wurde nicht gefunden",
"Noun": "Nomen",
"Adjective": "Adjektiv",
"Verb": "Verb",
"Antonyms": "Antonyme"
}

9
translations/es-ES.json Normal file
View File

@ -0,0 +1,9 @@
{
"Synonym": "Sinónimo",
"Lookup": "Búsqueda",
"This word not found": "Esta palabra no se encuentra",
"Noun": "Sustantivo",
"Adjective": "Adjetivo",
"Verb": "Verbo",
"Antonyms": "Antónimos"
}

9
translations/fr-FR.json Normal file
View File

@ -0,0 +1,9 @@
{
"Synonym": "Synonyme",
"Lookup": "Recherche",
"This word not found": "Ce mot n'est pas trouvé",
"Noun": "Nom",
"Adjective": "Adjectif",
"Verb": "Verbe",
"Antonyms": "Antonymes"
}

9
translations/ru-RU.json Normal file
View File

@ -0,0 +1,9 @@
{
"Synonym": "Синоним",
"Lookup": "Поиск",
"This word not found": "Это слово не найдено",
"Noun": "Имя существительное",
"Adjective": "Имя прилагательное",
"Verb": "Глагол",
"Antonyms": "Антонимы"
}