7
sdkjs-plugins/content/drawio/3rd-Party.txt
Normal file
@ -0,0 +1,7 @@
|
||||
This plugin uses code from the following 3rd party projects.
|
||||
|
||||
|
||||
1. draw.io, this project, is a configurable diagramming/whiteboarding visualization application. draw.io is owned and developed by JGraph Ltd, a UK based software company. (https://github.com/jgraph/drawio)
|
||||
|
||||
License: Apache License 2.0
|
||||
License File: drawio.license
|
||||
25
sdkjs-plugins/content/drawio/README.md
Normal file
@ -0,0 +1,25 @@
|
||||
## Overview
|
||||
|
||||
Create, edit, and insert diagrams into your documents.
|
||||
|
||||
This plugin uses [draw.io](https://github.com/jgraph/drawio), a configurable diagramming/whiteboarding visualization application. draw.io is owned and developed by JGraph Ltd, a UK based software company.
|
||||
|
||||
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. Open the Plugins tab and click on **draw.io**.
|
||||
2. Create your own diagram in the opened window or paste one from any available resources.
|
||||
3. Click "Save & exit".
|
||||
4. You will see a ready diagram. If you need to make further changes to this diagram, just click on it.
|
||||
5. To insert the ready diagram into your document, click the Insert button.
|
||||
|
||||
## 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 in this repository or visit [our forum](https://forum.onlyoffice.com/c/plugins/38).
|
||||
|
||||
If you need more information about how to use or build your own plugin, please visit our [API documentation](https://api.onlyoffice.com/plugin/basic).
|
||||
104
sdkjs-plugins/content/drawio/config.json
Normal file
@ -0,0 +1,104 @@
|
||||
{
|
||||
"name": "draw.io",
|
||||
"nameLocale": {
|
||||
"ru": "draw.io",
|
||||
"fr": "draw.io",
|
||||
"es": "draw.io",
|
||||
"de": "draw.io"
|
||||
},
|
||||
"guid": "asc.{DB38923B-A8C0-4DE9-8AEE-A61BB5C901A5}",
|
||||
"version": "1.0.1",
|
||||
|
||||
"variations": [
|
||||
{
|
||||
"description": "draw.io",
|
||||
"descriptionLocale": {
|
||||
"ru": "draw.io",
|
||||
"fr": "draw.io",
|
||||
"es": "draw.io",
|
||||
"de": "draw.io"
|
||||
},
|
||||
"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": false,
|
||||
"EditorsSupport": [ "word", "cell", "slide" ],
|
||||
|
||||
"isVisual": true,
|
||||
"isModal": true,
|
||||
"isInsideMode": false,
|
||||
|
||||
"initDataType": "ole",
|
||||
"initData": "",
|
||||
|
||||
"isUpdateOleOnResize": false,
|
||||
|
||||
"buttons": [
|
||||
{
|
||||
"text": "Insert",
|
||||
"primary": true,
|
||||
"textLocale": {
|
||||
"ru": "Вставить",
|
||||
"fr": "Insérer",
|
||||
"es": "Insertar",
|
||||
"de": "Einfügen",
|
||||
"cs": "Vložit"
|
||||
}
|
||||
},
|
||||
{
|
||||
"text": "Cancel",
|
||||
"primary": false,
|
||||
"textLocale": {
|
||||
"ru": "Отмена",
|
||||
"fr": "Annuler",
|
||||
"es": "Cancelar",
|
||||
"de": "Abbrechen",
|
||||
"cs": "Zrušit"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
"size": [ 1200, 1000 ]
|
||||
}
|
||||
]
|
||||
}
|
||||
59
sdkjs-plugins/content/drawio/index.html
Normal file
@ -0,0 +1,59 @@
|
||||
<!--
|
||||
(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 lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>draw.io</title>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.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>
|
||||
<link rel="stylesheet" href="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.css">
|
||||
<script src="vendor/drawio/diagram-editor.js"></script>
|
||||
<script src="scripts/code.js"></script>
|
||||
<style>
|
||||
html, body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.div_preview {
|
||||
width: calc(100% - 10px);
|
||||
height: calc(100% - 10px);
|
||||
overflow: auto;
|
||||
}
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
.noselect {
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
.div-loader {
|
||||
margin: 10px;
|
||||
height: 40px;
|
||||
top: 50%;
|
||||
right: 50%;
|
||||
position: absolute;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="noselect">
|
||||
<div id="div_preview" class="div_preview noselect hidden"></div>
|
||||
<div id="loader-container" class="asc-loader-container div-loader"></div>
|
||||
</body>
|
||||
</html>
|
||||
201
sdkjs-plugins/content/drawio/licenses/drawio.license
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
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.
|
||||
BIN
sdkjs-plugins/content/drawio/resources/dark/icon.png
Normal file
|
After Width: | Height: | Size: 453 B |
BIN
sdkjs-plugins/content/drawio/resources/dark/icon@1.25x.png
Normal file
|
After Width: | Height: | Size: 645 B |
BIN
sdkjs-plugins/content/drawio/resources/dark/icon@1.5x.png
Normal file
|
After Width: | Height: | Size: 615 B |
BIN
sdkjs-plugins/content/drawio/resources/dark/icon@1.75x.png
Normal file
|
After Width: | Height: | Size: 743 B |
BIN
sdkjs-plugins/content/drawio/resources/dark/icon@2x.png
Normal file
|
After Width: | Height: | Size: 932 B |
BIN
sdkjs-plugins/content/drawio/resources/light/icon.png
Normal file
|
After Width: | Height: | Size: 469 B |
BIN
sdkjs-plugins/content/drawio/resources/light/icon@1.25x.png
Normal file
|
After Width: | Height: | Size: 659 B |
BIN
sdkjs-plugins/content/drawio/resources/light/icon@1.5x.png
Normal file
|
After Width: | Height: | Size: 617 B |
BIN
sdkjs-plugins/content/drawio/resources/light/icon@1.75x.png
Normal file
|
After Width: | Height: | Size: 754 B |
BIN
sdkjs-plugins/content/drawio/resources/light/icon@2x.png
Normal file
|
After Width: | Height: | Size: 941 B |
125
sdkjs-plugins/content/drawio/scripts/code.js
Normal file
@ -0,0 +1,125 @@
|
||||
/**
|
||||
*
|
||||
* (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 img;
|
||||
var editor;
|
||||
var UI = "kennedy";
|
||||
var loader;
|
||||
var lang = "";
|
||||
var title = "Click on diagram to edit."
|
||||
|
||||
window.Asc.plugin.init = function(data)
|
||||
{
|
||||
lang = this.info.lang.split('-')[0];
|
||||
img = document.createElement('img');
|
||||
img.setAttribute('title', title)
|
||||
document.getElementById("div_preview").appendChild(img);
|
||||
// create an empti image for editor (if data doesn't set), after export we put the result in it
|
||||
if (!data)
|
||||
data = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAMSURBVBhXY/j//z8ABf4C/qc1gYQAAAAASUVORK5CYII=";
|
||||
|
||||
img.setAttribute('src', data);
|
||||
var config = {css: "button.geBigButton:nth-of-type(1) {background-color:transparent !important; color:"+ (UI == 'dark' ? '#ccc' : '#000') +" !important;} body>a {display: none !important;} body {-khtml-user-select: none; user-select: none; -moz-user-select: none; -webkit-user-select: none;} div>img:not([title]) { pointer-events: none; }"};
|
||||
img.onclick = function() {
|
||||
makeLoader();
|
||||
editor = DiagramEditor.editElement([this, document.getElementById("div_preview")], config, UI, null, ['lang=' + lang], closePlugin, hideLoader);
|
||||
editor.isChanged = true;
|
||||
}
|
||||
editor = DiagramEditor.editElement([img, document.getElementById("div_preview")], config, UI, null, ['lang=' + lang], closePlugin, hideLoader);
|
||||
window.Asc.plugin.resizeWindow(1200, 1000, 800, 600, 0, 0);
|
||||
};
|
||||
|
||||
window.Asc.plugin.button = function(id)
|
||||
{
|
||||
if (id == 0) {
|
||||
if (editor.frame) {
|
||||
// if editor is opened
|
||||
editor.closePlugin(true);
|
||||
} else {
|
||||
closePlugin(editor.isChanged);
|
||||
}
|
||||
} else {
|
||||
this.executeCommand("close", "");
|
||||
}
|
||||
};
|
||||
|
||||
function closePlugin (bPaste) {
|
||||
if (bPaste)
|
||||
{
|
||||
var _info = window.Asc.plugin.info;
|
||||
var _method = (_info.objectId === undefined) ? "AddOleObject" : "EditOleObject";
|
||||
// we should use timeout for image export from diagram editor
|
||||
setTimeout(function() {
|
||||
var _param = {
|
||||
guid : _info.guid,
|
||||
widthPix : (_info.mmToPx * (img.width >> 2) ) >> 0,
|
||||
heightPix : (_info.mmToPx * (img.height >> 2) ) >> 0,
|
||||
width : img.width ? (img.width >> 2) : _info.width ? _info.width : 100,
|
||||
height : img.height ? (img.height >> 2) : _info.height ? _info.height : 70,
|
||||
imgSrc : img.getAttribute('src'),
|
||||
data : img.getAttribute('src'),
|
||||
objectId : _info.objectId,
|
||||
resize : _info.resize
|
||||
};
|
||||
|
||||
window.Asc.plugin.executeMethod(_method, [_param], function() {
|
||||
window.Asc.plugin.executeCommand("close", "");
|
||||
});
|
||||
}, 1);
|
||||
|
||||
} else {
|
||||
window.Asc.plugin.executeCommand("close", "");
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function makeLoader() {
|
||||
loader && (loader.remove ? loader.remove() : $('#loader-container')[0].removeChild(loader));
|
||||
loader = showLoader($('#loader-container')[0], window.Asc.plugin.tr('Loading') + '...');
|
||||
if (img) img.classList.add('hidden');
|
||||
};
|
||||
|
||||
function hideLoader() {
|
||||
loader && (loader.remove ? loader.remove() : $('#loader-container')[0].removeChild(loader));
|
||||
loader = undefined;
|
||||
};
|
||||
|
||||
window.Asc.plugin.onTranslate = function()
|
||||
{
|
||||
title = window.Asc.plugin.tr(title);
|
||||
if (img)
|
||||
img.setAttribute("title", title);
|
||||
makeLoader();
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
window.Asc.plugin.onThemeChanged = function(theme)
|
||||
{
|
||||
window.Asc.plugin.onThemeChangedBase(theme);
|
||||
UI = (theme.type.indexOf("dark") !== -1) ? "dark" : "kennedy";
|
||||
};
|
||||
|
||||
})(window, undefined);
|
||||
4
sdkjs-plugins/content/drawio/translations/cs-CS.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"Loading" : "Načítání",
|
||||
"Click on diagram to edit." : "Klikněte na diagram pro úpravu."
|
||||
}
|
||||
4
sdkjs-plugins/content/drawio/translations/de-DE.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"Loading" : "Laden",
|
||||
"Click on diagram to edit." : "Klicken Sie zum Bearbeiten auf das Diagramm."
|
||||
}
|
||||
4
sdkjs-plugins/content/drawio/translations/es-ES.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"Loading" : "Carga",
|
||||
"Click on diagram to edit." : "Haga clic en el diagrama para editar."
|
||||
}
|
||||
4
sdkjs-plugins/content/drawio/translations/fr-FR.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"Loading" : "Chargement",
|
||||
"Click on diagram to edit." : "Cliquez sur le diagramme pour le modifier."
|
||||
}
|
||||
7
sdkjs-plugins/content/drawio/translations/langs.json
Normal file
@ -0,0 +1,7 @@
|
||||
[
|
||||
"cs-CS",
|
||||
"de-DE",
|
||||
"es-ES",
|
||||
"fr-FR",
|
||||
"ru-RU"
|
||||
]
|
||||
4
sdkjs-plugins/content/drawio/translations/ru-RU.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"Loading" : "Загрузка",
|
||||
"Click on diagram to edit." : "Нажмите на диаграмму для редактирования."
|
||||
}
|
||||
502
sdkjs-plugins/content/drawio/vendor/drawio/diagram-editor.js
vendored
Normal file
@ -0,0 +1,502 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2020, JGraph Ltd
|
||||
* Copyright (c) 2006-2020, Gaudenz Alder
|
||||
*
|
||||
* Usage: DiagramEditor.editElement(elt) where elt is an img or object with
|
||||
* a data URI src or data attribute or an svg node with a content attribute.
|
||||
*
|
||||
* See https://jgraph.github.io/drawio-integration/javascript.html
|
||||
*/
|
||||
function DiagramEditor(config, ui, done, initialized, urlParams, callback, hideLoader)
|
||||
{
|
||||
this.config = (config != null) ? config : this.config;
|
||||
this.ui = (ui != null) ? ui : this.ui;
|
||||
this.done = (done != null) ? done : this.done;
|
||||
this.initialized = (initialized != null) ? initialized : this.initialized;
|
||||
this.urlParams = urlParams;
|
||||
this.isChanged = false;
|
||||
this.isClosePlugin = false;
|
||||
this.pluginCallback = callback;
|
||||
this.hideLoader = hideLoader;
|
||||
this.unsaved_xml = null;
|
||||
this.curPage = 0;
|
||||
this.empty_xml = "ddHBDoMgDADQr+GOoIl357bLTh52JtIJCVqDGN2+fhpwjrhdSHktlBTCi3a+WNGrG0owhFE5E34ijGV5uqwrPD2wNEBjtfSU7FDpFwSkQUctYYgKHaJxuo+xxq6D2kUmrMUpLnugibv2ooEDVLUwR71r6ZTXPKO7X0E3auuc0JBpxVYcYFBC4vRFvCS8sIjOR+1cgFlnt83Fnzv/yX4eZqFzPw4swX73sok+iJdv";
|
||||
|
||||
var self = this;
|
||||
|
||||
this.handleMessageEvent = function(evt)
|
||||
{
|
||||
if (self.frame != null && evt.source == self.frame.contentWindow &&
|
||||
evt.data.length > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var msg = JSON.parse(evt.data);
|
||||
|
||||
if (msg != null)
|
||||
{
|
||||
self.handleMessage(msg);
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Static method to edit the diagram in the given img or object.
|
||||
*/
|
||||
DiagramEditor.editElement = function(arrel, config, ui, done, urlParams, callback, hideLoader)
|
||||
{
|
||||
var elt = arrel[0];
|
||||
var div = arrel[1];
|
||||
if (!elt.diagramEditorStarting)
|
||||
{
|
||||
elt.diagramEditorStarting = true;
|
||||
var editor = new DiagramEditor(config, ui, done, function()
|
||||
{
|
||||
delete elt.diagramEditorStarting;
|
||||
div.classList.remove("hidden");
|
||||
this.frame.classList.remove("hidden");
|
||||
}, urlParams, callback, hideLoader);
|
||||
editor.editElement(elt);
|
||||
return editor;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Global configuration.
|
||||
*/
|
||||
DiagramEditor.prototype.config = null;
|
||||
|
||||
/**
|
||||
* Protocol and domain to use.
|
||||
*/
|
||||
DiagramEditor.prototype.drawDomain = 'https://embed.diagrams.net/';
|
||||
|
||||
/**
|
||||
* UI theme to be use.
|
||||
*/
|
||||
DiagramEditor.prototype.ui = 'kennedy';
|
||||
|
||||
/**
|
||||
* Contains XML for pending image export.
|
||||
*/
|
||||
DiagramEditor.prototype.xml = null;
|
||||
|
||||
/**
|
||||
* Format to use.
|
||||
*/
|
||||
DiagramEditor.prototype.format = 'xml';
|
||||
|
||||
/**
|
||||
* Specifies if libraries should be enabled.
|
||||
*/
|
||||
DiagramEditor.prototype.libraries = true;
|
||||
|
||||
/**
|
||||
* CSS style for the iframe.
|
||||
*/
|
||||
DiagramEditor.prototype.frameStyle = 'position:absolute;border:0;width:calc(100% - 10px);height:100%;';
|
||||
|
||||
/**
|
||||
* Adds the iframe and starts editing.
|
||||
*/
|
||||
DiagramEditor.prototype.editElement = function(elem)
|
||||
{
|
||||
var src = this.getElementData(elem);
|
||||
this.startElement = elem;
|
||||
var fmt = this.format;
|
||||
|
||||
if (src.substring(0, 15) === 'data:image/png;')
|
||||
{
|
||||
fmt = 'xmlpng';
|
||||
}
|
||||
else if (src.substring(0, 19) === 'data:image/svg+xml;' ||
|
||||
elem.nodeName.toLowerCase() == 'svg')
|
||||
{
|
||||
fmt = 'xmlsvg';
|
||||
}
|
||||
|
||||
this.startEditing(src, fmt);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds the iframe and starts editing.
|
||||
*/
|
||||
DiagramEditor.prototype.getElementData = function(elem)
|
||||
{
|
||||
var name = elem.nodeName.toLowerCase();
|
||||
|
||||
return elem.getAttribute((name == 'svg') ? 'content' :
|
||||
((name == 'img') ? 'src' : 'data'));
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds the iframe and starts editing.
|
||||
*/
|
||||
DiagramEditor.prototype.setElementData = function(elem, data)
|
||||
{
|
||||
var name = elem.nodeName.toLowerCase();
|
||||
|
||||
if (name == 'svg')
|
||||
{
|
||||
elem.outerHTML = atob(data.substring(data.indexOf(',') + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
elem.setAttribute((name == 'img') ? 'src' : 'data', data);
|
||||
}
|
||||
|
||||
return elem;
|
||||
};
|
||||
|
||||
/**
|
||||
* Starts the editor for the given data.
|
||||
*/
|
||||
DiagramEditor.prototype.startEditing = function(data, format, title)
|
||||
{
|
||||
if (this.frame == null)
|
||||
{
|
||||
window.addEventListener('message', this.handleMessageEvent);
|
||||
this.format = (format != null) ? format : this.format;
|
||||
this.title = (title != null) ? title : this.title;
|
||||
this.data = data;
|
||||
|
||||
this.frame = this.createFrame(
|
||||
this.getFrameUrl(),
|
||||
this.getFrameStyle());
|
||||
document.body.appendChild(this.frame);
|
||||
this.setWaiting(true);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates the waiting cursor.
|
||||
*/
|
||||
DiagramEditor.prototype.setWaiting = function(waiting)
|
||||
{
|
||||
if (this.startElement != null)
|
||||
{
|
||||
// Redirect cursor to parent for SVG and object
|
||||
var elt = this.startElement;
|
||||
var name = elt.nodeName.toLowerCase();
|
||||
|
||||
if (name == 'svg' || name == 'object')
|
||||
{
|
||||
elt = elt.parentNode;
|
||||
}
|
||||
|
||||
if (elt != null)
|
||||
{
|
||||
if (waiting)
|
||||
{
|
||||
this.frame.style.pointerEvents = 'none';
|
||||
this.previousCursor = elt.style.cursor;
|
||||
elt.style.cursor = 'wait';
|
||||
}
|
||||
else
|
||||
{
|
||||
elt.style.cursor = this.previousCursor;
|
||||
this.frame.style.pointerEvents = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates the waiting cursor.
|
||||
*/
|
||||
DiagramEditor.prototype.setActive = function(active)
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
this.previousOverflow = document.body.style.overflow;
|
||||
document.body.style.overflow = 'hidden';
|
||||
}
|
||||
else
|
||||
{
|
||||
document.body.style.overflow = this.previousOverflow;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes the iframe.
|
||||
*/
|
||||
DiagramEditor.prototype.stopEditing = function()
|
||||
{
|
||||
if (this.frame != null)
|
||||
{
|
||||
window.removeEventListener('message', this.handleMessageEvent);
|
||||
document.body.removeChild(this.frame);
|
||||
this.setActive(false);
|
||||
this.frame = null;
|
||||
var t = this;
|
||||
var el = this.startElement;
|
||||
setTimeout(function() {
|
||||
// check for empy element
|
||||
if ( (el.height && el.height < 10) || (el.width && el.width < 10) )
|
||||
t.pluginCallback(false);
|
||||
}, 1);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Send the given message to the iframe.
|
||||
*/
|
||||
DiagramEditor.prototype.postMessage = function(msg)
|
||||
{
|
||||
if (this.frame != null)
|
||||
{
|
||||
// if we put id of the current page instead of the first page id, final image will be from curent page
|
||||
if (this.curPage !== 0) {
|
||||
var first = {start : 0, id: ""};
|
||||
var needed = {start : 0, id: ""};
|
||||
var newXml = "";
|
||||
var pos = 0;
|
||||
var i = 0;
|
||||
while (pos !== -1) {
|
||||
var str = '<diagram id="';
|
||||
pos = msg.xml.indexOf(str, pos + 1) + str.length;
|
||||
if (i == 0) {
|
||||
first.start = pos;
|
||||
var end = msg.xml.indexOf('"', first.start);
|
||||
first.id = msg.xml.slice(first.start, end);
|
||||
}
|
||||
if (i == this.curPage) {
|
||||
needed.start = pos;
|
||||
var end = msg.xml.indexOf('"', needed.start);
|
||||
needed.id = msg.xml.slice(needed.start, end);
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
newXml = msg.xml.slice(0, needed.start).replace(first.id, needed.id) + msg.xml.slice(needed.start).replace(needed.id, first.id);
|
||||
msg.xml = newXml;
|
||||
}
|
||||
|
||||
this.frame.contentWindow.postMessage(JSON.stringify(msg), '*');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the diagram data.
|
||||
*/
|
||||
DiagramEditor.prototype.getData = function()
|
||||
{
|
||||
return this.data;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the title for the editor.
|
||||
*/
|
||||
DiagramEditor.prototype.getTitle = function()
|
||||
{
|
||||
return this.title;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the CSS style for the iframe.
|
||||
*/
|
||||
DiagramEditor.prototype.getFrameStyle = function()
|
||||
{
|
||||
// if we use document.body.scrollLeft, we have bug 55144 https://bugzilla.onlyoffice.com/show_bug.cgi?id=55141
|
||||
return this.frameStyle + ';left:' + 5 /*document.body.scrollLeft*/ + 'px;' +
|
||||
'top:' + document.body.scrollTop + 'px;';
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the URL for the iframe.
|
||||
*/
|
||||
DiagramEditor.prototype.getFrameUrl = function()
|
||||
{
|
||||
var url = this.drawDomain + '?proto=json&spin=1';
|
||||
|
||||
if (this.ui != null)
|
||||
{
|
||||
url += '&ui=' + this.ui;
|
||||
}
|
||||
|
||||
if (this.libraries != null)
|
||||
{
|
||||
url += '&libraries=1';
|
||||
}
|
||||
|
||||
if (this.config != null)
|
||||
{
|
||||
url += '&configure=1';
|
||||
}
|
||||
|
||||
if (this.urlParams != null)
|
||||
{
|
||||
url += '&' + this.urlParams.join('&');
|
||||
}
|
||||
|
||||
return url;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates the iframe.
|
||||
*/
|
||||
DiagramEditor.prototype.createFrame = function(url, style)
|
||||
{
|
||||
var frame = document.createElement('iframe');
|
||||
frame.setAttribute('frameborder', '0');
|
||||
frame.setAttribute('style', style);
|
||||
frame.setAttribute('src', url);
|
||||
frame.classList.add("hidden");
|
||||
return frame;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the status of the editor.
|
||||
*/
|
||||
DiagramEditor.prototype.setStatus = function(messageKey, modified)
|
||||
{
|
||||
this.postMessage({action: 'status', messageKey: messageKey, modified: modified});
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles the given message.
|
||||
*/
|
||||
DiagramEditor.prototype.handleMessage = function(msg)
|
||||
{
|
||||
switch (msg.event) {
|
||||
case "configure":
|
||||
this.configureEditor();
|
||||
break;
|
||||
|
||||
case "init":
|
||||
this.initializeEditor();
|
||||
break;
|
||||
|
||||
case "autosave":
|
||||
// for normal work when you push exit without save
|
||||
this.curPage = msg.currentPage;
|
||||
this.save(msg.xml, true, this.startElement);
|
||||
break;
|
||||
|
||||
case "export":
|
||||
this.setElementData(this.startElement, msg.data);
|
||||
this.stopEditing();
|
||||
this.xml = null;
|
||||
if (this.isClosePlugin || !this.isChanged) {
|
||||
this.isClosePlugin = false;
|
||||
this.pluginCallback(this.isChanged);
|
||||
}
|
||||
break;
|
||||
|
||||
case "save":
|
||||
// todo: saving if nothing has changed in a non-empty diagram
|
||||
this.curPage = msg.currentPage;
|
||||
this.save(msg.xml, false, this.startElement);
|
||||
if (msg.exit) {
|
||||
msg.event = 'exit';
|
||||
this.handleMessage(msg);
|
||||
}
|
||||
else {
|
||||
this.setStatus('allChangesSaved', false);
|
||||
}
|
||||
break;
|
||||
|
||||
case "load":
|
||||
this.hideLoader();
|
||||
break;
|
||||
|
||||
case "exit":
|
||||
// for dialog window
|
||||
// this.postMessage({action: 'prompt', title: 'page number', okKey: 'ok', defaultValue: '1' });
|
||||
this.startElement.classList.remove("hidden");
|
||||
if (this.format != 'xml') {
|
||||
if (this.xml != null) {
|
||||
this.postMessage({action: 'export', format: this.format,
|
||||
xml: this.xml, spinKey: 'export'});
|
||||
} else {
|
||||
this.stopEditing(msg);
|
||||
if (!this.isChanged)
|
||||
this.pluginCallback(false);
|
||||
}
|
||||
} else {
|
||||
if (msg.modified == null || msg.modified)
|
||||
this.save(msg.xml, false, this.startElement);
|
||||
|
||||
this.stopEditing(msg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Posts configure message to editor.
|
||||
*/
|
||||
DiagramEditor.prototype.configureEditor = function()
|
||||
{
|
||||
this.postMessage({action: 'configure', config: this.config});
|
||||
};
|
||||
|
||||
/**
|
||||
* Posts load message to editor.
|
||||
*/
|
||||
DiagramEditor.prototype.initializeEditor = function()
|
||||
{
|
||||
//https://desk.draw.io/support/solutions/articles/16000042544-how-does-embed-mode-work-
|
||||
this.postMessage({action: 'load', autosave: 1, noSaveBtn: '1', noExitBtn: '1',
|
||||
modified: 'unsavedChanges', xml: this.getData(),
|
||||
title: this.getTitle()});
|
||||
this.setWaiting(false);
|
||||
this.setActive(true);
|
||||
this.initialized();
|
||||
};
|
||||
|
||||
/**
|
||||
* Saves the given data.
|
||||
*/
|
||||
DiagramEditor.prototype.save = function(data, draft, elt)
|
||||
{
|
||||
if (data.indexOf(this.empty_xml) === -1)
|
||||
this.done(data, draft, elt);
|
||||
};
|
||||
|
||||
/**
|
||||
* Invoked after save.
|
||||
*/
|
||||
DiagramEditor.prototype.done = function(data, draft)
|
||||
{
|
||||
// hook for subclassers
|
||||
if (!draft) {
|
||||
this.isChanged = true;
|
||||
this.xml = data;
|
||||
} else {
|
||||
this.unsaved_xml = data;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Invoked after the editor has sent the init message.
|
||||
*/
|
||||
DiagramEditor.prototype.initialized = function()
|
||||
{
|
||||
// hook for subclassers
|
||||
};
|
||||
|
||||
/**
|
||||
* Static method to export the diagram when the plugin is closing.
|
||||
*/
|
||||
DiagramEditor.prototype.closePlugin = function(bUnsaved)
|
||||
{
|
||||
if (bUnsaved && this.unsaved_xml) {
|
||||
this.save(this.unsaved_xml, false);
|
||||
}
|
||||
|
||||
this.isClosePlugin = true;
|
||||
if (this.isChanged)
|
||||
this.postMessage({action: 'export', format: this.format, xml: this.xml, spinKey: 'export'});
|
||||
else
|
||||
this.pluginCallback(false);
|
||||
|
||||
};
|
||||