@atlaskit/editor-common 74.52.2 → 74.53.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 (33) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/cjs/hooks/useSharedPluginState.js +3 -3
  3. package/dist/cjs/monitoring/error.js +1 -1
  4. package/dist/cjs/preset/builder.js +6 -1
  5. package/dist/cjs/preset/core-plugin.js +2 -2
  6. package/dist/cjs/preset/editor-commands.js +1 -1
  7. package/dist/cjs/preset/plugin-injection-api.js +4 -5
  8. package/dist/cjs/ui/DropList/index.js +1 -1
  9. package/dist/es2019/hooks/useSharedPluginState.js +3 -3
  10. package/dist/es2019/monitoring/error.js +1 -1
  11. package/dist/es2019/preset/builder.js +6 -1
  12. package/dist/es2019/preset/core-plugin.js +2 -2
  13. package/dist/es2019/preset/editor-commands.js +1 -1
  14. package/dist/es2019/preset/plugin-injection-api.js +4 -5
  15. package/dist/es2019/ui/DropList/index.js +1 -1
  16. package/dist/esm/hooks/useSharedPluginState.js +3 -3
  17. package/dist/esm/monitoring/error.js +1 -1
  18. package/dist/esm/preset/builder.js +6 -1
  19. package/dist/esm/preset/core-plugin.js +2 -2
  20. package/dist/esm/preset/editor-commands.js +1 -1
  21. package/dist/esm/preset/plugin-injection-api.js +4 -5
  22. package/dist/esm/ui/DropList/index.js +1 -1
  23. package/dist/types/hooks/useSharedPluginState.d.ts +5 -5
  24. package/dist/types/preset/editor-commands.d.ts +1 -1
  25. package/dist/types/preset/plugin-injection-api.d.ts +3 -21
  26. package/dist/types/types/index.d.ts +1 -1
  27. package/dist/types/types/next-editor-plugin.d.ts +35 -15
  28. package/dist/types-ts4.5/hooks/useSharedPluginState.d.ts +5 -5
  29. package/dist/types-ts4.5/preset/editor-commands.d.ts +1 -1
  30. package/dist/types-ts4.5/preset/plugin-injection-api.d.ts +8 -27
  31. package/dist/types-ts4.5/types/index.d.ts +1 -1
  32. package/dist/types-ts4.5/types/next-editor-plugin.d.ts +38 -18
  33. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 74.53.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`8467bdcdf4f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8467bdcdf4f) - Removing `dependencies` prop from PluginInjectionAPI and changing
8
+ signature of `NextEditorPlugin`.
9
+
10
+ Previously a `NextEditorPlugin` would be consumed as so:
11
+
12
+ ```ts
13
+ const plugin: NextEditorPlugin< ... > = (config, api) => {
14
+ // Can use api like so:
15
+ api.dependencies.core.actions.execute( ... )
16
+ return { ... }
17
+ }
18
+ ```
19
+
20
+ Now these have become named parameters like so and the `pluginInjectionAPI` is used
21
+ without the `dependencies` prop:
22
+
23
+ ```ts
24
+ const plugin: NextEditorPlugin< ... > = ({ config, api }) => {
25
+ // Can use api like so:
26
+ api.core.actions.execute( ... )
27
+ return { ... }
28
+ }
29
+ ```
30
+
3
31
  ## 74.52.2
4
32
 
5
33
  ### Patch Changes
@@ -54,7 +54,7 @@ function useStaticPlugins(plugins) {
54
54
  * return <p>{ dogState.title } { exampleState.description }</p>
55
55
  * }
56
56
  *
57
- * const examplePlugin: NextEditorPlugin<'example', { dependencies: [typeof pluginDog] }> = (_, api) => {
57
+ * const examplePlugin: NextEditorPlugin<'example', { dependencies: [typeof pluginDog] }> = ({ api }) => {
58
58
  * return {
59
59
  * name: 'example',
60
60
  * contentComponent: () =>
@@ -76,9 +76,9 @@ function useSharedPluginState(injectionApi, plugins) {
76
76
  // Create a memoized object containing the named plugins
77
77
  var namedExternalPlugins = (0, _react.useMemo)(function () {
78
78
  return pluginNames.reduce(function (acc, pluginName) {
79
- return _objectSpread(_objectSpread({}, acc), {}, (0, _defineProperty2.default)({}, "".concat(pluginName, "State"), injectionApi === null || injectionApi === void 0 ? void 0 : injectionApi.dependencies[pluginName]));
79
+ return _objectSpread(_objectSpread({}, acc), {}, (0, _defineProperty2.default)({}, "".concat(pluginName, "State"), injectionApi === null || injectionApi === void 0 ? void 0 : injectionApi[pluginName]));
80
80
  }, {});
81
- }, [injectionApi === null || injectionApi === void 0 ? void 0 : injectionApi.dependencies, pluginNames]);
81
+ }, [injectionApi, pluginNames]);
82
82
  return useSharedPluginStateInternal(namedExternalPlugins);
83
83
  }
84
84
  function useSharedPluginStateInternal(externalPlugins) {
@@ -16,7 +16,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
16
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(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; }
17
17
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
18
18
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
19
- var packageVersion = "74.52.2";
19
+ var packageVersion = "74.53.0";
20
20
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
21
21
  // Remove URL as it has UGC
22
22
  // TODO: Sanitise the URL instead of just removing it
@@ -116,7 +116,12 @@ var EditorPresetBuilder = /*#__PURE__*/function () {
116
116
  if (typeof fn !== 'function') {
117
117
  return null;
118
118
  }
119
- var plugin = pluginInjectionAPI ? fn(config, pluginInjectionAPI.api()) : fn(config);
119
+ var plugin = pluginInjectionAPI ? fn({
120
+ config: config,
121
+ api: pluginInjectionAPI.api()
122
+ }) : fn({
123
+ config: config
124
+ });
120
125
  if (plugin && excludePlugins !== null && excludePlugins !== void 0 && excludePlugins.has(plugin.name)) {
121
126
  return null;
122
127
  }
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.corePlugin = void 0;
7
7
  var _editorCommands = require("./editor-commands");
8
8
  var corePlugin = function corePlugin(_ref) {
9
- var getEditorView = _ref.getEditorView;
9
+ var config = _ref.config;
10
10
  return {
11
11
  name: 'core',
12
12
  actions: {
13
13
  execute: function execute(command) {
14
- var editorView = getEditorView();
14
+ var editorView = config === null || config === void 0 ? void 0 : config.getEditorView();
15
15
  if (!editorView || !command) {
16
16
  return false;
17
17
  }
@@ -17,7 +17,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
17
17
  /**
18
18
  * Convert a EditorCommand to a standard Prosemirror Command.
19
19
  * The preferred approach to dispatching a `EditorCommand` is via the
20
- * `dependencies.core.actions.execute` on `pluginInjectionAPI`. In some cases
20
+ * `core.actions.execute` on `pluginInjectionAPI`. In some cases
21
21
  * the type may require a Command until we refactor this out and this
22
22
  * function is suitable for those cases.
23
23
  *
@@ -280,7 +280,9 @@ var EditorPluginInjectionAPI = /*#__PURE__*/function () {
280
280
  this.commandsAPI = new EditorCommandsAPI();
281
281
  // Special core plugin that is always added
282
282
  this.addPlugin((0, _corePlugin.corePlugin)({
283
- getEditorView: getEditorView
283
+ config: {
284
+ getEditorView: getEditorView
285
+ }
284
286
  }));
285
287
  }
286
288
  (0, _createClass2.default)(EditorPluginInjectionAPI, [{
@@ -290,7 +292,7 @@ var EditorPluginInjectionAPI = /*#__PURE__*/function () {
290
292
  actionsAPI = this.actionsAPI,
291
293
  commandsAPI = this.commandsAPI,
292
294
  getPluginByName = this.getPluginByName;
293
- var dependencies = new Proxy({}, {
295
+ return new Proxy({}, {
294
296
  get: function get(target, prop, receiver) {
295
297
  // If we pass this as a prop React hates us
296
298
  // Let's just reflect the result and ignore these
@@ -316,9 +318,6 @@ var EditorPluginInjectionAPI = /*#__PURE__*/function () {
316
318
  return proxyCoreAPI;
317
319
  }
318
320
  });
319
- return {
320
- dependencies: dependencies
321
- };
322
321
  }
323
322
  }]);
324
323
  return EditorPluginInjectionAPI;
@@ -24,7 +24,7 @@ var _templateObject, _templateObject2, _templateObject3;
24
24
  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); }; }
25
25
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
26
26
  var packageName = "@atlaskit/editor-common";
27
- var packageVersion = "74.52.2";
27
+ var packageVersion = "74.53.0";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var DropList = /*#__PURE__*/function (_Component) {
@@ -39,7 +39,7 @@ function useStaticPlugins(plugins) {
39
39
  * return <p>{ dogState.title } { exampleState.description }</p>
40
40
  * }
41
41
  *
42
- * const examplePlugin: NextEditorPlugin<'example', { dependencies: [typeof pluginDog] }> = (_, api) => {
42
+ * const examplePlugin: NextEditorPlugin<'example', { dependencies: [typeof pluginDog] }> = ({ api }) => {
43
43
  * return {
44
44
  * name: 'example',
45
45
  * contentComponent: () =>
@@ -61,8 +61,8 @@ export function useSharedPluginState(injectionApi, plugins) {
61
61
  // Create a memoized object containing the named plugins
62
62
  const namedExternalPlugins = useMemo(() => pluginNames.reduce((acc, pluginName) => ({
63
63
  ...acc,
64
- [`${pluginName}State`]: injectionApi === null || injectionApi === void 0 ? void 0 : injectionApi.dependencies[pluginName]
65
- }), {}), [injectionApi === null || injectionApi === void 0 ? void 0 : injectionApi.dependencies, pluginNames]);
64
+ [`${pluginName}State`]: injectionApi === null || injectionApi === void 0 ? void 0 : injectionApi[pluginName]
65
+ }), {}), [injectionApi, pluginNames]);
66
66
  return useSharedPluginStateInternal(namedExternalPlugins);
67
67
  }
68
68
  function useSharedPluginStateInternal(externalPlugins) {
@@ -1,6 +1,6 @@
1
1
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
2
2
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
3
- const packageVersion = "74.52.2";
3
+ const packageVersion = "74.53.0";
4
4
  const sanitiseSentryEvents = (data, _hint) => {
5
5
  // Remove URL as it has UGC
6
6
  // TODO: Sanitise the URL instead of just removing it
@@ -81,7 +81,12 @@ export class EditorPresetBuilder {
81
81
  if (typeof fn !== 'function') {
82
82
  return null;
83
83
  }
84
- const plugin = pluginInjectionAPI ? fn(config, pluginInjectionAPI.api()) : fn(config);
84
+ const plugin = pluginInjectionAPI ? fn({
85
+ config,
86
+ api: pluginInjectionAPI.api()
87
+ }) : fn({
88
+ config
89
+ });
85
90
  if (plugin && excludePlugins !== null && excludePlugins !== void 0 && excludePlugins.has(plugin.name)) {
86
91
  return null;
87
92
  }
@@ -1,12 +1,12 @@
1
1
  import { editorCommandToPMCommand } from './editor-commands';
2
2
  export const corePlugin = ({
3
- getEditorView
3
+ config
4
4
  }) => {
5
5
  return {
6
6
  name: 'core',
7
7
  actions: {
8
8
  execute: command => {
9
- const editorView = getEditorView();
9
+ const editorView = config === null || config === void 0 ? void 0 : config.getEditorView();
10
10
  if (!editorView || !command) {
11
11
  return false;
12
12
  }
@@ -2,7 +2,7 @@ import { Transaction } from '@atlaskit/editor-prosemirror/state';
2
2
  /**
3
3
  * Convert a EditorCommand to a standard Prosemirror Command.
4
4
  * The preferred approach to dispatching a `EditorCommand` is via the
5
- * `dependencies.core.actions.execute` on `pluginInjectionAPI`. In some cases
5
+ * `core.actions.execute` on `pluginInjectionAPI`. In some cases
6
6
  * the type may require a Command until we refactor this out and this
7
7
  * function is suitable for those cases.
8
8
  *
@@ -199,7 +199,9 @@ export class EditorPluginInjectionAPI {
199
199
  this.commandsAPI = new EditorCommandsAPI();
200
200
  // Special core plugin that is always added
201
201
  this.addPlugin(corePlugin({
202
- getEditorView
202
+ config: {
203
+ getEditorView
204
+ }
203
205
  }));
204
206
  }
205
207
  api() {
@@ -209,7 +211,7 @@ export class EditorPluginInjectionAPI {
209
211
  commandsAPI,
210
212
  getPluginByName
211
213
  } = this;
212
- const dependencies = new Proxy({}, {
214
+ return new Proxy({}, {
213
215
  get: function (target, prop, receiver) {
214
216
  // If we pass this as a prop React hates us
215
217
  // Let's just reflect the result and ignore these
@@ -235,8 +237,5 @@ export class EditorPluginInjectionAPI {
235
237
  return proxyCoreAPI;
236
238
  }
237
239
  });
238
- return {
239
- dependencies
240
- };
241
240
  }
242
241
  }
@@ -8,7 +8,7 @@ import { themed } from '@atlaskit/theme/components';
8
8
  import { borderRadius } from '@atlaskit/theme/constants';
9
9
  import Layer from '../Layer';
10
10
  const packageName = "@atlaskit/editor-common";
11
- const packageVersion = "74.52.2";
11
+ const packageVersion = "74.53.0";
12
12
  const halfFocusRing = 1;
13
13
  const dropOffset = '0, 8';
14
14
  class DropList extends Component {
@@ -47,7 +47,7 @@ function useStaticPlugins(plugins) {
47
47
  * return <p>{ dogState.title } { exampleState.description }</p>
48
48
  * }
49
49
  *
50
- * const examplePlugin: NextEditorPlugin<'example', { dependencies: [typeof pluginDog] }> = (_, api) => {
50
+ * const examplePlugin: NextEditorPlugin<'example', { dependencies: [typeof pluginDog] }> = ({ api }) => {
51
51
  * return {
52
52
  * name: 'example',
53
53
  * contentComponent: () =>
@@ -69,9 +69,9 @@ export function useSharedPluginState(injectionApi, plugins) {
69
69
  // Create a memoized object containing the named plugins
70
70
  var namedExternalPlugins = useMemo(function () {
71
71
  return pluginNames.reduce(function (acc, pluginName) {
72
- return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, "".concat(pluginName, "State"), injectionApi === null || injectionApi === void 0 ? void 0 : injectionApi.dependencies[pluginName]));
72
+ return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, "".concat(pluginName, "State"), injectionApi === null || injectionApi === void 0 ? void 0 : injectionApi[pluginName]));
73
73
  }, {});
74
- }, [injectionApi === null || injectionApi === void 0 ? void 0 : injectionApi.dependencies, pluginNames]);
74
+ }, [injectionApi, pluginNames]);
75
75
  return useSharedPluginStateInternal(namedExternalPlugins);
76
76
  }
77
77
  function useSharedPluginStateInternal(externalPlugins) {
@@ -6,7 +6,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
6
6
  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) { _defineProperty(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; }
7
7
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
8
8
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
9
- var packageVersion = "74.52.2";
9
+ var packageVersion = "74.53.0";
10
10
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
11
11
  // Remove URL as it has UGC
12
12
  // TODO: Sanitise the URL instead of just removing it
@@ -109,7 +109,12 @@ export var EditorPresetBuilder = /*#__PURE__*/function () {
109
109
  if (typeof fn !== 'function') {
110
110
  return null;
111
111
  }
112
- var plugin = pluginInjectionAPI ? fn(config, pluginInjectionAPI.api()) : fn(config);
112
+ var plugin = pluginInjectionAPI ? fn({
113
+ config: config,
114
+ api: pluginInjectionAPI.api()
115
+ }) : fn({
116
+ config: config
117
+ });
113
118
  if (plugin && excludePlugins !== null && excludePlugins !== void 0 && excludePlugins.has(plugin.name)) {
114
119
  return null;
115
120
  }
@@ -1,11 +1,11 @@
1
1
  import { editorCommandToPMCommand } from './editor-commands';
2
2
  export var corePlugin = function corePlugin(_ref) {
3
- var getEditorView = _ref.getEditorView;
3
+ var config = _ref.config;
4
4
  return {
5
5
  name: 'core',
6
6
  actions: {
7
7
  execute: function execute(command) {
8
- var editorView = getEditorView();
8
+ var editorView = config === null || config === void 0 ? void 0 : config.getEditorView();
9
9
  if (!editorView || !command) {
10
10
  return false;
11
11
  }
@@ -9,7 +9,7 @@ import { Transaction } from '@atlaskit/editor-prosemirror/state';
9
9
  /**
10
10
  * Convert a EditorCommand to a standard Prosemirror Command.
11
11
  * The preferred approach to dispatching a `EditorCommand` is via the
12
- * `dependencies.core.actions.execute` on `pluginInjectionAPI`. In some cases
12
+ * `core.actions.execute` on `pluginInjectionAPI`. In some cases
13
13
  * the type may require a Command until we refactor this out and this
14
14
  * function is suitable for those cases.
15
15
  *
@@ -271,7 +271,9 @@ export var EditorPluginInjectionAPI = /*#__PURE__*/function () {
271
271
  this.commandsAPI = new EditorCommandsAPI();
272
272
  // Special core plugin that is always added
273
273
  this.addPlugin(corePlugin({
274
- getEditorView: getEditorView
274
+ config: {
275
+ getEditorView: getEditorView
276
+ }
275
277
  }));
276
278
  }
277
279
  _createClass(EditorPluginInjectionAPI, [{
@@ -281,7 +283,7 @@ export var EditorPluginInjectionAPI = /*#__PURE__*/function () {
281
283
  actionsAPI = this.actionsAPI,
282
284
  commandsAPI = this.commandsAPI,
283
285
  getPluginByName = this.getPluginByName;
284
- var dependencies = new Proxy({}, {
286
+ return new Proxy({}, {
285
287
  get: function get(target, prop, receiver) {
286
288
  // If we pass this as a prop React hates us
287
289
  // Let's just reflect the result and ignore these
@@ -307,9 +309,6 @@ export var EditorPluginInjectionAPI = /*#__PURE__*/function () {
307
309
  return proxyCoreAPI;
308
310
  }
309
311
  });
310
- return {
311
- dependencies: dependencies
312
- };
313
312
  }
314
313
  }]);
315
314
  return EditorPluginInjectionAPI;
@@ -18,7 +18,7 @@ import { themed } from '@atlaskit/theme/components';
18
18
  import { borderRadius } from '@atlaskit/theme/constants';
19
19
  import Layer from '../Layer';
20
20
  var packageName = "@atlaskit/editor-common";
21
- var packageVersion = "74.52.2";
21
+ var packageVersion = "74.53.0";
22
22
  var halfFocusRing = 1;
23
23
  var dropOffset = '0, 8';
24
24
  var DropList = /*#__PURE__*/function (_Component) {
@@ -1,8 +1,8 @@
1
- import type { ExtractPluginSharedState, NextEditorPlugin, PluginDependenciesAPI, PluginInjectionAPIWithDependencies, PublicPluginAPI } from '../types/next-editor-plugin';
2
- type NamedPluginStatesFromInjectionAPI<API extends PluginInjectionAPIWithDependencies<any> | undefined, PluginList extends string[]> = Readonly<{
3
- [K in PluginList[number] as `${K}State`]: API extends PluginInjectionAPIWithDependencies<any> ? API['dependencies'][K] extends PluginDependenciesAPI<infer Plugin> | undefined ? ExtractPluginSharedState<Plugin> | undefined : never : never;
1
+ import type { ExtractPluginSharedState, NextEditorPlugin, PluginDependenciesAPI, PublicPluginAPI } from '../types/next-editor-plugin';
2
+ type NamedPluginStatesFromInjectionAPI<API extends PublicPluginAPI<any> | undefined, PluginList extends string[]> = Readonly<{
3
+ [K in PluginList[number] as `${K}State`]: API extends PublicPluginAPI<any> ? API[K] extends PluginDependenciesAPI<infer Plugin> | undefined ? ExtractPluginSharedState<Plugin> | undefined : never : never;
4
4
  }>;
5
- type ExtractPluginNames<API extends PluginInjectionAPIWithDependencies<any>> = API extends PluginInjectionAPIWithDependencies<any> ? keyof API['dependencies'] : never;
5
+ type ExtractPluginNames<API extends PublicPluginAPI<any>> = API extends PublicPluginAPI<any> ? keyof API : never;
6
6
  /**
7
7
  *
8
8
  * Used to return the current plugin state of
@@ -19,7 +19,7 @@ type ExtractPluginNames<API extends PluginInjectionAPIWithDependencies<any>> = A
19
19
  * return <p>{ dogState.title } { exampleState.description }</p>
20
20
  * }
21
21
  *
22
- * const examplePlugin: NextEditorPlugin<'example', { dependencies: [typeof pluginDog] }> = (_, api) => {
22
+ * const examplePlugin: NextEditorPlugin<'example', { dependencies: [typeof pluginDog] }> = ({ api }) => {
23
23
  * return {
24
24
  * name: 'example',
25
25
  * contentComponent: () =>
@@ -4,7 +4,7 @@ import type { EditorCommand } from '../types/editor-command';
4
4
  /**
5
5
  * Convert a EditorCommand to a standard Prosemirror Command.
6
6
  * The preferred approach to dispatching a `EditorCommand` is via the
7
- * `dependencies.core.actions.execute` on `pluginInjectionAPI`. In some cases
7
+ * `core.actions.execute` on `pluginInjectionAPI`. In some cases
8
8
  * the type may require a Command until we refactor this out and this
9
9
  * function is suitable for those cases.
10
10
  *
@@ -1,6 +1,6 @@
1
1
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
2
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
- import type { DefaultEditorPlugin, NextEditorPlugin, PluginDependenciesAPI, PluginInjectionAPI } from '../types/next-editor-plugin';
3
+ import type { NextEditorPlugin, PluginDependenciesAPI, PluginInjectionAPI } from '../types/next-editor-plugin';
4
4
  type NextEditorPluginInitializedType = ReturnType<NextEditorPlugin<any>>;
5
5
  type SharedStateAPIProps = {
6
6
  getEditorState: () => EditorState | undefined;
@@ -29,7 +29,7 @@ type EditorStateDelta = {
29
29
  readonly oldEditorState: EditorState;
30
30
  };
31
31
  interface PluginInjectionAPIDefinition {
32
- api: <T extends NextEditorPlugin<any, any>>() => PluginInjectionAPI<T extends NextEditorPlugin<infer Name, any> ? Name : never, T extends NextEditorPlugin<any, infer Metadata> ? Metadata : never>;
32
+ api: <T extends NextEditorPlugin<any, any>>() => PluginInjectionAPI<T extends NextEditorPlugin<infer Name, any> ? Name : never, T extends NextEditorPlugin<any, infer Metadata> ? Metadata : never>['dependencies'];
33
33
  onEditorViewUpdated: (props: EditorStateDelta) => void;
34
34
  onEditorPluginInitialized: (plugin: NextEditorPluginInitializedType) => void;
35
35
  }
@@ -39,25 +39,7 @@ export declare class EditorPluginInjectionAPI implements PluginInjectionAPIDefin
39
39
  private commandsAPI;
40
40
  private plugins;
41
41
  constructor({ getEditorState, getEditorView }: PluginInjectionAPIProps);
42
- api<T extends NextEditorPlugin<any, any>>(): {
43
- dependencies: import("../types/next-editor-plugin").CreatePluginDependenciesAPI<[NextEditorPlugin<T extends (config?: any, api?: PluginInjectionAPI<infer Name extends string, any> | undefined) => DefaultEditorPlugin<infer Name extends string, any> ? Name : never, T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never>, ..."dependencies" extends keyof (T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never) ? (T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never)["dependencies"] extends (((config?: any, api?: PluginInjectionAPI<any, any> | undefined) => DefaultEditorPlugin<any, any>) | import("../types/next-editor-plugin").OptionalPlugin<(config?: any, api?: PluginInjectionAPI<any, any> | undefined) => DefaultEditorPlugin<any, any>>)[] ? Exclude<(T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never)["dependencies"], undefined> : [] : [], (config: {
44
- getEditorView: () => EditorView | undefined;
45
- }, api?: PluginInjectionAPI<"core", {
46
- pluginConfiguration: {
47
- getEditorView: () => EditorView | undefined;
48
- };
49
- actions: {
50
- execute: (command: import("../types").EditorCommand | undefined) => boolean;
51
- };
52
- }> | undefined) => DefaultEditorPlugin<"core", {
53
- pluginConfiguration: {
54
- getEditorView: () => EditorView | undefined;
55
- };
56
- actions: {
57
- execute: (command: import("../types").EditorCommand | undefined) => boolean;
58
- };
59
- }>]>;
60
- };
42
+ api<T extends NextEditorPlugin<any, any>>(): import("../types/next-editor-plugin").PublicPluginAPI<[NextEditorPlugin<T extends import("../types/next-editor-plugin").NextEditorPluginFunctionOptionalConfigDefinition<infer Name extends string, any, any> ? Name : never, T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never>, ..."dependencies" extends keyof (T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never) ? (T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never)["dependencies"] extends (import("../types/next-editor-plugin").NextEditorPluginFunctionOptionalConfigDefinition<any, any, any> | import("../types/next-editor-plugin").OptionalPlugin<import("../types/next-editor-plugin").NextEditorPluginFunctionOptionalConfigDefinition<any, any, any>>)[] ? Exclude<(T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never)["dependencies"], undefined> : [] : []]>;
61
43
  onEditorViewUpdated: ({ newEditorState, oldEditorState, }: EditorStateDiff) => void;
62
44
  onEditorPluginInitialized: (plugin: NextEditorPluginInitializedType) => void;
63
45
  private addPlugin;
@@ -28,7 +28,7 @@ export type { EditorReactContext } from './editor-react-context';
28
28
  export type { PMPluginFactoryParams, PMPluginFactory, PMPlugin, } from './plugin-factory';
29
29
  export type { NodeConfig, MarkConfig, NodeViewConfig, } from './prosemirror-config';
30
30
  export type { PluginsOptions, EditorPlugin, getPosHandler, getPosHandlerNode, } from './editor-plugin';
31
- export type { NextEditorPlugin, AllEditorPresetPluginTypes, PluginDependenciesAPI, ExtractPluginNameFromAllBuilderPlugins, SafePresetCheck, DefaultEditorPlugin, OptionalPlugin, PluginInjectionAPI, CreatePluginDependenciesAPI, NextEditorPluginMetadata, ExtractInjectionAPI, ExtractPluginActions, PluginInjectionAPIWithDependency, PluginInjectionAPIWithDependencies, PublicPluginAPI, } from './next-editor-plugin';
31
+ export type { NextEditorPlugin, AllEditorPresetPluginTypes, PluginDependenciesAPI, ExtractPluginNameFromAllBuilderPlugins, SafePresetCheck, DefaultEditorPlugin, OptionalPlugin, PluginInjectionAPI, CreatePluginDependenciesAPI, NextEditorPluginMetadata, ExtractInjectionAPI, ExtractPluginActions, PluginInjectionAPIWithDependency, PluginInjectionAPIWithDependencies, PublicPluginAPI, NextEditorPluginFunctionOptionalConfigDefinition, } from './next-editor-plugin';
32
32
  export type { ExtractPublicEditorAPI } from './editor-public-api';
33
33
  export type { EditorCommand, EditorCommandWithMetadata, } from './editor-command';
34
34
  export type IconProps = {
@@ -34,20 +34,30 @@ export interface NextEditorPluginMetadata {
34
34
  readonly actions?: NextEditorPluginActions;
35
35
  readonly commands?: NextEditorEditorCommands;
36
36
  }
37
- export type PluginInjectionAPI<Name extends string, Metadata extends NextEditorPluginMetadata> = PublicPluginAPI<[
38
- NextEditorPlugin<Name, Metadata>,
39
- ...ExtractPluginDependenciesFromMetadata<Metadata>
40
- ]>;
37
+ /**
38
+ * `PluginInjectionAPI` doesn't actually use `dependencies`,
39
+ * we should use it as PluginInjectionAPI< ... >['dependencies']
40
+ * it is only here because otherwise typescript blows up
41
+ * trying to compare `PluginInjectionAPI` to `PublicPluginAPI`
42
+ */
43
+ export type PluginInjectionAPI<Name extends string, Metadata extends NextEditorPluginMetadata> = {
44
+ dependencies: PublicPluginAPI<[
45
+ NextEditorPlugin<Name, Metadata>,
46
+ ...ExtractPluginDependenciesFromMetadata<Metadata>
47
+ ]>;
48
+ };
41
49
  export type PluginInjectionAPIWithDependency<Plugin extends NextEditorPlugin<any, any>> = PublicPluginAPI<[Plugin]>;
42
50
  export type PluginInjectionAPIWithDependencies<Plugins extends NextEditorPlugin<any, any>[]> = PublicPluginAPI<Plugins>;
43
- type NextEditorPluginFunctionDefinition<Name extends string, Metadata extends NextEditorPluginMetadata, Configuration> = (config: Configuration, api?: PluginInjectionAPI<Name, Metadata>) => DefaultEditorPlugin<Name, Metadata>;
44
- type NextEditorPluginFunctionOptionalConfigDefinition<Name extends string, Metadata extends NextEditorPluginMetadata, Configuration = undefined> = (config?: Configuration, api?: PluginInjectionAPI<Name, Metadata>) => DefaultEditorPlugin<Name, Metadata>;
51
+ export type NextEditorPluginFunctionOptionalConfigDefinition<Name extends string, Metadata extends NextEditorPluginMetadata, Configuration = undefined> = (props: {
52
+ config: Configuration;
53
+ api?: PluginInjectionAPI<Name, Metadata>['dependencies'];
54
+ }) => DefaultEditorPlugin<Name, Metadata>;
45
55
  type OptionalPrivateProperty = {
46
56
  __optionalPluginType: true;
47
57
  };
48
58
  export type OptionalPlugin<EditorPlugin extends NextEditorPlugin<any, any>> = EditorPlugin & OptionalPrivateProperty;
49
59
  type DependencyPlugin = OptionalPlugin<NextEditorPlugin<any, any>> | NextEditorPlugin<any, any>;
50
- export type NextEditorPlugin<Name extends string, Metadata extends NextEditorPluginMetadata = {}> = Metadata extends NextEditorPluginMetadata ? 'pluginConfiguration' extends keyof Metadata ? undefined extends Metadata['pluginConfiguration'] ? NextEditorPluginFunctionOptionalConfigDefinition<Name, Metadata, Metadata['pluginConfiguration']> : NextEditorPluginFunctionDefinition<Name, Metadata, Metadata['pluginConfiguration']> : NextEditorPluginFunctionOptionalConfigDefinition<Name, Metadata> : never;
60
+ export type NextEditorPlugin<Name extends string, Metadata extends NextEditorPluginMetadata = {}> = Metadata extends NextEditorPluginMetadata ? 'pluginConfiguration' extends keyof Metadata ? NextEditorPluginFunctionOptionalConfigDefinition<Name, Metadata, Metadata['pluginConfiguration']> : NextEditorPluginFunctionOptionalConfigDefinition<Name, Metadata> : never;
51
61
  type FilterOptionalPlugins<T extends DependencyPlugin[]> = T extends [
52
62
  infer Head,
53
63
  ...infer Tail
@@ -58,10 +68,22 @@ type ExtractSharedStateFromMetadata<Metadata> = 'sharedState' extends keyof Meta
58
68
  type ExtractActionsFromMetadata<Metadata> = 'actions' extends keyof Metadata ? Metadata['actions'] : never;
59
69
  type ExtractCommandsFromMetadata<Metadata> = 'commands' extends keyof Metadata ? Metadata['commands'] : never;
60
70
  type ExtractPluginConfigurationFromMetadata<Metadata> = 'pluginConfiguration' extends keyof Metadata ? Metadata['pluginConfiguration'] : never;
61
- export type ExtractPluginDependencies<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (config: any, api: any) => DefaultEditorPlugin<any, infer Metadata> ? ExtractPluginDependenciesFromMetadataWithoutOptionals<Metadata> : never : never;
62
- type ExtractPluginConfiguration<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (config: any, api: any) => DefaultEditorPlugin<any, infer Metadata> ? ExtractPluginConfigurationFromMetadata<Metadata> : never : never;
63
- export type ExtractPluginSharedState<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (config: any, api: any) => DefaultEditorPlugin<any, infer Metadata> ? ExtractSharedStateFromMetadata<Metadata> : never : never;
64
- export type ExtractPluginActions<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (config: any, api: any) => DefaultEditorPlugin<any, infer Metadata> ? ExtractActionsFromMetadata<Metadata> : never : never;
71
+ export type ExtractPluginDependencies<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (props: {
72
+ config: any;
73
+ api: any;
74
+ }) => DefaultEditorPlugin<any, infer Metadata> ? ExtractPluginDependenciesFromMetadataWithoutOptionals<Metadata> : never : never;
75
+ type ExtractPluginConfiguration<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (props: {
76
+ config: any;
77
+ api: any;
78
+ }) => DefaultEditorPlugin<any, infer Metadata> ? ExtractPluginConfigurationFromMetadata<Metadata> : never : never;
79
+ export type ExtractPluginSharedState<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (props: {
80
+ config: any;
81
+ api: any;
82
+ }) => DefaultEditorPlugin<any, infer Metadata> ? ExtractSharedStateFromMetadata<Metadata> : never : never;
83
+ export type ExtractPluginActions<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (props: {
84
+ config: any;
85
+ api: any;
86
+ }) => DefaultEditorPlugin<any, infer Metadata> ? ExtractActionsFromMetadata<Metadata> : never : never;
65
87
  type ExtractPluginName<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (...args: any) => DefaultEditorPlugin<infer PluginName, any> ? PluginName : never : never;
66
88
  type Unsubscribe = () => void;
67
89
  export type PluginDependenciesAPI<Plugin extends NextEditorPlugin<any, any>> = {
@@ -101,10 +123,8 @@ type CheckTupleRequirements<Plugin, Config, ArrayType> = unknown extends Config
101
123
  ] extends [never] ? Plugin : ArrayType;
102
124
  type CheckBasicPlugin<Plugin> = Plugin extends (args: any, api: any) => EditorPlugin ? CheckTupleRequirements<Plugin, ExtractPluginConfiguration<Plugin>, PluginAsArray<Plugin>> : never;
103
125
  export type ExtractPluginNameFromAllBuilderPlugins<Plugin extends AllEditorPresetPluginTypes> = Plugin extends Array<any> ? Plugin extends [infer MaybePlugin, ...any] ? MaybePlugin extends NextEditorPlugin<any, any> ? ExtractPluginName<MaybePlugin> : never : never : Plugin extends NextEditorPlugin<any, any> ? ExtractPluginName<Plugin> : never;
104
- export type ExtractInjectionAPI<Plugin> = Plugin extends NextEditorPlugin<infer Name, infer Metadata> ? PluginInjectionAPI<Name, Metadata> : never;
105
- export type PublicPluginAPI<PluginList extends NextEditorPlugin<any, any>[]> = {
106
- dependencies: CreatePluginDependenciesAPI<[...PluginList, CorePlugin]>;
107
- };
126
+ export type ExtractInjectionAPI<Plugin> = Plugin extends NextEditorPlugin<infer Name, infer Metadata> ? PluginInjectionAPI<Name, Metadata>['dependencies'] : never;
127
+ export type PublicPluginAPI<PluginList extends NextEditorPlugin<any, any>[]> = CreatePluginDependenciesAPI<[...PluginList, CorePlugin]>;
108
128
  export type ExtractNextEditorPlugins<Plugins extends AllEditorPresetPluginTypes[]> = {
109
129
  [PluginNumber in keyof Plugins]: Plugins[PluginNumber] extends NextEditorPlugin<infer Name, infer Metadata> ? NextEditorPlugin<Name, Metadata> : Plugins[PluginNumber] extends [
110
130
  NextEditorPlugin<infer Name, infer Metadata>,
@@ -1,8 +1,8 @@
1
- import type { ExtractPluginSharedState, NextEditorPlugin, PluginDependenciesAPI, PluginInjectionAPIWithDependencies, PublicPluginAPI } from '../types/next-editor-plugin';
2
- type NamedPluginStatesFromInjectionAPI<API extends PluginInjectionAPIWithDependencies<any> | undefined, PluginList extends string[]> = Readonly<{
3
- [K in PluginList[number] as `${K}State`]: API extends PluginInjectionAPIWithDependencies<any> ? API['dependencies'][K] extends PluginDependenciesAPI<infer Plugin> | undefined ? ExtractPluginSharedState<Plugin> | undefined : never : never;
1
+ import type { ExtractPluginSharedState, NextEditorPlugin, PluginDependenciesAPI, PublicPluginAPI } from '../types/next-editor-plugin';
2
+ type NamedPluginStatesFromInjectionAPI<API extends PublicPluginAPI<any> | undefined, PluginList extends string[]> = Readonly<{
3
+ [K in PluginList[number] as `${K}State`]: API extends PublicPluginAPI<any> ? API[K] extends PluginDependenciesAPI<infer Plugin> | undefined ? ExtractPluginSharedState<Plugin> | undefined : never : never;
4
4
  }>;
5
- type ExtractPluginNames<API extends PluginInjectionAPIWithDependencies<any>> = API extends PluginInjectionAPIWithDependencies<any> ? keyof API['dependencies'] : never;
5
+ type ExtractPluginNames<API extends PublicPluginAPI<any>> = API extends PublicPluginAPI<any> ? keyof API : never;
6
6
  /**
7
7
  *
8
8
  * Used to return the current plugin state of
@@ -19,7 +19,7 @@ type ExtractPluginNames<API extends PluginInjectionAPIWithDependencies<any>> = A
19
19
  * return <p>{ dogState.title } { exampleState.description }</p>
20
20
  * }
21
21
  *
22
- * const examplePlugin: NextEditorPlugin<'example', { dependencies: [typeof pluginDog] }> = (_, api) => {
22
+ * const examplePlugin: NextEditorPlugin<'example', { dependencies: [typeof pluginDog] }> = ({ api }) => {
23
23
  * return {
24
24
  * name: 'example',
25
25
  * contentComponent: () =>
@@ -4,7 +4,7 @@ import type { EditorCommand } from '../types/editor-command';
4
4
  /**
5
5
  * Convert a EditorCommand to a standard Prosemirror Command.
6
6
  * The preferred approach to dispatching a `EditorCommand` is via the
7
- * `dependencies.core.actions.execute` on `pluginInjectionAPI`. In some cases
7
+ * `core.actions.execute` on `pluginInjectionAPI`. In some cases
8
8
  * the type may require a Command until we refactor this out and this
9
9
  * function is suitable for those cases.
10
10
  *
@@ -1,6 +1,6 @@
1
1
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
2
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
- import type { DefaultEditorPlugin, NextEditorPlugin, PluginDependenciesAPI, PluginInjectionAPI } from '../types/next-editor-plugin';
3
+ import type { NextEditorPlugin, PluginDependenciesAPI, PluginInjectionAPI } from '../types/next-editor-plugin';
4
4
  type NextEditorPluginInitializedType = ReturnType<NextEditorPlugin<any>>;
5
5
  type SharedStateAPIProps = {
6
6
  getEditorState: () => EditorState | undefined;
@@ -29,7 +29,7 @@ type EditorStateDelta = {
29
29
  readonly oldEditorState: EditorState;
30
30
  };
31
31
  interface PluginInjectionAPIDefinition {
32
- api: <T extends NextEditorPlugin<any, any>>() => PluginInjectionAPI<T extends NextEditorPlugin<infer Name, any> ? Name : never, T extends NextEditorPlugin<any, infer Metadata> ? Metadata : never>;
32
+ api: <T extends NextEditorPlugin<any, any>>() => PluginInjectionAPI<T extends NextEditorPlugin<infer Name, any> ? Name : never, T extends NextEditorPlugin<any, infer Metadata> ? Metadata : never>['dependencies'];
33
33
  onEditorViewUpdated: (props: EditorStateDelta) => void;
34
34
  onEditorPluginInitialized: (plugin: NextEditorPluginInitializedType) => void;
35
35
  }
@@ -39,31 +39,12 @@ export declare class EditorPluginInjectionAPI implements PluginInjectionAPIDefin
39
39
  private commandsAPI;
40
40
  private plugins;
41
41
  constructor({ getEditorState, getEditorView }: PluginInjectionAPIProps);
42
- api<T extends NextEditorPlugin<any, any>>(): {
43
- dependencies: import("../types/next-editor-plugin").CreatePluginDependenciesAPI<[
44
- NextEditorPlugin<T extends (config?: any, api?: PluginInjectionAPI<infer Name extends string, any> | undefined) => DefaultEditorPlugin<infer Name extends string, any> ? Name : never, T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never>,
45
- ..."dependencies" extends keyof (T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never) ? (T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never)["dependencies"] extends (((config?: any, api?: PluginInjectionAPI<any, any> | undefined) => DefaultEditorPlugin<any, any>) | import("../types/next-editor-plugin").OptionalPlugin<(config?: any, api?: PluginInjectionAPI<any, any> | undefined) => DefaultEditorPlugin<any, any>>)[] ? Exclude<(T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never)["dependencies"], undefined> : [
46
- ] : [
47
- ],
48
- (config: {
49
- getEditorView: () => EditorView | undefined;
50
- }, api?: PluginInjectionAPI<"core", {
51
- pluginConfiguration: {
52
- getEditorView: () => EditorView | undefined;
53
- };
54
- actions: {
55
- execute: (command: import("../types").EditorCommand | undefined) => boolean;
56
- };
57
- }> | undefined) => DefaultEditorPlugin<"core", {
58
- pluginConfiguration: {
59
- getEditorView: () => EditorView | undefined;
60
- };
61
- actions: {
62
- execute: (command: import("../types").EditorCommand | undefined) => boolean;
63
- };
64
- }>
65
- ]>;
66
- };
42
+ api<T extends NextEditorPlugin<any, any>>(): import("../types/next-editor-plugin").PublicPluginAPI<[
43
+ NextEditorPlugin<T extends import("../types/next-editor-plugin").NextEditorPluginFunctionOptionalConfigDefinition<infer Name extends string, any, any> ? Name : never, T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never>,
44
+ ..."dependencies" extends keyof (T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never) ? (T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never)["dependencies"] extends (import("../types/next-editor-plugin").NextEditorPluginFunctionOptionalConfigDefinition<any, any, any> | import("../types/next-editor-plugin").OptionalPlugin<import("../types/next-editor-plugin").NextEditorPluginFunctionOptionalConfigDefinition<any, any, any>>)[] ? Exclude<(T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never)["dependencies"], undefined> : [
45
+ ] : [
46
+ ]
47
+ ]>;
67
48
  onEditorViewUpdated: ({ newEditorState, oldEditorState, }: EditorStateDiff) => void;
68
49
  onEditorPluginInitialized: (plugin: NextEditorPluginInitializedType) => void;
69
50
  private addPlugin;
@@ -28,7 +28,7 @@ export type { EditorReactContext } from './editor-react-context';
28
28
  export type { PMPluginFactoryParams, PMPluginFactory, PMPlugin, } from './plugin-factory';
29
29
  export type { NodeConfig, MarkConfig, NodeViewConfig, } from './prosemirror-config';
30
30
  export type { PluginsOptions, EditorPlugin, getPosHandler, getPosHandlerNode, } from './editor-plugin';
31
- export type { NextEditorPlugin, AllEditorPresetPluginTypes, PluginDependenciesAPI, ExtractPluginNameFromAllBuilderPlugins, SafePresetCheck, DefaultEditorPlugin, OptionalPlugin, PluginInjectionAPI, CreatePluginDependenciesAPI, NextEditorPluginMetadata, ExtractInjectionAPI, ExtractPluginActions, PluginInjectionAPIWithDependency, PluginInjectionAPIWithDependencies, PublicPluginAPI, } from './next-editor-plugin';
31
+ export type { NextEditorPlugin, AllEditorPresetPluginTypes, PluginDependenciesAPI, ExtractPluginNameFromAllBuilderPlugins, SafePresetCheck, DefaultEditorPlugin, OptionalPlugin, PluginInjectionAPI, CreatePluginDependenciesAPI, NextEditorPluginMetadata, ExtractInjectionAPI, ExtractPluginActions, PluginInjectionAPIWithDependency, PluginInjectionAPIWithDependencies, PublicPluginAPI, NextEditorPluginFunctionOptionalConfigDefinition, } from './next-editor-plugin';
32
32
  export type { ExtractPublicEditorAPI } from './editor-public-api';
33
33
  export type { EditorCommand, EditorCommandWithMetadata, } from './editor-command';
34
34
  export type IconProps = {
@@ -34,22 +34,32 @@ export interface NextEditorPluginMetadata {
34
34
  readonly actions?: NextEditorPluginActions;
35
35
  readonly commands?: NextEditorEditorCommands;
36
36
  }
37
- export type PluginInjectionAPI<Name extends string, Metadata extends NextEditorPluginMetadata> = PublicPluginAPI<[
38
- NextEditorPlugin<Name, Metadata>,
39
- ...ExtractPluginDependenciesFromMetadata<Metadata>
40
- ]>;
37
+ /**
38
+ * `PluginInjectionAPI` doesn't actually use `dependencies`,
39
+ * we should use it as PluginInjectionAPI< ... >['dependencies']
40
+ * it is only here because otherwise typescript blows up
41
+ * trying to compare `PluginInjectionAPI` to `PublicPluginAPI`
42
+ */
43
+ export type PluginInjectionAPI<Name extends string, Metadata extends NextEditorPluginMetadata> = {
44
+ dependencies: PublicPluginAPI<[
45
+ NextEditorPlugin<Name, Metadata>,
46
+ ...ExtractPluginDependenciesFromMetadata<Metadata>
47
+ ]>;
48
+ };
41
49
  export type PluginInjectionAPIWithDependency<Plugin extends NextEditorPlugin<any, any>> = PublicPluginAPI<[
42
50
  Plugin
43
51
  ]>;
44
52
  export type PluginInjectionAPIWithDependencies<Plugins extends NextEditorPlugin<any, any>[]> = PublicPluginAPI<Plugins>;
45
- type NextEditorPluginFunctionDefinition<Name extends string, Metadata extends NextEditorPluginMetadata, Configuration> = (config: Configuration, api?: PluginInjectionAPI<Name, Metadata>) => DefaultEditorPlugin<Name, Metadata>;
46
- type NextEditorPluginFunctionOptionalConfigDefinition<Name extends string, Metadata extends NextEditorPluginMetadata, Configuration = undefined> = (config?: Configuration, api?: PluginInjectionAPI<Name, Metadata>) => DefaultEditorPlugin<Name, Metadata>;
53
+ export type NextEditorPluginFunctionOptionalConfigDefinition<Name extends string, Metadata extends NextEditorPluginMetadata, Configuration = undefined> = (props: {
54
+ config: Configuration;
55
+ api?: PluginInjectionAPI<Name, Metadata>['dependencies'];
56
+ }) => DefaultEditorPlugin<Name, Metadata>;
47
57
  type OptionalPrivateProperty = {
48
58
  __optionalPluginType: true;
49
59
  };
50
60
  export type OptionalPlugin<EditorPlugin extends NextEditorPlugin<any, any>> = EditorPlugin & OptionalPrivateProperty;
51
61
  type DependencyPlugin = OptionalPlugin<NextEditorPlugin<any, any>> | NextEditorPlugin<any, any>;
52
- export type NextEditorPlugin<Name extends string, Metadata extends NextEditorPluginMetadata = {}> = Metadata extends NextEditorPluginMetadata ? 'pluginConfiguration' extends keyof Metadata ? undefined extends Metadata['pluginConfiguration'] ? NextEditorPluginFunctionOptionalConfigDefinition<Name, Metadata, Metadata['pluginConfiguration']> : NextEditorPluginFunctionDefinition<Name, Metadata, Metadata['pluginConfiguration']> : NextEditorPluginFunctionOptionalConfigDefinition<Name, Metadata> : never;
62
+ export type NextEditorPlugin<Name extends string, Metadata extends NextEditorPluginMetadata = {}> = Metadata extends NextEditorPluginMetadata ? 'pluginConfiguration' extends keyof Metadata ? NextEditorPluginFunctionOptionalConfigDefinition<Name, Metadata, Metadata['pluginConfiguration']> : NextEditorPluginFunctionOptionalConfigDefinition<Name, Metadata> : never;
53
63
  type FilterOptionalPlugins<T extends DependencyPlugin[]> = T extends [
54
64
  infer Head,
55
65
  ...infer Tail
@@ -66,10 +76,22 @@ type ExtractSharedStateFromMetadata<Metadata> = 'sharedState' extends keyof Meta
66
76
  type ExtractActionsFromMetadata<Metadata> = 'actions' extends keyof Metadata ? Metadata['actions'] : never;
67
77
  type ExtractCommandsFromMetadata<Metadata> = 'commands' extends keyof Metadata ? Metadata['commands'] : never;
68
78
  type ExtractPluginConfigurationFromMetadata<Metadata> = 'pluginConfiguration' extends keyof Metadata ? Metadata['pluginConfiguration'] : never;
69
- export type ExtractPluginDependencies<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (config: any, api: any) => DefaultEditorPlugin<any, infer Metadata> ? ExtractPluginDependenciesFromMetadataWithoutOptionals<Metadata> : never : never;
70
- type ExtractPluginConfiguration<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (config: any, api: any) => DefaultEditorPlugin<any, infer Metadata> ? ExtractPluginConfigurationFromMetadata<Metadata> : never : never;
71
- export type ExtractPluginSharedState<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (config: any, api: any) => DefaultEditorPlugin<any, infer Metadata> ? ExtractSharedStateFromMetadata<Metadata> : never : never;
72
- export type ExtractPluginActions<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (config: any, api: any) => DefaultEditorPlugin<any, infer Metadata> ? ExtractActionsFromMetadata<Metadata> : never : never;
79
+ export type ExtractPluginDependencies<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (props: {
80
+ config: any;
81
+ api: any;
82
+ }) => DefaultEditorPlugin<any, infer Metadata> ? ExtractPluginDependenciesFromMetadataWithoutOptionals<Metadata> : never : never;
83
+ type ExtractPluginConfiguration<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (props: {
84
+ config: any;
85
+ api: any;
86
+ }) => DefaultEditorPlugin<any, infer Metadata> ? ExtractPluginConfigurationFromMetadata<Metadata> : never : never;
87
+ export type ExtractPluginSharedState<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (props: {
88
+ config: any;
89
+ api: any;
90
+ }) => DefaultEditorPlugin<any, infer Metadata> ? ExtractSharedStateFromMetadata<Metadata> : never : never;
91
+ export type ExtractPluginActions<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (props: {
92
+ config: any;
93
+ api: any;
94
+ }) => DefaultEditorPlugin<any, infer Metadata> ? ExtractActionsFromMetadata<Metadata> : never : never;
73
95
  type ExtractPluginName<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (...args: any) => DefaultEditorPlugin<infer PluginName, any> ? PluginName : never : never;
74
96
  type Unsubscribe = () => void;
75
97
  export type PluginDependenciesAPI<Plugin extends NextEditorPlugin<any, any>> = {
@@ -121,13 +143,11 @@ export type ExtractPluginNameFromAllBuilderPlugins<Plugin extends AllEditorPrese
121
143
  infer MaybePlugin,
122
144
  ...any
123
145
  ] ? MaybePlugin extends NextEditorPlugin<any, any> ? ExtractPluginName<MaybePlugin> : never : never : Plugin extends NextEditorPlugin<any, any> ? ExtractPluginName<Plugin> : never;
124
- export type ExtractInjectionAPI<Plugin> = Plugin extends NextEditorPlugin<infer Name, infer Metadata> ? PluginInjectionAPI<Name, Metadata> : never;
125
- export type PublicPluginAPI<PluginList extends NextEditorPlugin<any, any>[]> = {
126
- dependencies: CreatePluginDependenciesAPI<[
127
- ...PluginList,
128
- CorePlugin
129
- ]>;
130
- };
146
+ export type ExtractInjectionAPI<Plugin> = Plugin extends NextEditorPlugin<infer Name, infer Metadata> ? PluginInjectionAPI<Name, Metadata>['dependencies'] : never;
147
+ export type PublicPluginAPI<PluginList extends NextEditorPlugin<any, any>[]> = CreatePluginDependenciesAPI<[
148
+ ...PluginList,
149
+ CorePlugin
150
+ ]>;
131
151
  export type ExtractNextEditorPlugins<Plugins extends AllEditorPresetPluginTypes[]> = {
132
152
  [PluginNumber in keyof Plugins]: Plugins[PluginNumber] extends NextEditorPlugin<infer Name, infer Metadata> ? NextEditorPlugin<Name, Metadata> : Plugins[PluginNumber] extends [
133
153
  NextEditorPlugin<infer Name, infer Metadata>,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.52.2",
3
+ "version": "74.53.0",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -112,7 +112,7 @@
112
112
  "@atlaskit/spinner": "^15.5.0",
113
113
  "@atlaskit/task-decision": "^17.7.0",
114
114
  "@atlaskit/theme": "^12.5.0",
115
- "@atlaskit/tokens": "^1.16.0",
115
+ "@atlaskit/tokens": "^1.17.0",
116
116
  "@atlaskit/tooltip": "^17.8.0",
117
117
  "@atlaskit/ufo": "^0.2.0",
118
118
  "@atlaskit/width-detector": "^4.1.0",