Files
talk/plugins/talk-plugin-rich-text/client/components/rte/lib/api.js
T
2018-03-25 00:02:42 +01:00

23 lines
583 B
JavaScript

import { selectionIsInside } from './dom';
/**
* An instance of API is passed to all the buttons to
* interact with RTE, which servers as a clean abstraction.
*/
export default class API {
constructor(contentEditable, onChange, canUndo, canRedo, undo, redo) {
this.contentEditable = contentEditable;
this.broadcastChange = onChange;
this.canUndo = canUndo;
this.canRedo = canRedo;
this.undo = undo;
this.redo = redo;
}
isSelectionInside() {
return selectionIsInside(this.contentEditable);
}
focus() {
this.contentEditable.focus();
}
}