@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,8 +0,0 @@
1
- import { defineMessages } from 'react-intl-next';
2
- export const messages = defineMessages({
3
- editText: {
4
- id: 'fabric.editor.editDateText',
5
- defaultMessage: 'Edit Date',
6
- description: 'Title for the input that changes the date'
7
- }
8
- });
@@ -1,183 +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, 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
- const DatePicker = Loadable({
15
- loader: () => import( /* webpackChunkName: "@atlaskit-internal_editor-datepicker" */'./ui/DatePicker').then(mod => mod.default),
16
- loading: () => null
17
- });
18
- function ContentComponent({
19
- editorView,
20
- dispatchAnalyticsEvent,
21
- popupsMountPoint,
22
- popupsBoundariesElement,
23
- popupsScrollableElement,
24
- dependencyApi,
25
- weekStartDay
26
- }) {
27
- const {
28
- dispatch
29
- } = editorView;
30
- const domAtPos = editorView.domAtPos.bind(editorView);
31
- const {
32
- editorDisabledState,
33
- dateState
34
- } = useSharedPluginState(dependencyApi, ['date', 'editorDisabled']);
35
- if (!(dateState !== null && dateState !== void 0 && dateState.showDatePickerAt) || editorDisabledState !== null && editorDisabledState !== void 0 && editorDisabledState.editorDisabled) {
36
- return null;
37
- }
38
- const {
39
- showDatePickerAt,
40
- isNew,
41
- focusDateInput
42
- } = dateState;
43
- const 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: () => {
53
- dependencyApi === null || dependencyApi === void 0 ? void 0 : dependencyApi.core.actions.execute(deleteDateCommand(dependencyApi));
54
- editorView.focus();
55
- },
56
- 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 ? void 0 : dependencyApi.core.actions.execute(insertDateCommand(dependencyApi)({
62
- date,
63
- commitMethod
64
- }));
65
- editorView.focus();
66
- },
67
- onTextChanged: date => {
68
- dependencyApi === null || dependencyApi === void 0 ? void 0 : dependencyApi.core.actions.execute(insertDateCommand(dependencyApi)({
69
- date,
70
- enterPressed: false
71
- }));
72
- },
73
- closeDatePicker: () => {
74
- closeDatePicker()(editorView.state, dispatch);
75
- editorView.focus();
76
- },
77
- closeDatePickerWithAnalytics: ({
78
- date
79
- }) => {
80
- closeDatePickerWithAnalytics({
81
- date
82
- })(editorView.state, dispatch);
83
- editorView.focus();
84
- },
85
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
86
- weekStartDay: weekStartDay
87
- });
88
- }
89
- const datePlugin = ({
90
- config: options = {},
91
- api
92
- }) => ({
93
- name: 'date',
94
- getSharedState(editorState) {
95
- if (!editorState) {
96
- return {
97
- showDatePickerAt: null,
98
- isNew: false,
99
- focusDateInput: false
100
- };
101
- }
102
- const {
103
- showDatePickerAt,
104
- isNew,
105
- focusDateInput
106
- } = datePluginKey.getState(editorState) || {};
107
- return {
108
- showDatePickerAt,
109
- isNew: !!isNew,
110
- focusDateInput: !!focusDateInput
111
- };
112
- },
113
- commands: {
114
- insertDate: insertDateCommand(api),
115
- deleteDate: deleteDateCommand(api)
116
- },
117
- nodes() {
118
- return [{
119
- name: 'date',
120
- node: date
121
- }];
122
- },
123
- pmPlugins() {
124
- return [{
125
- name: 'date',
126
- plugin: options => {
127
- DatePicker.preload();
128
- return createDatePlugin(options);
129
- }
130
- }, {
131
- name: 'dateKeymap',
132
- plugin: () => {
133
- DatePicker.preload();
134
- return keymap();
135
- }
136
- }];
137
- },
138
- contentComponent({
139
- editorView,
140
- dispatchAnalyticsEvent,
141
- popupsMountPoint,
142
- popupsBoundariesElement,
143
- popupsScrollableElement
144
- }) {
145
- return /*#__PURE__*/React.createElement(ContentComponent, {
146
- dependencyApi: api,
147
- editorView: editorView,
148
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
149
- popupsMountPoint: popupsMountPoint,
150
- popupsBoundariesElement: popupsBoundariesElement,
151
- popupsScrollableElement: popupsScrollableElement,
152
- weekStartDay: options.weekStartDay
153
- });
154
- },
155
- pluginsOptions: {
156
- quickInsert: ({
157
- formatMessage
158
- }) => [{
159
- id: 'date',
160
- title: formatMessage(messages.date),
161
- description: formatMessage(messages.dateDescription),
162
- priority: 800,
163
- keywords: ['calendar', 'day', 'time', 'today', '/'],
164
- keyshortcut: '//',
165
- icon: () => /*#__PURE__*/React.createElement(IconDate, null),
166
- action(insert, state) {
167
- var _api$analytics, _api$analytics$action, _api$analytics$action2;
168
- const tr = createDate(true)(insert, state);
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
- 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
- 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
- const list = {};
7
- bindKeymapWithCommand(enter.common, (state, dispatch) => {
8
- const datePlugin = getPluginState(state);
9
- const 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, (state, dispatch) => {
21
- const datePlugin = getPluginState(state);
22
- const 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,35 +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
- const {
8
- createPluginState,
9
- getPluginState
10
- } = pluginFactory(pluginKey, reducer, {
11
- mapping,
12
- onSelectionChanged
13
- });
14
- const createPlugin = pmPluginFactoryParams => {
15
- const newPluginState = {
16
- showDatePickerAt: null,
17
- isNew: false,
18
- isDateEmpty: false,
19
- focusDateInput: false
20
- };
21
- return new SafePlugin({
22
- state: createPluginState(pmPluginFactoryParams.dispatch, newPluginState),
23
- key: pluginKey,
24
- props: {
25
- nodeViews: {
26
- date: getInlineNodeViewProducer({
27
- pmPluginFactoryParams,
28
- Component: DateNodeView
29
- })
30
- }
31
- }
32
- });
33
- };
34
- export { getPluginState };
35
- export default createPlugin;
@@ -1,2 +0,0 @@
1
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export const pluginKey = new PluginKey('datePlugin');
@@ -1 +0,0 @@
1
- export {};
@@ -1,70 +0,0 @@
1
- import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
2
- export function reducer(pluginState, meta) {
3
- // If the same nodeview is clicked twice, calendar should close
4
- if (meta.showDatePickerAt === pluginState.showDatePickerAt) {
5
- return {
6
- ...pluginState,
7
- showDatePickerAt: null
8
- };
9
- }
10
- const {
11
- showDatePickerAt,
12
- isNew
13
- } = pluginState;
14
- const {
15
- showDatePickerAt: showDatePickerAtMeta
16
- } = meta;
17
- // If date picker position has changed, it is no longer new
18
- if (showDatePickerAt && showDatePickerAtMeta && showDatePickerAt !== showDatePickerAtMeta && isNew) {
19
- return {
20
- ...pluginState,
21
- ...meta,
22
- isNew: false
23
- };
24
- }
25
- return {
26
- ...pluginState,
27
- ...meta
28
- };
29
- }
30
- export function mapping(tr, pluginState) {
31
- if (!pluginState.showDatePickerAt) {
32
- return pluginState;
33
- }
34
- const {
35
- pos
36
- } = tr.mapping.mapResult(pluginState.showDatePickerAt);
37
- return {
38
- showDatePickerAt: pos,
39
- isNew: pluginState.isNew,
40
- isDateEmpty: pluginState.isDateEmpty,
41
- focusDateInput: pluginState.focusDateInput
42
- };
43
- }
44
- export function onSelectionChanged(tr, pluginState) {
45
- if (tr.docChanged && isDateNodeSelection(tr.selection)) {
46
- return {
47
- ...pluginState,
48
- isQuickInsertAction: false,
49
- showDatePickerAt: tr.selection.from
50
- };
51
- } else if (!isDateNodeSelection(tr.selection) && !pluginState.isQuickInsertAction) {
52
- if (pluginState.showDatePickerAt) {
53
- return {
54
- showDatePickerAt: null,
55
- isNew: false,
56
- isDateEmpty: false,
57
- focusDateInput: false
58
- };
59
- }
60
- return pluginState;
61
- }
62
- return pluginState;
63
- }
64
- const isDateNodeSelection = selection => {
65
- if (selection instanceof NodeSelection) {
66
- const nodeTypeName = selection.node.type.name;
67
- return nodeTypeName === 'date';
68
- }
69
- return false;
70
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,233 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- /** @jsx jsx */
3
-
4
- import React from 'react';
5
- import { css, jsx } from '@emotion/react';
6
- import { defineMessages, injectIntl } from 'react-intl-next';
7
- import { findDateSegmentByPosition, adjustDate, isDatePossiblyValid } from '../../utils/internal';
8
- import { parseDateType, formatDateType } from '../../utils/formatParse';
9
- import { EVENT_TYPE, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
10
- import TextField from '@atlaskit/textfield';
11
- import { ErrorMessage } from '@atlaskit/form';
12
- const dateTextFieldWrapper = css`
13
- padding: 22px;
14
- padding-bottom: ${"var(--ds-space-150, 12px)"};
15
- `;
16
- const messages = defineMessages({
17
- invalidDateError: {
18
- id: 'fabric.editor.invalidDateError',
19
- defaultMessage: 'Enter a valid date',
20
- description: 'Error message when the date typed in is invalid, requesting they inputs a new date'
21
- }
22
- });
23
- class DatePickerInput extends React.Component {
24
- constructor(props) {
25
- super(props);
26
- /**
27
- * Focus the input textfield
28
- */
29
- _defineProperty(this, "focusInput", () => {
30
- if (!this.inputRef) {
31
- return;
32
- }
33
- // Defer to prevent editor scrolling to top (See FS-3227, also ED-2992)
34
- this.autofocusTimeout = setTimeout(() => {
35
- this.inputRef.focus();
36
- });
37
- });
38
- /**
39
- * Select all the input text
40
- */
41
- _defineProperty(this, "selectInput", () => {
42
- if (!this.inputRef) {
43
- return;
44
- }
45
- // Defer to prevent editor scrolling to top (See FS-3227, also ED-2992)
46
- this.autoSelectAllTimeout = setTimeout(() => {
47
- this.inputRef.select();
48
- });
49
- });
50
- _defineProperty(this, "handleInputRef", ref => {
51
- const {
52
- autoFocus,
53
- autoSelectAll
54
- } = this.props;
55
- if (ref) {
56
- this.inputRef = ref;
57
- }
58
- if (ref && autoFocus) {
59
- this.focusInput();
60
- }
61
- if (autoSelectAll) {
62
- this.selectInput();
63
- }
64
- });
65
- _defineProperty(this, "handleChange", evt => {
66
- const textFieldValue = evt.target.value;
67
- const {
68
- locale,
69
- dispatchAnalyticsEvent
70
- } = this.props;
71
- const newDate = parseDateType(textFieldValue, locale);
72
- if (newDate !== undefined && newDate !== null) {
73
- this.setState({
74
- inputText: textFieldValue
75
- });
76
- this.props.onNewDate(newDate);
77
- if (dispatchAnalyticsEvent) {
78
- dispatchAnalyticsEvent({
79
- eventType: EVENT_TYPE.TRACK,
80
- action: ACTION.TYPING_FINISHED,
81
- actionSubject: ACTION_SUBJECT.DATE
82
- });
83
- }
84
- } else {
85
- // if invalid, just update state text (to rerender textfield)
86
- this.setState({
87
- inputText: textFieldValue
88
- });
89
- }
90
- });
91
- _defineProperty(this, "handleKeyPress", event => {
92
- const {
93
- locale,
94
- dispatchAnalyticsEvent
95
- } = this.props;
96
- const textFieldValue = event.target.value;
97
-
98
- // Fire event on every keypress (textfield not necessarily empty)
99
- if (dispatchAnalyticsEvent && event.key !== 'Enter' && event.key !== 'Backspace') {
100
- dispatchAnalyticsEvent({
101
- eventType: EVENT_TYPE.TRACK,
102
- action: ACTION.TYPING_STARTED,
103
- actionSubject: ACTION_SUBJECT.DATE
104
- });
105
- }
106
- if (event.key !== 'Enter') {
107
- return;
108
- }
109
- if (textFieldValue === '') {
110
- this.props.onEmptySubmit();
111
- return;
112
- }
113
- const newDate = parseDateType(textFieldValue, locale);
114
- this.props.onSubmitDate(newDate);
115
- });
116
- // arrow keys are only triggered by onKeyDown, not onKeyPress
117
- _defineProperty(this, "handleKeyDown", event => {
118
- const dateString = event.target.value;
119
- const {
120
- locale
121
- } = this.props;
122
- let adjustment;
123
- if (event.key === 'ArrowUp') {
124
- adjustment = 1;
125
- } else if (event.key === 'ArrowDown') {
126
- adjustment = -1;
127
- }
128
- if (adjustment === undefined) {
129
- return;
130
- }
131
- const {
132
- dispatchAnalyticsEvent
133
- } = this.props;
134
- const cursorPos = this.inputRef.selectionStart;
135
- const activeSegment = findDateSegmentByPosition(cursorPos, dateString, locale);
136
- if (activeSegment === undefined) {
137
- return;
138
- }
139
- let dateSegment;
140
- switch (activeSegment) {
141
- case 'day':
142
- dateSegment = ACTION_SUBJECT_ID.DATE_DAY;
143
- break;
144
- case 'month':
145
- dateSegment = ACTION_SUBJECT_ID.DATE_MONTH;
146
- break;
147
- default:
148
- dateSegment = ACTION_SUBJECT_ID.DATE_YEAR;
149
- }
150
- if (dispatchAnalyticsEvent) {
151
- dispatchAnalyticsEvent({
152
- eventType: EVENT_TYPE.TRACK,
153
- action: adjustment > 0 ? ACTION.INCREMENTED : ACTION.DECREMENTED,
154
- actionSubject: ACTION_SUBJECT.DATE_SEGMENT,
155
- attributes: {
156
- dateSegment
157
- }
158
- });
159
- }
160
- const oldDateType = parseDateType(dateString, locale);
161
- if (oldDateType === undefined || oldDateType === null) {
162
- return;
163
- }
164
- const newDateType = adjustDate(oldDateType, activeSegment, adjustment);
165
- this.setState({
166
- inputText: formatDateType(newDateType, locale)
167
- });
168
- this.props.onNewDate(newDateType);
169
- this.setInputSelectionPos = Math.min(cursorPos, dateString.length);
170
- event.preventDefault();
171
- });
172
- const {
173
- date
174
- } = props;
175
- this.setInputSelectionPos = undefined;
176
- const inputText = formatDateType(date, this.props.locale);
177
- this.state = {
178
- inputText
179
- };
180
- }
181
- render() {
182
- const {
183
- locale,
184
- intl: {
185
- formatMessage
186
- }
187
- } = this.props;
188
- const {
189
- inputText
190
- } = this.state;
191
- const possiblyValid = isDatePossiblyValid(inputText);
192
- const attemptedDateParse = parseDateType(inputText, locale);
193
-
194
- // Don't display an error for an empty input.
195
- const 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
- componentDidUpdate() {
211
- const setInputSelectionPos = this.setInputSelectionPos;
212
- if (setInputSelectionPos !== undefined) {
213
- this.inputRef.setSelectionRange(setInputSelectionPos, setInputSelectionPos);
214
- this.setInputSelectionPos = undefined;
215
- }
216
- if (this.inputRef && this.props.autoFocus) {
217
- // TODO: Check if input already has focus
218
- this.focusInput();
219
- }
220
-
221
- // Don't select all text here - would seleect text on each keystroke
222
- }
223
-
224
- componentWillUnmount() {
225
- if (this.autofocusTimeout !== undefined) {
226
- clearTimeout(this.autofocusTimeout);
227
- }
228
- if (this.autoSelectAllTimeout !== undefined) {
229
- clearTimeout(this.autoSelectAllTimeout);
230
- }
231
- }
232
- }
233
- export default injectIntl(DatePickerInput);