UNPKG

@atlaskit/editor-core

Version:

A package contains Atlassian editor core functionality

44 lines (43 loc) 1.76 kB
import _defineProperty from "@babel/runtime/helpers/defineProperty"; 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 class WithHelpTrigger extends React.Component { constructor(...args) { super(...args); _defineProperty(this, "openHelp", () => { // Ignored via go/ees005 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const { editorActions } = this.context; // eslint-disable-next-line @typescript-eslint/no-explicit-any const 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 } }); const editorView = editorActions._privateGetEditorView(); if (editorView) { deprecatedOpenHelpCommand(editorView.state.tr, editorView.dispatch); } }); } render() { return this.props.render(this.openHelp); } } _defineProperty(WithHelpTrigger, "contextType", EditorContext); export default WithHelpTrigger;