@atlaskit/editor-plugin-table 7.6.14 → 7.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/commands/misc.js +0 -2
- package/dist/cjs/nodeviews/OverflowShadowsObserver.js +1 -3
- package/dist/cjs/nodeviews/TableComponent.js +3 -18
- package/dist/cjs/nodeviews/TableContainer.js +6 -25
- package/dist/cjs/nodeviews/TableResizer.js +2 -2
- package/dist/cjs/nodeviews/table.js +0 -2
- package/dist/cjs/plugin.js +3 -20
- package/dist/cjs/pm-plugins/main.js +1 -2
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +12 -21
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +32 -57
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +1 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +29 -4
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-logic.js +19 -0
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +16 -28
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +2 -12
- package/dist/cjs/reducer.js +0 -2
- package/dist/cjs/transforms/column-width.js +3 -5
- package/dist/cjs/types.js +0 -1
- package/dist/cjs/ui/ColumnResizeWidget/index.js +5 -1
- package/dist/cjs/ui/common-styles.js +5 -12
- package/dist/cjs/ui/ui-styles.js +7 -12
- package/dist/cjs/utils/index.js +0 -6
- package/dist/cjs/utils/nodes.js +5 -18
- package/dist/es2019/commands/misc.js +0 -2
- package/dist/es2019/nodeviews/OverflowShadowsObserver.js +1 -3
- package/dist/es2019/nodeviews/TableComponent.js +3 -18
- package/dist/es2019/nodeviews/TableContainer.js +6 -24
- package/dist/es2019/nodeviews/TableResizer.js +2 -2
- package/dist/es2019/nodeviews/table.js +0 -2
- package/dist/es2019/plugin.js +5 -24
- package/dist/es2019/pm-plugins/main.js +1 -2
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +13 -22
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +30 -53
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +1 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +28 -4
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-logic.js +20 -0
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +14 -24
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +2 -12
- package/dist/es2019/reducer.js +0 -5
- package/dist/es2019/transforms/column-width.js +3 -5
- package/dist/es2019/types.js +0 -1
- package/dist/es2019/ui/ColumnResizeWidget/index.js +5 -1
- package/dist/es2019/ui/common-styles.js +15 -46
- package/dist/es2019/ui/ui-styles.js +34 -41
- package/dist/es2019/utils/index.js +1 -1
- package/dist/es2019/utils/nodes.js +0 -15
- package/dist/esm/commands/misc.js +0 -2
- package/dist/esm/nodeviews/OverflowShadowsObserver.js +1 -3
- package/dist/esm/nodeviews/TableComponent.js +3 -18
- package/dist/esm/nodeviews/TableContainer.js +6 -25
- package/dist/esm/nodeviews/TableResizer.js +2 -2
- package/dist/esm/nodeviews/table.js +0 -2
- package/dist/esm/plugin.js +5 -22
- package/dist/esm/pm-plugins/main.js +1 -2
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +13 -22
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +32 -57
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +1 -2
- package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +30 -4
- package/dist/esm/pm-plugins/table-resizing/utils/resize-logic.js +18 -0
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +16 -28
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +2 -12
- package/dist/esm/reducer.js +0 -2
- package/dist/esm/transforms/column-width.js +3 -5
- package/dist/esm/types.js +0 -1
- package/dist/esm/ui/ColumnResizeWidget/index.js +5 -1
- package/dist/esm/ui/common-styles.js +6 -13
- package/dist/esm/ui/ui-styles.js +7 -12
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/nodes.js +0 -13
- package/dist/types/nodeviews/TableContainer.d.ts +1 -2
- package/dist/types/nodeviews/types.d.ts +0 -1
- package/dist/types/plugin.d.ts +0 -1
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/resize-logic.d.ts +4 -0
- package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +0 -1
- package/dist/types/types.d.ts +0 -9
- package/dist/types/ui/FloatingContextualButton/index.d.ts +0 -2
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/nodes.d.ts +0 -1
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +1 -2
- package/dist/types-ts4.5/nodeviews/types.d.ts +0 -1
- package/dist/types-ts4.5/plugin.d.ts +0 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-logic.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +0 -1
- package/dist/types-ts4.5/types.d.ts +0 -9
- package/dist/types-ts4.5/ui/FloatingContextualButton/index.d.ts +0 -2
- package/dist/types-ts4.5/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/utils/nodes.d.ts +0 -1
- package/package.json +7 -10
- package/src/commands/misc.ts +0 -2
- package/src/nodeviews/OverflowShadowsObserver.ts +1 -6
- package/src/nodeviews/TableComponent.tsx +2 -25
- package/src/nodeviews/TableContainer.tsx +7 -34
- package/src/nodeviews/TableResizer.tsx +2 -8
- package/src/nodeviews/table.tsx +0 -2
- package/src/nodeviews/types.ts +0 -1
- package/src/plugin.tsx +4 -43
- package/src/pm-plugins/main.ts +0 -2
- package/src/pm-plugins/table-resizing/event-handlers.ts +13 -37
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +40 -61
- package/src/pm-plugins/table-resizing/utils/misc.ts +4 -6
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +52 -9
- package/src/pm-plugins/table-resizing/utils/resize-logic.ts +25 -0
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +18 -29
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +2 -13
- package/src/reducer.ts +0 -3
- package/src/transforms/column-width.ts +2 -10
- package/src/types.ts +0 -8
- package/src/ui/ColumnResizeWidget/index.tsx +10 -1
- package/src/ui/FloatingContextualButton/index.tsx +0 -2
- package/src/ui/common-styles.ts +15 -53
- package/src/ui/ui-styles.ts +34 -47
- package/src/utils/index.ts +0 -1
- package/src/utils/nodes.ts +0 -23
- package/dist/cjs/ui/LayoutButton/index.js +0 -206
- package/dist/es2019/ui/LayoutButton/index.js +0 -168
- package/dist/esm/ui/LayoutButton/index.js +0 -196
- package/dist/types/ui/LayoutButton/index.d.ts +0 -21
- package/dist/types-ts4.5/ui/LayoutButton/index.d.ts +0 -21
- package/src/ui/LayoutButton/index.tsx +0 -217
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
import React, { createRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import classnames from 'classnames';
|
|
4
|
-
import type { WrappedComponentProps } from 'react-intl-next';
|
|
5
|
-
import { injectIntl } from 'react-intl-next';
|
|
6
|
-
|
|
7
|
-
import type { TableLayout } from '@atlaskit/adf-schema';
|
|
8
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
9
|
-
import commonMessages from '@atlaskit/editor-common/messages';
|
|
10
|
-
import { Popup } from '@atlaskit/editor-common/ui';
|
|
11
|
-
import type { PopupPosition } from '@atlaskit/editor-common/ui';
|
|
12
|
-
import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
13
|
-
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
14
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
15
|
-
import CollapseIcon from '@atlaskit/icon/glyph/editor/collapse';
|
|
16
|
-
import ExpandIcon from '@atlaskit/icon/glyph/editor/expand';
|
|
17
|
-
|
|
18
|
-
import { toggleTableLayoutWithAnalytics } from '../../commands-with-analytics';
|
|
19
|
-
import type { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
20
|
-
import { TableCssClassName as ClassName } from '../../types';
|
|
21
|
-
|
|
22
|
-
export interface Props {
|
|
23
|
-
editorView: EditorView;
|
|
24
|
-
targetRef?: HTMLElement;
|
|
25
|
-
mountPoint?: HTMLElement;
|
|
26
|
-
boundariesElement?: HTMLElement;
|
|
27
|
-
scrollableElement?: HTMLElement;
|
|
28
|
-
isResizing?: boolean;
|
|
29
|
-
layout?: TableLayout;
|
|
30
|
-
stickyHeader?: RowStickyState;
|
|
31
|
-
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const addPopupOffset = (pos: PopupPosition) => ({
|
|
35
|
-
...pos,
|
|
36
|
-
|
|
37
|
-
// add 12 pixels to align y position with
|
|
38
|
-
//the columns controls
|
|
39
|
-
top: pos.top ? pos.top + 12 : undefined,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const getMessage = (layout: TableLayout) => {
|
|
43
|
-
switch (layout) {
|
|
44
|
-
case 'default':
|
|
45
|
-
return commonMessages.layoutWide;
|
|
46
|
-
case 'wide':
|
|
47
|
-
return commonMessages.layoutFullWidth;
|
|
48
|
-
default:
|
|
49
|
-
return commonMessages.layoutFixedWidth;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
class LayoutButton extends React.Component<Props & WrappedComponentProps, any> {
|
|
54
|
-
static displayName = 'LayoutButton';
|
|
55
|
-
private stickyButtonRef = createRef<HTMLDivElement>();
|
|
56
|
-
|
|
57
|
-
private resizeObserver: ResizeObserver = new ResizeObserver((entries) => {
|
|
58
|
-
entries.forEach(() => {
|
|
59
|
-
const resizeButton = this.stickyButtonRef.current;
|
|
60
|
-
const tableWrapper = this.props.targetRef;
|
|
61
|
-
if (resizeButton && tableWrapper) {
|
|
62
|
-
const clientRect = tableWrapper.getBoundingClientRect();
|
|
63
|
-
resizeButton.style.left = `${clientRect.right}px`;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
getTitle() {
|
|
69
|
-
const {
|
|
70
|
-
intl: { formatMessage },
|
|
71
|
-
layout = 'default',
|
|
72
|
-
} = this.props;
|
|
73
|
-
return formatMessage(getMessage(layout));
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
toolbarButton() {
|
|
77
|
-
const { isResizing, layout = 'default' } = this.props;
|
|
78
|
-
const title = this.getTitle();
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<div
|
|
82
|
-
className={classnames(ClassName.LAYOUT_BUTTON, {
|
|
83
|
-
[ClassName.IS_RESIZING]: isResizing,
|
|
84
|
-
})}
|
|
85
|
-
>
|
|
86
|
-
<ToolbarButton
|
|
87
|
-
title={title}
|
|
88
|
-
onClick={this.handleClick}
|
|
89
|
-
iconBefore={
|
|
90
|
-
layout === 'full-width' ? (
|
|
91
|
-
<CollapseIcon label={title} />
|
|
92
|
-
) : (
|
|
93
|
-
<ExpandIcon label={title} />
|
|
94
|
-
)
|
|
95
|
-
}
|
|
96
|
-
/>
|
|
97
|
-
</div>
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
getStickyTargetRef(pos: number): Node | null {
|
|
102
|
-
const { editorView } = this.props;
|
|
103
|
-
const domAtPos = editorView.domAtPos.bind(editorView);
|
|
104
|
-
const node = findDomRefAtPos(pos, domAtPos) as HTMLElement;
|
|
105
|
-
return node.dataset['headerRow'] && node.classList.contains('sticky')
|
|
106
|
-
? node
|
|
107
|
-
: null;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
renderSticky(button: JSX.Element, targetRef: Node, tableRef: Node) {
|
|
111
|
-
const title = this.getTitle();
|
|
112
|
-
|
|
113
|
-
if (
|
|
114
|
-
!(targetRef instanceof HTMLElement) ||
|
|
115
|
-
!(tableRef instanceof HTMLElement)
|
|
116
|
-
) {
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
const pos = targetRef.getBoundingClientRect();
|
|
120
|
-
const tablePos = tableRef.getBoundingClientRect();
|
|
121
|
-
|
|
122
|
-
return (
|
|
123
|
-
<div
|
|
124
|
-
ref={this.stickyButtonRef}
|
|
125
|
-
aria-label={title}
|
|
126
|
-
style={{
|
|
127
|
-
position: 'fixed',
|
|
128
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
129
|
-
top: pos.top + 22,
|
|
130
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
131
|
-
left: tablePos.right,
|
|
132
|
-
}}
|
|
133
|
-
>
|
|
134
|
-
{button}
|
|
135
|
-
</div>
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
renderPopup(button: JSX.Element) {
|
|
140
|
-
const { mountPoint, boundariesElement, scrollableElement, targetRef } =
|
|
141
|
-
this.props;
|
|
142
|
-
|
|
143
|
-
if (!targetRef) {
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const title = this.getTitle();
|
|
148
|
-
|
|
149
|
-
return (
|
|
150
|
-
<Popup
|
|
151
|
-
ariaLabel={title}
|
|
152
|
-
target={targetRef}
|
|
153
|
-
alignY="start"
|
|
154
|
-
alignX="end"
|
|
155
|
-
onPositionCalculated={addPopupOffset}
|
|
156
|
-
stick={true}
|
|
157
|
-
mountTo={mountPoint}
|
|
158
|
-
boundariesElement={boundariesElement}
|
|
159
|
-
scrollableElement={scrollableElement}
|
|
160
|
-
forcePlacement={true}
|
|
161
|
-
>
|
|
162
|
-
{button}
|
|
163
|
-
</Popup>
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
render() {
|
|
168
|
-
const { stickyHeader } = this.props;
|
|
169
|
-
const button = this.toolbarButton();
|
|
170
|
-
|
|
171
|
-
const stickyTargetRef =
|
|
172
|
-
stickyHeader && stickyHeader.sticky && stickyHeader.pos
|
|
173
|
-
? this.getStickyTargetRef(stickyHeader.pos)
|
|
174
|
-
: null;
|
|
175
|
-
if (stickyTargetRef && this.props.targetRef) {
|
|
176
|
-
return this.renderSticky(button, stickyTargetRef, this.props.targetRef);
|
|
177
|
-
} else {
|
|
178
|
-
return this.renderPopup(button);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
componentDidMount() {
|
|
183
|
-
const dom = this.props.editorView.dom;
|
|
184
|
-
const scrollPanel = dom.closest('.fabric-editor-popup-scroll-parent');
|
|
185
|
-
if (scrollPanel instanceof HTMLElement) {
|
|
186
|
-
this.resizeObserver.observe(scrollPanel);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
componentWillUnmount() {
|
|
191
|
-
const dom = this.props.editorView.dom;
|
|
192
|
-
const scrollPanel = dom.closest('.fabric-editor-popup-scroll-parent');
|
|
193
|
-
if (scrollPanel instanceof HTMLElement) {
|
|
194
|
-
this.resizeObserver.unobserve(scrollPanel);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
shouldComponentUpdate(nextProps: Props) {
|
|
199
|
-
const { targetRef, layout, isResizing, stickyHeader } = this.props;
|
|
200
|
-
return (
|
|
201
|
-
stickyHeader !== nextProps.stickyHeader ||
|
|
202
|
-
targetRef !== nextProps.targetRef ||
|
|
203
|
-
layout !== nextProps.layout ||
|
|
204
|
-
isResizing !== nextProps.isResizing
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
private handleClick = () => {
|
|
209
|
-
const { state, dispatch } = this.props.editorView;
|
|
210
|
-
toggleTableLayoutWithAnalytics(this.props.editorAnalyticsAPI)(
|
|
211
|
-
state,
|
|
212
|
-
dispatch,
|
|
213
|
-
);
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
export default injectIntl(LayoutButton);
|