Skip to content

Commit

Permalink
Feature/native socket (#3149)
Browse files Browse the repository at this point in the history
* Add class for native socket

* Change event message to object

* Send auth information to native socket engine

* Release/v7.3.0 (#3147)

* Add new version of AutoCorrection method

* Fix autocorrection method

* Improve AutoCorrection method

* Improve AutoCorrection process

* Improve AutoCorrection method
+ now GetTextForAutoCorrection can process content with any length

* Fix work of AutoCorrection method
+ Change Unicode radical parser processing

* Refactor and update AutoCorrection method

* Fix AutoCorrection Degree and cursor position

* Refactor and fix math selection

* Fix and refactor autocorrection method

* Add "chain" auto-correction mode, refactor

* Fix ContentPos on auto-correction

* Fix LaTeX autocorrection

* Fix auto-correction processing

* Fix auto-correction processing
+ fix content delete on auto-correction
+ add delete space char on proceed auto-correction block
+ fix setting CurPos of content
+ refactor

* Fix auto-correction
+ add IsStartAutoCorrection method that an auto-correction trigger
+ fix Unicode processing of matrix and degree
+ fix CDegree, CDegreeSubSup, CFraction, CDelimiter GetTextOfElement methods

* Fix auto-correction
+ add tests for auto-correction
+ refactor code
+ delete previous version of auto-correction

* [de] Fix work of math autocorrection
+ Add tests for math autocorrection
+ Fix Unicode parser -GetOperandLiteral
+ Refactor code

* [de] Add more tests
+ fix processing of dot and comma
+ fix processing of Unicode symbols in autocorrection
+ fix CMathText.GetTextOfElement
+ add OtherLiteral (greek alphabet, math symbols etc.) in ConvertTokens function
+ fix CRadical.GetTextOfElement method
+ fix radical's Unicode parsing

* [de] Improve the work of math conversion
+ add CMathContent.GetInfoForAutoCorrection method
+ fix CMathText.GetTextOfElement
+ fix ConvertTokens.NaryLiteral
+ Add several methods to ParaRun to service the autocorrection math (MathAutocorrection_GetBracketsInfo, MathAutocorrection_GetOperatorInfo, MathAutocorrection_GetSlashesInfo,MathAutocorrection_IsLastElementOperator)
+ refactor Unicode and LaTeX parsers

* [de] Improve work of math Autocorrection
+Add ParaRun MathAutocorrection_IsLastElementLBracket, MathAutocorrection_IsLastElementRBracket methods
+Correct trigger function for autocorrection
+Rewrite processing of brackets for autocorrection
+Add more rules
+Add more tests

* [de] Redesign parentheses processing
+ Fix CRadical, CMathFunc, ParaRun GetTextOfElement method
+ Add mode tests for autocorrection
+ Add method to convert content of brackets, but not the parenthesis block itself
+ Remove obsolete math-autocorrect code
+ Fix processing of Unicode Rect, Radicals and Closer

* [de] Fix math selection after merge

* [de] Fix after merges

* Fix bug #59880

* [se] Fix bug 48891

* [pe] remove unused checks in viewPr marks drawing

* [bug] fix bug 56928

* [pe] refactoring update interface method

* [de] Prepare autocorrection method

* [pe] speed up grid drawing

* [pe] fix grid drawing

* [bug][pe] fix updating paragraph properties

* [pe][bug] fix resize tables in presentation

* [de] Rework saving/loading view position when applying collaboration changes

* [de] Fix the problem with fast updating view position

* [pe] fix table styles previews in pe

* [de][bug] for bug 42649: improve editing of watermarks which come from files created in MS Word:
* now we think that font size below 36 is auto
* compare watermark properties on applying and don't apply equal ones

* [de] Delete unnecessary file

Co-authored-by: EvgeniyIgol <[email protected]>
Co-authored-by: GoshaZotov <[email protected]>
Co-authored-by: Sergey Luzyanin <[email protected]>
Co-authored-by: KirillovIlya <[email protected]>

* Fix craches in native apps

* Fix crash in native

Co-authored-by: EvgeniyIgol <[email protected]>
Co-authored-by: GoshaZotov <[email protected]>
Co-authored-by: Sergey Luzyanin <[email protected]>
Co-authored-by: KirillovIlya <[email protected]>
  • Loading branch information
5 people authored Dec 6, 2022
1 parent be10506 commit 29686a1
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 41 deletions.
2 changes: 1 addition & 1 deletion cell/native/native.js
Original file line number Diff line number Diff line change
Expand Up @@ -6441,7 +6441,7 @@ window["native"]["offline_apply_event"] = function(type,params) {

case 10020: // ASC_SOCKET_EVENT_TYPE_MESSAGE
{
_api.CoAuthoringApi._CoAuthoringApi._onServerMessage(params);
_api.CoAuthoringApi._CoAuthoringApi._onServerMessage(params ? JSON.parse(params) : {});
break;
}

Expand Down
7 changes: 6 additions & 1 deletion common/Native/Wrappers/DrawingDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -2929,7 +2929,12 @@ CDrawingDocument.prototype =
}

return null;
}
},

GetVisibleRegion : function()
{
return null;
}
};

function check_KeyboardEvent(e)
Expand Down
4 changes: 4 additions & 0 deletions common/Native/Wrappers/HtmlPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ function CEditorPage(api)
{
};

this.ScrollToAbsolutePosition = function(x, y, PageNum, isBottom)
{
};

this.onButtonTabsClick = function()
{
};
Expand Down
2 changes: 1 addition & 1 deletion common/Native/Wrappers/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2490,7 +2490,7 @@ Asc['asc_docs_api'].prototype["Call_Menu_Event"] = function(type, _params)

case 10020: // ASC_SOCKET_EVENT_TYPE_MESSAGE
{
_api.CoAuthoringApi._CoAuthoringApi._onServerMessage(_params);
_api.CoAuthoringApi._CoAuthoringApi._onServerMessage(_params ? JSON.parse(_params) : {});
break;
}

Expand Down
101 changes: 64 additions & 37 deletions common/docscoapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -1761,49 +1761,76 @@
});
};

function CNativeSocket(settings)
{
this.engine = window['SockJS'];
this.settings = settings;
this.io = this;
this.settings["type"] = "socketio";
}
CNativeSocket.prototype.open = function() { return this.engine.open(this.settings); };
CNativeSocket.prototype.send = function(message) { return this.engine.send(message); };
CNativeSocket.prototype.close = function() { return this.engine.close(); };
CNativeSocket.prototype.emit = function(message, data) { return this.send(JSON.stringify(data)); };

CNativeSocket.prototype.reconnectionAttempts = function(val) { this.settings["reconnectionAttempts"] = val; };
CNativeSocket.prototype.reconnectionDelay = function(val) { this.settings["reconnectionDelay"] = val; };
CNativeSocket.prototype.reconnectionDelayMax = function(val) { this.settings["reconnectionDelayMax"] = val; };
CNativeSocket.prototype.randomizationFactor = function(val) { this.settings["randomizationFactor"] = val; };

DocsCoApi.prototype._initSocksJs = function () {
var t = this;
let socket;
if (window['IS_NATIVE_EDITOR']) {
//todo native
// sockjs = this.sockjs = window['SockJS'];
// sockjs.open();
socket = this.sockjs = new CNativeSocket({
"path": this.socketio_url,
"transports": ["websocket", "polling"],
"closeOnBeforeunload": false,
"reconnectionAttempts": 15,
"reconnectionDelay": 500,
"reconnectionDelayMax": 10000,
"randomizationFactor": 0.5,
"auth": {
"token": this.jwtOpen
}
});
socket.open();
} else {
let io = AscCommon.getSocketIO();
socket = io({
"path": this.socketio_url,
"transports": ["websocket", "polling"],
"closeOnBeforeunload": false,
"reconnectionAttempts": 15,
"reconnectionDelay": 500,
"reconnectionDelayMax": 10000,
"randomizationFactor": 0.5,
"auth": {
"token": this.jwtOpen
}
});
socket.on("connect", function () {
t._onServerOpen();
});
socket.on("message", function (data) {
t._onServerMessage(data);
});
socket.on("error", function (data) {
console.error("socket.error:" + JSON.stringify(data));
});
socket.on("disconnect", function (reason) {
t._onServerClose(false, reason);
});
socket.io.on("reconnect_failed", () => {
t._onServerClose(true);
});
socket.io.engine.on('close', (event) => {
if (event === "forced close") {
t._onServerClose(true);
}
});
let io = AscCommon.getSocketIO();
socket = io({
"path": this.socketio_url,
"transports": ["websocket", "polling"],
"closeOnBeforeunload": false,
"reconnectionAttempts": 15,
"reconnectionDelay": 500,
"reconnectionDelayMax": 10000,
"randomizationFactor": 0.5,
"auth": {
"token": this.jwtOpen
}
});
socket.on("connect", function () {
t._onServerOpen();
});
socket.on("message", function (data) {
t._onServerMessage(data);
});
socket.on("error", function (data) {
console.error("socket.error:" + JSON.stringify(data));
});
socket.on("disconnect", function (reason) {
t._onServerClose(false, reason);
});
socket.io.on("reconnect_failed", () => {
t._onServerClose(true);
});
socket.io.engine.on('close', (event) => {
if (event === "forced close") {
t._onServerClose(true);
}
this.socketio = socket;
});
}
this.socketio = socket;

return socket;
};
Expand Down
2 changes: 1 addition & 1 deletion slide/Native/Wrappers/native.js
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,7 @@ Asc['asc_docs_api'].prototype["Call_Menu_Event"] = function(type, _params)

case 10020: // ASC_SOCKET_EVENT_TYPE_MESSAGE
{
this.CoAuthoringApi._CoAuthoringApi._onServerMessage(_params);
this.CoAuthoringApi._CoAuthoringApi._onServerMessage(_params ? JSON.parse(_params) : {});
break;
}

Expand Down
2 changes: 2 additions & 0 deletions word/Editor/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -14708,6 +14708,8 @@ CDocument.prototype.private_StoreViewPositions = function(state)
}

let viewPort = this.DrawingDocument.GetVisibleRegion();
if (!viewPort)
return;

let selectionBounds = this.GetSelectionBounds();

Expand Down

0 comments on commit 29686a1

Please sign in to comment.