@atlaskit/editor-plugin-panel 9.0.9 → 9.0.11
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 +14 -0
- package/dist/cjs/editor-actions/actions.js +9 -34
- package/dist/cjs/panelPlugin.js +36 -69
- package/dist/es2019/editor-actions/actions.js +2 -27
- package/dist/es2019/panelPlugin.js +38 -75
- package/dist/esm/editor-actions/actions.js +2 -25
- package/dist/esm/panelPlugin.js +36 -69
- package/dist/types/editor-actions/actions.d.ts +1 -3
- package/dist/types-ts4.5/editor-actions/actions.d.ts +1 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-panel
|
|
2
2
|
|
|
3
|
+
## 9.0.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`ef378e27dc43d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ef378e27dc43d) -
|
|
8
|
+
Clean up platform_editor_fix_quick_insert_consistency_exp
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 9.0.10
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 9.0.9
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -4,18 +4,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.changePanelType = void 0;
|
|
8
|
-
exports.insertPanelWithAnalytics = insertPanelWithAnalytics;
|
|
9
|
-
exports.removePanel = void 0;
|
|
7
|
+
exports.removePanel = exports.changePanelType = void 0;
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var _adfSchema = require("@atlaskit/adf-schema");
|
|
12
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
|
-
var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
|
|
14
10
|
var _panel = require("@atlaskit/editor-common/panel");
|
|
15
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
16
11
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
17
|
-
var
|
|
18
|
-
var
|
|
12
|
+
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
13
|
+
var _utils2 = require("../pm-plugins/utils/utils");
|
|
19
14
|
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; }
|
|
20
15
|
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; }
|
|
21
16
|
var removePanel = exports.removePanel = function removePanel(editorAnalyticsAPI) {
|
|
@@ -31,10 +26,10 @@ var removePanel = exports.removePanel = function removePanel(editorAnalyticsAPI)
|
|
|
31
26
|
eventType: _analytics.EVENT_TYPE.TRACK
|
|
32
27
|
};
|
|
33
28
|
var deleteTr = tr;
|
|
34
|
-
if ((0,
|
|
35
|
-
deleteTr = (0,
|
|
36
|
-
} else if ((0,
|
|
37
|
-
deleteTr = (0,
|
|
29
|
+
if ((0, _utils.findSelectedNodeOfType)(nodes.panel)(tr.selection)) {
|
|
30
|
+
deleteTr = (0, _utils.removeSelectedNode)(tr);
|
|
31
|
+
} else if ((0, _utils.findParentNodeOfType)(nodes.panel)(tr.selection)) {
|
|
32
|
+
deleteTr = (0, _utils.removeParentNodeOfType)(nodes.panel)(tr);
|
|
38
33
|
}
|
|
39
34
|
if (!deleteTr) {
|
|
40
35
|
return false;
|
|
@@ -53,7 +48,7 @@ var changePanelType = exports.changePanelType = function changePanelType(editorA
|
|
|
53
48
|
return function (state, dispatch) {
|
|
54
49
|
var nodes = state.schema.nodes,
|
|
55
50
|
tr = state.tr;
|
|
56
|
-
var panelNode = (0,
|
|
51
|
+
var panelNode = (0, _utils2.findPanel)(state);
|
|
57
52
|
if (panelNode === undefined) {
|
|
58
53
|
return false;
|
|
59
54
|
}
|
|
@@ -103,24 +98,4 @@ var changePanelType = exports.changePanelType = function changePanelType(editorA
|
|
|
103
98
|
return true;
|
|
104
99
|
};
|
|
105
100
|
};
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
// Delete with 'platform_editor_fix_quick_insert_consistency_exp'
|
|
109
|
-
function insertPanelWithAnalytics(inputMethod, analyticsAPI) {
|
|
110
|
-
return (0, _editorAnalytics.withAnalytics)(analyticsAPI, {
|
|
111
|
-
action: _analytics.ACTION.INSERTED,
|
|
112
|
-
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
113
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.PANEL,
|
|
114
|
-
attributes: {
|
|
115
|
-
inputMethod: inputMethod,
|
|
116
|
-
panelType: _adfSchema.PanelType.INFO // only info panels can be inserted via this action
|
|
117
|
-
},
|
|
118
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
119
|
-
})(function (state, dispatch) {
|
|
120
|
-
var nodes = state.schema.nodes;
|
|
121
|
-
if (nodes.panel && nodes.paragraph) {
|
|
122
|
-
return (0, _utils.wrapSelectionIn)(nodes.panel)(state, dispatch);
|
|
123
|
-
}
|
|
124
|
-
return false;
|
|
125
|
-
});
|
|
126
|
-
}
|
|
101
|
+
};
|
package/dist/cjs/panelPlugin.js
CHANGED
|
@@ -16,10 +16,7 @@ var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
|
16
16
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
17
17
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
18
18
|
var _colors = require("@atlaskit/theme/colors");
|
|
19
|
-
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
20
19
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
21
|
-
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
22
|
-
var _actions = require("./editor-actions/actions");
|
|
23
20
|
var _keymaps = _interopRequireDefault(require("./pm-plugins/keymaps"));
|
|
24
21
|
var _main = require("./pm-plugins/main");
|
|
25
22
|
var _panelBlockMenuItem = require("./ui/panelBlockMenuItem");
|
|
@@ -82,28 +79,23 @@ var panelPlugin = function panelPlugin(_ref) {
|
|
|
82
79
|
},
|
|
83
80
|
actions: {
|
|
84
81
|
insertPanel: function insertPanel(inputMethod) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
};
|
|
103
|
-
} else {
|
|
104
|
-
var _api$analytics;
|
|
105
|
-
return (0, _actions.insertPanelWithAnalytics)(inputMethod, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
|
|
106
|
-
}
|
|
82
|
+
return function (state, dispatch) {
|
|
83
|
+
var tr = createPanelAction({
|
|
84
|
+
state: state,
|
|
85
|
+
attributes: {
|
|
86
|
+
panelType: _adfSchema.PanelType.INFO
|
|
87
|
+
},
|
|
88
|
+
api: api,
|
|
89
|
+
inputMethod: inputMethod
|
|
90
|
+
});
|
|
91
|
+
if (!tr) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
if (dispatch) {
|
|
95
|
+
dispatch(tr);
|
|
96
|
+
}
|
|
97
|
+
return true;
|
|
98
|
+
};
|
|
107
99
|
}
|
|
108
100
|
},
|
|
109
101
|
pluginsOptions: {
|
|
@@ -261,55 +253,30 @@ function createPanelAction(_ref4) {
|
|
|
261
253
|
inputMethod = _ref4$inputMethod === void 0 ? _analytics.INPUT_METHOD.QUICK_INSERT : _ref4$inputMethod;
|
|
262
254
|
var panel = state.schema.nodes.panel;
|
|
263
255
|
var tr;
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
*/
|
|
270
|
-
if ((0, _expValEquals.expValEquals)('platform_editor_fix_quick_insert_consistency_exp', 'isEnabled', true)) {
|
|
271
|
-
// If the selection is empty, we want to insert the panel on a new line
|
|
272
|
-
if (state.selection.empty) {
|
|
273
|
-
var node = panel.createAndFill(_objectSpread({}, attributes));
|
|
274
|
-
if (!node) {
|
|
275
|
-
return false;
|
|
276
|
-
}
|
|
277
|
-
if (typeAheadInsert !== undefined) {
|
|
278
|
-
// If the type-ahead insert is provided, we should use that to insert the node
|
|
279
|
-
tr = typeAheadInsert(node);
|
|
280
|
-
} else {
|
|
281
|
-
var _insertSelectedItem;
|
|
282
|
-
// Otherwise we can use insertSelectedItem to insert the node
|
|
283
|
-
tr = (_insertSelectedItem = (0, _insert.insertSelectedItem)(node)(state, state.tr, state.selection.head)) === null || _insertSelectedItem === void 0 ? void 0 : _insertSelectedItem.scrollIntoView();
|
|
284
|
-
}
|
|
285
|
-
} else {
|
|
286
|
-
tr = (0, _utils.createWrapSelectionTransaction)({
|
|
287
|
-
state: state,
|
|
288
|
-
type: panel,
|
|
289
|
-
nodeAttributes: _objectSpread({}, attributes)
|
|
290
|
-
});
|
|
256
|
+
// If the selection is empty, we want to insert the panel on a new line
|
|
257
|
+
if (state.selection.empty) {
|
|
258
|
+
var node = panel.createAndFill(_objectSpread({}, attributes));
|
|
259
|
+
if (!node) {
|
|
260
|
+
return false;
|
|
291
261
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
296
|
-
tr = state.selection.empty && (0, _utils.createWrapSelectionTransaction)({
|
|
297
|
-
state: state,
|
|
298
|
-
type: panel,
|
|
299
|
-
nodeAttributes: _objectSpread({}, attributes)
|
|
300
|
-
});
|
|
262
|
+
if (typeAheadInsert !== undefined) {
|
|
263
|
+
// If the type-ahead insert is provided, we should use that to insert the node
|
|
264
|
+
tr = typeAheadInsert(node);
|
|
301
265
|
} else {
|
|
302
|
-
var
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- This is only optional within the experiment, so safe to assume non-null here
|
|
307
|
-
tr = state.selection.empty && typeAheadInsert(_node);
|
|
266
|
+
var _insertSelectedItem;
|
|
267
|
+
// Otherwise we can use insertSelectedItem to insert the node
|
|
268
|
+
tr = (_insertSelectedItem = (0, _insert.insertSelectedItem)(node)(state, state.tr, state.selection.head)) === null || _insertSelectedItem === void 0 ? void 0 : _insertSelectedItem.scrollIntoView();
|
|
308
269
|
}
|
|
270
|
+
} else {
|
|
271
|
+
tr = (0, _utils.createWrapSelectionTransaction)({
|
|
272
|
+
state: state,
|
|
273
|
+
type: panel,
|
|
274
|
+
nodeAttributes: _objectSpread({}, attributes)
|
|
275
|
+
});
|
|
309
276
|
}
|
|
310
277
|
if (tr) {
|
|
311
|
-
var _api$
|
|
312
|
-
api === null || api === void 0 || (_api$
|
|
278
|
+
var _api$analytics;
|
|
279
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
313
280
|
action: _analytics.ACTION.INSERTED,
|
|
314
281
|
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
315
282
|
actionSubjectId: _analytics.ACTION_SUBJECT_ID.PANEL,
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
1
|
+
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
2
|
import { getPanelTypeBackgroundNoTokens } from '@atlaskit/editor-common/panel';
|
|
5
|
-
import { wrapSelectionIn } from '@atlaskit/editor-common/utils';
|
|
6
3
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
4
|
import { findParentNodeOfType, findSelectedNodeOfType, removeParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
|
|
8
5
|
import { findPanel } from '../pm-plugins/utils/utils';
|
|
@@ -92,26 +89,4 @@ export const changePanelType = editorAnalyticsAPI => (panelType, panelOptions =
|
|
|
92
89
|
dispatch(newTrWithSelection);
|
|
93
90
|
}
|
|
94
91
|
return true;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
// Delete with 'platform_editor_fix_quick_insert_consistency_exp'
|
|
98
|
-
export function insertPanelWithAnalytics(inputMethod, analyticsAPI) {
|
|
99
|
-
return withAnalytics(analyticsAPI, {
|
|
100
|
-
action: ACTION.INSERTED,
|
|
101
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
102
|
-
actionSubjectId: ACTION_SUBJECT_ID.PANEL,
|
|
103
|
-
attributes: {
|
|
104
|
-
inputMethod: inputMethod,
|
|
105
|
-
panelType: PanelType.INFO // only info panels can be inserted via this action
|
|
106
|
-
},
|
|
107
|
-
eventType: EVENT_TYPE.TRACK
|
|
108
|
-
})(function (state, dispatch) {
|
|
109
|
-
const {
|
|
110
|
-
nodes
|
|
111
|
-
} = state.schema;
|
|
112
|
-
if (nodes.panel && nodes.paragraph) {
|
|
113
|
-
return wrapSelectionIn(nodes.panel)(state, dispatch);
|
|
114
|
-
}
|
|
115
|
-
return false;
|
|
116
|
-
});
|
|
117
|
-
}
|
|
92
|
+
};
|
|
@@ -8,10 +8,7 @@ import { IconCustomPanel, IconPanel, IconPanelError, IconPanelNote, IconPanelSuc
|
|
|
8
8
|
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
9
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
10
|
import { T50 } from '@atlaskit/theme/colors';
|
|
11
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
12
11
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
13
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
14
|
-
import { insertPanelWithAnalytics } from './editor-actions/actions';
|
|
15
12
|
import keymap from './pm-plugins/keymaps';
|
|
16
13
|
import { createPlugin } from './pm-plugins/main';
|
|
17
14
|
import { createPanelBlockMenuItem } from './ui/panelBlockMenuItem';
|
|
@@ -70,28 +67,23 @@ const panelPlugin = ({
|
|
|
70
67
|
},
|
|
71
68
|
actions: {
|
|
72
69
|
insertPanel(inputMethod) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
};
|
|
91
|
-
} else {
|
|
92
|
-
var _api$analytics;
|
|
93
|
-
return insertPanelWithAnalytics(inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
|
|
94
|
-
}
|
|
70
|
+
return function (state, dispatch) {
|
|
71
|
+
const tr = createPanelAction({
|
|
72
|
+
state,
|
|
73
|
+
attributes: {
|
|
74
|
+
panelType: PanelType.INFO
|
|
75
|
+
},
|
|
76
|
+
api,
|
|
77
|
+
inputMethod
|
|
78
|
+
});
|
|
79
|
+
if (!tr) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
if (dispatch) {
|
|
83
|
+
dispatch(tr);
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
};
|
|
95
87
|
}
|
|
96
88
|
},
|
|
97
89
|
pluginsOptions: {
|
|
@@ -239,63 +231,34 @@ function createPanelAction({
|
|
|
239
231
|
panel
|
|
240
232
|
} = state.schema.nodes;
|
|
241
233
|
let tr;
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
if (
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
});
|
|
254
|
-
if (!node) {
|
|
255
|
-
return false;
|
|
256
|
-
}
|
|
257
|
-
if (typeAheadInsert !== undefined) {
|
|
258
|
-
// If the type-ahead insert is provided, we should use that to insert the node
|
|
259
|
-
tr = typeAheadInsert(node);
|
|
260
|
-
} else {
|
|
261
|
-
var _insertSelectedItem;
|
|
262
|
-
// Otherwise we can use insertSelectedItem to insert the node
|
|
263
|
-
tr = (_insertSelectedItem = insertSelectedItem(node)(state, state.tr, state.selection.head)) === null || _insertSelectedItem === void 0 ? void 0 : _insertSelectedItem.scrollIntoView();
|
|
264
|
-
}
|
|
234
|
+
// If the selection is empty, we want to insert the panel on a new line
|
|
235
|
+
if (state.selection.empty) {
|
|
236
|
+
const node = panel.createAndFill({
|
|
237
|
+
...attributes
|
|
238
|
+
});
|
|
239
|
+
if (!node) {
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
if (typeAheadInsert !== undefined) {
|
|
243
|
+
// If the type-ahead insert is provided, we should use that to insert the node
|
|
244
|
+
tr = typeAheadInsert(node);
|
|
265
245
|
} else {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
nodeAttributes: {
|
|
270
|
-
...attributes
|
|
271
|
-
}
|
|
272
|
-
});
|
|
246
|
+
var _insertSelectedItem;
|
|
247
|
+
// Otherwise we can use insertSelectedItem to insert the node
|
|
248
|
+
tr = (_insertSelectedItem = insertSelectedItem(node)(state, state.tr, state.selection.head)) === null || _insertSelectedItem === void 0 ? void 0 : _insertSelectedItem.scrollIntoView();
|
|
273
249
|
}
|
|
274
250
|
} else {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
state,
|
|
280
|
-
type: panel,
|
|
281
|
-
nodeAttributes: {
|
|
282
|
-
...attributes
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
} else {
|
|
286
|
-
const node = panel.createAndFill({
|
|
251
|
+
tr = createWrapSelectionTransaction({
|
|
252
|
+
state,
|
|
253
|
+
type: panel,
|
|
254
|
+
nodeAttributes: {
|
|
287
255
|
...attributes
|
|
288
|
-
});
|
|
289
|
-
if (!node) {
|
|
290
|
-
return false;
|
|
291
256
|
}
|
|
292
|
-
|
|
293
|
-
tr = state.selection.empty && typeAheadInsert(node);
|
|
294
|
-
}
|
|
257
|
+
});
|
|
295
258
|
}
|
|
296
259
|
if (tr) {
|
|
297
|
-
var _api$
|
|
298
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
260
|
+
var _api$analytics;
|
|
261
|
+
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent({
|
|
299
262
|
action: ACTION.INSERTED,
|
|
300
263
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
301
264
|
actionSubjectId: ACTION_SUBJECT_ID.PANEL,
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
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; }
|
|
3
3
|
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; }
|
|
4
|
-
import {
|
|
5
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
|
-
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
4
|
+
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
7
5
|
import { getPanelTypeBackgroundNoTokens } from '@atlaskit/editor-common/panel';
|
|
8
|
-
import { wrapSelectionIn } from '@atlaskit/editor-common/utils';
|
|
9
6
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
10
7
|
import { findParentNodeOfType, findSelectedNodeOfType, removeParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
|
|
11
8
|
import { findPanel } from '../pm-plugins/utils/utils';
|
|
@@ -94,24 +91,4 @@ export var changePanelType = function changePanelType(editorAnalyticsAPI) {
|
|
|
94
91
|
return true;
|
|
95
92
|
};
|
|
96
93
|
};
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
// Delete with 'platform_editor_fix_quick_insert_consistency_exp'
|
|
100
|
-
export function insertPanelWithAnalytics(inputMethod, analyticsAPI) {
|
|
101
|
-
return withAnalytics(analyticsAPI, {
|
|
102
|
-
action: ACTION.INSERTED,
|
|
103
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
104
|
-
actionSubjectId: ACTION_SUBJECT_ID.PANEL,
|
|
105
|
-
attributes: {
|
|
106
|
-
inputMethod: inputMethod,
|
|
107
|
-
panelType: PanelType.INFO // only info panels can be inserted via this action
|
|
108
|
-
},
|
|
109
|
-
eventType: EVENT_TYPE.TRACK
|
|
110
|
-
})(function (state, dispatch) {
|
|
111
|
-
var nodes = state.schema.nodes;
|
|
112
|
-
if (nodes.panel && nodes.paragraph) {
|
|
113
|
-
return wrapSelectionIn(nodes.panel)(state, dispatch);
|
|
114
|
-
}
|
|
115
|
-
return false;
|
|
116
|
-
});
|
|
117
|
-
}
|
|
94
|
+
};
|
package/dist/esm/panelPlugin.js
CHANGED
|
@@ -11,10 +11,7 @@ import { IconCustomPanel, IconPanel, IconPanelError, IconPanelNote, IconPanelSuc
|
|
|
11
11
|
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
12
12
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
13
|
import { T50 } from '@atlaskit/theme/colors';
|
|
14
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
15
14
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
16
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
17
|
-
import { insertPanelWithAnalytics } from './editor-actions/actions';
|
|
18
15
|
import keymap from './pm-plugins/keymaps';
|
|
19
16
|
import { createPlugin } from './pm-plugins/main';
|
|
20
17
|
import { createPanelBlockMenuItem } from './ui/panelBlockMenuItem';
|
|
@@ -75,28 +72,23 @@ var panelPlugin = function panelPlugin(_ref) {
|
|
|
75
72
|
},
|
|
76
73
|
actions: {
|
|
77
74
|
insertPanel: function insertPanel(inputMethod) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
};
|
|
96
|
-
} else {
|
|
97
|
-
var _api$analytics;
|
|
98
|
-
return insertPanelWithAnalytics(inputMethod, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
|
|
99
|
-
}
|
|
75
|
+
return function (state, dispatch) {
|
|
76
|
+
var tr = createPanelAction({
|
|
77
|
+
state: state,
|
|
78
|
+
attributes: {
|
|
79
|
+
panelType: PanelType.INFO
|
|
80
|
+
},
|
|
81
|
+
api: api,
|
|
82
|
+
inputMethod: inputMethod
|
|
83
|
+
});
|
|
84
|
+
if (!tr) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
if (dispatch) {
|
|
88
|
+
dispatch(tr);
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
};
|
|
100
92
|
}
|
|
101
93
|
},
|
|
102
94
|
pluginsOptions: {
|
|
@@ -254,55 +246,30 @@ function createPanelAction(_ref4) {
|
|
|
254
246
|
inputMethod = _ref4$inputMethod === void 0 ? INPUT_METHOD.QUICK_INSERT : _ref4$inputMethod;
|
|
255
247
|
var panel = state.schema.nodes.panel;
|
|
256
248
|
var tr;
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
*/
|
|
263
|
-
if (expValEquals('platform_editor_fix_quick_insert_consistency_exp', 'isEnabled', true)) {
|
|
264
|
-
// If the selection is empty, we want to insert the panel on a new line
|
|
265
|
-
if (state.selection.empty) {
|
|
266
|
-
var node = panel.createAndFill(_objectSpread({}, attributes));
|
|
267
|
-
if (!node) {
|
|
268
|
-
return false;
|
|
269
|
-
}
|
|
270
|
-
if (typeAheadInsert !== undefined) {
|
|
271
|
-
// If the type-ahead insert is provided, we should use that to insert the node
|
|
272
|
-
tr = typeAheadInsert(node);
|
|
273
|
-
} else {
|
|
274
|
-
var _insertSelectedItem;
|
|
275
|
-
// Otherwise we can use insertSelectedItem to insert the node
|
|
276
|
-
tr = (_insertSelectedItem = insertSelectedItem(node)(state, state.tr, state.selection.head)) === null || _insertSelectedItem === void 0 ? void 0 : _insertSelectedItem.scrollIntoView();
|
|
277
|
-
}
|
|
278
|
-
} else {
|
|
279
|
-
tr = createWrapSelectionTransaction({
|
|
280
|
-
state: state,
|
|
281
|
-
type: panel,
|
|
282
|
-
nodeAttributes: _objectSpread({}, attributes)
|
|
283
|
-
});
|
|
249
|
+
// If the selection is empty, we want to insert the panel on a new line
|
|
250
|
+
if (state.selection.empty) {
|
|
251
|
+
var node = panel.createAndFill(_objectSpread({}, attributes));
|
|
252
|
+
if (!node) {
|
|
253
|
+
return false;
|
|
284
254
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
289
|
-
tr = state.selection.empty && createWrapSelectionTransaction({
|
|
290
|
-
state: state,
|
|
291
|
-
type: panel,
|
|
292
|
-
nodeAttributes: _objectSpread({}, attributes)
|
|
293
|
-
});
|
|
255
|
+
if (typeAheadInsert !== undefined) {
|
|
256
|
+
// If the type-ahead insert is provided, we should use that to insert the node
|
|
257
|
+
tr = typeAheadInsert(node);
|
|
294
258
|
} else {
|
|
295
|
-
var
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- This is only optional within the experiment, so safe to assume non-null here
|
|
300
|
-
tr = state.selection.empty && typeAheadInsert(_node);
|
|
259
|
+
var _insertSelectedItem;
|
|
260
|
+
// Otherwise we can use insertSelectedItem to insert the node
|
|
261
|
+
tr = (_insertSelectedItem = insertSelectedItem(node)(state, state.tr, state.selection.head)) === null || _insertSelectedItem === void 0 ? void 0 : _insertSelectedItem.scrollIntoView();
|
|
301
262
|
}
|
|
263
|
+
} else {
|
|
264
|
+
tr = createWrapSelectionTransaction({
|
|
265
|
+
state: state,
|
|
266
|
+
type: panel,
|
|
267
|
+
nodeAttributes: _objectSpread({}, attributes)
|
|
268
|
+
});
|
|
302
269
|
}
|
|
303
270
|
if (tr) {
|
|
304
|
-
var _api$
|
|
305
|
-
api === null || api === void 0 || (_api$
|
|
271
|
+
var _api$analytics;
|
|
272
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
306
273
|
action: ACTION.INSERTED,
|
|
307
274
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
308
275
|
actionSubjectId: ACTION_SUBJECT_ID.PANEL,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { PanelType } from '@atlaskit/adf-schema';
|
|
2
|
-
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
1
|
+
import type { PanelType } from '@atlaskit/adf-schema';
|
|
3
2
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
4
3
|
import type { Command } from '@atlaskit/editor-common/types';
|
|
5
4
|
import type { PanelOptions } from '../pm-plugins/main';
|
|
@@ -9,4 +8,3 @@ export type DomAtPos = (pos: number) => {
|
|
|
9
8
|
};
|
|
10
9
|
export declare const removePanel: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
11
10
|
export declare const changePanelType: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (panelType: PanelType, panelOptions?: PanelOptions, allowCustomPanel?: boolean) => Command;
|
|
12
|
-
export declare function insertPanelWithAnalytics(inputMethod: INPUT_METHOD, analyticsAPI?: EditorAnalyticsAPI): Command;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { PanelType } from '@atlaskit/adf-schema';
|
|
2
|
-
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
1
|
+
import type { PanelType } from '@atlaskit/adf-schema';
|
|
3
2
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
4
3
|
import type { Command } from '@atlaskit/editor-common/types';
|
|
5
4
|
import type { PanelOptions } from '../pm-plugins/main';
|
|
@@ -9,4 +8,3 @@ export type DomAtPos = (pos: number) => {
|
|
|
9
8
|
};
|
|
10
9
|
export declare const removePanel: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
11
10
|
export declare const changePanelType: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (panelType: PanelType, panelOptions?: PanelOptions, allowCustomPanel?: boolean) => Command;
|
|
12
|
-
export declare function insertPanelWithAnalytics(inputMethod: INPUT_METHOD, analyticsAPI?: EditorAnalyticsAPI): Command;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-panel",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.11",
|
|
4
4
|
"description": "Panel plugin for @atlaskit/editor-core.",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@atlaskit/icon": "^30.0.0",
|
|
43
43
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
44
44
|
"@atlaskit/theme": "^21.0.0",
|
|
45
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
45
|
+
"@atlaskit/tmp-editor-statsig": "^20.0.0",
|
|
46
46
|
"@atlaskit/tokens": "^11.0.0",
|
|
47
47
|
"@babel/runtime": "^7.0.0",
|
|
48
48
|
"uuid": "^3.1.0"
|