st-h/ember-content-editable

paste & input events.

gregtap opened this issue · 5 comments

handlePaste is called to check against max length.
It would be handy to an action key-paste event triggered.

Same for the input event.

Or maybe an on-paste event

jfrux commented
// app/app.js
import Application from '@ember/application';
import Resolver from './resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';
import computed from '@ember/object/computed';
const App = Application.extend({
  modulePrefix: config.modulePrefix,
  podModulePrefix: config.podModulePrefix,
  Resolver,
  customEvents: {
    paste: "paste"
  }
});

loadInitializers(App, config.modulePrefix);

export default App;
$ ember g component inline-editor
// app/components/inline-editor.js
import ContentEditable from 'ember-content-editable/components/content-editable';

export default ContentEditable.extend({
  paste(e) {
    const text = (event.originalEvent || event).clipboardData.getData('text/plain');
    e.preventDefault();
    this.$().html(text);
  }
});
st-h commented

@joshuairl I am a little unsure about the edit history of your post, but yes - I think we can add a hook for paste events to the 1.0.0 release of the addon.

jfrux commented
st-h commented

@joshuairl ah, thanks for the input. Added a paste hook to the 1.0.0 release.