@atlaskit/editor-common 67.0.1 → 68.0.0

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/styles/shared/block-marks.js +1 -1
  3. package/dist/cjs/styles/shared/column-layout.js +1 -1
  4. package/dist/cjs/styles/shared/shadow.js +3 -1
  5. package/dist/cjs/styles/shared/table.js +1 -1
  6. package/dist/cjs/styles/shared/task-decision.js +1 -1
  7. package/dist/cjs/ui/BaseTheme/index.js +4 -21
  8. package/dist/cjs/ui/OverflowShadow/index.js +49 -11
  9. package/dist/cjs/ui/OverflowShadow/shadowObserver.js +107 -0
  10. package/dist/cjs/ui/index.js +14 -0
  11. package/dist/cjs/utils/breakout.js +2 -2
  12. package/dist/cjs/utils/unsupportedContent/get-unsupported-content-level-data.js +3 -3
  13. package/dist/cjs/utils/validate-using-spec.js +2 -2
  14. package/dist/cjs/version.json +1 -1
  15. package/dist/es2019/styles/shared/block-marks.js +1 -1
  16. package/dist/es2019/styles/shared/column-layout.js +1 -0
  17. package/dist/es2019/styles/shared/shadow.js +12 -0
  18. package/dist/es2019/styles/shared/table.js +3 -3
  19. package/dist/es2019/styles/shared/task-decision.js +1 -0
  20. package/dist/es2019/ui/BaseTheme/index.js +3 -21
  21. package/dist/es2019/ui/OverflowShadow/index.js +48 -12
  22. package/dist/es2019/ui/OverflowShadow/shadowObserver.js +82 -0
  23. package/dist/es2019/ui/index.js +1 -0
  24. package/dist/es2019/utils/breakout.js +1 -1
  25. package/dist/es2019/utils/unsupportedContent/get-unsupported-content-level-data.js +1 -1
  26. package/dist/es2019/utils/validate-using-spec.js +1 -1
  27. package/dist/es2019/version.json +1 -1
  28. package/dist/esm/styles/shared/block-marks.js +1 -1
  29. package/dist/esm/styles/shared/column-layout.js +1 -1
  30. package/dist/esm/styles/shared/shadow.js +2 -1
  31. package/dist/esm/styles/shared/table.js +1 -1
  32. package/dist/esm/styles/shared/task-decision.js +1 -1
  33. package/dist/esm/ui/BaseTheme/index.js +4 -22
  34. package/dist/esm/ui/OverflowShadow/index.js +50 -11
  35. package/dist/esm/ui/OverflowShadow/shadowObserver.js +98 -0
  36. package/dist/esm/ui/index.js +1 -0
  37. package/dist/esm/utils/breakout.js +2 -2
  38. package/dist/esm/utils/unsupportedContent/get-unsupported-content-level-data.js +1 -1
  39. package/dist/esm/utils/validate-using-spec.js +1 -1
  40. package/dist/esm/version.json +1 -1
  41. package/dist/types/extensions/manifest-helpers.d.ts +1 -1
  42. package/dist/types/extensions/module-helpers.d.ts +1 -1
  43. package/dist/types/extensions/types/extension-handler.d.ts +1 -1
  44. package/dist/types/extensions/types/extension-manifest-toolbar-item.d.ts +1 -1
  45. package/dist/types/extensions/types/extension-manifest.d.ts +1 -1
  46. package/dist/types/extensions/types/utils.d.ts +1 -1
  47. package/dist/types/provider-factory/autoformatting-provider.d.ts +1 -1
  48. package/dist/types/ui/BaseTheme/index.d.ts +2 -4
  49. package/dist/types/ui/OverflowShadow/index.d.ts +10 -3
  50. package/dist/types/ui/OverflowShadow/shadowObserver.d.ts +27 -0
  51. package/dist/types/ui/index.d.ts +1 -0
  52. package/dist/types/utils/unsupportedContent/get-unsupported-content-level-data.d.ts +1 -1
  53. package/dist/types/utils/validate-using-spec.d.ts +2 -1
  54. package/package.json +7 -7
@@ -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 browser from '../../utils/browser';
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.scrollableSelector) {
94
- this.scrollable = container.querySelectorAll(options.scrollableSelector);
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 (this.overflowContainer && !isIE11) {
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
- this.updateShadows();
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
- const classNames = [showRightShadow && shadowClassNames.RIGHT_SHADOW, showLeftShadow && shadowClassNames.LEFT_SHADOW].filter(Boolean).join(' ');
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
+ }
@@ -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: (containerWidth, allowDynamicTextSizing) => allowDynamicTextSizing && containerWidth ? breakoutConsts.mapBreakpointToLayoutMaxWidth(breakoutConsts.getBreakpoint(containerWidth)) : breakoutConsts.defaultLayoutWidth,
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 { traverse } from '@atlaskit/adf-utils';
1
+ import { traverse } from '@atlaskit/adf-utils/traverse';
2
2
  export let UNSUPPORTED_CONTENT_LEVEL_SEVERITY;
3
3
 
4
4
  (function (UNSUPPORTED_CONTENT_LEVEL_SEVERITY) {
@@ -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';
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "67.0.1",
3
+ "version": "68.0.0",
4
4
  "sideEffects": false
5
5
  }
@@ -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-child {\n p,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n .heading-wrapper {\n &:first-child {\n margin-top: 0;\n }\n }\n }\n"])));
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 {\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-child > 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 {\n margin-top: 0;\n }\n\n > .ProseMirror-gapcursor.-right:first-child + * {\n margin-top: 0;\n }\n\n > .ProseMirror-gapcursor:first-child + 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({
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 {\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 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 breakpoint = _ref.breakpoint,
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: dynamicTextSizing ? mapBreakpointToFontSize(breakpoint) : baseFontSize || mapBreakpointToFontSize('S'),
46
- layoutMaxWidth: dynamicTextSizing ? mapBreakpointToLayoutMaxWidth(breakpoint) : akEditorDefaultLayoutWidth
29
+ baseFontSize: baseFontSize || fontSize(),
30
+ layoutMaxWidth: akEditorDefaultLayoutWidth
47
31
  }, CHANNEL, {
48
32
  mode: mode
49
33
  });
50
- }, [breakpoint, dynamicTextSizing, baseFontSize, mode]);
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));
@@ -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 browser from '../../utils/browser';
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.scrollableSelector) {
119
- _this.scrollable = container.querySelectorAll(options.scrollableSelector);
123
+ if (options.useShadowObserver) {
124
+ _this.initShadowObserver();
125
+
126
+ return;
120
127
  }
121
128
 
122
129
  _this.updateShadows();
123
130
 
124
- if (!isIE11) {
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 (this.overflowContainer && !isIE11) {
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
- this.updateShadows();
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
@@ -0,0 +1,98 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ export var ShadowKeys;
5
+
6
+ (function (ShadowKeys) {
7
+ ShadowKeys["SHOW_LEFT_SHADOW"] = "showLeftShadow";
8
+ ShadowKeys["SHOW_RIGHT_SHADOW"] = "showRightShadow";
9
+ })(ShadowKeys || (ShadowKeys = {}));
10
+
11
+ export var shadowObserverClassNames = {
12
+ SENTINEL_LEFT: 'sentinel-left',
13
+ SENTINEL_RIGHT: 'sentinel-right',
14
+ SHADOW_CONTAINER: 'with-shadow-observer'
15
+ };
16
+
17
+ var requestIdleCallback = function requestIdleCallback(fn) {
18
+ return window.requestIdleCallback ? window.requestIdleCallback(fn) : window.requestAnimationFrame(fn);
19
+ };
20
+
21
+ var cancelIdleCallback = function cancelIdleCallback(id) {
22
+ return window.cancelIdleCallback ? window.cancelIdleCallback(id) : window.cancelAnimationFrame(id);
23
+ };
24
+
25
+ export var ShadowObserver = /*#__PURE__*/function () {
26
+ function ShadowObserver(_ref) {
27
+ var _defineProperty2,
28
+ _this = this;
29
+
30
+ var scrollContainer = _ref.scrollContainer,
31
+ onUpdateShadows = _ref.onUpdateShadows;
32
+
33
+ _classCallCheck(this, ShadowObserver);
34
+
35
+ _defineProperty(this, "sentinels", {});
36
+
37
+ _defineProperty(this, "shadowStates", (_defineProperty2 = {}, _defineProperty(_defineProperty2, ShadowKeys.SHOW_LEFT_SHADOW, false), _defineProperty(_defineProperty2, ShadowKeys.SHOW_RIGHT_SHADOW, false), _defineProperty2));
38
+
39
+ _defineProperty(this, "init", function () {
40
+ if (!_this.scrollContainer || _this.intersectionObserver) {
41
+ return;
42
+ }
43
+
44
+ _this.sentinels.right = document.createElement('div');
45
+
46
+ _this.sentinels.right.classList.add(shadowObserverClassNames.SENTINEL_RIGHT);
47
+
48
+ _this.scrollContainer.appendChild(_this.sentinels.right);
49
+
50
+ _this.sentinels.left = document.createElement('div');
51
+
52
+ _this.sentinels.left.classList.add(shadowObserverClassNames.SENTINEL_LEFT);
53
+
54
+ _this.scrollContainer.prepend(_this.sentinels.left);
55
+
56
+ _this.intersectionObserver = new IntersectionObserver(function (entries, _) {
57
+ entries.forEach(_this.onIntersect);
58
+ }, {
59
+ root: _this.scrollContainer
60
+ });
61
+
62
+ _this.intersectionObserver.observe(_this.sentinels.left);
63
+
64
+ _this.intersectionObserver.observe(_this.sentinels.right);
65
+ });
66
+
67
+ _defineProperty(this, "onIntersect", function (entry) {
68
+ _this.requestCallbackId = requestIdleCallback(function () {
69
+ if (entry.target.classList.contains(shadowObserverClassNames.SENTINEL_LEFT)) {
70
+ _this.shadowStates[ShadowKeys.SHOW_LEFT_SHADOW] = !entry.isIntersecting;
71
+ }
72
+
73
+ if (entry.target.classList.contains(shadowObserverClassNames.SENTINEL_RIGHT)) {
74
+ _this.shadowStates[ShadowKeys.SHOW_RIGHT_SHADOW] = !entry.isIntersecting;
75
+ }
76
+
77
+ _this.onUpdateShadows(_this.shadowStates);
78
+ });
79
+ });
80
+
81
+ this.scrollContainer = scrollContainer;
82
+ this.onUpdateShadows = onUpdateShadows;
83
+ this.init();
84
+ }
85
+
86
+ _createClass(ShadowObserver, [{
87
+ key: "dispose",
88
+ value: function dispose() {
89
+ if (this.intersectionObserver) {
90
+ this.intersectionObserver.disconnect();
91
+ this.intersectionObserver = undefined;
92
+ this.requestCallbackId && cancelIdleCallback(this.requestCallbackId);
93
+ }
94
+ }
95
+ }]);
96
+
97
+ return ShadowObserver;
98
+ }();
@@ -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,8 +29,8 @@ var breakoutConsts = {
29
29
  return '100%';
30
30
  }
31
31
  },
32
- calcLineLength: function calcLineLength(containerWidth, allowDynamicTextSizing) {
33
- return allowDynamicTextSizing && containerWidth ? breakoutConsts.mapBreakpointToLayoutMaxWidth(breakoutConsts.getBreakpoint(containerWidth)) : breakoutConsts.defaultLayoutWidth;
32
+ calcLineLength: function calcLineLength() {
33
+ return breakoutConsts.defaultLayoutWidth;
34
34
  },
35
35
  calcWideWidth: function calcWideWidth() {
36
36
  var containerWidth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : breakoutConsts.defaultLayoutWidth;
@@ -1,4 +1,4 @@
1
- import { traverse } from '@atlaskit/adf-utils';
1
+ import { traverse } from '@atlaskit/adf-utils/traverse';
2
2
  export var UNSUPPORTED_CONTENT_LEVEL_SEVERITY;
3
3
 
4
4
  (function (UNSUPPORTED_CONTENT_LEVEL_SEVERITY) {
@@ -1,4 +1,4 @@
1
- import { validator } from '@atlaskit/adf-utils';
1
+ import { validator } from '@atlaskit/adf-utils/validator';
2
2
  export var UNSUPPORTED_NODE_ATTRIBUTE = 'unsupportedNodeAttribute';
3
3
  import { ACTION_SUBJECT_ID } from './analytics';
4
4
  import { fireUnsupportedEvent } from './track-unsupported-content';
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "67.0.1",
3
+ "version": "68.0.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,4 +1,4 @@
1
- import { ADFEntity } from '@atlaskit/adf-utils';
1
+ import type { ADFEntity } from '@atlaskit/adf-utils/types';
2
2
  import { ExtensionKey, ExtensionManifest, ExtensionModuleAction, ExtensionModuleActionObject, ExtensionType, Module } from './types/extension-manifest';
3
3
  export declare const FORGE_EXTENSION_TYPE = "com.atlassian.ecosystem";
4
4
  export declare const getExtensionKeyAndNodeKey: (extensionKey: ExtensionKey, extensionType: ExtensionType) => string[];
@@ -1,4 +1,4 @@
1
- import { ADFEntity } from '@atlaskit/adf-utils';
1
+ import type { ADFEntity } from '@atlaskit/adf-utils/types';
2
2
  import { ExtensionAPI, ExtensionAutoConvertHandler, ExtensionManifest, ExtensionModule, ExtensionProvider, ExtensionToolbarButton, MenuItem } from './types';
3
3
  export declare const groupBy: <T>(arr: T[], attr: keyof T, keyRenamer: (key: T[keyof T]) => string) => {
4
4
  [k: string]: T;