@atlaskit/editor-plugin-media 1.27.1 → 1.27.2

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 (52) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/nodeviews/lazy-media-group.js +36 -0
  3. package/dist/cjs/nodeviews/lazy-media-inline.js +34 -0
  4. package/dist/cjs/nodeviews/lazy-media-single.js +35 -0
  5. package/dist/cjs/nodeviews/lazy-media.js +36 -0
  6. package/dist/cjs/plugin.js +17 -15
  7. package/dist/cjs/toDOM-fixes/media.js +25 -0
  8. package/dist/cjs/toDOM-fixes/mediaGroup.js +94 -0
  9. package/dist/cjs/toDOM-fixes/mediaInline.js +48 -0
  10. package/dist/cjs/toDOM-fixes/mediaSingle.js +160 -0
  11. package/dist/cjs/toDOM-fixes/toDOMAttrs.js +80 -0
  12. package/dist/es2019/nodeviews/lazy-media-group.js +23 -0
  13. package/dist/es2019/nodeviews/lazy-media-inline.js +23 -0
  14. package/dist/es2019/nodeviews/lazy-media-single.js +23 -0
  15. package/dist/es2019/nodeviews/lazy-media.js +23 -0
  16. package/dist/es2019/plugin.js +20 -19
  17. package/dist/es2019/toDOM-fixes/media.js +17 -0
  18. package/dist/es2019/toDOM-fixes/mediaGroup.js +85 -0
  19. package/dist/es2019/toDOM-fixes/mediaInline.js +41 -0
  20. package/dist/es2019/toDOM-fixes/mediaSingle.js +152 -0
  21. package/dist/es2019/toDOM-fixes/toDOMAttrs.js +69 -0
  22. package/dist/esm/nodeviews/lazy-media-group.js +24 -0
  23. package/dist/esm/nodeviews/lazy-media-inline.js +22 -0
  24. package/dist/esm/nodeviews/lazy-media-single.js +23 -0
  25. package/dist/esm/nodeviews/lazy-media.js +24 -0
  26. package/dist/esm/plugin.js +20 -19
  27. package/dist/esm/toDOM-fixes/media.js +19 -0
  28. package/dist/esm/toDOM-fixes/mediaGroup.js +87 -0
  29. package/dist/esm/toDOM-fixes/mediaInline.js +41 -0
  30. package/dist/esm/toDOM-fixes/mediaSingle.js +152 -0
  31. package/dist/esm/toDOM-fixes/toDOMAttrs.js +74 -0
  32. package/dist/types/media-plugin-options.d.ts +3 -4
  33. package/dist/types/nodeviews/lazy-media-group.d.ts +7 -0
  34. package/dist/types/nodeviews/lazy-media-inline.d.ts +7 -0
  35. package/dist/types/nodeviews/lazy-media-single.d.ts +9 -0
  36. package/dist/types/nodeviews/lazy-media.d.ts +8 -0
  37. package/dist/types/toDOM-fixes/media.d.ts +1 -0
  38. package/dist/types/toDOM-fixes/mediaGroup.d.ts +36 -0
  39. package/dist/types/toDOM-fixes/mediaInline.d.ts +1 -0
  40. package/dist/types/toDOM-fixes/mediaSingle.d.ts +29 -0
  41. package/dist/types/toDOM-fixes/toDOMAttrs.d.ts +35 -0
  42. package/dist/types-ts4.5/media-plugin-options.d.ts +3 -4
  43. package/dist/types-ts4.5/nodeviews/lazy-media-group.d.ts +7 -0
  44. package/dist/types-ts4.5/nodeviews/lazy-media-inline.d.ts +7 -0
  45. package/dist/types-ts4.5/nodeviews/lazy-media-single.d.ts +9 -0
  46. package/dist/types-ts4.5/nodeviews/lazy-media.d.ts +8 -0
  47. package/dist/types-ts4.5/toDOM-fixes/media.d.ts +1 -0
  48. package/dist/types-ts4.5/toDOM-fixes/mediaGroup.d.ts +36 -0
  49. package/dist/types-ts4.5/toDOM-fixes/mediaInline.d.ts +1 -0
  50. package/dist/types-ts4.5/toDOM-fixes/mediaSingle.d.ts +29 -0
  51. package/dist/types-ts4.5/toDOM-fixes/toDOMAttrs.d.ts +35 -0
  52. package/package.json +5 -2
@@ -0,0 +1,22 @@
1
+ import { withLazyLoading } from '@atlaskit/editor-common/lazy-node-view';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
3
+ import { ReactMediaInlineNode } from './mediaInline';
4
+ export var lazyMediaInlineView = function lazyMediaInlineView(portalProviderAPI, eventDispatcher, providerFactory, api, dispatchAnalyticsEvent) {
5
+ if (!fg('platform_editor_lazy-node-views')) {
6
+ return ReactMediaInlineNode(portalProviderAPI, eventDispatcher, providerFactory, api, dispatchAnalyticsEvent);
7
+ }
8
+ return withLazyLoading({
9
+ nodeName: 'mediaInline',
10
+ getNodeViewOptions: function getNodeViewOptions() {},
11
+ loader: function loader() {
12
+ var result = import( /* webpackChunkName: "@atlaskit-internal_editor-plugin-media-inline-lazy-node-view" */
13
+ './mediaInline').then(function (_ref) {
14
+ var ReactMediaInlineNode = _ref.ReactMediaInlineNode;
15
+ return function (node, view, getPos) {
16
+ return ReactMediaInlineNode(portalProviderAPI, eventDispatcher, providerFactory, api, dispatchAnalyticsEvent)(node, view, getPos);
17
+ };
18
+ });
19
+ return result;
20
+ }
21
+ });
22
+ };
@@ -0,0 +1,23 @@
1
+ import { withLazyLoading } from '@atlaskit/editor-common/lazy-node-view';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
3
+ import { ReactMediaSingleNode } from './mediaSingle';
4
+ export var lazyMediaSingleView = function lazyMediaSingleView(portalProviderAPI, eventDispatcher, providerFactory, api, dispatchAnalyticsEvent) {
5
+ var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
6
+ if (!fg('platform_editor_lazy-node-views')) {
7
+ return ReactMediaSingleNode(portalProviderAPI, eventDispatcher, providerFactory, api, dispatchAnalyticsEvent, options);
8
+ }
9
+ return withLazyLoading({
10
+ nodeName: 'mediaSingle',
11
+ getNodeViewOptions: function getNodeViewOptions() {},
12
+ loader: function loader() {
13
+ var result = import( /* webpackChunkName: "@atlaskit-internal_editor-plugin-media-single-lazy-node-view" */
14
+ './mediaSingle').then(function (_ref) {
15
+ var ReactMediaSingleNode = _ref.ReactMediaSingleNode;
16
+ return function (node, view, getPos) {
17
+ return ReactMediaSingleNode(portalProviderAPI, eventDispatcher, providerFactory, api, dispatchAnalyticsEvent, options)(node, view, getPos);
18
+ };
19
+ });
20
+ return result;
21
+ }
22
+ });
23
+ };
@@ -0,0 +1,24 @@
1
+ import { withLazyLoading } from '@atlaskit/editor-common/lazy-node-view';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
3
+ import { ReactMediaNode } from './mediaNodeView';
4
+ export var lazyMediaView = function lazyMediaView(portalProviderAPI, eventDispatcher, providerFactory) {
5
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
6
+ var api = arguments.length > 4 ? arguments[4] : undefined;
7
+ if (!fg('platform_editor_lazy-node-views')) {
8
+ return ReactMediaNode(portalProviderAPI, eventDispatcher, providerFactory, options, api);
9
+ }
10
+ return withLazyLoading({
11
+ nodeName: 'media',
12
+ getNodeViewOptions: function getNodeViewOptions() {},
13
+ loader: function loader() {
14
+ var result = import( /* webpackChunkName: "@atlaskit-internal_editor-plugin-media-lazy-node-view" */
15
+ './mediaNodeView').then(function (_ref) {
16
+ var ReactMediaNode = _ref.ReactMediaNode;
17
+ return function (node, view, getPos) {
18
+ return ReactMediaNode(portalProviderAPI, eventDispatcher, providerFactory, options, api)(node, view, getPos);
19
+ };
20
+ });
21
+ return result;
22
+ }
23
+ });
24
+ };
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import { media, mediaGroup, mediaInline, mediaSingleSpec } from '@atlaskit/adf-schema';
3
2
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
3
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
4
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
@@ -7,19 +6,22 @@ import { IconImages } from '@atlaskit/editor-common/quick-insert';
7
6
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
8
7
  import { NodeSelection, PluginKey } from '@atlaskit/editor-prosemirror/state';
9
8
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
10
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
11
- import { ReactMediaGroupNode } from './nodeviews/mediaGroup';
12
- import { ReactMediaInlineNode } from './nodeviews/mediaInline';
13
- import { ReactMediaNode } from './nodeviews/mediaNodeView';
14
- import { ReactMediaSingleNode } from './nodeviews/mediaSingle';
9
+ import { fg } from '@atlaskit/platform-feature-flags';
10
+ import { lazyMediaView } from './nodeviews/lazy-media';
11
+ import { lazyMediaGroupView } from './nodeviews/lazy-media-group';
12
+ import { lazyMediaInlineView } from './nodeviews/lazy-media-inline';
13
+ import { lazyMediaSingleView } from './nodeviews/lazy-media-single';
15
14
  import { createPlugin as createMediaAltTextPlugin } from './pm-plugins/alt-text';
16
15
  import keymapMediaAltTextPlugin from './pm-plugins/alt-text/keymap';
17
16
  import keymapPlugin from './pm-plugins/keymap';
18
17
  import keymapMediaSinglePlugin from './pm-plugins/keymap-media-single';
19
18
  import linkingPlugin from './pm-plugins/linking';
20
19
  import keymapLinkingPlugin from './pm-plugins/linking/keymap';
21
- import { stateKey } from './pm-plugins/main';
22
- import { createPlugin, stateKey as pluginKey } from './pm-plugins/main';
20
+ import { createPlugin, stateKey } from './pm-plugins/main';
21
+ import { mediaSpecWithFixedToDOM } from './toDOM-fixes/media';
22
+ import { mediaGroupSpecWithFixedToDOM } from './toDOM-fixes/mediaGroup';
23
+ import { mediaInlineSpecWithFixedToDOM } from './toDOM-fixes/mediaInline';
24
+ import { mediaSingleSpecWithFixedToDOM } from './toDOM-fixes/mediaSingle';
23
25
  import { floatingToolbar as _floatingToolbar } from './toolbar';
24
26
  import { MediaPickerComponents } from './ui/MediaPicker';
25
27
  import ToolbarMedia from './ui/ToolbarMedia';
@@ -77,26 +79,25 @@ export var mediaPlugin = function mediaPlugin(_ref2) {
77
79
  allowCaptions = _ref4.allowCaptions,
78
80
  mediaFeatureFlags = _ref4.featureFlags;
79
81
  var allowMediaInline = getMediaFeatureFlag('mediaInline', mediaFeatureFlags);
80
- var mediaSingleOption = getBooleanFF('platform.editor.media.extended-resize-experience') ? {
82
+ var mediaSingleOption = fg('platform.editor.media.extended-resize-experience') ? {
81
83
  withCaption: allowCaptions,
82
84
  withExtendedWidthTypes: true
83
85
  } : {
84
86
  withCaption: allowCaptions,
85
87
  withExtendedWidthTypes: false
86
88
  };
87
- var mediaSingleNode = mediaSingleSpec(mediaSingleOption);
88
89
  return [{
89
90
  name: 'mediaGroup',
90
- node: mediaGroup
91
+ node: mediaGroupSpecWithFixedToDOM()
91
92
  }, {
92
93
  name: 'mediaSingle',
93
- node: mediaSingleNode
94
+ node: mediaSingleSpecWithFixedToDOM(mediaSingleOption)
94
95
  }, {
95
96
  name: 'media',
96
- node: media
97
+ node: mediaSpecWithFixedToDOM()
97
98
  }, {
98
99
  name: 'mediaInline',
99
- node: mediaInline
100
+ node: mediaInlineSpecWithFixedToDOM()
100
101
  }].filter(function (node) {
101
102
  if (node.name === 'mediaGroup') {
102
103
  return allowMediaGroup;
@@ -126,10 +127,10 @@ export var mediaPlugin = function mediaPlugin(_ref2) {
126
127
  return createPlugin(schema, {
127
128
  providerFactory: providerFactory,
128
129
  nodeViews: {
129
- mediaGroup: ReactMediaGroupNode(portalProviderAPI, eventDispatcher, providerFactory, options, api),
130
- mediaSingle: ReactMediaSingleNode(portalProviderAPI, eventDispatcher, providerFactory, api, dispatchAnalyticsEvent, options),
131
- media: ReactMediaNode(portalProviderAPI, eventDispatcher, providerFactory, options, api),
132
- mediaInline: ReactMediaInlineNode(portalProviderAPI, eventDispatcher, providerFactory, api)
130
+ mediaGroup: lazyMediaGroupView(portalProviderAPI, eventDispatcher, providerFactory, options, api),
131
+ mediaSingle: lazyMediaSingleView(portalProviderAPI, eventDispatcher, providerFactory, api, dispatchAnalyticsEvent, options),
132
+ media: lazyMediaView(portalProviderAPI, eventDispatcher, providerFactory, options, api),
133
+ mediaInline: lazyMediaInlineView(portalProviderAPI, eventDispatcher, providerFactory, api)
133
134
  },
134
135
  errorReporter: errorReporter,
135
136
  uploadErrorHandler: options && options.uploadErrorHandler,
@@ -250,7 +251,7 @@ export var mediaPlugin = function mediaPlugin(_ref2) {
250
251
  },
251
252
  action: function action(insert, state) {
252
253
  var _api$analytics4;
253
- var pluginState = pluginKey.getState(state);
254
+ var pluginState = stateKey.getState(state);
254
255
  pluginState === null || pluginState === void 0 || pluginState.showMediaPicker();
255
256
  var tr = insert('');
256
257
  api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 || _api$analytics4.actions.attachAnalyticsEvent({
@@ -0,0 +1,19 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import { media } from '@atlaskit/adf-schema';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
6
+ import { getMediaAttrs } from './toDOMAttrs';
7
+
8
+ // @nodeSpecException:toDOM patch
9
+ export var mediaSpecWithFixedToDOM = function mediaSpecWithFixedToDOM() {
10
+ if (!fg('platform_editor_lazy-node-views')) {
11
+ return media;
12
+ }
13
+ return _objectSpread(_objectSpread({}, media), {}, {
14
+ toDOM: function toDOM(node) {
15
+ var attrs = getMediaAttrs('media', node);
16
+ return ['div', attrs];
17
+ }
18
+ });
19
+ };
@@ -0,0 +1,87 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import { mediaGroup } from '@atlaskit/adf-schema';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
6
+ var skeletonStyling = "background: ".concat("var(--ds-background-neutral, #091E420F)", ";");
7
+
8
+ /**
9
+ * Duplicate consts from `media-card`.
10
+ * `packages/media/media-card/src/utils/cardDimensions.ts`
11
+ *
12
+ * WHY?
13
+ * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
14
+ * `media-card` from here or it will cause dependency issues.
15
+ *
16
+ * In the long term likely `toDOM` will move back out of `adf-schema` in which
17
+ * case we can consolidate them.
18
+ */
19
+ export var defaultImageCardDimensions = {
20
+ width: 156,
21
+ height: 125
22
+ };
23
+ export var defaultHorizontalCardDimensions = {
24
+ width: 435,
25
+ height: 125
26
+ };
27
+ export var defaultSquareCardDimensions = {
28
+ width: 300,
29
+ height: 300
30
+ };
31
+
32
+ /**
33
+ * Duplicate logic from `@atlaskit/media-card` for computing the dimensions of a media group card.
34
+ * From: `packages/media/media-card/src/utils/cardDimensions.ts`
35
+ *
36
+ * WHY?
37
+ * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
38
+ * `@atlaskit/media-card` from here or it will cause dependency issues.
39
+ *
40
+ * In the long term likely `toDOM` will move back out of `adf-schema` in which
41
+ * case we can consolidate them.
42
+ */
43
+ export var getDefaultCardDimensions = function getDefaultCardDimensions() {
44
+ var appearance = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'auto';
45
+ if (appearance === 'image') {
46
+ return defaultImageCardDimensions;
47
+ }
48
+ if (appearance === 'square') {
49
+ return defaultSquareCardDimensions;
50
+ }
51
+ if (appearance === 'horizontal') {
52
+ return defaultHorizontalCardDimensions;
53
+ }
54
+ return defaultImageCardDimensions;
55
+ };
56
+
57
+ // @nodeSpecException:toDOM patch
58
+ export var mediaGroupSpecWithFixedToDOM = function mediaGroupSpecWithFixedToDOM() {
59
+ if (!fg('platform_editor_lazy-node-views')) {
60
+ return mediaGroup;
61
+ }
62
+ return _objectSpread(_objectSpread({}, mediaGroup), {}, {
63
+ toDOM: function toDOM(node) {
64
+ var childNodes = [];
65
+ for (var i = 0; i < node.childCount; i++) {
66
+ var _getDefaultCardDimens = getDefaultCardDimensions(),
67
+ width = _getDefaultCardDimens.width,
68
+ height = _getDefaultCardDimens.height;
69
+ var nodeHolder = ['img', {
70
+ width: width,
71
+ height: height,
72
+ // Transparent image workaround to control styling
73
+ src: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
74
+ style: "margin-left: ".concat(i !== 0 ? "4px" : '0', "; margin-right: 4px; border-radius: ", "var(--ds-border-radius, 3px)", "; ").concat(skeletonStyling)
75
+ }];
76
+ childNodes.push(nodeHolder);
77
+ }
78
+
79
+ // Margin margin that consolidates the margin in the
80
+ return ['div', {
81
+ style: 'margin: "3px 5px";',
82
+ // From adf-schema
83
+ 'data-node-type': 'mediaGroup'
84
+ }].concat(childNodes);
85
+ }
86
+ });
87
+ };
@@ -0,0 +1,41 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import { mediaInline } from '@atlaskit/adf-schema';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
6
+ import { getMediaAttrs } from './toDOMAttrs';
7
+ var skeletonStyling = "background: ".concat("var(--ds-background-neutral, #091E420F)", ";");
8
+ // Matches media
9
+ var fallbackAspectRatio = 1.25;
10
+
11
+ // @nodeSpecException:toDOM patch
12
+ export var mediaInlineSpecWithFixedToDOM = function mediaInlineSpecWithFixedToDOM() {
13
+ if (!fg('platform_editor_lazy-node-views')) {
14
+ return mediaInline;
15
+ }
16
+ return _objectSpread(_objectSpread({}, mediaInline), {}, {
17
+ toDOM: function toDOM(node) {
18
+ var dataAttrs = getMediaAttrs('mediaInline', node);
19
+ if (node.attrs.type === 'image') {
20
+ var aspectRatio = node.attrs.width && node.attrs.height ? node.attrs.width / node.attrs.height : fallbackAspectRatio;
21
+ return ['span', _objectSpread(_objectSpread({}, dataAttrs), {}, {
22
+ style: 'display: inline-block; transform: translateY(6px)',
23
+ class: 'media-inline-image-wrapper'
24
+ }), ['span', {
25
+ height: '100%',
26
+ width: '100%',
27
+ // Transparent image workaround to control styling
28
+ src: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
29
+ style: "display: inline-block; aspect-ratio: ".concat(aspectRatio, "; height: 100%; width: 100%; border-radius: ", "var(--ds-border-radius, 3px)", "; ").concat(skeletonStyling)
30
+ }]];
31
+ } else {
32
+ return ['span', _objectSpread(_objectSpread({}, dataAttrs), {}, {
33
+ style: "display: inline-block; transform: translateY(6px); ".concat(skeletonStyling),
34
+ class: 'media-inline-image-wrapper'
35
+ }), ['span', {
36
+ style: "display: inline-block; height: 100%; width: 100%; aspect-ratio: ".concat(fallbackAspectRatio, ";")
37
+ }]];
38
+ }
39
+ }
40
+ });
41
+ };
@@ -0,0 +1,152 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import { mediaSingleSpec } from '@atlaskit/adf-schema';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
6
+ import { getAttrsFromNodeMediaSingle, getMediaAttrs } from './toDOMAttrs';
7
+ var skeletonStyling = "background: ".concat("var(--ds-background-neutral, #091E420F)", "; outline: none;");
8
+ export var wrappedLayouts = ['wrap-left', 'wrap-right', 'align-end', 'align-start'];
9
+
10
+ /**
11
+ * Duplicate of method from `@atlaskit/editor-common/utils`.
12
+ * `packages/editor/editor-common/src/utils/rich-media-utils.ts`
13
+ *
14
+ * WHY?
15
+ * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
16
+ * `@atlaskit/editor-common` from here or it will cause dependency issues.
17
+ *
18
+ * In the long term likely `toDOM` will move back out of `adf-schema` in which
19
+ * case we can consolidate them.
20
+ */
21
+ export var shouldAddDefaultWrappedWidth = function shouldAddDefaultWrappedWidth(layout, width, lineLength) {
22
+ return wrappedLayouts.indexOf(layout) > -1 && lineLength && width && width > 0.5 * lineLength;
23
+ };
24
+ var MEDIA_SINGLE_GUTTER_SIZE = 24;
25
+ var DEFAULT_EMBED_CARD_WIDTH = 680;
26
+ var akEditorMediaResizeHandlerPaddingWide = 12;
27
+
28
+ /**
29
+ * Duplicate of method from `@atlaskit/editor-common/media-single`.
30
+ * `packages/editor/editor-common/src/media-single/utils.ts`
31
+ *
32
+ * WHY?
33
+ * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
34
+ * `@atlaskit/editor-common` from here or it will cause dependency issues.
35
+ *
36
+ * In the long term likely `toDOM` will move back out of `adf-schema` in which
37
+ * case we can consolidate them.
38
+ */
39
+ export function getMediaSinglePixelWidth(width, editorWidth) {
40
+ var widthType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'percentage';
41
+ var gutterOffset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
42
+ if (widthType === 'pixel') {
43
+ return width;
44
+ }
45
+ return Math.ceil((editorWidth + gutterOffset) * (width / 100) - gutterOffset);
46
+ }
47
+
48
+ /**
49
+ * Duplicate logic from `@atlaskit/editor-common/ui` for MediaSingle.
50
+ * `packages/editor/editor-common/src/ui/MediaSingle/index.tsx`
51
+ *
52
+ * WHY?
53
+ * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
54
+ * `@atlaskit/editor-common` from here or it will cause dependency issues.
55
+ *
56
+ * In the long term likely `toDOM` will move back out of `adf-schema` in which
57
+ * case we can consolidate them.
58
+ */
59
+ function computeMediaSingleDimensions(_ref) {
60
+ var childNode = _ref.childNode,
61
+ mediaSingleWidth = _ref.mediaSingleWidth,
62
+ widthType = _ref.widthType;
63
+ // TODO: We can't retrieve the editor width from here easily.
64
+ // For now we're using the default line length here, but this will be
65
+ // incorrect on smaller devices.
66
+ var editorWidth = 760;
67
+ var width = childNode === null || childNode === void 0 ? void 0 : childNode.attrs.width;
68
+ var height = childNode === null || childNode === void 0 ? void 0 : childNode.attrs.height;
69
+ if (!mediaSingleWidth && shouldAddDefaultWrappedWidth(childNode === null || childNode === void 0 ? void 0 : childNode.attrs.layout, width, editorWidth)) {
70
+ mediaSingleWidth = widthType === 'pixel' ? editorWidth / 2 : 50;
71
+ }
72
+ var isHeightOnly = width === undefined;
73
+ if (mediaSingleWidth) {
74
+ var pxWidth = getMediaSinglePixelWidth(mediaSingleWidth, editorWidth, widthType, MEDIA_SINGLE_GUTTER_SIZE);
75
+ if (isHeightOnly) {
76
+ return {
77
+ width: pxWidth - akEditorMediaResizeHandlerPaddingWide,
78
+ height: height
79
+ };
80
+ } else {
81
+ return {
82
+ width: pxWidth,
83
+ height: height / width * pxWidth
84
+ };
85
+ }
86
+ } else if (isHeightOnly) {
87
+ return {
88
+ width: DEFAULT_EMBED_CARD_WIDTH - akEditorMediaResizeHandlerPaddingWide,
89
+ height: height
90
+ };
91
+ }
92
+ return {
93
+ height: height,
94
+ width: width
95
+ };
96
+ }
97
+ function computeLayoutStyles(width, layout) {
98
+ switch (layout) {
99
+ case 'align-end':
100
+ return "margin-left: auto; margin-right: 0; width: ".concat(width, "px;");
101
+ case 'align-start':
102
+ return "margin-left: 0; margin-right: auto; width: ".concat(width, "px;");
103
+ case 'center':
104
+ return 'margin-left: auto; margin-right: auto;';
105
+ case 'full-width':
106
+ case 'wide':
107
+ return 'width: 100%; margin-top: 56px; margin-bottom: 56px;';
108
+ case 'wrap-left':
109
+ return 'float: left;';
110
+ case 'wrap-right':
111
+ return 'float: right;';
112
+ }
113
+ }
114
+
115
+ // @nodeSpecException:toDOM patch
116
+ export var mediaSingleSpecWithFixedToDOM = function mediaSingleSpecWithFixedToDOM(mediaSingleOption) {
117
+ var mediaSingleNode = mediaSingleSpec(mediaSingleOption);
118
+ if (!fg('platform_editor_lazy-node-views')) {
119
+ return mediaSingleNode;
120
+ }
121
+ return _objectSpread(_objectSpread({}, mediaSingleNode), {}, {
122
+ toDOM: function toDOM(node) {
123
+ var _mediaSingleAttrs$lay, _childNode$type;
124
+ var childNode = node.firstChild;
125
+ var mediaSingleAttrs = node.attrs;
126
+ var layout = (_mediaSingleAttrs$lay = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.layout) !== null && _mediaSingleAttrs$lay !== void 0 ? _mediaSingleAttrs$lay : 'center';
127
+ var mediaSingleWidth = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.width;
128
+ var widthType = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.widthType;
129
+ var dataAttrs = getAttrsFromNodeMediaSingle(mediaSingleOption.withExtendedWidthTypes, node);
130
+ var mediaAttrs = (childNode === null || childNode === void 0 || (_childNode$type = childNode.type) === null || _childNode$type === void 0 ? void 0 : _childNode$type.name) === 'media' ? getMediaAttrs('media', childNode) : undefined;
131
+ var _computeMediaSingleDi = computeMediaSingleDimensions({
132
+ childNode: childNode,
133
+ widthType: widthType,
134
+ mediaSingleWidth: mediaSingleWidth
135
+ }),
136
+ width = _computeMediaSingleDi.width,
137
+ height = _computeMediaSingleDi.height;
138
+ var layoutStyles = computeLayoutStyles(width, layout);
139
+ var style = "display: block; margin-top: ".concat("var(--ds-space-300, 24px)", "; margin-bottom: ", "var(--ds-space-300, 24px)", "; ", layoutStyles);
140
+ if ((childNode === null || childNode === void 0 ? void 0 : childNode.attrs.type) === 'external') {
141
+ return ['div', dataAttrs, ['img', _objectSpread(_objectSpread({}, mediaAttrs), {}, {
142
+ src: childNode.attrs.url,
143
+ style: style
144
+ })]];
145
+ }
146
+ return ['div', dataAttrs, ['div', _objectSpread(_objectSpread({}, mediaAttrs), {}, {
147
+ // Transparent image workaround to control styling
148
+ style: "width: ".concat(width, "px; height: ").concat(height, "px; ").concat(style, " ").concat(skeletonStyling, " border-radius: ", "var(--ds-border-radius, 3px)", ";")
149
+ })]];
150
+ }
151
+ });
152
+ };
@@ -0,0 +1,74 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import { N30 } from '@atlaskit/theme/colors';
5
+
6
+ /**
7
+ * Copied from `packages/adf-schema/src/schema/nodes/media.ts`
8
+ *
9
+ * When we patch adf-schema with media `toDOM` fixes we can remove this.
10
+ */
11
+ export var getMediaAttrs = function getMediaAttrs(nodeName, node) {
12
+ var copyPrivateAttributes = function copyPrivateAttributes(from, to, map) {
13
+ if (node.attrs) {
14
+ Object.keys(node.attrs).forEach(function (key) {
15
+ if (key[0] === '_' && key[1] === '_' && from[key]) {
16
+ to[map ? map(key) : key] = from[key];
17
+ }
18
+ });
19
+ }
20
+ };
21
+ var attrs = {
22
+ 'data-id': node.attrs.id,
23
+ 'data-node-type': "".concat(nodeName),
24
+ 'data-type': node.attrs.type,
25
+ 'data-collection': node.attrs.collection,
26
+ 'data-occurrence-key': node.attrs.occurrenceKey,
27
+ 'data-width': node.attrs.width,
28
+ 'data-height': node.attrs.height,
29
+ 'data-url': node.attrs.url,
30
+ 'data-alt': node.attrs.alt,
31
+ // toDOM is used for static rendering as well as editor rendering. This comes into play for
32
+ // emails, copy/paste, etc, so the title and styling here *is* useful (despite a React-based
33
+ // node view being used for editing).
34
+ title: 'Attachment',
35
+ // Manually kept in sync with the style of media cards. The goal is to render a plain gray
36
+ // rectangle that provides an affordance for media.
37
+ style: "display: inline-block; border-radius: 3px; background: ".concat(N30, "; box-shadow: 0 1px 1px rgba(9, 30, 66, 0.2), 0 0 1px 0 rgba(9, 30, 66, 0.24);")
38
+ };
39
+ copyPrivateAttributes(node.attrs, attrs, function (key) {
40
+ return "data-".concat(camelCaseToKebabCase(key.slice(2)));
41
+ });
42
+ return attrs;
43
+ };
44
+ export var camelCaseToKebabCase = function camelCaseToKebabCase(str) {
45
+ return str.replace(/([^A-Z]+)([A-Z])/g, function (_, x, y) {
46
+ return "".concat(x, "-").concat(y.toLowerCase());
47
+ });
48
+ };
49
+
50
+ /**
51
+ * Copied from `packages/adf-schema/src/schema/nodes/media-single.ts`
52
+ *
53
+ * When we patch adf-schema with media `toDOM` fixes we can remove this.
54
+ */
55
+ export var getAttrsFromNodeMediaSingle = function getAttrsFromNodeMediaSingle(withExtendedWidthTypes, node) {
56
+ var _node$attrs = node.attrs,
57
+ layout = _node$attrs.layout,
58
+ width = _node$attrs.width;
59
+ var attrs = {
60
+ 'data-node-type': 'mediaSingle',
61
+ 'data-layout': layout,
62
+ 'data-width': ''
63
+ };
64
+ if (width) {
65
+ attrs['data-width'] = isFinite(width) && Math.floor(width) === width ? width : width.toFixed(2);
66
+ }
67
+ if (withExtendedWidthTypes && node.attrs.widthType) {
68
+ var widthType = node.attrs.widthType;
69
+ return _objectSpread(_objectSpread({}, attrs), {}, {
70
+ 'data-width-type': widthType || 'percentage'
71
+ });
72
+ }
73
+ return attrs;
74
+ };
@@ -1,12 +1,11 @@
1
+ import type { NodeViewConstructor } from '@atlaskit/editor-common/lazy-node-view';
1
2
  import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
2
3
  import type { ErrorReporter } from '@atlaskit/editor-common/utils';
3
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
- import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
5
- import type { CustomMediaPicker, getPosHandler, MediaState } from './types';
4
+ import type { CustomMediaPicker, MediaState } from './types';
6
5
  export type MediaPluginOptions = {
7
6
  providerFactory: ProviderFactory;
8
7
  nodeViews: {
9
- [name: string]: (node: PMNode, view: EditorView, getPos: getPosHandler) => NodeView;
8
+ [name: string]: NodeViewConstructor;
10
9
  };
11
10
  errorReporter?: ErrorReporter;
12
11
  uploadErrorHandler?: (state: MediaState) => void;
@@ -0,0 +1,7 @@
1
+ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
2
+ import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
3
+ import { type PortalProviderAPI } from '@atlaskit/editor-common/src/portal';
4
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
5
+ import type { MediaNextEditorPluginType } from '../next-plugin-type';
6
+ import type { MediaOptions } from '../types';
7
+ export declare const lazyMediaGroupView: (portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, options: MediaOptions | undefined, api: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined) => import("@atlaskit/editor-common/lazy-node-view").NodeViewConstructor;
@@ -0,0 +1,7 @@
1
+ import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
2
+ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
3
+ import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
4
+ import { type PortalProviderAPI } from '@atlaskit/editor-common/src/portal';
5
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
6
+ import type { MediaNextEditorPluginType } from '../next-plugin-type';
7
+ export declare const lazyMediaInlineView: (portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, api: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined, dispatchAnalyticsEvent?: DispatchAnalyticsEvent) => import("@atlaskit/editor-common/lazy-node-view").NodeViewConstructor;
@@ -0,0 +1,9 @@
1
+ import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
2
+ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
3
+ import { type NodeViewConstructor } from '@atlaskit/editor-common/lazy-node-view';
4
+ import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
5
+ import { type PortalProviderAPI } from '@atlaskit/editor-common/src/portal';
6
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
7
+ import type { MediaNextEditorPluginType } from '../next-plugin-type';
8
+ import type { MediaOptions } from '../types';
9
+ export declare const lazyMediaSingleView: (portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, api: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined, dispatchAnalyticsEvent?: DispatchAnalyticsEvent, options?: MediaOptions) => NodeViewConstructor;
@@ -0,0 +1,8 @@
1
+ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
2
+ import { type NodeViewConstructor } from '@atlaskit/editor-common/lazy-node-view';
3
+ import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
4
+ import { type PortalProviderAPI } from '@atlaskit/editor-common/src/portal';
5
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
6
+ import type { MediaNextEditorPluginType } from '../next-plugin-type';
7
+ import type { MediaOptions } from '../types';
8
+ export declare const lazyMediaView: (portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, options: MediaOptions | undefined, api: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined) => NodeViewConstructor;
@@ -0,0 +1 @@
1
+ export declare const mediaSpecWithFixedToDOM: () => import("prosemirror-model").NodeSpec;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Duplicate consts from `media-card`.
3
+ * `packages/media/media-card/src/utils/cardDimensions.ts`
4
+ *
5
+ * WHY?
6
+ * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
7
+ * `media-card` from here or it will cause dependency issues.
8
+ *
9
+ * In the long term likely `toDOM` will move back out of `adf-schema` in which
10
+ * case we can consolidate them.
11
+ */
12
+ export declare const defaultImageCardDimensions: {
13
+ width: number;
14
+ height: number;
15
+ };
16
+ export declare const defaultHorizontalCardDimensions: {
17
+ width: number;
18
+ height: number;
19
+ };
20
+ export declare const defaultSquareCardDimensions: {
21
+ width: number;
22
+ height: number;
23
+ };
24
+ /**
25
+ * Duplicate logic from `@atlaskit/media-card` for computing the dimensions of a media group card.
26
+ * From: `packages/media/media-card/src/utils/cardDimensions.ts`
27
+ *
28
+ * WHY?
29
+ * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
30
+ * `@atlaskit/media-card` from here or it will cause dependency issues.
31
+ *
32
+ * In the long term likely `toDOM` will move back out of `adf-schema` in which
33
+ * case we can consolidate them.
34
+ */
35
+ export declare const getDefaultCardDimensions: (appearance?: 'image' | 'square' | 'horizontal' | 'auto') => Required<typeof defaultImageCardDimensions>;
36
+ export declare const mediaGroupSpecWithFixedToDOM: () => import("prosemirror-model").NodeSpec;
@@ -0,0 +1 @@
1
+ export declare const mediaInlineSpecWithFixedToDOM: () => import("prosemirror-model").NodeSpec;