@atlaskit/editor-common 67.0.0 → 68.0.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 +32 -0
- package/dist/cjs/styles/shared/block-marks.js +1 -1
- package/dist/cjs/styles/shared/column-layout.js +1 -1
- package/dist/cjs/styles/shared/shadow.js +3 -1
- package/dist/cjs/styles/shared/table.js +1 -1
- package/dist/cjs/styles/shared/task-decision.js +1 -1
- package/dist/cjs/ui/BaseTheme/index.js +4 -21
- package/dist/cjs/ui/Expand/index.js +1 -1
- package/dist/cjs/ui/OverflowShadow/index.js +49 -11
- package/dist/cjs/ui/OverflowShadow/shadowObserver.js +107 -0
- package/dist/cjs/ui/index.js +14 -0
- package/dist/cjs/utils/breakout.js +2 -2
- package/dist/cjs/utils/unsupportedContent/get-unsupported-content-level-data.js +3 -3
- package/dist/cjs/utils/validate-using-spec.js +2 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/styles/shared/block-marks.js +3 -2
- package/dist/es2019/styles/shared/column-layout.js +1 -0
- package/dist/es2019/styles/shared/shadow.js +12 -0
- package/dist/es2019/styles/shared/table.js +5 -4
- package/dist/es2019/styles/shared/task-decision.js +3 -1
- package/dist/es2019/ui/BaseTheme/index.js +3 -21
- package/dist/es2019/ui/Expand/index.js +2 -1
- package/dist/es2019/ui/OverflowShadow/index.js +48 -12
- package/dist/es2019/ui/OverflowShadow/shadowObserver.js +82 -0
- package/dist/es2019/ui/index.js +1 -0
- package/dist/es2019/utils/breakout.js +1 -1
- package/dist/es2019/utils/unsupportedContent/get-unsupported-content-level-data.js +1 -1
- package/dist/es2019/utils/validate-using-spec.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/styles/shared/block-marks.js +1 -1
- package/dist/esm/styles/shared/column-layout.js +1 -1
- package/dist/esm/styles/shared/shadow.js +2 -1
- package/dist/esm/styles/shared/table.js +1 -1
- package/dist/esm/styles/shared/task-decision.js +1 -1
- package/dist/esm/ui/BaseTheme/index.js +4 -22
- package/dist/esm/ui/Expand/index.js +1 -1
- package/dist/esm/ui/OverflowShadow/index.js +50 -11
- package/dist/esm/ui/OverflowShadow/shadowObserver.js +98 -0
- package/dist/esm/ui/index.js +1 -0
- package/dist/esm/utils/breakout.js +2 -2
- package/dist/esm/utils/unsupportedContent/get-unsupported-content-level-data.js +1 -1
- package/dist/esm/utils/validate-using-spec.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/extensions/manifest-helpers.d.ts +1 -1
- package/dist/types/extensions/module-helpers.d.ts +1 -1
- package/dist/types/extensions/types/extension-handler.d.ts +1 -1
- package/dist/types/extensions/types/extension-manifest-toolbar-item.d.ts +1 -1
- package/dist/types/extensions/types/extension-manifest.d.ts +1 -1
- package/dist/types/extensions/types/utils.d.ts +1 -1
- package/dist/types/provider-factory/autoformatting-provider.d.ts +1 -1
- package/dist/types/ui/BaseTheme/index.d.ts +2 -4
- package/dist/types/ui/OverflowShadow/index.d.ts +10 -3
- package/dist/types/ui/OverflowShadow/shadowObserver.d.ts +27 -0
- package/dist/types/ui/index.d.ts +1 -0
- package/dist/types/utils/unsupportedContent/get-unsupported-content-level-data.d.ts +1 -1
- package/dist/types/utils/validate-using-spec.d.ts +2 -1
- package/package.json +11 -11
|
@@ -4,20 +4,6 @@ import { akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
|
4
4
|
import { useGlobalTheme } from '@atlaskit/theme/components';
|
|
5
5
|
import { CHANNEL, fontSize } from '@atlaskit/theme/constants';
|
|
6
6
|
import { WidthConsumer } from '../WidthProvider';
|
|
7
|
-
|
|
8
|
-
function mapBreakpointToFontSize(breakpoint) {
|
|
9
|
-
switch (breakpoint) {
|
|
10
|
-
case 'M':
|
|
11
|
-
return fontSize() + 2;
|
|
12
|
-
|
|
13
|
-
case 'L':
|
|
14
|
-
return fontSize() + 4;
|
|
15
|
-
|
|
16
|
-
default:
|
|
17
|
-
return fontSize();
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
7
|
export function mapBreakpointToLayoutMaxWidth(breakpoint) {
|
|
22
8
|
switch (breakpoint) {
|
|
23
9
|
case 'M':
|
|
@@ -31,8 +17,6 @@ export function mapBreakpointToLayoutMaxWidth(breakpoint) {
|
|
|
31
17
|
}
|
|
32
18
|
}
|
|
33
19
|
export function BaseThemeWrapper({
|
|
34
|
-
breakpoint,
|
|
35
|
-
dynamicTextSizing,
|
|
36
20
|
baseFontSize,
|
|
37
21
|
children
|
|
38
22
|
}) {
|
|
@@ -40,26 +24,24 @@ export function BaseThemeWrapper({
|
|
|
40
24
|
mode
|
|
41
25
|
} = useGlobalTheme();
|
|
42
26
|
const memoizedTheme = useMemo(() => ({
|
|
43
|
-
baseFontSize:
|
|
44
|
-
layoutMaxWidth:
|
|
27
|
+
baseFontSize: baseFontSize || fontSize(),
|
|
28
|
+
layoutMaxWidth: akEditorDefaultLayoutWidth,
|
|
45
29
|
// Below is used for editor dark mode.
|
|
46
30
|
[CHANNEL]: {
|
|
47
31
|
mode
|
|
48
32
|
}
|
|
49
|
-
}), [
|
|
33
|
+
}), [baseFontSize, mode]);
|
|
50
34
|
return /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
51
35
|
theme: memoizedTheme
|
|
52
36
|
}, children);
|
|
53
37
|
}
|
|
54
38
|
export function BaseTheme({
|
|
55
39
|
children,
|
|
56
|
-
dynamicTextSizing,
|
|
57
40
|
baseFontSize
|
|
58
41
|
}) {
|
|
59
42
|
return /*#__PURE__*/React.createElement(WidthConsumer, null, ({
|
|
60
43
|
breakpoint
|
|
61
44
|
}) => /*#__PURE__*/React.createElement(BaseThemeWrapper, {
|
|
62
|
-
dynamicTextSizing: dynamicTextSizing,
|
|
63
45
|
breakpoint: breakpoint,
|
|
64
46
|
baseFontSize: baseFontSize
|
|
65
47
|
}, /*#__PURE__*/React.createElement(React.Fragment, null, children)));
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import
|
|
4
|
+
import { ShadowObserver, shadowObserverClassNames } from './shadowObserver';
|
|
5
5
|
export const shadowClassNames = {
|
|
6
6
|
RIGHT_SHADOW: 'right-shadow',
|
|
7
7
|
LEFT_SHADOW: 'left-shadow'
|
|
8
8
|
};
|
|
9
|
-
const isIE11 = browser.ie_version === 11;
|
|
10
9
|
export default function overflowShadow(Component, options) {
|
|
11
10
|
return class OverflowShadow extends React.Component {
|
|
12
11
|
constructor(...args) {
|
|
13
12
|
super(...args);
|
|
14
13
|
|
|
14
|
+
_defineProperty(this, "overflowContainerWidth", 0);
|
|
15
|
+
|
|
15
16
|
_defineProperty(this, "state", {
|
|
16
17
|
showLeftShadow: false,
|
|
17
18
|
showRightShadow: false
|
|
18
19
|
});
|
|
19
20
|
|
|
20
21
|
_defineProperty(this, "handleScroll", event => {
|
|
21
|
-
if (!this.overflowContainer || event.target !== this.overflowContainer) {
|
|
22
|
+
if (!this.overflowContainer || event.target !== this.overflowContainer || options.useShadowObserver) {
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -26,6 +27,10 @@ export default function overflowShadow(Component, options) {
|
|
|
26
27
|
});
|
|
27
28
|
|
|
28
29
|
_defineProperty(this, "updateShadows", () => {
|
|
30
|
+
if (options.useShadowObserver) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
29
34
|
this.setState(prevState => {
|
|
30
35
|
if (!this.overflowContainer) {
|
|
31
36
|
return;
|
|
@@ -90,20 +95,22 @@ export default function overflowShadow(Component, options) {
|
|
|
90
95
|
this.overflowContainer = container;
|
|
91
96
|
}
|
|
92
97
|
|
|
93
|
-
if (options.
|
|
94
|
-
this.
|
|
98
|
+
if (options.useShadowObserver) {
|
|
99
|
+
this.initShadowObserver();
|
|
100
|
+
return;
|
|
95
101
|
}
|
|
96
102
|
|
|
97
103
|
this.updateShadows();
|
|
98
|
-
|
|
99
|
-
if (!isIE11) {
|
|
100
|
-
this.overflowContainer.addEventListener('scroll', this.handleScroll);
|
|
101
|
-
}
|
|
104
|
+
this.overflowContainer.addEventListener('scroll', this.handleScroll);
|
|
102
105
|
});
|
|
103
106
|
}
|
|
104
107
|
|
|
105
108
|
componentWillUnmount() {
|
|
106
|
-
if (
|
|
109
|
+
if (options.useShadowObserver) {
|
|
110
|
+
return this.shadowObserver && this.shadowObserver.dispose();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (this.overflowContainer) {
|
|
107
114
|
this.overflowContainer.removeEventListener('scroll', this.handleScroll);
|
|
108
115
|
}
|
|
109
116
|
|
|
@@ -111,7 +118,36 @@ export default function overflowShadow(Component, options) {
|
|
|
111
118
|
}
|
|
112
119
|
|
|
113
120
|
componentDidUpdate() {
|
|
114
|
-
|
|
121
|
+
if (!options.useShadowObserver) {
|
|
122
|
+
this.updateShadows();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
initShadowObserver() {
|
|
127
|
+
if (this.shadowObserver || !this.overflowContainer) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
this.shadowObserver = new ShadowObserver({
|
|
132
|
+
scrollContainer: this.overflowContainer,
|
|
133
|
+
onUpdateShadows: shadowStates => {
|
|
134
|
+
this.setState(prevState => {
|
|
135
|
+
const {
|
|
136
|
+
showLeftShadow,
|
|
137
|
+
showRightShadow
|
|
138
|
+
} = shadowStates;
|
|
139
|
+
|
|
140
|
+
if (showLeftShadow !== prevState.showLeftShadow || showRightShadow !== prevState.showRightShadow) {
|
|
141
|
+
return {
|
|
142
|
+
showLeftShadow,
|
|
143
|
+
showRightShadow
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return null;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
});
|
|
115
151
|
}
|
|
116
152
|
|
|
117
153
|
render() {
|
|
@@ -119,7 +155,7 @@ export default function overflowShadow(Component, options) {
|
|
|
119
155
|
showLeftShadow,
|
|
120
156
|
showRightShadow
|
|
121
157
|
} = this.state;
|
|
122
|
-
|
|
158
|
+
let classNames = [showRightShadow && shadowClassNames.RIGHT_SHADOW, showLeftShadow && shadowClassNames.LEFT_SHADOW, options.useShadowObserver && shadowObserverClassNames.SHADOW_CONTAINER].filter(Boolean).join(' ');
|
|
123
159
|
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
124
160
|
handleRef: this.handleContainer,
|
|
125
161
|
shadowClassNames: classNames
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
export let ShadowKeys;
|
|
3
|
+
|
|
4
|
+
(function (ShadowKeys) {
|
|
5
|
+
ShadowKeys["SHOW_LEFT_SHADOW"] = "showLeftShadow";
|
|
6
|
+
ShadowKeys["SHOW_RIGHT_SHADOW"] = "showRightShadow";
|
|
7
|
+
})(ShadowKeys || (ShadowKeys = {}));
|
|
8
|
+
|
|
9
|
+
export const shadowObserverClassNames = {
|
|
10
|
+
SENTINEL_LEFT: 'sentinel-left',
|
|
11
|
+
SENTINEL_RIGHT: 'sentinel-right',
|
|
12
|
+
SHADOW_CONTAINER: 'with-shadow-observer'
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const requestIdleCallback = fn => {
|
|
16
|
+
return window.requestIdleCallback ? window.requestIdleCallback(fn) : window.requestAnimationFrame(fn);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const cancelIdleCallback = id => {
|
|
20
|
+
return window.cancelIdleCallback ? window.cancelIdleCallback(id) : window.cancelAnimationFrame(id);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export class ShadowObserver {
|
|
24
|
+
constructor({
|
|
25
|
+
scrollContainer,
|
|
26
|
+
onUpdateShadows
|
|
27
|
+
}) {
|
|
28
|
+
_defineProperty(this, "sentinels", {});
|
|
29
|
+
|
|
30
|
+
_defineProperty(this, "shadowStates", {
|
|
31
|
+
[ShadowKeys.SHOW_LEFT_SHADOW]: false,
|
|
32
|
+
[ShadowKeys.SHOW_RIGHT_SHADOW]: false
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
_defineProperty(this, "init", () => {
|
|
36
|
+
if (!this.scrollContainer || this.intersectionObserver) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
this.sentinels.right = document.createElement('div');
|
|
41
|
+
this.sentinels.right.classList.add(shadowObserverClassNames.SENTINEL_RIGHT);
|
|
42
|
+
this.scrollContainer.appendChild(this.sentinels.right);
|
|
43
|
+
this.sentinels.left = document.createElement('div');
|
|
44
|
+
this.sentinels.left.classList.add(shadowObserverClassNames.SENTINEL_LEFT);
|
|
45
|
+
this.scrollContainer.prepend(this.sentinels.left);
|
|
46
|
+
this.intersectionObserver = new IntersectionObserver((entries, _) => {
|
|
47
|
+
entries.forEach(this.onIntersect);
|
|
48
|
+
}, {
|
|
49
|
+
root: this.scrollContainer
|
|
50
|
+
});
|
|
51
|
+
this.intersectionObserver.observe(this.sentinels.left);
|
|
52
|
+
this.intersectionObserver.observe(this.sentinels.right);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
_defineProperty(this, "onIntersect", entry => {
|
|
56
|
+
this.requestCallbackId = requestIdleCallback(() => {
|
|
57
|
+
if (entry.target.classList.contains(shadowObserverClassNames.SENTINEL_LEFT)) {
|
|
58
|
+
this.shadowStates[ShadowKeys.SHOW_LEFT_SHADOW] = !entry.isIntersecting;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (entry.target.classList.contains(shadowObserverClassNames.SENTINEL_RIGHT)) {
|
|
62
|
+
this.shadowStates[ShadowKeys.SHOW_RIGHT_SHADOW] = !entry.isIntersecting;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
this.onUpdateShadows(this.shadowStates);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
this.scrollContainer = scrollContainer;
|
|
70
|
+
this.onUpdateShadows = onUpdateShadows;
|
|
71
|
+
this.init();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
dispose() {
|
|
75
|
+
if (this.intersectionObserver) {
|
|
76
|
+
this.intersectionObserver.disconnect();
|
|
77
|
+
this.intersectionObserver = undefined;
|
|
78
|
+
this.requestCallbackId && cancelIdleCallback(this.requestCallbackId);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
}
|
package/dist/es2019/ui/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export { BaseTheme, mapBreakpointToLayoutMaxWidth } from './BaseTheme';
|
|
|
10
10
|
export { default as withOuterListeners } from './with-outer-listeners';
|
|
11
11
|
export { WidthConsumer, WidthProvider, getBreakpoint } from './WidthProvider';
|
|
12
12
|
export { default as overflowShadow, shadowClassNames } from './OverflowShadow';
|
|
13
|
+
export { shadowObserverClassNames, ShadowObserver } from './OverflowShadow/shadowObserver';
|
|
13
14
|
export { WithCreateAnalyticsEvent } from './WithCreateAnalyticsEvent';
|
|
14
15
|
export { messages as expandMessages, sharedExpandStyles, ExpandIconWrapper, expandLayoutWrapperStyle, ExpandLayoutWrapperWithRef } from './Expand';
|
|
15
16
|
export { ErrorMessage, HelperMessage, ValidMessage } from './Messages';
|
|
@@ -29,7 +29,7 @@ const breakoutConsts = {
|
|
|
29
29
|
return '100%';
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
|
-
calcLineLength: (
|
|
32
|
+
calcLineLength: () => breakoutConsts.defaultLayoutWidth,
|
|
33
33
|
calcWideWidth: (containerWidth = breakoutConsts.defaultLayoutWidth, maxWidth = Infinity, fallback = '100%') => {
|
|
34
34
|
const effectiveFullWidth = containerWidth - breakoutConsts.padding;
|
|
35
35
|
const layoutMaxWidth = breakoutConsts.mapBreakpointToLayoutMaxWidth(breakoutConsts.getBreakpoint(containerWidth));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { validator } from '@atlaskit/adf-utils';
|
|
1
|
+
import { validator } from '@atlaskit/adf-utils/validator';
|
|
2
2
|
export const UNSUPPORTED_NODE_ATTRIBUTE = 'unsupportedNodeAttribute';
|
|
3
3
|
import { ACTION_SUBJECT_ID } from './analytics';
|
|
4
4
|
import { fireUnsupportedEvent } from './track-unsupported-content';
|
package/dist/es2019/version.json
CHANGED
|
@@ -3,4 +3,4 @@ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral
|
|
|
3
3
|
var _templateObject;
|
|
4
4
|
|
|
5
5
|
import { css } from '@emotion/react';
|
|
6
|
-
export var blockMarksSharedStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n /**\n * We need to remove margin-top from first item\n * inside doc, tableCell, tableHeader, blockquote, etc.\n */\n *:not(.fabric-editor-block-mark) >,\n /* For nested block marks */\n *:not(.fabric-editor-block-mark) > div.fabric-editor-block-mark:first-
|
|
6
|
+
export var blockMarksSharedStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n /**\n * We need to remove margin-top from first item\n * inside doc, tableCell, tableHeader, blockquote, etc.\n */\n *:not(.fabric-editor-block-mark) >,\n /* For nested block marks */\n *:not(.fabric-editor-block-mark) > div.fabric-editor-block-mark:first-of-type {\n p,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n .heading-wrapper {\n :first-child:not(style),\n style:first-child + * {\n margin-top: 0;\n }\n }\n }\n"])));
|
|
@@ -4,5 +4,5 @@ var _templateObject;
|
|
|
4
4
|
|
|
5
5
|
import { css } from '@emotion/react';
|
|
6
6
|
import { gridMediumMaxWidth } from '@atlaskit/editor-shared-styles';
|
|
7
|
-
var columnLayoutSharedStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n [data-layout-section] {\n display: flex;\n flex-direction: row;\n & > * {\n flex: 1;\n min-width: 0;\n }\n\n & > .unsupportedBlockView-content-wrap {\n min-width: initial;\n }\n\n @media screen and (max-width: ", "px) {\n flex-direction: column;\n }\n }\n"])), gridMediumMaxWidth);
|
|
7
|
+
var columnLayoutSharedStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n [data-layout-section] {\n position: relative;\n display: flex;\n flex-direction: row;\n & > * {\n flex: 1;\n min-width: 0;\n }\n\n & > .unsupportedBlockView-content-wrap {\n min-width: initial;\n }\n\n @media screen and (max-width: ", "px) {\n flex-direction: column;\n }\n }\n"])), gridMediumMaxWidth);
|
|
8
8
|
export { columnLayoutSharedStyle };
|
|
@@ -8,6 +8,7 @@ import { css } from '@emotion/react';
|
|
|
8
8
|
import { akEditorShadowZIndex } from '@atlaskit/editor-shared-styles';
|
|
9
9
|
import { N40A } from '@atlaskit/theme/colors';
|
|
10
10
|
import { shadowClassNames } from '../../ui/OverflowShadow';
|
|
11
|
+
import { shadowObserverClassNames } from '../../ui/OverflowShadow/shadowObserver';
|
|
11
12
|
var shadowWidth = 8;
|
|
12
13
|
/**
|
|
13
14
|
* TODO: This is close to working and removes a tone of JS from OverflowShadow component
|
|
@@ -23,5 +24,5 @@ var shadowWidth = 8;
|
|
|
23
24
|
* background-attachment: local, local, scroll, scroll;
|
|
24
25
|
*/
|
|
25
26
|
|
|
26
|
-
var shadowSharedStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &\n .", "::before,\n .", "::after,\n .", "::before,\n .", "::after {\n display: none;\n position: absolute;\n pointer-events: none;\n z-index: ", ";\n width: ", "px;\n content: '';\n /* Scrollbar is outside the content in IE, inset in other browsers. */\n height: calc(100%);\n }\n\n & .", ", .", " {\n position: relative;\n }\n\n & .", "::before {\n background: linear-gradient(to left, rgba(99, 114, 130, 0) 0, ", " 100%);\n top: 0px;\n left: 0;\n display: block;\n }\n\n & .", "::after {\n background: linear-gradient(\n to right,\n rgba(99, 114, 130, 0) 0,\n ", " 100%\n );\n left: calc(100% - ", "px);\n top: 0px;\n display: block;\n }\n"])), shadowClassNames.RIGHT_SHADOW, shadowClassNames.RIGHT_SHADOW, shadowClassNames.LEFT_SHADOW, shadowClassNames.LEFT_SHADOW, akEditorShadowZIndex, shadowWidth, shadowClassNames.RIGHT_SHADOW, shadowClassNames.LEFT_SHADOW, shadowClassNames.LEFT_SHADOW, N40A, shadowClassNames.RIGHT_SHADOW, N40A, shadowWidth);
|
|
27
|
+
var shadowSharedStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &\n .", "::before,\n .", "::after,\n .", "::before,\n .", "::after {\n display: none;\n position: absolute;\n pointer-events: none;\n z-index: ", ";\n width: ", "px;\n content: '';\n /* Scrollbar is outside the content in IE, inset in other browsers. */\n height: calc(100%);\n }\n\n & .", ", .", " {\n position: relative;\n }\n\n & .", "::before {\n background: linear-gradient(to left, rgba(99, 114, 130, 0) 0, ", " 100%);\n top: 0px;\n left: 0;\n display: block;\n }\n\n & .", "::after {\n background: linear-gradient(\n to right,\n rgba(99, 114, 130, 0) 0,\n ", " 100%\n );\n left: calc(100% - ", "px);\n top: 0px;\n display: block;\n }\n & .", " {\n height: 100%;\n width: 0px;\n min-width: 0px;\n }\n\n & .", " {\n height: 100%;\n width: 0px;\n min-width: 0px;\n }\n"])), shadowClassNames.RIGHT_SHADOW, shadowClassNames.RIGHT_SHADOW, shadowClassNames.LEFT_SHADOW, shadowClassNames.LEFT_SHADOW, akEditorShadowZIndex, shadowWidth, shadowClassNames.RIGHT_SHADOW, shadowClassNames.LEFT_SHADOW, shadowClassNames.LEFT_SHADOW, N40A, shadowClassNames.RIGHT_SHADOW, N40A, shadowWidth, shadowObserverClassNames.SENTINEL_LEFT, shadowObserverClassNames.SENTINEL_RIGHT);
|
|
27
28
|
export { shadowSharedStyle };
|
|
@@ -36,7 +36,7 @@ export var TableSharedCssClassName = {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
var tableSharedStyle = function tableSharedStyle(props) {
|
|
39
|
-
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .", " {\n position: relative;\n margin: 0 auto ", "px;\n box-sizing: border-box;\n\n /**\n * Fix block top alignment inside table cells.\n */\n .decisionItemView-content-wrap:first-
|
|
39
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .", " {\n position: relative;\n margin: 0 auto ", "px;\n box-sizing: border-box;\n\n /**\n * Fix block top alignment inside table cells.\n */\n .decisionItemView-content-wrap:first-of-type > div {\n margin-top: 0;\n }\n }\n .", "[data-number-column='true'] {\n padding-left: ", "px;\n clear: both;\n }\n .", " > table {\n margin: ", "px 0 0 0;\n }\n\n .", " > table,\n .", " > table {\n margin: ", "px ", "px 0 0;\n }\n\n /* avoid applying styles to nested tables (possible via extensions) */\n .", " > table,\n .", " > table,\n .", " > table {\n border-collapse: collapse;\n border: ", "px solid\n ", ";\n table-layout: fixed;\n font-size: 1em;\n width: 100%;\n\n &[data-autosize='true'] {\n table-layout: auto;\n }\n\n & {\n * {\n box-sizing: border-box;\n }\n hr {\n box-sizing: content-box;\n }\n\n tbody {\n border-bottom: none;\n }\n th td {\n background-color: ", ";\n }\n th,\n td {\n min-width: ", "px;\n font-weight: normal;\n vertical-align: top;\n border: 1px solid\n ", ";\n border-right-width: 0;\n border-bottom-width: 0;\n padding: ", "px;\n /* https://stackoverflow.com/questions/7517127/borders-not-shown-in-firefox-with-border-collapse-on-table-position-relative-o */\n ", "\n\n ", ";\n\n > :first-child:not(style),\n > style:first-child + * {\n margin-top: 0;\n }\n\n > .ProseMirror-gapcursor.-right:first-of-type + * {\n margin-top: 0;\n }\n\n > .ProseMirror-gapcursor:first-of-type + span + * {\n margin-top: 0;\n }\n\n th p:not(:first-of-type),\n td p:not(:first-of-type) {\n margin-top: 12px;\n }\n }\n th {\n background-color: ", ";\n text-align: left;\n\n /* only apply this styling to codeblocks in default background headercells */\n /* TODO this needs to be overhauled as it relies on unsafe selectors */\n &:not([style]) {\n .code-block {\n background-image: ", ";\n background-attachment: local, scroll, scroll;\n background-position: 100% 0, 100% 0, 0 0;\n background-color: ", ";\n\n .line-number-gutter {\n background-color: ", ";\n }\n\n /* this is only relevant to the element taken care of by renderer */\n > [data-ds--code--code-block] {\n background-image: ", "!important;\n\n background-color: ", "!important;\n\n // selector lives inside @atlaskit/code\n --ds--code--line-number-bg-color: ", ";\n }\n }\n }\n }\n }\n }\n"])), TableSharedCssClassName.TABLE_CONTAINER, tableMarginBottom, TableSharedCssClassName.TABLE_CONTAINER, akEditorTableNumberColumnWidth - 1, TableSharedCssClassName.TABLE_NODE_WRAPPER, tableMarginTop, TableSharedCssClassName.TABLE_CONTAINER, TableSharedCssClassName.TABLE_STICKY_WRAPPER, tableMarginTop, tableMarginSides, TableSharedCssClassName.TABLE_CONTAINER, TableSharedCssClassName.TABLE_NODE_WRAPPER, TableSharedCssClassName.TABLE_STICKY_WRAPPER, tableCellBorderWidth, themed({
|
|
40
40
|
light: token('color.border', akEditorTableBorder),
|
|
41
41
|
dark: token('color.border', akEditorTableBorderDark)
|
|
42
42
|
})(props), token('color.background.neutral.subtle', 'white'), tableCellMinWidth, themed({
|
|
@@ -7,4 +7,4 @@ import { akEditorTableCellMinWidth } from '@atlaskit/editor-shared-styles';
|
|
|
7
7
|
export var TaskDecisionSharedCssClassName = {
|
|
8
8
|
DECISION_CONTAINER: 'decisionItemView-content-wrap'
|
|
9
9
|
};
|
|
10
|
-
export var tasksAndDecisionsStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ProseMirror {\n .taskItemView-content-wrap,\n .", " {\n position: relative;\n min-width: ", "px;\n }\n\n .", " {\n margin-top: 0;\n }\n }\n\n div[data-task-list-local-id] {\n margin: 12px 0 0 0;\n }\n\n div[data-task-list-local-id]:first-child {\n margin-top: 0;\n }\n\n div[data-task-list-local-id] div[data-task-list-local-id] {\n margin-top: 0px;\n margin-left: 24px;\n }\n"])), TaskDecisionSharedCssClassName.DECISION_CONTAINER, akEditorTableCellMinWidth, TaskDecisionSharedCssClassName.DECISION_CONTAINER);
|
|
10
|
+
export var tasksAndDecisionsStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ProseMirror {\n .taskItemView-content-wrap,\n .", " {\n position: relative;\n min-width: ", "px;\n }\n\n .", " {\n margin-top: 0;\n }\n }\n\n div[data-task-list-local-id] {\n margin: 12px 0 0 0;\n }\n\n // If task list is first in the document then set margin top to zero.\n div[data-task-list-local-id]:first-child,\n style:first-child + div[data-task-list-local-id] {\n margin-top: 0;\n }\n\n div[data-task-list-local-id] div[data-task-list-local-id] {\n margin-top: 0px;\n margin-left: 24px;\n }\n"])), TaskDecisionSharedCssClassName.DECISION_CONTAINER, akEditorTableCellMinWidth, TaskDecisionSharedCssClassName.DECISION_CONTAINER);
|
|
@@ -5,20 +5,6 @@ import { akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
|
5
5
|
import { useGlobalTheme } from '@atlaskit/theme/components';
|
|
6
6
|
import { CHANNEL, fontSize } from '@atlaskit/theme/constants';
|
|
7
7
|
import { WidthConsumer } from '../WidthProvider';
|
|
8
|
-
|
|
9
|
-
function mapBreakpointToFontSize(breakpoint) {
|
|
10
|
-
switch (breakpoint) {
|
|
11
|
-
case 'M':
|
|
12
|
-
return fontSize() + 2;
|
|
13
|
-
|
|
14
|
-
case 'L':
|
|
15
|
-
return fontSize() + 4;
|
|
16
|
-
|
|
17
|
-
default:
|
|
18
|
-
return fontSize();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
8
|
export function mapBreakpointToLayoutMaxWidth(breakpoint) {
|
|
23
9
|
switch (breakpoint) {
|
|
24
10
|
case 'M':
|
|
@@ -32,9 +18,7 @@ export function mapBreakpointToLayoutMaxWidth(breakpoint) {
|
|
|
32
18
|
}
|
|
33
19
|
}
|
|
34
20
|
export function BaseThemeWrapper(_ref) {
|
|
35
|
-
var
|
|
36
|
-
dynamicTextSizing = _ref.dynamicTextSizing,
|
|
37
|
-
baseFontSize = _ref.baseFontSize,
|
|
21
|
+
var baseFontSize = _ref.baseFontSize,
|
|
38
22
|
children = _ref.children;
|
|
39
23
|
|
|
40
24
|
var _useGlobalTheme = useGlobalTheme(),
|
|
@@ -42,24 +26,22 @@ export function BaseThemeWrapper(_ref) {
|
|
|
42
26
|
|
|
43
27
|
var memoizedTheme = useMemo(function () {
|
|
44
28
|
return _defineProperty({
|
|
45
|
-
baseFontSize:
|
|
46
|
-
layoutMaxWidth:
|
|
29
|
+
baseFontSize: baseFontSize || fontSize(),
|
|
30
|
+
layoutMaxWidth: akEditorDefaultLayoutWidth
|
|
47
31
|
}, CHANNEL, {
|
|
48
32
|
mode: mode
|
|
49
33
|
});
|
|
50
|
-
}, [
|
|
34
|
+
}, [baseFontSize, mode]);
|
|
51
35
|
return /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
52
36
|
theme: memoizedTheme
|
|
53
37
|
}, children);
|
|
54
38
|
}
|
|
55
39
|
export function BaseTheme(_ref3) {
|
|
56
40
|
var children = _ref3.children,
|
|
57
|
-
dynamicTextSizing = _ref3.dynamicTextSizing,
|
|
58
41
|
baseFontSize = _ref3.baseFontSize;
|
|
59
42
|
return /*#__PURE__*/React.createElement(WidthConsumer, null, function (_ref4) {
|
|
60
43
|
var breakpoint = _ref4.breakpoint;
|
|
61
44
|
return /*#__PURE__*/React.createElement(BaseThemeWrapper, {
|
|
62
|
-
dynamicTextSizing: dynamicTextSizing,
|
|
63
45
|
breakpoint: breakpoint,
|
|
64
46
|
baseFontSize: baseFontSize
|
|
65
47
|
}, /*#__PURE__*/React.createElement(React.Fragment, null, children));
|
|
@@ -88,7 +88,7 @@ var containerStyles = function containerStyles(styleProps) {
|
|
|
88
88
|
var marginHorizontal = styleProps['data-node-type'] === 'expand' ? "-".concat(akLayoutGutterOffset, "px") : 0;
|
|
89
89
|
var margin = "".concat(marginTop, " ").concat(marginHorizontal, " ").concat(marginBottom);
|
|
90
90
|
return function (themeProps) {
|
|
91
|
-
return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n border-width: 1px;\n border-style: solid;\n border-color: ", ";\n border-radius: ", "px;\n min-height: 25px;\n background: ", ";\n margin: ", ";\n\n transition: background 0.3s ", ",\n border-color 0.3s ", ";\n padding: ", "px;\n\n // TODO: https://product-fabric.atlassian.net/browse/DSP-4152\n &:hover {\n border: 1px solid\n ", ";\n background: ", ";\n }\n\n td >
|
|
91
|
+
return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n border-width: 1px;\n border-style: solid;\n border-color: ", ";\n border-radius: ", "px;\n min-height: 25px;\n background: ", ";\n margin: ", ";\n\n transition: background 0.3s ", ",\n border-color 0.3s ", ";\n padding: ", "px;\n\n // TODO: https://product-fabric.atlassian.net/browse/DSP-4152\n &:hover {\n border: 1px solid\n ", ";\n background: ", ";\n }\n\n td > :not(style):first-child,\n td > style:first-child + * {\n margin-top: 0;\n }\n "])), focused ? EXPAND_FOCUSED_BORDER_COLOR : expanded ? EXPAND_EXPANDED_BORDER_COLOR(themeProps) : EXPAND_COLLAPSED_BORDER_COLOR, BORDER_RADIUS, !expanded ? EXPAND_COLLAPSED_BACKGROUND : EXPAND_SELECTED_BACKGROUND(themeProps), margin, akEditorSwoopCubicBezier, akEditorSwoopCubicBezier, gridSize(), themed({
|
|
92
92
|
light: token('color.border', colors.N50A),
|
|
93
93
|
dark: token('color.border', colors.DN50)
|
|
94
94
|
})(themeProps), EXPAND_SELECTED_BACKGROUND(themeProps));
|
|
@@ -12,12 +12,11 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
12
12
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
13
13
|
|
|
14
14
|
import React from 'react';
|
|
15
|
-
import
|
|
15
|
+
import { ShadowObserver, shadowObserverClassNames } from './shadowObserver';
|
|
16
16
|
export var shadowClassNames = {
|
|
17
17
|
RIGHT_SHADOW: 'right-shadow',
|
|
18
18
|
LEFT_SHADOW: 'left-shadow'
|
|
19
19
|
};
|
|
20
|
-
var isIE11 = browser.ie_version === 11;
|
|
21
20
|
export default function overflowShadow(Component, options) {
|
|
22
21
|
return /*#__PURE__*/function (_React$Component) {
|
|
23
22
|
_inherits(OverflowShadow, _React$Component);
|
|
@@ -35,13 +34,15 @@ export default function overflowShadow(Component, options) {
|
|
|
35
34
|
|
|
36
35
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
37
36
|
|
|
37
|
+
_defineProperty(_assertThisInitialized(_this), "overflowContainerWidth", 0);
|
|
38
|
+
|
|
38
39
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
39
40
|
showLeftShadow: false,
|
|
40
41
|
showRightShadow: false
|
|
41
42
|
});
|
|
42
43
|
|
|
43
44
|
_defineProperty(_assertThisInitialized(_this), "handleScroll", function (event) {
|
|
44
|
-
if (!_this.overflowContainer || event.target !== _this.overflowContainer) {
|
|
45
|
+
if (!_this.overflowContainer || event.target !== _this.overflowContainer || options.useShadowObserver) {
|
|
45
46
|
return;
|
|
46
47
|
}
|
|
47
48
|
|
|
@@ -49,6 +50,10 @@ export default function overflowShadow(Component, options) {
|
|
|
49
50
|
});
|
|
50
51
|
|
|
51
52
|
_defineProperty(_assertThisInitialized(_this), "updateShadows", function () {
|
|
53
|
+
if (options.useShadowObserver) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
52
57
|
_this.setState(function (prevState) {
|
|
53
58
|
if (!_this.overflowContainer) {
|
|
54
59
|
return;
|
|
@@ -115,15 +120,15 @@ export default function overflowShadow(Component, options) {
|
|
|
115
120
|
_this.overflowContainer = container;
|
|
116
121
|
}
|
|
117
122
|
|
|
118
|
-
if (options.
|
|
119
|
-
_this.
|
|
123
|
+
if (options.useShadowObserver) {
|
|
124
|
+
_this.initShadowObserver();
|
|
125
|
+
|
|
126
|
+
return;
|
|
120
127
|
}
|
|
121
128
|
|
|
122
129
|
_this.updateShadows();
|
|
123
130
|
|
|
124
|
-
|
|
125
|
-
_this.overflowContainer.addEventListener('scroll', _this.handleScroll);
|
|
126
|
-
}
|
|
131
|
+
_this.overflowContainer.addEventListener('scroll', _this.handleScroll);
|
|
127
132
|
});
|
|
128
133
|
|
|
129
134
|
return _this;
|
|
@@ -132,7 +137,11 @@ export default function overflowShadow(Component, options) {
|
|
|
132
137
|
_createClass(OverflowShadow, [{
|
|
133
138
|
key: "componentWillUnmount",
|
|
134
139
|
value: function componentWillUnmount() {
|
|
135
|
-
if (
|
|
140
|
+
if (options.useShadowObserver) {
|
|
141
|
+
return this.shadowObserver && this.shadowObserver.dispose();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (this.overflowContainer) {
|
|
136
145
|
this.overflowContainer.removeEventListener('scroll', this.handleScroll);
|
|
137
146
|
}
|
|
138
147
|
|
|
@@ -141,7 +150,37 @@ export default function overflowShadow(Component, options) {
|
|
|
141
150
|
}, {
|
|
142
151
|
key: "componentDidUpdate",
|
|
143
152
|
value: function componentDidUpdate() {
|
|
144
|
-
|
|
153
|
+
if (!options.useShadowObserver) {
|
|
154
|
+
this.updateShadows();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}, {
|
|
158
|
+
key: "initShadowObserver",
|
|
159
|
+
value: function initShadowObserver() {
|
|
160
|
+
var _this2 = this;
|
|
161
|
+
|
|
162
|
+
if (this.shadowObserver || !this.overflowContainer) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
this.shadowObserver = new ShadowObserver({
|
|
167
|
+
scrollContainer: this.overflowContainer,
|
|
168
|
+
onUpdateShadows: function onUpdateShadows(shadowStates) {
|
|
169
|
+
_this2.setState(function (prevState) {
|
|
170
|
+
var showLeftShadow = shadowStates.showLeftShadow,
|
|
171
|
+
showRightShadow = shadowStates.showRightShadow;
|
|
172
|
+
|
|
173
|
+
if (showLeftShadow !== prevState.showLeftShadow || showRightShadow !== prevState.showRightShadow) {
|
|
174
|
+
return {
|
|
175
|
+
showLeftShadow: showLeftShadow,
|
|
176
|
+
showRightShadow: showRightShadow
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return null;
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
});
|
|
145
184
|
}
|
|
146
185
|
}, {
|
|
147
186
|
key: "render",
|
|
@@ -149,7 +188,7 @@ export default function overflowShadow(Component, options) {
|
|
|
149
188
|
var _this$state = this.state,
|
|
150
189
|
showLeftShadow = _this$state.showLeftShadow,
|
|
151
190
|
showRightShadow = _this$state.showRightShadow;
|
|
152
|
-
var classNames = [showRightShadow && shadowClassNames.RIGHT_SHADOW, showLeftShadow && shadowClassNames.LEFT_SHADOW].filter(Boolean).join(' ');
|
|
191
|
+
var classNames = [showRightShadow && shadowClassNames.RIGHT_SHADOW, showLeftShadow && shadowClassNames.LEFT_SHADOW, options.useShadowObserver && shadowObserverClassNames.SHADOW_CONTAINER].filter(Boolean).join(' ');
|
|
153
192
|
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
154
193
|
handleRef: this.handleContainer,
|
|
155
194
|
shadowClassNames: classNames
|