UNPKG

@atlaskit/editor-plugin-code-bidi-warning

Version:

Code bidi warning plugin for @atlaskit/editor-core.

63 lines (62 loc) 2.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createPlugin = void 0; var _messages = require("@atlaskit/editor-common/messages"); var _safePlugin = require("@atlaskit/editor-common/safe-plugin"); var _view = require("@atlaskit/editor-prosemirror/view"); var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals"); var _pluginKey = require("./plugin-key"); var _reactPluginFactory = require("./react-plugin-factory"); var createPlugin = exports.createPlugin = function createPlugin(api, _ref, _ref2) { var dispatch = _ref.dispatch, getIntl = _ref.getIntl, nodeViewPortalProviderAPI = _ref.nodeViewPortalProviderAPI; var appearance = _ref2.appearance; var intl = getIntl(); var codeBidiWarningLabel = intl.formatMessage(_messages.codeBidiWarningMessages.label); var _reactPluginFactoryCr = (0, _reactPluginFactory.pluginFactoryCreator)(nodeViewPortalProviderAPI), createPluginState = _reactPluginFactoryCr.createPluginState, getPluginState = _reactPluginFactoryCr.getPluginState; return new _safePlugin.SafePlugin({ key: _pluginKey.codeBidiWarningPluginKey, state: createPluginState(dispatch, function (state) { var _api$limitedMode; if ((0, _expValEquals.expValEquals)('platform_editor_remove_bidi_char_warning', 'isEnabled', true)) { return { decorationSet: _view.DecorationSet.empty, codeBidiWarningLabel: '', tooltipEnabled: false }; } if (api !== null && api !== void 0 && (_api$limitedMode = api.limitedMode) !== null && _api$limitedMode !== void 0 && (_api$limitedMode = _api$limitedMode.sharedState.currentState()) !== null && _api$limitedMode !== void 0 && _api$limitedMode.enabled) { return { decorationSet: _view.DecorationSet.empty, codeBidiWarningLabel: '', tooltipEnabled: false }; } return { decorationSet: (0, _reactPluginFactory.createBidiWarningsDecorationSetFromDoc)({ doc: state.doc, codeBidiWarningLabel: codeBidiWarningLabel, tooltipEnabled: true, nodeViewPortalProviderAPI: nodeViewPortalProviderAPI }), codeBidiWarningLabel: codeBidiWarningLabel, tooltipEnabled: true }; }), props: { decorations: function decorations(state) { if ((0, _expValEquals.expValEquals)('platform_editor_remove_bidi_char_warning', 'isEnabled', true)) { return _view.DecorationSet.empty; } var _getPluginState = getPluginState(state), decorationSet = _getPluginState.decorationSet; return decorationSet; } } }); };