@atlaskit/editor-plugin-synced-block 4.4.1 → 4.5.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/editor-plugin-synced-block
2
2
 
3
+ ## 4.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`4daaa6358e6fb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4daaa6358e6fb) -
8
+ Update resourceId generation for create reference from browser copy + pasting source block
9
+
10
+ ### Patch Changes
11
+
12
+ - [`dcc6a3e73f414`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/dcc6a3e73f414) -
13
+ [ux] EDITOR-3304 add offline error state for sync blocks and update other error UI to match new
14
+ designs
15
+ - Updated dependencies
16
+
3
17
  ## 4.4.1
4
18
 
5
19
  ### Patch Changes
@@ -67,7 +67,8 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
67
67
  useFetchSyncBlockData: function useFetchSyncBlockData() {
68
68
  var _this2$api;
69
69
  return (0, _editorSyncedBlockProvider.useFetchSyncBlockData)(syncBlockStore, resourceId, localId, (_this2$api = _this2.api) === null || _this2$api === void 0 || (_this2$api = _this2$api.analytics) === null || _this2$api === void 0 || (_this2$api = _this2$api.actions) === null || _this2$api === void 0 ? void 0 : _this2$api.fireAnalyticsEvent);
70
- }
70
+ },
71
+ api: this.api
71
72
  });
72
73
  }
73
74
  }, {
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.syncedBlockPluginKey = exports.createPlugin = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
7
9
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
8
10
  var _selection = require("@atlaskit/editor-common/selection");
9
11
  var _syncBlock = require("@atlaskit/editor-common/sync-block");
@@ -21,6 +23,8 @@ var _trackSyncBlocks4 = require("./utils/track-sync-blocks");
21
23
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
22
24
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
23
25
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
26
+ 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; }
27
+ 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; }
24
28
  var syncedBlockPluginKey = exports.syncedBlockPluginKey = new _state.PluginKey('syncedBlockPlugin');
25
29
  var createPlugin = exports.createPlugin = function createPlugin(options, pmPluginFactoryParams, syncBlockStore, api) {
26
30
  var _ref = options || {},
@@ -108,6 +112,36 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
108
112
  mousedown: function mousedown(view, event) {
109
113
  return (0, _ignoreDomEvent.shouldIgnoreDomEvent)(view, event, api);
110
114
  }
115
+ },
116
+ transformCopied: function transformCopied(slice, _ref2) {
117
+ var state = _ref2.state;
118
+ var pluginState = syncedBlockPluginKey.getState(state);
119
+ var syncBlockStore = pluginState === null || pluginState === void 0 ? void 0 : pluginState.syncBlockStore;
120
+ var schema = state.schema;
121
+ if (!syncBlockStore) {
122
+ return slice;
123
+ }
124
+ return (0, _utils.mapSlice)(slice, function (node) {
125
+ if (node.type.name === 'bodiedSyncBlock' && node.attrs.resourceId) {
126
+ try {
127
+ var newResourceId = syncBlockStore.referenceManager.generateResourceIdForReference(node.attrs.resourceId);
128
+ // Convert bodiedSyncBlock to syncBlock
129
+ // The paste transformation will regenrate the localId
130
+ var newAttrs = _objectSpread(_objectSpread({}, node.attrs), {}, {
131
+ resourceId: newResourceId
132
+ });
133
+ var newMarks = schema.nodes.syncBlock.markSet ? node.marks.filter(function (mark) {
134
+ var _schema$nodes$syncBlo;
135
+ return (_schema$nodes$syncBlo = schema.nodes.syncBlock.markSet) === null || _schema$nodes$syncBlo === void 0 ? void 0 : _schema$nodes$syncBlo.includes(mark.type);
136
+ }) : node.marks;
137
+ return schema.nodes.syncBlock.create(newAttrs, null, newMarks);
138
+ } catch (error) {
139
+ // If generateResourceIdForReference died, return the original node
140
+ return node;
141
+ }
142
+ }
143
+ return node;
144
+ });
111
145
  }
112
146
  },
113
147
  filterTransaction: function filterTransaction(tr, state) {
@@ -168,8 +202,8 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
168
202
  if (errorFlag) {
169
203
  // Use setTimeout to dispatch transaction in next tick and avoid re-entrant dispatch
170
204
  setTimeout(function () {
171
- api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
172
- var tr = _ref2.tr;
205
+ api === null || api === void 0 || api.core.actions.execute(function (_ref3) {
206
+ var tr = _ref3.tr;
173
207
  return tr.setMeta(syncedBlockPluginKey, {
174
208
  activeFlag: {
175
209
  id: errorFlag
@@ -13,14 +13,16 @@ var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperCompone
13
13
  var syncedBlockRenderer = _ref.syncedBlockRenderer,
14
14
  useFetchSyncBlockData = _ref.useFetchSyncBlockData,
15
15
  localId = _ref.localId,
16
- useFetchSyncBlockTitle = _ref.useFetchSyncBlockTitle;
16
+ useFetchSyncBlockTitle = _ref.useFetchSyncBlockTitle,
17
+ api = _ref.api;
17
18
  return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
18
19
  "data-testid": SyncBlockRendererWrapperDataId
19
20
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
20
21
  ,
21
22
  className: _syncBlock.SyncBlockSharedCssClassName.renderer
22
23
  }, syncedBlockRenderer({
23
- useFetchSyncBlockData: useFetchSyncBlockData
24
+ useFetchSyncBlockData: useFetchSyncBlockData,
25
+ api: api
24
26
  })), /*#__PURE__*/_react.default.createElement(_SyncBlockLabel.SyncBlockLabel, {
25
27
  isSource: false,
26
28
  useFetchSyncBlockTitle: useFetchSyncBlockTitle,
@@ -39,7 +39,8 @@ class SyncBlock extends ReactNodeView {
39
39
  useFetchSyncBlockData: () => {
40
40
  var _this$api2, _this$api2$analytics, _this$api2$analytics$;
41
41
  return useFetchSyncBlockData(syncBlockStore, resourceId, localId, (_this$api2 = this.api) === null || _this$api2 === void 0 ? void 0 : (_this$api2$analytics = _this$api2.analytics) === null || _this$api2$analytics === void 0 ? void 0 : (_this$api2$analytics$ = _this$api2$analytics.actions) === null || _this$api2$analytics$ === void 0 ? void 0 : _this$api2$analytics$.fireAnalyticsEvent);
42
- }
42
+ },
43
+ api: this.api
43
44
  });
44
45
  }
45
46
  destroy() {
@@ -1,7 +1,7 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
3
3
  import { BodiedSyncBlockSharedCssClassName, SyncBlockStateCssClassName } from '@atlaskit/editor-common/sync-block';
4
- import { pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
4
+ import { mapSlice, pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
5
5
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
6
  import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
7
7
  import { convertPMNodesToSyncBlockNodes, rebaseTransaction } from '@atlaskit/editor-synced-block-provider';
@@ -99,6 +99,40 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
99
99
  mousedown(view, event) {
100
100
  return shouldIgnoreDomEvent(view, event, api);
101
101
  }
102
+ },
103
+ transformCopied: (slice, {
104
+ state
105
+ }) => {
106
+ const pluginState = syncedBlockPluginKey.getState(state);
107
+ const syncBlockStore = pluginState === null || pluginState === void 0 ? void 0 : pluginState.syncBlockStore;
108
+ const {
109
+ schema
110
+ } = state;
111
+ if (!syncBlockStore) {
112
+ return slice;
113
+ }
114
+ return mapSlice(slice, node => {
115
+ if (node.type.name === 'bodiedSyncBlock' && node.attrs.resourceId) {
116
+ try {
117
+ const newResourceId = syncBlockStore.referenceManager.generateResourceIdForReference(node.attrs.resourceId);
118
+ // Convert bodiedSyncBlock to syncBlock
119
+ // The paste transformation will regenrate the localId
120
+ const newAttrs = {
121
+ ...node.attrs,
122
+ resourceId: newResourceId
123
+ };
124
+ const newMarks = schema.nodes.syncBlock.markSet ? node.marks.filter(mark => {
125
+ var _schema$nodes$syncBlo;
126
+ return (_schema$nodes$syncBlo = schema.nodes.syncBlock.markSet) === null || _schema$nodes$syncBlo === void 0 ? void 0 : _schema$nodes$syncBlo.includes(mark.type);
127
+ }) : node.marks;
128
+ return schema.nodes.syncBlock.create(newAttrs, null, newMarks);
129
+ } catch (error) {
130
+ // If generateResourceIdForReference died, return the original node
131
+ return node;
132
+ }
133
+ }
134
+ return node;
135
+ });
102
136
  }
103
137
  },
104
138
  filterTransaction: (tr, state) => {
@@ -6,7 +6,8 @@ const SyncBlockRendererWrapperComponent = ({
6
6
  syncedBlockRenderer,
7
7
  useFetchSyncBlockData,
8
8
  localId,
9
- useFetchSyncBlockTitle
9
+ useFetchSyncBlockTitle,
10
+ api
10
11
  }) => {
11
12
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
12
13
  "data-testid": SyncBlockRendererWrapperDataId
@@ -14,7 +15,8 @@ const SyncBlockRendererWrapperComponent = ({
14
15
  ,
15
16
  className: SyncBlockSharedCssClassName.renderer
16
17
  }, syncedBlockRenderer({
17
- useFetchSyncBlockData
18
+ useFetchSyncBlockData,
19
+ api
18
20
  })), /*#__PURE__*/React.createElement(SyncBlockLabel, {
19
21
  isSource: false,
20
22
  useFetchSyncBlockTitle: useFetchSyncBlockTitle,
@@ -60,7 +60,8 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
60
60
  useFetchSyncBlockData: function useFetchSyncBlockData() {
61
61
  var _this2$api;
62
62
  return _useFetchSyncBlockData(syncBlockStore, resourceId, localId, (_this2$api = _this2.api) === null || _this2$api === void 0 || (_this2$api = _this2$api.analytics) === null || _this2$api === void 0 || (_this2$api = _this2$api.actions) === null || _this2$api === void 0 ? void 0 : _this2$api.fireAnalyticsEvent);
63
- }
63
+ },
64
+ api: this.api
64
65
  });
65
66
  }
66
67
  }, {
@@ -1,10 +1,13 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
2
3
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
3
4
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
+ 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; }
6
+ 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) { _defineProperty(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; }
4
7
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
8
  import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
6
9
  import { BodiedSyncBlockSharedCssClassName, SyncBlockStateCssClassName } from '@atlaskit/editor-common/sync-block';
7
- import { pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
10
+ import { mapSlice, pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
8
11
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
9
12
  import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
10
13
  import { convertPMNodesToSyncBlockNodes, rebaseTransaction } from '@atlaskit/editor-synced-block-provider';
@@ -102,6 +105,36 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
102
105
  mousedown: function mousedown(view, event) {
103
106
  return shouldIgnoreDomEvent(view, event, api);
104
107
  }
108
+ },
109
+ transformCopied: function transformCopied(slice, _ref2) {
110
+ var state = _ref2.state;
111
+ var pluginState = syncedBlockPluginKey.getState(state);
112
+ var syncBlockStore = pluginState === null || pluginState === void 0 ? void 0 : pluginState.syncBlockStore;
113
+ var schema = state.schema;
114
+ if (!syncBlockStore) {
115
+ return slice;
116
+ }
117
+ return mapSlice(slice, function (node) {
118
+ if (node.type.name === 'bodiedSyncBlock' && node.attrs.resourceId) {
119
+ try {
120
+ var newResourceId = syncBlockStore.referenceManager.generateResourceIdForReference(node.attrs.resourceId);
121
+ // Convert bodiedSyncBlock to syncBlock
122
+ // The paste transformation will regenrate the localId
123
+ var newAttrs = _objectSpread(_objectSpread({}, node.attrs), {}, {
124
+ resourceId: newResourceId
125
+ });
126
+ var newMarks = schema.nodes.syncBlock.markSet ? node.marks.filter(function (mark) {
127
+ var _schema$nodes$syncBlo;
128
+ return (_schema$nodes$syncBlo = schema.nodes.syncBlock.markSet) === null || _schema$nodes$syncBlo === void 0 ? void 0 : _schema$nodes$syncBlo.includes(mark.type);
129
+ }) : node.marks;
130
+ return schema.nodes.syncBlock.create(newAttrs, null, newMarks);
131
+ } catch (error) {
132
+ // If generateResourceIdForReference died, return the original node
133
+ return node;
134
+ }
135
+ }
136
+ return node;
137
+ });
105
138
  }
106
139
  },
107
140
  filterTransaction: function filterTransaction(tr, state) {
@@ -162,8 +195,8 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
162
195
  if (errorFlag) {
163
196
  // Use setTimeout to dispatch transaction in next tick and avoid re-entrant dispatch
164
197
  setTimeout(function () {
165
- api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
166
- var tr = _ref2.tr;
198
+ api === null || api === void 0 || api.core.actions.execute(function (_ref3) {
199
+ var tr = _ref3.tr;
167
200
  return tr.setMeta(syncedBlockPluginKey, {
168
201
  activeFlag: {
169
202
  id: errorFlag
@@ -6,14 +6,16 @@ var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperCompone
6
6
  var syncedBlockRenderer = _ref.syncedBlockRenderer,
7
7
  useFetchSyncBlockData = _ref.useFetchSyncBlockData,
8
8
  localId = _ref.localId,
9
- useFetchSyncBlockTitle = _ref.useFetchSyncBlockTitle;
9
+ useFetchSyncBlockTitle = _ref.useFetchSyncBlockTitle,
10
+ api = _ref.api;
10
11
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
11
12
  "data-testid": SyncBlockRendererWrapperDataId
12
13
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
13
14
  ,
14
15
  className: SyncBlockSharedCssClassName.renderer
15
16
  }, syncedBlockRenderer({
16
- useFetchSyncBlockData: useFetchSyncBlockData
17
+ useFetchSyncBlockData: useFetchSyncBlockData,
18
+ api: api
17
19
  })), /*#__PURE__*/React.createElement(SyncBlockLabel, {
18
20
  isSource: false,
19
21
  useFetchSyncBlockTitle: useFetchSyncBlockTitle,
@@ -1,5 +1,5 @@
1
1
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
2
- import type { EditorCommand, LongPressSelectionPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
+ import type { EditorCommand, ExtractInjectionAPI, LongPressSelectionPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
3
3
  import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
4
4
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
5
5
  import type { BlockControlsPlugin } from '@atlaskit/editor-plugin-block-controls';
@@ -36,6 +36,7 @@ export type SyncedBlockEditorProps = {
36
36
  popupsMountPoint: HTMLElement;
37
37
  };
38
38
  export type SyncedBlockRendererProps = {
39
+ api?: ExtractInjectionAPI<SyncedBlockPlugin>;
39
40
  useFetchSyncBlockData: () => UseFetchSyncBlockDataResult;
40
41
  };
41
42
  export interface SyncedBlockPluginOptions extends LongPressSelectionPluginOptions {
@@ -1,11 +1,13 @@
1
1
  import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
3
  import type { UseFetchSyncBlockDataResult } from '@atlaskit/editor-synced-block-provider';
3
- import type { SyncedBlockRendererProps } from '../syncedBlockPluginType';
4
+ import type { SyncedBlockPlugin, SyncedBlockRendererProps } from '../syncedBlockPluginType';
4
5
  type Props = {
5
- syncedBlockRenderer: (props: SyncedBlockRendererProps) => React.JSX.Element;
6
+ api?: ExtractInjectionAPI<SyncedBlockPlugin>;
6
7
  localId: string;
8
+ syncedBlockRenderer: (props: SyncedBlockRendererProps) => React.JSX.Element;
7
9
  useFetchSyncBlockData: () => UseFetchSyncBlockDataResult;
8
10
  useFetchSyncBlockTitle: () => string | undefined;
9
11
  };
10
- export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ syncedBlockRenderer, useFetchSyncBlockData, localId, useFetchSyncBlockTitle, }: Props) => React.JSX.Element>;
12
+ export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ syncedBlockRenderer, useFetchSyncBlockData, localId, useFetchSyncBlockTitle, api, }: Props) => React.JSX.Element>;
11
13
  export {};
@@ -1,5 +1,5 @@
1
1
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
2
- import type { EditorCommand, LongPressSelectionPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
+ import type { EditorCommand, ExtractInjectionAPI, LongPressSelectionPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
3
3
  import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
4
4
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
5
5
  import type { BlockControlsPlugin } from '@atlaskit/editor-plugin-block-controls';
@@ -36,6 +36,7 @@ export type SyncedBlockEditorProps = {
36
36
  popupsMountPoint: HTMLElement;
37
37
  };
38
38
  export type SyncedBlockRendererProps = {
39
+ api?: ExtractInjectionAPI<SyncedBlockPlugin>;
39
40
  useFetchSyncBlockData: () => UseFetchSyncBlockDataResult;
40
41
  };
41
42
  export interface SyncedBlockPluginOptions extends LongPressSelectionPluginOptions {
@@ -1,11 +1,13 @@
1
1
  import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
3
  import type { UseFetchSyncBlockDataResult } from '@atlaskit/editor-synced-block-provider';
3
- import type { SyncedBlockRendererProps } from '../syncedBlockPluginType';
4
+ import type { SyncedBlockPlugin, SyncedBlockRendererProps } from '../syncedBlockPluginType';
4
5
  type Props = {
5
- syncedBlockRenderer: (props: SyncedBlockRendererProps) => React.JSX.Element;
6
+ api?: ExtractInjectionAPI<SyncedBlockPlugin>;
6
7
  localId: string;
8
+ syncedBlockRenderer: (props: SyncedBlockRendererProps) => React.JSX.Element;
7
9
  useFetchSyncBlockData: () => UseFetchSyncBlockDataResult;
8
10
  useFetchSyncBlockTitle: () => string | undefined;
9
11
  };
10
- export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ syncedBlockRenderer, useFetchSyncBlockData, localId, useFetchSyncBlockTitle, }: Props) => React.JSX.Element>;
12
+ export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ syncedBlockRenderer, useFetchSyncBlockData, localId, useFetchSyncBlockTitle, api, }: Props) => React.JSX.Element>;
11
13
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-synced-block",
3
- "version": "4.4.1",
3
+ "version": "4.5.0",
4
4
  "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -39,7 +39,7 @@
39
39
  "@atlaskit/editor-plugin-selection": "^6.1.0",
40
40
  "@atlaskit/editor-prosemirror": "7.0.0",
41
41
  "@atlaskit/editor-shared-styles": "^3.10.0",
42
- "@atlaskit/editor-synced-block-provider": "^2.14.0",
42
+ "@atlaskit/editor-synced-block-provider": "^2.15.0",
43
43
  "@atlaskit/editor-tables": "^2.9.0",
44
44
  "@atlaskit/editor-toolbar": "^0.18.0",
45
45
  "@atlaskit/flag": "^17.6.0",