@atlaskit/editor-core 188.0.12 → 188.1.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.
Files changed (91) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/plugins/annotation/toolbar.js +5 -23
  3. package/dist/cjs/plugins/code-block/index.js +3 -3
  4. package/dist/cjs/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.js +2 -2
  5. package/dist/cjs/plugins/help-dialog/index.js +3 -3
  6. package/dist/cjs/plugins/help-dialog/ui/index.js +21 -26
  7. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +4 -4
  8. package/dist/cjs/plugins/media/index.js +12 -6
  9. package/dist/cjs/plugins/media/utils/media-common.js +7 -109
  10. package/dist/cjs/plugins/media/utils/media-single.js +7 -68
  11. package/dist/cjs/plugins/panel/index.js +13 -13
  12. package/dist/cjs/plugins/paste/handlers.js +4 -4
  13. package/dist/cjs/plugins/paste/plugins/media.js +181 -0
  14. package/dist/cjs/plugins/paste/pm-plugins/analytics.js +2 -2
  15. package/dist/cjs/plugins/paste/pm-plugins/main.js +6 -7
  16. package/dist/cjs/plugins/undo-redo/ui/ToolbarUndoRedo/index.js +3 -3
  17. package/dist/cjs/ui/Alignment/index.js +1 -1
  18. package/dist/cjs/version-wrapper.js +1 -1
  19. package/dist/es2019/plugins/annotation/toolbar.js +2 -18
  20. package/dist/es2019/plugins/code-block/index.js +3 -3
  21. package/dist/es2019/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.js +1 -1
  22. package/dist/es2019/plugins/help-dialog/index.js +1 -1
  23. package/dist/es2019/plugins/help-dialog/ui/index.js +8 -13
  24. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +1 -1
  25. package/dist/es2019/plugins/media/index.js +13 -6
  26. package/dist/es2019/plugins/media/utils/media-common.js +2 -107
  27. package/dist/es2019/plugins/media/utils/media-single.js +6 -72
  28. package/dist/es2019/plugins/panel/index.js +13 -13
  29. package/dist/es2019/plugins/paste/handlers.js +4 -4
  30. package/dist/es2019/plugins/paste/plugins/media.js +176 -0
  31. package/dist/es2019/plugins/paste/pm-plugins/analytics.js +2 -2
  32. package/dist/es2019/plugins/paste/pm-plugins/main.js +3 -4
  33. package/dist/es2019/plugins/undo-redo/ui/ToolbarUndoRedo/index.js +3 -3
  34. package/dist/es2019/ui/Alignment/index.js +1 -1
  35. package/dist/es2019/version-wrapper.js +1 -1
  36. package/dist/esm/plugins/annotation/toolbar.js +2 -18
  37. package/dist/esm/plugins/code-block/index.js +3 -3
  38. package/dist/esm/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.js +1 -1
  39. package/dist/esm/plugins/help-dialog/index.js +1 -1
  40. package/dist/esm/plugins/help-dialog/ui/index.js +8 -13
  41. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +1 -1
  42. package/dist/esm/plugins/media/index.js +13 -6
  43. package/dist/esm/plugins/media/utils/media-common.js +2 -106
  44. package/dist/esm/plugins/media/utils/media-single.js +6 -66
  45. package/dist/esm/plugins/panel/index.js +13 -13
  46. package/dist/esm/plugins/paste/handlers.js +4 -4
  47. package/dist/esm/plugins/paste/plugins/media.js +172 -0
  48. package/dist/esm/plugins/paste/pm-plugins/analytics.js +2 -2
  49. package/dist/esm/plugins/paste/pm-plugins/main.js +3 -4
  50. package/dist/esm/plugins/undo-redo/ui/ToolbarUndoRedo/index.js +3 -3
  51. package/dist/esm/ui/Alignment/index.js +1 -1
  52. package/dist/esm/version-wrapper.js +1 -1
  53. package/dist/types/labs/next/presets/default.d.ts +6 -0
  54. package/dist/types/plugins/annotation/toolbar.d.ts +0 -17
  55. package/dist/types/plugins/help-dialog/index.d.ts +2 -15
  56. package/dist/types/plugins/media/next-plugin-type.d.ts +4 -0
  57. package/dist/types/plugins/media/utils/media-common.d.ts +2 -10
  58. package/dist/types/plugins/media/utils/media-single.d.ts +2 -4
  59. package/dist/types/plugins/paste/handlers.d.ts +2 -2
  60. package/dist/types/plugins/paste/index.d.ts +5 -2
  61. package/dist/types/plugins/paste/plugins/media.d.ts +12 -0
  62. package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +2 -2
  63. package/dist/types/plugins/paste/pm-plugins/main.d.ts +2 -2
  64. package/dist/types/ui/Alignment/index.d.ts +2 -2
  65. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  66. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  67. package/dist/types-ts4.5/labs/next/presets/default.d.ts +6 -0
  68. package/dist/types-ts4.5/plugins/annotation/toolbar.d.ts +0 -17
  69. package/dist/types-ts4.5/plugins/help-dialog/index.d.ts +2 -15
  70. package/dist/types-ts4.5/plugins/media/next-plugin-type.d.ts +4 -0
  71. package/dist/types-ts4.5/plugins/media/utils/media-common.d.ts +2 -10
  72. package/dist/types-ts4.5/plugins/media/utils/media-single.d.ts +2 -4
  73. package/dist/types-ts4.5/plugins/paste/handlers.d.ts +2 -2
  74. package/dist/types-ts4.5/plugins/paste/index.d.ts +5 -2
  75. package/dist/types-ts4.5/plugins/paste/plugins/media.d.ts +12 -0
  76. package/dist/types-ts4.5/plugins/paste/pm-plugins/analytics.d.ts +2 -2
  77. package/dist/types-ts4.5/plugins/paste/pm-plugins/main.d.ts +2 -2
  78. package/dist/types-ts4.5/ui/Alignment/index.d.ts +2 -2
  79. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  80. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  81. package/package.json +6 -5
  82. package/dist/cjs/plugins/undo-redo/messages.js +0 -19
  83. package/dist/cjs/ui/Alignment/messages.js +0 -24
  84. package/dist/es2019/plugins/undo-redo/messages.js +0 -13
  85. package/dist/es2019/ui/Alignment/messages.js +0 -18
  86. package/dist/esm/plugins/undo-redo/messages.js +0 -13
  87. package/dist/esm/ui/Alignment/messages.js +0 -18
  88. package/dist/types/plugins/undo-redo/messages.d.ts +0 -12
  89. package/dist/types/ui/Alignment/messages.d.ts +0 -17
  90. package/dist/types-ts4.5/plugins/undo-redo/messages.d.ts +0 -12
  91. package/dist/types-ts4.5/ui/Alignment/messages.d.ts +0 -17
@@ -6,7 +6,7 @@ import { addLinkMetadata } from '@atlaskit/editor-common/card';
6
6
  import { mapChildren } from '../../../utils/slice';
7
7
  import { getExtensionAutoConvertersFromProvider } from '@atlaskit/editor-common/extensions';
8
8
  import { isPastedFile as isPastedFileFromEvent } from '@atlaskit/editor-common/paste';
9
- import { transformSliceForMedia } from '../../media/utils/media-single';
9
+ import { transformSliceForMedia, transformSliceToCorrectMediaWrapper, unwrapNestedMediaElements } from '../plugins/media';
10
10
  import { escapeLinks, htmlContainsSingleFile, isPastedFromWord, isPastedFromExcel, htmlHasInvalidLinkTags, removeDuplicateInvalidLinks, transformUnsupportedBlockCardToInline } from '../util';
11
11
  import { linkifyContent } from '@atlaskit/editor-common/utils';
12
12
  import { transformSliceNestedExpandToExpand } from '../../expand/utils';
@@ -16,7 +16,6 @@ import { createPasteMeasurePayload, getContentNodeTypes, handlePasteAsPlainTextW
16
16
  import { ACTION, analyticsPluginKey, INPUT_METHOD, PasteTypes } from '../../analytics';
17
17
  import { isInsideBlockQuote, insideTable, measurements } from '../../../utils';
18
18
  import { measureRender } from '@atlaskit/editor-common/utils';
19
- import { transformSliceToCorrectMediaWrapper, unwrapNestedMediaElements } from '../../media/utils/media-common';
20
19
  import { upgradeTextToLists, splitParagraphs } from '../commands';
21
20
  import { md } from '@atlaskit/editor-common/paste';
22
21
  import { transformSliceToDecisionList } from '../../tasks-and-decisions/utils';
@@ -77,7 +76,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
77
76
  }
78
77
  },
79
78
  handlePaste(view, rawEvent, slice) {
80
- var _text, _analyticsPlugin$perf, _analyticsPlugin$perf2, _schema$nodes, _schema$nodes2, _schema$nodes3, _pluginInjectionApi$a;
79
+ var _text, _analyticsPlugin$perf, _analyticsPlugin$perf2, _schema$nodes, _schema$nodes2, _schema$nodes3, _pluginInjectionApi$m;
81
80
  const event = rawEvent;
82
81
  if (!event.clipboardData) {
83
82
  return false;
@@ -246,7 +245,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
246
245
  if (handleCodeBlockWithAnalytics(view, event, slice, text)(state, dispatch)) {
247
246
  return true;
248
247
  }
249
- if (handleMediaSingleWithAnalytics(view, event, slice, isPastedFile ? PasteTypes.binary : PasteTypes.richText, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(state, dispatch, view)) {
248
+ if (handleMediaSingleWithAnalytics(view, event, slice, isPastedFile ? PasteTypes.binary : PasteTypes.richText, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$m = pluginInjectionApi.media) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.actions.insertMediaAsMediaSingle)(state, dispatch, view)) {
250
249
  return true;
251
250
  }
252
251
  if (handleSelectedTableWithAnalytics(view, event, slice)(state, dispatch)) {
@@ -7,7 +7,7 @@ import RedoIcon from '@atlaskit/icon/glyph/redo';
7
7
  import { undo as undoKeymap, redo as redoKeymap, ToolTipContent, tooltip } from '../../../../keymaps';
8
8
  import { separatorStyles, buttonGroupStyle } from '@atlaskit/editor-common/styles';
9
9
  import ToolbarButton, { TOOLBAR_BUTTON } from '../../../../ui/ToolbarButton';
10
- import { messages } from '../../messages';
10
+ import { undoRedoMessages } from '@atlaskit/editor-common/messages';
11
11
  import { createTypeAheadTools } from '../../../type-ahead/api';
12
12
  import { undoFromToolbar, redoFromToolbar } from '../../commands';
13
13
  import { getAriaKeyshortcuts } from '@atlaskit/editor-common/keymaps';
@@ -48,8 +48,8 @@ export class ToolbarUndoRedo extends PureComponent {
48
48
  const handleRedo = () => {
49
49
  forceFocus(editorView)(redoFromToolbar);
50
50
  };
51
- const labelUndo = formatMessage(messages.undo);
52
- const labelRedo = formatMessage(messages.redo);
51
+ const labelUndo = formatMessage(undoRedoMessages.undo);
52
+ const labelRedo = formatMessage(undoRedoMessages.redo);
53
53
  const {
54
54
  canUndo,
55
55
  canRedo
@@ -4,7 +4,7 @@ import { PureComponent } from 'react';
4
4
  import { injectIntl } from 'react-intl-next';
5
5
  import { IconMap } from '../../plugins/alignment/ui/ToolbarAlignment/icon-map';
6
6
  import AlignmentButton from './AlignmentButton';
7
- import { alignmentMessages } from './messages';
7
+ import { alignmentMessages } from '@atlaskit/editor-common/messages';
8
8
  import { alignmentWrapper } from './styles';
9
9
  import { alignLeft } from '../../keymaps';
10
10
  const alignmentOptions = [{
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "188.0.12";
2
+ export const version = "188.1.0";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import { defineMessages } from 'react-intl-next';
3
2
  import CommentIcon from '@atlaskit/icon/glyph/comment';
4
3
  // AFP-2532 TODO: Fix automatic suppressions below
5
4
  // eslint-disable-next-line @atlassian/tangerine/import/entry-points
@@ -7,23 +6,8 @@ import { addInlineComment, ToolTipContent } from '../../keymaps';
7
6
  import { setInlineCommentDraftState } from './commands';
8
7
  import { AnnotationTestIds, AnnotationSelectionType } from './types';
9
8
  import { isSelectionValid } from './utils';
10
- export var annotationMessages = defineMessages({
11
- createComment: {
12
- id: 'fabric.editor.createComment',
13
- defaultMessage: 'Comment',
14
- description: 'Create/add an inline comment based on the users selection'
15
- },
16
- createCommentInvalid: {
17
- id: 'fabric.editor.createCommentInvalid',
18
- defaultMessage: 'You can only comment on text and headings',
19
- description: 'Error message to communicate to the user they can only do the current action in certain contexts'
20
- },
21
- toolbar: {
22
- id: 'fabric.editor.annotationToolbar',
23
- defaultMessage: 'Annotation toolbar',
24
- description: 'A label for a toolbar (UI element) that creates annotations/comments in the document'
25
- }
26
- });
9
+ import { annotationMessages } from '@atlaskit/editor-common/messages';
10
+
27
11
  /**
28
12
  * Returns the coordintes at the bottom the selection.
29
13
  */
@@ -10,7 +10,7 @@ import ideUX from './pm-plugins/ide-ux';
10
10
  import { codeBlockCopySelectionPlugin } from './pm-plugins/codeBlockCopySelectionPlugin';
11
11
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
12
12
  import { IconCode } from '@atlaskit/editor-common/quick-insert';
13
- import { messages } from '@atlaskit/editor-plugin-block-type/messages';
13
+ import { blockTypeMessages } from '@atlaskit/editor-common/messages';
14
14
  import refreshBrowserSelectionOnChange from './refresh-browser-selection';
15
15
  import { createInsertCodeBlockTransaction, insertCodeBlockWithAnalytics } from './actions';
16
16
  import { createCodeBlockInputRule } from './pm-plugins/input-rule';
@@ -80,8 +80,8 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
80
80
  var formatMessage = _ref5.formatMessage;
81
81
  return [{
82
82
  id: 'codeblock',
83
- title: formatMessage(messages.codeblock),
84
- description: formatMessage(messages.codeblockDescription),
83
+ title: formatMessage(blockTypeMessages.codeblock),
84
+ description: formatMessage(blockTypeMessages.codeblockDescription),
85
85
  keywords: ['code block'],
86
86
  priority: 700,
87
87
  keyshortcut: '```',
@@ -2,7 +2,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
4
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
5
- import { getSelectedNodeOrNodeParentByNodeType } from '@atlaskit/editor-plugin-copy-button/utils';
5
+ import { getSelectedNodeOrNodeParentByNodeType } from '@atlaskit/editor-common/copy-button';
6
6
  export var copySelectionPluginKey = new PluginKey('codeBlockCopySelectionPlugin');
7
7
  function getSelectionDecorationStartAndEnd(_ref) {
8
8
  var state = _ref.state,
@@ -8,7 +8,7 @@ import { bindKeymapWithCommand, openHelp, tooltip } from '@atlaskit/editor-commo
8
8
  import { HelpDialogLoader } from './ui/HelpDialogLoader';
9
9
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
10
10
  import QuestionCircleIcon from '@atlaskit/icon/glyph/question-circle';
11
- import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
11
+ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
12
12
  import { openHelpCommand } from './commands';
13
13
  import { pluginKey } from './plugin-key';
14
14
  export function createPlugin(dispatch, imageEnabled) {
@@ -10,13 +10,8 @@ import AkModalDialog, { ModalTransition, useModal } from '@atlaskit/modal-dialog
10
10
  import { header, footer, contentWrapper, line, content, row, codeSm, codeMd, codeLg, title, column, dialogHeader } from './styles';
11
11
  import { navToFloatingToolbar, navToEditorToolbar, toggleBold, toggleItalic, toggleUnderline, toggleStrikethrough, toggleSubscript, toggleSuperscript, toggleHeading1, toggleHeading2, toggleHeading3, toggleHeading4, toggleHeading5, toggleHeading6, toggleOrderedList, insertRule, addLink, setNormalText, alignLeft, clearFormatting, undo, redo, pastePlainText, addInlineComment, toggleTaskItemCheckbox, toggleCode, openHelp, toggleBulletList, toggleBlockQuote } from '@atlaskit/editor-common/keymaps';
12
12
  import ToolbarButton from '../../../ui/ToolbarButton';
13
- import { toolbarMessages, listMessages } from '@atlaskit/editor-common/messages';
14
- import { messages as insertBlockMessages } from '../../insert-block/ui/ToolbarInsertBlock/messages';
15
- import { messages as blockTypeMessages } from '@atlaskit/editor-plugin-block-type/messages';
16
- import { messages as undoRedoMessages } from '../../undo-redo/messages';
17
- import { alignmentMessages } from '../../../ui/Alignment/messages';
13
+ import { alignmentMessages, annotationMessages, listMessages, toolbarInsertBlockMessages, toolbarMessages, undoRedoMessages, blockTypeMessages } from '@atlaskit/editor-common/messages';
18
14
  import { closeHelpCommand } from '../commands';
19
- import { annotationMessages } from '../../annotation/toolbar';
20
15
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
21
16
  var messages = defineMessages({
22
17
  editorHelp: {
@@ -267,7 +262,7 @@ export var formatting = function formatting(_ref2) {
267
262
  }, "```"));
268
263
  }
269
264
  }, {
270
- name: formatMessage(insertBlockMessages.horizontalRule),
265
+ name: formatMessage(toolbarInsertBlockMessages.horizontalRule),
271
266
  type: 'rule',
272
267
  keymap: function keymap() {
273
268
  return insertRule;
@@ -278,7 +273,7 @@ export var formatting = function formatting(_ref2) {
278
273
  }, "---"));
279
274
  }
280
275
  }, {
281
- name: formatMessage(insertBlockMessages.link),
276
+ name: formatMessage(toolbarInsertBlockMessages.link),
282
277
  type: 'link',
283
278
  keymap: function keymap() {
284
279
  return addLink;
@@ -286,7 +281,7 @@ export var formatting = function formatting(_ref2) {
286
281
  autoFormatting: function autoFormatting() {
287
282
  return jsx("span", null, jsx("span", {
288
283
  css: codeLg
289
- }, "[", jsx(FormattedMessage, insertBlockMessages.link), "](http://a.com)"));
284
+ }, "[", jsx(FormattedMessage, toolbarInsertBlockMessages.link), "](http://a.com)"));
290
285
  }
291
286
  }, {
292
287
  name: formatMessage(toolbarMessages.code),
@@ -300,7 +295,7 @@ export var formatting = function formatting(_ref2) {
300
295
  }, "`", jsx(FormattedMessage, toolbarMessages.code), "`"));
301
296
  }
302
297
  }, {
303
- name: formatMessage(insertBlockMessages.action),
298
+ name: formatMessage(toolbarInsertBlockMessages.action),
304
299
  type: 'taskItem',
305
300
  autoFormatting: function autoFormatting() {
306
301
  return jsx("span", null, jsx("span", {
@@ -310,7 +305,7 @@ export var formatting = function formatting(_ref2) {
310
305
  }, "Space"));
311
306
  }
312
307
  }, {
313
- name: formatMessage(insertBlockMessages.decision),
308
+ name: formatMessage(toolbarInsertBlockMessages.decision),
314
309
  type: 'decisionItem',
315
310
  autoFormatting: function autoFormatting() {
316
311
  return jsx("span", null, jsx("span", {
@@ -320,7 +315,7 @@ export var formatting = function formatting(_ref2) {
320
315
  }, "Space"));
321
316
  }
322
317
  }, {
323
- name: formatMessage(insertBlockMessages.emoji),
318
+ name: formatMessage(toolbarInsertBlockMessages.emoji),
324
319
  type: 'emoji',
325
320
  autoFormatting: function autoFormatting() {
326
321
  return jsx("span", null, jsx("span", {
@@ -328,7 +323,7 @@ export var formatting = function formatting(_ref2) {
328
323
  }, ":"));
329
324
  }
330
325
  }, {
331
- name: formatMessage(insertBlockMessages.mention),
326
+ name: formatMessage(toolbarInsertBlockMessages.mention),
332
327
  type: 'mention',
333
328
  autoFormatting: function autoFormatting() {
334
329
  return jsx("span", null, jsx("span", {
@@ -6,7 +6,7 @@ import React from 'react';
6
6
  import memoize from 'lodash/memoize';
7
7
  import memoizeOne from 'memoize-one';
8
8
  import { messages } from './messages';
9
- import { messages as blockTypeMessages } from '@atlaskit/editor-plugin-block-type/messages';
9
+ import { blockTypeMessages } from '@atlaskit/editor-common/messages';
10
10
  import { ToolTipContent } from '../../../../keymaps';
11
11
  import { sortItems } from './sort-items';
12
12
  import { action, link, media, mention, emoji, table, layout, codeblock, panel, blockquote, decision, horizontalrule, expand, date, placeholder, status, more, imageUpload } from './item';
@@ -23,6 +23,7 @@ import { ReactMediaNode } from './nodeviews/mediaNodeView';
23
23
  import { ReactMediaInlineNode } from './nodeviews/mediaInline';
24
24
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
25
25
  import { stateKey } from './pm-plugins/plugin-key';
26
+ import { insertMediaAsMediaSingle as _insertMediaAsMediaSingle } from './utils/media-single';
26
27
  export { insertMediaSingleNode } from './utils/media-single';
27
28
  var MediaPickerFunctionalComponent = function MediaPickerFunctionalComponent(_ref) {
28
29
  var api = _ref.api,
@@ -54,6 +55,12 @@ var mediaPlugin = function mediaPlugin(_ref2) {
54
55
  }
55
56
  return stateKey.getState(editorState) || null;
56
57
  },
58
+ actions: {
59
+ insertMediaAsMediaSingle: function insertMediaAsMediaSingle(view, node, inputMethod) {
60
+ var _api$analytics;
61
+ return _insertMediaAsMediaSingle(view, node, inputMethod, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
62
+ }
63
+ },
57
64
  nodes: function nodes() {
58
65
  var _ref3 = options || {},
59
66
  _ref3$allowMediaGroup = _ref3.allowMediaGroup,
@@ -134,8 +141,8 @@ var mediaPlugin = function mediaPlugin(_ref2) {
134
141
  }, {
135
142
  name: 'mediaKeymap',
136
143
  plugin: function plugin() {
137
- var _api$analytics;
138
- return keymapPlugin(options, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
144
+ var _api$analytics2;
145
+ return keymapPlugin(options, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions);
139
146
  }
140
147
  }];
141
148
  if (options && options.allowMediaSingle) {
@@ -155,9 +162,9 @@ var mediaPlugin = function mediaPlugin(_ref2) {
155
162
  pmPlugins.push({
156
163
  name: 'mediaAltTextKeymap',
157
164
  plugin: function plugin(_ref6) {
158
- var _api$analytics2;
165
+ var _api$analytics3;
159
166
  var schema = _ref6.schema;
160
- return keymapMediaAltTextPlugin(schema, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions);
167
+ return keymapMediaAltTextPlugin(schema, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
161
168
  }
162
169
  });
163
170
  }
@@ -240,11 +247,11 @@ var mediaPlugin = function mediaPlugin(_ref2) {
240
247
  return /*#__PURE__*/React.createElement(IconImages, null);
241
248
  },
242
249
  action: function action(insert, state) {
243
- var _api$analytics3;
250
+ var _api$analytics4;
244
251
  var pluginState = pluginKey.getState(state);
245
252
  pluginState === null || pluginState === void 0 || pluginState.showMediaPicker();
246
253
  var tr = insert('');
247
- api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 || _api$analytics3.actions.attachAnalyticsEvent({
254
+ api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 || _api$analytics4.actions.attachAnalyticsEvent({
248
255
  action: ACTION.OPENED,
249
256
  actionSubject: ACTION_SUBJECT.PICKER,
250
257
  actionSubjectId: ACTION_SUBJECT_ID.PICKER_CLOUD,
@@ -1,11 +1,8 @@
1
+ import { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, endPositionOfParent, GapCursorSelection, startPositionOfParent } from '@atlaskit/editor-common/selection';
2
+ import { createNewParagraphBelow, createParagraphNear } from '@atlaskit/editor-common/utils';
1
3
  import { deleteSelection, splitBlock } from '@atlaskit/editor-prosemirror/commands';
2
4
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
5
  import { findPositionOfNodeBefore } from '@atlaskit/editor-prosemirror/utils';
4
- import { createParagraphNear, createNewParagraphBelow } from '@atlaskit/editor-common/utils';
5
- import { mapSlice } from '@atlaskit/editor-common/utils';
6
- import { walkUpTreeUntil, removeNestedEmptyEls, unwrap } from '@atlaskit/editor-common/utils';
7
- import { isImage } from './is-image';
8
- import { GapCursorSelection, atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, endPositionOfParent, startPositionOfParent } from '@atlaskit/editor-common/selection';
9
6
  import { isMediaBlobUrl } from '@atlaskit/media-client';
10
7
  var isTemporary = function isTemporary(id) {
11
8
  return id.indexOf('temporary:') === 0;
@@ -164,107 +161,6 @@ export var copyOptionalAttrsFromMediaState = function copyOptionalAttrsFromMedia
164
161
  }
165
162
  });
166
163
  };
167
- export var transformSliceToCorrectMediaWrapper = function transformSliceToCorrectMediaWrapper(slice, schema) {
168
- var _schema$nodes = schema.nodes,
169
- mediaGroup = _schema$nodes.mediaGroup,
170
- mediaSingle = _schema$nodes.mediaSingle,
171
- media = _schema$nodes.media;
172
- return mapSlice(slice, function (node, parent) {
173
- if (!parent && node.type === media) {
174
- if (mediaSingle && (isImage(node.attrs.__fileMimeType) || node.attrs.type === 'external')) {
175
- return mediaSingle.createChecked({}, node);
176
- } else {
177
- return mediaGroup.createChecked({}, [node]);
178
- }
179
- }
180
- return node;
181
- });
182
- };
183
-
184
- /**
185
- * Check base styles to see if an element will be invisible when rendered in a document.
186
- * @param element
187
- */
188
- var isElementInvisible = function isElementInvisible(element) {
189
- return element.style.opacity === '0' || element.style.display === 'none' || element.style.visibility === 'hidden';
190
- };
191
- var VALID_TAGS_CONTAINER = ['DIV', 'TD'];
192
- function canContainImage(element) {
193
- if (!element) {
194
- return false;
195
- }
196
- return VALID_TAGS_CONTAINER.indexOf(element.tagName) !== -1;
197
- }
198
-
199
- /**
200
- * Given a html string, we attempt to hoist any nested `<img>` tags,
201
- * not directly wrapped by a `<div>` as ProseMirror no-op's
202
- * on those scenarios.
203
- * @param html
204
- */
205
- export var unwrapNestedMediaElements = function unwrapNestedMediaElements(html) {
206
- var parser = new DOMParser();
207
- var doc = parser.parseFromString(html, 'text/html');
208
- var wrapper = doc.body;
209
-
210
- // Remove Google Doc's wrapper <b> el
211
- var docsWrapper = wrapper.querySelector('b[id^="docs-internal-guid-"]');
212
- if (docsWrapper) {
213
- unwrap(wrapper, docsWrapper);
214
- }
215
- var imageTags = wrapper.querySelectorAll('img');
216
- if (!imageTags.length) {
217
- return html;
218
- }
219
- imageTags.forEach(function (imageTag) {
220
- // Capture the immediate parent, we may remove the media from here later.
221
- var mediaParent = imageTag.parentElement;
222
- if (!mediaParent) {
223
- return;
224
- }
225
-
226
- // If either the parent or the image itself contains styles that would make
227
- // them invisible on copy, dont paste them.
228
- if (isElementInvisible(mediaParent) || isElementInvisible(imageTag)) {
229
- mediaParent.removeChild(imageTag);
230
- return;
231
- }
232
-
233
- // If its wrapped by a valid container we assume its safe to bypass.
234
- // ProseMirror should handle these cases properly.
235
- if (canContainImage(mediaParent) || mediaParent instanceof HTMLSpanElement && mediaParent.closest('[class*="emoji-common"]')) {
236
- return;
237
- }
238
-
239
- // Find the top most element that the parent has a valid container for the image.
240
- // Stop just before found the wrapper
241
- var insertBeforeElement = walkUpTreeUntil(mediaParent, function (element) {
242
- // If is at the top just use this element as reference
243
- if (element.parentElement === wrapper) {
244
- return true;
245
- }
246
- return canContainImage(element.parentElement);
247
- });
248
-
249
- // Here we try to insert the media right after its top most valid parent element
250
- // Unless its the last element in our structure then we will insert above it.
251
- if (insertBeforeElement && insertBeforeElement.parentElement) {
252
- // Insert as close as possible to the most closest valid element index in the tree.
253
- insertBeforeElement.parentElement.insertBefore(imageTag, insertBeforeElement.nextElementSibling || insertBeforeElement);
254
-
255
- // Attempt to clean up lines left behind by the image
256
- mediaParent.innerText = mediaParent.innerText.trim();
257
- // Walk up and delete empty elements left over after removing the image tag
258
- removeNestedEmptyEls(mediaParent);
259
- }
260
- });
261
-
262
- // If last child is a hardbreak we don't want it
263
- if (wrapper.lastElementChild && wrapper.lastElementChild.tagName === 'BR') {
264
- wrapper.removeChild(wrapper.lastElementChild);
265
- }
266
- return wrapper.innerHTML;
267
- };
268
164
  export var getMediaNodeFromSelection = function getMediaNodeFromSelection(state) {
269
165
  if (!isSelectionMediaSingleNode(state)) {
270
166
  return null;
@@ -1,17 +1,16 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
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
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 { getMaxWidthForNestedNodeNext, getMediaSingleInitialWidth, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
5
+ import { checkNodeDown, isEmptyParagraph } from '@atlaskit/editor-common/utils';
4
6
  import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
5
- import { safeInsert as pmSafeInsert, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
6
- import { checkNodeDown, isEmptyParagraph, mapSlice } from '@atlaskit/editor-common/utils';
7
- import { getMediaSingleInitialWidth, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH, getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
8
- import { copyOptionalAttrsFromMediaState } from '../utils/media-common';
9
- import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
7
+ import { safeInsert as pmSafeInsert } from '@atlaskit/editor-prosemirror/utils';
8
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
10
9
  import { safeInsert, shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
11
- import { isImage } from './is-image';
10
+ import { copyOptionalAttrsFromMediaState } from '../utils/media-common';
12
11
  import { atTheBeginningOfBlock } from '@atlaskit/editor-common/selection';
13
- import { getRandomHex } from '@atlaskit/media-common';
14
12
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
13
+ import { isImage } from './is-image';
15
14
  var getInsertMediaAnalytics = function getInsertMediaAnalytics(inputMethod, fileExtension) {
16
15
  return {
17
16
  action: ACTION.INSERTED,
@@ -160,65 +159,6 @@ export var createMediaSingleNode = function createMediaSingleNode(schema, collec
160
159
  return mediaSingle.createChecked(extendedMediaSingleAttrs, mediaNode);
161
160
  };
162
161
  };
163
- export function transformSliceForMedia(slice, schema) {
164
- var _schema$nodes2 = schema.nodes,
165
- mediaSingle = _schema$nodes2.mediaSingle,
166
- layoutSection = _schema$nodes2.layoutSection,
167
- table = _schema$nodes2.table,
168
- bulletList = _schema$nodes2.bulletList,
169
- orderedList = _schema$nodes2.orderedList,
170
- media = _schema$nodes2.media,
171
- mediaInline = _schema$nodes2.mediaInline,
172
- expand = _schema$nodes2.expand,
173
- nestedExpand = _schema$nodes2.nestedExpand;
174
- return function (selection) {
175
- var newSlice = slice;
176
- if (hasParentNodeOfType([layoutSection, table, bulletList, orderedList, expand, nestedExpand])(selection)) {
177
- newSlice = mapSlice(newSlice, function (node) {
178
- var extendedOrLegacyAttrs = getBooleanFF('platform.editor.media.extended-resize-experience') ? {
179
- layout: node.attrs.layout,
180
- widthType: node.attrs.widthType,
181
- width: node.attrs.width
182
- } : {
183
- layout: node.attrs.layout
184
- };
185
- var attrs = {};
186
- if (hasParentNodeOfType([layoutSection, table])(selection)) {
187
- // Supports layouts
188
- attrs = _objectSpread({}, extendedOrLegacyAttrs);
189
- } else if (hasParentNodeOfType([bulletList, orderedList, expand, nestedExpand])(selection)) {
190
- // does not support other layouts
191
- attrs = _objectSpread(_objectSpread({}, extendedOrLegacyAttrs), {}, {
192
- layout: 'center'
193
- });
194
- }
195
- return node.type.name === 'mediaSingle' ? mediaSingle.createChecked(attrs, node.content, node.marks) : node;
196
- });
197
- }
198
- var __mediaTraceId = getRandomHex(8);
199
- newSlice = mapSlice(newSlice, function (node) {
200
- // This logic is duplicated in editor-plugin-ai where external images can be inserted
201
- // from external sources through the use of AI. The editor-plugin-ai package is avoiding
202
- // sharing dependencies with editor-core to support products using it with various versions
203
- // of editor packages.
204
- // The duplication is in the following file:
205
- // packages/editor/editor-plugin-ai/src/prebuilt/content-transformers/markdown-to-pm/markdown-transformer.ts
206
- if (node.type.name === 'media') {
207
- return media.createChecked(_objectSpread(_objectSpread({}, node.attrs), {}, {
208
- __external: node.attrs.type === 'external',
209
- __mediaTraceId: node.attrs.type === 'external' ? null : __mediaTraceId
210
- }), node.content, node.marks);
211
- }
212
- if (node.type.name === 'mediaInline') {
213
- return mediaInline.createChecked(_objectSpread(_objectSpread({}, node.attrs), {}, {
214
- __mediaTraceId: __mediaTraceId
215
- }), node.content, node.marks);
216
- }
217
- return node;
218
- });
219
- return newSlice;
220
- };
221
- }
222
162
  export function isCaptionNode(editorView) {
223
163
  var $from = editorView.state.selection.$from;
224
164
  var immediateWrapperParentNode = editorView.state.doc.nodeAt($from.before(Math.max($from.depth, 1)));
@@ -6,7 +6,7 @@ import keymap from './pm-plugins/keymaps';
6
6
  import { addAnalytics, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD, EVENT_TYPE } from '../analytics';
7
7
  import { IconPanel, IconPanelNote, IconPanelSuccess, IconPanelWarning, IconPanelError } from '@atlaskit/editor-common/quick-insert';
8
8
  import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
9
- import { messages } from '@atlaskit/editor-plugin-block-type/messages';
9
+ import { blockTypeMessages } from '@atlaskit/editor-common/messages';
10
10
  import { IconCustomPanel } from '@atlaskit/editor-common/quick-insert';
11
11
  import { T50 } from '@atlaskit/theme/colors';
12
12
  import { insertPanelWithAnalytics } from './actions';
@@ -49,9 +49,9 @@ var panelPlugin = function panelPlugin(_ref) {
49
49
  var formatMessage = _ref3.formatMessage;
50
50
  var quickInsertOptions = [{
51
51
  id: 'infopanel',
52
- title: formatMessage(messages.infoPanel),
52
+ title: formatMessage(blockTypeMessages.infoPanel),
53
53
  keywords: ['panel'],
54
- description: formatMessage(messages.infoPanelDescription),
54
+ description: formatMessage(blockTypeMessages.infoPanelDescription),
55
55
  priority: 800,
56
56
  icon: function icon() {
57
57
  return /*#__PURE__*/React.createElement(IconPanel, null);
@@ -66,8 +66,8 @@ var panelPlugin = function panelPlugin(_ref) {
66
66
  }
67
67
  }, {
68
68
  id: 'notepanel',
69
- title: formatMessage(messages.notePanel),
70
- description: formatMessage(messages.notePanelDescription),
69
+ title: formatMessage(blockTypeMessages.notePanel),
70
+ description: formatMessage(blockTypeMessages.notePanelDescription),
71
71
  priority: 1000,
72
72
  icon: function icon() {
73
73
  return /*#__PURE__*/React.createElement(IconPanelNote, null);
@@ -82,8 +82,8 @@ var panelPlugin = function panelPlugin(_ref) {
82
82
  }
83
83
  }, {
84
84
  id: 'successpanel',
85
- title: formatMessage(messages.successPanel),
86
- description: formatMessage(messages.successPanelDescription),
85
+ title: formatMessage(blockTypeMessages.successPanel),
86
+ description: formatMessage(blockTypeMessages.successPanelDescription),
87
87
  keywords: ['tip'],
88
88
  priority: 1000,
89
89
  icon: function icon() {
@@ -99,8 +99,8 @@ var panelPlugin = function panelPlugin(_ref) {
99
99
  }
100
100
  }, {
101
101
  id: 'warningpanel',
102
- title: formatMessage(messages.warningPanel),
103
- description: formatMessage(messages.warningPanelDescription),
102
+ title: formatMessage(blockTypeMessages.warningPanel),
103
+ description: formatMessage(blockTypeMessages.warningPanelDescription),
104
104
  priority: 1000,
105
105
  icon: function icon() {
106
106
  return /*#__PURE__*/React.createElement(IconPanelWarning, null);
@@ -115,8 +115,8 @@ var panelPlugin = function panelPlugin(_ref) {
115
115
  }
116
116
  }, {
117
117
  id: 'errorpanel',
118
- title: formatMessage(messages.errorPanel),
119
- description: formatMessage(messages.errorPanelDescription),
118
+ title: formatMessage(blockTypeMessages.errorPanel),
119
+ description: formatMessage(blockTypeMessages.errorPanelDescription),
120
120
  priority: 1000,
121
121
  icon: function icon() {
122
122
  return /*#__PURE__*/React.createElement(IconPanelError, null);
@@ -133,8 +133,8 @@ var panelPlugin = function panelPlugin(_ref) {
133
133
  if (options.allowCustomPanel && options.allowCustomPanelEdit) {
134
134
  quickInsertOptions.push({
135
135
  id: 'custompanel',
136
- title: formatMessage(messages.customPanel),
137
- description: formatMessage(messages.customPanelDescription),
136
+ title: formatMessage(blockTypeMessages.customPanel),
137
+ description: formatMessage(blockTypeMessages.customPanelDescription),
138
138
  priority: 1000,
139
139
  icon: function icon() {
140
140
  return /*#__PURE__*/React.createElement(IconCustomPanel, null);
@@ -14,10 +14,9 @@ import uuid from 'uuid/v4';
14
14
  import { replaceSelectedTable } from '@atlaskit/editor-tables/utils';
15
15
  import { compose, insideTable, isParagraph, isText, isLinkMark, insideTableCell, isInListItem } from '../../utils';
16
16
  import { mapSlice } from '../../utils/slice';
17
- import { INPUT_METHOD } from '../analytics';
17
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
18
18
  import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
19
19
  import { runMacroAutoConvert } from '../macro';
20
- import { insertMediaAsMediaSingle } from '../media/utils/media-single';
21
20
  import { addReplaceSelectedTableAnalytics, applyTextMarksToSlice, hasOnlyNodesOfType } from './util';
22
21
  import { linkifyContent, isListItemNode, isListNode, canLinkBeCreatedInRange } from '@atlaskit/editor-common/utils';
23
22
  import { insertSliceForLists } from './edge-cases';
@@ -543,12 +542,13 @@ function isOnlyMediaSingle(state, slice) {
543
542
  var mediaSingle = state.schema.nodes.mediaSingle;
544
543
  return mediaSingle && slice.content.childCount === 1 && slice.content.firstChild.type === mediaSingle;
545
544
  }
546
- export function handleMediaSingle(inputMethod, editorAnalyticsAPI) {
545
+ export function handleMediaSingle(inputMethod, insertMediaAsMediaSingle) {
547
546
  return function (slice) {
548
547
  return function (state, dispatch, view) {
549
548
  if (view) {
550
549
  if (isOnlyMedia(state, slice)) {
551
- return insertMediaAsMediaSingle(view, slice.content.firstChild, inputMethod, editorAnalyticsAPI);
550
+ var _insertMediaAsMediaSi;
551
+ return (_insertMediaAsMediaSi = insertMediaAsMediaSingle === null || insertMediaAsMediaSingle === void 0 ? void 0 : insertMediaAsMediaSingle(view, slice.content.firstChild, inputMethod)) !== null && _insertMediaAsMediaSi !== void 0 ? _insertMediaAsMediaSi : false;
552
552
  }
553
553
  if (insideTable(state) && isOnlyMediaSingle(state, slice)) {
554
554
  var tr = state.tr.replaceSelection(slice);