@atlaskit/editor-core 187.34.1 → 187.35.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.
Files changed (94) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/index.js +10 -42
  3. package/dist/cjs/plugins/block-type/commands/block-type.js +19 -211
  4. package/dist/cjs/plugins/block-type/commands/index.js +2 -28
  5. package/dist/cjs/plugins/block-type/index.js +21 -4
  6. package/dist/cjs/plugins/block-type/pm-plugins/input-rule.js +9 -64
  7. package/dist/cjs/plugins/block-type/pm-plugins/keymap.js +1 -1
  8. package/dist/cjs/plugins/code-block/actions.js +83 -6
  9. package/dist/cjs/plugins/code-block/index.js +27 -12
  10. package/dist/cjs/plugins/code-block/pm-plugins/input-rule.js +68 -0
  11. package/dist/cjs/plugins/copy-button/commands.js +2 -1
  12. package/dist/cjs/plugins/date/ui/DatePicker/index.js +3 -2
  13. package/dist/cjs/plugins/expand/commands.js +3 -3
  14. package/dist/cjs/plugins/expand/index.js +2 -2
  15. package/dist/cjs/plugins/index.js +1 -7
  16. package/dist/cjs/plugins/insert-block/index.js +34 -29
  17. package/dist/cjs/plugins/panel/actions.js +26 -2
  18. package/dist/cjs/plugins/panel/index.js +9 -5
  19. package/dist/cjs/version-wrapper.js +1 -1
  20. package/dist/es2019/index.js +16 -2
  21. package/dist/es2019/plugins/block-type/commands/block-type.js +15 -217
  22. package/dist/es2019/plugins/block-type/commands/index.js +1 -3
  23. package/dist/es2019/plugins/block-type/index.js +21 -4
  24. package/dist/es2019/plugins/block-type/pm-plugins/input-rule.js +3 -56
  25. package/dist/es2019/plugins/block-type/pm-plugins/keymap.js +2 -2
  26. package/dist/es2019/plugins/code-block/actions.js +84 -3
  27. package/dist/es2019/plugins/code-block/index.js +22 -7
  28. package/dist/es2019/plugins/code-block/pm-plugins/input-rule.js +60 -0
  29. package/dist/es2019/plugins/copy-button/commands.js +2 -1
  30. package/dist/es2019/plugins/date/ui/DatePicker/index.js +3 -2
  31. package/dist/es2019/plugins/expand/commands.js +1 -1
  32. package/dist/es2019/plugins/expand/index.js +1 -1
  33. package/dist/es2019/plugins/index.js +0 -1
  34. package/dist/es2019/plugins/insert-block/index.js +47 -42
  35. package/dist/es2019/plugins/panel/actions.js +26 -2
  36. package/dist/es2019/plugins/panel/index.js +8 -4
  37. package/dist/es2019/version-wrapper.js +1 -1
  38. package/dist/esm/index.js +16 -2
  39. package/dist/esm/plugins/block-type/commands/block-type.js +17 -205
  40. package/dist/esm/plugins/block-type/commands/index.js +1 -3
  41. package/dist/esm/plugins/block-type/index.js +21 -4
  42. package/dist/esm/plugins/block-type/pm-plugins/input-rule.js +3 -58
  43. package/dist/esm/plugins/block-type/pm-plugins/keymap.js +2 -2
  44. package/dist/esm/plugins/code-block/actions.js +76 -3
  45. package/dist/esm/plugins/code-block/index.js +25 -11
  46. package/dist/esm/plugins/code-block/pm-plugins/input-rule.js +62 -0
  47. package/dist/esm/plugins/copy-button/commands.js +2 -1
  48. package/dist/esm/plugins/date/ui/DatePicker/index.js +3 -2
  49. package/dist/esm/plugins/expand/commands.js +1 -1
  50. package/dist/esm/plugins/expand/index.js +1 -1
  51. package/dist/esm/plugins/index.js +0 -1
  52. package/dist/esm/plugins/insert-block/index.js +27 -22
  53. package/dist/esm/plugins/panel/actions.js +24 -2
  54. package/dist/esm/plugins/panel/index.js +8 -4
  55. package/dist/esm/version-wrapper.js +1 -1
  56. package/dist/types/index.d.ts +16 -3
  57. package/dist/types/labs/next/presets/default.d.ts +6 -0
  58. package/dist/types/plugins/block-type/commands/block-type.d.ts +1 -25
  59. package/dist/types/plugins/block-type/commands/index.d.ts +1 -3
  60. package/dist/types/plugins/block-type/index.d.ts +10 -2
  61. package/dist/types/plugins/code-block/actions.d.ts +11 -0
  62. package/dist/types/plugins/code-block/index.d.ts +6 -1
  63. package/dist/types/plugins/code-block/pm-plugins/input-rule.d.ts +3 -0
  64. package/dist/types/plugins/date/ui/DatePicker/index.d.ts +2 -2
  65. package/dist/types/plugins/index.d.ts +0 -2
  66. package/dist/types/plugins/insert-block/types.d.ts +7 -1
  67. package/dist/types/plugins/panel/actions.d.ts +4 -1
  68. package/dist/types/plugins/panel/index.d.ts +11 -2
  69. package/dist/types-ts4.5/index.d.ts +16 -3
  70. package/dist/types-ts4.5/labs/next/presets/default.d.ts +6 -0
  71. package/dist/types-ts4.5/plugins/block-type/commands/block-type.d.ts +1 -25
  72. package/dist/types-ts4.5/plugins/block-type/commands/index.d.ts +1 -3
  73. package/dist/types-ts4.5/plugins/block-type/index.d.ts +10 -2
  74. package/dist/types-ts4.5/plugins/code-block/actions.d.ts +11 -0
  75. package/dist/types-ts4.5/plugins/code-block/index.d.ts +6 -1
  76. package/dist/types-ts4.5/plugins/code-block/pm-plugins/input-rule.d.ts +3 -0
  77. package/dist/types-ts4.5/plugins/date/ui/DatePicker/index.d.ts +2 -2
  78. package/dist/types-ts4.5/plugins/index.d.ts +0 -2
  79. package/dist/types-ts4.5/plugins/insert-block/types.d.ts +7 -1
  80. package/dist/types-ts4.5/plugins/panel/actions.d.ts +4 -1
  81. package/dist/types-ts4.5/plugins/panel/index.d.ts +9 -2
  82. package/package.json +5 -5
  83. package/report.api.md +62 -23
  84. package/tmp/api-report-tmp.d.ts +49 -15
  85. package/dist/cjs/plugins/block-type/commands/insert-block.js +0 -60
  86. package/dist/es2019/plugins/block-type/commands/insert-block.js +0 -55
  87. package/dist/esm/plugins/block-type/commands/insert-block.js +0 -53
  88. package/dist/types/plugins/block-type/commands/insert-block.d.ts +0 -5
  89. package/dist/types-ts4.5/plugins/block-type/commands/insert-block.d.ts +0 -5
  90. /package/dist/cjs/plugins/{block-type/commands → code-block}/transform-to-code-block.js +0 -0
  91. /package/dist/es2019/plugins/{block-type/commands → code-block}/transform-to-code-block.js +0 -0
  92. /package/dist/esm/plugins/{block-type/commands → code-block}/transform-to-code-block.js +0 -0
  93. /package/dist/types/plugins/{block-type/commands → code-block}/transform-to-code-block.d.ts +0 -0
  94. /package/dist/types-ts4.5/plugins/{block-type/commands → code-block}/transform-to-code-block.d.ts +0 -0
@@ -3,7 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.resetShouldIgnoreFollowingMutations = exports.resetCopiedState = exports.removeCodeBlock = exports.ignoreFollowingMutations = exports.copyContentToClipboard = exports.changeLanguage = void 0;
6
+ exports.copyContentToClipboard = exports.changeLanguage = void 0;
7
+ exports.createInsertCodeBlockTransaction = createInsertCodeBlockTransaction;
8
+ exports.ignoreFollowingMutations = void 0;
9
+ exports.insertCodeBlockWithAnalytics = insertCodeBlockWithAnalytics;
10
+ exports.resetShouldIgnoreFollowingMutations = exports.resetCopiedState = exports.removeCodeBlock = void 0;
7
11
  var _utils = require("@atlaskit/editor-prosemirror/utils");
8
12
  var _state = require("@atlaskit/editor-prosemirror/state");
9
13
  var _pluginKey = require("./plugin-key");
@@ -11,7 +15,10 @@ var _codeBlockCopySelectionPlugin = require("./pm-plugins/codeBlockCopySelection
11
15
  var _actions = require("./pm-plugins/actions");
12
16
  var _clipboard = require("../../utils/clipboard");
13
17
  var _utils2 = require("../analytics/utils");
14
- var _types = require("../analytics/types");
18
+ var _insert = require("@atlaskit/editor-common/insert");
19
+ var _transformToCodeBlock = require("./transform-to-code-block");
20
+ var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
21
+ var _analytics = require("@atlaskit/editor-common/analytics");
15
22
  var removeCodeBlock = function removeCodeBlock(state, dispatch) {
16
23
  var nodes = state.schema.nodes,
17
24
  tr = state.tr;
@@ -42,12 +49,12 @@ var changeLanguage = function changeLanguage(language) {
42
49
  var result = tr.setSelection(selection);
43
50
  if (dispatch) {
44
51
  dispatch((0, _utils2.addAnalytics)(state, result, {
45
- action: _types.ACTION.LANGUAGE_SELECTED,
46
- actionSubject: _types.ACTION_SUBJECT.CODE_BLOCK,
52
+ action: _analytics.ACTION.LANGUAGE_SELECTED,
53
+ actionSubject: _analytics.ACTION_SUBJECT.CODE_BLOCK,
47
54
  attributes: {
48
55
  language: language
49
56
  },
50
- eventType: _types.EVENT_TYPE.TRACK
57
+ eventType: _analytics.EVENT_TYPE.TRACK
51
58
  }));
52
59
  }
53
60
  return true;
@@ -125,4 +132,74 @@ var resetShouldIgnoreFollowingMutations = function resetShouldIgnoreFollowingMut
125
132
  }
126
133
  return true;
127
134
  };
128
- exports.resetShouldIgnoreFollowingMutations = resetShouldIgnoreFollowingMutations;
135
+
136
+ /**
137
+ * This function creates a new transaction that inserts a code block,
138
+ * if there is text selected it will wrap the current selection if not it will
139
+ * append the codeblock to the end of the document.
140
+ */
141
+ exports.resetShouldIgnoreFollowingMutations = resetShouldIgnoreFollowingMutations;
142
+ function createInsertCodeBlockTransaction(_ref) {
143
+ var _state$selection$$fro;
144
+ var state = _ref.state;
145
+ var tr = state.tr;
146
+ var from = state.selection.from;
147
+ var codeBlock = state.schema.nodes.codeBlock;
148
+ var grandParentNodeType = (_state$selection$$fro = state.selection.$from.node(-1)) === null || _state$selection$$fro === void 0 ? void 0 : _state$selection$$fro.type;
149
+ var parentNodeType = state.selection.$from.parent.type;
150
+
151
+ /** We always want to append a codeBlock unless we're inserting into a paragraph
152
+ * AND it's a valid child of the grandparent node.
153
+ * Insert the current selection as codeBlock content unless it contains nodes other
154
+ * than paragraphs and inline.
155
+ */
156
+ var canInsertCodeBlock = (0, _insert.shouldSplitSelectedNodeOnNodeInsertion)({
157
+ parentNodeType: parentNodeType,
158
+ grandParentNodeType: grandParentNodeType,
159
+ content: codeBlock.createAndFill()
160
+ }) && contentAllowedInCodeBlock(state);
161
+ if (canInsertCodeBlock) {
162
+ tr = (0, _transformToCodeBlock.transformToCodeBlockAction)(state, from);
163
+ } else {
164
+ (0, _utils.safeInsert)(codeBlock.createAndFill())(tr).scrollIntoView();
165
+ }
166
+ return tr;
167
+ }
168
+
169
+ /**
170
+ * Check if the current selection contains any nodes that are not permitted
171
+ * as codeBlock child nodes. Note that this allows paragraphs and inline nodes
172
+ * as we extract their text content.
173
+ */
174
+ function contentAllowedInCodeBlock(state) {
175
+ var _state$selection = state.selection,
176
+ $from = _state$selection.$from,
177
+ $to = _state$selection.$to;
178
+ var isAllowedChild = true;
179
+ state.doc.nodesBetween($from.pos, $to.pos, function (node) {
180
+ if (!isAllowedChild) {
181
+ return false;
182
+ }
183
+ return isAllowedChild = node.type === state.schema.nodes.listItem || node.type === state.schema.nodes.bulletList || node.type === state.schema.nodes.orderedList || node.type === state.schema.nodes.paragraph || node.isInline || node.isText;
184
+ });
185
+ return isAllowedChild;
186
+ }
187
+ function insertCodeBlockWithAnalytics(inputMethod, analyticsAPI) {
188
+ return (0, _editorAnalytics.withAnalytics)(analyticsAPI, {
189
+ action: _analytics.ACTION.INSERTED,
190
+ actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
191
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.CODE_BLOCK,
192
+ attributes: {
193
+ inputMethod: inputMethod
194
+ },
195
+ eventType: _analytics.EVENT_TYPE.TRACK
196
+ })(function (state, dispatch) {
197
+ var tr = createInsertCodeBlockTransaction({
198
+ state: state
199
+ });
200
+ if (dispatch) {
201
+ dispatch(tr);
202
+ }
203
+ return true;
204
+ });
205
+ }
@@ -17,11 +17,10 @@ var _analytics = require("@atlaskit/editor-common/analytics");
17
17
  var _quickInsert = require("@atlaskit/editor-common/quick-insert");
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
+ var _actions = require("./actions");
21
+ var _inputRule = require("./pm-plugins/input-rule");
21
22
  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; } // 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
23
+ 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; }
25
24
  var codeBlockPlugin = function codeBlockPlugin(_ref) {
26
25
  var options = _ref.config,
27
26
  api = _ref.api;
@@ -44,6 +43,13 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
44
43
  appearance: (_options$appearance = options === null || options === void 0 ? void 0 : options.appearance) !== null && _options$appearance !== void 0 ? _options$appearance : 'comment'
45
44
  }));
46
45
  }
46
+ }, {
47
+ name: 'codeBlockInputRule',
48
+ plugin: function plugin(_ref3) {
49
+ var _api$analytics;
50
+ var schema = _ref3.schema;
51
+ return (0, _inputRule.createCodeBlockInputRule)(schema, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
52
+ }
47
53
  }, {
48
54
  name: 'codeBlockIDEKeyBindings',
49
55
  plugin: function plugin() {
@@ -51,8 +57,8 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
51
57
  }
52
58
  }, {
53
59
  name: 'codeBlockKeyMap',
54
- plugin: function plugin(_ref3) {
55
- var schema = _ref3.schema;
60
+ plugin: function plugin(_ref4) {
61
+ var schema = _ref4.schema;
56
62
  return (0, _keymaps.default)(schema);
57
63
  }
58
64
  }, {
@@ -67,9 +73,18 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
67
73
  onEditorViewStateUpdated: function onEditorViewStateUpdated(props) {
68
74
  (0, _refreshBrowserSelection.default)(props.originalTransaction, props.newEditorState);
69
75
  },
76
+ actions: {
77
+ /*
78
+ * Function will insert code block at current selection if block is empty or below current selection and set focus on it.
79
+ */
80
+ insertCodeBlock: function insertCodeBlock(inputMethod) {
81
+ var _api$analytics2;
82
+ return (0, _actions.insertCodeBlockWithAnalytics)(inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions);
83
+ }
84
+ },
70
85
  pluginsOptions: {
71
- quickInsert: function quickInsert(_ref4) {
72
- var formatMessage = _ref4.formatMessage;
86
+ quickInsert: function quickInsert(_ref5) {
87
+ var formatMessage = _ref5.formatMessage;
73
88
  return [{
74
89
  id: 'codeblock',
75
90
  title: formatMessage(_messages.messages.codeblock),
@@ -80,12 +95,12 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
80
95
  icon: function icon() {
81
96
  return /*#__PURE__*/_react.default.createElement(_quickInsert.IconCode, null);
82
97
  },
83
- action: function action(insert, state) {
84
- var _api$analytics;
85
- var tr = (0, _blockType.createInsertCodeBlockTransaction)({
98
+ action: function action(_insert, state) {
99
+ var _api$analytics3;
100
+ var tr = (0, _actions.createInsertCodeBlockTransaction)({
86
101
  state: state
87
102
  });
88
- api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent({
103
+ api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.attachAnalyticsEvent({
89
104
  action: _analytics.ACTION.INSERTED,
90
105
  actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
91
106
  actionSubjectId: _analytics.ACTION_SUBJECT_ID.CODE_BLOCK,
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createCodeBlockInputRule = createCodeBlockInputRule;
7
+ var _utils = require("@atlaskit/editor-prosemirror/utils");
8
+ var _prosemirrorInputRules = require("@atlaskit/prosemirror-input-rules");
9
+ var _analytics = require("@atlaskit/editor-common/analytics");
10
+ var _utils2 = require("@atlaskit/editor-common/utils");
11
+ var _transformToCodeBlock = require("../transform-to-code-block");
12
+ var _commands = require("@atlaskit/editor-common/commands");
13
+ function createCodeBlockInputRule(schema, editorAnalyticsAPI) {
14
+ var rules = getCodeBlockRules(editorAnalyticsAPI, schema);
15
+ return (0, _prosemirrorInputRules.createPlugin)('code-block-input-rule', rules, {
16
+ isBlockNodeRule: true
17
+ });
18
+ }
19
+
20
+ /**
21
+ * Get all code block input rules
22
+ *
23
+ * @param {Schema} schema
24
+ * @returns {InputRuleWithHandler[]}
25
+ */
26
+ function getCodeBlockRules(editorAnalyticsAPI, schema) {
27
+ var ruleAnalytics = (0, _utils2.inputRuleWithAnalytics)({
28
+ action: _analytics.ACTION.INSERTED,
29
+ actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
30
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.CODE_BLOCK,
31
+ attributes: {
32
+ inputMethod: _analytics.INPUT_METHOD.FORMATTING
33
+ },
34
+ eventType: _analytics.EVENT_TYPE.TRACK
35
+ }, editorAnalyticsAPI);
36
+ var validMatchLength = function validMatchLength(match) {
37
+ return match.length > 0 && match[0].length === 3;
38
+ };
39
+ var threeTildeRule = (0, _prosemirrorInputRules.createRule)(/(?!\s)(`{3,})$/, function (state, match, start, end) {
40
+ if (!validMatchLength(match)) {
41
+ return null;
42
+ }
43
+ var attributes = {};
44
+ if (match[4]) {
45
+ attributes.language = match[4];
46
+ }
47
+ if ((0, _transformToCodeBlock.isConvertableToCodeBlock)(state)) {
48
+ return (0, _transformToCodeBlock.transformToCodeBlockAction)(state, start, attributes);
49
+ }
50
+ var tr = state.tr;
51
+ tr.delete(start, end);
52
+ var codeBlock = tr.doc.type.schema.nodes.codeBlock.createChecked();
53
+ (0, _utils.safeInsert)(codeBlock)(tr);
54
+ return tr;
55
+ });
56
+ var leftNodeReplacementThreeTildeRule = (0, _prosemirrorInputRules.createRule)(new RegExp("((".concat(_prosemirrorInputRules.leafNodeReplacementCharacter, "`{3,})|^\\s(`{3,}))(\\S*)$")), function (state, match, start, end) {
57
+ if (!validMatchLength(match)) {
58
+ return null;
59
+ }
60
+ var attributes = {};
61
+ if (match[4]) {
62
+ attributes.language = match[4];
63
+ }
64
+ var inlineStart = Math.max(match.index + state.selection.$from.start(), 1);
65
+ return (0, _commands.insertBlock)(state, schema.nodes.codeBlock, inlineStart, end, attributes);
66
+ });
67
+ return [ruleAnalytics(threeTildeRule), ruleAnalytics(leftNodeReplacementThreeTildeRule)];
68
+ }
@@ -132,7 +132,8 @@ var createToolbarCopyCommandForNode = function createToolbarCopyCommandForNode(n
132
132
  div.firstChild.setAttribute('data-pm-slice', '0 0 []');
133
133
  }
134
134
  // ED-17083 safari seems have bugs for extension copy because exntension do not have a child text(innerText) and it will not recognized as html in clipboard, this could be merge into one if this extension fixed children issue or safari fix the copy bug
135
- if (_utils2.browser.safari && state.selection instanceof _state.NodeSelection && state.selection.node.type === state.schema.nodes.extension) {
135
+ // MEX-2528 safari has a bug related to the mediaSingle node with border or link. The image tag within the clipboard is not recognized as HTML when using the ClipboardItem API. To address this, we have to switch to ClipboardPolyfill
136
+ if (_utils2.browser.safari && state.selection instanceof _state.NodeSelection && (state.selection.node.type === state.schema.nodes.extension || state.selection.node.type === state.schema.nodes.mediaSingle)) {
136
137
  (0, _clipboard.copyHTMLToClipboardPolyfill)(div);
137
138
  } else {
138
139
  (0, _clipboard.copyHTMLToClipboard)(div);
@@ -31,7 +31,7 @@ var _templateObject;
31
31
  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); }; }
32
32
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
33
33
  var PopupWithListeners = (0, _withOuterListeners.default)(_ui.Popup);
34
- var popupContentWrapper = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n padding: 2px;\n border-radius: ", "px;\n box-shadow: ", ";\n background-color: ", ";\n"])), (0, _constants.borderRadius)(), "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(_colors.N60A, ", 0 0 1px ").concat(_colors.N60A), ")"), "var(--ds-surface-overlay, ".concat(_colors.N0, ")"));
34
+ var popupContentWrapper = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n padding: ", ";\n border-radius: ", "px;\n box-shadow: ", ";\n background-color: ", ";\n"])), "var(--ds-space-025, 2px)", (0, _constants.borderRadius)(), "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(_colors.N60A, ", 0 0 1px ").concat(_colors.N60A), ")"), "var(--ds-surface-overlay, ".concat(_colors.N0, ")"));
35
35
  var DatePicker = /*#__PURE__*/function (_React$Component) {
36
36
  (0, _inherits2.default)(DatePicker, _React$Component);
37
37
  var _super = _createSuper(DatePicker);
@@ -158,7 +158,8 @@ var DatePicker = /*#__PURE__*/function (_React$Component) {
158
158
  year: year,
159
159
  selected: selected,
160
160
  ref: this.handleRef,
161
- weekStartDay: weekStartDay
161
+ weekStartDay: weekStartDay,
162
+ testId: 'datepicker'
162
163
  })));
163
164
  }
164
165
  }]);
@@ -12,8 +12,8 @@ var _analytics = require("../analytics");
12
12
  var _gapCursorSelection = require("../selection/gap-cursor-selection");
13
13
  var _utils2 = require("./utils");
14
14
  var _pluginFactory = require("./pm-plugins/plugin-factory");
15
- var _blockType = require("../block-type/commands/block-type");
16
- var _utils3 = require("@atlaskit/editor-prosemirror/utils");
15
+ var _utils3 = require("@atlaskit/editor-common/utils");
16
+ var _utils4 = require("@atlaskit/editor-prosemirror/utils");
17
17
  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; }
18
18
  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; }
19
19
  var setExpandRef = function setExpandRef(ref) {
@@ -124,7 +124,7 @@ var insertExpand = function insertExpand(state, dispatch) {
124
124
  if (!expandNode) {
125
125
  return false;
126
126
  }
127
- var tr = state.selection.empty ? (0, _utils3.safeInsert)(expandNode)(state.tr).scrollIntoView() : (0, _blockType.createWrapSelectionTransaction)({
127
+ var tr = state.selection.empty ? (0, _utils4.safeInsert)(expandNode)(state.tr).scrollIntoView() : (0, _utils3.createWrapSelectionTransaction)({
128
128
  state: state,
129
129
  type: expandNode.type
130
130
  });
@@ -22,7 +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
+ var _utils = require("@atlaskit/editor-common/utils");
26
26
  var _pluginFactory = require("./pm-plugins/plugin-factory");
27
27
  var expandPlugin = function expandPlugin(_ref) {
28
28
  var _api$featureFlags;
@@ -75,7 +75,7 @@ var expandPlugin = function expandPlugin(_ref) {
75
75
  if (!node) {
76
76
  return false;
77
77
  }
78
- var tr = state.selection.empty ? insert(node) : (0, _blockType.createWrapSelectionTransaction)({
78
+ var tr = state.selection.empty ? insert(node) : (0, _utils.createWrapSelectionTransaction)({
79
79
  state: state,
80
80
  type: node.type
81
81
  });
@@ -47,12 +47,6 @@ Object.defineProperty(exports, "betterTypeHistoryPlugin", {
47
47
  return _betterTypeHistory.default;
48
48
  }
49
49
  });
50
- Object.defineProperty(exports, "blockPluginStateKey", {
51
- enumerable: true,
52
- get: function get() {
53
- return _blockType.pluginKey;
54
- }
55
- });
56
50
  Object.defineProperty(exports, "blockTypePlugin", {
57
51
  enumerable: true,
58
52
  get: function get() {
@@ -354,7 +348,7 @@ Object.defineProperty(exports, "viewUpdateSubscriptionPlugin", {
354
348
  }
355
349
  });
356
350
  var _base = require("./base");
357
- var _blockType = _interopRequireWildcard(require("./block-type"));
351
+ var _blockType = _interopRequireDefault(require("./block-type"));
358
352
  var _betterTypeHistory = _interopRequireDefault(require("./better-type-history"));
359
353
  var _clearMarksOnChangeToEmptyDocument = _interopRequireDefault(require("./clear-marks-on-change-to-empty-document"));
360
354
  var _codeBlock = _interopRequireDefault(require("./code-block"));
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _providerFactory = require("@atlaskit/editor-common/provider-factory");
10
- var _main = require("../block-type/pm-plugins/main");
11
10
  var _pluginKey = require("../media/pm-plugins/plugin-key");
12
11
  var _utils = require("../type-ahead/utils");
13
12
  var _layout = require("../layout");
@@ -15,25 +14,45 @@ var _macro = require("../macro");
15
14
  var _WithPluginState = _interopRequireDefault(require("../../ui/WithPluginState"));
16
15
  var _ToolbarInsertBlock = _interopRequireDefault(require("./ui/ToolbarInsertBlock"));
17
16
  var _key = require("../type-ahead/pm-plugins/key");
18
- var _commands = require("../block-type/commands");
17
+ var _types = require("../block-type/types");
19
18
  var _analytics = require("../analytics");
20
19
  var _pluginKey2 = require("../placeholder-text/plugin-key");
21
20
  var _pluginKey3 = require("../macro/plugin-key");
22
- var _types = require("../../ui/Toolbar/types");
21
+ var _types2 = require("../../ui/Toolbar/types");
23
22
  var _hooks = require("@atlaskit/editor-common/hooks");
24
23
  var toolbarSizeToButtons = function toolbarSizeToButtons(toolbarSize) {
25
24
  switch (toolbarSize) {
26
- case _types.ToolbarSize.XXL:
27
- case _types.ToolbarSize.XL:
28
- case _types.ToolbarSize.L:
29
- case _types.ToolbarSize.M:
25
+ case _types2.ToolbarSize.XXL:
26
+ case _types2.ToolbarSize.XL:
27
+ case _types2.ToolbarSize.L:
28
+ case _types2.ToolbarSize.M:
30
29
  return 7;
31
- case _types.ToolbarSize.S:
30
+ case _types2.ToolbarSize.S:
32
31
  return 2;
33
32
  default:
34
33
  return 0;
35
34
  }
36
35
  };
36
+ /**
37
+ * Wrapper over insertBlockTypeWithAnalytics to autobind toolbar input method
38
+ * @param name Block name
39
+ */
40
+ function handleInsertBlockType(insertCodeBlock, insertPanel, insertBlockQuote) {
41
+ return function (name) {
42
+ if (name === _types.CODE_BLOCK.name && insertCodeBlock) {
43
+ return insertCodeBlock(_analytics.INPUT_METHOD.TOOLBAR);
44
+ }
45
+ if (name === _types.PANEL.name && insertPanel) {
46
+ return insertPanel(_analytics.INPUT_METHOD.TOOLBAR);
47
+ }
48
+ if (name === _types.BLOCK_QUOTE.name && insertBlockQuote) {
49
+ return insertBlockQuote(_analytics.INPUT_METHOD.TOOLBAR);
50
+ }
51
+ return function () {
52
+ return false;
53
+ };
54
+ };
55
+ }
37
56
  var insertBlockPlugin = function insertBlockPlugin(_ref) {
38
57
  var _api$featureFlags;
39
58
  var _ref$config = _ref.config,
@@ -60,16 +79,13 @@ var insertBlockPlugin = function insertBlockPlugin(_ref) {
60
79
  return /*#__PURE__*/_react.default.createElement(_WithPluginState.default, {
61
80
  plugins: {
62
81
  typeAheadState: _key.pluginKey,
63
- // needed to check isTypeAheadAllowed in ToolbarInsertBlock
64
- blockTypeState: _main.pluginKey,
65
82
  mediaState: _pluginKey.stateKey,
66
83
  macroState: _pluginKey3.pluginKey,
67
84
  placeholderTextState: _pluginKey2.pluginKey,
68
85
  layoutState: _layout.pluginKey
69
86
  },
70
87
  render: function render(_ref3) {
71
- var blockTypeState = _ref3.blockTypeState,
72
- mediaState = _ref3.mediaState,
88
+ var mediaState = _ref3.mediaState,
73
89
  _ref3$macroState = _ref3.macroState,
74
90
  macroState = _ref3$macroState === void 0 ? {} : _ref3$macroState,
75
91
  placeholderTextState = _ref3.placeholderTextState,
@@ -88,7 +104,6 @@ var insertBlockPlugin = function insertBlockPlugin(_ref) {
88
104
  isToolbarReducedSpacing: isToolbarReducedSpacing,
89
105
  isLastItem: isLastItem,
90
106
  featureFlags: featureFlags,
91
- blockTypeState: blockTypeState,
92
107
  mediaState: mediaState,
93
108
  macroState: macroState,
94
109
  placeholderTextState: placeholderTextState,
@@ -108,11 +123,10 @@ var insertBlockPlugin = function insertBlockPlugin(_ref) {
108
123
  };
109
124
  };
110
125
  function ToolbarInsertBlockWithInjectionApi(_ref4) {
111
- var _pluginInjectionApi$a2, _pluginInjectionApi$i;
126
+ var _pluginInjectionApi$i, _pluginInjectionApi$c, _pluginInjectionApi$p, _pluginInjectionApi$b;
112
127
  var editorView = _ref4.editorView,
113
128
  editorActions = _ref4.editorActions,
114
129
  dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent,
115
- providerFactory = _ref4.providerFactory,
116
130
  popupsMountPoint = _ref4.popupsMountPoint,
117
131
  popupsBoundariesElement = _ref4.popupsBoundariesElement,
118
132
  popupsScrollableElement = _ref4.popupsScrollableElement,
@@ -123,28 +137,19 @@ function ToolbarInsertBlockWithInjectionApi(_ref4) {
123
137
  providers = _ref4.providers,
124
138
  pluginInjectionApi = _ref4.pluginInjectionApi,
125
139
  options = _ref4.options,
126
- blockTypeState = _ref4.blockTypeState,
127
140
  mediaState = _ref4.mediaState,
128
141
  macroState = _ref4.macroState,
129
142
  placeholderTextState = _ref4.placeholderTextState,
130
143
  layoutState = _ref4.layoutState,
131
144
  featureFlags = _ref4.featureFlags;
132
145
  var buttons = toolbarSizeToButtons(toolbarSize);
133
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji']),
146
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji', 'blockType']),
134
147
  dateState = _useSharedPluginState.dateState,
135
148
  hyperlinkState = _useSharedPluginState.hyperlinkState,
136
149
  imageUploadState = _useSharedPluginState.imageUploadState,
137
150
  mentionState = _useSharedPluginState.mentionState,
138
- emojiState = _useSharedPluginState.emojiState;
139
-
140
- /**
141
- * Wrapper over insertBlockTypeWithAnalytics to autobind toolbar input method
142
- * @param name Block name
143
- */
144
- var handleInsertBlockType = _react.default.useCallback(function (name) {
145
- var _pluginInjectionApi$a;
146
- return (0, _commands.insertBlockTypesWithAnalytics)(name, _analytics.INPUT_METHOD.TOOLBAR, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions);
147
- }, [pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions]);
151
+ emojiState = _useSharedPluginState.emojiState,
152
+ blockTypeState = _useSharedPluginState.blockTypeState;
148
153
  return /*#__PURE__*/_react.default.createElement(_ToolbarInsertBlock.default, {
149
154
  pluginInjectionApi: pluginInjectionApi,
150
155
  buttons: buttons,
@@ -174,7 +179,7 @@ function ToolbarInsertBlockWithInjectionApi(_ref4) {
174
179
  emojiProvider: providers.emojiProvider,
175
180
  nativeStatusSupported: options.nativeStatusSupported,
176
181
  horizontalRuleEnabled: options.horizontalRuleEnabled,
177
- onInsertBlockType: handleInsertBlockType,
182
+ onInsertBlockType: handleInsertBlockType(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.codeBlock) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions.insertCodeBlock, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$p = pluginInjectionApi.panel) === null || _pluginInjectionApi$p === void 0 ? void 0 : _pluginInjectionApi$p.actions.insertPanel, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$b = pluginInjectionApi.blockType) === null || _pluginInjectionApi$b === void 0 ? void 0 : _pluginInjectionApi$b.actions.insertBlockQuote),
178
183
  onInsertMacroFromMacroBrowser: _macro.insertMacroFromMacroBrowser,
179
184
  macroProvider: macroState.macroProvider,
180
185
  popupsMountPoint: popupsMountPoint,
@@ -185,7 +190,7 @@ function ToolbarInsertBlockWithInjectionApi(_ref4) {
185
190
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
186
191
  replacePlusMenuWithElementBrowser: options.replacePlusMenuWithElementBrowser,
187
192
  showElementBrowserLink: options.showElementBrowserLink,
188
- showSeparator: !isLastItem && toolbarSize <= _types.ToolbarSize.S,
193
+ showSeparator: !isLastItem && toolbarSize <= _types2.ToolbarSize.S,
189
194
  featureFlags: featureFlags
190
195
  });
191
196
  }
@@ -4,13 +4,18 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.removePanel = exports.changePanelType = void 0;
7
+ exports.changePanelType = void 0;
8
+ exports.insertPanelWithAnalytics = insertPanelWithAnalytics;
9
+ exports.removePanel = void 0;
8
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
11
  var _utils = require("@atlaskit/editor-prosemirror/utils");
10
12
  var _state = require("@atlaskit/editor-prosemirror/state");
13
+ var _adfSchema = require("@atlaskit/adf-schema");
11
14
  var _analytics = require("../analytics");
12
15
  var _utils2 = require("./utils");
13
16
  var _panel = require("@atlaskit/editor-common/panel");
17
+ var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
18
+ var _utils3 = require("@atlaskit/editor-common/utils");
14
19
  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; }
15
20
  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; }
16
21
  var removePanel = function removePanel() {
@@ -97,4 +102,23 @@ var changePanelType = function changePanelType(panelType) {
97
102
  return true;
98
103
  };
99
104
  };
100
- exports.changePanelType = changePanelType;
105
+ exports.changePanelType = changePanelType;
106
+ function insertPanelWithAnalytics(inputMethod, analyticsAPI) {
107
+ return (0, _editorAnalytics.withAnalytics)(analyticsAPI, {
108
+ action: _analytics.ACTION.INSERTED,
109
+ actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
110
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.PANEL,
111
+ attributes: {
112
+ inputMethod: inputMethod,
113
+ panelType: _adfSchema.PanelType.INFO // only info panels can be inserted via this action
114
+ },
115
+
116
+ eventType: _analytics.EVENT_TYPE.TRACK
117
+ })(function (state, dispatch) {
118
+ var nodes = state.schema.nodes;
119
+ if (nodes.panel && nodes.paragraph) {
120
+ return (0, _utils3.wrapSelectionIn)(nodes.panel)(state, dispatch);
121
+ }
122
+ return false;
123
+ });
124
+ }
@@ -12,12 +12,10 @@ var _toolbar = require("./toolbar");
12
12
  var _keymaps = _interopRequireDefault(require("./pm-plugins/keymaps"));
13
13
  var _analytics = require("../analytics");
14
14
  var _quickInsert = require("@atlaskit/editor-common/quick-insert");
15
+ var _utils = require("@atlaskit/editor-common/utils");
15
16
  var _messages = require("../block-type/messages");
16
17
  var _colors = require("@atlaskit/theme/colors");
17
- var _blockType = require("../block-type/commands/block-type");
18
- // Theres an existing interelationship between these files, where the imported function is being called for panel
19
- // Insertions via the drop down menu
20
- // tslint-ignore-next-line
18
+ var _actions = require("./actions");
21
19
  var panelPlugin = function panelPlugin(_ref) {
22
20
  var _ref$config = _ref.config,
23
21
  options = _ref$config === void 0 ? {} : _ref$config,
@@ -46,6 +44,12 @@ var panelPlugin = function panelPlugin(_ref) {
46
44
  }
47
45
  }];
48
46
  },
47
+ actions: {
48
+ insertPanel: function insertPanel(inputMethod) {
49
+ var _api$analytics;
50
+ return (0, _actions.insertPanelWithAnalytics)(inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
51
+ }
52
+ },
49
53
  pluginsOptions: {
50
54
  quickInsert: function quickInsert(_ref3) {
51
55
  var formatMessage = _ref3.formatMessage;
@@ -181,7 +185,7 @@ var panelPlugin = function panelPlugin(_ref) {
181
185
  function createPanelAction(_ref4) {
182
186
  var state = _ref4.state,
183
187
  attributes = _ref4.attributes;
184
- var tr = (0, _blockType.createWrapSelectionTransaction)({
188
+ var tr = (0, _utils.createWrapSelectionTransaction)({
185
189
  state: state,
186
190
  type: state.schema.nodes.panel,
187
191
  nodeAttributes: attributes
@@ -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 = "187.34.1";
9
+ var version = "187.35.0";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -20,10 +20,24 @@ export { mentionPluginKey } from './plugins/mentions';
20
20
  export { textColorPluginKey } from './plugins/text-color';
21
21
  export { changeColor } from './plugins/text-color/commands/change-color';
22
22
  export { insertHorizontalRule } from './plugins/rule/commands';
23
- export { blockPluginStateKey } from './plugins';
23
+
24
+ /**
25
+ * @private
26
+ * @deprecated DO NOT USE, temporary solution while decoupling plugins from editor-core
27
+ */
28
+
29
+ /**
30
+ * @private
31
+ * @deprecated DO NOT USE, temporary solution while decoupling plugins from editor-core
32
+ */
33
+
34
+ /**
35
+ * @private
36
+ * @deprecated DO NOT USE, temporary solution while decoupling plugins from editor-core
37
+ */
38
+
24
39
  export { subscribeToToolbarAndPickerUpdates } from './plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates';
25
40
  export { subscribeTypeAheadUpdates } from './plugins/view-update-subscription/subscribe/type-ahead-updates';
26
- export { insertBlockType, insertBlockTypesWithAnalytics, setBlockType, setBlockTypeWithAnalytics } from './plugins/block-type/commands';
27
41
  export { createTable } from '@atlaskit/editor-plugin-table/commands';
28
42
  export { insertTaskDecisionCommand } from './plugins/tasks-and-decisions/commands';
29
43
  export { EventDispatcher } from './event-dispatcher';