@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,293 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- /** @jsx jsx */
3
-
4
- import React from 'react';
5
- import { css, jsx } from '@emotion/react';
6
- import { withAnalyticsEvents } from '@atlaskit/analytics-next';
7
- import { Popup } from '@atlaskit/editor-common/ui';
8
- import { akEditorFloatingDialogZIndex } from '@atlaskit/editor-shared-styles';
9
- import { StatusPicker as AkStatusPicker } from '@atlaskit/status/picker';
10
- import { borderRadius } from '@atlaskit/theme/constants';
11
- import { N0 } from '@atlaskit/theme/colors';
12
- import { withReactEditorViewOuterListeners as withOuterListeners } from '@atlaskit/editor-common/ui-react';
13
- import { DEFAULT_STATUS } from '../actions';
14
- import { analyticsState, createStatusAnalyticsAndFire } from '../analytics';
15
- const PopupWithListeners = withOuterListeners(Popup);
16
- export let InputMethod = /*#__PURE__*/function (InputMethod) {
17
- InputMethod["blur"] = "blur";
18
- InputMethod["escKey"] = "escKey";
19
- InputMethod["enterKey"] = "enterKey";
20
- return InputMethod;
21
- }({});
22
- export let closingMethods = /*#__PURE__*/function (closingMethods) {
23
- closingMethods["ArrowLeft"] = "arrowLeft";
24
- closingMethods["ArrowRight"] = "arrowRight";
25
- return closingMethods;
26
- }({});
27
- const pickerContainer = css`
28
- background: ${`var(--ds-surface-overlay, ${N0})`};
29
- padding: ${"var(--ds-space-100, 8px)"} 0;
30
- border-radius: ${borderRadius()}px;
31
- box-shadow: ${"var(--ds-shadow-overlay, 0 0 1px rgba(9, 30, 66, 0.31), 0 4px 8px -2px rgba(9, 30, 66, 0.25))"};
32
- :focus {
33
- outline: none;
34
- }
35
- input {
36
- text-transform: uppercase;
37
- }
38
- `;
39
- export class StatusPickerWithoutAnalytcs extends React.Component {
40
- constructor(props) {
41
- super(props);
42
- _defineProperty(this, "handleClickOutside", event => {
43
- event.preventDefault();
44
- this.inputMethod = InputMethod.blur;
45
- const selectedText = window.getSelection();
46
- if (!selectedText) {
47
- this.props.closeStatusPicker();
48
- }
49
- });
50
- _defineProperty(this, "handleEscapeKeydown", event => {
51
- event.preventDefault();
52
- this.inputMethod = InputMethod.escKey;
53
- this.props.onEnter(this.state);
54
- });
55
- _defineProperty(this, "handleTabPress", event => {
56
- const colorButtons = event.currentTarget.querySelectorAll('button');
57
- const inputField = event.currentTarget.querySelector('input');
58
- const isInputFocussed = document.activeElement === inputField;
59
- const isButtonFocussed = Array.from(colorButtons).some(buttonElement => {
60
- var _document;
61
- return ((_document = document) === null || _document === void 0 ? void 0 : _document.activeElement) === buttonElement;
62
- });
63
- if (event !== null && event !== void 0 && event.shiftKey) {
64
- /* shift + tab */
65
- if (isInputFocussed) {
66
- colorButtons[0].focus();
67
- event.preventDefault();
68
- }
69
- /* After the user presses shift + tab the color-palette component updates tab index for the first color to be 0.
70
- To correctly set focus to the input field instead of the first color button we need to set focus manually
71
- */
72
- if (isButtonFocussed) {
73
- inputField === null || inputField === void 0 ? void 0 : inputField.focus();
74
- event.preventDefault();
75
- }
76
- } else {
77
- /* tab */
78
- if (isButtonFocussed) {
79
- inputField === null || inputField === void 0 ? void 0 : inputField.focus();
80
- event.preventDefault();
81
- }
82
- }
83
- });
84
- _defineProperty(this, "handleArrow", (event, closingMethod) => {
85
- var _document2;
86
- if (((_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.activeElement) === this.popupBodyWrapper.current) {
87
- var _this$popupBodyWrappe, _this$popupBodyWrappe2;
88
- event.preventDefault();
89
- (_this$popupBodyWrappe = this.popupBodyWrapper) === null || _this$popupBodyWrappe === void 0 ? void 0 : (_this$popupBodyWrappe2 = _this$popupBodyWrappe.current) === null || _this$popupBodyWrappe2 === void 0 ? void 0 : _this$popupBodyWrappe2.blur();
90
- this.props.closeStatusPicker({
91
- closingMethod
92
- });
93
- }
94
- });
95
- _defineProperty(this, "onKeyDown", event => {
96
- const isTabPressed = event.key === 'Tab';
97
- if (isTabPressed) {
98
- return this.handleTabPress(event);
99
- }
100
- if (event.key in closingMethods) {
101
- return this.handleArrow(event, closingMethods[event.key]);
102
- }
103
- });
104
- _defineProperty(this, "onColorHover", color => {
105
- this.createStatusAnalyticsAndFireFunc({
106
- action: 'hovered',
107
- actionSubject: 'statusColorPicker',
108
- attributes: {
109
- color,
110
- localId: this.state.localId,
111
- state: analyticsState(this.props.isNew)
112
- }
113
- });
114
- });
115
- _defineProperty(this, "onColorClick", color => {
116
- const {
117
- text,
118
- localId
119
- } = this.state;
120
- if (color === this.state.color) {
121
- this.createStatusAnalyticsAndFireFunc({
122
- action: 'clicked',
123
- actionSubject: 'statusColorPicker',
124
- attributes: {
125
- color,
126
- localId,
127
- state: analyticsState(this.props.isNew)
128
- }
129
- });
130
- // closes status box and commits colour
131
- this.onEnter();
132
- } else {
133
- this.setState({
134
- color
135
- });
136
- this.props.onSelect({
137
- text,
138
- color,
139
- localId
140
- });
141
- }
142
- });
143
- _defineProperty(this, "onTextChanged", text => {
144
- const {
145
- color,
146
- localId
147
- } = this.state;
148
- this.setState({
149
- text
150
- });
151
- this.props.onTextChanged({
152
- text,
153
- color,
154
- localId
155
- }, !!this.props.isNew);
156
- });
157
- _defineProperty(this, "onEnter", () => {
158
- this.inputMethod = InputMethod.enterKey;
159
- this.props.onEnter(this.state);
160
- });
161
- // cancel bubbling to fix clickOutside logic:
162
- // popup re-renders its content before the click event bubbles up to the document
163
- // therefore click target element would be different from the popup content
164
- _defineProperty(this, "handlePopupClick", event => event.nativeEvent.stopImmediatePropagation());
165
- this.state = this.extractStateFromProps(props);
166
- this.createStatusAnalyticsAndFireFunc = createStatusAnalyticsAndFire(props.createAnalyticsEvent);
167
- this.popupBodyWrapper = /*#__PURE__*/React.createRef();
168
- }
169
- fireStatusPopupOpenedAnalytics(state) {
170
- const {
171
- color,
172
- text,
173
- localId,
174
- isNew
175
- } = state;
176
- this.startTime = Date.now();
177
- this.createStatusAnalyticsAndFireFunc({
178
- action: 'opened',
179
- actionSubject: 'statusPopup',
180
- attributes: {
181
- textLength: text ? text.length : 0,
182
- selectedColor: color,
183
- localId,
184
- state: analyticsState(isNew)
185
- }
186
- });
187
- }
188
- fireStatusPopupClosedAnalytics(state) {
189
- const {
190
- color,
191
- text,
192
- localId,
193
- isNew
194
- } = state;
195
- this.createStatusAnalyticsAndFireFunc({
196
- action: 'closed',
197
- actionSubject: 'statusPopup',
198
- attributes: {
199
- inputMethod: this.inputMethod,
200
- duration: Date.now() - this.startTime,
201
- textLength: text ? text.length : 0,
202
- selectedColor: color,
203
- localId,
204
- state: analyticsState(isNew)
205
- }
206
- });
207
- }
208
- reset() {
209
- this.startTime = Date.now();
210
- this.inputMethod = InputMethod.blur;
211
- }
212
- componentDidMount() {
213
- this.reset();
214
- this.fireStatusPopupOpenedAnalytics(this.state);
215
- if (typeof this.props.isNew === 'boolean' && this.props.isNew === false) {
216
- // Wrapper should be focused only if status already exists otherwise input field will receive focus
217
- this.focusTimeout = requestAnimationFrame(() => {
218
- var _this$popupBodyWrappe3, _this$popupBodyWrappe4;
219
- // Defer to prevent editor scrolling to top. See https://product-fabric.atlassian.net/browse/DTR-1952
220
- (_this$popupBodyWrappe3 = this.popupBodyWrapper) === null || _this$popupBodyWrappe3 === void 0 ? void 0 : (_this$popupBodyWrappe4 = _this$popupBodyWrappe3.current) === null || _this$popupBodyWrappe4 === void 0 ? void 0 : _this$popupBodyWrappe4.focus();
221
- });
222
- }
223
- }
224
- componentWillUnmount() {
225
- this.focusTimeout && cancelAnimationFrame(this.focusTimeout);
226
- this.fireStatusPopupClosedAnalytics(this.state);
227
- this.startTime = 0;
228
- }
229
- componentDidUpdate(prevProps, prevState, _snapshot) {
230
- const element = this.props.target;
231
- if (prevProps.target !== element) {
232
- const newState = this.extractStateFromProps(this.props);
233
- this.setState(newState);
234
- this.fireStatusPopupClosedAnalytics(prevState);
235
- this.reset();
236
- this.fireStatusPopupOpenedAnalytics(newState);
237
- }
238
- }
239
- extractStateFromProps(props) {
240
- const {
241
- defaultColor,
242
- defaultText,
243
- defaultLocalId,
244
- isNew
245
- } = props;
246
- return {
247
- color: defaultColor || DEFAULT_STATUS.color,
248
- text: defaultText || DEFAULT_STATUS.text,
249
- localId: defaultLocalId,
250
- isNew
251
- };
252
- }
253
- render() {
254
- const {
255
- isNew,
256
- target,
257
- mountTo,
258
- boundariesElement,
259
- scrollableElement
260
- } = this.props;
261
- const {
262
- color,
263
- text
264
- } = this.state;
265
- return target && jsx(PopupWithListeners, {
266
- target: target,
267
- offset: [0, 8],
268
- handleClickOutside: this.handleClickOutside,
269
- handleEscapeKeydown: this.handleEscapeKeydown,
270
- zIndex: akEditorFloatingDialogZIndex,
271
- fitHeight: 40,
272
- mountTo: mountTo,
273
- boundariesElement: boundariesElement,
274
- scrollableElement: scrollableElement,
275
- closeOnTab: false
276
- }, jsx("div", {
277
- css: pickerContainer,
278
- tabIndex: -1,
279
- ref: this.popupBodyWrapper,
280
- onClick: this.handlePopupClick,
281
- onKeyDown: this.onKeyDown
282
- }, jsx(AkStatusPicker, {
283
- autoFocus: isNew,
284
- selectedColor: color,
285
- text: text,
286
- onColorClick: this.onColorClick,
287
- onColorHover: this.onColorHover,
288
- onTextChanged: this.onTextChanged,
289
- onEnter: this.onEnter
290
- })));
291
- }
292
- }
293
- export default withAnalyticsEvents()(StatusPickerWithoutAnalytcs);
@@ -1,12 +0,0 @@
1
- import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
2
- export const mayGetStatusAtSelection = selection => {
3
- if (selection && selection instanceof NodeSelection) {
4
- const nodeSelection = selection;
5
- if (nodeSelection.node.type.name === 'status') {
6
- return selection.node.attrs || null;
7
- }
8
- }
9
- return null;
10
- };
11
- export const isEmptyStatus = node => node && (node.text && node.text.trim().length === 0 || node.text === '');
12
- export const setNodeSelectionNearPos = (tr, pos) => tr.setSelection(NodeSelection.create(tr.doc, tr.mapping.map(pos)));