UNPKG

@atlaskit/editor-common

Version:

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

55 lines (52 loc) 2.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.shouldShowSelectionToolbar = exports.shouldShowPrimaryToolbar = exports.getInputMethodFromParentKeys = void 0; var _platformFeatureFlags = require("@atlaskit/platform-feature-flags"); var _analytics = require("../analytics"); var _keys = require("./keys"); var getInputMethodFromParentKeys = exports.getInputMethodFromParentKeys = function getInputMethodFromParentKeys(parents) { var _parents$at; return ((_parents$at = parents.at(0)) === null || _parents$at === void 0 ? void 0 : _parents$at.key) === _keys.TOOLBARS.INLINE_TEXT_TOOLBAR ? _analytics.INPUT_METHOD.FLOATING_TB : _analytics.INPUT_METHOD.TOOLBAR; }; /** * Determines whether the primary (top) toolbar should be shown based on contextual formatting mode * and toolbar docking position preference. * * @param contextualFormattingEnabled - The contextual formatting mode * @param toolbarDockingPosition - The user's toolbar docking preference * @returns true if the primary toolbar should be displayed, false otherwise */ var shouldShowPrimaryToolbar = exports.shouldShowPrimaryToolbar = function shouldShowPrimaryToolbar(contextualFormattingEnabled, toolbarDockingPosition) { if ((0, _platformFeatureFlags.fg)('platform_editor_toolbar_aifc_placement_overridden')) { if (contextualFormattingEnabled === 'controlled') { return toolbarDockingPosition !== 'none'; } if (contextualFormattingEnabled === 'always-pinned') { return true; } return false; } return toolbarDockingPosition !== 'none'; }; /** * Determines whether the selection (inline) toolbar should be shown based on contextual formatting mode * and toolbar docking position preference. * * @param contextualFormattingEnabled - The contextual formatting mode * @param toolbarDockingPosition - The user's toolbar docking preference * @returns true if the selection toolbar should be displayed, false otherwise */ var shouldShowSelectionToolbar = exports.shouldShowSelectionToolbar = function shouldShowSelectionToolbar(contextualFormattingEnabled, toolbarDockingPosition) { if ((0, _platformFeatureFlags.fg)('platform_editor_toolbar_aifc_placement_overridden')) { if (contextualFormattingEnabled === 'controlled') { return toolbarDockingPosition === 'top'; } if (contextualFormattingEnabled === 'always-inline') { return true; } return false; } return toolbarDockingPosition === 'top'; };