feature: client: edit-file: migrate to ESM

This commit is contained in:
coderiaser 2026-02-03 12:20:47 +02:00
parent c9f57c5f20
commit 2c2ca8eb39
3 changed files with 18 additions and 19 deletions

View file

@ -120,7 +120,7 @@ export default {
'sw': `${dir}/sw/sw.mjs`,
'cloudcmd': `${dir}/cloudcmd.mjs`,
[`${modules}/edit`]: `${dirModules}/edit.mjs`,
[`${modules}/edit-file`]: `${dirModules}/edit-file.js`,
[`${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-vim`]: `${dirModules}/edit-names-vim.mjs`,

View file

@ -4,9 +4,9 @@ import wraptile from 'wraptile';
import load from 'load.js';
import * as Util from '#common/util';
import * as CloudFunc from '#common/cloudfunc';
import DOM from '#dom';
import {registerSW, listenSW} from './sw/register.mjs';
import {initSortPanel, sortPanel} from './sort.mjs';
import DOM from '#dom';
import {createCloudCmd} from './client.mjs';
import * as Listeners from './listeners/index.mjs';

View file

@ -1,12 +1,15 @@
'use strict';
/* global CloudCmd, DOM*/
CloudCmd.EditFile = exports;
import Format from 'format-io';
import {fullstore} from 'fullstore';
import exec from 'execon';
import supermenu from 'supermenu';
const Format = require('format-io');
const {fullstore} = require('fullstore');
const exec = require('execon');
const supermenu = require('supermenu');
CloudCmd.EditFile = {
init,
show,
hide,
isChanged,
};
const Info = DOM.CurrentInfo;
@ -26,7 +29,7 @@ const ConfigView = {
},
};
module.exports.init = async () => {
export async function init() {
isLoading(true);
await CloudCmd.Edit();
@ -36,7 +39,7 @@ module.exports.init = async () => {
setListeners(editor);
isLoading(false);
};
}
function getName() {
const {name, isDir} = Info;
@ -47,7 +50,7 @@ function getName() {
return name;
}
module.exports.show = async (options) => {
export async function show(options) {
if (isLoading())
return;
@ -86,11 +89,9 @@ module.exports.show = async (options) => {
CloudCmd.Edit.show(optionsEdit);
return CloudCmd.Edit;
};
}
module.exports.hide = hide;
function hide() {
export function hide() {
CloudCmd.Edit.hide();
}
@ -176,9 +177,7 @@ function setMsgChanged(name) {
MSG_CHANGED = `Do you want to save changes to ${name}?`;
}
module.exports.isChanged = isChanged;
async function isChanged() {
export async function isChanged() {
const editor = CloudCmd.Edit.getEditor();
const is = editor.isChanged();