@atlaskit/editor-core 185.5.2 → 185.5.7

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 (195) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/i18n/cs.js +0 -10
  3. package/dist/cjs/i18n/da.js +0 -10
  4. package/dist/cjs/i18n/de.js +0 -10
  5. package/dist/cjs/i18n/en.js +0 -10
  6. package/dist/cjs/i18n/en_GB.js +0 -10
  7. package/dist/cjs/i18n/en_ZZ.js +0 -10
  8. package/dist/cjs/i18n/es.js +0 -10
  9. package/dist/cjs/i18n/fi.js +0 -10
  10. package/dist/cjs/i18n/fr.js +0 -10
  11. package/dist/cjs/i18n/hu.js +0 -10
  12. package/dist/cjs/i18n/it.js +0 -10
  13. package/dist/cjs/i18n/ja.js +0 -10
  14. package/dist/cjs/i18n/ko.js +0 -10
  15. package/dist/cjs/i18n/nb.js +0 -10
  16. package/dist/cjs/i18n/nl.js +0 -10
  17. package/dist/cjs/i18n/pl.js +0 -10
  18. package/dist/cjs/i18n/pt_BR.js +0 -10
  19. package/dist/cjs/i18n/ru.js +0 -10
  20. package/dist/cjs/i18n/sv.js +0 -10
  21. package/dist/cjs/i18n/th.js +0 -10
  22. package/dist/cjs/i18n/tr.js +0 -10
  23. package/dist/cjs/i18n/uk.js +0 -10
  24. package/dist/cjs/i18n/vi.js +0 -10
  25. package/dist/cjs/i18n/zh.js +0 -10
  26. package/dist/cjs/i18n/zh_TW.js +0 -10
  27. package/dist/cjs/plugins/breakout/ui/LayoutButton.js +5 -28
  28. package/dist/cjs/plugins/card/index.js +20 -6
  29. package/dist/cjs/plugins/card/nodeviews/datasource.js +39 -4
  30. package/dist/cjs/plugins/card/pm-plugins/actions.js +31 -1
  31. package/dist/cjs/plugins/card/pm-plugins/main.js +48 -3
  32. package/dist/cjs/plugins/card/pm-plugins/reducers.js +22 -0
  33. package/dist/cjs/plugins/card/styles.js +1 -1
  34. package/dist/cjs/plugins/card/ui/LayoutButton/index.js +113 -0
  35. package/dist/cjs/plugins/card/ui/LayoutButton/styled.js +17 -0
  36. package/dist/cjs/plugins/card/ui/LayoutButton/types.js +5 -0
  37. package/dist/cjs/plugins/card/ui/LayoutButton/utils.js +19 -0
  38. package/dist/cjs/plugins/media/pm-plugins/main.js +20 -1
  39. package/dist/cjs/version-wrapper.js +1 -1
  40. package/dist/cjs/version.json +1 -1
  41. package/dist/es2019/i18n/cs.js +0 -10
  42. package/dist/es2019/i18n/da.js +0 -10
  43. package/dist/es2019/i18n/de.js +0 -10
  44. package/dist/es2019/i18n/en.js +0 -10
  45. package/dist/es2019/i18n/en_GB.js +0 -10
  46. package/dist/es2019/i18n/en_ZZ.js +0 -10
  47. package/dist/es2019/i18n/es.js +0 -10
  48. package/dist/es2019/i18n/fi.js +0 -10
  49. package/dist/es2019/i18n/fr.js +0 -10
  50. package/dist/es2019/i18n/hu.js +0 -10
  51. package/dist/es2019/i18n/it.js +0 -10
  52. package/dist/es2019/i18n/ja.js +0 -10
  53. package/dist/es2019/i18n/ko.js +0 -10
  54. package/dist/es2019/i18n/nb.js +0 -10
  55. package/dist/es2019/i18n/nl.js +0 -10
  56. package/dist/es2019/i18n/pl.js +0 -10
  57. package/dist/es2019/i18n/pt_BR.js +0 -10
  58. package/dist/es2019/i18n/ru.js +0 -10
  59. package/dist/es2019/i18n/sv.js +0 -10
  60. package/dist/es2019/i18n/th.js +0 -10
  61. package/dist/es2019/i18n/tr.js +0 -10
  62. package/dist/es2019/i18n/uk.js +0 -10
  63. package/dist/es2019/i18n/vi.js +0 -10
  64. package/dist/es2019/i18n/zh.js +0 -10
  65. package/dist/es2019/i18n/zh_TW.js +0 -10
  66. package/dist/es2019/plugins/breakout/ui/LayoutButton.js +3 -26
  67. package/dist/es2019/plugins/breakout/utils/get-breakout-mode.js +0 -1
  68. package/dist/es2019/plugins/card/index.js +20 -3
  69. package/dist/es2019/plugins/card/nodeviews/datasource.js +38 -1
  70. package/dist/es2019/plugins/card/pm-plugins/actions.js +16 -0
  71. package/dist/es2019/plugins/card/pm-plugins/main.js +55 -4
  72. package/dist/es2019/plugins/card/pm-plugins/reducers.js +25 -0
  73. package/dist/es2019/plugins/card/styles.js +6 -0
  74. package/dist/es2019/plugins/card/ui/LayoutButton/index.js +106 -0
  75. package/dist/es2019/plugins/card/ui/LayoutButton/styled.js +10 -0
  76. package/dist/es2019/plugins/card/ui/LayoutButton/types.js +1 -0
  77. package/dist/es2019/plugins/card/ui/LayoutButton/utils.js +15 -0
  78. package/dist/es2019/plugins/media/pm-plugins/main.js +25 -3
  79. package/dist/es2019/version-wrapper.js +1 -1
  80. package/dist/es2019/version.json +1 -1
  81. package/dist/esm/i18n/cs.js +0 -10
  82. package/dist/esm/i18n/da.js +0 -10
  83. package/dist/esm/i18n/de.js +0 -10
  84. package/dist/esm/i18n/en.js +0 -10
  85. package/dist/esm/i18n/en_GB.js +0 -10
  86. package/dist/esm/i18n/en_ZZ.js +0 -10
  87. package/dist/esm/i18n/es.js +0 -10
  88. package/dist/esm/i18n/fi.js +0 -10
  89. package/dist/esm/i18n/fr.js +0 -10
  90. package/dist/esm/i18n/hu.js +0 -10
  91. package/dist/esm/i18n/it.js +0 -10
  92. package/dist/esm/i18n/ja.js +0 -10
  93. package/dist/esm/i18n/ko.js +0 -10
  94. package/dist/esm/i18n/nb.js +0 -10
  95. package/dist/esm/i18n/nl.js +0 -10
  96. package/dist/esm/i18n/pl.js +0 -10
  97. package/dist/esm/i18n/pt_BR.js +0 -10
  98. package/dist/esm/i18n/ru.js +0 -10
  99. package/dist/esm/i18n/sv.js +0 -10
  100. package/dist/esm/i18n/th.js +0 -10
  101. package/dist/esm/i18n/tr.js +0 -10
  102. package/dist/esm/i18n/uk.js +0 -10
  103. package/dist/esm/i18n/vi.js +0 -10
  104. package/dist/esm/i18n/zh.js +0 -10
  105. package/dist/esm/i18n/zh_TW.js +0 -10
  106. package/dist/esm/plugins/breakout/ui/LayoutButton.js +3 -26
  107. package/dist/esm/plugins/breakout/utils/get-breakout-mode.js +0 -1
  108. package/dist/esm/plugins/card/index.js +20 -3
  109. package/dist/esm/plugins/card/nodeviews/datasource.js +37 -3
  110. package/dist/esm/plugins/card/pm-plugins/actions.js +27 -0
  111. package/dist/esm/plugins/card/pm-plugins/main.js +49 -4
  112. package/dist/esm/plugins/card/pm-plugins/reducers.js +22 -0
  113. package/dist/esm/plugins/card/styles.js +1 -1
  114. package/dist/esm/plugins/card/ui/LayoutButton/index.js +102 -0
  115. package/dist/esm/plugins/card/ui/LayoutButton/styled.js +10 -0
  116. package/dist/esm/plugins/card/ui/LayoutButton/types.js +1 -0
  117. package/dist/esm/plugins/card/ui/LayoutButton/utils.js +12 -0
  118. package/dist/esm/plugins/media/pm-plugins/main.js +22 -3
  119. package/dist/esm/version-wrapper.js +1 -1
  120. package/dist/esm/version.json +1 -1
  121. package/dist/types/i18n/cs.d.ts +0 -10
  122. package/dist/types/i18n/da.d.ts +0 -10
  123. package/dist/types/i18n/de.d.ts +0 -10
  124. package/dist/types/i18n/en.d.ts +0 -10
  125. package/dist/types/i18n/en_GB.d.ts +0 -10
  126. package/dist/types/i18n/en_ZZ.d.ts +0 -10
  127. package/dist/types/i18n/es.d.ts +0 -10
  128. package/dist/types/i18n/fi.d.ts +0 -10
  129. package/dist/types/i18n/fr.d.ts +0 -10
  130. package/dist/types/i18n/hu.d.ts +0 -10
  131. package/dist/types/i18n/it.d.ts +0 -10
  132. package/dist/types/i18n/ja.d.ts +0 -10
  133. package/dist/types/i18n/ko.d.ts +0 -10
  134. package/dist/types/i18n/nb.d.ts +0 -10
  135. package/dist/types/i18n/nl.d.ts +0 -10
  136. package/dist/types/i18n/pl.d.ts +0 -10
  137. package/dist/types/i18n/pt_BR.d.ts +0 -10
  138. package/dist/types/i18n/ru.d.ts +0 -10
  139. package/dist/types/i18n/sv.d.ts +0 -10
  140. package/dist/types/i18n/th.d.ts +0 -10
  141. package/dist/types/i18n/tr.d.ts +0 -10
  142. package/dist/types/i18n/uk.d.ts +0 -10
  143. package/dist/types/i18n/vi.d.ts +0 -10
  144. package/dist/types/i18n/zh.d.ts +0 -10
  145. package/dist/types/i18n/zh_TW.d.ts +0 -10
  146. package/dist/types/plugins/breakout/commands/set-breakout-mode.d.ts +1 -1
  147. package/dist/types/plugins/breakout/utils/get-breakout-mode.d.ts +1 -1
  148. package/dist/types/plugins/card/index.d.ts +3 -1
  149. package/dist/types/plugins/card/nodeviews/datasource.d.ts +18 -2
  150. package/dist/types/plugins/card/pm-plugins/actions.d.ts +7 -0
  151. package/dist/types/plugins/card/pm-plugins/plugin-key.d.ts +2 -1
  152. package/dist/types/plugins/card/pm-plugins/util/state.d.ts +2 -0
  153. package/dist/types/plugins/card/types.d.ts +17 -1
  154. package/dist/types/plugins/card/ui/LayoutButton/index.d.ts +9 -0
  155. package/dist/types/plugins/card/ui/LayoutButton/styled.d.ts +1 -0
  156. package/dist/types/plugins/card/ui/LayoutButton/types.d.ts +19 -0
  157. package/dist/types/plugins/card/ui/LayoutButton/utils.d.ts +5 -0
  158. package/dist/types-ts4.5/i18n/cs.d.ts +0 -10
  159. package/dist/types-ts4.5/i18n/da.d.ts +0 -10
  160. package/dist/types-ts4.5/i18n/de.d.ts +0 -10
  161. package/dist/types-ts4.5/i18n/en.d.ts +0 -10
  162. package/dist/types-ts4.5/i18n/en_GB.d.ts +0 -10
  163. package/dist/types-ts4.5/i18n/en_ZZ.d.ts +0 -10
  164. package/dist/types-ts4.5/i18n/es.d.ts +0 -10
  165. package/dist/types-ts4.5/i18n/fi.d.ts +0 -10
  166. package/dist/types-ts4.5/i18n/fr.d.ts +0 -10
  167. package/dist/types-ts4.5/i18n/hu.d.ts +0 -10
  168. package/dist/types-ts4.5/i18n/it.d.ts +0 -10
  169. package/dist/types-ts4.5/i18n/ja.d.ts +0 -10
  170. package/dist/types-ts4.5/i18n/ko.d.ts +0 -10
  171. package/dist/types-ts4.5/i18n/nb.d.ts +0 -10
  172. package/dist/types-ts4.5/i18n/nl.d.ts +0 -10
  173. package/dist/types-ts4.5/i18n/pl.d.ts +0 -10
  174. package/dist/types-ts4.5/i18n/pt_BR.d.ts +0 -10
  175. package/dist/types-ts4.5/i18n/ru.d.ts +0 -10
  176. package/dist/types-ts4.5/i18n/sv.d.ts +0 -10
  177. package/dist/types-ts4.5/i18n/th.d.ts +0 -10
  178. package/dist/types-ts4.5/i18n/tr.d.ts +0 -10
  179. package/dist/types-ts4.5/i18n/uk.d.ts +0 -10
  180. package/dist/types-ts4.5/i18n/vi.d.ts +0 -10
  181. package/dist/types-ts4.5/i18n/zh.d.ts +0 -10
  182. package/dist/types-ts4.5/i18n/zh_TW.d.ts +0 -10
  183. package/dist/types-ts4.5/plugins/breakout/commands/set-breakout-mode.d.ts +1 -1
  184. package/dist/types-ts4.5/plugins/breakout/utils/get-breakout-mode.d.ts +1 -1
  185. package/dist/types-ts4.5/plugins/card/index.d.ts +3 -1
  186. package/dist/types-ts4.5/plugins/card/nodeviews/datasource.d.ts +18 -2
  187. package/dist/types-ts4.5/plugins/card/pm-plugins/actions.d.ts +7 -0
  188. package/dist/types-ts4.5/plugins/card/pm-plugins/plugin-key.d.ts +2 -1
  189. package/dist/types-ts4.5/plugins/card/pm-plugins/util/state.d.ts +2 -0
  190. package/dist/types-ts4.5/plugins/card/types.d.ts +17 -1
  191. package/dist/types-ts4.5/plugins/card/ui/LayoutButton/index.d.ts +9 -0
  192. package/dist/types-ts4.5/plugins/card/ui/LayoutButton/styled.d.ts +1 -0
  193. package/dist/types-ts4.5/plugins/card/ui/LayoutButton/types.d.ts +19 -0
  194. package/dist/types-ts4.5/plugins/card/ui/LayoutButton/utils.d.ts +5 -0
  195. package/package.json +4 -4
@@ -73,7 +73,6 @@ export default {
73
73
  'fabric.editor.edit': '編輯',
74
74
  'fabric.editor.editAltText': '編輯替代文字',
75
75
  'fabric.editor.editDateText': '編輯日期',
76
- 'fabric.editor.editLink': '編輯連結',
77
76
  'fabric.editor.editStatusColor': '編輯狀態顏色',
78
77
  'fabric.editor.editStatusText': '編輯狀態',
79
78
  'fabric.editor.editableContentLabel': '可編輯內容',
@@ -97,7 +96,6 @@ export default {
97
96
  'fabric.editor.elementbrowser.search.empty-state.sub-heading.link': '探索 Atlassian Marketplace',
98
97
  'fabric.editor.elementbrowser.sidebar.heading': '瀏覽',
99
98
  'fabric.editor.embedTitle': '嵌入',
100
- 'fabric.editor.emptyLink': '請輸入連結。',
101
99
  'fabric.editor.epic': '大型工作',
102
100
  'fabric.editor.error': '錯誤',
103
101
  'fabric.editor.errorPanel': '錯誤面板',
@@ -141,7 +139,6 @@ export default {
141
139
  'fabric.editor.hyperlink.linkAriaLabel': '連結標籤',
142
140
  'fabric.editor.hyperlink.searchLinkAriaDescription': '當您在欄位中輸入內容時,建議會顯示在下方',
143
141
  'fabric.editor.hyperlink.searchLinkResults': '{count, plural, =0 {沒有找到任何結果} other {找到 {count,number} 個結果}}',
144
- 'fabric.editor.hyperlinkToolbarPlaceholder': '貼上或搜尋連結',
145
142
  'fabric.editor.imageBorderBold': '粗體',
146
143
  'fabric.editor.imageBorderColor': '顏色',
147
144
  'fabric.editor.imageBorderMedium': '普通',
@@ -157,17 +154,13 @@ export default {
157
154
  'fabric.editor.inlineTitle': '內嵌',
158
155
  'fabric.editor.inputQueryAssistiveTxt': '自動完成結果可用時,請使用向上和向下箭頭查看,並輸入以進行選取。若您使用觸控螢幕裝置,請透過觸控或滑動手勢探索內容。',
159
156
  'fabric.editor.invalidDateError': '請輸入有效的日期',
160
- 'fabric.editor.invalidLink': '請輸入有效的連結。',
161
157
  'fabric.editor.inviteItem.title': '{userRole, select, admin {邀請團隊成員加入 {productName}} trusted {邀請團隊成員加入 {productName}} other {將團隊成員新增至 {productName}}}',
162
158
  'fabric.editor.italic': '斜體',
163
159
  'fabric.editor.keyboardShortcuts': '鍵盤快速鍵',
164
160
  'fabric.editor.leftSidebar': '左側資訊看板',
165
- 'fabric.editor.linkAddress': '連結位址',
166
- 'fabric.editor.linkPlaceholder': '貼上連結',
167
161
  'fabric.editor.lists': '清單',
168
162
  'fabric.editor.markdown': 'Markdown',
169
163
  'fabric.editor.matchCase': '大小寫須相符',
170
- 'fabric.editor.mediaAddLink': '新增連結',
171
164
  'fabric.editor.mediaGroupDeleteLabel': '刪除',
172
165
  'fabric.editor.mentionNode.label': '已標記使用者',
173
166
  'fabric.editor.mentionsAddLabel': '新增圖示',
@@ -203,7 +196,6 @@ export default {
203
196
  'fabric.editor.rightSidebar': '右側資訊看板',
204
197
  'fabric.editor.searchResults': '{itemsLength, plural, other {{itemsLength,number} 個搜尋結果}}',
205
198
  'fabric.editor.selectLanguage': '選取語言',
206
- 'fabric.editor.settingsLinks': '前往連結偏好設定',
207
199
  'fabric.editor.shortcut': '文字快顯',
208
200
  'fabric.editor.single': '單欄',
209
201
  'fabric.editor.statusPlaceholder': '設定狀態',
@@ -237,10 +229,8 @@ export default {
237
229
  'fabric.editor.typeahead.mentionInputLabel': '開始輸入以搜尋要標記的使用者',
238
230
  'fabric.editor.typeahead.mentionPopupLabel': '您可以標記的使用者',
239
231
  'fabric.editor.typeahead.metionListItemLabel': '使用者 {name} @{shortName}',
240
- 'fabric.editor.unableToOpenLink': '無法開啟此連結',
241
232
  'fabric.editor.underline': '底線',
242
233
  'fabric.editor.undo': '復原',
243
- 'fabric.editor.unlink': '取消連結',
244
234
  'fabric.editor.unorderedList': '項目符號清單',
245
235
  'fabric.editor.unorderedList.description': '建立未排序的清單',
246
236
  'fabric.editor.url': '顯示 URL',
@@ -12,13 +12,13 @@ import ToolbarButton from '../../../ui/ToolbarButton';
12
12
  import { getBreakoutMode } from '../utils/get-breakout-mode';
13
13
  import { setBreakoutMode } from '../commands/set-breakout-mode';
14
14
  import { removeBreakout } from '../commands/remove-breakout';
15
- import commonMessages from '../../../messages';
16
15
  import { BreakoutCssClassName } from '../constants';
17
16
  import { isBreakoutMarkAllowed } from '../utils/is-breakout-mark-allowed';
18
17
  import { getPluginState } from '../plugin-key';
19
18
  import { NodeSelection } from 'prosemirror-state';
20
19
  import { isSupportedNodeForBreakout } from '../utils/is-supported-node';
21
20
  import { layers } from '@atlaskit/theme/constants';
21
+ import { getNextBreakoutMode, getTitle } from '@atlaskit/editor-common/utils';
22
22
  const toolbarButtonWrapper = css`
23
23
  && button {
24
24
  background: ${`var(--ds-background-neutral, ${N20A})`};
@@ -29,29 +29,6 @@ const toolbarButtonWrapper = css`
29
29
  }
30
30
  }
31
31
  `;
32
- const BREAKOUT_MODE = {
33
- FULL_WIDTH: 'full-width',
34
- CENTER: 'center',
35
- WIDE: 'wide'
36
- };
37
- const getNextBreakoutMode = currentMode => {
38
- if (currentMode === BREAKOUT_MODE.FULL_WIDTH) {
39
- return BREAKOUT_MODE.CENTER;
40
- } else if (currentMode === BREAKOUT_MODE.WIDE) {
41
- return BREAKOUT_MODE.FULL_WIDTH;
42
- }
43
- return BREAKOUT_MODE.WIDE;
44
- };
45
- const getTitle = layout => {
46
- switch (layout) {
47
- case BREAKOUT_MODE.FULL_WIDTH:
48
- return commonMessages.layoutFixedWidth;
49
- case BREAKOUT_MODE.WIDE:
50
- return commonMessages.layoutFullWidth;
51
- default:
52
- return commonMessages.layoutWide;
53
- }
54
- };
55
32
  function getBreakoutNodeElement(pluginState, selection, editorView) {
56
33
  if (selection instanceof NodeSelection && isSupportedNodeForBreakout(selection.node)) {
57
34
  return findDomRefAtPos(selection.from, editorView.domAtPos.bind(editorView));
@@ -66,7 +43,7 @@ class LayoutButton extends React.Component {
66
43
  state,
67
44
  dispatch
68
45
  } = this.props.editorView;
69
- if ([BREAKOUT_MODE.WIDE, BREAKOUT_MODE.FULL_WIDTH].indexOf(breakoutMode) !== -1) {
46
+ if (['wide', 'full-width'].indexOf(breakoutMode) !== -1) {
70
47
  setBreakoutMode(breakoutMode)(state, dispatch);
71
48
  } else {
72
49
  removeBreakout()(state, dispatch);
@@ -122,7 +99,7 @@ class LayoutButton extends React.Component {
122
99
  title: title,
123
100
  testId: titleMessage.id,
124
101
  onClick: this.handleClick(nextBreakoutMode),
125
- iconBefore: breakoutMode === BREAKOUT_MODE.FULL_WIDTH ? jsx(CollapseIcon, {
102
+ iconBefore: breakoutMode === 'full-width' ? jsx(CollapseIcon, {
126
103
  label: title
127
104
  }) : jsx(ExpandIcon, {
128
105
  label: title
@@ -1,5 +1,4 @@
1
1
  import { findSupportedNodeForBreakout } from './find-breakout-node';
2
-
3
2
  /**
4
3
  * Get the current mode of the breakout at the selection
5
4
  * @param state Current EditorState
@@ -1,15 +1,23 @@
1
- import React, { Fragment } from 'react';
1
+ import React from 'react';
2
2
  import { inlineCard, blockCard, embedCard } from '@atlaskit/adf-schema';
3
3
  import { createPlugin } from './pm-plugins/main';
4
4
  import { floatingToolbar } from './toolbar';
5
5
  import { EditorSmartCardEvents } from './ui/EditorSmartCardEvents';
6
6
  import { cardKeymap } from './pm-plugins/keymap';
7
7
  import { EditorSmartCardEventsNext } from './ui/EditorSmartCardEventsNext';
8
+ import LayoutButton from './ui/LayoutButton';
9
+ import { pluginKey } from './pm-plugins/plugin-key';
8
10
  const cardPlugin = (options, api) => {
9
11
  var _api$dependencies, _api$dependencies$fea;
10
12
  const featureFlags = (api === null || api === void 0 ? void 0 : (_api$dependencies = api.dependencies) === null || _api$dependencies === void 0 ? void 0 : (_api$dependencies$fea = _api$dependencies.featureFlags) === null || _api$dependencies$fea === void 0 ? void 0 : _api$dependencies$fea.sharedState.currentState()) || {};
11
13
  return {
12
14
  name: 'card',
15
+ getSharedState(editorState) {
16
+ if (!editorState) {
17
+ return null;
18
+ }
19
+ return pluginKey.getState(editorState);
20
+ },
13
21
  nodes() {
14
22
  const nodes = [{
15
23
  name: 'inlineCard',
@@ -55,15 +63,24 @@ const cardPlugin = (options, api) => {
55
63
  return plugins;
56
64
  },
57
65
  contentComponent({
58
- editorView
66
+ editorView,
67
+ popupsMountPoint,
68
+ popupsScrollableElement,
69
+ popupsBoundariesElement
59
70
  }) {
60
71
  const {
61
72
  lpAnalyticsEventsNext
62
73
  } = featureFlags;
63
- return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(EditorSmartCardEvents, {
74
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditorSmartCardEvents, {
64
75
  editorView: editorView
65
76
  }), lpAnalyticsEventsNext && /*#__PURE__*/React.createElement(EditorSmartCardEventsNext, {
66
77
  editorView: editorView
78
+ }), /*#__PURE__*/React.createElement(LayoutButton, {
79
+ api: api,
80
+ editorView: editorView,
81
+ mountPoint: popupsMountPoint,
82
+ scrollableElement: popupsScrollableElement,
83
+ boundariesElement: popupsBoundariesElement
67
84
  }));
68
85
  },
69
86
  pluginsOptions: {
@@ -5,6 +5,9 @@ import PropTypes from 'prop-types';
5
5
  import { css, jsx } from '@emotion/react';
6
6
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
7
7
  import { DatasourceTableView } from '@atlaskit/link-datasource';
8
+ import { SmartCardSharedCssClassName } from '@atlaskit/editor-common/styles';
9
+ import { calcBreakoutWidthPx } from '@atlaskit/editor-common/utils';
10
+ export const DATASOURCE_INNER_CONTAINER_CLASSNAME = 'datasourceView-content-inner-wrap';
8
11
  const containerStyles = css({
9
12
  height: '500px',
10
13
  overflow: 'auto'
@@ -88,9 +91,43 @@ _defineProperty(DatasourceComponent, "contextTypes", {
88
91
  contextAdapter: PropTypes.object
89
92
  });
90
93
  export class Datasource extends ReactNodeView {
94
+ constructor(props) {
95
+ var _props$pluginInjectio, _props$pluginInjectio2, _props$pluginInjectio3, _sharedState$currentS;
96
+ super(props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props, undefined, true, undefined, props.hasIntlContext);
97
+ _defineProperty(this, "calcTableWidth", (layout, containerWidth) => {
98
+ if (layout === 'center') {
99
+ return 'inherit';
100
+ }
101
+ return calcBreakoutWidthPx(layout, containerWidth);
102
+ });
103
+ const sharedState = props === null || props === void 0 ? void 0 : (_props$pluginInjectio = props.pluginInjectionApi) === null || _props$pluginInjectio === void 0 ? void 0 : (_props$pluginInjectio2 = _props$pluginInjectio.dependencies) === null || _props$pluginInjectio2 === void 0 ? void 0 : (_props$pluginInjectio3 = _props$pluginInjectio2.width) === null || _props$pluginInjectio3 === void 0 ? void 0 : _props$pluginInjectio3.sharedState;
104
+ this.tableWidth = sharedState === null || sharedState === void 0 ? void 0 : (_sharedState$currentS = sharedState.currentState()) === null || _sharedState$currentS === void 0 ? void 0 : _sharedState$currentS.width;
105
+ sharedState === null || sharedState === void 0 ? void 0 : sharedState.onChange(({
106
+ nextSharedState
107
+ }) => {
108
+ if (nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.width && this.tableWidth !== (nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.width)) {
109
+ this.tableWidth = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.width;
110
+ this.update(this.node, []); // required to update the width when page is resized.
111
+ }
112
+ });
113
+ }
114
+
115
+ createDomRef() {
116
+ const domRef = document.createElement('div');
117
+ domRef.classList.add(SmartCardSharedCssClassName.DATASOURCE_CONTAINER);
118
+ return domRef;
119
+ }
91
120
  render() {
121
+ const {
122
+ attrs
123
+ } = this.node;
124
+ const calculatedWidth = this.calcTableWidth(attrs.layout, this.tableWidth);
92
125
  return jsx("div", {
93
- css: containerStyles
126
+ className: DATASOURCE_INNER_CONTAINER_CLASSNAME,
127
+ css: containerStyles,
128
+ style: {
129
+ minWidth: calculatedWidth
130
+ }
94
131
  }, jsx(DatasourceComponent, {
95
132
  node: this.node,
96
133
  view: this.view,
@@ -26,6 +26,22 @@ export const setProvider = cardProvider => tr => cardAction(tr, {
26
26
  type: 'SET_PROVIDER',
27
27
  provider: cardProvider
28
28
  });
29
+ export const setDatasourceTableRef = datasourceTableRef => tr => cardAction(tr, {
30
+ type: 'SET_DATASOURCE_TABLE_REF',
31
+ datasourceTableRef
32
+ });
33
+ export const setCardLayout = layout => tr => cardAction(tr, {
34
+ type: 'SET_CARD_LAYOUT',
35
+ layout
36
+ });
37
+ export const setCardLayoutAndDatasourceTableRef = ({
38
+ layout,
39
+ datasourceTableRef
40
+ }) => tr => cardAction(tr, {
41
+ type: 'SET_CARD_LAYOUT_AND_DATASOURCE_TABLE_REF',
42
+ layout,
43
+ datasourceTableRef
44
+ });
29
45
  export const showLinkToolbar = tr => cardAction(tr, {
30
46
  type: 'SHOW_LINK_TOOLBAR'
31
47
  });
@@ -1,4 +1,5 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { NodeSelection } from 'prosemirror-state';
2
3
  import rafSchedule from 'raf-schd';
3
4
  import { getInlineNodeViewProducer } from '@atlaskit/editor-common/react-node-view';
4
5
  import { BlockCard } from '../nodeviews/blockCard';
@@ -9,7 +10,9 @@ import reducer from './reducers';
9
10
  import { handleProvider, resolveWithProvider } from './util/resolve';
10
11
  import { getNewRequests, getPluginState, getPluginStateWithUpdatedPos } from './util/state';
11
12
  import { createAnalyticsQueue, eventsFromTransaction } from './analytics';
12
- import { Datasource } from '../nodeviews/datasource';
13
+ import { DATASOURCE_INNER_CONTAINER_CLASSNAME, Datasource } from '../nodeviews/datasource';
14
+ import { setDatasourceTableRef, setCardLayoutAndDatasourceTableRef } from './actions';
15
+ import { findDomRefAtPos } from 'prosemirror-utils';
13
16
  export { pluginKey } from './plugin-key';
14
17
  export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryParams => {
15
18
  const {
@@ -36,7 +39,9 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
36
39
  smartLinkEvents: undefined,
37
40
  smartLinkEventsNext: undefined,
38
41
  createAnalyticsEvent,
39
- editorAppearance
42
+ editorAppearance,
43
+ datasourceTableRef: undefined,
44
+ layout: undefined
40
45
  };
41
46
  },
42
47
  apply(tr, pluginState, prevEditorState) {
@@ -60,12 +65,48 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
60
65
  },
61
66
  view(view) {
62
67
  const subscriptionHandler = (name, provider) => handleProvider(name, provider, view);
68
+ const domAtPos = view.domAtPos.bind(view);
63
69
  const rafCancellationCallbacks = [];
64
70
  pmPluginFactoryParams.providerFactory.subscribe('cardProvider', subscriptionHandler);
65
71
  return {
66
72
  update(view, prevState) {
73
+ var _selection$node;
67
74
  const currentState = getPluginState(view.state);
68
75
  const oldState = getPluginState(prevState);
76
+ const {
77
+ state,
78
+ dispatch
79
+ } = view;
80
+ const {
81
+ selection,
82
+ tr,
83
+ schema
84
+ } = state;
85
+ const isBlockCardSelected = selection instanceof NodeSelection && ((_selection$node = selection.node) === null || _selection$node === void 0 ? void 0 : _selection$node.type) === schema.nodes.blockCard;
86
+ if (isBlockCardSelected) {
87
+ var _findDomRefAtPos, _node$attrs;
88
+ const datasourceTableRef = (_findDomRefAtPos = findDomRefAtPos(selection.from, domAtPos)) === null || _findDomRefAtPos === void 0 ? void 0 : _findDomRefAtPos.querySelector(`.${DATASOURCE_INNER_CONTAINER_CLASSNAME}`);
89
+ const {
90
+ node
91
+ } = selection;
92
+ const isDatasource = !!(node !== null && node !== void 0 && (_node$attrs = node.attrs) !== null && _node$attrs !== void 0 && _node$attrs.datasource);
93
+ const shouldUpdateTableRef = datasourceTableRef && (currentState === null || currentState === void 0 ? void 0 : currentState.datasourceTableRef) !== datasourceTableRef;
94
+ if (isDatasource && shouldUpdateTableRef) {
95
+ var _node$attrs2;
96
+ // since we use the plugin state, which is a shared state, we need to update the datasourceTableRef, layout on each selection
97
+ const layout = (node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.layout) || 'center';
98
+
99
+ // we use cardAction to set the same meta, hence, we will need to combine both layout+datasourceTableRef in one transaction
100
+ dispatch(setCardLayoutAndDatasourceTableRef({
101
+ datasourceTableRef,
102
+ layout
103
+ })(tr));
104
+ }
105
+ } else {
106
+ if (currentState !== null && currentState !== void 0 && currentState.datasourceTableRef) {
107
+ dispatch(setDatasourceTableRef(undefined)(tr));
108
+ }
109
+ }
69
110
  if (currentState && currentState.provider) {
70
111
  // Find requests in this state that weren't in the old one.
71
112
  const newRequests = getNewRequests(oldState, currentState);
@@ -111,6 +152,7 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
111
152
  }
112
153
  }),
113
154
  blockCard: (node, view, getPos) => {
155
+ var _node$attrs3;
114
156
  const {
115
157
  portalProviderAPI,
116
158
  eventDispatcher
@@ -120,8 +162,17 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
120
162
  showServerActions
121
163
  };
122
164
  const hasIntlContext = true;
123
- if (node.attrs.datasource) {
124
- return new Datasource(node, view, getPos, portalProviderAPI, eventDispatcher, undefined, undefined, true, undefined, hasIntlContext).init();
165
+ const isDatasource = !!(node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.datasource);
166
+ if (isDatasource) {
167
+ return new Datasource({
168
+ node,
169
+ view,
170
+ getPos,
171
+ portalProviderAPI,
172
+ eventDispatcher,
173
+ hasIntlContext,
174
+ pluginInjectionApi
175
+ }).init();
125
176
  }
126
177
  return new BlockCard(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, undefined, true, undefined, hasIntlContext).init();
127
178
  },
@@ -28,6 +28,25 @@ const setProvider = (state, action) => {
28
28
  provider: action.provider
29
29
  };
30
30
  };
31
+ const setCardLayout = (state, action) => {
32
+ return {
33
+ ...state,
34
+ layout: action.layout
35
+ };
36
+ };
37
+ const setDatasourceTableRef = (state, action) => {
38
+ return {
39
+ ...state,
40
+ datasourceTableRef: action.datasourceTableRef
41
+ };
42
+ };
43
+ const setCardLayoutDatasourceTableRef = (state, action) => {
44
+ return {
45
+ ...state,
46
+ datasourceTableRef: action.datasourceTableRef,
47
+ layout: action.layout
48
+ };
49
+ };
31
50
  const registerEvents = (state, action) => {
32
51
  return {
33
52
  ...state,
@@ -60,6 +79,12 @@ export default ((state, action) => {
60
79
  return registerEvents(state, action);
61
80
  case 'REGISTER_EVENTS_NEXT':
62
81
  return registerEventsNext(state, action);
82
+ case 'SET_DATASOURCE_TABLE_REF':
83
+ return setDatasourceTableRef(state, action);
84
+ case 'SET_CARD_LAYOUT':
85
+ return setCardLayout(state, action);
86
+ case 'SET_CARD_LAYOUT_AND_DATASOURCE_TABLE_REF':
87
+ return setCardLayoutDatasourceTableRef(state, action);
63
88
  case 'SHOW_LINK_TOOLBAR':
64
89
  case 'HIDE_LINK_TOOLBAR':
65
90
  return setLinkToolbar(state, action);
@@ -67,6 +67,12 @@ export const smartCardStyles = css`
67
67
  }
68
68
  }
69
69
 
70
+ .${SmartCardSharedCssClassName.DATASOURCE_CONTAINER}.${SmartCardSharedCssClassName.BLOCK_CARD_CONTAINER} {
71
+ max-width: 100%;
72
+ display: flex;
73
+ justify-content: center;
74
+ }
75
+
70
76
  .${SmartCardSharedCssClassName.EMBED_CARD_CONTAINER} {
71
77
  .${SmartCardSharedCssClassName.LOADER_WRAPPER} > div {
72
78
  cursor: pointer;
@@ -0,0 +1,106 @@
1
+ /** @jsx jsx */
2
+ import React, { useCallback, useMemo } from 'react';
3
+ import { jsx } from '@emotion/react';
4
+ import { Popup } from '@atlaskit/editor-common/ui';
5
+ import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
6
+ import CollapseIcon from '@atlaskit/icon/glyph/editor/collapse';
7
+ import ExpandIcon from '@atlaskit/icon/glyph/editor/expand';
8
+ import { injectIntl } from 'react-intl-next';
9
+ import { toolbarButtonWrapper } from './styled';
10
+ import { getDatasource } from './utils';
11
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
12
+ import { setCardLayout } from '../../pm-plugins/actions';
13
+ import { getNextBreakoutMode, getTitle } from '@atlaskit/editor-common/utils';
14
+ export const LayoutButton = ({
15
+ onLayoutChange,
16
+ layout = 'center',
17
+ intl: {
18
+ formatMessage
19
+ },
20
+ mountPoint,
21
+ boundariesElement,
22
+ scrollableElement,
23
+ targetElement,
24
+ testId = 'datasource-table-layout-button'
25
+ }) => {
26
+ const handleClick = useCallback(() => {
27
+ onLayoutChange && onLayoutChange(getNextBreakoutMode(layout));
28
+ }, [layout, onLayoutChange]);
29
+ const title = useMemo(() => {
30
+ return formatMessage(getTitle(layout));
31
+ }, [formatMessage, layout]);
32
+ if (!targetElement) {
33
+ return null;
34
+ }
35
+ return jsx(Popup, {
36
+ mountTo: mountPoint,
37
+ boundariesElement: boundariesElement,
38
+ scrollableElement: scrollableElement,
39
+ target: targetElement,
40
+ alignY: "start",
41
+ alignX: "end",
42
+ forcePlacement: true,
43
+ stick: true,
44
+ ariaLabel: title
45
+ }, jsx(ToolbarButton, {
46
+ testId: testId,
47
+ css: toolbarButtonWrapper,
48
+ title: title,
49
+ onClick: handleClick,
50
+ iconBefore: layout === 'full-width' ? jsx(CollapseIcon, {
51
+ label: title
52
+ }) : jsx(ExpandIcon, {
53
+ label: title
54
+ })
55
+ }));
56
+ };
57
+ const LayoutButtonWrapper = ({
58
+ editorView,
59
+ mountPoint,
60
+ scrollableElement,
61
+ boundariesElement,
62
+ intl,
63
+ api
64
+ }) => {
65
+ var _node$attrs, _node$attrs2;
66
+ const {
67
+ cardState
68
+ } = useSharedPluginState(api, ['card']);
69
+ const {
70
+ node,
71
+ pos
72
+ } = getDatasource(editorView);
73
+ const {
74
+ datasourceTableRef,
75
+ layout = (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.layout) || 'center'
76
+ } = cardState !== null && cardState !== void 0 ? cardState : {};
77
+ const isDatasource = !!(node !== null && node !== void 0 && (_node$attrs2 = node.attrs) !== null && _node$attrs2 !== void 0 && _node$attrs2.datasource);
78
+ const onLayoutChange = layout => {
79
+ if (pos === undefined) {
80
+ return;
81
+ }
82
+ const {
83
+ state,
84
+ dispatch
85
+ } = editorView;
86
+ const tr = state.tr.setNodeMarkup(pos, undefined, {
87
+ ...(node === null || node === void 0 ? void 0 : node.attrs),
88
+ layout
89
+ });
90
+ tr.setMeta('scrollIntoView', false);
91
+ dispatch(setCardLayout(layout)(tr));
92
+ };
93
+ if (!isDatasource) {
94
+ return null;
95
+ }
96
+ return jsx(LayoutButton, {
97
+ mountPoint: mountPoint,
98
+ scrollableElement: scrollableElement,
99
+ boundariesElement: boundariesElement,
100
+ targetElement: datasourceTableRef,
101
+ layout: layout,
102
+ onLayoutChange: onLayoutChange,
103
+ intl: intl
104
+ });
105
+ };
106
+ export default injectIntl(LayoutButtonWrapper);
@@ -0,0 +1,10 @@
1
+ import { css } from '@emotion/react';
2
+ import { B300, N300, N20A } from '@atlaskit/theme/colors';
3
+ export const toolbarButtonWrapper = css({
4
+ background: `${`var(--ds-background-neutral, ${N20A})`}`,
5
+ color: `${`var(--ds-icon, ${N300})`}`,
6
+ ':hover': {
7
+ background: `${`var(--ds-background-neutral-hovered, ${B300})`}`,
8
+ color: `${"var(--ds-icon, white)"} !important`
9
+ }
10
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ import { findSelectedNodeOfType } from 'prosemirror-utils';
2
+ export const getDatasource = editorView => {
3
+ var _findSelectedNodeOfTy;
4
+ const {
5
+ selection,
6
+ schema
7
+ } = editorView.state;
8
+ const {
9
+ blockCard
10
+ } = schema.nodes;
11
+ return (_findSelectedNodeOfTy = findSelectedNodeOfType([blockCard])(selection)) !== null && _findSelectedNodeOfTy !== void 0 ? _findSelectedNodeOfTy : {
12
+ node: undefined,
13
+ pos: undefined
14
+ };
15
+ };
@@ -2,12 +2,12 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React from 'react';
3
3
  import ReactDOM from 'react-dom';
4
4
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
- import { NodeSelection, TextSelection, AllSelection } from 'prosemirror-state';
5
+ import { NodeSelection, TextSelection, AllSelection, Selection } from 'prosemirror-state';
6
6
  import { insertPoint } from 'prosemirror-transform';
7
7
  import { Decoration, DecorationSet } from 'prosemirror-view';
8
8
  import { ErrorReporter, browser } from '@atlaskit/editor-common/utils';
9
9
  import assert from 'assert';
10
- import { findDomRefAtPos, isNodeSelection } from 'prosemirror-utils';
10
+ import { findDomRefAtPos, isNodeSelection, findSelectedNodeOfType, findParentNodeOfType } from 'prosemirror-utils';
11
11
  import { insertMediaSingleNode, isMediaSingle } from '../utils/media-single';
12
12
  import DropPlaceholder from '../ui/Media/DropPlaceholder';
13
13
  import { insertMediaGroupNode, insertMediaInlineNode, canInsertMediaInline } from '../utils/media-files';
@@ -379,8 +379,30 @@ export class MediaPluginStateImplementation {
379
379
  dispatch,
380
380
  state
381
381
  } = this.view;
382
+ const {
383
+ tr,
384
+ selection,
385
+ doc
386
+ } = state;
387
+ const {
388
+ media,
389
+ mediaGroup
390
+ } = state.schema.nodes;
391
+
392
+ // Workaround for wrong upload position
393
+ // @see https://product-fabric.atlassian.net/browse/MEX-2457
394
+ // If the media node is the last selectable item in the current cursor position and it is located within a mediaGroup,
395
+ // we relocate the cursor to the first child of the mediaGroup.
396
+ const sel = Selection.findFrom(doc.resolve(selection.$from.pos - 1), -1);
397
+ if (sel && findSelectedNodeOfType(media)(sel)) {
398
+ const parent = findParentNodeOfType(mediaGroup)(sel);
399
+ if (parent) {
400
+ tr.setSelection(NodeSelection.create(tr.doc, parent.start));
401
+ }
402
+ }
403
+
382
404
  // Trigger state change to be able to pick it up in the decorations handler
383
- dispatch(state.tr);
405
+ dispatch(tr);
384
406
  });
385
407
  this.options = options;
386
408
  this.mediaOptions = mediaOptions;
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "185.5.2";
2
+ export const version = "185.5.7";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "185.5.2",
3
+ "version": "185.5.7",
4
4
  "sideEffects": false
5
5
  }