@atlaskit/editor-core 187.9.2 → 187.10.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.
Files changed (201) hide show
  1. package/.eslintrc.js +1 -0
  2. package/CHANGELOG.md +17 -0
  3. package/dist/cjs/commands/index.js +8 -134
  4. package/dist/cjs/labs/next/presets/default.js +2 -2
  5. package/dist/cjs/plugins/base/index.js +2 -2
  6. package/dist/cjs/plugins/block-type/commands/block-type.js +34 -36
  7. package/dist/cjs/plugins/block-type/commands/transform-to-code-block.js +1 -2
  8. package/dist/cjs/plugins/block-type/index.js +16 -13
  9. package/dist/cjs/plugins/block-type/pm-plugins/input-rule.js +19 -18
  10. package/dist/cjs/plugins/block-type/pm-plugins/keymap.js +12 -14
  11. package/dist/cjs/plugins/block-type/pm-plugins/main.js +9 -9
  12. package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +7 -7
  13. package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/index.js +3 -4
  14. package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/styled.js +13 -5
  15. package/dist/cjs/plugins/block-type/utils.js +73 -2
  16. package/dist/cjs/plugins/caption/pm-plugins/keymap.js +2 -2
  17. package/dist/cjs/plugins/floating-toolbar/index.js +154 -132
  18. package/dist/cjs/plugins/floating-toolbar/pm-plugins/force-focus/index.js +11 -10
  19. package/dist/cjs/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +14 -7
  20. package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +6 -1
  21. package/dist/cjs/plugins/index.js +0 -7
  22. package/dist/cjs/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +4 -1
  23. package/dist/cjs/plugins/media/toolbar/alt-text.js +6 -6
  24. package/dist/cjs/plugins/media/toolbar/linking.js +4 -1
  25. package/dist/cjs/plugins/media/ui/MediaLinkingToolbar.js +2 -2
  26. package/dist/cjs/plugins/media/utils/media-common.js +5 -5
  27. package/dist/cjs/plugins/undo-redo/pm-plugins/keymaps.js +2 -2
  28. package/dist/cjs/ui/ColorPickerButton/index.js +3 -3
  29. package/dist/cjs/ui/styles.js +4 -11
  30. package/dist/cjs/utils/index.js +4 -80
  31. package/dist/cjs/utils/input-rules.js +6 -66
  32. package/dist/cjs/utils/mark.js +2 -38
  33. package/dist/cjs/version-wrapper.js +1 -1
  34. package/dist/cjs/version.json +1 -1
  35. package/dist/es2019/commands/index.js +1 -128
  36. package/dist/es2019/labs/next/presets/default.js +1 -1
  37. package/dist/es2019/plugins/base/index.js +1 -1
  38. package/dist/es2019/plugins/block-type/commands/block-type.js +11 -13
  39. package/dist/es2019/plugins/block-type/commands/transform-to-code-block.js +1 -2
  40. package/dist/es2019/plugins/block-type/index.js +21 -12
  41. package/dist/es2019/plugins/block-type/pm-plugins/input-rule.js +18 -18
  42. package/dist/es2019/plugins/block-type/pm-plugins/keymap.js +8 -9
  43. package/dist/es2019/plugins/block-type/pm-plugins/main.js +9 -9
  44. package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +2 -2
  45. package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/index.js +2 -3
  46. package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/styled.js +21 -2
  47. package/dist/es2019/plugins/block-type/utils.js +70 -1
  48. package/dist/es2019/plugins/caption/pm-plugins/keymap.js +1 -1
  49. package/dist/es2019/plugins/floating-toolbar/index.js +152 -128
  50. package/dist/es2019/plugins/floating-toolbar/pm-plugins/force-focus/index.js +12 -8
  51. package/dist/es2019/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +5 -4
  52. package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +12 -1
  53. package/dist/es2019/plugins/index.js +0 -1
  54. package/dist/es2019/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +3 -1
  55. package/dist/es2019/plugins/media/toolbar/alt-text.js +10 -6
  56. package/dist/es2019/plugins/media/toolbar/linking.js +8 -1
  57. package/dist/es2019/plugins/media/ui/MediaLinkingToolbar.js +5 -3
  58. package/dist/es2019/plugins/media/utils/media-common.js +1 -1
  59. package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -1
  60. package/dist/es2019/plugins/undo-redo/pm-plugins/keymaps.js +1 -1
  61. package/dist/es2019/ui/ColorPickerButton/index.js +2 -2
  62. package/dist/es2019/ui/styles.js +0 -16
  63. package/dist/es2019/utils/index.js +0 -80
  64. package/dist/es2019/utils/input-rules.js +4 -61
  65. package/dist/es2019/utils/mark.js +0 -33
  66. package/dist/es2019/version-wrapper.js +1 -1
  67. package/dist/es2019/version.json +1 -1
  68. package/dist/esm/commands/index.js +7 -125
  69. package/dist/esm/labs/next/presets/default.js +1 -1
  70. package/dist/esm/plugins/base/index.js +1 -1
  71. package/dist/esm/plugins/block-type/commands/block-type.js +11 -13
  72. package/dist/esm/plugins/block-type/commands/transform-to-code-block.js +1 -2
  73. package/dist/esm/plugins/block-type/index.js +15 -12
  74. package/dist/esm/plugins/block-type/pm-plugins/input-rule.js +18 -18
  75. package/dist/esm/plugins/block-type/pm-plugins/keymap.js +8 -9
  76. package/dist/esm/plugins/block-type/pm-plugins/main.js +9 -9
  77. package/dist/esm/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +2 -2
  78. package/dist/esm/plugins/block-type/ui/ToolbarBlockType/index.js +2 -3
  79. package/dist/esm/plugins/block-type/ui/ToolbarBlockType/styled.js +8 -4
  80. package/dist/esm/plugins/block-type/utils.js +69 -1
  81. package/dist/esm/plugins/caption/pm-plugins/keymap.js +1 -1
  82. package/dist/esm/plugins/floating-toolbar/index.js +153 -131
  83. package/dist/esm/plugins/floating-toolbar/pm-plugins/force-focus/index.js +9 -7
  84. package/dist/esm/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +14 -7
  85. package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +6 -1
  86. package/dist/esm/plugins/index.js +0 -1
  87. package/dist/esm/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +4 -1
  88. package/dist/esm/plugins/media/toolbar/alt-text.js +6 -6
  89. package/dist/esm/plugins/media/toolbar/linking.js +4 -1
  90. package/dist/esm/plugins/media/ui/MediaLinkingToolbar.js +2 -2
  91. package/dist/esm/plugins/media/utils/media-common.js +1 -1
  92. package/dist/esm/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -1
  93. package/dist/esm/plugins/undo-redo/pm-plugins/keymaps.js +1 -1
  94. package/dist/esm/ui/ColorPickerButton/index.js +3 -3
  95. package/dist/esm/ui/styles.js +3 -6
  96. package/dist/esm/utils/index.js +3 -77
  97. package/dist/esm/utils/input-rules.js +4 -61
  98. package/dist/esm/utils/mark.js +0 -35
  99. package/dist/esm/version-wrapper.js +1 -1
  100. package/dist/esm/version.json +1 -1
  101. package/dist/types/commands/index.d.ts +0 -6
  102. package/dist/types/labs/next/presets/default.d.ts +40 -8
  103. package/dist/types/plugins/block-type/commands/block-type.d.ts +5 -6
  104. package/dist/types/plugins/block-type/commands/delete-and-move-cursor.d.ts +1 -1
  105. package/dist/types/plugins/block-type/commands/delete-block-content.d.ts +1 -1
  106. package/dist/types/plugins/block-type/index.d.ts +1 -1
  107. package/dist/types/plugins/block-type/pm-plugins/input-rule.d.ts +3 -2
  108. package/dist/types/plugins/block-type/pm-plugins/keymap.d.ts +2 -2
  109. package/dist/types/plugins/block-type/pm-plugins/main.d.ts +2 -1
  110. package/dist/types/plugins/block-type/styles.d.ts +1 -1
  111. package/dist/types/plugins/block-type/types.d.ts +2 -3
  112. package/dist/types/plugins/block-type/ui/ToolbarBlockType/blocktype-button.d.ts +1 -2
  113. package/dist/types/plugins/block-type/ui/ToolbarBlockType/index.d.ts +2 -2
  114. package/dist/types/plugins/block-type/ui/ToolbarBlockType/styled.d.ts +5 -1
  115. package/dist/types/plugins/block-type/utils.d.ts +15 -1
  116. package/dist/types/plugins/date/index.d.ts +2 -2
  117. package/dist/types/plugins/floating-toolbar/index.d.ts +1 -7
  118. package/dist/types/plugins/floating-toolbar/pm-plugins/force-focus/index.d.ts +2 -1
  119. package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.d.ts +1 -1
  120. package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.d.ts +1 -1
  121. package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.d.ts +1 -1
  122. package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.d.ts +2 -1
  123. package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/types.d.ts +0 -3
  124. package/dist/types/plugins/floating-toolbar/ui/ExtensionsPlaceholder.d.ts +1 -1
  125. package/dist/types/plugins/floating-toolbar/ui/Toolbar.d.ts +1 -1
  126. package/dist/types/plugins/index.d.ts +0 -1
  127. package/dist/types/plugins/media/index.d.ts +2 -2
  128. package/dist/types/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.d.ts +1 -0
  129. package/dist/types/plugins/media/ui/MediaLinkingToolbar.d.ts +3 -3
  130. package/dist/types/plugins/undo-redo/pm-plugins/keymaps.d.ts +1 -1
  131. package/dist/types/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +1 -1
  132. package/dist/types/types/index.d.ts +1 -1
  133. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  134. package/dist/types/ui/ColorPickerButton/index.d.ts +2 -2
  135. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  136. package/dist/types/ui/styles.d.ts +0 -3
  137. package/dist/types/utils/index.d.ts +0 -6
  138. package/dist/types/utils/input-rules.d.ts +4 -16
  139. package/dist/types/utils/mark.d.ts +0 -1
  140. package/dist/types-ts4.5/commands/index.d.ts +0 -6
  141. package/dist/types-ts4.5/labs/next/presets/default.d.ts +44 -8
  142. package/dist/types-ts4.5/plugins/block-type/commands/block-type.d.ts +5 -6
  143. package/dist/types-ts4.5/plugins/block-type/commands/delete-and-move-cursor.d.ts +1 -1
  144. package/dist/types-ts4.5/plugins/block-type/commands/delete-block-content.d.ts +1 -1
  145. package/dist/types-ts4.5/plugins/block-type/index.d.ts +1 -1
  146. package/dist/types-ts4.5/plugins/block-type/pm-plugins/input-rule.d.ts +3 -2
  147. package/dist/types-ts4.5/plugins/block-type/pm-plugins/keymap.d.ts +2 -2
  148. package/dist/types-ts4.5/plugins/block-type/pm-plugins/main.d.ts +2 -1
  149. package/dist/types-ts4.5/plugins/block-type/styles.d.ts +1 -1
  150. package/dist/types-ts4.5/plugins/block-type/types.d.ts +2 -3
  151. package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/blocktype-button.d.ts +1 -2
  152. package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/index.d.ts +2 -2
  153. package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/styled.d.ts +5 -1
  154. package/dist/types-ts4.5/plugins/block-type/utils.d.ts +15 -1
  155. package/dist/types-ts4.5/plugins/date/index.d.ts +2 -2
  156. package/dist/types-ts4.5/plugins/floating-toolbar/index.d.ts +1 -7
  157. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/force-focus/index.d.ts +2 -1
  158. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.d.ts +1 -1
  159. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.d.ts +1 -1
  160. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.d.ts +1 -1
  161. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.d.ts +2 -1
  162. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/types.d.ts +0 -3
  163. package/dist/types-ts4.5/plugins/floating-toolbar/ui/ExtensionsPlaceholder.d.ts +1 -1
  164. package/dist/types-ts4.5/plugins/floating-toolbar/ui/Toolbar.d.ts +1 -1
  165. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  166. package/dist/types-ts4.5/plugins/media/index.d.ts +2 -2
  167. package/dist/types-ts4.5/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.d.ts +1 -0
  168. package/dist/types-ts4.5/plugins/media/ui/MediaLinkingToolbar.d.ts +3 -3
  169. package/dist/types-ts4.5/plugins/undo-redo/pm-plugins/keymaps.d.ts +1 -1
  170. package/dist/types-ts4.5/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +1 -1
  171. package/dist/types-ts4.5/types/index.d.ts +1 -1
  172. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  173. package/dist/types-ts4.5/ui/ColorPickerButton/index.d.ts +2 -2
  174. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  175. package/dist/types-ts4.5/ui/styles.d.ts +0 -3
  176. package/dist/types-ts4.5/utils/index.d.ts +0 -6
  177. package/dist/types-ts4.5/utils/input-rules.d.ts +4 -16
  178. package/dist/types-ts4.5/utils/mark.d.ts +0 -1
  179. package/package.json +6 -5
  180. package/report.api.md +9 -37
  181. package/tmp/api-report-tmp.d.ts +8 -34
  182. package/dist/cjs/plugins/editor-disabled/index.js +0 -75
  183. package/dist/cjs/types/allowed-block-types.js +0 -5
  184. package/dist/cjs/utils/keymap.js +0 -38
  185. package/dist/es2019/plugins/editor-disabled/index.js +0 -62
  186. package/dist/es2019/types/allowed-block-types.js +0 -1
  187. package/dist/es2019/utils/keymap.js +0 -33
  188. package/dist/esm/plugins/editor-disabled/index.js +0 -66
  189. package/dist/esm/types/allowed-block-types.js +0 -1
  190. package/dist/esm/utils/keymap.js +0 -33
  191. package/dist/types/plugins/editor-disabled/index.d.ts +0 -13
  192. package/dist/types/types/allowed-block-types.d.ts +0 -1
  193. package/dist/types/utils/keymap.d.ts +0 -11
  194. package/dist/types-ts4.5/plugins/editor-disabled/index.d.ts +0 -13
  195. package/dist/types-ts4.5/types/allowed-block-types.d.ts +0 -1
  196. package/dist/types-ts4.5/utils/keymap.d.ts +0 -11
  197. /package/dist/cjs/{keymaps → plugins/block-type}/consts.js +0 -0
  198. /package/dist/es2019/{keymaps → plugins/block-type}/consts.js +0 -0
  199. /package/dist/esm/{keymaps → plugins/block-type}/consts.js +0 -0
  200. /package/dist/types/{keymaps → plugins/block-type}/consts.d.ts +0 -0
  201. /package/dist/types-ts4.5/{keymaps → plugins/block-type}/consts.d.ts +0 -0
@@ -26,13 +26,11 @@ export default (() => new SafePlugin({
26
26
  /**
27
27
  * The provided selector should be the floating toolbar button that needs focus.
28
28
  */
29
- export function forceFocusSelector(selector, view) {
30
- if (view) {
31
- return view.dispatch(view.state.tr.setMeta(forceFocusStateKey, {
32
- selector
33
- }));
34
- }
35
- }
29
+ export const forceFocusSelector = selector => tr => {
30
+ return tr.setMeta(forceFocusStateKey, {
31
+ selector
32
+ });
33
+ };
36
34
 
37
35
  /**
38
36
  * If a selector is set and the element exists, focus it.
@@ -52,7 +50,13 @@ export function checkShouldForceFocusAndApply(view) {
52
50
  inline: 'nearest'
53
51
  });
54
52
  focusableElement.focus();
55
- forceFocusSelector(null, view);
53
+ const {
54
+ state: {
55
+ tr
56
+ },
57
+ dispatch
58
+ } = view;
59
+ dispatch(forceFocusSelector(null)(tr));
56
60
  }
57
61
  }
58
62
  }
@@ -60,11 +60,12 @@ export const ExtensionsPlaceholder = props => {
60
60
  } = props;
61
61
  const [extensions, setExtensions] = useState([]);
62
62
  useEffect(() => {
63
- if (extensionProvider) {
64
- getExtensions();
65
- }
63
+ getExtensions();
66
64
  async function getExtensions() {
67
- setExtensions(await extensionProvider.getExtensions());
65
+ const provider = await extensionProvider;
66
+ if (provider) {
67
+ setExtensions(await provider.getExtensions());
68
+ }
68
69
  }
69
70
  // leaving dependencies array empty so that this effect runs just once on component mount
70
71
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -405,7 +405,18 @@ class Toolbar extends Component {
405
405
  }
406
406
  }
407
407
  componentWillUnmount() {
408
- forceFocusSelector(null, this.props.editorView);
408
+ const {
409
+ editorView
410
+ } = this.props;
411
+ if (editorView) {
412
+ const {
413
+ state: {
414
+ tr
415
+ },
416
+ dispatch
417
+ } = editorView;
418
+ dispatch(forceFocusSelector(null)(tr));
419
+ }
409
420
  this.resetStyling({
410
421
  table: this.props.node.type.name === 'table'
411
422
  });
@@ -37,7 +37,6 @@ export { default as statusPlugin } from './status';
37
37
  export { default as breakoutPlugin } from './breakout';
38
38
  export { default as alignmentPlugin } from './alignment';
39
39
  export { default as dataConsumerMarkPlugin } from './data-consumer';
40
- export { default as editorDisabledPlugin } from './editor-disabled';
41
40
  export { default as fragmentMarkPlugin } from './fragment';
42
41
  export { default as indentationPlugin } from './indentation';
43
42
  export { default as annotationPlugin } from './annotation';
@@ -75,13 +75,15 @@ export class AltTextEditComponent extends React.Component {
75
75
  });
76
76
  _defineProperty(this, "dispatchCancelEvent", event => {
77
77
  const {
78
- view
78
+ view,
79
+ onEscape
79
80
  } = this.props;
80
81
 
81
82
  // We need to pass down the ESCAPE keymap
82
83
  // because when we focus on the Toolbar, Prosemirror blur,
83
84
  // making all keyboard shortcuts not working
84
85
  view.someProp('handleKeyDown', fn => fn(view, event));
86
+ onEscape === null || onEscape === void 0 ? void 0 : onEscape();
85
87
  });
86
88
  _defineProperty(this, "updateAltText", newAltText => {
87
89
  const {
@@ -6,7 +6,6 @@ import AltTextEdit from '../pm-plugins/alt-text/ui/AltTextEdit';
6
6
  import { CONTAINER_WIDTH_IN_PX } from '../pm-plugins/alt-text/ui/AltTextEdit';
7
7
  import { getMediaNodeFromSelection } from '../utils/media-common';
8
8
  import { ClassNames } from '../pm-plugins/alt-text/style';
9
- import { withOuterListeners } from '@atlaskit/editor-common/ui';
10
9
  import { forceFocusSelector } from '../../floating-toolbar/pm-plugins/force-focus';
11
10
  const testId = 'alt-text-edit-button';
12
11
  export const altTextButton = (intl, state) => {
@@ -26,7 +25,6 @@ export const altTextButton = (intl, state) => {
26
25
  })
27
26
  };
28
27
  };
29
- const AltTextEditWithListeners = withOuterListeners(AltTextEdit);
30
28
  export const altTextEditComponent = options => {
31
29
  return {
32
30
  type: 'custom',
@@ -43,15 +41,21 @@ export const altTextEditComponent = options => {
43
41
  /** Focus should move to the 'Alt text' button when the toolbar closes
44
42
  * and not close the floating toolbar.
45
43
  */
46
- const handleEsc = e => {
47
- forceFocusSelector(`[data-testid="${testId}"]`, view);
44
+ const handleEsc = () => {
45
+ const {
46
+ state: {
47
+ tr
48
+ },
49
+ dispatch
50
+ } = view;
51
+ dispatch(forceFocusSelector(`[data-testid="${testId}"]`)(tr));
48
52
  };
49
- return /*#__PURE__*/React.createElement(AltTextEditWithListeners, {
53
+ return /*#__PURE__*/React.createElement(AltTextEdit, {
50
54
  view: view,
51
55
  key: idx,
52
56
  value: mediaNode.attrs.alt,
53
57
  altTextValidator: options && options.altTextValidator,
54
- handleEscapeKeydown: handleEsc
58
+ onEscape: handleEsc
55
59
  });
56
60
  }
57
61
  };
@@ -68,7 +68,14 @@ export const getLinkingToolbar = (toolbarBaseConfig, mediaLinkingState, state, i
68
68
  /** Focus should move to the 'Add link' button when the toolbar closes
69
69
  * and not close the floating toolbar.
70
70
  */
71
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.floatingToolbar.actions) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.forceFocusSelector(FORCE_FOCUS_SELECTOR, view);
71
+ const {
72
+ state: {
73
+ tr
74
+ },
75
+ dispatch
76
+ } = view;
77
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.floatingToolbar.actions) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.forceFocusSelector(FORCE_FOCUS_SELECTOR)(tr);
78
+ dispatch(tr);
72
79
  },
73
80
  onSubmit: (href, meta) => {
74
81
  setUrlToMedia(href, meta.inputMethod)(view.state, view.dispatch, view);
@@ -18,15 +18,17 @@ import { INPUT_METHOD } from '../../analytics/types/enums';
18
18
  import { mediaLinkToolbarMessages } from './media-linking-toolbar-messages';
19
19
  const validationWrapper = css`
20
20
  line-height: 0;
21
- padding: 12px 24px 12px 0;
22
- margin: 0 4px 0 32px;
21
+ padding: ${"var(--ds-space-150, 12px)"} ${"var(--ds-space-300, 24px)"}
22
+ ${"var(--ds-space-150, 12px)"} 0;
23
+ margin: 0 ${"var(--ds-space-050, 4px)"} 0 ${"var(--ds-space-400, 32px)"};
23
24
  border-top: 1px solid ${`var(--ds-border-danger, ${R400})`};
24
25
  align-items: start;
25
26
  display: flex;
26
27
  flex-direction: column;
27
28
  `;
28
29
  const buttonWrapper = css`
29
- padding: 4px 8px 4px 0px;
30
+ padding: ${"var(--ds-space-050, 4px)"} ${"var(--ds-space-100, 8px)"}
31
+ ${"var(--ds-space-050, 4px)"} 0px;
30
32
  `;
31
33
  export class LinkAddToolbar extends React.PureComponent {
32
34
  constructor(...args) {
@@ -1,7 +1,7 @@
1
1
  import { deleteSelection, splitBlock } from '@atlaskit/editor-prosemirror/commands';
2
2
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { findPositionOfNodeBefore } from '@atlaskit/editor-prosemirror/utils';
4
- import { createParagraphNear, createNewParagraphBelow } from '../../../commands';
4
+ import { createParagraphNear, createNewParagraphBelow } from '@atlaskit/editor-common/utils';
5
5
  import { isTemporary } from '../../../utils';
6
6
  import { mapSlice } from '../../../utils/slice';
7
7
  import { walkUpTreeUntil, removeNestedEmptyEls, unwrap } from '../../../utils/dom';
@@ -4,7 +4,7 @@ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
4
4
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { findParentNodeOfType, findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
6
6
  import { uuid } from '@atlaskit/adf-schema';
7
- import { filterCommand as filter, isEmptySelectionAtStart, deleteEmptyParagraphAndMoveBlockUp, isEmptySelectionAtEnd } from '@atlaskit/editor-common/utils';
7
+ import { filterCommand as filter, isEmptySelectionAtStart, isEmptySelectionAtEnd, deleteEmptyParagraphAndMoveBlockUp } from '@atlaskit/editor-common/utils';
8
8
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INDENT_DIRECTION, INDENT_TYPE, INPUT_METHOD, withAnalytics } from '../../analytics';
9
9
  import { insertTaskDecisionWithAnalytics } from '../commands';
10
10
  import { joinAtCut, liftSelection, wrapSelectionInTaskList } from './commands';
@@ -1,5 +1,5 @@
1
1
  import * as keymaps from '../../../keymaps';
2
- import { keymap } from '../../../utils/keymap';
2
+ import { keymap } from '@atlaskit/editor-common/keymaps';
3
3
  import { redoFromKeyboard, undoFromKeyboard } from '../commands';
4
4
  export function keymapPlugin() {
5
5
  const list = {};
@@ -38,6 +38,7 @@ const colorPickerWrapper = theme => css`
38
38
  `;
39
39
  /* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
40
40
 
41
+ const ColorPaletteWithListeners = withOuterListeners(ColorPalette);
41
42
  const ColorPickerButton = props => {
42
43
  const buttonRef = React.useRef(null);
43
44
  const [isPopupOpen, setIsPopupOpen] = React.useState(false);
@@ -70,7 +71,6 @@ const ColorPickerButton = props => {
70
71
  setIsPopupPositioned(true);
71
72
  return position;
72
73
  }, []);
73
- const ColorPaletteWithListeners = withOuterListeners(ColorPalette);
74
74
  const {
75
75
  onChange,
76
76
  createAnalyticsEvent,
@@ -174,7 +174,7 @@ const ColorPickerButton = props => {
174
174
  width: ${((_props$size2 = props.size) === null || _props$size2 === void 0 ? void 0 : _props$size2.width) || '14px'};
175
175
  height: ${((_props$size3 = props.size) === null || _props$size3 === void 0 ? void 0 : _props$size3.height) || '14px'};
176
176
  padding: 0;
177
- margin: 0px 2px;
177
+ margin: 0px ${"var(--ds-space-025, 2px)"};
178
178
  }
179
179
  &:hover {
180
180
  background: ${themed({
@@ -1,25 +1,9 @@
1
1
  import { css } from '@emotion/react';
2
2
  export { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
3
3
  export { scrollbarStyles } from '@atlaskit/editor-shared-styles/scrollbar';
4
- export const wrapperSmallStyle = css`
5
- margin-left: ${"var(--ds-space-050, 4px)"};
6
- min-width: 40px;
7
- `;
8
4
  export const expandIconWrapperStyle = css`
9
5
  margin-left: -8px;
10
6
  `;
11
- export const buttonContentStyle = css`
12
- display: flex;
13
- min-width: 80px;
14
- align-items: center;
15
- overflow: hidden;
16
- justify-content: center;
17
- flex-direction: column;
18
- padding: ${"var(--ds-space-075, 6px)"};
19
- `;
20
- export const buttonContentReducedSpacingStyle = css`
21
- padding: ${"var(--ds-space-100, 8px)"};
22
- `;
23
7
  export const clickSelectWrapperStyle = css`
24
8
  user-select: all;
25
9
  `;
@@ -1,11 +1,8 @@
1
1
  import { toggleMark } from '@atlaskit/editor-prosemirror/commands';
2
- import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
3
2
  import { JSONTransformer } from '@atlaskit/editor-json-transformer';
4
3
  import { FakeTextCursorSelection } from '../plugins/fake-text-cursor/cursor';
5
4
  import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
6
5
  import { isNodeEmpty } from './document';
7
- import { atTheBeginningOfDoc, atTheEndOfDoc } from './prosemirror/position';
8
- import { isMediaNode } from '@atlaskit/editor-common/utils';
9
6
  export { insideTable } from '@atlaskit/editor-common/core-utils';
10
7
  export { isNodeEmpty, findFarthestParentNode, isSelectionEndOfParagraph, nodesBetweenChanged, getNodesCount } from './document';
11
8
  export { sanitiseMarksInSelection } from './mark';
@@ -18,41 +15,6 @@ function isMarkTypeCompatibleWithMark(markType, mark) {
18
15
  function isMarkTypeAllowedInNode(markType, state) {
19
16
  return toggleMark(markType)(state);
20
17
  }
21
- export function canMoveUp(state) {
22
- const {
23
- selection
24
- } = state;
25
- /**
26
- * If there's a media element on the selection it will use a gap cursor to move
27
- */
28
- if (selection instanceof NodeSelection && isMediaNode(selection.node)) {
29
- return true;
30
- }
31
- if (selection instanceof TextSelection) {
32
- if (!selection.empty) {
33
- return true;
34
- }
35
- }
36
- return !atTheBeginningOfDoc(state);
37
- }
38
- export function canMoveDown(state) {
39
- const {
40
- selection
41
- } = state;
42
-
43
- /**
44
- * If there's a media element on the selection it will use a gap cursor to move
45
- */
46
- if (selection instanceof NodeSelection && isMediaNode(selection.node)) {
47
- return true;
48
- }
49
- if (selection instanceof TextSelection) {
50
- if (!selection.empty) {
51
- return true;
52
- }
53
- }
54
- return !atTheEndOfDoc(state);
55
- }
56
18
  export function isSelectionInsideLastNodeInDocument(selection) {
57
19
  const docNode = selection.$anchor.node(0);
58
20
  const rootNode = selection.$anchor.node(1);
@@ -177,48 +139,6 @@ export function whichTransitionEvent() {
177
139
  }
178
140
  return;
179
141
  }
180
-
181
- /**
182
- * Function will create a list of wrapper blocks present in a selection.
183
- */
184
- function getSelectedWrapperNodes(state) {
185
- const nodes = [];
186
- if (state.selection) {
187
- const {
188
- $from,
189
- $to
190
- } = state.selection;
191
- const {
192
- blockquote,
193
- panel,
194
- orderedList,
195
- bulletList,
196
- listItem,
197
- codeBlock,
198
- decisionItem,
199
- decisionList,
200
- taskItem,
201
- taskList
202
- } = state.schema.nodes;
203
- state.doc.nodesBetween($from.pos, $to.pos, node => {
204
- if (node.isBlock && [blockquote, panel, orderedList, bulletList, listItem, codeBlock, decisionItem, decisionList, taskItem, taskList].indexOf(node.type) >= 0) {
205
- nodes.push(node.type);
206
- }
207
- });
208
- }
209
- return nodes;
210
- }
211
-
212
- /**
213
- * Function will check if changing block types: Paragraph, Heading is enabled.
214
- */
215
- export function areBlockTypesDisabled(state) {
216
- const nodesTypes = getSelectedWrapperNodes(state);
217
- const {
218
- panel
219
- } = state.schema.nodes;
220
- return nodesTypes.filter(type => type !== panel).length > 0;
221
- }
222
142
  export const isTemporary = id => {
223
143
  return id.indexOf('temporary:') === 0;
224
144
  };
@@ -1,7 +1,8 @@
1
- import { canJoin, findWrapping } from '@atlaskit/editor-prosemirror/transform';
2
- import { createRule } from '@atlaskit/prosemirror-input-rules';
3
1
  import { addAnalytics } from '../plugins/analytics';
4
- import { JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST } from '@atlaskit/editor-common/analytics';
2
+ /**
3
+ * @private
4
+ * @deprecated Use import {inputRuleWithAnalytics} from "@atlaskit/editor-common/utils"; instead
5
+ */
5
6
  export const ruleWithAnalytics = getPayload => {
6
7
  return originalRule => {
7
8
  const onHandlerApply = (state, tr, matchResult) => {
@@ -16,62 +17,4 @@ export const ruleWithAnalytics = getPayload => {
16
17
  onHandlerApply
17
18
  };
18
19
  };
19
- };
20
- export const createWrappingTextBlockRule = ({
21
- match,
22
- nodeType,
23
- getAttrs
24
- }) => {
25
- const handler = (state, match, start, end) => {
26
- const fixedStart = Math.max(start, 1);
27
- const $start = state.doc.resolve(fixedStart);
28
- const attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
29
- const nodeBefore = $start.node(-1);
30
- if (nodeBefore && !nodeBefore.canReplaceWith($start.index(-1), $start.indexAfter(-1), nodeType)) {
31
- return null;
32
- }
33
- return state.tr.delete(fixedStart, end).setBlockType(fixedStart, fixedStart, nodeType, attrs);
34
- };
35
- return createRule(match, handler);
36
- };
37
- export const createWrappingJoinRule = ({
38
- match,
39
- nodeType,
40
- getAttrs,
41
- joinPredicate
42
- }) => {
43
- const handler = (state, match, start, end) => {
44
- const attrs = (getAttrs instanceof Function ? getAttrs(match) : getAttrs) || {};
45
- const tr = state.tr;
46
- const fixedStart = Math.max(start, 1);
47
- tr.delete(fixedStart, end);
48
- const $start = tr.doc.resolve(fixedStart);
49
- const range = $start.blockRange();
50
- const wrapping = range && findWrapping(range, nodeType, attrs);
51
- if (!wrapping || !range) {
52
- return null;
53
- }
54
- const parentNodePosMapped = tr.mapping.map(range.start);
55
- const parentNode = tr.doc.nodeAt(parentNodePosMapped);
56
- const lastWrap = wrapping[wrapping.length - 1];
57
- if (parentNode && lastWrap) {
58
- const allowedMarks = lastWrap.type.allowedMarks(parentNode.marks) || [];
59
- tr.setNodeMarkup(parentNodePosMapped, parentNode.type, parentNode.attrs, allowedMarks);
60
- }
61
- tr.wrap(range, wrapping);
62
- const before = tr.doc.resolve(fixedStart - 1).nodeBefore;
63
- if (before && before.type === nodeType && canJoin(tr.doc, fixedStart - 1) && (!joinPredicate || joinPredicate(match, before, JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST.JOINED_TO_LIST_ABOVE))) {
64
- tr.join(fixedStart - 1);
65
- }
66
- return tr;
67
- };
68
- return createRule(match, handler);
69
- };
70
- export const createJoinNodesRule = (match, nodeType) => {
71
- return createWrappingJoinRule({
72
- nodeType,
73
- match,
74
- getAttrs: {},
75
- joinPredicate: (_, node) => node.type === nodeType
76
- });
77
20
  };
@@ -24,39 +24,6 @@ export const isMarkExcluded = (type, marks) => {
24
24
  }
25
25
  return false;
26
26
  };
27
- const not = fn => arg => !fn(arg);
28
- export const removeBlockMarks = (state, marks) => {
29
- const {
30
- selection,
31
- schema
32
- } = state;
33
- let {
34
- tr
35
- } = state;
36
-
37
- // Marks might not exist in Schema
38
- const marksToRemove = marks.filter(Boolean);
39
- if (marksToRemove.length === 0) {
40
- return undefined;
41
- }
42
-
43
- /** Saves an extra dispatch */
44
- let blockMarksExists = false;
45
- const hasMark = mark => marksToRemove.indexOf(mark.type) > -1;
46
- /**
47
- * When you need to toggle the selection
48
- * when another type which does not allow alignment is applied
49
- */
50
- state.doc.nodesBetween(selection.from, selection.to, (node, pos) => {
51
- if (node.type === schema.nodes.paragraph && node.marks.some(hasMark)) {
52
- blockMarksExists = true;
53
- const resolvedPos = state.doc.resolve(pos);
54
- const withoutBlockMarks = node.marks.filter(not(hasMark));
55
- tr = tr.setNodeMarkup(resolvedPos.pos, undefined, node.attrs, withoutBlockMarks);
56
- }
57
- });
58
- return blockMarksExists ? tr : undefined;
59
- };
60
27
 
61
28
  /**
62
29
  * Removes marks from nodes in the current selection that are not supported
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.9.2";
2
+ export const version = "187.10.1";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.9.2",
3
+ "version": "187.10.1",
4
4
  "sideEffects": false
5
5
  }
@@ -1,126 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
- import { Fragment } from '@atlaskit/editor-prosemirror/model';
5
- import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
4
+ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
5
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
7
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, withAnalytics } from '../plugins/analytics';
8
- import { canMoveDown, canMoveUp } from '../utils';
9
- export function preventDefault() {
10
- return function () {
11
- return true;
12
- };
13
- }
14
- export function insertNewLine() {
15
- return function (state, dispatch) {
16
- var $from = state.selection.$from;
17
- var parent = $from.parent;
18
- var hardBreak = state.schema.nodes.hardBreak;
19
- if (hardBreak) {
20
- var hardBreakNode = hardBreak.createChecked();
21
- if (parent && parent.type.validContent(Fragment.from(hardBreakNode))) {
22
- if (dispatch) {
23
- dispatch(state.tr.replaceSelectionWith(hardBreakNode, false));
24
- }
25
- return true;
26
- }
27
- }
28
- if (state.selection instanceof TextSelection) {
29
- if (dispatch) {
30
- dispatch(state.tr.insertText('\n'));
31
- }
32
- return true;
33
- }
34
- return false;
35
- };
36
- }
37
- export var insertNewLineWithAnalytics = withAnalytics({
38
- action: ACTION.INSERTED,
39
- actionSubject: ACTION_SUBJECT.TEXT,
40
- actionSubjectId: ACTION_SUBJECT_ID.LINE_BREAK,
41
- eventType: EVENT_TYPE.TRACK
42
- })(insertNewLine());
43
- export var createNewParagraphAbove = function createNewParagraphAbove(state, dispatch) {
44
- var append = false;
45
- if (!canMoveUp(state) && canCreateParagraphNear(state)) {
46
- createParagraphNear(append)(state, dispatch);
47
- return true;
48
- }
49
- return false;
50
- };
51
- export var createNewParagraphBelow = function createNewParagraphBelow(state, dispatch) {
52
- var append = true;
53
- if (!canMoveDown(state) && canCreateParagraphNear(state)) {
54
- createParagraphNear(append)(state, dispatch);
55
- return true;
56
- }
57
- return false;
58
- };
59
- function canCreateParagraphNear(state) {
60
- var $from = state.selection.$from;
61
- var node = $from.node($from.depth);
62
- var insideCodeBlock = !!node && node.type === state.schema.nodes.codeBlock;
63
- var isNodeSelection = state.selection instanceof NodeSelection;
64
- return $from.depth > 1 || isNodeSelection || insideCodeBlock;
65
- }
66
- export function createParagraphNear() {
67
- var append = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
68
- return function (state, dispatch) {
69
- var paragraph = state.schema.nodes.paragraph;
70
- if (!paragraph) {
71
- return false;
72
- }
73
- var insertPos;
74
- if (state.selection instanceof TextSelection) {
75
- if (topLevelNodeIsEmptyTextBlock(state)) {
76
- return false;
77
- }
78
- insertPos = getInsertPosFromTextBlock(state, append);
79
- } else {
80
- insertPos = getInsertPosFromNonTextBlock(state, append);
81
- }
82
- var tr = state.tr.insert(insertPos, paragraph.createAndFill());
83
- tr.setSelection(TextSelection.create(tr.doc, insertPos + 1));
84
- if (dispatch) {
85
- dispatch(tr);
86
- }
87
- return true;
88
- };
89
- }
90
- function getInsertPosFromTextBlock(state, append) {
91
- var _state$selection = state.selection,
92
- $from = _state$selection.$from,
93
- $to = _state$selection.$to;
94
- var pos;
95
- if (!append) {
96
- pos = $from.start(0);
97
- } else {
98
- pos = $to.end(0);
99
- }
100
- return pos;
101
- }
102
- function getInsertPosFromNonTextBlock(state, append) {
103
- var _state$selection2 = state.selection,
104
- $from = _state$selection2.$from,
105
- $to = _state$selection2.$to;
106
- var nodeAtSelection = state.selection instanceof NodeSelection && state.doc.nodeAt(state.selection.$anchor.pos);
107
- var isMediaSelection = nodeAtSelection && nodeAtSelection.type.name === 'mediaGroup';
108
- var pos;
109
- if (!append) {
110
- // The start position is different with text block because it starts from 0
111
- pos = $from.start($from.depth);
112
- // The depth is different with text block because it starts from 0
113
- pos = $from.depth > 0 && !isMediaSelection ? pos - 1 : pos;
114
- } else {
115
- pos = $to.end($to.depth);
116
- pos = $to.depth > 0 && !isMediaSelection ? pos + 1 : pos;
117
- }
118
- return pos;
119
- }
120
- function topLevelNodeIsEmptyTextBlock(state) {
121
- var topLevelNode = state.selection.$from.node(1);
122
- return topLevelNode.isTextblock && topLevelNode.type !== state.schema.nodes.codeBlock && topLevelNode.nodeSize === 2;
123
- }
124
6
  export function addParagraphAtEnd(tr) {
125
7
  var paragraph = tr.doc.type.schema.nodes.paragraph,
126
8
  doc = tr.doc;
@@ -144,9 +26,9 @@ export function createParagraphAtEnd() {
144
26
  }
145
27
  export var changeImageAlignment = function changeImageAlignment(align) {
146
28
  return function (state, dispatch) {
147
- var _state$selection3 = state.selection,
148
- from = _state$selection3.from,
149
- to = _state$selection3.to;
29
+ var _state$selection = state.selection,
30
+ from = _state$selection.from,
31
+ to = _state$selection.to;
150
32
  var tr = state.tr;
151
33
  state.doc.nodesBetween(from, to, function (node, pos) {
152
34
  if (node.type === state.schema.nodes.mediaSingle) {
@@ -205,9 +87,9 @@ export var toggleBlockMark = function toggleBlockMark(markType, getAttrs, allowe
205
87
  markApplied = toggleBlockMarkOnRange(pos, pos + cell.nodeSize, tr, state);
206
88
  });
207
89
  } else {
208
- var _state$selection4 = state.selection,
209
- from = _state$selection4.from,
210
- to = _state$selection4.to;
90
+ var _state$selection2 = state.selection,
91
+ from = _state$selection2.from,
92
+ to = _state$selection2.to;
211
93
  markApplied = toggleBlockMarkOnRange(from, to, tr, state);
212
94
  }
213
95
  if (markApplied && tr.docChanged) {
@@ -8,7 +8,7 @@ import textFormattingPlugin from '../../../plugins/text-formatting';
8
8
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
9
9
  import unsupportedContentPlugin from '../../../plugins/unsupported-content';
10
10
  import basePlugin from '../../../plugins/base';
11
- import editorDisabledPlugin from '../../../plugins/editor-disabled';
11
+ import { editorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
12
12
  import typeAheadPlugin from '../../../plugins/type-ahead';
13
13
  import submitEditorPlugin from '../../../plugins/submit-editor';
14
14
  import fakeTextCursorPlugin from '../../../plugins/fake-text-cursor';
@@ -14,7 +14,7 @@ import newlinePreserveMarksPlugin from './pm-plugins/newline-preserve-marks';
14
14
  import inlineCursorTargetPlugin from './pm-plugins/inline-cursor-target';
15
15
  import betterTypeHistoryPlugin from './pm-plugins/better-type-history';
16
16
  import scrollGutter from './pm-plugins/scroll-gutter';
17
- import { keymap } from '../../utils/keymap';
17
+ import { keymap } from '@atlaskit/editor-common/keymaps';
18
18
  import frozenEditor from './pm-plugins/frozen-editor';
19
19
  import compositionPlugin from './pm-plugins/composition';
20
20
  // Chrome >= 88