@atlaskit/editor-plugin-extension 0.7.0 → 0.7.2
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 +12 -0
- package/dist/cjs/actions.js +24 -13
- package/dist/cjs/context-panel.js +14 -8
- package/dist/cjs/extension-api.js +12 -0
- package/dist/cjs/pm-plugins/macro/actions.js +21 -11
- package/dist/cjs/toolbar.js +1 -1
- package/dist/es2019/actions.js +19 -5
- package/dist/es2019/context-panel.js +11 -3
- package/dist/es2019/extension-api.js +17 -1
- package/dist/es2019/pm-plugins/macro/actions.js +20 -6
- package/dist/es2019/toolbar.js +1 -1
- package/dist/esm/actions.js +24 -13
- package/dist/esm/context-panel.js +15 -8
- package/dist/esm/extension-api.js +12 -0
- package/dist/esm/pm-plugins/macro/actions.js +21 -11
- package/dist/esm/toolbar.js +1 -1
- package/dist/types/context-panel.d.ts +6 -1
- package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
- package/dist/types-ts4.5/context-panel.d.ts +6 -1
- package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-extension
|
|
2
2
|
|
|
3
|
+
## 0.7.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#70152](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/70152) [`53ed3673df28`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/53ed3673df28) - Updating adf-schema version to 35.5.1
|
|
8
|
+
|
|
9
|
+
## 0.7.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#70741](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/70741) [`7c1487568202`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7c1487568202) - ED-21973: Fix for MBE side panel config params update
|
|
14
|
+
|
|
3
15
|
## 0.7.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/cjs/actions.js
CHANGED
|
@@ -57,18 +57,26 @@ var performNodeUpdate = exports.performNodeUpdate = function performNodeUpdate(e
|
|
|
57
57
|
bodiedExtension = _schema$nodes.bodiedExtension,
|
|
58
58
|
multiBodiedExtension = _schema$nodes.multiBodiedExtension;
|
|
59
59
|
var isBodiedExtensionSelected = !!(0, _utils.findSelectedNodeOfType)([bodiedExtension])(selection);
|
|
60
|
+
var isMultiBodiedExtensionSelected = !!(0, _utils.findSelectedNodeOfType)([multiBodiedExtension])(selection);
|
|
60
61
|
var extensionState = (0, _main.getPluginState)(state);
|
|
62
|
+
var updateSelectionsByNodeType = function updateSelectionsByNodeType(nodeType) {
|
|
63
|
+
// Bodied/MultiBodied extensions can trigger an update when the cursor is inside which means that there is no node selected.
|
|
64
|
+
// To work around that we replace the parent and create a text selection instead of new node selection
|
|
65
|
+
tr = (0, _utils.replaceParentNodeOfType)(nodeType, newNode)(tr);
|
|
66
|
+
// Replacing selected node doesn't update the selection. `selection.node` still returns the old node
|
|
67
|
+
tr.setSelection(_state2.TextSelection.create(tr.doc, state.selection.anchor));
|
|
68
|
+
};
|
|
61
69
|
var targetSelectionSource = _analytics.TARGET_SELECTION_SOURCE.CURRENT_SELECTION;
|
|
62
70
|
var action = _analytics.ACTION.UPDATED;
|
|
63
71
|
var tr = state.tr;
|
|
64
72
|
|
|
65
73
|
// When it's a bodiedExtension but not selected
|
|
66
74
|
if (newNode.type === bodiedExtension && !isBodiedExtensionSelected) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
updateSelectionsByNodeType(state.schema.nodes.bodiedExtension);
|
|
76
|
+
}
|
|
77
|
+
// When it's a multiBodiedExtension but not selected
|
|
78
|
+
else if (newNode.type === multiBodiedExtension && !isMultiBodiedExtensionSelected) {
|
|
79
|
+
updateSelectionsByNodeType(state.schema.nodes.multiBodiedExtension);
|
|
72
80
|
}
|
|
73
81
|
// If any extension is currently selected
|
|
74
82
|
else if ((0, _utils.findSelectedNodeOfType)([extension, bodiedExtension, inlineExtension, multiBodiedExtension])(selection)) {
|
|
@@ -139,26 +147,29 @@ var updateExtensionParams = function updateExtensionParams(editorAnalyticsAPI) {
|
|
|
139
147
|
case 7:
|
|
140
148
|
newParameters = _context.sent;
|
|
141
149
|
if (!newParameters) {
|
|
142
|
-
_context.next =
|
|
150
|
+
_context.next = 12;
|
|
143
151
|
break;
|
|
144
152
|
}
|
|
145
153
|
newAttrs = _objectSpread(_objectSpread({}, attrs), {}, {
|
|
146
154
|
parameters: _objectSpread(_objectSpread({}, parameters), newParameters)
|
|
147
155
|
});
|
|
156
|
+
if (type.name === 'multiBodiedExtension') {
|
|
157
|
+
newAttrs.parameters.macroParams = _objectSpread(_objectSpread({}, parameters.macroParams), newParameters === null || newParameters === void 0 ? void 0 : newParameters.macroParams);
|
|
158
|
+
}
|
|
148
159
|
return _context.abrupt("return", performNodeUpdate(editorAnalyticsAPI)(type.name, newAttrs, content, marks, true)(state, dispatch, view));
|
|
149
|
-
case
|
|
150
|
-
_context.next =
|
|
160
|
+
case 12:
|
|
161
|
+
_context.next = 16;
|
|
151
162
|
break;
|
|
152
|
-
case
|
|
153
|
-
_context.prev =
|
|
163
|
+
case 14:
|
|
164
|
+
_context.prev = 14;
|
|
154
165
|
_context.t0 = _context["catch"](4);
|
|
155
|
-
case 15:
|
|
156
|
-
return _context.abrupt("return", true);
|
|
157
166
|
case 16:
|
|
167
|
+
return _context.abrupt("return", true);
|
|
168
|
+
case 17:
|
|
158
169
|
case "end":
|
|
159
170
|
return _context.stop();
|
|
160
171
|
}
|
|
161
|
-
}, _callee, null, [[4,
|
|
172
|
+
}, _callee, null, [[4, 14]]);
|
|
162
173
|
}));
|
|
163
174
|
return function (_x, _x2, _x3) {
|
|
164
175
|
return _ref.apply(this, arguments);
|
|
@@ -158,6 +158,8 @@ var getContextPanel = exports.getContextPanel = function getContextPanel(getEdit
|
|
|
158
158
|
};
|
|
159
159
|
};
|
|
160
160
|
};
|
|
161
|
+
|
|
162
|
+
// Added this interface to handle the macroParams on Parameters
|
|
161
163
|
function onChangeAction(_x2) {
|
|
162
164
|
return _onChangeAction.apply(this, arguments);
|
|
163
165
|
}
|
|
@@ -178,6 +180,7 @@ function _onChangeAction() {
|
|
|
178
180
|
_ref6,
|
|
179
181
|
positions,
|
|
180
182
|
node,
|
|
183
|
+
newAttributes,
|
|
181
184
|
newNode,
|
|
182
185
|
positionUpdated,
|
|
183
186
|
transaction,
|
|
@@ -235,15 +238,18 @@ function _onChangeAction() {
|
|
|
235
238
|
return _context3.abrupt("return");
|
|
236
239
|
case 23:
|
|
237
240
|
node = nodeWithPos.node;
|
|
238
|
-
|
|
239
|
-
parameters: _objectSpread(_objectSpread({}, oldParameters), newParameters)
|
|
240
|
-
|
|
241
|
+
newAttributes = _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
242
|
+
parameters: _objectSpread(_objectSpread(_objectSpread({}, oldParameters), newParameters), {}, {
|
|
243
|
+
macroParams: _objectSpread(_objectSpread({}, oldParameters === null || oldParameters === void 0 ? void 0 : oldParameters.macroParams), newParameters === null || newParameters === void 0 ? void 0 : newParameters.macroParams)
|
|
244
|
+
})
|
|
245
|
+
});
|
|
246
|
+
newNode = (0, _actions.buildExtensionNode)(nodeWithPos.node.toJSON().type, editorView.state.schema, newAttributes, node.content, node.marks);
|
|
241
247
|
if (newNode) {
|
|
242
|
-
_context3.next =
|
|
248
|
+
_context3.next = 28;
|
|
243
249
|
break;
|
|
244
250
|
}
|
|
245
251
|
return _context3.abrupt("return");
|
|
246
|
-
case
|
|
252
|
+
case 28:
|
|
247
253
|
positionUpdated = positions[key];
|
|
248
254
|
transaction = editorView.state.tr.replaceWith(positionUpdated, positionUpdated + newNode.nodeSize, newNode); // Ensure we preserve the selection, tr.replaceWith causes it to be lost in some cases
|
|
249
255
|
// when replacing the node
|
|
@@ -256,13 +262,13 @@ function _onChangeAction() {
|
|
|
256
262
|
}
|
|
257
263
|
positionsLess = _objectSpread({}, (0, _main.getPluginState)(editorView.state).positions);
|
|
258
264
|
delete positionsLess[key];
|
|
259
|
-
_context3.next =
|
|
265
|
+
_context3.next = 36;
|
|
260
266
|
return (0, _commands.updateState)({
|
|
261
267
|
positions: positionsLess
|
|
262
268
|
})(editorView.state, editorView.dispatch);
|
|
263
|
-
case 35:
|
|
264
|
-
editorView.dispatch(transaction);
|
|
265
269
|
case 36:
|
|
270
|
+
editorView.dispatch(transaction);
|
|
271
|
+
case 37:
|
|
266
272
|
case "end":
|
|
267
273
|
return _context3.stop();
|
|
268
274
|
}
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.getEditInLegacyMacroBrowser = exports.createExtensionAPI = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
9
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
10
|
var _validator = require("@atlaskit/adf-utils/validator");
|
|
10
11
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
@@ -17,6 +18,8 @@ var _commands = require("./commands");
|
|
|
17
18
|
var _actions = require("./pm-plugins/macro/actions");
|
|
18
19
|
var _pluginKey = require("./pm-plugins/macro/plugin-key");
|
|
19
20
|
var _utils3 = require("./utils");
|
|
21
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
22
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
20
23
|
var getEditInLegacyMacroBrowser = exports.getEditInLegacyMacroBrowser = function getEditInLegacyMacroBrowser(_ref) {
|
|
21
24
|
var view = _ref.view,
|
|
22
25
|
macroProvider = _ref.macroProvider,
|
|
@@ -221,6 +224,15 @@ var createExtensionAPI = exports.createExtensionAPI = function createExtensionAP
|
|
|
221
224
|
}) : node.marks;
|
|
222
225
|
var newContent = changedValues.hasOwnProperty('content') ? _model.Fragment.fromJSON(schema, changedValues.content) : node.content;
|
|
223
226
|
var newAttrs = changedValues.hasOwnProperty('attrs') ? changedValues.attrs : node.attrs;
|
|
227
|
+
if (node.type.name === 'multiBodiedExtension') {
|
|
228
|
+
var _changedValues$attrs, _node$attrs$parameter, _changedValues$attrs2;
|
|
229
|
+
newAttrs = _objectSpread(_objectSpread(_objectSpread({}, node.attrs), changedValues.attrs), {}, {
|
|
230
|
+
parameters: _objectSpread(_objectSpread(_objectSpread({}, node.attrs.parameters), (_changedValues$attrs = changedValues.attrs) === null || _changedValues$attrs === void 0 ? void 0 : _changedValues$attrs.parameters), {}, {
|
|
231
|
+
macroParams: _objectSpread(_objectSpread({}, (_node$attrs$parameter = node.attrs.parameters) === null || _node$attrs$parameter === void 0 ? void 0 : _node$attrs$parameter.macroParams), (_changedValues$attrs2 = changedValues.attrs) === null || _changedValues$attrs2 === void 0 || (_changedValues$attrs2 = _changedValues$attrs2.parameters) === null || _changedValues$attrs2 === void 0 ? void 0 : _changedValues$attrs2.macroParams)
|
|
232
|
+
})
|
|
233
|
+
});
|
|
234
|
+
// console.log('newAttrs', newAttrs);
|
|
235
|
+
}
|
|
224
236
|
|
|
225
237
|
// Validate if the new attributes, content and marks result in a valid node and adf.
|
|
226
238
|
try {
|
|
@@ -22,7 +22,7 @@ var insertMacroFromMacroBrowser = exports.insertMacroFromMacroBrowser = function
|
|
|
22
22
|
return function (macroProvider, macroNode, isEditing) {
|
|
23
23
|
return /*#__PURE__*/function () {
|
|
24
24
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(view) {
|
|
25
|
-
var newMacro, state, dispatch, currentLayout, node, selection, schema, _schema$nodes, extension, inlineExtension, bodiedExtension, extensionState, targetSelectionSource, tr, isBodiedExtensionSelected, pos, _macroNode$attrs, extensionType, extensionKey, layout, localId;
|
|
25
|
+
var newMacro, state, dispatch, currentLayout, node, selection, schema, _schema$nodes, extension, inlineExtension, bodiedExtension, multiBodiedExtension, updateSelectionsByNodeType, extensionState, targetSelectionSource, tr, isBodiedExtensionSelected, isMultiBodiedExtensionSelected, pos, _macroNode$attrs, extensionType, extensionKey, layout, localId;
|
|
26
26
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
27
27
|
while (1) switch (_context.prev = _context.next) {
|
|
28
28
|
case 0:
|
|
@@ -37,7 +37,7 @@ var insertMacroFromMacroBrowser = exports.insertMacroFromMacroBrowser = function
|
|
|
37
37
|
case 4:
|
|
38
38
|
newMacro = _context.sent;
|
|
39
39
|
if (!(newMacro && macroNode)) {
|
|
40
|
-
_context.next =
|
|
40
|
+
_context.next = 22;
|
|
41
41
|
break;
|
|
42
42
|
}
|
|
43
43
|
state = view.state, dispatch = view.dispatch;
|
|
@@ -52,19 +52,27 @@ var insertMacroFromMacroBrowser = exports.insertMacroFromMacroBrowser = function
|
|
|
52
52
|
return _context.abrupt("return", false);
|
|
53
53
|
case 11:
|
|
54
54
|
selection = state.selection, schema = state.schema;
|
|
55
|
-
_schema$nodes = schema.nodes, extension = _schema$nodes.extension, inlineExtension = _schema$nodes.inlineExtension, bodiedExtension = _schema$nodes.bodiedExtension;
|
|
55
|
+
_schema$nodes = schema.nodes, extension = _schema$nodes.extension, inlineExtension = _schema$nodes.inlineExtension, bodiedExtension = _schema$nodes.bodiedExtension, multiBodiedExtension = _schema$nodes.multiBodiedExtension;
|
|
56
|
+
updateSelectionsByNodeType = function updateSelectionsByNodeType(nodeType) {
|
|
57
|
+
// `isEditing` is `false` when we are inserting from insert-block toolbar
|
|
58
|
+
tr = isEditing ? (0, _utils.replaceParentNodeOfType)(nodeType, node)(tr) : (0, _utils.safeInsert)(node)(tr);
|
|
59
|
+
// Replacing selected node doesn't update the selection. `selection.node` still returns the old node
|
|
60
|
+
tr.setSelection(_state.TextSelection.create(tr.doc, state.selection.anchor));
|
|
61
|
+
};
|
|
56
62
|
extensionState = (0, _pluginFactory.getPluginState)(state);
|
|
57
63
|
targetSelectionSource = _analytics.TARGET_SELECTION_SOURCE.CURRENT_SELECTION;
|
|
58
64
|
tr = state.tr;
|
|
59
|
-
isBodiedExtensionSelected = !!(0, _utils.findSelectedNodeOfType)([bodiedExtension])(selection);
|
|
65
|
+
isBodiedExtensionSelected = !!(0, _utils.findSelectedNodeOfType)([bodiedExtension])(selection);
|
|
66
|
+
isMultiBodiedExtensionSelected = !!(0, _utils.findSelectedNodeOfType)([multiBodiedExtension])(selection); // When it's a bodiedExtension but not selected
|
|
60
67
|
if (macroNode.type === bodiedExtension && !isBodiedExtensionSelected) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
updateSelectionsByNodeType(state.schema.nodes.bodiedExtension);
|
|
69
|
+
}
|
|
70
|
+
// When it's a multiBodiedExtension but not selected
|
|
71
|
+
else if (macroNode.type === multiBodiedExtension && !isMultiBodiedExtensionSelected) {
|
|
72
|
+
updateSelectionsByNodeType(state.schema.nodes.multiBodiedExtension);
|
|
65
73
|
}
|
|
66
74
|
// If any extension is currently selected
|
|
67
|
-
else if ((0, _utils.findSelectedNodeOfType)([extension, bodiedExtension, inlineExtension])(selection)) {
|
|
75
|
+
else if ((0, _utils.findSelectedNodeOfType)([extension, bodiedExtension, inlineExtension, multiBodiedExtension])(selection)) {
|
|
68
76
|
tr = (0, _utils.replaceSelectedNode)(node)(tr);
|
|
69
77
|
// Replacing selected node doesn't update the selection. `selection.node` still returns the old node
|
|
70
78
|
tr.setSelection(_state.NodeSelection.create(tr.doc, tr.mapping.map(state.selection.anchor)));
|
|
@@ -101,9 +109,9 @@ var insertMacroFromMacroBrowser = exports.insertMacroFromMacroBrowser = function
|
|
|
101
109
|
dispatch(tr.scrollIntoView());
|
|
102
110
|
}
|
|
103
111
|
return _context.abrupt("return", true);
|
|
104
|
-
case
|
|
112
|
+
case 22:
|
|
105
113
|
return _context.abrupt("return", false);
|
|
106
|
-
case
|
|
114
|
+
case 23:
|
|
107
115
|
case "end":
|
|
108
116
|
return _context.stop();
|
|
109
117
|
}
|
|
@@ -130,6 +138,8 @@ var resolveMacro = exports.resolveMacro = function resolveMacro(macro, state, op
|
|
|
130
138
|
node = schema.nodes.bodiedExtension.create(_objectSpread(_objectSpread({}, attrs), optionalAttrs), schema.nodeFromJSON(macro).content);
|
|
131
139
|
} else if (type === 'inlineExtension') {
|
|
132
140
|
node = schema.nodes.inlineExtension.create(attrs);
|
|
141
|
+
} else if (type === 'multiBodiedExtension') {
|
|
142
|
+
node = schema.nodes.multiBodiedExtension.create(_objectSpread(_objectSpread({}, attrs), optionalAttrs), schema.nodeFromJSON(macro).content);
|
|
133
143
|
}
|
|
134
144
|
return node && (0, _insert.normaliseNestedLayout)(state, node);
|
|
135
145
|
};
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -64,7 +64,7 @@ var isLayoutSupported = function isLayoutSupported(state, selectedExtNode) {
|
|
|
64
64
|
if (!selectedExtNode) {
|
|
65
65
|
return false;
|
|
66
66
|
}
|
|
67
|
-
return !!((
|
|
67
|
+
return !!(([bodiedExtension, multiBodiedExtension].includes(selectedExtNode.node.type) || selectedExtNode.node.type === extension && !(0, _utils2.hasParentNodeOfType)([bodiedExtension, table, expand].filter(Boolean))(selection)) && !(0, _utils2.hasParentNodeOfType)([layoutSection])(selection));
|
|
68
68
|
};
|
|
69
69
|
var breakoutOptions = function breakoutOptions(state, formatMessage, extensionState, breakoutEnabled) {
|
|
70
70
|
var nodeWithPos = (0, _utils3.getSelectedExtension)(state, true);
|
package/dist/es2019/actions.js
CHANGED
|
@@ -42,7 +42,15 @@ export const performNodeUpdate = editorAnalyticsAPI => (type, newAttrs, content,
|
|
|
42
42
|
multiBodiedExtension
|
|
43
43
|
} = schema.nodes;
|
|
44
44
|
const isBodiedExtensionSelected = !!findSelectedNodeOfType([bodiedExtension])(selection);
|
|
45
|
+
const isMultiBodiedExtensionSelected = !!findSelectedNodeOfType([multiBodiedExtension])(selection);
|
|
45
46
|
const extensionState = getPluginState(state);
|
|
47
|
+
const updateSelectionsByNodeType = nodeType => {
|
|
48
|
+
// Bodied/MultiBodied extensions can trigger an update when the cursor is inside which means that there is no node selected.
|
|
49
|
+
// To work around that we replace the parent and create a text selection instead of new node selection
|
|
50
|
+
tr = replaceParentNodeOfType(nodeType, newNode)(tr);
|
|
51
|
+
// Replacing selected node doesn't update the selection. `selection.node` still returns the old node
|
|
52
|
+
tr.setSelection(TextSelection.create(tr.doc, state.selection.anchor));
|
|
53
|
+
};
|
|
46
54
|
let targetSelectionSource = TARGET_SELECTION_SOURCE.CURRENT_SELECTION;
|
|
47
55
|
let action = ACTION.UPDATED;
|
|
48
56
|
let {
|
|
@@ -51,11 +59,11 @@ export const performNodeUpdate = editorAnalyticsAPI => (type, newAttrs, content,
|
|
|
51
59
|
|
|
52
60
|
// When it's a bodiedExtension but not selected
|
|
53
61
|
if (newNode.type === bodiedExtension && !isBodiedExtensionSelected) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
updateSelectionsByNodeType(state.schema.nodes.bodiedExtension);
|
|
63
|
+
}
|
|
64
|
+
// When it's a multiBodiedExtension but not selected
|
|
65
|
+
else if (newNode.type === multiBodiedExtension && !isMultiBodiedExtensionSelected) {
|
|
66
|
+
updateSelectionsByNodeType(state.schema.nodes.multiBodiedExtension);
|
|
59
67
|
}
|
|
60
68
|
// If any extension is currently selected
|
|
61
69
|
else if (findSelectedNodeOfType([extension, bodiedExtension, inlineExtension, multiBodiedExtension])(selection)) {
|
|
@@ -126,6 +134,12 @@ const updateExtensionParams = editorAnalyticsAPI => (updateExtension, node, acti
|
|
|
126
134
|
...newParameters
|
|
127
135
|
}
|
|
128
136
|
};
|
|
137
|
+
if (type.name === 'multiBodiedExtension') {
|
|
138
|
+
newAttrs.parameters.macroParams = {
|
|
139
|
+
...parameters.macroParams,
|
|
140
|
+
...(newParameters === null || newParameters === void 0 ? void 0 : newParameters.macroParams)
|
|
141
|
+
};
|
|
142
|
+
}
|
|
129
143
|
return performNodeUpdate(editorAnalyticsAPI)(type.name, newAttrs, content, marks, true)(state, dispatch, view);
|
|
130
144
|
}
|
|
131
145
|
} catch {}
|
|
@@ -107,6 +107,9 @@ export const getContextPanel = getEditorView => (api, allowAutoSave, featureFlag
|
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
};
|
|
110
|
+
|
|
111
|
+
// Added this interface to handle the macroParams on Parameters
|
|
112
|
+
|
|
110
113
|
export async function onChangeAction(editorView, updatedParameters = {}, oldParameters = {}, nodeWithPos, onSaving) {
|
|
111
114
|
// WARNING: editorView.state stales quickly, do not unpack
|
|
112
115
|
const {
|
|
@@ -149,13 +152,18 @@ export async function onChangeAction(editorView, updatedParameters = {}, oldPara
|
|
|
149
152
|
const {
|
|
150
153
|
node
|
|
151
154
|
} = nodeWithPos;
|
|
152
|
-
const
|
|
155
|
+
const newAttributes = {
|
|
153
156
|
...node.attrs,
|
|
154
157
|
parameters: {
|
|
155
158
|
...oldParameters,
|
|
156
|
-
...newParameters
|
|
159
|
+
...newParameters,
|
|
160
|
+
macroParams: {
|
|
161
|
+
...(oldParameters === null || oldParameters === void 0 ? void 0 : oldParameters.macroParams),
|
|
162
|
+
...(newParameters === null || newParameters === void 0 ? void 0 : newParameters.macroParams)
|
|
163
|
+
}
|
|
157
164
|
}
|
|
158
|
-
}
|
|
165
|
+
};
|
|
166
|
+
const newNode = buildExtensionNode(nodeWithPos.node.toJSON().type, editorView.state.schema, newAttributes, node.content, node.marks);
|
|
159
167
|
if (!newNode) {
|
|
160
168
|
return;
|
|
161
169
|
}
|
|
@@ -234,7 +234,23 @@ export const createExtensionAPI = options => {
|
|
|
234
234
|
attrs
|
|
235
235
|
}) => mark.create(attrs)) : node.marks;
|
|
236
236
|
const newContent = changedValues.hasOwnProperty('content') ? Fragment.fromJSON(schema, changedValues.content) : node.content;
|
|
237
|
-
|
|
237
|
+
let newAttrs = changedValues.hasOwnProperty('attrs') ? changedValues.attrs : node.attrs;
|
|
238
|
+
if (node.type.name === 'multiBodiedExtension') {
|
|
239
|
+
var _changedValues$attrs, _node$attrs$parameter, _changedValues$attrs2, _changedValues$attrs3;
|
|
240
|
+
newAttrs = {
|
|
241
|
+
...node.attrs,
|
|
242
|
+
...changedValues.attrs,
|
|
243
|
+
parameters: {
|
|
244
|
+
...node.attrs.parameters,
|
|
245
|
+
...((_changedValues$attrs = changedValues.attrs) === null || _changedValues$attrs === void 0 ? void 0 : _changedValues$attrs.parameters),
|
|
246
|
+
macroParams: {
|
|
247
|
+
...((_node$attrs$parameter = node.attrs.parameters) === null || _node$attrs$parameter === void 0 ? void 0 : _node$attrs$parameter.macroParams),
|
|
248
|
+
...((_changedValues$attrs2 = changedValues.attrs) === null || _changedValues$attrs2 === void 0 ? void 0 : (_changedValues$attrs3 = _changedValues$attrs2.parameters) === null || _changedValues$attrs3 === void 0 ? void 0 : _changedValues$attrs3.macroParams)
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
// console.log('newAttrs', newAttrs);
|
|
253
|
+
}
|
|
238
254
|
|
|
239
255
|
// Validate if the new attributes, content and marks result in a valid node and adf.
|
|
240
256
|
try {
|
|
@@ -32,24 +32,33 @@ export const insertMacroFromMacroBrowser = editorAnalyticsAPI => (macroProvider,
|
|
|
32
32
|
const {
|
|
33
33
|
extension,
|
|
34
34
|
inlineExtension,
|
|
35
|
-
bodiedExtension
|
|
35
|
+
bodiedExtension,
|
|
36
|
+
multiBodiedExtension
|
|
36
37
|
} = schema.nodes;
|
|
38
|
+
const updateSelectionsByNodeType = nodeType => {
|
|
39
|
+
// `isEditing` is `false` when we are inserting from insert-block toolbar
|
|
40
|
+
tr = isEditing ? replaceParentNodeOfType(nodeType, node)(tr) : safeInsert(node)(tr);
|
|
41
|
+
// Replacing selected node doesn't update the selection. `selection.node` still returns the old node
|
|
42
|
+
tr.setSelection(TextSelection.create(tr.doc, state.selection.anchor));
|
|
43
|
+
};
|
|
37
44
|
const extensionState = getExtensionPluginState(state);
|
|
38
45
|
let targetSelectionSource = TARGET_SELECTION_SOURCE.CURRENT_SELECTION;
|
|
39
46
|
let {
|
|
40
47
|
tr
|
|
41
48
|
} = state;
|
|
42
49
|
const isBodiedExtensionSelected = !!findSelectedNodeOfType([bodiedExtension])(selection);
|
|
50
|
+
const isMultiBodiedExtensionSelected = !!findSelectedNodeOfType([multiBodiedExtension])(selection);
|
|
43
51
|
|
|
44
52
|
// When it's a bodiedExtension but not selected
|
|
45
53
|
if (macroNode.type === bodiedExtension && !isBodiedExtensionSelected) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
updateSelectionsByNodeType(state.schema.nodes.bodiedExtension);
|
|
55
|
+
}
|
|
56
|
+
// When it's a multiBodiedExtension but not selected
|
|
57
|
+
else if (macroNode.type === multiBodiedExtension && !isMultiBodiedExtensionSelected) {
|
|
58
|
+
updateSelectionsByNodeType(state.schema.nodes.multiBodiedExtension);
|
|
50
59
|
}
|
|
51
60
|
// If any extension is currently selected
|
|
52
|
-
else if (findSelectedNodeOfType([extension, bodiedExtension, inlineExtension])(selection)) {
|
|
61
|
+
else if (findSelectedNodeOfType([extension, bodiedExtension, inlineExtension, multiBodiedExtension])(selection)) {
|
|
53
62
|
tr = replaceSelectedNode(node)(tr);
|
|
54
63
|
// Replacing selected node doesn't update the selection. `selection.node` still returns the old node
|
|
55
64
|
tr.setSelection(NodeSelection.create(tr.doc, tr.mapping.map(state.selection.anchor)));
|
|
@@ -118,6 +127,11 @@ export const resolveMacro = (macro, state, optionalAttrs) => {
|
|
|
118
127
|
}, schema.nodeFromJSON(macro).content);
|
|
119
128
|
} else if (type === 'inlineExtension') {
|
|
120
129
|
node = schema.nodes.inlineExtension.create(attrs);
|
|
130
|
+
} else if (type === 'multiBodiedExtension') {
|
|
131
|
+
node = schema.nodes.multiBodiedExtension.create({
|
|
132
|
+
...attrs,
|
|
133
|
+
...optionalAttrs
|
|
134
|
+
}, schema.nodeFromJSON(macro).content);
|
|
121
135
|
}
|
|
122
136
|
return node && normaliseNestedLayout(state, node);
|
|
123
137
|
};
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -61,7 +61,7 @@ const isLayoutSupported = (state, selectedExtNode) => {
|
|
|
61
61
|
if (!selectedExtNode) {
|
|
62
62
|
return false;
|
|
63
63
|
}
|
|
64
|
-
return !!((
|
|
64
|
+
return !!(([bodiedExtension, multiBodiedExtension].includes(selectedExtNode.node.type) || selectedExtNode.node.type === extension && !hasParentNodeOfType([bodiedExtension, table, expand].filter(Boolean))(selection)) && !hasParentNodeOfType([layoutSection])(selection));
|
|
65
65
|
};
|
|
66
66
|
const breakoutOptions = (state, formatMessage, extensionState, breakoutEnabled) => {
|
|
67
67
|
const nodeWithPos = getSelectedExtension(state, true);
|
package/dist/esm/actions.js
CHANGED
|
@@ -44,18 +44,26 @@ export var performNodeUpdate = function performNodeUpdate(editorAnalyticsAPI) {
|
|
|
44
44
|
bodiedExtension = _schema$nodes.bodiedExtension,
|
|
45
45
|
multiBodiedExtension = _schema$nodes.multiBodiedExtension;
|
|
46
46
|
var isBodiedExtensionSelected = !!findSelectedNodeOfType([bodiedExtension])(selection);
|
|
47
|
+
var isMultiBodiedExtensionSelected = !!findSelectedNodeOfType([multiBodiedExtension])(selection);
|
|
47
48
|
var extensionState = getPluginState(state);
|
|
49
|
+
var updateSelectionsByNodeType = function updateSelectionsByNodeType(nodeType) {
|
|
50
|
+
// Bodied/MultiBodied extensions can trigger an update when the cursor is inside which means that there is no node selected.
|
|
51
|
+
// To work around that we replace the parent and create a text selection instead of new node selection
|
|
52
|
+
tr = replaceParentNodeOfType(nodeType, newNode)(tr);
|
|
53
|
+
// Replacing selected node doesn't update the selection. `selection.node` still returns the old node
|
|
54
|
+
tr.setSelection(TextSelection.create(tr.doc, state.selection.anchor));
|
|
55
|
+
};
|
|
48
56
|
var targetSelectionSource = TARGET_SELECTION_SOURCE.CURRENT_SELECTION;
|
|
49
57
|
var action = ACTION.UPDATED;
|
|
50
58
|
var tr = state.tr;
|
|
51
59
|
|
|
52
60
|
// When it's a bodiedExtension but not selected
|
|
53
61
|
if (newNode.type === bodiedExtension && !isBodiedExtensionSelected) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
updateSelectionsByNodeType(state.schema.nodes.bodiedExtension);
|
|
63
|
+
}
|
|
64
|
+
// When it's a multiBodiedExtension but not selected
|
|
65
|
+
else if (newNode.type === multiBodiedExtension && !isMultiBodiedExtensionSelected) {
|
|
66
|
+
updateSelectionsByNodeType(state.schema.nodes.multiBodiedExtension);
|
|
59
67
|
}
|
|
60
68
|
// If any extension is currently selected
|
|
61
69
|
else if (findSelectedNodeOfType([extension, bodiedExtension, inlineExtension, multiBodiedExtension])(selection)) {
|
|
@@ -126,26 +134,29 @@ var updateExtensionParams = function updateExtensionParams(editorAnalyticsAPI) {
|
|
|
126
134
|
case 7:
|
|
127
135
|
newParameters = _context.sent;
|
|
128
136
|
if (!newParameters) {
|
|
129
|
-
_context.next =
|
|
137
|
+
_context.next = 12;
|
|
130
138
|
break;
|
|
131
139
|
}
|
|
132
140
|
newAttrs = _objectSpread(_objectSpread({}, attrs), {}, {
|
|
133
141
|
parameters: _objectSpread(_objectSpread({}, parameters), newParameters)
|
|
134
142
|
});
|
|
143
|
+
if (type.name === 'multiBodiedExtension') {
|
|
144
|
+
newAttrs.parameters.macroParams = _objectSpread(_objectSpread({}, parameters.macroParams), newParameters === null || newParameters === void 0 ? void 0 : newParameters.macroParams);
|
|
145
|
+
}
|
|
135
146
|
return _context.abrupt("return", performNodeUpdate(editorAnalyticsAPI)(type.name, newAttrs, content, marks, true)(state, dispatch, view));
|
|
136
|
-
case
|
|
137
|
-
_context.next =
|
|
147
|
+
case 12:
|
|
148
|
+
_context.next = 16;
|
|
138
149
|
break;
|
|
139
|
-
case
|
|
140
|
-
_context.prev =
|
|
150
|
+
case 14:
|
|
151
|
+
_context.prev = 14;
|
|
141
152
|
_context.t0 = _context["catch"](4);
|
|
142
|
-
case 15:
|
|
143
|
-
return _context.abrupt("return", true);
|
|
144
153
|
case 16:
|
|
154
|
+
return _context.abrupt("return", true);
|
|
155
|
+
case 17:
|
|
145
156
|
case "end":
|
|
146
157
|
return _context.stop();
|
|
147
158
|
}
|
|
148
|
-
}, _callee, null, [[4,
|
|
159
|
+
}, _callee, null, [[4, 14]]);
|
|
149
160
|
}));
|
|
150
161
|
return function (_x, _x2, _x3) {
|
|
151
162
|
return _ref.apply(this, arguments);
|
|
@@ -150,6 +150,9 @@ export var getContextPanel = function getContextPanel(getEditorView) {
|
|
|
150
150
|
};
|
|
151
151
|
};
|
|
152
152
|
};
|
|
153
|
+
|
|
154
|
+
// Added this interface to handle the macroParams on Parameters
|
|
155
|
+
|
|
153
156
|
export function onChangeAction(_x2) {
|
|
154
157
|
return _onChangeAction.apply(this, arguments);
|
|
155
158
|
}
|
|
@@ -170,6 +173,7 @@ function _onChangeAction() {
|
|
|
170
173
|
_ref6,
|
|
171
174
|
positions,
|
|
172
175
|
node,
|
|
176
|
+
newAttributes,
|
|
173
177
|
newNode,
|
|
174
178
|
positionUpdated,
|
|
175
179
|
transaction,
|
|
@@ -227,15 +231,18 @@ function _onChangeAction() {
|
|
|
227
231
|
return _context3.abrupt("return");
|
|
228
232
|
case 23:
|
|
229
233
|
node = nodeWithPos.node;
|
|
230
|
-
|
|
231
|
-
parameters: _objectSpread(_objectSpread({}, oldParameters), newParameters)
|
|
232
|
-
|
|
234
|
+
newAttributes = _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
235
|
+
parameters: _objectSpread(_objectSpread(_objectSpread({}, oldParameters), newParameters), {}, {
|
|
236
|
+
macroParams: _objectSpread(_objectSpread({}, oldParameters === null || oldParameters === void 0 ? void 0 : oldParameters.macroParams), newParameters === null || newParameters === void 0 ? void 0 : newParameters.macroParams)
|
|
237
|
+
})
|
|
238
|
+
});
|
|
239
|
+
newNode = buildExtensionNode(nodeWithPos.node.toJSON().type, editorView.state.schema, newAttributes, node.content, node.marks);
|
|
233
240
|
if (newNode) {
|
|
234
|
-
_context3.next =
|
|
241
|
+
_context3.next = 28;
|
|
235
242
|
break;
|
|
236
243
|
}
|
|
237
244
|
return _context3.abrupt("return");
|
|
238
|
-
case
|
|
245
|
+
case 28:
|
|
239
246
|
positionUpdated = positions[key];
|
|
240
247
|
transaction = editorView.state.tr.replaceWith(positionUpdated, positionUpdated + newNode.nodeSize, newNode); // Ensure we preserve the selection, tr.replaceWith causes it to be lost in some cases
|
|
241
248
|
// when replacing the node
|
|
@@ -248,13 +255,13 @@ function _onChangeAction() {
|
|
|
248
255
|
}
|
|
249
256
|
positionsLess = _objectSpread({}, getPluginState(editorView.state).positions);
|
|
250
257
|
delete positionsLess[key];
|
|
251
|
-
_context3.next =
|
|
258
|
+
_context3.next = 36;
|
|
252
259
|
return updateState({
|
|
253
260
|
positions: positionsLess
|
|
254
261
|
})(editorView.state, editorView.dispatch);
|
|
255
|
-
case 35:
|
|
256
|
-
editorView.dispatch(transaction);
|
|
257
262
|
case 36:
|
|
263
|
+
editorView.dispatch(transaction);
|
|
264
|
+
case 37:
|
|
258
265
|
case "end":
|
|
259
266
|
return _context3.stop();
|
|
260
267
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
import _typeof from "@babel/runtime/helpers/typeof";
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2
5
|
import { validator } from '@atlaskit/adf-utils/validator';
|
|
3
6
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
7
|
import { nodeToJSON } from '@atlaskit/editor-common/utils';
|
|
@@ -214,6 +217,15 @@ export var createExtensionAPI = function createExtensionAPI(options) {
|
|
|
214
217
|
}) : node.marks;
|
|
215
218
|
var newContent = changedValues.hasOwnProperty('content') ? Fragment.fromJSON(schema, changedValues.content) : node.content;
|
|
216
219
|
var newAttrs = changedValues.hasOwnProperty('attrs') ? changedValues.attrs : node.attrs;
|
|
220
|
+
if (node.type.name === 'multiBodiedExtension') {
|
|
221
|
+
var _changedValues$attrs, _node$attrs$parameter, _changedValues$attrs2;
|
|
222
|
+
newAttrs = _objectSpread(_objectSpread(_objectSpread({}, node.attrs), changedValues.attrs), {}, {
|
|
223
|
+
parameters: _objectSpread(_objectSpread(_objectSpread({}, node.attrs.parameters), (_changedValues$attrs = changedValues.attrs) === null || _changedValues$attrs === void 0 ? void 0 : _changedValues$attrs.parameters), {}, {
|
|
224
|
+
macroParams: _objectSpread(_objectSpread({}, (_node$attrs$parameter = node.attrs.parameters) === null || _node$attrs$parameter === void 0 ? void 0 : _node$attrs$parameter.macroParams), (_changedValues$attrs2 = changedValues.attrs) === null || _changedValues$attrs2 === void 0 || (_changedValues$attrs2 = _changedValues$attrs2.parameters) === null || _changedValues$attrs2 === void 0 ? void 0 : _changedValues$attrs2.macroParams)
|
|
225
|
+
})
|
|
226
|
+
});
|
|
227
|
+
// console.log('newAttrs', newAttrs);
|
|
228
|
+
}
|
|
217
229
|
|
|
218
230
|
// Validate if the new attributes, content and marks result in a valid node and adf.
|
|
219
231
|
try {
|
|
@@ -15,7 +15,7 @@ export var insertMacroFromMacroBrowser = function insertMacroFromMacroBrowser(ed
|
|
|
15
15
|
return function (macroProvider, macroNode, isEditing) {
|
|
16
16
|
return /*#__PURE__*/function () {
|
|
17
17
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(view) {
|
|
18
|
-
var newMacro, state, dispatch, currentLayout, node, selection, schema, _schema$nodes, extension, inlineExtension, bodiedExtension, extensionState, targetSelectionSource, tr, isBodiedExtensionSelected, pos, _macroNode$attrs, extensionType, extensionKey, layout, localId;
|
|
18
|
+
var newMacro, state, dispatch, currentLayout, node, selection, schema, _schema$nodes, extension, inlineExtension, bodiedExtension, multiBodiedExtension, updateSelectionsByNodeType, extensionState, targetSelectionSource, tr, isBodiedExtensionSelected, isMultiBodiedExtensionSelected, pos, _macroNode$attrs, extensionType, extensionKey, layout, localId;
|
|
19
19
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
20
20
|
while (1) switch (_context.prev = _context.next) {
|
|
21
21
|
case 0:
|
|
@@ -30,7 +30,7 @@ export var insertMacroFromMacroBrowser = function insertMacroFromMacroBrowser(ed
|
|
|
30
30
|
case 4:
|
|
31
31
|
newMacro = _context.sent;
|
|
32
32
|
if (!(newMacro && macroNode)) {
|
|
33
|
-
_context.next =
|
|
33
|
+
_context.next = 22;
|
|
34
34
|
break;
|
|
35
35
|
}
|
|
36
36
|
state = view.state, dispatch = view.dispatch;
|
|
@@ -45,19 +45,27 @@ export var insertMacroFromMacroBrowser = function insertMacroFromMacroBrowser(ed
|
|
|
45
45
|
return _context.abrupt("return", false);
|
|
46
46
|
case 11:
|
|
47
47
|
selection = state.selection, schema = state.schema;
|
|
48
|
-
_schema$nodes = schema.nodes, extension = _schema$nodes.extension, inlineExtension = _schema$nodes.inlineExtension, bodiedExtension = _schema$nodes.bodiedExtension;
|
|
48
|
+
_schema$nodes = schema.nodes, extension = _schema$nodes.extension, inlineExtension = _schema$nodes.inlineExtension, bodiedExtension = _schema$nodes.bodiedExtension, multiBodiedExtension = _schema$nodes.multiBodiedExtension;
|
|
49
|
+
updateSelectionsByNodeType = function updateSelectionsByNodeType(nodeType) {
|
|
50
|
+
// `isEditing` is `false` when we are inserting from insert-block toolbar
|
|
51
|
+
tr = isEditing ? replaceParentNodeOfType(nodeType, node)(tr) : safeInsert(node)(tr);
|
|
52
|
+
// Replacing selected node doesn't update the selection. `selection.node` still returns the old node
|
|
53
|
+
tr.setSelection(TextSelection.create(tr.doc, state.selection.anchor));
|
|
54
|
+
};
|
|
49
55
|
extensionState = getExtensionPluginState(state);
|
|
50
56
|
targetSelectionSource = TARGET_SELECTION_SOURCE.CURRENT_SELECTION;
|
|
51
57
|
tr = state.tr;
|
|
52
|
-
isBodiedExtensionSelected = !!findSelectedNodeOfType([bodiedExtension])(selection);
|
|
58
|
+
isBodiedExtensionSelected = !!findSelectedNodeOfType([bodiedExtension])(selection);
|
|
59
|
+
isMultiBodiedExtensionSelected = !!findSelectedNodeOfType([multiBodiedExtension])(selection); // When it's a bodiedExtension but not selected
|
|
53
60
|
if (macroNode.type === bodiedExtension && !isBodiedExtensionSelected) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
updateSelectionsByNodeType(state.schema.nodes.bodiedExtension);
|
|
62
|
+
}
|
|
63
|
+
// When it's a multiBodiedExtension but not selected
|
|
64
|
+
else if (macroNode.type === multiBodiedExtension && !isMultiBodiedExtensionSelected) {
|
|
65
|
+
updateSelectionsByNodeType(state.schema.nodes.multiBodiedExtension);
|
|
58
66
|
}
|
|
59
67
|
// If any extension is currently selected
|
|
60
|
-
else if (findSelectedNodeOfType([extension, bodiedExtension, inlineExtension])(selection)) {
|
|
68
|
+
else if (findSelectedNodeOfType([extension, bodiedExtension, inlineExtension, multiBodiedExtension])(selection)) {
|
|
61
69
|
tr = replaceSelectedNode(node)(tr);
|
|
62
70
|
// Replacing selected node doesn't update the selection. `selection.node` still returns the old node
|
|
63
71
|
tr.setSelection(NodeSelection.create(tr.doc, tr.mapping.map(state.selection.anchor)));
|
|
@@ -94,9 +102,9 @@ export var insertMacroFromMacroBrowser = function insertMacroFromMacroBrowser(ed
|
|
|
94
102
|
dispatch(tr.scrollIntoView());
|
|
95
103
|
}
|
|
96
104
|
return _context.abrupt("return", true);
|
|
97
|
-
case
|
|
105
|
+
case 22:
|
|
98
106
|
return _context.abrupt("return", false);
|
|
99
|
-
case
|
|
107
|
+
case 23:
|
|
100
108
|
case "end":
|
|
101
109
|
return _context.stop();
|
|
102
110
|
}
|
|
@@ -123,6 +131,8 @@ export var resolveMacro = function resolveMacro(macro, state, optionalAttrs) {
|
|
|
123
131
|
node = schema.nodes.bodiedExtension.create(_objectSpread(_objectSpread({}, attrs), optionalAttrs), schema.nodeFromJSON(macro).content);
|
|
124
132
|
} else if (type === 'inlineExtension') {
|
|
125
133
|
node = schema.nodes.inlineExtension.create(attrs);
|
|
134
|
+
} else if (type === 'multiBodiedExtension') {
|
|
135
|
+
node = schema.nodes.multiBodiedExtension.create(_objectSpread(_objectSpread({}, attrs), optionalAttrs), schema.nodeFromJSON(macro).content);
|
|
126
136
|
}
|
|
127
137
|
return node && normaliseNestedLayout(state, node);
|
|
128
138
|
};
|
package/dist/esm/toolbar.js
CHANGED
|
@@ -57,7 +57,7 @@ var isLayoutSupported = function isLayoutSupported(state, selectedExtNode) {
|
|
|
57
57
|
if (!selectedExtNode) {
|
|
58
58
|
return false;
|
|
59
59
|
}
|
|
60
|
-
return !!((
|
|
60
|
+
return !!(([bodiedExtension, multiBodiedExtension].includes(selectedExtNode.node.type) || selectedExtNode.node.type === extension && !hasParentNodeOfType([bodiedExtension, table, expand].filter(Boolean))(selection)) && !hasParentNodeOfType([layoutSection])(selection));
|
|
61
61
|
};
|
|
62
62
|
var breakoutOptions = function breakoutOptions(state, formatMessage, extensionState, breakoutEnabled) {
|
|
63
63
|
var nodeWithPos = getSelectedExtension(state, true);
|
|
@@ -7,4 +7,9 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
|
7
7
|
import type { ExtensionPlugin } from './types';
|
|
8
8
|
export declare const duplicateSelection: (selectionToDuplicate: Selection, doc: Node) => Selection | undefined;
|
|
9
9
|
export declare const getContextPanel: (getEditorView?: () => EditorView | undefined) => (api: ExtractInjectionAPI<ExtensionPlugin> | undefined, allowAutoSave?: boolean, featureFlags?: FeatureFlags) => (state: EditorState) => JSX.Element | undefined;
|
|
10
|
-
|
|
10
|
+
interface Parameters {
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
macroParams?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
export declare function onChangeAction(editorView: EditorView, updatedParameters: Parameters | undefined, oldParameters: Parameters | undefined, nodeWithPos: ContentNodeWithPos, onSaving?: () => void): Promise<void>;
|
|
15
|
+
export {};
|
|
@@ -19,5 +19,5 @@ type Props = {
|
|
|
19
19
|
featureFlags?: FeatureFlags;
|
|
20
20
|
api: ExtractInjectionAPI<ExtensionPlugin> | undefined;
|
|
21
21
|
} & WithAnalyticsEventsProps;
|
|
22
|
-
declare const _default: React.ForwardRefExoticComponent<Pick<Omit<Props, keyof WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "featureFlags" | "api" | "autoSaveReject" | "
|
|
22
|
+
declare const _default: React.ForwardRefExoticComponent<Pick<Omit<Props, keyof WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "featureFlags" | "api" | "autoSaveReject" | "parameters" | "key" | "autoSave" | "onChange" | "errorMessage" | "analyticsContext" | "fields" | "extensionManifest" | "isLoading" | "onCancel" | "autoSaveTrigger" | "showHeader" | "closeOnEsc"> & React.RefAttributes<any>>;
|
|
23
23
|
export default _default;
|
|
@@ -7,4 +7,9 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
|
7
7
|
import type { ExtensionPlugin } from './types';
|
|
8
8
|
export declare const duplicateSelection: (selectionToDuplicate: Selection, doc: Node) => Selection | undefined;
|
|
9
9
|
export declare const getContextPanel: (getEditorView?: () => EditorView | undefined) => (api: ExtractInjectionAPI<ExtensionPlugin> | undefined, allowAutoSave?: boolean, featureFlags?: FeatureFlags) => (state: EditorState) => JSX.Element | undefined;
|
|
10
|
-
|
|
10
|
+
interface Parameters {
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
macroParams?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
export declare function onChangeAction(editorView: EditorView, updatedParameters: Parameters | undefined, oldParameters: Parameters | undefined, nodeWithPos: ContentNodeWithPos, onSaving?: () => void): Promise<void>;
|
|
15
|
+
export {};
|
|
@@ -19,5 +19,5 @@ type Props = {
|
|
|
19
19
|
featureFlags?: FeatureFlags;
|
|
20
20
|
api: ExtractInjectionAPI<ExtensionPlugin> | undefined;
|
|
21
21
|
} & WithAnalyticsEventsProps;
|
|
22
|
-
declare const _default: React.ForwardRefExoticComponent<Pick<Omit<Props, keyof WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "featureFlags" | "api" | "autoSaveReject" | "
|
|
22
|
+
declare const _default: React.ForwardRefExoticComponent<Pick<Omit<Props, keyof WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "featureFlags" | "api" | "autoSaveReject" | "parameters" | "key" | "autoSave" | "onChange" | "errorMessage" | "analyticsContext" | "fields" | "extensionManifest" | "isLoading" | "onCancel" | "autoSaveTrigger" | "showHeader" | "closeOnEsc"> & React.RefAttributes<any>>;
|
|
23
23
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-extension",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "editor-plugin-extension plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
".": "./src/index.ts"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@atlaskit/adf-schema": "^35.
|
|
27
|
+
"@atlaskit/adf-schema": "^35.5.1",
|
|
28
28
|
"@atlaskit/adf-utils": "^19.0.0",
|
|
29
29
|
"@atlaskit/analytics-next": "^9.1.0",
|
|
30
30
|
"@atlaskit/avatar": "^21.4.0",
|
|
31
|
-
"@atlaskit/button": "^17.
|
|
31
|
+
"@atlaskit/button": "^17.3.0",
|
|
32
32
|
"@atlaskit/checkbox": "^13.0.0",
|
|
33
33
|
"@atlaskit/datetime-picker": "^13.0.3",
|
|
34
|
-
"@atlaskit/editor-common": "^77.
|
|
34
|
+
"@atlaskit/editor-common": "^77.2.0",
|
|
35
35
|
"@atlaskit/editor-json-transformer": "^8.10.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^0.4.0",
|
|
37
37
|
"@atlaskit/editor-plugin-context-identifier": "^0.1.0",
|