@atlaskit/editor-plugin-date 0.2.7 → 0.2.9
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 +12 -0
- package/dist/cjs/actions.js +11 -5
- package/dist/cjs/plugin.js +1 -1
- package/dist/cjs/utils/internal.js +1 -1
- package/dist/es2019/actions.js +11 -5
- package/dist/es2019/plugin.js +1 -1
- package/dist/es2019/utils/internal.js +1 -1
- package/dist/esm/actions.js +11 -5
- package/dist/esm/plugin.js +1 -1
- package/dist/esm/utils/internal.js +1 -1
- package/dist/types/actions.d.ts +5 -7
- package/dist/types-ts4.5/actions.d.ts +5 -7
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-date
|
|
2
2
|
|
|
3
|
+
## 0.2.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#43549](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/43549) [`8f05c711498`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8f05c711498) - ED-20957 Fixed issue with adding date node inside a codeblock
|
|
8
|
+
|
|
9
|
+
## 0.2.8
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#43694](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/43694) [`fa3d07e4692`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fa3d07e4692) - [ux] [ED-20697] Fix issue where dates with dashes were being incorrectly marked as invalid
|
|
14
|
+
|
|
3
15
|
## 0.2.7
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/cjs/actions.js
CHANGED
|
@@ -8,17 +8,23 @@ var _analytics = require("@atlaskit/editor-common/analytics");
|
|
|
8
8
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
9
9
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
10
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
|
+
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
11
12
|
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
12
13
|
var _internal = require("./utils/internal");
|
|
13
14
|
var createDate = exports.createDate = function createDate(isQuickInsertAction) {
|
|
14
|
-
return function (
|
|
15
|
+
return function (state) {
|
|
15
16
|
var dateNode = state.schema.nodes.date.createChecked({
|
|
16
17
|
timestamp: (0, _utils.todayTimestampInUTC)()
|
|
17
18
|
});
|
|
18
|
-
var
|
|
19
|
-
var tr =
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
var fragment = _model.Fragment.fromArray([dateNode, state.schema.text(' ')]);
|
|
20
|
+
var tr = state.tr;
|
|
21
|
+
var insertable = (0, _utils2.canInsert)(tr.selection.$from, fragment);
|
|
22
|
+
if (!insertable) {
|
|
23
|
+
var parentSelection = _state.NodeSelection.create(tr.doc, tr.selection.from - tr.selection.$anchor.parentOffset - 1);
|
|
24
|
+
tr.insert(parentSelection.to, fragment).setSelection(_state.NodeSelection.create(tr.doc, parentSelection.to + 1));
|
|
25
|
+
} else {
|
|
26
|
+
tr.insert(tr.selection.from, fragment).setSelection(_state.NodeSelection.create(tr.doc, tr.selection.from - fragment.size));
|
|
27
|
+
}
|
|
22
28
|
var newPluginState = {
|
|
23
29
|
isQuickInsertAction: isQuickInsertAction,
|
|
24
30
|
showDatePickerAt: tr.selection.from,
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -177,7 +177,7 @@ var datePlugin = function datePlugin(_ref3) {
|
|
|
177
177
|
},
|
|
178
178
|
action: function action(insert, state) {
|
|
179
179
|
var _api$analytics, _api$analytics$attach;
|
|
180
|
-
var tr = (0, _actions.createDate)(true)(
|
|
180
|
+
var tr = (0, _actions.createDate)(true)(state);
|
|
181
181
|
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, {
|
|
182
182
|
action: _analytics.ACTION.INSERTED,
|
|
183
183
|
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
@@ -75,7 +75,7 @@ function isDatePossiblyValid(date) {
|
|
|
75
75
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
76
76
|
var c = _step.value;
|
|
77
77
|
var isNumber = c >= '0' && c <= '9';
|
|
78
|
-
var isValidPunctuation = '.
|
|
78
|
+
var isValidPunctuation = '. ,/-'.indexOf(c) !== -1;
|
|
79
79
|
if (!(isNumber || isValidPunctuation)) {
|
|
80
80
|
return false;
|
|
81
81
|
}
|
package/dist/es2019/actions.js
CHANGED
|
@@ -2,16 +2,22 @@ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/edit
|
|
|
2
2
|
import { todayTimestampInUTC } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import { canInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
5
6
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
6
7
|
import { isToday } from './utils/internal';
|
|
7
|
-
export const createDate = isQuickInsertAction =>
|
|
8
|
+
export const createDate = isQuickInsertAction => state => {
|
|
8
9
|
const dateNode = state.schema.nodes.date.createChecked({
|
|
9
10
|
timestamp: todayTimestampInUTC()
|
|
10
11
|
});
|
|
11
|
-
const
|
|
12
|
-
const tr =
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const fragment = Fragment.fromArray([dateNode, state.schema.text(' ')]);
|
|
13
|
+
const tr = state.tr;
|
|
14
|
+
const insertable = canInsert(tr.selection.$from, fragment);
|
|
15
|
+
if (!insertable) {
|
|
16
|
+
const parentSelection = NodeSelection.create(tr.doc, tr.selection.from - tr.selection.$anchor.parentOffset - 1);
|
|
17
|
+
tr.insert(parentSelection.to, fragment).setSelection(NodeSelection.create(tr.doc, parentSelection.to + 1));
|
|
18
|
+
} else {
|
|
19
|
+
tr.insert(tr.selection.from, fragment).setSelection(NodeSelection.create(tr.doc, tr.selection.from - fragment.size));
|
|
20
|
+
}
|
|
15
21
|
const newPluginState = {
|
|
16
22
|
isQuickInsertAction,
|
|
17
23
|
showDatePickerAt: tr.selection.from,
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -165,7 +165,7 @@ const datePlugin = ({
|
|
|
165
165
|
icon: () => /*#__PURE__*/React.createElement(IconDate, null),
|
|
166
166
|
action(insert, state) {
|
|
167
167
|
var _api$analytics, _api$analytics$action, _api$analytics$action2;
|
|
168
|
-
const tr = createDate(true)(
|
|
168
|
+
const tr = createDate(true)(state);
|
|
169
169
|
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : (_api$analytics$action = _api$analytics.actions) === null || _api$analytics$action === void 0 ? void 0 : (_api$analytics$action2 = _api$analytics$action.attachAnalyticsEvent) === null || _api$analytics$action2 === void 0 ? void 0 : _api$analytics$action2.call(_api$analytics$action, {
|
|
170
170
|
action: ACTION.INSERTED,
|
|
171
171
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
@@ -57,7 +57,7 @@ function isCursorInLastDateSegment(cursorPos, date) {
|
|
|
57
57
|
export function isDatePossiblyValid(date) {
|
|
58
58
|
for (const c of date) {
|
|
59
59
|
const isNumber = c >= '0' && c <= '9';
|
|
60
|
-
const isValidPunctuation = '.
|
|
60
|
+
const isValidPunctuation = '. ,/-'.indexOf(c) !== -1;
|
|
61
61
|
if (!(isNumber || isValidPunctuation)) {
|
|
62
62
|
return false;
|
|
63
63
|
}
|
package/dist/esm/actions.js
CHANGED
|
@@ -2,17 +2,23 @@ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/edit
|
|
|
2
2
|
import { todayTimestampInUTC } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import { canInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
5
6
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
6
7
|
import { isToday } from './utils/internal';
|
|
7
8
|
export var createDate = function createDate(isQuickInsertAction) {
|
|
8
|
-
return function (
|
|
9
|
+
return function (state) {
|
|
9
10
|
var dateNode = state.schema.nodes.date.createChecked({
|
|
10
11
|
timestamp: todayTimestampInUTC()
|
|
11
12
|
});
|
|
12
|
-
var
|
|
13
|
-
var tr =
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
var fragment = Fragment.fromArray([dateNode, state.schema.text(' ')]);
|
|
14
|
+
var tr = state.tr;
|
|
15
|
+
var insertable = canInsert(tr.selection.$from, fragment);
|
|
16
|
+
if (!insertable) {
|
|
17
|
+
var parentSelection = NodeSelection.create(tr.doc, tr.selection.from - tr.selection.$anchor.parentOffset - 1);
|
|
18
|
+
tr.insert(parentSelection.to, fragment).setSelection(NodeSelection.create(tr.doc, parentSelection.to + 1));
|
|
19
|
+
} else {
|
|
20
|
+
tr.insert(tr.selection.from, fragment).setSelection(NodeSelection.create(tr.doc, tr.selection.from - fragment.size));
|
|
21
|
+
}
|
|
16
22
|
var newPluginState = {
|
|
17
23
|
isQuickInsertAction: isQuickInsertAction,
|
|
18
24
|
showDatePickerAt: tr.selection.from,
|
package/dist/esm/plugin.js
CHANGED
|
@@ -165,7 +165,7 @@ var datePlugin = function datePlugin(_ref3) {
|
|
|
165
165
|
},
|
|
166
166
|
action: function action(insert, state) {
|
|
167
167
|
var _api$analytics, _api$analytics$attach;
|
|
168
|
-
var tr = createDate(true)(
|
|
168
|
+
var tr = createDate(true)(state);
|
|
169
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
170
|
action: ACTION.INSERTED,
|
|
171
171
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
@@ -64,7 +64,7 @@ export function isDatePossiblyValid(date) {
|
|
|
64
64
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
65
65
|
var c = _step.value;
|
|
66
66
|
var isNumber = c >= '0' && c <= '9';
|
|
67
|
-
var isValidPunctuation = '.
|
|
67
|
+
var isValidPunctuation = '. ,/-'.indexOf(c) !== -1;
|
|
68
68
|
if (!(isNumber || isValidPunctuation)) {
|
|
69
69
|
return false;
|
|
70
70
|
}
|
package/dist/types/actions.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { Command, CommandDispatch, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import type { DatePlugin, DateType } from './types';
|
|
4
|
-
export declare const createDate: (isQuickInsertAction?: boolean) => (
|
|
5
|
-
selectInlineNode: boolean;
|
|
6
|
-
}) => Transaction, state: EditorState) => Transaction;
|
|
4
|
+
export declare const createDate: (isQuickInsertAction?: boolean) => (state: EditorState) => Transaction;
|
|
7
5
|
/** Focus input */
|
|
8
6
|
export declare const focusDateInput: () => (state: EditorState, dispatch: CommandDispatch | undefined) => boolean;
|
|
9
7
|
export declare const setDatePickerAt: (showDatePickerAt: number | null) => (state: EditorState, dispatch: (tr: Transaction) => void) => boolean;
|
|
@@ -19,10 +17,10 @@ export declare const closeDatePickerWithAnalytics: ({ date, pluginInjectionApi,
|
|
|
19
17
|
attachAnalyticsEvent: import("@atlaskit/editor-plugin-analytics").CreateAttachPayloadIntoTransaction | null;
|
|
20
18
|
performanceTracking: import("@atlaskit/editor-common/types").PerformanceTracking | undefined;
|
|
21
19
|
};
|
|
22
|
-
dependencies: [import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
|
|
20
|
+
dependencies: [import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
|
|
23
21
|
pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
24
22
|
sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
25
|
-
}, import("@atlaskit/editor-common/types").FeatureFlags
|
|
23
|
+
}, import("@atlaskit/editor-common/types").FeatureFlags>>];
|
|
26
24
|
actions: import("@atlaskit/editor-common/analytics").EditorAnalyticsAPI;
|
|
27
25
|
}, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>, import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"editorDisabled", {
|
|
28
26
|
sharedState: import("@atlaskit/editor-plugin-editor-disabled").EditorDisabledPluginState;
|
|
@@ -39,10 +37,10 @@ export declare const closeDatePickerWithAnalytics: ({ date, pluginInjectionApi,
|
|
|
39
37
|
attachAnalyticsEvent: import("@atlaskit/editor-plugin-analytics").CreateAttachPayloadIntoTransaction | null;
|
|
40
38
|
performanceTracking: import("@atlaskit/editor-common/types").PerformanceTracking | undefined;
|
|
41
39
|
};
|
|
42
|
-
dependencies: [import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
|
|
40
|
+
dependencies: [import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
|
|
43
41
|
pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
44
42
|
sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
45
|
-
}, import("@atlaskit/editor-common/types").FeatureFlags
|
|
43
|
+
}, import("@atlaskit/editor-common/types").FeatureFlags>>];
|
|
46
44
|
actions: import("@atlaskit/editor-common/analytics").EditorAnalyticsAPI;
|
|
47
45
|
}, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>, import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"editorDisabled", {
|
|
48
46
|
sharedState: import("@atlaskit/editor-plugin-editor-disabled").EditorDisabledPluginState;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { Command, CommandDispatch, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import type { DatePlugin, DateType } from './types';
|
|
4
|
-
export declare const createDate: (isQuickInsertAction?: boolean) => (
|
|
5
|
-
selectInlineNode: boolean;
|
|
6
|
-
}) => Transaction, state: EditorState) => Transaction;
|
|
4
|
+
export declare const createDate: (isQuickInsertAction?: boolean) => (state: EditorState) => Transaction;
|
|
7
5
|
/** Focus input */
|
|
8
6
|
export declare const focusDateInput: () => (state: EditorState, dispatch: CommandDispatch | undefined) => boolean;
|
|
9
7
|
export declare const setDatePickerAt: (showDatePickerAt: number | null) => (state: EditorState, dispatch: (tr: Transaction) => void) => boolean;
|
|
@@ -22,10 +20,10 @@ export declare const closeDatePickerWithAnalytics: ({ date, pluginInjectionApi,
|
|
|
22
20
|
performanceTracking: import("@atlaskit/editor-common/types").PerformanceTracking | undefined;
|
|
23
21
|
};
|
|
24
22
|
dependencies: [
|
|
25
|
-
import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
|
|
23
|
+
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
|
|
26
24
|
pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
27
25
|
sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
28
|
-
}, import("@atlaskit/editor-common/types").FeatureFlags
|
|
26
|
+
}, import("@atlaskit/editor-common/types").FeatureFlags>>
|
|
29
27
|
];
|
|
30
28
|
actions: import("@atlaskit/editor-common/analytics").EditorAnalyticsAPI;
|
|
31
29
|
}, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>,
|
|
@@ -47,10 +45,10 @@ export declare const closeDatePickerWithAnalytics: ({ date, pluginInjectionApi,
|
|
|
47
45
|
performanceTracking: import("@atlaskit/editor-common/types").PerformanceTracking | undefined;
|
|
48
46
|
};
|
|
49
47
|
dependencies: [
|
|
50
|
-
import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
|
|
48
|
+
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
|
|
51
49
|
pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
52
50
|
sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
53
|
-
}, import("@atlaskit/editor-common/types").FeatureFlags
|
|
51
|
+
}, import("@atlaskit/editor-common/types").FeatureFlags>>
|
|
54
52
|
];
|
|
55
53
|
actions: import("@atlaskit/editor-common/analytics").EditorAnalyticsAPI;
|
|
56
54
|
}, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-date",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "Date plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@atlaskit/adf-schema": "^34.0.0",
|
|
35
35
|
"@atlaskit/calendar": "^14.0.0",
|
|
36
36
|
"@atlaskit/date": "^0.10.0",
|
|
37
|
-
"@atlaskit/editor-common": "^76.
|
|
37
|
+
"@atlaskit/editor-common": "^76.23.0",
|
|
38
38
|
"@atlaskit/editor-plugin-analytics": "^0.3.0",
|
|
39
39
|
"@atlaskit/editor-plugin-editor-disabled": "^0.2.0",
|
|
40
40
|
"@atlaskit/editor-prosemirror": "1.1.0",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@atlaskit/locale": "^2.6.0",
|
|
44
44
|
"@atlaskit/textfield": "6.0.0",
|
|
45
45
|
"@atlaskit/theme": "^12.6.0",
|
|
46
|
-
"@atlaskit/tokens": "^1.
|
|
46
|
+
"@atlaskit/tokens": "^1.29.0",
|
|
47
47
|
"@babel/runtime": "^7.0.0",
|
|
48
48
|
"@emotion/react": "^11.7.1",
|
|
49
49
|
"date-fns": "^2.17.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@atlaskit/editor-plugin-guideline": "^0.5.0",
|
|
60
60
|
"@atlaskit/editor-plugin-quick-insert": "^0.2.0",
|
|
61
61
|
"@atlaskit/editor-plugin-selection": "^0.1.0",
|
|
62
|
-
"@atlaskit/editor-plugin-table": "^5.
|
|
62
|
+
"@atlaskit/editor-plugin-table": "^5.4.0",
|
|
63
63
|
"@atlaskit/editor-plugin-tasks-and-decisions": "^0.2.0",
|
|
64
64
|
"@atlaskit/editor-plugin-type-ahead": "^0.7.0",
|
|
65
65
|
"@atlaskit/editor-plugin-width": "^0.2.0",
|