From 2cce72b8fcc775d5ac0128d9ca5b8170ab8655be Mon Sep 17 00:00:00 2001 From: Miguel Michelson Date: Wed, 8 Feb 2017 02:24:32 -0300 Subject: [PATCH] poc for widget delete --- .eslintrc.js | 27 +++++++++++++++++++++++++++ src/components/dante.js | 3 +++ src/components/dante_editor.js | 12 ++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 .eslintrc.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..84fde3a --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,27 @@ +module.exports = { + "extends": "standard", + "parser": "babel-eslint", + "rules": { + "strict": 0, + "indent": [2, 2, { "SwitchCase": 1 }], + "quotes": [2, "single"], + "linebreak-style": [2, "unix"], + "semi": [2, "always"] + }, + "env": { + "es6": true, + "browser": true + }, + "extends": "eslint:recommended", + "ecmaFeatures": { + "modules": true, + "jsx": true, + "experimentalObjectRestSpread": true + }, + "plugins": [ + "react", + "standard", + "promise" + ] + +}; \ No newline at end of file diff --git a/src/components/dante.js b/src/components/dante.js index 746129d..4de6c81 100644 --- a/src/components/dante.js +++ b/src/components/dante.js @@ -83,6 +83,9 @@ class Dante { const { editorState } = ctx.state return ctx.onChange(addNewBlockAt(editorState, block.getKey())) }, + handleDelete(ctx, block){ + debugger + }, widget_options: { displayOnInlineTooltip: true, insertion: "upload", diff --git a/src/components/dante_editor.js b/src/components/dante_editor.js index ac8716a..8742dbd 100644 --- a/src/components/dante_editor.js +++ b/src/components/dante_editor.js @@ -708,6 +708,16 @@ class DanteEditor extends React.Component { return true } + // catch delete, get block, check if has handle delete, then execute it + if (command.indexOf('delete') === 0) { + let config_block = this.getDataBlock(block) + if (config_block && config_block.handleDelete) { + config_block.handleDelete(this, block) + } + return true + } + + const newState = RichUtils.handleKeyCommand(this.state.editorState, command) if (newState) { this.onChange(newState) @@ -755,6 +765,8 @@ class DanteEditor extends React.Component { return cmd.cmd } return getDefaultKeyBinding(e) + } else if (e.keyCode == 8 || e.keyCode == 46) { + return "delete" } return getDefaultKeyBinding(e)