[pdf] Added list of values for pdf forms

This commit is contained in:
Nikita Khromov 2022-12-12 15:36:08 +05:00
parent 3ddbc065e9
commit 89aa44476a
4 changed files with 2310 additions and 30077 deletions

View file

@ -229,6 +229,7 @@ define([
this.api.asc_registerCallback('asc_onShowContentControlsActions',_.bind(this.onShowContentControlsActions, this)); this.api.asc_registerCallback('asc_onShowContentControlsActions',_.bind(this.onShowContentControlsActions, this));
this.api.asc_registerCallback('asc_onHideContentControlsActions',_.bind(this.onHideContentControlsActions, this)); this.api.asc_registerCallback('asc_onHideContentControlsActions',_.bind(this.onHideContentControlsActions, this));
} }
this.api.asc_registerCallback('asc_onShowPDFFormsActions',_.bind(this.onShowFormsPDFActions, this));
this.documentHolder.setApi(this.api); this.documentHolder.setApi(this.api);
} }
@ -1477,6 +1478,76 @@ define([
}, 10); }, 10);
this._fromShowContentControls = false; this._fromShowContentControls = false;
}, },
onShowListActionsPDF: function(obj) {
var type = obj.type,
isForm = true,
cmpEl = this.documentHolder.cmpEl,
menu = this.listControlMenu,
menuContainer = menu ? cmpEl.find(Common.Utils.String.format('#menu-container-{0}', menu.id)) : null,
me = this;
me._listObj = obj;
this._fromShowContentControls = true;
Common.UI.Menu.Manager.hideAll();
if (!menu) {
this.listControlMenu = menu = new Common.UI.Menu({
maxHeight: 207,
menuAlign: 'tr-bl',
items: []
});
menu.on('item:click', function(menu, item) {
setTimeout(function(){
(item.value!==-1) && me.api.asc_SelectPDFFormListItem(item.value);
}, 1);
});
// Prepare menu container
if (!menuContainer || menuContainer.length < 1) {
menuContainer = $(Common.Utils.String.format('<div id="menu-container-{0}" style="position: absolute; z-index: 10000;"><div class="dropdown-toggle" data-toggle="dropdown"></div></div>', menu.id));
cmpEl.append(menuContainer);
}
menu.render(menuContainer);
menu.cmpEl.attr({tabindex: "-1"});
menu.on('hide:after', function(){
me.listControlMenu.removeAll();
if (!me._fromShowContentControls)
me.api.asc_UncheckContentControlButtons();
});
}
var count = obj._options.length;
for (var i=0; i<count; i++) {
menu.addItem(new Common.UI.MenuItem({
caption : obj._options[i],
value : i,
template : _.template([
'<a id="<%= id %>" style="<%= style %>" tabindex="-1" type="menuitem">',
'<%= Common.Utils.String.htmlEncode(caption) %>',
'</a>'
].join(''))
}));
}
if (!isForm && menu.items.length<1) {
menu.addItem(new Common.UI.MenuItem({
caption : this.documentHolder.txtEmpty,
value : -1
}));
}
let X = (obj._pagePos.realX + obj._pagePos.w) / AscCommon.AscBrowser.retinaPixelRatio;
let Y = (obj._pagePos.realY + obj._pagePos.h) / AscCommon.AscBrowser.retinaPixelRatio;
menuContainer.css({left: X, top : Y});
menuContainer.attr('data-value', 'prevent-canvas-click');
this._preventClick = true;
menu.show();
_.delay(function() {
menu.cmpEl.focus();
}, 10);
this._fromShowContentControls = false;
},
onShowContentControlsActions: function(obj, x, y) { onShowContentControlsActions: function(obj, x, y) {
var type = obj.type; var type = obj.type;
@ -1502,6 +1573,13 @@ define([
break; break;
} }
}, },
onShowFormsPDFActions: function(obj, x, y) {
switch (obj.type) {
case AscPDFEditor.FIELD_TYPE.combobox:
this.onShowListActionsPDF(obj, x, y);
break;
}
},
onApiLockDocumentProps: function() { onApiLockDocumentProps: function() {
this._state.lock_doc = true; this._state.lock_doc = true;

16228
build/package-lock.json generated

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff