diff --git a/.webpack/js.mjs b/.webpack/js.mjs index ac70fc6f..4d07237d 100644 --- a/.webpack/js.mjs +++ b/.webpack/js.mjs @@ -122,7 +122,7 @@ export default { [`${modules}/edit`]: `${dirModules}/edit.mjs`, [`${modules}/edit-file`]: `${dirModules}/edit-file.mjs`, [`${modules}/edit-file-vim`]: `${dirModules}/edit-file-vim.mjs`, - [`${modules}/edit-names`]: `${dirModules}/edit-names.js`, + [`${modules}/edit-names`]: `${dirModules}/edit-names.mjs`, [`${modules}/edit-names-vim`]: `${dirModules}/edit-names-vim.mjs`, [`${modules}/menu`]: `${dirModules}/menu/index.mjs`, [`${modules}/view`]: `${dirModules}/view/index.mjs`, diff --git a/client/modules/edit-names.js b/client/modules/edit-names.mjs similarity index 91% rename from client/modules/edit-names.js rename to client/modules/edit-names.mjs index 710ed7ea..d2ffc0b9 100644 --- a/client/modules/edit-names.js +++ b/client/modules/edit-names.mjs @@ -1,13 +1,16 @@ -'use strict'; +import {tryToCatch} from 'try-to-catch'; +import exec from 'execon'; +import supermenu from 'supermenu'; +import {multiRename} from 'multi-rename'; -const {tryToCatch} = require('try-to-catch'); +const {CloudCmd, DOM} = globalThis; -/* global CloudCmd, DOM */ -CloudCmd.EditNames = exports; - -const exec = require('execon'); -const supermenu = require('supermenu'); -const {multiRename} = require('multi-rename'); +CloudCmd.EditNames = { + init, + show, + hide, + isChanged, +}; const Info = DOM.CurrentInfo; const {Dialog} = DOM; @@ -22,13 +25,13 @@ const ConfigView = { }, }; -module.exports.init = async () => { +export async function init() { await CloudCmd.Edit(); setListeners(); -}; +} -module.exports.show = (options) => { +export function show(options) { const names = getActiveNames().join('\n'); const config = { ...ConfigView, @@ -50,7 +53,7 @@ module.exports.show = (options) => { CloudCmd.Edit.show(config); return CloudCmd.Edit; -}; +} async function keyListener(event) { const ctrl = event.ctrlKey; @@ -77,9 +80,7 @@ function getActiveNames() { return DOM.getFilenames(DOM.getActiveFiles()); } -module.exports.hide = hide; - -function hide() { +export function hide() { CloudCmd.Edit.hide(); } @@ -201,9 +202,7 @@ function setMenu(event) { Menu.show(position.x, position.y); } -module.exports.isChanged = isChanged; - -async function isChanged() { +export async function isChanged() { const editor = CloudCmd.Edit.getEditor(); const msg = 'Apply new names?'; @@ -214,3 +213,4 @@ async function isChanged() { !cancel && await applyNames(); } +