@atlaskit/editor-core 189.4.0 → 189.4.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.
Files changed (131) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/plugins/index.js +0 -14
  3. package/dist/cjs/presets/universal.js +4 -2
  4. package/dist/cjs/ui/Appearance/FullPage/FullPageToolbar.js +7 -3
  5. package/dist/cjs/version-wrapper.js +1 -1
  6. package/dist/es2019/plugins/index.js +0 -2
  7. package/dist/es2019/presets/universal.js +3 -1
  8. package/dist/es2019/ui/Appearance/FullPage/FullPageToolbar.js +7 -3
  9. package/dist/es2019/version-wrapper.js +1 -1
  10. package/dist/esm/plugins/index.js +0 -2
  11. package/dist/esm/presets/universal.js +3 -1
  12. package/dist/esm/ui/Appearance/FullPage/FullPageToolbar.js +7 -3
  13. package/dist/esm/version-wrapper.js +1 -1
  14. package/dist/types/plugins/index.d.ts +0 -2
  15. package/dist/types-ts4.5/plugins/index.d.ts +0 -2
  16. package/package.json +11 -5
  17. package/dist/cjs/plugins/insert-block/index.js +0 -165
  18. package/dist/cjs/plugins/insert-block/types.js +0 -5
  19. package/dist/cjs/plugins/insert-block/ui/ElementBrowser/InsertMenu.js +0 -152
  20. package/dist/cjs/plugins/insert-block/ui/ElementBrowser/types.js +0 -5
  21. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +0 -42
  22. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.js +0 -42
  23. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +0 -66
  24. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +0 -217
  25. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.js +0 -49
  26. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +0 -565
  27. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/item.js +0 -250
  28. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/messages.js +0 -12
  29. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/shallow-equals.js +0 -20
  30. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/sort-items.js +0 -30
  31. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/styles.js +0 -11
  32. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/types.js +0 -5
  33. package/dist/cjs/plugins/toolbar-lists-indentation/index.js +0 -91
  34. package/dist/cjs/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +0 -56
  35. package/dist/cjs/plugins/toolbar-lists-indentation/types.js +0 -5
  36. package/dist/cjs/plugins/toolbar-lists-indentation/ui/Toolbar.js +0 -135
  37. package/dist/cjs/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +0 -168
  38. package/dist/cjs/plugins/toolbar-lists-indentation/ui/index.js +0 -63
  39. package/dist/cjs/plugins/toolbar-lists-indentation/ui/onItemActivated.js +0 -53
  40. package/dist/es2019/plugins/insert-block/index.js +0 -159
  41. package/dist/es2019/plugins/insert-block/types.js +0 -1
  42. package/dist/es2019/plugins/insert-block/ui/ElementBrowser/InsertMenu.js +0 -150
  43. package/dist/es2019/plugins/insert-block/ui/ElementBrowser/types.js +0 -1
  44. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +0 -35
  45. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.js +0 -35
  46. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +0 -59
  47. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +0 -198
  48. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.js +0 -37
  49. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +0 -558
  50. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/item.js +0 -201
  51. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/messages.js +0 -1
  52. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/shallow-equals.js +0 -8
  53. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/sort-items.js +0 -22
  54. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/styles.js +0 -16
  55. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/types.js +0 -1
  56. package/dist/es2019/plugins/toolbar-lists-indentation/index.js +0 -86
  57. package/dist/es2019/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +0 -53
  58. package/dist/es2019/plugins/toolbar-lists-indentation/types.js +0 -1
  59. package/dist/es2019/plugins/toolbar-lists-indentation/ui/Toolbar.js +0 -123
  60. package/dist/es2019/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +0 -158
  61. package/dist/es2019/plugins/toolbar-lists-indentation/ui/index.js +0 -58
  62. package/dist/es2019/plugins/toolbar-lists-indentation/ui/onItemActivated.js +0 -46
  63. package/dist/esm/plugins/insert-block/index.js +0 -158
  64. package/dist/esm/plugins/insert-block/types.js +0 -1
  65. package/dist/esm/plugins/insert-block/ui/ElementBrowser/InsertMenu.js +0 -146
  66. package/dist/esm/plugins/insert-block/ui/ElementBrowser/types.js +0 -1
  67. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +0 -35
  68. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.js +0 -35
  69. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +0 -59
  70. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +0 -210
  71. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.js +0 -41
  72. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +0 -560
  73. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/item.js +0 -243
  74. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/messages.js +0 -1
  75. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/shallow-equals.js +0 -13
  76. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/sort-items.js +0 -24
  77. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/styles.js +0 -4
  78. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/types.js +0 -1
  79. package/dist/esm/plugins/toolbar-lists-indentation/index.js +0 -83
  80. package/dist/esm/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +0 -50
  81. package/dist/esm/plugins/toolbar-lists-indentation/types.js +0 -1
  82. package/dist/esm/plugins/toolbar-lists-indentation/ui/Toolbar.js +0 -124
  83. package/dist/esm/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +0 -161
  84. package/dist/esm/plugins/toolbar-lists-indentation/ui/index.js +0 -56
  85. package/dist/esm/plugins/toolbar-lists-indentation/ui/onItemActivated.js +0 -47
  86. package/dist/types/plugins/insert-block/index.d.ts +0 -16
  87. package/dist/types/plugins/insert-block/types.d.ts +0 -45
  88. package/dist/types/plugins/insert-block/ui/ElementBrowser/InsertMenu.d.ts +0 -4
  89. package/dist/types/plugins/insert-block/ui/ElementBrowser/types.d.ts +0 -22
  90. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.d.ts +0 -28
  91. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.d.ts +0 -18
  92. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.d.ts +0 -30
  93. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +0 -39
  94. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.d.ts +0 -16
  95. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +0 -46
  96. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/item.d.ts +0 -34
  97. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/messages.d.ts +0 -1
  98. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/shallow-equals.d.ts +0 -1
  99. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/sort-items.d.ts +0 -2
  100. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/styles.d.ts +0 -1
  101. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +0 -59
  102. package/dist/types/plugins/toolbar-lists-indentation/index.d.ts +0 -33
  103. package/dist/types/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.d.ts +0 -19
  104. package/dist/types/plugins/toolbar-lists-indentation/types.d.ts +0 -20
  105. package/dist/types/plugins/toolbar-lists-indentation/ui/Toolbar.d.ts +0 -4
  106. package/dist/types/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.d.ts +0 -9
  107. package/dist/types/plugins/toolbar-lists-indentation/ui/index.d.ts +0 -26
  108. package/dist/types/plugins/toolbar-lists-indentation/ui/onItemActivated.d.ts +0 -9
  109. package/dist/types-ts4.5/plugins/insert-block/index.d.ts +0 -16
  110. package/dist/types-ts4.5/plugins/insert-block/types.d.ts +0 -45
  111. package/dist/types-ts4.5/plugins/insert-block/ui/ElementBrowser/InsertMenu.d.ts +0 -4
  112. package/dist/types-ts4.5/plugins/insert-block/ui/ElementBrowser/types.d.ts +0 -22
  113. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.d.ts +0 -28
  114. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.d.ts +0 -18
  115. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.d.ts +0 -30
  116. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +0 -42
  117. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.d.ts +0 -16
  118. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +0 -46
  119. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/item.d.ts +0 -34
  120. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/messages.d.ts +0 -1
  121. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/shallow-equals.d.ts +0 -1
  122. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/sort-items.d.ts +0 -2
  123. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/styles.d.ts +0 -1
  124. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +0 -59
  125. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/index.d.ts +0 -33
  126. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.d.ts +0 -19
  127. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/types.d.ts +0 -20
  128. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/Toolbar.d.ts +0 -4
  129. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.d.ts +0 -9
  130. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/index.d.ts +0 -26
  131. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/onItemActivated.d.ts +0 -9
@@ -1,560 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
5
- import _inherits from "@babel/runtime/helpers/inherits";
6
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
- 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; }
10
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12
- 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; } }
13
- /** @jsx jsx */
14
- import React from 'react';
15
- import { jsx } from '@emotion/react';
16
- import ReactDOM from 'react-dom';
17
- import { injectIntl } from 'react-intl-next';
18
- import { EmojiPicker as AkEmojiPicker } from '@atlaskit/emoji/picker';
19
- import { Popup } from '@atlaskit/editor-common/ui';
20
- import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
21
- import { separatorStyles, buttonGroupStyle, wrapperStyle } from '@atlaskit/editor-common/styles';
22
- import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
23
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
24
- import { messages } from './messages';
25
- import { createItems } from './create-items';
26
- import { BlockInsertMenu } from './block-insert-menu';
27
- import { withReactEditorViewOuterListeners as withOuterListeners } from '@atlaskit/editor-common/ui-react';
28
-
29
- /**
30
- * Checks if an element is detached (i.e. not in the current document)
31
- */
32
- var isDetachedElement = function isDetachedElement(el) {
33
- return !document.body.contains(el);
34
- };
35
- var noop = function noop() {};
36
- var EmojiPickerWithListeners = withOuterListeners(AkEmojiPicker);
37
- export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
38
- _inherits(ToolbarInsertBlock, _React$PureComponent);
39
- var _super = _createSuper(ToolbarInsertBlock);
40
- function ToolbarInsertBlock() {
41
- var _this;
42
- _classCallCheck(this, ToolbarInsertBlock);
43
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
44
- args[_key] = arguments[_key];
45
- }
46
- _this = _super.call.apply(_super, [this].concat(args));
47
- _defineProperty(_assertThisInitialized(_this), "state", {
48
- isPlusMenuOpen: false,
49
- emojiPickerOpen: false,
50
- isOpenedByKeyboard: false,
51
- buttons: [],
52
- dropdownItems: []
53
- });
54
- _defineProperty(_assertThisInitialized(_this), "onOpenChange", function (attrs) {
55
- var state = {
56
- isPlusMenuOpen: attrs.isPlusMenuOpen,
57
- emojiPickerOpen: _this.state.emojiPickerOpen
58
- };
59
- if (_this.state.emojiPickerOpen && !attrs.open) {
60
- state.emojiPickerOpen = false;
61
- }
62
- _this.setState(state, function () {
63
- var dispatchAnalyticsEvent = _this.props.dispatchAnalyticsEvent;
64
- if (!dispatchAnalyticsEvent) {
65
- return;
66
- }
67
- var isPlusMenuOpen = _this.state.isPlusMenuOpen;
68
- if (isPlusMenuOpen) {
69
- return dispatchAnalyticsEvent({
70
- action: ACTION.OPENED,
71
- actionSubject: ACTION_SUBJECT.PLUS_MENU,
72
- eventType: EVENT_TYPE.UI
73
- });
74
- }
75
- return dispatchAnalyticsEvent({
76
- action: ACTION.CLOSED,
77
- actionSubject: ACTION_SUBJECT.PLUS_MENU,
78
- eventType: EVENT_TYPE.UI
79
- });
80
- });
81
- });
82
- _defineProperty(_assertThisInitialized(_this), "togglePlusMenuVisibility", function (event) {
83
- var isPlusMenuOpen = _this.state.isPlusMenuOpen;
84
- _this.onOpenChange({
85
- isPlusMenuOpen: !isPlusMenuOpen
86
- });
87
- if ((event === null || event === void 0 ? void 0 : event.key) === 'Escape') {
88
- var _ref;
89
- (_ref = _this.plusButtonRef || _this.dropdownButtonRef) === null || _ref === void 0 || _ref.focus();
90
- }
91
- });
92
- _defineProperty(_assertThisInitialized(_this), "toggleEmojiPicker", function () {
93
- var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INPUT_METHOD.TOOLBAR;
94
- _this.setState(function (prevState) {
95
- return {
96
- emojiPickerOpen: !prevState.emojiPickerOpen
97
- };
98
- }, function () {
99
- if (_this.state.emojiPickerOpen) {
100
- var dispatchAnalyticsEvent = _this.props.dispatchAnalyticsEvent;
101
- if (dispatchAnalyticsEvent) {
102
- dispatchAnalyticsEvent({
103
- action: ACTION.OPENED,
104
- actionSubject: ACTION_SUBJECT.PICKER,
105
- actionSubjectId: ACTION_SUBJECT_ID.PICKER_EMOJI,
106
- attributes: {
107
- inputMethod: inputMethod
108
- },
109
- eventType: EVENT_TYPE.UI
110
- });
111
- }
112
- }
113
- });
114
- });
115
- _defineProperty(_assertThisInitialized(_this), "handleEmojiPressEscape", function () {
116
- var _this$emojiButtonRef;
117
- _this.toggleEmojiPicker(INPUT_METHOD.KEYBOARD);
118
- (_this$emojiButtonRef = _this.emojiButtonRef) === null || _this$emojiButtonRef === void 0 || _this$emojiButtonRef.focus();
119
- });
120
- _defineProperty(_assertThisInitialized(_this), "handleEmojiClickOutside", function (e) {
121
- // Ignore click events for detached elements.
122
- // Workaround for FS-1322 - where two onClicks fire - one when the upload button is
123
- // still in the document, and one once it's detached. Does not always occur, and
124
- // may be a side effect of a react render optimisation
125
- if (e.target && !isDetachedElement(e.target)) {
126
- _this.toggleEmojiPicker(INPUT_METHOD.TOOLBAR);
127
- }
128
- });
129
- _defineProperty(_assertThisInitialized(_this), "handleEmojiButtonRef", function (button) {
130
- var ref = ReactDOM.findDOMNode(button);
131
- if (ref) {
132
- _this.emojiButtonRef = ref;
133
- }
134
- });
135
- _defineProperty(_assertThisInitialized(_this), "handlePlusButtonRef", function (button) {
136
- var ref = ReactDOM.findDOMNode(button);
137
- if (ref) {
138
- _this.plusButtonRef = ref;
139
- }
140
- });
141
- _defineProperty(_assertThisInitialized(_this), "handleDropDownButtonRef", function (button) {
142
- var ref = ReactDOM.findDOMNode(button);
143
- if (ref) {
144
- _this.dropdownButtonRef = ref;
145
- }
146
- });
147
- _defineProperty(_assertThisInitialized(_this), "handleClick", function () {
148
- _this.togglePlusMenuVisibility();
149
- });
150
- _defineProperty(_assertThisInitialized(_this), "handleOpenByKeyboard", function (event) {
151
- if (event.key === 'Enter' || event.key === ' ') {
152
- _this.setState(_objectSpread(_objectSpread({}, _this.state), {}, {
153
- isOpenedByKeyboard: true
154
- }));
155
- event.preventDefault();
156
- _this.togglePlusMenuVisibility();
157
- }
158
- });
159
- _defineProperty(_assertThisInitialized(_this), "toggleLinkPanel", function (inputMethod) {
160
- var _pluginInjectionApi$c, _pluginInjectionApi$h;
161
- var pluginInjectionApi = _this.props.pluginInjectionApi;
162
- return (_pluginInjectionApi$c = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$h = pluginInjectionApi.hyperlink) === null || _pluginInjectionApi$h === void 0 ? void 0 : _pluginInjectionApi$h.commands.showLinkToolbar(inputMethod))) !== null && _pluginInjectionApi$c !== void 0 ? _pluginInjectionApi$c : false;
163
- });
164
- _defineProperty(_assertThisInitialized(_this), "insertMention", function (inputMethod) {
165
- var _pluginInjectionApi$m, _pluginInjectionApi$m2;
166
- var _this$props = _this.props,
167
- editorView = _this$props.editorView,
168
- pluginInjectionApi = _this$props.pluginInjectionApi;
169
- if (!editorView) {
170
- return true;
171
- }
172
- var pluginState = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.mention) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.sharedState.currentState();
173
- if (pluginState && pluginState.canInsertMention === false) {
174
- return false;
175
- }
176
- return Boolean(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m2 = pluginInjectionApi.mention) === null || _pluginInjectionApi$m2 === void 0 || (_pluginInjectionApi$m2 = _pluginInjectionApi$m2.actions) === null || _pluginInjectionApi$m2 === void 0 ? void 0 : _pluginInjectionApi$m2.openTypeAhead(inputMethod));
177
- });
178
- _defineProperty(_assertThisInitialized(_this), "insertTable", function (inputMethod) {
179
- var _pluginInjectionApi$t, _pluginInjectionApi$t2, _pluginInjectionApi$t3, _pluginInjectionApi$t4;
180
- var _this$props2 = _this.props,
181
- pluginInjectionApi = _this$props2.pluginInjectionApi,
182
- editorView = _this$props2.editorView;
183
- var state = editorView.state,
184
- dispatch = editorView.dispatch;
185
- return (_pluginInjectionApi$t = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$t2 = pluginInjectionApi.table) === null || _pluginInjectionApi$t2 === void 0 || (_pluginInjectionApi$t3 = (_pluginInjectionApi$t4 = _pluginInjectionApi$t2.actions).insertTable) === null || _pluginInjectionApi$t3 === void 0 ? void 0 : _pluginInjectionApi$t3.call(_pluginInjectionApi$t4, {
186
- action: ACTION.INSERTED,
187
- actionSubject: ACTION_SUBJECT.DOCUMENT,
188
- actionSubjectId: ACTION_SUBJECT_ID.TABLE,
189
- attributes: {
190
- inputMethod: inputMethod
191
- },
192
- eventType: EVENT_TYPE.TRACK
193
- })(state, dispatch)) !== null && _pluginInjectionApi$t !== void 0 ? _pluginInjectionApi$t : false;
194
- });
195
- _defineProperty(_assertThisInitialized(_this), "createDate", function (inputMethod) {
196
- var _pluginInjectionApi$d;
197
- var pluginInjectionApi = _this.props.pluginInjectionApi;
198
- pluginInjectionApi === null || pluginInjectionApi === void 0 || pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d = pluginInjectionApi.date) === null || _pluginInjectionApi$d === void 0 || (_pluginInjectionApi$d = _pluginInjectionApi$d.commands) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.insertDate({
199
- inputMethod: inputMethod
200
- }));
201
- return true;
202
- });
203
- _defineProperty(_assertThisInitialized(_this), "createPlaceholderText", function () {
204
- var _pluginInjectionApi$p;
205
- var _this$props3 = _this.props,
206
- editorView = _this$props3.editorView,
207
- pluginInjectionApi = _this$props3.pluginInjectionApi;
208
- pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$p = pluginInjectionApi.placeholderText) === null || _pluginInjectionApi$p === void 0 || _pluginInjectionApi$p.actions.showPlaceholderFloatingToolbar(editorView.state, editorView.dispatch);
209
- return true;
210
- });
211
- _defineProperty(_assertThisInitialized(_this), "insertLayoutColumns", function (inputMethod) {
212
- var _pluginInjectionApi$l;
213
- var _this$props4 = _this.props,
214
- editorView = _this$props4.editorView,
215
- pluginInjectionApi = _this$props4.pluginInjectionApi;
216
- pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$l = pluginInjectionApi.layout) === null || _pluginInjectionApi$l === void 0 || _pluginInjectionApi$l.actions.insertLayoutColumns(inputMethod)(editorView.state, editorView.dispatch);
217
- return true;
218
- });
219
- _defineProperty(_assertThisInitialized(_this), "createStatus", function (inputMethod) {
220
- var _pluginInjectionApi$s, _pluginInjectionApi$s2;
221
- var _this$props5 = _this.props,
222
- pluginInjectionApi = _this$props5.pluginInjectionApi,
223
- editorView = _this$props5.editorView;
224
- return (_pluginInjectionApi$s = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$s2 = pluginInjectionApi.status) === null || _pluginInjectionApi$s2 === void 0 || (_pluginInjectionApi$s2 = _pluginInjectionApi$s2.actions) === null || _pluginInjectionApi$s2 === void 0 ? void 0 : _pluginInjectionApi$s2.updateStatus(inputMethod)(editorView.state, editorView.dispatch)) !== null && _pluginInjectionApi$s !== void 0 ? _pluginInjectionApi$s : false;
225
- });
226
- _defineProperty(_assertThisInitialized(_this), "openMediaPicker", function (inputMethod) {
227
- var _this$props6 = _this.props,
228
- onShowMediaPicker = _this$props6.onShowMediaPicker,
229
- dispatchAnalyticsEvent = _this$props6.dispatchAnalyticsEvent;
230
- if (onShowMediaPicker) {
231
- onShowMediaPicker();
232
- if (dispatchAnalyticsEvent) {
233
- dispatchAnalyticsEvent({
234
- action: ACTION.OPENED,
235
- actionSubject: ACTION_SUBJECT.PICKER,
236
- actionSubjectId: ACTION_SUBJECT_ID.PICKER_CLOUD,
237
- attributes: {
238
- inputMethod: inputMethod
239
- },
240
- eventType: EVENT_TYPE.UI
241
- });
242
- }
243
- }
244
- return true;
245
- });
246
- _defineProperty(_assertThisInitialized(_this), "insertTaskDecision", function (name, inputMethod) {
247
- return function () {
248
- var _pluginInjectionApi$t5, _pluginInjectionApi$t6;
249
- var _this$props7 = _this.props,
250
- _this$props7$editorVi = _this$props7.editorView,
251
- state = _this$props7$editorVi.state,
252
- dispatch = _this$props7$editorVi.dispatch,
253
- pluginInjectionApi = _this$props7.pluginInjectionApi;
254
- var listType = name === 'action' ? 'taskList' : 'decisionList';
255
- return (_pluginInjectionApi$t5 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$t6 = pluginInjectionApi.taskDecision) === null || _pluginInjectionApi$t6 === void 0 ? void 0 : _pluginInjectionApi$t6.actions.insertTaskDecision(listType, inputMethod)(state, dispatch)) !== null && _pluginInjectionApi$t5 !== void 0 ? _pluginInjectionApi$t5 : false;
256
- };
257
- });
258
- _defineProperty(_assertThisInitialized(_this), "insertHorizontalRule", function (inputMethod) {
259
- var _pluginInjectionApi$r, _pluginInjectionApi$r2;
260
- var _this$props8 = _this.props,
261
- _this$props8$editorVi = _this$props8.editorView,
262
- state = _this$props8$editorVi.state,
263
- dispatch = _this$props8$editorVi.dispatch,
264
- pluginInjectionApi = _this$props8.pluginInjectionApi;
265
- return (_pluginInjectionApi$r = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$r2 = pluginInjectionApi.rule) === null || _pluginInjectionApi$r2 === void 0 ? void 0 : _pluginInjectionApi$r2.actions.insertHorizontalRule(inputMethod)(state, dispatch)) !== null && _pluginInjectionApi$r !== void 0 ? _pluginInjectionApi$r : false;
266
- });
267
- _defineProperty(_assertThisInitialized(_this), "insertExpand", function () {
268
- var _pluginInjectionApi$e, _pluginInjectionApi$e2;
269
- var _this$props9 = _this.props,
270
- _this$props9$editorVi = _this$props9.editorView,
271
- state = _this$props9$editorVi.state,
272
- dispatch = _this$props9$editorVi.dispatch,
273
- pluginInjectionApi = _this$props9.pluginInjectionApi;
274
- return (_pluginInjectionApi$e = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$e2 = pluginInjectionApi.expand) === null || _pluginInjectionApi$e2 === void 0 ? void 0 : _pluginInjectionApi$e2.actions.insertExpand(state, dispatch)) !== null && _pluginInjectionApi$e !== void 0 ? _pluginInjectionApi$e : false;
275
- });
276
- _defineProperty(_assertThisInitialized(_this), "insertBlockType", function (itemName) {
277
- return function () {
278
- var _this$props10 = _this.props,
279
- editorView = _this$props10.editorView,
280
- onInsertBlockType = _this$props10.onInsertBlockType;
281
- var state = editorView.state,
282
- dispatch = editorView.dispatch;
283
- onInsertBlockType(itemName)(state, dispatch);
284
- return true;
285
- };
286
- });
287
- _defineProperty(_assertThisInitialized(_this), "handleSelectedEmoji", function (emojiId) {
288
- var _pluginInjectionApi$e3;
289
- var pluginInjectionApi = _this.props.pluginInjectionApi;
290
- _this.props.editorView.focus();
291
- pluginInjectionApi === null || pluginInjectionApi === void 0 || pluginInjectionApi.core.actions.execute((_pluginInjectionApi$e3 = pluginInjectionApi.emoji) === null || _pluginInjectionApi$e3 === void 0 ? void 0 : _pluginInjectionApi$e3.commands.insertEmoji(emojiId, INPUT_METHOD.PICKER));
292
- _this.toggleEmojiPicker();
293
- return true;
294
- });
295
- _defineProperty(_assertThisInitialized(_this), "openElementBrowser", function () {
296
- var _pluginInjectionApi$q;
297
- var pluginInjectionApi = _this.props.pluginInjectionApi;
298
- pluginInjectionApi === null || pluginInjectionApi === void 0 || pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$q = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q === void 0 ? void 0 : _pluginInjectionApi$q.commands.openElementBrowserModal);
299
- });
300
- _defineProperty(_assertThisInitialized(_this), "onItemActivated", function (_ref2) {
301
- var item = _ref2.item,
302
- inputMethod = _ref2.inputMethod;
303
- var _this$props11 = _this.props,
304
- editorView = _this$props11.editorView,
305
- editorActions = _this$props11.editorActions,
306
- handleImageUpload = _this$props11.handleImageUpload,
307
- expandEnabled = _this$props11.expandEnabled;
308
-
309
- // need to do this before inserting nodes so scrollIntoView works properly
310
- if (!editorView.hasFocus()) {
311
- editorView.focus();
312
- }
313
- switch (item.value.name) {
314
- case 'link':
315
- _this.toggleLinkPanel(inputMethod);
316
- break;
317
- case 'table':
318
- _this.insertTable(inputMethod);
319
- break;
320
- case 'image upload':
321
- if (handleImageUpload) {
322
- var state = editorView.state,
323
- dispatch = editorView.dispatch;
324
- handleImageUpload()(state, dispatch);
325
- }
326
- break;
327
- case 'media':
328
- _this.openMediaPicker(inputMethod);
329
- break;
330
- case 'mention':
331
- _this.insertMention(inputMethod);
332
- break;
333
- case 'emoji':
334
- _this.toggleEmojiPicker(inputMethod);
335
- break;
336
- case 'codeblock':
337
- case 'blockquote':
338
- case 'panel':
339
- _this.insertBlockType(item.value.name)();
340
- break;
341
- case 'action':
342
- case 'decision':
343
- _this.insertTaskDecision(item.value.name, inputMethod)();
344
- break;
345
- case 'horizontalrule':
346
- _this.insertHorizontalRule(inputMethod);
347
- break;
348
- case 'macro':
349
- _this.openElementBrowser();
350
- break;
351
- case 'date':
352
- _this.createDate(inputMethod);
353
- break;
354
- case 'placeholder text':
355
- _this.createPlaceholderText();
356
- break;
357
- case 'layout':
358
- _this.insertLayoutColumns(inputMethod);
359
- break;
360
- case 'status':
361
- _this.createStatus(inputMethod);
362
- break;
363
-
364
- // https://product-fabric.atlassian.net/browse/ED-8053
365
- // @ts-ignore: OK to fallthrough to default
366
- case 'expand':
367
- if (expandEnabled) {
368
- _this.insertExpand();
369
- break;
370
- }
371
-
372
- // eslint-disable-next-line no-fallthrough
373
- default:
374
- if (item && item.onClick) {
375
- item.onClick(editorActions);
376
- break;
377
- }
378
- }
379
- _this.setState({
380
- isPlusMenuOpen: false
381
- });
382
- });
383
- _defineProperty(_assertThisInitialized(_this), "insertToolbarMenuItem", function (btn) {
384
- return _this.onItemActivated({
385
- item: btn,
386
- inputMethod: INPUT_METHOD.TOOLBAR
387
- });
388
- });
389
- _defineProperty(_assertThisInitialized(_this), "insertInsertMenuItem", function (_ref3) {
390
- var item = _ref3.item;
391
- return _this.onItemActivated({
392
- item: item,
393
- inputMethod: INPUT_METHOD.INSERT_MENU
394
- });
395
- });
396
- return _this;
397
- }
398
- _createClass(ToolbarInsertBlock, [{
399
- key: "componentDidUpdate",
400
- value: function componentDidUpdate(prevProps) {
401
- // If number of visible buttons changed, close emoji picker
402
- if (prevProps.buttons !== this.props.buttons) {
403
- this.setState({
404
- emojiPickerOpen: false
405
- });
406
- }
407
- if (this.state.isOpenedByKeyboard) {
408
- var _this$dropdownButtonR;
409
- var downArrowEvent = new KeyboardEvent('keydown', {
410
- bubbles: true,
411
- key: 'ArrowDown'
412
- });
413
- (_this$dropdownButtonR = this.dropdownButtonRef) === null || _this$dropdownButtonR === void 0 || _this$dropdownButtonR.dispatchEvent(downArrowEvent);
414
- this.setState(_objectSpread(_objectSpread({}, this.state), {}, {
415
- isOpenedByKeyboard: false
416
- }));
417
- }
418
- }
419
- }, {
420
- key: "renderPopup",
421
- value: function renderPopup() {
422
- var emojiPickerOpen = this.state.emojiPickerOpen;
423
- var _this$props12 = this.props,
424
- popupsMountPoint = _this$props12.popupsMountPoint,
425
- popupsBoundariesElement = _this$props12.popupsBoundariesElement,
426
- popupsScrollableElement = _this$props12.popupsScrollableElement,
427
- emojiProvider = _this$props12.emojiProvider,
428
- replacePlusMenuWithElementBrowser = _this$props12.replacePlusMenuWithElementBrowser;
429
- var dropdownEmoji = this.state.dropdownItems.some(function (_ref4) {
430
- var name = _ref4.value.name;
431
- return name === 'emoji';
432
- });
433
- var dropDownButtonRef = replacePlusMenuWithElementBrowser ? this.plusButtonRef : this.dropdownButtonRef;
434
- var ref = dropdownEmoji ? dropDownButtonRef : this.emojiButtonRef;
435
- if (!emojiPickerOpen || !ref || !emojiProvider) {
436
- return null;
437
- }
438
- return jsx(Popup, {
439
- target: ref,
440
- fitHeight: 350,
441
- fitWidth: 350,
442
- offset: [0, 3],
443
- mountTo: popupsMountPoint,
444
- boundariesElement: popupsBoundariesElement,
445
- scrollableElement: popupsScrollableElement,
446
- focusTrap: true,
447
- zIndex: akEditorMenuZIndex
448
- }, jsx(EmojiPickerWithListeners, {
449
- emojiProvider: emojiProvider,
450
- onSelection: this.handleSelectedEmoji,
451
- handleClickOutside: this.handleEmojiClickOutside,
452
- handleEscapeKeydown: this.handleEmojiPressEscape
453
- }));
454
- }
455
- }, {
456
- key: "render",
457
- value: function render() {
458
- var _this2 = this,
459
- _this$props$isDisable,
460
- _this$props$replacePl;
461
- var _this$state = this.state,
462
- buttons = _this$state.buttons,
463
- dropdownItems = _this$state.dropdownItems,
464
- emojiPickerOpen = _this$state.emojiPickerOpen;
465
- var _this$props13 = this.props,
466
- isDisabled = _this$props13.isDisabled,
467
- isReducedSpacing = _this$props13.isReducedSpacing;
468
- if (buttons.length === 0 && dropdownItems.length === 0) {
469
- return null;
470
- }
471
- return jsx("span", {
472
- css: buttonGroupStyle
473
- }, buttons.map(function (btn) {
474
- return jsx(ToolbarButton, {
475
- item: btn,
476
- testId: String(btn.content),
477
- ref: btn.value.name === 'emoji' ? _this2.handleEmojiButtonRef : noop,
478
- key: btn.value.name,
479
- spacing: isReducedSpacing ? 'none' : 'default',
480
- disabled: isDisabled || btn.isDisabled,
481
- iconBefore: btn.elemBefore,
482
- selected: btn.value.name === 'emoji' && emojiPickerOpen || btn.isActive,
483
- title: btn.title,
484
- "aria-label": btn['aria-label'],
485
- "aria-haspopup": btn['aria-haspopup'],
486
- "aria-keyshortcuts": btn['aria-keyshortcuts'],
487
- onItemClick: _this2.insertToolbarMenuItem
488
- });
489
- }), jsx("span", {
490
- css: wrapperStyle
491
- }, this.renderPopup(), jsx(BlockInsertMenu, {
492
- popupsMountPoint: this.props.popupsMountPoint,
493
- popupsBoundariesElement: this.props.popupsBoundariesElement,
494
- popupsScrollableElement: this.props.popupsScrollableElement,
495
- disabled: (_this$props$isDisable = this.props.isDisabled) !== null && _this$props$isDisable !== void 0 ? _this$props$isDisable : false,
496
- editorView: this.props.editorView,
497
- spacing: this.props.isReducedSpacing ? 'none' : 'default',
498
- label: this.props.intl.formatMessage(messages.insertMenu),
499
- open: this.state.isPlusMenuOpen,
500
- plusButtonRef: this.plusButtonRef,
501
- items: this.state.dropdownItems,
502
- onRef: this.handleDropDownButtonRef,
503
- onPlusButtonRef: this.handlePlusButtonRef,
504
- onClick: this.handleClick,
505
- onKeyDown: this.handleOpenByKeyboard,
506
- onItemActivated: this.insertInsertMenuItem,
507
- onInsert: this.insertInsertMenuItem,
508
- onOpenChange: this.onOpenChange,
509
- togglePlusMenuVisibility: this.togglePlusMenuVisibility,
510
- replacePlusMenuWithElementBrowser: (_this$props$replacePl = this.props.replacePlusMenuWithElementBrowser) !== null && _this$props$replacePl !== void 0 ? _this$props$replacePl : false,
511
- showElementBrowserLink: this.props.showElementBrowserLink || false,
512
- pluginInjectionApi: this.props.pluginInjectionApi
513
- })), this.props.showSeparator && jsx("span", {
514
- css: separatorStyles
515
- }));
516
- }
517
- }], [{
518
- key: "getDerivedStateFromProps",
519
- value: function getDerivedStateFromProps(props, state) {
520
- var _createItems = createItems({
521
- isTypeAheadAllowed: props.isTypeAheadAllowed,
522
- tableSupported: props.tableSupported,
523
- mediaUploadsEnabled: props.mediaUploadsEnabled,
524
- mediaSupported: props.mediaSupported,
525
- imageUploadSupported: props.imageUploadSupported,
526
- imageUploadEnabled: props.imageUploadEnabled,
527
- mentionsSupported: props.mentionsSupported,
528
- mentionsDisabled: props.mentionsDisabled,
529
- actionSupported: props.actionSupported,
530
- decisionSupported: props.decisionSupported,
531
- linkSupported: props.linkSupported,
532
- linkDisabled: props.linkDisabled,
533
- emojiDisabled: props.emojiDisabled,
534
- nativeStatusSupported: props.nativeStatusSupported,
535
- dateEnabled: props.dateEnabled,
536
- placeholderTextEnabled: props.placeholderTextEnabled,
537
- horizontalRuleEnabled: props.horizontalRuleEnabled,
538
- layoutSectionEnabled: props.layoutSectionEnabled,
539
- expandEnabled: props.expandEnabled,
540
- showElementBrowserLink: props.showElementBrowserLink,
541
- emojiProvider: props.emojiProvider,
542
- availableWrapperBlockTypes: props.availableWrapperBlockTypes,
543
- insertMenuItems: props.insertMenuItems,
544
- schema: props.editorView.state.schema,
545
- numberOfButtons: props.buttons,
546
- formatMessage: props.intl.formatMessage,
547
- isNewMenuEnabled: props.replacePlusMenuWithElementBrowser
548
- }),
549
- _createItems2 = _slicedToArray(_createItems, 2),
550
- buttons = _createItems2[0],
551
- dropdownItems = _createItems2[1];
552
- return _objectSpread(_objectSpread({}, state), {}, {
553
- buttons: buttons,
554
- dropdownItems: dropdownItems
555
- });
556
- }
557
- }]);
558
- return ToolbarInsertBlock;
559
- }(React.PureComponent);
560
- export default injectIntl(ToolbarInsertBlock);