UNPKG

@atlaskit/editor-plugin-table

Version:

Table plugin for the @atlaskit/editor

86 lines 3.51 kB
import React from 'react'; import { Popup } from '@atlaskit/editor-common/ui'; import { akEditorFloatingDialogZIndex, akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles'; import { CellSelection } from '@atlaskit/editor-tables/cell-selection'; import { dragMenuDropdownWidth, tablePopupMenuFitHeight } from '../consts'; import DragMenu from './DragMenu'; const FloatingDragMenu = ({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, tableNode, direction, index, targetCellPosition, getEditorContainerWidth, editorAnalyticsAPI, stickyHeaders, pluginConfig, isTableScalingEnabled, getEditorFeatureFlags, ariaNotifyPlugin, api, isCommentEditor }) => { var _getEditorFeatureFlag; if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) { return null; } const inStickyMode = stickyHeaders === null || stickyHeaders === void 0 ? void 0 : stickyHeaders.sticky; const targetHandleRef = direction === 'row' ? document.querySelector('#drag-handle-button-row') : document.querySelector('#drag-handle-button-column'); const offset = direction === 'row' ? [-9, 0] : [0, -7]; if (!targetHandleRef || !(editorView.state.selection instanceof CellSelection)) { return null; } const { tableWithFixedColumnWidthsOption = false } = (_getEditorFeatureFlag = getEditorFeatureFlags === null || getEditorFeatureFlags === void 0 ? void 0 : getEditorFeatureFlags()) !== null && _getEditorFeatureFlag !== void 0 ? _getEditorFeatureFlag : {}; const shouldUseIncreasedScalingPercent = isTableScalingEnabled && (tableWithFixedColumnWidthsOption || isCommentEditor); return /*#__PURE__*/React.createElement(Popup, { alignX: direction === 'row' ? 'right' : undefined, alignY: direction === 'row' ? 'start' : undefined // Ignored via go/ees005 // eslint-disable-next-line @atlaskit/editor/no-as-casting , target: targetHandleRef, mountTo: mountPoint, boundariesElement: boundariesElement, scrollableElement: scrollableElement, fitWidth: dragMenuDropdownWidth, fitHeight: tablePopupMenuFitHeight // z-index value below is to ensure that this menu is above other floating menu // in table, but below floating dialogs like typeaheads, pickers, etc. // In sticky mode, we want to show the menu above the sticky header , zIndex: inStickyMode ? akEditorFloatingDialogZIndex : akEditorFloatingOverlapPanelZIndex, forcePlacement: true, offset: offset, stick: true }, /*#__PURE__*/React.createElement(DragMenu, { editorView: editorView, isOpen: isOpen, tableNode: tableNode, direction: direction, index: index, target: targetHandleRef || undefined, targetCellPosition: targetCellPosition, getEditorContainerWidth: getEditorContainerWidth, editorAnalyticsAPI: editorAnalyticsAPI, pluginConfig: pluginConfig, fitWidth: dragMenuDropdownWidth, fitHeight: tablePopupMenuFitHeight, mountPoint: mountPoint, boundariesElement: boundariesElement, scrollableElement: scrollableElement, isTableScalingEnabled: isTableScalingEnabled, shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent, isTableFixedColumnWidthsOptionEnabled: tableWithFixedColumnWidthsOption, ariaNotifyPlugin: ariaNotifyPlugin, api: api, isCommentEditor: isCommentEditor || false })); }; FloatingDragMenu.displayName = 'FloatingDragMenu'; export default FloatingDragMenu;