@atlaskit/editor-core 188.10.5 → 188.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/architecture/0003-explicit-plugin-dependencies.md +1 -1
- package/dist/cjs/labs/next/presets/universal.js +4 -3
- package/dist/cjs/messages.js +1 -2
- package/dist/cjs/plugins/index.js +0 -14
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/labs/next/presets/universal.js +3 -2
- package/dist/es2019/messages.js +1 -2
- package/dist/es2019/plugins/index.js +0 -2
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/labs/next/presets/universal.js +3 -2
- package/dist/esm/messages.js +1 -2
- package/dist/esm/plugins/index.js +0 -2
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/messages.d.ts +1 -2
- package/dist/types/plugins/index.d.ts +0 -2
- package/dist/types/plugins/insert-block/types.d.ts +2 -4
- package/dist/types/types/editor-props.d.ts +1 -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/messages.d.ts +1 -2
- package/dist/types-ts4.5/plugins/index.d.ts +0 -2
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +2 -4
- package/dist/types-ts4.5/types/editor-props.d.ts +1 -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 +7 -10
- package/report.api.md +1 -9
- package/tmp/api-report-tmp.d.ts +1 -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/cjs/plugins/mentions/analytics.js +0 -157
- package/dist/cjs/plugins/mentions/index.js +0 -142
- package/dist/cjs/plugins/mentions/messages.js +0 -29
- package/dist/cjs/plugins/mentions/nodeviews/mention.js +0 -117
- package/dist/cjs/plugins/mentions/pm-plugins/key.js +0 -8
- package/dist/cjs/plugins/mentions/pm-plugins/main.js +0 -156
- package/dist/cjs/plugins/mentions/pm-plugins/utils.js +0 -23
- package/dist/cjs/plugins/mentions/type-ahead/index.js +0 -362
- package/dist/cjs/plugins/mentions/types.js +0 -5
- package/dist/cjs/plugins/mentions/ui/InviteItem/index.js +0 -76
- package/dist/cjs/plugins/mentions/ui/InviteItem/styles.js +0 -19
- package/dist/cjs/plugins/mentions/ui/Mention/index.js +0 -98
- package/dist/cjs/plugins/mentions/ui/ToolbarMention/index.js +0 -63
- package/dist/cjs/plugins/mentions/utils.js +0 -32
- 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/es2019/plugins/mentions/analytics.js +0 -147
- package/dist/es2019/plugins/mentions/index.js +0 -124
- package/dist/es2019/plugins/mentions/messages.js +0 -23
- package/dist/es2019/plugins/mentions/nodeviews/mention.js +0 -80
- package/dist/es2019/plugins/mentions/pm-plugins/key.js +0 -2
- package/dist/es2019/plugins/mentions/pm-plugins/main.js +0 -143
- package/dist/es2019/plugins/mentions/pm-plugins/utils.js +0 -14
- package/dist/es2019/plugins/mentions/type-ahead/index.js +0 -338
- package/dist/es2019/plugins/mentions/types.js +0 -1
- package/dist/es2019/plugins/mentions/ui/InviteItem/index.js +0 -66
- package/dist/es2019/plugins/mentions/ui/InviteItem/styles.js +0 -47
- package/dist/es2019/plugins/mentions/ui/Mention/index.js +0 -71
- package/dist/es2019/plugins/mentions/ui/ToolbarMention/index.js +0 -33
- package/dist/es2019/plugins/mentions/utils.js +0 -20
- 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/esm/plugins/mentions/analytics.js +0 -150
- package/dist/esm/plugins/mentions/index.js +0 -130
- package/dist/esm/plugins/mentions/messages.js +0 -23
- package/dist/esm/plugins/mentions/nodeviews/mention.js +0 -107
- package/dist/esm/plugins/mentions/pm-plugins/key.js +0 -2
- package/dist/esm/plugins/mentions/pm-plugins/main.js +0 -148
- package/dist/esm/plugins/mentions/pm-plugins/utils.js +0 -16
- package/dist/esm/plugins/mentions/type-ahead/index.js +0 -350
- package/dist/esm/plugins/mentions/types.js +0 -1
- package/dist/esm/plugins/mentions/ui/InviteItem/index.js +0 -65
- package/dist/esm/plugins/mentions/ui/InviteItem/styles.js +0 -12
- package/dist/esm/plugins/mentions/ui/Mention/index.js +0 -91
- package/dist/esm/plugins/mentions/ui/ToolbarMention/index.js +0 -53
- package/dist/esm/plugins/mentions/utils.js +0 -26
- 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/plugins/mentions/analytics.d.ts +0 -13
- package/dist/types/plugins/mentions/index.d.ts +0 -19
- package/dist/types/plugins/mentions/messages.d.ts +0 -22
- package/dist/types/plugins/mentions/nodeviews/mention.d.ts +0 -9
- package/dist/types/plugins/mentions/pm-plugins/key.d.ts +0 -3
- package/dist/types/plugins/mentions/pm-plugins/main.d.ts +0 -6
- package/dist/types/plugins/mentions/pm-plugins/utils.d.ts +0 -4
- package/dist/types/plugins/mentions/type-ahead/index.d.ts +0 -17
- package/dist/types/plugins/mentions/types.d.ts +0 -24
- package/dist/types/plugins/mentions/ui/InviteItem/index.d.ts +0 -22
- package/dist/types/plugins/mentions/ui/InviteItem/styles.d.ts +0 -8
- package/dist/types/plugins/mentions/ui/Mention/index.d.ts +0 -19
- package/dist/types/plugins/mentions/ui/ToolbarMention/index.d.ts +0 -13
- package/dist/types/plugins/mentions/utils.d.ts +0 -8
- 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
- package/dist/types-ts4.5/plugins/mentions/analytics.d.ts +0 -13
- package/dist/types-ts4.5/plugins/mentions/index.d.ts +0 -22
- package/dist/types-ts4.5/plugins/mentions/messages.d.ts +0 -22
- package/dist/types-ts4.5/plugins/mentions/nodeviews/mention.d.ts +0 -9
- package/dist/types-ts4.5/plugins/mentions/pm-plugins/key.d.ts +0 -3
- package/dist/types-ts4.5/plugins/mentions/pm-plugins/main.d.ts +0 -6
- package/dist/types-ts4.5/plugins/mentions/pm-plugins/utils.d.ts +0 -4
- package/dist/types-ts4.5/plugins/mentions/type-ahead/index.d.ts +0 -17
- package/dist/types-ts4.5/plugins/mentions/types.d.ts +0 -24
- package/dist/types-ts4.5/plugins/mentions/ui/InviteItem/index.d.ts +0 -22
- package/dist/types-ts4.5/plugins/mentions/ui/InviteItem/styles.d.ts +0 -8
- package/dist/types-ts4.5/plugins/mentions/ui/Mention/index.d.ts +0 -19
- package/dist/types-ts4.5/plugins/mentions/ui/ToolbarMention/index.d.ts +0 -13
- package/dist/types-ts4.5/plugins/mentions/utils.d.ts +0 -8
|
@@ -1,112 +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 var deleteDateCommand = function deleteDateCommand(pluginInjectionApi) {
|
|
10
|
-
return function (_ref) {
|
|
11
|
-
var _pluginInjectionApi$d, _pluginInjectionApi$d2;
|
|
12
|
-
var tr = _ref.tr;
|
|
13
|
-
var _ref2 = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d2 = pluginInjectionApi.date) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.sharedState.currentState()) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {},
|
|
14
|
-
showDatePickerAt = _ref2.showDatePickerAt;
|
|
15
|
-
if (!showDatePickerAt) {
|
|
16
|
-
return tr;
|
|
17
|
-
}
|
|
18
|
-
tr.delete(showDatePickerAt, showDatePickerAt + 1).setMeta(pluginKey, {
|
|
19
|
-
showDatePickerAt: null,
|
|
20
|
-
isNew: false
|
|
21
|
-
});
|
|
22
|
-
return tr;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
export var insertDateCommand = function insertDateCommand(pluginInjectionApi) {
|
|
26
|
-
return function (_ref3) {
|
|
27
|
-
var date = _ref3.date,
|
|
28
|
-
inputMethod = _ref3.inputMethod,
|
|
29
|
-
commitMethod = _ref3.commitMethod,
|
|
30
|
-
_ref3$enterPressed = _ref3.enterPressed,
|
|
31
|
-
enterPressed = _ref3$enterPressed === void 0 ? true : _ref3$enterPressed;
|
|
32
|
-
return function (_ref4) {
|
|
33
|
-
var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
|
|
34
|
-
var tr = _ref4.tr;
|
|
35
|
-
var schema = tr.doc.type.schema;
|
|
36
|
-
var timestamp;
|
|
37
|
-
if (date) {
|
|
38
|
-
timestamp = Date.UTC(date.year, date.month - 1, date.day).toString();
|
|
39
|
-
} else {
|
|
40
|
-
timestamp = todayTimestampInUTC();
|
|
41
|
-
}
|
|
42
|
-
if (inputMethod) {
|
|
43
|
-
var _pluginInjectionApi$a;
|
|
44
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 || (_pluginInjectionApi$a = _pluginInjectionApi$a.actions) === null || _pluginInjectionApi$a === void 0 || _pluginInjectionApi$a.attachAnalyticsEvent({
|
|
45
|
-
action: ACTION.INSERTED,
|
|
46
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
47
|
-
actionSubjectId: ACTION_SUBJECT_ID.DATE,
|
|
48
|
-
eventType: EVENT_TYPE.TRACK,
|
|
49
|
-
attributes: {
|
|
50
|
-
inputMethod: inputMethod
|
|
51
|
-
}
|
|
52
|
-
})(tr);
|
|
53
|
-
}
|
|
54
|
-
if (commitMethod) {
|
|
55
|
-
var _pluginInjectionApi$a2;
|
|
56
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 || (_pluginInjectionApi$a2 = _pluginInjectionApi$a2.actions) === null || _pluginInjectionApi$a2 === void 0 || _pluginInjectionApi$a2.attachAnalyticsEvent({
|
|
57
|
-
eventType: EVENT_TYPE.TRACK,
|
|
58
|
-
action: ACTION.COMMITTED,
|
|
59
|
-
actionSubject: ACTION_SUBJECT.DATE,
|
|
60
|
-
attributes: {
|
|
61
|
-
commitMethod: commitMethod,
|
|
62
|
-
isValid: date !== undefined,
|
|
63
|
-
isToday: isToday(date)
|
|
64
|
-
}
|
|
65
|
-
})(tr);
|
|
66
|
-
}
|
|
67
|
-
var _ref5 = (_pluginInjectionApi$d3 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d4 = pluginInjectionApi.date) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.sharedState.currentState()) !== null && _pluginInjectionApi$d3 !== void 0 ? _pluginInjectionApi$d3 : {},
|
|
68
|
-
showDatePickerAt = _ref5.showDatePickerAt;
|
|
69
|
-
if (!showDatePickerAt) {
|
|
70
|
-
var dateNode = schema.nodes.date.createChecked({
|
|
71
|
-
timestamp: timestamp
|
|
72
|
-
});
|
|
73
|
-
var textNode = schema.text(' ');
|
|
74
|
-
var fragment = Fragment.fromArray([dateNode, textNode]);
|
|
75
|
-
var _tr$selection = tr.selection,
|
|
76
|
-
from = _tr$selection.from,
|
|
77
|
-
to = _tr$selection.to;
|
|
78
|
-
var insertable = canInsert(tr.selection.$from, fragment);
|
|
79
|
-
if (!insertable) {
|
|
80
|
-
var parentSelection = NodeSelection.create(tr.doc, tr.selection.from - tr.selection.$anchor.parentOffset - 1);
|
|
81
|
-
tr.insert(parentSelection.to, fragment).setSelection(NodeSelection.create(tr.doc, parentSelection.to + 1));
|
|
82
|
-
} else {
|
|
83
|
-
tr.replaceWith(from, to, fragment).setSelection(NodeSelection.create(tr.doc, from));
|
|
84
|
-
}
|
|
85
|
-
if (tr.docChanged) {
|
|
86
|
-
tr.scrollIntoView().setMeta(pluginKey, {
|
|
87
|
-
isNew: true
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
return tr;
|
|
91
|
-
}
|
|
92
|
-
if (tr.doc.nodeAt(showDatePickerAt)) {
|
|
93
|
-
if (enterPressed) {
|
|
94
|
-
// Setting selection to outside the date node causes showDatePickerAt
|
|
95
|
-
// to be set to null by the PM plugin (onSelectionChanged), which will
|
|
96
|
-
// immediately close the datepicker once a valid date is typed in.
|
|
97
|
-
// Adding this check forces it to stay open until the user presses Enter.
|
|
98
|
-
tr = tr.setSelection(Selection.near(tr.doc.resolve(showDatePickerAt + 2)));
|
|
99
|
-
}
|
|
100
|
-
tr = tr.setNodeMarkup(showDatePickerAt, schema.nodes.date, {
|
|
101
|
-
timestamp: timestamp
|
|
102
|
-
}).setMeta(pluginKey, {
|
|
103
|
-
isNew: false
|
|
104
|
-
}).scrollIntoView();
|
|
105
|
-
if (!enterPressed) {
|
|
106
|
-
tr = tr.setSelection(NodeSelection.create(tr.doc, showDatePickerAt));
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return tr;
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as datePlugin } from './plugin';
|
|
@@ -1,37 +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
|
-
var timestamp = props.node.attrs.timestamp,
|
|
9
|
-
_props$view$state = props.view.state,
|
|
10
|
-
doc = _props$view$state.doc,
|
|
11
|
-
schema = _props$view$state.schema,
|
|
12
|
-
selection = _props$view$state.selection,
|
|
13
|
-
getPos = props.getPos;
|
|
14
|
-
var intl = useIntl();
|
|
15
|
-
var pos = typeof getPos === 'function' ? getPos() : undefined;
|
|
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
|
-
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;
|
|
23
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
24
|
-
className: DateSharedCssClassName.DATE_WRAPPER,
|
|
25
|
-
onClick: handleClick
|
|
26
|
-
}, /*#__PURE__*/React.createElement(Date, {
|
|
27
|
-
color: color,
|
|
28
|
-
value: timestamp
|
|
29
|
-
}, withinIncompleteTask ? timestampToTaskContext(timestamp, intl) : timestampToString(timestamp, intl)));
|
|
30
|
-
function handleClick(event) {
|
|
31
|
-
event.nativeEvent.stopImmediatePropagation();
|
|
32
|
-
var _props$view = props.view,
|
|
33
|
-
state = _props$view.state,
|
|
34
|
-
dispatch = _props$view.dispatch;
|
|
35
|
-
setDatePickerAt(state.selection.from)(state, dispatch);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
-
import Loadable from 'react-loadable';
|
|
4
|
-
import { date } from '@atlaskit/adf-schema';
|
|
5
|
-
import { closeDatePicker as _closeDatePicker, closeDatePickerWithAnalytics as _closeDatePickerWithAnalytics, createDate } from './actions';
|
|
6
|
-
import { insertDateCommand, deleteDateCommand } from './commands';
|
|
7
|
-
import createDatePlugin from './pm-plugins/main';
|
|
8
|
-
import keymap from './pm-plugins/keymap';
|
|
9
|
-
import { IconDate } from '@atlaskit/editor-common/quick-insert';
|
|
10
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
11
|
-
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
12
|
-
import { pluginKey as datePluginKey } from './pm-plugins/plugin-key';
|
|
13
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
14
|
-
var DatePicker = Loadable({
|
|
15
|
-
loader: function loader() {
|
|
16
|
-
return import( /* webpackChunkName: "@atlaskit-internal_editor-datepicker" */'./ui/DatePicker').then(function (mod) {
|
|
17
|
-
return mod.default;
|
|
18
|
-
});
|
|
19
|
-
},
|
|
20
|
-
loading: function loading() {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
function ContentComponent(_ref) {
|
|
25
|
-
var editorView = _ref.editorView,
|
|
26
|
-
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
27
|
-
popupsMountPoint = _ref.popupsMountPoint,
|
|
28
|
-
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
|
29
|
-
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
30
|
-
dependencyApi = _ref.dependencyApi,
|
|
31
|
-
weekStartDay = _ref.weekStartDay;
|
|
32
|
-
var dispatch = editorView.dispatch;
|
|
33
|
-
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
34
|
-
var _useSharedPluginState = useSharedPluginState(dependencyApi, ['date', 'editorDisabled']),
|
|
35
|
-
editorDisabledState = _useSharedPluginState.editorDisabledState,
|
|
36
|
-
dateState = _useSharedPluginState.dateState;
|
|
37
|
-
if (!(dateState !== null && dateState !== void 0 && dateState.showDatePickerAt) || editorDisabledState !== null && editorDisabledState !== void 0 && editorDisabledState.editorDisabled) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
var showDatePickerAt = dateState.showDatePickerAt,
|
|
41
|
-
isNew = dateState.isNew,
|
|
42
|
-
focusDateInput = dateState.focusDateInput;
|
|
43
|
-
var element = findDomRefAtPos(showDatePickerAt, domAtPos);
|
|
44
|
-
return /*#__PURE__*/React.createElement(DatePicker, {
|
|
45
|
-
mountTo: popupsMountPoint,
|
|
46
|
-
boundariesElement: popupsBoundariesElement,
|
|
47
|
-
scrollableElement: popupsScrollableElement,
|
|
48
|
-
key: showDatePickerAt,
|
|
49
|
-
element: element,
|
|
50
|
-
isNew: isNew,
|
|
51
|
-
autoFocus: focusDateInput,
|
|
52
|
-
onDelete: function onDelete() {
|
|
53
|
-
dependencyApi === null || dependencyApi === void 0 || dependencyApi.core.actions.execute(deleteDateCommand(dependencyApi));
|
|
54
|
-
editorView.focus();
|
|
55
|
-
},
|
|
56
|
-
onSelect: function onSelect(date, commitMethod) {
|
|
57
|
-
// Undefined means couldn't parse date, null means invalid (out of bounds) date
|
|
58
|
-
if (date === undefined || date === null) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
dependencyApi === null || dependencyApi === void 0 || dependencyApi.core.actions.execute(insertDateCommand(dependencyApi)({
|
|
62
|
-
date: date,
|
|
63
|
-
commitMethod: commitMethod
|
|
64
|
-
}));
|
|
65
|
-
editorView.focus();
|
|
66
|
-
},
|
|
67
|
-
onTextChanged: function onTextChanged(date) {
|
|
68
|
-
dependencyApi === null || dependencyApi === void 0 || dependencyApi.core.actions.execute(insertDateCommand(dependencyApi)({
|
|
69
|
-
date: date,
|
|
70
|
-
enterPressed: false
|
|
71
|
-
}));
|
|
72
|
-
},
|
|
73
|
-
closeDatePicker: function closeDatePicker() {
|
|
74
|
-
_closeDatePicker()(editorView.state, dispatch);
|
|
75
|
-
editorView.focus();
|
|
76
|
-
},
|
|
77
|
-
closeDatePickerWithAnalytics: function closeDatePickerWithAnalytics(_ref2) {
|
|
78
|
-
var date = _ref2.date;
|
|
79
|
-
_closeDatePickerWithAnalytics({
|
|
80
|
-
date: date
|
|
81
|
-
})(editorView.state, dispatch);
|
|
82
|
-
editorView.focus();
|
|
83
|
-
},
|
|
84
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
85
|
-
weekStartDay: weekStartDay
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
var datePlugin = function datePlugin(_ref3) {
|
|
89
|
-
var _ref3$config = _ref3.config,
|
|
90
|
-
options = _ref3$config === void 0 ? {} : _ref3$config,
|
|
91
|
-
api = _ref3.api;
|
|
92
|
-
return {
|
|
93
|
-
name: 'date',
|
|
94
|
-
getSharedState: function getSharedState(editorState) {
|
|
95
|
-
if (!editorState) {
|
|
96
|
-
return {
|
|
97
|
-
showDatePickerAt: null,
|
|
98
|
-
isNew: false,
|
|
99
|
-
focusDateInput: false
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
var _ref4 = datePluginKey.getState(editorState) || {},
|
|
103
|
-
showDatePickerAt = _ref4.showDatePickerAt,
|
|
104
|
-
isNew = _ref4.isNew,
|
|
105
|
-
focusDateInput = _ref4.focusDateInput;
|
|
106
|
-
return {
|
|
107
|
-
showDatePickerAt: showDatePickerAt,
|
|
108
|
-
isNew: !!isNew,
|
|
109
|
-
focusDateInput: !!focusDateInput
|
|
110
|
-
};
|
|
111
|
-
},
|
|
112
|
-
commands: {
|
|
113
|
-
insertDate: insertDateCommand(api),
|
|
114
|
-
deleteDate: deleteDateCommand(api)
|
|
115
|
-
},
|
|
116
|
-
nodes: function nodes() {
|
|
117
|
-
return [{
|
|
118
|
-
name: 'date',
|
|
119
|
-
node: date
|
|
120
|
-
}];
|
|
121
|
-
},
|
|
122
|
-
pmPlugins: function pmPlugins() {
|
|
123
|
-
return [{
|
|
124
|
-
name: 'date',
|
|
125
|
-
plugin: function plugin(options) {
|
|
126
|
-
DatePicker.preload();
|
|
127
|
-
return createDatePlugin(options);
|
|
128
|
-
}
|
|
129
|
-
}, {
|
|
130
|
-
name: 'dateKeymap',
|
|
131
|
-
plugin: function plugin() {
|
|
132
|
-
DatePicker.preload();
|
|
133
|
-
return keymap();
|
|
134
|
-
}
|
|
135
|
-
}];
|
|
136
|
-
},
|
|
137
|
-
contentComponent: function contentComponent(_ref5) {
|
|
138
|
-
var editorView = _ref5.editorView,
|
|
139
|
-
dispatchAnalyticsEvent = _ref5.dispatchAnalyticsEvent,
|
|
140
|
-
popupsMountPoint = _ref5.popupsMountPoint,
|
|
141
|
-
popupsBoundariesElement = _ref5.popupsBoundariesElement,
|
|
142
|
-
popupsScrollableElement = _ref5.popupsScrollableElement;
|
|
143
|
-
return /*#__PURE__*/React.createElement(ContentComponent, {
|
|
144
|
-
dependencyApi: api,
|
|
145
|
-
editorView: editorView,
|
|
146
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
147
|
-
popupsMountPoint: popupsMountPoint,
|
|
148
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
149
|
-
popupsScrollableElement: popupsScrollableElement,
|
|
150
|
-
weekStartDay: options.weekStartDay
|
|
151
|
-
});
|
|
152
|
-
},
|
|
153
|
-
pluginsOptions: {
|
|
154
|
-
quickInsert: function quickInsert(_ref6) {
|
|
155
|
-
var formatMessage = _ref6.formatMessage;
|
|
156
|
-
return [{
|
|
157
|
-
id: 'date',
|
|
158
|
-
title: formatMessage(messages.date),
|
|
159
|
-
description: formatMessage(messages.dateDescription),
|
|
160
|
-
priority: 800,
|
|
161
|
-
keywords: ['calendar', 'day', 'time', 'today', '/'],
|
|
162
|
-
keyshortcut: '//',
|
|
163
|
-
icon: function icon() {
|
|
164
|
-
return /*#__PURE__*/React.createElement(IconDate, null);
|
|
165
|
-
},
|
|
166
|
-
action: function action(insert, state) {
|
|
167
|
-
var _api$analytics, _api$analytics$attach;
|
|
168
|
-
var tr = createDate(true)(insert, state);
|
|
169
|
-
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || (_api$analytics$attach = _api$analytics.attachAnalyticsEvent) === null || _api$analytics$attach === void 0 || _api$analytics$attach.call(_api$analytics, {
|
|
170
|
-
action: ACTION.INSERTED,
|
|
171
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
172
|
-
actionSubjectId: ACTION_SUBJECT_ID.DATE,
|
|
173
|
-
eventType: EVENT_TYPE.TRACK,
|
|
174
|
-
attributes: {
|
|
175
|
-
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
176
|
-
}
|
|
177
|
-
})(tr);
|
|
178
|
-
return tr;
|
|
179
|
-
}
|
|
180
|
-
}];
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
};
|
|
185
|
-
export default datePlugin;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import { closeDatePicker, openDatePicker, focusDateInput } from '../actions';
|
|
3
|
-
import { keymap, enter, tab, bindKeymapWithCommand } from '@atlaskit/editor-common/keymaps';
|
|
4
|
-
import { getPluginState } from './main';
|
|
5
|
-
export function keymapPlugin() {
|
|
6
|
-
var list = {};
|
|
7
|
-
bindKeymapWithCommand(enter.common, function (state, dispatch) {
|
|
8
|
-
var datePlugin = getPluginState(state);
|
|
9
|
-
var isDateNode = state.selection instanceof NodeSelection ? state.selection.node.type === state.schema.nodes.date : false;
|
|
10
|
-
if (!isDateNode) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
if (!datePlugin.showDatePickerAt) {
|
|
14
|
-
openDatePicker()(state, dispatch);
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
closeDatePicker()(state, dispatch);
|
|
18
|
-
return true;
|
|
19
|
-
}, list);
|
|
20
|
-
bindKeymapWithCommand(tab.common, function (state, dispatch) {
|
|
21
|
-
var datePlugin = getPluginState(state);
|
|
22
|
-
var isDateNode = state.selection instanceof NodeSelection ? state.selection.node.type === state.schema.nodes.date : false;
|
|
23
|
-
if (!isDateNode) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
if (datePlugin.showDatePickerAt) {
|
|
27
|
-
focusDateInput()(state, dispatch);
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
return false;
|
|
31
|
-
}, list);
|
|
32
|
-
return keymap(list);
|
|
33
|
-
}
|
|
34
|
-
export default keymapPlugin;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { DateNodeView } from '../nodeviews/date';
|
|
3
|
-
import { getInlineNodeViewProducer } from '@atlaskit/editor-common/react-node-view';
|
|
4
|
-
import { pluginFactory } from '@atlaskit/editor-common/utils';
|
|
5
|
-
import { reducer, mapping, onSelectionChanged } from './utils';
|
|
6
|
-
import { pluginKey } from './plugin-key';
|
|
7
|
-
var _pluginFactory = pluginFactory(pluginKey, reducer, {
|
|
8
|
-
mapping: mapping,
|
|
9
|
-
onSelectionChanged: onSelectionChanged
|
|
10
|
-
}),
|
|
11
|
-
createPluginState = _pluginFactory.createPluginState,
|
|
12
|
-
getPluginState = _pluginFactory.getPluginState;
|
|
13
|
-
var createPlugin = function createPlugin(pmPluginFactoryParams) {
|
|
14
|
-
var newPluginState = {
|
|
15
|
-
showDatePickerAt: null,
|
|
16
|
-
isNew: false,
|
|
17
|
-
isDateEmpty: false,
|
|
18
|
-
focusDateInput: false
|
|
19
|
-
};
|
|
20
|
-
return new SafePlugin({
|
|
21
|
-
state: createPluginState(pmPluginFactoryParams.dispatch, newPluginState),
|
|
22
|
-
key: pluginKey,
|
|
23
|
-
props: {
|
|
24
|
-
nodeViews: {
|
|
25
|
-
date: getInlineNodeViewProducer({
|
|
26
|
-
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
27
|
-
Component: DateNodeView
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
export { getPluginState };
|
|
34
|
-
export default createPlugin;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,61 +0,0 @@
|
|
|
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 { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
export function reducer(pluginState, meta) {
|
|
6
|
-
// If the same nodeview is clicked twice, calendar should close
|
|
7
|
-
if (meta.showDatePickerAt === pluginState.showDatePickerAt) {
|
|
8
|
-
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
9
|
-
showDatePickerAt: null
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
var showDatePickerAt = pluginState.showDatePickerAt,
|
|
13
|
-
isNew = pluginState.isNew;
|
|
14
|
-
var showDatePickerAtMeta = meta.showDatePickerAt;
|
|
15
|
-
// If date picker position has changed, it is no longer new
|
|
16
|
-
if (showDatePickerAt && showDatePickerAtMeta && showDatePickerAt !== showDatePickerAtMeta && isNew) {
|
|
17
|
-
return _objectSpread(_objectSpread(_objectSpread({}, pluginState), meta), {}, {
|
|
18
|
-
isNew: false
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
return _objectSpread(_objectSpread({}, pluginState), meta);
|
|
22
|
-
}
|
|
23
|
-
export function mapping(tr, pluginState) {
|
|
24
|
-
if (!pluginState.showDatePickerAt) {
|
|
25
|
-
return pluginState;
|
|
26
|
-
}
|
|
27
|
-
var _tr$mapping$mapResult = tr.mapping.mapResult(pluginState.showDatePickerAt),
|
|
28
|
-
pos = _tr$mapping$mapResult.pos;
|
|
29
|
-
return {
|
|
30
|
-
showDatePickerAt: pos,
|
|
31
|
-
isNew: pluginState.isNew,
|
|
32
|
-
isDateEmpty: pluginState.isDateEmpty,
|
|
33
|
-
focusDateInput: pluginState.focusDateInput
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export function onSelectionChanged(tr, pluginState) {
|
|
37
|
-
if (tr.docChanged && isDateNodeSelection(tr.selection)) {
|
|
38
|
-
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
39
|
-
isQuickInsertAction: false,
|
|
40
|
-
showDatePickerAt: tr.selection.from
|
|
41
|
-
});
|
|
42
|
-
} else if (!isDateNodeSelection(tr.selection) && !pluginState.isQuickInsertAction) {
|
|
43
|
-
if (pluginState.showDatePickerAt) {
|
|
44
|
-
return {
|
|
45
|
-
showDatePickerAt: null,
|
|
46
|
-
isNew: false,
|
|
47
|
-
isDateEmpty: false,
|
|
48
|
-
focusDateInput: false
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
return pluginState;
|
|
52
|
-
}
|
|
53
|
-
return pluginState;
|
|
54
|
-
}
|
|
55
|
-
var isDateNodeSelection = function isDateNodeSelection(selection) {
|
|
56
|
-
if (selection instanceof NodeSelection) {
|
|
57
|
-
var nodeTypeName = selection.node.type.name;
|
|
58
|
-
return nodeTypeName === 'date';
|
|
59
|
-
}
|
|
60
|
-
return false;
|
|
61
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|