@atlaskit/editor-core
Version:
A package contains Atlassian editor core functionality
60 lines (59 loc) • 3.01 kB
JavaScript
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/inherits";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
import React from 'react';
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
import { createDispatch } from '@atlaskit/editor-common/event-dispatcher';
import { EditorContext } from '@atlaskit/editor-common/UNSAFE_do_not_use_editor_context';
import { analyticsEventKey } from '@atlaskit/editor-common/utils/analytics';
import { deprecatedOpenHelpCommand } from '@atlaskit/editor-plugins/help-dialog';
// Ignored via go/ees005
// eslint-disable-next-line @repo/internal/react/no-class-components
var WithHelpTrigger = /*#__PURE__*/function (_React$Component) {
function WithHelpTrigger() {
var _this;
_classCallCheck(this, WithHelpTrigger);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _callSuper(this, WithHelpTrigger, [].concat(args));
_defineProperty(_this, "openHelp", function () {
// Ignored via go/ees005
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
var _ref = _this.context,
editorActions = _ref.editorActions;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
var dispatch = createDispatch(editorActions.eventDispatcher);
dispatch(analyticsEventKey, {
payload: {
action: ACTION.CLICKED,
actionSubject: ACTION_SUBJECT.BUTTON,
actionSubjectId: ACTION_SUBJECT_ID.BUTTON_HELP,
attributes: {
inputMethod: INPUT_METHOD.TOOLBAR
},
eventType: EVENT_TYPE.UI
}
});
var editorView = editorActions._privateGetEditorView();
if (editorView) {
deprecatedOpenHelpCommand(editorView.state.tr, editorView.dispatch);
}
});
return _this;
}
_inherits(WithHelpTrigger, _React$Component);
return _createClass(WithHelpTrigger, [{
key: "render",
value: function render() {
return this.props.render(this.openHelp);
}
}]);
}(React.Component);
_defineProperty(WithHelpTrigger, "contextType", EditorContext);
export default WithHelpTrigger;