@atlaskit/editor-synced-block-provider 0.4.0 → 0.5.1

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-synced-block-provider
2
2
 
3
+ ## 0.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1256b3dd0431e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1256b3dd0431e) -
8
+ Fix isSource check in provider
9
+
10
+ ## 0.5.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [`3ebbf8e97e2d9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3ebbf8e97e2d9) -
15
+ Simplify provider API
16
+
3
17
  ## 0.4.0
4
18
 
5
19
  ### Minor Changes
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.useMemoizedSyncedBlockProvider = exports.useFetchDocNode = exports.SyncBlockProvider = void 0;
7
+ exports.useMemoizedSyncedBlockProvider = exports.useHandleContentChanges = exports.useFetchDocNode = exports.SyncBlockProvider = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
@@ -50,7 +50,7 @@ var SyncBlockProvider = exports.SyncBlockProvider = /*#__PURE__*/function (_Sync
50
50
  resourceIds.push(Promise.reject('No Synced Blockcontent to write'));
51
51
  return;
52
52
  }
53
- var resourceId = _this.writeProvider.writeData(_this.sourceId, node.attrs.localId, data[index].content, node.attrs.resourceId);
53
+ var resourceId = _this.writeProvider.writeData(data[index]);
54
54
  resourceIds.push(resourceId);
55
55
  });
56
56
  return Promise.all(resourceIds);
@@ -101,4 +101,21 @@ var useMemoizedSyncedBlockProvider = exports.useMemoizedSyncedBlockProvider = fu
101
101
  return (0, _react.useMemo)(function () {
102
102
  return new SyncBlockProvider(fetchProvider, writeProvider, sourceId);
103
103
  }, [fetchProvider, writeProvider, sourceId]);
104
+ };
105
+ var useHandleContentChanges = exports.useHandleContentChanges = function useHandleContentChanges(updatedDoc, isSource, node, provider) {
106
+ (0, _react.useEffect)(function () {
107
+ if (!isSource) {
108
+ return;
109
+ }
110
+ if (!provider) {
111
+ return;
112
+ }
113
+ var syncBlockNode = (0, _utils.convertSyncBlockPMNodeToSyncBlockData)(node, false);
114
+ var data = {
115
+ content: updatedDoc.toJSON(),
116
+ resourceId: node.attrs.resourceId,
117
+ localId: node.attrs.localId
118
+ };
119
+ provider === null || provider === void 0 || provider.writeNodesData([syncBlockNode], [data]);
120
+ }, [isSource, node, provider, updatedDoc]);
104
121
  };
@@ -10,6 +10,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
10
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
11
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
12
  var _uuid = _interopRequireDefault(require("uuid"));
13
+ var _ari = require("../utils/ari");
13
14
  var _rebaseTransaction2 = require("./rebase-transaction");
14
15
  // Do this typedef to make it clear that
15
16
  // this is a local identifier for a resource for local use
@@ -32,13 +33,18 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
32
33
  }, {
33
34
  key: "isSourceBlock",
34
35
  value: function isSourceBlock(node) {
36
+ var _this$dataProvider;
35
37
  if (node.type.name !== 'syncBlock') {
36
38
  return false;
37
39
  }
38
40
  var _node$attrs = node.attrs,
39
41
  resourceId = _node$attrs.resourceId,
40
42
  localId = _node$attrs.localId;
41
- return resourceId.includes(localId);
43
+ var sourceId = (_this$dataProvider = this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.getSourceId();
44
+ if (!sourceId) {
45
+ return false;
46
+ }
47
+ return typeof resourceId === 'string' && typeof sourceId === 'string' && typeof localId === 'string' && resourceId === (0, _ari.resourceIdFromSourceAndLocalId)(sourceId, localId);
42
48
  }
43
49
  }, {
44
50
  key: "registerConfirmationCallback",
@@ -57,15 +63,10 @@ var SyncBlockStoreManager = exports.SyncBlockStoreManager = /*#__PURE__*/functio
57
63
  }, {
58
64
  key: "createSyncBlockNode",
59
65
  value: function createSyncBlockNode() {
60
- var _this$dataProvider;
61
- // TODO: EDITOR-1644 - properly implement creation of the synced block
62
- // below is a temporary implementation for the creation of the synced block
63
- // the resource id needs to have pageId and content property key in it
64
- // Note: If the data provider is not set, the resource id will be the local id
65
-
66
+ var _this$dataProvider2;
66
67
  var localId = (0, _uuid.default)();
67
- var sourceId = (_this$dataProvider = this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.getSourceId();
68
- var resourceId = sourceId ? "".concat(sourceId, "/").concat(localId) : localId;
68
+ var sourceId = (_this$dataProvider2 = this.dataProvider) === null || _this$dataProvider2 === void 0 ? void 0 : _this$dataProvider2.getSourceId();
69
+ var resourceId = sourceId ? (0, _ari.resourceIdFromSourceAndLocalId)(sourceId, localId) : localId;
69
70
  var syncBlockNode = {
70
71
  attrs: {
71
72
  resourceId: resourceId,
package/dist/cjs/index.js CHANGED
@@ -69,6 +69,12 @@ Object.defineProperty(exports, "useFetchDocNode", {
69
69
  return _syncBlockProvider.useFetchDocNode;
70
70
  }
71
71
  });
72
+ Object.defineProperty(exports, "useHandleContentChanges", {
73
+ enumerable: true,
74
+ get: function get() {
75
+ return _syncBlockProvider.useHandleContentChanges;
76
+ }
77
+ });
72
78
  Object.defineProperty(exports, "useMemoizedContentAPIProviders", {
73
79
  enumerable: true,
74
80
  get: function get() {
@@ -47,11 +47,11 @@ var ConfluenceADFFetchProvider = /*#__PURE__*/function () {
47
47
  key: "fetchData",
48
48
  value: function () {
49
49
  var _fetchData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(resourceId) {
50
- var _contentProperty$data, pageId, localId, key, options, contentProperty, value, syncedBlockData;
50
+ var _contentProperty$data;
51
+ var pageId, localId, key, options, contentProperty, value, syncedBlockData;
51
52
  return _regenerator.default.wrap(function _callee$(_context) {
52
53
  while (1) switch (_context.prev = _context.next) {
53
54
  case 0:
54
- _context.prev = 0;
55
55
  pageId = (0, _ari.getPageIdFromAri)(resourceId);
56
56
  localId = (0, _ari.getLocalIdFromAri)(resourceId);
57
57
  key = getContentPropertyKey(this.config.contentPropertyKey, localId);
@@ -60,35 +60,29 @@ var ConfluenceADFFetchProvider = /*#__PURE__*/function () {
60
60
  key: key,
61
61
  cloudId: this.config.cloudId
62
62
  };
63
- _context.next = 7;
63
+ _context.next = 6;
64
64
  return (0, _contentProperty.getContentProperty)(options);
65
- case 7:
65
+ case 6:
66
66
  contentProperty = _context.sent;
67
67
  value = (_contentProperty$data = contentProperty.data.confluence.page.properties) === null || _contentProperty$data === void 0 || (_contentProperty$data = _contentProperty$data[0]) === null || _contentProperty$data === void 0 ? void 0 : _contentProperty$data.value;
68
68
  if (value) {
69
- _context.next = 11;
69
+ _context.next = 10;
70
70
  break;
71
71
  }
72
72
  throw new Error('Content property value does not exist');
73
- case 11:
73
+ case 10:
74
74
  // Parse the synced block content from the property value
75
75
  syncedBlockData = parseSyncedBlockContentPropertyValue(value);
76
76
  return _context.abrupt("return", {
77
- content: syncedBlockData.content
78
- });
79
- case 15:
80
- _context.prev = 15;
81
- _context.t0 = _context["catch"](0);
82
- // eslint-disable-next-line no-console
83
- console.error('Failed to fetch synced block data:', _context.t0);
84
- return _context.abrupt("return", {
85
- content: undefined
77
+ content: syncedBlockData.content,
78
+ resourceId: resourceId,
79
+ localId: localId
86
80
  });
87
- case 19:
81
+ case 12:
88
82
  case "end":
89
83
  return _context.stop();
90
84
  }
91
- }, _callee, this, [[0, 15]]);
85
+ }, _callee, this);
92
86
  }));
93
87
  function fetchData(_x) {
94
88
  return _fetchData.apply(this, arguments);
@@ -142,68 +136,64 @@ var ConfluenceADFWriteProvider = /*#__PURE__*/function () {
142
136
  return (0, _createClass2.default)(ConfluenceADFWriteProvider, [{
143
137
  key: "writeData",
144
138
  value: function () {
145
- var _writeData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(sourceId, localId, data, resourceId) {
146
- var pageId, syncedBlockValue, _contentProperty$data3, _localId, key, contentProperty, _key;
139
+ var _writeData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(data) {
140
+ var pageId, syncedBlockValue, _contentProperty$data3, localId, key, contentProperty, _key;
147
141
  return _regenerator.default.wrap(function _callee3$(_context3) {
148
142
  while (1) switch (_context3.prev = _context3.next) {
149
143
  case 0:
150
- _context3.prev = 0;
151
- pageId = (0, _ari.getPageIdFromAri)(sourceId);
144
+ pageId = (0, _ari.getPageIdFromAri)(data.resourceId);
145
+ if (!(data.sourceDocumentAri && data.resourceId !== (0, _ari.resourceIdFromSourceAndLocalId)(data.sourceDocumentAri, data.localId))) {
146
+ _context3.next = 3;
147
+ break;
148
+ }
149
+ return _context3.abrupt("return", Promise.reject('Resource ARI differs from source document ARI'));
150
+ case 3:
152
151
  syncedBlockValue = JSON.stringify({
153
- content: data
152
+ content: data.content
154
153
  });
155
- if (!resourceId) {
156
- _context3.next = 20;
154
+ if (!data.resourceId) {
155
+ _context3.next = 21;
157
156
  break;
158
157
  }
159
158
  // Update existing content property
160
- _localId = (0, _ari.getLocalIdFromAri)(resourceId);
161
- key = getContentPropertyKey(this.config.contentPropertyKey, _localId);
162
- _context3.next = 8;
159
+ localId = (0, _ari.getLocalIdFromAri)(data.resourceId);
160
+ key = getContentPropertyKey(this.config.contentPropertyKey, localId);
161
+ _context3.next = 9;
163
162
  return (0, _contentProperty.updateContentProperty)({
164
163
  pageId: pageId,
165
164
  key: key,
166
165
  value: syncedBlockValue,
167
166
  cloudId: this.config.cloudId
168
167
  });
169
- case 8:
168
+ case 9:
170
169
  contentProperty = _context3.sent;
171
170
  if (!(((_contentProperty$data3 = contentProperty.data.confluence.updateValuePageProperty.pageProperty) === null || _contentProperty$data3 === void 0 ? void 0 : _contentProperty$data3.key) === key)) {
172
- _context3.next = 13;
171
+ _context3.next = 14;
173
172
  break;
174
173
  }
175
174
  return _context3.abrupt("return", key);
176
- case 13:
175
+ case 14:
177
176
  if (!(contentProperty.data.confluence.updateValuePageProperty.pageProperty === null)) {
178
- _context3.next = 17;
177
+ _context3.next = 18;
179
178
  break;
180
179
  }
181
180
  return _context3.abrupt("return", this.createNewContentProperty(pageId, key, syncedBlockValue));
182
- case 17:
183
- throw new Error('Failed to update content property');
184
181
  case 18:
185
- _context3.next = 22;
182
+ throw new Error('Failed to update content property');
183
+ case 19:
184
+ _context3.next = 23;
186
185
  break;
187
- case 20:
186
+ case 21:
188
187
  // Create new content property
189
- _key = getContentPropertyKey(this.config.contentPropertyKey, localId);
188
+ _key = getContentPropertyKey(this.config.contentPropertyKey, data.localId);
190
189
  return _context3.abrupt("return", this.createNewContentProperty(pageId, _key, syncedBlockValue));
191
- case 22:
192
- _context3.next = 28;
193
- break;
194
- case 24:
195
- _context3.prev = 24;
196
- _context3.t0 = _context3["catch"](0);
197
- // eslint-disable-next-line no-console
198
- console.error('Failed to write synced block data:', _context3.t0);
199
- return _context3.abrupt("return", Promise.reject(_context3.t0));
200
- case 28:
190
+ case 23:
201
191
  case "end":
202
192
  return _context3.stop();
203
193
  }
204
- }, _callee3, this, [[0, 24]]);
194
+ }, _callee3, this);
205
195
  }));
206
- function writeData(_x5, _x6, _x7, _x8) {
196
+ function writeData(_x5) {
207
197
  return _writeData.apply(this, arguments);
208
198
  }
209
199
  return writeData;
@@ -7,16 +7,18 @@ exports.inMemoryWriteProvider = exports.inMemoryFetchProvider = void 0;
7
7
  var inMemStore = new Map();
8
8
  var inMemoryFetchProvider = exports.inMemoryFetchProvider = {
9
9
  fetchData: function fetchData(resourceId) {
10
- return Promise.resolve({
11
- content: inMemStore.get(resourceId)
12
- });
10
+ var data = inMemStore.get(resourceId);
11
+ if (!data) {
12
+ return Promise.reject(new Error('Data not found'));
13
+ }
14
+ return Promise.resolve(data);
13
15
  }
14
16
  };
15
17
  var inMemoryWriteProvider = exports.inMemoryWriteProvider = {
16
- writeData: function writeData(_sourceId, _localId, data, resourceId) {
17
- if (resourceId) {
18
- inMemStore.set(resourceId, data);
19
- return Promise.resolve(resourceId);
18
+ writeData: function writeData(data) {
19
+ if (data.resourceId) {
20
+ inMemStore.set(data.resourceId, data);
21
+ return Promise.resolve(data.resourceId);
20
22
  } else {
21
23
  var uuid = crypto.randomUUID();
22
24
  inMemStore.set(uuid, data);
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getPageIdFromAri = exports.getLocalIdFromAri = exports.getContentPropertyIdFromAri = exports.getContentPropertyAri = exports.getConfluencePageAri = void 0;
6
+ exports.resourceIdFromSourceAndLocalId = exports.getPageIdFromAri = exports.getLocalIdFromAri = exports.getContentPropertyIdFromAri = exports.getContentPropertyAri = exports.getConfluencePageAri = void 0;
7
7
  var getConfluencePageAri = exports.getConfluencePageAri = function getConfluencePageAri(pageId, cloudId) {
8
8
  return "ari:cloud:confluence:".concat(cloudId, ":page/").concat(pageId);
9
9
  };
@@ -39,4 +39,7 @@ var getContentPropertyIdFromAri = exports.getContentPropertyIdFromAri = function
39
39
  return match[1];
40
40
  }
41
41
  throw new Error("Invalid content property ARI: ".concat(ari));
42
+ };
43
+ var resourceIdFromSourceAndLocalId = exports.resourceIdFromSourceAndLocalId = function resourceIdFromSourceAndLocalId(sourceId, localId) {
44
+ return sourceId + '/' + localId;
42
45
  };
@@ -27,7 +27,7 @@ export class SyncBlockProvider extends SyncBlockDataProvider {
27
27
  resourceIds.push(Promise.reject('No Synced Blockcontent to write'));
28
28
  return;
29
29
  }
30
- const resourceId = this.writeProvider.writeData(this.sourceId, node.attrs.localId, data[index].content, node.attrs.resourceId);
30
+ const resourceId = this.writeProvider.writeData(data[index]);
31
31
  resourceIds.push(resourceId);
32
32
  });
33
33
  return Promise.all(resourceIds);
@@ -73,4 +73,21 @@ export const useMemoizedSyncedBlockProvider = (fetchProvider, writeProvider, sou
73
73
  return useMemo(() => {
74
74
  return new SyncBlockProvider(fetchProvider, writeProvider, sourceId);
75
75
  }, [fetchProvider, writeProvider, sourceId]);
76
+ };
77
+ export const useHandleContentChanges = (updatedDoc, isSource, node, provider) => {
78
+ useEffect(() => {
79
+ if (!isSource) {
80
+ return;
81
+ }
82
+ if (!provider) {
83
+ return;
84
+ }
85
+ const syncBlockNode = convertSyncBlockPMNodeToSyncBlockData(node, false);
86
+ const data = {
87
+ content: updatedDoc.toJSON(),
88
+ resourceId: node.attrs.resourceId,
89
+ localId: node.attrs.localId
90
+ };
91
+ provider === null || provider === void 0 ? void 0 : provider.writeNodesData([syncBlockNode], [data]);
92
+ }, [isSource, node, provider, updatedDoc]);
76
93
  };
@@ -1,4 +1,5 @@
1
1
  import uuid from 'uuid';
2
+ import { resourceIdFromSourceAndLocalId } from '../utils/ari';
2
3
  import { rebaseTransaction } from './rebase-transaction';
3
4
 
4
5
  // Do this typedef to make it clear that
@@ -18,6 +19,7 @@ export class SyncBlockStoreManager {
18
19
  this.editorView = editorView;
19
20
  }
20
21
  isSourceBlock(node) {
22
+ var _this$dataProvider;
21
23
  if (node.type.name !== 'syncBlock') {
22
24
  return false;
23
25
  }
@@ -25,7 +27,11 @@ export class SyncBlockStoreManager {
25
27
  resourceId,
26
28
  localId
27
29
  } = node.attrs;
28
- return resourceId.includes(localId);
30
+ const sourceId = (_this$dataProvider = this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.getSourceId();
31
+ if (!sourceId) {
32
+ return false;
33
+ }
34
+ return typeof resourceId === 'string' && typeof sourceId === 'string' && typeof localId === 'string' && resourceId === resourceIdFromSourceAndLocalId(sourceId, localId);
29
35
  }
30
36
  registerConfirmationCallback(callback) {
31
37
  this.confirmationCallback = callback;
@@ -37,15 +43,10 @@ export class SyncBlockStoreManager {
37
43
  return !!this.confirmationCallback;
38
44
  }
39
45
  createSyncBlockNode() {
40
- var _this$dataProvider;
41
- // TODO: EDITOR-1644 - properly implement creation of the synced block
42
- // below is a temporary implementation for the creation of the synced block
43
- // the resource id needs to have pageId and content property key in it
44
- // Note: If the data provider is not set, the resource id will be the local id
45
-
46
+ var _this$dataProvider2;
46
47
  const localId = uuid();
47
- const sourceId = (_this$dataProvider = this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.getSourceId();
48
- const resourceId = sourceId ? `${sourceId}/${localId}` : localId;
48
+ const sourceId = (_this$dataProvider2 = this.dataProvider) === null || _this$dataProvider2 === void 0 ? void 0 : _this$dataProvider2.getSourceId();
49
+ const resourceId = sourceId ? resourceIdFromSourceAndLocalId(sourceId, localId) : localId;
49
50
  const syncBlockNode = {
50
51
  attrs: {
51
52
  resourceId,
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @atlaskit/editor/no-re-export */
2
2
 
3
- export { SyncBlockProvider as SyncedBlockProvider, useFetchDocNode, useMemoizedSyncedBlockProvider } from './common/syncBlockProvider';
3
+ export { SyncBlockProvider as SyncedBlockProvider, useFetchDocNode, useHandleContentChanges, useMemoizedSyncedBlockProvider } from './common/syncBlockProvider';
4
4
  export { SyncBlockStoreManager } from './common/syncBlockStoreManager';
5
5
  export { inMemoryFetchProvider, inMemoryWriteProvider } from './providers/inMemory';
6
6
  export { getDefaultSyncBlockSchema } from './common/schema';
@@ -1,6 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { useMemo } from 'react';
3
- import { getLocalIdFromAri, getPageIdFromAri } from '../utils/ari';
3
+ import { getLocalIdFromAri, getPageIdFromAri, resourceIdFromSourceAndLocalId } from '../utils/ari';
4
4
  import { getContentProperty, createContentProperty, updateContentProperty } from '../utils/contentProperty';
5
5
 
6
6
  /**
@@ -33,34 +33,28 @@ class ConfluenceADFFetchProvider {
33
33
  this.config = config;
34
34
  }
35
35
  async fetchData(resourceId) {
36
- try {
37
- var _contentProperty$data, _contentProperty$data2;
38
- const pageId = getPageIdFromAri(resourceId);
39
- const localId = getLocalIdFromAri(resourceId);
40
- const key = getContentPropertyKey(this.config.contentPropertyKey, localId);
41
- const options = {
42
- pageId,
43
- key,
44
- cloudId: this.config.cloudId
45
- };
46
- const contentProperty = await getContentProperty(options);
47
- const value = (_contentProperty$data = contentProperty.data.confluence.page.properties) === null || _contentProperty$data === void 0 ? void 0 : (_contentProperty$data2 = _contentProperty$data[0]) === null || _contentProperty$data2 === void 0 ? void 0 : _contentProperty$data2.value;
48
- if (!value) {
49
- throw new Error('Content property value does not exist');
50
- }
51
-
52
- // Parse the synced block content from the property value
53
- const syncedBlockData = parseSyncedBlockContentPropertyValue(value);
54
- return {
55
- content: syncedBlockData.content
56
- };
57
- } catch (error) {
58
- // eslint-disable-next-line no-console
59
- console.error('Failed to fetch synced block data:', error);
60
- return {
61
- content: undefined
62
- };
36
+ var _contentProperty$data, _contentProperty$data2;
37
+ const pageId = getPageIdFromAri(resourceId);
38
+ const localId = getLocalIdFromAri(resourceId);
39
+ const key = getContentPropertyKey(this.config.contentPropertyKey, localId);
40
+ const options = {
41
+ pageId,
42
+ key,
43
+ cloudId: this.config.cloudId
44
+ };
45
+ const contentProperty = await getContentProperty(options);
46
+ const value = (_contentProperty$data = contentProperty.data.confluence.page.properties) === null || _contentProperty$data === void 0 ? void 0 : (_contentProperty$data2 = _contentProperty$data[0]) === null || _contentProperty$data2 === void 0 ? void 0 : _contentProperty$data2.value;
47
+ if (!value) {
48
+ throw new Error('Content property value does not exist');
63
49
  }
50
+
51
+ // Parse the synced block content from the property value
52
+ const syncedBlockData = parseSyncedBlockContentPropertyValue(value);
53
+ return {
54
+ content: syncedBlockData.content,
55
+ resourceId,
56
+ localId
57
+ };
64
58
  }
65
59
  }
66
60
 
@@ -85,39 +79,36 @@ class ConfluenceADFWriteProvider {
85
79
  });
86
80
  this.config = config;
87
81
  }
88
- async writeData(sourceId, localId, data, resourceId) {
89
- try {
90
- const pageId = getPageIdFromAri(sourceId);
91
- const syncedBlockValue = JSON.stringify({
92
- content: data
82
+ async writeData(data) {
83
+ const pageId = getPageIdFromAri(data.resourceId);
84
+ if (data.sourceDocumentAri && data.resourceId !== resourceIdFromSourceAndLocalId(data.sourceDocumentAri, data.localId)) {
85
+ return Promise.reject('Resource ARI differs from source document ARI');
86
+ }
87
+ const syncedBlockValue = JSON.stringify({
88
+ content: data.content
89
+ });
90
+ if (data.resourceId) {
91
+ var _contentProperty$data4;
92
+ // Update existing content property
93
+ const localId = getLocalIdFromAri(data.resourceId);
94
+ const key = getContentPropertyKey(this.config.contentPropertyKey, localId);
95
+ const contentProperty = await updateContentProperty({
96
+ pageId,
97
+ key,
98
+ value: syncedBlockValue,
99
+ cloudId: this.config.cloudId
93
100
  });
94
- if (resourceId) {
95
- var _contentProperty$data4;
96
- // Update existing content property
97
- const localId = getLocalIdFromAri(resourceId);
98
- const key = getContentPropertyKey(this.config.contentPropertyKey, localId);
99
- const contentProperty = await updateContentProperty({
100
- pageId,
101
- key,
102
- value: syncedBlockValue,
103
- cloudId: this.config.cloudId
104
- });
105
- if (((_contentProperty$data4 = contentProperty.data.confluence.updateValuePageProperty.pageProperty) === null || _contentProperty$data4 === void 0 ? void 0 : _contentProperty$data4.key) === key) {
106
- return key;
107
- } else if (contentProperty.data.confluence.updateValuePageProperty.pageProperty === null) {
108
- return this.createNewContentProperty(pageId, key, syncedBlockValue);
109
- } else {
110
- throw new Error('Failed to update content property');
111
- }
112
- } else {
113
- // Create new content property
114
- const key = getContentPropertyKey(this.config.contentPropertyKey, localId);
101
+ if (((_contentProperty$data4 = contentProperty.data.confluence.updateValuePageProperty.pageProperty) === null || _contentProperty$data4 === void 0 ? void 0 : _contentProperty$data4.key) === key) {
102
+ return key;
103
+ } else if (contentProperty.data.confluence.updateValuePageProperty.pageProperty === null) {
115
104
  return this.createNewContentProperty(pageId, key, syncedBlockValue);
105
+ } else {
106
+ throw new Error('Failed to update content property');
116
107
  }
117
- } catch (error) {
118
- // eslint-disable-next-line no-console
119
- console.error('Failed to write synced block data:', error);
120
- return Promise.reject(error);
108
+ } else {
109
+ // Create new content property
110
+ const key = getContentPropertyKey(this.config.contentPropertyKey, data.localId);
111
+ return this.createNewContentProperty(pageId, key, syncedBlockValue);
121
112
  }
122
113
  }
123
114
  }
@@ -1,16 +1,18 @@
1
1
  const inMemStore = new Map();
2
2
  export const inMemoryFetchProvider = {
3
3
  fetchData: resourceId => {
4
- return Promise.resolve({
5
- content: inMemStore.get(resourceId)
6
- });
4
+ const data = inMemStore.get(resourceId);
5
+ if (!data) {
6
+ return Promise.reject(new Error('Data not found'));
7
+ }
8
+ return Promise.resolve(data);
7
9
  }
8
10
  };
9
11
  export const inMemoryWriteProvider = {
10
- writeData: (_sourceId, _localId, data, resourceId) => {
11
- if (resourceId) {
12
- inMemStore.set(resourceId, data);
13
- return Promise.resolve(resourceId);
12
+ writeData: data => {
13
+ if (data.resourceId) {
14
+ inMemStore.set(data.resourceId, data);
15
+ return Promise.resolve(data.resourceId);
14
16
  } else {
15
17
  const uuid = crypto.randomUUID();
16
18
  inMemStore.set(uuid, data);
@@ -29,4 +29,7 @@ export const getContentPropertyIdFromAri = ari => {
29
29
  return match[1];
30
30
  }
31
31
  throw new Error(`Invalid content property ARI: ${ari}`);
32
+ };
33
+ export const resourceIdFromSourceAndLocalId = (sourceId, localId) => {
34
+ return sourceId + '/' + localId;
32
35
  };
@@ -43,7 +43,7 @@ export var SyncBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
43
43
  resourceIds.push(Promise.reject('No Synced Blockcontent to write'));
44
44
  return;
45
45
  }
46
- var resourceId = _this.writeProvider.writeData(_this.sourceId, node.attrs.localId, data[index].content, node.attrs.resourceId);
46
+ var resourceId = _this.writeProvider.writeData(data[index]);
47
47
  resourceIds.push(resourceId);
48
48
  });
49
49
  return Promise.all(resourceIds);
@@ -94,4 +94,21 @@ export var useMemoizedSyncedBlockProvider = function useMemoizedSyncedBlockProvi
94
94
  return useMemo(function () {
95
95
  return new SyncBlockProvider(fetchProvider, writeProvider, sourceId);
96
96
  }, [fetchProvider, writeProvider, sourceId]);
97
+ };
98
+ export var useHandleContentChanges = function useHandleContentChanges(updatedDoc, isSource, node, provider) {
99
+ useEffect(function () {
100
+ if (!isSource) {
101
+ return;
102
+ }
103
+ if (!provider) {
104
+ return;
105
+ }
106
+ var syncBlockNode = convertSyncBlockPMNodeToSyncBlockData(node, false);
107
+ var data = {
108
+ content: updatedDoc.toJSON(),
109
+ resourceId: node.attrs.resourceId,
110
+ localId: node.attrs.localId
111
+ };
112
+ provider === null || provider === void 0 || provider.writeNodesData([syncBlockNode], [data]);
113
+ }, [isSource, node, provider, updatedDoc]);
97
114
  };
@@ -3,6 +3,7 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/createClass";
4
4
  import _regeneratorRuntime from "@babel/runtime/regenerator";
5
5
  import uuid from 'uuid';
6
+ import { resourceIdFromSourceAndLocalId } from '../utils/ari';
6
7
  import { rebaseTransaction as _rebaseTransaction } from './rebase-transaction';
7
8
 
8
9
  // Do this typedef to make it clear that
@@ -27,13 +28,18 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
27
28
  }, {
28
29
  key: "isSourceBlock",
29
30
  value: function isSourceBlock(node) {
31
+ var _this$dataProvider;
30
32
  if (node.type.name !== 'syncBlock') {
31
33
  return false;
32
34
  }
33
35
  var _node$attrs = node.attrs,
34
36
  resourceId = _node$attrs.resourceId,
35
37
  localId = _node$attrs.localId;
36
- return resourceId.includes(localId);
38
+ var sourceId = (_this$dataProvider = this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.getSourceId();
39
+ if (!sourceId) {
40
+ return false;
41
+ }
42
+ return typeof resourceId === 'string' && typeof sourceId === 'string' && typeof localId === 'string' && resourceId === resourceIdFromSourceAndLocalId(sourceId, localId);
37
43
  }
38
44
  }, {
39
45
  key: "registerConfirmationCallback",
@@ -52,15 +58,10 @@ export var SyncBlockStoreManager = /*#__PURE__*/function () {
52
58
  }, {
53
59
  key: "createSyncBlockNode",
54
60
  value: function createSyncBlockNode() {
55
- var _this$dataProvider;
56
- // TODO: EDITOR-1644 - properly implement creation of the synced block
57
- // below is a temporary implementation for the creation of the synced block
58
- // the resource id needs to have pageId and content property key in it
59
- // Note: If the data provider is not set, the resource id will be the local id
60
-
61
+ var _this$dataProvider2;
61
62
  var localId = uuid();
62
- var sourceId = (_this$dataProvider = this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.getSourceId();
63
- var resourceId = sourceId ? "".concat(sourceId, "/").concat(localId) : localId;
63
+ var sourceId = (_this$dataProvider2 = this.dataProvider) === null || _this$dataProvider2 === void 0 ? void 0 : _this$dataProvider2.getSourceId();
64
+ var resourceId = sourceId ? resourceIdFromSourceAndLocalId(sourceId, localId) : localId;
64
65
  var syncBlockNode = {
65
66
  attrs: {
66
67
  resourceId: resourceId,
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @atlaskit/editor/no-re-export */
2
2
 
3
- export { SyncBlockProvider as SyncedBlockProvider, useFetchDocNode, useMemoizedSyncedBlockProvider } from './common/syncBlockProvider';
3
+ export { SyncBlockProvider as SyncedBlockProvider, useFetchDocNode, useHandleContentChanges, useMemoizedSyncedBlockProvider } from './common/syncBlockProvider';
4
4
  export { SyncBlockStoreManager } from './common/syncBlockStoreManager';
5
5
  export { inMemoryFetchProvider, inMemoryWriteProvider } from './providers/inMemory';
6
6
  export { getDefaultSyncBlockSchema } from './common/schema';
@@ -4,7 +4,7 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
4
  import _createClass from "@babel/runtime/helpers/createClass";
5
5
  import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
  import { useMemo } from 'react';
7
- import { getLocalIdFromAri, getPageIdFromAri } from '../utils/ari';
7
+ import { getLocalIdFromAri, getPageIdFromAri, resourceIdFromSourceAndLocalId } from '../utils/ari';
8
8
  import { getContentProperty, createContentProperty, updateContentProperty } from '../utils/contentProperty';
9
9
 
10
10
  /**
@@ -41,11 +41,11 @@ var ConfluenceADFFetchProvider = /*#__PURE__*/function () {
41
41
  key: "fetchData",
42
42
  value: function () {
43
43
  var _fetchData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resourceId) {
44
- var _contentProperty$data, pageId, localId, key, options, contentProperty, value, syncedBlockData;
44
+ var _contentProperty$data;
45
+ var pageId, localId, key, options, contentProperty, value, syncedBlockData;
45
46
  return _regeneratorRuntime.wrap(function _callee$(_context) {
46
47
  while (1) switch (_context.prev = _context.next) {
47
48
  case 0:
48
- _context.prev = 0;
49
49
  pageId = getPageIdFromAri(resourceId);
50
50
  localId = getLocalIdFromAri(resourceId);
51
51
  key = getContentPropertyKey(this.config.contentPropertyKey, localId);
@@ -54,35 +54,29 @@ var ConfluenceADFFetchProvider = /*#__PURE__*/function () {
54
54
  key: key,
55
55
  cloudId: this.config.cloudId
56
56
  };
57
- _context.next = 7;
57
+ _context.next = 6;
58
58
  return getContentProperty(options);
59
- case 7:
59
+ case 6:
60
60
  contentProperty = _context.sent;
61
61
  value = (_contentProperty$data = contentProperty.data.confluence.page.properties) === null || _contentProperty$data === void 0 || (_contentProperty$data = _contentProperty$data[0]) === null || _contentProperty$data === void 0 ? void 0 : _contentProperty$data.value;
62
62
  if (value) {
63
- _context.next = 11;
63
+ _context.next = 10;
64
64
  break;
65
65
  }
66
66
  throw new Error('Content property value does not exist');
67
- case 11:
67
+ case 10:
68
68
  // Parse the synced block content from the property value
69
69
  syncedBlockData = parseSyncedBlockContentPropertyValue(value);
70
70
  return _context.abrupt("return", {
71
- content: syncedBlockData.content
72
- });
73
- case 15:
74
- _context.prev = 15;
75
- _context.t0 = _context["catch"](0);
76
- // eslint-disable-next-line no-console
77
- console.error('Failed to fetch synced block data:', _context.t0);
78
- return _context.abrupt("return", {
79
- content: undefined
71
+ content: syncedBlockData.content,
72
+ resourceId: resourceId,
73
+ localId: localId
80
74
  });
81
- case 19:
75
+ case 12:
82
76
  case "end":
83
77
  return _context.stop();
84
78
  }
85
- }, _callee, this, [[0, 15]]);
79
+ }, _callee, this);
86
80
  }));
87
81
  function fetchData(_x) {
88
82
  return _fetchData.apply(this, arguments);
@@ -136,68 +130,64 @@ var ConfluenceADFWriteProvider = /*#__PURE__*/function () {
136
130
  return _createClass(ConfluenceADFWriteProvider, [{
137
131
  key: "writeData",
138
132
  value: function () {
139
- var _writeData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(sourceId, localId, data, resourceId) {
140
- var pageId, syncedBlockValue, _contentProperty$data3, _localId, key, contentProperty, _key;
133
+ var _writeData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(data) {
134
+ var pageId, syncedBlockValue, _contentProperty$data3, localId, key, contentProperty, _key;
141
135
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
142
136
  while (1) switch (_context3.prev = _context3.next) {
143
137
  case 0:
144
- _context3.prev = 0;
145
- pageId = getPageIdFromAri(sourceId);
138
+ pageId = getPageIdFromAri(data.resourceId);
139
+ if (!(data.sourceDocumentAri && data.resourceId !== resourceIdFromSourceAndLocalId(data.sourceDocumentAri, data.localId))) {
140
+ _context3.next = 3;
141
+ break;
142
+ }
143
+ return _context3.abrupt("return", Promise.reject('Resource ARI differs from source document ARI'));
144
+ case 3:
146
145
  syncedBlockValue = JSON.stringify({
147
- content: data
146
+ content: data.content
148
147
  });
149
- if (!resourceId) {
150
- _context3.next = 20;
148
+ if (!data.resourceId) {
149
+ _context3.next = 21;
151
150
  break;
152
151
  }
153
152
  // Update existing content property
154
- _localId = getLocalIdFromAri(resourceId);
155
- key = getContentPropertyKey(this.config.contentPropertyKey, _localId);
156
- _context3.next = 8;
153
+ localId = getLocalIdFromAri(data.resourceId);
154
+ key = getContentPropertyKey(this.config.contentPropertyKey, localId);
155
+ _context3.next = 9;
157
156
  return updateContentProperty({
158
157
  pageId: pageId,
159
158
  key: key,
160
159
  value: syncedBlockValue,
161
160
  cloudId: this.config.cloudId
162
161
  });
163
- case 8:
162
+ case 9:
164
163
  contentProperty = _context3.sent;
165
164
  if (!(((_contentProperty$data3 = contentProperty.data.confluence.updateValuePageProperty.pageProperty) === null || _contentProperty$data3 === void 0 ? void 0 : _contentProperty$data3.key) === key)) {
166
- _context3.next = 13;
165
+ _context3.next = 14;
167
166
  break;
168
167
  }
169
168
  return _context3.abrupt("return", key);
170
- case 13:
169
+ case 14:
171
170
  if (!(contentProperty.data.confluence.updateValuePageProperty.pageProperty === null)) {
172
- _context3.next = 17;
171
+ _context3.next = 18;
173
172
  break;
174
173
  }
175
174
  return _context3.abrupt("return", this.createNewContentProperty(pageId, key, syncedBlockValue));
176
- case 17:
177
- throw new Error('Failed to update content property');
178
175
  case 18:
179
- _context3.next = 22;
176
+ throw new Error('Failed to update content property');
177
+ case 19:
178
+ _context3.next = 23;
180
179
  break;
181
- case 20:
180
+ case 21:
182
181
  // Create new content property
183
- _key = getContentPropertyKey(this.config.contentPropertyKey, localId);
182
+ _key = getContentPropertyKey(this.config.contentPropertyKey, data.localId);
184
183
  return _context3.abrupt("return", this.createNewContentProperty(pageId, _key, syncedBlockValue));
185
- case 22:
186
- _context3.next = 28;
187
- break;
188
- case 24:
189
- _context3.prev = 24;
190
- _context3.t0 = _context3["catch"](0);
191
- // eslint-disable-next-line no-console
192
- console.error('Failed to write synced block data:', _context3.t0);
193
- return _context3.abrupt("return", Promise.reject(_context3.t0));
194
- case 28:
184
+ case 23:
195
185
  case "end":
196
186
  return _context3.stop();
197
187
  }
198
- }, _callee3, this, [[0, 24]]);
188
+ }, _callee3, this);
199
189
  }));
200
- function writeData(_x5, _x6, _x7, _x8) {
190
+ function writeData(_x5) {
201
191
  return _writeData.apply(this, arguments);
202
192
  }
203
193
  return writeData;
@@ -1,16 +1,18 @@
1
1
  var inMemStore = new Map();
2
2
  export var inMemoryFetchProvider = {
3
3
  fetchData: function fetchData(resourceId) {
4
- return Promise.resolve({
5
- content: inMemStore.get(resourceId)
6
- });
4
+ var data = inMemStore.get(resourceId);
5
+ if (!data) {
6
+ return Promise.reject(new Error('Data not found'));
7
+ }
8
+ return Promise.resolve(data);
7
9
  }
8
10
  };
9
11
  export var inMemoryWriteProvider = {
10
- writeData: function writeData(_sourceId, _localId, data, resourceId) {
11
- if (resourceId) {
12
- inMemStore.set(resourceId, data);
13
- return Promise.resolve(resourceId);
12
+ writeData: function writeData(data) {
13
+ if (data.resourceId) {
14
+ inMemStore.set(data.resourceId, data);
15
+ return Promise.resolve(data.resourceId);
14
16
  } else {
15
17
  var uuid = crypto.randomUUID();
16
18
  inMemStore.set(uuid, data);
@@ -33,4 +33,7 @@ export var getContentPropertyIdFromAri = function getContentPropertyIdFromAri(ar
33
33
  return match[1];
34
34
  }
35
35
  throw new Error("Invalid content property ARI: ".concat(ari));
36
+ };
37
+ export var resourceIdFromSourceAndLocalId = function resourceIdFromSourceAndLocalId(sourceId, localId) {
38
+ return sourceId + '/' + localId;
36
39
  };
@@ -24,3 +24,4 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
24
24
  }
25
25
  export declare const useFetchDocNode: (editorView: EditorView, node: PMNode, defaultDocNode: DocNode, provider?: SyncBlockDataProvider) => DocNode;
26
26
  export declare const useMemoizedSyncedBlockProvider: (fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string) => SyncBlockProvider;
27
+ export declare const useHandleContentChanges: (updatedDoc: PMNode, isSource: boolean, node: PMNode, provider?: SyncBlockDataProvider) => void;
@@ -12,13 +12,20 @@ export type SyncBlockNode = {
12
12
  };
13
13
  export type SyncBlockData = {
14
14
  content: ADFEntity | undefined;
15
- resourceId?: string;
15
+ createdAt?: string;
16
+ createdBy?: string;
17
+ isSynced?: boolean;
18
+ localId: string;
19
+ resourceId: string;
20
+ sourceDocumentAri?: string;
21
+ status?: 'deleted' | 'active';
22
+ updatedAt?: string;
16
23
  };
17
24
  export interface ADFFetchProvider {
18
25
  fetchData: (resourceId: string) => Promise<SyncBlockData>;
19
26
  }
20
27
  export interface ADFWriteProvider {
21
- writeData: (sourceId: string, localId: string, data: ADFEntity, resourceId?: string) => Promise<string>;
28
+ writeData: (data: SyncBlockData) => Promise<string>;
22
29
  }
23
30
  export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode, SyncBlockData> {
24
31
  abstract writeNodesData: (nodes: SyncBlockNode[], data: SyncBlockData[]) => Promise<Array<string | undefined>>;
@@ -1,4 +1,4 @@
1
- export { SyncBlockProvider as SyncedBlockProvider, useFetchDocNode, useMemoizedSyncedBlockProvider, } from './common/syncBlockProvider';
1
+ export { SyncBlockProvider as SyncedBlockProvider, useFetchDocNode, useHandleContentChanges, useMemoizedSyncedBlockProvider, } from './common/syncBlockProvider';
2
2
  export { SyncBlockStoreManager } from './common/syncBlockStoreManager';
3
3
  export type { SyncBlockDataProvider, ADFFetchProvider, ADFWriteProvider, SyncBlockData, SyncBlockNode, } from './common/types';
4
4
  export { inMemoryFetchProvider, inMemoryWriteProvider } from './providers/inMemory';
@@ -25,7 +25,7 @@ declare class ConfluenceADFWriteProvider implements ADFWriteProvider {
25
25
  private config;
26
26
  constructor(config: ContentAPIConfig);
27
27
  private createNewContentProperty;
28
- writeData(sourceId: string, localId: string, data: ADFEntity, resourceId?: string): Promise<string>;
28
+ writeData(data: SyncBlockData): Promise<string>;
29
29
  }
30
30
  /**
31
31
  * Convenience function to create providers with default content property key
@@ -8,3 +8,4 @@ export declare const getPageIdFromAri: (ari: string) => string;
8
8
  export declare const getLocalIdFromAri: (ari: string) => string;
9
9
  export declare const getContentPropertyAri: (contentPropertyId: string, cloudId: string) => string;
10
10
  export declare const getContentPropertyIdFromAri: (ari: string) => string;
11
+ export declare const resourceIdFromSourceAndLocalId: (sourceId: string, localId: string) => string;
@@ -24,3 +24,4 @@ export declare class SyncBlockProvider extends SyncBlockDataProvider {
24
24
  }
25
25
  export declare const useFetchDocNode: (editorView: EditorView, node: PMNode, defaultDocNode: DocNode, provider?: SyncBlockDataProvider) => DocNode;
26
26
  export declare const useMemoizedSyncedBlockProvider: (fetchProvider: ADFFetchProvider, writeProvider: ADFWriteProvider, sourceId: string) => SyncBlockProvider;
27
+ export declare const useHandleContentChanges: (updatedDoc: PMNode, isSource: boolean, node: PMNode, provider?: SyncBlockDataProvider) => void;
@@ -12,13 +12,20 @@ export type SyncBlockNode = {
12
12
  };
13
13
  export type SyncBlockData = {
14
14
  content: ADFEntity | undefined;
15
- resourceId?: string;
15
+ createdAt?: string;
16
+ createdBy?: string;
17
+ isSynced?: boolean;
18
+ localId: string;
19
+ resourceId: string;
20
+ sourceDocumentAri?: string;
21
+ status?: 'deleted' | 'active';
22
+ updatedAt?: string;
16
23
  };
17
24
  export interface ADFFetchProvider {
18
25
  fetchData: (resourceId: string) => Promise<SyncBlockData>;
19
26
  }
20
27
  export interface ADFWriteProvider {
21
- writeData: (sourceId: string, localId: string, data: ADFEntity, resourceId?: string) => Promise<string>;
28
+ writeData: (data: SyncBlockData) => Promise<string>;
22
29
  }
23
30
  export declare abstract class SyncBlockDataProvider extends NodeDataProvider<SyncBlockNode, SyncBlockData> {
24
31
  abstract writeNodesData: (nodes: SyncBlockNode[], data: SyncBlockData[]) => Promise<Array<string | undefined>>;
@@ -1,4 +1,4 @@
1
- export { SyncBlockProvider as SyncedBlockProvider, useFetchDocNode, useMemoizedSyncedBlockProvider, } from './common/syncBlockProvider';
1
+ export { SyncBlockProvider as SyncedBlockProvider, useFetchDocNode, useHandleContentChanges, useMemoizedSyncedBlockProvider, } from './common/syncBlockProvider';
2
2
  export { SyncBlockStoreManager } from './common/syncBlockStoreManager';
3
3
  export type { SyncBlockDataProvider, ADFFetchProvider, ADFWriteProvider, SyncBlockData, SyncBlockNode, } from './common/types';
4
4
  export { inMemoryFetchProvider, inMemoryWriteProvider } from './providers/inMemory';
@@ -25,7 +25,7 @@ declare class ConfluenceADFWriteProvider implements ADFWriteProvider {
25
25
  private config;
26
26
  constructor(config: ContentAPIConfig);
27
27
  private createNewContentProperty;
28
- writeData(sourceId: string, localId: string, data: ADFEntity, resourceId?: string): Promise<string>;
28
+ writeData(data: SyncBlockData): Promise<string>;
29
29
  }
30
30
  /**
31
31
  * Convenience function to create providers with default content property key
@@ -8,3 +8,4 @@ export declare const getPageIdFromAri: (ari: string) => string;
8
8
  export declare const getLocalIdFromAri: (ari: string) => string;
9
9
  export declare const getContentPropertyAri: (contentPropertyId: string, cloudId: string) => string;
10
10
  export declare const getContentPropertyIdFromAri: (ari: string) => string;
11
+ export declare const resourceIdFromSourceAndLocalId: (sourceId: string, localId: string) => string;
package/package.json CHANGED
@@ -82,7 +82,7 @@
82
82
  }
83
83
  },
84
84
  "name": "@atlaskit/editor-synced-block-provider",
85
- "version": "0.4.0",
85
+ "version": "0.5.1",
86
86
  "description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
87
87
  "author": "Atlassian Pty Ltd",
88
88
  "license": "Apache-2.0",