@atlaskit/editor-core 187.4.11 → 187.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/editor-next/index.js +93 -115
- package/dist/cjs/editor.js +8 -2
- package/dist/cjs/ui/CollapsedEditor/index.js +7 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/editor-next/index.js +91 -77
- package/dist/es2019/editor.js +8 -2
- package/dist/es2019/ui/CollapsedEditor/index.js +7 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/editor-next/index.js +92 -115
- package/dist/esm/editor.js +8 -2
- package/dist/esm/ui/CollapsedEditor/index.js +7 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/editor-next/editor-internal.d.ts +9 -9
- package/dist/types/editor-next/index.d.ts +8 -32
- package/dist/types/editor.d.ts +1 -1
- package/dist/types/types/editor-props.d.ts +32 -32
- package/dist/types/ui/CollapsedEditor/index.d.ts +3 -3
- package/dist/types-ts4.5/editor-next/editor-internal.d.ts +9 -9
- package/dist/types-ts4.5/editor-next/index.d.ts +8 -32
- package/dist/types-ts4.5/editor.d.ts +1 -1
- package/dist/types-ts4.5/types/editor-props.d.ts +32 -32
- package/dist/types-ts4.5/ui/CollapsedEditor/index.d.ts +3 -3
- package/package.json +3 -3
- package/report.api.md +12 -41
- package/tmp/api-report-tmp.d.ts +12 -38
- package/dist/cjs/editor-next/utils/editorPropTypes.js +0 -36
- package/dist/cjs/editor-next/utils/onEditorCreated.js +0 -28
- package/dist/es2019/editor-next/utils/editorPropTypes.js +0 -29
- package/dist/es2019/editor-next/utils/onEditorCreated.js +0 -21
- package/dist/esm/editor-next/utils/editorPropTypes.js +0 -28
- package/dist/esm/editor-next/utils/onEditorCreated.js +0 -21
- package/dist/types/editor-next/utils/editorPropTypes.d.ts +0 -19
- package/dist/types/editor-next/utils/onEditorCreated.d.ts +0 -12
- package/dist/types-ts4.5/editor-next/utils/editorPropTypes.d.ts +0 -19
- package/dist/types-ts4.5/editor-next/utils/onEditorCreated.d.ts +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 187.5.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`01237de37e7`](https://bitbucket.org/atlassian/atlassian-frontend/commits/01237de37e7) - [ED-17901] Update clear button on input to have tabindex and update tests to test for both chrome / firefox and safari
|
|
8
|
+
|
|
9
|
+
## 187.5.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`164ab991f40`](https://bitbucket.org/atlassian/atlassian-frontend/commits/164ab991f40) - Updating the composable editor (@atlaskit/editor-core/composable-editor) to a functional component.
|
|
14
|
+
|
|
3
15
|
## 187.4.11
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -4,142 +4,120 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
8
|
-
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
11
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
12
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
7
|
+
exports.Editor = Editor;
|
|
8
|
+
exports.default = EditorNext;
|
|
14
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
var _react =
|
|
10
|
+
var _react = require("react");
|
|
16
11
|
var _react2 = require("@emotion/react");
|
|
17
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
18
12
|
var _v = _interopRequireDefault(require("uuid/v4"));
|
|
19
13
|
var _analyticsNamespacedContext = require("@atlaskit/analytics-namespaced-context");
|
|
20
14
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
21
|
-
var
|
|
15
|
+
var _ufo = require("@atlaskit/editor-common/ufo");
|
|
22
16
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
17
|
+
var _plugins = require("../plugins");
|
|
23
18
|
var _actions = _interopRequireDefault(require("../actions"));
|
|
24
19
|
var _featureFlagsFromProps = require("../create-editor/feature-flags-from-props");
|
|
25
|
-
var _plugins = require("../plugins");
|
|
26
20
|
var _versionWrapper = require("../version-wrapper");
|
|
21
|
+
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
22
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
23
|
+
var _EditorContext = require("../ui/EditorContext");
|
|
24
|
+
var _measureEnum = _interopRequireDefault(require("../utils/performance/measure-enum"));
|
|
27
25
|
var _editorInternal = _interopRequireDefault(require("./editor-internal"));
|
|
28
26
|
var _deprecationWarnings = _interopRequireDefault(require("./utils/deprecationWarnings"));
|
|
29
|
-
var
|
|
30
|
-
var _onEditorCreated2 = _interopRequireDefault(require("./utils/onEditorCreated"));
|
|
27
|
+
var _sendDurationAnalytics = _interopRequireDefault(require("./utils/sendDurationAnalytics"));
|
|
31
28
|
var _trackEditorActions = _interopRequireDefault(require("./utils/trackEditorActions"));
|
|
32
29
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
33
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
});
|
|
53
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getExperienceStore", function () {
|
|
54
|
-
return _this.experienceStore;
|
|
55
|
-
});
|
|
30
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } /** @jsx jsx */
|
|
31
|
+
function Editor(passedProps) {
|
|
32
|
+
var _editorContext$editor;
|
|
33
|
+
var defaultProps = {
|
|
34
|
+
appearance: 'comment',
|
|
35
|
+
disabled: false,
|
|
36
|
+
quickInsert: true
|
|
37
|
+
};
|
|
38
|
+
var props = _objectSpread(_objectSpread({}, defaultProps), passedProps);
|
|
39
|
+
var editorContext = (0, _EditorContext.useEditorContext)();
|
|
40
|
+
var editorActions = (0, _react.useRef)((_editorContext$editor = editorContext === null || editorContext === void 0 ? void 0 : editorContext.editorActions) !== null && _editorContext$editor !== void 0 ? _editorContext$editor : new _actions.default());
|
|
41
|
+
var startTime = (0, _react.useRef)(performance.now());
|
|
42
|
+
var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
43
|
+
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
44
|
+
var experienceStore = (0, _react.useRef)();
|
|
45
|
+
var handleAnalyticsEvent = function handleAnalyticsEvent(data) {
|
|
46
|
+
return (0, _analytics.fireAnalyticsEvent)(createAnalyticsEvent)(data);
|
|
47
|
+
};
|
|
48
|
+
(0, _hooks.useConstructor)(function () {
|
|
56
49
|
(0, _deprecationWarnings.default)(props);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
_this.startTime = performance.now();
|
|
60
|
-
_this.onEditorCreated = _this.onEditorCreated.bind((0, _assertThisInitialized2.default)(_this));
|
|
61
|
-
_this.onEditorDestroyed = _this.onEditorDestroyed.bind((0, _assertThisInitialized2.default)(_this));
|
|
62
|
-
_this.getExperienceStore = _this.getExperienceStore.bind((0, _assertThisInitialized2.default)(_this));
|
|
63
|
-
(0, _trackEditorActions.default)(_this.editorActions, props.performanceTracking, function (value) {
|
|
64
|
-
return _this.handleAnalyticsEvent(value);
|
|
50
|
+
(0, _trackEditorActions.default)(editorActions.current, props.performanceTracking, function (value) {
|
|
51
|
+
return handleAnalyticsEvent(value);
|
|
65
52
|
});
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
}, {
|
|
81
|
-
key: "onEditorDestroyed",
|
|
82
|
-
value: function onEditorDestroyed(_instance) {
|
|
83
|
-
var _this$props$onDestroy, _this$props2;
|
|
84
|
-
this.unregisterEditorFromActions();
|
|
85
|
-
(_this$props$onDestroy = (_this$props2 = this.props).onDestroy) === null || _this$props$onDestroy === void 0 ? void 0 : _this$props$onDestroy.call(_this$props2);
|
|
53
|
+
});
|
|
54
|
+
var getExperienceStore = function getExperienceStore() {
|
|
55
|
+
return experienceStore.current;
|
|
56
|
+
};
|
|
57
|
+
var onEditorCreated = function onEditorCreated(instance) {
|
|
58
|
+
var _props$featureFlags;
|
|
59
|
+
editorActions.current._privateRegisterEditor(instance.view, instance.eventDispatcher, instance.transformer, function () {
|
|
60
|
+
return (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(props);
|
|
61
|
+
});
|
|
62
|
+
if ((_props$featureFlags = props.featureFlags) !== null && _props$featureFlags !== void 0 && _props$featureFlags.ufo) {
|
|
63
|
+
var _experienceStore$curr;
|
|
64
|
+
experienceStore.current = _ufo.ExperienceStore.getInstance(instance.view);
|
|
65
|
+
(_experienceStore$curr = experienceStore.current) === null || _experienceStore$curr === void 0 ? void 0 : _experienceStore$curr.start(_ufo.EditorExperience.loadEditor, startTime.current);
|
|
86
66
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
67
|
+
if (props.onEditorReady) {
|
|
68
|
+
var _props$performanceTra, _props$performanceTra2, _props$featureFlags2;
|
|
69
|
+
var measureEditorReady = (props === null || props === void 0 ? void 0 : (_props$performanceTra = props.performanceTracking) === null || _props$performanceTra === void 0 ? void 0 : (_props$performanceTra2 = _props$performanceTra.onEditorReadyCallbackTracking) === null || _props$performanceTra2 === void 0 ? void 0 : _props$performanceTra2.enabled) || ((_props$featureFlags2 = props.featureFlags) === null || _props$featureFlags2 === void 0 ? void 0 : _props$featureFlags2.ufo);
|
|
70
|
+
measureEditorReady && (0, _utils.startMeasure)(_measureEnum.default.ON_EDITOR_READY_CALLBACK);
|
|
71
|
+
props.onEditorReady(editorActions.current);
|
|
72
|
+
measureEditorReady && (0, _utils.stopMeasure)(_measureEnum.default.ON_EDITOR_READY_CALLBACK, (0, _sendDurationAnalytics.default)(_analytics.ACTION.ON_EDITOR_READY_CALLBACK, props, getExperienceStore, createAnalyticsEvent));
|
|
91
73
|
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
74
|
+
};
|
|
75
|
+
var onEditorDestroyed = function onEditorDestroyed(_instance) {
|
|
76
|
+
var _props$onDestroy;
|
|
77
|
+
editorActions.current._privateUnregisterEditor();
|
|
78
|
+
(_props$onDestroy = props.onDestroy) === null || _props$onDestroy === void 0 ? void 0 : _props$onDestroy.call(props);
|
|
79
|
+
};
|
|
80
|
+
return (0, _react2.jsx)(_editorInternal.default, {
|
|
81
|
+
props: props,
|
|
82
|
+
handleAnalyticsEvent: handleAnalyticsEvent,
|
|
83
|
+
createAnalyticsEvent: createAnalyticsEvent,
|
|
84
|
+
preset: props.preset,
|
|
85
|
+
handleSave: function handleSave(view) {
|
|
86
|
+
var _props$onSave;
|
|
87
|
+
return (_props$onSave = props.onSave) === null || _props$onSave === void 0 ? void 0 : _props$onSave.call(props, view);
|
|
88
|
+
},
|
|
89
|
+
editorActions: editorActions.current,
|
|
90
|
+
getExperienceStore: getExperienceStore,
|
|
91
|
+
onEditorCreated: onEditorCreated,
|
|
92
|
+
onEditorDestroyed: onEditorDestroyed
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function EditorNext(props) {
|
|
96
|
+
var editorSessionId = (0, _react.useRef)((0, _v.default)());
|
|
97
|
+
return (0, _react2.jsx)(_analyticsNamespacedContext.FabricEditorAnalyticsContext, {
|
|
98
|
+
data: {
|
|
99
|
+
packageName: _versionWrapper.name,
|
|
100
|
+
packageVersion: _versionWrapper.version,
|
|
101
|
+
componentName: 'editorCore',
|
|
102
|
+
appearance: (0, _utils.getAnalyticsAppearance)(props.appearance),
|
|
103
|
+
editorSessionId: editorSessionId.current
|
|
96
104
|
}
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
componentName: 'editorCore',
|
|
106
|
-
appearance: (0, _utils.getAnalyticsAppearance)(this.props.appearance),
|
|
107
|
-
editorSessionId: this.editorSessionId
|
|
108
|
-
}
|
|
109
|
-
}, (0, _react2.jsx)(_ui.WithCreateAnalyticsEvent, {
|
|
110
|
-
render: function render(createAnalyticsEvent) {
|
|
111
|
-
return (_this3.createAnalyticsEvent = createAnalyticsEvent) && (0, _react2.jsx)(_editorInternal.default, {
|
|
112
|
-
props: _this3.props,
|
|
113
|
-
handleAnalyticsEvent: _this3.handleAnalyticsEvent,
|
|
114
|
-
createAnalyticsEvent: _this3.createAnalyticsEvent,
|
|
115
|
-
preset: _this3.props.preset,
|
|
116
|
-
handleSave: _this3.handleSave,
|
|
117
|
-
editorActions: _this3.editorActions,
|
|
118
|
-
getExperienceStore: _this3.getExperienceStore,
|
|
119
|
-
onEditorCreated: _this3.onEditorCreated,
|
|
120
|
-
onEditorDestroyed: _this3.onEditorDestroyed
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
}));
|
|
105
|
+
}, (0, _react2.jsx)(Editor, props));
|
|
106
|
+
}
|
|
107
|
+
EditorNext.propTypes = {
|
|
108
|
+
minHeight: function minHeight(_ref) {
|
|
109
|
+
var appearance = _ref.appearance,
|
|
110
|
+
_minHeight = _ref.minHeight;
|
|
111
|
+
if (_minHeight && appearance && !['comment', 'chromeless'].includes(appearance)) {
|
|
112
|
+
return new Error('minHeight only supports editor appearance chromeless and comment for Editor');
|
|
124
113
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
(0, _defineProperty2.default)(EditorNext, "defaultProps", {
|
|
130
|
-
appearance: 'comment',
|
|
131
|
-
disabled: false,
|
|
132
|
-
quickInsert: true
|
|
133
|
-
});
|
|
134
|
-
(0, _defineProperty2.default)(EditorNext, "contextTypes", {
|
|
135
|
-
editorActions: _propTypes.default.object
|
|
136
|
-
});
|
|
137
|
-
(0, _defineProperty2.default)(EditorNext, "propTypes", _objectSpread(_objectSpread({}, (0, _editorPropTypes.propTypes)('minHeight only supports editor appearance chromeless and comment for EditorNext')), {}, {
|
|
138
|
-
preset: function preset(_ref) {
|
|
139
|
-
var _preset = _ref.preset;
|
|
114
|
+
return null;
|
|
115
|
+
},
|
|
116
|
+
preset: function preset(_ref2) {
|
|
117
|
+
var _preset = _ref2.preset;
|
|
140
118
|
if (!_preset.has(_plugins.basePlugin)) {
|
|
141
119
|
return new Error('Presets must contain the base plugin');
|
|
142
120
|
}
|
|
143
121
|
return null;
|
|
144
122
|
}
|
|
145
|
-
}
|
|
123
|
+
};
|
package/dist/cjs/editor.js
CHANGED
|
@@ -14,7 +14,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
14
14
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
15
15
|
var _react = _interopRequireDefault(require("react"));
|
|
16
16
|
var _react2 = require("@emotion/react");
|
|
17
|
-
var _editorPropTypes = require("./editor-next/utils/editorPropTypes");
|
|
18
17
|
var _editorNext = _interopRequireDefault(require("./editor-next"));
|
|
19
18
|
var _useUniversalPreset = _interopRequireDefault(require("./labs/next/presets/useUniversalPreset"));
|
|
20
19
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
@@ -46,4 +45,11 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
46
45
|
return Editor;
|
|
47
46
|
}(_react.default.Component);
|
|
48
47
|
exports.default = Editor;
|
|
49
|
-
(0, _defineProperty2.default)(Editor, "defaultProps",
|
|
48
|
+
(0, _defineProperty2.default)(Editor, "defaultProps", {
|
|
49
|
+
appearance: 'comment',
|
|
50
|
+
disabled: false,
|
|
51
|
+
extensionHandlers: {},
|
|
52
|
+
allowHelpDialog: true,
|
|
53
|
+
allowNewInsertionBehaviour: true,
|
|
54
|
+
quickInsert: true
|
|
55
|
+
});
|
|
@@ -41,7 +41,7 @@ var CollapsedEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
41
41
|
(0, _createClass2.default)(CollapsedEditor, [{
|
|
42
42
|
key: "componentDidUpdate",
|
|
43
43
|
value: function componentDidUpdate() {
|
|
44
|
-
if (this.props.isExpanded && this.editorComponent && (!this.previouslyExpanded || this.previouslyExpanded === undefined)) {
|
|
44
|
+
if (this.props.isExpanded && (this.editorComponent || this.functionalEditor) && (!this.previouslyExpanded || this.previouslyExpanded === undefined)) {
|
|
45
45
|
var _this$props$onExpand, _this$props;
|
|
46
46
|
(_this$props$onExpand = (_this$props = this.props).onExpand) === null || _this$props$onExpand === void 0 ? void 0 : _this$props$onExpand.call(_this$props);
|
|
47
47
|
}
|
|
@@ -55,12 +55,18 @@ var CollapsedEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
55
55
|
if (child.type !== _editor.default && child.type !== _EditorWithActions.default && child.type !== _editorNext.default) {
|
|
56
56
|
throw new Error('Expected child to be of type `Editor`');
|
|
57
57
|
}
|
|
58
|
+
this.functionalEditor = child.type === _editorNext.default;
|
|
58
59
|
if (!this.props.isExpanded) {
|
|
59
60
|
return /*#__PURE__*/_react.default.createElement(_ui.IntlProviderIfMissingWrapper, null, /*#__PURE__*/_react.default.createElement(_ChromeCollapsed.default, {
|
|
60
61
|
onFocus: this.props.onFocus,
|
|
61
62
|
text: this.props.placeholder
|
|
62
63
|
}));
|
|
63
64
|
}
|
|
65
|
+
|
|
66
|
+
// Let's avoid ref logic for functional Editor
|
|
67
|
+
if (this.functionalEditor) {
|
|
68
|
+
return child;
|
|
69
|
+
}
|
|
64
70
|
return /*#__PURE__*/_react.default.cloneElement(child, {
|
|
65
71
|
ref: function ref(editorComponent) {
|
|
66
72
|
return _this2.handleEditorRef(editorComponent, child.ref);
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = "@atlaskit/editor-core";
|
|
8
8
|
exports.name = name;
|
|
9
|
-
var version = "187.
|
|
9
|
+
var version = "187.5.5";
|
|
10
10
|
exports.version = version;
|
|
11
11
|
var nextMajorVersion = function nextMajorVersion() {
|
|
12
12
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,91 +1,105 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
1
|
/** @jsx jsx */
|
|
3
|
-
import
|
|
2
|
+
import { useRef } from 'react';
|
|
4
3
|
import { jsx } from '@emotion/react';
|
|
5
|
-
import PropTypes from 'prop-types';
|
|
6
4
|
import uuid from 'uuid/v4';
|
|
7
5
|
import { FabricEditorAnalyticsContext } from '@atlaskit/analytics-namespaced-context';
|
|
8
|
-
import { fireAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
9
|
-
import {
|
|
10
|
-
import { getAnalyticsAppearance } from '@atlaskit/editor-common/utils';
|
|
6
|
+
import { ACTION, fireAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
7
|
+
import { EditorExperience, ExperienceStore } from '@atlaskit/editor-common/ufo';
|
|
8
|
+
import { getAnalyticsAppearance, startMeasure, stopMeasure } from '@atlaskit/editor-common/utils';
|
|
9
|
+
import { basePlugin } from '../plugins';
|
|
11
10
|
import EditorActions from '../actions';
|
|
12
11
|
import { createFeatureFlagsFromProps } from '../create-editor/feature-flags-from-props';
|
|
13
|
-
import { basePlugin } from '../plugins';
|
|
14
12
|
import { name, version } from '../version-wrapper';
|
|
13
|
+
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
14
|
+
import { useConstructor } from '@atlaskit/editor-common/hooks';
|
|
15
|
+
import { useEditorContext } from '../ui/EditorContext';
|
|
16
|
+
import measurements from '../utils/performance/measure-enum';
|
|
15
17
|
import EditorInternal from './editor-internal';
|
|
16
18
|
import deprecationWarnings from './utils/deprecationWarnings';
|
|
17
|
-
import
|
|
18
|
-
import onEditorCreated from './utils/onEditorCreated';
|
|
19
|
+
import sendDurationAnalytics from './utils/sendDurationAnalytics';
|
|
19
20
|
import trackEditorActions from './utils/trackEditorActions';
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
export function Editor(passedProps) {
|
|
22
|
+
var _editorContext$editor;
|
|
23
|
+
const defaultProps = {
|
|
24
|
+
appearance: 'comment',
|
|
25
|
+
disabled: false,
|
|
26
|
+
quickInsert: true
|
|
27
|
+
};
|
|
28
|
+
const props = {
|
|
29
|
+
...defaultProps,
|
|
30
|
+
...passedProps
|
|
31
|
+
};
|
|
32
|
+
const editorContext = useEditorContext();
|
|
33
|
+
const editorActions = useRef((_editorContext$editor = editorContext === null || editorContext === void 0 ? void 0 : editorContext.editorActions) !== null && _editorContext$editor !== void 0 ? _editorContext$editor : new EditorActions());
|
|
34
|
+
const startTime = useRef(performance.now());
|
|
35
|
+
const {
|
|
36
|
+
createAnalyticsEvent
|
|
37
|
+
} = useAnalyticsEvents();
|
|
38
|
+
const experienceStore = useRef();
|
|
39
|
+
const handleAnalyticsEvent = data => fireAnalyticsEvent(createAnalyticsEvent)(data);
|
|
40
|
+
useConstructor(() => {
|
|
32
41
|
deprecationWarnings(props);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
42
|
+
trackEditorActions(editorActions.current, props.performanceTracking, value => handleAnalyticsEvent(value));
|
|
43
|
+
});
|
|
44
|
+
const getExperienceStore = () => experienceStore.current;
|
|
45
|
+
const onEditorCreated = instance => {
|
|
46
|
+
var _props$featureFlags;
|
|
47
|
+
editorActions.current._privateRegisterEditor(instance.view, instance.eventDispatcher, instance.transformer, () => createFeatureFlagsFromProps(props));
|
|
48
|
+
if ((_props$featureFlags = props.featureFlags) !== null && _props$featureFlags !== void 0 && _props$featureFlags.ufo) {
|
|
49
|
+
var _experienceStore$curr;
|
|
50
|
+
experienceStore.current = ExperienceStore.getInstance(instance.view);
|
|
51
|
+
(_experienceStore$curr = experienceStore.current) === null || _experienceStore$curr === void 0 ? void 0 : _experienceStore$curr.start(EditorExperience.loadEditor, startTime.current);
|
|
52
|
+
}
|
|
53
|
+
if (props.onEditorReady) {
|
|
54
|
+
var _props$performanceTra, _props$performanceTra2, _props$featureFlags2;
|
|
55
|
+
const measureEditorReady = (props === null || props === void 0 ? void 0 : (_props$performanceTra = props.performanceTracking) === null || _props$performanceTra === void 0 ? void 0 : (_props$performanceTra2 = _props$performanceTra.onEditorReadyCallbackTracking) === null || _props$performanceTra2 === void 0 ? void 0 : _props$performanceTra2.enabled) || ((_props$featureFlags2 = props.featureFlags) === null || _props$featureFlags2 === void 0 ? void 0 : _props$featureFlags2.ufo);
|
|
56
|
+
measureEditorReady && startMeasure(measurements.ON_EDITOR_READY_CALLBACK);
|
|
57
|
+
props.onEditorReady(editorActions.current);
|
|
58
|
+
measureEditorReady && stopMeasure(measurements.ON_EDITOR_READY_CALLBACK, sendDurationAnalytics(ACTION.ON_EDITOR_READY_CALLBACK, props, getExperienceStore, createAnalyticsEvent));
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const onEditorDestroyed = _instance => {
|
|
62
|
+
var _props$onDestroy;
|
|
63
|
+
editorActions.current._privateUnregisterEditor();
|
|
64
|
+
(_props$onDestroy = props.onDestroy) === null || _props$onDestroy === void 0 ? void 0 : _props$onDestroy.call(props);
|
|
65
|
+
};
|
|
66
|
+
return jsx(EditorInternal, {
|
|
67
|
+
props: props,
|
|
68
|
+
handleAnalyticsEvent: handleAnalyticsEvent,
|
|
69
|
+
createAnalyticsEvent: createAnalyticsEvent,
|
|
70
|
+
preset: props.preset,
|
|
71
|
+
handleSave: view => {
|
|
72
|
+
var _props$onSave;
|
|
73
|
+
return (_props$onSave = props.onSave) === null || _props$onSave === void 0 ? void 0 : _props$onSave.call(props, view);
|
|
74
|
+
},
|
|
75
|
+
editorActions: editorActions.current,
|
|
76
|
+
getExperienceStore: getExperienceStore,
|
|
77
|
+
onEditorCreated: onEditorCreated,
|
|
78
|
+
onEditorDestroyed: onEditorDestroyed
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
export default function EditorNext(props) {
|
|
82
|
+
const editorSessionId = useRef(uuid());
|
|
83
|
+
return jsx(FabricEditorAnalyticsContext, {
|
|
84
|
+
data: {
|
|
85
|
+
packageName: name,
|
|
86
|
+
packageVersion: version,
|
|
87
|
+
componentName: 'editorCore',
|
|
88
|
+
appearance: getAnalyticsAppearance(props.appearance),
|
|
89
|
+
editorSessionId: editorSessionId.current
|
|
90
|
+
}
|
|
91
|
+
}, jsx(Editor, props));
|
|
78
92
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
93
|
+
EditorNext.propTypes = {
|
|
94
|
+
minHeight: ({
|
|
95
|
+
appearance,
|
|
96
|
+
minHeight
|
|
97
|
+
}) => {
|
|
98
|
+
if (minHeight && appearance && !['comment', 'chromeless'].includes(appearance)) {
|
|
99
|
+
return new Error('minHeight only supports editor appearance chromeless and comment for Editor');
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
},
|
|
89
103
|
preset: ({
|
|
90
104
|
preset
|
|
91
105
|
}) => {
|
|
@@ -94,4 +108,4 @@ _defineProperty(EditorNext, "propTypes", {
|
|
|
94
108
|
}
|
|
95
109
|
return null;
|
|
96
110
|
}
|
|
97
|
-
}
|
|
111
|
+
};
|
package/dist/es2019/editor.js
CHANGED
|
@@ -3,7 +3,6 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { jsx } from '@emotion/react';
|
|
6
|
-
import { defaultProps } from './editor-next/utils/editorPropTypes';
|
|
7
6
|
import EditorNext from './editor-next';
|
|
8
7
|
import useUniversalPreset from './labs/next/presets/useUniversalPreset';
|
|
9
8
|
const EditorNextWrapper = ({
|
|
@@ -23,4 +22,11 @@ export default class Editor extends React.Component {
|
|
|
23
22
|
});
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
|
-
_defineProperty(Editor, "defaultProps",
|
|
25
|
+
_defineProperty(Editor, "defaultProps", {
|
|
26
|
+
appearance: 'comment',
|
|
27
|
+
disabled: false,
|
|
28
|
+
extensionHandlers: {},
|
|
29
|
+
allowHelpDialog: true,
|
|
30
|
+
allowNewInsertionBehaviour: true,
|
|
31
|
+
quickInsert: true
|
|
32
|
+
});
|
|
@@ -16,7 +16,7 @@ export default class CollapsedEditor extends React.Component {
|
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
componentDidUpdate() {
|
|
19
|
-
if (this.props.isExpanded && this.editorComponent && (!this.previouslyExpanded || this.previouslyExpanded === undefined)) {
|
|
19
|
+
if (this.props.isExpanded && (this.editorComponent || this.functionalEditor) && (!this.previouslyExpanded || this.previouslyExpanded === undefined)) {
|
|
20
20
|
var _this$props$onExpand, _this$props;
|
|
21
21
|
(_this$props$onExpand = (_this$props = this.props).onExpand) === null || _this$props$onExpand === void 0 ? void 0 : _this$props$onExpand.call(_this$props);
|
|
22
22
|
}
|
|
@@ -27,12 +27,18 @@ export default class CollapsedEditor extends React.Component {
|
|
|
27
27
|
if (child.type !== Editor && child.type !== EditorWithActions && child.type !== EditorNext) {
|
|
28
28
|
throw new Error('Expected child to be of type `Editor`');
|
|
29
29
|
}
|
|
30
|
+
this.functionalEditor = child.type === EditorNext;
|
|
30
31
|
if (!this.props.isExpanded) {
|
|
31
32
|
return /*#__PURE__*/React.createElement(IntlProviderIfMissingWrapper, null, /*#__PURE__*/React.createElement(ChromeCollapsed, {
|
|
32
33
|
onFocus: this.props.onFocus,
|
|
33
34
|
text: this.props.placeholder
|
|
34
35
|
}));
|
|
35
36
|
}
|
|
37
|
+
|
|
38
|
+
// Let's avoid ref logic for functional Editor
|
|
39
|
+
if (this.functionalEditor) {
|
|
40
|
+
return child;
|
|
41
|
+
}
|
|
36
42
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
37
43
|
ref: editorComponent => this.handleEditorRef(editorComponent, child.ref)
|
|
38
44
|
});
|
package/dist/es2019/version.json
CHANGED