@atlaskit/editor-plugin-toolbar
Version:
Toolbar plugin for @atlaskit/editor-core
31 lines • 781 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 var createConfirmDialogStore = function createConfirmDialogStore() {
var options;
var listeners = new Set();
var set = function set(next) {
options = next;
listeners.forEach(function (listener) {
return listener();
});
};
return {
getOptions: function getOptions() {
return options;
},
show: function show(next) {
return set(next);
},
hide: function hide() {
return set();
},
subscribe: function subscribe(listener) {
listeners.add(listener);
return function () {
listeners.delete(listener);
};
}
};
};