@atlaskit/editor-core 187.2.2 → 187.2.4

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 (33) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/plugins/image-upload/index.js +17 -1
  3. package/dist/cjs/plugins/image-upload/pm-plugins/commands-toolbar.js +19 -0
  4. package/dist/cjs/plugins/image-upload/pm-plugins/main.js +76 -77
  5. package/dist/cjs/plugins/insert-block/index.js +12 -17
  6. package/dist/cjs/version-wrapper.js +1 -1
  7. package/dist/cjs/version.json +1 -1
  8. package/dist/es2019/plugins/image-upload/index.js +31 -15
  9. package/dist/es2019/plugins/image-upload/pm-plugins/commands-toolbar.js +12 -0
  10. package/dist/es2019/plugins/image-upload/pm-plugins/main.js +1 -4
  11. package/dist/es2019/plugins/insert-block/index.js +8 -13
  12. package/dist/es2019/version-wrapper.js +1 -1
  13. package/dist/es2019/version.json +1 -1
  14. package/dist/esm/plugins/image-upload/index.js +17 -1
  15. package/dist/esm/plugins/image-upload/pm-plugins/commands-toolbar.js +12 -0
  16. package/dist/esm/plugins/image-upload/pm-plugins/main.js +76 -77
  17. package/dist/esm/plugins/insert-block/index.js +8 -13
  18. package/dist/esm/version-wrapper.js +1 -1
  19. package/dist/esm/version.json +1 -1
  20. package/dist/types/plugins/image-upload/index.d.ts +15 -2
  21. package/dist/types/plugins/image-upload/pm-plugins/commands-toolbar.d.ts +3 -0
  22. package/dist/types/plugins/image-upload/pm-plugins/commands.d.ts +2 -2
  23. package/dist/types/plugins/image-upload/pm-plugins/main.d.ts +2 -2
  24. package/dist/types/plugins/image-upload/types.d.ts +4 -0
  25. package/dist/types/plugins/insert-block/index.d.ts +3 -1
  26. package/dist/types-ts4.5/plugins/image-upload/index.d.ts +15 -2
  27. package/dist/types-ts4.5/plugins/image-upload/pm-plugins/commands-toolbar.d.ts +3 -0
  28. package/dist/types-ts4.5/plugins/image-upload/pm-plugins/commands.d.ts +2 -2
  29. package/dist/types-ts4.5/plugins/image-upload/pm-plugins/main.d.ts +2 -2
  30. package/dist/types-ts4.5/plugins/image-upload/types.d.ts +4 -0
  31. package/dist/types-ts4.5/plugins/insert-block/index.d.ts +3 -1
  32. package/package.json +1 -1
  33. package/tmp/api-report-tmp.d.ts +0 -2257
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 187.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`30f2b96479f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/30f2b96479f) - Update image upload plugin to use optional plugin upload interface
8
+
9
+ ## 187.2.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [`a70c938c3de`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a70c938c3de) - fix issue where wrong expand node type was being inserted into tables (insert menu)
14
+
3
15
  ## 187.2.2
4
16
 
5
17
  ### Patch Changes
@@ -7,13 +7,29 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _main = require("./pm-plugins/main");
9
9
  var _inputRule = _interopRequireDefault(require("./pm-plugins/input-rule"));
10
+ var _pluginKey = require("./pm-plugins/plugin-key");
11
+ var _commandsToolbar = require("./pm-plugins/commands-toolbar");
10
12
  var imageUpload = function imageUpload() {
13
+ var uploadHandlerReference = {
14
+ current: null
15
+ };
11
16
  return {
12
17
  name: 'imageUpload',
18
+ getSharedState: function getSharedState(editorState) {
19
+ if (!editorState) {
20
+ return undefined;
21
+ }
22
+ return _pluginKey.stateKey.getState(editorState);
23
+ },
24
+ actions: {
25
+ startUpload: function startUpload() {
26
+ return (0, _commandsToolbar.insertActionForToolbar)(uploadHandlerReference);
27
+ }
28
+ },
13
29
  pmPlugins: function pmPlugins() {
14
30
  return [{
15
31
  name: 'imageUpload',
16
- plugin: _main.createPlugin
32
+ plugin: (0, _main.createPlugin)(uploadHandlerReference)
17
33
  }, {
18
34
  name: 'imageUploadInputRule',
19
35
  plugin: function plugin(_ref) {
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.insertActionForToolbar = void 0;
7
+ var _commands = require("./commands");
8
+ var insertActionForToolbar = function insertActionForToolbar(uploadHandlerReference) {
9
+ return function (state, dispatch) {
10
+ if (!uploadHandlerReference.current) {
11
+ return false;
12
+ }
13
+ uploadHandlerReference.current(undefined, function (options) {
14
+ (0, _commands.insertExternalImage)(options)(state, dispatch);
15
+ });
16
+ return true;
17
+ };
18
+ };
19
+ exports.insertActionForToolbar = insertActionForToolbar;
@@ -109,87 +109,86 @@ var getNewActiveUpload = function getNewActiveUpload(tr, pluginState) {
109
109
  }
110
110
  return pluginState.activeUpload;
111
111
  };
112
- var createPlugin = function createPlugin(_ref2) {
113
- var dispatch = _ref2.dispatch,
114
- providerFactory = _ref2.providerFactory;
115
- var uploadHandlerReference = {
116
- current: null
117
- };
118
- return new _safePlugin.SafePlugin({
119
- state: {
120
- init: function init(_config, state) {
121
- return {
122
- active: false,
123
- enabled: (0, _utils.canInsertMedia)(state),
124
- hidden: !state.schema.nodes.media || !state.schema.nodes.mediaSingle
125
- };
126
- },
127
- apply: function apply(tr, pluginState, _oldState, newState) {
128
- var newActive = (0, _utils.isMediaSelected)(newState);
129
- var newEnabled = (0, _utils.canInsertMedia)(newState);
130
- var newActiveUpload = getNewActiveUpload(tr, pluginState);
131
- if (newActive !== pluginState.active || newEnabled !== pluginState.enabled || newActiveUpload !== pluginState.activeUpload) {
132
- var newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
133
- active: newActive,
134
- enabled: newEnabled,
135
- activeUpload: newActiveUpload
136
- });
137
- dispatch(_pluginKey.stateKey, newPluginState);
138
- return newPluginState;
112
+ var createPlugin = function createPlugin(uploadHandlerReference) {
113
+ return function (_ref2) {
114
+ var dispatch = _ref2.dispatch,
115
+ providerFactory = _ref2.providerFactory;
116
+ return new _safePlugin.SafePlugin({
117
+ state: {
118
+ init: function init(_config, state) {
119
+ return {
120
+ active: false,
121
+ enabled: (0, _utils.canInsertMedia)(state),
122
+ hidden: !state.schema.nodes.media || !state.schema.nodes.mediaSingle
123
+ };
124
+ },
125
+ apply: function apply(tr, pluginState, _oldState, newState) {
126
+ var newActive = (0, _utils.isMediaSelected)(newState);
127
+ var newEnabled = (0, _utils.canInsertMedia)(newState);
128
+ var newActiveUpload = getNewActiveUpload(tr, pluginState);
129
+ if (newActive !== pluginState.active || newEnabled !== pluginState.enabled || newActiveUpload !== pluginState.activeUpload) {
130
+ var newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
131
+ active: newActive,
132
+ enabled: newEnabled,
133
+ activeUpload: newActiveUpload
134
+ });
135
+ dispatch(_pluginKey.stateKey, newPluginState);
136
+ return newPluginState;
137
+ }
138
+ return pluginState;
139
139
  }
140
- return pluginState;
141
- }
142
- },
143
- key: _pluginKey.stateKey,
144
- view: function view() {
145
- var handleProvider = /*#__PURE__*/function () {
146
- var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, provider) {
147
- var imageUploadProvider;
148
- return _regenerator.default.wrap(function _callee$(_context) {
149
- while (1) switch (_context.prev = _context.next) {
150
- case 0:
151
- if (!(name !== 'imageUploadProvider' || !provider)) {
152
- _context.next = 2;
140
+ },
141
+ key: _pluginKey.stateKey,
142
+ view: function view() {
143
+ var handleProvider = /*#__PURE__*/function () {
144
+ var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, provider) {
145
+ var imageUploadProvider;
146
+ return _regenerator.default.wrap(function _callee$(_context) {
147
+ while (1) switch (_context.prev = _context.next) {
148
+ case 0:
149
+ if (!(name !== 'imageUploadProvider' || !provider)) {
150
+ _context.next = 2;
151
+ break;
152
+ }
153
+ return _context.abrupt("return");
154
+ case 2:
155
+ _context.prev = 2;
156
+ _context.next = 5;
157
+ return provider;
158
+ case 5:
159
+ imageUploadProvider = _context.sent;
160
+ uploadHandlerReference.current = imageUploadProvider;
161
+ _context.next = 12;
153
162
  break;
154
- }
155
- return _context.abrupt("return");
156
- case 2:
157
- _context.prev = 2;
158
- _context.next = 5;
159
- return provider;
160
- case 5:
161
- imageUploadProvider = _context.sent;
162
- uploadHandlerReference.current = imageUploadProvider;
163
- _context.next = 12;
164
- break;
165
- case 9:
166
- _context.prev = 9;
167
- _context.t0 = _context["catch"](2);
168
- uploadHandlerReference.current = null;
169
- case 12:
170
- case "end":
171
- return _context.stop();
172
- }
173
- }, _callee, null, [[2, 9]]);
174
- }));
175
- return function handleProvider(_x, _x2) {
176
- return _ref3.apply(this, arguments);
163
+ case 9:
164
+ _context.prev = 9;
165
+ _context.t0 = _context["catch"](2);
166
+ uploadHandlerReference.current = null;
167
+ case 12:
168
+ case "end":
169
+ return _context.stop();
170
+ }
171
+ }, _callee, null, [[2, 9]]);
172
+ }));
173
+ return function handleProvider(_x, _x2) {
174
+ return _ref3.apply(this, arguments);
175
+ };
176
+ }();
177
+ providerFactory.subscribe('imageUploadProvider', handleProvider);
178
+ return {
179
+ destroy: function destroy() {
180
+ uploadHandlerReference.current = null;
181
+ providerFactory.unsubscribe('imageUploadProvider', handleProvider);
182
+ }
177
183
  };
178
- }();
179
- providerFactory.subscribe('imageUploadProvider', handleProvider);
180
- return {
181
- destroy: function destroy() {
182
- uploadHandlerReference.current = null;
183
- providerFactory.unsubscribe('imageUploadProvider', handleProvider);
184
+ },
185
+ props: {
186
+ handleDOMEvents: {
187
+ drop: createDOMHandler(_dragDrop.isDroppedFile, 'atlassian.editor.image.drop', uploadHandlerReference),
188
+ paste: createDOMHandler(_clipboard.isPastedFile, 'atlassian.editor.image.paste', uploadHandlerReference)
184
189
  }
185
- };
186
- },
187
- props: {
188
- handleDOMEvents: {
189
- drop: createDOMHandler(_dragDrop.isDroppedFile, 'atlassian.editor.image.drop', uploadHandlerReference),
190
- paste: createDOMHandler(_clipboard.isPastedFile, 'atlassian.editor.image.paste', uploadHandlerReference)
191
190
  }
192
- }
193
- });
191
+ });
192
+ };
194
193
  };
195
194
  exports.createPlugin = createPlugin;
@@ -18,11 +18,9 @@ var _WithPluginState = _interopRequireDefault(require("../../ui/WithPluginState"
18
18
  var _ToolbarInsertBlock = _interopRequireDefault(require("./ui/ToolbarInsertBlock"));
19
19
  var _key2 = require("../type-ahead/pm-plugins/key");
20
20
  var _commands = require("../block-type/commands");
21
- var _commands2 = require("../image-upload/pm-plugins/commands");
22
21
  var _analytics = require("../analytics");
23
- var _pluginKey2 = require("../image-upload/pm-plugins/plugin-key");
24
- var _pluginKey3 = require("../placeholder-text/plugin-key");
25
- var _pluginKey4 = require("../macro/plugin-key");
22
+ var _pluginKey2 = require("../placeholder-text/plugin-key");
23
+ var _pluginKey3 = require("../macro/plugin-key");
26
24
  var _types = require("../../ui/Toolbar/types");
27
25
  var _hooks = require("@atlaskit/editor-common/hooks");
28
26
  var toolbarSizeToButtons = function toolbarSizeToButtons(toolbarSize) {
@@ -75,10 +73,9 @@ var insertBlockPlugin = function insertBlockPlugin() {
75
73
  blockTypeState: _main.pluginKey,
76
74
  mediaState: _pluginKey.stateKey,
77
75
  mentionState: _key.mentionPluginKey,
78
- macroState: _pluginKey4.pluginKey,
76
+ macroState: _pluginKey3.pluginKey,
79
77
  emojiState: _emoji.emojiPluginKey,
80
- imageUpload: _pluginKey2.stateKey,
81
- placeholderTextState: _pluginKey3.pluginKey,
78
+ placeholderTextState: _pluginKey2.pluginKey,
82
79
  layoutState: _layout.pluginKey
83
80
  },
84
81
  render: function render(_ref2) {
@@ -88,7 +85,6 @@ var insertBlockPlugin = function insertBlockPlugin() {
88
85
  _ref2$macroState = _ref2.macroState,
89
86
  macroState = _ref2$macroState === void 0 ? {} : _ref2$macroState,
90
87
  emojiState = _ref2.emojiState,
91
- imageUpload = _ref2.imageUpload,
92
88
  placeholderTextState = _ref2.placeholderTextState,
93
89
  layoutState = _ref2.layoutState;
94
90
  return /*#__PURE__*/_react.default.createElement(ToolbarInsertBlockWithInjectionApi, {
@@ -110,7 +106,6 @@ var insertBlockPlugin = function insertBlockPlugin() {
110
106
  mediaState: mediaState,
111
107
  macroState: macroState,
112
108
  emojiState: emojiState,
113
- imageUpload: imageUpload,
114
109
  placeholderTextState: placeholderTextState,
115
110
  layoutState: layoutState,
116
111
  providers: providers,
@@ -128,7 +123,7 @@ var insertBlockPlugin = function insertBlockPlugin() {
128
123
  };
129
124
  };
130
125
  function ToolbarInsertBlockWithInjectionApi(_ref3) {
131
- var _pluginInjectionApi$d;
126
+ var _pluginInjectionApi$d, _pluginInjectionApi$d2;
132
127
  var editorView = _ref3.editorView,
133
128
  editorActions = _ref3.editorActions,
134
129
  dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent,
@@ -148,14 +143,14 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
148
143
  mediaState = _ref3.mediaState,
149
144
  macroState = _ref3.macroState,
150
145
  emojiState = _ref3.emojiState,
151
- imageUpload = _ref3.imageUpload,
152
146
  placeholderTextState = _ref3.placeholderTextState,
153
147
  layoutState = _ref3.layoutState,
154
148
  featureFlags = _ref3.featureFlags;
155
149
  var buttons = toolbarSizeToButtons(toolbarSize);
156
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['hyperlink', 'date']),
150
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload']),
157
151
  dateState = _useSharedPluginState.dateState,
158
- hyperlinkState = _useSharedPluginState.hyperlinkState;
152
+ hyperlinkState = _useSharedPluginState.hyperlinkState,
153
+ imageUploadState = _useSharedPluginState.imageUploadState;
159
154
  return /*#__PURE__*/_react.default.createElement(_ToolbarInsertBlock.default, {
160
155
  pluginInjectionApi: pluginInjectionApi,
161
156
  buttons: buttons,
@@ -174,9 +169,9 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
174
169
  mediaUploadsEnabled: mediaState && mediaState.allowsUploads,
175
170
  onShowMediaPicker: mediaState && mediaState.showMediaPicker,
176
171
  mediaSupported: !!mediaState,
177
- imageUploadSupported: !!imageUpload,
178
- imageUploadEnabled: imageUpload && imageUpload.enabled,
179
- handleImageUpload: _commands2.startImageUpload,
172
+ imageUploadSupported: !!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.dependencies.imageUpload),
173
+ imageUploadEnabled: imageUploadState === null || imageUploadState === void 0 ? void 0 : imageUploadState.enabled,
174
+ handleImageUpload: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.imageUpload) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions.startUpload,
180
175
  availableWrapperBlockTypes: blockTypeState && blockTypeState.availableWrapperBlockTypes,
181
176
  linkSupported: !!hyperlinkState,
182
177
  linkDisabled: !hyperlinkState || !hyperlinkState.canInsertLink || !!hyperlinkState.activeLinkMark,
@@ -184,7 +179,7 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
184
179
  emojiProvider: providers.emojiProvider,
185
180
  nativeStatusSupported: options.nativeStatusSupported,
186
181
  horizontalRuleEnabled: options.horizontalRuleEnabled,
187
- onInsertBlockType: handleInsertBlockType(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions),
182
+ onInsertBlockType: handleInsertBlockType(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d2 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions),
188
183
  onInsertMacroFromMacroBrowser: _macro.insertMacroFromMacroBrowser,
189
184
  macroProvider: macroState.macroProvider,
190
185
  popupsMountPoint: popupsMountPoint,
@@ -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.2.3";
9
+ var version = "187.2.4";
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.2.3",
3
+ "version": "187.2.4",
4
4
  "sideEffects": false
5
5
  }
@@ -1,18 +1,34 @@
1
1
  import { createPlugin } from './pm-plugins/main';
2
2
  import inputRulePlugin from './pm-plugins/input-rule';
3
- const imageUpload = () => ({
4
- name: 'imageUpload',
5
- pmPlugins() {
6
- return [{
7
- name: 'imageUpload',
8
- plugin: createPlugin
9
- }, {
10
- name: 'imageUploadInputRule',
11
- plugin: ({
12
- schema,
13
- featureFlags
14
- }) => inputRulePlugin(schema, featureFlags)
15
- }];
16
- }
17
- });
3
+ import { stateKey } from './pm-plugins/plugin-key';
4
+ import { insertActionForToolbar } from './pm-plugins/commands-toolbar';
5
+ const imageUpload = () => {
6
+ let uploadHandlerReference = {
7
+ current: null
8
+ };
9
+ return {
10
+ name: 'imageUpload',
11
+ getSharedState(editorState) {
12
+ if (!editorState) {
13
+ return undefined;
14
+ }
15
+ return stateKey.getState(editorState);
16
+ },
17
+ actions: {
18
+ startUpload: () => insertActionForToolbar(uploadHandlerReference)
19
+ },
20
+ pmPlugins() {
21
+ return [{
22
+ name: 'imageUpload',
23
+ plugin: createPlugin(uploadHandlerReference)
24
+ }, {
25
+ name: 'imageUploadInputRule',
26
+ plugin: ({
27
+ schema,
28
+ featureFlags
29
+ }) => inputRulePlugin(schema, featureFlags)
30
+ }];
31
+ }
32
+ };
33
+ };
18
34
  export default imageUpload;
@@ -0,0 +1,12 @@
1
+ import { insertExternalImage } from './commands';
2
+ export const insertActionForToolbar = uploadHandlerReference => {
3
+ return (state, dispatch) => {
4
+ if (!uploadHandlerReference.current) {
5
+ return false;
6
+ }
7
+ uploadHandlerReference.current(undefined, options => {
8
+ insertExternalImage(options)(state, dispatch);
9
+ });
10
+ return true;
11
+ };
12
+ };
@@ -98,13 +98,10 @@ const getNewActiveUpload = (tr, pluginState) => {
98
98
  }
99
99
  return pluginState.activeUpload;
100
100
  };
101
- export const createPlugin = ({
101
+ export const createPlugin = uploadHandlerReference => ({
102
102
  dispatch,
103
103
  providerFactory
104
104
  }) => {
105
- let uploadHandlerReference = {
106
- current: null
107
- };
108
105
  return new SafePlugin({
109
106
  state: {
110
107
  init(_config, state) {
@@ -11,9 +11,7 @@ import WithPluginState from '../../ui/WithPluginState';
11
11
  import ToolbarInsertBlock from './ui/ToolbarInsertBlock';
12
12
  import { pluginKey as typeAheadPluginKey } from '../type-ahead/pm-plugins/key';
13
13
  import { insertBlockTypesWithAnalytics } from '../block-type/commands';
14
- import { startImageUpload } from '../image-upload/pm-plugins/commands';
15
14
  import { INPUT_METHOD } from '../analytics';
16
- import { stateKey as imageUploadStateKey } from '../image-upload/pm-plugins/plugin-key';
17
15
  import { pluginKey as placeholderTextStateKey } from '../placeholder-text/plugin-key';
18
16
  import { pluginKey as macroStateKey } from '../macro/plugin-key';
19
17
  import { ToolbarSize } from '../../ui/Toolbar/types';
@@ -67,7 +65,6 @@ const insertBlockPlugin = (options = {}, api) => {
67
65
  mentionState: mentionPluginKey,
68
66
  macroState: macroStateKey,
69
67
  emojiState: emojiPluginKey,
70
- imageUpload: imageUploadStateKey,
71
68
  placeholderTextState: placeholderTextStateKey,
72
69
  layoutState: layoutStateKey
73
70
  },
@@ -77,7 +74,6 @@ const insertBlockPlugin = (options = {}, api) => {
77
74
  mediaState,
78
75
  macroState = {},
79
76
  emojiState,
80
- imageUpload,
81
77
  placeholderTextState,
82
78
  layoutState
83
79
  }) => /*#__PURE__*/React.createElement(ToolbarInsertBlockWithInjectionApi, {
@@ -99,7 +95,6 @@ const insertBlockPlugin = (options = {}, api) => {
99
95
  mediaState: mediaState,
100
96
  macroState: macroState,
101
97
  emojiState: emojiState,
102
- imageUpload: imageUpload,
103
98
  placeholderTextState: placeholderTextState,
104
99
  layoutState: layoutState,
105
100
  providers: providers,
@@ -135,17 +130,17 @@ function ToolbarInsertBlockWithInjectionApi({
135
130
  mediaState,
136
131
  macroState,
137
132
  emojiState,
138
- imageUpload,
139
133
  placeholderTextState,
140
134
  layoutState,
141
135
  featureFlags
142
136
  }) {
143
- var _pluginInjectionApi$d;
137
+ var _pluginInjectionApi$d, _pluginInjectionApi$d2;
144
138
  const buttons = toolbarSizeToButtons(toolbarSize);
145
139
  const {
146
140
  dateState,
147
- hyperlinkState
148
- } = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date']);
141
+ hyperlinkState,
142
+ imageUploadState
143
+ } = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload']);
149
144
  return /*#__PURE__*/React.createElement(ToolbarInsertBlock, {
150
145
  pluginInjectionApi: pluginInjectionApi,
151
146
  buttons: buttons,
@@ -164,9 +159,9 @@ function ToolbarInsertBlockWithInjectionApi({
164
159
  mediaUploadsEnabled: mediaState && mediaState.allowsUploads,
165
160
  onShowMediaPicker: mediaState && mediaState.showMediaPicker,
166
161
  mediaSupported: !!mediaState,
167
- imageUploadSupported: !!imageUpload,
168
- imageUploadEnabled: imageUpload && imageUpload.enabled,
169
- handleImageUpload: startImageUpload,
162
+ imageUploadSupported: !!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.dependencies.imageUpload),
163
+ imageUploadEnabled: imageUploadState === null || imageUploadState === void 0 ? void 0 : imageUploadState.enabled,
164
+ handleImageUpload: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.imageUpload) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions.startUpload,
170
165
  availableWrapperBlockTypes: blockTypeState && blockTypeState.availableWrapperBlockTypes,
171
166
  linkSupported: !!hyperlinkState,
172
167
  linkDisabled: !hyperlinkState || !hyperlinkState.canInsertLink || !!hyperlinkState.activeLinkMark,
@@ -174,7 +169,7 @@ function ToolbarInsertBlockWithInjectionApi({
174
169
  emojiProvider: providers.emojiProvider,
175
170
  nativeStatusSupported: options.nativeStatusSupported,
176
171
  horizontalRuleEnabled: options.horizontalRuleEnabled,
177
- onInsertBlockType: handleInsertBlockType(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions),
172
+ onInsertBlockType: handleInsertBlockType(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d2 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions),
178
173
  onInsertMacroFromMacroBrowser: insertMacroFromMacroBrowser,
179
174
  macroProvider: macroState.macroProvider,
180
175
  popupsMountPoint: popupsMountPoint,
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.2.3";
2
+ export const version = "187.2.4";
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.2.3",
3
+ "version": "187.2.4",
4
4
  "sideEffects": false
5
5
  }
@@ -1,12 +1,28 @@
1
1
  import { createPlugin } from './pm-plugins/main';
2
2
  import inputRulePlugin from './pm-plugins/input-rule';
3
+ import { stateKey } from './pm-plugins/plugin-key';
4
+ import { insertActionForToolbar } from './pm-plugins/commands-toolbar';
3
5
  var imageUpload = function imageUpload() {
6
+ var uploadHandlerReference = {
7
+ current: null
8
+ };
4
9
  return {
5
10
  name: 'imageUpload',
11
+ getSharedState: function getSharedState(editorState) {
12
+ if (!editorState) {
13
+ return undefined;
14
+ }
15
+ return stateKey.getState(editorState);
16
+ },
17
+ actions: {
18
+ startUpload: function startUpload() {
19
+ return insertActionForToolbar(uploadHandlerReference);
20
+ }
21
+ },
6
22
  pmPlugins: function pmPlugins() {
7
23
  return [{
8
24
  name: 'imageUpload',
9
- plugin: createPlugin
25
+ plugin: createPlugin(uploadHandlerReference)
10
26
  }, {
11
27
  name: 'imageUploadInputRule',
12
28
  plugin: function plugin(_ref) {
@@ -0,0 +1,12 @@
1
+ import { insertExternalImage } from './commands';
2
+ export var insertActionForToolbar = function insertActionForToolbar(uploadHandlerReference) {
3
+ return function (state, dispatch) {
4
+ if (!uploadHandlerReference.current) {
5
+ return false;
6
+ }
7
+ uploadHandlerReference.current(undefined, function (options) {
8
+ insertExternalImage(options)(state, dispatch);
9
+ });
10
+ return true;
11
+ };
12
+ };