Merge pull request 'fix/bug-78267' (#835) from fix/bug-78267 into release/v9.2.0

Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/web-apps/pulls/835
This commit is contained in:
Oleg Korshul
2025-11-13 20:02:42 +00:00
7 changed files with 92 additions and 34 deletions

View File

@ -594,6 +594,10 @@ define([
// weight = range for main key + “cost” of extra keys
return keyIndex * 100 + extras;
}
if (first.ascShortcut.asc_IsLocked() && !second.ascShortcut.asc_IsLocked()) return -1;
if (!first.ascShortcut.asc_IsLocked() && second.ascShortcut.asc_IsLocked()) return 1;
let wFirst = getWeight(first.ascShortcut);
let wSecond = getWeight(second.ascShortcut);

View File

@ -81,7 +81,7 @@ define([
'<div class="recent-wrap">',
'<div class="recent-icon">',
'<div>',
'<svg><use href="#<% if (typeof format !== "undefined") { %><%= format %><% } else { %>blank<% } %>"></use></svg>',
'<svg><use href="#<% if (typeof format !== "undefined" && format && format.length > 0) { %><%= format %><% } else { %>neutral<% } %>"></use></svg>',
'<div class= <% if (typeof format !== "undefined") {%> "img-format-<%=format %>"<% } else {%> "svg-file-recent"<%} %>></div>',
'</div>',
'</div>',

View File

@ -103,7 +103,7 @@ define([
'</div>',
'<% if (action.isLocked) { %>',
'<button type="button" class="btn-toolbar">',
'<i class="icon options__icon toolbar__icon btn-lock icon-lock">&nbsp;</i>',
'<i class="icon options__icon toolbar__icon btn-lock icon-lock">&nbsp;</i>',
'</button>',
'<% } else { %>',
'<button type="button" class="action-edit btn-toolbar">',

View File

@ -97,13 +97,22 @@ define([
getFocusedComponents: function() {
const dynamicComponents = [];
this.shortcutsCollection.each(function(record) {
dynamicComponents.push(record.get('keysInput'), record.get('removeBtn'));
if(record.get('removeBtn')) {
dynamicComponents.push(record.get('keysInput'), record.get('removeBtn'));
}
});
return dynamicComponents.concat(this.getFooterButtons());
},
getDefaultFocusableComponent: function() {
return this.shortcutsCollection.at(0).get('keysInput');
const firstFocusableItem = this.shortcutsCollection.find(function(item) {
return item.get('removeBtn');
});
if(firstFocusableItem) {
return firstFocusableItem.get('keysInput');
} else {
return this.getFooterButtons()[0];
}
},
_setDefaults: function() {
@ -157,7 +166,7 @@ define([
},
/**
* Finds all actions that already have the given shortcut assigned.
* Finds all actions that currently use the specified shortcut and returns both the action and the shortcut.
*
* If `extraAction` is provided and its `extraAction.actionType` matches the current item,
* the method will check `extraAction.shortcuts` instead of the original shortcuts.
@ -167,7 +176,7 @@ define([
* @param {Object} [extraAction] Optional object that can replace the shortcuts of a matching action.
* @param {number} extraAction.actionType The type of the action to match.
* @param {CAscShortcut[]} extraAction.shortcuts Custom list of shortcuts to check for this action.
* @returns {Object[]} Array of action objects that already use the given shortcut.
* @returns {Object[]} Array of objects containing `action` and the matching `shortcut`.
*/
_findAssignedActions: function(ascShortcut, extraAction) {
const shortcutIndex = ascShortcut.asc_GetShortcutIndex();
@ -184,17 +193,20 @@ define([
item.shortcuts = extraAction.shortcuts;
}
const existsVisible = _.some(item.shortcuts, function(shortcut) {
const foundShortcut = _.find(item.shortcuts, function(shortcut) {
return shortcut.ascShortcut.asc_GetShortcutIndex() == shortcutIndex &&
!shortcut.ascShortcut.asc_IsHidden();
});
if (existsVisible) {
foundItems.push(item);
if (foundShortcut) {
foundItems.push({
action: item.action,
shortcut: foundShortcut
});
}
}
return _.map(foundItems, function(item) { return item.action; });
return foundItems;
},
/**
@ -230,9 +242,7 @@ define([
'<div class="item ' + (index == 0 ? 'first' : '') + '">' +
'<div class="keys-input"></div>' +
(isLocked
? '<button type="button" class="btn-toolbar">' +
'<i class="icon toolbar__icon btn-menu-about">&nbsp;</i>' +
'</button>'
? '<i class="lock-info-icon icon toolbar__icon btn-menu-about">&nbsp;</i>'
: '<button type="button" class="btn-toolbar remove-btn">' +
'<i class="icon toolbar__icon btn-cc-remove">&nbsp;</i>' +
'</button>'
@ -252,10 +262,21 @@ define([
placeHolder : me.txtInputPlaceholder,
disabled : isLocked
});
const removeButton = new Common.UI.Button({
el: $item.find('.remove-btn'),
});
item.set({ keysInput: keysInput, removeBtn: removeButton });
let removeButton;
if(isLocked) {
$item.find('.lock-info-icon').tooltip({
title: me.txtCantBeEdited,
placement: 'cursor',
zIndex : parseInt(me.$window.css('z-index')) + 10
});
} else {
removeButton = new Common.UI.Button({
el: $item.find('.remove-btn')
});
}
item.set({ keysInput: keysInput, removeBtn: removeButton});
const $keysInput = $item.find('.keys-input input');
$keysInput.on('keydown', function(e) {
@ -356,11 +377,20 @@ define([
});
$item.find('.remove-btn').on('click', function() {
const removedIndex = me.shortcutsCollection.findIndex(function(record) {
return record == item;
});
me.shortcutsCollection.remove(item);
if(me.shortcutsCollection.length == 0) {
me.onAddShortcut();
}
me.$window.find('#shortcuts-list .item input').last().focus();
let newFocusableIndex = removedIndex < me.shortcutsCollection.length ? removedIndex : removedIndex - 1;
if(me.shortcutsCollection.at(newFocusableIndex).get('removeBtn')) {
me.shortcutsCollection.at(newFocusableIndex).get('removeBtn').focus();
} else {
me.getFooterButtons()[0].focus();;
}
});
});
this.fixHeight(true);
@ -378,19 +408,22 @@ define([
this.shortcutsCollection.each(function(item) {
const ascShortcut = item.get('ascShortcut');
const assignedActionNames = [];
const assignedActions = me._findAssignedActions(ascShortcut, {
const assignedItem = me._findAssignedActions(ascShortcut, {
actionType: me.options.action.type,
shortcuts: me.shortcutsCollection.toJSON().slice(0, _.indexOf(me.shortcutsCollection.models, item))
});
const isDefaultShortcut = me._isDefaultShortcut(ascShortcut);
const isDisabled = !isDefaultShortcut &&
_.some(assignedActions, function(action) { return action.isLocked; });
_.some(assignedItem, function(item) {
return item.action.isLocked || item.shortcut.ascShortcut.asc_IsLocked();
});
isButtonDisabled = isButtonDisabled || isDisabled;
for (let i = 0; i < assignedActions.length; i++) {
const action = assignedActions[i];
if(action.isLocked == isDisabled) {
for (let i = 0; i < assignedItem.length; i++) {
const action = assignedItem[i].action;
const ascShortcut = assignedItem[i].shortcut.ascShortcut;
if((action.isLocked || ascShortcut.asc_IsLocked()) == isDisabled) {
assignedActionNames.push('“' + action.name + '”');
}
}
@ -480,7 +513,8 @@ define([
txtRestoreToDefault: 'Restore to default',
txtTypeDesiredShortcut: 'Type desired shortcut',
txtRestoreDescription: 'All shortcuts for action “%1” will be restored to deafult.',
txtRestoreContinue: 'Do you want to continue?'
txtRestoreContinue: 'Do you want to continue?',
txtCantBeEdited: 'This shortcut cant be edited'
}, Common.Views.ShortcutsEditDialog || {}))
});

View File

@ -68,6 +68,8 @@
border: 1px solid @border-divider;
box-shadow: 0 1px 0 0 @border-divider-ie;
box-shadow: 0 1px 0 0 @border-divider;
color: @text-normal-ie;
color: @text-normal;
}
.action-keys-item-comma {
display: flex;
@ -104,6 +106,15 @@
opacity: 1;
}
}
&.selected {
button {
:not(:hover).icon {
background-position-x: -20px;
background-position-x: @button-small-active-icon-offset-x;
}
}
}
}
}
@ -147,6 +158,13 @@
flex: 1;
.margin-right(8px);
}
.lock-info-icon {
width: @x-small-btn-icon-size-ie;
width: @x-small-btn-icon-size;
height: @x-small-btn-icon-size-ie;
height: @x-small-btn-icon-size;
}
}
.item:not(.first) {
margin-top: 8px;

View File

@ -1197,6 +1197,7 @@
"Common.Views.ShortcutsEditDialog.txtRestoreToDefault": "Restore to default",
"Common.Views.ShortcutsEditDialog.txtTitle": "Edit shortcut",
"Common.Views.ShortcutsEditDialog.txtTypeDesiredShortcut": "Type desired shortcut",
"Common.Views.ShortcutsEditDialog.txtCantBeEdited": "This shortcut cant be edited",
"Common.Views.SignDialog.textBold": "Bold",
"Common.Views.SignDialog.textCertificate": "Certificate",
"Common.Views.SignDialog.textChange": "Change",

View File

@ -386,20 +386,21 @@
div {
width: 100%;
height: 100%;
svg {
display: none;
width: 24px;
height: 30px;
.pixel-ratio__2_5 & {
display: block;
}
}
div{
background: ~"url(@{common-image-const-path}/doc-formats/formats.png)";
background-size: 1200px 30px;
svg {
display: none;
width: 24px;
height: 30px;
.pixel-ratio__2_5 & {
display: block;
}
}
&:not(.svg-file-recent) {
.pixel-ratio__1_25 & {
background-image: ~"url(@{common-image-const-path}/doc-formats/formats@1.25x.png)";