Browse Source

Improve isInputFocused method in Canvas

pull/1625/head
artf 8 years ago
parent
commit
2c9c550bb1
  1. 9
      src/canvas/config/config.js
  2. 10
      src/canvas/index.js

9
src/canvas/config/config.js

@ -24,5 +24,12 @@ module.exports = {
* return component.getName();
* }
*/
customBadgeLabel: ''
customBadgeLabel: '',
/**
* When some textable component is selected and focused (eg. input or text component) the editor
* stops some commands (eg. disables the copy/paste of components with CTRL+C/V to allow the copy/paste of the text).
* This option allows to customize, by a selector, which element should not be considered textable
*/
notTextable: ['button', 'input[type=checkbox]', 'input[type=radio]']
};

10
src/canvas/index.js

@ -409,11 +409,11 @@ module.exports = () => {
* @private
*/
isInputFocused() {
let contentDocument = this.getFrameEl().contentDocument;
return (
contentDocument.activeElement &&
contentDocument.activeElement.tagName !== 'BODY'
);
const doc = this.getDocument();
const toIgnore = ['body', ...this.getConfig().notTextable];
const focused = doc && doc.activeElement;
return focused && !toIgnore.some(item => focused.matches(item));
},
/**

Loading…
Cancel
Save