diff --git a/CHANGELOG.md b/CHANGELOG.md index fb920ee5..73cfccb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ - the html property is no longer restricted / sanitized - input/textarea/select no longer have their appearance property reset in custom html - canvas: added `contextType` property + - file: honor server's `remote-root` option (remove root path from displayed path and returned value) + - scripting - user scripts are longer protected against infinite loop and the main window object may be reached (it's not supported to break out of scripting context, but resources are no longer wasted to prevent it) diff --git a/src/client/ui/ui-filebrowser.mjs b/src/client/ui/ui-filebrowser.mjs index a33520ac..be975f89 100644 --- a/src/client/ui/ui-filebrowser.mjs +++ b/src/client/ui/ui-filebrowser.mjs @@ -40,6 +40,7 @@ export default function UiFilebrowser(options, callback) { ` var files = [], + root = '', path = '' var extRe = options.extension ? new RegExp('.*\\.' + options.extension + '$') : /.*/ @@ -75,10 +76,10 @@ export default function UiFilebrowser(options, callback) { if (files.some(x=>x.name===saveInput.value)) { if (!confirm(locales('remotesave_overwrite'))) return } - callback([path, saveInput.value]) + callback([path, saveInput.value], root) popup.close() } else { - callback([path, choice ? choice.value : '']) + callback([path, choice ? choice.value : ''], root) popup.close() } } @@ -142,11 +143,13 @@ export default function UiFilebrowser(options, callback) { ipc.on('listDir', (data)=>{ - ariane.textContent = path = data.path + path = data.path + root = data.root + + ariane.textContent = path.replace(root, '/') files = data.files.filter(x=>x.folder || x.name.match(extRe)) - function alphaSort(a, b){ // convert to strings and force lowercase a = typeof a.name === 'string' ? a.name.toLowerCase() : a.name.toString() diff --git a/src/client/widgets/basics/file.mjs b/src/client/widgets/basics/file.mjs index a8bf1a77..c22fe27c 100644 --- a/src/client/widgets/basics/file.mjs +++ b/src/client/widgets/basics/file.mjs @@ -58,9 +58,13 @@ export default class File extends Widget { directory: this.getProp('directory') === 'auto' ? undefined : this.getProp('directory'), loadDir: this.getProp('allowDir'), save: this.getProp('mode') === 'save' - }, (path)=>{ + }, (path, root)=>{ - this.setValue(path.join(path[0][0] === '/' ? '/' : '\\'), { + var sep = path[0][0] === '/' ? '/' : '\\', + val = path.join(sep) + if (root) val = val.replace(root, sep).replace(sep + sep, sep) + + this.setValue(val, { sync: true, send: true }) diff --git a/src/server/node/ipc/callbacks.mjs b/src/server/node/ipc/callbacks.mjs index 70c6a603..aec87ff7 100644 --- a/src/server/node/ipc/callbacks.mjs +++ b/src/server/node/ipc/callbacks.mjs @@ -567,7 +567,8 @@ export default class Callbacks { list = list.filter(x=>x.folder || x.name.match(extRe)) this.ipcServer.send('listDir', { path: p, - files: list + files: list, + root: root }, clientId) settings.write('last-dir', p, false, false) }