@atlaskit/editor-core 185.12.1 → 185.13.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 +12 -0
- package/dist/cjs/plugins/block-type/commands/block-type.js +79 -44
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +2 -1
- package/dist/cjs/plugins/code-block/index.js +7 -3
- package/dist/cjs/plugins/expand/commands.js +6 -2
- package/dist/cjs/plugins/expand/index.js +5 -1
- package/dist/cjs/plugins/panel/index.js +81 -43
- package/dist/cjs/plugins/quick-insert/commands.js +2 -0
- package/dist/cjs/ui/ElementBrowser/InsertMenu.js +10 -0
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/block-type/commands/block-type.js +86 -51
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +2 -1
- package/dist/es2019/plugins/code-block/index.js +7 -2
- package/dist/es2019/plugins/expand/commands.js +6 -2
- package/dist/es2019/plugins/expand/index.js +5 -1
- package/dist/es2019/plugins/panel/index.js +82 -41
- package/dist/es2019/plugins/quick-insert/commands.js +2 -0
- package/dist/es2019/ui/ElementBrowser/InsertMenu.js +10 -0
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/block-type/commands/block-type.js +76 -43
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +2 -1
- package/dist/esm/plugins/code-block/index.js +7 -2
- package/dist/esm/plugins/expand/commands.js +6 -2
- package/dist/esm/plugins/expand/index.js +5 -1
- package/dist/esm/plugins/panel/index.js +81 -43
- package/dist/esm/plugins/quick-insert/commands.js +2 -0
- package/dist/esm/ui/ElementBrowser/InsertMenu.js +10 -0
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/block-type/commands/block-type.d.ts +25 -0
- package/dist/types-ts4.5/plugins/block-type/commands/block-type.d.ts +25 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 185.13.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`36f667d92e5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/36f667d92e5) - Add data-testid to ToolbarBlockType
|
|
8
|
+
|
|
9
|
+
## 185.12.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`a20c7920f82`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a20c7920f82) - [ux] ED-15477 Update insertion behaviour for expands, code blocks and panels to make them consistent
|
|
14
|
+
|
|
3
15
|
## 185.12.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.cleanUpAtTheStartOfDocument = void 0;
|
|
7
|
+
exports.createInsertCodeBlockTransaction = createInsertCodeBlockTransaction;
|
|
8
|
+
exports.createWrapSelectionTransaction = createWrapSelectionTransaction;
|
|
7
9
|
exports.insertBlockType = insertBlockType;
|
|
8
10
|
exports.insertBlockTypesWithAnalytics = void 0;
|
|
9
11
|
exports.setBlockType = setBlockType;
|
|
@@ -225,34 +227,53 @@ var insertBlockTypesWithAnalytics = function insertBlockTypesWithAnalytics(name,
|
|
|
225
227
|
}
|
|
226
228
|
};
|
|
227
229
|
|
|
230
|
+
/**
|
|
231
|
+
* This function creates a new transaction that wraps the current selection
|
|
232
|
+
* in the specified node type if it results in a valid transaction.
|
|
233
|
+
* If not valid, it performs a safe insert operation.
|
|
234
|
+
*
|
|
235
|
+
* Example of when wrapping might not be valid is when attempting to wrap
|
|
236
|
+
* content that is already inside a panel with another panel
|
|
237
|
+
*/
|
|
238
|
+
exports.insertBlockTypesWithAnalytics = insertBlockTypesWithAnalytics;
|
|
239
|
+
function createWrapSelectionTransaction(_ref3) {
|
|
240
|
+
var state = _ref3.state,
|
|
241
|
+
type = _ref3.type,
|
|
242
|
+
nodeAttributes = _ref3.nodeAttributes;
|
|
243
|
+
var tr = state.tr;
|
|
244
|
+
var _state$selection = state.selection,
|
|
245
|
+
$from = _state$selection.$from,
|
|
246
|
+
$to = _state$selection.$to;
|
|
247
|
+
var _state$schema$marks = state.schema.marks,
|
|
248
|
+
alignment = _state$schema$marks.alignment,
|
|
249
|
+
indentation = _state$schema$marks.indentation;
|
|
250
|
+
|
|
251
|
+
/** Alignment or Indentation is not valid inside block types */
|
|
252
|
+
var removeAlignTr = (0, _mark.removeBlockMarks)(state, [alignment, indentation]);
|
|
253
|
+
tr = removeAlignTr || tr;
|
|
254
|
+
var range = $from.blockRange($to);
|
|
255
|
+
var wrapping = range && (0, _prosemirrorTransform.findWrapping)(range, type, nodeAttributes);
|
|
256
|
+
if (range && wrapping) {
|
|
257
|
+
tr.wrap(range, wrapping).scrollIntoView();
|
|
258
|
+
} else {
|
|
259
|
+
/** We always want to append a block type */
|
|
260
|
+
(0, _prosemirrorUtils.safeInsert)(type.createAndFill())(tr).scrollIntoView();
|
|
261
|
+
}
|
|
262
|
+
return tr;
|
|
263
|
+
}
|
|
264
|
+
|
|
228
265
|
/**
|
|
229
266
|
* Function will add wrapping node.
|
|
230
267
|
* 1. If currently selected blocks can be wrapped in the wrapper type it will wrap them.
|
|
231
268
|
* 2. If current block can not be wrapped inside wrapping block it will create a new block below selection,
|
|
232
269
|
* and set selection on it.
|
|
233
270
|
*/
|
|
234
|
-
exports.insertBlockTypesWithAnalytics = insertBlockTypesWithAnalytics;
|
|
235
271
|
function wrapSelectionIn(type) {
|
|
236
272
|
return function (state, dispatch) {
|
|
237
|
-
var tr =
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
var _state$schema$marks = state.schema.marks,
|
|
242
|
-
alignment = _state$schema$marks.alignment,
|
|
243
|
-
indentation = _state$schema$marks.indentation;
|
|
244
|
-
|
|
245
|
-
/** Alignment or Indentation is not valid inside block types */
|
|
246
|
-
var removeAlignTr = (0, _mark.removeBlockMarks)(state, [alignment, indentation]);
|
|
247
|
-
tr = removeAlignTr || tr;
|
|
248
|
-
var range = $from.blockRange($to);
|
|
249
|
-
var wrapping = range && (0, _prosemirrorTransform.findWrapping)(range, type);
|
|
250
|
-
if (range && wrapping) {
|
|
251
|
-
tr.wrap(range, wrapping).scrollIntoView();
|
|
252
|
-
} else {
|
|
253
|
-
/** We always want to append a block type */
|
|
254
|
-
(0, _prosemirrorUtils.safeInsert)(type.createAndFill())(tr).scrollIntoView();
|
|
255
|
-
}
|
|
273
|
+
var tr = createWrapSelectionTransaction({
|
|
274
|
+
state: state,
|
|
275
|
+
type: type
|
|
276
|
+
});
|
|
256
277
|
if (dispatch) {
|
|
257
278
|
dispatch(tr);
|
|
258
279
|
}
|
|
@@ -260,39 +281,53 @@ function wrapSelectionIn(type) {
|
|
|
260
281
|
};
|
|
261
282
|
}
|
|
262
283
|
|
|
284
|
+
/**
|
|
285
|
+
* This function creates a new transaction that inserts a code block,
|
|
286
|
+
* if there is text selected it will wrap the current selection if not it will
|
|
287
|
+
* append the codeblock to the end of the document.
|
|
288
|
+
*/
|
|
289
|
+
function createInsertCodeBlockTransaction(_ref4) {
|
|
290
|
+
var _state$selection$$fro;
|
|
291
|
+
var state = _ref4.state;
|
|
292
|
+
var tr = state.tr;
|
|
293
|
+
var from = state.selection.from;
|
|
294
|
+
var codeBlock = state.schema.nodes.codeBlock;
|
|
295
|
+
var grandParentNodeType = (_state$selection$$fro = state.selection.$from.node(-1)) === null || _state$selection$$fro === void 0 ? void 0 : _state$selection$$fro.type;
|
|
296
|
+
var parentNodeType = state.selection.$from.parent.type;
|
|
297
|
+
|
|
298
|
+
/** We always want to append a codeBlock unless we're inserting into a paragraph
|
|
299
|
+
* AND it's a valid child of the grandparent node.
|
|
300
|
+
* Insert the current selection as codeBlock content unless it contains nodes other
|
|
301
|
+
* than paragraphs and inline.
|
|
302
|
+
*/
|
|
303
|
+
var canInsertCodeBlock = (0, _insert.shouldSplitSelectedNodeOnNodeInsertion)({
|
|
304
|
+
parentNodeType: parentNodeType,
|
|
305
|
+
grandParentNodeType: grandParentNodeType,
|
|
306
|
+
content: codeBlock.createAndFill()
|
|
307
|
+
}) && contentAllowedInCodeBlock(state);
|
|
308
|
+
if (canInsertCodeBlock) {
|
|
309
|
+
tr = (0, _transformToCodeBlock.transformToCodeBlockAction)(state, from);
|
|
310
|
+
} else {
|
|
311
|
+
(0, _prosemirrorUtils.safeInsert)(codeBlock.createAndFill())(tr).scrollIntoView();
|
|
312
|
+
}
|
|
313
|
+
return tr;
|
|
314
|
+
}
|
|
315
|
+
|
|
263
316
|
/**
|
|
264
317
|
* Function will insert code block at current selection if block is empty or below current selection and set focus on it.
|
|
265
318
|
*/
|
|
266
319
|
function insertCodeBlock() {
|
|
267
320
|
return function (state, dispatch) {
|
|
268
|
-
var
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
var codeBlock = state.schema.nodes.codeBlock;
|
|
272
|
-
var grandParentNodeType = (_state$selection$$fro = state.selection.$from.node(-1)) === null || _state$selection$$fro === void 0 ? void 0 : _state$selection$$fro.type;
|
|
273
|
-
var parentNodeType = state.selection.$from.parent.type;
|
|
274
|
-
|
|
275
|
-
/** We always want to append a codeBlock unless we're inserting into a paragraph
|
|
276
|
-
* AND it's a valid child of the grandparent node.
|
|
277
|
-
* Insert the current selection as codeBlock content unless it contains nodes other
|
|
278
|
-
* than paragraphs and inline.
|
|
279
|
-
*/
|
|
280
|
-
var canInsertCodeBlock = (0, _insert.shouldSplitSelectedNodeOnNodeInsertion)({
|
|
281
|
-
parentNodeType: parentNodeType,
|
|
282
|
-
grandParentNodeType: grandParentNodeType,
|
|
283
|
-
content: codeBlock.createAndFill()
|
|
284
|
-
}) && contentAllowedInCodeBlock(state);
|
|
285
|
-
if (canInsertCodeBlock) {
|
|
286
|
-
tr = (0, _transformToCodeBlock.transformToCodeBlockAction)(state, from);
|
|
287
|
-
} else {
|
|
288
|
-
(0, _prosemirrorUtils.safeInsert)(codeBlock.createAndFill())(tr).scrollIntoView();
|
|
289
|
-
}
|
|
321
|
+
var tr = createInsertCodeBlockTransaction({
|
|
322
|
+
state: state
|
|
323
|
+
});
|
|
290
324
|
if (dispatch) {
|
|
291
325
|
dispatch(tr);
|
|
292
326
|
}
|
|
293
327
|
return true;
|
|
294
328
|
};
|
|
295
329
|
}
|
|
330
|
+
|
|
296
331
|
/**
|
|
297
332
|
* Check if the current selection contains any nodes that are not permitted
|
|
298
333
|
* as codeBlock child nodes. Note that this allows paragraphs and inline nodes
|
|
@@ -312,8 +347,8 @@ function contentAllowedInCodeBlock(state) {
|
|
|
312
347
|
return isAllowedChild;
|
|
313
348
|
}
|
|
314
349
|
var cleanUpAtTheStartOfDocument = function cleanUpAtTheStartOfDocument(state, dispatch) {
|
|
315
|
-
var
|
|
316
|
-
$cursor =
|
|
350
|
+
var _ref5 = state.selection,
|
|
351
|
+
$cursor = _ref5.$cursor;
|
|
317
352
|
if ($cursor && !$cursor.nodeBefore && !$cursor.nodeAfter && $cursor.pos === 1) {
|
|
318
353
|
var tr = state.tr,
|
|
319
354
|
schema = state.schema;
|
|
@@ -37,7 +37,8 @@ var BlockTypeButton = function BlockTypeButton(props) {
|
|
|
37
37
|
"aria-haspopup": true,
|
|
38
38
|
"aria-expanded": props['aria-expanded'],
|
|
39
39
|
iconAfter: (0, _react2.jsx)("span", {
|
|
40
|
-
css: [_styles.wrapperStyle, props.isSmall && _styles.wrapperSmallStyle]
|
|
40
|
+
css: [_styles.wrapperStyle, props.isSmall && _styles.wrapperSmallStyle],
|
|
41
|
+
"data-testid": "toolbar-block-type-text-styles-icon"
|
|
41
42
|
}, props.isSmall && (0, _react2.jsx)(_textStyle.default, {
|
|
42
43
|
label: labelTextStyles
|
|
43
44
|
}), (0, _react2.jsx)("span", {
|
|
@@ -17,8 +17,11 @@ var _analytics = require("@atlaskit/editor-common/analytics");
|
|
|
17
17
|
var _assets = require("../quick-insert/assets");
|
|
18
18
|
var _messages = require("../block-type/messages");
|
|
19
19
|
var _refreshBrowserSelection = _interopRequireDefault(require("./refresh-browser-selection"));
|
|
20
|
+
var _blockType = require("../block-type/commands/block-type");
|
|
20
21
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } // Theres an existing interelationship between these files, where the imported function is being called for code-block
|
|
23
|
+
// Insertions via the drop down menu
|
|
24
|
+
// tslint-ignore-next-line
|
|
22
25
|
var codeBlockPlugin = function codeBlockPlugin(options, api) {
|
|
23
26
|
return {
|
|
24
27
|
name: 'codeBlock',
|
|
@@ -76,8 +79,9 @@ var codeBlockPlugin = function codeBlockPlugin(options, api) {
|
|
|
76
79
|
},
|
|
77
80
|
action: function action(insert, state) {
|
|
78
81
|
var _api$dependencies$ana;
|
|
79
|
-
var
|
|
80
|
-
|
|
82
|
+
var tr = (0, _blockType.createInsertCodeBlockTransaction)({
|
|
83
|
+
state: state
|
|
84
|
+
});
|
|
81
85
|
api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions.attachAnalyticsEvent({
|
|
82
86
|
action: _analytics.ACTION.INSERTED,
|
|
83
87
|
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
@@ -7,12 +7,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.updateExpandTitle = exports.toggleExpandExpanded = exports.setSelectionInsideExpand = exports.setExpandRef = exports.insertExpand = exports.focusTitle = exports.deleteExpandAtPos = exports.deleteExpand = exports.createExpandNode = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _prosemirrorState = require("prosemirror-state");
|
|
10
|
-
var _prosemirrorUtils = require("prosemirror-utils");
|
|
11
10
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
12
11
|
var _analytics = require("../analytics");
|
|
13
12
|
var _gapCursorSelection = require("../selection/gap-cursor-selection");
|
|
14
13
|
var _utils2 = require("./utils");
|
|
15
14
|
var _pluginFactory = require("./pm-plugins/plugin-factory");
|
|
15
|
+
var _blockType = require("../block-type/commands/block-type");
|
|
16
16
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
17
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18
18
|
var setExpandRef = function setExpandRef(ref) {
|
|
@@ -118,6 +118,10 @@ var createExpandNode = function createExpandNode(state) {
|
|
|
118
118
|
exports.createExpandNode = createExpandNode;
|
|
119
119
|
var insertExpand = function insertExpand(state, dispatch) {
|
|
120
120
|
var expandNode = createExpandNode(state);
|
|
121
|
+
var tr = (0, _blockType.createWrapSelectionTransaction)({
|
|
122
|
+
state: state,
|
|
123
|
+
type: state.schema.nodes.expand
|
|
124
|
+
});
|
|
121
125
|
var payload = {
|
|
122
126
|
action: _analytics.ACTION.INSERTED,
|
|
123
127
|
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
@@ -128,7 +132,7 @@ var insertExpand = function insertExpand(state, dispatch) {
|
|
|
128
132
|
eventType: _analytics.EVENT_TYPE.TRACK
|
|
129
133
|
};
|
|
130
134
|
if (dispatch && expandNode) {
|
|
131
|
-
dispatch((0, _analytics.addAnalytics)(state,
|
|
135
|
+
dispatch((0, _analytics.addAnalytics)(state, tr, payload));
|
|
132
136
|
}
|
|
133
137
|
return true;
|
|
134
138
|
};
|
|
@@ -22,6 +22,7 @@ var _analytics = require("../analytics");
|
|
|
22
22
|
var _toolbar = require("./toolbar");
|
|
23
23
|
var _commands = require("./commands");
|
|
24
24
|
var _messages = require("../insert-block/ui/ToolbarInsertBlock/messages");
|
|
25
|
+
var _blockType = require("../block-type/commands/block-type");
|
|
25
26
|
var _pluginFactory = require("./pm-plugins/plugin-factory");
|
|
26
27
|
var expandPlugin = function expandPlugin() {
|
|
27
28
|
var _api$dependencies, _api$dependencies$fea;
|
|
@@ -73,7 +74,10 @@ var expandPlugin = function expandPlugin() {
|
|
|
73
74
|
if (!node) {
|
|
74
75
|
return false;
|
|
75
76
|
}
|
|
76
|
-
var tr =
|
|
77
|
+
var tr = (0, _blockType.createWrapSelectionTransaction)({
|
|
78
|
+
state: state,
|
|
79
|
+
type: state.schema.nodes.expand
|
|
80
|
+
});
|
|
77
81
|
return (0, _analytics.addAnalytics)(state, tr, {
|
|
78
82
|
action: _analytics.ACTION.INSERTED,
|
|
79
83
|
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
@@ -15,25 +15,10 @@ var _assets = require("../quick-insert/assets");
|
|
|
15
15
|
var _messages = require("../block-type/messages");
|
|
16
16
|
var _customPanel = _interopRequireDefault(require("../quick-insert/assets/custom-panel"));
|
|
17
17
|
var _colors = require("@atlaskit/theme/colors");
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
action: _analytics.ACTION.INSERTED,
|
|
23
|
-
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
24
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.PANEL,
|
|
25
|
-
attributes: {
|
|
26
|
-
inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT,
|
|
27
|
-
panelType: panelAttributes.panelType
|
|
28
|
-
},
|
|
29
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
return tr;
|
|
33
|
-
};
|
|
34
|
-
var insertPanelType = function insertPanelType(panelAttributes, state) {
|
|
35
|
-
return state.schema.nodes.panel.createChecked(panelAttributes, state.schema.nodes.paragraph.createChecked());
|
|
36
|
-
};
|
|
18
|
+
var _blockType = require("../block-type/commands/block-type");
|
|
19
|
+
// Theres an existing interelationship between these files, where the imported function is being called for panel
|
|
20
|
+
// Insertions via the drop down menu
|
|
21
|
+
// tslint-ignore-next-line
|
|
37
22
|
var panelPlugin = function panelPlugin() {
|
|
38
23
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
39
24
|
var api = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -74,9 +59,12 @@ var panelPlugin = function panelPlugin() {
|
|
|
74
59
|
return /*#__PURE__*/_react.default.createElement(_assets.IconPanel, null);
|
|
75
60
|
},
|
|
76
61
|
action: function action(insert, state) {
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
|
|
62
|
+
return createPanelAction({
|
|
63
|
+
state: state,
|
|
64
|
+
attributes: {
|
|
65
|
+
panelType: _adfSchema.PanelType.INFO
|
|
66
|
+
}
|
|
67
|
+
});
|
|
80
68
|
}
|
|
81
69
|
}, {
|
|
82
70
|
id: 'notepanel',
|
|
@@ -87,9 +75,12 @@ var panelPlugin = function panelPlugin() {
|
|
|
87
75
|
return /*#__PURE__*/_react.default.createElement(_assets.IconPanelNote, null);
|
|
88
76
|
},
|
|
89
77
|
action: function action(insert, state) {
|
|
90
|
-
return
|
|
91
|
-
|
|
92
|
-
|
|
78
|
+
return createPanelAction({
|
|
79
|
+
state: state,
|
|
80
|
+
attributes: {
|
|
81
|
+
panelType: _adfSchema.PanelType.NOTE
|
|
82
|
+
}
|
|
83
|
+
});
|
|
93
84
|
}
|
|
94
85
|
}, {
|
|
95
86
|
id: 'successpanel',
|
|
@@ -101,9 +92,12 @@ var panelPlugin = function panelPlugin() {
|
|
|
101
92
|
return /*#__PURE__*/_react.default.createElement(_assets.IconPanelSuccess, null);
|
|
102
93
|
},
|
|
103
94
|
action: function action(insert, state) {
|
|
104
|
-
return
|
|
105
|
-
|
|
106
|
-
|
|
95
|
+
return createPanelAction({
|
|
96
|
+
state: state,
|
|
97
|
+
attributes: {
|
|
98
|
+
panelType: _adfSchema.PanelType.SUCCESS
|
|
99
|
+
}
|
|
100
|
+
});
|
|
107
101
|
}
|
|
108
102
|
}, {
|
|
109
103
|
id: 'warningpanel',
|
|
@@ -114,9 +108,12 @@ var panelPlugin = function panelPlugin() {
|
|
|
114
108
|
return /*#__PURE__*/_react.default.createElement(_assets.IconPanelWarning, null);
|
|
115
109
|
},
|
|
116
110
|
action: function action(insert, state) {
|
|
117
|
-
return
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
return createPanelAction({
|
|
112
|
+
state: state,
|
|
113
|
+
attributes: {
|
|
114
|
+
panelType: _adfSchema.PanelType.WARNING
|
|
115
|
+
}
|
|
116
|
+
});
|
|
120
117
|
}
|
|
121
118
|
}, {
|
|
122
119
|
id: 'errorpanel',
|
|
@@ -127,9 +124,12 @@ var panelPlugin = function panelPlugin() {
|
|
|
127
124
|
return /*#__PURE__*/_react.default.createElement(_assets.IconPanelError, null);
|
|
128
125
|
},
|
|
129
126
|
action: function action(insert, state) {
|
|
130
|
-
return
|
|
131
|
-
|
|
132
|
-
|
|
127
|
+
return createPanelAction({
|
|
128
|
+
state: state,
|
|
129
|
+
attributes: {
|
|
130
|
+
panelType: _adfSchema.PanelType.ERROR
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
133
|
}
|
|
134
134
|
}];
|
|
135
135
|
if (options.allowCustomPanel && options.allowCustomPanelEdit) {
|
|
@@ -142,15 +142,18 @@ var panelPlugin = function panelPlugin() {
|
|
|
142
142
|
return /*#__PURE__*/_react.default.createElement(_customPanel.default, null);
|
|
143
143
|
},
|
|
144
144
|
action: function action(insert, state) {
|
|
145
|
-
return
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
145
|
+
return createPanelAction({
|
|
146
|
+
state: state,
|
|
147
|
+
attributes: {
|
|
148
|
+
panelType: _adfSchema.PanelType.CUSTOM,
|
|
149
|
+
panelIcon: ':rainbow:',
|
|
150
|
+
panelIconId: '1f308',
|
|
151
|
+
panelIconText: '🌈',
|
|
152
|
+
// TODO: https://product-fabric.atlassian.net/browse/DSP-7268
|
|
153
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
154
|
+
panelColor: _colors.T50
|
|
155
|
+
}
|
|
156
|
+
});
|
|
154
157
|
}
|
|
155
158
|
});
|
|
156
159
|
}
|
|
@@ -162,5 +165,40 @@ var panelPlugin = function panelPlugin() {
|
|
|
162
165
|
}
|
|
163
166
|
};
|
|
164
167
|
};
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Creates panel action and wrap selection transaction with analytics for the panel insertion.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* const tr = createPanelAction({
|
|
174
|
+
* state: editorState,
|
|
175
|
+
* attributes: { panelType: 'info' },
|
|
176
|
+
* });
|
|
177
|
+
* if (tr) {
|
|
178
|
+
* applyTransaction(tr);
|
|
179
|
+
* }
|
|
180
|
+
*/
|
|
181
|
+
function createPanelAction(_ref3) {
|
|
182
|
+
var state = _ref3.state,
|
|
183
|
+
attributes = _ref3.attributes;
|
|
184
|
+
var tr = (0, _blockType.createWrapSelectionTransaction)({
|
|
185
|
+
state: state,
|
|
186
|
+
type: state.schema.nodes.panel,
|
|
187
|
+
nodeAttributes: attributes
|
|
188
|
+
});
|
|
189
|
+
if (tr) {
|
|
190
|
+
(0, _analytics.addAnalytics)(state, tr, {
|
|
191
|
+
action: _analytics.ACTION.INSERTED,
|
|
192
|
+
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
193
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.PANEL,
|
|
194
|
+
attributes: {
|
|
195
|
+
inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT,
|
|
196
|
+
panelType: attributes.panelType
|
|
197
|
+
},
|
|
198
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
return tr;
|
|
202
|
+
}
|
|
165
203
|
var _default = panelPlugin;
|
|
166
204
|
exports.default = _default;
|
|
@@ -40,6 +40,8 @@ var insertItem = function insertItem(item) {
|
|
|
40
40
|
return (0, _insert.insertSelectedItem)(maybeNode, opts)(state, state.tr, state.selection.head);
|
|
41
41
|
};
|
|
42
42
|
var tr = item.action(insert, state);
|
|
43
|
+
|
|
44
|
+
/** @note There is no transaction when called without a search currently (different insert) */
|
|
43
45
|
if (tr && dispatch) {
|
|
44
46
|
dispatch(tr);
|
|
45
47
|
}
|
|
@@ -47,6 +47,10 @@ var InsertMenu = function InsertMenu(_ref) {
|
|
|
47
47
|
name: item.value.name
|
|
48
48
|
}) || item.elemBefore;
|
|
49
49
|
},
|
|
50
|
+
/**
|
|
51
|
+
* @note This transformed items action is only used when a quick insert item has been
|
|
52
|
+
* called from the quick insert menu and a search has not been performed.
|
|
53
|
+
*/
|
|
50
54
|
action: function action() {
|
|
51
55
|
return onInsert({
|
|
52
56
|
item: item
|
|
@@ -69,6 +73,12 @@ var InsertMenu = function InsertMenu(_ref) {
|
|
|
69
73
|
var getItems = (0, _react.useCallback)(function (quickInsertState) {
|
|
70
74
|
return function (query, category) {
|
|
71
75
|
var result;
|
|
76
|
+
/**
|
|
77
|
+
* @warning The results if there is a query are not the same as the results if there is no query.
|
|
78
|
+
* For example: If you have a typed panel and then select the panel item then it will call a different action
|
|
79
|
+
* than is specified on the editor plugins quick insert
|
|
80
|
+
* @see above transform function for more details.
|
|
81
|
+
*/
|
|
72
82
|
if (query) {
|
|
73
83
|
result = (0, _search.searchQuickInsertItems)(quickInsertState, {})(query, category);
|
|
74
84
|
} else {
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = "@atlaskit/editor-core";
|
|
8
8
|
exports.name = name;
|
|
9
|
-
var version = "185.
|
|
9
|
+
var version = "185.13.0";
|
|
10
10
|
exports.version = version;
|
|
11
11
|
var nextMajorVersion = function nextMajorVersion() {
|
|
12
12
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
package/dist/cjs/version.json
CHANGED