@atlaskit/editor-plugin-extension 0.6.2 → 0.7.0
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 +17 -0
- package/dist/cjs/actions.js +7 -22
- package/dist/cjs/context-panel.js +4 -1
- package/dist/cjs/plugin.js +5 -4
- package/dist/cjs/pm-plugins/main.js +11 -54
- package/dist/cjs/toolbar.js +5 -1
- package/dist/cjs/ui/ConfigPanel/ConfigPanel.js +55 -29
- package/dist/cjs/ui/ConfigPanel/ConfigPanelFieldsLoader.js +3 -1
- package/dist/es2019/actions.js +3 -19
- package/dist/es2019/context-panel.js +4 -1
- package/dist/es2019/plugin.js +5 -4
- package/dist/es2019/pm-plugins/main.js +4 -23
- package/dist/es2019/toolbar.js +5 -1
- package/dist/es2019/ui/ConfigPanel/ConfigPanel.js +58 -28
- package/dist/es2019/ui/ConfigPanel/ConfigPanelFieldsLoader.js +3 -1
- package/dist/esm/actions.js +6 -21
- package/dist/esm/context-panel.js +4 -1
- package/dist/esm/plugin.js +5 -4
- package/dist/esm/pm-plugins/main.js +10 -53
- package/dist/esm/toolbar.js +5 -1
- package/dist/esm/ui/ConfigPanel/ConfigPanel.js +55 -29
- package/dist/esm/ui/ConfigPanel/ConfigPanelFieldsLoader.js +3 -1
- package/dist/types/actions.d.ts +2 -5
- package/dist/types/context-panel.d.ts +3 -3
- package/dist/types/pm-plugins/main.d.ts +1 -2
- package/dist/types/types.d.ts +4 -4
- package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +4 -3
- package/dist/types/ui/ConfigPanel/ConfigPanelFieldsLoader.d.ts +4 -3
- package/dist/types-ts4.5/actions.d.ts +2 -5
- package/dist/types-ts4.5/context-panel.d.ts +3 -3
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -2
- package/dist/types-ts4.5/types.d.ts +4 -4
- package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanel.d.ts +4 -3
- package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanelFieldsLoader.d.ts +4 -3
- package/example-utils/config-panel/ConfigPanelWithProviders.tsx +2 -1
- package/example-utils/config-panel/FieldTypePicker.tsx +1 -1
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-extension
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#68640](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/68640) [`e173cb423c75`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e173cb423c75) - Migrate extension plugin to useSharedPluginState from WithPluginState. Adds new dependency on BasePlugin.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 0.6.3
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#68264](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/68264) [`daa71f6aa162`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/daa71f6aa162) - [ux] ED-21883: Updated MultiBodied Extension related CSS and selections
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 0.6.2
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/cjs/actions.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.performNodeUpdate = exports.
|
|
7
|
+
exports.performNodeUpdate = exports.editExtension = exports.createEditSelectedExtensionAction = exports.buildExtensionNode = void 0;
|
|
8
8
|
Object.defineProperty(exports, "transformSliceToRemoveOpenBodiedExtension", {
|
|
9
9
|
enumerable: true,
|
|
10
10
|
get: function get() {
|
|
@@ -166,28 +166,13 @@ var updateExtensionParams = function updateExtensionParams(editorAnalyticsAPI) {
|
|
|
166
166
|
}();
|
|
167
167
|
};
|
|
168
168
|
};
|
|
169
|
-
|
|
170
|
-
// This is to decouple extensions from editor core
|
|
171
|
-
// Ideally in the future we completely deprecate `EditorActions`
|
|
172
|
-
var editSelectedExtension = exports.editSelectedExtension = function editSelectedExtension(editorActions) {
|
|
173
|
-
var editorView = editorActions._privateGetEditorView();
|
|
174
|
-
var _getPluginState = (0, _main.getPluginState)(editorView.state),
|
|
175
|
-
updateExtension = _getPluginState.updateExtension,
|
|
176
|
-
applyChangeToContextPanel = _getPluginState.applyChangeToContextPanel;
|
|
177
|
-
// The analytics API cannot be accessed in this case because
|
|
178
|
-
// we do not have access to the plugin injection API. Rather
|
|
179
|
-
// than change the way this works - we just won't use analytics
|
|
180
|
-
// here for now.
|
|
181
|
-
var editorAnalyticsAPI = undefined;
|
|
182
|
-
return editExtension(null, applyChangeToContextPanel, editorAnalyticsAPI, updateExtension)(editorView.state, editorView.dispatch, editorView);
|
|
183
|
-
};
|
|
184
169
|
var editExtension = exports.editExtension = function editExtension(macroProvider, applyChangeToContextPanel, editorAnalyticsAPI, updateExtension) {
|
|
185
170
|
return function (state, dispatch, view) {
|
|
186
171
|
if (!view) {
|
|
187
172
|
return false;
|
|
188
173
|
}
|
|
189
|
-
var
|
|
190
|
-
localId =
|
|
174
|
+
var _getPluginState = (0, _main.getPluginState)(state),
|
|
175
|
+
localId = _getPluginState.localId;
|
|
191
176
|
var nodeWithPos = (0, _utils2.findExtensionWithLocalId)(state, localId);
|
|
192
177
|
if (!nodeWithPos) {
|
|
193
178
|
return false;
|
|
@@ -225,15 +210,15 @@ var editExtension = exports.editExtension = function editExtension(macroProvider
|
|
|
225
210
|
};
|
|
226
211
|
var createEditSelectedExtensionAction = exports.createEditSelectedExtensionAction = function createEditSelectedExtensionAction(_ref2) {
|
|
227
212
|
var editorViewRef = _ref2.editorViewRef,
|
|
228
|
-
editorAnalyticsAPI = _ref2.editorAnalyticsAPI
|
|
213
|
+
editorAnalyticsAPI = _ref2.editorAnalyticsAPI,
|
|
214
|
+
applyChangeToContextPanel = _ref2.applyChangeToContextPanel;
|
|
229
215
|
return function () {
|
|
230
216
|
var view = editorViewRef.current;
|
|
231
217
|
if (!view) {
|
|
232
218
|
return false;
|
|
233
219
|
}
|
|
234
|
-
var
|
|
235
|
-
updateExtension =
|
|
236
|
-
applyChangeToContextPanel = _getPluginState3.applyChangeToContextPanel;
|
|
220
|
+
var _getPluginState2 = (0, _main.getPluginState)(view.state),
|
|
221
|
+
updateExtension = _getPluginState2.updateExtension;
|
|
237
222
|
return editExtension(null, applyChangeToContextPanel, editorAnalyticsAPI, updateExtension)(view.state, view.dispatch, view);
|
|
238
223
|
};
|
|
239
224
|
};
|
|
@@ -46,9 +46,11 @@ var duplicateSelection = exports.duplicateSelection = function duplicateSelectio
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
var getContextPanel = exports.getContextPanel = function getContextPanel(getEditorView) {
|
|
49
|
-
return function (allowAutoSave, featureFlags
|
|
49
|
+
return function (api, allowAutoSave, featureFlags) {
|
|
50
50
|
return function (state) {
|
|
51
|
+
var _api$contextPanel;
|
|
51
52
|
var nodeWithPos = (0, _utils.getSelectedExtension)(state, true);
|
|
53
|
+
var applyChange = api === null || api === void 0 || (_api$contextPanel = api.contextPanel) === null || _api$contextPanel === void 0 ? void 0 : _api$contextPanel.actions.applyChange;
|
|
52
54
|
|
|
53
55
|
// Adding checks to bail out early
|
|
54
56
|
if (!nodeWithPos) {
|
|
@@ -82,6 +84,7 @@ var getContextPanel = exports.getContextPanel = function getContextPanel(getEdit
|
|
|
82
84
|
return null;
|
|
83
85
|
}
|
|
84
86
|
return /*#__PURE__*/_react.default.createElement(_ConfigPanelLoader.default, {
|
|
87
|
+
api: api,
|
|
85
88
|
showHeader: true,
|
|
86
89
|
closeOnEsc: true,
|
|
87
90
|
extensionType: extensionType,
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -19,7 +19,7 @@ var _main = require("./pm-plugins/main");
|
|
|
19
19
|
var _uniqueId = require("./pm-plugins/unique-id");
|
|
20
20
|
var _toolbar = require("./toolbar");
|
|
21
21
|
var extensionPlugin = exports.extensionPlugin = function extensionPlugin(_ref) {
|
|
22
|
-
var _api$featureFlags, _api$analytics2, _api$analytics3, _api$
|
|
22
|
+
var _api$featureFlags, _api$analytics2, _api$analytics3, _api$contextPanel3, _api$decorations, _api$contextPanel4, _api$analytics4;
|
|
23
23
|
var _ref$config = _ref.config,
|
|
24
24
|
options = _ref$config === void 0 ? {} : _ref$config,
|
|
25
25
|
_api = _ref.api;
|
|
@@ -126,7 +126,8 @@ var extensionPlugin = exports.extensionPlugin = function extensionPlugin(_ref) {
|
|
|
126
126
|
insertMacroFromMacroBrowser: (0, _actions2.insertMacroFromMacroBrowser)(_api === null || _api === void 0 || (_api$analytics2 = _api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions),
|
|
127
127
|
editSelectedExtension: (0, _actions.createEditSelectedExtensionAction)({
|
|
128
128
|
editorViewRef: editorViewRef,
|
|
129
|
-
editorAnalyticsAPI: _api === null || _api === void 0 || (_api$analytics3 = _api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions
|
|
129
|
+
editorAnalyticsAPI: _api === null || _api === void 0 || (_api$analytics3 = _api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions,
|
|
130
|
+
applyChangeToContextPanel: _api === null || _api === void 0 || (_api$contextPanel3 = _api.contextPanel) === null || _api$contextPanel3 === void 0 ? void 0 : _api$contextPanel3.actions.applyChange
|
|
130
131
|
}),
|
|
131
132
|
runMacroAutoConvert: _actions2.runMacroAutoConvert,
|
|
132
133
|
forceAutoSave: _commands.forceAutoSave
|
|
@@ -135,13 +136,13 @@ var extensionPlugin = exports.extensionPlugin = function extensionPlugin(_ref) {
|
|
|
135
136
|
floatingToolbar: (0, _toolbar.getToolbarConfig)({
|
|
136
137
|
breakoutEnabled: options.breakoutEnabled,
|
|
137
138
|
hoverDecoration: _api === null || _api === void 0 || (_api$decorations = _api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions.hoverDecoration,
|
|
138
|
-
applyChangeToContextPanel: _api === null || _api === void 0 || (_api$
|
|
139
|
+
applyChangeToContextPanel: _api === null || _api === void 0 || (_api$contextPanel4 = _api.contextPanel) === null || _api$contextPanel4 === void 0 ? void 0 : _api$contextPanel4.actions.applyChange,
|
|
139
140
|
editorAnalyticsAPI: _api === null || _api === void 0 || (_api$analytics4 = _api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions
|
|
140
141
|
}),
|
|
141
142
|
contextPanel: (0, _contextPanel.getContextPanel)(function () {
|
|
142
143
|
var _editorViewRef$curren;
|
|
143
144
|
return (_editorViewRef$curren = editorViewRef.current) !== null && _editorViewRef$curren !== void 0 ? _editorViewRef$curren : undefined;
|
|
144
|
-
})(options.allowAutoSave, featureFlags
|
|
145
|
+
})(_api, options.allowAutoSave, featureFlags)
|
|
145
146
|
}
|
|
146
147
|
};
|
|
147
148
|
};
|
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "createCommand", {
|
|
|
10
10
|
return _pluginFactory.createCommand;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
exports.createPlugin = exports.createExtensionProviderHandler =
|
|
13
|
+
exports.createPlugin = exports.createExtensionProviderHandler = void 0;
|
|
14
14
|
Object.defineProperty(exports, "getPluginState", {
|
|
15
15
|
enumerable: true,
|
|
16
16
|
get: function get() {
|
|
@@ -123,50 +123,12 @@ var createExtensionProviderHandler = exports.createExtensionProviderHandler = fu
|
|
|
123
123
|
};
|
|
124
124
|
}();
|
|
125
125
|
};
|
|
126
|
-
var
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
case 0:
|
|
133
|
-
if (!(name === 'contextIdentifierProvider' && provider)) {
|
|
134
|
-
_context3.next = 11;
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
_context3.prev = 1;
|
|
138
|
-
_context3.next = 4;
|
|
139
|
-
return provider;
|
|
140
|
-
case 4:
|
|
141
|
-
contextIdentifierProvider = _context3.sent;
|
|
142
|
-
(0, _commands.updateState)({
|
|
143
|
-
contextIdentifierProvider: contextIdentifierProvider
|
|
144
|
-
})(view.state, view.dispatch);
|
|
145
|
-
_context3.next = 11;
|
|
146
|
-
break;
|
|
147
|
-
case 8:
|
|
148
|
-
_context3.prev = 8;
|
|
149
|
-
_context3.t0 = _context3["catch"](1);
|
|
150
|
-
(0, _commands.updateState)({
|
|
151
|
-
contextIdentifierProvider: undefined
|
|
152
|
-
})(view.state, view.dispatch);
|
|
153
|
-
case 11:
|
|
154
|
-
case "end":
|
|
155
|
-
return _context3.stop();
|
|
156
|
-
}
|
|
157
|
-
}, _callee3, null, [[1, 8]]);
|
|
158
|
-
}));
|
|
159
|
-
return function (_x6, _x7) {
|
|
160
|
-
return _ref3.apply(this, arguments);
|
|
161
|
-
};
|
|
162
|
-
}();
|
|
163
|
-
};
|
|
164
|
-
var handleUpdate = exports.handleUpdate = function handleUpdate(_ref4) {
|
|
165
|
-
var view = _ref4.view,
|
|
166
|
-
prevState = _ref4.prevState,
|
|
167
|
-
domAtPos = _ref4.domAtPos,
|
|
168
|
-
extensionHandlers = _ref4.extensionHandlers,
|
|
169
|
-
applyChange = _ref4.applyChange;
|
|
126
|
+
var handleUpdate = exports.handleUpdate = function handleUpdate(_ref3) {
|
|
127
|
+
var view = _ref3.view,
|
|
128
|
+
prevState = _ref3.prevState,
|
|
129
|
+
domAtPos = _ref3.domAtPos,
|
|
130
|
+
extensionHandlers = _ref3.extensionHandlers,
|
|
131
|
+
applyChange = _ref3.applyChange;
|
|
170
132
|
var state = view.state,
|
|
171
133
|
dispatch = view.dispatch;
|
|
172
134
|
var _getPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
@@ -224,13 +186,11 @@ var handleUpdate = exports.handleUpdate = function handleUpdate(_ref4) {
|
|
|
224
186
|
return true;
|
|
225
187
|
};
|
|
226
188
|
var createPlugin = exports.createPlugin = function createPlugin(dispatch, providerFactory, extensionHandlers, portalProviderAPI, eventDispatcher, pluginInjectionApi) {
|
|
227
|
-
var _pluginInjectionApi$c;
|
|
228
189
|
var useLongPressSelection = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
229
190
|
var options = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : {};
|
|
230
191
|
var state = (0, _pluginFactory.createPluginState)(dispatch, {
|
|
231
192
|
showEditButton: false,
|
|
232
|
-
showContextPanel: false
|
|
233
|
-
applyChangeToContextPanel: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.contextPanel) === null || _pluginInjectionApi$c === void 0 || (_pluginInjectionApi$c = _pluginInjectionApi$c.actions) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.applyChange
|
|
193
|
+
showContextPanel: false
|
|
234
194
|
});
|
|
235
195
|
var extensionNodeViewOptions = {
|
|
236
196
|
appearance: options.appearance
|
|
@@ -240,23 +200,20 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, provid
|
|
|
240
200
|
view: function view(editorView) {
|
|
241
201
|
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
242
202
|
var extensionProviderHandler = createExtensionProviderHandler(editorView);
|
|
243
|
-
var contextIdentificationProviderHandler = createContextIdentifierProviderHandler(editorView);
|
|
244
203
|
providerFactory.subscribe('extensionProvider', extensionProviderHandler);
|
|
245
|
-
providerFactory.subscribe('contextIdentificationProvider', contextIdentificationProviderHandler);
|
|
246
204
|
return {
|
|
247
205
|
update: function update(view, prevState) {
|
|
248
|
-
var _pluginInjectionApi$
|
|
206
|
+
var _pluginInjectionApi$c;
|
|
249
207
|
handleUpdate({
|
|
250
208
|
view: view,
|
|
251
209
|
prevState: prevState,
|
|
252
210
|
domAtPos: domAtPos,
|
|
253
211
|
extensionHandlers: extensionHandlers,
|
|
254
|
-
applyChange: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
212
|
+
applyChange: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.contextPanel) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions.applyChange
|
|
255
213
|
});
|
|
256
214
|
},
|
|
257
215
|
destroy: function destroy() {
|
|
258
216
|
providerFactory.unsubscribe('extensionProvider', extensionProviderHandler);
|
|
259
|
-
providerFactory.unsubscribe('contextIdentificationProvider', contextIdentificationProviderHandler);
|
|
260
217
|
}
|
|
261
218
|
};
|
|
262
219
|
},
|
|
@@ -313,7 +270,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, provid
|
|
|
313
270
|
inlineExtension: (0, _extensibility.ExtensionNodeView)(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi),
|
|
314
271
|
multiBodiedExtension: (0, _extensibility.ExtensionNodeView)(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi)
|
|
315
272
|
},
|
|
316
|
-
handleClickOn: (0, _selection.createSelectionClickHandler)(['extension', 'bodiedExtension'], function (target) {
|
|
273
|
+
handleClickOn: (0, _selection.createSelectionClickHandler)(['extension', 'bodiedExtension', 'multiBodiedExtension'], function (target) {
|
|
317
274
|
return !target.closest('.extension-content');
|
|
318
275
|
}, {
|
|
319
276
|
useLongPressSelection: useLongPressSelection
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -186,8 +186,12 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(_ref
|
|
|
186
186
|
*
|
|
187
187
|
*/
|
|
188
188
|
var frameheight = mbeFrameRect.height > 0 ? mbeFrameRect.height : 102;
|
|
189
|
+
// MBE wrapper header height includes, top margin 8px + bottom margin 8px + Line height of 16px + padding top 8px
|
|
190
|
+
// Ref: platform/packages/editor/editor-common/src/extensibility/MultiBodiedExtension/styles.ts
|
|
191
|
+
var wrapperHeaderHeight = 40;
|
|
192
|
+
var toolbarTopPos = mbeNodeRect.top + frameheight + wrapperHeaderHeight + scrollWrapper.scrollTop;
|
|
189
193
|
return {
|
|
190
|
-
top:
|
|
194
|
+
top: toolbarTopPos,
|
|
191
195
|
left: nextPos.left
|
|
192
196
|
};
|
|
193
197
|
},
|
|
@@ -26,9 +26,8 @@ var _buttonGroup = _interopRequireDefault(require("@atlaskit/button/button-group
|
|
|
26
26
|
var _customThemeButton = _interopRequireDefault(require("@atlaskit/button/custom-theme-button"));
|
|
27
27
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
28
28
|
var _extensions = require("@atlaskit/editor-common/extensions");
|
|
29
|
-
var
|
|
29
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
30
30
|
var _form = _interopRequireWildcard(require("@atlaskit/form"));
|
|
31
|
-
var _pluginKey = require("../../plugin-key");
|
|
32
31
|
var _constants = require("./constants");
|
|
33
32
|
var _ErrorMessage = _interopRequireDefault(require("./ErrorMessage"));
|
|
34
33
|
var _FormContent = _interopRequireDefault(require("./FormContent"));
|
|
@@ -414,7 +413,8 @@ var ConfigPanel = /*#__PURE__*/function (_React$Component) {
|
|
|
414
413
|
errorMessage = _this$props7.errorMessage,
|
|
415
414
|
fields = _this$props7.fields,
|
|
416
415
|
isLoading = _this$props7.isLoading,
|
|
417
|
-
onCancel = _this$props7.onCancel
|
|
416
|
+
onCancel = _this$props7.onCancel,
|
|
417
|
+
api = _this$props7.api;
|
|
418
418
|
var _this$state = this.state,
|
|
419
419
|
currentParameters = _this$state.currentParameters,
|
|
420
420
|
hasParsedParameters = _this$state.hasParsedParameters,
|
|
@@ -437,32 +437,20 @@ var ConfigPanel = /*#__PURE__*/function (_React$Component) {
|
|
|
437
437
|
noValidate: true,
|
|
438
438
|
onKeyDown: handleKeyDown,
|
|
439
439
|
"data-testid": "extension-config-panel"
|
|
440
|
-
}), _this2.renderHeader(extensionManifest), /*#__PURE__*/_react.default.createElement(
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
fields: fields,
|
|
455
|
-
firstVisibleFieldName: firstVisibleFieldName,
|
|
456
|
-
hasParsedParameters: hasParsedParameters,
|
|
457
|
-
isLoading: isLoading || false,
|
|
458
|
-
onCancel: onCancel,
|
|
459
|
-
onFieldChange: onFieldChange,
|
|
460
|
-
parameters: currentParameters,
|
|
461
|
-
submitting: submitting,
|
|
462
|
-
contextIdentifierProvider: extension === null || extension === void 0 ? void 0 : extension.contextIdentifierProvider,
|
|
463
|
-
featureFlags: featureFlags
|
|
464
|
-
}));
|
|
465
|
-
}
|
|
440
|
+
}), _this2.renderHeader(extensionManifest), /*#__PURE__*/_react.default.createElement(ConfigFormIntlWithBoundary, {
|
|
441
|
+
api: api,
|
|
442
|
+
canSave: !autoSave,
|
|
443
|
+
errorMessage: errorMessage,
|
|
444
|
+
extensionManifest: extensionManifest,
|
|
445
|
+
fields: fields !== null && fields !== void 0 ? fields : [],
|
|
446
|
+
firstVisibleFieldName: firstVisibleFieldName,
|
|
447
|
+
hasParsedParameters: hasParsedParameters,
|
|
448
|
+
isLoading: isLoading || false,
|
|
449
|
+
onCancel: onCancel,
|
|
450
|
+
onFieldChange: onFieldChange,
|
|
451
|
+
parameters: currentParameters,
|
|
452
|
+
submitting: submitting,
|
|
453
|
+
featureFlags: featureFlags
|
|
466
454
|
}));
|
|
467
455
|
});
|
|
468
456
|
});
|
|
@@ -470,6 +458,44 @@ var ConfigPanel = /*#__PURE__*/function (_React$Component) {
|
|
|
470
458
|
}]);
|
|
471
459
|
return ConfigPanel;
|
|
472
460
|
}(_react.default.Component);
|
|
461
|
+
function ConfigFormIntlWithBoundary(_ref6) {
|
|
462
|
+
var api = _ref6.api,
|
|
463
|
+
fields = _ref6.fields,
|
|
464
|
+
submitting = _ref6.submitting,
|
|
465
|
+
parameters = _ref6.parameters,
|
|
466
|
+
featureFlags = _ref6.featureFlags,
|
|
467
|
+
canSave = _ref6.canSave,
|
|
468
|
+
extensionManifest = _ref6.extensionManifest,
|
|
469
|
+
onFieldChange = _ref6.onFieldChange,
|
|
470
|
+
onCancel = _ref6.onCancel,
|
|
471
|
+
isLoading = _ref6.isLoading,
|
|
472
|
+
hasParsedParameters = _ref6.hasParsedParameters,
|
|
473
|
+
firstVisibleFieldName = _ref6.firstVisibleFieldName,
|
|
474
|
+
errorMessage = _ref6.errorMessage;
|
|
475
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['contextIdentifier']),
|
|
476
|
+
contextIdentifierState = _useSharedPluginState.contextIdentifierState;
|
|
477
|
+
var _ref7 = contextIdentifierState !== null && contextIdentifierState !== void 0 ? contextIdentifierState : {},
|
|
478
|
+
contextIdentifierProvider = _ref7.contextIdentifierProvider;
|
|
479
|
+
return /*#__PURE__*/_react.default.createElement(_FormErrorBoundary.FormErrorBoundary, {
|
|
480
|
+
contextIdentifierProvider: contextIdentifierProvider,
|
|
481
|
+
extensionKey: extensionManifest.key,
|
|
482
|
+
fields: fields
|
|
483
|
+
}, /*#__PURE__*/_react.default.createElement(ConfigFormIntl, {
|
|
484
|
+
canSave: canSave,
|
|
485
|
+
errorMessage: errorMessage,
|
|
486
|
+
extensionManifest: extensionManifest,
|
|
487
|
+
fields: fields,
|
|
488
|
+
firstVisibleFieldName: firstVisibleFieldName,
|
|
489
|
+
hasParsedParameters: hasParsedParameters,
|
|
490
|
+
isLoading: isLoading || false,
|
|
491
|
+
onCancel: onCancel,
|
|
492
|
+
onFieldChange: onFieldChange,
|
|
493
|
+
parameters: parameters,
|
|
494
|
+
submitting: submitting,
|
|
495
|
+
contextIdentifierProvider: contextIdentifierProvider,
|
|
496
|
+
featureFlags: featureFlags
|
|
497
|
+
}));
|
|
498
|
+
}
|
|
473
499
|
var _default = exports.default = (0, _analyticsNext.withAnalyticsContext)({
|
|
474
500
|
source: 'ConfigPanel'
|
|
475
501
|
})((0, _analyticsNext.withAnalyticsEvents)()(ConfigPanel));
|
|
@@ -87,7 +87,8 @@ function FieldsLoader(_ref) {
|
|
|
87
87
|
showHeader = _ref.showHeader,
|
|
88
88
|
featureFlags = _ref.featureFlags,
|
|
89
89
|
onChange = _ref.onChange,
|
|
90
|
-
onCancel = _ref.onCancel
|
|
90
|
+
onCancel = _ref.onCancel,
|
|
91
|
+
api = _ref.api;
|
|
91
92
|
var _useStateFromPromise = (0, _useStateFromPromise3.useStateFromPromise)(function () {
|
|
92
93
|
return extensionProvider.getExtension(extensionType, extensionKey);
|
|
93
94
|
}, [extensionProvider, extensionType, extensionKey]),
|
|
@@ -104,6 +105,7 @@ function FieldsLoader(_ref) {
|
|
|
104
105
|
extensionParameters: extensionParameters
|
|
105
106
|
}, function (fields) {
|
|
106
107
|
return /*#__PURE__*/_react.default.createElement(_ConfigPanel.default, {
|
|
108
|
+
api: api,
|
|
107
109
|
extensionManifest: extensionManifest,
|
|
108
110
|
isLoading: !extensionManifest || errorMessage === null && !fields,
|
|
109
111
|
fields: fields,
|
package/dist/es2019/actions.js
CHANGED
|
@@ -131,22 +131,6 @@ const updateExtensionParams = editorAnalyticsAPI => (updateExtension, node, acti
|
|
|
131
131
|
} catch {}
|
|
132
132
|
return true;
|
|
133
133
|
};
|
|
134
|
-
|
|
135
|
-
// This is to decouple extensions from editor core
|
|
136
|
-
// Ideally in the future we completely deprecate `EditorActions`
|
|
137
|
-
export const editSelectedExtension = editorActions => {
|
|
138
|
-
const editorView = editorActions._privateGetEditorView();
|
|
139
|
-
const {
|
|
140
|
-
updateExtension,
|
|
141
|
-
applyChangeToContextPanel
|
|
142
|
-
} = getPluginState(editorView.state);
|
|
143
|
-
// The analytics API cannot be accessed in this case because
|
|
144
|
-
// we do not have access to the plugin injection API. Rather
|
|
145
|
-
// than change the way this works - we just won't use analytics
|
|
146
|
-
// here for now.
|
|
147
|
-
const editorAnalyticsAPI = undefined;
|
|
148
|
-
return editExtension(null, applyChangeToContextPanel, editorAnalyticsAPI, updateExtension)(editorView.state, editorView.dispatch, editorView);
|
|
149
|
-
};
|
|
150
134
|
export const editExtension = (macroProvider, applyChangeToContextPanel, editorAnalyticsAPI, updateExtension) => (state, dispatch, view) => {
|
|
151
135
|
if (!view) {
|
|
152
136
|
return false;
|
|
@@ -190,7 +174,8 @@ export const editExtension = (macroProvider, applyChangeToContextPanel, editorAn
|
|
|
190
174
|
};
|
|
191
175
|
export const createEditSelectedExtensionAction = ({
|
|
192
176
|
editorViewRef,
|
|
193
|
-
editorAnalyticsAPI
|
|
177
|
+
editorAnalyticsAPI,
|
|
178
|
+
applyChangeToContextPanel
|
|
194
179
|
}) => () => {
|
|
195
180
|
const {
|
|
196
181
|
current: view
|
|
@@ -199,8 +184,7 @@ export const createEditSelectedExtensionAction = ({
|
|
|
199
184
|
return false;
|
|
200
185
|
}
|
|
201
186
|
const {
|
|
202
|
-
updateExtension
|
|
203
|
-
applyChangeToContextPanel
|
|
187
|
+
updateExtension
|
|
204
188
|
} = getPluginState(view.state);
|
|
205
189
|
return editExtension(null, applyChangeToContextPanel, editorAnalyticsAPI, updateExtension)(view.state, view.dispatch, view);
|
|
206
190
|
};
|
|
@@ -28,8 +28,10 @@ export const duplicateSelection = (selectionToDuplicate, doc) => {
|
|
|
28
28
|
return new CellSelection(doc.resolve(selectionToDuplicate.$anchorCell.pos), doc.resolve(selectionToDuplicate.$headCell.pos));
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
export const getContextPanel = getEditorView => (allowAutoSave, featureFlags
|
|
31
|
+
export const getContextPanel = getEditorView => (api, allowAutoSave, featureFlags) => state => {
|
|
32
|
+
var _api$contextPanel;
|
|
32
33
|
const nodeWithPos = getSelectedExtension(state, true);
|
|
34
|
+
const applyChange = api === null || api === void 0 ? void 0 : (_api$contextPanel = api.contextPanel) === null || _api$contextPanel === void 0 ? void 0 : _api$contextPanel.actions.applyChange;
|
|
33
35
|
|
|
34
36
|
// Adding checks to bail out early
|
|
35
37
|
if (!nodeWithPos) {
|
|
@@ -64,6 +66,7 @@ export const getContextPanel = getEditorView => (allowAutoSave, featureFlags, ap
|
|
|
64
66
|
return null;
|
|
65
67
|
}
|
|
66
68
|
return /*#__PURE__*/React.createElement(ConfigPanelLoader, {
|
|
69
|
+
api: api,
|
|
67
70
|
showHeader: true,
|
|
68
71
|
closeOnEsc: true,
|
|
69
72
|
extensionType: extensionType,
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -15,7 +15,7 @@ export const extensionPlugin = ({
|
|
|
15
15
|
config: options = {},
|
|
16
16
|
api
|
|
17
17
|
}) => {
|
|
18
|
-
var _api$featureFlags, _api$analytics2, _api$analytics3, _api$
|
|
18
|
+
var _api$featureFlags, _api$analytics2, _api$analytics3, _api$contextPanel3, _api$decorations, _api$contextPanel4, _api$analytics4;
|
|
19
19
|
const featureFlags = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
20
20
|
//Note: This is a hack to get the editor view reference in the plugin. Copied from table plugin.
|
|
21
21
|
//This is needed to get the current selection in the editor
|
|
@@ -117,7 +117,8 @@ export const extensionPlugin = ({
|
|
|
117
117
|
insertMacroFromMacroBrowser: insertMacroFromMacroBrowser(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions),
|
|
118
118
|
editSelectedExtension: createEditSelectedExtensionAction({
|
|
119
119
|
editorViewRef,
|
|
120
|
-
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions
|
|
120
|
+
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions,
|
|
121
|
+
applyChangeToContextPanel: api === null || api === void 0 ? void 0 : (_api$contextPanel3 = api.contextPanel) === null || _api$contextPanel3 === void 0 ? void 0 : _api$contextPanel3.actions.applyChange
|
|
121
122
|
}),
|
|
122
123
|
runMacroAutoConvert,
|
|
123
124
|
forceAutoSave
|
|
@@ -126,13 +127,13 @@ export const extensionPlugin = ({
|
|
|
126
127
|
floatingToolbar: getToolbarConfig({
|
|
127
128
|
breakoutEnabled: options.breakoutEnabled,
|
|
128
129
|
hoverDecoration: api === null || api === void 0 ? void 0 : (_api$decorations = api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions.hoverDecoration,
|
|
129
|
-
applyChangeToContextPanel: api === null || api === void 0 ? void 0 : (_api$
|
|
130
|
+
applyChangeToContextPanel: api === null || api === void 0 ? void 0 : (_api$contextPanel4 = api.contextPanel) === null || _api$contextPanel4 === void 0 ? void 0 : _api$contextPanel4.actions.applyChange,
|
|
130
131
|
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions
|
|
131
132
|
}),
|
|
132
133
|
contextPanel: getContextPanel(() => {
|
|
133
134
|
var _editorViewRef$curren;
|
|
134
135
|
return (_editorViewRef$curren = editorViewRef.current) !== null && _editorViewRef$curren !== void 0 ? _editorViewRef$curren : undefined;
|
|
135
|
-
})(options.allowAutoSave, featureFlags
|
|
136
|
+
})(api, options.allowAutoSave, featureFlags)
|
|
136
137
|
}
|
|
137
138
|
};
|
|
138
139
|
};
|
|
@@ -44,20 +44,6 @@ export const createExtensionProviderHandler = view => async (name, provider) =>
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
-
export const createContextIdentifierProviderHandler = view => async (name, provider) => {
|
|
48
|
-
if (name === 'contextIdentifierProvider' && provider) {
|
|
49
|
-
try {
|
|
50
|
-
const contextIdentifierProvider = await provider;
|
|
51
|
-
updateState({
|
|
52
|
-
contextIdentifierProvider
|
|
53
|
-
})(view.state, view.dispatch);
|
|
54
|
-
} catch {
|
|
55
|
-
updateState({
|
|
56
|
-
contextIdentifierProvider: undefined
|
|
57
|
-
})(view.state, view.dispatch);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
47
|
export const handleUpdate = ({
|
|
62
48
|
view,
|
|
63
49
|
prevState,
|
|
@@ -129,11 +115,9 @@ export const handleUpdate = ({
|
|
|
129
115
|
return true;
|
|
130
116
|
};
|
|
131
117
|
const createPlugin = (dispatch, providerFactory, extensionHandlers, portalProviderAPI, eventDispatcher, pluginInjectionApi, useLongPressSelection = false, options = {}) => {
|
|
132
|
-
var _pluginInjectionApi$c, _pluginInjectionApi$c2;
|
|
133
118
|
const state = createPluginState(dispatch, {
|
|
134
119
|
showEditButton: false,
|
|
135
|
-
showContextPanel: false
|
|
136
|
-
applyChangeToContextPanel: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.contextPanel) === null || _pluginInjectionApi$c === void 0 ? void 0 : (_pluginInjectionApi$c2 = _pluginInjectionApi$c.actions) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.applyChange
|
|
120
|
+
showContextPanel: false
|
|
137
121
|
});
|
|
138
122
|
const extensionNodeViewOptions = {
|
|
139
123
|
appearance: options.appearance
|
|
@@ -143,23 +127,20 @@ const createPlugin = (dispatch, providerFactory, extensionHandlers, portalProvid
|
|
|
143
127
|
view: editorView => {
|
|
144
128
|
const domAtPos = editorView.domAtPos.bind(editorView);
|
|
145
129
|
const extensionProviderHandler = createExtensionProviderHandler(editorView);
|
|
146
|
-
const contextIdentificationProviderHandler = createContextIdentifierProviderHandler(editorView);
|
|
147
130
|
providerFactory.subscribe('extensionProvider', extensionProviderHandler);
|
|
148
|
-
providerFactory.subscribe('contextIdentificationProvider', contextIdentificationProviderHandler);
|
|
149
131
|
return {
|
|
150
132
|
update: (view, prevState) => {
|
|
151
|
-
var _pluginInjectionApi$
|
|
133
|
+
var _pluginInjectionApi$c;
|
|
152
134
|
handleUpdate({
|
|
153
135
|
view,
|
|
154
136
|
prevState,
|
|
155
137
|
domAtPos,
|
|
156
138
|
extensionHandlers,
|
|
157
|
-
applyChange: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
139
|
+
applyChange: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.contextPanel) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions.applyChange
|
|
158
140
|
});
|
|
159
141
|
},
|
|
160
142
|
destroy: () => {
|
|
161
143
|
providerFactory.unsubscribe('extensionProvider', extensionProviderHandler);
|
|
162
|
-
providerFactory.unsubscribe('contextIdentificationProvider', contextIdentificationProviderHandler);
|
|
163
144
|
}
|
|
164
145
|
};
|
|
165
146
|
},
|
|
@@ -221,7 +202,7 @@ const createPlugin = (dispatch, providerFactory, extensionHandlers, portalProvid
|
|
|
221
202
|
inlineExtension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi),
|
|
222
203
|
multiBodiedExtension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi)
|
|
223
204
|
},
|
|
224
|
-
handleClickOn: createSelectionClickHandler(['extension', 'bodiedExtension'], target => !target.closest('.extension-content'), {
|
|
205
|
+
handleClickOn: createSelectionClickHandler(['extension', 'bodiedExtension', 'multiBodiedExtension'], target => !target.closest('.extension-content'), {
|
|
225
206
|
useLongPressSelection
|
|
226
207
|
})
|
|
227
208
|
}
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -183,8 +183,12 @@ export const getToolbarConfig = ({
|
|
|
183
183
|
*
|
|
184
184
|
*/
|
|
185
185
|
const frameheight = mbeFrameRect.height > 0 ? mbeFrameRect.height : 102;
|
|
186
|
+
// MBE wrapper header height includes, top margin 8px + bottom margin 8px + Line height of 16px + padding top 8px
|
|
187
|
+
// Ref: platform/packages/editor/editor-common/src/extensibility/MultiBodiedExtension/styles.ts
|
|
188
|
+
const wrapperHeaderHeight = 40;
|
|
189
|
+
const toolbarTopPos = mbeNodeRect.top + frameheight + wrapperHeaderHeight + scrollWrapper.scrollTop;
|
|
186
190
|
return {
|
|
187
|
-
top:
|
|
191
|
+
top: toolbarTopPos,
|
|
188
192
|
left: nextPos.left
|
|
189
193
|
};
|
|
190
194
|
},
|