@atlaskit/editor-plugin-date 7.2.0 → 7.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/editor-plugin-date
2
2
 
3
+ ## 7.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 7.2.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`34d0a1168dab6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/34d0a1168dab6) -
14
+ Hydration fixes for date plugin ContentComponent
15
+ - Updated dependencies
16
+
3
17
  ## 7.2.0
4
18
 
5
19
  ### Minor Changes
@@ -19,6 +19,7 @@ var _utils = require("@atlaskit/editor-common/utils");
19
19
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
20
20
  var _comment = _interopRequireDefault(require("@atlaskit/icon/core/comment"));
21
21
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
22
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
22
23
  var _actions = require("./pm-plugins/actions");
23
24
  var _commands = require("./pm-plugins/commands");
24
25
  var _keymap = _interopRequireDefault(require("./pm-plugins/keymap"));
@@ -37,6 +38,20 @@ var DatePicker = (0, _reactLoadable.default)({
37
38
  return null;
38
39
  }
39
40
  });
41
+ function getDateNode(editorView, showDatePickerAt) {
42
+ if (!editorView) {
43
+ return null;
44
+ }
45
+ var domAtPos = editorView.domAtPos.bind(editorView);
46
+
47
+ // Ignored via go/ees005
48
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
49
+ var element = (0, _utils2.findDomRefAtPos)(showDatePickerAt, domAtPos);
50
+
51
+ // Resolves ED-23702 for when the date is wrapped in an inline comment
52
+ var dateNode = element !== null && element !== void 0 && element.classList.contains(_styles.DateSharedCssClassName.DATE_CONTAINER) ? element : element === null || element === void 0 ? void 0 : element.querySelector(".".concat(_styles.DateSharedCssClassName.DATE_CONTAINER));
53
+ return dateNode || element;
54
+ }
40
55
  function ContentComponent(_ref) {
41
56
  var editorView = _ref.editorView,
42
57
  dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
@@ -45,8 +60,6 @@ function ContentComponent(_ref) {
45
60
  popupsScrollableElement = _ref.popupsScrollableElement,
46
61
  dependencyApi = _ref.dependencyApi,
47
62
  weekStartDay = _ref.weekStartDay;
48
- var dispatch = editorView.dispatch;
49
- var domAtPos = editorView.domAtPos.bind(editorView);
50
63
  var _useSharedPluginState = (0, _hooks.useSharedPluginState)(dependencyApi, ['date', 'editorDisabled']),
51
64
  editorDisabledState = _useSharedPluginState.editorDisabledState,
52
65
  dateState = _useSharedPluginState.dateState;
@@ -56,25 +69,22 @@ function ContentComponent(_ref) {
56
69
  var showDatePickerAt = dateState.showDatePickerAt,
57
70
  isNew = dateState.isNew,
58
71
  focusDateInput = dateState.focusDateInput;
59
-
60
- // Ignored via go/ees005
61
- // eslint-disable-next-line @atlaskit/editor/no-as-casting
62
- var element = (0, _utils2.findDomRefAtPos)(showDatePickerAt, domAtPos);
63
-
64
- // Resolves ED-23702 for when the date is wrapped in an inline comment
65
- var dateNode = element !== null && element !== void 0 && element.classList.contains(_styles.DateSharedCssClassName.DATE_CONTAINER) ? element : element === null || element === void 0 ? void 0 : element.querySelector(".".concat(_styles.DateSharedCssClassName.DATE_CONTAINER));
72
+ var dateNode = getDateNode(editorView, showDatePickerAt);
66
73
  return /*#__PURE__*/_react.default.createElement(DatePicker, {
67
74
  mountTo: popupsMountPoint,
68
75
  boundariesElement: popupsBoundariesElement,
69
76
  scrollableElement: popupsScrollableElement,
70
77
  key: showDatePickerAt,
71
- element: dateNode || element,
78
+ element: dateNode,
72
79
  isNew: isNew,
73
80
  autoFocus: focusDateInput,
74
81
  onDelete: function onDelete() {
75
82
  var _dependencyApi$core;
83
+ if ((0, _expValEquals.expValEquals)('platform_editor_hydratable_ui', 'isEnabled', true) && !editorView) {
84
+ return;
85
+ }
76
86
  dependencyApi === null || dependencyApi === void 0 || (_dependencyApi$core = dependencyApi.core) === null || _dependencyApi$core === void 0 || _dependencyApi$core.actions.execute((0, _commands.deleteDateCommand)(dependencyApi));
77
- editorView.focus();
87
+ editorView === null || editorView === void 0 || editorView.focus();
78
88
  },
79
89
  onSelect: function onSelect(date, commitMethod) {
80
90
  var _dependencyApi$core2;
@@ -82,11 +92,14 @@ function ContentComponent(_ref) {
82
92
  if (date === undefined || date === null) {
83
93
  return;
84
94
  }
95
+ if ((0, _expValEquals.expValEquals)('platform_editor_hydratable_ui', 'isEnabled', true) && !editorView) {
96
+ return;
97
+ }
85
98
  dependencyApi === null || dependencyApi === void 0 || (_dependencyApi$core2 = dependencyApi.core) === null || _dependencyApi$core2 === void 0 || _dependencyApi$core2.actions.execute((0, _commands.insertDateCommand)(dependencyApi)({
86
99
  date: date,
87
100
  commitMethod: commitMethod
88
101
  }));
89
- editorView.focus();
102
+ editorView === null || editorView === void 0 || editorView.focus();
90
103
  },
91
104
  onTextChanged: function onTextChanged(date) {
92
105
  var _dependencyApi$core3;
@@ -96,14 +109,20 @@ function ContentComponent(_ref) {
96
109
  }));
97
110
  },
98
111
  closeDatePicker: function closeDatePicker() {
99
- (0, _actions.closeDatePicker)()(editorView.state, dispatch);
100
- editorView.focus();
112
+ if (!editorView) {
113
+ return;
114
+ }
115
+ (0, _actions.closeDatePicker)()(editorView.state, editorView.dispatch);
116
+ editorView === null || editorView === void 0 || editorView.focus();
101
117
  },
102
118
  closeDatePickerWithAnalytics: function closeDatePickerWithAnalytics(_ref2) {
103
119
  var date = _ref2.date;
120
+ if (!editorView) {
121
+ return;
122
+ }
104
123
  (0, _actions.closeDatePickerWithAnalytics)({
105
124
  date: date
106
- })(editorView.state, dispatch);
125
+ })(editorView.state, editorView.dispatch);
107
126
  editorView.focus();
108
127
  },
109
128
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
@@ -1,4 +1,4 @@
1
- /* date-picker-input.tsx generated by @compiled/babel-plugin v0.38.1 */
1
+ /* date-picker-input.tsx generated by @compiled/babel-plugin v0.36.1 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -1,4 +1,4 @@
1
- /* index.tsx generated by @compiled/babel-plugin v0.38.1 */
1
+ /* index.tsx generated by @compiled/babel-plugin v0.36.1 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -11,6 +11,7 @@ import { calculateToolbarPositionAboveSelection } from '@atlaskit/editor-common/
11
11
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
12
12
  import CommentIcon from '@atlaskit/icon/core/comment';
13
13
  import { fg } from '@atlaskit/platform-feature-flags';
14
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
14
15
  import { closeDatePicker, closeDatePickerWithAnalytics, createDate } from './pm-plugins/actions';
15
16
  import { deleteDateCommand, insertDateCommand } from './pm-plugins/commands';
16
17
  import keymap from './pm-plugins/keymap';
@@ -20,6 +21,20 @@ const DatePicker = Loadable({
20
21
  loader: () => import( /* webpackChunkName: "@atlaskit-internal_editor-datepicker" */'./ui/DatePicker').then(mod => mod.default),
21
22
  loading: () => null
22
23
  });
24
+ function getDateNode(editorView, showDatePickerAt) {
25
+ if (!editorView) {
26
+ return null;
27
+ }
28
+ const domAtPos = editorView.domAtPos.bind(editorView);
29
+
30
+ // Ignored via go/ees005
31
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
32
+ const element = findDomRefAtPos(showDatePickerAt, domAtPos);
33
+
34
+ // Resolves ED-23702 for when the date is wrapped in an inline comment
35
+ const dateNode = element !== null && element !== void 0 && element.classList.contains(DateSharedCssClassName.DATE_CONTAINER) ? element : element === null || element === void 0 ? void 0 : element.querySelector(`.${DateSharedCssClassName.DATE_CONTAINER}`);
36
+ return dateNode || element;
37
+ }
23
38
  function ContentComponent({
24
39
  editorView,
25
40
  dispatchAnalyticsEvent,
@@ -29,10 +44,6 @@ function ContentComponent({
29
44
  dependencyApi,
30
45
  weekStartDay
31
46
  }) {
32
- const {
33
- dispatch
34
- } = editorView;
35
- const domAtPos = editorView.domAtPos.bind(editorView);
36
47
  const {
37
48
  editorDisabledState,
38
49
  dateState
@@ -45,25 +56,22 @@ function ContentComponent({
45
56
  isNew,
46
57
  focusDateInput
47
58
  } = dateState;
48
-
49
- // Ignored via go/ees005
50
- // eslint-disable-next-line @atlaskit/editor/no-as-casting
51
- const element = findDomRefAtPos(showDatePickerAt, domAtPos);
52
-
53
- // Resolves ED-23702 for when the date is wrapped in an inline comment
54
- const dateNode = element !== null && element !== void 0 && element.classList.contains(DateSharedCssClassName.DATE_CONTAINER) ? element : element === null || element === void 0 ? void 0 : element.querySelector(`.${DateSharedCssClassName.DATE_CONTAINER}`);
59
+ const dateNode = getDateNode(editorView, showDatePickerAt);
55
60
  return /*#__PURE__*/React.createElement(DatePicker, {
56
61
  mountTo: popupsMountPoint,
57
62
  boundariesElement: popupsBoundariesElement,
58
63
  scrollableElement: popupsScrollableElement,
59
64
  key: showDatePickerAt,
60
- element: dateNode || element,
65
+ element: dateNode,
61
66
  isNew: isNew,
62
67
  autoFocus: focusDateInput,
63
68
  onDelete: () => {
64
69
  var _dependencyApi$core;
70
+ if (expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) && !editorView) {
71
+ return;
72
+ }
65
73
  dependencyApi === null || dependencyApi === void 0 ? void 0 : (_dependencyApi$core = dependencyApi.core) === null || _dependencyApi$core === void 0 ? void 0 : _dependencyApi$core.actions.execute(deleteDateCommand(dependencyApi));
66
- editorView.focus();
74
+ editorView === null || editorView === void 0 ? void 0 : editorView.focus();
67
75
  },
68
76
  onSelect: (date, commitMethod) => {
69
77
  var _dependencyApi$core2;
@@ -71,11 +79,14 @@ function ContentComponent({
71
79
  if (date === undefined || date === null) {
72
80
  return;
73
81
  }
82
+ if (expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) && !editorView) {
83
+ return;
84
+ }
74
85
  dependencyApi === null || dependencyApi === void 0 ? void 0 : (_dependencyApi$core2 = dependencyApi.core) === null || _dependencyApi$core2 === void 0 ? void 0 : _dependencyApi$core2.actions.execute(insertDateCommand(dependencyApi)({
75
86
  date,
76
87
  commitMethod
77
88
  }));
78
- editorView.focus();
89
+ editorView === null || editorView === void 0 ? void 0 : editorView.focus();
79
90
  },
80
91
  onTextChanged: date => {
81
92
  var _dependencyApi$core3;
@@ -85,15 +96,21 @@ function ContentComponent({
85
96
  }));
86
97
  },
87
98
  closeDatePicker: () => {
88
- closeDatePicker()(editorView.state, dispatch);
89
- editorView.focus();
99
+ if (!editorView) {
100
+ return;
101
+ }
102
+ closeDatePicker()(editorView.state, editorView.dispatch);
103
+ editorView === null || editorView === void 0 ? void 0 : editorView.focus();
90
104
  },
91
105
  closeDatePickerWithAnalytics: ({
92
106
  date
93
107
  }) => {
108
+ if (!editorView) {
109
+ return;
110
+ }
94
111
  closeDatePickerWithAnalytics({
95
112
  date
96
- })(editorView.state, dispatch);
113
+ })(editorView.state, editorView.dispatch);
97
114
  editorView.focus();
98
115
  },
99
116
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
@@ -1,4 +1,4 @@
1
- /* date-picker-input.tsx generated by @compiled/babel-plugin v0.38.1 */
1
+ /* date-picker-input.tsx generated by @compiled/babel-plugin v0.36.1 */
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import "./date-picker-input.compiled.css";
4
4
  import { ax, ix } from "@compiled/react/runtime";
@@ -1,4 +1,4 @@
1
- /* index.tsx generated by @compiled/babel-plugin v0.38.1 */
1
+ /* index.tsx generated by @compiled/babel-plugin v0.36.1 */
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import "./index.compiled.css";
4
4
  import { ax, ix } from "@compiled/react/runtime";
@@ -11,6 +11,7 @@ import { calculateToolbarPositionAboveSelection } from '@atlaskit/editor-common/
11
11
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
12
12
  import CommentIcon from '@atlaskit/icon/core/comment';
13
13
  import { fg } from '@atlaskit/platform-feature-flags';
14
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
14
15
  import { closeDatePicker as _closeDatePicker, closeDatePickerWithAnalytics as _closeDatePickerWithAnalytics, createDate } from './pm-plugins/actions';
15
16
  import { deleteDateCommand, insertDateCommand } from './pm-plugins/commands';
16
17
  import keymap from './pm-plugins/keymap';
@@ -26,6 +27,20 @@ var DatePicker = Loadable({
26
27
  return null;
27
28
  }
28
29
  });
30
+ function getDateNode(editorView, showDatePickerAt) {
31
+ if (!editorView) {
32
+ return null;
33
+ }
34
+ var domAtPos = editorView.domAtPos.bind(editorView);
35
+
36
+ // Ignored via go/ees005
37
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
38
+ var element = findDomRefAtPos(showDatePickerAt, domAtPos);
39
+
40
+ // Resolves ED-23702 for when the date is wrapped in an inline comment
41
+ var dateNode = element !== null && element !== void 0 && element.classList.contains(DateSharedCssClassName.DATE_CONTAINER) ? element : element === null || element === void 0 ? void 0 : element.querySelector(".".concat(DateSharedCssClassName.DATE_CONTAINER));
42
+ return dateNode || element;
43
+ }
29
44
  function ContentComponent(_ref) {
30
45
  var editorView = _ref.editorView,
31
46
  dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
@@ -34,8 +49,6 @@ function ContentComponent(_ref) {
34
49
  popupsScrollableElement = _ref.popupsScrollableElement,
35
50
  dependencyApi = _ref.dependencyApi,
36
51
  weekStartDay = _ref.weekStartDay;
37
- var dispatch = editorView.dispatch;
38
- var domAtPos = editorView.domAtPos.bind(editorView);
39
52
  var _useSharedPluginState = useSharedPluginState(dependencyApi, ['date', 'editorDisabled']),
40
53
  editorDisabledState = _useSharedPluginState.editorDisabledState,
41
54
  dateState = _useSharedPluginState.dateState;
@@ -45,25 +58,22 @@ function ContentComponent(_ref) {
45
58
  var showDatePickerAt = dateState.showDatePickerAt,
46
59
  isNew = dateState.isNew,
47
60
  focusDateInput = dateState.focusDateInput;
48
-
49
- // Ignored via go/ees005
50
- // eslint-disable-next-line @atlaskit/editor/no-as-casting
51
- var element = findDomRefAtPos(showDatePickerAt, domAtPos);
52
-
53
- // Resolves ED-23702 for when the date is wrapped in an inline comment
54
- var dateNode = element !== null && element !== void 0 && element.classList.contains(DateSharedCssClassName.DATE_CONTAINER) ? element : element === null || element === void 0 ? void 0 : element.querySelector(".".concat(DateSharedCssClassName.DATE_CONTAINER));
61
+ var dateNode = getDateNode(editorView, showDatePickerAt);
55
62
  return /*#__PURE__*/React.createElement(DatePicker, {
56
63
  mountTo: popupsMountPoint,
57
64
  boundariesElement: popupsBoundariesElement,
58
65
  scrollableElement: popupsScrollableElement,
59
66
  key: showDatePickerAt,
60
- element: dateNode || element,
67
+ element: dateNode,
61
68
  isNew: isNew,
62
69
  autoFocus: focusDateInput,
63
70
  onDelete: function onDelete() {
64
71
  var _dependencyApi$core;
72
+ if (expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) && !editorView) {
73
+ return;
74
+ }
65
75
  dependencyApi === null || dependencyApi === void 0 || (_dependencyApi$core = dependencyApi.core) === null || _dependencyApi$core === void 0 || _dependencyApi$core.actions.execute(deleteDateCommand(dependencyApi));
66
- editorView.focus();
76
+ editorView === null || editorView === void 0 || editorView.focus();
67
77
  },
68
78
  onSelect: function onSelect(date, commitMethod) {
69
79
  var _dependencyApi$core2;
@@ -71,11 +81,14 @@ function ContentComponent(_ref) {
71
81
  if (date === undefined || date === null) {
72
82
  return;
73
83
  }
84
+ if (expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) && !editorView) {
85
+ return;
86
+ }
74
87
  dependencyApi === null || dependencyApi === void 0 || (_dependencyApi$core2 = dependencyApi.core) === null || _dependencyApi$core2 === void 0 || _dependencyApi$core2.actions.execute(insertDateCommand(dependencyApi)({
75
88
  date: date,
76
89
  commitMethod: commitMethod
77
90
  }));
78
- editorView.focus();
91
+ editorView === null || editorView === void 0 || editorView.focus();
79
92
  },
80
93
  onTextChanged: function onTextChanged(date) {
81
94
  var _dependencyApi$core3;
@@ -85,14 +98,20 @@ function ContentComponent(_ref) {
85
98
  }));
86
99
  },
87
100
  closeDatePicker: function closeDatePicker() {
88
- _closeDatePicker()(editorView.state, dispatch);
89
- editorView.focus();
101
+ if (!editorView) {
102
+ return;
103
+ }
104
+ _closeDatePicker()(editorView.state, editorView.dispatch);
105
+ editorView === null || editorView === void 0 || editorView.focus();
90
106
  },
91
107
  closeDatePickerWithAnalytics: function closeDatePickerWithAnalytics(_ref2) {
92
108
  var date = _ref2.date;
109
+ if (!editorView) {
110
+ return;
111
+ }
93
112
  _closeDatePickerWithAnalytics({
94
113
  date: date
95
- })(editorView.state, dispatch);
114
+ })(editorView.state, editorView.dispatch);
96
115
  editorView.focus();
97
116
  },
98
117
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
@@ -1,4 +1,4 @@
1
- /* date-picker-input.tsx generated by @compiled/babel-plugin v0.38.1 */
1
+ /* date-picker-input.tsx generated by @compiled/babel-plugin v0.36.1 */
2
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/createClass";
4
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
@@ -1,4 +1,4 @@
1
- /* index.tsx generated by @compiled/babel-plugin v0.38.1 */
1
+ /* index.tsx generated by @compiled/babel-plugin v0.36.1 */
2
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/createClass";
4
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-date",
3
- "version": "7.2.0",
3
+ "version": "7.2.2",
4
4
  "description": "Date plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -39,13 +39,13 @@
39
39
  "@atlaskit/editor-plugin-editor-viewmode": "^7.0.0",
40
40
  "@atlaskit/editor-prosemirror": "7.0.0",
41
41
  "@atlaskit/editor-shared-styles": "^3.6.0",
42
- "@atlaskit/form": "^12.6.0",
43
- "@atlaskit/icon": "^28.1.0",
42
+ "@atlaskit/form": "^13.0.0",
43
+ "@atlaskit/icon": "^28.2.0",
44
44
  "@atlaskit/locale": "^3.0.0",
45
45
  "@atlaskit/platform-feature-flags": "^1.1.0",
46
46
  "@atlaskit/textfield": "^8.0.0",
47
47
  "@atlaskit/theme": "^21.0.0",
48
- "@atlaskit/tmp-editor-statsig": "^12.18.0",
48
+ "@atlaskit/tmp-editor-statsig": "^12.26.0",
49
49
  "@atlaskit/tokens": "^6.3.0",
50
50
  "@atlaskit/visually-hidden": "^3.0.0",
51
51
  "@babel/runtime": "^7.0.0",
@@ -69,7 +69,7 @@
69
69
  "@testing-library/react": "^13.4.0"
70
70
  },
71
71
  "peerDependencies": {
72
- "@atlaskit/editor-common": "^109.5.0",
72
+ "@atlaskit/editor-common": "^109.11.0",
73
73
  "react": "^18.2.0",
74
74
  "react-dom": "^18.2.0"
75
75
  },