mirror of
https://github.com/ONLYOFFICE/web-apps.git
synced 2026-04-07 14:06:16 +08:00
Merge pull request 'Fix bug 77751' (#798) from fix/bug77751 into hotfix/v9.2.0
This commit is contained in:
@ -140,44 +140,56 @@ define([
|
|||||||
value: `1-${countPages}`,
|
value: `1-${countPages}`,
|
||||||
description: this.textEnterRangeDescription,
|
description: this.textEnterRangeDescription,
|
||||||
inputConfig: {
|
inputConfig: {
|
||||||
maxLength: 20,
|
maxLength: 50,
|
||||||
allowBlank: false,
|
allowBlank: false,
|
||||||
validation: function(value) {
|
validation: function(value) {
|
||||||
const singlePage = /^\d+$/;
|
const singlePage = /^\d+$/;
|
||||||
const range = /^(\d+)-(\d+)$/;
|
const range = /^(\d+)-(\d+)$/;
|
||||||
|
|
||||||
if (singlePage.test(value)) {
|
const parts = value.split(',').map(v => v.trim()).filter(Boolean);
|
||||||
const page = parseInt(value, 10);
|
if (parts.length === 0) return me.txtInvalidFormat;
|
||||||
if (page < 1 || page > countPages) return Common.Utils.String.format(me.txtInvalidRange, countPages);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const match = value.match(range);
|
for (const part of parts) {
|
||||||
if (match) {
|
if (singlePage.test(part)) {
|
||||||
const start = parseInt(match[1], 10);
|
const page = parseInt(part, 10);
|
||||||
const end = parseInt(match[2], 10);
|
if (page < 1 || page > countPages) {
|
||||||
if (start < 1 || end < 1 || start > countPages || end > countPages) {
|
return Common.Utils.String.format(me.txtInvalidRange, countPages);
|
||||||
return Common.Utils.String.format(me.txtInvalidRange, countPages);
|
}
|
||||||
|
} else {
|
||||||
|
const match = part.match(range);
|
||||||
|
if (match) {
|
||||||
|
const start = parseInt(match[1], 10);
|
||||||
|
const end = parseInt(match[2], 10);
|
||||||
|
if (start < 1 || end < 1 || start > countPages || end > countPages) {
|
||||||
|
return Common.Utils.String.format(me.txtInvalidRange, countPages);
|
||||||
|
}
|
||||||
|
if (start > end) return me.txtReversedRange;
|
||||||
|
} else {
|
||||||
|
return me.txtInvalidFormat;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (start > end) return me.txtReversedRange;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
return me.txtInvalidFormat;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handler: function(result, value) {
|
handler: function(result, value) {
|
||||||
if (result === 'ok') {
|
if (result === 'ok') {
|
||||||
let pages = [];
|
let pages = [];
|
||||||
|
const parts = value.split(',').map(v => v.trim()).filter(Boolean);
|
||||||
|
|
||||||
if (value.includes('-')) {
|
for (const part of parts) {
|
||||||
const [start, end] = value.split('-').map(p => parseInt(p, 10));
|
if (part.includes('-')) {
|
||||||
for (let i = start; i <= end; i++) {
|
const [start, end] = part.split('-').map(p => parseInt(p, 10));
|
||||||
pages.push(i - 1);
|
for (let i = start; i <= end; i++) {
|
||||||
|
pages.push(i - 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pages.push(parseInt(part, 10) - 1);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
pages.push(parseInt(value, 10) - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pages = Array.from(new Set(pages)).sort((a, b) => a - b);
|
||||||
|
|
||||||
me.api.RedactPages(pages);
|
me.api.RedactPages(pages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user