Skip to content

Commit

Permalink
Merge pull request #2946 from ONLYOFFICE/fix/pdf-remove-annot
Browse files Browse the repository at this point in the history
Fix/pdf remove annot
  • Loading branch information
JuliaRadzhabova authored Apr 18, 2024
2 parents f2b679e + 8965860 commit 8b8d63a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
23 changes: 21 additions & 2 deletions apps/pdfeditor/main/app/controller/DocumentHolder.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ define([
if (type==='pdf') {
view.menuPDFViewCopy.on('click', _.bind(me.onCutCopyPaste, me));
view.menuAddComment.on('click', _.bind(me.addComment, me));
view.menuRemoveComment.on('click', _.bind(me.removeComment, me));
} else if (type==='forms') {
view.menuPDFFormsUndo.on('click', _.bind(me.onUndo, me));
view.menuPDFFormsRedo.on('click', _.bind(me.onRedo, me));
Expand All @@ -239,6 +240,7 @@ define([
} else if (type==='edit') {
view.menuPDFEditCopy.on('click', _.bind(me.onCutCopyPaste, me));
view.menuEditAddComment.on('click', _.bind(me.addComment, me));
view.menuEditRemoveComment.on('click', _.bind(me.removeComment, me));
/*
var diagramEditor = this.getApplication().getController('Common.Controllers.ExternalDiagramEditor').getView('Common.Views.ExternalDiagramEditor');
if (diagramEditor) {
Expand Down Expand Up @@ -395,7 +397,16 @@ define([
var documentHolder = this.documentHolder;
if (!documentHolder.viewPDFModeMenu)
documentHolder.createDelayedElementsPDFViewer();
return {menu_to_show: documentHolder.viewPDFModeMenu, menu_props: {}};

var menu_props = {};
selectedElements && _.each(selectedElements, function(element, index) {
if (Asc.c_oAscTypeSelectElement.Annot == element.get_ObjectType()) {
menu_props.annotProps = {};
menu_props.annotProps.value = element.get_ObjectValue();
}
});

return {menu_to_show: documentHolder.viewPDFModeMenu, menu_props: menu_props};
},

fillPDFEditMenuProps: function(selectedElements) {
Expand Down Expand Up @@ -453,6 +464,10 @@ define([
menu_props.mathProps = {};
menu_props.mathProps.value = elValue;
documentHolder._currentMathObj = elValue;
} else if (Asc.c_oAscTypeSelectElement.Annot == elType) {
menu_to_show = documentHolder.editPDFModeMenu;
menu_props.annotProps = {};
menu_props.annotProps.value = elValue;
}
});
if (menu_to_show === null) {
Expand Down Expand Up @@ -515,7 +530,7 @@ define([
showObjectMenu: function(event, docElement, eOpts){
var me = this;
if (me.api){
var obj = me.mode && me.mode.isRestrictedEdit ? (event.get_Type() == 0 ? me.fillFormsMenuProps(me.api.getSelectedElements()) : null) : (me.mode && me.mode.isEdit && me.mode.isPDFEdit ? me.fillPDFEditMenuProps(me.api.getSelectedElements()) : me.fillViewMenuProps());
var obj = me.mode && me.mode.isRestrictedEdit ? (event.get_Type() == 0 ? me.fillFormsMenuProps(me.api.getSelectedElements()) : null) : (me.mode && me.mode.isEdit && me.mode.isPDFEdit ? me.fillPDFEditMenuProps(me.api.getSelectedElements()) : me.fillViewMenuProps(me.api.getSelectedElements()));
if (obj) me.showPopupMenu(obj.menu_to_show, obj.menu_props, event, docElement, eOpts);
}
},
Expand Down Expand Up @@ -1110,6 +1125,10 @@ define([
}
},

removeComment: function(item, e, eOpt){
this.api && this.api.asc_remove();
},

onCutCopyPaste: function(item, e) {
var me = this;
if (me.api) {
Expand Down
21 changes: 18 additions & 3 deletions apps/pdfeditor/main/app/view/DocumentHolder.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,22 @@ define([
caption : me.addCommentText
});

me.menuRemoveComment = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-cc-remove',
caption : me.removeCommentText
});

this.viewPDFModeMenu = new Common.UI.Menu({
cls: 'shifted-right',
initMenu: function (value) {
me.menuPDFViewCopy.setDisabled(!(me.api && me.api.can_CopyCut()));
me.menuAddComment.setVisible(me.mode && me.mode.canComments);
me.menuRemoveComment.setVisible(value && value.annotProps && value.annotProps.value);
},
items: [
me.menuPDFViewCopy,
me.menuAddComment
me.menuAddComment,
me.menuRemoveComment
]
}).on('hide:after', function (menu, e, isFromInputControl) {
me.clearCustomItems(menu);
Expand Down Expand Up @@ -139,15 +146,22 @@ define([
caption : me.addCommentText
});

me.menuEditRemoveComment = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-cc-remove',
caption : me.removeCommentText
});

this.editPDFModeMenu = new Common.UI.Menu({
cls: 'shifted-right',
initMenu: function (value) {
me.menuPDFEditCopy.setDisabled(!(me.api && me.api.can_CopyCut()));
me.menuEditAddComment.setVisible(me.mode && me.mode.canComments);
me.menuEditRemoveComment.setVisible(value && value.annotProps && value.annotProps.value);
},
items: [
me.menuPDFEditCopy,
me.menuEditAddComment
me.menuEditAddComment,
me.menuEditRemoveComment
]
}).on('hide:after', function (menu, e, isFromInputControl) {
me.clearCustomItems(menu);
Expand Down Expand Up @@ -2362,7 +2376,8 @@ define([
txtDeletePage: 'Delete page',
txtNewPage: 'Insert blank page',
txtRotateRight: 'Rotate page right',
txtRotateLeft: 'Rotate page left'
txtRotateLeft: 'Rotate page left',
removeCommentText: 'Remove'

}, PDFE.Views.DocumentHolder || {}));
});
1 change: 1 addition & 0 deletions apps/pdfeditor/main/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,7 @@
"PDFE.Views.DocumentHolder.txtNewPage": "Insert blank page",
"PDFE.Views.DocumentHolder.txtRotateRight": "Rotate page right",
"PDFE.Views.DocumentHolder.txtRotateLeft": "Rotate page left",
"PDFE.Views.DocumentHolder.removeCommentText": "Remove",
"PDFE.Views.FileMenu.btnBackCaption": "Open File Location",
"PDFE.Views.FileMenu.btnCloseEditor": "Close File",
"PDFE.Views.FileMenu.btnCloseMenuCaption": "Close Menu",
Expand Down

0 comments on commit 8b8d63a

Please sign in to comment.