Skip to content

Commit

Permalink
Enable special paste for unprotected regions
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliaRadzhabova committed Jan 23, 2025
1 parent 7c21a51 commit 0dd7b78
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
7 changes: 7 additions & 0 deletions apps/documenteditor/main/app/controller/DocumentHolder.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,13 @@ define([
} else if (type === Asc.c_oAscTypeSelectElement.Paragraph || type === Asc.c_oAscTypeSelectElement.Table || type === Asc.c_oAscTypeSelectElement.Header) {
var value = selectedElements[i].get_ObjectValue();
value && (locked = locked || value.get_Locked());
} else if (type === Asc.c_oAscTypeSelectElement.UnProtectedRegion) { //(unprotected region)
var value = selectedElements[i].get_ObjectValue();
me.documentHolder._unprotectedRegion = {
canEditText: value.get_canEditText(),
canEditPara: value.get_canEditPara(),
canInsObject: value.get_canInsObject()
};
}
}
if (in_equation) {
Expand Down
6 changes: 4 additions & 2 deletions apps/documenteditor/main/app/controller/DocumentHolderExt.js
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,8 @@ define([], function () {
dh.disableSpecialPaste = function() {
var pasteContainer = this.documentHolder.cmpEl.find('#special-paste-container'),
docProtection = this.documentHolder._docProtection,
disabled = this._isDisabled || docProtection.isReadOnly || docProtection.isCommentsOnly;
unprotectedRegion = this.documentHolder._unprotectedRegion,
disabled = this._isDisabled || docProtection.isReadOnly && !unprotectedRegion.canInsObject || docProtection.isCommentsOnly && !unprotectedRegion.canInsObject;

if (pasteContainer.length>0 && pasteContainer.is(':visible')) {
this.btnSpecialPaste.setDisabled(!!disabled);
Expand Down Expand Up @@ -2276,7 +2277,8 @@ define([], function () {
dh.disableEquationBar = function() {
var eqContainer = this.documentHolder.cmpEl.find('#equation-container'),
docProtection = this.documentHolder._docProtection,
disabled = this._isDisabled || this._state.equationLocked || docProtection.isReadOnly || docProtection.isFormsOnly || docProtection.isCommentsOnly;
unprotectedRegion = this.documentHolder._unprotectedRegion,
disabled = this._isDisabled || this._state.equationLocked || docProtection.isReadOnly && !unprotectedRegion.canInsObject || docProtection.isFormsOnly || docProtection.isCommentsOnly && !unprotectedRegion.canInsObject;

if (eqContainer.length>0 && eqContainer.is(':visible')) {
this.equationBtns.forEach(function(item){
Expand Down
5 changes: 5 additions & 0 deletions apps/documenteditor/main/app/view/DocumentHolder.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ define([
isFormsOnly: false,
isCommentsOnly: false
};
this._unprotectedRegion = {
canEditText: false,
canEditPara: false,
canInsObject: false
};
this._langs = null;
},

Expand Down
2 changes: 1 addition & 1 deletion apps/documenteditor/main/app/view/DocumentHolderExt.js
Original file line number Diff line number Diff line change
Expand Up @@ -2134,7 +2134,7 @@ define([], function () {
}

me.menuViewUndo.setVisible(me.mode.canCoAuthoring && me.mode.canComments && !me._isDisabled);
me.menuViewUndo.setDisabled(!me.api.asc_getCanUndo() || me._docProtection.isReadOnly);
me.menuViewUndo.setDisabled(!me.api.asc_getCanUndo());
me.menuViewCopySeparator.setVisible(isInSign);

var isRequested = (signProps) ? signProps.asc_getRequested() : false;
Expand Down

0 comments on commit 0dd7b78

Please sign in to comment.