UNPKG

@atlaskit/editor-plugin-table

Version:

Table plugin for the @atlaskit/editor

180 lines (174 loc) 12.2 kB
import _defineProperty from "@babel/runtime/helpers/defineProperty"; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /* eslint-disable @atlaskit/editor/no-re-export */ // Entry file in package.json import { tableCellSelector, tableHeaderSelector, tablePrefixSelector } from '@atlaskit/adf-schema'; import { TableSharedCssClassName } from '@atlaskit/editor-common/styles'; export var RESIZE_HANDLE_AREA_DECORATION_GAP = 30; /** * @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-6877 Internal documentation for deprecation (no external access)} **/ // override getPluginState but do not expose publicly as this type is experimental and will change // in the future /* * This type represents the start and end from a cell in a column, * for example, on this table the cell C1 will have * `left: 1` and `right: 3`. * * ``` * left right * 1 3 * | | * | | * | | * _______∨_____________∨_______ * | | | | * | B1 | C1 | A1 | * |______|______ ______|______| * | | | | * | B2 | D1 | A2 | * |______ ______|______|______| * | | | | * | B3 | C2 | D2 | * |______|______|_____________| * ``` * */ export var TableDecorations = /*#__PURE__*/function (TableDecorations) { /** Classic controls */ TableDecorations["ALL_CONTROLS_HOVER"] = "CONTROLS_HOVER"; TableDecorations["ROW_CONTROLS_HOVER"] = "ROW_CONTROLS_HOVER"; TableDecorations["COLUMN_CONTROLS_HOVER"] = "COLUMN_CONTROLS_HOVER"; TableDecorations["TABLE_CONTROLS_HOVER"] = "TABLE_CONTROLS_HOVER"; TableDecorations["CELL_CONTROLS_HOVER"] = "CELL_CONTROLS_HOVER"; TableDecorations["COLUMN_CONTROLS_DECORATIONS"] = "COLUMN_CONTROLS_DECORATIONS"; TableDecorations["COLUMN_DROP_TARGET_DECORATIONS"] = "COLUMN_DROP_TARGET_DECORATIONS"; TableDecorations["COLUMN_SELECTED"] = "COLUMN_SELECTED"; TableDecorations["COLUMN_RESIZING_HANDLE"] = "COLUMN_RESIZING_HANDLE"; TableDecorations["COLUMN_RESIZING_HANDLE_WIDGET"] = "COLUMN_RESIZING_HANDLE_WIDGET"; TableDecorations["COLUMN_RESIZING_HANDLE_LINE"] = "COLUMN_RESIZING_HANDLE_LINE"; TableDecorations["COLUMN_INSERT_LINE"] = "COLUMN_INSERT_LINE"; TableDecorations["ROW_INSERT_LINE"] = "ROW_INSERT_LINE"; TableDecorations["LAST_CELL_ELEMENT"] = "LAST_CELL_ELEMENT"; return TableDecorations; }({}); export var TableCssClassName = _objectSpread(_objectSpread({}, TableSharedCssClassName), {}, { /** Classic controls */ COLUMN_CONTROLS: "".concat(tablePrefixSelector, "-column-controls"), COLUMN_CONTROLS_DECORATIONS: "".concat(tablePrefixSelector, "-column-controls-decoration"), COLUMN_SELECTED: "".concat(tablePrefixSelector, "-column__selected"), ROW_CONTROLS_WRAPPER: "".concat(tablePrefixSelector, "-row-controls-wrapper"), ROW_CONTROLS: "".concat(tablePrefixSelector, "-row-controls"), ROW_CONTROLS_INNER: "".concat(tablePrefixSelector, "-row-controls__inner"), ROW_CONTROLS_BUTTON_WRAP: "".concat(tablePrefixSelector, "-row-controls__button-wrap"), ROW_CONTROLS_BUTTON: "".concat(tablePrefixSelector, "-row-controls__button"), CONTROLS_BUTTON: "".concat(tablePrefixSelector, "-controls__button"), CONTROLS_BUTTON_ICON: "".concat(tablePrefixSelector, "-controls__button-icon"), CONTROLS_INSERT_BUTTON: "".concat(tablePrefixSelector, "-controls__insert-button"), CONTROLS_INSERT_BUTTON_INNER: "".concat(tablePrefixSelector, "-controls__insert-button-inner"), CONTROLS_INSERT_BUTTON_WRAP: "".concat(tablePrefixSelector, "-controls__insert-button-wrap"), CONTROLS_INSERT_LINE: "".concat(tablePrefixSelector, "-controls__insert-line"), CONTROLS_BUTTON_OVERLAY: "".concat(tablePrefixSelector, "-controls__button-overlay"), DRAG_CONTROLS_INSERT_BUTTON: "".concat(tablePrefixSelector, "-controls__drag-insert-button"), DRAG_CONTROLS_INSERT_BUTTON_INNER: "".concat(tablePrefixSelector, "-controls__drag-insert-button-inner"), DRAG_CONTROLS_INSERT_BUTTON_INNER_COLUMN: "".concat(tablePrefixSelector, "-controls__drag-insert-button-inner-column"), DRAG_CONTROLS_INSERT_BUTTON_INNER_ROW: "".concat(tablePrefixSelector, "-controls__drag-insert-button-inner-row"), DRAG_CONTROLS_INSERT_BUTTON_INNER_ROW_CHROMELESS: "".concat(tablePrefixSelector, "-controls__drag-insert-button-inner-row-chromeless"), DRAG_CONTROLS_INSERT_BUTTON_WRAP: "".concat(tablePrefixSelector, "-controls__drag-insert-button-wrap"), CONTROLS_INSERT_MARKER: "".concat(tablePrefixSelector, "-controls__insert-marker"), CONTROLS_INSERT_COLUMN: "".concat(tablePrefixSelector, "-controls__insert-column"), CONTROLS_INSERT_ROW: "".concat(tablePrefixSelector, "-controls__insert-row"), CONTROLS_DELETE_BUTTON_WRAP: "".concat(tablePrefixSelector, "-controls__delete-button-wrap"), CONTROLS_DELETE_BUTTON: "".concat(tablePrefixSelector, "-controls__delete-button"), CONTROLS_FLOATING_BUTTON_COLUMN: "".concat(tablePrefixSelector, "-controls-floating__button-column"), CONTROLS_FLOATING_BUTTON_ROW: "".concat(tablePrefixSelector, "-controls-floating__button-row"), CORNER_CONTROLS: "".concat(tablePrefixSelector, "-corner-controls"), CORNER_CONTROLS_INSERT_ROW_MARKER: "".concat(tablePrefixSelector, "-corner-controls__insert-row-marker"), CORNER_CONTROLS_INSERT_COLUMN_MARKER: "".concat(tablePrefixSelector, "-corner-controls__insert-column-marker"), CONTROLS_CORNER_BUTTON: "".concat(tablePrefixSelector, "-corner-button"), /** drag and drop controls */ DRAG_ROW_CONTROLS_WRAPPER: "".concat(tablePrefixSelector, "-drag-row-controls-wrapper"), DRAG_ROW_CONTROLS: "".concat(tablePrefixSelector, "-drag-row-controls"), DRAG_ROW_FLOATING_INSERT_DOT_WRAPPER: "".concat(tablePrefixSelector, "-drag-row-floating-insert-dot-wrapper"), DRAG_ROW_FLOATING_INSERT_DOT: "".concat(tablePrefixSelector, "-drag-row-floating-insert-dot"), DRAG_ROW_FLOATING_DRAG_HANDLE: "".concat(tablePrefixSelector, "-drag-row-floating-drag-handle"), DRAG_COLUMN_CONTROLS: "".concat(tablePrefixSelector, "-drag-column-controls"), DRAG_COLUMN_FLOATING_INSERT_DOT_WRAPPER: "".concat(tablePrefixSelector, "-drag-columns-floating-insert-dot-wrapper"), DRAG_COLUMN_FLOATING_INSERT_DOT: "".concat(tablePrefixSelector, "-drag-columns-floating-insert-dot"), DRAG_COLUMN_CONTROLS_WRAPPER: "".concat(tablePrefixSelector, "-col-controls-wrapper"), DRAG_COLUMN_DROP_TARGET_CONTROLS: "".concat(tablePrefixSelector, "-col-drop-target-controls"), DRAG_COLUMN_CONTROLS_INNER: "".concat(tablePrefixSelector, "-col-controls__inner"), DRAG_HANDLE_BUTTON_CONTAINER: "".concat(tablePrefixSelector, "-drag-handle-button-container"), DRAG_HANDLE_BUTTON_CLICKABLE_ZONE: "".concat(tablePrefixSelector, "-drag-handle-button-clickable-zone"), DRAG_CORNER_BUTTON: "".concat(tablePrefixSelector, "-drag-corner-button"), DRAG_CORNER_BUTTON_INNER: "".concat(tablePrefixSelector, "-drag-corner-button-inner"), /** nested tables classes */ NESTED_TABLE_WITH_CONTROLS: "".concat(tablePrefixSelector, "-nested-table-with-controls"), /** disabled classes */ DRAG_HANDLE_DISABLED: "".concat(tablePrefixSelector, "-drag-handle-disabled"), /** minimised handle class */ DRAG_HANDLE_MINIMISED: "".concat(tablePrefixSelector, "-drag-handle-minimised"), DRAG_SUBMENU: "".concat(tablePrefixSelector, "-drag-submenu"), DRAG_SUBMENU_ICON: "".concat(tablePrefixSelector, "-drag-submenu-icon"), /** Other classes */ NUMBERED_COLUMN: "".concat(tablePrefixSelector, "-numbered-column"), NUMBERED_COLUMN_BUTTON: "".concat(tablePrefixSelector, "-numbered-column__button"), NUMBERED_COLUMN_BUTTON_DISABLED: "".concat(tablePrefixSelector, "-numbered-column__button-disabled"), HOVERED_COLUMN: "".concat(tablePrefixSelector, "-hovered-column"), HOVERED_ROW: "".concat(tablePrefixSelector, "-hovered-row"), HOVERED_TABLE: "".concat(tablePrefixSelector, "-hovered-table"), HOVERED_NO_HIGHLIGHT: "".concat(tablePrefixSelector, "-hovered-no-highlight"), HOVERED_CELL: "".concat(tablePrefixSelector, "-hovered-cell"), HOVERED_CELL_IN_DANGER: 'danger', HOVERED_CELL_ACTIVE: 'active', HOVERED_CELL_WARNING: "".concat(tablePrefixSelector, "-hovered-cell__warning"), HOVERED_DELETE_BUTTON: "".concat(tablePrefixSelector, "-hovered-delete-button"), WITH_CONTROLS: "".concat(tablePrefixSelector, "-with-controls"), RESIZING_PLUGIN: "".concat(tablePrefixSelector, "-resizing-plugin"), RESIZE_CURSOR: "".concat(tablePrefixSelector, "-resize-cursor"), IS_RESIZING: "".concat(tablePrefixSelector, "-is-resizing"), RESIZE_HANDLE_DECORATION: "".concat(tablePrefixSelector, "-resize-decoration"), CONTEXTUAL_SUBMENU: "".concat(tablePrefixSelector, "-contextual-submenu"), CONTEXTUAL_MENU_BUTTON_WRAP: "".concat(tablePrefixSelector, "-contextual-menu-button-wrap"), CONTEXTUAL_MENU_BUTTON: "".concat(tablePrefixSelector, "-contextual-menu-button"), CONTEXTUAL_MENU_BUTTON_FIXED: "".concat(tablePrefixSelector, "-contextual-menu-button-fixed"), CONTEXTUAL_MENU_ICON: "".concat(tablePrefixSelector, "-contextual-submenu-icon"), CONTEXTUAL_MENU_ICON_SMALL: "".concat(tablePrefixSelector, "-contextual-submenu-icon-small"), // come from prosemirror-table SELECTED_CELL: 'selectedCell', // defined in ReactNodeView based on PM node name NODEVIEW_WRAPPER: 'tableView-content-wrap', TABLE_SELECTED: "".concat(tablePrefixSelector, "-table__selected"), TABLE_CELL: tableCellSelector, TABLE_HEADER_CELL: tableHeaderSelector, TABLE_STICKY: "".concat(tablePrefixSelector, "-sticky"), TABLE_CHROMELESS: "".concat(tablePrefixSelector, "-chromeless"), TOP_LEFT_CELL: 'table > tbody > tr:nth-child(2) > td:nth-child(1)', LAST_ITEM_IN_CELL: "".concat(tablePrefixSelector, "-last-item-in-cell"), WITH_COLUMN_INSERT_LINE: "".concat(tablePrefixSelector, "-column-insert-line"), WITH_COLUMN_INSERT_LINE_INACTIVE: "".concat(tablePrefixSelector, "-column-insert-line__inactive"), WITH_FIRST_COLUMN_INSERT_LINE: "".concat(tablePrefixSelector, "-first-column-insert-line"), WITH_FIRST_COLUMN_INSERT_LINE_INACTIVE: "".concat(tablePrefixSelector, "-first-column-insert-line__inactive"), WITH_LAST_COLUMN_INSERT_LINE: "".concat(tablePrefixSelector, "-last-column-insert-line"), WITH_LAST_COLUMN_INSERT_LINE_INACTIVE: "".concat(tablePrefixSelector, "-last-column-insert-line__inactive"), WITH_RESIZE_LINE: "".concat(tablePrefixSelector, "-column-resize-line"), WITH_RESIZE_LINE_LAST_COLUMN: "".concat(tablePrefixSelector, "-column-resize-line-last-column"), WITH_DRAG_RESIZE_LINE: "".concat(tablePrefixSelector, "-drag-column-resize-line"), WITH_DRAG_RESIZE_LINE_LAST_COLUMN: "".concat(tablePrefixSelector, "-drag-column-resize-line-last-column"), WITH_ROW_INSERT_LINE: "".concat(tablePrefixSelector, "-row-insert-line"), WITH_ROW_INSERT_LINE_INACTIVE: "".concat(tablePrefixSelector, "-row-insert-line__inactive"), WITH_LAST_ROW_INSERT_LINE: "".concat(tablePrefixSelector, "-last-row-insert-line"), WITH_LAST_ROW_INSERT_LINE_INACTIVE: "".concat(tablePrefixSelector, "-last-row-insert-line__inactive"), NATIVE_STICKY: "".concat(tablePrefixSelector, "-row-native-sticky"), NATIVE_STICKY_ACTIVE: "".concat(tablePrefixSelector, "-row-native-sticky-active"), NO_OVERFLOW: "".concat(tablePrefixSelector, "-no-overflow") }); export var ShadowEvent = /*#__PURE__*/function (ShadowEvent) { ShadowEvent["SHOW_BEFORE_SHADOW"] = "showBeforeShadow"; ShadowEvent["SHOW_AFTER_SHADOW"] = "showAfterShadow"; return ShadowEvent; }({}); /** * Drag and Drop interfaces */