mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-04-06 17:31:09 +08:00
Add description for using numeration in multi rename
This commit is contained in:
parent
bec1558be1
commit
8d7f444a7b
29
js/api.js
29
js/api.js
@ -209,14 +209,35 @@ const Blockbench = {
|
||||
showMessageBox(options = 0, cb) {
|
||||
return new MessageBox(options, cb).show();
|
||||
},
|
||||
async textPrompt(title, value, callback, placeholder = null) {
|
||||
/**
|
||||
*
|
||||
* @param {*} title
|
||||
* @param {*} value
|
||||
* @param {*} callback
|
||||
* @param {object} options Options
|
||||
* @param {string} options.info Info text
|
||||
* @param {string} options.description Description for the text input
|
||||
* @returns {Promise<string>} Input value
|
||||
*/
|
||||
async textPrompt(title, value, callback, options = 0) {
|
||||
if (typeof options == 'string') {
|
||||
options = {placeholder: options};
|
||||
console.warn('textPrompt: 4th argument is expected to be a string');
|
||||
}
|
||||
let answer = await new Promise((resolve) => {
|
||||
let form = {
|
||||
text: {full_width: true, placeholder: options.placeholder, value, description: options.description}
|
||||
};
|
||||
if (options.info) {
|
||||
form.description = {
|
||||
type: 'info',
|
||||
text: tl(options.info)
|
||||
}
|
||||
}
|
||||
new Dialog({
|
||||
id: 'text_input',
|
||||
title: title || 'dialog.input.title',
|
||||
form: {
|
||||
text: {full_width: true, placeholder, value}
|
||||
},
|
||||
form,
|
||||
onConfirm({text}) {
|
||||
if (callback) callback(text);
|
||||
resolve(text);
|
||||
|
@ -676,7 +676,7 @@ BARS.defineActions(function() {
|
||||
Blockbench.showQuickMessage('message.invalid_link')
|
||||
})
|
||||
}
|
||||
}, 'https://blckbn.ch/123abc')
|
||||
}, {placeholder: 'https://blckbn.ch/123abc'});
|
||||
}
|
||||
})
|
||||
new Action('extrude_texture', {
|
||||
|
@ -952,11 +952,15 @@ function renameOutliner(element) {
|
||||
if (name) {
|
||||
Undo.initEdit({elements: selected})
|
||||
selected.forEach(function(obj, i) {
|
||||
obj.name = name.replace(/%/g, obj.index).replace(/\$/g, i)
|
||||
obj.name = name.replace(/%+/g, val => {
|
||||
return (obj.getParentArray().indexOf(obj)+1).toDigitString(val.length)
|
||||
}).replace(/\$+/g, val => {
|
||||
return (i+1).toDigitString(val.length)
|
||||
});
|
||||
})
|
||||
Undo.finishEdit('Rename')
|
||||
}
|
||||
})
|
||||
}, {description: tl('message.rename_elements.numbering')})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -420,6 +420,8 @@
|
||||
"message.invalid_session.title": "Invalid Session Token",
|
||||
"message.invalid_session.message": "The session you are trying to join has expired or the token provided is invalid.",
|
||||
|
||||
"message.rename_elements.numbering": "You can use special characters to generate sequential numbers: % to get the index of the element within its group, $ to get the index within the selection.",
|
||||
|
||||
"dialog.project.title": "Project",
|
||||
"dialog.project.name": "File Name",
|
||||
"dialog.project.parent": "Parent Model",
|
||||
|
Loading…
x
Reference in New Issue
Block a user