@atlaskit/editor-common 71.0.3 → 72.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.
Files changed (148) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/dist/cjs/analytics/types/enums.js +20 -1
  3. package/dist/cjs/i18n/index.js +13 -5
  4. package/dist/cjs/i18n/languages.js +42 -0
  5. package/dist/cjs/keymaps/index.js +56 -6
  6. package/dist/cjs/styles/index.js +8 -2
  7. package/dist/cjs/styles/shared/annotation.js +9 -14
  8. package/dist/cjs/styles/shared/block-marks.js +1 -1
  9. package/dist/cjs/styles/shared/blockquote.js +1 -3
  10. package/dist/cjs/styles/shared/code-block.js +13 -16
  11. package/dist/cjs/styles/shared/code-mark.js +2 -4
  12. package/dist/cjs/styles/shared/lists.js +55 -4
  13. package/dist/cjs/styles/shared/panel.js +29 -39
  14. package/dist/cjs/styles/shared/rule.js +2 -4
  15. package/dist/cjs/styles/shared/shadow.js +1 -1
  16. package/dist/cjs/styles/shared/table.js +24 -26
  17. package/dist/cjs/types/next-editor-plugin.js +5 -0
  18. package/dist/cjs/ui/Caption/index.js +2 -4
  19. package/dist/cjs/ui/DropList/index.js +5 -7
  20. package/dist/cjs/ui/Emoji/index.js +11 -2
  21. package/dist/cjs/ui/Expand/index.js +17 -19
  22. package/dist/cjs/ui/Messages/index.js +3 -5
  23. package/dist/cjs/ui/Popup/index.js +72 -2
  24. package/dist/cjs/ui/Popup/utils.js +13 -6
  25. package/dist/cjs/ui/UnsupportedBlock/index.js +3 -5
  26. package/dist/cjs/ui/UnsupportedInline/index.js +3 -5
  27. package/dist/cjs/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.js +138 -0
  28. package/dist/cjs/ui-color/ColorPalette/index.js +20 -2
  29. package/dist/cjs/ui-menu/DropdownMenu/index.js +12 -12
  30. package/dist/cjs/ui-menu/ToolbarButton/index.js +3 -1
  31. package/dist/cjs/utils/analytics.js +1 -38
  32. package/dist/cjs/utils/builder.js +44 -0
  33. package/dist/cjs/utils/compareNodes.js +86 -33
  34. package/dist/cjs/utils/index.js +47 -1
  35. package/dist/cjs/utils/list.js +47 -0
  36. package/dist/cjs/utils/plugin-state-factory.js +9 -9
  37. package/dist/cjs/utils/referentiality.js +281 -2
  38. package/dist/cjs/utils/track-unsupported-content.js +19 -20
  39. package/dist/cjs/utils/validate-using-spec.js +8 -2
  40. package/dist/cjs/version.json +1 -1
  41. package/dist/es2019/analytics/types/enums.js +20 -1
  42. package/dist/es2019/i18n/index.js +4 -3
  43. package/dist/es2019/i18n/languages.js +34 -0
  44. package/dist/es2019/keymaps/index.js +48 -2
  45. package/dist/es2019/styles/index.js +1 -1
  46. package/dist/es2019/styles/shared/annotation.js +9 -13
  47. package/dist/es2019/styles/shared/block-marks.js +8 -1
  48. package/dist/es2019/styles/shared/blockquote.js +1 -2
  49. package/dist/es2019/styles/shared/code-block.js +18 -18
  50. package/dist/es2019/styles/shared/code-mark.js +2 -3
  51. package/dist/es2019/styles/shared/lists.js +44 -2
  52. package/dist/es2019/styles/shared/panel.js +29 -37
  53. package/dist/es2019/styles/shared/rule.js +2 -3
  54. package/dist/es2019/styles/shared/shadow.js +20 -6
  55. package/dist/es2019/styles/shared/table.js +24 -26
  56. package/dist/es2019/types/next-editor-plugin.js +1 -0
  57. package/dist/es2019/ui/Caption/index.js +2 -3
  58. package/dist/es2019/ui/DropList/index.js +5 -6
  59. package/dist/es2019/ui/Emoji/index.js +11 -2
  60. package/dist/es2019/ui/Expand/index.js +17 -18
  61. package/dist/es2019/ui/Messages/index.js +3 -4
  62. package/dist/es2019/ui/Popup/index.js +68 -2
  63. package/dist/es2019/ui/Popup/utils.js +13 -6
  64. package/dist/es2019/ui/UnsupportedBlock/index.js +3 -4
  65. package/dist/es2019/ui/UnsupportedInline/index.js +3 -4
  66. package/dist/es2019/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.js +120 -0
  67. package/dist/es2019/ui-color/ColorPalette/index.js +29 -13
  68. package/dist/es2019/ui-menu/DropdownMenu/index.js +13 -12
  69. package/dist/es2019/ui-menu/ToolbarButton/index.js +3 -1
  70. package/dist/es2019/utils/analytics.js +0 -33
  71. package/dist/es2019/utils/builder.js +16 -0
  72. package/dist/es2019/utils/compareNodes.js +79 -28
  73. package/dist/es2019/utils/index.js +4 -2
  74. package/dist/es2019/utils/list.js +31 -0
  75. package/dist/es2019/utils/plugin-state-factory.js +9 -9
  76. package/dist/es2019/utils/referentiality.js +240 -0
  77. package/dist/es2019/utils/track-unsupported-content.js +20 -16
  78. package/dist/es2019/utils/validate-using-spec.js +8 -2
  79. package/dist/es2019/version.json +1 -1
  80. package/dist/esm/analytics/types/enums.js +20 -1
  81. package/dist/esm/i18n/index.js +4 -3
  82. package/dist/esm/i18n/languages.js +34 -0
  83. package/dist/esm/keymaps/index.js +49 -2
  84. package/dist/esm/styles/index.js +1 -1
  85. package/dist/esm/styles/shared/annotation.js +9 -13
  86. package/dist/esm/styles/shared/block-marks.js +1 -1
  87. package/dist/esm/styles/shared/blockquote.js +1 -2
  88. package/dist/esm/styles/shared/code-block.js +13 -15
  89. package/dist/esm/styles/shared/code-mark.js +2 -3
  90. package/dist/esm/styles/shared/lists.js +49 -2
  91. package/dist/esm/styles/shared/panel.js +29 -37
  92. package/dist/esm/styles/shared/rule.js +2 -3
  93. package/dist/esm/styles/shared/shadow.js +1 -2
  94. package/dist/esm/styles/shared/table.js +24 -26
  95. package/dist/esm/types/next-editor-plugin.js +1 -0
  96. package/dist/esm/ui/Caption/index.js +2 -3
  97. package/dist/esm/ui/DropList/index.js +5 -6
  98. package/dist/esm/ui/Emoji/index.js +11 -2
  99. package/dist/esm/ui/Expand/index.js +17 -18
  100. package/dist/esm/ui/Messages/index.js +3 -4
  101. package/dist/esm/ui/Popup/index.js +73 -2
  102. package/dist/esm/ui/Popup/utils.js +13 -6
  103. package/dist/esm/ui/UnsupportedBlock/index.js +2 -3
  104. package/dist/esm/ui/UnsupportedInline/index.js +2 -3
  105. package/dist/esm/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.js +124 -0
  106. package/dist/esm/ui-color/ColorPalette/index.js +19 -3
  107. package/dist/esm/ui-menu/DropdownMenu/index.js +12 -11
  108. package/dist/esm/ui-menu/ToolbarButton/index.js +3 -1
  109. package/dist/esm/utils/analytics.js +0 -33
  110. package/dist/esm/utils/builder.js +30 -0
  111. package/dist/esm/utils/compareNodes.js +83 -32
  112. package/dist/esm/utils/index.js +4 -2
  113. package/dist/esm/utils/list.js +31 -0
  114. package/dist/esm/utils/plugin-state-factory.js +9 -9
  115. package/dist/esm/utils/referentiality.js +269 -0
  116. package/dist/esm/utils/track-unsupported-content.js +19 -20
  117. package/dist/esm/utils/validate-using-spec.js +8 -2
  118. package/dist/esm/version.json +1 -1
  119. package/dist/types/analytics/types/enums.d.ts +23 -4
  120. package/dist/types/collab/types.d.ts +1 -1
  121. package/dist/types/i18n/index.d.ts +4 -3
  122. package/dist/types/i18n/languages.d.ts +35 -0
  123. package/dist/types/keymaps/index.d.ts +1 -0
  124. package/dist/types/styles/index.d.ts +1 -1
  125. package/dist/types/styles/shared/lists.d.ts +3 -1
  126. package/dist/types/types/collab.d.ts +1 -1
  127. package/dist/types/types/copy-button.d.ts +4 -0
  128. package/dist/types/types/feature-flags.d.ts +30 -25
  129. package/dist/types/types/floating-toolbar.d.ts +26 -1
  130. package/dist/types/types/index.d.ts +2 -1
  131. package/dist/types/types/next-editor-plugin.d.ts +61 -0
  132. package/dist/types/ui/Emoji/index.d.ts +2 -0
  133. package/dist/types/ui/Popup/index.d.ts +19 -0
  134. package/dist/types/ui/Popup/utils.d.ts +3 -3
  135. package/dist/types/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.d.ts +214 -0
  136. package/dist/types/ui-color/ColorPalette/index.d.ts +7 -0
  137. package/dist/types/ui-menu/DropdownMenu/types.d.ts +1 -0
  138. package/dist/types/ui-menu/ToolbarButton/index.d.ts +3 -1
  139. package/dist/types/utils/analytics.d.ts +1 -21
  140. package/dist/types/utils/builder.d.ts +8 -0
  141. package/dist/types/utils/compareNodes.d.ts +16 -0
  142. package/dist/types/utils/index.d.ts +3 -1
  143. package/dist/types/utils/list.d.ts +10 -0
  144. package/dist/types/utils/plugin-state-factory.d.ts +1 -1
  145. package/dist/types/utils/referentiality.d.ts +4 -0
  146. package/dist/types/utils/track-unsupported-content.d.ts +14 -2
  147. package/package.json +15 -12
  148. package/report.api.md +1 -1
@@ -1,12 +1,10 @@
1
1
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
2
- // TODO: https://product-fabric.atlassian.net/browse/DSP-4118
3
2
  import { css } from '@emotion/react';
4
3
  import { tableCellContentDomSelector, tableCellSelector, tableHeaderSelector, tablePrefixSelector } from '@atlaskit/adf-schema';
5
4
  import { akEditorBreakoutPadding, akEditorFullWidthLayoutWidth, akEditorSelectedNodeClassName, akEditorTableBorder, akEditorTableBorderDark, akEditorTableNumberColumnWidth, akEditorTableToolbar, akEditorTableToolbarDark, akEditorWideLayoutWidth, getTableCellBackgroundDarkModeColors, overflowShadow } from '@atlaskit/editor-shared-styles';
6
5
  import { DN20 } from '@atlaskit/theme/colors';
7
6
  import { themed } from '@atlaskit/theme/components';
8
7
  import { gridSize } from '@atlaskit/theme/constants';
9
- import { token } from '@atlaskit/tokens';
10
8
  import browser from '../../utils/browser';
11
9
  import { CodeBlockSharedCssClassName } from './code-block';
12
10
  export const tableMarginTop = 24;
@@ -66,8 +64,8 @@ const tableSharedStyle = props => css`
66
64
  border-collapse: collapse;
67
65
  border: ${tableCellBorderWidth}px solid
68
66
  ${themed({
69
- light: token('color.border', akEditorTableBorder),
70
- dark: token('color.border', akEditorTableBorderDark)
67
+ light: `var(--ds-border, ${akEditorTableBorder})`,
68
+ dark: `var(--ds-border, ${akEditorTableBorderDark})`
71
69
  })(props)};
72
70
  table-layout: fixed;
73
71
  font-size: 1em;
@@ -89,7 +87,7 @@ const tableSharedStyle = props => css`
89
87
  border-bottom: none;
90
88
  }
91
89
  th td {
92
- background-color: ${token('color.background.neutral.subtle', 'white')};
90
+ background-color: ${"var(--ds-background-neutral-subtle, white)"};
93
91
  }
94
92
  th,
95
93
  td {
@@ -98,8 +96,8 @@ const tableSharedStyle = props => css`
98
96
  vertical-align: top;
99
97
  border: 1px solid
100
98
  ${themed({
101
- light: token('color.border', akEditorTableBorder),
102
- dark: token('color.border', akEditorTableBorderDark)
99
+ light: `var(--ds-border, ${akEditorTableBorder})`,
100
+ dark: `var(--ds-border, ${akEditorTableBorderDark})`
103
101
  })(props)};
104
102
  border-right-width: 0;
105
103
  border-bottom-width: 0;
@@ -133,8 +131,8 @@ const tableSharedStyle = props => css`
133
131
  }
134
132
  th {
135
133
  background-color: ${themed({
136
- light: token('color.background.neutral', akEditorTableToolbar),
137
- dark: token('color.background.neutral', akEditorTableToolbarDark)
134
+ light: `var(--ds-background-neutral, ${akEditorTableToolbar})`,
135
+ dark: `var(--ds-background-neutral, ${akEditorTableToolbarDark})`
138
136
  })(props)};
139
137
  text-align: left;
140
138
 
@@ -143,34 +141,34 @@ const tableSharedStyle = props => css`
143
141
  &:not([style]):not(.danger) {
144
142
  .${CodeBlockSharedCssClassName.CODEBLOCK_CONTAINER}:not(.danger) {
145
143
  background-color: ${themed({
146
- light: token('elevation.surface.raised', 'rgb(235, 237, 240)'),
147
- dark: token('elevation.surface.raised', 'rgb(36, 47, 66)')
144
+ light: "var(--ds-surface-raised, rgb(235, 237, 240))",
145
+ dark: "var(--ds-surface-raised, rgb(36, 47, 66))"
148
146
  })(props)};
149
147
 
150
148
  :not(.${akEditorSelectedNodeClassName}) {
151
149
  box-shadow: 0px 0px 0px 1px
152
- ${token('color.border', 'transparent')};
150
+ ${"var(--ds-border, transparent)"};
153
151
  }
154
152
 
155
153
  .${CodeBlockSharedCssClassName.CODEBLOCK_CONTENT_WRAPPER} {
156
154
  background-image: ${overflowShadow({
157
155
  background: themed({
158
- light: token('color.background.neutral', 'rgb(235, 237, 240)'),
159
- dark: token('color.background.neutral', 'rgb(36, 47, 66)')
156
+ light: "var(--ds-background-neutral, rgb(235, 237, 240))",
157
+ dark: "var(--ds-background-neutral, rgb(36, 47, 66))"
160
158
  })(props),
161
- width: `${gridSize()}px`
159
+ leftCoverWidth: `${gridSize() * 3}px`
162
160
  })};
163
161
 
164
162
  background-color: ${themed({
165
- light: token('color.background.neutral', 'rgb(235, 237, 240)'),
166
- dark: token('color.background.neutral', 'rgb(36, 47, 66)')
163
+ light: "var(--ds-background-neutral, rgb(235, 237, 240))",
164
+ dark: "var(--ds-background-neutral, rgb(36, 47, 66))"
167
165
  })(props)};
168
166
  }
169
167
 
170
168
  .${CodeBlockSharedCssClassName.CODEBLOCK_LINE_NUMBER_GUTTER} {
171
169
  background-color: ${themed({
172
- light: token('color.background.neutral', 'rgb(226, 229, 233)'),
173
- dark: token('color.background.neutral', DN20)
170
+ light: "var(--ds-background-neutral, rgb(226, 229, 233))",
171
+ dark: `var(--ds-background-neutral, ${DN20})`
174
172
  })(props)};
175
173
  }
176
174
 
@@ -178,21 +176,21 @@ const tableSharedStyle = props => css`
178
176
  > [data-ds--code--code-block] {
179
177
  background-image: ${overflowShadow({
180
178
  background: themed({
181
- light: token('color.background.neutral', 'rgb(235, 237, 240)'),
182
- dark: token('color.background.neutral', 'rgb(36, 47, 66)')
179
+ light: "var(--ds-background-neutral, rgb(235, 237, 240))",
180
+ dark: "var(--ds-background-neutral, rgb(36, 47, 66))"
183
181
  })(props),
184
- width: `${gridSize()}px`
182
+ leftCoverWidth: `${gridSize() * 3}px`
185
183
  })}!important;
186
184
 
187
185
  background-color: ${themed({
188
- light: token('color.background.neutral', 'rgb(235, 237, 240)'),
189
- dark: token('color.background.neutral', 'rgb(36, 47, 66)')
186
+ light: "var(--ds-background-neutral, rgb(235, 237, 240))",
187
+ dark: "var(--ds-background-neutral, rgb(36, 47, 66))"
190
188
  })(props)}!important;
191
189
 
192
190
  // selector lives inside @atlaskit/code
193
191
  --ds--code--line-number-bg-color: ${themed({
194
- light: token('color.background.neutral', 'rgb(226, 229, 233)'),
195
- dark: token('color.background.neutral', DN20)
192
+ light: "var(--ds-background-neutral, rgb(226, 229, 233))",
193
+ dark: `var(--ds-background-neutral, ${DN20})`
196
194
  })(props)};
197
195
  }
198
196
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -5,16 +5,15 @@ import React from 'react';
5
5
  import { css, jsx } from '@emotion/react';
6
6
  import { injectIntl } from 'react-intl-next';
7
7
  import { N200, N400 } from '@atlaskit/theme/colors';
8
- import { token } from '@atlaskit/tokens';
9
8
  import { messages } from './messages';
10
9
  const captionWrapperStyle = css`
11
10
  margin-top: 8px;
12
11
  text-align: center;
13
12
  position: relative;
14
- color: ${token('color.text.subtle', N400)};
13
+ color: ${`var(--ds-text-subtle, ${N400})`};
15
14
  `;
16
15
  const placeholderStyle = css`
17
- color: ${token('color.text.subtlest', N200)};
16
+ color: ${`var(--ds-text-subtlest, ${N200})`};
18
17
  position: absolute;
19
18
  top: 0;
20
19
  width: 100%;
@@ -7,10 +7,9 @@ import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@
7
7
  import { DN50, DN600, N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
8
8
  import { themed } from '@atlaskit/theme/components';
9
9
  import { borderRadius, gridSize } from '@atlaskit/theme/constants';
10
- import { token } from '@atlaskit/tokens';
11
10
  import Layer from '../Layer';
12
11
  const packageName = "@atlaskit/editor-common";
13
- const packageVersion = "71.0.3";
12
+ const packageVersion = "72.0.1";
14
13
  const halfFocusRing = 1;
15
14
  const dropOffset = `0, ${gridSize()}px`;
16
15
 
@@ -33,12 +32,12 @@ class DropList extends Component {
33
32
  _defineProperty(this, "menuWrapper", theme => {
34
33
  return css`
35
34
  color: ${themed({
36
- light: token('color.text', N900),
37
- dark: token('color.text', DN600)
35
+ light: `var(--ds-text, ${N900})`,
36
+ dark: `var(--ds-text, ${DN600})`
38
37
  })(theme)};
39
38
  background-color: ${themed({
40
- light: token('elevation.surface.overlay', N0),
41
- dark: token('elevation.surface.overlay', DN50)
39
+ light: `var(--ds-surface-overlay, ${N0})`,
40
+ dark: `var(--ds-surface-overlay, ${DN50})`
42
41
  })(theme)};
43
42
  border-radius: ${borderRadius()}px;
44
43
  box-shadow: 0 ${gridSize() / 2}px ${gridSize()}px -${gridSize() / 4}px ${N50A},
@@ -7,13 +7,16 @@ export default class EmojiNode extends PureComponent {
7
7
  super(props);
8
8
 
9
9
  _defineProperty(this, "renderWithProvider", providers => {
10
+ var _resourceConfig$optim;
11
+
10
12
  const {
11
13
  allowTextFallback,
12
14
  shortName,
13
15
  id,
14
16
  fallback,
15
17
  fitToHeight,
16
- showTooltip
18
+ showTooltip,
19
+ resourceConfig
17
20
  } = this.props;
18
21
 
19
22
  if (allowTextFallback && !providers.emojiProvider) {
@@ -36,7 +39,13 @@ export default class EmojiNode extends PureComponent {
36
39
  },
37
40
  emojiProvider: providers.emojiProvider,
38
41
  showTooltip: showTooltip,
39
- fitToHeight: fitToHeight
42
+ fitToHeight: fitToHeight,
43
+ optimistic: true,
44
+ optimisticImageURL: resourceConfig === null || resourceConfig === void 0 ? void 0 : (_resourceConfig$optim = resourceConfig.optimisticImageApi) === null || _resourceConfig$optim === void 0 ? void 0 : _resourceConfig$optim.getUrl({
45
+ id,
46
+ fallback,
47
+ shortName
48
+ })
40
49
  });
41
50
  });
42
51
 
@@ -8,7 +8,6 @@ import { akEditorLineHeight, akEditorSwoopCubicBezier, akLayoutGutterOffset, rel
8
8
  import * as colors from '@atlaskit/theme/colors';
9
9
  import { themed } from '@atlaskit/theme/components';
10
10
  import { fontSize, gridSize } from '@atlaskit/theme/constants';
11
- import { token } from '@atlaskit/tokens';
12
11
  export const messages = defineMessages({
13
12
  collapseNode: {
14
13
  id: 'fabric.editor.collapseNode',
@@ -32,16 +31,16 @@ export const messages = defineMessages({
32
31
  }
33
32
  });
34
33
  const BORDER_RADIUS = gridSize() / 2;
35
- const EXPAND_COLLAPSED_BACKGROUND = token('color.background.neutral.subtle', 'transparent');
34
+ const EXPAND_COLLAPSED_BACKGROUND = "var(--ds-background-neutral-subtle, transparent)";
36
35
  const EXPAND_SELECTED_BACKGROUND = themed({
37
- light: token('elevation.surface', 'rgba(255, 255, 255, 0.6)'),
38
- dark: token('elevation.surface', 'rgba(9, 10, 11, 0.29)')
36
+ light: "var(--ds-surface, rgba(255, 255, 255, 0.6))",
37
+ dark: "var(--ds-surface, rgba(9, 10, 11, 0.29))"
39
38
  });
40
- const EXPAND_FOCUSED_BORDER_COLOR = token('color.border.focused', colors.B300);
39
+ const EXPAND_FOCUSED_BORDER_COLOR = `var(--ds-border-focused, ${colors.B300})`;
41
40
  const EXPAND_COLLAPSED_BORDER_COLOR = 'transparent';
42
41
  const EXPAND_EXPANDED_BORDER_COLOR = themed({
43
- light: token('color.border', colors.N40A),
44
- dark: token('color.border', colors.DN50)
42
+ light: `var(--ds-border, ${colors.N40A})`,
43
+ dark: `var(--ds-border, ${colors.DN50})`
45
44
  });
46
45
  export const ExpandIconWrapper = ({
47
46
  children,
@@ -56,15 +55,15 @@ const expandIconWrapperStyle = props => css`
56
55
  cursor: pointer;
57
56
  display: flex;
58
57
  color: ${themed({
59
- light: token('color.icon', colors.N90),
60
- dark: token('color.icon', '#d9dde3')
58
+ light: `var(--ds-icon, ${colors.N90})`,
59
+ dark: "var(--ds-icon, #d9dde3)"
61
60
  })(props)};
62
61
  border-radius: ${gridSize() / 2}px;
63
62
  width: 24px;
64
63
  height: 24px;
65
64
 
66
65
  &:hover {
67
- background: ${token('color.background.neutral.subtle.hovered', colors.N30A)};
66
+ background: ${`var(--ds-background-neutral-subtle-hovered, ${colors.N30A})`};
68
67
  }
69
68
 
70
69
  svg {
@@ -123,8 +122,8 @@ const containerStyles = styleProps => {
123
122
  // https://product-fabric.atlassian.net/browse/DSP-4152
124
123
  border: 1px solid
125
124
  ${themed({
126
- light: token('color.border', colors.N50A),
127
- dark: token('color.border', colors.DN50)
125
+ light: `var(--ds-border, ${colors.N50A})`,
126
+ dark: `var(--ds-border, ${colors.DN50})`
128
127
  })(themeProps)};
129
128
  background: ${EXPAND_SELECTED_BACKGROUND(themeProps)};
130
129
  }
@@ -171,8 +170,8 @@ const titleInputStyles = props => css`
171
170
  line-height: ${akEditorLineHeight};
172
171
  font-weight: normal;
173
172
  color: ${themed({
174
- light: token('color.text.subtlest', colors.N200A),
175
- dark: token('color.text.subtlest', colors.DN600)
173
+ light: `var(--ds-text-subtlest, ${colors.N200A})`,
174
+ dark: `var(--ds-text-subtlest, ${colors.DN600})`
176
175
  })(props)};
177
176
  background: transparent;
178
177
  display: flex;
@@ -183,8 +182,8 @@ const titleInputStyles = props => css`
183
182
  &::placeholder {
184
183
  opacity: 0.6;
185
184
  color: ${themed({
186
- light: token('color.text.subtlest', colors.N200A),
187
- dark: token('color.text.subtlest', colors.DN600)
185
+ light: `var(--ds-text-subtlest, ${colors.N200A})`,
186
+ dark: `var(--ds-text-subtlest, ${colors.DN600})`
188
187
  })(props)};
189
188
  }
190
189
  `;
@@ -198,8 +197,8 @@ const titleContainerStyles = props => css`
198
197
  font-size: ${relativeFontSizeToBase16(fontSize())};
199
198
  width: 100%;
200
199
  color: ${themed({
201
- light: token('color.text.subtle', colors.N300A),
202
- dark: token('color.text.subtle', colors.DN600)
200
+ light: `var(--ds-text-subtle, ${colors.N300A})`,
201
+ dark: `var(--ds-text-subtle, ${colors.DN600})`
203
202
  })(props)};
204
203
  overflow: hidden;
205
204
  cursor: pointer;
@@ -5,17 +5,16 @@ import ErrorIcon from '@atlaskit/icon/glyph/error';
5
5
  import { G400, N200, R400 } from '@atlaskit/theme/colors';
6
6
  import { gridSize } from '@atlaskit/theme/constants';
7
7
  import { h200 } from '@atlaskit/theme/typography';
8
- import { token } from '@atlaskit/tokens';
9
8
  const errorColor = css`
10
- color: ${token('color.text.danger', R400)};
9
+ color: ${`var(--ds-text-danger, ${R400})`};
11
10
  `;
12
11
  const validColor = css`
13
- color: ${token('color.text.success', G400)};
12
+ color: ${`var(--ds-text-success, ${G400})`};
14
13
  `;
15
14
 
16
15
  const messageStyle = props => css`
17
16
  ${h200(props)} font-weight: normal;
18
- color: ${token('color.text.subtlest', N200)};
17
+ color: ${`var(--ds-text-subtlest, ${N200})`};
19
18
  margin-top: ${gridSize() / 2}px;
20
19
  display: flex;
21
20
  justify-content: baseline;
@@ -1,5 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React from 'react';
3
+ import createFocusTrap from 'focus-trap';
3
4
  import rafSchedule from 'raf-schd';
4
5
  import { createPortal } from 'react-dom';
5
6
  import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
@@ -16,6 +17,8 @@ export default class Popup extends React.Component {
16
17
  validPosition: true
17
18
  });
18
19
 
20
+ _defineProperty(this, "popupRef", /*#__PURE__*/React.createRef());
21
+
19
22
  _defineProperty(this, "placement", ['', '']);
20
23
 
21
24
  _defineProperty(this, "handleRef", popup => {
@@ -35,6 +38,24 @@ export default class Popup extends React.Component {
35
38
  _defineProperty(this, "resizeObserver", (_window = window) !== null && _window !== void 0 && _window.ResizeObserver ? new ResizeObserver(() => {
36
39
  this.scheduledUpdatePosition(this.props);
37
40
  }) : undefined);
41
+
42
+ _defineProperty(this, "initFocusTrap", rafSchedule(() => {
43
+ const popup = this.popupRef.current;
44
+
45
+ if (!popup) {
46
+ return;
47
+ }
48
+
49
+ const trapConfig = {
50
+ clickOutsideDeactivates: true,
51
+ escapeDeactivates: true,
52
+ initialFocus: popup,
53
+ fallbackFocus: popup,
54
+ returnFocusOnDeactivate: false
55
+ };
56
+ this.focusTrap = createFocusTrap(popup, trapConfig);
57
+ this.focusTrap.activate();
58
+ }));
38
59
  }
39
60
 
40
61
  /**
@@ -54,14 +75,15 @@ export default class Popup extends React.Component {
54
75
  stick,
55
76
  forcePlacement,
56
77
  allowOutOfBounds,
57
- rect
78
+ rect,
79
+ preventOverflow
58
80
  } = props;
59
81
 
60
82
  if (!target || !popup) {
61
83
  return {};
62
84
  }
63
85
 
64
- const placement = calculatePlacement(target, boundariesElement || document.body, fitWidth, fitHeight, alignX, alignY, forcePlacement);
86
+ const placement = calculatePlacement(target, boundariesElement || document.body, fitWidth, fitHeight, alignX, alignY, forcePlacement, preventOverflow);
65
87
 
66
88
  if (onPlacementChanged && this.placement.join('') !== placement.join('')) {
67
89
  onPlacementChanged(placement);
@@ -119,6 +141,7 @@ export default class Popup extends React.Component {
119
141
 
120
142
 
121
143
  initPopup(popup) {
144
+ this.popupRef.current = popup;
122
145
  const {
123
146
  target
124
147
  } = this.props;
@@ -144,6 +167,10 @@ export default class Popup extends React.Component {
144
167
  */
145
168
 
146
169
  this.scheduledUpdatePosition(this.props);
170
+
171
+ if (this.props.focusTrap) {
172
+ this.initFocusTrap();
173
+ }
147
174
  }
148
175
 
149
176
  UNSAFE_componentWillReceiveProps(newProps) {
@@ -152,6 +179,44 @@ export default class Popup extends React.Component {
152
179
  this.scheduledUpdatePosition(newProps);
153
180
  }
154
181
 
182
+ /**
183
+ * Cancels the initialisation of the focus trap if it has not yet occured
184
+ * Deactivates the focus trap if it exists
185
+ */
186
+ destroyFocusTrap() {
187
+ var _this$focusTrap;
188
+
189
+ this.initFocusTrap.cancel();
190
+ (_this$focusTrap = this.focusTrap) === null || _this$focusTrap === void 0 ? void 0 : _this$focusTrap.deactivate();
191
+ }
192
+ /**
193
+ * Handle pausing, unpausing, and initialising (if not yet initialised) of the focus trap
194
+ */
195
+
196
+
197
+ handleChangedFocusTrapProp(prevProps) {
198
+ if (prevProps.focusTrap !== this.props.focusTrap) {
199
+ // If currently set to disable, then pause the trap if it exists
200
+ if (!this.props.focusTrap) {
201
+ var _this$focusTrap2;
202
+
203
+ return (_this$focusTrap2 = this.focusTrap) === null || _this$focusTrap2 === void 0 ? void 0 : _this$focusTrap2.pause();
204
+ } // If set to enabled and trap already exists, unpause
205
+
206
+
207
+ if (this.focusTrap) {
208
+ this.focusTrap.unpause();
209
+ } // Else initialise the focus trap
210
+
211
+
212
+ return this.initFocusTrap();
213
+ }
214
+ }
215
+
216
+ componentDidUpdate(prevProps) {
217
+ this.handleChangedFocusTrapProp(prevProps);
218
+ }
219
+
155
220
  componentDidMount() {
156
221
  window.addEventListener('resize', this.onResize);
157
222
  const {
@@ -186,6 +251,7 @@ export default class Popup extends React.Component {
186
251
  }
187
252
 
188
253
  this.scheduledUpdatePosition.cancel();
254
+ this.destroyFocusTrap();
189
255
  }
190
256
 
191
257
  renderPopup() {
@@ -8,7 +8,7 @@ export function isTextNode(elem) {
8
8
  * Decides if given fitHeight fits below or above the target taking boundaries into account.
9
9
  */
10
10
 
11
- export function getVerticalPlacement(target, boundariesElement, fitHeight, alignY, forcePlacement) {
11
+ export function getVerticalPlacement(target, boundariesElement, fitHeight, alignY, forcePlacement, preventOverflow) {
12
12
  if (forcePlacement && alignY) {
13
13
  return alignY;
14
14
  }
@@ -31,7 +31,13 @@ export function getVerticalPlacement(target, boundariesElement, fitHeight, align
31
31
  height: targetHeight
32
32
  } = target.getBoundingClientRect();
33
33
  const spaceAbove = targetTop - (boundariesTop - boundariesElement.scrollTop);
34
- const spaceBelow = boundariesTop + boundariesHeight - (targetTop + targetHeight);
34
+ const spaceBelow = boundariesTop + boundariesHeight - (targetTop + targetHeight); // Force vertical placement to bottom if the space above doesn't accomodate the fitHeight
35
+
36
+ if (preventOverflow) {
37
+ if (spaceAbove <= fitHeight) {
38
+ return 'bottom';
39
+ }
40
+ }
35
41
 
36
42
  if (spaceBelow >= fitHeight || spaceBelow >= spaceAbove) {
37
43
  return 'bottom';
@@ -43,8 +49,9 @@ export function getVerticalPlacement(target, boundariesElement, fitHeight, align
43
49
  * Decides if given fitWidth fits to the left or to the right of the target taking boundaries into account.
44
50
  */
45
51
 
46
- export function getHorizontalPlacement(target, boundariesElement, fitWidth, alignX, forcePlacement) {
47
- if (forcePlacement && alignX) {
52
+ export function getHorizontalPlacement(target, boundariesElement, fitWidth, alignX, forcePlacement, preventOverflow) {
53
+ // force placement unless preventOverflow is enabled
54
+ if (forcePlacement && alignX && !preventOverflow) {
48
55
  return alignX;
49
56
  }
50
57
 
@@ -75,8 +82,8 @@ export function getHorizontalPlacement(target, boundariesElement, fitWidth, alig
75
82
 
76
83
  return 'right';
77
84
  }
78
- export function calculatePlacement(target, boundariesElement, fitWidth, fitHeight, alignX, alignY, forcePlacement) {
79
- return [getVerticalPlacement(target, boundariesElement, fitHeight, alignY, forcePlacement), getHorizontalPlacement(target, boundariesElement, fitWidth, alignX, forcePlacement)];
85
+ export function calculatePlacement(target, boundariesElement, fitWidth, fitHeight, alignX, alignY, forcePlacement, preventOverflow) {
86
+ return [getVerticalPlacement(target, boundariesElement, fitHeight, alignY, forcePlacement, preventOverflow), getHorizontalPlacement(target, boundariesElement, fitWidth, alignX, forcePlacement, preventOverflow)];
80
87
  }
81
88
 
82
89
  const calculateHorizontalPlacement = ({
@@ -6,15 +6,14 @@ import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
6
6
  import QuestionsIcon from '@atlaskit/icon/glyph/question-circle';
7
7
  import { N30, N50 } from '@atlaskit/theme/colors';
8
8
  import { borderRadius, fontSize } from '@atlaskit/theme/constants';
9
- import { token } from '@atlaskit/tokens';
10
9
  import Tooltip from '@atlaskit/tooltip';
10
+ import { ACTION_SUBJECT_ID } from '../../analytics';
11
11
  import { unsupportedContentMessages } from '../../messages/unsupportedContent';
12
- import { ACTION_SUBJECT_ID } from '../../utils/analytics';
13
12
  import { trackUnsupportedContentTooltipDisplayedFor } from '../../utils/track-unsupported-content';
14
13
  import { getUnsupportedContent } from '../unsupported-content-helper';
15
14
  const blockNodeStyle = css`
16
- background: ${token('color.background.disabled', N30)};
17
- border: 1px dashed ${token('color.border.disabled', N50)};
15
+ background: ${`var(--ds-background-disabled, ${N30})`};
16
+ border: 1px dashed ${`var(--ds-border-disabled, ${N50})`};
18
17
  border-radius: ${borderRadius()}px;
19
18
  box-sizing: border-box;
20
19
  cursor: default;
@@ -6,16 +6,15 @@ import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
6
6
  import QuestionsIcon from '@atlaskit/icon/glyph/question-circle';
7
7
  import { N30, N50 } from '@atlaskit/theme/colors';
8
8
  import { borderRadius, fontSize } from '@atlaskit/theme/constants';
9
- import { token } from '@atlaskit/tokens';
10
9
  import Tooltip from '@atlaskit/tooltip';
10
+ import { ACTION_SUBJECT_ID } from '../../analytics';
11
11
  import { unsupportedContentMessages } from '../../messages/unsupportedContent';
12
- import { ACTION_SUBJECT_ID } from '../../utils/analytics';
13
12
  import { trackUnsupportedContentTooltipDisplayedFor } from '../../utils/track-unsupported-content';
14
13
  import { getUnsupportedContent } from '../unsupported-content-helper';
15
14
  const inlineNodeStyle = css`
16
15
  align-items: center;
17
- background: ${token('color.background.disabled', N30)};
18
- border: 1px dashed ${token('color.border.disabled', N50)};
16
+ background: ${`var(--ds-background-disabled, ${N30})`};
17
+ border: 1px dashed ${`var(--ds-border-disabled, ${N50})`};
19
18
  border-radius: ${borderRadius()}px;
20
19
  box-sizing: border-box;
21
20
  cursor: default;