@atlaskit/editor-core 188.8.0 → 188.9.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 (95) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/composable-editor/editor-internal.js +2 -2
  3. package/dist/cjs/create-editor/ReactEditorView.js +796 -8
  4. package/dist/cjs/labs/next/presets/universal.js +7 -4
  5. package/dist/cjs/plugins/index.js +0 -21
  6. package/dist/cjs/version-wrapper.js +1 -1
  7. package/dist/es2019/composable-editor/editor-internal.js +1 -1
  8. package/dist/es2019/create-editor/ReactEditorView.js +753 -2
  9. package/dist/es2019/labs/next/presets/universal.js +4 -1
  10. package/dist/es2019/plugins/index.js +0 -3
  11. package/dist/es2019/version-wrapper.js +1 -1
  12. package/dist/esm/composable-editor/editor-internal.js +1 -1
  13. package/dist/esm/create-editor/ReactEditorView.js +797 -8
  14. package/dist/esm/labs/next/presets/universal.js +4 -1
  15. package/dist/esm/plugins/index.js +0 -3
  16. package/dist/esm/version-wrapper.js +1 -1
  17. package/dist/types/create-editor/ReactEditorView.d.ts +119 -5
  18. package/dist/types/plugins/index.d.ts +0 -3
  19. package/dist/types/plugins/insert-block/types.d.ts +1 -1
  20. package/dist/types/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +1 -1
  21. package/dist/types-ts4.5/create-editor/ReactEditorView.d.ts +119 -5
  22. package/dist/types-ts4.5/plugins/index.d.ts +0 -3
  23. package/dist/types-ts4.5/plugins/insert-block/types.d.ts +1 -1
  24. package/dist/types-ts4.5/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +1 -1
  25. package/package.json +5 -3
  26. package/dist/cjs/create-editor/ReactEditorViewInternal.js +0 -812
  27. package/dist/cjs/create-editor/ReactEditorViewNext.js +0 -15
  28. package/dist/cjs/plugins/save-on-enter/index.js +0 -70
  29. package/dist/cjs/plugins/scroll-into-view/index.js +0 -55
  30. package/dist/cjs/plugins/status/actions.js +0 -158
  31. package/dist/cjs/plugins/status/analytics.js +0 -31
  32. package/dist/cjs/plugins/status/index.js +0 -143
  33. package/dist/cjs/plugins/status/keymap.js +0 -22
  34. package/dist/cjs/plugins/status/nodeviews/status.js +0 -58
  35. package/dist/cjs/plugins/status/plugin-key.js +0 -9
  36. package/dist/cjs/plugins/status/plugin.js +0 -133
  37. package/dist/cjs/plugins/status/types.js +0 -5
  38. package/dist/cjs/plugins/status/ui/statusPicker.js +0 -314
  39. package/dist/cjs/plugins/status/utils.js +0 -22
  40. package/dist/es2019/create-editor/ReactEditorViewInternal.js +0 -753
  41. package/dist/es2019/create-editor/ReactEditorViewNext.js +0 -7
  42. package/dist/es2019/plugins/save-on-enter/index.js +0 -63
  43. package/dist/es2019/plugins/scroll-into-view/index.js +0 -44
  44. package/dist/es2019/plugins/status/actions.js +0 -144
  45. package/dist/es2019/plugins/status/analytics.js +0 -18
  46. package/dist/es2019/plugins/status/index.js +0 -135
  47. package/dist/es2019/plugins/status/keymap.js +0 -13
  48. package/dist/es2019/plugins/status/nodeviews/status.js +0 -60
  49. package/dist/es2019/plugins/status/plugin-key.js +0 -3
  50. package/dist/es2019/plugins/status/plugin.js +0 -113
  51. package/dist/es2019/plugins/status/types.js +0 -1
  52. package/dist/es2019/plugins/status/ui/statusPicker.js +0 -293
  53. package/dist/es2019/plugins/status/utils.js +0 -12
  54. package/dist/esm/create-editor/ReactEditorViewInternal.js +0 -806
  55. package/dist/esm/create-editor/ReactEditorViewNext.js +0 -7
  56. package/dist/esm/plugins/save-on-enter/index.js +0 -63
  57. package/dist/esm/plugins/scroll-into-view/index.js +0 -50
  58. package/dist/esm/plugins/status/actions.js +0 -151
  59. package/dist/esm/plugins/status/analytics.js +0 -24
  60. package/dist/esm/plugins/status/index.js +0 -136
  61. package/dist/esm/plugins/status/keymap.js +0 -15
  62. package/dist/esm/plugins/status/nodeviews/status.js +0 -51
  63. package/dist/esm/plugins/status/plugin-key.js +0 -3
  64. package/dist/esm/plugins/status/plugin.js +0 -115
  65. package/dist/esm/plugins/status/types.js +0 -1
  66. package/dist/esm/plugins/status/ui/statusPicker.js +0 -308
  67. package/dist/esm/plugins/status/utils.js +0 -16
  68. package/dist/types/create-editor/ReactEditorViewInternal.d.ts +0 -119
  69. package/dist/types/create-editor/ReactEditorViewNext.d.ts +0 -8
  70. package/dist/types/plugins/save-on-enter/index.d.ts +0 -10
  71. package/dist/types/plugins/scroll-into-view/index.d.ts +0 -14
  72. package/dist/types/plugins/status/actions.d.ts +0 -16
  73. package/dist/types/plugins/status/analytics.d.ts +0 -4
  74. package/dist/types/plugins/status/index.d.ts +0 -15
  75. package/dist/types/plugins/status/keymap.d.ts +0 -3
  76. package/dist/types/plugins/status/nodeviews/status.d.ts +0 -25
  77. package/dist/types/plugins/status/plugin-key.d.ts +0 -4
  78. package/dist/types/plugins/status/plugin.d.ts +0 -7
  79. package/dist/types/plugins/status/types.d.ts +0 -18
  80. package/dist/types/plugins/status/ui/statusPicker.d.ts +0 -63
  81. package/dist/types/plugins/status/utils.d.ts +0 -5
  82. package/dist/types-ts4.5/create-editor/ReactEditorViewInternal.d.ts +0 -119
  83. package/dist/types-ts4.5/create-editor/ReactEditorViewNext.d.ts +0 -8
  84. package/dist/types-ts4.5/plugins/save-on-enter/index.d.ts +0 -10
  85. package/dist/types-ts4.5/plugins/scroll-into-view/index.d.ts +0 -14
  86. package/dist/types-ts4.5/plugins/status/actions.d.ts +0 -16
  87. package/dist/types-ts4.5/plugins/status/analytics.d.ts +0 -4
  88. package/dist/types-ts4.5/plugins/status/index.d.ts +0 -17
  89. package/dist/types-ts4.5/plugins/status/keymap.d.ts +0 -3
  90. package/dist/types-ts4.5/plugins/status/nodeviews/status.d.ts +0 -25
  91. package/dist/types-ts4.5/plugins/status/plugin-key.d.ts +0 -4
  92. package/dist/types-ts4.5/plugins/status/plugin.d.ts +0 -7
  93. package/dist/types-ts4.5/plugins/status/types.d.ts +0 -18
  94. package/dist/types-ts4.5/plugins/status/ui/statusPicker.d.ts +0 -63
  95. package/dist/types-ts4.5/plugins/status/utils.d.ts +0 -5
@@ -1,133 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- Object.defineProperty(exports, "pluginKey", {
9
- enumerable: true,
10
- get: function get() {
11
- return _pluginKey.pluginKey;
12
- }
13
- });
14
- Object.defineProperty(exports, "pluginKeyName", {
15
- enumerable: true,
16
- get: function get() {
17
- return _pluginKey.pluginKeyName;
18
- }
19
- });
20
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
21
- var _state = require("@atlaskit/editor-prosemirror/state");
22
- var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
23
- var _utils = require("@atlaskit/editor-common/utils");
24
- var _reactNodeView = require("@atlaskit/editor-common/react-node-view");
25
- var _status = require("./nodeviews/status");
26
- var _pluginKey = require("./plugin-key");
27
- var _utils2 = require("./utils");
28
- 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; }
29
- 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; }
30
- var createPlugin = function createPlugin(pmPluginFactoryParams, options) {
31
- return new _safePlugin.SafePlugin({
32
- state: {
33
- init: function init() {
34
- return {
35
- isNew: false,
36
- showStatusPickerAt: null
37
- };
38
- },
39
- apply: function apply(tr, state, oldEditorState) {
40
- var meta = tr.getMeta(_pluginKey.pluginKey);
41
- if (meta) {
42
- var newState = _objectSpread(_objectSpread({}, state), meta);
43
- pmPluginFactoryParams.dispatch(_pluginKey.pluginKey, newState);
44
- return newState;
45
- }
46
- if (tr.docChanged && state.showStatusPickerAt) {
47
- var _tr$mapping$mapResult = tr.mapping.mapResult(state.showStatusPickerAt),
48
- pos = _tr$mapping$mapResult.pos,
49
- deleted = _tr$mapping$mapResult.deleted;
50
- var showStatusPickerAt = deleted ? null : pos;
51
- var _newState = _objectSpread(_objectSpread({}, state), {}, {
52
- showStatusPickerAt: showStatusPickerAt
53
- });
54
- if (_newState.showStatusPickerAt !== state.showStatusPickerAt) {
55
- pmPluginFactoryParams.dispatch(_pluginKey.pluginKey, _newState);
56
- return _newState;
57
- }
58
- }
59
- if (tr.selectionSet) {
60
- // Change in selection, while status picker was open, update state, if required.
61
- var selectionFrom = tr.selection.from;
62
- var nodeAtSelection = tr.doc.nodeAt(selectionFrom);
63
- var _showStatusPickerAt = null;
64
- if (nodeAtSelection && nodeAtSelection.type === oldEditorState.schema.nodes.status && tr.selection instanceof _state.NodeSelection) {
65
- _showStatusPickerAt = selectionFrom;
66
- }
67
- if (_showStatusPickerAt !== state.showStatusPickerAt) {
68
- var _newState2 = _objectSpread(_objectSpread({}, state), {}, {
69
- isNew: false,
70
- showStatusPickerAt: _showStatusPickerAt
71
- });
72
- pmPluginFactoryParams.dispatch(_pluginKey.pluginKey, _newState2);
73
- return _newState2;
74
- }
75
- }
76
- return state;
77
- }
78
- },
79
- filterTransaction: function filterTransaction(tr, state) {
80
- // if it is a selection change transaction, and selection changes from node to text
81
- if (tr.selectionSet && !tr.steps.length && tr.isGeneric && tr.selection instanceof _state.TextSelection && state.selection instanceof _state.NodeSelection) {
82
- var _ref = _pluginKey.pluginKey.getState(state) || {},
83
- isNew = _ref.isNew,
84
- showStatusPickerAt = _ref.showStatusPickerAt;
85
- var nodeAtSelection = tr.doc.nodeAt(tr.selection.from);
86
- // prevent changing node selection to text selection on dom change right after inserting status
87
- // if newly selected status is selected with status picker opened
88
- if (isNew && showStatusPickerAt && nodeAtSelection && nodeAtSelection.type === state.schema.nodes.status) {
89
- return false;
90
- }
91
- }
92
- return true;
93
- },
94
- appendTransaction: function appendTransaction(transactions, oldEditorState, newEditorState) {
95
- var changed = false;
96
- var tr = newEditorState.tr;
97
-
98
- /**
99
- * When user start creating status, and, when users navigates away
100
- * while empty, then we want to remove empty ("set a status") status.
101
- * But when transaction to add empty status happens from undo/redo
102
- * we don't want to remove it.
103
- */
104
- if (transactions.find(function (tr) {
105
- return tr.selectionSet && !tr.getMeta(_utils.pmHistoryPluginKey);
106
- })) {
107
- var oldStatus = (0, _utils2.mayGetStatusAtSelection)(oldEditorState.selection);
108
- var newStatus = (0, _utils2.mayGetStatusAtSelection)(newEditorState.selection);
109
- if (oldStatus && (newStatus && oldStatus.localId !== newStatus.localId || !newStatus)) {
110
- if ((0, _utils2.isEmptyStatus)(oldStatus)) {
111
- var pos = oldEditorState.selection.from;
112
- tr.delete(tr.mapping.map(pos), tr.mapping.map(pos + 1));
113
- changed = true;
114
- }
115
- }
116
- }
117
- return changed ? tr : undefined;
118
- },
119
- key: _pluginKey.pluginKey,
120
- props: {
121
- nodeViews: {
122
- status: (0, _reactNodeView.getInlineNodeViewProducer)({
123
- pmPluginFactoryParams: pmPluginFactoryParams,
124
- Component: _status.StatusNodeView,
125
- extraComponentProps: {
126
- options: options
127
- }
128
- })
129
- }
130
- }
131
- });
132
- };
133
- var _default = exports.default = createPlugin;
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1,314 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = exports.closingMethods = exports.StatusPickerWithoutAnalytcs = exports.InputMethod = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
11
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
16
- var _react = _interopRequireDefault(require("react"));
17
- var _react2 = require("@emotion/react");
18
- var _analyticsNext = require("@atlaskit/analytics-next");
19
- var _ui = require("@atlaskit/editor-common/ui");
20
- var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
21
- var _picker = require("@atlaskit/status/picker");
22
- var _constants = require("@atlaskit/theme/constants");
23
- var _colors = require("@atlaskit/theme/colors");
24
- var _uiReact = require("@atlaskit/editor-common/ui-react");
25
- var _actions = require("../actions");
26
- var _analytics = require("../analytics");
27
- var _templateObject;
28
- /** @jsx jsx */
29
- 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); }; }
30
- 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; } }
31
- var PopupWithListeners = (0, _uiReact.withReactEditorViewOuterListeners)(_ui.Popup);
32
- var InputMethod = exports.InputMethod = /*#__PURE__*/function (InputMethod) {
33
- InputMethod["blur"] = "blur";
34
- InputMethod["escKey"] = "escKey";
35
- InputMethod["enterKey"] = "enterKey";
36
- return InputMethod;
37
- }({});
38
- var closingMethods = exports.closingMethods = /*#__PURE__*/function (closingMethods) {
39
- closingMethods["ArrowLeft"] = "arrowLeft";
40
- closingMethods["ArrowRight"] = "arrowRight";
41
- return closingMethods;
42
- }({});
43
- var pickerContainer = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n background: ", ";\n padding: ", " 0;\n border-radius: ", "px;\n box-shadow: ", ";\n :focus {\n outline: none;\n }\n input {\n text-transform: uppercase;\n }\n"])), "var(--ds-surface-overlay, ".concat(_colors.N0, ")"), "var(--ds-space-100, 8px)", (0, _constants.borderRadius)(), "var(--ds-shadow-overlay, 0 0 1px rgba(9, 30, 66, 0.31), 0 4px 8px -2px rgba(9, 30, 66, 0.25))");
44
- var StatusPickerWithoutAnalytcs = exports.StatusPickerWithoutAnalytcs = /*#__PURE__*/function (_React$Component) {
45
- (0, _inherits2.default)(StatusPickerWithoutAnalytcs, _React$Component);
46
- var _super = _createSuper(StatusPickerWithoutAnalytcs);
47
- function StatusPickerWithoutAnalytcs(props) {
48
- var _this;
49
- (0, _classCallCheck2.default)(this, StatusPickerWithoutAnalytcs);
50
- _this = _super.call(this, props);
51
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleClickOutside", function (event) {
52
- event.preventDefault();
53
- _this.inputMethod = InputMethod.blur;
54
- var selectedText = window.getSelection();
55
- if (!selectedText) {
56
- _this.props.closeStatusPicker();
57
- }
58
- });
59
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleEscapeKeydown", function (event) {
60
- event.preventDefault();
61
- _this.inputMethod = InputMethod.escKey;
62
- _this.props.onEnter(_this.state);
63
- });
64
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleTabPress", function (event) {
65
- var colorButtons = event.currentTarget.querySelectorAll('button');
66
- var inputField = event.currentTarget.querySelector('input');
67
- var isInputFocussed = document.activeElement === inputField;
68
- var isButtonFocussed = Array.from(colorButtons).some(function (buttonElement) {
69
- var _document;
70
- return ((_document = document) === null || _document === void 0 ? void 0 : _document.activeElement) === buttonElement;
71
- });
72
- if (event !== null && event !== void 0 && event.shiftKey) {
73
- /* shift + tab */
74
- if (isInputFocussed) {
75
- colorButtons[0].focus();
76
- event.preventDefault();
77
- }
78
- /* After the user presses shift + tab the color-palette component updates tab index for the first color to be 0.
79
- To correctly set focus to the input field instead of the first color button we need to set focus manually
80
- */
81
- if (isButtonFocussed) {
82
- inputField === null || inputField === void 0 || inputField.focus();
83
- event.preventDefault();
84
- }
85
- } else {
86
- /* tab */
87
- if (isButtonFocussed) {
88
- inputField === null || inputField === void 0 || inputField.focus();
89
- event.preventDefault();
90
- }
91
- }
92
- });
93
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleArrow", function (event, closingMethod) {
94
- var _document2;
95
- if (((_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.activeElement) === _this.popupBodyWrapper.current) {
96
- var _this$popupBodyWrappe;
97
- event.preventDefault();
98
- (_this$popupBodyWrappe = _this.popupBodyWrapper) === null || _this$popupBodyWrappe === void 0 || (_this$popupBodyWrappe = _this$popupBodyWrappe.current) === null || _this$popupBodyWrappe === void 0 || _this$popupBodyWrappe.blur();
99
- _this.props.closeStatusPicker({
100
- closingMethod: closingMethod
101
- });
102
- }
103
- });
104
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onKeyDown", function (event) {
105
- var isTabPressed = event.key === 'Tab';
106
- if (isTabPressed) {
107
- return _this.handleTabPress(event);
108
- }
109
- if (event.key in closingMethods) {
110
- return _this.handleArrow(event, closingMethods[event.key]);
111
- }
112
- });
113
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onColorHover", function (color) {
114
- _this.createStatusAnalyticsAndFireFunc({
115
- action: 'hovered',
116
- actionSubject: 'statusColorPicker',
117
- attributes: {
118
- color: color,
119
- localId: _this.state.localId,
120
- state: (0, _analytics.analyticsState)(_this.props.isNew)
121
- }
122
- });
123
- });
124
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onColorClick", function (color) {
125
- var _this$state = _this.state,
126
- text = _this$state.text,
127
- localId = _this$state.localId;
128
- if (color === _this.state.color) {
129
- _this.createStatusAnalyticsAndFireFunc({
130
- action: 'clicked',
131
- actionSubject: 'statusColorPicker',
132
- attributes: {
133
- color: color,
134
- localId: localId,
135
- state: (0, _analytics.analyticsState)(_this.props.isNew)
136
- }
137
- });
138
- // closes status box and commits colour
139
- _this.onEnter();
140
- } else {
141
- _this.setState({
142
- color: color
143
- });
144
- _this.props.onSelect({
145
- text: text,
146
- color: color,
147
- localId: localId
148
- });
149
- }
150
- });
151
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onTextChanged", function (text) {
152
- var _this$state2 = _this.state,
153
- color = _this$state2.color,
154
- localId = _this$state2.localId;
155
- _this.setState({
156
- text: text
157
- });
158
- _this.props.onTextChanged({
159
- text: text,
160
- color: color,
161
- localId: localId
162
- }, !!_this.props.isNew);
163
- });
164
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onEnter", function () {
165
- _this.inputMethod = InputMethod.enterKey;
166
- _this.props.onEnter(_this.state);
167
- });
168
- // cancel bubbling to fix clickOutside logic:
169
- // popup re-renders its content before the click event bubbles up to the document
170
- // therefore click target element would be different from the popup content
171
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handlePopupClick", function (event) {
172
- return event.nativeEvent.stopImmediatePropagation();
173
- });
174
- _this.state = _this.extractStateFromProps(props);
175
- _this.createStatusAnalyticsAndFireFunc = (0, _analytics.createStatusAnalyticsAndFire)(props.createAnalyticsEvent);
176
- _this.popupBodyWrapper = /*#__PURE__*/_react.default.createRef();
177
- return _this;
178
- }
179
- (0, _createClass2.default)(StatusPickerWithoutAnalytcs, [{
180
- key: "fireStatusPopupOpenedAnalytics",
181
- value: function fireStatusPopupOpenedAnalytics(state) {
182
- var color = state.color,
183
- text = state.text,
184
- localId = state.localId,
185
- isNew = state.isNew;
186
- this.startTime = Date.now();
187
- this.createStatusAnalyticsAndFireFunc({
188
- action: 'opened',
189
- actionSubject: 'statusPopup',
190
- attributes: {
191
- textLength: text ? text.length : 0,
192
- selectedColor: color,
193
- localId: localId,
194
- state: (0, _analytics.analyticsState)(isNew)
195
- }
196
- });
197
- }
198
- }, {
199
- key: "fireStatusPopupClosedAnalytics",
200
- value: function fireStatusPopupClosedAnalytics(state) {
201
- var color = state.color,
202
- text = state.text,
203
- localId = state.localId,
204
- isNew = state.isNew;
205
- this.createStatusAnalyticsAndFireFunc({
206
- action: 'closed',
207
- actionSubject: 'statusPopup',
208
- attributes: {
209
- inputMethod: this.inputMethod,
210
- duration: Date.now() - this.startTime,
211
- textLength: text ? text.length : 0,
212
- selectedColor: color,
213
- localId: localId,
214
- state: (0, _analytics.analyticsState)(isNew)
215
- }
216
- });
217
- }
218
- }, {
219
- key: "reset",
220
- value: function reset() {
221
- this.startTime = Date.now();
222
- this.inputMethod = InputMethod.blur;
223
- }
224
- }, {
225
- key: "componentDidMount",
226
- value: function componentDidMount() {
227
- var _this2 = this;
228
- this.reset();
229
- this.fireStatusPopupOpenedAnalytics(this.state);
230
- if (typeof this.props.isNew === 'boolean' && this.props.isNew === false) {
231
- // Wrapper should be focused only if status already exists otherwise input field will receive focus
232
- this.focusTimeout = requestAnimationFrame(function () {
233
- var _this2$popupBodyWrapp;
234
- // Defer to prevent editor scrolling to top. See https://product-fabric.atlassian.net/browse/DTR-1952
235
- (_this2$popupBodyWrapp = _this2.popupBodyWrapper) === null || _this2$popupBodyWrapp === void 0 || (_this2$popupBodyWrapp = _this2$popupBodyWrapp.current) === null || _this2$popupBodyWrapp === void 0 || _this2$popupBodyWrapp.focus();
236
- });
237
- }
238
- }
239
- }, {
240
- key: "componentWillUnmount",
241
- value: function componentWillUnmount() {
242
- this.focusTimeout && cancelAnimationFrame(this.focusTimeout);
243
- this.fireStatusPopupClosedAnalytics(this.state);
244
- this.startTime = 0;
245
- }
246
- }, {
247
- key: "componentDidUpdate",
248
- value: function componentDidUpdate(prevProps, prevState, _snapshot) {
249
- var element = this.props.target;
250
- if (prevProps.target !== element) {
251
- var newState = this.extractStateFromProps(this.props);
252
- this.setState(newState);
253
- this.fireStatusPopupClosedAnalytics(prevState);
254
- this.reset();
255
- this.fireStatusPopupOpenedAnalytics(newState);
256
- }
257
- }
258
- }, {
259
- key: "extractStateFromProps",
260
- value: function extractStateFromProps(props) {
261
- var defaultColor = props.defaultColor,
262
- defaultText = props.defaultText,
263
- defaultLocalId = props.defaultLocalId,
264
- isNew = props.isNew;
265
- return {
266
- color: defaultColor || _actions.DEFAULT_STATUS.color,
267
- text: defaultText || _actions.DEFAULT_STATUS.text,
268
- localId: defaultLocalId,
269
- isNew: isNew
270
- };
271
- }
272
- }, {
273
- key: "render",
274
- value: function render() {
275
- var _this$props = this.props,
276
- isNew = _this$props.isNew,
277
- target = _this$props.target,
278
- mountTo = _this$props.mountTo,
279
- boundariesElement = _this$props.boundariesElement,
280
- scrollableElement = _this$props.scrollableElement;
281
- var _this$state3 = this.state,
282
- color = _this$state3.color,
283
- text = _this$state3.text;
284
- return target && (0, _react2.jsx)(PopupWithListeners, {
285
- target: target,
286
- offset: [0, 8],
287
- handleClickOutside: this.handleClickOutside,
288
- handleEscapeKeydown: this.handleEscapeKeydown,
289
- zIndex: _editorSharedStyles.akEditorFloatingDialogZIndex,
290
- fitHeight: 40,
291
- mountTo: mountTo,
292
- boundariesElement: boundariesElement,
293
- scrollableElement: scrollableElement,
294
- closeOnTab: false
295
- }, (0, _react2.jsx)("div", {
296
- css: pickerContainer,
297
- tabIndex: -1,
298
- ref: this.popupBodyWrapper,
299
- onClick: this.handlePopupClick,
300
- onKeyDown: this.onKeyDown
301
- }, (0, _react2.jsx)(_picker.StatusPicker, {
302
- autoFocus: isNew,
303
- selectedColor: color,
304
- text: text,
305
- onColorClick: this.onColorClick,
306
- onColorHover: this.onColorHover,
307
- onTextChanged: this.onTextChanged,
308
- onEnter: this.onEnter
309
- })));
310
- }
311
- }]);
312
- return StatusPickerWithoutAnalytcs;
313
- }(_react.default.Component);
314
- var _default = exports.default = (0, _analyticsNext.withAnalyticsEvents)()(StatusPickerWithoutAnalytcs);
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.setNodeSelectionNearPos = exports.mayGetStatusAtSelection = exports.isEmptyStatus = void 0;
7
- var _state = require("@atlaskit/editor-prosemirror/state");
8
- var mayGetStatusAtSelection = exports.mayGetStatusAtSelection = function mayGetStatusAtSelection(selection) {
9
- if (selection && selection instanceof _state.NodeSelection) {
10
- var nodeSelection = selection;
11
- if (nodeSelection.node.type.name === 'status') {
12
- return selection.node.attrs || null;
13
- }
14
- }
15
- return null;
16
- };
17
- var isEmptyStatus = exports.isEmptyStatus = function isEmptyStatus(node) {
18
- return node && (node.text && node.text.trim().length === 0 || node.text === '');
19
- };
20
- var setNodeSelectionNearPos = exports.setNodeSelectionNearPos = function setNodeSelectionNearPos(tr, pos) {
21
- return tr.setSelection(_state.NodeSelection.create(tr.doc, tr.mapping.map(pos)));
22
- };