editor.js/src/components/block-tunes/block-tune-delete.ts
Peter Savchenko 3272efc3f7
chore(linting): eslint updated, code linted (#2174)
* update eslint + autofix

* a bunch of eslint fixes

* some spelling & eslint fixes

* fix some eslint errors and spells

* Update __module.ts

* a bunch of eslint fixes in tests

* Update cypress.yml

* Update cypress.yml

* fix cypress docker image name

* fixes for tests

* more tests fixed

* rm rule ignore

* rm another ignored rule

* Update .eslintrc
2022-11-25 21:56:50 +04:00

57 lines
1.1 KiB
TypeScript

/**
* @class DeleteTune
* @classdesc Editor's default tune that moves up selected block
* @copyright <CodeX Team> 2018
*/
import { API, BlockTune, PopoverItem } from '../../../types';
import $ from '../dom';
/**
*
*/
export default class DeleteTune implements BlockTune {
/**
* Set Tool is Tune
*/
public static readonly isTune = true;
/**
* Property that contains Editor.js API methods
*
* @see {@link docs/api.md}
*/
private readonly api: API;
/**
* DeleteTune constructor
*
* @param {API} api - Editor's API
*/
constructor({ api }) {
this.api = api;
}
/**
* Tune's appearance in block settings menu
*/
public render(): PopoverItem {
return {
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
icon: $.svg('cross', 14, 14).outerHTML,
label: this.api.i18n.t('Delete'),
name: 'delete',
confirmation: {
label: this.api.i18n.t('Click to delete'),
onActivate: (): void => this.handleClick(),
},
};
}
/**
* Delete block conditions passed
*/
public handleClick(): void {
this.api.blocks.delete();
}
}