Code: Select all
const buttonName = this.baseListServices.i18nService.translate(_('document.save-to-assets'))
let userButton = (this.viewer.jsObject as any).SmallButton("none", buttonName, "none"); // (name, captionText, imageName, toolTip, arrow, styleName);
// userButton.image.src = "assets/icons/saveAsstes.png";
userButton.image.src = "assets/icons/box-archive-solid.svg";
userButton.name = "saveToAssets"; // It is the name of the button
userButton.tooltip = this.baseListServices.i18nService.translate(_('document.save-to-assets')); // It is the tooltip of the button
userButton.arrow = true; // It means that the button has no drop-down menu
// userButton.action = function () { alert("My Button Event"); }
userButton.onclick = async () => { await this.saveToDoducmentAssets() };
let toolbarTable = this.viewer.jsObject.controls.toolbar.firstChild.firstChild; // It is the toolbar table
let buttonsTable = toolbarTable.rows[0].firstChild.firstChild; // It is the table with buttons
// console.log(buttonsTable);
let userButtonCell = buttonsTable.rows[0].insertCell(0); // It is the cell for the new button
userButtonCell.className = "stiJsViewerClearAllStyles"; // It is the class for the new button
userButtonCell.appendChild(userButton); // Add the new button to the cell