@atlaskit/editor-plugin-synced-block 0.1.2 → 2.0.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 (103) hide show
  1. package/CHANGELOG.md +5 -15
  2. package/afm-cc/tsconfig.json +0 -15
  3. package/afm-dev-agents/tsconfig.json +0 -15
  4. package/afm-jira/tsconfig.json +0 -15
  5. package/afm-passionfruit/tsconfig.json +0 -15
  6. package/afm-post-office/tsconfig.json +0 -15
  7. package/afm-rovo-extension/tsconfig.json +0 -15
  8. package/afm-townsquare/tsconfig.json +0 -15
  9. package/dist/cjs/nodeviews/syncedBlock.js +20 -0
  10. package/dist/cjs/pm-plugins/main.js +0 -21
  11. package/dist/cjs/syncedBlockPlugin.js +9 -5
  12. package/dist/cjs/ui/floating-toolbar.js +39 -0
  13. package/dist/es2019/nodeviews/syncedBlock.js +10 -0
  14. package/dist/es2019/pm-plugins/main.js +0 -24
  15. package/dist/es2019/syncedBlockPlugin.js +18 -15
  16. package/dist/es2019/ui/floating-toolbar.js +31 -0
  17. package/dist/esm/nodeviews/syncedBlock.js +13 -0
  18. package/dist/esm/pm-plugins/main.js +0 -21
  19. package/dist/esm/syncedBlockPlugin.js +9 -4
  20. package/dist/esm/ui/floating-toolbar.js +32 -0
  21. package/dist/types/index.d.ts +0 -1
  22. package/dist/types/nodeviews/syncedBlock.d.ts +11 -0
  23. package/dist/types/ui/floating-toolbar.d.ts +2 -0
  24. package/dist/types-ts4.5/index.d.ts +0 -1
  25. package/dist/types-ts4.5/nodeviews/syncedBlock.d.ts +11 -0
  26. package/dist/types-ts4.5/ui/floating-toolbar.d.ts +2 -0
  27. package/package.json +3 -9
  28. package/SyncedBlock/package.json +0 -15
  29. package/dist/cjs/pm-plugins/SyncClient.js +0 -167
  30. package/dist/cjs/pm-plugins/utils.js +0 -19
  31. package/dist/cjs/types/index.js +0 -1
  32. package/dist/cjs/ui/extensions/synced-block/components/GlobalStyles.js +0 -25
  33. package/dist/cjs/ui/extensions/synced-block/components/SyncedBlockLiveView.js +0 -25
  34. package/dist/cjs/ui/extensions/synced-block/components/SyncedBlockRenderer.js +0 -25
  35. package/dist/cjs/ui/extensions/synced-block/constants.js +0 -32
  36. package/dist/cjs/ui/extensions/synced-block/getSyncedBlockExtensionProvider.js +0 -11
  37. package/dist/cjs/ui/extensions/synced-block/hooks/useLiveSyncedBlockContent.js +0 -29
  38. package/dist/cjs/ui/extensions/synced-block/hooks/usePollContentProperty.js +0 -121
  39. package/dist/cjs/ui/extensions/synced-block/index.js +0 -19
  40. package/dist/cjs/ui/extensions/synced-block/manifest.js +0 -281
  41. package/dist/cjs/ui/extensions/synced-block/utils/ari.js +0 -29
  42. package/dist/cjs/ui/extensions/synced-block/utils/content-property.js +0 -159
  43. package/dist/cjs/ui/extensions/synced-block/utils/synced-block.js +0 -65
  44. package/dist/es2019/pm-plugins/SyncClient.js +0 -102
  45. package/dist/es2019/pm-plugins/utils.js +0 -13
  46. package/dist/es2019/types/index.js +0 -0
  47. package/dist/es2019/ui/extensions/synced-block/components/GlobalStyles.js +0 -18
  48. package/dist/es2019/ui/extensions/synced-block/components/SyncedBlockLiveView.js +0 -19
  49. package/dist/es2019/ui/extensions/synced-block/components/SyncedBlockRenderer.js +0 -19
  50. package/dist/es2019/ui/extensions/synced-block/constants.js +0 -26
  51. package/dist/es2019/ui/extensions/synced-block/getSyncedBlockExtensionProvider.js +0 -5
  52. package/dist/es2019/ui/extensions/synced-block/hooks/useLiveSyncedBlockContent.js +0 -24
  53. package/dist/es2019/ui/extensions/synced-block/hooks/usePollContentProperty.js +0 -107
  54. package/dist/es2019/ui/extensions/synced-block/index.js +0 -5
  55. package/dist/es2019/ui/extensions/synced-block/manifest.js +0 -172
  56. package/dist/es2019/ui/extensions/synced-block/utils/ari.js +0 -19
  57. package/dist/es2019/ui/extensions/synced-block/utils/content-property.js +0 -108
  58. package/dist/es2019/ui/extensions/synced-block/utils/synced-block.js +0 -57
  59. package/dist/esm/pm-plugins/SyncClient.js +0 -160
  60. package/dist/esm/pm-plugins/utils.js +0 -13
  61. package/dist/esm/types/index.js +0 -0
  62. package/dist/esm/ui/extensions/synced-block/components/GlobalStyles.js +0 -18
  63. package/dist/esm/ui/extensions/synced-block/components/SyncedBlockLiveView.js +0 -18
  64. package/dist/esm/ui/extensions/synced-block/components/SyncedBlockRenderer.js +0 -18
  65. package/dist/esm/ui/extensions/synced-block/constants.js +0 -26
  66. package/dist/esm/ui/extensions/synced-block/getSyncedBlockExtensionProvider.js +0 -5
  67. package/dist/esm/ui/extensions/synced-block/hooks/useLiveSyncedBlockContent.js +0 -23
  68. package/dist/esm/ui/extensions/synced-block/hooks/usePollContentProperty.js +0 -114
  69. package/dist/esm/ui/extensions/synced-block/index.js +0 -5
  70. package/dist/esm/ui/extensions/synced-block/manifest.js +0 -274
  71. package/dist/esm/ui/extensions/synced-block/utils/ari.js +0 -23
  72. package/dist/esm/ui/extensions/synced-block/utils/content-property.js +0 -153
  73. package/dist/esm/ui/extensions/synced-block/utils/synced-block.js +0 -58
  74. package/dist/types/pm-plugins/SyncClient.d.ts +0 -14
  75. package/dist/types/pm-plugins/utils.d.ts +0 -5
  76. package/dist/types/types/index.d.ts +0 -3
  77. package/dist/types/ui/extensions/synced-block/components/GlobalStyles.d.ts +0 -6
  78. package/dist/types/ui/extensions/synced-block/components/SyncedBlockLiveView.d.ts +0 -7
  79. package/dist/types/ui/extensions/synced-block/components/SyncedBlockRenderer.d.ts +0 -7
  80. package/dist/types/ui/extensions/synced-block/constants.d.ts +0 -8
  81. package/dist/types/ui/extensions/synced-block/getSyncedBlockExtensionProvider.d.ts +0 -3
  82. package/dist/types/ui/extensions/synced-block/hooks/useLiveSyncedBlockContent.d.ts +0 -6
  83. package/dist/types/ui/extensions/synced-block/hooks/usePollContentProperty.d.ts +0 -7
  84. package/dist/types/ui/extensions/synced-block/index.d.ts +0 -2
  85. package/dist/types/ui/extensions/synced-block/manifest.d.ts +0 -3
  86. package/dist/types/ui/extensions/synced-block/utils/ari.d.ts +0 -4
  87. package/dist/types/ui/extensions/synced-block/utils/content-property.d.ts +0 -33
  88. package/dist/types/ui/extensions/synced-block/utils/synced-block.d.ts +0 -24
  89. package/dist/types-ts4.5/pm-plugins/SyncClient.d.ts +0 -14
  90. package/dist/types-ts4.5/pm-plugins/utils.d.ts +0 -5
  91. package/dist/types-ts4.5/types/index.d.ts +0 -3
  92. package/dist/types-ts4.5/ui/extensions/synced-block/components/GlobalStyles.d.ts +0 -6
  93. package/dist/types-ts4.5/ui/extensions/synced-block/components/SyncedBlockLiveView.d.ts +0 -7
  94. package/dist/types-ts4.5/ui/extensions/synced-block/components/SyncedBlockRenderer.d.ts +0 -7
  95. package/dist/types-ts4.5/ui/extensions/synced-block/constants.d.ts +0 -8
  96. package/dist/types-ts4.5/ui/extensions/synced-block/getSyncedBlockExtensionProvider.d.ts +0 -3
  97. package/dist/types-ts4.5/ui/extensions/synced-block/hooks/useLiveSyncedBlockContent.d.ts +0 -6
  98. package/dist/types-ts4.5/ui/extensions/synced-block/hooks/usePollContentProperty.d.ts +0 -7
  99. package/dist/types-ts4.5/ui/extensions/synced-block/index.d.ts +0 -2
  100. package/dist/types-ts4.5/ui/extensions/synced-block/manifest.d.ts +0 -3
  101. package/dist/types-ts4.5/ui/extensions/synced-block/utils/ari.d.ts +0 -4
  102. package/dist/types-ts4.5/ui/extensions/synced-block/utils/content-property.d.ts +0 -33
  103. package/dist/types-ts4.5/ui/extensions/synced-block/utils/synced-block.d.ts +0 -24
@@ -1,274 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
- import _regeneratorRuntime from "@babel/runtime/regenerator";
4
- import React from 'react';
5
- import { copyHTMLToClipboard } from '@atlaskit/editor-common/clipboard';
6
- import { DOMSerializer, Fragment, Mark } from '@atlaskit/editor-prosemirror/model';
7
- import SmartLinkIcon from '@atlaskit/icon/core/smart-link';
8
- import SyncedBlockLiveView from './components/SyncedBlockLiveView';
9
- import { getPageId } from './constants';
10
- import { getConfluencePageAri, getContentPropertyAri } from './utils/ari';
11
- import { createContentProperty } from './utils/content-property';
12
- import { SYNCED_BLOCK_EXTENSION_KEY, SYNCED_BLOCK_EXTENSION_TYPE, SYNCED_BLOCK_REFERENCE_KEY, SYNCED_BLOCK_REFERENCE_NODE, SYNCED_BLOCK_SOURCE_KEY, SYNCED_BLOCK_SOURCE_NODE, getDefaultSyncedBlockContent, isSyncedBlockAttributes, stringifySyncedBlockContentPropertyValue } from './utils/synced-block';
13
- var getRandomId = function getRandomId() {
14
- if (!globalThis.crypto || typeof globalThis.crypto.randomUUID !== 'function') {
15
- return new Date().toISOString();
16
- }
17
- return globalThis.crypto.randomUUID();
18
- };
19
- var copyToClipboard = function copyToClipboard(adf, schema) {
20
- if (!schema) {
21
- throw new Error('copyToClipboard(): Schema is required.');
22
- }
23
-
24
- // Validate the given ADF
25
- var nodeType = schema.nodes[adf.type];
26
- if (!nodeType) {
27
- throw new Error("copyToClipboard(): Invalid ADF type '".concat(adf.type, "'."));
28
- }
29
- var fragment = Fragment.fromJSON(schema, adf.content);
30
- var marks = (adf.marks || []).map(function (markEntity) {
31
- return Mark.fromJSON(schema, markEntity);
32
- });
33
- var newNode = nodeType === null || nodeType === void 0 ? void 0 : nodeType.createChecked(adf.attrs, fragment, marks);
34
- if (!newNode) {
35
- throw new Error('copyToClipboard(): Could not create a node for given ADFEntity.');
36
- }
37
- var domNode = DOMSerializer.fromSchema(schema).serializeNode(newNode);
38
- var div = document.createElement('div');
39
- div.appendChild(domNode);
40
- copyHTMLToClipboard(div);
41
- };
42
-
43
- // Remaining tasks
44
- // - Better location for content sync implementation – currently done in SyncedBlockSource renderer which won't work in editor
45
- // - Could implement an editor plugin to do this, if there's no native way to do it with extensions
46
- // - Implement separate content property for storage of the metadata of a synced block, separate from the content
47
- // - Update polling to use the metadata content property, then if metadata updated, fetch the content property
48
- // - Investigate re-rendering of SyncedBlockReference in editor on every document change (is this just atlaskit behavior?)
49
- // - On copy of the synced block, transform into a reference
50
- // - Move implementation into Confluence and test in branch environment
51
- // - Dealing with orphaned synced block content properties data
52
- // - Getting current page id in editor context and the cloud id
53
- // - Explore hiding the frame for the extension in the editor, currently using `__hideFrame: true` and commented code to enable
54
- export var getSyncedBlockManifest = function getSyncedBlockManifest(schema) {
55
- return {
56
- title: 'Synced Block',
57
- type: SYNCED_BLOCK_EXTENSION_TYPE,
58
- key: SYNCED_BLOCK_EXTENSION_KEY,
59
- description: 'Synced block spike',
60
- icons: {
61
- // Ignored via go/ees005
62
- // eslint-disable-next-line require-await
63
- '48': function () {
64
- var _2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
65
- return _regeneratorRuntime.wrap(function _callee$(_context) {
66
- while (1) switch (_context.prev = _context.next) {
67
- case 0:
68
- return _context.abrupt("return", function () {
69
- return /*#__PURE__*/React.createElement(SmartLinkIcon, {
70
- label: "Synced Block",
71
- size: "medium"
72
- });
73
- });
74
- case 1:
75
- case "end":
76
- return _context.stop();
77
- }
78
- }, _callee);
79
- }));
80
- function _() {
81
- return _2.apply(this, arguments);
82
- }
83
- return _;
84
- }()
85
- },
86
- modules: {
87
- quickInsert: [{
88
- key: 'quick-insert-synced-block-source',
89
- action: function () {
90
- var _action = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_api) {
91
- var contentPropertyKey, content, value, contentProperty, attributes;
92
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
93
- while (1) switch (_context2.prev = _context2.next) {
94
- case 0:
95
- contentPropertyKey = "synced-block-" + getRandomId();
96
- content = getDefaultSyncedBlockContent();
97
- value = stringifySyncedBlockContentPropertyValue({
98
- adf: content
99
- });
100
- _context2.next = 5;
101
- return createContentProperty({
102
- pageId: getPageId(),
103
- key: contentPropertyKey,
104
- value: value
105
- });
106
- case 5:
107
- contentProperty = _context2.sent;
108
- attributes = {
109
- extensionType: SYNCED_BLOCK_EXTENSION_TYPE,
110
- extensionKey: SYNCED_BLOCK_SOURCE_KEY,
111
- parameters: {
112
- sourceDocumentAri: getConfluencePageAri(getPageId()),
113
- contentAri: getContentPropertyAri(contentProperty.id),
114
- contentPropertyKey: contentPropertyKey
115
- },
116
- localId: 'testId'
117
- };
118
- content.attrs = attributes;
119
- return _context2.abrupt("return", content);
120
- case 9:
121
- case "end":
122
- return _context2.stop();
123
- }
124
- }, _callee2);
125
- }));
126
- function action(_x) {
127
- return _action.apply(this, arguments);
128
- }
129
- return action;
130
- }()
131
- }],
132
- nodes: _defineProperty(_defineProperty({}, SYNCED_BLOCK_SOURCE_NODE, {
133
- type: 'bodiedExtension',
134
- // Ignored via go/ees005
135
- // eslint-disable-next-line require-await
136
- render: function () {
137
- var _render = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
138
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
139
- while (1) switch (_context3.prev = _context3.next) {
140
- case 0:
141
- return _context3.abrupt("return", function (props) {
142
- if (!isSyncedBlockAttributes(props.node)) {
143
- return null;
144
- }
145
- var _props$node$parameter = props.node.parameters,
146
- sourceDocumentAri = _props$node$parameter.sourceDocumentAri,
147
- contentAri = _props$node$parameter.contentAri;
148
- return /*#__PURE__*/React.createElement(SyncedBlockLiveView, {
149
- sourceDocumentAri: sourceDocumentAri,
150
- contentAri: contentAri
151
- });
152
- });
153
- case 1:
154
- case "end":
155
- return _context3.stop();
156
- }
157
- }, _callee3);
158
- }));
159
- function render() {
160
- return _render.apply(this, arguments);
161
- }
162
- return render;
163
- }(),
164
- // @ts-expect-error
165
- __hideFrame: true
166
- }), SYNCED_BLOCK_REFERENCE_NODE, {
167
- type: 'extension',
168
- // Ignored via go/ees005
169
- // eslint-disable-next-line require-await
170
- render: function () {
171
- var _render2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
172
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
173
- while (1) switch (_context4.prev = _context4.next) {
174
- case 0:
175
- return _context4.abrupt("return", function (props) {
176
- if (!isSyncedBlockAttributes(props.node)) {
177
- return null;
178
- }
179
- var _props$node$parameter2 = props.node.parameters,
180
- sourceDocumentAri = _props$node$parameter2.sourceDocumentAri,
181
- contentAri = _props$node$parameter2.contentAri;
182
- return /*#__PURE__*/React.createElement(SyncedBlockLiveView, {
183
- sourceDocumentAri: sourceDocumentAri,
184
- contentAri: contentAri
185
- });
186
- });
187
- case 1:
188
- case "end":
189
- return _context4.stop();
190
- }
191
- }, _callee4);
192
- }));
193
- function render() {
194
- return _render2.apply(this, arguments);
195
- }
196
- return render;
197
- }(),
198
- // @ts-expect-error
199
- __hideFrame: true
200
- }),
201
- contextualToolbars: [{
202
- context: {
203
- type: 'extension',
204
- nodeType: 'bodiedExtension',
205
- extensionType: SYNCED_BLOCK_EXTENSION_TYPE,
206
- extensionKey: SYNCED_BLOCK_SOURCE_KEY
207
- },
208
- toolbarItems: [{
209
- key: 'toolbar-item-key',
210
- label: 'Referenece',
211
- display: 'icon',
212
- tooltip: 'Copy reference to clipboard',
213
- // Ignored via go/ees005
214
- // eslint-disable-next-line require-await
215
- icon: function () {
216
- var _icon = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
217
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
218
- while (1) switch (_context5.prev = _context5.next) {
219
- case 0:
220
- return _context5.abrupt("return", function () {
221
- return /*#__PURE__*/React.createElement(SmartLinkIcon, {
222
- label: "Synced Block",
223
- size: "medium"
224
- });
225
- });
226
- case 1:
227
- case "end":
228
- return _context5.stop();
229
- }
230
- }, _callee5);
231
- }));
232
- function icon() {
233
- return _icon.apply(this, arguments);
234
- }
235
- return icon;
236
- }(),
237
- // Ignored via go/ees005
238
- // eslint-disable-next-line require-await
239
- action: function () {
240
- var _action2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(contextNode) {
241
- var _contextNode$attrs, _contextNode$attrs2;
242
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
243
- while (1) switch (_context6.prev = _context6.next) {
244
- case 0:
245
- try {
246
- copyToClipboard({
247
- type: 'extension',
248
- attrs: {
249
- extensionType: SYNCED_BLOCK_EXTENSION_TYPE,
250
- extensionKey: SYNCED_BLOCK_REFERENCE_KEY,
251
- parameters: {
252
- sourceDocumentAri: (_contextNode$attrs = contextNode.attrs) === null || _contextNode$attrs === void 0 || (_contextNode$attrs = _contextNode$attrs.parameters) === null || _contextNode$attrs === void 0 ? void 0 : _contextNode$attrs.sourceDocumentAri,
253
- contentAri: (_contextNode$attrs2 = contextNode.attrs) === null || _contextNode$attrs2 === void 0 || (_contextNode$attrs2 = _contextNode$attrs2.parameters) === null || _contextNode$attrs2 === void 0 ? void 0 : _contextNode$attrs2.contentAri
254
- },
255
- localId: 'testId'
256
- }
257
- }, schema);
258
- } catch (e) {}
259
- case 1:
260
- case "end":
261
- return _context6.stop();
262
- }
263
- }, _callee6);
264
- }));
265
- function action(_x2) {
266
- return _action2.apply(this, arguments);
267
- }
268
- return action;
269
- }()
270
- }]
271
- }]
272
- }
273
- };
274
- };
@@ -1,23 +0,0 @@
1
- import { getCloudId } from '../constants';
2
- export var getConfluencePageAri = function getConfluencePageAri(pageId) {
3
- return "ari:cloud:confluence:".concat(getCloudId(), ":page/").concat(pageId);
4
- };
5
- export var getPageIdFromAri = function getPageIdFromAri(ari) {
6
- // eslint-disable-next-line require-unicode-regexp
7
- var match = ari.match(/ari:cloud:confluence:[^:]+:page\/(\d+)/);
8
- if (match) {
9
- return match[1];
10
- }
11
- throw new Error("Invalid page ARI: ".concat(ari));
12
- };
13
- export var getContentPropertyAri = function getContentPropertyAri(contentPropertyId) {
14
- return "ari:cloud:confluence:".concat(getCloudId(), ":content/").concat(contentPropertyId);
15
- };
16
- export var getContentPropertyIdFromAri = function getContentPropertyIdFromAri(ari) {
17
- // eslint-disable-next-line require-unicode-regexp
18
- var match = ari.match(/ari:cloud:confluence:[^:]+:content\/([^/]+)/);
19
- if (match) {
20
- return match[1];
21
- }
22
- throw new Error("Invalid content property ARI: ".concat(ari));
23
- };
@@ -1,153 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
- import _regeneratorRuntime from "@babel/runtime/regenerator";
3
- import { getCloudId } from '../constants';
4
- import { getConfluencePageAri } from './ari';
5
-
6
- // Uncomment for proxy in Atlaskit, which will route to hello.atlassian.net
7
- // const BASE_URL = 'https://localhost:9876';
8
- var BASE_URL = "/gateway/api/ex/confluence/".concat(getCloudId());
9
- var API_BASE_URL = "".concat(BASE_URL, "/wiki/api/v2");
10
- var COMMON_HEADERS = {
11
- 'Content-Type': 'application/json',
12
- Accept: 'application/json'
13
- };
14
- var getContentPropertiesUrl = function getContentPropertiesUrl(_ref) {
15
- var pageId = _ref.pageId,
16
- contentPropertyId = _ref.contentPropertyId;
17
- var url = "".concat(API_BASE_URL, "/pages/").concat(pageId, "/properties");
18
- if (contentPropertyId) {
19
- return "".concat(url, "/").concat(contentPropertyId);
20
- }
21
- return url;
22
- };
23
- var getGraphQLPropertiesUrl = function getGraphQLPropertiesUrl() {
24
- return "/cgraphql/api/graphql";
25
- };
26
- export var createContentProperty = /*#__PURE__*/function () {
27
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2) {
28
- var pageId, key, value, url, body, response, contentProperty;
29
- return _regeneratorRuntime.wrap(function _callee$(_context) {
30
- while (1) switch (_context.prev = _context.next) {
31
- case 0:
32
- pageId = _ref2.pageId, key = _ref2.key, value = _ref2.value;
33
- url = getContentPropertiesUrl({
34
- pageId: pageId
35
- });
36
- body = JSON.stringify({
37
- key: key,
38
- value: value
39
- });
40
- _context.next = 5;
41
- return fetch(url, {
42
- method: 'POST',
43
- headers: COMMON_HEADERS,
44
- body: body
45
- });
46
- case 5:
47
- response = _context.sent;
48
- if (response.ok) {
49
- _context.next = 8;
50
- break;
51
- }
52
- throw new Error("Failed to create content property: ".concat(response.statusText));
53
- case 8:
54
- _context.next = 10;
55
- return response.json();
56
- case 10:
57
- contentProperty = _context.sent;
58
- return _context.abrupt("return", contentProperty);
59
- case 12:
60
- case "end":
61
- return _context.stop();
62
- }
63
- }, _callee);
64
- }));
65
- return function createContentProperty(_x) {
66
- return _ref3.apply(this, arguments);
67
- };
68
- }();
69
- export var getContentProperty = /*#__PURE__*/function () {
70
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref4) {
71
- var pageId, contentPropertyId, signal, url, response, contentProperty;
72
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
73
- while (1) switch (_context2.prev = _context2.next) {
74
- case 0:
75
- pageId = _ref4.pageId, contentPropertyId = _ref4.contentPropertyId, signal = _ref4.signal;
76
- url = getContentPropertiesUrl({
77
- pageId: pageId,
78
- contentPropertyId: contentPropertyId
79
- });
80
- _context2.next = 4;
81
- return fetch(url, {
82
- method: 'GET',
83
- headers: COMMON_HEADERS,
84
- signal: signal
85
- });
86
- case 4:
87
- response = _context2.sent;
88
- if (response.ok) {
89
- _context2.next = 7;
90
- break;
91
- }
92
- throw new Error("Failed to get content property: ".concat(response.statusText));
93
- case 7:
94
- _context2.next = 9;
95
- return response.json();
96
- case 9:
97
- contentProperty = _context2.sent;
98
- return _context2.abrupt("return", contentProperty);
99
- case 11:
100
- case "end":
101
- return _context2.stop();
102
- }
103
- }, _callee2);
104
- }));
105
- return function getContentProperty(_x2) {
106
- return _ref5.apply(this, arguments);
107
- };
108
- }();
109
- var getQuery = function getQuery(documentARI, key, value) {
110
- return "mutation {\n\t confluence {\n\t updateValuePageProperty(input: {\n\t pageId: \"".concat(documentARI, "\",\n\t key: \"").concat(key, "\",\n\t value: \"").concat(value, "\",\n\t useSameVersion: true\n\t }) {\n\t pageProperty {\n\t key,\n\t value\n\t }\n\t }\n\t }\n\t}");
111
- };
112
- export var updateContentProperty = /*#__PURE__*/function () {
113
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref6) {
114
- var pageId, key, value, url, documentARI, query, bodyData, response, contentProperty;
115
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
116
- while (1) switch (_context3.prev = _context3.next) {
117
- case 0:
118
- pageId = _ref6.pageId, key = _ref6.key, value = _ref6.value;
119
- url = getGraphQLPropertiesUrl();
120
- documentARI = getConfluencePageAri(pageId); // eslint-disable-next-line require-unicode-regexp
121
- query = getQuery(documentARI, key, value.replace(/"/g, '\\"'));
122
- bodyData = {
123
- query: query
124
- };
125
- _context3.next = 7;
126
- return fetch(url, {
127
- method: 'POST',
128
- headers: COMMON_HEADERS,
129
- body: JSON.stringify(bodyData)
130
- });
131
- case 7:
132
- response = _context3.sent;
133
- if (response.ok) {
134
- _context3.next = 10;
135
- break;
136
- }
137
- throw new Error("Failed to update content property: ".concat(response.statusText));
138
- case 10:
139
- _context3.next = 12;
140
- return response.json();
141
- case 12:
142
- contentProperty = _context3.sent;
143
- return _context3.abrupt("return", contentProperty);
144
- case 14:
145
- case "end":
146
- return _context3.stop();
147
- }
148
- }, _callee3);
149
- }));
150
- return function updateContentProperty(_x3) {
151
- return _ref7.apply(this, arguments);
152
- };
153
- }();
@@ -1,58 +0,0 @@
1
- import _typeof from "@babel/runtime/helpers/typeof";
2
- export var SYNCED_BLOCK_EXTENSION_TYPE = 'com.atlassian.platform.extensions';
3
- export var SYNCED_BLOCK_EXTENSION_KEY = 'synced-block';
4
- export var SYNCED_BLOCK_SOURCE_NODE = 'source';
5
- export var SYNCED_BLOCK_SOURCE_KEY = "".concat(SYNCED_BLOCK_EXTENSION_KEY, ":").concat(SYNCED_BLOCK_SOURCE_NODE);
6
- export var SYNCED_BLOCK_REFERENCE_NODE = 'reference';
7
- export var SYNCED_BLOCK_REFERENCE_KEY = "".concat(SYNCED_BLOCK_EXTENSION_KEY, ":").concat(SYNCED_BLOCK_REFERENCE_NODE);
8
- export var isSyncedBlockAttributes = function isSyncedBlockAttributes(attributes) {
9
- return !!attributes && _typeof(attributes) === 'object' && 'extensionKey' in attributes && (attributes.extensionKey === SYNCED_BLOCK_SOURCE_KEY || attributes.extensionKey === SYNCED_BLOCK_REFERENCE_KEY);
10
- };
11
- export var getDefaultSyncedBlockContent = function getDefaultSyncedBlockContent() {
12
- var attributes = {
13
- extensionType: SYNCED_BLOCK_EXTENSION_TYPE,
14
- extensionKey: SYNCED_BLOCK_SOURCE_KEY,
15
- parameters: {
16
- sourceDocumentAri: '',
17
- contentAri: '',
18
- contentPropertyKey: ''
19
- },
20
- localId: ''
21
- };
22
- return {
23
- type: 'bodiedExtension',
24
- attrs: attributes,
25
- content: [{
26
- type: 'paragraph',
27
- content: [{
28
- type: 'text',
29
- text: 'This is a synced block. Please edit the source document to update the content.'
30
- }]
31
- }]
32
- };
33
- };
34
- export var parseSyncedBlockContentPropertyValue = function parseSyncedBlockContentPropertyValue(value) {
35
- try {
36
- if (typeof value === 'string') {
37
- return JSON.parse(value);
38
- }
39
- return value;
40
- } catch (error) {
41
- // eslint-disable-next-line no-console
42
- console.error('Failed to parse synced block content:', error);
43
- return {
44
- adf: getDefaultSyncedBlockContent()
45
- };
46
- }
47
- };
48
- export var stringifySyncedBlockContentPropertyValue = function stringifySyncedBlockContentPropertyValue(value) {
49
- try {
50
- return JSON.stringify(value);
51
- } catch (error) {
52
- // eslint-disable-next-line no-console
53
- console.error('Failed to serialize synced block content:', error);
54
- return JSON.stringify({
55
- adf: getDefaultSyncedBlockContent()
56
- });
57
- }
58
- };
@@ -1,14 +0,0 @@
1
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- export declare class SyncClient {
3
- private requestMap;
4
- constructor();
5
- private getRequestState;
6
- private setRequestState;
7
- private sendRequest;
8
- syncContent({ sourceDocumentAri, contentAri, contentPropertyKey, node, }: {
9
- contentAri: string;
10
- contentPropertyKey: string;
11
- node: PMNode;
12
- sourceDocumentAri: string;
13
- }): void;
14
- }
@@ -1,5 +0,0 @@
1
- import type { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
2
- export declare const findSyncedBlockParent: ($pos: ResolvedPos) => {
3
- node: import("prosemirror-model").Node;
4
- attributes: import("../ui/extensions/synced-block/utils/synced-block").SyncedBlockAttributes;
5
- } | undefined;
@@ -1,3 +0,0 @@
1
- export type SyncedBlockPluginOptions = {
2
- clouldId?: string;
3
- };
@@ -1,6 +0,0 @@
1
- /**
2
- * @jsxRuntime classic
3
- * @jsx jsx
4
- */
5
- import { jsx } from '@emotion/react';
6
- export declare const GlobalStylesWrapper: () => jsx.JSX.Element;
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- type SyncedBlockLiveView = {
3
- contentAri: string;
4
- sourceDocumentAri: string;
5
- };
6
- declare const SyncedBlockLiveView: ({ sourceDocumentAri, contentAri }: SyncedBlockLiveView) => React.JSX.Element;
7
- export default SyncedBlockLiveView;
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- import type { SyncedBlockContentPropertyValue } from '../utils/synced-block';
3
- type SyncedBlockRenderer = {
4
- syncedBlockContent: SyncedBlockContentPropertyValue;
5
- };
6
- declare const SyncedBlockRenderer: ({ syncedBlockContent }: SyncedBlockRenderer) => React.JSX.Element;
7
- export default SyncedBlockRenderer;
@@ -1,8 +0,0 @@
1
- export declare const getPageId: () => string;
2
- /**
3
- * This by no means is a stable way to get the cloud id, but it works for now.
4
- * We should switch passing the cloud id from Confluence to a Editor plugin,
5
- * for instance the user preferences plugin would have a seperate place for user and cloud info
6
- * @returns the cloud id from the initial state
7
- */
8
- export declare const getCloudId: () => string;
@@ -1,3 +0,0 @@
1
- import { DefaultExtensionProvider } from '@atlaskit/editor-common/extensions';
2
- import type { Schema } from '@atlaskit/editor-prosemirror/model';
3
- export declare const getSyncedBlockExtensionProvider: (schema?: Schema) => DefaultExtensionProvider<import("@atlaskit/editor-common/extensions").Parameters>;
@@ -1,6 +0,0 @@
1
- type UseLiveSyncedBlockContentOptions = {
2
- contentAri: string;
3
- sourceDocumentAri: string;
4
- };
5
- export declare const useLiveSyncedBlockContent: ({ sourceDocumentAri, contentAri, }: UseLiveSyncedBlockContentOptions) => import("../utils/synced-block").SyncedBlockContentPropertyValue | null;
6
- export {};
@@ -1,7 +0,0 @@
1
- import type { ContentProperty } from '../utils/content-property';
2
- type UsePollContentPropertyOptions = {
3
- contentAri: string;
4
- sourceDocumentAri: string;
5
- };
6
- export declare const usePollContentProperty: ({ sourceDocumentAri, contentAri, }: UsePollContentPropertyOptions) => ContentProperty | undefined;
7
- export {};
@@ -1,2 +0,0 @@
1
- export { getSyncedBlockExtensionProvider } from './getSyncedBlockExtensionProvider';
2
- export { getSyncedBlockManifest } from './manifest';
@@ -1,3 +0,0 @@
1
- import type { ExtensionManifest } from '@atlaskit/editor-common/extensions';
2
- import { type Schema } from '@atlaskit/editor-prosemirror/model';
3
- export declare const getSyncedBlockManifest: (schema?: Schema) => ExtensionManifest;
@@ -1,4 +0,0 @@
1
- export declare const getConfluencePageAri: (pageId: string) => string;
2
- export declare const getPageIdFromAri: (ari: string) => string;
3
- export declare const getContentPropertyAri: (contentPropertyId: string) => string;
4
- export declare const getContentPropertyIdFromAri: (ari: string) => string;
@@ -1,33 +0,0 @@
1
- export type ContentProperty = {
2
- id: string;
3
- key: string;
4
- value: string;
5
- version: ContentPropertyVersion;
6
- };
7
- type ContentPropertyVersion = {
8
- authorId: string;
9
- createdAt: string;
10
- message: string;
11
- minorEdit: boolean;
12
- number: number;
13
- };
14
- type CreateContentPropertyOptions = {
15
- key: string;
16
- pageId: string;
17
- value: string;
18
- };
19
- export declare const createContentProperty: ({ pageId, key, value, }: CreateContentPropertyOptions) => Promise<ContentProperty>;
20
- type GetContentPropertyOptions = {
21
- contentPropertyId: string;
22
- pageId: string;
23
- signal?: AbortSignal;
24
- };
25
- export declare const getContentProperty: ({ pageId, contentPropertyId, signal, }: GetContentPropertyOptions) => Promise<ContentProperty>;
26
- type UpdateContentPropertyOptions = {
27
- key: string;
28
- pageId: string;
29
- signal?: AbortSignal;
30
- value: string;
31
- };
32
- export declare const updateContentProperty: ({ pageId, key, value, }: UpdateContentPropertyOptions) => Promise<ContentProperty>;
33
- export {};
@@ -1,24 +0,0 @@
1
- import type { ADFEntity } from '@atlaskit/adf-utils/types';
2
- export declare const SYNCED_BLOCK_EXTENSION_TYPE = "com.atlassian.platform.extensions";
3
- export declare const SYNCED_BLOCK_EXTENSION_KEY = "synced-block";
4
- export declare const SYNCED_BLOCK_SOURCE_NODE = "source";
5
- export declare const SYNCED_BLOCK_SOURCE_KEY = "synced-block:source";
6
- export declare const SYNCED_BLOCK_REFERENCE_NODE = "reference";
7
- export declare const SYNCED_BLOCK_REFERENCE_KEY = "synced-block:reference";
8
- export type SyncedBlockAttributes = {
9
- extensionKey: typeof SYNCED_BLOCK_SOURCE_KEY | typeof SYNCED_BLOCK_REFERENCE_KEY;
10
- extensionType: typeof SYNCED_BLOCK_EXTENSION_TYPE;
11
- localId: string;
12
- parameters: {
13
- contentAri: string;
14
- contentPropertyKey: string;
15
- sourceDocumentAri: string;
16
- };
17
- };
18
- export declare const isSyncedBlockAttributes: (attributes: unknown) => attributes is SyncedBlockAttributes;
19
- export type SyncedBlockContentPropertyValue = {
20
- adf: ADFEntity;
21
- };
22
- export declare const getDefaultSyncedBlockContent: () => ADFEntity;
23
- export declare const parseSyncedBlockContentPropertyValue: (value: string | object) => SyncedBlockContentPropertyValue;
24
- export declare const stringifySyncedBlockContentPropertyValue: (value: SyncedBlockContentPropertyValue) => string;