UNPKG

@atlaskit/editor-common

Version:

A package that contains common classes and components for editor and renderer

24 lines 843 B
import { PluginKey } from '@atlaskit/editor-prosemirror/state'; import { SafePlugin } from '../../../safe-plugin'; export const appearancePluginKey = new PluginKey('appearancePlugin'); const DEFAULT_APPEARANCE = 'comment'; export function createAppearancePlugin(initialAppearance) { return new SafePlugin({ key: appearancePluginKey, state: { init: () => ({ appearance: initialAppearance !== null && initialAppearance !== void 0 ? initialAppearance : DEFAULT_APPEARANCE }), apply: (tr, pluginState) => { const meta = tr.getMeta(appearancePluginKey); if ((meta === null || meta === void 0 ? void 0 : meta.appearance) !== undefined) { return { ...pluginState, appearance: meta.appearance }; } return pluginState; } } }); }