@atlaskit/editor-plugin-date 4.1.6 → 4.1.8
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 +17 -0
- package/dist/cjs/datePlugin.js +5 -6
- package/dist/cjs/nodeviews/DateNodeView.js +63 -0
- package/dist/cjs/nodeviews/dateNodeSpec.js +62 -27
- package/dist/cjs/pm-plugins/main.js +15 -5
- package/dist/es2019/datePlugin.js +5 -6
- package/dist/es2019/nodeviews/DateNodeView.js +49 -0
- package/dist/es2019/nodeviews/dateNodeSpec.js +62 -26
- package/dist/es2019/pm-plugins/main.js +17 -5
- package/dist/esm/datePlugin.js +5 -6
- package/dist/esm/nodeviews/DateNodeView.js +56 -0
- package/dist/esm/nodeviews/dateNodeSpec.js +61 -26
- package/dist/esm/pm-plugins/main.js +15 -5
- package/dist/types/nodeviews/DateNodeView.d.ts +14 -0
- package/dist/types/nodeviews/dateNodeSpec.d.ts +17 -2
- package/dist/types/pm-plugins/actions.d.ts +1 -0
- package/dist/types/pm-plugins/main.d.ts +3 -2
- package/dist/types-ts4.5/nodeviews/DateNodeView.d.ts +14 -0
- package/dist/types-ts4.5/nodeviews/dateNodeSpec.d.ts +23 -2
- package/dist/types-ts4.5/pm-plugins/actions.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +3 -2
- package/package.json +10 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-date
|
|
2
2
|
|
|
3
|
+
## 4.1.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#137676](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/137676)
|
|
8
|
+
[`4a54b4a64712e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4a54b4a64712e) -
|
|
9
|
+
ED-27338: clean up vanilla date implementation
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 4.1.7
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#134341](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/134341)
|
|
17
|
+
[`e53990137fb56`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e53990137fb56) -
|
|
18
|
+
ED-27338: converts editor date node to vanilla js
|
|
19
|
+
|
|
3
20
|
## 4.1.6
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/cjs/datePlugin.js
CHANGED
|
@@ -17,7 +17,6 @@ var _styles = require("@atlaskit/editor-common/styles");
|
|
|
17
17
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
18
18
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
19
19
|
var _comment = _interopRequireDefault(require("@atlaskit/icon/core/comment"));
|
|
20
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
20
|
var _dateNodeSpec = require("./nodeviews/dateNodeSpec");
|
|
22
21
|
var _actions = require("./pm-plugins/actions");
|
|
23
22
|
var _commands = require("./pm-plugins/commands");
|
|
@@ -113,7 +112,7 @@ function ContentComponent(_ref) {
|
|
|
113
112
|
}
|
|
114
113
|
var datePlugin = function datePlugin(_ref3) {
|
|
115
114
|
var _ref3$config = _ref3.config,
|
|
116
|
-
|
|
115
|
+
config = _ref3$config === void 0 ? {} : _ref3$config,
|
|
117
116
|
api = _ref3.api;
|
|
118
117
|
return {
|
|
119
118
|
name: 'date',
|
|
@@ -148,9 +147,9 @@ var datePlugin = function datePlugin(_ref3) {
|
|
|
148
147
|
pmPlugins: function pmPlugins() {
|
|
149
148
|
return [{
|
|
150
149
|
name: 'date',
|
|
151
|
-
plugin: function plugin(
|
|
150
|
+
plugin: function plugin(pmPluginFactoryParams) {
|
|
152
151
|
DatePicker.preload();
|
|
153
|
-
return (0, _main.default)(
|
|
152
|
+
return (0, _main.default)(pmPluginFactoryParams);
|
|
154
153
|
}
|
|
155
154
|
}, {
|
|
156
155
|
name: 'dateKeymap',
|
|
@@ -173,7 +172,7 @@ var datePlugin = function datePlugin(_ref3) {
|
|
|
173
172
|
popupsMountPoint: popupsMountPoint,
|
|
174
173
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
175
174
|
popupsScrollableElement: popupsScrollableElement,
|
|
176
|
-
weekStartDay:
|
|
175
|
+
weekStartDay: config.weekStartDay
|
|
177
176
|
});
|
|
178
177
|
},
|
|
179
178
|
pluginsOptions: {
|
|
@@ -210,7 +209,7 @@ var datePlugin = function datePlugin(_ref3) {
|
|
|
210
209
|
var _api$editorViewMode;
|
|
211
210
|
return (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view';
|
|
212
211
|
};
|
|
213
|
-
if (!isViewMode()
|
|
212
|
+
if (!isViewMode()) {
|
|
214
213
|
return undefined;
|
|
215
214
|
}
|
|
216
215
|
var onClick = function onClick(stateFromClickEvent, dispatch) {
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.DateNodeView = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _bindEventListener = require("bind-event-listener");
|
|
12
|
+
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
13
|
+
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
14
|
+
var _actions = require("../pm-plugins/actions");
|
|
15
|
+
var _dateNodeSpec = require("./dateNodeSpec");
|
|
16
|
+
var DateNodeView = exports.DateNodeView = /*#__PURE__*/function () {
|
|
17
|
+
function DateNodeView(node, view, getPos, intl) {
|
|
18
|
+
(0, _classCallCheck2.default)(this, DateNodeView);
|
|
19
|
+
(0, _defineProperty2.default)(this, "dom", document.createElement('span'));
|
|
20
|
+
this.node = node;
|
|
21
|
+
try {
|
|
22
|
+
var spec = (0, _dateNodeSpec.dateToDOM)(node, view.state, getPos, intl);
|
|
23
|
+
var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, spec),
|
|
24
|
+
dom = _DOMSerializer$render.dom;
|
|
25
|
+
if (!(dom instanceof HTMLElement)) {
|
|
26
|
+
throw new Error('DOMSerializer.renderSpec() did not return HTMLElement');
|
|
27
|
+
}
|
|
28
|
+
this.dom = dom;
|
|
29
|
+
this.clickUnBind = (0, _bindEventListener.bind)(this.dom, {
|
|
30
|
+
type: 'click',
|
|
31
|
+
listener: function listener(event) {
|
|
32
|
+
event.stopImmediatePropagation();
|
|
33
|
+
var state = view.state,
|
|
34
|
+
dispatch = view.dispatch;
|
|
35
|
+
(0, _actions.setDatePickerAt)(state.selection.from)(state, dispatch);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
} catch (error) {
|
|
39
|
+
DateNodeView.logError(error instanceof Error ? error : new Error('Unknown error on DateNodeView constructor'));
|
|
40
|
+
this.renderFallback();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return (0, _createClass2.default)(DateNodeView, [{
|
|
44
|
+
key: "renderFallback",
|
|
45
|
+
value: function renderFallback() {
|
|
46
|
+
var fallbackElement = document.createElement('span');
|
|
47
|
+
fallbackElement.innerText = this.node.attrs.timestamp;
|
|
48
|
+
this.dom.appendChild(fallbackElement);
|
|
49
|
+
}
|
|
50
|
+
}, {
|
|
51
|
+
key: "destroy",
|
|
52
|
+
value: function destroy() {
|
|
53
|
+
this.clickUnBind && this.clickUnBind();
|
|
54
|
+
}
|
|
55
|
+
}], [{
|
|
56
|
+
key: "logError",
|
|
57
|
+
value: function logError(error) {
|
|
58
|
+
void (0, _monitoring.logException)(error, {
|
|
59
|
+
location: 'editor-plugin-date/DateNodeView'
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}]);
|
|
63
|
+
}();
|
|
@@ -4,18 +4,20 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.dateNodeSpec = void 0;
|
|
7
|
+
exports.dateToDOMvirtualization = exports.dateToDOM = exports.dateNodeSpec = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _reactIntlNext = require("react-intl-next");
|
|
10
10
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
11
11
|
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
12
12
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
13
|
+
var _whitespace = require("@atlaskit/editor-common/whitespace");
|
|
13
14
|
var _colors = require("@atlaskit/theme/colors");
|
|
14
15
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
16
|
+
var _utils2 = require("./utils");
|
|
15
17
|
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; }
|
|
16
18
|
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) { (0, _defineProperty2.default)(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; }
|
|
17
19
|
var isSSR = Boolean(process.env.REACT_SSR);
|
|
18
|
-
var
|
|
20
|
+
var intlRef;
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
23
|
* Wrapper for ADF date node spec to augment toDOM implementation
|
|
@@ -24,33 +26,66 @@ var intl;
|
|
|
24
26
|
* @returns
|
|
25
27
|
*/
|
|
26
28
|
var dateNodeSpec = exports.dateNodeSpec = function dateNodeSpec() {
|
|
27
|
-
if (isSSR || (0, _experiments.editorExperiment)('platform_editor_inline_node_virtualization', 'off')) {
|
|
29
|
+
if (!(0, _experiments.editorExperiment)('platform_editor_vanilla_dom', true) && (isSSR || (0, _experiments.editorExperiment)('platform_editor_inline_node_virtualization', 'off'))) {
|
|
28
30
|
return _adfSchema.date;
|
|
29
31
|
}
|
|
30
32
|
return _objectSpread(_objectSpread({}, _adfSchema.date), {}, {
|
|
31
|
-
toDOM:
|
|
32
|
-
intl = intl || (0, _reactIntlNext.createIntl)({
|
|
33
|
-
locale: document.documentElement.lang || 'en-US'
|
|
34
|
-
});
|
|
35
|
-
var timestamp = node.attrs.timestamp;
|
|
36
|
-
var displayString = (0, _utils.timestampToString)(timestamp, intl);
|
|
37
|
-
var wrapperAttrs = {
|
|
38
|
-
class: 'date-lozenger-container',
|
|
39
|
-
'data-node-type': 'date',
|
|
40
|
-
'data-timestamp': timestamp,
|
|
41
|
-
'aria-busy': 'true'
|
|
42
|
-
};
|
|
43
|
-
var attrs = {
|
|
44
|
-
style: (0, _lazyNodeView.convertToInlineCss)({
|
|
45
|
-
// Taken from @atlaskit/date Component
|
|
46
|
-
backgroundColor: "var(--ds-background-neutral, ".concat(_colors.N30A, ")"),
|
|
47
|
-
color: "var(--ds-text, ".concat(_colors.N800, ")"),
|
|
48
|
-
borderRadius: "var(--ds-border-radius-100, 4px)",
|
|
49
|
-
padding: "var(--ds-space-025, 2px)".concat(" ", "var(--ds-space-050, 4px)"),
|
|
50
|
-
margin: '0 1px'
|
|
51
|
-
})
|
|
52
|
-
};
|
|
53
|
-
return ['span', wrapperAttrs, ['span', attrs, displayString]];
|
|
54
|
-
}
|
|
33
|
+
toDOM: dateToDOMvirtualization
|
|
55
34
|
});
|
|
35
|
+
};
|
|
36
|
+
var dateToDOMvirtualization = exports.dateToDOMvirtualization = function dateToDOMvirtualization(node) {
|
|
37
|
+
intlRef = intlRef || (0, _reactIntlNext.createIntl)({
|
|
38
|
+
locale: document.documentElement.lang || 'en-US'
|
|
39
|
+
});
|
|
40
|
+
var timestamp = node.attrs.timestamp;
|
|
41
|
+
var displayString = (0, _utils.timestampToString)(timestamp, intlRef);
|
|
42
|
+
var wrapperAttrs = {
|
|
43
|
+
class: 'date-lozenger-container',
|
|
44
|
+
'data-node-type': 'date',
|
|
45
|
+
'data-timestamp': timestamp,
|
|
46
|
+
'aria-busy': 'true'
|
|
47
|
+
};
|
|
48
|
+
var attrs = {
|
|
49
|
+
style: (0, _lazyNodeView.convertToInlineCss)({
|
|
50
|
+
// Taken from @atlaskit/date Component
|
|
51
|
+
backgroundColor: "var(--ds-background-neutral, ".concat(_colors.N30A, ")"),
|
|
52
|
+
color: "var(--ds-text, ".concat(_colors.N800, ")"),
|
|
53
|
+
borderRadius: "var(--ds-border-radius-100, 4px)",
|
|
54
|
+
padding: "var(--ds-space-025, 2px)".concat(" ", "var(--ds-space-050, 4px)"),
|
|
55
|
+
margin: '0 1px'
|
|
56
|
+
})
|
|
57
|
+
};
|
|
58
|
+
return ['span', wrapperAttrs, ['span', attrs, displayString]];
|
|
59
|
+
};
|
|
60
|
+
var dateToDOM = exports.dateToDOM = function dateToDOM(node, state, getPos, intl) {
|
|
61
|
+
var timestamp = node.attrs.timestamp;
|
|
62
|
+
var pos = getPos === null || getPos === void 0 ? void 0 : getPos();
|
|
63
|
+
var _getDateInformation = (0, _utils2.getDateInformation)(timestamp, intl, state, pos),
|
|
64
|
+
displayString = _getDateInformation.displayString,
|
|
65
|
+
color = _getDateInformation.color;
|
|
66
|
+
var nodeWrapperAttrs = {
|
|
67
|
+
contenteditable: 'false',
|
|
68
|
+
timestamp: timestamp,
|
|
69
|
+
class: 'dateView-content-wrap inlineNodeView',
|
|
70
|
+
'data-prosemirror-content-type': 'node',
|
|
71
|
+
'data-prosemirror-node-name': 'date',
|
|
72
|
+
'data-prosemirror-node-inline': 'true',
|
|
73
|
+
'data-prosemirror-node-view-type': 'vanilla',
|
|
74
|
+
draggable: 'true'
|
|
75
|
+
};
|
|
76
|
+
var wrapperAttrs = {
|
|
77
|
+
class: 'date-lozenger-container',
|
|
78
|
+
'data-node-type': 'date',
|
|
79
|
+
'data-timestamp': timestamp
|
|
80
|
+
};
|
|
81
|
+
var attrs = color === undefined ? {} : {
|
|
82
|
+
class: "date-node-color-".concat(color)
|
|
83
|
+
};
|
|
84
|
+
return ['span', nodeWrapperAttrs, ['span', {
|
|
85
|
+
class: 'zeroWidthSpaceContainer'
|
|
86
|
+
}, ['span', {
|
|
87
|
+
class: 'inlineNodeViewAddZeroWidthSpace'
|
|
88
|
+
}, _whitespace.ZERO_WIDTH_SPACE]], ['span', wrapperAttrs, ['span', attrs, displayString]], ['span', {
|
|
89
|
+
class: 'inlineNodeViewAddZeroWidthSpace'
|
|
90
|
+
}, _whitespace.ZERO_WIDTH_SPACE]];
|
|
56
91
|
};
|
|
@@ -7,7 +7,9 @@ exports.getPluginState = exports.default = void 0;
|
|
|
7
7
|
var _reactNodeView = require("@atlaskit/editor-common/react-node-view");
|
|
8
8
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
9
9
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
10
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
10
11
|
var _date = require("../nodeviews/date");
|
|
12
|
+
var _DateNodeView = require("../nodeviews/DateNodeView");
|
|
11
13
|
var _pluginKey = require("./plugin-key");
|
|
12
14
|
var _utils2 = require("./utils");
|
|
13
15
|
var _pluginFactory = (0, _utils.pluginFactory)(_pluginKey.pluginKey, _utils2.reducer, {
|
|
@@ -17,6 +19,7 @@ var _pluginFactory = (0, _utils.pluginFactory)(_pluginKey.pluginKey, _utils2.red
|
|
|
17
19
|
createPluginState = _pluginFactory.createPluginState,
|
|
18
20
|
getPluginState = exports.getPluginState = _pluginFactory.getPluginState;
|
|
19
21
|
var createPlugin = function createPlugin(pmPluginFactoryParams) {
|
|
22
|
+
var dispatch = pmPluginFactoryParams.dispatch;
|
|
20
23
|
var newPluginState = {
|
|
21
24
|
showDatePickerAt: null,
|
|
22
25
|
isNew: false,
|
|
@@ -24,14 +27,21 @@ var createPlugin = function createPlugin(pmPluginFactoryParams) {
|
|
|
24
27
|
focusDateInput: false
|
|
25
28
|
};
|
|
26
29
|
return new _safePlugin.SafePlugin({
|
|
27
|
-
state: createPluginState(
|
|
30
|
+
state: createPluginState(dispatch, newPluginState),
|
|
28
31
|
key: _pluginKey.pluginKey,
|
|
29
32
|
props: {
|
|
30
33
|
nodeViews: {
|
|
31
|
-
date: (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
date: function date(node, view, getPos, decorations) {
|
|
35
|
+
if ((0, _experiments.editorExperiment)('platform_editor_vanilla_dom', true, {
|
|
36
|
+
exposure: true
|
|
37
|
+
})) {
|
|
38
|
+
return new _DateNodeView.DateNodeView(node, view, getPos, pmPluginFactoryParams.getIntl());
|
|
39
|
+
}
|
|
40
|
+
return (0, _reactNodeView.getInlineNodeViewProducer)({
|
|
41
|
+
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
42
|
+
Component: _date.DateNodeView
|
|
43
|
+
})(node, view, getPos, decorations);
|
|
44
|
+
}
|
|
35
45
|
}
|
|
36
46
|
}
|
|
37
47
|
});
|
|
@@ -9,7 +9,6 @@ import { DateSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
|
9
9
|
import { calculateToolbarPositionAboveSelection } from '@atlaskit/editor-common/utils';
|
|
10
10
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
11
11
|
import CommentIcon from '@atlaskit/icon/core/comment';
|
|
12
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
12
|
import { dateNodeSpec } from './nodeviews/dateNodeSpec';
|
|
14
13
|
import { closeDatePicker, closeDatePickerWithAnalytics, createDate } from './pm-plugins/actions';
|
|
15
14
|
import { deleteDateCommand, insertDateCommand } from './pm-plugins/commands';
|
|
@@ -101,7 +100,7 @@ function ContentComponent({
|
|
|
101
100
|
});
|
|
102
101
|
}
|
|
103
102
|
const datePlugin = ({
|
|
104
|
-
config
|
|
103
|
+
config = {},
|
|
105
104
|
api
|
|
106
105
|
}) => ({
|
|
107
106
|
name: 'date',
|
|
@@ -137,9 +136,9 @@ const datePlugin = ({
|
|
|
137
136
|
pmPlugins() {
|
|
138
137
|
return [{
|
|
139
138
|
name: 'date',
|
|
140
|
-
plugin:
|
|
139
|
+
plugin: pmPluginFactoryParams => {
|
|
141
140
|
DatePicker.preload();
|
|
142
|
-
return createDatePlugin(
|
|
141
|
+
return createDatePlugin(pmPluginFactoryParams);
|
|
143
142
|
}
|
|
144
143
|
}, {
|
|
145
144
|
name: 'dateKeymap',
|
|
@@ -163,7 +162,7 @@ const datePlugin = ({
|
|
|
163
162
|
popupsMountPoint: popupsMountPoint,
|
|
164
163
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
165
164
|
popupsScrollableElement: popupsScrollableElement,
|
|
166
|
-
weekStartDay:
|
|
165
|
+
weekStartDay: config.weekStartDay
|
|
167
166
|
});
|
|
168
167
|
},
|
|
169
168
|
pluginsOptions: {
|
|
@@ -197,7 +196,7 @@ const datePlugin = ({
|
|
|
197
196
|
var _api$editorViewMode, _api$editorViewMode$s;
|
|
198
197
|
return (api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : (_api$editorViewMode$s = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode$s === void 0 ? void 0 : _api$editorViewMode$s.mode) === 'view';
|
|
199
198
|
};
|
|
200
|
-
if (!isViewMode()
|
|
199
|
+
if (!isViewMode()) {
|
|
201
200
|
return undefined;
|
|
202
201
|
}
|
|
203
202
|
const onClick = (stateFromClickEvent, dispatch) => {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { bind } from 'bind-event-listener';
|
|
3
|
+
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
4
|
+
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
+
import { setDatePickerAt } from '../pm-plugins/actions';
|
|
6
|
+
import { dateToDOM } from './dateNodeSpec';
|
|
7
|
+
export class DateNodeView {
|
|
8
|
+
static logError(error) {
|
|
9
|
+
void logException(error, {
|
|
10
|
+
location: 'editor-plugin-date/DateNodeView'
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
constructor(node, view, getPos, intl) {
|
|
14
|
+
_defineProperty(this, "dom", document.createElement('span'));
|
|
15
|
+
this.node = node;
|
|
16
|
+
try {
|
|
17
|
+
const spec = dateToDOM(node, view.state, getPos, intl);
|
|
18
|
+
const {
|
|
19
|
+
dom
|
|
20
|
+
} = DOMSerializer.renderSpec(document, spec);
|
|
21
|
+
if (!(dom instanceof HTMLElement)) {
|
|
22
|
+
throw new Error('DOMSerializer.renderSpec() did not return HTMLElement');
|
|
23
|
+
}
|
|
24
|
+
this.dom = dom;
|
|
25
|
+
this.clickUnBind = bind(this.dom, {
|
|
26
|
+
type: 'click',
|
|
27
|
+
listener: event => {
|
|
28
|
+
event.stopImmediatePropagation();
|
|
29
|
+
const {
|
|
30
|
+
state,
|
|
31
|
+
dispatch
|
|
32
|
+
} = view;
|
|
33
|
+
setDatePickerAt(state.selection.from)(state, dispatch);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
} catch (error) {
|
|
37
|
+
DateNodeView.logError(error instanceof Error ? error : new Error('Unknown error on DateNodeView constructor'));
|
|
38
|
+
this.renderFallback();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
renderFallback() {
|
|
42
|
+
const fallbackElement = document.createElement('span');
|
|
43
|
+
fallbackElement.innerText = this.node.attrs.timestamp;
|
|
44
|
+
this.dom.appendChild(fallbackElement);
|
|
45
|
+
}
|
|
46
|
+
destroy() {
|
|
47
|
+
this.clickUnBind && this.clickUnBind();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -2,10 +2,12 @@ import { createIntl } from 'react-intl-next';
|
|
|
2
2
|
import { date } from '@atlaskit/adf-schema';
|
|
3
3
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
4
4
|
import { timestampToString } from '@atlaskit/editor-common/utils';
|
|
5
|
+
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
5
6
|
import { N30A, N800 } from '@atlaskit/theme/colors';
|
|
6
7
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
|
+
import { getDateInformation } from './utils';
|
|
7
9
|
const isSSR = Boolean(process.env.REACT_SSR);
|
|
8
|
-
let
|
|
10
|
+
let intlRef;
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Wrapper for ADF date node spec to augment toDOM implementation
|
|
@@ -14,34 +16,68 @@ let intl;
|
|
|
14
16
|
* @returns
|
|
15
17
|
*/
|
|
16
18
|
export const dateNodeSpec = () => {
|
|
17
|
-
if (isSSR || editorExperiment('platform_editor_inline_node_virtualization', 'off')) {
|
|
19
|
+
if (!editorExperiment('platform_editor_vanilla_dom', true) && (isSSR || editorExperiment('platform_editor_inline_node_virtualization', 'off'))) {
|
|
18
20
|
return date;
|
|
19
21
|
}
|
|
20
22
|
return {
|
|
21
23
|
...date,
|
|
22
|
-
toDOM:
|
|
23
|
-
intl = intl || createIntl({
|
|
24
|
-
locale: document.documentElement.lang || 'en-US'
|
|
25
|
-
});
|
|
26
|
-
const timestamp = node.attrs.timestamp;
|
|
27
|
-
const displayString = timestampToString(timestamp, intl);
|
|
28
|
-
const wrapperAttrs = {
|
|
29
|
-
class: 'date-lozenger-container',
|
|
30
|
-
'data-node-type': 'date',
|
|
31
|
-
'data-timestamp': timestamp,
|
|
32
|
-
'aria-busy': 'true'
|
|
33
|
-
};
|
|
34
|
-
const attrs = {
|
|
35
|
-
style: convertToInlineCss({
|
|
36
|
-
// Taken from @atlaskit/date Component
|
|
37
|
-
backgroundColor: `var(--ds-background-neutral, ${N30A})`,
|
|
38
|
-
color: `var(--ds-text, ${N800})`,
|
|
39
|
-
borderRadius: "var(--ds-border-radius-100, 4px)",
|
|
40
|
-
padding: `${"var(--ds-space-025, 2px)"} ${"var(--ds-space-050, 4px)"}`,
|
|
41
|
-
margin: '0 1px'
|
|
42
|
-
})
|
|
43
|
-
};
|
|
44
|
-
return ['span', wrapperAttrs, ['span', attrs, displayString]];
|
|
45
|
-
}
|
|
24
|
+
toDOM: dateToDOMvirtualization
|
|
46
25
|
};
|
|
26
|
+
};
|
|
27
|
+
export const dateToDOMvirtualization = node => {
|
|
28
|
+
intlRef = intlRef || createIntl({
|
|
29
|
+
locale: document.documentElement.lang || 'en-US'
|
|
30
|
+
});
|
|
31
|
+
const timestamp = node.attrs.timestamp;
|
|
32
|
+
const displayString = timestampToString(timestamp, intlRef);
|
|
33
|
+
const wrapperAttrs = {
|
|
34
|
+
class: 'date-lozenger-container',
|
|
35
|
+
'data-node-type': 'date',
|
|
36
|
+
'data-timestamp': timestamp,
|
|
37
|
+
'aria-busy': 'true'
|
|
38
|
+
};
|
|
39
|
+
const attrs = {
|
|
40
|
+
style: convertToInlineCss({
|
|
41
|
+
// Taken from @atlaskit/date Component
|
|
42
|
+
backgroundColor: `var(--ds-background-neutral, ${N30A})`,
|
|
43
|
+
color: `var(--ds-text, ${N800})`,
|
|
44
|
+
borderRadius: "var(--ds-border-radius-100, 4px)",
|
|
45
|
+
padding: `${"var(--ds-space-025, 2px)"} ${"var(--ds-space-050, 4px)"}`,
|
|
46
|
+
margin: '0 1px'
|
|
47
|
+
})
|
|
48
|
+
};
|
|
49
|
+
return ['span', wrapperAttrs, ['span', attrs, displayString]];
|
|
50
|
+
};
|
|
51
|
+
export const dateToDOM = (node, state, getPos, intl) => {
|
|
52
|
+
const timestamp = node.attrs.timestamp;
|
|
53
|
+
const pos = getPos === null || getPos === void 0 ? void 0 : getPos();
|
|
54
|
+
const {
|
|
55
|
+
displayString,
|
|
56
|
+
color
|
|
57
|
+
} = getDateInformation(timestamp, intl, state, pos);
|
|
58
|
+
const nodeWrapperAttrs = {
|
|
59
|
+
contenteditable: 'false',
|
|
60
|
+
timestamp: timestamp,
|
|
61
|
+
class: 'dateView-content-wrap inlineNodeView',
|
|
62
|
+
'data-prosemirror-content-type': 'node',
|
|
63
|
+
'data-prosemirror-node-name': 'date',
|
|
64
|
+
'data-prosemirror-node-inline': 'true',
|
|
65
|
+
'data-prosemirror-node-view-type': 'vanilla',
|
|
66
|
+
draggable: 'true'
|
|
67
|
+
};
|
|
68
|
+
const wrapperAttrs = {
|
|
69
|
+
class: 'date-lozenger-container',
|
|
70
|
+
'data-node-type': 'date',
|
|
71
|
+
'data-timestamp': timestamp
|
|
72
|
+
};
|
|
73
|
+
const attrs = color === undefined ? {} : {
|
|
74
|
+
class: `date-node-color-${color}`
|
|
75
|
+
};
|
|
76
|
+
return ['span', nodeWrapperAttrs, ['span', {
|
|
77
|
+
class: 'zeroWidthSpaceContainer'
|
|
78
|
+
}, ['span', {
|
|
79
|
+
class: 'inlineNodeViewAddZeroWidthSpace'
|
|
80
|
+
}, ZERO_WIDTH_SPACE]], ['span', wrapperAttrs, ['span', attrs, displayString]], ['span', {
|
|
81
|
+
class: 'inlineNodeViewAddZeroWidthSpace'
|
|
82
|
+
}, ZERO_WIDTH_SPACE]];
|
|
47
83
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { getInlineNodeViewProducer } from '@atlaskit/editor-common/react-node-view';
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import { pluginFactory } from '@atlaskit/editor-common/utils';
|
|
4
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
5
|
import { DateNodeView } from '../nodeviews/date';
|
|
6
|
+
import { DateNodeView as DateNodeViewVanilla } from '../nodeviews/DateNodeView';
|
|
5
7
|
import { pluginKey } from './plugin-key';
|
|
6
8
|
import { mapping, onSelectionChanged, reducer } from './utils';
|
|
7
9
|
const {
|
|
@@ -12,6 +14,9 @@ const {
|
|
|
12
14
|
onSelectionChanged
|
|
13
15
|
});
|
|
14
16
|
const createPlugin = pmPluginFactoryParams => {
|
|
17
|
+
const {
|
|
18
|
+
dispatch
|
|
19
|
+
} = pmPluginFactoryParams;
|
|
15
20
|
const newPluginState = {
|
|
16
21
|
showDatePickerAt: null,
|
|
17
22
|
isNew: false,
|
|
@@ -19,14 +24,21 @@ const createPlugin = pmPluginFactoryParams => {
|
|
|
19
24
|
focusDateInput: false
|
|
20
25
|
};
|
|
21
26
|
return new SafePlugin({
|
|
22
|
-
state: createPluginState(
|
|
27
|
+
state: createPluginState(dispatch, newPluginState),
|
|
23
28
|
key: pluginKey,
|
|
24
29
|
props: {
|
|
25
30
|
nodeViews: {
|
|
26
|
-
date:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
date: (node, view, getPos, decorations) => {
|
|
32
|
+
if (editorExperiment('platform_editor_vanilla_dom', true, {
|
|
33
|
+
exposure: true
|
|
34
|
+
})) {
|
|
35
|
+
return new DateNodeViewVanilla(node, view, getPos, pmPluginFactoryParams.getIntl());
|
|
36
|
+
}
|
|
37
|
+
return getInlineNodeViewProducer({
|
|
38
|
+
pmPluginFactoryParams,
|
|
39
|
+
Component: DateNodeView
|
|
40
|
+
})(node, view, getPos, decorations);
|
|
41
|
+
}
|
|
30
42
|
}
|
|
31
43
|
}
|
|
32
44
|
});
|
package/dist/esm/datePlugin.js
CHANGED
|
@@ -9,7 +9,6 @@ import { DateSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
|
9
9
|
import { calculateToolbarPositionAboveSelection } from '@atlaskit/editor-common/utils';
|
|
10
10
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
11
11
|
import CommentIcon from '@atlaskit/icon/core/comment';
|
|
12
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
12
|
import { dateNodeSpec } from './nodeviews/dateNodeSpec';
|
|
14
13
|
import { closeDatePicker as _closeDatePicker, closeDatePickerWithAnalytics as _closeDatePickerWithAnalytics, createDate } from './pm-plugins/actions';
|
|
15
14
|
import { deleteDateCommand, insertDateCommand } from './pm-plugins/commands';
|
|
@@ -101,7 +100,7 @@ function ContentComponent(_ref) {
|
|
|
101
100
|
}
|
|
102
101
|
var datePlugin = function datePlugin(_ref3) {
|
|
103
102
|
var _ref3$config = _ref3.config,
|
|
104
|
-
|
|
103
|
+
config = _ref3$config === void 0 ? {} : _ref3$config,
|
|
105
104
|
api = _ref3.api;
|
|
106
105
|
return {
|
|
107
106
|
name: 'date',
|
|
@@ -136,9 +135,9 @@ var datePlugin = function datePlugin(_ref3) {
|
|
|
136
135
|
pmPlugins: function pmPlugins() {
|
|
137
136
|
return [{
|
|
138
137
|
name: 'date',
|
|
139
|
-
plugin: function plugin(
|
|
138
|
+
plugin: function plugin(pmPluginFactoryParams) {
|
|
140
139
|
DatePicker.preload();
|
|
141
|
-
return createDatePlugin(
|
|
140
|
+
return createDatePlugin(pmPluginFactoryParams);
|
|
142
141
|
}
|
|
143
142
|
}, {
|
|
144
143
|
name: 'dateKeymap',
|
|
@@ -161,7 +160,7 @@ var datePlugin = function datePlugin(_ref3) {
|
|
|
161
160
|
popupsMountPoint: popupsMountPoint,
|
|
162
161
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
163
162
|
popupsScrollableElement: popupsScrollableElement,
|
|
164
|
-
weekStartDay:
|
|
163
|
+
weekStartDay: config.weekStartDay
|
|
165
164
|
});
|
|
166
165
|
},
|
|
167
166
|
pluginsOptions: {
|
|
@@ -198,7 +197,7 @@ var datePlugin = function datePlugin(_ref3) {
|
|
|
198
197
|
var _api$editorViewMode;
|
|
199
198
|
return (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view';
|
|
200
199
|
};
|
|
201
|
-
if (!isViewMode()
|
|
200
|
+
if (!isViewMode()) {
|
|
202
201
|
return undefined;
|
|
203
202
|
}
|
|
204
203
|
var onClick = function onClick(stateFromClickEvent, dispatch) {
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
import { bind } from 'bind-event-listener';
|
|
5
|
+
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
6
|
+
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
7
|
+
import { setDatePickerAt } from '../pm-plugins/actions';
|
|
8
|
+
import { dateToDOM } from './dateNodeSpec';
|
|
9
|
+
export var DateNodeView = /*#__PURE__*/function () {
|
|
10
|
+
function DateNodeView(node, view, getPos, intl) {
|
|
11
|
+
_classCallCheck(this, DateNodeView);
|
|
12
|
+
_defineProperty(this, "dom", document.createElement('span'));
|
|
13
|
+
this.node = node;
|
|
14
|
+
try {
|
|
15
|
+
var spec = dateToDOM(node, view.state, getPos, intl);
|
|
16
|
+
var _DOMSerializer$render = DOMSerializer.renderSpec(document, spec),
|
|
17
|
+
dom = _DOMSerializer$render.dom;
|
|
18
|
+
if (!(dom instanceof HTMLElement)) {
|
|
19
|
+
throw new Error('DOMSerializer.renderSpec() did not return HTMLElement');
|
|
20
|
+
}
|
|
21
|
+
this.dom = dom;
|
|
22
|
+
this.clickUnBind = bind(this.dom, {
|
|
23
|
+
type: 'click',
|
|
24
|
+
listener: function listener(event) {
|
|
25
|
+
event.stopImmediatePropagation();
|
|
26
|
+
var state = view.state,
|
|
27
|
+
dispatch = view.dispatch;
|
|
28
|
+
setDatePickerAt(state.selection.from)(state, dispatch);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
} catch (error) {
|
|
32
|
+
DateNodeView.logError(error instanceof Error ? error : new Error('Unknown error on DateNodeView constructor'));
|
|
33
|
+
this.renderFallback();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return _createClass(DateNodeView, [{
|
|
37
|
+
key: "renderFallback",
|
|
38
|
+
value: function renderFallback() {
|
|
39
|
+
var fallbackElement = document.createElement('span');
|
|
40
|
+
fallbackElement.innerText = this.node.attrs.timestamp;
|
|
41
|
+
this.dom.appendChild(fallbackElement);
|
|
42
|
+
}
|
|
43
|
+
}, {
|
|
44
|
+
key: "destroy",
|
|
45
|
+
value: function destroy() {
|
|
46
|
+
this.clickUnBind && this.clickUnBind();
|
|
47
|
+
}
|
|
48
|
+
}], [{
|
|
49
|
+
key: "logError",
|
|
50
|
+
value: function logError(error) {
|
|
51
|
+
void logException(error, {
|
|
52
|
+
location: 'editor-plugin-date/DateNodeView'
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}]);
|
|
56
|
+
}();
|
|
@@ -5,10 +5,12 @@ import { createIntl } from 'react-intl-next';
|
|
|
5
5
|
import { date } from '@atlaskit/adf-schema';
|
|
6
6
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
7
7
|
import { timestampToString } from '@atlaskit/editor-common/utils';
|
|
8
|
+
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
8
9
|
import { N30A, N800 } from '@atlaskit/theme/colors';
|
|
9
10
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
11
|
+
import { getDateInformation } from './utils';
|
|
10
12
|
var isSSR = Boolean(process.env.REACT_SSR);
|
|
11
|
-
var
|
|
13
|
+
var intlRef;
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Wrapper for ADF date node spec to augment toDOM implementation
|
|
@@ -17,33 +19,66 @@ var intl;
|
|
|
17
19
|
* @returns
|
|
18
20
|
*/
|
|
19
21
|
export var dateNodeSpec = function dateNodeSpec() {
|
|
20
|
-
if (isSSR || editorExperiment('platform_editor_inline_node_virtualization', 'off')) {
|
|
22
|
+
if (!editorExperiment('platform_editor_vanilla_dom', true) && (isSSR || editorExperiment('platform_editor_inline_node_virtualization', 'off'))) {
|
|
21
23
|
return date;
|
|
22
24
|
}
|
|
23
25
|
return _objectSpread(_objectSpread({}, date), {}, {
|
|
24
|
-
toDOM:
|
|
25
|
-
intl = intl || createIntl({
|
|
26
|
-
locale: document.documentElement.lang || 'en-US'
|
|
27
|
-
});
|
|
28
|
-
var timestamp = node.attrs.timestamp;
|
|
29
|
-
var displayString = timestampToString(timestamp, intl);
|
|
30
|
-
var wrapperAttrs = {
|
|
31
|
-
class: 'date-lozenger-container',
|
|
32
|
-
'data-node-type': 'date',
|
|
33
|
-
'data-timestamp': timestamp,
|
|
34
|
-
'aria-busy': 'true'
|
|
35
|
-
};
|
|
36
|
-
var attrs = {
|
|
37
|
-
style: convertToInlineCss({
|
|
38
|
-
// Taken from @atlaskit/date Component
|
|
39
|
-
backgroundColor: "var(--ds-background-neutral, ".concat(N30A, ")"),
|
|
40
|
-
color: "var(--ds-text, ".concat(N800, ")"),
|
|
41
|
-
borderRadius: "var(--ds-border-radius-100, 4px)",
|
|
42
|
-
padding: "var(--ds-space-025, 2px)".concat(" ", "var(--ds-space-050, 4px)"),
|
|
43
|
-
margin: '0 1px'
|
|
44
|
-
})
|
|
45
|
-
};
|
|
46
|
-
return ['span', wrapperAttrs, ['span', attrs, displayString]];
|
|
47
|
-
}
|
|
26
|
+
toDOM: dateToDOMvirtualization
|
|
48
27
|
});
|
|
28
|
+
};
|
|
29
|
+
export var dateToDOMvirtualization = function dateToDOMvirtualization(node) {
|
|
30
|
+
intlRef = intlRef || createIntl({
|
|
31
|
+
locale: document.documentElement.lang || 'en-US'
|
|
32
|
+
});
|
|
33
|
+
var timestamp = node.attrs.timestamp;
|
|
34
|
+
var displayString = timestampToString(timestamp, intlRef);
|
|
35
|
+
var wrapperAttrs = {
|
|
36
|
+
class: 'date-lozenger-container',
|
|
37
|
+
'data-node-type': 'date',
|
|
38
|
+
'data-timestamp': timestamp,
|
|
39
|
+
'aria-busy': 'true'
|
|
40
|
+
};
|
|
41
|
+
var attrs = {
|
|
42
|
+
style: convertToInlineCss({
|
|
43
|
+
// Taken from @atlaskit/date Component
|
|
44
|
+
backgroundColor: "var(--ds-background-neutral, ".concat(N30A, ")"),
|
|
45
|
+
color: "var(--ds-text, ".concat(N800, ")"),
|
|
46
|
+
borderRadius: "var(--ds-border-radius-100, 4px)",
|
|
47
|
+
padding: "var(--ds-space-025, 2px)".concat(" ", "var(--ds-space-050, 4px)"),
|
|
48
|
+
margin: '0 1px'
|
|
49
|
+
})
|
|
50
|
+
};
|
|
51
|
+
return ['span', wrapperAttrs, ['span', attrs, displayString]];
|
|
52
|
+
};
|
|
53
|
+
export var dateToDOM = function dateToDOM(node, state, getPos, intl) {
|
|
54
|
+
var timestamp = node.attrs.timestamp;
|
|
55
|
+
var pos = getPos === null || getPos === void 0 ? void 0 : getPos();
|
|
56
|
+
var _getDateInformation = getDateInformation(timestamp, intl, state, pos),
|
|
57
|
+
displayString = _getDateInformation.displayString,
|
|
58
|
+
color = _getDateInformation.color;
|
|
59
|
+
var nodeWrapperAttrs = {
|
|
60
|
+
contenteditable: 'false',
|
|
61
|
+
timestamp: timestamp,
|
|
62
|
+
class: 'dateView-content-wrap inlineNodeView',
|
|
63
|
+
'data-prosemirror-content-type': 'node',
|
|
64
|
+
'data-prosemirror-node-name': 'date',
|
|
65
|
+
'data-prosemirror-node-inline': 'true',
|
|
66
|
+
'data-prosemirror-node-view-type': 'vanilla',
|
|
67
|
+
draggable: 'true'
|
|
68
|
+
};
|
|
69
|
+
var wrapperAttrs = {
|
|
70
|
+
class: 'date-lozenger-container',
|
|
71
|
+
'data-node-type': 'date',
|
|
72
|
+
'data-timestamp': timestamp
|
|
73
|
+
};
|
|
74
|
+
var attrs = color === undefined ? {} : {
|
|
75
|
+
class: "date-node-color-".concat(color)
|
|
76
|
+
};
|
|
77
|
+
return ['span', nodeWrapperAttrs, ['span', {
|
|
78
|
+
class: 'zeroWidthSpaceContainer'
|
|
79
|
+
}, ['span', {
|
|
80
|
+
class: 'inlineNodeViewAddZeroWidthSpace'
|
|
81
|
+
}, ZERO_WIDTH_SPACE]], ['span', wrapperAttrs, ['span', attrs, displayString]], ['span', {
|
|
82
|
+
class: 'inlineNodeViewAddZeroWidthSpace'
|
|
83
|
+
}, ZERO_WIDTH_SPACE]];
|
|
49
84
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { getInlineNodeViewProducer } from '@atlaskit/editor-common/react-node-view';
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import { pluginFactory } from '@atlaskit/editor-common/utils';
|
|
4
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
5
|
import { DateNodeView } from '../nodeviews/date';
|
|
6
|
+
import { DateNodeView as DateNodeViewVanilla } from '../nodeviews/DateNodeView';
|
|
5
7
|
import { pluginKey } from './plugin-key';
|
|
6
8
|
import { mapping, onSelectionChanged, reducer } from './utils';
|
|
7
9
|
var _pluginFactory = pluginFactory(pluginKey, reducer, {
|
|
@@ -11,6 +13,7 @@ var _pluginFactory = pluginFactory(pluginKey, reducer, {
|
|
|
11
13
|
createPluginState = _pluginFactory.createPluginState,
|
|
12
14
|
getPluginState = _pluginFactory.getPluginState;
|
|
13
15
|
var createPlugin = function createPlugin(pmPluginFactoryParams) {
|
|
16
|
+
var dispatch = pmPluginFactoryParams.dispatch;
|
|
14
17
|
var newPluginState = {
|
|
15
18
|
showDatePickerAt: null,
|
|
16
19
|
isNew: false,
|
|
@@ -18,14 +21,21 @@ var createPlugin = function createPlugin(pmPluginFactoryParams) {
|
|
|
18
21
|
focusDateInput: false
|
|
19
22
|
};
|
|
20
23
|
return new SafePlugin({
|
|
21
|
-
state: createPluginState(
|
|
24
|
+
state: createPluginState(dispatch, newPluginState),
|
|
22
25
|
key: pluginKey,
|
|
23
26
|
props: {
|
|
24
27
|
nodeViews: {
|
|
25
|
-
date:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
date: function date(node, view, getPos, decorations) {
|
|
29
|
+
if (editorExperiment('platform_editor_vanilla_dom', true, {
|
|
30
|
+
exposure: true
|
|
31
|
+
})) {
|
|
32
|
+
return new DateNodeViewVanilla(node, view, getPos, pmPluginFactoryParams.getIntl());
|
|
33
|
+
}
|
|
34
|
+
return getInlineNodeViewProducer({
|
|
35
|
+
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
36
|
+
Component: DateNodeView
|
|
37
|
+
})(node, view, getPos, decorations);
|
|
38
|
+
}
|
|
29
39
|
}
|
|
30
40
|
}
|
|
31
41
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { getPosHandlerNode } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
+
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
+
import type { NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
+
export declare class DateNodeView implements NodeView {
|
|
7
|
+
private readonly node;
|
|
8
|
+
private clickUnBind;
|
|
9
|
+
readonly dom: HTMLElement;
|
|
10
|
+
private static logError;
|
|
11
|
+
constructor(node: PMNode, view: EditorView, getPos: getPosHandlerNode, intl: IntlShape);
|
|
12
|
+
private renderFallback;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
}
|
|
@@ -1,8 +1,23 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import { getPosHandlerNode } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { DOMOutputSpec, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
+
import { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
5
|
/**
|
|
3
6
|
* Wrapper for ADF date node spec to augment toDOM implementation
|
|
4
7
|
* with fallback UI for lazy node view rendering / window virtualization
|
|
5
8
|
* @nodeSpecException:toDOM patch
|
|
6
9
|
* @returns
|
|
7
10
|
*/
|
|
8
|
-
export declare const dateNodeSpec: () => NodeSpec;
|
|
11
|
+
export declare const dateNodeSpec: () => import("prosemirror-model").NodeSpec;
|
|
12
|
+
export declare const dateToDOMvirtualization: (node: PMNode) => DOMOutputSpec;
|
|
13
|
+
export declare const dateToDOM: (node: PMNode, state: EditorState, getPos: getPosHandlerNode, intl: IntlShape) => [string, Record<string, string>, (string | {
|
|
14
|
+
class: string;
|
|
15
|
+
} | (string | {
|
|
16
|
+
class: string;
|
|
17
|
+
})[])[], (string | Record<string, string> | (string | {
|
|
18
|
+
class?: undefined;
|
|
19
|
+
} | {
|
|
20
|
+
class: string;
|
|
21
|
+
})[])[], (string | {
|
|
22
|
+
class: string;
|
|
23
|
+
})[]];
|
|
@@ -32,6 +32,7 @@ export declare const closeDatePickerWithAnalytics: ({ date, pluginInjectionApi,
|
|
|
32
32
|
stripNonExistingAnnotations: (slice: import("prosemirror-model").Slice, state: EditorState) => boolean | undefined;
|
|
33
33
|
setInlineCommentDraftState: (drafting: boolean, inputMethod: import("@atlaskit/editor-plugin-annotation").InlineCommentInputMethod, targetType?: import("@atlaskit/editor-plugin-annotation").TargetType | undefined, targetNodeId?: string | undefined, isOpeningMediaCommentFromToolbar?: boolean | undefined) => Command;
|
|
34
34
|
showCommentForBlockNode: (node: import("prosemirror-model").Node | null, viewMethod?: import("@atlaskit/editor-common/analytics").VIEW_METHOD | undefined, isOpeningMediaCommentFromToolbar?: boolean | undefined) => Command;
|
|
35
|
+
hasAnyUnResolvedAnnotationInPage: (state: EditorState) => boolean;
|
|
35
36
|
};
|
|
36
37
|
}, import("@atlaskit/editor-plugin-annotation").AnnotationProviders | undefined>>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"editorViewMode", {
|
|
37
38
|
sharedState: import("@atlaskit/editor-plugin-editor-viewmode").EditorViewModePluginState | null;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import type { PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { DatePluginState } from './types';
|
|
3
4
|
declare const getPluginState: (state: import("prosemirror-state").EditorState) => DatePluginState;
|
|
4
|
-
declare const createPlugin:
|
|
5
|
+
declare const createPlugin: (pmPluginFactoryParams: PMPluginFactoryParams) => SafePlugin<DatePluginState>;
|
|
5
6
|
export { getPluginState };
|
|
6
7
|
export default createPlugin;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { getPosHandlerNode } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
+
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
+
import type { NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
+
export declare class DateNodeView implements NodeView {
|
|
7
|
+
private readonly node;
|
|
8
|
+
private clickUnBind;
|
|
9
|
+
readonly dom: HTMLElement;
|
|
10
|
+
private static logError;
|
|
11
|
+
constructor(node: PMNode, view: EditorView, getPos: getPosHandlerNode, intl: IntlShape);
|
|
12
|
+
private renderFallback;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
}
|
|
@@ -1,8 +1,29 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import { getPosHandlerNode } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { DOMOutputSpec, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
+
import { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
5
|
/**
|
|
3
6
|
* Wrapper for ADF date node spec to augment toDOM implementation
|
|
4
7
|
* with fallback UI for lazy node view rendering / window virtualization
|
|
5
8
|
* @nodeSpecException:toDOM patch
|
|
6
9
|
* @returns
|
|
7
10
|
*/
|
|
8
|
-
export declare const dateNodeSpec: () => NodeSpec;
|
|
11
|
+
export declare const dateNodeSpec: () => import("prosemirror-model").NodeSpec;
|
|
12
|
+
export declare const dateToDOMvirtualization: (node: PMNode) => DOMOutputSpec;
|
|
13
|
+
export declare const dateToDOM: (node: PMNode, state: EditorState, getPos: getPosHandlerNode, intl: IntlShape) => [
|
|
14
|
+
string,
|
|
15
|
+
Record<string, string>,
|
|
16
|
+
(string | {
|
|
17
|
+
class: string;
|
|
18
|
+
} | (string | {
|
|
19
|
+
class: string;
|
|
20
|
+
})[])[],
|
|
21
|
+
(string | Record<string, string> | (string | {
|
|
22
|
+
class?: undefined;
|
|
23
|
+
} | {
|
|
24
|
+
class: string;
|
|
25
|
+
})[])[],
|
|
26
|
+
(string | {
|
|
27
|
+
class: string;
|
|
28
|
+
})[]
|
|
29
|
+
];
|
|
@@ -37,6 +37,7 @@ export declare const closeDatePickerWithAnalytics: ({ date, pluginInjectionApi,
|
|
|
37
37
|
stripNonExistingAnnotations: (slice: import("prosemirror-model").Slice, state: EditorState) => boolean | undefined;
|
|
38
38
|
setInlineCommentDraftState: (drafting: boolean, inputMethod: import("@atlaskit/editor-plugin-annotation").InlineCommentInputMethod, targetType?: import("@atlaskit/editor-plugin-annotation").TargetType | undefined, targetNodeId?: string | undefined, isOpeningMediaCommentFromToolbar?: boolean | undefined) => Command;
|
|
39
39
|
showCommentForBlockNode: (node: import("prosemirror-model").Node | null, viewMethod?: import("@atlaskit/editor-common/analytics").VIEW_METHOD | undefined, isOpeningMediaCommentFromToolbar?: boolean | undefined) => Command;
|
|
40
|
+
hasAnyUnResolvedAnnotationInPage: (state: EditorState) => boolean;
|
|
40
41
|
};
|
|
41
42
|
}, import("@atlaskit/editor-plugin-annotation").AnnotationProviders | undefined>>,
|
|
42
43
|
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"editorViewMode", {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import type { PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { DatePluginState } from './types';
|
|
3
4
|
declare const getPluginState: (state: import("prosemirror-state").EditorState) => DatePluginState;
|
|
4
|
-
declare const createPlugin:
|
|
5
|
+
declare const createPlugin: (pmPluginFactoryParams: PMPluginFactoryParams) => SafePlugin<DatePluginState>;
|
|
5
6
|
export { getPluginState };
|
|
6
7
|
export default createPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-date",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.8",
|
|
4
4
|
"description": "Date plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -37,22 +37,23 @@
|
|
|
37
37
|
"@atlaskit/calendar": "^17.1.0",
|
|
38
38
|
"@atlaskit/css": "^0.10.0",
|
|
39
39
|
"@atlaskit/date": "^2.0.0",
|
|
40
|
-
"@atlaskit/editor-common": "^102.
|
|
40
|
+
"@atlaskit/editor-common": "^102.19.0",
|
|
41
41
|
"@atlaskit/editor-plugin-analytics": "^2.2.0",
|
|
42
|
-
"@atlaskit/editor-plugin-annotation": "^2.
|
|
42
|
+
"@atlaskit/editor-plugin-annotation": "^2.2.0",
|
|
43
43
|
"@atlaskit/editor-plugin-editor-disabled": "^2.0.0",
|
|
44
44
|
"@atlaskit/editor-plugin-editor-viewmode": "^3.0.0",
|
|
45
45
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
46
46
|
"@atlaskit/editor-shared-styles": "^3.4.0",
|
|
47
47
|
"@atlaskit/form": "^12.0.0",
|
|
48
|
-
"@atlaskit/icon": "^25.
|
|
48
|
+
"@atlaskit/icon": "^25.5.0",
|
|
49
49
|
"@atlaskit/locale": "^3.0.0",
|
|
50
50
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
51
51
|
"@atlaskit/textfield": "^8.0.0",
|
|
52
52
|
"@atlaskit/theme": "^18.0.0",
|
|
53
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
54
|
-
"@atlaskit/tokens": "^4.
|
|
53
|
+
"@atlaskit/tmp-editor-statsig": "^4.6.0",
|
|
54
|
+
"@atlaskit/tokens": "^4.6.0",
|
|
55
55
|
"@babel/runtime": "^7.0.0",
|
|
56
|
+
"bind-event-listener": "^3.0.0",
|
|
56
57
|
"date-fns": "^2.17.0",
|
|
57
58
|
"react-intl-next": "npm:react-intl@^5.18.1",
|
|
58
59
|
"react-loadable": "^5.1.0"
|
|
@@ -63,11 +64,11 @@
|
|
|
63
64
|
"@atlaskit/editor-plugin-decorations": "^2.0.0",
|
|
64
65
|
"@atlaskit/editor-plugin-feature-flags": "^1.3.0",
|
|
65
66
|
"@atlaskit/editor-plugin-guideline": "^2.0.0",
|
|
66
|
-
"@atlaskit/editor-plugin-quick-insert": "^2.
|
|
67
|
+
"@atlaskit/editor-plugin-quick-insert": "^2.2.0",
|
|
67
68
|
"@atlaskit/editor-plugin-selection": "^2.1.0",
|
|
68
|
-
"@atlaskit/editor-plugin-table": "^10.
|
|
69
|
+
"@atlaskit/editor-plugin-table": "^10.6.0",
|
|
69
70
|
"@atlaskit/editor-plugin-tasks-and-decisions": "^5.0.0",
|
|
70
|
-
"@atlaskit/editor-plugin-type-ahead": "^2.
|
|
71
|
+
"@atlaskit/editor-plugin-type-ahead": "^2.3.0",
|
|
71
72
|
"@atlaskit/editor-plugin-width": "^3.0.0",
|
|
72
73
|
"@testing-library/react": "^13.4.0"
|
|
73
74
|
},
|
|
@@ -113,9 +114,6 @@
|
|
|
113
114
|
"platform-feature-flags": {
|
|
114
115
|
"editor_inline_comments_paste_insert_nodes": {
|
|
115
116
|
"type": "boolean"
|
|
116
|
-
},
|
|
117
|
-
"platform_inline_node_as_valid_annotation_selection": {
|
|
118
|
-
"type": "boolean"
|
|
119
117
|
}
|
|
120
118
|
}
|
|
121
119
|
}
|