@atlaskit/editor-plugin-width
Version:
Width plugin for @atlaskit/editor-core
37 lines (36 loc) • 1.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.widthPlugin = void 0;
var _main = require("./pm-plugins/main");
var _pluginKey = require("./pm-plugins/plugin-key");
var _useWidthObserver = require("./ui/hooks/useWidthObserver");
/**
* Width plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
* from `@atlaskit/editor-core`.
*/
var widthPlugin = exports.widthPlugin = function widthPlugin() {
return {
name: 'width',
pmPlugins: function pmPlugins() {
return [{
name: 'width',
plugin: function plugin(_ref) {
var dispatch = _ref.dispatch;
return (0, _main.createPlugin)(dispatch);
}
}];
},
getSharedState: function getSharedState(editorState) {
if (!editorState) {
return undefined;
}
return _pluginKey.pluginKey.getState(editorState);
},
// Dispatches between the legacy hook and its replacement while
// `platform_editor_reduce_forced_layout` runs. On cleanup, point this at the surviving
// hook and delete `useWidthObserver`.
usePluginHook: _useWidthObserver.useWidthObserver
};
};