@atlaskit/editor-synced-block-provider 0.7.0 → 0.9.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,23 @@
1
1
  # @atlaskit/editor-synced-block-provider
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`d69b1dec4af70`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d69b1dec4af70) -
8
+ Generate link to source block with localid parameter
9
+
10
+ ## 0.8.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [`5167552fe1a93`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5167552fe1a93) -
15
+ [EDITOR-2339] Bump @atlaskit/adf-schema to 51.3.0
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+
3
21
  ## 0.7.0
4
22
 
5
23
  ### Minor Changes
@@ -85,14 +85,20 @@ var SyncBlockProvider = exports.SyncBlockProvider = /*#__PURE__*/function (_Sync
85
85
  value: function retrieveSyncBlockSourceUrl(node) {
86
86
  var resourceId = node.attrs.resourceId;
87
87
  var pageARI;
88
+ var sourceLocalId;
88
89
  if (resourceId && typeof resourceId === 'string') {
89
90
  try {
90
91
  pageARI = (0, _ari.getPageARIFromResourceId)(resourceId);
91
92
  } catch (error) {
92
93
  return Promise.reject(error);
93
94
  }
95
+ try {
96
+ sourceLocalId = (0, _ari.getLocalIdFromAri)(resourceId);
97
+ } catch (error) {
98
+ // EDITOR-1921: log analytic here, safe to continue
99
+ }
94
100
  }
95
- return pageARI ? fetchURLfromARI(pageARI) : Promise.resolve(undefined);
101
+ return pageARI ? fetchURLfromARI(pageARI, sourceLocalId) : Promise.resolve(undefined);
96
102
  }
97
103
  }]);
98
104
  }(_types.SyncBlockDataProvider);
@@ -150,7 +156,7 @@ var useHandleContentChanges = exports.useHandleContentChanges = function useHand
150
156
  }, [isSource, node, provider, updatedDoc]);
151
157
  };
152
158
  var fetchURLfromARI = /*#__PURE__*/function () {
153
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(ari) {
159
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(ari, sourceLocalId) {
154
160
  var response, _payload$data, payload, url;
155
161
  return _regenerator.default.wrap(function _callee$(_context) {
156
162
  while (1) switch (_context.prev = _context.next) {
@@ -181,7 +187,7 @@ var fetchURLfromARI = /*#__PURE__*/function () {
181
187
  _context.next = 10;
182
188
  break;
183
189
  }
184
- return _context.abrupt("return", url);
190
+ return _context.abrupt("return", sourceLocalId ? url + "?block=".concat(sourceLocalId) : url);
185
191
  case 10:
186
192
  _context.next = 13;
187
193
  break;
@@ -196,7 +202,7 @@ var fetchURLfromARI = /*#__PURE__*/function () {
196
202
  }
197
203
  }, _callee);
198
204
  }));
199
- return function fetchURLfromARI(_x) {
205
+ return function fetchURLfromARI(_x, _x2) {
200
206
  return _ref.apply(this, arguments);
201
207
  };
202
208
  }();
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.resourceIdFromSourceAndLocalId = exports.getPageIdAndTypeFromAri = exports.getPageARIFromResourceId = exports.getLocalIdFromAri = exports.getContentPropertyIdFromAri = exports.getContentPropertyAri = exports.getConfluencePageAri = void 0;
6
+ exports.resourceIdFromSourceAndLocalId = exports.getPageIdAndTypeFromAri = exports.getPageARIFromResourceId = exports.getLocalIdFromAri = exports.getContentPropertyAri = exports.getConfluencePageAri = void 0;
7
7
  /* eslint-disable require-unicode-regexp */
8
8
 
9
9
  var getConfluencePageAri = exports.getConfluencePageAri = function getConfluencePageAri(pageId, cloudId) {
@@ -37,21 +37,6 @@ var getPageARIFromResourceId = exports.getPageARIFromResourceId = function getPa
37
37
  var getContentPropertyAri = exports.getContentPropertyAri = function getContentPropertyAri(contentPropertyId, cloudId) {
38
38
  return "ari:cloud:confluence:".concat(cloudId, ":content/").concat(contentPropertyId);
39
39
  };
40
-
41
- /**
42
- * DEPRECATED - Will be removed in the future
43
- * @private
44
- * @deprecated
45
- * @param ari
46
- * @returns
47
- */
48
- var getContentPropertyIdFromAri = exports.getContentPropertyIdFromAri = function getContentPropertyIdFromAri(ari) {
49
- var match = ari.match(/ari:cloud:confluence:[^:]+:content\/([^/]+)/);
50
- if (match) {
51
- return match[1];
52
- }
53
- throw new Error("Invalid content property ARI: ".concat(ari));
54
- };
55
40
  var resourceIdFromSourceAndLocalId = exports.resourceIdFromSourceAndLocalId = function resourceIdFromSourceAndLocalId(sourceId, localId) {
56
41
  return sourceId + '/' + localId;
57
42
  };
@@ -1,6 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { useEffect, useState, useMemo } from 'react';
3
- import { getPageARIFromResourceId } from '../utils/ari';
3
+ import { getLocalIdFromAri, getPageARIFromResourceId } from '../utils/ari';
4
4
  import { convertSyncBlockPMNodeToSyncBlockData } from '../utils/utils';
5
5
  import { SyncBlockDataProvider } from './types';
6
6
  export class SyncBlockProvider extends SyncBlockDataProvider {
@@ -50,14 +50,20 @@ export class SyncBlockProvider extends SyncBlockDataProvider {
50
50
  resourceId
51
51
  } = node.attrs;
52
52
  let pageARI;
53
+ let sourceLocalId;
53
54
  if (resourceId && typeof resourceId === 'string') {
54
55
  try {
55
56
  pageARI = getPageARIFromResourceId(resourceId);
56
57
  } catch (error) {
57
58
  return Promise.reject(error);
58
59
  }
60
+ try {
61
+ sourceLocalId = getLocalIdFromAri(resourceId);
62
+ } catch (error) {
63
+ // EDITOR-1921: log analytic here, safe to continue
64
+ }
59
65
  }
60
- return pageARI ? fetchURLfromARI(pageARI) : Promise.resolve(undefined);
66
+ return pageARI ? fetchURLfromARI(pageARI, sourceLocalId) : Promise.resolve(undefined);
61
67
  }
62
68
  }
63
69
  export const useFetchDocNode = (editorView, node, defaultDocNode, provider) => {
@@ -111,7 +117,7 @@ export const useHandleContentChanges = (updatedDoc, isSource, node, provider) =>
111
117
  provider === null || provider === void 0 ? void 0 : provider.writeNodesData([syncBlockNode], [data]);
112
118
  }, [isSource, node, provider, updatedDoc]);
113
119
  };
114
- const fetchURLfromARI = async ari => {
120
+ const fetchURLfromARI = async (ari, sourceLocalId) => {
115
121
  const response = await fetch('/gateway/api/object-resolver/resolve/ari', {
116
122
  method: 'POST',
117
123
  headers: {
@@ -127,7 +133,7 @@ const fetchURLfromARI = async ari => {
127
133
  const payload = await response.json();
128
134
  const url = payload === null || payload === void 0 ? void 0 : (_payload$data = payload.data) === null || _payload$data === void 0 ? void 0 : _payload$data.url;
129
135
  if (typeof url === 'string') {
130
- return url;
136
+ return sourceLocalId ? url + `?block=${sourceLocalId}` : url;
131
137
  }
132
138
  } else {
133
139
  //eslint-disable-next-line no-console
@@ -26,21 +26,6 @@ export const getPageARIFromResourceId = resourceId => {
26
26
  throw new Error(`Invalid resourceId: ${resourceId}`);
27
27
  };
28
28
  export const getContentPropertyAri = (contentPropertyId, cloudId) => `ari:cloud:confluence:${cloudId}:content/${contentPropertyId}`;
29
-
30
- /**
31
- * DEPRECATED - Will be removed in the future
32
- * @private
33
- * @deprecated
34
- * @param ari
35
- * @returns
36
- */
37
- export const getContentPropertyIdFromAri = ari => {
38
- const match = ari.match(/ari:cloud:confluence:[^:]+:content\/([^/]+)/);
39
- if (match) {
40
- return match[1];
41
- }
42
- throw new Error(`Invalid content property ARI: ${ari}`);
43
- };
44
29
  export const resourceIdFromSourceAndLocalId = (sourceId, localId) => {
45
30
  return sourceId + '/' + localId;
46
31
  };
@@ -12,7 +12,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
12
12
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
13
13
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
14
14
  import { useEffect, useState, useMemo } from 'react';
15
- import { getPageARIFromResourceId } from '../utils/ari';
15
+ import { getLocalIdFromAri, getPageARIFromResourceId } from '../utils/ari';
16
16
  import { convertSyncBlockPMNodeToSyncBlockData } from '../utils/utils';
17
17
  import { SyncBlockDataProvider } from './types';
18
18
  export var SyncBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
@@ -78,14 +78,20 @@ export var SyncBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
78
78
  value: function retrieveSyncBlockSourceUrl(node) {
79
79
  var resourceId = node.attrs.resourceId;
80
80
  var pageARI;
81
+ var sourceLocalId;
81
82
  if (resourceId && typeof resourceId === 'string') {
82
83
  try {
83
84
  pageARI = getPageARIFromResourceId(resourceId);
84
85
  } catch (error) {
85
86
  return Promise.reject(error);
86
87
  }
88
+ try {
89
+ sourceLocalId = getLocalIdFromAri(resourceId);
90
+ } catch (error) {
91
+ // EDITOR-1921: log analytic here, safe to continue
92
+ }
87
93
  }
88
- return pageARI ? fetchURLfromARI(pageARI) : Promise.resolve(undefined);
94
+ return pageARI ? fetchURLfromARI(pageARI, sourceLocalId) : Promise.resolve(undefined);
89
95
  }
90
96
  }]);
91
97
  }(SyncBlockDataProvider);
@@ -143,7 +149,7 @@ export var useHandleContentChanges = function useHandleContentChanges(updatedDoc
143
149
  }, [isSource, node, provider, updatedDoc]);
144
150
  };
145
151
  var fetchURLfromARI = /*#__PURE__*/function () {
146
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ari) {
152
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ari, sourceLocalId) {
147
153
  var response, _payload$data, payload, url;
148
154
  return _regeneratorRuntime.wrap(function _callee$(_context) {
149
155
  while (1) switch (_context.prev = _context.next) {
@@ -174,7 +180,7 @@ var fetchURLfromARI = /*#__PURE__*/function () {
174
180
  _context.next = 10;
175
181
  break;
176
182
  }
177
- return _context.abrupt("return", url);
183
+ return _context.abrupt("return", sourceLocalId ? url + "?block=".concat(sourceLocalId) : url);
178
184
  case 10:
179
185
  _context.next = 13;
180
186
  break;
@@ -189,7 +195,7 @@ var fetchURLfromARI = /*#__PURE__*/function () {
189
195
  }
190
196
  }, _callee);
191
197
  }));
192
- return function fetchURLfromARI(_x) {
198
+ return function fetchURLfromARI(_x, _x2) {
193
199
  return _ref.apply(this, arguments);
194
200
  };
195
201
  }();
@@ -31,21 +31,6 @@ export var getPageARIFromResourceId = function getPageARIFromResourceId(resource
31
31
  export var getContentPropertyAri = function getContentPropertyAri(contentPropertyId, cloudId) {
32
32
  return "ari:cloud:confluence:".concat(cloudId, ":content/").concat(contentPropertyId);
33
33
  };
34
-
35
- /**
36
- * DEPRECATED - Will be removed in the future
37
- * @private
38
- * @deprecated
39
- * @param ari
40
- * @returns
41
- */
42
- export var getContentPropertyIdFromAri = function getContentPropertyIdFromAri(ari) {
43
- var match = ari.match(/ari:cloud:confluence:[^:]+:content\/([^/]+)/);
44
- if (match) {
45
- return match[1];
46
- }
47
- throw new Error("Invalid content property ARI: ".concat(ari));
48
- };
49
34
  export var resourceIdFromSourceAndLocalId = function resourceIdFromSourceAndLocalId(sourceId, localId) {
50
35
  return sourceId + '/' + localId;
51
36
  };
@@ -7,12 +7,4 @@ export declare const getPageIdAndTypeFromAri: (ari: string) => {
7
7
  export declare const getLocalIdFromAri: (ari: string) => string;
8
8
  export declare const getPageARIFromResourceId: (resourceId: string) => string;
9
9
  export declare const getContentPropertyAri: (contentPropertyId: string, cloudId: string) => string;
10
- /**
11
- * DEPRECATED - Will be removed in the future
12
- * @private
13
- * @deprecated
14
- * @param ari
15
- * @returns
16
- */
17
- export declare const getContentPropertyIdFromAri: (ari: string) => string;
18
10
  export declare const resourceIdFromSourceAndLocalId: (sourceId: string, localId: string) => string;
@@ -7,12 +7,4 @@ export declare const getPageIdAndTypeFromAri: (ari: string) => {
7
7
  export declare const getLocalIdFromAri: (ari: string) => string;
8
8
  export declare const getPageARIFromResourceId: (resourceId: string) => string;
9
9
  export declare const getContentPropertyAri: (contentPropertyId: string, cloudId: string) => string;
10
- /**
11
- * DEPRECATED - Will be removed in the future
12
- * @private
13
- * @deprecated
14
- * @param ari
15
- * @returns
16
- */
17
- export declare const getContentPropertyIdFromAri: (ari: string) => string;
18
10
  export declare const resourceIdFromSourceAndLocalId: (sourceId: string, localId: string) => string;
package/package.json CHANGED
@@ -24,13 +24,13 @@
24
24
  ],
25
25
  "atlaskit:src": "src/index.ts",
26
26
  "dependencies": {
27
- "@atlaskit/adf-schema": "^51.2.0",
28
- "@atlaskit/adf-utils": "^19.24.0",
27
+ "@atlaskit/adf-schema": "^51.3.0",
28
+ "@atlaskit/adf-utils": "^19.25.0",
29
29
  "@atlaskit/css": "^0.15.0",
30
- "@atlaskit/editor-json-transformer": "^8.30.0",
30
+ "@atlaskit/editor-json-transformer": "^8.31.0",
31
31
  "@atlaskit/editor-prosemirror": "7.0.0",
32
- "@atlaskit/node-data-provider": "^7.1.0",
33
- "@atlaskit/primitives": "^15.0.0",
32
+ "@atlaskit/node-data-provider": "^7.2.0",
33
+ "@atlaskit/primitives": "^16.0.0",
34
34
  "@atlaskit/tokens": "^7.0.0",
35
35
  "@babel/runtime": "^7.0.0",
36
36
  "@compiled/react": "^0.18.6",
@@ -82,7 +82,7 @@
82
82
  }
83
83
  },
84
84
  "name": "@atlaskit/editor-synced-block-provider",
85
- "version": "0.7.0",
85
+ "version": "0.9.0",
86
86
  "description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
87
87
  "author": "Atlassian Pty Ltd",
88
88
  "license": "Apache-2.0",