Files
talk/plugins/talk-plugin-rich-text/client/components/rte/lib/api.js
T
Chi Vinh Le a55cee5cc1 IE Fixes
2018-03-25 17:50:29 +02:00

38 lines
632 B
JavaScript

import { isSelectionInside } from './dom';
/**
* An instance of API is passed to all the buttons to
* interact with RTE, which servers as a clean abstraction.
*/
function createAPI(
getContainer,
broadcastChange,
canUndo,
canRedo,
undo,
redo,
getFocused
) {
return {
broadcastChange,
canUndo,
canRedo,
undo,
redo,
get focused() {
return getFocused();
},
get container() {
return getContainer();
},
focus() {
this.container.focus();
},
isSelectionInside() {
return isSelectionInside(getContainer());
},
};
}
export default createAPI;