UNPKG

@atlaskit/editor-plugin-connectivity

Version:

Connectivity plugin for @atlaskit/editor-core

28 lines 1.1 kB
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin'; import { PluginKey } from '@atlaskit/editor-prosemirror/state'; export var key = new PluginKey('offlineMode'); export var createPlugin = function createPlugin() { return new SafePlugin({ key: key, state: { init: function init() { return { browserState: 'online', externalState: undefined }; }, apply: function apply(tr, pluginState) { var meta = tr.getMeta(key); if (meta) { var externalState = meta.externalState, browserState = meta.browserState; return { browserState: browserState !== null && browserState !== void 0 ? browserState : pluginState === null || pluginState === void 0 ? void 0 : pluginState.browserState, externalState: externalState === null ? undefined : externalState !== null && externalState !== void 0 ? externalState : pluginState === null || pluginState === void 0 ? void 0 : pluginState.externalState }; } return pluginState; } } }); };