@atlaskit/editor-plugin-date 2.6.1 → 2.6.3
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 +15 -0
- package/dist/cjs/datePlugin.js +2 -2
- package/dist/cjs/nodeviews/date.js +8 -16
- package/dist/cjs/nodeviews/dateNodeSpec.js +56 -0
- package/dist/cjs/nodeviews/utils.js +30 -0
- package/dist/es2019/datePlugin.js +2 -2
- package/dist/es2019/nodeviews/date.js +10 -24
- package/dist/es2019/nodeviews/dateNodeSpec.js +47 -0
- package/dist/es2019/nodeviews/utils.js +28 -0
- package/dist/esm/datePlugin.js +2 -2
- package/dist/esm/nodeviews/date.js +8 -16
- package/dist/esm/nodeviews/dateNodeSpec.js +49 -0
- package/dist/esm/nodeviews/utils.js +24 -0
- package/dist/types/nodeviews/dateNodeSpec.d.ts +8 -0
- package/dist/types/nodeviews/utils.d.ts +8 -0
- package/dist/types-ts4.5/nodeviews/dateNodeSpec.d.ts +8 -0
- package/dist/types-ts4.5/nodeviews/utils.d.ts +8 -0
- package/package.json +14 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-date
|
|
2
2
|
|
|
3
|
+
## 2.6.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 2.6.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#112186](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/112186)
|
|
14
|
+
[`9462d8ca2405a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9462d8ca2405a) -
|
|
15
|
+
Bump adf-schema to 47.2.1
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 2.6.1
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/cjs/datePlugin.js
CHANGED
|
@@ -8,7 +8,6 @@ exports.default = void 0;
|
|
|
8
8
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _reactLoadable = _interopRequireDefault(require("react-loadable"));
|
|
11
|
-
var _adfSchema = require("@atlaskit/adf-schema");
|
|
12
11
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
12
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
14
13
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
@@ -19,6 +18,7 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
19
18
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
20
19
|
var _comment = _interopRequireDefault(require("@atlaskit/icon/core/comment"));
|
|
21
20
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
|
+
var _dateNodeSpec = require("./nodeviews/dateNodeSpec");
|
|
22
22
|
var _actions = require("./pm-plugins/actions");
|
|
23
23
|
var _commands = require("./pm-plugins/commands");
|
|
24
24
|
var _keymap = _interopRequireDefault(require("./pm-plugins/keymap"));
|
|
@@ -142,7 +142,7 @@ var datePlugin = function datePlugin(_ref3) {
|
|
|
142
142
|
nodes: function nodes() {
|
|
143
143
|
return [{
|
|
144
144
|
name: 'date',
|
|
145
|
-
node:
|
|
145
|
+
node: (0, _dateNodeSpec.dateNodeSpec)()
|
|
146
146
|
}];
|
|
147
147
|
},
|
|
148
148
|
pmPlugins: function pmPlugins() {
|
|
@@ -9,24 +9,16 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
var _reactIntlNext = require("react-intl-next");
|
|
10
10
|
var _date = require("@atlaskit/date");
|
|
11
11
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
12
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
13
12
|
var _actions = require("../pm-plugins/actions");
|
|
13
|
+
var _utils = require("./utils");
|
|
14
14
|
function DateNodeView(props) {
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
doc = _props$view$state.doc,
|
|
18
|
-
schema = _props$view$state.schema,
|
|
19
|
-
selection = _props$view$state.selection,
|
|
20
|
-
getPos = props.getPos;
|
|
15
|
+
var _props$getPos;
|
|
16
|
+
var timestamp = props.node.attrs.timestamp;
|
|
21
17
|
var intl = (0, _reactIntlNext.useIntl)();
|
|
22
|
-
var pos =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
var $nodePos = typeof pos === 'number' ? doc.resolve(pos) : selection.$from;
|
|
27
|
-
var parent = $nodePos.parent;
|
|
28
|
-
var withinIncompleteTask = parent.type === schema.nodes.taskItem && parent.attrs.state !== 'DONE';
|
|
29
|
-
var color = withinIncompleteTask && (0, _utils.isPastDate)(timestamp) ? 'red' : undefined;
|
|
18
|
+
var pos = (_props$getPos = props.getPos) === null || _props$getPos === void 0 ? void 0 : _props$getPos.call(props);
|
|
19
|
+
var _getDateInformation = (0, _utils.getDateInformation)(timestamp, intl, props.view.state, pos),
|
|
20
|
+
displayString = _getDateInformation.displayString,
|
|
21
|
+
color = _getDateInformation.color;
|
|
30
22
|
return (
|
|
31
23
|
/*#__PURE__*/
|
|
32
24
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop, jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -- Ignored via go/DSP-18766
|
|
@@ -36,7 +28,7 @@ function DateNodeView(props) {
|
|
|
36
28
|
}, /*#__PURE__*/_react.default.createElement(_date.Date, {
|
|
37
29
|
color: color,
|
|
38
30
|
value: timestamp
|
|
39
|
-
},
|
|
31
|
+
}, displayString))
|
|
40
32
|
);
|
|
41
33
|
function handleClick(event) {
|
|
42
34
|
event.nativeEvent.stopImmediatePropagation();
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.dateNodeSpec = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _reactIntlNext = require("react-intl-next");
|
|
10
|
+
var _adfSchema = require("@atlaskit/adf-schema");
|
|
11
|
+
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
12
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
13
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
var isSSR = Boolean(process.env.REACT_SSR);
|
|
18
|
+
var intl;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Wrapper for ADF date node spec to augment toDOM implementation
|
|
22
|
+
* with fallback UI for lazy node view rendering / window virtualization
|
|
23
|
+
* @nodeSpecException:toDOM patch
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
var dateNodeSpec = exports.dateNodeSpec = function dateNodeSpec() {
|
|
27
|
+
if (isSSR || !(0, _platformFeatureFlags.fg)('platform_editor_lego__inline_node_virtualization')) {
|
|
28
|
+
return _adfSchema.date;
|
|
29
|
+
}
|
|
30
|
+
return _objectSpread(_objectSpread({}, _adfSchema.date), {}, {
|
|
31
|
+
toDOM: function toDOM(node) {
|
|
32
|
+
intl = intl || (0, _reactIntlNext.createIntl)({
|
|
33
|
+
locale: document.documentElement.lang || 'en-US'
|
|
34
|
+
});
|
|
35
|
+
var timestamp = node.attrs.timestamp;
|
|
36
|
+
var displayString = (0, _utils.timestampToString)(timestamp, intl);
|
|
37
|
+
var wrapperAttrs = {
|
|
38
|
+
class: 'date-lozenger-container',
|
|
39
|
+
'data-node-type': 'date',
|
|
40
|
+
'data-timestamp': timestamp,
|
|
41
|
+
'aria-busy': 'true'
|
|
42
|
+
};
|
|
43
|
+
var attrs = {
|
|
44
|
+
style: (0, _lazyNodeView.convertToInlineCss)({
|
|
45
|
+
// Taken from @atlaskit/date Component
|
|
46
|
+
backgroundColor: "var(--ds-background-neutral, ".concat(_colors.N30A, ")"),
|
|
47
|
+
color: "var(--ds-text, ".concat(_colors.N800, ")"),
|
|
48
|
+
borderRadius: "var(--ds-border-radius-100, 4px)",
|
|
49
|
+
padding: "var(--ds-space-025, 2px)".concat(" ", "var(--ds-space-050, 4px)"),
|
|
50
|
+
margin: '0 1px'
|
|
51
|
+
})
|
|
52
|
+
};
|
|
53
|
+
return ['span', wrapperAttrs, ['span', attrs, displayString]];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getDateInformation = void 0;
|
|
7
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
8
|
+
var getDateInformation = exports.getDateInformation = function getDateInformation(timestamp, intl, state, pos) {
|
|
9
|
+
if (!state) {
|
|
10
|
+
return {
|
|
11
|
+
color: undefined,
|
|
12
|
+
displayString: (0, _utils.timestampToString)(timestamp, intl)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
var doc = state.doc,
|
|
16
|
+
selection = state.selection;
|
|
17
|
+
var taskItem = state.schema.nodes.taskItem;
|
|
18
|
+
|
|
19
|
+
// We fall back to selection.$from even though it does not cover all use cases
|
|
20
|
+
// eg. upon Editor init, selection is at the start, not at the Date node
|
|
21
|
+
var $nodePos = typeof pos === 'number' ? doc.resolve(pos) : selection.$from;
|
|
22
|
+
var parent = $nodePos.parent;
|
|
23
|
+
var withinIncompleteTask = parent.type === taskItem && parent.attrs.state !== 'DONE';
|
|
24
|
+
var color = withinIncompleteTask && (0, _utils.isPastDate)(timestamp) ? 'red' : undefined;
|
|
25
|
+
var displayString = withinIncompleteTask ? (0, _utils.timestampToTaskContext)(timestamp, intl) : (0, _utils.timestampToString)(timestamp, intl);
|
|
26
|
+
return {
|
|
27
|
+
displayString: displayString,
|
|
28
|
+
color: color
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Loadable from 'react-loadable';
|
|
3
|
-
import { date } from '@atlaskit/adf-schema';
|
|
4
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
4
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
6
5
|
import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
@@ -11,6 +10,7 @@ import { calculateToolbarPositionAboveSelection } from '@atlaskit/editor-common/
|
|
|
11
10
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
12
11
|
import CommentIcon from '@atlaskit/icon/core/comment';
|
|
13
12
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
|
+
import { dateNodeSpec } from './nodeviews/dateNodeSpec';
|
|
14
14
|
import { closeDatePicker, closeDatePickerWithAnalytics, createDate } from './pm-plugins/actions';
|
|
15
15
|
import { deleteDateCommand, insertDateCommand } from './pm-plugins/commands';
|
|
16
16
|
import keymap from './pm-plugins/keymap';
|
|
@@ -131,7 +131,7 @@ const datePlugin = ({
|
|
|
131
131
|
nodes() {
|
|
132
132
|
return [{
|
|
133
133
|
name: 'date',
|
|
134
|
-
node:
|
|
134
|
+
node: dateNodeSpec()
|
|
135
135
|
}];
|
|
136
136
|
},
|
|
137
137
|
pmPlugins() {
|
|
@@ -2,33 +2,19 @@ import React from 'react';
|
|
|
2
2
|
import { useIntl } from 'react-intl-next';
|
|
3
3
|
import { Date } from '@atlaskit/date';
|
|
4
4
|
import { DateSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
5
|
-
import { isPastDate, timestampToString, timestampToTaskContext } from '@atlaskit/editor-common/utils';
|
|
6
5
|
import { setDatePickerAt } from '../pm-plugins/actions';
|
|
6
|
+
import { getDateInformation } from './utils';
|
|
7
7
|
export function DateNodeView(props) {
|
|
8
|
+
var _props$getPos;
|
|
8
9
|
const {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
timestamp
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
view: {
|
|
15
|
-
state: {
|
|
16
|
-
doc,
|
|
17
|
-
schema,
|
|
18
|
-
selection
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
getPos
|
|
22
|
-
} = props;
|
|
10
|
+
timestamp
|
|
11
|
+
} = props.node.attrs;
|
|
23
12
|
const intl = useIntl();
|
|
24
|
-
const pos =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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;
|
|
13
|
+
const pos = (_props$getPos = props.getPos) === null || _props$getPos === void 0 ? void 0 : _props$getPos.call(props);
|
|
14
|
+
const {
|
|
15
|
+
displayString,
|
|
16
|
+
color
|
|
17
|
+
} = getDateInformation(timestamp, intl, props.view.state, pos);
|
|
32
18
|
return (
|
|
33
19
|
/*#__PURE__*/
|
|
34
20
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop, jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -- Ignored via go/DSP-18766
|
|
@@ -38,7 +24,7 @@ export function DateNodeView(props) {
|
|
|
38
24
|
}, /*#__PURE__*/React.createElement(Date, {
|
|
39
25
|
color: color,
|
|
40
26
|
value: timestamp
|
|
41
|
-
},
|
|
27
|
+
}, displayString))
|
|
42
28
|
);
|
|
43
29
|
function handleClick(event) {
|
|
44
30
|
event.nativeEvent.stopImmediatePropagation();
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createIntl } from 'react-intl-next';
|
|
2
|
+
import { date } from '@atlaskit/adf-schema';
|
|
3
|
+
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
4
|
+
import { timestampToString } from '@atlaskit/editor-common/utils';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
|
+
import { N30A, N800 } from '@atlaskit/theme/colors';
|
|
7
|
+
const isSSR = Boolean(process.env.REACT_SSR);
|
|
8
|
+
let intl;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wrapper for ADF date node spec to augment toDOM implementation
|
|
12
|
+
* with fallback UI for lazy node view rendering / window virtualization
|
|
13
|
+
* @nodeSpecException:toDOM patch
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export const dateNodeSpec = () => {
|
|
17
|
+
if (isSSR || !fg('platform_editor_lego__inline_node_virtualization')) {
|
|
18
|
+
return date;
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
...date,
|
|
22
|
+
toDOM: node => {
|
|
23
|
+
intl = intl || createIntl({
|
|
24
|
+
locale: document.documentElement.lang || 'en-US'
|
|
25
|
+
});
|
|
26
|
+
const timestamp = node.attrs.timestamp;
|
|
27
|
+
const displayString = timestampToString(timestamp, intl);
|
|
28
|
+
const wrapperAttrs = {
|
|
29
|
+
class: 'date-lozenger-container',
|
|
30
|
+
'data-node-type': 'date',
|
|
31
|
+
'data-timestamp': timestamp,
|
|
32
|
+
'aria-busy': 'true'
|
|
33
|
+
};
|
|
34
|
+
const attrs = {
|
|
35
|
+
style: convertToInlineCss({
|
|
36
|
+
// Taken from @atlaskit/date Component
|
|
37
|
+
backgroundColor: `var(--ds-background-neutral, ${N30A})`,
|
|
38
|
+
color: `var(--ds-text, ${N800})`,
|
|
39
|
+
borderRadius: "var(--ds-border-radius-100, 4px)",
|
|
40
|
+
padding: `${"var(--ds-space-025, 2px)"} ${"var(--ds-space-050, 4px)"}`,
|
|
41
|
+
margin: '0 1px'
|
|
42
|
+
})
|
|
43
|
+
};
|
|
44
|
+
return ['span', wrapperAttrs, ['span', attrs, displayString]];
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { isPastDate, timestampToString, timestampToTaskContext } from '@atlaskit/editor-common/utils';
|
|
2
|
+
export const getDateInformation = (timestamp, intl, state, pos) => {
|
|
3
|
+
if (!state) {
|
|
4
|
+
return {
|
|
5
|
+
color: undefined,
|
|
6
|
+
displayString: timestampToString(timestamp, intl)
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
const {
|
|
10
|
+
doc,
|
|
11
|
+
selection
|
|
12
|
+
} = state;
|
|
13
|
+
const {
|
|
14
|
+
taskItem
|
|
15
|
+
} = state.schema.nodes;
|
|
16
|
+
|
|
17
|
+
// We fall back to selection.$from even though it does not cover all use cases
|
|
18
|
+
// eg. upon Editor init, selection is at the start, not at the Date node
|
|
19
|
+
const $nodePos = typeof pos === 'number' ? doc.resolve(pos) : selection.$from;
|
|
20
|
+
const parent = $nodePos.parent;
|
|
21
|
+
const withinIncompleteTask = parent.type === taskItem && parent.attrs.state !== 'DONE';
|
|
22
|
+
const color = withinIncompleteTask && isPastDate(timestamp) ? 'red' : undefined;
|
|
23
|
+
const displayString = withinIncompleteTask ? timestampToTaskContext(timestamp, intl) : timestampToString(timestamp, intl);
|
|
24
|
+
return {
|
|
25
|
+
displayString,
|
|
26
|
+
color
|
|
27
|
+
};
|
|
28
|
+
};
|
package/dist/esm/datePlugin.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Loadable from 'react-loadable';
|
|
3
|
-
import { date } from '@atlaskit/adf-schema';
|
|
4
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
4
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
6
5
|
import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
@@ -11,6 +10,7 @@ import { calculateToolbarPositionAboveSelection } from '@atlaskit/editor-common/
|
|
|
11
10
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
12
11
|
import CommentIcon from '@atlaskit/icon/core/comment';
|
|
13
12
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
|
+
import { dateNodeSpec } from './nodeviews/dateNodeSpec';
|
|
14
14
|
import { closeDatePicker as _closeDatePicker, closeDatePickerWithAnalytics as _closeDatePickerWithAnalytics, createDate } from './pm-plugins/actions';
|
|
15
15
|
import { deleteDateCommand, insertDateCommand } from './pm-plugins/commands';
|
|
16
16
|
import keymap from './pm-plugins/keymap';
|
|
@@ -130,7 +130,7 @@ var datePlugin = function datePlugin(_ref3) {
|
|
|
130
130
|
nodes: function nodes() {
|
|
131
131
|
return [{
|
|
132
132
|
name: 'date',
|
|
133
|
-
node:
|
|
133
|
+
node: dateNodeSpec()
|
|
134
134
|
}];
|
|
135
135
|
},
|
|
136
136
|
pmPlugins: function pmPlugins() {
|
|
@@ -2,24 +2,16 @@ import React from 'react';
|
|
|
2
2
|
import { useIntl } from 'react-intl-next';
|
|
3
3
|
import { Date } from '@atlaskit/date';
|
|
4
4
|
import { DateSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
5
|
-
import { isPastDate, timestampToString, timestampToTaskContext } from '@atlaskit/editor-common/utils';
|
|
6
5
|
import { setDatePickerAt } from '../pm-plugins/actions';
|
|
6
|
+
import { getDateInformation } from './utils';
|
|
7
7
|
export function DateNodeView(props) {
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
doc = _props$view$state.doc,
|
|
11
|
-
schema = _props$view$state.schema,
|
|
12
|
-
selection = _props$view$state.selection,
|
|
13
|
-
getPos = props.getPos;
|
|
8
|
+
var _props$getPos;
|
|
9
|
+
var timestamp = props.node.attrs.timestamp;
|
|
14
10
|
var intl = useIntl();
|
|
15
|
-
var pos =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var $nodePos = typeof pos === 'number' ? doc.resolve(pos) : selection.$from;
|
|
20
|
-
var parent = $nodePos.parent;
|
|
21
|
-
var withinIncompleteTask = parent.type === schema.nodes.taskItem && parent.attrs.state !== 'DONE';
|
|
22
|
-
var color = withinIncompleteTask && isPastDate(timestamp) ? 'red' : undefined;
|
|
11
|
+
var pos = (_props$getPos = props.getPos) === null || _props$getPos === void 0 ? void 0 : _props$getPos.call(props);
|
|
12
|
+
var _getDateInformation = getDateInformation(timestamp, intl, props.view.state, pos),
|
|
13
|
+
displayString = _getDateInformation.displayString,
|
|
14
|
+
color = _getDateInformation.color;
|
|
23
15
|
return (
|
|
24
16
|
/*#__PURE__*/
|
|
25
17
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop, jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -- Ignored via go/DSP-18766
|
|
@@ -29,7 +21,7 @@ export function DateNodeView(props) {
|
|
|
29
21
|
}, /*#__PURE__*/React.createElement(Date, {
|
|
30
22
|
color: color,
|
|
31
23
|
value: timestamp
|
|
32
|
-
},
|
|
24
|
+
}, displayString))
|
|
33
25
|
);
|
|
34
26
|
function handleClick(event) {
|
|
35
27
|
event.nativeEvent.stopImmediatePropagation();
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
import { createIntl } from 'react-intl-next';
|
|
5
|
+
import { date } from '@atlaskit/adf-schema';
|
|
6
|
+
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
7
|
+
import { timestampToString } from '@atlaskit/editor-common/utils';
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
|
+
import { N30A, N800 } from '@atlaskit/theme/colors';
|
|
10
|
+
var isSSR = Boolean(process.env.REACT_SSR);
|
|
11
|
+
var intl;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Wrapper for ADF date node spec to augment toDOM implementation
|
|
15
|
+
* with fallback UI for lazy node view rendering / window virtualization
|
|
16
|
+
* @nodeSpecException:toDOM patch
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
export var dateNodeSpec = function dateNodeSpec() {
|
|
20
|
+
if (isSSR || !fg('platform_editor_lego__inline_node_virtualization')) {
|
|
21
|
+
return date;
|
|
22
|
+
}
|
|
23
|
+
return _objectSpread(_objectSpread({}, date), {}, {
|
|
24
|
+
toDOM: function toDOM(node) {
|
|
25
|
+
intl = intl || createIntl({
|
|
26
|
+
locale: document.documentElement.lang || 'en-US'
|
|
27
|
+
});
|
|
28
|
+
var timestamp = node.attrs.timestamp;
|
|
29
|
+
var displayString = timestampToString(timestamp, intl);
|
|
30
|
+
var wrapperAttrs = {
|
|
31
|
+
class: 'date-lozenger-container',
|
|
32
|
+
'data-node-type': 'date',
|
|
33
|
+
'data-timestamp': timestamp,
|
|
34
|
+
'aria-busy': 'true'
|
|
35
|
+
};
|
|
36
|
+
var attrs = {
|
|
37
|
+
style: convertToInlineCss({
|
|
38
|
+
// Taken from @atlaskit/date Component
|
|
39
|
+
backgroundColor: "var(--ds-background-neutral, ".concat(N30A, ")"),
|
|
40
|
+
color: "var(--ds-text, ".concat(N800, ")"),
|
|
41
|
+
borderRadius: "var(--ds-border-radius-100, 4px)",
|
|
42
|
+
padding: "var(--ds-space-025, 2px)".concat(" ", "var(--ds-space-050, 4px)"),
|
|
43
|
+
margin: '0 1px'
|
|
44
|
+
})
|
|
45
|
+
};
|
|
46
|
+
return ['span', wrapperAttrs, ['span', attrs, displayString]];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { isPastDate, timestampToString, timestampToTaskContext } from '@atlaskit/editor-common/utils';
|
|
2
|
+
export var getDateInformation = function getDateInformation(timestamp, intl, state, pos) {
|
|
3
|
+
if (!state) {
|
|
4
|
+
return {
|
|
5
|
+
color: undefined,
|
|
6
|
+
displayString: timestampToString(timestamp, intl)
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
var doc = state.doc,
|
|
10
|
+
selection = state.selection;
|
|
11
|
+
var taskItem = state.schema.nodes.taskItem;
|
|
12
|
+
|
|
13
|
+
// We fall back to selection.$from even though it does not cover all use cases
|
|
14
|
+
// eg. upon Editor init, selection is at the start, not at the Date node
|
|
15
|
+
var $nodePos = typeof pos === 'number' ? doc.resolve(pos) : selection.$from;
|
|
16
|
+
var parent = $nodePos.parent;
|
|
17
|
+
var withinIncompleteTask = parent.type === taskItem && parent.attrs.state !== 'DONE';
|
|
18
|
+
var color = withinIncompleteTask && isPastDate(timestamp) ? 'red' : undefined;
|
|
19
|
+
var displayString = withinIncompleteTask ? timestampToTaskContext(timestamp, intl) : timestampToString(timestamp, intl);
|
|
20
|
+
return {
|
|
21
|
+
displayString: displayString,
|
|
22
|
+
color: color
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { NodeSpec } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
/**
|
|
3
|
+
* Wrapper for ADF date node spec to augment toDOM implementation
|
|
4
|
+
* with fallback UI for lazy node view rendering / window virtualization
|
|
5
|
+
* @nodeSpecException:toDOM patch
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare const dateNodeSpec: () => NodeSpec;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/dist/types/state';
|
|
3
|
+
type DateInformation = {
|
|
4
|
+
color: 'red' | undefined;
|
|
5
|
+
displayString: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const getDateInformation: (timestamp: string | number, intl: IntlShape, state?: EditorState, pos?: number) => DateInformation;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { NodeSpec } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
/**
|
|
3
|
+
* Wrapper for ADF date node spec to augment toDOM implementation
|
|
4
|
+
* with fallback UI for lazy node view rendering / window virtualization
|
|
5
|
+
* @nodeSpecException:toDOM patch
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare const dateNodeSpec: () => NodeSpec;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/dist/types/state';
|
|
3
|
+
type DateInformation = {
|
|
4
|
+
color: 'red' | undefined;
|
|
5
|
+
displayString: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const getDateInformation: (timestamp: string | number, intl: IntlShape, state?: EditorState, pos?: number) => DateInformation;
|
|
8
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-date",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.3",
|
|
4
4
|
"description": "Date plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,22 +31,22 @@
|
|
|
31
31
|
".": "./src/index.ts"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaskit/adf-schema": "^
|
|
34
|
+
"@atlaskit/adf-schema": "^47.2.1",
|
|
35
35
|
"@atlaskit/calendar": "^16.3.0",
|
|
36
36
|
"@atlaskit/date": "^1.0.0",
|
|
37
|
-
"@atlaskit/editor-common": "^99.
|
|
37
|
+
"@atlaskit/editor-common": "^99.17.0",
|
|
38
38
|
"@atlaskit/editor-plugin-analytics": "^1.12.0",
|
|
39
|
-
"@atlaskit/editor-plugin-annotation": "1.28.
|
|
39
|
+
"@atlaskit/editor-plugin-annotation": "1.28.1",
|
|
40
40
|
"@atlaskit/editor-plugin-editor-disabled": "^1.5.0",
|
|
41
41
|
"@atlaskit/editor-plugin-editor-viewmode": "^2.2.0",
|
|
42
42
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
43
|
-
"@atlaskit/editor-shared-styles": "^3.
|
|
43
|
+
"@atlaskit/editor-shared-styles": "^3.3.0",
|
|
44
44
|
"@atlaskit/form": "^11.1.0",
|
|
45
|
-
"@atlaskit/icon": "^23.
|
|
45
|
+
"@atlaskit/icon": "^23.9.0",
|
|
46
46
|
"@atlaskit/locale": "^2.8.0",
|
|
47
|
-
"@atlaskit/platform-feature-flags": "^1.
|
|
48
|
-
"@atlaskit/textfield": "6.8.
|
|
49
|
-
"@atlaskit/theme": "^
|
|
47
|
+
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
48
|
+
"@atlaskit/textfield": "6.8.3",
|
|
49
|
+
"@atlaskit/theme": "^16.0.0",
|
|
50
50
|
"@atlaskit/tokens": "^3.3.0",
|
|
51
51
|
"@babel/runtime": "^7.0.0",
|
|
52
52
|
"@emotion/react": "^11.7.1",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"@atlaskit/editor-plugin-feature-flags": "^1.3.0",
|
|
62
62
|
"@atlaskit/editor-plugin-guideline": "^1.4.0",
|
|
63
63
|
"@atlaskit/editor-plugin-quick-insert": "^1.10.0",
|
|
64
|
-
"@atlaskit/editor-plugin-selection": "^1.
|
|
65
|
-
"@atlaskit/editor-plugin-table": "^9.
|
|
64
|
+
"@atlaskit/editor-plugin-selection": "^1.8.0",
|
|
65
|
+
"@atlaskit/editor-plugin-table": "^9.5.0",
|
|
66
66
|
"@atlaskit/editor-plugin-tasks-and-decisions": "^2.14.0",
|
|
67
67
|
"@atlaskit/editor-plugin-type-ahead": "^1.13.0",
|
|
68
68
|
"@atlaskit/editor-plugin-width": "^2.1.0",
|
|
@@ -114,6 +114,9 @@
|
|
|
114
114
|
},
|
|
115
115
|
"platform_inline_node_as_valid_annotation_selection": {
|
|
116
116
|
"type": "boolean"
|
|
117
|
+
},
|
|
118
|
+
"platform_editor_lego__inline_node_virtualization": {
|
|
119
|
+
"type": "boolean"
|
|
117
120
|
}
|
|
118
121
|
}
|
|
119
122
|
}
|