mirror of
https://github.com/ONLYOFFICE/sdkjs.git
synced 2026-04-07 14:09:12 +08:00
For bug 52732
This commit is contained in:
@ -217,6 +217,9 @@
|
||||
|
||||
this.openedAt = undefined;
|
||||
|
||||
this.isBlurEditor = false;
|
||||
this._correctEmbeddedWork();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -302,6 +305,29 @@
|
||||
};
|
||||
}
|
||||
};
|
||||
baseEditorsApi.prototype._correctEmbeddedWork = function()
|
||||
{
|
||||
let body = document.getElementById("viewport");
|
||||
if (body && body.addEventListener)
|
||||
{
|
||||
body.addEventListener("mousewheel", function(e) {
|
||||
e.preventDefault && e.preventDefault();
|
||||
e.stopPropagation && e.stopPropagation();
|
||||
return false;
|
||||
}, false);
|
||||
body.addEventListener("DOMMouseScroll", function(e)
|
||||
{
|
||||
e.preventDefault && e.preventDefault();
|
||||
e.stopPropagation && e.stopPropagation();
|
||||
return false;
|
||||
}, false);
|
||||
}
|
||||
|
||||
var _t = this;
|
||||
window.addEventListener("blur", function(){
|
||||
_t.isBlurEditor = true;
|
||||
}, false);
|
||||
};
|
||||
baseEditorsApi.prototype._editorNameById = function()
|
||||
{
|
||||
var res = '';
|
||||
|
||||
100
common/embed/embed.js
Normal file
100
common/embed/embed.js
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
(function(){
|
||||
|
||||
window.AscEmbed = window.AscEmbed || {};
|
||||
function ScrollLocker(frame)
|
||||
{
|
||||
this.frame = frame;
|
||||
this.x = window.scrollX;
|
||||
this.y = window.scrollY;
|
||||
this.isLock = false;
|
||||
|
||||
document.addEventListener("scroll", this.onScroll.bind(this), false);
|
||||
window.addEventListener("blur", this.onBlur.bind(this), false);
|
||||
|
||||
window.addEventListener("pointermove", this.onMove.bind(this), false);
|
||||
window.addEventListener("wheel", this.onMove.bind(this), false);
|
||||
|
||||
this.frame.addEventListener("pointerover", this.onOver.bind(this), false);
|
||||
this.frame.addEventListener("pointerleave", this.onLeave.bind(this), false);
|
||||
}
|
||||
|
||||
ScrollLocker.prototype.onScroll = function()
|
||||
{
|
||||
if (document.activeElement === this.frame || this.isLock)
|
||||
{
|
||||
window.scrollTo(this.x, this.y);
|
||||
return;
|
||||
}
|
||||
this.x = window.scrollX;
|
||||
this.y = window.scrollY;
|
||||
};
|
||||
|
||||
ScrollLocker.prototype.onBlur = function()
|
||||
{
|
||||
if (document.activeElement === this.frame)
|
||||
{
|
||||
this.isLock = true;
|
||||
var _t = this;
|
||||
setTimeout(function(){
|
||||
_t.isLock = false;
|
||||
}, 100);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
ScrollLocker.prototype.onOver = function()
|
||||
{
|
||||
};
|
||||
|
||||
ScrollLocker.prototype.onLeave = function()
|
||||
{
|
||||
this.frame.blur();
|
||||
};
|
||||
|
||||
ScrollLocker.prototype.onMove = function()
|
||||
{
|
||||
if (document.activeElement === this.frame)
|
||||
this.frame.blur();
|
||||
};
|
||||
|
||||
window.AscEmbed.initWorker = function(frame)
|
||||
{
|
||||
window.AscEmbed.workers = window.AscEmbed.workers || [];
|
||||
let worker = new ScrollLocker(frame);
|
||||
window.AscEmbed.workers.push(worker);
|
||||
return worker;
|
||||
};
|
||||
})();
|
||||
37
common/embed/make.py
Normal file
37
common/embed/make.py
Normal file
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
sys.path.append('../../../build_tools/scripts')
|
||||
import base
|
||||
import os
|
||||
|
||||
params = sys.argv[1:]
|
||||
|
||||
#compilation_level = "WHITESPACE_ONLY"
|
||||
compilation_level = "SIMPLE_OPTIMIZATIONS"
|
||||
base.cmd("python", ["./min.py"])
|
||||
|
||||
min_content = base.readFile("./embed.min.js")
|
||||
|
||||
if (1 != len(params)):
|
||||
exit(0)
|
||||
|
||||
api_file = params[0]
|
||||
api_content = base.readFile(api_file)
|
||||
|
||||
pos_return_editor_obj = api_content.find("return {")
|
||||
|
||||
new_content = ""
|
||||
new_content += min_content
|
||||
new_content += "\n "
|
||||
new_content += "function _createEmbedWorker() { return new AscEmbed._createEmbedWorker(); }"
|
||||
new_content += "\n\n"
|
||||
|
||||
new_content += " return {"
|
||||
new_content += "\n"
|
||||
new_content += " createEmbedWorker : _createEmbedWorker,"
|
||||
|
||||
new_api_content = api_content[0:pos_return_editor_obj] + new_content + api_content[pos_return_editor_obj + 8:]
|
||||
|
||||
base.delete_file(api_file)
|
||||
base.writeFile(api_file, new_api_content)
|
||||
14
common/embed/min.py
Normal file
14
common/embed/min.py
Normal file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
sys.path.append('../../../build_tools/scripts')
|
||||
import base
|
||||
import os
|
||||
|
||||
#compilation_level = "WHITESPACE_ONLY"
|
||||
compilation_level = "SIMPLE_OPTIMIZATIONS"
|
||||
base.cmd("java", ["-jar", "../../build/node_modules/google-closure-compiler-java/compiler.jar",
|
||||
"--compilation_level", compilation_level,
|
||||
"--js_output_file", "embed.min.js",
|
||||
"--js", "embed.js"])
|
||||
|
||||
@ -1614,6 +1614,7 @@
|
||||
t.clear(true);
|
||||
|
||||
t.isNoClearOnFocus = false;
|
||||
t.Api.isBlurEditor = false;
|
||||
|
||||
var _nativeFocusElementNoRemoveOnElementFocus = t.nativeFocusElementNoRemoveOnElementFocus;
|
||||
t.nativeFocusElementNoRemoveOnElementFocus = false;
|
||||
|
||||
@ -1135,6 +1135,7 @@
|
||||
|
||||
t.isNoClearOnFocus = false;
|
||||
*/
|
||||
t.Api.isBlurEditor = false;
|
||||
|
||||
var _nativeFocusElementNoRemoveOnElementFocus = t.nativeFocusElementNoRemoveOnElementFocus;
|
||||
t.nativeFocusElementNoRemoveOnElementFocus = false;
|
||||
|
||||
@ -1996,10 +1996,17 @@ function CDrawingDocument()
|
||||
};
|
||||
this.DrawTarget = function()
|
||||
{
|
||||
if (0 != oThis.SlidesCount && "block" != oThis.TargetHtmlElement.style.display && oThis.NeedTarget && !oThis.TransitionSlide.IsPlaying())
|
||||
oThis.TargetHtmlElement.style.display = "block";
|
||||
else
|
||||
oThis.TargetHtmlElement.style.display = "none";
|
||||
let isNeedTarget = (0 != oThis.SlidesCount) && oThis.NeedTarget && !oThis.TransitionSlide.IsPlaying();
|
||||
let isShow = false;
|
||||
if (isNeedTarget)
|
||||
{
|
||||
if (oThis.m_oWordControl.m_oApi.isBlurEditor)
|
||||
isShow = true;
|
||||
else if ("block" != oThis.TargetHtmlElement.style.display)
|
||||
isShow = true;
|
||||
}
|
||||
|
||||
oThis.TargetHtmlElement.style.display = isShow ? "block" : "none";
|
||||
};
|
||||
this.TargetShow = function()
|
||||
{
|
||||
|
||||
@ -3546,9 +3546,12 @@ function CDrawingDocument()
|
||||
};
|
||||
this.DrawTarget = function ()
|
||||
{
|
||||
if (oThis.NeedTarget && oThis.m_oWordControl.IsFocus)
|
||||
if (oThis.NeedTarget)
|
||||
{
|
||||
oThis.showTarget(!oThis.isShowTarget());
|
||||
if (oThis.m_oWordControl.IsFocus && !oThis.m_oWordControl.m_oApi.isBlurEditor)
|
||||
oThis.showTarget(!oThis.isShowTarget());
|
||||
else
|
||||
oThis.showTarget(true);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user