Fixes due code review (#1365)

This commit is contained in:
Peter Savchenko 2020-10-13 19:14:09 +03:00 committed by GitHub
parent 9581fc2dc9
commit ea6f81d5e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 15 deletions

2
dist/editor.js vendored

File diff suppressed because one or more lines are too long

View file

@ -70,8 +70,10 @@ export default class MoveUpTune implements BlockTune {
*/
public handleClick(event: MouseEvent, button: HTMLElement): void {
const currentBlockIndex = this.api.blocks.getCurrentBlockIndex();
const currentBlock = this.api.blocks.getBlockByIndex(currentBlockIndex);
const previousBlock = this.api.blocks.getBlockByIndex(currentBlockIndex - 1);
if (currentBlockIndex === 0) {
if (currentBlockIndex === 0 || !currentBlock || !previousBlock) {
button.classList.add(this.CSS.animation);
window.setTimeout(() => {
@ -81,13 +83,6 @@ export default class MoveUpTune implements BlockTune {
return;
}
const currentBlock = this.api.blocks.getBlockByIndex(currentBlockIndex);
const previousBlock = this.api.blocks.getBlockByIndex(currentBlockIndex - 1);
if (!currentBlock || !previousBlock) {
return;
}
const currentBlockElement = currentBlock.holder;
const previousBlockElement = previousBlock.holder;

View file

@ -58,7 +58,7 @@ export default class BlocksAPI extends Module {
const block = this.Editor.BlockManager.getBlockByIndex(index);
if (block === undefined) {
_.log('There is no block at index `' + index + '`', 'warn');
_.logLabeled('There is no block at index `' + index + '`', 'warn');
return;
}

View file

@ -16,11 +16,6 @@ export interface BlockTool extends BaseTool {
*/
sanitize?: SanitizerConfig;
/**
* Creates and returns Tools HTML markup
*/
render(): HTMLElement;
/**
* Process Tool's element in DOM and return raw data
* @param {HTMLElement} block - element created by {@link BlockTool#render} function