@atlaskit/editor-core 187.17.2 → 187.17.3

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 (41) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/labs/next/presets/default.js +2 -1
  3. package/dist/cjs/plugins/base/index.js +5 -12
  4. package/dist/cjs/plugins/media/index.js +3 -2
  5. package/dist/cjs/plugins/media/next-plugin-type.js +5 -0
  6. package/dist/cjs/plugins/media/ui/MediaPicker/index.js +35 -26
  7. package/dist/cjs/plugins/placeholder/index.js +10 -9
  8. package/dist/cjs/version-wrapper.js +1 -1
  9. package/dist/cjs/version.json +1 -1
  10. package/dist/es2019/labs/next/presets/default.js +2 -1
  11. package/dist/es2019/plugins/base/index.js +0 -6
  12. package/dist/es2019/plugins/media/index.js +3 -2
  13. package/dist/es2019/plugins/media/next-plugin-type.js +1 -0
  14. package/dist/es2019/plugins/media/ui/MediaPicker/index.js +37 -26
  15. package/dist/es2019/plugins/placeholder/index.js +13 -11
  16. package/dist/es2019/version-wrapper.js +1 -1
  17. package/dist/es2019/version.json +1 -1
  18. package/dist/esm/labs/next/presets/default.js +2 -1
  19. package/dist/esm/plugins/base/index.js +5 -12
  20. package/dist/esm/plugins/media/index.js +3 -2
  21. package/dist/esm/plugins/media/next-plugin-type.js +1 -0
  22. package/dist/esm/plugins/media/ui/MediaPicker/index.js +35 -26
  23. package/dist/esm/plugins/placeholder/index.js +11 -11
  24. package/dist/esm/version-wrapper.js +1 -1
  25. package/dist/esm/version.json +1 -1
  26. package/dist/types/plugins/media/index.d.ts +3 -26
  27. package/dist/types/plugins/media/next-plugin-type.d.ts +27 -0
  28. package/dist/types/plugins/media/ui/MediaPicker/index.d.ts +4 -2
  29. package/dist/types/plugins/placeholder/index.d.ts +4 -2
  30. package/dist/types-ts4.5/plugins/media/index.d.ts +3 -26
  31. package/dist/types-ts4.5/plugins/media/next-plugin-type.d.ts +27 -0
  32. package/dist/types-ts4.5/plugins/media/ui/MediaPicker/index.d.ts +4 -2
  33. package/dist/types-ts4.5/plugins/placeholder/index.d.ts +6 -2
  34. package/package.json +3 -2
  35. package/report.api.md +23 -18
  36. package/tmp/api-report-tmp.d.ts +20 -15
  37. package/dist/cjs/plugins/base/pm-plugins/focus-handler.js +0 -56
  38. package/dist/es2019/plugins/base/pm-plugins/focus-handler.js +0 -44
  39. package/dist/esm/plugins/base/pm-plugins/focus-handler.js +0 -48
  40. package/dist/types/plugins/base/pm-plugins/focus-handler.d.ts +0 -6
  41. package/dist/types-ts4.5/plugins/base/pm-plugins/focus-handler.d.ts +0 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 187.17.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`7a438d76a8a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7a438d76a8a) - [ED-16733] Extract Focus plugin to its own plugin
8
+ - Updated dependencies
9
+
3
10
  ## 187.17.2
4
11
 
5
12
  ### Patch Changes
@@ -14,6 +14,7 @@ var _textFormatting = _interopRequireDefault(require("../../../plugins/text-form
14
14
  var _editorPluginWidth = require("@atlaskit/editor-plugin-width");
15
15
  var _unsupportedContent = _interopRequireDefault(require("../../../plugins/unsupported-content"));
16
16
  var _base = _interopRequireDefault(require("../../../plugins/base"));
17
+ var _editorPluginFocus = require("@atlaskit/editor-plugin-focus");
17
18
  var _editorPluginEditorDisabled = require("@atlaskit/editor-plugin-editor-disabled");
18
19
  var _typeAhead = _interopRequireDefault(require("../../../plugins/type-ahead"));
19
20
  var _submitEditor = _interopRequireDefault(require("../../../plugins/submit-editor"));
@@ -60,7 +61,7 @@ function createDefaultPreset(options) {
60
61
  }]);
61
62
  }
62
63
  return builder;
63
- }).add([_paste.default, options.paste]).add(_clipboard.default).add([_base.default, options.base]).add(_editorPluginDecorations.decorationsPlugin).maybeAdd(_undoRedo.default, function (p, builder) {
64
+ }).add([_paste.default, options.paste]).add(_clipboard.default).add(_editorPluginFocus.focusPlugin).add([_base.default, options.base]).add(_editorPluginDecorations.decorationsPlugin).maybeAdd(_undoRedo.default, function (p, builder) {
64
65
  var _options$featureFlags;
65
66
  // The undo redo plugin needs to be add before the blockTypePlugin
66
67
  if ((_options$featureFlags = options.featureFlags) !== null && _options$featureFlags !== void 0 && _options$featureFlags.undoRedoButtons) {
@@ -11,7 +11,6 @@ var _history = require("@atlaskit/editor-prosemirror/history");
11
11
  var _utils = require("@atlaskit/editor-common/utils");
12
12
  var _adfSchema = require("@atlaskit/adf-schema");
13
13
  var _filterSteps = _interopRequireDefault(require("./pm-plugins/filter-steps"));
14
- var _focusHandler = _interopRequireDefault(require("./pm-plugins/focus-handler"));
15
14
  var _fixChrome88Selection = _interopRequireDefault(require("./pm-plugins/fix-chrome-88-selection"));
16
15
  var _disableSpellChecking = _interopRequireDefault(require("./pm-plugins/disable-spell-checking"));
17
16
  var _contextIdentifier = _interopRequireDefault(require("./pm-plugins/context-identifier"));
@@ -55,19 +54,13 @@ var basePlugin = function basePlugin(options, api) {
55
54
  }
56
55
  });
57
56
  plugins.push({
58
- name: 'focusHandlerPlugin',
59
- plugin: function plugin(_ref2) {
60
- var dispatch = _ref2.dispatch;
61
- return (0, _focusHandler.default)(dispatch);
62
- }
63
- }, {
64
57
  name: 'newlinePreserveMarksPlugin',
65
58
  plugin: _newlinePreserveMarks.default
66
59
  }, {
67
60
  name: 'frozenEditor',
68
- plugin: function plugin(_ref3) {
61
+ plugin: function plugin(_ref2) {
69
62
  var _options$inputTrackin;
70
- var dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent;
63
+ var dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent;
71
64
  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 ? (0, _frozenEditor.default)(dispatchAnalyticsEvent, options.inputTracking, options.browserFreezeTracking, options.ufo) : undefined;
72
65
  }
73
66
  }, {
@@ -91,9 +84,9 @@ var basePlugin = function basePlugin(options, api) {
91
84
  }
92
85
  }, {
93
86
  name: 'contextIdentifier',
94
- plugin: function plugin(_ref4) {
95
- var dispatch = _ref4.dispatch,
96
- providerFactory = _ref4.providerFactory;
87
+ plugin: function plugin(_ref3) {
88
+ var dispatch = _ref3.dispatch,
89
+ providerFactory = _ref3.providerFactory;
97
90
  return (0, _contextIdentifier.default)(dispatch, providerFactory);
98
91
  }
99
92
  });
@@ -34,8 +34,8 @@ var _MediaPicker = require("./ui/MediaPicker");
34
34
  var _messages = require("../insert-block/ui/ToolbarInsertBlock/messages");
35
35
  var _mediaNodeView = require("./nodeviews/mediaNodeView");
36
36
  var _mediaInline = require("./nodeviews/mediaInline");
37
- var _pluginKey = require("./pm-plugins/plugin-key");
38
37
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
38
+ var _pluginKey = require("./pm-plugins/plugin-key");
39
39
  var _mediaSingle2 = require("./utils/media-single");
40
40
  var mediaPlugin = function mediaPlugin() {
41
41
  var _api$dependencies, _api$dependencies$fea;
@@ -210,7 +210,8 @@ var mediaPlugin = function mediaPlugin() {
210
210
  return /*#__PURE__*/_react.default.createElement(_MediaPicker.MediaPickerComponents, {
211
211
  editorDomElement: editorView.dom,
212
212
  mediaState: mediaState,
213
- appearance: appearance
213
+ appearance: appearance,
214
+ api: api
214
215
  });
215
216
  }
216
217
  }));
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -16,10 +16,35 @@ var _react = _interopRequireDefault(require("react"));
16
16
  var _ClipboardWrapper = require("./ClipboardWrapper");
17
17
  var _DropzoneWrapper = require("./DropzoneWrapper");
18
18
  var _BrowserWrapper = require("./BrowserWrapper");
19
- var _WithPluginState = _interopRequireDefault(require("../../../../ui/WithPluginState"));
20
- var _focusHandler = require("../../../../plugins/base/pm-plugins/focus-handler");
19
+ var _hooks = require("@atlaskit/editor-common/hooks");
21
20
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
22
21
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
22
+ var MediaPicker = function MediaPicker(_ref) {
23
+ var api = _ref.api,
24
+ isPopupOpened = _ref.isPopupOpened,
25
+ appearance = _ref.appearance,
26
+ mediaState = _ref.mediaState,
27
+ onBrowseFn = _ref.onBrowseFn,
28
+ editorDomElement = _ref.editorDomElement;
29
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['focus']),
30
+ focusState = _useSharedPluginState.focusState;
31
+ var featureFlags = mediaState.mediaOptions && mediaState.mediaOptions.featureFlags;
32
+ var clipboard = focusState !== null && focusState !== void 0 && focusState.hasFocus ? /*#__PURE__*/_react.default.createElement(_ClipboardWrapper.ClipboardWrapper, {
33
+ mediaState: mediaState,
34
+ featureFlags: featureFlags
35
+ }) : null;
36
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, clipboard, /*#__PURE__*/_react.default.createElement(_DropzoneWrapper.DropzoneWrapper, {
37
+ mediaState: mediaState,
38
+ isActive: !isPopupOpened,
39
+ featureFlags: featureFlags,
40
+ editorDomElement: editorDomElement,
41
+ appearance: appearance
42
+ }), /*#__PURE__*/_react.default.createElement(_BrowserWrapper.BrowserWrapper, {
43
+ onBrowseFn: onBrowseFn,
44
+ mediaState: mediaState,
45
+ featureFlags: featureFlags
46
+ }));
47
+ };
23
48
  var MediaPickerComponents = /*#__PURE__*/function (_React$Component) {
24
49
  (0, _inherits2.default)(MediaPickerComponents, _React$Component);
25
50
  var _super = _createSuper(MediaPickerComponents);
@@ -53,35 +78,19 @@ var MediaPickerComponents = /*#__PURE__*/function (_React$Component) {
53
78
  }, {
54
79
  key: "render",
55
80
  value: function render() {
56
- var _this3 = this;
57
81
  var _this$props = this.props,
82
+ api = _this$props.api,
58
83
  mediaState = _this$props.mediaState,
59
84
  editorDomElement = _this$props.editorDomElement,
60
85
  appearance = _this$props.appearance;
61
86
  var isPopupOpened = this.state.isPopupOpened;
62
- var featureFlags = mediaState.mediaOptions && mediaState.mediaOptions.featureFlags;
63
- return /*#__PURE__*/_react.default.createElement(_WithPluginState.default, {
64
- plugins: {
65
- focus: _focusHandler.focusStateKey
66
- },
67
- render: function render(_ref) {
68
- var focus = _ref.focus;
69
- var clipboard = focus ? /*#__PURE__*/_react.default.createElement(_ClipboardWrapper.ClipboardWrapper, {
70
- mediaState: mediaState,
71
- featureFlags: featureFlags
72
- }) : null;
73
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, clipboard, /*#__PURE__*/_react.default.createElement(_DropzoneWrapper.DropzoneWrapper, {
74
- mediaState: mediaState,
75
- isActive: !isPopupOpened,
76
- featureFlags: featureFlags,
77
- editorDomElement: editorDomElement,
78
- appearance: appearance
79
- }), /*#__PURE__*/_react.default.createElement(_BrowserWrapper.BrowserWrapper, {
80
- onBrowseFn: _this3.onBrowseFn,
81
- mediaState: mediaState,
82
- featureFlags: featureFlags
83
- }));
84
- }
87
+ return /*#__PURE__*/_react.default.createElement(MediaPicker, {
88
+ mediaState: mediaState,
89
+ editorDomElement: editorDomElement,
90
+ appearance: appearance,
91
+ isPopupOpened: isPopupOpened,
92
+ onBrowseFn: this.onBrowseFn,
93
+ api: api
85
94
  });
86
95
  }
87
96
  }]);
@@ -10,7 +10,6 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
10
10
  var _utils = require("@atlaskit/editor-common/utils");
11
11
  var _state = require("@atlaskit/editor-prosemirror/state");
12
12
  var _view = require("@atlaskit/editor-prosemirror/view");
13
- var _focusHandler = require("../base/pm-plugins/focus-handler");
14
13
  var _utils2 = require("../type-ahead/utils");
15
14
  var _composition = require("../base/pm-plugins/composition");
16
15
  var pluginKey = new _state.PluginKey('placeholderPlugin');
@@ -62,8 +61,7 @@ function setPlaceHolderState(placeholderText, pos) {
62
61
  var emptyPlaceholder = {
63
62
  hasPlaceholder: false
64
63
  };
65
- function createPlaceHolderStateFrom(editorState, defaultPlaceholderText, bracketPlaceholderText) {
66
- var isEditorFocused = _focusHandler.focusStateKey.getState(editorState);
64
+ function createPlaceHolderStateFrom(isEditorFocused, editorState, defaultPlaceholderText, bracketPlaceholderText) {
67
65
  if ((0, _utils2.isTypeAheadOpen)(editorState)) {
68
66
  return emptyPlaceholder;
69
67
  }
@@ -78,7 +76,7 @@ function createPlaceHolderStateFrom(editorState, defaultPlaceholderText, bracket
78
76
  }
79
77
  return emptyPlaceholder;
80
78
  }
81
- function createPlugin(defaultPlaceholderText, bracketPlaceholderText) {
79
+ function createPlugin(defaultPlaceholderText, bracketPlaceholderText, api) {
82
80
  if (!defaultPlaceholderText && !bracketPlaceholderText) {
83
81
  return;
84
82
  }
@@ -86,19 +84,22 @@ function createPlugin(defaultPlaceholderText, bracketPlaceholderText) {
86
84
  key: pluginKey,
87
85
  state: {
88
86
  init: function init(_, state) {
89
- return createPlaceHolderStateFrom(state, defaultPlaceholderText, bracketPlaceholderText);
87
+ var _api$dependencies$foc;
88
+ return createPlaceHolderStateFrom(Boolean(api === null || api === void 0 ? void 0 : (_api$dependencies$foc = api.dependencies.focus.sharedState.currentState()) === null || _api$dependencies$foc === void 0 ? void 0 : _api$dependencies$foc.hasFocus), state, defaultPlaceholderText, bracketPlaceholderText);
90
89
  },
91
90
  apply: function apply(tr, _oldPluginState, _oldEditorState, newEditorState) {
91
+ var _api$dependencies$foc2;
92
92
  var meta = tr.getMeta(pluginKey);
93
+ var isEditorFocused = Boolean(api === null || api === void 0 ? void 0 : (_api$dependencies$foc2 = api.dependencies.focus.sharedState.currentState()) === null || _api$dependencies$foc2 === void 0 ? void 0 : _api$dependencies$foc2.hasFocus);
93
94
  if (meta) {
94
95
  if (meta.removePlaceholder) {
95
96
  return emptyPlaceholder;
96
97
  }
97
98
  if (meta.applyPlaceholderIfEmpty) {
98
- return createPlaceHolderStateFrom(newEditorState, defaultPlaceholderText, bracketPlaceholderText);
99
+ return createPlaceHolderStateFrom(isEditorFocused, newEditorState, defaultPlaceholderText, bracketPlaceholderText);
99
100
  }
100
101
  }
101
- return createPlaceHolderStateFrom(newEditorState, defaultPlaceholderText, bracketPlaceholderText);
102
+ return createPlaceHolderStateFrom(isEditorFocused, newEditorState, defaultPlaceholderText, bracketPlaceholderText);
102
103
  }
103
104
  },
104
105
  props: {
@@ -115,14 +116,14 @@ function createPlugin(defaultPlaceholderText, bracketPlaceholderText) {
115
116
  }
116
117
  });
117
118
  }
118
- var placeholderPlugin = function placeholderPlugin(options) {
119
+ var placeholderPlugin = function placeholderPlugin(options, api) {
119
120
  return {
120
121
  name: 'placeholder',
121
122
  pmPlugins: function pmPlugins() {
122
123
  return [{
123
124
  name: 'placeholder',
124
125
  plugin: function plugin() {
125
- return createPlugin(options && options.placeholder, options && options.placeholderBracketHint);
126
+ return createPlugin(options && options.placeholder, options && options.placeholderBracketHint, api);
126
127
  }
127
128
  }];
128
129
  }
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = "@atlaskit/editor-core";
8
8
  exports.name = name;
9
- var version = "187.17.2";
9
+ var version = "187.17.3";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.17.2",
3
+ "version": "187.17.3",
4
4
  "sideEffects": false
5
5
  }
@@ -8,6 +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 { focusPlugin } from '@atlaskit/editor-plugin-focus';
11
12
  import { editorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
12
13
  import typeAheadPlugin from '../../../plugins/type-ahead';
13
14
  import submitEditorPlugin from '../../../plugins/submit-editor';
@@ -56,7 +57,7 @@ export function createDefaultPreset(options) {
56
57
  }]);
57
58
  }
58
59
  return builder;
59
- }).add([pastePlugin, options.paste]).add(clipboardPlugin).add([basePlugin, options.base]).add(decorationsPlugin).maybeAdd(undoRedoPlugin, (p, builder) => {
60
+ }).add([pastePlugin, options.paste]).add(clipboardPlugin).add(focusPlugin).add([basePlugin, options.base]).add(decorationsPlugin).maybeAdd(undoRedoPlugin, (p, builder) => {
60
61
  var _options$featureFlags;
61
62
  // The undo redo plugin needs to be add before the blockTypePlugin
62
63
  if ((_options$featureFlags = options.featureFlags) !== null && _options$featureFlags !== void 0 && _options$featureFlags.undoRedoButtons) {
@@ -3,7 +3,6 @@ import { history } from '@atlaskit/editor-prosemirror/history';
3
3
  import { browser } from '@atlaskit/editor-common/utils';
4
4
  import { doc, paragraph, text } from '@atlaskit/adf-schema';
5
5
  import filterStepsPlugin from './pm-plugins/filter-steps';
6
- import focusHandlerPlugin from './pm-plugins/focus-handler';
7
6
  import fixChrome88SelectionPlugin from './pm-plugins/fix-chrome-88-selection';
8
7
  import disableSpellcheckingPlugin from './pm-plugins/disable-spell-checking';
9
8
  import contextIdentifierPlugin from './pm-plugins/context-identifier';
@@ -41,11 +40,6 @@ const basePlugin = (options, api) => {
41
40
  plugin: () => options && options.allowInlineCursorTarget ? inlineCursorTargetPlugin() : undefined
42
41
  });
43
42
  plugins.push({
44
- name: 'focusHandlerPlugin',
45
- plugin: ({
46
- dispatch
47
- }) => focusHandlerPlugin(dispatch)
48
- }, {
49
43
  name: 'newlinePreserveMarksPlugin',
50
44
  plugin: newlinePreserveMarksPlugin
51
45
  }, {
@@ -21,8 +21,8 @@ import { MediaPickerComponents } from './ui/MediaPicker';
21
21
  import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
22
22
  import { ReactMediaNode } from './nodeviews/mediaNodeView';
23
23
  import { ReactMediaInlineNode } from './nodeviews/mediaInline';
24
- import { stateKey } from './pm-plugins/plugin-key';
25
24
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
25
+ import { stateKey } from './pm-plugins/plugin-key';
26
26
  export { insertMediaSingleNode } from './utils/media-single';
27
27
  const mediaPlugin = (options = {}, api) => {
28
28
  var _api$dependencies, _api$dependencies$fea;
@@ -197,7 +197,8 @@ const mediaPlugin = (options = {}, api) => {
197
197
  }) => /*#__PURE__*/React.createElement(MediaPickerComponents, {
198
198
  editorDomElement: editorView.dom,
199
199
  mediaState: mediaState,
200
- appearance: appearance
200
+ appearance: appearance,
201
+ api: api
201
202
  })
202
203
  }));
203
204
  },
@@ -0,0 +1 @@
1
+ export {};
@@ -3,8 +3,35 @@ import React from 'react';
3
3
  import { ClipboardWrapper } from './ClipboardWrapper';
4
4
  import { DropzoneWrapper } from './DropzoneWrapper';
5
5
  import { BrowserWrapper } from './BrowserWrapper';
6
- import WithPluginState from '../../../../ui/WithPluginState';
7
- import { focusStateKey } from '../../../../plugins/base/pm-plugins/focus-handler';
6
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
7
+ const MediaPicker = ({
8
+ api,
9
+ isPopupOpened,
10
+ appearance,
11
+ mediaState,
12
+ onBrowseFn,
13
+ editorDomElement
14
+ }) => {
15
+ const {
16
+ focusState
17
+ } = useSharedPluginState(api, ['focus']);
18
+ const featureFlags = mediaState.mediaOptions && mediaState.mediaOptions.featureFlags;
19
+ const clipboard = focusState !== null && focusState !== void 0 && focusState.hasFocus ? /*#__PURE__*/React.createElement(ClipboardWrapper, {
20
+ mediaState: mediaState,
21
+ featureFlags: featureFlags
22
+ }) : null;
23
+ return /*#__PURE__*/React.createElement(React.Fragment, null, clipboard, /*#__PURE__*/React.createElement(DropzoneWrapper, {
24
+ mediaState: mediaState,
25
+ isActive: !isPopupOpened,
26
+ featureFlags: featureFlags,
27
+ editorDomElement: editorDomElement,
28
+ appearance: appearance
29
+ }), /*#__PURE__*/React.createElement(BrowserWrapper, {
30
+ onBrowseFn: onBrowseFn,
31
+ mediaState: mediaState,
32
+ featureFlags: featureFlags
33
+ }));
34
+ };
8
35
  export class MediaPickerComponents extends React.Component {
9
36
  constructor(...args) {
10
37
  super(...args);
@@ -30,6 +57,7 @@ export class MediaPickerComponents extends React.Component {
30
57
  }
31
58
  render() {
32
59
  const {
60
+ api,
33
61
  mediaState,
34
62
  editorDomElement,
35
63
  appearance
@@ -37,30 +65,13 @@ export class MediaPickerComponents extends React.Component {
37
65
  const {
38
66
  isPopupOpened
39
67
  } = this.state;
40
- const featureFlags = mediaState.mediaOptions && mediaState.mediaOptions.featureFlags;
41
- return /*#__PURE__*/React.createElement(WithPluginState, {
42
- plugins: {
43
- focus: focusStateKey
44
- },
45
- render: ({
46
- focus
47
- }) => {
48
- const clipboard = focus ? /*#__PURE__*/React.createElement(ClipboardWrapper, {
49
- mediaState: mediaState,
50
- featureFlags: featureFlags
51
- }) : null;
52
- return /*#__PURE__*/React.createElement(React.Fragment, null, clipboard, /*#__PURE__*/React.createElement(DropzoneWrapper, {
53
- mediaState: mediaState,
54
- isActive: !isPopupOpened,
55
- featureFlags: featureFlags,
56
- editorDomElement: editorDomElement,
57
- appearance: appearance
58
- }), /*#__PURE__*/React.createElement(BrowserWrapper, {
59
- onBrowseFn: this.onBrowseFn,
60
- mediaState: mediaState,
61
- featureFlags: featureFlags
62
- }));
63
- }
68
+ return /*#__PURE__*/React.createElement(MediaPicker, {
69
+ mediaState: mediaState,
70
+ editorDomElement: editorDomElement,
71
+ appearance: appearance,
72
+ isPopupOpened: isPopupOpened,
73
+ onBrowseFn: this.onBrowseFn,
74
+ api: api
64
75
  });
65
76
  }
66
77
  }
@@ -1,10 +1,8 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { browser } from '@atlaskit/editor-common/utils';
2
+ import { browser, isEmptyDocument, bracketTyped } from '@atlaskit/editor-common/utils';
3
3
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
4
  import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
5
- import { isEmptyDocument, bracketTyped } from '@atlaskit/editor-common/utils';
6
5
  export const pluginKey = new PluginKey('placeholderPlugin');
7
- import { focusStateKey } from '../base/pm-plugins/focus-handler';
8
6
  import { isTypeAheadOpen } from '../type-ahead/utils';
9
7
  import { isComposing } from '../base/pm-plugins/composition';
10
8
  function getPlaceholderState(editorState) {
@@ -52,8 +50,7 @@ function setPlaceHolderState(placeholderText, pos) {
52
50
  const emptyPlaceholder = {
53
51
  hasPlaceholder: false
54
52
  };
55
- function createPlaceHolderStateFrom(editorState, defaultPlaceholderText, bracketPlaceholderText) {
56
- const isEditorFocused = focusStateKey.getState(editorState);
53
+ function createPlaceHolderStateFrom(isEditorFocused, editorState, defaultPlaceholderText, bracketPlaceholderText) {
57
54
  if (isTypeAheadOpen(editorState)) {
58
55
  return emptyPlaceholder;
59
56
  }
@@ -70,25 +67,30 @@ function createPlaceHolderStateFrom(editorState, defaultPlaceholderText, bracket
70
67
  }
71
68
  return emptyPlaceholder;
72
69
  }
73
- export function createPlugin(defaultPlaceholderText, bracketPlaceholderText) {
70
+ export function createPlugin(defaultPlaceholderText, bracketPlaceholderText, api) {
74
71
  if (!defaultPlaceholderText && !bracketPlaceholderText) {
75
72
  return;
76
73
  }
77
74
  return new SafePlugin({
78
75
  key: pluginKey,
79
76
  state: {
80
- init: (_, state) => createPlaceHolderStateFrom(state, defaultPlaceholderText, bracketPlaceholderText),
77
+ init: (_, state) => {
78
+ var _api$dependencies$foc;
79
+ return createPlaceHolderStateFrom(Boolean(api === null || api === void 0 ? void 0 : (_api$dependencies$foc = api.dependencies.focus.sharedState.currentState()) === null || _api$dependencies$foc === void 0 ? void 0 : _api$dependencies$foc.hasFocus), state, defaultPlaceholderText, bracketPlaceholderText);
80
+ },
81
81
  apply: (tr, _oldPluginState, _oldEditorState, newEditorState) => {
82
+ var _api$dependencies$foc2;
82
83
  const meta = tr.getMeta(pluginKey);
84
+ const isEditorFocused = Boolean(api === null || api === void 0 ? void 0 : (_api$dependencies$foc2 = api.dependencies.focus.sharedState.currentState()) === null || _api$dependencies$foc2 === void 0 ? void 0 : _api$dependencies$foc2.hasFocus);
83
85
  if (meta) {
84
86
  if (meta.removePlaceholder) {
85
87
  return emptyPlaceholder;
86
88
  }
87
89
  if (meta.applyPlaceholderIfEmpty) {
88
- return createPlaceHolderStateFrom(newEditorState, defaultPlaceholderText, bracketPlaceholderText);
90
+ return createPlaceHolderStateFrom(isEditorFocused, newEditorState, defaultPlaceholderText, bracketPlaceholderText);
89
91
  }
90
92
  }
91
- return createPlaceHolderStateFrom(newEditorState, defaultPlaceholderText, bracketPlaceholderText);
93
+ return createPlaceHolderStateFrom(isEditorFocused, newEditorState, defaultPlaceholderText, bracketPlaceholderText);
92
94
  }
93
95
  },
94
96
  props: {
@@ -106,12 +108,12 @@ export function createPlugin(defaultPlaceholderText, bracketPlaceholderText) {
106
108
  }
107
109
  });
108
110
  }
109
- const placeholderPlugin = options => ({
111
+ const placeholderPlugin = (options, api) => ({
110
112
  name: 'placeholder',
111
113
  pmPlugins() {
112
114
  return [{
113
115
  name: 'placeholder',
114
- plugin: () => createPlugin(options && options.placeholder, options && options.placeholderBracketHint)
116
+ plugin: () => createPlugin(options && options.placeholder, options && options.placeholderBracketHint, api)
115
117
  }];
116
118
  }
117
119
  });
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.17.2";
2
+ export const version = "187.17.3";
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.17.2",
3
+ "version": "187.17.3",
4
4
  "sideEffects": false
5
5
  }
@@ -8,6 +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 { focusPlugin } from '@atlaskit/editor-plugin-focus';
11
12
  import { editorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
12
13
  import typeAheadPlugin from '../../../plugins/type-ahead';
13
14
  import submitEditorPlugin from '../../../plugins/submit-editor';
@@ -52,7 +53,7 @@ export function createDefaultPreset(options) {
52
53
  }]);
53
54
  }
54
55
  return builder;
55
- }).add([pastePlugin, options.paste]).add(clipboardPlugin).add([basePlugin, options.base]).add(decorationsPlugin).maybeAdd(undoRedoPlugin, function (p, builder) {
56
+ }).add([pastePlugin, options.paste]).add(clipboardPlugin).add(focusPlugin).add([basePlugin, options.base]).add(decorationsPlugin).maybeAdd(undoRedoPlugin, function (p, builder) {
56
57
  var _options$featureFlags;
57
58
  // The undo redo plugin needs to be add before the blockTypePlugin
58
59
  if ((_options$featureFlags = options.featureFlags) !== null && _options$featureFlags !== void 0 && _options$featureFlags.undoRedoButtons) {
@@ -6,7 +6,6 @@ import { history } from '@atlaskit/editor-prosemirror/history';
6
6
  import { browser } from '@atlaskit/editor-common/utils';
7
7
  import { doc, paragraph, text } from '@atlaskit/adf-schema';
8
8
  import filterStepsPlugin from './pm-plugins/filter-steps';
9
- import focusHandlerPlugin from './pm-plugins/focus-handler';
10
9
  import fixChrome88SelectionPlugin from './pm-plugins/fix-chrome-88-selection';
11
10
  import disableSpellcheckingPlugin from './pm-plugins/disable-spell-checking';
12
11
  import contextIdentifierPlugin from './pm-plugins/context-identifier';
@@ -47,19 +46,13 @@ var basePlugin = function basePlugin(options, api) {
47
46
  }
48
47
  });
49
48
  plugins.push({
50
- name: 'focusHandlerPlugin',
51
- plugin: function plugin(_ref2) {
52
- var dispatch = _ref2.dispatch;
53
- return focusHandlerPlugin(dispatch);
54
- }
55
- }, {
56
49
  name: 'newlinePreserveMarksPlugin',
57
50
  plugin: newlinePreserveMarksPlugin
58
51
  }, {
59
52
  name: 'frozenEditor',
60
- plugin: function plugin(_ref3) {
53
+ plugin: function plugin(_ref2) {
61
54
  var _options$inputTrackin;
62
- var dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent;
55
+ var dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent;
63
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;
64
57
  }
65
58
  }, {
@@ -83,9 +76,9 @@ var basePlugin = function basePlugin(options, api) {
83
76
  }
84
77
  }, {
85
78
  name: 'contextIdentifier',
86
- plugin: function plugin(_ref4) {
87
- var dispatch = _ref4.dispatch,
88
- providerFactory = _ref4.providerFactory;
79
+ plugin: function plugin(_ref3) {
80
+ var dispatch = _ref3.dispatch,
81
+ providerFactory = _ref3.providerFactory;
89
82
  return contextIdentifierPlugin(dispatch, providerFactory);
90
83
  }
91
84
  });
@@ -21,8 +21,8 @@ import { MediaPickerComponents } from './ui/MediaPicker';
21
21
  import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
22
22
  import { ReactMediaNode } from './nodeviews/mediaNodeView';
23
23
  import { ReactMediaInlineNode } from './nodeviews/mediaInline';
24
- import { stateKey } from './pm-plugins/plugin-key';
25
24
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
25
+ import { stateKey } from './pm-plugins/plugin-key';
26
26
  export { insertMediaSingleNode } from './utils/media-single';
27
27
  var mediaPlugin = function mediaPlugin() {
28
28
  var _api$dependencies, _api$dependencies$fea;
@@ -197,7 +197,8 @@ var mediaPlugin = function mediaPlugin() {
197
197
  return /*#__PURE__*/React.createElement(MediaPickerComponents, {
198
198
  editorDomElement: editorView.dom,
199
199
  mediaState: mediaState,
200
- appearance: appearance
200
+ appearance: appearance,
201
+ api: api
201
202
  });
202
203
  }
203
204
  }));
@@ -0,0 +1 @@
1
+ export {};