@atlaskit/editor-plugin-date 0.2.8 → 0.2.10
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/es2019/actions.js +11 -5
- package/dist/es2019/plugin.js +1 -1
- package/dist/esm/actions.js +11 -5
- package/dist/esm/plugin.js +1 -1
- package/dist/types/actions.d.ts +1 -3
- package/dist/types-ts4.5/actions.d.ts +1 -3
- package/package.json +5 -5
- package/tmp/api-report-tmp.d.ts +0 -62
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-date
|
|
2
2
|
|
|
3
|
+
## 0.2.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#56790](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/56790) [`ff577a7969d4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ff577a7969d4) - ED-21266: Updated @atlaskit/adf-schema to 34.0.1
|
|
8
|
+
|
|
9
|
+
## 0.2.9
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#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
|
|
14
|
+
|
|
3
15
|
## 0.2.8
|
|
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,
|
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,
|
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,
|
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;
|
|
@@ -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;
|
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.10",
|
|
4
4
|
"description": "Date plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
".": "./src/index.ts"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaskit/adf-schema": "^34.0.
|
|
34
|
+
"@atlaskit/adf-schema": "^34.0.1",
|
|
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",
|
package/tmp/api-report-tmp.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
## API Report File for "@atlaskit/editor-plugin-date"
|
|
2
|
-
|
|
3
|
-
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
|
|
7
|
-
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
8
|
-
import type { EditorCommand } from '@atlaskit/editor-common/types';
|
|
9
|
-
import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
|
|
10
|
-
import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
11
|
-
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
12
|
-
import type { TOOLBAR_MENU_TYPE } from '@atlaskit/editor-common/types';
|
|
13
|
-
import type { WeekDay } from '@atlaskit/calendar/types';
|
|
14
|
-
|
|
15
|
-
// @public (undocumented)
|
|
16
|
-
export type DatePlugin = NextEditorPlugin<'date', {
|
|
17
|
-
pluginConfiguration: DatePluginConfig | undefined;
|
|
18
|
-
dependencies: [typeof analyticsPlugin, EditorDisabledPlugin];
|
|
19
|
-
sharedState: DatePluginSharedState;
|
|
20
|
-
commands: {
|
|
21
|
-
insertDate: InsertDate;
|
|
22
|
-
deleteDate: DeleteDate;
|
|
23
|
-
};
|
|
24
|
-
}>;
|
|
25
|
-
|
|
26
|
-
// @public (undocumented)
|
|
27
|
-
export const datePlugin: DatePlugin;
|
|
28
|
-
|
|
29
|
-
// @public (undocumented)
|
|
30
|
-
export interface DatePluginConfig {
|
|
31
|
-
// (undocumented)
|
|
32
|
-
weekStartDay?: WeekDay;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// @public (undocumented)
|
|
36
|
-
export type DatePluginSharedState = {
|
|
37
|
-
showDatePickerAt?: null | number;
|
|
38
|
-
isNew: boolean;
|
|
39
|
-
focusDateInput: boolean;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// @public (undocumented)
|
|
43
|
-
export type DateType = {
|
|
44
|
-
year: number;
|
|
45
|
-
month: number;
|
|
46
|
-
day?: number;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// @public (undocumented)
|
|
50
|
-
type DeleteDate = EditorCommand;
|
|
51
|
-
|
|
52
|
-
// @public (undocumented)
|
|
53
|
-
type InsertDate = (props: {
|
|
54
|
-
date?: DateType;
|
|
55
|
-
inputMethod?: TOOLBAR_MENU_TYPE;
|
|
56
|
-
commitMethod?: INPUT_METHOD.KEYBOARD | INPUT_METHOD.PICKER;
|
|
57
|
-
enterPressed?: boolean;
|
|
58
|
-
}) => EditorCommand;
|
|
59
|
-
|
|
60
|
-
// (No @packageDocumentation comment for this package)
|
|
61
|
-
|
|
62
|
-
```
|