@atlaskit/editor-core 185.2.0 → 185.2.5

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 (258) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/actions/index.js +2 -2
  3. package/dist/cjs/create-editor/ReactEditorViewInternal.js +1 -2
  4. package/dist/cjs/index.js +0 -6
  5. package/dist/cjs/labs/next/internal/hooks/use-editor/create-editor.js +1 -1
  6. package/dist/cjs/messages.js +6 -56
  7. package/dist/cjs/nodeviews/getInlineNodeViewProducer.styles.js +2 -2
  8. package/dist/cjs/plugins/base/pm-plugins/scroll-gutter.js +1 -1
  9. package/dist/cjs/plugins/card/nodeviews/blockCard.js +2 -2
  10. package/dist/cjs/plugins/card/nodeviews/embedCard.js +6 -6
  11. package/dist/cjs/plugins/card/nodeviews/genericCard.js +2 -1
  12. package/dist/cjs/plugins/card/pm-plugins/doc.js +9 -11
  13. package/dist/cjs/plugins/card/pm-plugins/keymap.js +3 -6
  14. package/dist/cjs/plugins/card/pm-plugins/main.js +2 -2
  15. package/dist/cjs/plugins/card/toolbar.js +13 -16
  16. package/dist/cjs/plugins/card/ui/EditLinkToolbar.js +19 -18
  17. package/dist/cjs/plugins/card/ui/ResizableEmbedCard.js +7 -10
  18. package/dist/cjs/plugins/card/utils.js +3 -4
  19. package/dist/cjs/plugins/clear-marks-on-change-to-empty-document/index.js +1 -1
  20. package/dist/cjs/plugins/custom-autoformat/doc.js +1 -1
  21. package/dist/cjs/plugins/date/pm-plugins/main.js +2 -2
  22. package/dist/cjs/plugins/emoji/index.js +2 -2
  23. package/dist/cjs/plugins/floating-toolbar/index.js +8 -2
  24. package/dist/cjs/plugins/hyperlink/Toolbar.js +8 -8
  25. package/dist/cjs/plugins/hyperlink/commands.js +2 -3
  26. package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +2 -2
  27. package/dist/cjs/plugins/layout/actions.js +1 -1
  28. package/dist/cjs/plugins/media/nodeviews/mediaNodeUpdater.js +1 -1
  29. package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +2 -3
  30. package/dist/cjs/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +1 -2
  31. package/dist/cjs/plugins/media/toolbar/index.js +10 -9
  32. package/dist/cjs/plugins/media/toolbar/linking-toolbar-appearance.js +4 -3
  33. package/dist/cjs/plugins/media/toolbar/linking.js +6 -6
  34. package/dist/cjs/plugins/media/ui/MediaLinkingToolbar.js +1 -1
  35. package/dist/cjs/plugins/media/ui/ResizableMediaSingle/index.js +6 -8
  36. package/dist/cjs/plugins/media/utils/media-files.js +8 -7
  37. package/dist/cjs/plugins/mentions/pm-plugins/main.js +2 -2
  38. package/dist/cjs/plugins/placeholder/index.js +2 -3
  39. package/dist/cjs/plugins/status/plugin.js +2 -2
  40. package/dist/cjs/plugins/unsupported-content/index.js +3 -3
  41. package/dist/cjs/ui/LinkSearch/ToolbarComponents.js +4 -11
  42. package/dist/cjs/utils/document.js +7 -249
  43. package/dist/cjs/utils/index.js +1 -23
  44. package/dist/cjs/version-wrapper.js +1 -1
  45. package/dist/cjs/version.json +1 -1
  46. package/dist/es2019/actions/index.js +2 -1
  47. package/dist/es2019/create-editor/ReactEditorViewInternal.js +1 -1
  48. package/dist/es2019/index.js +1 -1
  49. package/dist/es2019/labs/next/internal/hooks/use-editor/create-editor.js +1 -1
  50. package/dist/es2019/messages.js +2 -54
  51. package/dist/es2019/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
  52. package/dist/es2019/plugins/base/pm-plugins/scroll-gutter.js +1 -1
  53. package/dist/es2019/plugins/card/nodeviews/blockCard.js +1 -1
  54. package/dist/es2019/plugins/card/nodeviews/embedCard.js +3 -3
  55. package/dist/es2019/plugins/card/nodeviews/genericCard.js +2 -1
  56. package/dist/es2019/plugins/card/pm-plugins/doc.js +2 -3
  57. package/dist/es2019/plugins/card/pm-plugins/keymap.js +3 -3
  58. package/dist/es2019/plugins/card/pm-plugins/main.js +1 -1
  59. package/dist/es2019/plugins/card/toolbar.js +8 -10
  60. package/dist/es2019/plugins/card/ui/EditLinkToolbar.js +10 -8
  61. package/dist/es2019/plugins/card/ui/ResizableEmbedCard.js +1 -4
  62. package/dist/es2019/plugins/card/utils.js +1 -2
  63. package/dist/es2019/plugins/clear-marks-on-change-to-empty-document/index.js +1 -1
  64. package/dist/es2019/plugins/custom-autoformat/doc.js +1 -1
  65. package/dist/es2019/plugins/date/pm-plugins/main.js +1 -1
  66. package/dist/es2019/plugins/emoji/index.js +1 -1
  67. package/dist/es2019/plugins/floating-toolbar/index.js +5 -2
  68. package/dist/es2019/plugins/hyperlink/Toolbar.js +3 -3
  69. package/dist/es2019/plugins/hyperlink/commands.js +1 -2
  70. package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +1 -1
  71. package/dist/es2019/plugins/layout/actions.js +1 -1
  72. package/dist/es2019/plugins/media/nodeviews/mediaNodeUpdater.js +1 -1
  73. package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +1 -1
  74. package/dist/es2019/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +1 -1
  75. package/dist/es2019/plugins/media/toolbar/index.js +10 -9
  76. package/dist/es2019/plugins/media/toolbar/linking-toolbar-appearance.js +2 -1
  77. package/dist/es2019/plugins/media/toolbar/linking.js +4 -4
  78. package/dist/es2019/plugins/media/ui/MediaLinkingToolbar.js +1 -1
  79. package/dist/es2019/plugins/media/ui/ResizableMediaSingle/index.js +2 -4
  80. package/dist/es2019/plugins/media/utils/media-files.js +4 -3
  81. package/dist/es2019/plugins/mentions/pm-plugins/main.js +1 -1
  82. package/dist/es2019/plugins/placeholder/index.js +1 -1
  83. package/dist/es2019/plugins/status/plugin.js +1 -1
  84. package/dist/es2019/plugins/unsupported-content/index.js +1 -1
  85. package/dist/es2019/ui/LinkSearch/ToolbarComponents.js +1 -4
  86. package/dist/es2019/utils/document.js +3 -244
  87. package/dist/es2019/utils/index.js +1 -4
  88. package/dist/es2019/version-wrapper.js +1 -1
  89. package/dist/es2019/version.json +1 -1
  90. package/dist/esm/actions/index.js +2 -1
  91. package/dist/esm/create-editor/ReactEditorViewInternal.js +1 -1
  92. package/dist/esm/index.js +1 -1
  93. package/dist/esm/labs/next/internal/hooks/use-editor/create-editor.js +1 -1
  94. package/dist/esm/messages.js +2 -54
  95. package/dist/esm/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
  96. package/dist/esm/plugins/base/pm-plugins/scroll-gutter.js +1 -1
  97. package/dist/esm/plugins/card/nodeviews/blockCard.js +1 -1
  98. package/dist/esm/plugins/card/nodeviews/embedCard.js +3 -3
  99. package/dist/esm/plugins/card/nodeviews/genericCard.js +2 -1
  100. package/dist/esm/plugins/card/pm-plugins/doc.js +2 -3
  101. package/dist/esm/plugins/card/pm-plugins/keymap.js +3 -3
  102. package/dist/esm/plugins/card/pm-plugins/main.js +1 -1
  103. package/dist/esm/plugins/card/toolbar.js +8 -10
  104. package/dist/esm/plugins/card/ui/EditLinkToolbar.js +18 -16
  105. package/dist/esm/plugins/card/ui/ResizableEmbedCard.js +1 -4
  106. package/dist/esm/plugins/card/utils.js +1 -2
  107. package/dist/esm/plugins/clear-marks-on-change-to-empty-document/index.js +1 -1
  108. package/dist/esm/plugins/custom-autoformat/doc.js +1 -1
  109. package/dist/esm/plugins/date/pm-plugins/main.js +1 -1
  110. package/dist/esm/plugins/emoji/index.js +1 -1
  111. package/dist/esm/plugins/floating-toolbar/index.js +5 -2
  112. package/dist/esm/plugins/hyperlink/Toolbar.js +3 -3
  113. package/dist/esm/plugins/hyperlink/commands.js +1 -2
  114. package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +1 -1
  115. package/dist/esm/plugins/layout/actions.js +1 -1
  116. package/dist/esm/plugins/media/nodeviews/mediaNodeUpdater.js +1 -1
  117. package/dist/esm/plugins/media/nodeviews/mediaSingle.js +1 -1
  118. package/dist/esm/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +1 -1
  119. package/dist/esm/plugins/media/toolbar/index.js +10 -9
  120. package/dist/esm/plugins/media/toolbar/linking-toolbar-appearance.js +2 -1
  121. package/dist/esm/plugins/media/toolbar/linking.js +4 -4
  122. package/dist/esm/plugins/media/ui/MediaLinkingToolbar.js +1 -1
  123. package/dist/esm/plugins/media/ui/ResizableMediaSingle/index.js +2 -4
  124. package/dist/esm/plugins/media/utils/media-files.js +4 -3
  125. package/dist/esm/plugins/mentions/pm-plugins/main.js +1 -1
  126. package/dist/esm/plugins/placeholder/index.js +1 -1
  127. package/dist/esm/plugins/status/plugin.js +1 -1
  128. package/dist/esm/plugins/unsupported-content/index.js +1 -1
  129. package/dist/esm/ui/LinkSearch/ToolbarComponents.js +1 -4
  130. package/dist/esm/utils/document.js +6 -240
  131. package/dist/esm/utils/index.js +1 -4
  132. package/dist/esm/version-wrapper.js +1 -1
  133. package/dist/esm/version.json +1 -1
  134. package/dist/types/index.d.ts +1 -2
  135. package/dist/types/labs/next/presets/cxhtml.d.ts +9 -3
  136. package/dist/types/labs/next/presets/default.d.ts +13 -1
  137. package/dist/types/labs/next/presets/mobile.d.ts +9 -3
  138. package/dist/types/messages.d.ts +2 -53
  139. package/dist/types/plugins/card/index.d.ts +3 -1
  140. package/dist/types/plugins/card/nodeviews/blockCard.d.ts +1 -1
  141. package/dist/types/plugins/card/nodeviews/genericCard.d.ts +3 -3
  142. package/dist/types/plugins/card/nodeviews/inlineCard.d.ts +1 -1
  143. package/dist/types/plugins/card/toolbar.d.ts +1 -1
  144. package/dist/types/plugins/card/types.d.ts +1 -1
  145. package/dist/types/plugins/card/ui/EditLinkToolbar.d.ts +7 -4
  146. package/dist/types/plugins/card/ui/ResizableEmbedCard.d.ts +1 -1
  147. package/dist/types/plugins/date/nodeviews/date.d.ts +1 -1
  148. package/dist/types/plugins/emoji/nodeviews/emoji.d.ts +1 -1
  149. package/dist/types/plugins/floating-toolbar/index.d.ts +2 -6
  150. package/dist/types/plugins/floating-toolbar/ui/Toolbar.d.ts +1 -1
  151. package/dist/types/plugins/hyperlink/Toolbar.d.ts +1 -1
  152. package/dist/types/plugins/hyperlink/commands.d.ts +2 -3
  153. package/dist/types/plugins/hyperlink/index.d.ts +1 -1
  154. package/dist/types/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.d.ts +1 -1
  155. package/dist/types/plugins/hyperlink/ui/HyperlinkAddToolbar/index.d.ts +1 -1
  156. package/dist/types/plugins/media/index.d.ts +3 -1
  157. package/dist/types/plugins/media/nodeviews/mediaInline.d.ts +1 -1
  158. package/dist/types/plugins/media/nodeviews/mediaNodeUpdater.d.ts +1 -1
  159. package/dist/types/plugins/media/nodeviews/types.d.ts +1 -1
  160. package/dist/types/plugins/media/toolbar/linking.d.ts +3 -1
  161. package/dist/types/plugins/media/ui/ResizableMediaSingle/types.d.ts +0 -15
  162. package/dist/types/plugins/media/utils/media-files.d.ts +1 -1
  163. package/dist/types/plugins/mentions/nodeviews/mention.d.ts +1 -1
  164. package/dist/types/plugins/status/nodeviews/status.d.ts +1 -1
  165. package/dist/types/plugins/unsupported-content/unsupported-inline-node-view.d.ts +1 -1
  166. package/dist/types/types/editor-props.d.ts +1 -1
  167. package/dist/types/ui/LinkSearch/ToolbarComponents.d.ts +0 -4
  168. package/dist/types/utils/document.d.ts +0 -12
  169. package/dist/types/utils/index.d.ts +1 -2
  170. package/dist/types-ts4.5/index.d.ts +1 -2
  171. package/dist/types-ts4.5/labs/next/presets/cxhtml.d.ts +9 -3
  172. package/dist/types-ts4.5/labs/next/presets/default.d.ts +13 -1
  173. package/dist/types-ts4.5/labs/next/presets/mobile.d.ts +9 -3
  174. package/dist/types-ts4.5/messages.d.ts +2 -53
  175. package/dist/types-ts4.5/plugins/card/index.d.ts +3 -1
  176. package/dist/types-ts4.5/plugins/card/nodeviews/blockCard.d.ts +1 -1
  177. package/dist/types-ts4.5/plugins/card/nodeviews/genericCard.d.ts +3 -3
  178. package/dist/types-ts4.5/plugins/card/nodeviews/inlineCard.d.ts +1 -1
  179. package/dist/types-ts4.5/plugins/card/toolbar.d.ts +1 -1
  180. package/dist/types-ts4.5/plugins/card/types.d.ts +1 -1
  181. package/dist/types-ts4.5/plugins/card/ui/EditLinkToolbar.d.ts +7 -4
  182. package/dist/types-ts4.5/plugins/card/ui/ResizableEmbedCard.d.ts +1 -1
  183. package/dist/types-ts4.5/plugins/date/nodeviews/date.d.ts +1 -1
  184. package/dist/types-ts4.5/plugins/emoji/nodeviews/emoji.d.ts +1 -1
  185. package/dist/types-ts4.5/plugins/floating-toolbar/index.d.ts +2 -9
  186. package/dist/types-ts4.5/plugins/floating-toolbar/ui/Toolbar.d.ts +1 -1
  187. package/dist/types-ts4.5/plugins/hyperlink/Toolbar.d.ts +1 -1
  188. package/dist/types-ts4.5/plugins/hyperlink/commands.d.ts +2 -3
  189. package/dist/types-ts4.5/plugins/hyperlink/index.d.ts +1 -1
  190. package/dist/types-ts4.5/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.d.ts +1 -1
  191. package/dist/types-ts4.5/plugins/hyperlink/ui/HyperlinkAddToolbar/index.d.ts +1 -1
  192. package/dist/types-ts4.5/plugins/media/index.d.ts +3 -1
  193. package/dist/types-ts4.5/plugins/media/nodeviews/mediaInline.d.ts +1 -1
  194. package/dist/types-ts4.5/plugins/media/nodeviews/mediaNodeUpdater.d.ts +1 -1
  195. package/dist/types-ts4.5/plugins/media/nodeviews/types.d.ts +1 -1
  196. package/dist/types-ts4.5/plugins/media/toolbar/linking.d.ts +3 -1
  197. package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/types.d.ts +0 -15
  198. package/dist/types-ts4.5/plugins/media/utils/media-files.d.ts +1 -1
  199. package/dist/types-ts4.5/plugins/mentions/nodeviews/mention.d.ts +1 -1
  200. package/dist/types-ts4.5/plugins/status/nodeviews/status.d.ts +1 -1
  201. package/dist/types-ts4.5/plugins/unsupported-content/unsupported-inline-node-view.d.ts +1 -1
  202. package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
  203. package/dist/types-ts4.5/ui/LinkSearch/ToolbarComponents.d.ts +0 -4
  204. package/dist/types-ts4.5/utils/document.d.ts +0 -12
  205. package/dist/types-ts4.5/utils/index.d.ts +1 -2
  206. package/package.json +11 -14
  207. package/report.api.md +11 -34
  208. package/tmp/api-report-tmp.d.ts +10 -34
  209. package/dist/cjs/nodeviews/getInlineNodeViewProducer.js +0 -227
  210. package/dist/cjs/plugins/hyperlink/types.js +0 -5
  211. package/dist/cjs/ui/MediaAndEmbedsToolbar/index.js +0 -152
  212. package/dist/cjs/ui/Resizer/index.js +0 -210
  213. package/dist/cjs/ui/Resizer/styled.js +0 -15
  214. package/dist/cjs/ui/Resizer/types.js +0 -5
  215. package/dist/cjs/ui/Resizer/utils.js +0 -21
  216. package/dist/cjs/utils/filter/privacy-filter.js +0 -55
  217. package/dist/cjs/utils/linking-utils.js +0 -84
  218. package/dist/cjs/utils/rich-media-utils.js +0 -130
  219. package/dist/es2019/nodeviews/getInlineNodeViewProducer.js +0 -221
  220. package/dist/es2019/plugins/hyperlink/types.js +0 -1
  221. package/dist/es2019/ui/MediaAndEmbedsToolbar/index.js +0 -159
  222. package/dist/es2019/ui/Resizer/index.js +0 -191
  223. package/dist/es2019/ui/Resizer/styled.js +0 -15
  224. package/dist/es2019/ui/Resizer/types.js +0 -1
  225. package/dist/es2019/ui/Resizer/utils.js +0 -12
  226. package/dist/es2019/utils/filter/privacy-filter.js +0 -47
  227. package/dist/es2019/utils/linking-utils.js +0 -74
  228. package/dist/es2019/utils/rich-media-utils.js +0 -108
  229. package/dist/esm/nodeviews/getInlineNodeViewProducer.js +0 -217
  230. package/dist/esm/plugins/hyperlink/types.js +0 -1
  231. package/dist/esm/ui/MediaAndEmbedsToolbar/index.js +0 -144
  232. package/dist/esm/ui/Resizer/index.js +0 -203
  233. package/dist/esm/ui/Resizer/styled.js +0 -7
  234. package/dist/esm/ui/Resizer/types.js +0 -1
  235. package/dist/esm/ui/Resizer/utils.js +0 -12
  236. package/dist/esm/utils/filter/privacy-filter.js +0 -48
  237. package/dist/esm/utils/linking-utils.js +0 -74
  238. package/dist/esm/utils/rich-media-utils.js +0 -117
  239. package/dist/types/nodeviews/getInlineNodeViewProducer.d.ts +0 -24
  240. package/dist/types/plugins/hyperlink/types.d.ts +0 -35
  241. package/dist/types/ui/MediaAndEmbedsToolbar/index.d.ts +0 -9
  242. package/dist/types/ui/Resizer/index.d.ts +0 -41
  243. package/dist/types/ui/Resizer/styled.d.ts +0 -2
  244. package/dist/types/ui/Resizer/types.d.ts +0 -26
  245. package/dist/types/ui/Resizer/utils.d.ts +0 -6
  246. package/dist/types/utils/filter/privacy-filter.d.ts +0 -9
  247. package/dist/types/utils/linking-utils.d.ts +0 -14
  248. package/dist/types/utils/rich-media-utils.d.ts +0 -8
  249. package/dist/types-ts4.5/nodeviews/getInlineNodeViewProducer.d.ts +0 -24
  250. package/dist/types-ts4.5/plugins/hyperlink/types.d.ts +0 -35
  251. package/dist/types-ts4.5/ui/MediaAndEmbedsToolbar/index.d.ts +0 -9
  252. package/dist/types-ts4.5/ui/Resizer/index.d.ts +0 -41
  253. package/dist/types-ts4.5/ui/Resizer/styled.d.ts +0 -2
  254. package/dist/types-ts4.5/ui/Resizer/types.d.ts +0 -26
  255. package/dist/types-ts4.5/ui/Resizer/utils.d.ts +0 -6
  256. package/dist/types-ts4.5/utils/filter/privacy-filter.d.ts +0 -9
  257. package/dist/types-ts4.5/utils/linking-utils.d.ts +0 -14
  258. package/dist/types-ts4.5/utils/rich-media-utils.d.ts +0 -8
@@ -1,144 +0,0 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
- import { NodeSelection } from 'prosemirror-state';
3
- import { hasParentNodeOfType } from 'prosemirror-utils';
4
- import commonMessages from '../../messages';
5
- import WrapLeftIcon from '@atlaskit/icon/glyph/editor/media-wrap-left';
6
- import WrapRightIcon from '@atlaskit/icon/glyph/editor/media-wrap-right';
7
- import WideIcon from '@atlaskit/icon/glyph/editor/media-wide';
8
- import FullWidthIcon from '@atlaskit/icon/glyph/editor/media-full-width';
9
- import EditorAlignImageLeft from '@atlaskit/icon/glyph/editor/align-image-left';
10
- import EditorAlignImageRight from '@atlaskit/icon/glyph/editor/align-image-right';
11
- import EditorAlignImageCenter from '@atlaskit/icon/glyph/editor/align-image-center';
12
- import { alignAttributes } from '../../utils/rich-media-utils';
13
- import { DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
14
- import { addAnalytics } from '../../plugins/analytics/utils';
15
- import { ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, ACTION } from '../../plugins/analytics';
16
- import { toolbarMessages } from './toolbar-messages';
17
- import { insideTable, isInLayoutColumn } from '../../utils';
18
- var alignmentIcons = [{
19
- id: 'editor.media.alignLeft',
20
- value: 'align-start',
21
- icon: EditorAlignImageLeft
22
- }, {
23
- id: 'editor.media.alignCenter',
24
- value: 'center',
25
- icon: EditorAlignImageCenter
26
- }, {
27
- id: 'editor.media.alignRight',
28
- value: 'align-end',
29
- icon: EditorAlignImageRight
30
- }];
31
- var wrappingIcons = [{
32
- id: 'editor.media.wrapLeft',
33
- value: 'wrap-left',
34
- icon: WrapLeftIcon
35
- }, {
36
- id: 'editor.media.wrapRight',
37
- value: 'wrap-right',
38
- icon: WrapRightIcon
39
- }];
40
- var breakoutIcons = [{
41
- value: 'wide',
42
- icon: WideIcon
43
- }, {
44
- value: 'full-width',
45
- icon: FullWidthIcon
46
- }];
47
- var layoutToMessages = {
48
- 'wrap-left': toolbarMessages.wrapLeft,
49
- center: commonMessages.alignImageCenter,
50
- 'wrap-right': toolbarMessages.wrapRight,
51
- wide: commonMessages.layoutWide,
52
- 'full-width': commonMessages.layoutFullWidth,
53
- 'align-end': commonMessages.alignImageRight,
54
- 'align-start': commonMessages.alignImageLeft
55
- };
56
- var getNodeWidth = function getNodeWidth(node, schema) {
57
- var embedCard = schema.nodes.embedCard;
58
- if (node.type === embedCard) {
59
- return node.attrs.originalWidth || DEFAULT_EMBED_CARD_WIDTH;
60
- }
61
- return node.firstChild && node.firstChild.attrs.width || node.attrs.width;
62
- };
63
- var makeAlign = function makeAlign(layout, nodeType, widthPluginDependencyApi) {
64
- return function (state, dispatch) {
65
- var _ref = state.selection,
66
- node = _ref.node;
67
- var previousLayoutType = node.attrs.layout;
68
- var mediaSingle = state.schema.nodes.mediaSingle;
69
- if (!dispatch) {
70
- return false;
71
- }
72
- var widthPluginState = widthPluginDependencyApi === null || widthPluginDependencyApi === void 0 ? void 0 : widthPluginDependencyApi.sharedState.currentState();
73
- if (!node || node.type !== nodeType || !widthPluginState) {
74
- return false;
75
- }
76
- var nodeWidth = getNodeWidth(node, state.schema);
77
- var newAttrs = alignAttributes(layout, node.attrs, undefined, nodeWidth, widthPluginState.lineLength);
78
- var tr = state.tr.setNodeMarkup(state.selection.from, undefined, newAttrs);
79
- tr.setMeta('scrollIntoView', false);
80
- // when image captions are enabled, the wrong node gets selected after
81
- // setNodeMarkup is called
82
- tr.setSelection(NodeSelection.create(tr.doc, state.selection.from));
83
- var paragraph = tr.doc.type.schema.nodes.paragraph;
84
-
85
- // see https://product-fabric.atlassian.net/browse/ED-15518 insert a new paragraph when an embedded card is wrapped left or right
86
- if (layout.startsWith('wrap') && paragraph && !tr.doc.nodeAt(state.selection.to) && (insideTable(state) || isInLayoutColumn(state))) {
87
- tr.insert(state.selection.to, paragraph.createAndFill());
88
- }
89
- dispatch(addAnalytics(state, tr, {
90
- eventType: EVENT_TYPE.TRACK,
91
- action: ACTION.SELECTED,
92
- actionSubject: ACTION_SUBJECT[node.type === mediaSingle ? 'MEDIA_SINGLE' : 'EMBEDS'],
93
- actionSubjectId: ACTION_SUBJECT_ID.RICH_MEDIA_LAYOUT,
94
- attributes: {
95
- previousLayoutType: previousLayoutType,
96
- currentLayoutType: layout
97
- }
98
- }));
99
- return true;
100
- };
101
- };
102
- var mapIconsToToolbarItem = function mapIconsToToolbarItem(icons, layout, intl, nodeType, widthPluginDependencyApi) {
103
- return icons.map(function (toolbarItem) {
104
- var id = toolbarItem.id,
105
- value = toolbarItem.value;
106
- return {
107
- id: id,
108
- type: 'button',
109
- icon: toolbarItem.icon,
110
- title: intl.formatMessage(layoutToMessages[value]),
111
- selected: layout === value,
112
- onClick: makeAlign(value, nodeType, widthPluginDependencyApi)
113
- };
114
- });
115
- };
116
- var shouldHideLayoutToolbar = function shouldHideLayoutToolbar(selection, _ref2, allowResizingInTables) {
117
- var nodes = _ref2.nodes;
118
- return hasParentNodeOfType([nodes.bodiedExtension, nodes.listItem, nodes.expand, nodes.nestedExpand].concat(_toConsumableArray(allowResizingInTables ? [] : [nodes.table])).filter(Boolean))(selection);
119
- };
120
- var buildLayoutButtons = function buildLayoutButtons(state, intl, nodeType, widthPluginDependencyApi, allowResizing, allowResizingInTables) {
121
- var allowWrapping = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : true;
122
- var allowAlignment = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : true;
123
- var selection = state.selection;
124
- if (!(selection instanceof NodeSelection) || !selection.node || !nodeType || shouldHideLayoutToolbar(selection, state.schema, allowResizingInTables)) {
125
- return [];
126
- }
127
- var layout = selection.node.attrs.layout;
128
- var alignmentToolbarItems = allowAlignment ? mapIconsToToolbarItem(alignmentIcons, layout, intl, nodeType, widthPluginDependencyApi) : [];
129
- var wrappingToolbarItems = allowWrapping ? mapIconsToToolbarItem(wrappingIcons, layout, intl, nodeType, widthPluginDependencyApi) : [];
130
- var breakOutToolbarItems = !allowResizing ? mapIconsToToolbarItem(breakoutIcons, layout, intl, nodeType, widthPluginDependencyApi) : [];
131
- var items = [].concat(_toConsumableArray(alignmentToolbarItems), _toConsumableArray(getSeparatorBetweenAlignmentAndWrapping(allowAlignment, allowWrapping)), _toConsumableArray(wrappingToolbarItems), _toConsumableArray(getSeparatorBeforeBreakoutItems(allowAlignment, allowWrapping, allowResizing)), _toConsumableArray(breakOutToolbarItems));
132
- return items;
133
- };
134
- var getSeparatorBetweenAlignmentAndWrapping = function getSeparatorBetweenAlignmentAndWrapping(allowAlignment, allowWrapping) {
135
- return allowAlignment && allowWrapping ? [{
136
- type: 'separator'
137
- }] : [];
138
- };
139
- var getSeparatorBeforeBreakoutItems = function getSeparatorBeforeBreakoutItems(allowAlignment, allowWrapping, allowResizing) {
140
- return !allowResizing && (allowAlignment || allowWrapping) ? [{
141
- type: 'separator'
142
- }] : [];
143
- };
144
- export default buildLayoutButtons;
@@ -1,203 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
- 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; } }
10
- import React from 'react';
11
- import classnames from 'classnames';
12
- import { Resizable } from 're-resizable';
13
- import { gridTypeForLayout } from '@atlaskit/editor-common/utils';
14
- import { snapTo, handleSides } from './utils';
15
- import { richMediaClassName } from '@atlaskit/editor-common/styles';
16
- import { akRichMediaResizeZIndex } from '@atlaskit/editor-shared-styles';
17
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../../plugins/analytics';
18
- var getResizeAnalyticsEvent = function getResizeAnalyticsEvent(type, size, layout) {
19
- var actionSubject = type === 'embed' ? ACTION_SUBJECT.EMBEDS : ACTION_SUBJECT.MEDIA_SINGLE;
20
- return {
21
- action: ACTION.EDITED,
22
- actionSubject: actionSubject,
23
- actionSubjectId: ACTION_SUBJECT_ID.RESIZED,
24
- attributes: {
25
- size: size,
26
- layout: layout
27
- },
28
- eventType: EVENT_TYPE.UI
29
- };
30
- };
31
- var getWidthFromSnapPoints = function getWidthFromSnapPoints(width, snapPoints) {
32
- if (snapPoints.length) {
33
- return Math.min(Math.max(width, snapPoints[0]), snapPoints[snapPoints.length - 1]);
34
- }
35
- return width;
36
- };
37
- var Resizer = /*#__PURE__*/function (_React$Component) {
38
- _inherits(Resizer, _React$Component);
39
- var _super = _createSuper(Resizer);
40
- function Resizer() {
41
- var _this;
42
- _classCallCheck(this, Resizer);
43
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
44
- args[_key] = arguments[_key];
45
- }
46
- _this = _super.call.apply(_super, [this].concat(args));
47
- _defineProperty(_assertThisInitialized(_this), "resizable", /*#__PURE__*/React.createRef());
48
- _defineProperty(_assertThisInitialized(_this), "state", {
49
- isResizing: false
50
- });
51
- _defineProperty(_assertThisInitialized(_this), "handleResizeStart", function (event) {
52
- var _this$props = _this.props,
53
- _this$props$innerPadd = _this$props.innerPadding,
54
- innerPadding = _this$props$innerPadd === void 0 ? 0 : _this$props$innerPadd,
55
- highlights = _this$props.highlights,
56
- displayGrid = _this$props.displayGrid,
57
- layout = _this$props.layout,
58
- width = _this$props.width,
59
- snapPoints = _this$props.snapPoints;
60
-
61
- // prevent creating a drag event on Firefox
62
- event.preventDefault();
63
- _this.setState({
64
- isResizing: true
65
- }, function () {
66
- var newHighlights = highlights(width + innerPadding, snapPoints);
67
- displayGrid === null || displayGrid === void 0 ? void 0 : displayGrid(newHighlights.length > 0, gridTypeForLayout(layout), newHighlights);
68
- });
69
- });
70
- _defineProperty(_assertThisInitialized(_this), "handleResize", function (_event, _direction, _elementRef, delta) {
71
- var _this$props2 = _this.props,
72
- highlights = _this$props2.highlights,
73
- calcNewSize = _this$props2.calcNewSize,
74
- scaleFactor = _this$props2.scaleFactor,
75
- snapPoints = _this$props2.snapPoints,
76
- displayGrid = _this$props2.displayGrid,
77
- layout = _this$props2.layout,
78
- updateSize = _this$props2.updateSize,
79
- _this$props2$innerPad = _this$props2.innerPadding,
80
- innerPadding = _this$props2$innerPad === void 0 ? 0 : _this$props2$innerPad;
81
- var resizable = _this.resizable.current;
82
- var isResizing = _this.state.isResizing;
83
- if (!resizable || !resizable.state.original || !isResizing) {
84
- return;
85
- }
86
- var newWidth = getWidthFromSnapPoints(resizable.state.original.width + delta.width * (scaleFactor || 1), snapPoints);
87
- var newSize = calcNewSize(newWidth + innerPadding, false);
88
- if (newSize.layout !== layout) {
89
- updateSize(newSize.width, newSize.layout);
90
- }
91
- var newHighlights = highlights(newWidth, snapPoints);
92
- displayGrid === null || displayGrid === void 0 ? void 0 : displayGrid(newHighlights.length > 0, gridTypeForLayout(newSize.layout), newHighlights);
93
- resizable.updateSize({
94
- width: newWidth,
95
- height: 'auto'
96
- });
97
- resizable.setState({
98
- isResizing: true
99
- });
100
- });
101
- _defineProperty(_assertThisInitialized(_this), "handleResizeStop", function (_event, _direction, _elementRef, delta) {
102
- var _this$props3 = _this.props,
103
- highlights = _this$props3.highlights,
104
- calcNewSize = _this$props3.calcNewSize,
105
- snapPoints = _this$props3.snapPoints,
106
- displayGrid = _this$props3.displayGrid,
107
- layout = _this$props3.layout,
108
- updateSize = _this$props3.updateSize,
109
- dispatchAnalyticsEvent = _this$props3.dispatchAnalyticsEvent,
110
- nodeType = _this$props3.nodeType;
111
- var resizable = _this.resizable.current;
112
- var isResizing = _this.state.isResizing;
113
- if (!resizable || !resizable.state.original || !isResizing) {
114
- return;
115
- }
116
- var newWidth = getWidthFromSnapPoints(resizable.state.original.width + delta.width, snapPoints);
117
- var snapWidth = snapTo(newWidth, snapPoints);
118
- var newSize = calcNewSize(snapWidth, true);
119
- var newHighlights = highlights(newWidth, snapPoints);
120
- if (dispatchAnalyticsEvent) {
121
- dispatchAnalyticsEvent(getResizeAnalyticsEvent(nodeType, newSize.width, newSize.layout));
122
- }
123
- // show committed grid size
124
- displayGrid === null || displayGrid === void 0 ? void 0 : displayGrid(newHighlights.length > 0, gridTypeForLayout(newSize.layout), newHighlights);
125
- _this.setState({
126
- isResizing: false
127
- }, function () {
128
- updateSize(newSize.width, newSize.layout);
129
- displayGrid === null || displayGrid === void 0 ? void 0 : displayGrid(false, gridTypeForLayout(layout), []);
130
- });
131
- });
132
- return _this;
133
- }
134
- _createClass(Resizer, [{
135
- key: "render",
136
- value: function render() {
137
- var handleStyles = {};
138
- var handles = {};
139
- var handleComponent = {};
140
- var _this$props4 = this.props,
141
- _this$props4$innerPad = _this$props4.innerPadding,
142
- innerPadding = _this$props4$innerPad === void 0 ? 0 : _this$props4$innerPad,
143
- width = _this$props4.width,
144
- pctWidth = _this$props4.pctWidth,
145
- selected = _this$props4.selected,
146
- layout = _this$props4.layout,
147
- enable = _this$props4.enable,
148
- children = _this$props4.children,
149
- ratio = _this$props4.ratio,
150
- handleComponentFunc = _this$props4.handleComponentFunc;
151
- var isResizing = this.state.isResizing;
152
- handleSides.forEach(function (side) {
153
- var _handleStyles$side;
154
- handles[side] = "richMedia-resize-handle-".concat(side);
155
- handleStyles[side] = (_handleStyles$side = {
156
- width: '24px'
157
- }, _defineProperty(_handleStyles$side, side, "".concat(-13 - innerPadding, "px")), _defineProperty(_handleStyles$side, "zIndex", akRichMediaResizeZIndex), _defineProperty(_handleStyles$side, "pointerEvents", 'auto'), _handleStyles$side);
158
- var sideHandleComponent = handleComponentFunc && handleComponentFunc(side);
159
- if (sideHandleComponent) {
160
- handleComponent[side] = sideHandleComponent;
161
- }
162
- });
163
- var className = classnames(richMediaClassName, "image-".concat(layout), this.props.className, {
164
- 'is-resizing': isResizing,
165
- 'not-resized': !pctWidth,
166
- 'richMedia-selected': selected,
167
- 'rich-media-wrapped': layout === 'wrap-left' || layout === 'wrap-right'
168
- });
169
- var handleWrapperStyle;
170
- if (ratio) {
171
- handleWrapperStyle = {
172
- position: 'absolute',
173
- width: '100%',
174
- paddingBottom: "".concat(ratio, "%"),
175
- top: 0,
176
- pointerEvents: 'none'
177
- };
178
- }
179
-
180
- // Ideally, Resizable would let you pass in the component rather than
181
- // the div. For now, we just apply the same styles using CSS
182
- return /*#__PURE__*/React.createElement(Resizable, {
183
- ref: this.resizable,
184
- size: {
185
- width: width,
186
- // just content itself (no paddings)
187
- height: 'auto'
188
- },
189
- className: className,
190
- handleClasses: handles,
191
- handleStyles: handleStyles,
192
- handleWrapperStyle: handleWrapperStyle,
193
- handleComponent: handleComponent,
194
- enable: enable,
195
- onResize: this.handleResize,
196
- onResizeStop: this.handleResizeStop,
197
- onResizeStart: this.handleResizeStart
198
- }, children);
199
- }
200
- }]);
201
- return Resizer;
202
- }(React.Component);
203
- export { Resizer as default };
@@ -1,7 +0,0 @@
1
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
- var _templateObject;
3
- import { css } from '@emotion/react';
4
- import { MediaSingleDimensionHelper } from '@atlaskit/editor-common/ui';
5
- export var wrapperStyle = function wrapperStyle(props) {
6
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n & > div {\n ", ";\n position: relative;\n clear: both;\n\n > div {\n position: absolute;\n height: 100%;\n width: 100%;\n }\n }\n"])), MediaSingleDimensionHelper(props));
7
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,12 +0,0 @@
1
- export var snapTo = function snapTo(target, points) {
2
- return points.length === 0 ?
3
- // extreme last case if there are no points somehow
4
- target : points.reduce(function (point, closest) {
5
- return Math.abs(closest - target) < Math.abs(point - target) ? closest : point;
6
- });
7
- };
8
- export var handleSides = ['left', 'right'];
9
- export var imageAlignmentMap = {
10
- left: 'start',
11
- right: 'end'
12
- };
@@ -1,48 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
- import { traverse } from '@atlaskit/adf-utils/traverse';
5
- import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
6
- /**
7
- * Sanitises a document where some content should not be in the document (e.g. mention names).
8
- *
9
- * It is expected that these names we be resolved separately (e.g. when rendering
10
- * a node view).
11
- */
12
- export function sanitizeNodeForPrivacy(json, providerFactory) {
13
- var mentionNames = new Map();
14
- var hasCacheableMentions = false;
15
- var sanitizedJSON = traverse(json, {
16
- mention: function mention(node) {
17
- if (node.attrs && node.attrs.text) {
18
- hasCacheableMentions = true;
19
- // Remove @ prefix
20
- var text = node.attrs.text;
21
- var name = text.startsWith('@') ? text.slice(1) : text;
22
- mentionNames.set(node.attrs.id, name);
23
- }
24
- return _objectSpread(_objectSpread({}, node), {}, {
25
- attrs: _objectSpread(_objectSpread({}, node.attrs), {}, {
26
- text: ''
27
- })
28
- });
29
- }
30
- });
31
- if (hasCacheableMentions && providerFactory) {
32
- var handler = function handler(_name, providerPromise) {
33
- if (providerPromise) {
34
- providerPromise.then(function (provider) {
35
- if (isResolvingMentionProvider(provider)) {
36
- mentionNames.forEach(function (name, id) {
37
- provider.cacheMentionName(id, name);
38
- });
39
- mentionNames.clear();
40
- providerFactory.unsubscribe('mentionProvider', handler);
41
- }
42
- });
43
- }
44
- };
45
- providerFactory.subscribe('mentionProvider', handler);
46
- }
47
- return sanitizedJSON;
48
- }
@@ -1,74 +0,0 @@
1
- import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
- export var buildEditLinkPayload = function buildEditLinkPayload(type) {
3
- return {
4
- action: ACTION.CLICKED,
5
- actionSubject: type === ACTION_SUBJECT_ID.HYPERLINK ? ACTION_SUBJECT.HYPERLINK : ACTION_SUBJECT.SMART_LINK,
6
- actionSubjectId: ACTION_SUBJECT_ID.EDIT_LINK,
7
- attributes: type !== ACTION_SUBJECT_ID.HYPERLINK ? {
8
- display: type
9
- } : {},
10
- eventType: EVENT_TYPE.UI
11
- };
12
- };
13
- var mapLinkTypeToCardAppearance = function mapLinkTypeToCardAppearance(type) {
14
- switch (type) {
15
- case ACTION_SUBJECT_ID.CARD_INLINE:
16
- {
17
- return 'inline';
18
- }
19
- case ACTION_SUBJECT_ID.CARD_BLOCK:
20
- {
21
- return 'block';
22
- }
23
- case ACTION_SUBJECT_ID.EMBEDS:
24
- {
25
- return 'embed';
26
- }
27
- default:
28
- {
29
- return 'url';
30
- }
31
- }
32
- };
33
- export var buildVisitedLinkPayload = function buildVisitedLinkPayload(type) {
34
- return type === ACTION_SUBJECT_ID.HYPERLINK ? {
35
- action: ACTION.VISITED,
36
- actionSubject: ACTION_SUBJECT.HYPERLINK,
37
- actionSubjectId: undefined,
38
- attributes: {
39
- inputMethod: INPUT_METHOD.TOOLBAR
40
- },
41
- eventType: EVENT_TYPE.TRACK
42
- } : {
43
- action: ACTION.VISITED,
44
- actionSubject: ACTION_SUBJECT.SMART_LINK,
45
- actionSubjectId: type,
46
- attributes: {
47
- inputMethod: INPUT_METHOD.TOOLBAR
48
- },
49
- eventType: EVENT_TYPE.TRACK
50
- };
51
- };
52
- export var buildOpenedSettingsPayload = function buildOpenedSettingsPayload(type) {
53
- return {
54
- action: ACTION.CLICKED,
55
- actionSubject: ACTION_SUBJECT.BUTTON,
56
- actionSubjectId: ACTION_SUBJECT_ID.GOTO_SMART_LINK_SETTINGS,
57
- attributes: {
58
- inputMethod: INPUT_METHOD.TOOLBAR,
59
- display: mapLinkTypeToCardAppearance(type)
60
- },
61
- eventType: EVENT_TYPE.UI
62
- };
63
- };
64
- export var unlinkPayload = function unlinkPayload(type) {
65
- return {
66
- action: ACTION.UNLINK,
67
- actionSubject: type === ACTION_SUBJECT_ID.HYPERLINK ? ACTION_SUBJECT.HYPERLINK : ACTION_SUBJECT.SMART_LINK,
68
- actionSubjectId: type === ACTION_SUBJECT_ID.HYPERLINK ? undefined : type,
69
- attributes: {
70
- inputMethod: INPUT_METHOD.TOOLBAR
71
- },
72
- eventType: EVENT_TYPE.TRACK
73
- };
74
- };
@@ -1,117 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
- import { wrappedLayouts, shouldAddDefaultWrappedWidth, calcPxFromColumns } from '@atlaskit/editor-common/ui';
5
- import { findParentNodeOfTypeClosestToPos } from 'prosemirror-utils';
6
- import { akEditorBreakoutPadding } from '@atlaskit/editor-shared-styles';
7
- export var nonWrappedLayouts = ['center', 'wide', 'full-width'];
8
- export var floatingLayouts = ['wrap-left', 'wrap-right'];
9
- export var isRichMediaInsideOfBlockNode = function isRichMediaInsideOfBlockNode(view, pos) {
10
- if (typeof pos !== 'number' || isNaN(pos) || !view) {
11
- return false;
12
- }
13
- var $pos = view.state.doc.resolve(pos);
14
- var _view$state$schema$no = view.state.schema.nodes,
15
- expand = _view$state$schema$no.expand,
16
- nestedExpand = _view$state$schema$no.nestedExpand,
17
- layoutColumn = _view$state$schema$no.layoutColumn;
18
- return !!findParentNodeOfTypeClosestToPos($pos, [expand, nestedExpand, layoutColumn]);
19
- };
20
- export var alignAttributes = function alignAttributes(layout, oldAttrs) {
21
- var gridSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 12;
22
- var originalWidth = arguments.length > 3 ? arguments[3] : undefined;
23
- var lineLength = arguments.length > 4 ? arguments[4] : undefined;
24
- var width = oldAttrs.width;
25
- var oldLayout = oldAttrs.layout;
26
- var oldLayoutIsNonWrapped = nonWrappedLayouts.indexOf(oldLayout) > -1;
27
- var newLayoutIsNonWrapped = nonWrappedLayouts.indexOf(layout) > -1;
28
- var newLayoutIsWrapped = wrappedLayouts.indexOf(layout) > -1;
29
- var oldLayoutIsWrapped = wrappedLayouts.indexOf(oldLayout) > -1;
30
- if (oldLayoutIsNonWrapped && shouldAddDefaultWrappedWidth(layout, originalWidth, lineLength)) {
31
- // 'full-width' or 'wide' or 'center' -> 'wrap-left' or 'wrap-right' or 'align-end' or 'align-start'
32
- if (!width || width >= 100 || oldLayout !== 'center' // == 'full-width' or 'wide'
33
- ) {
34
- width = 50;
35
- }
36
- } else if (layout !== oldLayout && ['full-width', 'wide'].indexOf(oldLayout) > -1) {
37
- // 'full-width' -> 'center' or 'wide'
38
- // 'wide' -> 'center' or 'full-width'
39
- // unset width
40
- width = undefined;
41
- } else if (width) {
42
- var cols = Math.round(width / 100 * gridSize);
43
- var targetCols = cols;
44
- if (oldLayoutIsWrapped && newLayoutIsNonWrapped) {
45
- // wrap -> center needs to align to even grid
46
- targetCols = Math.floor(targetCols / 2) * 2;
47
- width = undefined;
48
- } else if (oldLayoutIsNonWrapped && newLayoutIsWrapped) {
49
- // Can be here only if
50
- // 'full-width' or 'wide' or 'center' -> 'wrap-left' or 'wrap-right' or 'align-end' or 'align-start'
51
- // AND
52
- // !originalWidth || !lineLength || small image
53
- // AND
54
- // width defined!
55
-
56
- // cannot resize to full column width, and cannot resize to 1 column
57
- if (cols <= 1) {
58
- targetCols = 2;
59
- } else if (cols >= gridSize) {
60
- targetCols = 10;
61
- }
62
- }
63
- if (targetCols !== cols) {
64
- width = targetCols / gridSize * 100;
65
- }
66
- }
67
- return _objectSpread(_objectSpread({}, oldAttrs), {}, {
68
- layout: layout,
69
- width: width
70
- });
71
- };
72
- export function calculateSnapPoints(_ref) {
73
- var $pos = _ref.$pos,
74
- akEditorWideLayoutWidth = _ref.akEditorWideLayoutWidth,
75
- allowBreakoutSnapPoints = _ref.allowBreakoutSnapPoints,
76
- containerWidth = _ref.containerWidth,
77
- gridSize = _ref.gridSize,
78
- gridWidth = _ref.gridWidth,
79
- insideInlineLike = _ref.insideInlineLike,
80
- insideLayout = _ref.insideLayout,
81
- isVideoFile = _ref.isVideoFile,
82
- lineLength = _ref.lineLength,
83
- offsetLeft = _ref.offsetLeft,
84
- wrappedLayout = _ref.wrappedLayout;
85
- var snapTargets = [];
86
- for (var i = 0; i < gridWidth; i++) {
87
- var pxFromColumns = calcPxFromColumns(i, lineLength, gridWidth);
88
- snapTargets.push(insideLayout ? pxFromColumns : pxFromColumns - offsetLeft);
89
- }
90
- // full width
91
- snapTargets.push(lineLength - offsetLeft);
92
- var columns = wrappedLayout || insideInlineLike ? 1 : 2;
93
- var minimumWidth = calcPxFromColumns(columns, lineLength, gridSize);
94
- var snapPoints = snapTargets.filter(function (width) {
95
- return width >= minimumWidth;
96
- });
97
- if (!$pos) {
98
- return snapPoints;
99
- }
100
- snapPoints = isVideoFile ? snapPoints.filter(function (width) {
101
- return width > 320;
102
- }) : snapPoints;
103
- var isTopLevel = $pos.parent.type.name === 'doc';
104
- if (isTopLevel && allowBreakoutSnapPoints) {
105
- snapPoints.push(akEditorWideLayoutWidth);
106
- var fullWidthPoint = containerWidth - akEditorBreakoutPadding;
107
- if (fullWidthPoint > akEditorWideLayoutWidth) {
108
- snapPoints.push(fullWidthPoint);
109
- }
110
- }
111
-
112
- // EDM-1107: Ensure new snapPoints are sorted with existing points
113
- snapPoints = snapPoints.sort(function (a, b) {
114
- return a - b;
115
- });
116
- return snapPoints;
117
- }
@@ -1,24 +0,0 @@
1
- import React from 'react';
2
- import { EditorProps, EditorView } from 'prosemirror-view';
3
- import { Node as PMNode } from 'prosemirror-model';
4
- import type { PMPluginFactoryParams } from '../types';
5
- export type InlineNodeViewComponentProps = {
6
- view: EditorView;
7
- getPos: NodeViewParams['getPos'];
8
- node: PMNode;
9
- };
10
- type InlineNodeViewComponent<ExtraComponentProps> = React.ComponentType<InlineNodeViewComponentProps & ExtraComponentProps>;
11
- export declare const inlineNodeViewClassname = "inlineNodeView";
12
- type NodeViewProducer = NonNullable<EditorProps['nodeViews']>[string];
13
- type NodeViewParams = {
14
- node: Parameters<NodeViewProducer>[0];
15
- view: Parameters<NodeViewProducer>[1];
16
- getPos: Parameters<NodeViewProducer>[2];
17
- decorations: Parameters<NodeViewProducer>[3];
18
- };
19
- export declare function getInlineNodeViewProducer<ExtraComponentProps>({ pmPluginFactoryParams, Component, extraComponentProps, }: {
20
- pmPluginFactoryParams: PMPluginFactoryParams;
21
- Component: InlineNodeViewComponent<ExtraComponentProps>;
22
- extraComponentProps?: ExtraComponentProps;
23
- }): NodeViewProducer;
24
- export {};
@@ -1,35 +0,0 @@
1
- import { CardOptions } from '@atlaskit/editor-common/card';
2
- import { LinkPickerProps } from '@atlaskit/link-picker';
3
- import { INPUT_METHOD } from '../analytics/types';
4
- import { EditorAppearance } from '@atlaskit/editor-common/types';
5
- export type LinkInputType = INPUT_METHOD.MANUAL | INPUT_METHOD.TYPEAHEAD;
6
- /**
7
- * Configuration for the link picker
8
- * Extends `LinkPickerProps` to provide future extensibility out-of-the-box
9
- */
10
- export interface LinkPickerOptions extends Partial<LinkPickerProps> {
11
- }
12
- /**
13
- * Configuration for editor linking behaviours
14
- */
15
- export interface LinkingOptions {
16
- /**
17
- * Initial props to configure the link picker component with. Primarily used to provide link search and suggestions capabilities.
18
- * @see https://atlaskit.atlassian.com/packages/editor/editor-core/example/full-page-with-link-picker
19
- * @see https://atlaskit.atlassian.com/packages/linking-platform/link-picker
20
- */
21
- linkPicker?: LinkPickerOptions;
22
- /**
23
- * Enables and configure smart link behaviour
24
- */
25
- smartLinks?: CardOptions;
26
- }
27
- /**
28
- * Configuration for the Hyperlink plugin
29
- */
30
- export interface HyperlinkPluginOptions {
31
- cardOptions?: CardOptions;
32
- linkPicker?: LinkPickerOptions;
33
- platform?: 'mobile' | 'web';
34
- editorAppearance?: EditorAppearance;
35
- }