mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 00:47:01 +00:00
feature: client: key: migrate to ESM
This commit is contained in:
parent
8a769fd512
commit
d574a93d6d
6 changed files with 252 additions and 256 deletions
|
|
@ -12,7 +12,7 @@ import currify from 'currify';
|
|||
import Images from './dom/images.js';
|
||||
import {unregisterSW} from './sw/register.js';
|
||||
import {getJsonFromFileTable} from './get-json-from-file-table.mjs';
|
||||
import Key from './key/index.js';
|
||||
import {Key} from './key/index.mjs';
|
||||
import {
|
||||
apiURL,
|
||||
formatMsg,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
/* global CloudCmd */
|
||||
/* global CloudCmd*/
|
||||
import tryToPromiseAll from '../../common/try-to-promise-all.js';
|
||||
import Storage from './storage.js';
|
||||
import DOM from './index.js';
|
||||
|
||||
const Info = DOM.CurrentInfo;
|
||||
const CLASS = 'cut-file';
|
||||
const COPY = 'copy';
|
||||
const CUT = 'cut';
|
||||
|
|
@ -57,6 +55,7 @@ async function readBuffer() {
|
|||
}
|
||||
|
||||
export const copy = checkEnabled(async () => {
|
||||
const Info = globalThis.DOM.CurrentInfo;
|
||||
const names = getNames();
|
||||
const from = Info.dirPath;
|
||||
|
||||
|
|
@ -73,6 +72,7 @@ export const copy = checkEnabled(async () => {
|
|||
});
|
||||
|
||||
export const cut = checkEnabled(async () => {
|
||||
const Info = globalThis.DOM.CurrentInfo;
|
||||
const names = getNames();
|
||||
const from = Info.dirPath;
|
||||
|
||||
|
|
@ -97,6 +97,7 @@ export const clear = checkEnabled(async () => {
|
|||
});
|
||||
|
||||
export const paste = checkEnabled(async () => {
|
||||
const Info = globalThis.DOM.CurrentInfo;
|
||||
const [error, cp, ct] = await readBuffer();
|
||||
|
||||
if (error || !cp && !ct)
|
||||
|
|
|
|||
|
|
@ -1,16 +1,12 @@
|
|||
'use strict';
|
||||
|
||||
/* global CloudCmd, DOM */
|
||||
const clipboard = require('@cloudcmd/clipboard');
|
||||
const {fullstore} = require('fullstore');
|
||||
|
||||
const Buffer = require('../dom/buffer.mjs');
|
||||
const Events = require('#dom/events');
|
||||
const KEY = require('./key');
|
||||
|
||||
const _vim = require('./vim');
|
||||
const setCurrentByChar = require('./set-current-by-char');
|
||||
const {createBinder} = require('./binder');
|
||||
import clipboard from '@cloudcmd/clipboard';
|
||||
import {fullstore} from 'fullstore';
|
||||
import * as Events from '#dom/events';
|
||||
import * as Buffer from '../dom/buffer.mjs';
|
||||
import KEY from './key.js';
|
||||
import _vim from './vim/index.js';
|
||||
import setCurrentByChar from './set-current-by-char.js';
|
||||
import {createBinder} from './binder.js';
|
||||
|
||||
const Chars = fullstore();
|
||||
|
||||
|
|
@ -28,13 +24,16 @@ Chars([]);
|
|||
const {assign} = Object;
|
||||
const binder = createBinder();
|
||||
|
||||
module.exports = assign(binder, KEY);
|
||||
module.exports.bind = () => {
|
||||
const bind = () => {
|
||||
Events.addKey(listener, true);
|
||||
binder.setBind();
|
||||
};
|
||||
|
||||
module.exports._listener = listener;
|
||||
export const Key = assign(binder, KEY, {
|
||||
bind,
|
||||
});
|
||||
|
||||
export const _listener = listener;
|
||||
|
||||
function getChar(event) {
|
||||
/*
|
||||
|
|
@ -7,7 +7,8 @@ const supertape = require('supertape');
|
|||
|
||||
const {ESC} = require('./key');
|
||||
|
||||
const {_listener, setBind} = require('.');
|
||||
const {Key, _listener} = require('./index.mjs');
|
||||
|
||||
const {getDOM, getCloudCmd} = require('./vim/globals.fixture');
|
||||
const test = autoGlobals(supertape);
|
||||
const {stub} = supertape;
|
||||
|
|
@ -26,7 +27,7 @@ test('cloudcmd: client: key: enable vim', async (t) => {
|
|||
altKey: false,
|
||||
};
|
||||
|
||||
setBind();
|
||||
Key.setBind();
|
||||
|
||||
await _listener(event, {
|
||||
vim,
|
||||
|
|
@ -48,7 +49,7 @@ test('cloudcmd: client: key: disable vim', async (t) => {
|
|||
altKey: false,
|
||||
};
|
||||
|
||||
setBind();
|
||||
Key.setBind();
|
||||
await _listener(event, {
|
||||
config,
|
||||
_config,
|
||||
|
|
|
|||
|
|
@ -403,11 +403,8 @@ async function _processFiles(options, data) {
|
|||
to,
|
||||
names,
|
||||
};
|
||||
debugger;
|
||||
|
||||
operation(files, async () => {
|
||||
console.log('sssss');
|
||||
debugger;
|
||||
await DOM.Storage.remove(from);
|
||||
|
||||
const {panel, panelPassive} = Info;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue