adding the glavred plugin, attempt 3

This commit is contained in:
Nrorn
2023-09-25 15:06:41 +03:00
parent 5a2a0e4ac2
commit 76cfd0dea2
34 changed files with 2537 additions and 1 deletions

View File

@ -0,0 +1,16 @@
This plugin uses code from the following 3rd party projects.
1. Glavred api is a javascript library helps authors to write a text without superfluous words and the language garbage. (https://glvrd.ru/api/)
2. iscroll.js is a high performance, small footprint, dependency free, multi-platform javascript scroller. (https://github.com/cubiq/iscroll)
License: MIT
License File: iscroll.license
3. jQuery - Query is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. (http://jquery.com/)
License: MIT License
License File: jQuery.license

View File

@ -0,0 +1,5 @@
# Change Log
## 1.0.0
* Initial release.

View File

@ -0,0 +1,20 @@
## Overview
The Glavred plugin helps you make your text in Russian more informative and clear.
The plugin uses [Glavred API](https://glvrd.ru/api/).
The plugin is compatible with [self-hosted](https://github.com/ONLYOFFICE/DocumentServer) and [desktop](https://github.com/ONLYOFFICE/DesktopEditors) versions of ONLYOFFICE editors. It can be added to ONLYOFFICE instances manually.
## How to use
1. Highlight the phrase you want to check.
2. Open the Plugins tab and press Glavred.
## How to install
Detailed instructions can be found in [ONLYOFFICE API documentation](https://api.onlyoffice.com/plugin/installation).
## User feedback and support
To ask questions and share feedback, use Issues or Discussion in this repository.

View File

@ -0,0 +1,91 @@
{
"name" : "Glavred",
"nameLocale": {
"ru": "Главред",
"fr": "Glavred",
"es": "Glavred",
"de": "Glavred"
},
"guid" : "asc.{B631E142-E40B-4B4C-90B9-2D00222A286E}",
"version" : "1.0.0",
"offered" : "Nrorn",
"variations" : [
{
"description" : "Make your text more informative and clear (suitable when working with texts in Russian).",
"descriptionLocale": {
"ru": "Очистите текст от словесного мусора и проверьте его на соответствие информационному стилю.",
"fr": "Rendez votre texte plus informatif et clair (convient pour les textes en russe).",
"es": "Haga que su texto sea más informativo y claro (adecuado cuando trabaje con textos en ruso).",
"de": "Machen Sie Ihren Text informativer und deutlicher (geeignet für die Arbeit mit Texten auf Russisch)."
},
"url" : "index.html",
"icons": [ "resources/light/icon.png", "resources/light/icon@2x.png" ],
"icons2": [
{
"style" : "light",
"100%": {
"normal": "resources/light/icon.png"
},
"125%": {
"normal": "resources/light/icon@1.25x.png"
},
"150%": {
"normal": "resources/light/icon@1.5x.png"
},
"175%": {
"normal": "resources/light/icon@1.75x.png"
},
"200%": {
"normal": "resources/light/icon@2x.png"
}
},
{
"style" : "dark",
"100%": {
"normal": "resources/dark/icon.png"
},
"125%": {
"normal": "resources/dark/icon@1.25x.png"
},
"150%": {
"normal": "resources/dark/icon@1.5x.png"
},
"175%": {
"normal": "resources/dark/icon@1.75x.png"
},
"200%": {
"normal": "resources/dark/icon@2x.png"
}
}
],
"isViewer" : true,
"EditorsSupport" : ["word"],
"isVisual" : true,
"isModal" : true,
"isInsideMode" : false,
"initDataType" : "text",
"isUpdateOleOnResize" : false,
"buttons" : [ { "text": "Ok", "primary": true } ],
"store": {
"background": {
"light" : "#233450",
"dark" : "#233450"
},
"screenshots" : [
"resources/store/screenshots/screen_1.png",
"resources/store/screenshots/screen_2.png",
"resources/store/screenshots/screen_3.png"
],
"icons" : {
"light" : "resources/store/icons",
"dark" : "resources/store/icons"
},
"categories": ["specAbilities"]
}
}
]
}

Binary file not shown.

View File

@ -0,0 +1,32 @@
<!--
(c) Copyright Ascensio System SIA 2020
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE html>
<html>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://api.glvrd.ru/v1/glvrd.js"></script>
<script src="./vendor/iscroll.js"></script>
<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>
<script src="./scripts/code.js"></script>
<link rel="stylesheet" type="text/css" href="https://glvrd.ru/static/glaveditor.css">
<body style="position:fixed; box-sizing:border-box;width:100%;height:100%;margin:0;padding:0;font-family: 'Helvetica Neue', Arial, sans-serif;overflow:hidden;">
<div style="position:absolute;left:0;top:0;width:99%;height:90%">
<div id="id_text" style="position:absolute;box-sizing:border-box;padding:20px;left:0;top:0;width:60%;height:100%;overflow:auto;"></div>
<div id="id_hint" style="position:absolute;box-sizing:border-box;padding:10px;left:60%;top:0;width:40%;height:100%"></div>
</div>
<div id="id_score" style="box-sizing:border-box;position:absolute;box-sizing: border-box;left:0;top:90%;width:99%;height:10%;"></div>
</body>
</html>

View File

@ -0,0 +1,22 @@
Copyright (c) 2008-2013 Matteo Spinelli, http://cubiq.org
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,20 @@
Copyright (c) 2009 John Resig, http://jquery.com/
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Binary file not shown.

After

Width:  |  Height:  |  Size: 527 B

View File

@ -0,0 +1,3 @@
<svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M23.2 13.7863C23.2 13.7863 22.1557 19.8356 17.6767 19.8356C13.9837 19.8356 11.1014 15.1014 7.94521 11.6822C6.7313 10.3671 5.67397 9.59128 4 8.52603L4.52603 8C4.52603 8 6.63014 8.52603 9.78631 11.1562C12.1736 12.9857 14.2575 15.6274 15.0466 15.6274C16.0987 15.6273 15.8356 11.9452 15.8356 11.9452C15.8356 11.9452 16.3617 11.1562 19.7809 11.6822C23.2156 12.2106 23.2 13.7863 23.2 13.7863Z" fill="#A6A6A6"/>
</svg>

After

Width:  |  Height:  |  Size: 517 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 504 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 618 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 948 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 B

View File

@ -0,0 +1,3 @@
<svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M23.2 13.7863C23.2 13.7863 22.1557 19.8356 17.6767 19.8356C13.9837 19.8356 11.1014 15.1014 7.94521 11.6822C6.7313 10.3671 5.67397 9.59128 4 8.52603L4.52603 8C4.52603 8 6.63014 8.52603 9.78631 11.1562C12.1736 12.9857 14.2575 15.6274 15.0466 15.6274C16.0987 15.6273 15.8356 11.9452 15.8356 11.9452C15.8356 11.9452 16.3617 11.1562 19.7809 11.6822C23.2156 12.2106 23.2 13.7863 23.2 13.7863Z" fill="#444444"/>
</svg>

After

Width:  |  Height:  |  Size: 517 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 645 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 629 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 837 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,7 @@
<svg width="120" height="60" viewBox="0 0 120 60" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M35.536 35.306L35.9615 36.3065V36.41C35.3635 36.6553 34.731 36.8662 34.064 37.0425C33.4047 37.2112 32.7185 37.3377 32.0055 37.422C31.3002 37.5063 30.568 37.5485 29.809 37.5485C28.4443 37.5485 27.2177 37.3722 26.129 37.0195C25.0403 36.6592 24.1127 36.1378 23.346 35.4555C22.5793 34.7732 21.9967 33.9413 21.598 32.96C21.1993 31.9787 21 30.867 21 29.625C21 27.9997 21.368 26.5775 22.104 25.3585C22.8477 24.1318 23.9095 23.1812 25.2895 22.5065C26.6695 21.8242 28.3178 21.483 30.2345 21.483C30.7942 21.483 31.3308 21.5175 31.8445 21.5865C32.3582 21.6478 32.937 21.759 33.581 21.92L32.638 22.104L34.179 21H34.524L35.3175 26.635L34.685 26.7615L32.316 22.84L33.5465 24.082C32.9562 23.6297 32.3543 23.2962 31.741 23.0815C31.1353 22.8668 30.4607 22.7595 29.717 22.7595C28.82 22.7595 28.0265 22.886 27.3365 23.139C26.6465 23.392 26.0677 23.7715 25.6 24.2775C25.1323 24.7835 24.7758 25.4122 24.5305 26.1635C24.2928 26.9148 24.174 27.7888 24.174 28.7855C24.174 30.4185 24.4308 31.7947 24.9445 32.914C25.4658 34.0257 26.1712 34.8652 27.0605 35.4325C27.9575 35.9998 28.9657 36.2835 30.085 36.2835C30.5527 36.2835 31.0012 36.2452 31.4305 36.1685C31.8675 36.0842 32.27 35.9653 32.638 35.812C33.0137 35.651 33.3242 35.4593 33.5695 35.237L32.5115 36.755V31.488L30.568 30.821V30.338H37.054V30.821L35.536 31.4535V35.306Z" fill="#FF6F3D"/>
<path d="M50.3108 38.1005H49.9428L48.3788 37.2725H41.3868V36.019H49.3678L48.0798 36.4445L50.8283 32.2125L51.4033 32.3505L50.3108 38.1005ZM43.0428 22.8745V37.2725H38.2703V36.801L39.9953 36.1685V22.8745L38.2703 22.242V21.7705H44.7793V22.242L43.0428 22.8745Z" fill="#FF6F3D"/>
<path d="M50.9288 22.8975L49.2153 22.242V21.7705H56.1728V22.242L54.2178 22.8745L59.1283 34.869L58.5073 34.892L62.8312 22.886L60.9798 22.242V21.7705H65.9132V22.242L64.1998 22.886L58.7143 37.4105H57.0353L50.9288 22.8975Z" fill="#FF6F3D"/>
<path d="M73.4366 28.82C74.3336 28.82 75.0658 28.5747 75.6331 28.084C76.2004 27.5857 76.4841 26.865 76.4841 25.922C76.4841 25.3087 76.3576 24.7873 76.1046 24.358C75.8593 23.921 75.4568 23.5913 74.8971 23.369C74.3374 23.139 73.5976 23.024 72.6776 23.024H68.8481L69.2966 21.7705H74.1266C75.4299 21.7705 76.4764 21.9468 77.2661 22.2995C78.0558 22.6445 78.6308 23.1083 78.9911 23.691C79.3591 24.2737 79.5431 24.9253 79.5431 25.646C79.5431 26.3283 79.3821 26.9417 79.0601 27.486C78.7381 28.0303 78.2628 28.4788 77.6341 28.8315C77.0054 29.1842 76.2234 29.4103 75.2881 29.51V29.4525C75.9551 29.4832 76.4841 29.5867 76.8751 29.763C77.2738 29.9317 77.5919 30.1885 77.8296 30.5335C78.0749 30.8785 78.2934 31.3347 78.4851 31.902L79.4971 34.846C79.6811 35.3597 79.8536 35.7353 80.0146 35.973C80.1833 36.203 80.3788 36.3487 80.6011 36.41C80.8234 36.4637 81.0994 36.4905 81.4291 36.4905V37.2955C80.4861 37.3645 79.7194 37.3875 79.1291 37.3645C78.5388 37.3415 78.0711 37.2572 77.7261 37.1115C77.3811 36.9582 77.1089 36.7282 76.9096 36.4215C76.7179 36.1148 76.5493 35.7123 76.4036 35.214L75.4606 32.224C75.2843 31.6567 75.1079 31.2197 74.9316 30.913C74.7629 30.5987 74.5521 30.3802 74.2991 30.2575C74.0538 30.1348 73.7241 30.0735 73.3101 30.0735H69.2161L68.7676 28.82H73.4366ZM71.3436 21.7705V36.157L73.0801 36.801V37.2725H66.5596V36.801L68.3076 36.157V22.8745L66.5596 22.242V21.7705H71.3436Z" fill="#FF6F3D"/>
<path d="M94.9344 29.326C94.9344 27.164 94.3671 25.5732 93.2324 24.5535C92.1054 23.5338 90.5452 23.024 88.5519 23.024H85.4354L85.2399 21.7705H89.1154C91.1241 21.7705 92.7954 22.0388 94.1294 22.5755C95.4634 23.1122 96.4639 23.921 97.1309 25.002C97.7979 26.083 98.1314 27.4362 98.1314 29.0615C98.1314 30.8095 97.7404 32.293 96.9584 33.512C96.1764 34.731 95.1069 35.6625 93.7499 36.3065C92.3929 36.9505 90.8596 37.2725 89.1499 37.2725H85.2399L85.4354 36.019H88.7819C90.0239 36.019 91.1049 35.7928 92.0249 35.3405C92.9449 34.8805 93.6579 34.1598 94.1639 33.1785C94.6776 32.1895 94.9344 30.9053 94.9344 29.326ZM82.2039 37.2725V36.801L83.9289 36.1685V22.8745L82.2039 22.242V21.7705H86.9764V37.2725H82.2039Z" fill="#FF6F3D"/>
</svg>

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 392 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 KiB

View File

@ -0,0 +1,140 @@
/**
*
* (c) Copyright Ascensio System SIA 2020
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
(function(window, undefined){
var hints = [];
window.Asc.plugin.isEmpty = false;
window.Asc.plugin.makeEmpty = function()
{
document.body.innerHTML = ("<div style=\"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;color:#848484;font-size:20px;" +
"background:#F4F4F4;display:table;width:100%;height:100%;text-align:center;\">" +
"<span style=\"display:table-cell;vertical-align: middle;\">" + window.Asc.plugin.tr("Please select text before run plugin!") + "</span></div>");
}
window.Asc.plugin.init = function(text)
{
text = escape(text.split("\n").join("<br>"));
document.getElementById("id_text").innerHTML = text;
if (text == "")
{
window.Asc.plugin.isEmpty = true;
window.Asc.plugin.makeEmpty();
return;
}
var uAgent = navigator.userAgent.toLowerCase();
var isSailfishOS = ((uAgent.indexOf("sailfish") > -1) && (uAgent.indexOf("emulatedevicepixelratio") > -1)) ? true : false;
glvrd.proofread(text, function(result)
{
if (result.status == 'ok')
{
document.getElementById("id_score").innerHTML =
"<span style='font-size: 30px;position:absolute;bottom:0;left:20px;width:100%;'>" + result.score +
"<span style='font-size: 12px;'> балла из 10 по шкале Главреда" + "</span></span>";
var len = result.fragments.length;
var output = "";
var last = 0;
for (var i = 0; i < len; i++)
{
var fragment = result.fragments[i];
hints.push("<h1>" + fragment.hint.name + "</h1><br/>" + fragment.hint.description);
if (last != fragment.start)
output += text.substr(last, fragment.start - last);
output += ("<em id='data" + i + "'>" + text.substr(fragment.start, fragment.end - fragment.start) + "</em>");
last = fragment.end;
}
if (last != (text.length - 1))
{
output += text.substr(last);
}
if (!isSailfishOS)
{
document.getElementById("id_text").innerHTML = output;
}
else
{
var inner = "<div style=\"margin:0;padding:0;\">" + output + "</div>";
var elem = document.getElementById("id_text");
elem.style.overflow = "hidden";
elem.style.boxSizing = "border-box";
elem.style.padding = "5px";
elem.innerHTML = inner;
setTimeout(function(){
new IScroll(elem, { mouseWheel: true, scrollX: true });
}, 100);
}
var _elements = document.getElementsByTagName("em");
for (var j = 0; j < _elements.length; j++)
{
_elements[j].onclick = function(e)
{
var _ems = document.getElementsByTagName("em");
for (var k = 0; k < _ems.length; k++)
_ems[k].className = "";
this.className = "active current";
var hintIndex = parseInt(this.getAttribute("id").substr("4"));
if (!isSailfishOS)
{
document.getElementById("id_hint").innerHTML = hints[hintIndex];
}
else
{
var inner = "<div style=\"margin:0;padding:0;word-break:break-all;\">" + hints[hintIndex] + "</div>";
var elem = document.getElementById("id_hint");
elem.style.overflow = "hidden";
elem.style.boxSizing = "border-box";
elem.style.padding = "5px";
elem.innerHTML = inner;
setTimeout(function(){
new IScroll(elem, { mouseWheel: true, scrollX: true });
}, 100);
}
};
}
}
else
{
document.getElementById("id_score").innerHTML = "ERROR";
}
});
};
window.Asc.plugin.button = function(id)
{
this.executeCommand("close", "");
};
window.Asc.plugin.onTranslate = function(){
if (window.Asc.plugin.isEmpty)
window.Asc.plugin.makeEmpty();
};
})(window, undefined);

View File

@ -0,0 +1,3 @@
[
"ru-RU"
]

View File

@ -0,0 +1,3 @@
{
"Please select text before run plugin!" : "Пожалуйста выделите текст перед запуском!"
}

File diff suppressed because it is too large Load Diff

View File

@ -27,5 +27,6 @@
{ "name": "chess", "discussion": "246" }, { "name": "chess", "discussion": "246" },
{ "name": "openai", "discussion": "248" }, { "name": "openai", "discussion": "248" },
{ "name": "speechrecognition", "discussion": "249" }, { "name": "speechrecognition", "discussion": "249" },
{ "name": "zhipu", "discussion": "250"} { "name": "zhipu", "discussion": "250"},
{ "name": "glavred", "discussion": "" }
] ]