@atlaskit/editor-core 188.10.7 → 188.11.1
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 +16 -0
- package/architecture/0003-explicit-plugin-dependencies.md +1 -1
- package/dist/cjs/i18n/cs.js +0 -60
- package/dist/cjs/i18n/da.js +0 -60
- package/dist/cjs/i18n/de.js +0 -60
- package/dist/cjs/i18n/en.js +0 -60
- package/dist/cjs/i18n/en_GB.js +0 -60
- package/dist/cjs/i18n/en_ZZ.js +0 -60
- package/dist/cjs/i18n/es.js +0 -60
- package/dist/cjs/i18n/fi.js +0 -60
- package/dist/cjs/i18n/fr.js +0 -60
- package/dist/cjs/i18n/hu.js +0 -60
- package/dist/cjs/i18n/it.js +0 -60
- package/dist/cjs/i18n/ja.js +0 -60
- package/dist/cjs/i18n/ko.js +0 -60
- package/dist/cjs/i18n/nb.js +0 -60
- package/dist/cjs/i18n/nl.js +0 -60
- package/dist/cjs/i18n/pl.js +0 -60
- package/dist/cjs/i18n/pt_BR.js +0 -60
- package/dist/cjs/i18n/ru.js +0 -60
- package/dist/cjs/i18n/sv.js +0 -60
- package/dist/cjs/i18n/th.js +0 -60
- package/dist/cjs/i18n/tr.js +0 -60
- package/dist/cjs/i18n/uk.js +0 -60
- package/dist/cjs/i18n/vi.js +0 -60
- package/dist/cjs/i18n/zh.js +0 -60
- package/dist/cjs/i18n/zh_TW.js +0 -60
- package/dist/cjs/labs/next/presets/universal.js +2 -2
- package/dist/cjs/messages.js +1 -2
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/decisionItem.js +1 -1
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +1 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/i18n/cs.js +0 -60
- package/dist/es2019/i18n/da.js +0 -60
- package/dist/es2019/i18n/de.js +0 -60
- package/dist/es2019/i18n/en.js +0 -60
- package/dist/es2019/i18n/en_GB.js +0 -60
- package/dist/es2019/i18n/en_ZZ.js +0 -60
- package/dist/es2019/i18n/es.js +0 -60
- package/dist/es2019/i18n/fi.js +0 -60
- package/dist/es2019/i18n/fr.js +0 -60
- package/dist/es2019/i18n/hu.js +0 -60
- package/dist/es2019/i18n/it.js +0 -60
- package/dist/es2019/i18n/ja.js +0 -60
- package/dist/es2019/i18n/ko.js +0 -60
- package/dist/es2019/i18n/nb.js +0 -60
- package/dist/es2019/i18n/nl.js +0 -60
- package/dist/es2019/i18n/pl.js +0 -60
- package/dist/es2019/i18n/pt_BR.js +0 -60
- package/dist/es2019/i18n/ru.js +0 -60
- package/dist/es2019/i18n/sv.js +0 -60
- package/dist/es2019/i18n/th.js +0 -60
- package/dist/es2019/i18n/tr.js +0 -60
- package/dist/es2019/i18n/uk.js +0 -60
- package/dist/es2019/i18n/vi.js +0 -60
- package/dist/es2019/i18n/zh.js +0 -60
- package/dist/es2019/i18n/zh_TW.js +0 -60
- package/dist/es2019/labs/next/presets/universal.js +1 -1
- package/dist/es2019/messages.js +1 -2
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/decisionItem.js +1 -1
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +1 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/i18n/cs.js +0 -60
- package/dist/esm/i18n/da.js +0 -60
- package/dist/esm/i18n/de.js +0 -60
- package/dist/esm/i18n/en.js +0 -60
- package/dist/esm/i18n/en_GB.js +0 -60
- package/dist/esm/i18n/en_ZZ.js +0 -60
- package/dist/esm/i18n/es.js +0 -60
- package/dist/esm/i18n/fi.js +0 -60
- package/dist/esm/i18n/fr.js +0 -60
- package/dist/esm/i18n/hu.js +0 -60
- package/dist/esm/i18n/it.js +0 -60
- package/dist/esm/i18n/ja.js +0 -60
- package/dist/esm/i18n/ko.js +0 -60
- package/dist/esm/i18n/nb.js +0 -60
- package/dist/esm/i18n/nl.js +0 -60
- package/dist/esm/i18n/pl.js +0 -60
- package/dist/esm/i18n/pt_BR.js +0 -60
- package/dist/esm/i18n/ru.js +0 -60
- package/dist/esm/i18n/sv.js +0 -60
- package/dist/esm/i18n/th.js +0 -60
- package/dist/esm/i18n/tr.js +0 -60
- package/dist/esm/i18n/uk.js +0 -60
- package/dist/esm/i18n/vi.js +0 -60
- package/dist/esm/i18n/zh.js +0 -60
- package/dist/esm/i18n/zh_TW.js +0 -60
- package/dist/esm/labs/next/presets/universal.js +1 -1
- package/dist/esm/messages.js +1 -2
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/decisionItem.js +1 -1
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +1 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/i18n/cs.d.ts +0 -60
- package/dist/types/i18n/da.d.ts +0 -60
- package/dist/types/i18n/de.d.ts +0 -60
- package/dist/types/i18n/en.d.ts +0 -60
- package/dist/types/i18n/en_GB.d.ts +0 -60
- package/dist/types/i18n/en_ZZ.d.ts +0 -60
- package/dist/types/i18n/es.d.ts +0 -60
- package/dist/types/i18n/fi.d.ts +0 -60
- package/dist/types/i18n/fr.d.ts +0 -60
- package/dist/types/i18n/hu.d.ts +0 -60
- package/dist/types/i18n/it.d.ts +0 -60
- package/dist/types/i18n/ja.d.ts +0 -60
- package/dist/types/i18n/ko.d.ts +0 -60
- package/dist/types/i18n/nb.d.ts +0 -60
- package/dist/types/i18n/nl.d.ts +0 -60
- package/dist/types/i18n/pl.d.ts +0 -60
- package/dist/types/i18n/pt_BR.d.ts +0 -60
- package/dist/types/i18n/ru.d.ts +0 -60
- package/dist/types/i18n/sv.d.ts +0 -60
- package/dist/types/i18n/th.d.ts +0 -60
- package/dist/types/i18n/tr.d.ts +0 -60
- package/dist/types/i18n/uk.d.ts +0 -60
- package/dist/types/i18n/vi.d.ts +0 -60
- package/dist/types/i18n/zh.d.ts +0 -60
- package/dist/types/i18n/zh_TW.d.ts +0 -60
- package/dist/types/messages.d.ts +1 -2
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types/ui/ConfigPanel/FormErrorBoundary.d.ts +1 -1
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types-ts4.5/i18n/cs.d.ts +0 -60
- package/dist/types-ts4.5/i18n/da.d.ts +0 -60
- package/dist/types-ts4.5/i18n/de.d.ts +0 -60
- package/dist/types-ts4.5/i18n/en.d.ts +0 -60
- package/dist/types-ts4.5/i18n/en_GB.d.ts +0 -60
- package/dist/types-ts4.5/i18n/en_ZZ.d.ts +0 -60
- package/dist/types-ts4.5/i18n/es.d.ts +0 -60
- package/dist/types-ts4.5/i18n/fi.d.ts +0 -60
- package/dist/types-ts4.5/i18n/fr.d.ts +0 -60
- package/dist/types-ts4.5/i18n/hu.d.ts +0 -60
- package/dist/types-ts4.5/i18n/it.d.ts +0 -60
- package/dist/types-ts4.5/i18n/ja.d.ts +0 -60
- package/dist/types-ts4.5/i18n/ko.d.ts +0 -60
- package/dist/types-ts4.5/i18n/nb.d.ts +0 -60
- package/dist/types-ts4.5/i18n/nl.d.ts +0 -60
- package/dist/types-ts4.5/i18n/pl.d.ts +0 -60
- package/dist/types-ts4.5/i18n/pt_BR.d.ts +0 -60
- package/dist/types-ts4.5/i18n/ru.d.ts +0 -60
- package/dist/types-ts4.5/i18n/sv.d.ts +0 -60
- package/dist/types-ts4.5/i18n/th.d.ts +0 -60
- package/dist/types-ts4.5/i18n/tr.d.ts +0 -60
- package/dist/types-ts4.5/i18n/uk.d.ts +0 -60
- package/dist/types-ts4.5/i18n/vi.d.ts +0 -60
- package/dist/types-ts4.5/i18n/zh.d.ts +0 -60
- package/dist/types-ts4.5/i18n/zh_TW.d.ts +0 -60
- package/dist/types-ts4.5/messages.d.ts +1 -2
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types-ts4.5/ui/ConfigPanel/FormErrorBoundary.d.ts +1 -1
- package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
- package/package.json +6 -9
- package/dist/cjs/plugins/date/actions.js +0 -105
- package/dist/cjs/plugins/date/commands.js +0 -118
- package/dist/cjs/plugins/date/index.js +0 -13
- package/dist/cjs/plugins/date/nodeviews/date.js +0 -44
- package/dist/cjs/plugins/date/nodeviews/messages.js +0 -14
- package/dist/cjs/plugins/date/plugin.js +0 -197
- package/dist/cjs/plugins/date/pm-plugins/keymap.js +0 -41
- package/dist/cjs/plugins/date/pm-plugins/main.js +0 -39
- package/dist/cjs/plugins/date/pm-plugins/plugin-key.js +0 -8
- package/dist/cjs/plugins/date/pm-plugins/types.js +0 -5
- package/dist/cjs/plugins/date/pm-plugins/utils.js +0 -70
- package/dist/cjs/plugins/date/types.js +0 -5
- package/dist/cjs/plugins/date/ui/DatePicker/date-picker-input.js +0 -244
- package/dist/cjs/plugins/date/ui/DatePicker/index.js +0 -168
- package/dist/cjs/plugins/date/utils/formatParse.js +0 -88
- package/dist/cjs/plugins/date/utils/internal.js +0 -176
- package/dist/es2019/plugins/date/actions.js +0 -93
- package/dist/es2019/plugins/date/commands.js +0 -113
- package/dist/es2019/plugins/date/index.js +0 -1
- package/dist/es2019/plugins/date/nodeviews/date.js +0 -47
- package/dist/es2019/plugins/date/nodeviews/messages.js +0 -8
- package/dist/es2019/plugins/date/plugin.js +0 -183
- package/dist/es2019/plugins/date/pm-plugins/keymap.js +0 -34
- package/dist/es2019/plugins/date/pm-plugins/main.js +0 -35
- package/dist/es2019/plugins/date/pm-plugins/plugin-key.js +0 -2
- package/dist/es2019/plugins/date/pm-plugins/types.js +0 -1
- package/dist/es2019/plugins/date/pm-plugins/utils.js +0 -70
- package/dist/es2019/plugins/date/types.js +0 -1
- package/dist/es2019/plugins/date/ui/DatePicker/date-picker-input.js +0 -233
- package/dist/es2019/plugins/date/ui/DatePicker/index.js +0 -152
- package/dist/es2019/plugins/date/utils/formatParse.js +0 -83
- package/dist/es2019/plugins/date/utils/internal.js +0 -151
- package/dist/esm/plugins/date/actions.js +0 -99
- package/dist/esm/plugins/date/commands.js +0 -112
- package/dist/esm/plugins/date/index.js +0 -1
- package/dist/esm/plugins/date/nodeviews/date.js +0 -37
- package/dist/esm/plugins/date/nodeviews/messages.js +0 -8
- package/dist/esm/plugins/date/plugin.js +0 -185
- package/dist/esm/plugins/date/pm-plugins/keymap.js +0 -34
- package/dist/esm/plugins/date/pm-plugins/main.js +0 -34
- package/dist/esm/plugins/date/pm-plugins/plugin-key.js +0 -2
- package/dist/esm/plugins/date/pm-plugins/types.js +0 -1
- package/dist/esm/plugins/date/pm-plugins/utils.js +0 -61
- package/dist/esm/plugins/date/types.js +0 -1
- package/dist/esm/plugins/date/ui/DatePicker/date-picker-input.js +0 -238
- package/dist/esm/plugins/date/ui/DatePicker/index.js +0 -162
- package/dist/esm/plugins/date/utils/formatParse.js +0 -79
- package/dist/esm/plugins/date/utils/internal.js +0 -165
- package/dist/types/plugins/date/actions.d.ts +0 -47
- package/dist/types/plugins/date/commands.d.ts +0 -12
- package/dist/types/plugins/date/index.d.ts +0 -1
- package/dist/types/plugins/date/nodeviews/date.d.ts +0 -3
- package/dist/types/plugins/date/nodeviews/messages.d.ts +0 -7
- package/dist/types/plugins/date/plugin.d.ts +0 -3
- package/dist/types/plugins/date/pm-plugins/keymap.d.ts +0 -3
- package/dist/types/plugins/date/pm-plugins/main.d.ts +0 -6
- package/dist/types/plugins/date/pm-plugins/plugin-key.d.ts +0 -3
- package/dist/types/plugins/date/pm-plugins/types.d.ts +0 -12
- package/dist/types/plugins/date/pm-plugins/utils.d.ts +0 -5
- package/dist/types/plugins/date/types.d.ts +0 -1
- package/dist/types/plugins/date/ui/DatePicker/date-picker-input.d.ts +0 -24
- package/dist/types/plugins/date/ui/DatePicker/index.d.ts +0 -36
- package/dist/types/plugins/date/utils/formatParse.d.ts +0 -27
- package/dist/types/plugins/date/utils/internal.d.ts +0 -33
- package/dist/types-ts4.5/plugins/date/actions.d.ts +0 -58
- package/dist/types-ts4.5/plugins/date/commands.d.ts +0 -14
- package/dist/types-ts4.5/plugins/date/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/date/nodeviews/date.d.ts +0 -3
- package/dist/types-ts4.5/plugins/date/nodeviews/messages.d.ts +0 -7
- package/dist/types-ts4.5/plugins/date/plugin.d.ts +0 -3
- package/dist/types-ts4.5/plugins/date/pm-plugins/keymap.d.ts +0 -3
- package/dist/types-ts4.5/plugins/date/pm-plugins/main.d.ts +0 -6
- package/dist/types-ts4.5/plugins/date/pm-plugins/plugin-key.d.ts +0 -3
- package/dist/types-ts4.5/plugins/date/pm-plugins/types.d.ts +0 -12
- package/dist/types-ts4.5/plugins/date/pm-plugins/utils.d.ts +0 -5
- package/dist/types-ts4.5/plugins/date/types.d.ts +0 -1
- package/dist/types-ts4.5/plugins/date/ui/DatePicker/date-picker-input.d.ts +0 -24
- package/dist/types-ts4.5/plugins/date/ui/DatePicker/index.d.ts +0 -36
- package/dist/types-ts4.5/plugins/date/utils/formatParse.d.ts +0 -27
- package/dist/types-ts4.5/plugins/date/utils/internal.d.ts +0 -33
|
@@ -1,168 +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
|
-
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 _reactDom = _interopRequireDefault(require("react-dom"));
|
|
19
|
-
var _ui = require("@atlaskit/editor-common/ui");
|
|
20
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
21
|
-
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
22
|
-
var _calendar = _interopRequireDefault(require("@atlaskit/calendar"));
|
|
23
|
-
var _constants = require("@atlaskit/theme/constants");
|
|
24
|
-
var _colors = require("@atlaskit/theme/colors");
|
|
25
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
26
|
-
var _reactIntlNext = require("react-intl-next");
|
|
27
|
-
var _datePickerInput = _interopRequireDefault(require("./date-picker-input"));
|
|
28
|
-
var _templateObject;
|
|
29
|
-
/** @jsx jsx */
|
|
30
|
-
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); }; }
|
|
31
|
-
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; } }
|
|
32
|
-
var PopupWithListeners = (0, _ui.withOuterListeners)(_ui.Popup);
|
|
33
|
-
var popupContentWrapper = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n padding: ", ";\n border-radius: ", "px;\n box-shadow: ", ";\n background-color: ", ";\n"])), "var(--ds-space-025, 2px)", (0, _constants.borderRadius)(), "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(_colors.N60A, ", 0 0 1px ").concat(_colors.N60A), ")"), "var(--ds-surface-overlay, ".concat(_colors.N0, ")"));
|
|
34
|
-
var DatePicker = /*#__PURE__*/function (_React$Component) {
|
|
35
|
-
(0, _inherits2.default)(DatePicker, _React$Component);
|
|
36
|
-
var _super = _createSuper(DatePicker);
|
|
37
|
-
function DatePicker(props) {
|
|
38
|
-
var _this;
|
|
39
|
-
(0, _classCallCheck2.default)(this, DatePicker);
|
|
40
|
-
_this = _super.call(this, props);
|
|
41
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleNewDate", function (date) {
|
|
42
|
-
_this.props.onTextChanged(date);
|
|
43
|
-
_this.setState({
|
|
44
|
-
latestValidDate: date
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleKeyboardSubmitDate", function (date) {
|
|
48
|
-
_this.props.onSelect(date, _analytics.INPUT_METHOD.KEYBOARD);
|
|
49
|
-
});
|
|
50
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleEmptySubmitDate", function () {
|
|
51
|
-
_this.props.onDelete();
|
|
52
|
-
});
|
|
53
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleOnChange", function (_ref) {
|
|
54
|
-
var day = _ref.day,
|
|
55
|
-
month = _ref.month,
|
|
56
|
-
year = _ref.year;
|
|
57
|
-
var date = {
|
|
58
|
-
day: day,
|
|
59
|
-
month: month,
|
|
60
|
-
year: year
|
|
61
|
-
};
|
|
62
|
-
_this.setState({
|
|
63
|
-
latestValidDate: date
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "closeDatePickerWithAnalytics", function () {
|
|
67
|
-
_this.props.closeDatePickerWithAnalytics({
|
|
68
|
-
date: _this.state.latestValidDate
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleRef", function (ref) {
|
|
72
|
-
var elm = ref && _reactDom.default.findDOMNode(ref);
|
|
73
|
-
if (elm) {
|
|
74
|
-
elm.focus();
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
var timestamp = props.element.getAttribute('timestamp');
|
|
78
|
-
if (timestamp) {
|
|
79
|
-
// Warning: The 'Date' return type of timestampToUTCDate() is not a JS date, it's more similar
|
|
80
|
-
// to the DateType type
|
|
81
|
-
var _timestampToUTCDate = (0, _utils.timestampToUTCDate)(timestamp),
|
|
82
|
-
day = _timestampToUTCDate.day,
|
|
83
|
-
month = _timestampToUTCDate.month,
|
|
84
|
-
year = _timestampToUTCDate.year;
|
|
85
|
-
var _date = {
|
|
86
|
-
day: day,
|
|
87
|
-
month: month,
|
|
88
|
-
year: year
|
|
89
|
-
};
|
|
90
|
-
_this.state = {
|
|
91
|
-
selected: [(0, _utils.timestampToIsoFormat)(timestamp)],
|
|
92
|
-
date: _date,
|
|
93
|
-
latestValidDate: _date
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
return _this;
|
|
97
|
-
}
|
|
98
|
-
(0, _createClass2.default)(DatePicker, [{
|
|
99
|
-
key: "render",
|
|
100
|
-
value: function render() {
|
|
101
|
-
var _this$props = this.props,
|
|
102
|
-
element = _this$props.element,
|
|
103
|
-
_onSelect = _this$props.onSelect,
|
|
104
|
-
mountTo = _this$props.mountTo,
|
|
105
|
-
boundariesElement = _this$props.boundariesElement,
|
|
106
|
-
scrollableElement = _this$props.scrollableElement,
|
|
107
|
-
intl = _this$props.intl,
|
|
108
|
-
dispatchAnalyticsEvent = _this$props.dispatchAnalyticsEvent,
|
|
109
|
-
isNew = _this$props.isNew,
|
|
110
|
-
autoFocus = _this$props.autoFocus,
|
|
111
|
-
weekStartDay = _this$props.weekStartDay;
|
|
112
|
-
var timestamp = element.getAttribute('timestamp');
|
|
113
|
-
if (this.state === null) {
|
|
114
|
-
// Without this, you can blow up the page by slowing down cpu, opening date, typing after date
|
|
115
|
-
// then clicking on date lozenge and typing quickly before it opens
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
var _this$state = this.state,
|
|
119
|
-
date = _this$state.date,
|
|
120
|
-
selected = _this$state.selected,
|
|
121
|
-
latestValidDate = _this$state.latestValidDate;
|
|
122
|
-
var day = latestValidDate.day,
|
|
123
|
-
month = latestValidDate.month,
|
|
124
|
-
year = latestValidDate.year;
|
|
125
|
-
if (!timestamp) {
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
return (0, _react2.jsx)(PopupWithListeners, {
|
|
129
|
-
target: element,
|
|
130
|
-
offset: [0, 8],
|
|
131
|
-
fitHeight: 327,
|
|
132
|
-
fitWidth: 340,
|
|
133
|
-
handleClickOutside: this.closeDatePickerWithAnalytics,
|
|
134
|
-
handleEscapeKeydown: this.closeDatePickerWithAnalytics,
|
|
135
|
-
zIndex: _editorSharedStyles.akEditorFloatingDialogZIndex,
|
|
136
|
-
mountTo: mountTo,
|
|
137
|
-
boundariesElement: boundariesElement,
|
|
138
|
-
scrollableElement: scrollableElement,
|
|
139
|
-
ariaLabel: null
|
|
140
|
-
}, (0, _react2.jsx)("div", {
|
|
141
|
-
css: popupContentWrapper
|
|
142
|
-
}, (0, _react2.jsx)(_datePickerInput.default, {
|
|
143
|
-
date: date,
|
|
144
|
-
onNewDate: this.handleNewDate,
|
|
145
|
-
onSubmitDate: this.handleKeyboardSubmitDate,
|
|
146
|
-
onEmptySubmit: this.handleEmptySubmitDate,
|
|
147
|
-
locale: intl.locale,
|
|
148
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
149
|
-
autoFocus: autoFocus,
|
|
150
|
-
autoSelectAll: isNew
|
|
151
|
-
}), (0, _react2.jsx)(_calendar.default, {
|
|
152
|
-
onChange: this.handleOnChange,
|
|
153
|
-
onSelect: function onSelect(date) {
|
|
154
|
-
return _onSelect(date, _analytics.INPUT_METHOD.PICKER);
|
|
155
|
-
},
|
|
156
|
-
day: day,
|
|
157
|
-
month: month,
|
|
158
|
-
year: year,
|
|
159
|
-
selected: selected,
|
|
160
|
-
ref: this.handleRef,
|
|
161
|
-
weekStartDay: weekStartDay,
|
|
162
|
-
testId: 'datepicker'
|
|
163
|
-
})));
|
|
164
|
-
}
|
|
165
|
-
}]);
|
|
166
|
-
return DatePicker;
|
|
167
|
-
}(_react.default.Component);
|
|
168
|
-
var _default = exports.default = (0, _reactIntlNext.injectIntl)(DatePicker);
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.dateToDateType = dateToDateType;
|
|
7
|
-
exports.dateTypeToDate = dateTypeToDate;
|
|
8
|
-
exports.formatDateType = formatDateType;
|
|
9
|
-
exports.parseDateType = parseDateType;
|
|
10
|
-
var _locale = require("@atlaskit/locale");
|
|
11
|
-
/**
|
|
12
|
-
* Attempt to parse a string representing a date in a particular locale to a date object
|
|
13
|
-
* @param dateString The string representing the date in the given locale, eg '02/12/2000'
|
|
14
|
-
* @param l10n The localisation provider created by createLocalizationProvider
|
|
15
|
-
* @returns Editor DateType when can parse, null when can't parse or invalid
|
|
16
|
-
*/
|
|
17
|
-
function parseDateType(dateString, locale) {
|
|
18
|
-
try {
|
|
19
|
-
var l10n = (0, _locale.createLocalizationProvider)(locale);
|
|
20
|
-
var date = l10n.parseDate(dateString);
|
|
21
|
-
|
|
22
|
-
// If date is invalid
|
|
23
|
-
if (isNaN(date.getTime())) {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
var year = date.getFullYear();
|
|
27
|
-
if (year < 1000 || year > 9999) {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
var dateObj = {
|
|
31
|
-
day: date.getDate(),
|
|
32
|
-
month: date.getMonth() + 1,
|
|
33
|
-
year: year
|
|
34
|
-
};
|
|
35
|
-
return dateObj;
|
|
36
|
-
} catch (e) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Convert an EditorDateType to a date string string formatted for a particular locale
|
|
43
|
-
* @param date The date object
|
|
44
|
-
* @param locale The locale code string (eg. "en-AU")
|
|
45
|
-
* @returns Date string, eg "25/5/20"
|
|
46
|
-
*/
|
|
47
|
-
function formatDateType(date, locale) {
|
|
48
|
-
var day = date.day,
|
|
49
|
-
month = date.month,
|
|
50
|
-
year = date.year;
|
|
51
|
-
var l10n = (0, _locale.createLocalizationProvider)(locale);
|
|
52
|
-
|
|
53
|
-
// The JS Date api represents month as a number between 0-11 :)
|
|
54
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
|
|
55
|
-
var dateObj = new Date(year, month - 1, day);
|
|
56
|
-
return l10n.formatDate(dateObj);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Convert an Editor DateType to a JavaScript Date object
|
|
61
|
-
* @param date Editor DateType
|
|
62
|
-
* @returns JavaScript Date object
|
|
63
|
-
*/
|
|
64
|
-
function dateTypeToDate(date) {
|
|
65
|
-
var day = date.day,
|
|
66
|
-
month = date.month,
|
|
67
|
-
year = date.year;
|
|
68
|
-
// The JS Date api represents month as a number between 0-11 :)
|
|
69
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
|
|
70
|
-
var dateObj = new Date(year, month - 1, day);
|
|
71
|
-
return dateObj;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Convert a JavaScript Date to an editor DateType
|
|
76
|
-
* @param date JavaScript Date object
|
|
77
|
-
* @returns Editor DateType
|
|
78
|
-
*/
|
|
79
|
-
function dateToDateType(date) {
|
|
80
|
-
var dateObj = {
|
|
81
|
-
day: date.getDate(),
|
|
82
|
-
// The JS Date api represents month as a number between 0-11 :)
|
|
83
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
|
|
84
|
-
month: date.getMonth() + 1,
|
|
85
|
-
year: date.getFullYear()
|
|
86
|
-
};
|
|
87
|
-
return dateObj;
|
|
88
|
-
}
|
|
@@ -1,176 +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.adjustDate = adjustDate;
|
|
8
|
-
exports.findDateSegmentByPosition = findDateSegmentByPosition;
|
|
9
|
-
exports.getLocaleDatePlaceholder = getLocaleDatePlaceholder;
|
|
10
|
-
exports.isDatePossiblyValid = isDatePossiblyValid;
|
|
11
|
-
exports.isToday = isToday;
|
|
12
|
-
var _formatParse = require("./formatParse");
|
|
13
|
-
var _addDays = _interopRequireDefault(require("date-fns/addDays"));
|
|
14
|
-
var _addMonths = _interopRequireDefault(require("date-fns/addMonths"));
|
|
15
|
-
var _addYears = _interopRequireDefault(require("date-fns/addYears"));
|
|
16
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
17
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
18
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
19
|
-
function isDigit(c) {
|
|
20
|
-
if (c === undefined) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
return c >= '0' && c <= '9';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Check if cursor is in first segment of a date.
|
|
28
|
-
* @param cursorPos Cursor pos, with 0 referring to the left of first char
|
|
29
|
-
* @param date Date string in any locale
|
|
30
|
-
*/
|
|
31
|
-
function isCursorInFirstDateSegment(cursorPos, date) {
|
|
32
|
-
var posCounter = cursorPos - 1;
|
|
33
|
-
var isAdjacent = true;
|
|
34
|
-
// The date without any non-digit characters on the end
|
|
35
|
-
var strippedDate = date.replace(/[^0-9]+$/g, '');
|
|
36
|
-
while (posCounter >= 0 && isAdjacent) {
|
|
37
|
-
var c = strippedDate[posCounter];
|
|
38
|
-
if (!isDigit(c)) {
|
|
39
|
-
isAdjacent = false;
|
|
40
|
-
}
|
|
41
|
-
posCounter -= 1;
|
|
42
|
-
}
|
|
43
|
-
return isAdjacent;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Check if cursor is in last segment of a date.
|
|
48
|
-
* @param cursorPos Cursor pos, with 0 referring to the left of first char
|
|
49
|
-
* @param date Date string in any locale
|
|
50
|
-
*/
|
|
51
|
-
function isCursorInLastDateSegment(cursorPos, date) {
|
|
52
|
-
var posCounter = cursorPos;
|
|
53
|
-
var isAdjacent = true;
|
|
54
|
-
// The date without any non-digit characters on the end
|
|
55
|
-
var strippedDate = date.replace(/[^0-9]+$/g, '');
|
|
56
|
-
while (posCounter < strippedDate.length && isAdjacent) {
|
|
57
|
-
var c = strippedDate[posCounter];
|
|
58
|
-
if (!isDigit(c)) {
|
|
59
|
-
isAdjacent = false;
|
|
60
|
-
}
|
|
61
|
-
posCounter += 1;
|
|
62
|
-
}
|
|
63
|
-
return isAdjacent;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Inconclusively check if a date string is valid - a value of false means it is definitely
|
|
68
|
-
* invalid, a value of true means it might be valid.
|
|
69
|
-
* @param date Date string to be parsed
|
|
70
|
-
*/
|
|
71
|
-
function isDatePossiblyValid(date) {
|
|
72
|
-
var _iterator = _createForOfIteratorHelper(date),
|
|
73
|
-
_step;
|
|
74
|
-
try {
|
|
75
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
76
|
-
var c = _step.value;
|
|
77
|
-
var isNumber = c >= '0' && c <= '9';
|
|
78
|
-
var isValidPunctuation = '. ,/'.indexOf(c) !== -1;
|
|
79
|
-
if (!(isNumber || isValidPunctuation)) {
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
} catch (err) {
|
|
84
|
-
_iterator.e(err);
|
|
85
|
-
} finally {
|
|
86
|
-
_iterator.f();
|
|
87
|
-
}
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Find the segment of a date a position refers to. Eg: pos 2 in 29/03/2020 is in
|
|
93
|
-
* the day segment.
|
|
94
|
-
* @param position Cursor position, with 0 referring to the left of the first char
|
|
95
|
-
* @param date The localised date string
|
|
96
|
-
* @param locale The language to interpret the date string in
|
|
97
|
-
*/
|
|
98
|
-
function findDateSegmentByPosition(position, date, locale) {
|
|
99
|
-
if (position > date.length) {
|
|
100
|
-
return undefined;
|
|
101
|
-
}
|
|
102
|
-
var placeholder = getLocaleDatePlaceholder(locale);
|
|
103
|
-
if (!placeholder) {
|
|
104
|
-
return undefined;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// The placeholder without any non-digit characters on the end
|
|
108
|
-
var strippedPlaceholder = placeholder.replace(/[^ymd]+$/g, '');
|
|
109
|
-
var keyToSegment = {
|
|
110
|
-
d: 'day',
|
|
111
|
-
m: 'month',
|
|
112
|
-
y: 'year'
|
|
113
|
-
};
|
|
114
|
-
var firstSegment = keyToSegment[strippedPlaceholder[0]];
|
|
115
|
-
var lastSegment = keyToSegment[strippedPlaceholder[strippedPlaceholder.length - 1]];
|
|
116
|
-
var allPossibleSegments = ['day', 'month', 'year'];
|
|
117
|
-
var middleSegment = allPossibleSegments.filter(function (s) {
|
|
118
|
-
return s !== firstSegment && s !== lastSegment;
|
|
119
|
-
})[0];
|
|
120
|
-
if (isCursorInFirstDateSegment(position, date)) {
|
|
121
|
-
return firstSegment;
|
|
122
|
-
}
|
|
123
|
-
if (isCursorInLastDateSegment(position, date)) {
|
|
124
|
-
return lastSegment;
|
|
125
|
-
}
|
|
126
|
-
return middleSegment;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Generate a placeholder date string for a given locale
|
|
131
|
-
* eg: locale 'hu-HU' -> 'yyyy. mm. dd.'
|
|
132
|
-
* @param locale A locale string supported by Intl.DateTimeFormat
|
|
133
|
-
* @returns A placeholder string. d=1 or 2 digit day, dd=zero padded
|
|
134
|
-
* day, same for month but letter m, yyyy=year
|
|
135
|
-
*/
|
|
136
|
-
function getLocaleDatePlaceholder(locale) {
|
|
137
|
-
var uniqueDateType = {
|
|
138
|
-
day: 7,
|
|
139
|
-
month: 1,
|
|
140
|
-
year: 1992
|
|
141
|
-
};
|
|
142
|
-
var localisedDateString = (0, _formatParse.formatDateType)(uniqueDateType, locale);
|
|
143
|
-
var shortDateFormat = localisedDateString.replace(/\d+/g, function (str) {
|
|
144
|
-
if (!str) {
|
|
145
|
-
return '';
|
|
146
|
-
}
|
|
147
|
-
var num = parseInt(str);
|
|
148
|
-
switch (num % 100) {
|
|
149
|
-
case 92:
|
|
150
|
-
return str.replace(/.{1}/g, 'y');
|
|
151
|
-
case 1:
|
|
152
|
-
return str.length === 1 ? 'm' : 'mm';
|
|
153
|
-
case 7:
|
|
154
|
-
return str.length === 1 ? 'd' : 'dd';
|
|
155
|
-
}
|
|
156
|
-
return '';
|
|
157
|
-
});
|
|
158
|
-
return shortDateFormat;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Adjust date segment up or down. Eg. If day is the active segment and adjustment is -1,
|
|
163
|
-
* reduce the day by one.
|
|
164
|
-
* @param date Valid datetype
|
|
165
|
-
* @param activeSegment which part of the date is selected/being adjusted
|
|
166
|
-
* @param adjustment how many units the segment is being adjusted (can be pos or neg, usually 1 or -1)
|
|
167
|
-
*/
|
|
168
|
-
function adjustDate(date, activeSegment, adjustment) {
|
|
169
|
-
var originalDate = (0, _formatParse.dateTypeToDate)(date);
|
|
170
|
-
var newDate = activeSegment === 'day' ? (0, _addDays.default)(originalDate, adjustment) : activeSegment === 'month' ? (0, _addMonths.default)(originalDate, adjustment) : (0, _addYears.default)(originalDate, adjustment);
|
|
171
|
-
return (0, _formatParse.dateToDateType)(newDate);
|
|
172
|
-
}
|
|
173
|
-
function isToday(date) {
|
|
174
|
-
var today = new Date();
|
|
175
|
-
return date !== undefined && today.getDate() === date.day && date.month === today.getMonth() + 1 && date.year === today.getFullYear();
|
|
176
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import { todayTimestampInUTC } from '@atlaskit/editor-common/utils';
|
|
4
|
-
import { pluginKey } from './pm-plugins/plugin-key';
|
|
5
|
-
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
|
-
import { isToday } from './utils/internal';
|
|
7
|
-
export const createDate = isQuickInsertAction => (insert, state) => {
|
|
8
|
-
const dateNode = state.schema.nodes.date.createChecked({
|
|
9
|
-
timestamp: todayTimestampInUTC()
|
|
10
|
-
});
|
|
11
|
-
const space = state.schema.text(' ');
|
|
12
|
-
const tr = insert(Fragment.from([dateNode, space]), {
|
|
13
|
-
selectInlineNode: true
|
|
14
|
-
});
|
|
15
|
-
const newPluginState = {
|
|
16
|
-
isQuickInsertAction,
|
|
17
|
-
showDatePickerAt: tr.selection.from,
|
|
18
|
-
isNew: true,
|
|
19
|
-
isDateEmpty: false,
|
|
20
|
-
focusDateInput: false
|
|
21
|
-
};
|
|
22
|
-
return tr.setMeta(pluginKey, newPluginState);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/** Focus input */
|
|
26
|
-
export const focusDateInput = () => (state, dispatch) => {
|
|
27
|
-
const pluginState = pluginKey.getState(state);
|
|
28
|
-
if (!pluginState || pluginState.showDatePickerAt === null) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
if (!dispatch) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
const tr = state.tr.setMeta(pluginKey, {
|
|
35
|
-
focusDateInput: true
|
|
36
|
-
});
|
|
37
|
-
dispatch(tr);
|
|
38
|
-
return true;
|
|
39
|
-
};
|
|
40
|
-
export const setDatePickerAt = showDatePickerAt => (state, dispatch) => {
|
|
41
|
-
dispatch(state.tr.setMeta(pluginKey, {
|
|
42
|
-
showDatePickerAt
|
|
43
|
-
}));
|
|
44
|
-
return true;
|
|
45
|
-
};
|
|
46
|
-
export const closeDatePicker = () => (state, dispatch) => {
|
|
47
|
-
const {
|
|
48
|
-
showDatePickerAt
|
|
49
|
-
} = pluginKey.getState(state) || {};
|
|
50
|
-
if (!dispatch) {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
const tr = showDatePickerAt ? state.tr.setMeta(pluginKey, {
|
|
54
|
-
showDatePickerAt: null,
|
|
55
|
-
isNew: false
|
|
56
|
-
}).setSelection(Selection.near(state.tr.doc.resolve(showDatePickerAt + 2))) : state.tr.setMeta(pluginKey, {
|
|
57
|
-
isNew: false
|
|
58
|
-
});
|
|
59
|
-
dispatch(tr);
|
|
60
|
-
return false;
|
|
61
|
-
};
|
|
62
|
-
export const closeDatePickerWithAnalytics = ({
|
|
63
|
-
date,
|
|
64
|
-
pluginInjectionApi
|
|
65
|
-
}) => {
|
|
66
|
-
var _pluginInjectionApi$a, _pluginInjectionApi$a2;
|
|
67
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : (_pluginInjectionApi$a2 = _pluginInjectionApi$a.actions) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.attachAnalyticsEvent({
|
|
68
|
-
eventType: EVENT_TYPE.TRACK,
|
|
69
|
-
action: ACTION.COMMITTED,
|
|
70
|
-
actionSubject: ACTION_SUBJECT.DATE,
|
|
71
|
-
attributes: {
|
|
72
|
-
commitMethod: INPUT_METHOD.BLUR,
|
|
73
|
-
isValid: date !== undefined,
|
|
74
|
-
isToday: isToday(date)
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
return closeDatePicker();
|
|
78
|
-
};
|
|
79
|
-
export const openDatePicker = () => (state, dispatch) => {
|
|
80
|
-
const {
|
|
81
|
-
$from
|
|
82
|
-
} = state.selection;
|
|
83
|
-
const node = state.doc.nodeAt($from.pos);
|
|
84
|
-
if (node && node.type.name === state.schema.nodes.date.name) {
|
|
85
|
-
const showDatePickerAt = $from.pos;
|
|
86
|
-
if (dispatch) {
|
|
87
|
-
dispatch(state.tr.setMeta(pluginKey, {
|
|
88
|
-
showDatePickerAt
|
|
89
|
-
}).setSelection(NodeSelection.create(state.doc, showDatePickerAt)));
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return false;
|
|
93
|
-
};
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import { canInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
-
import { todayTimestampInUTC } from '@atlaskit/editor-common/utils';
|
|
6
|
-
import { pluginKey } from './pm-plugins/plugin-key';
|
|
7
|
-
import { isToday } from './utils/internal';
|
|
8
|
-
/** Delete the date and close the datepicker */
|
|
9
|
-
export const deleteDateCommand = pluginInjectionApi => ({
|
|
10
|
-
tr
|
|
11
|
-
}) => {
|
|
12
|
-
var _pluginInjectionApi$d, _pluginInjectionApi$d2;
|
|
13
|
-
const {
|
|
14
|
-
showDatePickerAt
|
|
15
|
-
} = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d2 = pluginInjectionApi.date) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.sharedState.currentState()) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {};
|
|
16
|
-
if (!showDatePickerAt) {
|
|
17
|
-
return tr;
|
|
18
|
-
}
|
|
19
|
-
tr.delete(showDatePickerAt, showDatePickerAt + 1).setMeta(pluginKey, {
|
|
20
|
-
showDatePickerAt: null,
|
|
21
|
-
isNew: false
|
|
22
|
-
});
|
|
23
|
-
return tr;
|
|
24
|
-
};
|
|
25
|
-
export const insertDateCommand = pluginInjectionApi => ({
|
|
26
|
-
date,
|
|
27
|
-
inputMethod,
|
|
28
|
-
commitMethod,
|
|
29
|
-
enterPressed = true
|
|
30
|
-
}) => ({
|
|
31
|
-
tr
|
|
32
|
-
}) => {
|
|
33
|
-
var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
|
|
34
|
-
const {
|
|
35
|
-
schema
|
|
36
|
-
} = tr.doc.type;
|
|
37
|
-
let timestamp;
|
|
38
|
-
if (date) {
|
|
39
|
-
timestamp = Date.UTC(date.year, date.month - 1, date.day).toString();
|
|
40
|
-
} else {
|
|
41
|
-
timestamp = todayTimestampInUTC();
|
|
42
|
-
}
|
|
43
|
-
if (inputMethod) {
|
|
44
|
-
var _pluginInjectionApi$a, _pluginInjectionApi$a2;
|
|
45
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : (_pluginInjectionApi$a2 = _pluginInjectionApi$a.actions) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.attachAnalyticsEvent({
|
|
46
|
-
action: ACTION.INSERTED,
|
|
47
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
48
|
-
actionSubjectId: ACTION_SUBJECT_ID.DATE,
|
|
49
|
-
eventType: EVENT_TYPE.TRACK,
|
|
50
|
-
attributes: {
|
|
51
|
-
inputMethod
|
|
52
|
-
}
|
|
53
|
-
})(tr);
|
|
54
|
-
}
|
|
55
|
-
if (commitMethod) {
|
|
56
|
-
var _pluginInjectionApi$a3, _pluginInjectionApi$a4;
|
|
57
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : (_pluginInjectionApi$a4 = _pluginInjectionApi$a3.actions) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.attachAnalyticsEvent({
|
|
58
|
-
eventType: EVENT_TYPE.TRACK,
|
|
59
|
-
action: ACTION.COMMITTED,
|
|
60
|
-
actionSubject: ACTION_SUBJECT.DATE,
|
|
61
|
-
attributes: {
|
|
62
|
-
commitMethod,
|
|
63
|
-
isValid: date !== undefined,
|
|
64
|
-
isToday: isToday(date)
|
|
65
|
-
}
|
|
66
|
-
})(tr);
|
|
67
|
-
}
|
|
68
|
-
const {
|
|
69
|
-
showDatePickerAt
|
|
70
|
-
} = (_pluginInjectionApi$d3 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d4 = pluginInjectionApi.date) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.sharedState.currentState()) !== null && _pluginInjectionApi$d3 !== void 0 ? _pluginInjectionApi$d3 : {};
|
|
71
|
-
if (!showDatePickerAt) {
|
|
72
|
-
const dateNode = schema.nodes.date.createChecked({
|
|
73
|
-
timestamp
|
|
74
|
-
});
|
|
75
|
-
const textNode = schema.text(' ');
|
|
76
|
-
const fragment = Fragment.fromArray([dateNode, textNode]);
|
|
77
|
-
const {
|
|
78
|
-
from,
|
|
79
|
-
to
|
|
80
|
-
} = tr.selection;
|
|
81
|
-
const insertable = canInsert(tr.selection.$from, fragment);
|
|
82
|
-
if (!insertable) {
|
|
83
|
-
const parentSelection = NodeSelection.create(tr.doc, tr.selection.from - tr.selection.$anchor.parentOffset - 1);
|
|
84
|
-
tr.insert(parentSelection.to, fragment).setSelection(NodeSelection.create(tr.doc, parentSelection.to + 1));
|
|
85
|
-
} else {
|
|
86
|
-
tr.replaceWith(from, to, fragment).setSelection(NodeSelection.create(tr.doc, from));
|
|
87
|
-
}
|
|
88
|
-
if (tr.docChanged) {
|
|
89
|
-
tr.scrollIntoView().setMeta(pluginKey, {
|
|
90
|
-
isNew: true
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
return tr;
|
|
94
|
-
}
|
|
95
|
-
if (tr.doc.nodeAt(showDatePickerAt)) {
|
|
96
|
-
if (enterPressed) {
|
|
97
|
-
// Setting selection to outside the date node causes showDatePickerAt
|
|
98
|
-
// to be set to null by the PM plugin (onSelectionChanged), which will
|
|
99
|
-
// immediately close the datepicker once a valid date is typed in.
|
|
100
|
-
// Adding this check forces it to stay open until the user presses Enter.
|
|
101
|
-
tr = tr.setSelection(Selection.near(tr.doc.resolve(showDatePickerAt + 2)));
|
|
102
|
-
}
|
|
103
|
-
tr = tr.setNodeMarkup(showDatePickerAt, schema.nodes.date, {
|
|
104
|
-
timestamp
|
|
105
|
-
}).setMeta(pluginKey, {
|
|
106
|
-
isNew: false
|
|
107
|
-
}).scrollIntoView();
|
|
108
|
-
if (!enterPressed) {
|
|
109
|
-
tr = tr.setSelection(NodeSelection.create(tr.doc, showDatePickerAt));
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return tr;
|
|
113
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as datePlugin } from './plugin';
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { DateSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
3
|
-
import { useIntl } from 'react-intl-next';
|
|
4
|
-
import { timestampToString, timestampToTaskContext, isPastDate } from '@atlaskit/editor-common/utils';
|
|
5
|
-
import { Date } from '@atlaskit/date';
|
|
6
|
-
import { setDatePickerAt } from '../actions';
|
|
7
|
-
export function DateNodeView(props) {
|
|
8
|
-
const {
|
|
9
|
-
node: {
|
|
10
|
-
attrs: {
|
|
11
|
-
timestamp
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
view: {
|
|
15
|
-
state: {
|
|
16
|
-
doc,
|
|
17
|
-
schema,
|
|
18
|
-
selection
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
getPos
|
|
22
|
-
} = props;
|
|
23
|
-
const intl = useIntl();
|
|
24
|
-
let pos = typeof getPos === 'function' ? getPos() : undefined;
|
|
25
|
-
|
|
26
|
-
// We fall back to selection.$from even though it does not cover all use cases
|
|
27
|
-
// eg. upon Editor init, selection is at the start, not at the Date node
|
|
28
|
-
const $nodePos = typeof pos === 'number' ? doc.resolve(pos) : selection.$from;
|
|
29
|
-
const parent = $nodePos.parent;
|
|
30
|
-
const withinIncompleteTask = parent.type === schema.nodes.taskItem && parent.attrs.state !== 'DONE';
|
|
31
|
-
const color = withinIncompleteTask && isPastDate(timestamp) ? 'red' : undefined;
|
|
32
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
33
|
-
className: DateSharedCssClassName.DATE_WRAPPER,
|
|
34
|
-
onClick: handleClick
|
|
35
|
-
}, /*#__PURE__*/React.createElement(Date, {
|
|
36
|
-
color: color,
|
|
37
|
-
value: timestamp
|
|
38
|
-
}, withinIncompleteTask ? timestampToTaskContext(timestamp, intl) : timestampToString(timestamp, intl)));
|
|
39
|
-
function handleClick(event) {
|
|
40
|
-
event.nativeEvent.stopImmediatePropagation();
|
|
41
|
-
const {
|
|
42
|
-
state,
|
|
43
|
-
dispatch
|
|
44
|
-
} = props.view;
|
|
45
|
-
setDatePickerAt(state.selection.from)(state, dispatch);
|
|
46
|
-
}
|
|
47
|
-
}
|