@atlaskit/editor-plugin-media 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/editor-plugin-media
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#64354](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/64354) [`b07fcd05c2c9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b07fcd05c2c9) - [ux] Added border support for media inline node
8
+
9
+ ### Patch Changes
10
+
11
+ - [#65031](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/65031) [`a00094111b5a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a00094111b5a) - ED-21609 Update adf-schema to 35.3.0
12
+ - Updated dependencies
13
+
14
+ ## 0.9.1
15
+
16
+ ### Patch Changes
17
+
18
+ - [#63950](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/63950) [`aa44815a0e60`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/aa44815a0e60) - [ux] changed color for instructions to add alt text
19
+ - Updated dependencies
20
+
3
21
  ## 0.9.0
4
22
 
5
23
  ### Minor Changes
@@ -33,7 +33,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
33
33
  var CONTAINER_WIDTH_IN_PX = exports.CONTAINER_WIDTH_IN_PX = _ui.RECENT_SEARCH_WIDTH_IN_PX;
34
34
  var MAX_ALT_TEXT_LENGTH = exports.MAX_ALT_TEXT_LENGTH = 510; // double tweet length
35
35
 
36
- var supportText = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n font-size: ", ";\n padding: ", " ", ";\n line-height: 20px;\n border-top: 1px solid ", ";\n margin: 0;\n"])), "var(--ds-text-subtlest, ".concat(_colors.N100, ")"), (0, _editorSharedStyles.relativeFontSizeToBase16)(12), "var(--ds-space-150, 12px)", "var(--ds-space-500, 40px)", "var(--ds-border, ".concat(_colors.N30, ")"));
36
+ var supportText = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n font-size: ", ";\n padding: ", " ", ";\n line-height: 20px;\n border-top: 1px solid ", ";\n margin: 0;\n"])), "var(--ds-text-subtlest, ".concat(_colors.N200, ")"), (0, _editorSharedStyles.relativeFontSizeToBase16)(12), "var(--ds-space-150, 12px)", "var(--ds-space-500, 40px)", "var(--ds-border, ".concat(_colors.N30, ")"));
37
37
  var container = (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n width: ", "px;\n display: flex;\n flex-direction: column;\n overflow: auto;\n line-height: 2;\n"])), CONTAINER_WIDTH_IN_PX);
38
38
  var inputWrapper = (0, _react2.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n line-height: 0;\n padding: 5px 0;\n align-items: center;\n"])));
39
39
  var validationWrapper = (0, _react2.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n line-height: 0;\n padding: ", " ", "\n ", " 0;\n margin: 0 ", " 0 ", ";\n border-top: 1px solid ", ";\n align-items: start;\n flex-direction: column;\n"])), "var(--ds-space-150, 12px)", "var(--ds-space-300, 24px)", "var(--ds-space-150, 12px)", "var(--ds-space-150, 12px)", "var(--ds-space-500, 40px)", "var(--ds-border-danger, ".concat(_colors.R400, ")"));
@@ -118,7 +118,7 @@ var removeInlineCard = exports.removeInlineCard = function removeInlineCard(stat
118
118
  };
119
119
  var toggleBorderMark = exports.toggleBorderMark = function toggleBorderMark(editorAnalyticsAPI) {
120
120
  return function (state, dispatch) {
121
- var nodeWithPos = (0, _currentMediaNode.currentMediaNodeWithPos)(state);
121
+ var nodeWithPos = (0, _currentMediaNode.currentMediaNodeWithPos)(state) || (0, _currentMediaNode.currentMediaInlineNodeWithPos)(state);
122
122
  if (!nodeWithPos) {
123
123
  return false;
124
124
  }
@@ -173,7 +173,7 @@ var setBorderMark = exports.setBorderMark = function setBorderMark(editorAnalyti
173
173
  return function (attrs) {
174
174
  return function (state, dispatch) {
175
175
  var _node$marks$find, _ref, _attrs$color, _ref2, _attrs$size;
176
- var nodeWithPos = (0, _currentMediaNode.currentMediaNodeWithPos)(state);
176
+ var nodeWithPos = (0, _currentMediaNode.currentMediaNodeWithPos)(state) || (0, _currentMediaNode.currentMediaInlineNodeWithPos)(state);
177
177
  if (!nodeWithPos) {
178
178
  return false;
179
179
  }
@@ -265,9 +265,7 @@ var changeMediaSingleToMediaInline = exports.changeMediaSingleToMediaInline = fu
265
265
  }
266
266
  var mediaInlineNode = mediaInline.create(_objectSpread(_objectSpread({}, mediaNode.attrs), {}, {
267
267
  type: 'image'
268
- // TODO: [ED-20261] copy marks across once both border and link marks are supported for inline image
269
- }));
270
-
268
+ }), null, mediaNode.marks);
271
269
  var space = state.schema.text(' ');
272
270
  var content = _model.Fragment.from([mediaInlineNode, space]);
273
271
  var node = paragraph.createChecked({}, content);
@@ -10,7 +10,7 @@ function shouldShowImageBorder(editorState) {
10
10
  if (!border) {
11
11
  return false;
12
12
  }
13
- var nodeWithPos = (0, _currentMediaNode.currentMediaNodeWithPos)(editorState);
13
+ var nodeWithPos = (0, _currentMediaNode.currentMediaNodeWithPos)(editorState) || (0, _currentMediaNode.currentMediaInlineNodeWithPos)(editorState);
14
14
  if (!nodeWithPos) {
15
15
  return false;
16
16
  }
@@ -159,7 +159,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
159
159
  }
160
160
  var dispatch = editorView.dispatch,
161
161
  state = editorView.state;
162
- var borderMark = (0, _currentMediaNode.currentMediaNodeBorderMark)(state);
162
+ var borderMark = (0, _currentMediaNode.currentMediaOrInlineNodeBorderMark)(state);
163
163
  return /*#__PURE__*/_react.default.createElement(_ImageBorder.default, {
164
164
  toggleBorder: function toggleBorder() {
165
165
  var _pluginInjectionApi$a;
@@ -16,10 +16,13 @@ var _remove = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/remove
16
16
  var _mediaUi = require("@atlaskit/media-ui");
17
17
  var _linking = require("../commands/linking");
18
18
  var _linking2 = require("../pm-plugins/linking");
19
+ var _ImageBorder = _interopRequireDefault(require("../ui/ImageBorder"));
20
+ var _currentMediaNode = require("../utils/current-media-node");
19
21
  var _isType = require("../utils/is-type");
20
22
  var _altText = require("./alt-text");
21
23
  var _commands = require("./commands");
22
24
  var _filePreviewItem = require("./filePreviewItem");
25
+ var _imageBorder = require("./imageBorder");
23
26
  var _linkingToolbarAppearance = require("./linking-toolbar-appearance");
24
27
  var _utils = require("./utils");
25
28
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -111,13 +114,38 @@ var getMediaInlineImageToolbar = exports.getMediaInlineImageToolbar = function g
111
114
  var mediaInline = state.schema.nodes.mediaInline;
112
115
  var mediaInlineImageTitle = intl.formatMessage(_messages.mediaAndEmbedToolbarMessages.changeToMediaInlineImage);
113
116
  var mediaSingleTitle = intl.formatMessage(_messages.mediaAndEmbedToolbarMessages.changeToMediaSingle);
114
-
115
- // TODO: border marks, media single switcher, alt text, etc
116
117
  var widthPluginState = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$w = pluginInjectionApi.width) === null || _pluginInjectionApi$w === void 0 ? void 0 : _pluginInjectionApi$w.sharedState.currentState();
117
- // if type is image, return inline image floating toolbar items
118
- var inlineImageItems = [
119
- // TODO: border marks, media single switcher, link, etc
120
- {
118
+ var inlineImageItems = [];
119
+ if ((0, _imageBorder.shouldShowImageBorder)(state)) {
120
+ inlineImageItems.push({
121
+ type: 'custom',
122
+ fallback: [],
123
+ render: function render(editorView) {
124
+ if (!editorView) {
125
+ return null;
126
+ }
127
+ var dispatch = editorView.dispatch,
128
+ state = editorView.state;
129
+ var borderMark = (0, _currentMediaNode.currentMediaOrInlineNodeBorderMark)(state);
130
+ return /*#__PURE__*/_react.default.createElement(_ImageBorder.default, {
131
+ toggleBorder: function toggleBorder() {
132
+ var _pluginInjectionApi$a2;
133
+ (0, _commands.toggleBorderMark)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions)(state, dispatch);
134
+ },
135
+ setBorder: function setBorder(attrs) {
136
+ var _pluginInjectionApi$a3;
137
+ (0, _commands.setBorderMark)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions)(attrs)(state, dispatch);
138
+ },
139
+ borderMark: borderMark,
140
+ intl: intl
141
+ });
142
+ }
143
+ });
144
+ inlineImageItems.push({
145
+ type: 'separator'
146
+ });
147
+ }
148
+ inlineImageItems.push({
121
149
  id: 'editor.media.convert.mediainline',
122
150
  type: 'button',
123
151
  title: mediaInlineImageTitle,
@@ -144,10 +172,10 @@ var getMediaInlineImageToolbar = exports.getMediaInlineImageToolbar = function g
144
172
  onClick: (0, _commands.changeMediaInlineToMediaSingle)(editorAnalyticsAPI, widthPluginState)
145
173
  }, {
146
174
  type: 'separator'
147
- }];
175
+ });
148
176
  if (options.allowAltTextOnImages) {
149
- var _pluginInjectionApi$a2;
150
- inlineImageItems.push((0, _altText.altTextButton)(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions), {
177
+ var _pluginInjectionApi$a4;
178
+ inlineImageItems.push((0, _altText.altTextButton)(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions), {
151
179
  type: 'separator'
152
180
  });
153
181
  }
@@ -165,10 +193,10 @@ var getMediaInlineImageToolbar = exports.getMediaInlineImageToolbar = function g
165
193
  };
166
194
  var openLink = function openLink() {
167
195
  if (editorView) {
168
- var _pluginInjectionApi$a3;
196
+ var _pluginInjectionApi$a5;
169
197
  var tr = editorView.state.tr,
170
198
  dispatch = editorView.dispatch;
171
- pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 || _pluginInjectionApi$a3.actions.attachAnalyticsEvent({
199
+ pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a5 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a5 === void 0 || _pluginInjectionApi$a5.actions.attachAnalyticsEvent({
172
200
  eventType: _analytics.EVENT_TYPE.TRACK,
173
201
  action: _analytics.ACTION.VISITED,
174
202
  actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.currentMediaNodeWithPos = exports.currentMediaNodeBorderMark = exports.currentMediaNode = exports.currentMediaInlineNodeWithPos = exports.currentMediaInlineNode = void 0;
6
+ exports.currentMediaOrInlineNodeBorderMark = exports.currentMediaNodeWithPos = exports.currentMediaNode = exports.currentMediaInlineNodeWithPos = exports.currentMediaInlineNode = void 0;
7
7
  var _state = require("@atlaskit/editor-prosemirror/state");
8
8
  var currentMediaNodeWithPos = exports.currentMediaNodeWithPos = function currentMediaNodeWithPos(editorState) {
9
9
  var doc = editorState.doc,
@@ -47,8 +47,8 @@ var currentMediaInlineNode = exports.currentMediaInlineNode = function currentMe
47
47
  var _currentMediaInlineNo;
48
48
  return (_currentMediaInlineNo = currentMediaInlineNodeWithPos(editorState)) === null || _currentMediaInlineNo === void 0 ? void 0 : _currentMediaInlineNo.node;
49
49
  };
50
- var currentMediaNodeBorderMark = exports.currentMediaNodeBorderMark = function currentMediaNodeBorderMark(editorState) {
51
- var node = currentMediaNode(editorState);
50
+ var currentMediaOrInlineNodeBorderMark = exports.currentMediaOrInlineNodeBorderMark = function currentMediaOrInlineNodeBorderMark(editorState) {
51
+ var node = currentMediaNode(editorState) || currentMediaInlineNode(editorState);
52
52
  if (!node) {
53
53
  return;
54
54
  }
@@ -11,14 +11,14 @@ import { FloatingToolbarButton as Button, ErrorMessage, PanelTextInput, RECENT_S
11
11
  import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
12
12
  import ChevronLeftLargeIcon from '@atlaskit/icon/glyph/chevron-left-large';
13
13
  import CrossCircleIcon from '@atlaskit/icon/glyph/cross-circle';
14
- import { N100, N30, N80, R400 } from '@atlaskit/theme/colors';
14
+ import { N200, N30, N80, R400 } from '@atlaskit/theme/colors';
15
15
  import { closeMediaAltTextMenu, closeMediaAltTextMenuAndSave } from '../commands';
16
16
  import { messages } from '../messages';
17
17
  export const CONTAINER_WIDTH_IN_PX = RECENT_SEARCH_WIDTH_IN_PX;
18
18
  export const MAX_ALT_TEXT_LENGTH = 510; // double tweet length
19
19
 
20
20
  const supportText = css`
21
- color: ${`var(--ds-text-subtlest, ${N100})`};
21
+ color: ${`var(--ds-text-subtlest, ${N200})`};
22
22
  font-size: ${relativeFontSizeToBase16(12)};
23
23
  padding: ${"var(--ds-space-150, 12px)"} ${"var(--ds-space-500, 40px)"};
24
24
  line-height: 20px;
@@ -3,7 +3,7 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
3
3
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { isNodeSelection, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { getMediaInputResizeAnalyticsEvent } from '../utils/analytics';
6
- import { currentMediaNodeWithPos } from '../utils/current-media-node';
6
+ import { currentMediaInlineNodeWithPos, currentMediaNodeWithPos } from '../utils/current-media-node';
7
7
  import { changeFromMediaInlineToMediaSingleNode } from '../utils/media-single';
8
8
  import { getSelectedMediaSingle, removeMediaGroupNode } from './utils';
9
9
  export const DEFAULT_BORDER_COLOR = '#091e4224';
@@ -106,7 +106,7 @@ export const removeInlineCard = (state, dispatch) => {
106
106
  return false;
107
107
  };
108
108
  export const toggleBorderMark = editorAnalyticsAPI => (state, dispatch) => {
109
- const nodeWithPos = currentMediaNodeWithPos(state);
109
+ const nodeWithPos = currentMediaNodeWithPos(state) || currentMediaInlineNodeWithPos(state);
110
110
  if (!nodeWithPos) {
111
111
  return false;
112
112
  }
@@ -156,7 +156,7 @@ export const toggleBorderMark = editorAnalyticsAPI => (state, dispatch) => {
156
156
  };
157
157
  export const setBorderMark = editorAnalyticsAPI => attrs => (state, dispatch) => {
158
158
  var _node$marks$find, _ref, _attrs$color, _ref2, _attrs$size;
159
- const nodeWithPos = currentMediaNodeWithPos(state);
159
+ const nodeWithPos = currentMediaNodeWithPos(state) || currentMediaInlineNodeWithPos(state);
160
160
  if (!nodeWithPos) {
161
161
  return false;
162
162
  }
@@ -242,9 +242,7 @@ export const changeMediaSingleToMediaInline = editorAnalyticsAPI => (state, disp
242
242
  const mediaInlineNode = mediaInline.create({
243
243
  ...mediaNode.attrs,
244
244
  type: 'image'
245
- // TODO: [ED-20261] copy marks across once both border and link marks are supported for inline image
246
- });
247
-
245
+ }, null, mediaNode.marks);
248
246
  const space = state.schema.text(' ');
249
247
  const content = Fragment.from([mediaInlineNode, space]);
250
248
  const node = paragraph.createChecked({}, content);
@@ -1,10 +1,10 @@
1
- import { currentMediaNodeWithPos } from '../utils/current-media-node';
1
+ import { currentMediaInlineNodeWithPos, currentMediaNodeWithPos } from '../utils/current-media-node';
2
2
  export function shouldShowImageBorder(editorState) {
3
3
  const border = editorState.schema.marks.border;
4
4
  if (!border) {
5
5
  return false;
6
6
  }
7
- const nodeWithPos = currentMediaNodeWithPos(editorState);
7
+ const nodeWithPos = currentMediaNodeWithPos(editorState) || currentMediaInlineNodeWithPos(editorState);
8
8
  if (!nodeWithPos) {
9
9
  return false;
10
10
  }
@@ -19,7 +19,7 @@ import { getMediaLinkingState } from '../pm-plugins/linking';
19
19
  import { stateKey } from '../pm-plugins/plugin-key';
20
20
  import ImageBorderItem from '../ui/ImageBorder';
21
21
  import { FullWidthDisplay, PixelEntry } from '../ui/PixelEntry';
22
- import { currentMediaNodeBorderMark } from '../utils/current-media-node';
22
+ import { currentMediaOrInlineNodeBorderMark } from '../utils/current-media-node';
23
23
  import { isVideo } from '../utils/media-single';
24
24
  import { altTextButton, getAltTextToolbar } from './alt-text';
25
25
  import { changeMediaCardToInline, changeMediaSingleToMediaInline, setBorderMark, toggleBorderMark, updateMediaSingleWidth } from './commands';
@@ -154,7 +154,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
154
154
  dispatch,
155
155
  state
156
156
  } = editorView;
157
- const borderMark = currentMediaNodeBorderMark(state);
157
+ const borderMark = currentMediaOrInlineNodeBorderMark(state);
158
158
  return /*#__PURE__*/React.createElement(ImageBorderItem, {
159
159
  toggleBorder: () => {
160
160
  var _pluginInjectionApi$a;
@@ -8,10 +8,13 @@ import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
8
8
  import { messages } from '@atlaskit/media-ui';
9
9
  import { showLinkingToolbar } from '../commands/linking';
10
10
  import { getMediaLinkingState } from '../pm-plugins/linking';
11
+ import ImageBorderItem from '../ui/ImageBorder';
12
+ import { currentMediaOrInlineNodeBorderMark } from '../utils/current-media-node';
11
13
  import { isImage } from '../utils/is-type';
12
14
  import { altTextButton } from './alt-text';
13
- import { changeInlineToMediaCard, changeMediaInlineToMediaSingle, removeInlineCard } from './commands';
15
+ import { changeInlineToMediaCard, changeMediaInlineToMediaSingle, removeInlineCard, setBorderMark, toggleBorderMark } from './commands';
14
16
  import { FilePreviewItem } from './filePreviewItem';
17
+ import { shouldShowImageBorder } from './imageBorder';
15
18
  import { LinkToolbarAppearance } from './linking-toolbar-appearance';
16
19
  import { downloadMedia } from './utils';
17
20
  export const generateMediaInlineFloatingToolbar = (state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi, options = {}) => {
@@ -103,13 +106,40 @@ export const getMediaInlineImageToolbar = (state, intl, mediaPluginState, hoverD
103
106
  } = state.schema.nodes;
104
107
  const mediaInlineImageTitle = intl.formatMessage(mediaAndEmbedToolbarMessages.changeToMediaInlineImage);
105
108
  const mediaSingleTitle = intl.formatMessage(mediaAndEmbedToolbarMessages.changeToMediaSingle);
106
-
107
- // TODO: border marks, media single switcher, alt text, etc
108
109
  const widthPluginState = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$w = pluginInjectionApi.width) === null || _pluginInjectionApi$w === void 0 ? void 0 : _pluginInjectionApi$w.sharedState.currentState();
109
- // if type is image, return inline image floating toolbar items
110
- const inlineImageItems = [
111
- // TODO: border marks, media single switcher, link, etc
112
- {
110
+ const inlineImageItems = [];
111
+ if (shouldShowImageBorder(state)) {
112
+ inlineImageItems.push({
113
+ type: 'custom',
114
+ fallback: [],
115
+ render: editorView => {
116
+ if (!editorView) {
117
+ return null;
118
+ }
119
+ const {
120
+ dispatch,
121
+ state
122
+ } = editorView;
123
+ const borderMark = currentMediaOrInlineNodeBorderMark(state);
124
+ return /*#__PURE__*/React.createElement(ImageBorderItem, {
125
+ toggleBorder: () => {
126
+ var _pluginInjectionApi$a2;
127
+ toggleBorderMark(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions)(state, dispatch);
128
+ },
129
+ setBorder: attrs => {
130
+ var _pluginInjectionApi$a3;
131
+ setBorderMark(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions)(attrs)(state, dispatch);
132
+ },
133
+ borderMark: borderMark,
134
+ intl: intl
135
+ });
136
+ }
137
+ });
138
+ inlineImageItems.push({
139
+ type: 'separator'
140
+ });
141
+ }
142
+ inlineImageItems.push({
113
143
  id: 'editor.media.convert.mediainline',
114
144
  type: 'button',
115
145
  title: mediaInlineImageTitle,
@@ -132,10 +162,10 @@ export const getMediaInlineImageToolbar = (state, intl, mediaPluginState, hoverD
132
162
  onClick: changeMediaInlineToMediaSingle(editorAnalyticsAPI, widthPluginState)
133
163
  }, {
134
164
  type: 'separator'
135
- }];
165
+ });
136
166
  if (options.allowAltTextOnImages) {
137
- var _pluginInjectionApi$a2;
138
- inlineImageItems.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions), {
167
+ var _pluginInjectionApi$a4;
168
+ inlineImageItems.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions), {
139
169
  type: 'separator'
140
170
  });
141
171
  }
@@ -155,14 +185,14 @@ export const getMediaInlineImageToolbar = (state, intl, mediaPluginState, hoverD
155
185
  };
156
186
  const openLink = () => {
157
187
  if (editorView) {
158
- var _pluginInjectionApi$a3;
188
+ var _pluginInjectionApi$a5;
159
189
  const {
160
190
  state: {
161
191
  tr
162
192
  },
163
193
  dispatch
164
194
  } = editorView;
165
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions.attachAnalyticsEvent({
195
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a5 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a5 === void 0 ? void 0 : _pluginInjectionApi$a5.actions.attachAnalyticsEvent({
166
196
  eventType: EVENT_TYPE.TRACK,
167
197
  action: ACTION.VISITED,
168
198
  actionSubject: ACTION_SUBJECT.MEDIA,
@@ -45,8 +45,8 @@ export const currentMediaInlineNode = editorState => {
45
45
  var _currentMediaInlineNo;
46
46
  return (_currentMediaInlineNo = currentMediaInlineNodeWithPos(editorState)) === null || _currentMediaInlineNo === void 0 ? void 0 : _currentMediaInlineNo.node;
47
47
  };
48
- export const currentMediaNodeBorderMark = editorState => {
49
- const node = currentMediaNode(editorState);
48
+ export const currentMediaOrInlineNodeBorderMark = editorState => {
49
+ const node = currentMediaNode(editorState) || currentMediaInlineNode(editorState);
50
50
  if (!node) {
51
51
  return;
52
52
  }
@@ -21,13 +21,13 @@ import { FloatingToolbarButton as Button, ErrorMessage, PanelTextInput, RECENT_S
21
21
  import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
22
22
  import ChevronLeftLargeIcon from '@atlaskit/icon/glyph/chevron-left-large';
23
23
  import CrossCircleIcon from '@atlaskit/icon/glyph/cross-circle';
24
- import { N100, N30, N80, R400 } from '@atlaskit/theme/colors';
24
+ import { N200, N30, N80, R400 } from '@atlaskit/theme/colors';
25
25
  import { closeMediaAltTextMenu, closeMediaAltTextMenuAndSave } from '../commands';
26
26
  import { messages } from '../messages';
27
27
  export var CONTAINER_WIDTH_IN_PX = RECENT_SEARCH_WIDTH_IN_PX;
28
28
  export var MAX_ALT_TEXT_LENGTH = 510; // double tweet length
29
29
 
30
- var supportText = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n font-size: ", ";\n padding: ", " ", ";\n line-height: 20px;\n border-top: 1px solid ", ";\n margin: 0;\n"])), "var(--ds-text-subtlest, ".concat(N100, ")"), relativeFontSizeToBase16(12), "var(--ds-space-150, 12px)", "var(--ds-space-500, 40px)", "var(--ds-border, ".concat(N30, ")"));
30
+ var supportText = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n font-size: ", ";\n padding: ", " ", ";\n line-height: 20px;\n border-top: 1px solid ", ";\n margin: 0;\n"])), "var(--ds-text-subtlest, ".concat(N200, ")"), relativeFontSizeToBase16(12), "var(--ds-space-150, 12px)", "var(--ds-space-500, 40px)", "var(--ds-border, ".concat(N30, ")"));
31
31
  var container = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: ", "px;\n display: flex;\n flex-direction: column;\n overflow: auto;\n line-height: 2;\n"])), CONTAINER_WIDTH_IN_PX);
32
32
  var inputWrapper = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n line-height: 0;\n padding: 5px 0;\n align-items: center;\n"])));
33
33
  var validationWrapper = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: flex;\n line-height: 0;\n padding: ", " ", "\n ", " 0;\n margin: 0 ", " 0 ", ";\n border-top: 1px solid ", ";\n align-items: start;\n flex-direction: column;\n"])), "var(--ds-space-150, 12px)", "var(--ds-space-300, 24px)", "var(--ds-space-150, 12px)", "var(--ds-space-150, 12px)", "var(--ds-space-500, 40px)", "var(--ds-border-danger, ".concat(R400, ")"));
@@ -6,7 +6,7 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
6
6
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
7
7
  import { isNodeSelection, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
8
8
  import { getMediaInputResizeAnalyticsEvent } from '../utils/analytics';
9
- import { currentMediaNodeWithPos } from '../utils/current-media-node';
9
+ import { currentMediaInlineNodeWithPos, currentMediaNodeWithPos } from '../utils/current-media-node';
10
10
  import { changeFromMediaInlineToMediaSingleNode } from '../utils/media-single';
11
11
  import { getSelectedMediaSingle, removeMediaGroupNode } from './utils';
12
12
  export var DEFAULT_BORDER_COLOR = '#091e4224';
@@ -111,7 +111,7 @@ export var removeInlineCard = function removeInlineCard(state, dispatch) {
111
111
  };
112
112
  export var toggleBorderMark = function toggleBorderMark(editorAnalyticsAPI) {
113
113
  return function (state, dispatch) {
114
- var nodeWithPos = currentMediaNodeWithPos(state);
114
+ var nodeWithPos = currentMediaNodeWithPos(state) || currentMediaInlineNodeWithPos(state);
115
115
  if (!nodeWithPos) {
116
116
  return false;
117
117
  }
@@ -166,7 +166,7 @@ export var setBorderMark = function setBorderMark(editorAnalyticsAPI) {
166
166
  return function (attrs) {
167
167
  return function (state, dispatch) {
168
168
  var _node$marks$find, _ref, _attrs$color, _ref2, _attrs$size;
169
- var nodeWithPos = currentMediaNodeWithPos(state);
169
+ var nodeWithPos = currentMediaNodeWithPos(state) || currentMediaInlineNodeWithPos(state);
170
170
  if (!nodeWithPos) {
171
171
  return false;
172
172
  }
@@ -258,9 +258,7 @@ export var changeMediaSingleToMediaInline = function changeMediaSingleToMediaInl
258
258
  }
259
259
  var mediaInlineNode = mediaInline.create(_objectSpread(_objectSpread({}, mediaNode.attrs), {}, {
260
260
  type: 'image'
261
- // TODO: [ED-20261] copy marks across once both border and link marks are supported for inline image
262
- }));
263
-
261
+ }), null, mediaNode.marks);
264
262
  var space = state.schema.text(' ');
265
263
  var content = Fragment.from([mediaInlineNode, space]);
266
264
  var node = paragraph.createChecked({}, content);
@@ -1,10 +1,10 @@
1
- import { currentMediaNodeWithPos } from '../utils/current-media-node';
1
+ import { currentMediaInlineNodeWithPos, currentMediaNodeWithPos } from '../utils/current-media-node';
2
2
  export function shouldShowImageBorder(editorState) {
3
3
  var border = editorState.schema.marks.border;
4
4
  if (!border) {
5
5
  return false;
6
6
  }
7
- var nodeWithPos = currentMediaNodeWithPos(editorState);
7
+ var nodeWithPos = currentMediaNodeWithPos(editorState) || currentMediaInlineNodeWithPos(editorState);
8
8
  if (!nodeWithPos) {
9
9
  return false;
10
10
  }
@@ -23,7 +23,7 @@ import { getMediaLinkingState } from '../pm-plugins/linking';
23
23
  import { stateKey } from '../pm-plugins/plugin-key';
24
24
  import ImageBorderItem from '../ui/ImageBorder';
25
25
  import { FullWidthDisplay, PixelEntry } from '../ui/PixelEntry';
26
- import { currentMediaNodeBorderMark } from '../utils/current-media-node';
26
+ import { currentMediaOrInlineNodeBorderMark } from '../utils/current-media-node';
27
27
  import { isVideo } from '../utils/media-single';
28
28
  import { altTextButton, getAltTextToolbar } from './alt-text';
29
29
  import { changeMediaCardToInline, changeMediaSingleToMediaInline, setBorderMark, toggleBorderMark, updateMediaSingleWidth } from './commands';
@@ -149,7 +149,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
149
149
  }
150
150
  var dispatch = editorView.dispatch,
151
151
  state = editorView.state;
152
- var borderMark = currentMediaNodeBorderMark(state);
152
+ var borderMark = currentMediaOrInlineNodeBorderMark(state);
153
153
  return /*#__PURE__*/React.createElement(ImageBorderItem, {
154
154
  toggleBorder: function toggleBorder() {
155
155
  var _pluginInjectionApi$a;
@@ -8,10 +8,13 @@ import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
8
8
  import { messages } from '@atlaskit/media-ui';
9
9
  import { showLinkingToolbar } from '../commands/linking';
10
10
  import { getMediaLinkingState } from '../pm-plugins/linking';
11
+ import ImageBorderItem from '../ui/ImageBorder';
12
+ import { currentMediaOrInlineNodeBorderMark } from '../utils/current-media-node';
11
13
  import { isImage } from '../utils/is-type';
12
14
  import { altTextButton } from './alt-text';
13
- import { changeInlineToMediaCard, changeMediaInlineToMediaSingle, removeInlineCard } from './commands';
15
+ import { changeInlineToMediaCard, changeMediaInlineToMediaSingle, removeInlineCard, setBorderMark, toggleBorderMark } from './commands';
14
16
  import { FilePreviewItem } from './filePreviewItem';
17
+ import { shouldShowImageBorder } from './imageBorder';
15
18
  import { LinkToolbarAppearance } from './linking-toolbar-appearance';
16
19
  import { downloadMedia } from './utils';
17
20
  export var generateMediaInlineFloatingToolbar = function generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi) {
@@ -101,13 +104,38 @@ export var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(stat
101
104
  var mediaInline = state.schema.nodes.mediaInline;
102
105
  var mediaInlineImageTitle = intl.formatMessage(mediaAndEmbedToolbarMessages.changeToMediaInlineImage);
103
106
  var mediaSingleTitle = intl.formatMessage(mediaAndEmbedToolbarMessages.changeToMediaSingle);
104
-
105
- // TODO: border marks, media single switcher, alt text, etc
106
107
  var widthPluginState = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$w = pluginInjectionApi.width) === null || _pluginInjectionApi$w === void 0 ? void 0 : _pluginInjectionApi$w.sharedState.currentState();
107
- // if type is image, return inline image floating toolbar items
108
- var inlineImageItems = [
109
- // TODO: border marks, media single switcher, link, etc
110
- {
108
+ var inlineImageItems = [];
109
+ if (shouldShowImageBorder(state)) {
110
+ inlineImageItems.push({
111
+ type: 'custom',
112
+ fallback: [],
113
+ render: function render(editorView) {
114
+ if (!editorView) {
115
+ return null;
116
+ }
117
+ var dispatch = editorView.dispatch,
118
+ state = editorView.state;
119
+ var borderMark = currentMediaOrInlineNodeBorderMark(state);
120
+ return /*#__PURE__*/React.createElement(ImageBorderItem, {
121
+ toggleBorder: function toggleBorder() {
122
+ var _pluginInjectionApi$a2;
123
+ toggleBorderMark(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions)(state, dispatch);
124
+ },
125
+ setBorder: function setBorder(attrs) {
126
+ var _pluginInjectionApi$a3;
127
+ setBorderMark(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions)(attrs)(state, dispatch);
128
+ },
129
+ borderMark: borderMark,
130
+ intl: intl
131
+ });
132
+ }
133
+ });
134
+ inlineImageItems.push({
135
+ type: 'separator'
136
+ });
137
+ }
138
+ inlineImageItems.push({
111
139
  id: 'editor.media.convert.mediainline',
112
140
  type: 'button',
113
141
  title: mediaInlineImageTitle,
@@ -134,10 +162,10 @@ export var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(stat
134
162
  onClick: changeMediaInlineToMediaSingle(editorAnalyticsAPI, widthPluginState)
135
163
  }, {
136
164
  type: 'separator'
137
- }];
165
+ });
138
166
  if (options.allowAltTextOnImages) {
139
- var _pluginInjectionApi$a2;
140
- inlineImageItems.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions), {
167
+ var _pluginInjectionApi$a4;
168
+ inlineImageItems.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions), {
141
169
  type: 'separator'
142
170
  });
143
171
  }
@@ -155,10 +183,10 @@ export var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(stat
155
183
  };
156
184
  var openLink = function openLink() {
157
185
  if (editorView) {
158
- var _pluginInjectionApi$a3;
186
+ var _pluginInjectionApi$a5;
159
187
  var tr = editorView.state.tr,
160
188
  dispatch = editorView.dispatch;
161
- pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 || _pluginInjectionApi$a3.actions.attachAnalyticsEvent({
189
+ pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a5 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a5 === void 0 || _pluginInjectionApi$a5.actions.attachAnalyticsEvent({
162
190
  eventType: EVENT_TYPE.TRACK,
163
191
  action: ACTION.VISITED,
164
192
  actionSubject: ACTION_SUBJECT.MEDIA,
@@ -41,8 +41,8 @@ export var currentMediaInlineNode = function currentMediaInlineNode(editorState)
41
41
  var _currentMediaInlineNo;
42
42
  return (_currentMediaInlineNo = currentMediaInlineNodeWithPos(editorState)) === null || _currentMediaInlineNo === void 0 ? void 0 : _currentMediaInlineNo.node;
43
43
  };
44
- export var currentMediaNodeBorderMark = function currentMediaNodeBorderMark(editorState) {
45
- var node = currentMediaNode(editorState);
44
+ export var currentMediaOrInlineNodeBorderMark = function currentMediaOrInlineNodeBorderMark(editorState) {
45
+ var node = currentMediaNode(editorState) || currentMediaInlineNode(editorState);
46
46
  if (!node) {
47
47
  return;
48
48
  }
@@ -11,4 +11,4 @@ export declare const currentMediaInlineNodeWithPos: (editorState: EditorState) =
11
11
  } | undefined;
12
12
  export declare const currentMediaNode: (editorState: EditorState) => PMNode | undefined;
13
13
  export declare const currentMediaInlineNode: (editorState: EditorState) => PMNode | undefined;
14
- export declare const currentMediaNodeBorderMark: (editorState: EditorState) => BorderMarkAttributes | undefined;
14
+ export declare const currentMediaOrInlineNodeBorderMark: (editorState: EditorState) => BorderMarkAttributes | undefined;
@@ -11,4 +11,4 @@ export declare const currentMediaInlineNodeWithPos: (editorState: EditorState) =
11
11
  } | undefined;
12
12
  export declare const currentMediaNode: (editorState: EditorState) => PMNode | undefined;
13
13
  export declare const currentMediaInlineNode: (editorState: EditorState) => PMNode | undefined;
14
- export declare const currentMediaNodeBorderMark: (editorState: EditorState) => BorderMarkAttributes | undefined;
14
+ export declare const currentMediaOrInlineNodeBorderMark: (editorState: EditorState) => BorderMarkAttributes | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Media plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,11 +33,11 @@
33
33
  "./types": "./src/types.ts"
34
34
  },
35
35
  "dependencies": {
36
- "@atlaskit/adf-schema": "^35.2.0",
36
+ "@atlaskit/adf-schema": "^35.3.0",
37
37
  "@atlaskit/analytics-namespaced-context": "^6.7.0",
38
38
  "@atlaskit/analytics-next": "^9.1.0",
39
- "@atlaskit/button": "^17.1.0",
40
- "@atlaskit/editor-common": "^76.30.0",
39
+ "@atlaskit/button": "^17.2.0",
40
+ "@atlaskit/editor-common": "^76.35.0",
41
41
  "@atlaskit/editor-palette": "1.5.2",
42
42
  "@atlaskit/editor-plugin-analytics": "^0.4.0",
43
43
  "@atlaskit/editor-plugin-decorations": "^0.2.0",
@@ -50,7 +50,7 @@
50
50
  "@atlaskit/editor-plugin-selection": "^0.1.0",
51
51
  "@atlaskit/editor-plugin-width": "^0.2.0",
52
52
  "@atlaskit/editor-prosemirror": "1.1.0",
53
- "@atlaskit/editor-shared-styles": "^2.6.0",
53
+ "@atlaskit/editor-shared-styles": "^2.9.0",
54
54
  "@atlaskit/editor-tables": "^2.3.0",
55
55
  "@atlaskit/form": "^9.0.3",
56
56
  "@atlaskit/icon": "^22.0.0",
@@ -65,7 +65,7 @@
65
65
  "@atlaskit/platform-feature-flags": "^0.2.0",
66
66
  "@atlaskit/textfield": "^6.0.0",
67
67
  "@atlaskit/theme": "^12.6.0",
68
- "@atlaskit/tokens": "^1.32.0",
68
+ "@atlaskit/tokens": "^1.33.0",
69
69
  "@atlaskit/tooltip": "^18.1.0",
70
70
  "@babel/runtime": "^7.0.0",
71
71
  "@emotion/react": "^11.7.1",