@atlaskit/editor-core 188.10.7 → 188.11.1

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.
Files changed (236) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/architecture/0003-explicit-plugin-dependencies.md +1 -1
  3. package/dist/cjs/i18n/cs.js +0 -60
  4. package/dist/cjs/i18n/da.js +0 -60
  5. package/dist/cjs/i18n/de.js +0 -60
  6. package/dist/cjs/i18n/en.js +0 -60
  7. package/dist/cjs/i18n/en_GB.js +0 -60
  8. package/dist/cjs/i18n/en_ZZ.js +0 -60
  9. package/dist/cjs/i18n/es.js +0 -60
  10. package/dist/cjs/i18n/fi.js +0 -60
  11. package/dist/cjs/i18n/fr.js +0 -60
  12. package/dist/cjs/i18n/hu.js +0 -60
  13. package/dist/cjs/i18n/it.js +0 -60
  14. package/dist/cjs/i18n/ja.js +0 -60
  15. package/dist/cjs/i18n/ko.js +0 -60
  16. package/dist/cjs/i18n/nb.js +0 -60
  17. package/dist/cjs/i18n/nl.js +0 -60
  18. package/dist/cjs/i18n/pl.js +0 -60
  19. package/dist/cjs/i18n/pt_BR.js +0 -60
  20. package/dist/cjs/i18n/ru.js +0 -60
  21. package/dist/cjs/i18n/sv.js +0 -60
  22. package/dist/cjs/i18n/th.js +0 -60
  23. package/dist/cjs/i18n/tr.js +0 -60
  24. package/dist/cjs/i18n/uk.js +0 -60
  25. package/dist/cjs/i18n/vi.js +0 -60
  26. package/dist/cjs/i18n/zh.js +0 -60
  27. package/dist/cjs/i18n/zh_TW.js +0 -60
  28. package/dist/cjs/labs/next/presets/universal.js +2 -2
  29. package/dist/cjs/messages.js +1 -2
  30. package/dist/cjs/plugins/index.js +0 -7
  31. package/dist/cjs/plugins/tasks-and-decisions/nodeviews/decisionItem.js +1 -1
  32. package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +1 -1
  33. package/dist/cjs/version-wrapper.js +1 -1
  34. package/dist/es2019/i18n/cs.js +0 -60
  35. package/dist/es2019/i18n/da.js +0 -60
  36. package/dist/es2019/i18n/de.js +0 -60
  37. package/dist/es2019/i18n/en.js +0 -60
  38. package/dist/es2019/i18n/en_GB.js +0 -60
  39. package/dist/es2019/i18n/en_ZZ.js +0 -60
  40. package/dist/es2019/i18n/es.js +0 -60
  41. package/dist/es2019/i18n/fi.js +0 -60
  42. package/dist/es2019/i18n/fr.js +0 -60
  43. package/dist/es2019/i18n/hu.js +0 -60
  44. package/dist/es2019/i18n/it.js +0 -60
  45. package/dist/es2019/i18n/ja.js +0 -60
  46. package/dist/es2019/i18n/ko.js +0 -60
  47. package/dist/es2019/i18n/nb.js +0 -60
  48. package/dist/es2019/i18n/nl.js +0 -60
  49. package/dist/es2019/i18n/pl.js +0 -60
  50. package/dist/es2019/i18n/pt_BR.js +0 -60
  51. package/dist/es2019/i18n/ru.js +0 -60
  52. package/dist/es2019/i18n/sv.js +0 -60
  53. package/dist/es2019/i18n/th.js +0 -60
  54. package/dist/es2019/i18n/tr.js +0 -60
  55. package/dist/es2019/i18n/uk.js +0 -60
  56. package/dist/es2019/i18n/vi.js +0 -60
  57. package/dist/es2019/i18n/zh.js +0 -60
  58. package/dist/es2019/i18n/zh_TW.js +0 -60
  59. package/dist/es2019/labs/next/presets/universal.js +1 -1
  60. package/dist/es2019/messages.js +1 -2
  61. package/dist/es2019/plugins/index.js +0 -1
  62. package/dist/es2019/plugins/tasks-and-decisions/nodeviews/decisionItem.js +1 -1
  63. package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +1 -1
  64. package/dist/es2019/version-wrapper.js +1 -1
  65. package/dist/esm/i18n/cs.js +0 -60
  66. package/dist/esm/i18n/da.js +0 -60
  67. package/dist/esm/i18n/de.js +0 -60
  68. package/dist/esm/i18n/en.js +0 -60
  69. package/dist/esm/i18n/en_GB.js +0 -60
  70. package/dist/esm/i18n/en_ZZ.js +0 -60
  71. package/dist/esm/i18n/es.js +0 -60
  72. package/dist/esm/i18n/fi.js +0 -60
  73. package/dist/esm/i18n/fr.js +0 -60
  74. package/dist/esm/i18n/hu.js +0 -60
  75. package/dist/esm/i18n/it.js +0 -60
  76. package/dist/esm/i18n/ja.js +0 -60
  77. package/dist/esm/i18n/ko.js +0 -60
  78. package/dist/esm/i18n/nb.js +0 -60
  79. package/dist/esm/i18n/nl.js +0 -60
  80. package/dist/esm/i18n/pl.js +0 -60
  81. package/dist/esm/i18n/pt_BR.js +0 -60
  82. package/dist/esm/i18n/ru.js +0 -60
  83. package/dist/esm/i18n/sv.js +0 -60
  84. package/dist/esm/i18n/th.js +0 -60
  85. package/dist/esm/i18n/tr.js +0 -60
  86. package/dist/esm/i18n/uk.js +0 -60
  87. package/dist/esm/i18n/vi.js +0 -60
  88. package/dist/esm/i18n/zh.js +0 -60
  89. package/dist/esm/i18n/zh_TW.js +0 -60
  90. package/dist/esm/labs/next/presets/universal.js +1 -1
  91. package/dist/esm/messages.js +1 -2
  92. package/dist/esm/plugins/index.js +0 -1
  93. package/dist/esm/plugins/tasks-and-decisions/nodeviews/decisionItem.js +1 -1
  94. package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +1 -1
  95. package/dist/esm/version-wrapper.js +1 -1
  96. package/dist/types/i18n/cs.d.ts +0 -60
  97. package/dist/types/i18n/da.d.ts +0 -60
  98. package/dist/types/i18n/de.d.ts +0 -60
  99. package/dist/types/i18n/en.d.ts +0 -60
  100. package/dist/types/i18n/en_GB.d.ts +0 -60
  101. package/dist/types/i18n/en_ZZ.d.ts +0 -60
  102. package/dist/types/i18n/es.d.ts +0 -60
  103. package/dist/types/i18n/fi.d.ts +0 -60
  104. package/dist/types/i18n/fr.d.ts +0 -60
  105. package/dist/types/i18n/hu.d.ts +0 -60
  106. package/dist/types/i18n/it.d.ts +0 -60
  107. package/dist/types/i18n/ja.d.ts +0 -60
  108. package/dist/types/i18n/ko.d.ts +0 -60
  109. package/dist/types/i18n/nb.d.ts +0 -60
  110. package/dist/types/i18n/nl.d.ts +0 -60
  111. package/dist/types/i18n/pl.d.ts +0 -60
  112. package/dist/types/i18n/pt_BR.d.ts +0 -60
  113. package/dist/types/i18n/ru.d.ts +0 -60
  114. package/dist/types/i18n/sv.d.ts +0 -60
  115. package/dist/types/i18n/th.d.ts +0 -60
  116. package/dist/types/i18n/tr.d.ts +0 -60
  117. package/dist/types/i18n/uk.d.ts +0 -60
  118. package/dist/types/i18n/vi.d.ts +0 -60
  119. package/dist/types/i18n/zh.d.ts +0 -60
  120. package/dist/types/i18n/zh_TW.d.ts +0 -60
  121. package/dist/types/messages.d.ts +1 -2
  122. package/dist/types/plugins/index.d.ts +0 -1
  123. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  124. package/dist/types/ui/ConfigPanel/FormErrorBoundary.d.ts +1 -1
  125. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  126. package/dist/types-ts4.5/i18n/cs.d.ts +0 -60
  127. package/dist/types-ts4.5/i18n/da.d.ts +0 -60
  128. package/dist/types-ts4.5/i18n/de.d.ts +0 -60
  129. package/dist/types-ts4.5/i18n/en.d.ts +0 -60
  130. package/dist/types-ts4.5/i18n/en_GB.d.ts +0 -60
  131. package/dist/types-ts4.5/i18n/en_ZZ.d.ts +0 -60
  132. package/dist/types-ts4.5/i18n/es.d.ts +0 -60
  133. package/dist/types-ts4.5/i18n/fi.d.ts +0 -60
  134. package/dist/types-ts4.5/i18n/fr.d.ts +0 -60
  135. package/dist/types-ts4.5/i18n/hu.d.ts +0 -60
  136. package/dist/types-ts4.5/i18n/it.d.ts +0 -60
  137. package/dist/types-ts4.5/i18n/ja.d.ts +0 -60
  138. package/dist/types-ts4.5/i18n/ko.d.ts +0 -60
  139. package/dist/types-ts4.5/i18n/nb.d.ts +0 -60
  140. package/dist/types-ts4.5/i18n/nl.d.ts +0 -60
  141. package/dist/types-ts4.5/i18n/pl.d.ts +0 -60
  142. package/dist/types-ts4.5/i18n/pt_BR.d.ts +0 -60
  143. package/dist/types-ts4.5/i18n/ru.d.ts +0 -60
  144. package/dist/types-ts4.5/i18n/sv.d.ts +0 -60
  145. package/dist/types-ts4.5/i18n/th.d.ts +0 -60
  146. package/dist/types-ts4.5/i18n/tr.d.ts +0 -60
  147. package/dist/types-ts4.5/i18n/uk.d.ts +0 -60
  148. package/dist/types-ts4.5/i18n/vi.d.ts +0 -60
  149. package/dist/types-ts4.5/i18n/zh.d.ts +0 -60
  150. package/dist/types-ts4.5/i18n/zh_TW.d.ts +0 -60
  151. package/dist/types-ts4.5/messages.d.ts +1 -2
  152. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  153. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  154. package/dist/types-ts4.5/ui/ConfigPanel/FormErrorBoundary.d.ts +1 -1
  155. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  156. package/package.json +6 -9
  157. package/dist/cjs/plugins/date/actions.js +0 -105
  158. package/dist/cjs/plugins/date/commands.js +0 -118
  159. package/dist/cjs/plugins/date/index.js +0 -13
  160. package/dist/cjs/plugins/date/nodeviews/date.js +0 -44
  161. package/dist/cjs/plugins/date/nodeviews/messages.js +0 -14
  162. package/dist/cjs/plugins/date/plugin.js +0 -197
  163. package/dist/cjs/plugins/date/pm-plugins/keymap.js +0 -41
  164. package/dist/cjs/plugins/date/pm-plugins/main.js +0 -39
  165. package/dist/cjs/plugins/date/pm-plugins/plugin-key.js +0 -8
  166. package/dist/cjs/plugins/date/pm-plugins/types.js +0 -5
  167. package/dist/cjs/plugins/date/pm-plugins/utils.js +0 -70
  168. package/dist/cjs/plugins/date/types.js +0 -5
  169. package/dist/cjs/plugins/date/ui/DatePicker/date-picker-input.js +0 -244
  170. package/dist/cjs/plugins/date/ui/DatePicker/index.js +0 -168
  171. package/dist/cjs/plugins/date/utils/formatParse.js +0 -88
  172. package/dist/cjs/plugins/date/utils/internal.js +0 -176
  173. package/dist/es2019/plugins/date/actions.js +0 -93
  174. package/dist/es2019/plugins/date/commands.js +0 -113
  175. package/dist/es2019/plugins/date/index.js +0 -1
  176. package/dist/es2019/plugins/date/nodeviews/date.js +0 -47
  177. package/dist/es2019/plugins/date/nodeviews/messages.js +0 -8
  178. package/dist/es2019/plugins/date/plugin.js +0 -183
  179. package/dist/es2019/plugins/date/pm-plugins/keymap.js +0 -34
  180. package/dist/es2019/plugins/date/pm-plugins/main.js +0 -35
  181. package/dist/es2019/plugins/date/pm-plugins/plugin-key.js +0 -2
  182. package/dist/es2019/plugins/date/pm-plugins/types.js +0 -1
  183. package/dist/es2019/plugins/date/pm-plugins/utils.js +0 -70
  184. package/dist/es2019/plugins/date/types.js +0 -1
  185. package/dist/es2019/plugins/date/ui/DatePicker/date-picker-input.js +0 -233
  186. package/dist/es2019/plugins/date/ui/DatePicker/index.js +0 -152
  187. package/dist/es2019/plugins/date/utils/formatParse.js +0 -83
  188. package/dist/es2019/plugins/date/utils/internal.js +0 -151
  189. package/dist/esm/plugins/date/actions.js +0 -99
  190. package/dist/esm/plugins/date/commands.js +0 -112
  191. package/dist/esm/plugins/date/index.js +0 -1
  192. package/dist/esm/plugins/date/nodeviews/date.js +0 -37
  193. package/dist/esm/plugins/date/nodeviews/messages.js +0 -8
  194. package/dist/esm/plugins/date/plugin.js +0 -185
  195. package/dist/esm/plugins/date/pm-plugins/keymap.js +0 -34
  196. package/dist/esm/plugins/date/pm-plugins/main.js +0 -34
  197. package/dist/esm/plugins/date/pm-plugins/plugin-key.js +0 -2
  198. package/dist/esm/plugins/date/pm-plugins/types.js +0 -1
  199. package/dist/esm/plugins/date/pm-plugins/utils.js +0 -61
  200. package/dist/esm/plugins/date/types.js +0 -1
  201. package/dist/esm/plugins/date/ui/DatePicker/date-picker-input.js +0 -238
  202. package/dist/esm/plugins/date/ui/DatePicker/index.js +0 -162
  203. package/dist/esm/plugins/date/utils/formatParse.js +0 -79
  204. package/dist/esm/plugins/date/utils/internal.js +0 -165
  205. package/dist/types/plugins/date/actions.d.ts +0 -47
  206. package/dist/types/plugins/date/commands.d.ts +0 -12
  207. package/dist/types/plugins/date/index.d.ts +0 -1
  208. package/dist/types/plugins/date/nodeviews/date.d.ts +0 -3
  209. package/dist/types/plugins/date/nodeviews/messages.d.ts +0 -7
  210. package/dist/types/plugins/date/plugin.d.ts +0 -3
  211. package/dist/types/plugins/date/pm-plugins/keymap.d.ts +0 -3
  212. package/dist/types/plugins/date/pm-plugins/main.d.ts +0 -6
  213. package/dist/types/plugins/date/pm-plugins/plugin-key.d.ts +0 -3
  214. package/dist/types/plugins/date/pm-plugins/types.d.ts +0 -12
  215. package/dist/types/plugins/date/pm-plugins/utils.d.ts +0 -5
  216. package/dist/types/plugins/date/types.d.ts +0 -1
  217. package/dist/types/plugins/date/ui/DatePicker/date-picker-input.d.ts +0 -24
  218. package/dist/types/plugins/date/ui/DatePicker/index.d.ts +0 -36
  219. package/dist/types/plugins/date/utils/formatParse.d.ts +0 -27
  220. package/dist/types/plugins/date/utils/internal.d.ts +0 -33
  221. package/dist/types-ts4.5/plugins/date/actions.d.ts +0 -58
  222. package/dist/types-ts4.5/plugins/date/commands.d.ts +0 -14
  223. package/dist/types-ts4.5/plugins/date/index.d.ts +0 -1
  224. package/dist/types-ts4.5/plugins/date/nodeviews/date.d.ts +0 -3
  225. package/dist/types-ts4.5/plugins/date/nodeviews/messages.d.ts +0 -7
  226. package/dist/types-ts4.5/plugins/date/plugin.d.ts +0 -3
  227. package/dist/types-ts4.5/plugins/date/pm-plugins/keymap.d.ts +0 -3
  228. package/dist/types-ts4.5/plugins/date/pm-plugins/main.d.ts +0 -6
  229. package/dist/types-ts4.5/plugins/date/pm-plugins/plugin-key.d.ts +0 -3
  230. package/dist/types-ts4.5/plugins/date/pm-plugins/types.d.ts +0 -12
  231. package/dist/types-ts4.5/plugins/date/pm-plugins/utils.d.ts +0 -5
  232. package/dist/types-ts4.5/plugins/date/types.d.ts +0 -1
  233. package/dist/types-ts4.5/plugins/date/ui/DatePicker/date-picker-input.d.ts +0 -24
  234. package/dist/types-ts4.5/plugins/date/ui/DatePicker/index.d.ts +0 -36
  235. package/dist/types-ts4.5/plugins/date/utils/formatParse.d.ts +0 -27
  236. package/dist/types-ts4.5/plugins/date/utils/internal.d.ts +0 -33
@@ -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,2 +0,0 @@
1
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export var pluginKey = new PluginKey('datePlugin');
@@ -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 {};
@@ -1,238 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
9
- var _templateObject;
10
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
- /** @jsx jsx */
13
-
14
- import React from 'react';
15
- import { css, jsx } from '@emotion/react';
16
- import { defineMessages, injectIntl } from 'react-intl-next';
17
- import { findDateSegmentByPosition, adjustDate, isDatePossiblyValid } from '../../utils/internal';
18
- import { parseDateType, formatDateType } from '../../utils/formatParse';
19
- import { EVENT_TYPE, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
20
- import TextField from '@atlaskit/textfield';
21
- import { ErrorMessage } from '@atlaskit/form';
22
- var dateTextFieldWrapper = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 22px;\n padding-bottom: ", ";\n"])), "var(--ds-space-150, 12px)");
23
- var messages = defineMessages({
24
- invalidDateError: {
25
- id: 'fabric.editor.invalidDateError',
26
- defaultMessage: 'Enter a valid date',
27
- description: 'Error message when the date typed in is invalid, requesting they inputs a new date'
28
- }
29
- });
30
- var DatePickerInput = /*#__PURE__*/function (_React$Component) {
31
- _inherits(DatePickerInput, _React$Component);
32
- var _super = _createSuper(DatePickerInput);
33
- function DatePickerInput(props) {
34
- var _this;
35
- _classCallCheck(this, DatePickerInput);
36
- _this = _super.call(this, props);
37
- /**
38
- * Focus the input textfield
39
- */
40
- _defineProperty(_assertThisInitialized(_this), "focusInput", function () {
41
- if (!_this.inputRef) {
42
- return;
43
- }
44
- // Defer to prevent editor scrolling to top (See FS-3227, also ED-2992)
45
- _this.autofocusTimeout = setTimeout(function () {
46
- _this.inputRef.focus();
47
- });
48
- });
49
- /**
50
- * Select all the input text
51
- */
52
- _defineProperty(_assertThisInitialized(_this), "selectInput", function () {
53
- if (!_this.inputRef) {
54
- return;
55
- }
56
- // Defer to prevent editor scrolling to top (See FS-3227, also ED-2992)
57
- _this.autoSelectAllTimeout = setTimeout(function () {
58
- _this.inputRef.select();
59
- });
60
- });
61
- _defineProperty(_assertThisInitialized(_this), "handleInputRef", function (ref) {
62
- var _this$props = _this.props,
63
- autoFocus = _this$props.autoFocus,
64
- autoSelectAll = _this$props.autoSelectAll;
65
- if (ref) {
66
- _this.inputRef = ref;
67
- }
68
- if (ref && autoFocus) {
69
- _this.focusInput();
70
- }
71
- if (autoSelectAll) {
72
- _this.selectInput();
73
- }
74
- });
75
- _defineProperty(_assertThisInitialized(_this), "handleChange", function (evt) {
76
- var textFieldValue = evt.target.value;
77
- var _this$props2 = _this.props,
78
- locale = _this$props2.locale,
79
- dispatchAnalyticsEvent = _this$props2.dispatchAnalyticsEvent;
80
- var newDate = parseDateType(textFieldValue, locale);
81
- if (newDate !== undefined && newDate !== null) {
82
- _this.setState({
83
- inputText: textFieldValue
84
- });
85
- _this.props.onNewDate(newDate);
86
- if (dispatchAnalyticsEvent) {
87
- dispatchAnalyticsEvent({
88
- eventType: EVENT_TYPE.TRACK,
89
- action: ACTION.TYPING_FINISHED,
90
- actionSubject: ACTION_SUBJECT.DATE
91
- });
92
- }
93
- } else {
94
- // if invalid, just update state text (to rerender textfield)
95
- _this.setState({
96
- inputText: textFieldValue
97
- });
98
- }
99
- });
100
- _defineProperty(_assertThisInitialized(_this), "handleKeyPress", function (event) {
101
- var _this$props3 = _this.props,
102
- locale = _this$props3.locale,
103
- dispatchAnalyticsEvent = _this$props3.dispatchAnalyticsEvent;
104
- var textFieldValue = event.target.value;
105
-
106
- // Fire event on every keypress (textfield not necessarily empty)
107
- if (dispatchAnalyticsEvent && event.key !== 'Enter' && event.key !== 'Backspace') {
108
- dispatchAnalyticsEvent({
109
- eventType: EVENT_TYPE.TRACK,
110
- action: ACTION.TYPING_STARTED,
111
- actionSubject: ACTION_SUBJECT.DATE
112
- });
113
- }
114
- if (event.key !== 'Enter') {
115
- return;
116
- }
117
- if (textFieldValue === '') {
118
- _this.props.onEmptySubmit();
119
- return;
120
- }
121
- var newDate = parseDateType(textFieldValue, locale);
122
- _this.props.onSubmitDate(newDate);
123
- });
124
- // arrow keys are only triggered by onKeyDown, not onKeyPress
125
- _defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (event) {
126
- var dateString = event.target.value;
127
- var locale = _this.props.locale;
128
- var adjustment;
129
- if (event.key === 'ArrowUp') {
130
- adjustment = 1;
131
- } else if (event.key === 'ArrowDown') {
132
- adjustment = -1;
133
- }
134
- if (adjustment === undefined) {
135
- return;
136
- }
137
- var dispatchAnalyticsEvent = _this.props.dispatchAnalyticsEvent;
138
- var cursorPos = _this.inputRef.selectionStart;
139
- var activeSegment = findDateSegmentByPosition(cursorPos, dateString, locale);
140
- if (activeSegment === undefined) {
141
- return;
142
- }
143
- var dateSegment;
144
- switch (activeSegment) {
145
- case 'day':
146
- dateSegment = ACTION_SUBJECT_ID.DATE_DAY;
147
- break;
148
- case 'month':
149
- dateSegment = ACTION_SUBJECT_ID.DATE_MONTH;
150
- break;
151
- default:
152
- dateSegment = ACTION_SUBJECT_ID.DATE_YEAR;
153
- }
154
- if (dispatchAnalyticsEvent) {
155
- dispatchAnalyticsEvent({
156
- eventType: EVENT_TYPE.TRACK,
157
- action: adjustment > 0 ? ACTION.INCREMENTED : ACTION.DECREMENTED,
158
- actionSubject: ACTION_SUBJECT.DATE_SEGMENT,
159
- attributes: {
160
- dateSegment: dateSegment
161
- }
162
- });
163
- }
164
- var oldDateType = parseDateType(dateString, locale);
165
- if (oldDateType === undefined || oldDateType === null) {
166
- return;
167
- }
168
- var newDateType = adjustDate(oldDateType, activeSegment, adjustment);
169
- _this.setState({
170
- inputText: formatDateType(newDateType, locale)
171
- });
172
- _this.props.onNewDate(newDateType);
173
- _this.setInputSelectionPos = Math.min(cursorPos, dateString.length);
174
- event.preventDefault();
175
- });
176
- var date = props.date;
177
- _this.setInputSelectionPos = undefined;
178
- var inputText = formatDateType(date, _this.props.locale);
179
- _this.state = {
180
- inputText: inputText
181
- };
182
- return _this;
183
- }
184
- _createClass(DatePickerInput, [{
185
- key: "render",
186
- value: function render() {
187
- var _this$props4 = this.props,
188
- locale = _this$props4.locale,
189
- formatMessage = _this$props4.intl.formatMessage;
190
- var inputText = this.state.inputText;
191
- var possiblyValid = isDatePossiblyValid(inputText);
192
- var attemptedDateParse = parseDateType(inputText, locale);
193
-
194
- // Don't display an error for an empty input.
195
- var displayError = (attemptedDateParse === null || !possiblyValid) && inputText !== '';
196
- return jsx("div", {
197
- css: dateTextFieldWrapper
198
- }, jsx(TextField, {
199
- name: "datetextfield",
200
- value: inputText,
201
- ref: this.handleInputRef,
202
- onChange: this.handleChange,
203
- onKeyPress: this.handleKeyPress,
204
- onKeyDown: this.handleKeyDown,
205
- spellCheck: false,
206
- autoComplete: "off",
207
- isInvalid: displayError
208
- }), displayError && jsx(ErrorMessage, null, formatMessage(messages.invalidDateError)));
209
- }
210
- }, {
211
- key: "componentDidUpdate",
212
- value: function componentDidUpdate() {
213
- var setInputSelectionPos = this.setInputSelectionPos;
214
- if (setInputSelectionPos !== undefined) {
215
- this.inputRef.setSelectionRange(setInputSelectionPos, setInputSelectionPos);
216
- this.setInputSelectionPos = undefined;
217
- }
218
- if (this.inputRef && this.props.autoFocus) {
219
- // TODO: Check if input already has focus
220
- this.focusInput();
221
- }
222
-
223
- // Don't select all text here - would seleect text on each keystroke
224
- }
225
- }, {
226
- key: "componentWillUnmount",
227
- value: function componentWillUnmount() {
228
- if (this.autofocusTimeout !== undefined) {
229
- clearTimeout(this.autofocusTimeout);
230
- }
231
- if (this.autoSelectAllTimeout !== undefined) {
232
- clearTimeout(this.autoSelectAllTimeout);
233
- }
234
- }
235
- }]);
236
- return DatePickerInput;
237
- }(React.Component);
238
- export default injectIntl(DatePickerInput);