@atlaskit/editor-core 188.7.3 → 188.7.6
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 +13 -0
- package/dist/cjs/messages.js +1 -2
- package/dist/cjs/plugins/date/actions.js +8 -114
- package/dist/cjs/plugins/date/commands.js +118 -0
- package/dist/cjs/plugins/date/plugin.js +13 -7
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +34 -33
- package/dist/cjs/plugins/status/index.js +3 -3
- package/dist/cjs/plugins/status/nodeviews/status.js +4 -3
- package/dist/cjs/ui/ContentStyles/index.js +2 -2
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/messages.js +1 -2
- package/dist/es2019/plugins/date/actions.js +3 -109
- package/dist/es2019/plugins/date/commands.js +113 -0
- package/dist/es2019/plugins/date/plugin.js +14 -8
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +5 -3
- package/dist/es2019/plugins/status/index.js +1 -1
- package/dist/es2019/plugins/status/nodeviews/status.js +3 -2
- package/dist/es2019/ui/ContentStyles/index.js +1 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/messages.js +1 -2
- package/dist/esm/plugins/date/actions.js +8 -114
- package/dist/esm/plugins/date/commands.js +112 -0
- package/dist/esm/plugins/date/plugin.js +14 -8
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +34 -33
- package/dist/esm/plugins/status/index.js +1 -1
- package/dist/esm/plugins/status/nodeviews/status.js +3 -2
- package/dist/esm/ui/ContentStyles/index.js +1 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/messages.d.ts +1 -2
- package/dist/types/plugins/date/actions.d.ts +4 -10
- package/dist/types/plugins/date/commands.d.ts +20 -0
- package/dist/types/plugins/date/types.d.ts +4 -4
- package/dist/types/plugins/status/analytics.d.ts +1 -1
- package/dist/types/plugins/status/nodeviews/status.d.ts +2 -1
- package/dist/types-ts4.5/messages.d.ts +1 -2
- package/dist/types-ts4.5/plugins/date/actions.d.ts +4 -10
- package/dist/types-ts4.5/plugins/date/commands.d.ts +22 -0
- package/dist/types-ts4.5/plugins/date/types.d.ts +4 -4
- package/dist/types-ts4.5/plugins/status/analytics.d.ts +1 -1
- package/dist/types-ts4.5/plugins/status/nodeviews/status.d.ts +2 -1
- package/package.json +3 -3
- package/dist/cjs/plugins/status/nodeviews/messages.js +0 -24
- package/dist/es2019/plugins/status/nodeviews/messages.js +0 -18
- package/dist/esm/plugins/status/nodeviews/messages.js +0 -18
- package/dist/types/plugins/status/nodeviews/messages.d.ts +0 -17
- package/dist/types-ts4.5/plugins/status/nodeviews/messages.d.ts +0 -17
- /package/dist/cjs/{plugins/status/styles.js → ui/ContentStyles/status.js} +0 -0
- /package/dist/es2019/{plugins/status/styles.js → ui/ContentStyles/status.js} +0 -0
- /package/dist/esm/{plugins/status/styles.js → ui/ContentStyles/status.js} +0 -0
- /package/dist/types/{plugins/status/styles.d.ts → ui/ContentStyles/status.d.ts} +0 -0
- /package/dist/types-ts4.5/{plugins/status/styles.d.ts → ui/ContentStyles/status.d.ts} +0 -0
|
@@ -2,9 +2,8 @@ import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
|
2
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import { todayTimestampInUTC } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
5
|
-
import { ACTION, ACTION_SUBJECT,
|
|
5
|
+
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
6
|
import { isToday } from './utils/internal';
|
|
7
|
-
import { canInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
8
7
|
export const createDate = isQuickInsertAction => (insert, state) => {
|
|
9
8
|
const dateNode = state.schema.nodes.date.createChecked({
|
|
10
9
|
timestamp: todayTimestampInUTC()
|
|
@@ -23,25 +22,6 @@ export const createDate = isQuickInsertAction => (insert, state) => {
|
|
|
23
22
|
return tr.setMeta(pluginKey, newPluginState);
|
|
24
23
|
};
|
|
25
24
|
|
|
26
|
-
/** Delete the date and close the datepicker */
|
|
27
|
-
export const deleteDate = () => (state, dispatch) => {
|
|
28
|
-
const pluginState = pluginKey.getState(state);
|
|
29
|
-
if (!pluginState || pluginState.showDatePickerAt === null) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
const {
|
|
33
|
-
showDatePickerAt
|
|
34
|
-
} = pluginState;
|
|
35
|
-
const tr = state.tr.delete(showDatePickerAt, showDatePickerAt + 1).setMeta(pluginKey, {
|
|
36
|
-
showDatePickerAt: null,
|
|
37
|
-
isNew: false
|
|
38
|
-
});
|
|
39
|
-
if (dispatch) {
|
|
40
|
-
dispatch(tr);
|
|
41
|
-
}
|
|
42
|
-
return true;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
25
|
/** Focus input */
|
|
46
26
|
export const focusDateInput = () => (state, dispatch) => {
|
|
47
27
|
const pluginState = pluginKey.getState(state);
|
|
@@ -57,92 +37,6 @@ export const focusDateInput = () => (state, dispatch) => {
|
|
|
57
37
|
dispatch(tr);
|
|
58
38
|
return true;
|
|
59
39
|
};
|
|
60
|
-
export const insertDate = (date, inputMethod, commitMethod, enterPressed = true, pluginInjectionApi) => (state, dispatch) => {
|
|
61
|
-
const {
|
|
62
|
-
schema
|
|
63
|
-
} = state;
|
|
64
|
-
let timestamp;
|
|
65
|
-
if (date) {
|
|
66
|
-
timestamp = Date.UTC(date.year, date.month - 1, date.day).toString();
|
|
67
|
-
} else {
|
|
68
|
-
timestamp = todayTimestampInUTC();
|
|
69
|
-
}
|
|
70
|
-
let tr = state.tr;
|
|
71
|
-
if (inputMethod) {
|
|
72
|
-
var _pluginInjectionApi$a, _pluginInjectionApi$a2;
|
|
73
|
-
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({
|
|
74
|
-
action: ACTION.INSERTED,
|
|
75
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
76
|
-
actionSubjectId: ACTION_SUBJECT_ID.DATE,
|
|
77
|
-
eventType: EVENT_TYPE.TRACK,
|
|
78
|
-
attributes: {
|
|
79
|
-
inputMethod
|
|
80
|
-
}
|
|
81
|
-
})(tr);
|
|
82
|
-
}
|
|
83
|
-
if (commitMethod) {
|
|
84
|
-
var _pluginInjectionApi$a3, _pluginInjectionApi$a4;
|
|
85
|
-
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({
|
|
86
|
-
eventType: EVENT_TYPE.TRACK,
|
|
87
|
-
action: ACTION.COMMITTED,
|
|
88
|
-
actionSubject: ACTION_SUBJECT.DATE,
|
|
89
|
-
attributes: {
|
|
90
|
-
commitMethod,
|
|
91
|
-
isValid: date !== undefined,
|
|
92
|
-
isToday: isToday(date)
|
|
93
|
-
}
|
|
94
|
-
})(tr);
|
|
95
|
-
}
|
|
96
|
-
const {
|
|
97
|
-
showDatePickerAt
|
|
98
|
-
} = pluginKey.getState(state) || {};
|
|
99
|
-
if (!showDatePickerAt) {
|
|
100
|
-
const dateNode = schema.nodes.date.createChecked({
|
|
101
|
-
timestamp
|
|
102
|
-
});
|
|
103
|
-
const textNode = state.schema.text(' ');
|
|
104
|
-
const fragment = Fragment.fromArray([dateNode, textNode]);
|
|
105
|
-
const {
|
|
106
|
-
from,
|
|
107
|
-
to
|
|
108
|
-
} = state.selection;
|
|
109
|
-
const insertable = canInsert(tr.selection.$from, fragment);
|
|
110
|
-
if (!insertable) {
|
|
111
|
-
const parentSelection = NodeSelection.create(tr.doc, tr.selection.from - tr.selection.$anchor.parentOffset - 1);
|
|
112
|
-
tr.insert(parentSelection.to, fragment).setSelection(NodeSelection.create(tr.doc, parentSelection.to + 1));
|
|
113
|
-
} else {
|
|
114
|
-
tr.replaceWith(from, to, fragment).setSelection(NodeSelection.create(tr.doc, from));
|
|
115
|
-
}
|
|
116
|
-
if (dispatch) {
|
|
117
|
-
dispatch(tr.scrollIntoView().setMeta(pluginKey, {
|
|
118
|
-
isNew: true
|
|
119
|
-
}));
|
|
120
|
-
}
|
|
121
|
-
return true;
|
|
122
|
-
}
|
|
123
|
-
if (state.doc.nodeAt(showDatePickerAt)) {
|
|
124
|
-
if (enterPressed) {
|
|
125
|
-
// Setting selection to outside the date node causes showDatePickerAt
|
|
126
|
-
// to be set to null by the PM plugin (onSelectionChanged), which will
|
|
127
|
-
// immediately close the datepicker once a valid date is typed in.
|
|
128
|
-
// Adding this check forces it to stay open until the user presses Enter.
|
|
129
|
-
tr = tr.setSelection(Selection.near(tr.doc.resolve(showDatePickerAt + 2)));
|
|
130
|
-
}
|
|
131
|
-
tr = tr.setNodeMarkup(showDatePickerAt, schema.nodes.date, {
|
|
132
|
-
timestamp
|
|
133
|
-
}).setMeta(pluginKey, {
|
|
134
|
-
isNew: false
|
|
135
|
-
}).scrollIntoView();
|
|
136
|
-
if (!enterPressed) {
|
|
137
|
-
tr = tr.setSelection(NodeSelection.create(tr.doc, showDatePickerAt));
|
|
138
|
-
}
|
|
139
|
-
if (dispatch) {
|
|
140
|
-
dispatch(tr);
|
|
141
|
-
}
|
|
142
|
-
return true;
|
|
143
|
-
}
|
|
144
|
-
return false;
|
|
145
|
-
};
|
|
146
40
|
export const setDatePickerAt = showDatePickerAt => (state, dispatch) => {
|
|
147
41
|
dispatch(state.tr.setMeta(pluginKey, {
|
|
148
42
|
showDatePickerAt
|
|
@@ -169,8 +63,8 @@ export const closeDatePickerWithAnalytics = ({
|
|
|
169
63
|
date,
|
|
170
64
|
pluginInjectionApi
|
|
171
65
|
}) => {
|
|
172
|
-
var _pluginInjectionApi$
|
|
173
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
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({
|
|
174
68
|
eventType: EVENT_TYPE.TRACK,
|
|
175
69
|
action: ACTION.COMMITTED,
|
|
176
70
|
actionSubject: ACTION_SUBJECT.DATE,
|
|
@@ -0,0 +1,113 @@
|
|
|
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
|
+
};
|
|
@@ -2,7 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
3
3
|
import Loadable from 'react-loadable';
|
|
4
4
|
import { date } from '@atlaskit/adf-schema';
|
|
5
|
-
import {
|
|
5
|
+
import { closeDatePicker, closeDatePickerWithAnalytics, createDate } from './actions';
|
|
6
|
+
import { insertDateCommand, deleteDateCommand } from './commands';
|
|
6
7
|
import createDatePlugin from './pm-plugins/main';
|
|
7
8
|
import keymap from './pm-plugins/keymap';
|
|
8
9
|
import { IconDate } from '@atlaskit/editor-common/quick-insert';
|
|
@@ -49,20 +50,25 @@ function ContentComponent({
|
|
|
49
50
|
isNew: isNew,
|
|
50
51
|
autoFocus: focusDateInput,
|
|
51
52
|
onDelete: () => {
|
|
52
|
-
|
|
53
|
+
dependencyApi === null || dependencyApi === void 0 ? void 0 : dependencyApi.core.actions.execute(deleteDateCommand(dependencyApi));
|
|
53
54
|
editorView.focus();
|
|
54
|
-
return;
|
|
55
55
|
},
|
|
56
56
|
onSelect: (date, commitMethod) => {
|
|
57
57
|
// Undefined means couldn't parse date, null means invalid (out of bounds) date
|
|
58
58
|
if (date === undefined || date === null) {
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
dependencyApi === null || dependencyApi === void 0 ? void 0 : dependencyApi.core.actions.execute(insertDateCommand(dependencyApi)({
|
|
62
|
+
date,
|
|
63
|
+
commitMethod
|
|
64
|
+
}));
|
|
62
65
|
editorView.focus();
|
|
63
66
|
},
|
|
64
67
|
onTextChanged: date => {
|
|
65
|
-
|
|
68
|
+
dependencyApi === null || dependencyApi === void 0 ? void 0 : dependencyApi.core.actions.execute(insertDateCommand(dependencyApi)({
|
|
69
|
+
date,
|
|
70
|
+
enterPressed: false
|
|
71
|
+
}));
|
|
66
72
|
},
|
|
67
73
|
closeDatePicker: () => {
|
|
68
74
|
closeDatePicker()(editorView.state, dispatch);
|
|
@@ -104,9 +110,9 @@ const datePlugin = ({
|
|
|
104
110
|
focusDateInput: !!focusDateInput
|
|
105
111
|
};
|
|
106
112
|
},
|
|
107
|
-
|
|
108
|
-
insertDate,
|
|
109
|
-
deleteDate
|
|
113
|
+
commands: {
|
|
114
|
+
insertDate: insertDateCommand(api),
|
|
115
|
+
deleteDate: deleteDateCommand(api)
|
|
110
116
|
},
|
|
111
117
|
nodes() {
|
|
112
118
|
return [{
|
|
@@ -191,10 +191,12 @@ export class ToolbarInsertBlock extends React.PureComponent {
|
|
|
191
191
|
_defineProperty(this, "createDate", inputMethod => {
|
|
192
192
|
var _pluginInjectionApi$d, _pluginInjectionApi$d2;
|
|
193
193
|
const {
|
|
194
|
-
pluginInjectionApi
|
|
195
|
-
editorView
|
|
194
|
+
pluginInjectionApi
|
|
196
195
|
} = this.props;
|
|
197
|
-
|
|
196
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.date) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.commands) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.insertDate({
|
|
197
|
+
inputMethod
|
|
198
|
+
}));
|
|
199
|
+
return true;
|
|
198
200
|
});
|
|
199
201
|
_defineProperty(this, "createPlaceholderText", () => {
|
|
200
202
|
const {
|
|
@@ -3,7 +3,7 @@ import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
|
3
3
|
import { status } from '@atlaskit/adf-schema';
|
|
4
4
|
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
5
5
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
|
-
import { messages } from '
|
|
6
|
+
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
7
|
import { IconStatus } from '@atlaskit/editor-common/quick-insert';
|
|
8
8
|
import { updateStatusWithAnalytics, commitStatusPicker, createStatus, updateStatus } from './actions';
|
|
9
9
|
import { keymapPlugin } from './keymap';
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
4
|
import { injectIntl } from 'react-intl-next';
|
|
5
5
|
import { Status } from '@atlaskit/status/element';
|
|
6
|
-
import { messages } from '
|
|
6
|
+
import { statusMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
7
|
const styledStatus = css`
|
|
8
8
|
opacity: 1;
|
|
9
9
|
`;
|
|
@@ -29,7 +29,8 @@ const StatusContainerView = props => {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
return jsx("span", {
|
|
32
|
-
css: text ? styledStatus : styledStatusPlaceholder
|
|
32
|
+
css: text ? styledStatus : styledStatusPlaceholder,
|
|
33
|
+
"data-testid": "statusContainerView"
|
|
33
34
|
}, jsx(Status, {
|
|
34
35
|
text: statusText,
|
|
35
36
|
color: color,
|
|
@@ -18,7 +18,7 @@ import { expandStyles } from '../../plugins/expand/ui/styles';
|
|
|
18
18
|
import { MediaSharedClassNames } from '@atlaskit/editor-common/styles';
|
|
19
19
|
import { findReplaceStyles } from '../../plugins/find-replace/styles';
|
|
20
20
|
import { taskDecisionStyles } from '../../plugins/tasks-and-decisions/styles';
|
|
21
|
-
import { statusStyles } from '
|
|
21
|
+
import { statusStyles } from './status';
|
|
22
22
|
import { dateStyles } from './date';
|
|
23
23
|
import { InlineNodeViewSharedStyles } from '../../nodeviews/getInlineNodeViewProducer.styles';
|
|
24
24
|
import { linkSharedStyle, codeMarkSharedStyles, ruleSharedStyles } from '@atlaskit/editor-common/styles';
|
package/dist/esm/messages.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Common Translations will live here
|
|
2
|
-
import commonMessages, { linkMessages, linkToolbarMessages } from '@atlaskit/editor-common/messages';
|
|
2
|
+
import commonMessages, { linkMessages, linkToolbarMessages, statusMessages } from '@atlaskit/editor-common/messages';
|
|
3
3
|
import { messages as dateMessages } from './plugins/date/nodeviews/messages';
|
|
4
|
-
import { messages as statusMessages } from './plugins/status/nodeviews/messages';
|
|
5
4
|
export { linkMessages };
|
|
6
5
|
export { statusMessages };
|
|
7
6
|
export { dateMessages };
|
|
@@ -2,9 +2,8 @@ import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
|
2
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import { todayTimestampInUTC } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
5
|
-
import { ACTION, ACTION_SUBJECT,
|
|
5
|
+
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
6
|
import { isToday } from './utils/internal';
|
|
7
|
-
import { canInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
8
7
|
export var createDate = function createDate(isQuickInsertAction) {
|
|
9
8
|
return function (insert, state) {
|
|
10
9
|
var dateNode = state.schema.nodes.date.createChecked({
|
|
@@ -25,25 +24,6 @@ export var createDate = function createDate(isQuickInsertAction) {
|
|
|
25
24
|
};
|
|
26
25
|
};
|
|
27
26
|
|
|
28
|
-
/** Delete the date and close the datepicker */
|
|
29
|
-
export var deleteDate = function deleteDate() {
|
|
30
|
-
return function (state, dispatch) {
|
|
31
|
-
var pluginState = pluginKey.getState(state);
|
|
32
|
-
if (!pluginState || pluginState.showDatePickerAt === null) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
var showDatePickerAt = pluginState.showDatePickerAt;
|
|
36
|
-
var tr = state.tr.delete(showDatePickerAt, showDatePickerAt + 1).setMeta(pluginKey, {
|
|
37
|
-
showDatePickerAt: null,
|
|
38
|
-
isNew: false
|
|
39
|
-
});
|
|
40
|
-
if (dispatch) {
|
|
41
|
-
dispatch(tr);
|
|
42
|
-
}
|
|
43
|
-
return true;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
|
|
47
27
|
/** Focus input */
|
|
48
28
|
export var focusDateInput = function focusDateInput() {
|
|
49
29
|
return function (state, dispatch) {
|
|
@@ -61,92 +41,6 @@ export var focusDateInput = function focusDateInput() {
|
|
|
61
41
|
return true;
|
|
62
42
|
};
|
|
63
43
|
};
|
|
64
|
-
export var insertDate = function insertDate(date, inputMethod, commitMethod) {
|
|
65
|
-
var enterPressed = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
66
|
-
var pluginInjectionApi = arguments.length > 4 ? arguments[4] : undefined;
|
|
67
|
-
return function (state, dispatch) {
|
|
68
|
-
var schema = state.schema;
|
|
69
|
-
var timestamp;
|
|
70
|
-
if (date) {
|
|
71
|
-
timestamp = Date.UTC(date.year, date.month - 1, date.day).toString();
|
|
72
|
-
} else {
|
|
73
|
-
timestamp = todayTimestampInUTC();
|
|
74
|
-
}
|
|
75
|
-
var tr = state.tr;
|
|
76
|
-
if (inputMethod) {
|
|
77
|
-
var _pluginInjectionApi$a;
|
|
78
|
-
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({
|
|
79
|
-
action: ACTION.INSERTED,
|
|
80
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
81
|
-
actionSubjectId: ACTION_SUBJECT_ID.DATE,
|
|
82
|
-
eventType: EVENT_TYPE.TRACK,
|
|
83
|
-
attributes: {
|
|
84
|
-
inputMethod: inputMethod
|
|
85
|
-
}
|
|
86
|
-
})(tr);
|
|
87
|
-
}
|
|
88
|
-
if (commitMethod) {
|
|
89
|
-
var _pluginInjectionApi$a2;
|
|
90
|
-
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({
|
|
91
|
-
eventType: EVENT_TYPE.TRACK,
|
|
92
|
-
action: ACTION.COMMITTED,
|
|
93
|
-
actionSubject: ACTION_SUBJECT.DATE,
|
|
94
|
-
attributes: {
|
|
95
|
-
commitMethod: commitMethod,
|
|
96
|
-
isValid: date !== undefined,
|
|
97
|
-
isToday: isToday(date)
|
|
98
|
-
}
|
|
99
|
-
})(tr);
|
|
100
|
-
}
|
|
101
|
-
var _ref = pluginKey.getState(state) || {},
|
|
102
|
-
showDatePickerAt = _ref.showDatePickerAt;
|
|
103
|
-
if (!showDatePickerAt) {
|
|
104
|
-
var dateNode = schema.nodes.date.createChecked({
|
|
105
|
-
timestamp: timestamp
|
|
106
|
-
});
|
|
107
|
-
var textNode = state.schema.text(' ');
|
|
108
|
-
var fragment = Fragment.fromArray([dateNode, textNode]);
|
|
109
|
-
var _state$selection = state.selection,
|
|
110
|
-
from = _state$selection.from,
|
|
111
|
-
to = _state$selection.to;
|
|
112
|
-
var insertable = canInsert(tr.selection.$from, fragment);
|
|
113
|
-
if (!insertable) {
|
|
114
|
-
var parentSelection = NodeSelection.create(tr.doc, tr.selection.from - tr.selection.$anchor.parentOffset - 1);
|
|
115
|
-
tr.insert(parentSelection.to, fragment).setSelection(NodeSelection.create(tr.doc, parentSelection.to + 1));
|
|
116
|
-
} else {
|
|
117
|
-
tr.replaceWith(from, to, fragment).setSelection(NodeSelection.create(tr.doc, from));
|
|
118
|
-
}
|
|
119
|
-
if (dispatch) {
|
|
120
|
-
dispatch(tr.scrollIntoView().setMeta(pluginKey, {
|
|
121
|
-
isNew: true
|
|
122
|
-
}));
|
|
123
|
-
}
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
if (state.doc.nodeAt(showDatePickerAt)) {
|
|
127
|
-
if (enterPressed) {
|
|
128
|
-
// Setting selection to outside the date node causes showDatePickerAt
|
|
129
|
-
// to be set to null by the PM plugin (onSelectionChanged), which will
|
|
130
|
-
// immediately close the datepicker once a valid date is typed in.
|
|
131
|
-
// Adding this check forces it to stay open until the user presses Enter.
|
|
132
|
-
tr = tr.setSelection(Selection.near(tr.doc.resolve(showDatePickerAt + 2)));
|
|
133
|
-
}
|
|
134
|
-
tr = tr.setNodeMarkup(showDatePickerAt, schema.nodes.date, {
|
|
135
|
-
timestamp: timestamp
|
|
136
|
-
}).setMeta(pluginKey, {
|
|
137
|
-
isNew: false
|
|
138
|
-
}).scrollIntoView();
|
|
139
|
-
if (!enterPressed) {
|
|
140
|
-
tr = tr.setSelection(NodeSelection.create(tr.doc, showDatePickerAt));
|
|
141
|
-
}
|
|
142
|
-
if (dispatch) {
|
|
143
|
-
dispatch(tr);
|
|
144
|
-
}
|
|
145
|
-
return true;
|
|
146
|
-
}
|
|
147
|
-
return false;
|
|
148
|
-
};
|
|
149
|
-
};
|
|
150
44
|
export var setDatePickerAt = function setDatePickerAt(showDatePickerAt) {
|
|
151
45
|
return function (state, dispatch) {
|
|
152
46
|
dispatch(state.tr.setMeta(pluginKey, {
|
|
@@ -157,8 +51,8 @@ export var setDatePickerAt = function setDatePickerAt(showDatePickerAt) {
|
|
|
157
51
|
};
|
|
158
52
|
export var closeDatePicker = function closeDatePicker() {
|
|
159
53
|
return function (state, dispatch) {
|
|
160
|
-
var
|
|
161
|
-
showDatePickerAt =
|
|
54
|
+
var _ref = pluginKey.getState(state) || {},
|
|
55
|
+
showDatePickerAt = _ref.showDatePickerAt;
|
|
162
56
|
if (!dispatch) {
|
|
163
57
|
return false;
|
|
164
58
|
}
|
|
@@ -172,11 +66,11 @@ export var closeDatePicker = function closeDatePicker() {
|
|
|
172
66
|
return false;
|
|
173
67
|
};
|
|
174
68
|
};
|
|
175
|
-
export var closeDatePickerWithAnalytics = function closeDatePickerWithAnalytics(
|
|
176
|
-
var _pluginInjectionApi$
|
|
177
|
-
var date =
|
|
178
|
-
pluginInjectionApi =
|
|
179
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
69
|
+
export var closeDatePickerWithAnalytics = function closeDatePickerWithAnalytics(_ref2) {
|
|
70
|
+
var _pluginInjectionApi$a;
|
|
71
|
+
var date = _ref2.date,
|
|
72
|
+
pluginInjectionApi = _ref2.pluginInjectionApi;
|
|
73
|
+
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({
|
|
180
74
|
eventType: EVENT_TYPE.TRACK,
|
|
181
75
|
action: ACTION.COMMITTED,
|
|
182
76
|
actionSubject: ACTION_SUBJECT.DATE,
|
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
};
|