@atlaskit/editor-plugin-help-dialog 0.1.0 → 0.2.0

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 (40) hide show
  1. package/.eslintrc.js +2 -0
  2. package/CHANGELOG.md +6 -0
  3. package/dist/cjs/commands.js +19 -0
  4. package/dist/cjs/index.js +15 -1
  5. package/dist/cjs/plugin-key.js +8 -0
  6. package/dist/cjs/plugin.js +137 -0
  7. package/dist/cjs/ui/HelpDialogLoader.js +24 -0
  8. package/dist/cjs/ui/index.js +563 -0
  9. package/dist/cjs/ui/styles.js +50 -0
  10. package/dist/es2019/commands.js +13 -0
  11. package/dist/es2019/index.js +6 -1
  12. package/dist/es2019/plugin-key.js +2 -0
  13. package/dist/es2019/plugin.js +124 -0
  14. package/dist/es2019/ui/HelpDialogLoader.js +6 -0
  15. package/dist/es2019/ui/index.js +441 -0
  16. package/dist/es2019/ui/styles.js +110 -0
  17. package/dist/esm/commands.js +13 -0
  18. package/dist/esm/index.js +6 -1
  19. package/dist/esm/plugin-key.js +2 -0
  20. package/dist/esm/plugin.js +129 -0
  21. package/dist/esm/ui/HelpDialogLoader.js +12 -0
  22. package/dist/esm/ui/index.js +552 -0
  23. package/dist/esm/ui/styles.js +40 -0
  24. package/dist/types/commands.d.ts +3 -0
  25. package/dist/types/index.d.ts +6 -0
  26. package/dist/types/plugin-key.d.ts +2 -0
  27. package/dist/types/plugin.d.ts +4 -0
  28. package/dist/types/ui/HelpDialogLoader.d.ts +4 -0
  29. package/dist/types/ui/index.d.ts +27 -0
  30. package/dist/types/ui/styles.d.ts +33 -0
  31. package/dist/types-ts4.5/commands.d.ts +3 -0
  32. package/dist/types-ts4.5/index.d.ts +6 -0
  33. package/dist/types-ts4.5/plugin-key.d.ts +2 -0
  34. package/dist/types-ts4.5/plugin.d.ts +4 -0
  35. package/dist/types-ts4.5/ui/HelpDialogLoader.d.ts +4 -0
  36. package/dist/types-ts4.5/ui/index.d.ts +27 -0
  37. package/dist/types-ts4.5/ui/styles.d.ts +33 -0
  38. package/package.json +12 -3
  39. package/report.api.md +10 -0
  40. package/tmp/api-report-tmp.d.ts +7 -0
package/.eslintrc.js CHANGED
@@ -2,5 +2,7 @@ module.exports = {
2
2
  rules: {
3
3
  '@typescript-eslint/no-duplicate-imports': 'error',
4
4
  '@typescript-eslint/no-explicit-any': 'error',
5
+ '@atlaskit/design-system/consistent-css-prop-usage': 'warn',
6
+ '@repo/internal/dom-events/no-unsafe-event-listeners': 'warn',
5
7
  },
6
8
  };
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/editor-plugin-help-dialog
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#41049](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41049) [`56e271b5da6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/56e271b5da6) - Extract help-dialog-plugin from editor-core
8
+
3
9
  ## 0.1.0
4
10
 
5
11
  ### Minor Changes
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.openHelpCommand = exports.closeHelpCommand = void 0;
7
+ var _pluginKey = require("./plugin-key");
8
+ var openHelpCommand = exports.openHelpCommand = function openHelpCommand(tr, dispatch) {
9
+ tr = tr.setMeta(_pluginKey.pluginKey, true);
10
+ if (dispatch) {
11
+ dispatch(tr);
12
+ return true;
13
+ }
14
+ return false;
15
+ };
16
+ var closeHelpCommand = exports.closeHelpCommand = function closeHelpCommand(tr, dispatch) {
17
+ tr = tr.setMeta(_pluginKey.pluginKey, false);
18
+ dispatch(tr);
19
+ };
package/dist/cjs/index.js CHANGED
@@ -2,4 +2,18 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
- });
5
+ });
6
+ Object.defineProperty(exports, "deprecatedOpenHelpCommand", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _commands.openHelpCommand;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "helpDialogPlugin", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _plugin.helpDialogPlugin;
16
+ }
17
+ });
18
+ var _plugin = require("./plugin");
19
+ var _commands = require("./commands");
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.pluginKey = void 0;
7
+ var _state = require("@atlaskit/editor-prosemirror/state");
8
+ var pluginKey = exports.pluginKey = new _state.PluginKey('helpDialogPlugin');
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createPlugin = createPlugin;
8
+ exports.helpDialogPlugin = void 0;
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _react = _interopRequireDefault(require("react"));
11
+ var _analytics = require("@atlaskit/editor-common/analytics");
12
+ var _keymaps = require("@atlaskit/editor-common/keymaps");
13
+ var _messages = require("@atlaskit/editor-common/messages");
14
+ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
15
+ var _keymap = require("@atlaskit/editor-prosemirror/keymap");
16
+ var _questionCircle = _interopRequireDefault(require("@atlaskit/icon/glyph/question-circle"));
17
+ var _commands = require("./commands");
18
+ var _pluginKey = require("./plugin-key");
19
+ var _HelpDialogLoader = require("./ui/HelpDialogLoader");
20
+ 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; }
21
+ 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; }
22
+ function createPlugin(dispatch, imageEnabled) {
23
+ return new _safePlugin.SafePlugin({
24
+ key: _pluginKey.pluginKey,
25
+ state: {
26
+ init: function init() {
27
+ return {
28
+ isVisible: false,
29
+ imageEnabled: imageEnabled
30
+ };
31
+ },
32
+ apply: function apply(tr, _value, state) {
33
+ var isVisible = tr.getMeta(_pluginKey.pluginKey);
34
+ var currentState = _pluginKey.pluginKey.getState(state);
35
+ if (isVisible !== undefined && isVisible !== currentState.isVisible) {
36
+ var newState = _objectSpread(_objectSpread({}, currentState), {}, {
37
+ isVisible: isVisible
38
+ });
39
+ dispatch(_pluginKey.pluginKey, newState);
40
+ return newState;
41
+ }
42
+ return currentState;
43
+ }
44
+ }
45
+ });
46
+ }
47
+ var helpDialogPlugin = exports.helpDialogPlugin = function helpDialogPlugin(_ref) {
48
+ var _ref$config = _ref.config,
49
+ imageUploadProviderExists = _ref$config === void 0 ? false : _ref$config,
50
+ api = _ref.api;
51
+ return {
52
+ name: 'helpDialog',
53
+ pmPlugins: function pmPlugins() {
54
+ return [{
55
+ name: 'helpDialog',
56
+ plugin: function plugin(_ref2) {
57
+ var dispatch = _ref2.dispatch;
58
+ return createPlugin(dispatch, imageUploadProviderExists);
59
+ }
60
+ }, {
61
+ name: 'helpDialogKeymap',
62
+ plugin: function plugin() {
63
+ var _api$analytics;
64
+ return keymapPlugin(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
65
+ }
66
+ }];
67
+ },
68
+ pluginsOptions: {
69
+ quickInsert: function quickInsert(_ref3) {
70
+ var formatMessage = _ref3.formatMessage;
71
+ return [{
72
+ id: 'helpdialog',
73
+ title: formatMessage(_messages.toolbarInsertBlockMessages.help),
74
+ description: formatMessage(_messages.toolbarInsertBlockMessages.helpDescription),
75
+ keywords: ['?'],
76
+ priority: 4000,
77
+ keyshortcut: (0, _keymaps.tooltip)(_keymaps.openHelp),
78
+ icon: function icon() {
79
+ return /*#__PURE__*/_react.default.createElement(_questionCircle.default, {
80
+ label: ""
81
+ });
82
+ },
83
+ action: function action(insert) {
84
+ var _api$analytics2;
85
+ var tr = insert('');
86
+ (0, _commands.openHelpCommand)(tr);
87
+ api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent({
88
+ action: _analytics.ACTION.HELP_OPENED,
89
+ actionSubject: _analytics.ACTION_SUBJECT.HELP,
90
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.HELP_QUICK_INSERT,
91
+ attributes: {
92
+ inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
93
+ },
94
+ eventType: _analytics.EVENT_TYPE.UI
95
+ })(tr);
96
+ return tr;
97
+ }
98
+ }];
99
+ }
100
+ },
101
+ contentComponent: function contentComponent(_ref4) {
102
+ var editorView = _ref4.editorView;
103
+ return /*#__PURE__*/_react.default.createElement(_HelpDialogLoader.HelpDialogLoader, {
104
+ pluginInjectionApi: api,
105
+ editorView: editorView,
106
+ quickInsertEnabled: !!(api !== null && api !== void 0 && api.quickInsert)
107
+ });
108
+ },
109
+ getSharedState: function getSharedState(editorState) {
110
+ if (!editorState) {
111
+ return null;
112
+ }
113
+ return _pluginKey.pluginKey.getState(editorState) || null;
114
+ }
115
+ };
116
+ };
117
+ var keymapPlugin = function keymapPlugin(editorAnalyticsAPI) {
118
+ var list = {};
119
+ (0, _keymaps.bindKeymapWithCommand)(_keymaps.openHelp.common, function (state, dispatch) {
120
+ var tr = state.tr;
121
+ var isVisible = tr.getMeta(_pluginKey.pluginKey);
122
+ if (!isVisible) {
123
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
124
+ action: _analytics.ACTION.CLICKED,
125
+ actionSubject: _analytics.ACTION_SUBJECT.BUTTON,
126
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.BUTTON_HELP,
127
+ attributes: {
128
+ inputMethod: _analytics.INPUT_METHOD.SHORTCUT
129
+ },
130
+ eventType: _analytics.EVENT_TYPE.UI
131
+ })(tr);
132
+ (0, _commands.openHelpCommand)(tr, dispatch);
133
+ }
134
+ return true;
135
+ }, list);
136
+ return (0, _keymap.keymap)(list);
137
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.HelpDialogLoader = void 0;
8
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
9
+ var _reactLoadable = _interopRequireDefault(require("react-loadable"));
10
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || (0, _typeof2.default)(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
12
+ var HelpDialogLoader = exports.HelpDialogLoader = (0, _reactLoadable.default)({
13
+ loader: function loader() {
14
+ return Promise.resolve().then(function () {
15
+ return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_editor-core-helpdialog" */
16
+ './index'));
17
+ }).then(function (mod) {
18
+ return mod.default;
19
+ });
20
+ },
21
+ loading: function loading() {
22
+ return null;
23
+ }
24
+ });