@atlaskit/editor-plugin-toolbar
Version:
Toolbar plugin for @atlaskit/editor-core
23 lines • 589 B
JavaScript
/**
* Holds the open confirm dialog for a toolbar action. Create one per editor, call `show` from the
* action, and render `ConfirmDialog` with the same store.
*/
export const createConfirmDialogStore = () => {
let options;
const listeners = new Set();
const set = next => {
options = next;
listeners.forEach(listener => listener());
};
return {
getOptions: () => options,
show: next => set(next),
hide: () => set(),
subscribe: listener => {
listeners.add(listener);
return () => {
listeners.delete(listener);
};
}
};
};