@atlaskit/editor-core 187.2.2 → 187.2.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.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/plugins/image-upload/index.js +17 -1
- package/dist/cjs/plugins/image-upload/pm-plugins/commands-toolbar.js +19 -0
- package/dist/cjs/plugins/image-upload/pm-plugins/main.js +76 -77
- package/dist/cjs/plugins/insert-block/index.js +12 -17
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/image-upload/index.js +31 -15
- package/dist/es2019/plugins/image-upload/pm-plugins/commands-toolbar.js +12 -0
- package/dist/es2019/plugins/image-upload/pm-plugins/main.js +1 -4
- package/dist/es2019/plugins/insert-block/index.js +8 -13
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/image-upload/index.js +17 -1
- package/dist/esm/plugins/image-upload/pm-plugins/commands-toolbar.js +12 -0
- package/dist/esm/plugins/image-upload/pm-plugins/main.js +76 -77
- package/dist/esm/plugins/insert-block/index.js +8 -13
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/image-upload/index.d.ts +15 -2
- package/dist/types/plugins/image-upload/pm-plugins/commands-toolbar.d.ts +3 -0
- package/dist/types/plugins/image-upload/pm-plugins/commands.d.ts +2 -2
- package/dist/types/plugins/image-upload/pm-plugins/main.d.ts +2 -2
- package/dist/types/plugins/image-upload/types.d.ts +4 -0
- package/dist/types/plugins/insert-block/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/image-upload/index.d.ts +15 -2
- package/dist/types-ts4.5/plugins/image-upload/pm-plugins/commands-toolbar.d.ts +3 -0
- package/dist/types-ts4.5/plugins/image-upload/pm-plugins/commands.d.ts +2 -2
- package/dist/types-ts4.5/plugins/image-upload/pm-plugins/main.d.ts +2 -2
- package/dist/types-ts4.5/plugins/image-upload/types.d.ts +4 -0
- package/dist/types-ts4.5/plugins/insert-block/index.d.ts +3 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 187.2.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`a70c938c3de`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a70c938c3de) - fix issue where wrong expand node type was being inserted into tables (insert menu)
|
|
8
|
+
|
|
3
9
|
## 187.2.2
|
|
4
10
|
|
|
5
11
|
### 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(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return
|
|
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
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
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
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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("../
|
|
24
|
-
var _pluginKey3 = require("../
|
|
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:
|
|
76
|
+
macroState: _pluginKey3.pluginKey,
|
|
79
77
|
emojiState: _emoji.emojiPluginKey,
|
|
80
|
-
|
|
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:
|
|
179
|
-
handleImageUpload:
|
|
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$
|
|
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.
|
|
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('.');
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,18 +1,34 @@
|
|
|
1
1
|
import { createPlugin } from './pm-plugins/main';
|
|
2
2
|
import inputRulePlugin from './pm-plugins/input-rule';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
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
|
-
|
|
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:
|
|
169
|
-
handleImageUpload:
|
|
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$
|
|
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,
|
package/dist/es2019/version.json
CHANGED
|
@@ -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
|
+
};
|
|
@@ -102,86 +102,85 @@ var getNewActiveUpload = function getNewActiveUpload(tr, pluginState) {
|
|
|
102
102
|
}
|
|
103
103
|
return pluginState.activeUpload;
|
|
104
104
|
};
|
|
105
|
-
export var createPlugin = function createPlugin(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return
|
|
105
|
+
export var createPlugin = function createPlugin(uploadHandlerReference) {
|
|
106
|
+
return function (_ref2) {
|
|
107
|
+
var dispatch = _ref2.dispatch,
|
|
108
|
+
providerFactory = _ref2.providerFactory;
|
|
109
|
+
return new SafePlugin({
|
|
110
|
+
state: {
|
|
111
|
+
init: function init(_config, state) {
|
|
112
|
+
return {
|
|
113
|
+
active: false,
|
|
114
|
+
enabled: canInsertMedia(state),
|
|
115
|
+
hidden: !state.schema.nodes.media || !state.schema.nodes.mediaSingle
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
apply: function apply(tr, pluginState, _oldState, newState) {
|
|
119
|
+
var newActive = isMediaSelected(newState);
|
|
120
|
+
var newEnabled = canInsertMedia(newState);
|
|
121
|
+
var newActiveUpload = getNewActiveUpload(tr, pluginState);
|
|
122
|
+
if (newActive !== pluginState.active || newEnabled !== pluginState.enabled || newActiveUpload !== pluginState.activeUpload) {
|
|
123
|
+
var newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
124
|
+
active: newActive,
|
|
125
|
+
enabled: newEnabled,
|
|
126
|
+
activeUpload: newActiveUpload
|
|
127
|
+
});
|
|
128
|
+
dispatch(stateKey, newPluginState);
|
|
129
|
+
return newPluginState;
|
|
130
|
+
}
|
|
131
|
+
return pluginState;
|
|
132
132
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
133
|
+
},
|
|
134
|
+
key: stateKey,
|
|
135
|
+
view: function view() {
|
|
136
|
+
var handleProvider = /*#__PURE__*/function () {
|
|
137
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(name, provider) {
|
|
138
|
+
var imageUploadProvider;
|
|
139
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
140
|
+
while (1) switch (_context.prev = _context.next) {
|
|
141
|
+
case 0:
|
|
142
|
+
if (!(name !== 'imageUploadProvider' || !provider)) {
|
|
143
|
+
_context.next = 2;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
return _context.abrupt("return");
|
|
147
|
+
case 2:
|
|
148
|
+
_context.prev = 2;
|
|
149
|
+
_context.next = 5;
|
|
150
|
+
return provider;
|
|
151
|
+
case 5:
|
|
152
|
+
imageUploadProvider = _context.sent;
|
|
153
|
+
uploadHandlerReference.current = imageUploadProvider;
|
|
154
|
+
_context.next = 12;
|
|
146
155
|
break;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
}));
|
|
168
|
-
return function handleProvider(_x, _x2) {
|
|
169
|
-
return _ref3.apply(this, arguments);
|
|
156
|
+
case 9:
|
|
157
|
+
_context.prev = 9;
|
|
158
|
+
_context.t0 = _context["catch"](2);
|
|
159
|
+
uploadHandlerReference.current = null;
|
|
160
|
+
case 12:
|
|
161
|
+
case "end":
|
|
162
|
+
return _context.stop();
|
|
163
|
+
}
|
|
164
|
+
}, _callee, null, [[2, 9]]);
|
|
165
|
+
}));
|
|
166
|
+
return function handleProvider(_x, _x2) {
|
|
167
|
+
return _ref3.apply(this, arguments);
|
|
168
|
+
};
|
|
169
|
+
}();
|
|
170
|
+
providerFactory.subscribe('imageUploadProvider', handleProvider);
|
|
171
|
+
return {
|
|
172
|
+
destroy: function destroy() {
|
|
173
|
+
uploadHandlerReference.current = null;
|
|
174
|
+
providerFactory.unsubscribe('imageUploadProvider', handleProvider);
|
|
175
|
+
}
|
|
170
176
|
};
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
providerFactory.unsubscribe('imageUploadProvider', handleProvider);
|
|
177
|
+
},
|
|
178
|
+
props: {
|
|
179
|
+
handleDOMEvents: {
|
|
180
|
+
drop: createDOMHandler(isDroppedFile, 'atlassian.editor.image.drop', uploadHandlerReference),
|
|
181
|
+
paste: createDOMHandler(isPastedFile, 'atlassian.editor.image.paste', uploadHandlerReference)
|
|
177
182
|
}
|
|
178
|
-
};
|
|
179
|
-
},
|
|
180
|
-
props: {
|
|
181
|
-
handleDOMEvents: {
|
|
182
|
-
drop: createDOMHandler(isDroppedFile, 'atlassian.editor.image.drop', uploadHandlerReference),
|
|
183
|
-
paste: createDOMHandler(isPastedFile, 'atlassian.editor.image.paste', uploadHandlerReference)
|
|
184
183
|
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
184
|
+
});
|
|
185
|
+
};
|
|
187
186
|
};
|
|
@@ -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';
|
|
@@ -70,7 +68,6 @@ var insertBlockPlugin = function insertBlockPlugin() {
|
|
|
70
68
|
mentionState: mentionPluginKey,
|
|
71
69
|
macroState: macroStateKey,
|
|
72
70
|
emojiState: emojiPluginKey,
|
|
73
|
-
imageUpload: imageUploadStateKey,
|
|
74
71
|
placeholderTextState: placeholderTextStateKey,
|
|
75
72
|
layoutState: layoutStateKey
|
|
76
73
|
},
|
|
@@ -81,7 +78,6 @@ var insertBlockPlugin = function insertBlockPlugin() {
|
|
|
81
78
|
_ref2$macroState = _ref2.macroState,
|
|
82
79
|
macroState = _ref2$macroState === void 0 ? {} : _ref2$macroState,
|
|
83
80
|
emojiState = _ref2.emojiState,
|
|
84
|
-
imageUpload = _ref2.imageUpload,
|
|
85
81
|
placeholderTextState = _ref2.placeholderTextState,
|
|
86
82
|
layoutState = _ref2.layoutState;
|
|
87
83
|
return /*#__PURE__*/React.createElement(ToolbarInsertBlockWithInjectionApi, {
|
|
@@ -103,7 +99,6 @@ var insertBlockPlugin = function insertBlockPlugin() {
|
|
|
103
99
|
mediaState: mediaState,
|
|
104
100
|
macroState: macroState,
|
|
105
101
|
emojiState: emojiState,
|
|
106
|
-
imageUpload: imageUpload,
|
|
107
102
|
placeholderTextState: placeholderTextState,
|
|
108
103
|
layoutState: layoutState,
|
|
109
104
|
providers: providers,
|
|
@@ -121,7 +116,7 @@ var insertBlockPlugin = function insertBlockPlugin() {
|
|
|
121
116
|
};
|
|
122
117
|
};
|
|
123
118
|
function ToolbarInsertBlockWithInjectionApi(_ref3) {
|
|
124
|
-
var _pluginInjectionApi$d;
|
|
119
|
+
var _pluginInjectionApi$d, _pluginInjectionApi$d2;
|
|
125
120
|
var editorView = _ref3.editorView,
|
|
126
121
|
editorActions = _ref3.editorActions,
|
|
127
122
|
dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent,
|
|
@@ -141,14 +136,14 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
|
|
|
141
136
|
mediaState = _ref3.mediaState,
|
|
142
137
|
macroState = _ref3.macroState,
|
|
143
138
|
emojiState = _ref3.emojiState,
|
|
144
|
-
imageUpload = _ref3.imageUpload,
|
|
145
139
|
placeholderTextState = _ref3.placeholderTextState,
|
|
146
140
|
layoutState = _ref3.layoutState,
|
|
147
141
|
featureFlags = _ref3.featureFlags;
|
|
148
142
|
var buttons = toolbarSizeToButtons(toolbarSize);
|
|
149
|
-
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date']),
|
|
143
|
+
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload']),
|
|
150
144
|
dateState = _useSharedPluginState.dateState,
|
|
151
|
-
hyperlinkState = _useSharedPluginState.hyperlinkState
|
|
145
|
+
hyperlinkState = _useSharedPluginState.hyperlinkState,
|
|
146
|
+
imageUploadState = _useSharedPluginState.imageUploadState;
|
|
152
147
|
return /*#__PURE__*/React.createElement(ToolbarInsertBlock, {
|
|
153
148
|
pluginInjectionApi: pluginInjectionApi,
|
|
154
149
|
buttons: buttons,
|
|
@@ -167,9 +162,9 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
|
|
|
167
162
|
mediaUploadsEnabled: mediaState && mediaState.allowsUploads,
|
|
168
163
|
onShowMediaPicker: mediaState && mediaState.showMediaPicker,
|
|
169
164
|
mediaSupported: !!mediaState,
|
|
170
|
-
imageUploadSupported: !!imageUpload,
|
|
171
|
-
imageUploadEnabled:
|
|
172
|
-
handleImageUpload:
|
|
165
|
+
imageUploadSupported: !!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.dependencies.imageUpload),
|
|
166
|
+
imageUploadEnabled: imageUploadState === null || imageUploadState === void 0 ? void 0 : imageUploadState.enabled,
|
|
167
|
+
handleImageUpload: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.imageUpload) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions.startUpload,
|
|
173
168
|
availableWrapperBlockTypes: blockTypeState && blockTypeState.availableWrapperBlockTypes,
|
|
174
169
|
linkSupported: !!hyperlinkState,
|
|
175
170
|
linkDisabled: !hyperlinkState || !hyperlinkState.canInsertLink || !!hyperlinkState.activeLinkMark,
|
|
@@ -177,7 +172,7 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
|
|
|
177
172
|
emojiProvider: providers.emojiProvider,
|
|
178
173
|
nativeStatusSupported: options.nativeStatusSupported,
|
|
179
174
|
horizontalRuleEnabled: options.horizontalRuleEnabled,
|
|
180
|
-
onInsertBlockType: handleInsertBlockType(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
175
|
+
onInsertBlockType: handleInsertBlockType(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d2 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions),
|
|
181
176
|
onInsertMacroFromMacroBrowser: insertMacroFromMacroBrowser,
|
|
182
177
|
macroProvider: macroState.macroProvider,
|
|
183
178
|
popupsMountPoint: popupsMountPoint,
|
package/dist/esm/version.json
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
import { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
-
|
|
1
|
+
import type { Command, NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
+
type ImageUploadActions = {
|
|
3
|
+
startUpload: () => Command;
|
|
4
|
+
};
|
|
5
|
+
type ImageUploadSharedState = {
|
|
6
|
+
active: boolean;
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
hidden: boolean;
|
|
9
|
+
};
|
|
10
|
+
type ImageUploadPlugin = NextEditorPlugin<'imageUpload', {
|
|
11
|
+
actions: ImageUploadActions;
|
|
12
|
+
sharedState: ImageUploadSharedState | undefined;
|
|
13
|
+
}>;
|
|
14
|
+
declare const imageUpload: ImageUploadPlugin;
|
|
3
15
|
export default imageUpload;
|
|
16
|
+
export type { ImageUploadPlugin };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InsertedImageProperties } from '@atlaskit/editor-common/provider-factory';
|
|
1
|
+
import type { InsertedImageProperties } from '@atlaskit/editor-common/provider-factory';
|
|
2
2
|
import type { Command } from '../../../types';
|
|
3
|
-
import { ImageUploadPluginReferenceEvent } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { ImageUploadPluginReferenceEvent } from '@atlaskit/editor-common/types';
|
|
4
4
|
export declare const insertExternalImage: (options: InsertedImageProperties) => Command;
|
|
5
5
|
export declare const startImageUpload: (event?: ImageUploadPluginReferenceEvent) => Command;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { ImageUploadPluginState } from '../types';
|
|
2
|
+
import { ImageUploadPluginState, UploadHandlerReference } from '../types';
|
|
3
3
|
import type { PMPluginFactoryParams } from '../../../types';
|
|
4
|
-
export declare const createPlugin: ({ dispatch, providerFactory
|
|
4
|
+
export declare const createPlugin: (uploadHandlerReference: UploadHandlerReference) => ({ dispatch, providerFactory }: PMPluginFactoryParams) => SafePlugin<ImageUploadPluginState>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ImageUploadPluginReferenceEvent } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { ImageUploadProvider } from '@atlaskit/editor-common/provider-factory';
|
|
2
3
|
export type { InsertedImageProperties, ImageUploadProvider as ImageUploadHandler, } from '@atlaskit/editor-common/provider-factory';
|
|
3
4
|
export type ImageUploadPluginAction = {
|
|
4
5
|
name: 'START_UPLOAD';
|
|
@@ -12,3 +13,6 @@ export type ImageUploadPluginState = {
|
|
|
12
13
|
event?: ImageUploadPluginReferenceEvent;
|
|
13
14
|
};
|
|
14
15
|
};
|
|
16
|
+
export type UploadHandlerReference = {
|
|
17
|
+
current: ImageUploadProvider | null;
|
|
18
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { ImageUploadPlugin } from '../image-upload';
|
|
2
3
|
import type datePlugin from '../date';
|
|
3
4
|
import { tablesPlugin } from '@atlaskit/editor-plugin-table';
|
|
4
5
|
import type { hyperlinkPlugin } from '@atlaskit/editor-plugin-hyperlink';
|
|
@@ -20,7 +21,8 @@ declare const insertBlockPlugin: NextEditorPlugin<'insertBlock', {
|
|
|
20
21
|
OptionalPlugin<typeof tablesPlugin>,
|
|
21
22
|
OptionalPlugin<typeof hyperlinkPlugin>,
|
|
22
23
|
OptionalPlugin<typeof datePlugin>,
|
|
23
|
-
OptionalPlugin<typeof analyticsPlugin
|
|
24
|
+
OptionalPlugin<typeof analyticsPlugin>,
|
|
25
|
+
OptionalPlugin<ImageUploadPlugin>
|
|
24
26
|
];
|
|
25
27
|
}>;
|
|
26
28
|
export default insertBlockPlugin;
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
import { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
-
|
|
1
|
+
import type { Command, NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
+
type ImageUploadActions = {
|
|
3
|
+
startUpload: () => Command;
|
|
4
|
+
};
|
|
5
|
+
type ImageUploadSharedState = {
|
|
6
|
+
active: boolean;
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
hidden: boolean;
|
|
9
|
+
};
|
|
10
|
+
type ImageUploadPlugin = NextEditorPlugin<'imageUpload', {
|
|
11
|
+
actions: ImageUploadActions;
|
|
12
|
+
sharedState: ImageUploadSharedState | undefined;
|
|
13
|
+
}>;
|
|
14
|
+
declare const imageUpload: ImageUploadPlugin;
|
|
3
15
|
export default imageUpload;
|
|
16
|
+
export type { ImageUploadPlugin };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InsertedImageProperties } from '@atlaskit/editor-common/provider-factory';
|
|
1
|
+
import type { InsertedImageProperties } from '@atlaskit/editor-common/provider-factory';
|
|
2
2
|
import type { Command } from '../../../types';
|
|
3
|
-
import { ImageUploadPluginReferenceEvent } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { ImageUploadPluginReferenceEvent } from '@atlaskit/editor-common/types';
|
|
4
4
|
export declare const insertExternalImage: (options: InsertedImageProperties) => Command;
|
|
5
5
|
export declare const startImageUpload: (event?: ImageUploadPluginReferenceEvent) => Command;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { ImageUploadPluginState } from '../types';
|
|
2
|
+
import { ImageUploadPluginState, UploadHandlerReference } from '../types';
|
|
3
3
|
import type { PMPluginFactoryParams } from '../../../types';
|
|
4
|
-
export declare const createPlugin: ({ dispatch, providerFactory
|
|
4
|
+
export declare const createPlugin: (uploadHandlerReference: UploadHandlerReference) => ({ dispatch, providerFactory }: PMPluginFactoryParams) => SafePlugin<ImageUploadPluginState>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ImageUploadPluginReferenceEvent } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { ImageUploadProvider } from '@atlaskit/editor-common/provider-factory';
|
|
2
3
|
export type { InsertedImageProperties, ImageUploadProvider as ImageUploadHandler, } from '@atlaskit/editor-common/provider-factory';
|
|
3
4
|
export type ImageUploadPluginAction = {
|
|
4
5
|
name: 'START_UPLOAD';
|
|
@@ -12,3 +13,6 @@ export type ImageUploadPluginState = {
|
|
|
12
13
|
event?: ImageUploadPluginReferenceEvent;
|
|
13
14
|
};
|
|
14
15
|
};
|
|
16
|
+
export type UploadHandlerReference = {
|
|
17
|
+
current: ImageUploadProvider | null;
|
|
18
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { ImageUploadPlugin } from '../image-upload';
|
|
2
3
|
import type datePlugin from '../date';
|
|
3
4
|
import { tablesPlugin } from '@atlaskit/editor-plugin-table';
|
|
4
5
|
import type { hyperlinkPlugin } from '@atlaskit/editor-plugin-hyperlink';
|
|
@@ -20,7 +21,8 @@ declare const insertBlockPlugin: NextEditorPlugin<'insertBlock', {
|
|
|
20
21
|
OptionalPlugin<typeof tablesPlugin>,
|
|
21
22
|
OptionalPlugin<typeof hyperlinkPlugin>,
|
|
22
23
|
OptionalPlugin<typeof datePlugin>,
|
|
23
|
-
OptionalPlugin<typeof analyticsPlugin
|
|
24
|
+
OptionalPlugin<typeof analyticsPlugin>,
|
|
25
|
+
OptionalPlugin<ImageUploadPlugin>
|
|
24
26
|
];
|
|
25
27
|
}>;
|
|
26
28
|
export default insertBlockPlugin;
|