@atlaskit/editor-plugin-media-insert 9.1.0 → 9.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/editor-plugin-media-insert
2
2
 
3
+ ## 9.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 9.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`12a4ac6a0a8cd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/12a4ac6a0a8cd) -
14
+ [ux] this change moves smart value logic out of atlaskit
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+
3
20
  ## 9.1.0
4
21
 
5
22
  ### Minor Changes
@@ -119,7 +119,8 @@ var mediaInsertPlugin = exports.mediaInsertPlugin = function mediaInsertPlugin(_
119
119
  insertExternalMediaSingle: insertExternalMediaSingle,
120
120
  insertFile: insertFile,
121
121
  isOnlyExternalLinks: config === null || config === void 0 ? void 0 : config.isOnlyExternalLinks,
122
- isUrlValidationOff: config === null || config === void 0 ? void 0 : config.isUrlValidationOff
122
+ customizedUrlValidation: config === null || config === void 0 ? void 0 : config.customizedUrlValidation,
123
+ customizedHelperMessage: config === null || config === void 0 ? void 0 : config.customizedHelperMessage
123
124
  });
124
125
  },
125
126
  pluginsOptions: {
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.MediaFromURL = MediaFromURL;
9
- exports.isValidUrl = exports.isValidSmartValue = void 0;
9
+ exports.isValidUrl = void 0;
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
11
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
12
12
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
@@ -52,18 +52,12 @@ var INITIAL_PREVIEW_STATE = Object.freeze({
52
52
  warning: null,
53
53
  previewInfo: null
54
54
  });
55
- var isValidInput = function isValidInput(value, isUrlValidationOff) {
56
- if (isUrlValidationOff) {
57
- return isValidUrl(value) || isValidSmartValue(value);
55
+ var isValidInput = function isValidInput(value, customizedUrlValidation) {
56
+ if (customizedUrlValidation) {
57
+ return customizedUrlValidation(value);
58
58
  }
59
59
  return isValidUrl(value);
60
60
  };
61
- var isValidSmartValue = exports.isValidSmartValue = function isValidSmartValue(value) {
62
- if (/^\{\{(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+\}\}$/.test(value) && value.length < MAX_URL_LENGTH) {
63
- return true;
64
- }
65
- return false;
66
- };
67
61
  var MAX_URL_LENGTH = 2048;
68
62
  var isValidUrl = exports.isValidUrl = function isValidUrl(value) {
69
63
  try {
@@ -110,7 +104,8 @@ function MediaFromURL(_ref) {
110
104
  insertMediaSingle = _ref.insertMediaSingle,
111
105
  insertExternalMediaSingle = _ref.insertExternalMediaSingle,
112
106
  isOnlyExternalLinks = _ref.isOnlyExternalLinks,
113
- isUrlValidationOff = _ref.isUrlValidationOff;
107
+ customizedUrlValidation = _ref.customizedUrlValidation,
108
+ customizedHelperMessage = _ref.customizedHelperMessage;
114
109
  var intl = (0, _reactIntlNext.useIntl)();
115
110
  var strings = {
116
111
  loadPreview: intl.formatMessage(_messages.mediaInsertMessages.loadPreview),
@@ -119,8 +114,7 @@ function MediaFromURL(_ref) {
119
114
  cancel: intl.formatMessage(_messages.mediaInsertMessages.cancel),
120
115
  errorMessage: intl.formatMessage(_messages.mediaInsertMessages.fromUrlErrorMessage),
121
116
  warning: intl.formatMessage(_messages.mediaInsertMessages.fromUrlWarning),
122
- invalidUrl: intl.formatMessage(_messages.mediaInsertMessages.invalidUrlErrorMessage),
123
- insertSmartValueHelperMessage: intl.formatMessage(_messages.mediaInsertMessages.insertSmartValueHelperMessage)
117
+ invalidUrl: intl.formatMessage(_messages.mediaInsertMessages.invalidUrlErrorMessage)
124
118
  };
125
119
  var _React$useReducer = _react.default.useReducer(previewStateReducer, INITIAL_PREVIEW_STATE),
126
120
  _React$useReducer2 = (0, _slicedToArray2.default)(_React$useReducer, 2),
@@ -220,7 +214,7 @@ function MediaFromURL(_ref) {
220
214
  type: 'reset'
221
215
  });
222
216
  setInput(url);
223
- if (!isValidInput(url, isUrlValidationOff)) {
217
+ if (!isValidInput(url, customizedUrlValidation)) {
224
218
  return;
225
219
  }
226
220
  if (pasteFlag.current) {
@@ -229,7 +223,7 @@ function MediaFromURL(_ref) {
229
223
  uploadExternalMedia(url);
230
224
  }
231
225
  }
232
- }, [uploadExternalMedia, isOnlyExternalLinks, isUrlValidationOff]);
226
+ }, [uploadExternalMedia, isOnlyExternalLinks, customizedUrlValidation]);
233
227
  var _onPaste = _react.default.useCallback(function (e, inputUrl) {
234
228
  // Note: this is a little weird, but the paste event will always be
235
229
  // fired before the change event when pasting. We don't really want to
@@ -322,7 +316,7 @@ function MediaFromURL(_ref) {
322
316
  isRequired: true,
323
317
  name: "inputUrl",
324
318
  validate: function validate(value) {
325
- return value && isValidInput(value, isUrlValidationOff) ? undefined : strings.invalidUrl;
319
+ return value && isValidInput(value, customizedUrlValidation) ? undefined : strings.invalidUrl;
326
320
  }
327
321
  }, function (_ref5) {
328
322
  var _ref5$fieldProps = _ref5.fieldProps,
@@ -355,7 +349,7 @@ function MediaFromURL(_ref) {
355
349
  formProps.onSubmit();
356
350
  }
357
351
  }
358
- })), isUrlValidationOff && /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_form.HelperMessage, null, strings.insertSmartValueHelperMessage)), /*#__PURE__*/_react.default.createElement(_form.MessageWrapper, null, error && /*#__PURE__*/_react.default.createElement(_form.ErrorMessage, null, /*#__PURE__*/_react.default.createElement(_primitives.Box, {
352
+ })), customizedHelperMessage && /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_form.HelperMessage, null, customizedHelperMessage)), /*#__PURE__*/_react.default.createElement(_form.MessageWrapper, null, error && /*#__PURE__*/_react.default.createElement(_form.ErrorMessage, null, /*#__PURE__*/_react.default.createElement(_primitives.Box, {
359
353
  as: "span"
360
354
  }, error)))), !previewState.previewInfo && !previewState.error && !previewState.warning && !isOnlyExternalLinks && /*#__PURE__*/_react.default.createElement(_primitives.Flex, {
361
355
  xcss: PreviewBoxStyles,
@@ -393,7 +387,7 @@ function MediaFromURL(_ref) {
393
387
  }, strings.cancel), /*#__PURE__*/_react.default.createElement(_new.default, {
394
388
  type: "submit",
395
389
  appearance: "primary",
396
- isDisabled: isOnlyExternalLinks ? !input || !isValidInput(input, isUrlValidationOff) : !previewState.previewInfo && !previewState.warning,
390
+ isDisabled: isOnlyExternalLinks ? !input || !isValidInput(input, customizedUrlValidation) : !previewState.previewInfo && !previewState.warning,
397
391
  onClick: function onClick() {
398
392
  return formProps.onSubmit();
399
393
  }
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.MediaFromURLWithForm = MediaFromURLWithForm;
9
- exports.isValidUrl = exports.isValidSmartValue = void 0;
9
+ exports.isValidUrl = void 0;
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
11
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
12
12
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
@@ -53,18 +53,12 @@ var INITIAL_PREVIEW_STATE = Object.freeze({
53
53
  previewInfo: null
54
54
  });
55
55
  var MAX_URL_LENGTH = 2048;
56
- var isValidInput = function isValidInput(value, isUrlValidationOff) {
57
- if (isUrlValidationOff) {
58
- return isValidUrl(value) || isValidSmartValue(value);
56
+ var isValidInput = function isValidInput(value, customizedUrlValidation) {
57
+ if (customizedUrlValidation) {
58
+ return customizedUrlValidation(value);
59
59
  }
60
60
  return isValidUrl(value);
61
61
  };
62
- var isValidSmartValue = exports.isValidSmartValue = function isValidSmartValue(value) {
63
- if (/^\{\{(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+\}\}$/.test(value) && value.length < MAX_URL_LENGTH) {
64
- return true;
65
- }
66
- return false;
67
- };
68
62
  var isValidUrl = exports.isValidUrl = function isValidUrl(value) {
69
63
  try {
70
64
  // Check for spaces and length first to avoid the expensive URL parsing
@@ -110,7 +104,8 @@ function MediaFromURLWithForm(_ref) {
110
104
  insertMediaSingle = _ref.insertMediaSingle,
111
105
  insertExternalMediaSingle = _ref.insertExternalMediaSingle,
112
106
  isOnlyExternalLinks = _ref.isOnlyExternalLinks,
113
- isUrlValidationOff = _ref.isUrlValidationOff;
107
+ customizedUrlValidation = _ref.customizedUrlValidation,
108
+ customizedHelperMessage = _ref.customizedHelperMessage;
114
109
  var intl = (0, _reactIntlNext.useIntl)();
115
110
  var strings = {
116
111
  loadPreview: intl.formatMessage(_messages.mediaInsertMessages.loadPreview),
@@ -119,8 +114,7 @@ function MediaFromURLWithForm(_ref) {
119
114
  cancel: intl.formatMessage(_messages.mediaInsertMessages.cancel),
120
115
  errorMessage: intl.formatMessage(_messages.mediaInsertMessages.fromUrlErrorMessage),
121
116
  warning: intl.formatMessage(_messages.mediaInsertMessages.fromUrlWarning),
122
- invalidUrl: intl.formatMessage(_messages.mediaInsertMessages.invalidUrlErrorMessage),
123
- insertSmartValueHelperMessage: intl.formatMessage(_messages.mediaInsertMessages.insertSmartValueHelperMessage)
117
+ invalidUrl: intl.formatMessage(_messages.mediaInsertMessages.invalidUrlErrorMessage)
124
118
  };
125
119
  var _React$useReducer = _react.default.useReducer(previewStateReducer, INITIAL_PREVIEW_STATE),
126
120
  _React$useReducer2 = (0, _slicedToArray2.default)(_React$useReducer, 2),
@@ -220,7 +214,7 @@ function MediaFromURLWithForm(_ref) {
220
214
  type: 'reset'
221
215
  });
222
216
  setInput(url);
223
- if (!isValidInput(url, isUrlValidationOff)) {
217
+ if (!isValidInput(url, customizedUrlValidation)) {
224
218
  return;
225
219
  }
226
220
  if (pasteFlag.current) {
@@ -229,7 +223,7 @@ function MediaFromURLWithForm(_ref) {
229
223
  uploadExternalMedia(url);
230
224
  }
231
225
  }
232
- }, [uploadExternalMedia, isOnlyExternalLinks, isUrlValidationOff]);
226
+ }, [uploadExternalMedia, isOnlyExternalLinks, customizedUrlValidation]);
233
227
  var _onPaste = _react.default.useCallback(function (e, inputUrl) {
234
228
  // Note: this is a little weird, but the paste event will always be
235
229
  // fired before the change event when pasting. We don't really want to
@@ -324,7 +318,7 @@ function MediaFromURLWithForm(_ref) {
324
318
  isRequired: true,
325
319
  name: "inputUrl",
326
320
  validate: function validate(value) {
327
- return value && isValidInput(value, isUrlValidationOff) ? undefined : strings.invalidUrl;
321
+ return value && isValidInput(value, customizedUrlValidation) ? undefined : strings.invalidUrl;
328
322
  }
329
323
  }, function (_ref5) {
330
324
  var _ref5$fieldProps = _ref5.fieldProps,
@@ -351,7 +345,7 @@ function MediaFromURLWithForm(_ref) {
351
345
  onURLChange(value);
352
346
  _onChange(value);
353
347
  }
354
- })), isUrlValidationOff && /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_form.HelperMessage, null, strings.insertSmartValueHelperMessage)), /*#__PURE__*/_react.default.createElement(_form.MessageWrapper, null, error && /*#__PURE__*/_react.default.createElement(_form.ErrorMessage, null, /*#__PURE__*/_react.default.createElement(_primitives.Box, {
348
+ })), customizedHelperMessage && /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_form.HelperMessage, null, customizedHelperMessage)), /*#__PURE__*/_react.default.createElement(_form.MessageWrapper, null, error && /*#__PURE__*/_react.default.createElement(_form.ErrorMessage, null, /*#__PURE__*/_react.default.createElement(_primitives.Box, {
355
349
  as: "span"
356
350
  }, error)))), !previewState.previewInfo && !previewState.error && !previewState.warning && !isOnlyExternalLinks && /*#__PURE__*/_react.default.createElement(_primitives.Flex, {
357
351
  xcss: PreviewBoxStyles,
@@ -386,7 +380,7 @@ function MediaFromURLWithForm(_ref) {
386
380
  }, strings.cancel), /*#__PURE__*/_react.default.createElement(_new.default, {
387
381
  type: "submit",
388
382
  appearance: "primary",
389
- isDisabled: isOnlyExternalLinks ? !input || !isValidInput(input, isUrlValidationOff) : !previewState.previewInfo && !previewState.warning
383
+ isDisabled: isOnlyExternalLinks ? !input || !isValidInput(input, customizedUrlValidation) : !previewState.previewInfo && !previewState.warning
390
384
  }, strings.insert)))))
391
385
  );
392
386
  });
@@ -76,8 +76,8 @@ var MediaInsertPicker = exports.MediaInsertPicker = function MediaInsertPicker(_
76
76
  insertFile = _ref2.insertFile,
77
77
  _ref2$isOnlyExternalL = _ref2.isOnlyExternalLinks,
78
78
  isOnlyExternalLinks = _ref2$isOnlyExternalL === void 0 ? false : _ref2$isOnlyExternalL,
79
- _ref2$isUrlValidation = _ref2.isUrlValidationOff,
80
- isUrlValidationOff = _ref2$isUrlValidation === void 0 ? false : _ref2$isUrlValidation;
79
+ customizedUrlValidation = _ref2.customizedUrlValidation,
80
+ customizedHelperMessage = _ref2.customizedHelperMessage;
81
81
  var _useSharedState = useSharedState(api),
82
82
  mediaProvider = _useSharedState.mediaProvider,
83
83
  isOpen = _useSharedState.isOpen,
@@ -163,7 +163,8 @@ var MediaInsertPicker = exports.MediaInsertPicker = function MediaInsertPicker(_
163
163
  insertMediaSingle: insertMediaSingle,
164
164
  insertExternalMediaSingle: insertExternalMediaSingle,
165
165
  isOnlyExternalLinks: isOnlyExternalLinks,
166
- isUrlValidationOff: isUrlValidationOff
166
+ customizedUrlValidation: customizedUrlValidation,
167
+ customizedHelperMessage: customizedHelperMessage
167
168
  }) : /*#__PURE__*/_react.default.createElement(_MediaFromURLWithForm.MediaFromURLWithForm, {
168
169
  mediaProvider: mediaProvider,
169
170
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
@@ -174,7 +175,8 @@ var MediaInsertPicker = exports.MediaInsertPicker = function MediaInsertPicker(_
174
175
  insertMediaSingle: insertMediaSingle,
175
176
  insertExternalMediaSingle: insertExternalMediaSingle,
176
177
  isOnlyExternalLinks: isOnlyExternalLinks,
177
- isUrlValidationOff: isUrlValidationOff
178
+ customizedUrlValidation: customizedUrlValidation,
179
+ customizedHelperMessage: customizedHelperMessage
178
180
  }))));
179
181
  }));
180
182
  };
@@ -113,7 +113,8 @@ export const mediaInsertPlugin = ({
113
113
  insertExternalMediaSingle: insertExternalMediaSingle,
114
114
  insertFile: insertFile,
115
115
  isOnlyExternalLinks: config === null || config === void 0 ? void 0 : config.isOnlyExternalLinks,
116
- isUrlValidationOff: config === null || config === void 0 ? void 0 : config.isUrlValidationOff
116
+ customizedUrlValidation: config === null || config === void 0 ? void 0 : config.customizedUrlValidation,
117
+ customizedHelperMessage: config === null || config === void 0 ? void 0 : config.customizedHelperMessage
117
118
  });
118
119
  },
119
120
  pluginsOptions: {
@@ -35,18 +35,12 @@ const INITIAL_PREVIEW_STATE = Object.freeze({
35
35
  warning: null,
36
36
  previewInfo: null
37
37
  });
38
- const isValidInput = (value, isUrlValidationOff) => {
39
- if (isUrlValidationOff) {
40
- return isValidUrl(value) || isValidSmartValue(value);
38
+ const isValidInput = (value, customizedUrlValidation) => {
39
+ if (customizedUrlValidation) {
40
+ return customizedUrlValidation(value);
41
41
  }
42
42
  return isValidUrl(value);
43
43
  };
44
- export const isValidSmartValue = value => {
45
- if (/^\{\{.+\}\}$/u.test(value) && value.length < MAX_URL_LENGTH) {
46
- return true;
47
- }
48
- return false;
49
- };
50
44
  const MAX_URL_LENGTH = 2048;
51
45
  export const isValidUrl = value => {
52
46
  try {
@@ -97,7 +91,8 @@ export function MediaFromURL({
97
91
  insertMediaSingle,
98
92
  insertExternalMediaSingle,
99
93
  isOnlyExternalLinks,
100
- isUrlValidationOff
94
+ customizedUrlValidation,
95
+ customizedHelperMessage
101
96
  }) {
102
97
  const intl = useIntl();
103
98
  const strings = {
@@ -107,8 +102,7 @@ export function MediaFromURL({
107
102
  cancel: intl.formatMessage(mediaInsertMessages.cancel),
108
103
  errorMessage: intl.formatMessage(mediaInsertMessages.fromUrlErrorMessage),
109
104
  warning: intl.formatMessage(mediaInsertMessages.fromUrlWarning),
110
- invalidUrl: intl.formatMessage(mediaInsertMessages.invalidUrlErrorMessage),
111
- insertSmartValueHelperMessage: intl.formatMessage(mediaInsertMessages.insertSmartValueHelperMessage)
105
+ invalidUrl: intl.formatMessage(mediaInsertMessages.invalidUrlErrorMessage)
112
106
  };
113
107
  const [previewState, dispatch] = React.useReducer(previewStateReducer, INITIAL_PREVIEW_STATE);
114
108
  const [input, setInput] = React.useState('');
@@ -184,7 +178,7 @@ export function MediaFromURL({
184
178
  type: 'reset'
185
179
  });
186
180
  setInput(url);
187
- if (!isValidInput(url, isUrlValidationOff)) {
181
+ if (!isValidInput(url, customizedUrlValidation)) {
188
182
  return;
189
183
  }
190
184
  if (pasteFlag.current) {
@@ -193,7 +187,7 @@ export function MediaFromURL({
193
187
  uploadExternalMedia(url);
194
188
  }
195
189
  }
196
- }, [uploadExternalMedia, isOnlyExternalLinks, isUrlValidationOff]);
190
+ }, [uploadExternalMedia, isOnlyExternalLinks, customizedUrlValidation]);
197
191
  const onPaste = React.useCallback((e, inputUrl) => {
198
192
  // Note: this is a little weird, but the paste event will always be
199
193
  // fired before the change event when pasting. We don't really want to
@@ -286,7 +280,7 @@ export function MediaFromURL({
286
280
  "aria-required": true,
287
281
  isRequired: true,
288
282
  name: "inputUrl",
289
- validate: value => value && isValidInput(value, isUrlValidationOff) ? undefined : strings.invalidUrl
283
+ validate: value => value && isValidInput(value, customizedUrlValidation) ? undefined : strings.invalidUrl
290
284
  }, ({
291
285
  fieldProps: {
292
286
  value,
@@ -317,7 +311,7 @@ export function MediaFromURL({
317
311
  formProps.onSubmit();
318
312
  }
319
313
  }
320
- })), isUrlValidationOff && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(HelperMessage, null, strings.insertSmartValueHelperMessage)), /*#__PURE__*/React.createElement(MessageWrapper, null, error && /*#__PURE__*/React.createElement(ErrorMessage, null, /*#__PURE__*/React.createElement(Box, {
314
+ })), customizedHelperMessage && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(HelperMessage, null, customizedHelperMessage)), /*#__PURE__*/React.createElement(MessageWrapper, null, error && /*#__PURE__*/React.createElement(ErrorMessage, null, /*#__PURE__*/React.createElement(Box, {
321
315
  as: "span"
322
316
  }, error)))), !previewState.previewInfo && !previewState.error && !previewState.warning && !isOnlyExternalLinks && /*#__PURE__*/React.createElement(Flex, {
323
317
  xcss: PreviewBoxStyles,
@@ -350,7 +344,7 @@ export function MediaFromURL({
350
344
  }, strings.cancel), /*#__PURE__*/React.createElement(Button, {
351
345
  type: "submit",
352
346
  appearance: "primary",
353
- isDisabled: isOnlyExternalLinks ? !input || !isValidInput(input, isUrlValidationOff) : !previewState.previewInfo && !previewState.warning,
347
+ isDisabled: isOnlyExternalLinks ? !input || !isValidInput(input, customizedUrlValidation) : !previewState.previewInfo && !previewState.warning,
354
348
  onClick: () => formProps.onSubmit()
355
349
  }, strings.insert))))));
356
350
  }
@@ -36,18 +36,12 @@ const INITIAL_PREVIEW_STATE = Object.freeze({
36
36
  previewInfo: null
37
37
  });
38
38
  const MAX_URL_LENGTH = 2048;
39
- const isValidInput = (value, isUrlValidationOff) => {
40
- if (isUrlValidationOff) {
41
- return isValidUrl(value) || isValidSmartValue(value);
39
+ const isValidInput = (value, customizedUrlValidation) => {
40
+ if (customizedUrlValidation) {
41
+ return customizedUrlValidation(value);
42
42
  }
43
43
  return isValidUrl(value);
44
44
  };
45
- export const isValidSmartValue = value => {
46
- if (/^\{\{.+\}\}$/u.test(value) && value.length < MAX_URL_LENGTH) {
47
- return true;
48
- }
49
- return false;
50
- };
51
45
  export const isValidUrl = value => {
52
46
  try {
53
47
  // Check for spaces and length first to avoid the expensive URL parsing
@@ -97,7 +91,8 @@ export function MediaFromURLWithForm({
97
91
  insertMediaSingle,
98
92
  insertExternalMediaSingle,
99
93
  isOnlyExternalLinks,
100
- isUrlValidationOff
94
+ customizedUrlValidation,
95
+ customizedHelperMessage
101
96
  }) {
102
97
  const intl = useIntl();
103
98
  const strings = {
@@ -107,8 +102,7 @@ export function MediaFromURLWithForm({
107
102
  cancel: intl.formatMessage(mediaInsertMessages.cancel),
108
103
  errorMessage: intl.formatMessage(mediaInsertMessages.fromUrlErrorMessage),
109
104
  warning: intl.formatMessage(mediaInsertMessages.fromUrlWarning),
110
- invalidUrl: intl.formatMessage(mediaInsertMessages.invalidUrlErrorMessage),
111
- insertSmartValueHelperMessage: intl.formatMessage(mediaInsertMessages.insertSmartValueHelperMessage)
105
+ invalidUrl: intl.formatMessage(mediaInsertMessages.invalidUrlErrorMessage)
112
106
  };
113
107
  const [previewState, dispatch] = React.useReducer(previewStateReducer, INITIAL_PREVIEW_STATE);
114
108
  const [input, setInput] = React.useState('');
@@ -184,7 +178,7 @@ export function MediaFromURLWithForm({
184
178
  type: 'reset'
185
179
  });
186
180
  setInput(url);
187
- if (!isValidInput(url, isUrlValidationOff)) {
181
+ if (!isValidInput(url, customizedUrlValidation)) {
188
182
  return;
189
183
  }
190
184
  if (pasteFlag.current) {
@@ -193,7 +187,7 @@ export function MediaFromURLWithForm({
193
187
  uploadExternalMedia(url);
194
188
  }
195
189
  }
196
- }, [uploadExternalMedia, isOnlyExternalLinks, isUrlValidationOff]);
190
+ }, [uploadExternalMedia, isOnlyExternalLinks, customizedUrlValidation]);
197
191
  const onPaste = React.useCallback((e, inputUrl) => {
198
192
  // Note: this is a little weird, but the paste event will always be
199
193
  // fired before the change event when pasting. We don't really want to
@@ -288,7 +282,7 @@ export function MediaFromURLWithForm({
288
282
  "aria-required": true,
289
283
  isRequired: true,
290
284
  name: "inputUrl",
291
- validate: value => value && isValidInput(value, isUrlValidationOff) ? undefined : strings.invalidUrl
285
+ validate: value => value && isValidInput(value, customizedUrlValidation) ? undefined : strings.invalidUrl
292
286
  }, ({
293
287
  fieldProps: {
294
288
  value,
@@ -313,7 +307,7 @@ export function MediaFromURLWithForm({
313
307
  onURLChange(value);
314
308
  onChange(value);
315
309
  }
316
- })), isUrlValidationOff && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(HelperMessage, null, strings.insertSmartValueHelperMessage)), /*#__PURE__*/React.createElement(MessageWrapper, null, error && /*#__PURE__*/React.createElement(ErrorMessage, null, /*#__PURE__*/React.createElement(Box, {
310
+ })), customizedHelperMessage && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(HelperMessage, null, customizedHelperMessage)), /*#__PURE__*/React.createElement(MessageWrapper, null, error && /*#__PURE__*/React.createElement(ErrorMessage, null, /*#__PURE__*/React.createElement(Box, {
317
311
  as: "span"
318
312
  }, error)))), !previewState.previewInfo && !previewState.error && !previewState.warning && !isOnlyExternalLinks && /*#__PURE__*/React.createElement(Flex, {
319
313
  xcss: PreviewBoxStyles,
@@ -345,6 +339,6 @@ export function MediaFromURLWithForm({
345
339
  }, strings.cancel), /*#__PURE__*/React.createElement(Button, {
346
340
  type: "submit",
347
341
  appearance: "primary",
348
- isDisabled: isOnlyExternalLinks ? !input || !isValidInput(input, isUrlValidationOff) : !previewState.previewInfo && !previewState.warning
342
+ isDisabled: isOnlyExternalLinks ? !input || !isValidInput(input, customizedUrlValidation) : !previewState.previewInfo && !previewState.warning
349
343
  }, strings.insert))))));
350
344
  }
@@ -68,7 +68,8 @@ export const MediaInsertPicker = ({
68
68
  insertExternalMediaSingle,
69
69
  insertFile,
70
70
  isOnlyExternalLinks = false,
71
- isUrlValidationOff = false
71
+ customizedUrlValidation,
72
+ customizedHelperMessage
72
73
  }) => {
73
74
  const {
74
75
  mediaProvider,
@@ -154,7 +155,8 @@ export const MediaInsertPicker = ({
154
155
  insertMediaSingle: insertMediaSingle,
155
156
  insertExternalMediaSingle: insertExternalMediaSingle,
156
157
  isOnlyExternalLinks: isOnlyExternalLinks,
157
- isUrlValidationOff: isUrlValidationOff
158
+ customizedUrlValidation: customizedUrlValidation,
159
+ customizedHelperMessage: customizedHelperMessage
158
160
  }) : /*#__PURE__*/React.createElement(MediaFromURLWithForm, {
159
161
  mediaProvider: mediaProvider,
160
162
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
@@ -165,6 +167,7 @@ export const MediaInsertPicker = ({
165
167
  insertMediaSingle: insertMediaSingle,
166
168
  insertExternalMediaSingle: insertExternalMediaSingle,
167
169
  isOnlyExternalLinks: isOnlyExternalLinks,
168
- isUrlValidationOff: isUrlValidationOff
170
+ customizedUrlValidation: customizedUrlValidation,
171
+ customizedHelperMessage: customizedHelperMessage
169
172
  }))))));
170
173
  };
@@ -112,7 +112,8 @@ export var mediaInsertPlugin = function mediaInsertPlugin(_ref) {
112
112
  insertExternalMediaSingle: insertExternalMediaSingle,
113
113
  insertFile: insertFile,
114
114
  isOnlyExternalLinks: config === null || config === void 0 ? void 0 : config.isOnlyExternalLinks,
115
- isUrlValidationOff: config === null || config === void 0 ? void 0 : config.isUrlValidationOff
115
+ customizedUrlValidation: config === null || config === void 0 ? void 0 : config.customizedUrlValidation,
116
+ customizedHelperMessage: config === null || config === void 0 ? void 0 : config.customizedHelperMessage
116
117
  });
117
118
  },
118
119
  pluginsOptions: {
@@ -43,18 +43,12 @@ var INITIAL_PREVIEW_STATE = Object.freeze({
43
43
  warning: null,
44
44
  previewInfo: null
45
45
  });
46
- var isValidInput = function isValidInput(value, isUrlValidationOff) {
47
- if (isUrlValidationOff) {
48
- return isValidUrl(value) || isValidSmartValue(value);
46
+ var isValidInput = function isValidInput(value, customizedUrlValidation) {
47
+ if (customizedUrlValidation) {
48
+ return customizedUrlValidation(value);
49
49
  }
50
50
  return isValidUrl(value);
51
51
  };
52
- export var isValidSmartValue = function isValidSmartValue(value) {
53
- if (/^\{\{(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+\}\}$/.test(value) && value.length < MAX_URL_LENGTH) {
54
- return true;
55
- }
56
- return false;
57
- };
58
52
  var MAX_URL_LENGTH = 2048;
59
53
  export var isValidUrl = function isValidUrl(value) {
60
54
  try {
@@ -101,7 +95,8 @@ export function MediaFromURL(_ref) {
101
95
  insertMediaSingle = _ref.insertMediaSingle,
102
96
  insertExternalMediaSingle = _ref.insertExternalMediaSingle,
103
97
  isOnlyExternalLinks = _ref.isOnlyExternalLinks,
104
- isUrlValidationOff = _ref.isUrlValidationOff;
98
+ customizedUrlValidation = _ref.customizedUrlValidation,
99
+ customizedHelperMessage = _ref.customizedHelperMessage;
105
100
  var intl = useIntl();
106
101
  var strings = {
107
102
  loadPreview: intl.formatMessage(mediaInsertMessages.loadPreview),
@@ -110,8 +105,7 @@ export function MediaFromURL(_ref) {
110
105
  cancel: intl.formatMessage(mediaInsertMessages.cancel),
111
106
  errorMessage: intl.formatMessage(mediaInsertMessages.fromUrlErrorMessage),
112
107
  warning: intl.formatMessage(mediaInsertMessages.fromUrlWarning),
113
- invalidUrl: intl.formatMessage(mediaInsertMessages.invalidUrlErrorMessage),
114
- insertSmartValueHelperMessage: intl.formatMessage(mediaInsertMessages.insertSmartValueHelperMessage)
108
+ invalidUrl: intl.formatMessage(mediaInsertMessages.invalidUrlErrorMessage)
115
109
  };
116
110
  var _React$useReducer = React.useReducer(previewStateReducer, INITIAL_PREVIEW_STATE),
117
111
  _React$useReducer2 = _slicedToArray(_React$useReducer, 2),
@@ -211,7 +205,7 @@ export function MediaFromURL(_ref) {
211
205
  type: 'reset'
212
206
  });
213
207
  setInput(url);
214
- if (!isValidInput(url, isUrlValidationOff)) {
208
+ if (!isValidInput(url, customizedUrlValidation)) {
215
209
  return;
216
210
  }
217
211
  if (pasteFlag.current) {
@@ -220,7 +214,7 @@ export function MediaFromURL(_ref) {
220
214
  uploadExternalMedia(url);
221
215
  }
222
216
  }
223
- }, [uploadExternalMedia, isOnlyExternalLinks, isUrlValidationOff]);
217
+ }, [uploadExternalMedia, isOnlyExternalLinks, customizedUrlValidation]);
224
218
  var _onPaste = React.useCallback(function (e, inputUrl) {
225
219
  // Note: this is a little weird, but the paste event will always be
226
220
  // fired before the change event when pasting. We don't really want to
@@ -313,7 +307,7 @@ export function MediaFromURL(_ref) {
313
307
  isRequired: true,
314
308
  name: "inputUrl",
315
309
  validate: function validate(value) {
316
- return value && isValidInput(value, isUrlValidationOff) ? undefined : strings.invalidUrl;
310
+ return value && isValidInput(value, customizedUrlValidation) ? undefined : strings.invalidUrl;
317
311
  }
318
312
  }, function (_ref5) {
319
313
  var _ref5$fieldProps = _ref5.fieldProps,
@@ -346,7 +340,7 @@ export function MediaFromURL(_ref) {
346
340
  formProps.onSubmit();
347
341
  }
348
342
  }
349
- })), isUrlValidationOff && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(HelperMessage, null, strings.insertSmartValueHelperMessage)), /*#__PURE__*/React.createElement(MessageWrapper, null, error && /*#__PURE__*/React.createElement(ErrorMessage, null, /*#__PURE__*/React.createElement(Box, {
343
+ })), customizedHelperMessage && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(HelperMessage, null, customizedHelperMessage)), /*#__PURE__*/React.createElement(MessageWrapper, null, error && /*#__PURE__*/React.createElement(ErrorMessage, null, /*#__PURE__*/React.createElement(Box, {
350
344
  as: "span"
351
345
  }, error)))), !previewState.previewInfo && !previewState.error && !previewState.warning && !isOnlyExternalLinks && /*#__PURE__*/React.createElement(Flex, {
352
346
  xcss: PreviewBoxStyles,
@@ -384,7 +378,7 @@ export function MediaFromURL(_ref) {
384
378
  }, strings.cancel), /*#__PURE__*/React.createElement(Button, {
385
379
  type: "submit",
386
380
  appearance: "primary",
387
- isDisabled: isOnlyExternalLinks ? !input || !isValidInput(input, isUrlValidationOff) : !previewState.previewInfo && !previewState.warning,
381
+ isDisabled: isOnlyExternalLinks ? !input || !isValidInput(input, customizedUrlValidation) : !previewState.previewInfo && !previewState.warning,
388
382
  onClick: function onClick() {
389
383
  return formProps.onSubmit();
390
384
  }
@@ -44,18 +44,12 @@ var INITIAL_PREVIEW_STATE = Object.freeze({
44
44
  previewInfo: null
45
45
  });
46
46
  var MAX_URL_LENGTH = 2048;
47
- var isValidInput = function isValidInput(value, isUrlValidationOff) {
48
- if (isUrlValidationOff) {
49
- return isValidUrl(value) || isValidSmartValue(value);
47
+ var isValidInput = function isValidInput(value, customizedUrlValidation) {
48
+ if (customizedUrlValidation) {
49
+ return customizedUrlValidation(value);
50
50
  }
51
51
  return isValidUrl(value);
52
52
  };
53
- export var isValidSmartValue = function isValidSmartValue(value) {
54
- if (/^\{\{(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+\}\}$/.test(value) && value.length < MAX_URL_LENGTH) {
55
- return true;
56
- }
57
- return false;
58
- };
59
53
  export var isValidUrl = function isValidUrl(value) {
60
54
  try {
61
55
  // Check for spaces and length first to avoid the expensive URL parsing
@@ -101,7 +95,8 @@ export function MediaFromURLWithForm(_ref) {
101
95
  insertMediaSingle = _ref.insertMediaSingle,
102
96
  insertExternalMediaSingle = _ref.insertExternalMediaSingle,
103
97
  isOnlyExternalLinks = _ref.isOnlyExternalLinks,
104
- isUrlValidationOff = _ref.isUrlValidationOff;
98
+ customizedUrlValidation = _ref.customizedUrlValidation,
99
+ customizedHelperMessage = _ref.customizedHelperMessage;
105
100
  var intl = useIntl();
106
101
  var strings = {
107
102
  loadPreview: intl.formatMessage(mediaInsertMessages.loadPreview),
@@ -110,8 +105,7 @@ export function MediaFromURLWithForm(_ref) {
110
105
  cancel: intl.formatMessage(mediaInsertMessages.cancel),
111
106
  errorMessage: intl.formatMessage(mediaInsertMessages.fromUrlErrorMessage),
112
107
  warning: intl.formatMessage(mediaInsertMessages.fromUrlWarning),
113
- invalidUrl: intl.formatMessage(mediaInsertMessages.invalidUrlErrorMessage),
114
- insertSmartValueHelperMessage: intl.formatMessage(mediaInsertMessages.insertSmartValueHelperMessage)
108
+ invalidUrl: intl.formatMessage(mediaInsertMessages.invalidUrlErrorMessage)
115
109
  };
116
110
  var _React$useReducer = React.useReducer(previewStateReducer, INITIAL_PREVIEW_STATE),
117
111
  _React$useReducer2 = _slicedToArray(_React$useReducer, 2),
@@ -211,7 +205,7 @@ export function MediaFromURLWithForm(_ref) {
211
205
  type: 'reset'
212
206
  });
213
207
  setInput(url);
214
- if (!isValidInput(url, isUrlValidationOff)) {
208
+ if (!isValidInput(url, customizedUrlValidation)) {
215
209
  return;
216
210
  }
217
211
  if (pasteFlag.current) {
@@ -220,7 +214,7 @@ export function MediaFromURLWithForm(_ref) {
220
214
  uploadExternalMedia(url);
221
215
  }
222
216
  }
223
- }, [uploadExternalMedia, isOnlyExternalLinks, isUrlValidationOff]);
217
+ }, [uploadExternalMedia, isOnlyExternalLinks, customizedUrlValidation]);
224
218
  var _onPaste = React.useCallback(function (e, inputUrl) {
225
219
  // Note: this is a little weird, but the paste event will always be
226
220
  // fired before the change event when pasting. We don't really want to
@@ -315,7 +309,7 @@ export function MediaFromURLWithForm(_ref) {
315
309
  isRequired: true,
316
310
  name: "inputUrl",
317
311
  validate: function validate(value) {
318
- return value && isValidInput(value, isUrlValidationOff) ? undefined : strings.invalidUrl;
312
+ return value && isValidInput(value, customizedUrlValidation) ? undefined : strings.invalidUrl;
319
313
  }
320
314
  }, function (_ref5) {
321
315
  var _ref5$fieldProps = _ref5.fieldProps,
@@ -342,7 +336,7 @@ export function MediaFromURLWithForm(_ref) {
342
336
  onURLChange(value);
343
337
  _onChange(value);
344
338
  }
345
- })), isUrlValidationOff && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(HelperMessage, null, strings.insertSmartValueHelperMessage)), /*#__PURE__*/React.createElement(MessageWrapper, null, error && /*#__PURE__*/React.createElement(ErrorMessage, null, /*#__PURE__*/React.createElement(Box, {
339
+ })), customizedHelperMessage && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(HelperMessage, null, customizedHelperMessage)), /*#__PURE__*/React.createElement(MessageWrapper, null, error && /*#__PURE__*/React.createElement(ErrorMessage, null, /*#__PURE__*/React.createElement(Box, {
346
340
  as: "span"
347
341
  }, error)))), !previewState.previewInfo && !previewState.error && !previewState.warning && !isOnlyExternalLinks && /*#__PURE__*/React.createElement(Flex, {
348
342
  xcss: PreviewBoxStyles,
@@ -377,7 +371,7 @@ export function MediaFromURLWithForm(_ref) {
377
371
  }, strings.cancel), /*#__PURE__*/React.createElement(Button, {
378
372
  type: "submit",
379
373
  appearance: "primary",
380
- isDisabled: isOnlyExternalLinks ? !input || !isValidInput(input, isUrlValidationOff) : !previewState.previewInfo && !previewState.warning
374
+ isDisabled: isOnlyExternalLinks ? !input || !isValidInput(input, customizedUrlValidation) : !previewState.previewInfo && !previewState.warning
381
375
  }, strings.insert)))))
382
376
  );
383
377
  });
@@ -67,8 +67,8 @@ export var MediaInsertPicker = function MediaInsertPicker(_ref2) {
67
67
  insertFile = _ref2.insertFile,
68
68
  _ref2$isOnlyExternalL = _ref2.isOnlyExternalLinks,
69
69
  isOnlyExternalLinks = _ref2$isOnlyExternalL === void 0 ? false : _ref2$isOnlyExternalL,
70
- _ref2$isUrlValidation = _ref2.isUrlValidationOff,
71
- isUrlValidationOff = _ref2$isUrlValidation === void 0 ? false : _ref2$isUrlValidation;
70
+ customizedUrlValidation = _ref2.customizedUrlValidation,
71
+ customizedHelperMessage = _ref2.customizedHelperMessage;
72
72
  var _useSharedState = useSharedState(api),
73
73
  mediaProvider = _useSharedState.mediaProvider,
74
74
  isOpen = _useSharedState.isOpen,
@@ -154,7 +154,8 @@ export var MediaInsertPicker = function MediaInsertPicker(_ref2) {
154
154
  insertMediaSingle: insertMediaSingle,
155
155
  insertExternalMediaSingle: insertExternalMediaSingle,
156
156
  isOnlyExternalLinks: isOnlyExternalLinks,
157
- isUrlValidationOff: isUrlValidationOff
157
+ customizedUrlValidation: customizedUrlValidation,
158
+ customizedHelperMessage: customizedHelperMessage
158
159
  }) : /*#__PURE__*/React.createElement(MediaFromURLWithForm, {
159
160
  mediaProvider: mediaProvider,
160
161
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
@@ -165,7 +166,8 @@ export var MediaInsertPicker = function MediaInsertPicker(_ref2) {
165
166
  insertMediaSingle: insertMediaSingle,
166
167
  insertExternalMediaSingle: insertExternalMediaSingle,
167
168
  isOnlyExternalLinks: isOnlyExternalLinks,
168
- isUrlValidationOff: isUrlValidationOff
169
+ customizedUrlValidation: customizedUrlValidation,
170
+ customizedHelperMessage: customizedHelperMessage
169
171
  }))));
170
172
  }));
171
173
  };
@@ -2,6 +2,7 @@ import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/
2
2
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
3
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
4
4
  import type { MediaPlugin } from '@atlaskit/editor-plugin-media';
5
+ import type { CustomizedHelperMessage } from './types';
5
6
  export type MediaInsertPluginState = {
6
7
  isOpen?: boolean;
7
8
  mountInfo?: {
@@ -50,7 +51,8 @@ export type MediaInsertPluginConfig = {
50
51
  * ```
51
52
  */
52
53
  isOnlyExternalLinks?: boolean;
53
- isUrlValidationOff?: boolean;
54
+ customizedUrlValidation?: (input: string) => boolean;
55
+ customizedHelperMessage?: CustomizedHelperMessage;
54
56
  };
55
57
  export type MediaInsertPlugin = NextEditorPlugin<'mediaInsert', {
56
58
  dependencies: MediaInsertPluginDependencies;
@@ -7,6 +7,7 @@ export type InsertMediaSingle = (props: {
7
7
  mediaState: MediaState;
8
8
  inputMethod: InputMethodInsertMedia;
9
9
  }) => boolean;
10
+ export type CustomizedHelperMessage = string;
10
11
  export type InsertExternalMediaSingle = (props: {
11
12
  url: string;
12
13
  alt: string;
@@ -25,5 +26,6 @@ export type MediaInsertPickerProps = Pick<UiComponentFactoryParams, 'editorView'
25
26
  insertExternalMediaSingle: InsertExternalMediaSingle;
26
27
  insertFile: InsertFile;
27
28
  isOnlyExternalLinks: MediaInsertPluginConfig['isOnlyExternalLinks'];
28
- isUrlValidationOff: MediaInsertPluginConfig['isUrlValidationOff'];
29
+ customizedUrlValidation?: MediaInsertPluginConfig['customizedUrlValidation'];
30
+ customizedHelperMessage?: MediaInsertPluginConfig['customizedHelperMessage'];
29
31
  };
@@ -1,8 +1,7 @@
1
1
  import React from 'react';
2
2
  import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
3
3
  import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
4
- import { type InsertExternalMediaSingle, type InsertMediaSingle } from '../types';
5
- export declare const isValidSmartValue: (value: string) => boolean;
4
+ import { type CustomizedHelperMessage, type InsertExternalMediaSingle, type InsertMediaSingle } from '../types';
6
5
  export declare const isValidUrl: (value: string) => boolean;
7
6
  type Props = {
8
7
  mediaProvider: MediaProvider;
@@ -11,7 +10,8 @@ type Props = {
11
10
  insertMediaSingle: InsertMediaSingle;
12
11
  insertExternalMediaSingle: InsertExternalMediaSingle;
13
12
  isOnlyExternalLinks: boolean;
14
- isUrlValidationOff: boolean;
13
+ customizedUrlValidation?: (input: string) => boolean;
14
+ customizedHelperMessage?: CustomizedHelperMessage;
15
15
  };
16
- export declare function MediaFromURL({ mediaProvider, dispatchAnalyticsEvent, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, isOnlyExternalLinks, isUrlValidationOff, }: Props): React.JSX.Element;
16
+ export declare function MediaFromURL({ mediaProvider, dispatchAnalyticsEvent, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, isOnlyExternalLinks, customizedUrlValidation, customizedHelperMessage, }: Props): React.JSX.Element;
17
17
  export {};
@@ -1,8 +1,7 @@
1
1
  import React from 'react';
2
2
  import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
3
3
  import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
4
- import { type InsertExternalMediaSingle, type InsertMediaSingle } from '../types';
5
- export declare const isValidSmartValue: (value: string) => boolean;
4
+ import { type CustomizedHelperMessage, type InsertExternalMediaSingle, type InsertMediaSingle } from '../types';
6
5
  export declare const isValidUrl: (value: string) => boolean;
7
6
  type Props = {
8
7
  mediaProvider: MediaProvider;
@@ -11,7 +10,8 @@ type Props = {
11
10
  insertMediaSingle: InsertMediaSingle;
12
11
  insertExternalMediaSingle: InsertExternalMediaSingle;
13
12
  isOnlyExternalLinks: boolean;
14
- isUrlValidationOff: boolean;
13
+ customizedUrlValidation?: (input: string) => boolean;
14
+ customizedHelperMessage?: CustomizedHelperMessage;
15
15
  };
16
- export declare function MediaFromURLWithForm({ mediaProvider, dispatchAnalyticsEvent, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, isOnlyExternalLinks, isUrlValidationOff, }: Props): React.JSX.Element;
16
+ export declare function MediaFromURLWithForm({ mediaProvider, dispatchAnalyticsEvent, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, isOnlyExternalLinks, customizedUrlValidation, customizedHelperMessage, }: Props): React.JSX.Element;
17
17
  export {};
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import { type MediaInsertPickerProps } from '../types';
3
- export declare const MediaInsertPicker: ({ api, editorView, dispatchAnalyticsEvent, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, insertFile, isOnlyExternalLinks, isUrlValidationOff, }: MediaInsertPickerProps) => React.JSX.Element | null;
3
+ export declare const MediaInsertPicker: ({ api, editorView, dispatchAnalyticsEvent, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, insertFile, isOnlyExternalLinks, customizedUrlValidation, customizedHelperMessage, }: MediaInsertPickerProps) => React.JSX.Element | null;
@@ -2,6 +2,7 @@ import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/
2
2
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
3
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
4
4
  import type { MediaPlugin } from '@atlaskit/editor-plugin-media';
5
+ import type { CustomizedHelperMessage } from './types';
5
6
  export type MediaInsertPluginState = {
6
7
  isOpen?: boolean;
7
8
  mountInfo?: {
@@ -50,7 +51,8 @@ export type MediaInsertPluginConfig = {
50
51
  * ```
51
52
  */
52
53
  isOnlyExternalLinks?: boolean;
53
- isUrlValidationOff?: boolean;
54
+ customizedUrlValidation?: (input: string) => boolean;
55
+ customizedHelperMessage?: CustomizedHelperMessage;
54
56
  };
55
57
  export type MediaInsertPlugin = NextEditorPlugin<'mediaInsert', {
56
58
  dependencies: MediaInsertPluginDependencies;
@@ -7,6 +7,7 @@ export type InsertMediaSingle = (props: {
7
7
  mediaState: MediaState;
8
8
  inputMethod: InputMethodInsertMedia;
9
9
  }) => boolean;
10
+ export type CustomizedHelperMessage = string;
10
11
  export type InsertExternalMediaSingle = (props: {
11
12
  url: string;
12
13
  alt: string;
@@ -25,5 +26,6 @@ export type MediaInsertPickerProps = Pick<UiComponentFactoryParams, 'editorView'
25
26
  insertExternalMediaSingle: InsertExternalMediaSingle;
26
27
  insertFile: InsertFile;
27
28
  isOnlyExternalLinks: MediaInsertPluginConfig['isOnlyExternalLinks'];
28
- isUrlValidationOff: MediaInsertPluginConfig['isUrlValidationOff'];
29
+ customizedUrlValidation?: MediaInsertPluginConfig['customizedUrlValidation'];
30
+ customizedHelperMessage?: MediaInsertPluginConfig['customizedHelperMessage'];
29
31
  };
@@ -1,8 +1,7 @@
1
1
  import React from 'react';
2
2
  import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
3
3
  import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
4
- import { type InsertExternalMediaSingle, type InsertMediaSingle } from '../types';
5
- export declare const isValidSmartValue: (value: string) => boolean;
4
+ import { type CustomizedHelperMessage, type InsertExternalMediaSingle, type InsertMediaSingle } from '../types';
6
5
  export declare const isValidUrl: (value: string) => boolean;
7
6
  type Props = {
8
7
  mediaProvider: MediaProvider;
@@ -11,7 +10,8 @@ type Props = {
11
10
  insertMediaSingle: InsertMediaSingle;
12
11
  insertExternalMediaSingle: InsertExternalMediaSingle;
13
12
  isOnlyExternalLinks: boolean;
14
- isUrlValidationOff: boolean;
13
+ customizedUrlValidation?: (input: string) => boolean;
14
+ customizedHelperMessage?: CustomizedHelperMessage;
15
15
  };
16
- export declare function MediaFromURL({ mediaProvider, dispatchAnalyticsEvent, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, isOnlyExternalLinks, isUrlValidationOff, }: Props): React.JSX.Element;
16
+ export declare function MediaFromURL({ mediaProvider, dispatchAnalyticsEvent, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, isOnlyExternalLinks, customizedUrlValidation, customizedHelperMessage, }: Props): React.JSX.Element;
17
17
  export {};
@@ -1,8 +1,7 @@
1
1
  import React from 'react';
2
2
  import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
3
3
  import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
4
- import { type InsertExternalMediaSingle, type InsertMediaSingle } from '../types';
5
- export declare const isValidSmartValue: (value: string) => boolean;
4
+ import { type CustomizedHelperMessage, type InsertExternalMediaSingle, type InsertMediaSingle } from '../types';
6
5
  export declare const isValidUrl: (value: string) => boolean;
7
6
  type Props = {
8
7
  mediaProvider: MediaProvider;
@@ -11,7 +10,8 @@ type Props = {
11
10
  insertMediaSingle: InsertMediaSingle;
12
11
  insertExternalMediaSingle: InsertExternalMediaSingle;
13
12
  isOnlyExternalLinks: boolean;
14
- isUrlValidationOff: boolean;
13
+ customizedUrlValidation?: (input: string) => boolean;
14
+ customizedHelperMessage?: CustomizedHelperMessage;
15
15
  };
16
- export declare function MediaFromURLWithForm({ mediaProvider, dispatchAnalyticsEvent, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, isOnlyExternalLinks, isUrlValidationOff, }: Props): React.JSX.Element;
16
+ export declare function MediaFromURLWithForm({ mediaProvider, dispatchAnalyticsEvent, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, isOnlyExternalLinks, customizedUrlValidation, customizedHelperMessage, }: Props): React.JSX.Element;
17
17
  export {};
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import { type MediaInsertPickerProps } from '../types';
3
- export declare const MediaInsertPicker: ({ api, editorView, dispatchAnalyticsEvent, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, insertFile, isOnlyExternalLinks, isUrlValidationOff, }: MediaInsertPickerProps) => React.JSX.Element | null;
3
+ export declare const MediaInsertPicker: ({ api, editorView, dispatchAnalyticsEvent, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, closeMediaInsertPicker, insertMediaSingle, insertExternalMediaSingle, insertFile, isOnlyExternalLinks, customizedUrlValidation, customizedHelperMessage, }: MediaInsertPickerProps) => React.JSX.Element | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media-insert",
3
- "version": "9.1.0",
3
+ "version": "9.2.1",
4
4
  "description": "Media Insert plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -25,13 +25,13 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@atlaskit/adf-schema": "^50.2.0",
28
- "@atlaskit/button": "^23.3.0",
28
+ "@atlaskit/button": "^23.4.0",
29
29
  "@atlaskit/editor-plugin-analytics": "^3.0.0",
30
30
  "@atlaskit/editor-plugin-media": "^5.2.0",
31
31
  "@atlaskit/editor-prosemirror": "7.0.0",
32
32
  "@atlaskit/editor-shared-styles": "^3.6.0",
33
- "@atlaskit/form": "^12.0.0",
34
- "@atlaskit/icon": "^27.10.0",
33
+ "@atlaskit/form": "^12.1.0",
34
+ "@atlaskit/icon": "^27.12.0",
35
35
  "@atlaskit/media-card": "^79.5.0",
36
36
  "@atlaskit/media-client": "^35.3.0",
37
37
  "@atlaskit/media-client-react": "^4.1.0",
@@ -41,12 +41,12 @@
41
41
  "@atlaskit/section-message": "^8.5.0",
42
42
  "@atlaskit/tabs": "^18.1.0",
43
43
  "@atlaskit/textfield": "^8.0.0",
44
- "@atlaskit/tmp-editor-statsig": "^9.26.0",
44
+ "@atlaskit/tmp-editor-statsig": "^10.0.0",
45
45
  "@babel/runtime": "^7.0.0",
46
46
  "react-intl-next": "npm:react-intl@^5.18.1"
47
47
  },
48
48
  "peerDependencies": {
49
- "@atlaskit/editor-common": "^107.20.0",
49
+ "@atlaskit/editor-common": "^107.25.0",
50
50
  "@atlaskit/tokens": "^6.0.0",
51
51
  "react": "^18.2.0",
52
52
  "react-dom": "^18.2.0"