@atlaskit/editor-core 187.28.0 → 187.28.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/create-editor/ReactEditorViewInternal.js +3 -3
  3. package/dist/cjs/create-editor/create-plugins-list.js +2 -2
  4. package/dist/cjs/index.js +0 -7
  5. package/dist/cjs/labs/next/presets/default.js +2 -2
  6. package/dist/cjs/plugins/base/index.js +7 -126
  7. package/dist/cjs/plugins/base/plugin.js +140 -0
  8. package/dist/cjs/plugins/base/pm-plugins/scroll-gutter.js +3 -9
  9. package/dist/cjs/plugins/index.js +2 -2
  10. package/dist/cjs/plugins/list/index.js +17 -0
  11. package/dist/cjs/plugins/list/utils/find.js +4 -3
  12. package/dist/cjs/plugins/media/toolbar/index.js +1 -1
  13. package/dist/cjs/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +7 -2
  14. package/dist/cjs/plugins/media/utils/media-single.js +7 -5
  15. package/dist/cjs/plugins/paste/handlers.js +27 -3
  16. package/dist/cjs/plugins/paste/pm-plugins/analytics.js +2 -2
  17. package/dist/cjs/plugins/paste/pm-plugins/main.js +2 -2
  18. package/dist/cjs/plugins/toolbar-lists-indentation/index.js +58 -36
  19. package/dist/cjs/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +6 -6
  20. package/dist/cjs/plugins/toolbar-lists-indentation/ui/index.js +3 -3
  21. package/dist/cjs/plugins/toolbar-lists-indentation/ui/onItemActivated.js +8 -9
  22. package/dist/cjs/test-utils.js +2 -2
  23. package/dist/cjs/ui/ContentStyles/index.js +19 -18
  24. package/dist/cjs/ui/ToolbarFeedback/index.js +22 -16
  25. package/dist/cjs/version-wrapper.js +1 -1
  26. package/dist/es2019/create-editor/ReactEditorViewInternal.js +3 -3
  27. package/dist/es2019/create-editor/create-plugins-list.js +1 -1
  28. package/dist/es2019/index.js +0 -1
  29. package/dist/es2019/labs/next/presets/default.js +1 -1
  30. package/dist/es2019/plugins/base/index.js +2 -104
  31. package/dist/es2019/plugins/base/plugin.js +109 -0
  32. package/dist/es2019/plugins/base/pm-plugins/scroll-gutter.js +1 -4
  33. package/dist/es2019/plugins/index.js +1 -1
  34. package/dist/es2019/plugins/list/index.js +19 -0
  35. package/dist/es2019/plugins/list/utils/find.js +2 -2
  36. package/dist/es2019/plugins/media/toolbar/index.js +2 -2
  37. package/dist/es2019/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +9 -4
  38. package/dist/es2019/plugins/media/utils/media-single.js +3 -4
  39. package/dist/es2019/plugins/paste/handlers.js +27 -3
  40. package/dist/es2019/plugins/paste/pm-plugins/analytics.js +2 -2
  41. package/dist/es2019/plugins/paste/pm-plugins/main.js +2 -2
  42. package/dist/es2019/plugins/toolbar-lists-indentation/index.js +62 -38
  43. package/dist/es2019/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +6 -6
  44. package/dist/es2019/plugins/toolbar-lists-indentation/ui/index.js +3 -3
  45. package/dist/es2019/plugins/toolbar-lists-indentation/ui/onItemActivated.js +5 -6
  46. package/dist/es2019/test-utils.js +1 -1
  47. package/dist/es2019/ui/ContentStyles/index.js +25 -3
  48. package/dist/es2019/ui/ToolbarFeedback/index.js +14 -9
  49. package/dist/es2019/version-wrapper.js +1 -1
  50. package/dist/esm/create-editor/ReactEditorViewInternal.js +3 -3
  51. package/dist/esm/create-editor/create-plugins-list.js +1 -1
  52. package/dist/esm/index.js +0 -1
  53. package/dist/esm/labs/next/presets/default.js +1 -1
  54. package/dist/esm/plugins/base/index.js +2 -123
  55. package/dist/esm/plugins/base/plugin.js +128 -0
  56. package/dist/esm/plugins/base/pm-plugins/scroll-gutter.js +1 -4
  57. package/dist/esm/plugins/index.js +1 -1
  58. package/dist/esm/plugins/list/index.js +19 -0
  59. package/dist/esm/plugins/list/utils/find.js +2 -2
  60. package/dist/esm/plugins/media/toolbar/index.js +2 -2
  61. package/dist/esm/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +9 -4
  62. package/dist/esm/plugins/media/utils/media-single.js +5 -4
  63. package/dist/esm/plugins/paste/handlers.js +25 -3
  64. package/dist/esm/plugins/paste/pm-plugins/analytics.js +2 -2
  65. package/dist/esm/plugins/paste/pm-plugins/main.js +2 -2
  66. package/dist/esm/plugins/toolbar-lists-indentation/index.js +60 -37
  67. package/dist/esm/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +6 -6
  68. package/dist/esm/plugins/toolbar-lists-indentation/ui/index.js +3 -3
  69. package/dist/esm/plugins/toolbar-lists-indentation/ui/onItemActivated.js +5 -6
  70. package/dist/esm/test-utils.js +1 -1
  71. package/dist/esm/ui/ContentStyles/index.js +6 -5
  72. package/dist/esm/ui/ToolbarFeedback/index.js +20 -14
  73. package/dist/esm/version-wrapper.js +1 -1
  74. package/dist/types/index.d.ts +0 -1
  75. package/dist/types/plugins/base/index.d.ts +4 -16
  76. package/dist/types/plugins/base/plugin.d.ts +23 -0
  77. package/dist/types/plugins/base/pm-plugins/scroll-gutter.d.ts +0 -3
  78. package/dist/types/plugins/index.d.ts +1 -1
  79. package/dist/types/plugins/list/types.d.ts +1 -8
  80. package/dist/types/plugins/list/utils/find.d.ts +1 -1
  81. package/dist/types/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +1 -0
  82. package/dist/types/plugins/media/utils/media-single.d.ts +1 -0
  83. package/dist/types/plugins/paste/handlers.d.ts +4 -2
  84. package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +2 -1
  85. package/dist/types/plugins/toolbar-lists-indentation/index.d.ts +5 -2
  86. package/dist/types/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.d.ts +4 -1
  87. package/dist/types/plugins/toolbar-lists-indentation/ui/index.d.ts +3 -3
  88. package/dist/types/plugins/toolbar-lists-indentation/ui/onItemActivated.d.ts +3 -2
  89. package/dist/types/ui/ToolbarFeedback/index.d.ts +1 -19
  90. package/dist/types-ts4.5/index.d.ts +0 -1
  91. package/dist/types-ts4.5/plugins/base/index.d.ts +4 -18
  92. package/dist/types-ts4.5/plugins/base/plugin.d.ts +25 -0
  93. package/dist/types-ts4.5/plugins/base/pm-plugins/scroll-gutter.d.ts +0 -3
  94. package/dist/types-ts4.5/plugins/index.d.ts +1 -1
  95. package/dist/types-ts4.5/plugins/list/types.d.ts +1 -8
  96. package/dist/types-ts4.5/plugins/list/utils/find.d.ts +1 -1
  97. package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +1 -0
  98. package/dist/types-ts4.5/plugins/media/utils/media-single.d.ts +1 -0
  99. package/dist/types-ts4.5/plugins/paste/handlers.d.ts +4 -2
  100. package/dist/types-ts4.5/plugins/paste/pm-plugins/analytics.d.ts +2 -1
  101. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/index.d.ts +5 -2
  102. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.d.ts +4 -1
  103. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/index.d.ts +3 -3
  104. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/onItemActivated.d.ts +3 -2
  105. package/dist/types-ts4.5/ui/ToolbarFeedback/index.d.ts +1 -19
  106. package/package.json +2 -2
  107. package/report.api.md +4 -58
  108. package/tmp/api-report-tmp.d.ts +4 -47
  109. package/dist/cjs/plugins/list/styles.js +0 -15
  110. package/dist/cjs/utils/list-commands.js +0 -17
  111. package/dist/cjs/utils/lists.js +0 -31
  112. package/dist/es2019/plugins/list/styles.js +0 -26
  113. package/dist/es2019/utils/list-commands.js +0 -11
  114. package/dist/es2019/utils/lists.js +0 -26
  115. package/dist/esm/plugins/list/styles.js +0 -7
  116. package/dist/esm/utils/list-commands.js +0 -11
  117. package/dist/esm/utils/lists.js +0 -24
  118. package/dist/types/plugins/list/styles.d.ts +0 -1
  119. package/dist/types/utils/list-commands.d.ts +0 -6
  120. package/dist/types/utils/lists.d.ts +0 -2
  121. package/dist/types-ts4.5/plugins/list/styles.d.ts +0 -1
  122. package/dist/types-ts4.5/utils/list-commands.d.ts +0 -6
  123. package/dist/types-ts4.5/utils/lists.d.ts +0 -2
@@ -1,104 +1,2 @@
1
- import { baseKeymap } from '@atlaskit/editor-prosemirror/commands';
2
- import { history } from '@atlaskit/editor-prosemirror/history';
3
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
- import { browser } from '@atlaskit/editor-common/utils';
5
- import { doc, paragraph, text } from '@atlaskit/adf-schema';
6
- import filterStepsPlugin from './pm-plugins/filter-steps';
7
- import fixChrome88SelectionPlugin from './pm-plugins/fix-chrome-88-selection';
8
- import disableSpellcheckingPlugin from './pm-plugins/disable-spell-checking';
9
- import contextIdentifierPlugin from './pm-plugins/context-identifier';
10
- import newlinePreserveMarksPlugin from './pm-plugins/newline-preserve-marks';
11
- import inlineCursorTargetPlugin from './pm-plugins/inline-cursor-target';
12
- import scrollGutter from './pm-plugins/scroll-gutter';
13
- import { keymap } from '@atlaskit/editor-common/keymaps';
14
- import frozenEditor from './pm-plugins/frozen-editor';
15
- // Chrome >= 88
16
- export const isChromeWithSelectionBug = browser.chrome && browser.chrome_version >= 88;
17
- const basePlugin = (options, api) => {
18
- var _api$dependencies, _api$dependencies$fea;
19
- const featureFlags = (api === null || api === void 0 ? void 0 : (_api$dependencies = api.dependencies) === null || _api$dependencies === void 0 ? void 0 : (_api$dependencies$fea = _api$dependencies.featureFlags) === null || _api$dependencies$fea === void 0 ? void 0 : _api$dependencies$fea.sharedState.currentState()) || {};
20
- return {
21
- name: 'base',
22
- pmPlugins() {
23
- const plugins = [{
24
- name: 'filterStepsPlugin',
25
- plugin: ({
26
- dispatchAnalyticsEvent
27
- }) => filterStepsPlugin(dispatchAnalyticsEvent)
28
- }];
29
-
30
- // In Chrome, when the selection is placed between adjacent nodes which are not contenteditatble
31
- // the cursor appears at the right most point of the parent container.
32
- // In Firefox, when the selection is placed between adjacent nodes which are not contenteditatble
33
- // no cursor is presented to users.
34
- // In Safari, when the selection is placed between adjacent nodes which are not contenteditatble
35
- // it is not possible to navigate with arrow keys.
36
- // This plugin works around the issues by inserting decorations between
37
- // inline nodes which are set as contenteditable, and have a zero width space.
38
- plugins.push({
39
- name: 'inlineCursorTargetPlugin',
40
- plugin: () => options && options.allowInlineCursorTarget ? inlineCursorTargetPlugin() : undefined
41
- });
42
- plugins.push({
43
- name: 'newlinePreserveMarksPlugin',
44
- plugin: newlinePreserveMarksPlugin
45
- }, {
46
- name: 'frozenEditor',
47
- plugin: ({
48
- dispatchAnalyticsEvent
49
- }) => {
50
- var _options$inputTrackin;
51
- return options !== null && options !== void 0 && (_options$inputTrackin = options.inputTracking) !== null && _options$inputTrackin !== void 0 && _options$inputTrackin.enabled || options !== null && options !== void 0 && options.ufo ? frozenEditor(dispatchAnalyticsEvent, options.inputTracking, options.browserFreezeTracking, options.ufo) : undefined;
52
- }
53
- }, {
54
- name: 'history',
55
- plugin: () => history()
56
- },
57
- // should be last :(
58
- {
59
- name: 'codeBlockIndent',
60
- plugin: () => keymap({
61
- ...baseKeymap,
62
- 'Mod-[': () => true,
63
- 'Mod-]': () => true
64
- })
65
- }, {
66
- name: 'contextIdentifier',
67
- plugin: ({
68
- dispatch,
69
- providerFactory
70
- }) => contextIdentifierPlugin(dispatch, providerFactory)
71
- });
72
- if (options && options.allowScrollGutter) {
73
- plugins.push({
74
- name: 'scrollGutterPlugin',
75
- plugin: () => scrollGutter(options.allowScrollGutter)
76
- });
77
- }
78
- if (isChromeWithSelectionBug && !getBooleanFF('platform.editor.disable-chrome-88-selection-fix_uk53m')) {
79
- plugins.push({
80
- name: 'fixChrome88SelectionPlugin',
81
- plugin: () => fixChrome88SelectionPlugin()
82
- });
83
- }
84
- plugins.push({
85
- name: 'disableSpellcheckingPlugin',
86
- plugin: () => disableSpellcheckingPlugin(featureFlags)
87
- });
88
- return plugins;
89
- },
90
- nodes() {
91
- return [{
92
- name: 'doc',
93
- node: doc
94
- }, {
95
- name: 'paragraph',
96
- node: paragraph
97
- }, {
98
- name: 'text',
99
- node: text
100
- }];
101
- }
102
- };
103
- };
104
- export default basePlugin;
1
+ import basePlugin from './plugin';
2
+ export { basePlugin };
@@ -0,0 +1,109 @@
1
+ import { baseKeymap } from '@atlaskit/editor-prosemirror/commands';
2
+ import { history } from '@atlaskit/editor-prosemirror/history';
3
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
+ import { browser } from '@atlaskit/editor-common/utils';
5
+ import { doc, paragraph, text } from '@atlaskit/adf-schema';
6
+ import filterStepsPlugin from './pm-plugins/filter-steps';
7
+ import fixChrome88SelectionPlugin from './pm-plugins/fix-chrome-88-selection';
8
+ import disableSpellcheckingPlugin from './pm-plugins/disable-spell-checking';
9
+ import contextIdentifierPlugin, { getContextIdentifier } from './pm-plugins/context-identifier';
10
+ import newlinePreserveMarksPlugin from './pm-plugins/newline-preserve-marks';
11
+ import inlineCursorTargetPlugin from './pm-plugins/inline-cursor-target';
12
+ import scrollGutter from './pm-plugins/scroll-gutter';
13
+ import { keymap } from '@atlaskit/editor-common/keymaps';
14
+ import frozenEditor from './pm-plugins/frozen-editor';
15
+ // Chrome >= 88
16
+ export const isChromeWithSelectionBug = browser.chrome && browser.chrome_version >= 88;
17
+ const basePlugin = (options, api) => {
18
+ var _api$dependencies, _api$dependencies$fea;
19
+ const featureFlags = (api === null || api === void 0 ? void 0 : (_api$dependencies = api.dependencies) === null || _api$dependencies === void 0 ? void 0 : (_api$dependencies$fea = _api$dependencies.featureFlags) === null || _api$dependencies$fea === void 0 ? void 0 : _api$dependencies$fea.sharedState.currentState()) || {};
20
+ return {
21
+ name: 'base',
22
+ getSharedState(editorState) {
23
+ return {
24
+ contextIdentifier: getContextIdentifier(editorState)
25
+ };
26
+ },
27
+ pmPlugins() {
28
+ const plugins = [{
29
+ name: 'filterStepsPlugin',
30
+ plugin: ({
31
+ dispatchAnalyticsEvent
32
+ }) => filterStepsPlugin(dispatchAnalyticsEvent)
33
+ }];
34
+
35
+ // In Chrome, when the selection is placed between adjacent nodes which are not contenteditatble
36
+ // the cursor appears at the right most point of the parent container.
37
+ // In Firefox, when the selection is placed between adjacent nodes which are not contenteditatble
38
+ // no cursor is presented to users.
39
+ // In Safari, when the selection is placed between adjacent nodes which are not contenteditatble
40
+ // it is not possible to navigate with arrow keys.
41
+ // This plugin works around the issues by inserting decorations between
42
+ // inline nodes which are set as contenteditable, and have a zero width space.
43
+ plugins.push({
44
+ name: 'inlineCursorTargetPlugin',
45
+ plugin: () => options && options.allowInlineCursorTarget ? inlineCursorTargetPlugin() : undefined
46
+ });
47
+ plugins.push({
48
+ name: 'newlinePreserveMarksPlugin',
49
+ plugin: newlinePreserveMarksPlugin
50
+ }, {
51
+ name: 'frozenEditor',
52
+ plugin: ({
53
+ dispatchAnalyticsEvent
54
+ }) => {
55
+ var _options$inputTrackin;
56
+ return options !== null && options !== void 0 && (_options$inputTrackin = options.inputTracking) !== null && _options$inputTrackin !== void 0 && _options$inputTrackin.enabled || options !== null && options !== void 0 && options.ufo ? frozenEditor(dispatchAnalyticsEvent, options.inputTracking, options.browserFreezeTracking, options.ufo) : undefined;
57
+ }
58
+ }, {
59
+ name: 'history',
60
+ plugin: () => history()
61
+ },
62
+ // should be last :(
63
+ {
64
+ name: 'codeBlockIndent',
65
+ plugin: () => keymap({
66
+ ...baseKeymap,
67
+ 'Mod-[': () => true,
68
+ 'Mod-]': () => true
69
+ })
70
+ }, {
71
+ name: 'contextIdentifier',
72
+ plugin: ({
73
+ dispatch,
74
+ providerFactory
75
+ }) => contextIdentifierPlugin(dispatch, providerFactory)
76
+ });
77
+ if (options && options.allowScrollGutter) {
78
+ plugins.push({
79
+ name: 'scrollGutterPlugin',
80
+ plugin: () => scrollGutter(options.allowScrollGutter)
81
+ });
82
+ }
83
+ if (isChromeWithSelectionBug && !getBooleanFF('platform.editor.disable-chrome-88-selection-fix_uk53m')) {
84
+ plugins.push({
85
+ name: 'fixChrome88SelectionPlugin',
86
+ plugin: () => fixChrome88SelectionPlugin()
87
+ });
88
+ }
89
+ plugins.push({
90
+ name: 'disableSpellcheckingPlugin',
91
+ plugin: () => disableSpellcheckingPlugin(featureFlags)
92
+ });
93
+ return plugins;
94
+ },
95
+ nodes() {
96
+ return [{
97
+ name: 'doc',
98
+ node: doc
99
+ }, {
100
+ name: 'paragraph',
101
+ node: paragraph
102
+ }, {
103
+ name: 'text',
104
+ node: text
105
+ }];
106
+ }
107
+ };
108
+ };
109
+ export default basePlugin;
@@ -1,9 +1,6 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { isEmptyDocument } from '@atlaskit/editor-common/utils';
2
+ import { GUTTER_SELECTOR, GUTTER_SIZE_IN_PX, isEmptyDocument } from '@atlaskit/editor-common/utils';
3
3
  import { getMobileDimensionsPluginState } from '../../mobile-dimensions/utils';
4
- export const GUTTER_SIZE_IN_PX = 120; // Default gutter size
5
- export const GUTTER_SIZE_MOBILE_IN_PX = 36; // Gutter size for Mobile
6
- export const GUTTER_SELECTOR = '#editor-scroll-gutter';
7
4
  const MIN_TAP_SIZE_IN_PX = 40;
8
5
  function supportsIntersectionObserver() {
9
6
  if (typeof window !== 'undefined' && 'IntersectionObserver' in window && 'IntersectionObserverEntry' in window && 'intersectionRatio' in window.IntersectionObserverEntry.prototype) {
@@ -1,4 +1,4 @@
1
- export { default as basePlugin } from './base';
1
+ export { basePlugin } from './base';
2
2
  export { default as blockTypePlugin } from './block-type';
3
3
  export { pluginKey as blockPluginStateKey } from './block-type';
4
4
  export { default as betterTypeHistoryPlugin } from './better-type-history';
@@ -7,6 +7,11 @@ import { listMessages as messages } from '@atlaskit/editor-common/messages';
7
7
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '../analytics';
8
8
  import { toggleBulletList, toggleOrderedList, tooltip } from '../../keymaps';
9
9
  import { IconList, IconListNumber } from '@atlaskit/editor-common/quick-insert';
10
+ import { isInsideListItem } from './utils/selection';
11
+ import { indentList, outdentList, toggleBulletList as toggleBulletListCommand, toggleOrderedList as toggleOrderedListCommand } from './commands';
12
+ import { findRootParentListNode } from './utils/find';
13
+ import { pluginKey as listPluginKey } from './pm-plugins/main';
14
+
10
15
  /*
11
16
  Toolbar buttons to bullet and ordered list can be found in
12
17
  packages/editor/editor-core/src/plugins/toolbar-lists-indentation/ui/Toolbar.tsx
@@ -17,6 +22,20 @@ const listPlugin = (options, api) => {
17
22
  const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions;
18
23
  return {
19
24
  name: 'list',
25
+ actions: {
26
+ indentList: indentList(editorAnalyticsAPI),
27
+ outdentList: outdentList(editorAnalyticsAPI),
28
+ toggleOrderedList: toggleOrderedListCommand(editorAnalyticsAPI),
29
+ toggleBulletList: toggleBulletListCommand(editorAnalyticsAPI),
30
+ isInsideListItem,
31
+ findRootParentListNode
32
+ },
33
+ getSharedState: editorState => {
34
+ if (!editorState) {
35
+ return undefined;
36
+ }
37
+ return listPluginKey.getState(editorState);
38
+ },
20
39
  nodes() {
21
40
  return [{
22
41
  name: 'bulletList',
@@ -36,7 +36,7 @@ export function findFirstParentListItemNode($pos) {
36
36
  pos: listItemNodePosition.pos
37
37
  };
38
38
  }
39
- export function findRootParentListNode($pos) {
39
+ export const findRootParentListNode = $pos => {
40
40
  const {
41
41
  doc
42
42
  } = $pos;
@@ -58,4 +58,4 @@ export function findRootParentListNode($pos) {
58
58
  }
59
59
  const listNodePosition = doc.resolve(parentList.pos);
60
60
  return findRootParentListNode(listNodePosition);
61
- }
61
+ };
@@ -25,7 +25,7 @@ import ImageBorderItem from '../ui/ImageBorder';
25
25
  import { currentMediaNodeBorderMark } from '../utils/current-media-node';
26
26
  import { shouldShowImageBorder } from './imageBorder';
27
27
  import { PixelEntry } from '../ui/PixelEntry';
28
- import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_GUTTER_SIZE, calcMediaSinglePixelWidth } from '@atlaskit/editor-common/media-single';
28
+ import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_GUTTER_SIZE, calcMediaSinglePixelWidth } from '@atlaskit/editor-common/media-single';
29
29
  import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
30
30
  const remove = (state, dispatch) => {
31
31
  if (dispatch) {
@@ -308,7 +308,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
308
308
  mediaWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
309
309
  mediaHeight: mediaHeight || DEFAULT_IMAGE_HEIGHT,
310
310
  validate: value => {
311
- if (value !== '' && !isNaN(value) && value >= MEDIA_SINGLE_MIN_PIXEL_WIDTH && value <= akEditorFullWidthLayoutWidth) {
311
+ if (value !== '' && !isNaN(value) && value >= MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH && value <= akEditorFullWidthLayoutWidth) {
312
312
  return true;
313
313
  }
314
314
  return false;
@@ -6,12 +6,12 @@ import { findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit
6
6
  import { getMediaClient } from '@atlaskit/media-client';
7
7
  import { calcPctFromPx, wrappedLayouts, handleSides, imageAlignmentMap } from '@atlaskit/editor-common/ui';
8
8
  import { nonWrappedLayouts, setNodeSelection } from '@atlaskit/editor-common/utils';
9
- import { akEditorFullWidthLayoutWidth, akEditorGutterPadding } from '@atlaskit/editor-shared-styles';
9
+ import { akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
10
10
  import { wrapperStyle } from './styled';
11
11
  import { ResizerNext } from '@atlaskit/editor-common/resizer';
12
12
  import classnames from 'classnames';
13
13
  import { richMediaClassName, resizerStyles } from '@atlaskit/editor-common/styles';
14
- import { MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_RESIZE_THROTTLE_TIME, calculateOffsetLeft, DEFAULT_IMAGE_WIDTH, calcMediaSingleMaxWidth } from '@atlaskit/editor-common/media-single';
14
+ import { MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_RESIZE_THROTTLE_TIME, calculateOffsetLeft, DEFAULT_IMAGE_WIDTH, calcMediaSingleMaxWidth } from '@atlaskit/editor-common/media-single';
15
15
  import { findClosestSnap, getGuidelinesWithHighlights, generateDefaultGuidelines, generateDynamicGuidelines, getGuidelineSnaps, getGuidelineTypeFromKey, getRelativeGuideSnaps, getRelativeGuidelines } from '@atlaskit/editor-common/guideline';
16
16
  import memoizeOne from 'memoize-one';
17
17
  import { getMediaResizeAnalyticsEvent } from '../../utils/analytics';
@@ -132,6 +132,9 @@ class ResizableMediaSingleNext extends React.Component {
132
132
  }
133
133
  return calcMediaSingleMaxWidth(containerWidth);
134
134
  }));
135
+ _defineProperty(this, "calcMinWidth", memoizeOne((isVideoFile, contentWidth) => {
136
+ return Math.min(contentWidth || akEditorDefaultLayoutWidth, isVideoFile ? MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH : MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH);
137
+ }));
135
138
  _defineProperty(this, "getRelativeGuides", () => {
136
139
  const $pos = this.$pos;
137
140
  const relativeGuides = $pos && $pos.nodeAfter && this.state.size.width ? getRelativeGuidelines(this.state.relativeGuides, {
@@ -411,7 +414,8 @@ class ResizableMediaSingleNext extends React.Component {
411
414
  } = this.props;
412
415
  const {
413
416
  isResizing,
414
- size
417
+ size,
418
+ isVideoFile
415
419
  } = this.state;
416
420
  const enable = {};
417
421
  handleSides.forEach(side => {
@@ -430,6 +434,7 @@ class ResizableMediaSingleNext extends React.Component {
430
434
  });
431
435
  const resizerNextClassName = classnames(className, resizerStyles);
432
436
  const maxWidth = this.calcMaxWidth(lineLength, containerWidth, fullWidthMode);
437
+ const minWidth = this.calcMinWidth(isVideoFile, lineLength);
433
438
  return jsx("div", {
434
439
  ref: this.saveWrapper,
435
440
  css: wrapperStyle({
@@ -442,7 +447,7 @@ class ResizableMediaSingleNext extends React.Component {
442
447
  isExtendedResizeExperienceOn: true
443
448
  })
444
449
  }, jsx(ResizerNext, {
445
- minWidth: MEDIA_SINGLE_MIN_PIXEL_WIDTH,
450
+ minWidth: minWidth,
446
451
  maxWidth: maxWidth,
447
452
  className: resizerNextClassName,
448
453
  snapGap: MEDIA_SINGLE_SNAP_GAP,
@@ -1,8 +1,8 @@
1
1
  import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
2
2
  import { safeInsert as pmSafeInsert, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
3
3
  import { checkNodeDown } from '../../../utils';
4
+ import { getMediaSingleInitialWidth, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
4
5
  import { isEmptyParagraph, floatingLayouts } from '@atlaskit/editor-common/utils';
5
- import { getMediaSingleInitialWidth } from '@atlaskit/editor-common/media-single';
6
6
  import { copyOptionalAttrsFromMediaState } from '../utils/media-common';
7
7
  import { mapSlice } from '../../../utils/slice';
8
8
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
@@ -94,9 +94,7 @@ export const insertMediaSingleNode = (view, mediaState, inputMethod, collection,
94
94
  // add undefined as fallback as we don't want media single width to have upper limit as 0
95
95
  // if widthPluginState.width is 0, default 760 will be used
96
96
  const contentWidth = (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.lineLength) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.width) || undefined;
97
- const node = createMediaSingleNode(state.schema, collection, contentWidth,
98
- // pass undefined to use default min width
99
- undefined, alignLeftOnInsert)(mediaState);
97
+ const node = createMediaSingleNode(state.schema, collection, contentWidth, mediaState.status !== 'error' && isVideo(mediaState.fileMimeType) ? MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH : MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, alignLeftOnInsert)(mediaState);
100
98
  let fileExtension;
101
99
  if (mediaState.fileName) {
102
100
  const extensionIdx = mediaState.fileName.lastIndexOf('.');
@@ -219,6 +217,7 @@ export function isCaptionNode(editorView) {
219
217
  }
220
218
  return false;
221
219
  }
220
+ export const isVideo = fileType => !!fileType && fileType.includes('video');
222
221
  export const getParentWidthForNestedMediaSingleNode = (resolvedPos, view) => {
223
222
  const domNode = view.nodeDOM(resolvedPos.pos);
224
223
  if (resolvedPos.nodeAfter && floatingLayouts.includes(resolvedPos.nodeAfter.attrs.layout) && domNode && domNode.parentElement) {
@@ -15,7 +15,6 @@ import { linkifyContent, isListItemNode, isListNode, canLinkBeCreatedInRange } f
15
15
  import { insertSliceForLists } from './edge-cases';
16
16
  import { startTrackingPastedMacroPositions, stopTrackingPastedMacroPositions } from './commands';
17
17
  import { getPluginState as getPastePluginState } from './pm-plugins/plugin-factory';
18
- import { doesSelectionWhichStartsOrEndsInListContainEntireList } from '../../utils/lists';
19
18
  import { anyMarkActive } from '@atlaskit/editor-common/mark';
20
19
  // remove text attribute from mention for copy/paste (GDPR)
21
20
  export function handleMention(slice, schema) {
@@ -234,7 +233,32 @@ export function handlePasteNonNestableBlockNodesIntoList(slice) {
234
233
  return false;
235
234
  };
236
235
  }
237
- export function handlePastePanelOrDecisionContentIntoList(slice) {
236
+ export const doesSelectionWhichStartsOrEndsInListContainEntireList = (selection, findRootParentListNode) => {
237
+ const {
238
+ $from,
239
+ $to,
240
+ from,
241
+ to
242
+ } = selection;
243
+ const selectionParentListItemNodeResolvedPos = findRootParentListNode ? findRootParentListNode($from) || findRootParentListNode($to) : null;
244
+ const selectionParentListNode = selectionParentListItemNodeResolvedPos === null || selectionParentListItemNodeResolvedPos === void 0 ? void 0 : selectionParentListItemNodeResolvedPos.parent;
245
+ if (!selectionParentListItemNodeResolvedPos || !selectionParentListNode) {
246
+ return false;
247
+ }
248
+ const startOfEntireList = $from.pos < $to.pos ? selectionParentListItemNodeResolvedPos.pos + $from.depth - 1 : selectionParentListItemNodeResolvedPos.pos + $to.depth - 1;
249
+ const endOfEntireList = $from.pos < $to.pos ? selectionParentListItemNodeResolvedPos.pos + selectionParentListNode.nodeSize - $to.depth - 1 : selectionParentListItemNodeResolvedPos.pos + selectionParentListNode.nodeSize - $from.depth - 1;
250
+ if (!startOfEntireList || !endOfEntireList) {
251
+ return false;
252
+ }
253
+ if (from < to) {
254
+ return startOfEntireList >= $from.pos && endOfEntireList <= $to.pos;
255
+ } else if (from > to) {
256
+ return startOfEntireList >= $to.pos && endOfEntireList <= $from.pos;
257
+ } else {
258
+ return false;
259
+ }
260
+ };
261
+ export function handlePastePanelOrDecisionContentIntoList(slice, findRootParentListNode) {
238
262
  return (state, dispatch) => {
239
263
  const {
240
264
  schema,
@@ -247,7 +271,7 @@ export function handlePastePanelOrDecisionContentIntoList(slice) {
247
271
  const blockNode = slice.content.firstChild;
248
272
  const isSliceWholeNode = slice.openStart === 0 && slice.openEnd === 0;
249
273
  const selectionParentListItemNode = selection.$to.node(selection.$to.depth - 1);
250
- const sliceIsWholeNodeButShouldNotReplaceSelection = isSliceWholeNode && !doesSelectionWhichStartsOrEndsInListContainEntireList(selection);
274
+ const sliceIsWholeNodeButShouldNotReplaceSelection = isSliceWholeNode && !doesSelectionWhichStartsOrEndsInListContainEntireList(selection, findRootParentListNode);
251
275
  if (!selectionParentListItemNode || (selectionParentListItemNode === null || selectionParentListItemNode === void 0 ? void 0 : selectionParentListItemNode.type) !== schema.nodes.listItem || !blockNode || !['panel', 'decisionList'].includes(blockNode === null || blockNode === void 0 ? void 0 : blockNode.type.name) || slice.content.childCount > 1 || (blockNode === null || blockNode === void 0 ? void 0 : blockNode.content.firstChild) === undefined || sliceIsWholeNodeButShouldNotReplaceSelection) {
252
276
  return false;
253
277
  }
@@ -280,9 +280,9 @@ function injectAnalyticsPayloadBeforeCommand(createPayloadByTransaction) {
280
280
  };
281
281
  };
282
282
  }
283
- export const handlePastePanelOrDecisionIntoListWithAnalytics = (view, event, slice) => injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
283
+ export const handlePastePanelOrDecisionIntoListWithAnalytics = (view, event, slice, findRootParentListNode) => injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
284
284
  type: PasteTypes.richText
285
- }))(handlePastePanelOrDecisionContentIntoList(slice));
285
+ }))(handlePastePanelOrDecisionContentIntoList(slice, findRootParentListNode));
286
286
  export const handlePasteNonNestableBlockNodesIntoListWithAnalytics = (view, event, slice) => injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
287
287
  type: PasteTypes.richText,
288
288
  pasteSplitList: true
@@ -281,7 +281,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
281
281
 
282
282
  // finally, handle rich-text copy-paste
283
283
  if (isRichText) {
284
- var _pluginInjectionApi$d6, _pluginInjectionApi$d7;
284
+ var _pluginInjectionApi$d6, _pluginInjectionApi$d7, _pluginInjectionApi$d8;
285
285
  // linkify the text where possible
286
286
  slice = linkifyContent(state.schema)(slice);
287
287
  if (handlePasteLinkOnSelectedTextWithAnalytics(view, event, slice, PasteTypes.richText)(state, dispatch)) {
@@ -344,7 +344,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
344
344
  if (handlePasteIntoCaptionWithAnalytics(view, event, slice, PasteTypes.richText)(state, dispatch)) {
345
345
  return true;
346
346
  }
347
- if (handlePastePanelOrDecisionIntoListWithAnalytics(view, event, slice)(state, dispatch)) {
347
+ if (handlePastePanelOrDecisionIntoListWithAnalytics(view, event, slice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d8 = pluginInjectionApi.dependencies.list) === null || _pluginInjectionApi$d8 === void 0 ? void 0 : _pluginInjectionApi$d8.actions.findRootParentListNode)(state, dispatch)) {
348
348
  return true;
349
349
  }
350
350
  if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists && handlePasteNonNestableBlockNodesIntoListWithAnalytics(view, event, slice)(state, dispatch)) {
@@ -1,18 +1,23 @@
1
1
  import React from 'react';
2
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
2
3
  import ToolbarListsIndentation from './ui';
3
- import WithPluginState from '../../ui/WithPluginState';
4
4
  import { ToolbarSize } from '../../ui/Toolbar/types';
5
- import { pluginKey as listPluginKey } from '../list/pm-plugins/main';
6
- import { pluginKey as indentationButtonsPluginKey, createPlugin as indentationButtonsPlugin } from './pm-plugins/indentation-buttons';
5
+ import { createPlugin as indentationButtonsPlugin } from './pm-plugins/indentation-buttons';
6
+ import { pluginKey as indentationButtonPluginKey } from './pm-plugins/indentation-buttons';
7
7
  const toolbarListsIndentationPlugin = ({
8
8
  showIndentationButtons,
9
9
  allowHeadingAndParagraphIndentation
10
10
  }, api) => {
11
- var _api$dependencies$ana;
12
- const featureFlags = (api === null || api === void 0 ? void 0 : api.dependencies.featureFlags.sharedState.currentState()) || {};
13
- const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions;
11
+ var _api$dependencies$fea;
12
+ const featureFlags = (api === null || api === void 0 ? void 0 : (_api$dependencies$fea = api.dependencies.featureFlags) === null || _api$dependencies$fea === void 0 ? void 0 : _api$dependencies$fea.sharedState.currentState()) || {};
14
13
  return {
15
14
  name: 'toolbarListsIndentation',
15
+ getSharedState(editorState) {
16
+ if (!editorState) {
17
+ return undefined;
18
+ }
19
+ return indentationButtonPluginKey.getState(editorState);
20
+ },
16
21
  pmPlugins() {
17
22
  return [{
18
23
  name: 'indentationButtons',
@@ -21,7 +26,8 @@ const toolbarListsIndentationPlugin = ({
21
26
  }) => indentationButtonsPlugin({
22
27
  dispatch,
23
28
  showIndentationButtons,
24
- allowHeadingAndParagraphIndentation
29
+ allowHeadingAndParagraphIndentation,
30
+ api
25
31
  })
26
32
  }];
27
33
  },
@@ -35,39 +41,57 @@ const toolbarListsIndentationPlugin = ({
35
41
  isToolbarReducedSpacing
36
42
  }) {
37
43
  const isSmall = toolbarSize < ToolbarSize.L;
38
- return /*#__PURE__*/React.createElement(WithPluginState, {
39
- plugins: {
40
- listState: listPluginKey,
41
- indentationState: indentationButtonsPluginKey
42
- },
43
- render: ({
44
- listState,
45
- indentationState
46
- }) => {
47
- if (!listState) {
48
- return null;
49
- }
50
- return /*#__PURE__*/React.createElement(ToolbarListsIndentation, {
51
- featureFlags: featureFlags,
52
- isSmall: isSmall,
53
- isReducedSpacing: isToolbarReducedSpacing,
54
- disabled: disabled,
55
- editorView: editorView,
56
- popupsMountPoint: popupsMountPoint,
57
- popupsBoundariesElement: popupsBoundariesElement,
58
- popupsScrollableElement: popupsScrollableElement,
59
- bulletListActive: listState.bulletListActive,
60
- bulletListDisabled: listState.bulletListDisabled,
61
- orderedListActive: listState.orderedListActive,
62
- orderedListDisabled: listState.orderedListDisabled,
63
- showIndentationButtons: !!showIndentationButtons,
64
- indentDisabled: indentationState.indentDisabled,
65
- outdentDisabled: indentationState.outdentDisabled,
66
- editorAnalyticsAPI: editorAnalyticsAPI
67
- });
68
- }
44
+ return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
45
+ featureFlags: featureFlags,
46
+ popupsMountPoint: popupsMountPoint,
47
+ popupsBoundariesElement: popupsBoundariesElement,
48
+ popupsScrollableElement: popupsScrollableElement,
49
+ isSmall: isSmall,
50
+ isToolbarReducedSpacing: isToolbarReducedSpacing,
51
+ disabled: disabled,
52
+ editorView: editorView,
53
+ showIndentationButtons: showIndentationButtons,
54
+ pluginInjectionApi: api
69
55
  });
70
56
  }
71
57
  };
72
58
  };
59
+ function PrimaryToolbarComponent({
60
+ featureFlags,
61
+ popupsMountPoint,
62
+ popupsBoundariesElement,
63
+ popupsScrollableElement,
64
+ isSmall,
65
+ isToolbarReducedSpacing,
66
+ disabled,
67
+ editorView,
68
+ showIndentationButtons,
69
+ pluginInjectionApi
70
+ }) {
71
+ const {
72
+ listState,
73
+ toolbarListsIndentationState
74
+ } = useSharedPluginState(pluginInjectionApi, ['list', 'toolbarListsIndentation']);
75
+ if (!listState) {
76
+ return null;
77
+ }
78
+ return /*#__PURE__*/React.createElement(ToolbarListsIndentation, {
79
+ featureFlags: featureFlags,
80
+ isSmall: isSmall,
81
+ isReducedSpacing: isToolbarReducedSpacing,
82
+ disabled: disabled,
83
+ editorView: editorView,
84
+ popupsMountPoint: popupsMountPoint,
85
+ popupsBoundariesElement: popupsBoundariesElement,
86
+ popupsScrollableElement: popupsScrollableElement,
87
+ bulletListActive: listState.bulletListActive,
88
+ bulletListDisabled: listState.bulletListDisabled,
89
+ orderedListActive: listState.orderedListActive,
90
+ orderedListDisabled: listState.orderedListDisabled,
91
+ showIndentationButtons: !!showIndentationButtons,
92
+ indentDisabled: toolbarListsIndentationState.indentDisabled,
93
+ outdentDisabled: toolbarListsIndentationState.outdentDisabled,
94
+ pluginInjectionApi: pluginInjectionApi
95
+ });
96
+ }
73
97
  export default toolbarListsIndentationPlugin;
@@ -2,12 +2,11 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
2
  import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
3
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import { shallowEqual } from '@atlaskit/editor-common/utils';
5
- import { isInsideListItem } from '../../list/utils/selection';
6
5
  import { getCurrentIndentLevel as getTaskListIndentLevel, getTaskItemIndex, isInsideTask } from '../../tasks-and-decisions/pm-plugins/helpers';
7
6
  import { isIndentationAllowed, MAX_INDENTATION_LEVEL } from '../../indentation/commands';
8
7
  import { getListItemAttributes } from '@atlaskit/editor-common/lists';
9
8
  export const pluginKey = new PluginKey('indentationButtonsPlugin');
10
- function getIndentationButtonsState(editorState, allowHeadingAndParagraphIndentation) {
9
+ function getIndentationButtonsState(editorState, allowHeadingAndParagraphIndentation, api) {
11
10
  const state = {
12
11
  indentDisabled: true,
13
12
  outdentDisabled: true,
@@ -22,7 +21,7 @@ function getIndentationButtonsState(editorState, allowHeadingAndParagraphIndenta
22
21
  // not use the indentation mark.
23
22
  // Check for lists before paragraphs and headings in case
24
23
  // the selection is in a list nested in a layout column.
25
- if (isInsideListItem(editorState)) {
24
+ if (api !== null && api !== void 0 && api.dependencies.list.actions.isInsideListItem(editorState)) {
26
25
  const {
27
26
  indentLevel,
28
27
  itemIndex
@@ -70,7 +69,8 @@ function getIndentationButtonsState(editorState, allowHeadingAndParagraphIndenta
70
69
  export const createPlugin = ({
71
70
  dispatch,
72
71
  showIndentationButtons,
73
- allowHeadingAndParagraphIndentation
72
+ allowHeadingAndParagraphIndentation,
73
+ api
74
74
  }) => new SafePlugin({
75
75
  state: {
76
76
  init(_config, state) {
@@ -79,11 +79,11 @@ export const createPlugin = ({
79
79
  outdentDisabled: true,
80
80
  node: null
81
81
  };
82
- return showIndentationButtons ? getIndentationButtonsState(state, allowHeadingAndParagraphIndentation) : initialState;
82
+ return showIndentationButtons ? getIndentationButtonsState(state, allowHeadingAndParagraphIndentation, api) : initialState;
83
83
  },
84
84
  apply(_tr, pluginState, _oldState, newState) {
85
85
  if (showIndentationButtons) {
86
- const state = getIndentationButtonsState(newState, allowHeadingAndParagraphIndentation);
86
+ const state = getIndentationButtonsState(newState, allowHeadingAndParagraphIndentation, api);
87
87
  if (!shallowEqual(pluginState, state)) {
88
88
  dispatch(pluginKey, state);
89
89
  return state;