From 246295386b22f258dd7bea7033fd60ceeeb5f0aa Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 28 Jun 2021 14:51:32 +0300 Subject: [PATCH 1/5] [SSE] Show user's cursor on co-editing --- .../main/app/controller/DocumentHolder.js | 80 ++++++++++++++++--- 1 file changed, 67 insertions(+), 13 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 657726150..1efa49d4b 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -114,6 +114,8 @@ define([ me._currentParaObjDisabled = false; me._isDisabled = false; me._state = {}; + me.fastcoauthtips = []; + me._TtHeight = 20; /** coauthoring begin **/ this.wrapEvents = { apiHideComment: _.bind(this.onApiHideComment, this) @@ -332,6 +334,9 @@ define([ this.api.asc_registerCallback('asc_onTableTotalMenu', _.bind(this.onTableTotalMenu, this)); this.api.asc_registerCallback('asc_onShowPivotGroupDialog', _.bind(this.onShowPivotGroupDialog, this)); } + this.api.asc_registerCallback('asc_onShowForeignCursorLabel', _.bind(this.onShowForeignCursorLabel, this)); + this.api.asc_registerCallback('asc_onHideForeignCursorLabel', _.bind(this.onHideForeignCursorLabel, this)); + return this; }, @@ -1129,17 +1134,6 @@ define([ } } // show tooltips - /** coauthoring begin **/ - var getUserName = function(id){ - var usersStore = SSE.getCollection('Common.Collections.Users'); - if (usersStore){ - var rec = usersStore.findUser(id); - if (rec) - return AscCommon.UserInfoParser.getParsedName(rec.get('username')); - } - return me.guestText; - }; - /** coauthoring end **/ if (index_hyperlink) { if (!hyperlinkTip.parentEl) { @@ -1305,7 +1299,7 @@ define([ if (showPoint[1] >= coAuthTip.XY[1] && showPoint[1] + coAuthTip.ttHeight < coAuthTip.XY[1] + coAuthTip.apiHeight) { - src.text(getUserName(data.asc_getUserId())); + src.text(me.getUserName(data.asc_getUserId())); if (coAuthTip.bodyWidth - showPoint[0] < coAuthTip.ref.width() ) { src.css({ visibility : 'visible', @@ -3617,7 +3611,67 @@ define([ win.setActiveCategory(2); } }, - + + onShowForeignCursorLabel: function(UserId, X, Y, color) { + /** coauthoring begin **/ + var src; + var me = this; + for (var i=0; i Date: Mon, 28 Jun 2021 16:06:32 +0300 Subject: [PATCH 2/5] [SSE] Bugfix --- .../main/app/controller/DocumentHolder.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 1efa49d4b..90484adbb 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -3631,17 +3631,6 @@ define([ 'background-color': '#'+Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b())}); src.text(me.getUserName(UserId)); - - src.css({ - height : coAuthTip.ttHeight + 'px', - position : 'absolute', - zIndex : '900', - visibility : 'visible' - }); - $(document.body).append(src); - - - $('#editor_sdk').append(src); me.fastcoauthtips.push(src); src.fadeIn(150); From 108ed183d57d8fd7bbd71672701ee14cb73bf5f0 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 28 Jul 2021 22:13:08 +0300 Subject: [PATCH 3/5] [SSE] Show name for foreign user --- .../main/app/controller/DocumentHolder.js | 65 ++++++++++++++++++- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 90484adbb..22dc66a58 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -104,7 +104,10 @@ define([ }, filter: {ttHeight: 40}, func_arg: {}, - input_msg: {} + input_msg: {}, + foreignSelect: { + ttHeight: 20 + } }; me.mouse = {}; me.popupmenu = false; @@ -162,10 +165,12 @@ define([ }, 'modal:show': function(e){ me.hideCoAuthTips(); + me.hideForeignSelectTips(); }, 'layout:changed': function(e){ me.hideHyperlinkTip(); me.hideCoAuthTips(); + me.hideForeignSelectTips(); me.onDocumentResize(); }, 'cells:range': function(status){ @@ -1022,6 +1027,15 @@ define([ } }, + hideForeignSelectTips: function() { + if (this.tooltips.foreignSelect.ref) { + $(this.tooltips.foreignSelect.ref).remove(); + this.tooltips.foreignSelect.ref = undefined; + this.tooltips.foreignSelect.x_point = undefined; + this.tooltips.foreignSelect.y_point = undefined; + } + }, + hideHyperlinkTip: function() { if (!this.tooltips.hyperlink.isHidden && this.tooltips.hyperlink.ref) { this.tooltips.hyperlink.ref.hide(); @@ -1040,7 +1054,8 @@ define([ index_locked, index_column, index_row, index_filter, - index_slicer; + index_slicer, + index_foreign; for (var i = dataarray.length; i > 0; i--) { switch (dataarray[i-1].asc_getType()) { case Asc.c_oAscMouseMoveType.Hyperlink: @@ -1066,6 +1081,9 @@ define([ case Asc.c_oAscMouseMoveType.Tooltip: index_slicer = i; break; + case Asc.c_oAscMouseMoveType.ForeignSelect: + index_foreign = i; + break; } } @@ -1079,6 +1097,7 @@ define([ row_columnTip = me.tooltips.row_column, filterTip = me.tooltips.filter, slicerTip = me.tooltips.slicer, + foreignSelect = me.tooltips.foreignSelect, pos = [ me.documentHolder.cmpEl.offset().left - $(window).scrollLeft(), me.documentHolder.cmpEl.offset().top - $(window).scrollTop() @@ -1116,6 +1135,9 @@ define([ if (!index_locked) { me.hideCoAuthTips(); } + if (!index_foreign) { + me.hideForeignSelectTips(); + } if (index_slicer===undefined) { if (!slicerTip.isHidden && slicerTip.ref) { slicerTip.ref.hide(); @@ -1315,6 +1337,45 @@ define([ } } } + if (index_foreign) { + data = dataarray[index_foreign-1]; + + if (!coAuthTip.XY) + me.onDocumentResize(); + + if (foreignSelect.x_point != data.asc_getX() || foreignSelect.y_point != data.asc_getY()) { + me.hideForeignSelectTips(); + + foreignSelect.x_point = data.asc_getX(); + foreignSelect.y_point = data.asc_getY(); + + var src = $(document.createElement("div")), + color = new AscCommon.CColor(255, 0,255);//data.asc_getColor(); + foreignSelect.ref = src; + + src.addClass('username-tip'); + src.css({ + height : foreignSelect.ttHeight + 'px', + position : 'absolute', + zIndex : '900', + visibility : 'visible', + 'background-color': '#'+Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()) + }); + $(document.body).append(src); + + showPoint = [ + foreignSelect.x_point + coAuthTip.XY[0], + foreignSelect.y_point + coAuthTip.XY[1] - foreignSelect.ttHeight + ]; + + src.text(me.getUserName(data.asc_getUserId())); + src.css({ + visibility : 'visible', + left : ((showPoint[0]+foreignSelect.ref.width()>coAuthTip.bodyWidth) ? coAuthTip.bodyWidth-foreignSelect.ref.width() : showPoint[0]) + 'px', + top : showPoint[1] + 'px' + }); + } + } } if (index_filter!==undefined && !(me.dlgFilter && me.dlgFilter.isVisible()) && !(me.currentMenu && me.currentMenu.isVisible()) && !dataarray[index_filter-1].asc_getFilter().asc_getPivotObj()) { From f469783c3865b619f5b72cb97f3dcf456d208f27 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 30 Jul 2021 16:14:30 +0300 Subject: [PATCH 4/5] [SSE] Show user color for selected cell --- apps/spreadsheeteditor/main/app/controller/DocumentHolder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 22dc66a58..c88cfbe92 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -1350,7 +1350,7 @@ define([ foreignSelect.y_point = data.asc_getY(); var src = $(document.createElement("div")), - color = new AscCommon.CColor(255, 0,255);//data.asc_getColor(); + color = data.asc_getColor(); foreignSelect.ref = src; src.addClass('username-tip'); From dc084a1d0a7de95de247b2d10d7cb133d0f1d206 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 30 Jul 2021 17:41:35 +0300 Subject: [PATCH 5/5] [SSE] Fix foreign cursor position --- .../main/app/controller/DocumentHolder.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index c88cfbe92..aaa81b2dc 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -1322,7 +1322,7 @@ define([ if (showPoint[1] >= coAuthTip.XY[1] && showPoint[1] + coAuthTip.ttHeight < coAuthTip.XY[1] + coAuthTip.apiHeight) { src.text(me.getUserName(data.asc_getUserId())); - if (coAuthTip.bodyWidth - showPoint[0] < coAuthTip.ref.width() ) { + if (coAuthTip.bodyWidth - showPoint[0] < coAuthTip.ref.outerWidth() ) { src.css({ visibility : 'visible', left : '0px', @@ -1371,7 +1371,7 @@ define([ src.text(me.getUserName(data.asc_getUserId())); src.css({ visibility : 'visible', - left : ((showPoint[0]+foreignSelect.ref.width()>coAuthTip.bodyWidth) ? coAuthTip.bodyWidth-foreignSelect.ref.width() : showPoint[0]) + 'px', + left : ((showPoint[0]+foreignSelect.ref.outerWidth()>coAuthTip.bodyWidth-coAuthTip.rightMenuWidth) ? coAuthTip.bodyWidth-coAuthTip.rightMenuWidth-foreignSelect.ref.outerWidth() : showPoint[0]) + 'px', top : showPoint[1] + 'px' }); } @@ -3683,6 +3683,11 @@ define([ break; } } + var coAuthTip = this.tooltips.coauth; + if (X<0 || X+coAuthTip.XY[0]>coAuthTip.bodyWidth-coAuthTip.rightMenuWidth || Y<0 || Y>coAuthTip.apiHeight) { + src && this.onHideForeignCursorLabel(UserId); + return; + } if (!src) { src = $(document.createElement("div")); @@ -3696,7 +3701,10 @@ define([ me.fastcoauthtips.push(src); src.fadeIn(150); } - src.css({top: (Y-me._TtHeight) + 'px', left: X + 'px'}); + src.css({ + left : ((X+coAuthTip.XY[0]+src.outerWidth()>coAuthTip.bodyWidth-coAuthTip.rightMenuWidth) ? coAuthTip.bodyWidth-coAuthTip.rightMenuWidth-src.outerWidth()-coAuthTip.XY[0] : X) + 'px', + top : (Y-me._TtHeight) + 'px' + }); /** coauthoring end **/ },