@atlaskit/editor-core 185.12.0 → 185.12.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/plugins/block-type/commands/block-type.js +79 -44
- package/dist/cjs/plugins/card/ui/EditLinkToolbar.js +4 -3
- package/dist/cjs/plugins/card/ui/EditorSmartCardEventsNext.js +15 -36
- 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/hyperlink/Toolbar.js +1 -0
- 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/card/ui/EditLinkToolbar.js +4 -3
- package/dist/es2019/plugins/card/ui/EditorSmartCardEventsNext.js +21 -35
- 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/hyperlink/Toolbar.js +1 -0
- 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/card/ui/EditLinkToolbar.js +4 -3
- package/dist/esm/plugins/card/ui/EditorSmartCardEventsNext.js +15 -36
- 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/hyperlink/Toolbar.js +1 -0
- 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/plugins/card/types.d.ts +2 -3
- package/dist/types/plugins/card/ui/EditLinkToolbar.d.ts +2 -2
- package/dist/types-ts4.5/plugins/block-type/commands/block-type.d.ts +25 -0
- package/dist/types-ts4.5/plugins/card/types.d.ts +2 -3
- package/dist/types-ts4.5/plugins/card/ui/EditLinkToolbar.d.ts +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 185.12.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`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
|
|
8
|
+
|
|
9
|
+
## 185.12.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`a9bd271beba`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a9bd271beba) - Fixes link updated linking platform events being dispatched without an updateType
|
|
14
|
+
|
|
3
15
|
## 185.12.0
|
|
4
16
|
|
|
5
17
|
### Minor 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;
|
|
@@ -87,10 +87,10 @@ var EditLinkToolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
87
87
|
,
|
|
88
88
|
invokeMethod: _analytics.INPUT_METHOD.FLOATING_TB,
|
|
89
89
|
featureFlags: featureFlags,
|
|
90
|
-
onSubmit: function onSubmit(href, title, displayText,
|
|
90
|
+
onSubmit: function onSubmit(href, title, displayText, inputMethod, analytic) {
|
|
91
91
|
_this2.hideLinkToolbar();
|
|
92
92
|
if (_onSubmit) {
|
|
93
|
-
_onSubmit(href, displayText || title, analytic);
|
|
93
|
+
_onSubmit(href, displayText || title, inputMethod, analytic);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
});
|
|
@@ -142,7 +142,7 @@ var buildEditLinkToolbar = function buildEditLinkToolbar(_ref) {
|
|
|
142
142
|
node: node,
|
|
143
143
|
featureFlags: featureFlags,
|
|
144
144
|
forceFocusSelector: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.floatingToolbar.actions) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.forceFocusSelector,
|
|
145
|
-
onSubmit: function onSubmit(newHref, newText, analytic) {
|
|
145
|
+
onSubmit: function onSubmit(newHref, newText, inputMethod, analytic) {
|
|
146
146
|
var urlChanged = newHref !== displayInfo.url;
|
|
147
147
|
var titleChanged = newText !== displayInfo.title;
|
|
148
148
|
|
|
@@ -152,6 +152,7 @@ var buildEditLinkToolbar = function buildEditLinkToolbar(_ref) {
|
|
|
152
152
|
var _pluginInjectionApi$d2;
|
|
153
153
|
return (0, _card.commandWithMetadata)((0, _doc.changeSelectedCardToLink)(newText, newHref, undefined, undefined, undefined, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d2 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions), {
|
|
154
154
|
action: _analytics.ACTION.UPDATED,
|
|
155
|
+
inputMethod: inputMethod,
|
|
155
156
|
sourceEvent: analytic
|
|
156
157
|
})(view.state, view.dispatch);
|
|
157
158
|
}
|
|
@@ -12,7 +12,6 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
|
|
|
12
12
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
13
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
14
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
16
15
|
var _react = _interopRequireWildcard(require("react"));
|
|
17
16
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
18
17
|
var _linkAnalytics = require("@atlaskit/link-analytics");
|
|
@@ -21,9 +20,6 @@ var _analyticsNext = require("@atlaskit/analytics-next");
|
|
|
21
20
|
var _actions = require("../pm-plugins/actions");
|
|
22
21
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
23
22
|
var _state = require("../pm-plugins/util/state");
|
|
24
|
-
var _excluded = ["url", "display", "nodeContext"],
|
|
25
|
-
_excluded2 = ["url", "display", "previousDisplay", "nodeContext"],
|
|
26
|
-
_excluded3 = ["url", "display", "nodeContext"];
|
|
27
23
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
28
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
25
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
@@ -47,14 +43,7 @@ var withHistoryMethod = function withHistoryMethod(fn) {
|
|
|
47
43
|
};
|
|
48
44
|
};
|
|
49
45
|
var getMethod = withHistoryMethod(function (_ref) {
|
|
50
|
-
var inputMethod = _ref.inputMethod
|
|
51
|
-
sourceEvent = _ref.sourceEvent;
|
|
52
|
-
/**
|
|
53
|
-
* If sourceEvent is present, don't provide a custom method
|
|
54
|
-
*/
|
|
55
|
-
if (sourceEvent) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
46
|
+
var inputMethod = _ref.inputMethod;
|
|
58
47
|
switch (inputMethod) {
|
|
59
48
|
case _analytics.INPUT_METHOD.CLIPBOARD:
|
|
60
49
|
return 'editor_paste';
|
|
@@ -68,14 +57,7 @@ var getMethod = withHistoryMethod(function (_ref) {
|
|
|
68
57
|
}
|
|
69
58
|
});
|
|
70
59
|
var getUpdateType = withHistoryMethod(function (_ref2) {
|
|
71
|
-
var action = _ref2.action
|
|
72
|
-
sourceEvent = _ref2.sourceEvent;
|
|
73
|
-
/**
|
|
74
|
-
* If sourceEvent is present, don't provide a custom method
|
|
75
|
-
*/
|
|
76
|
-
if (sourceEvent) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
60
|
+
var action = _ref2.action;
|
|
79
61
|
switch (action) {
|
|
80
62
|
case _analytics.ACTION.CHANGED_TYPE:
|
|
81
63
|
return 'display_update';
|
|
@@ -124,11 +106,10 @@ var EventsBinding = function EventsBinding(_ref4) {
|
|
|
124
106
|
linkDeleted = _useSmartLinkLifecycl.linkDeleted;
|
|
125
107
|
var events = (0, _react.useMemo)(function () {
|
|
126
108
|
return {
|
|
127
|
-
created: function created(
|
|
128
|
-
var url =
|
|
129
|
-
display =
|
|
130
|
-
nodeContext =
|
|
131
|
-
metadata = (0, _objectWithoutProperties2.default)(_ref5, _excluded);
|
|
109
|
+
created: function created(metadata) {
|
|
110
|
+
var url = metadata.url,
|
|
111
|
+
display = metadata.display,
|
|
112
|
+
nodeContext = metadata.nodeContext;
|
|
132
113
|
var displayCategory = displayCategoryFromDisplay(display);
|
|
133
114
|
var sourceEvent = getSourceEventFromMetadata(metadata);
|
|
134
115
|
var creationMethod = getMethod(metadata);
|
|
@@ -141,12 +122,11 @@ var EventsBinding = function EventsBinding(_ref4) {
|
|
|
141
122
|
creationMethod: creationMethod
|
|
142
123
|
});
|
|
143
124
|
},
|
|
144
|
-
updated: function updated(
|
|
145
|
-
var url =
|
|
146
|
-
display =
|
|
147
|
-
previousDisplay =
|
|
148
|
-
nodeContext =
|
|
149
|
-
metadata = (0, _objectWithoutProperties2.default)(_ref6, _excluded2);
|
|
125
|
+
updated: function updated(metadata) {
|
|
126
|
+
var url = metadata.url,
|
|
127
|
+
display = metadata.display,
|
|
128
|
+
previousDisplay = metadata.previousDisplay,
|
|
129
|
+
nodeContext = metadata.nodeContext;
|
|
150
130
|
var displayCategory = displayCategoryFromDisplay(display);
|
|
151
131
|
var sourceEvent = getSourceEventFromMetadata(metadata);
|
|
152
132
|
var updateMethod = getMethod(metadata);
|
|
@@ -162,11 +142,10 @@ var EventsBinding = function EventsBinding(_ref4) {
|
|
|
162
142
|
updateType: updateType
|
|
163
143
|
});
|
|
164
144
|
},
|
|
165
|
-
deleted: function deleted(
|
|
166
|
-
var url =
|
|
167
|
-
display =
|
|
168
|
-
nodeContext =
|
|
169
|
-
metadata = (0, _objectWithoutProperties2.default)(_ref7, _excluded3);
|
|
145
|
+
deleted: function deleted(metadata) {
|
|
146
|
+
var url = metadata.url,
|
|
147
|
+
display = metadata.display,
|
|
148
|
+
nodeContext = metadata.nodeContext;
|
|
170
149
|
var displayCategory = displayCategoryFromDisplay(display);
|
|
171
150
|
var sourceEvent = getSourceEventFromMetadata(metadata);
|
|
172
151
|
var deleteMethod = getMethod(metadata);
|
|
@@ -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,
|
|
@@ -221,6 +221,7 @@ var getToolbarConfig = function getToolbarConfig(options, featureFlags, pluginIn
|
|
|
221
221
|
var action = isEdit ? _analytics.ACTION.UPDATED : _analytics.ACTION.INSERTED;
|
|
222
222
|
var command = isEdit ? (0, _card.commandWithMetadata)((0, _commands.updateLink)(href, displayText || title, activeLinkMark.pos), {
|
|
223
223
|
action: action,
|
|
224
|
+
inputMethod: inputMethod,
|
|
224
225
|
sourceEvent: analytic
|
|
225
226
|
}) : (0, _commands.insertLinkWithAnalytics)(inputMethod, activeLinkMark.from, activeLinkMark.to, href, title, displayText, !!(options !== null && options !== void 0 && (_options$cardOptions = options.cardOptions) !== null && _options$cardOptions !== void 0 && _options$cardOptions.provider), analytic);
|
|
226
227
|
command(view.state, view.dispatch, view);
|
|
@@ -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.12.
|
|
9
|
+
var version = "185.12.2";
|
|
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