@atlaskit/editor-plugin-synced-block 0.1.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 +12 -0
- package/LICENSE.md +11 -0
- package/README.md +1 -0
- package/SyncedBlock/package.json +15 -0
- package/afm-cc/tsconfig.json +44 -0
- package/build/tsconfig.json +22 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/pm-plugins/SyncClient.js +167 -0
- package/dist/cjs/pm-plugins/main.js +50 -0
- package/dist/cjs/pm-plugins/utils.js +19 -0
- package/dist/cjs/syncedBlockPlugin.js +24 -0
- package/dist/cjs/syncedBlockPluginType.js +5 -0
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/ui/extensions/synced-block/components/GlobalStyles.js +25 -0
- package/dist/cjs/ui/extensions/synced-block/components/SyncedBlockLiveView.js +25 -0
- package/dist/cjs/ui/extensions/synced-block/components/SyncedBlockRenderer.js +25 -0
- package/dist/cjs/ui/extensions/synced-block/constants.js +32 -0
- package/dist/cjs/ui/extensions/synced-block/getSyncedBlockExtensionProvider.js +11 -0
- package/dist/cjs/ui/extensions/synced-block/hooks/useLiveSyncedBlockContent.js +29 -0
- package/dist/cjs/ui/extensions/synced-block/hooks/usePollContentProperty.js +121 -0
- package/dist/cjs/ui/extensions/synced-block/index.js +19 -0
- package/dist/cjs/ui/extensions/synced-block/manifest.js +254 -0
- package/dist/cjs/ui/extensions/synced-block/utils/ari.js +29 -0
- package/dist/cjs/ui/extensions/synced-block/utils/content-property.js +159 -0
- package/dist/cjs/ui/extensions/synced-block/utils/synced-block.js +65 -0
- package/dist/es2019/index.js +4 -0
- package/dist/es2019/pm-plugins/SyncClient.js +102 -0
- package/dist/es2019/pm-plugins/main.js +47 -0
- package/dist/es2019/pm-plugins/utils.js +13 -0
- package/dist/es2019/syncedBlockPlugin.js +17 -0
- package/dist/es2019/syncedBlockPluginType.js +1 -0
- package/dist/es2019/types/index.js +0 -0
- package/dist/es2019/ui/extensions/synced-block/components/GlobalStyles.js +18 -0
- package/dist/es2019/ui/extensions/synced-block/components/SyncedBlockLiveView.js +19 -0
- package/dist/es2019/ui/extensions/synced-block/components/SyncedBlockRenderer.js +19 -0
- package/dist/es2019/ui/extensions/synced-block/constants.js +26 -0
- package/dist/es2019/ui/extensions/synced-block/getSyncedBlockExtensionProvider.js +5 -0
- package/dist/es2019/ui/extensions/synced-block/hooks/useLiveSyncedBlockContent.js +24 -0
- package/dist/es2019/ui/extensions/synced-block/hooks/usePollContentProperty.js +107 -0
- package/dist/es2019/ui/extensions/synced-block/index.js +5 -0
- package/dist/es2019/ui/extensions/synced-block/manifest.js +147 -0
- package/dist/es2019/ui/extensions/synced-block/utils/ari.js +19 -0
- package/dist/es2019/ui/extensions/synced-block/utils/content-property.js +108 -0
- package/dist/es2019/ui/extensions/synced-block/utils/synced-block.js +57 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/pm-plugins/SyncClient.js +160 -0
- package/dist/esm/pm-plugins/main.js +44 -0
- package/dist/esm/pm-plugins/utils.js +13 -0
- package/dist/esm/syncedBlockPlugin.js +17 -0
- package/dist/esm/syncedBlockPluginType.js +1 -0
- package/dist/esm/types/index.js +0 -0
- package/dist/esm/ui/extensions/synced-block/components/GlobalStyles.js +18 -0
- package/dist/esm/ui/extensions/synced-block/components/SyncedBlockLiveView.js +18 -0
- package/dist/esm/ui/extensions/synced-block/components/SyncedBlockRenderer.js +18 -0
- package/dist/esm/ui/extensions/synced-block/constants.js +26 -0
- package/dist/esm/ui/extensions/synced-block/getSyncedBlockExtensionProvider.js +5 -0
- package/dist/esm/ui/extensions/synced-block/hooks/useLiveSyncedBlockContent.js +23 -0
- package/dist/esm/ui/extensions/synced-block/hooks/usePollContentProperty.js +114 -0
- package/dist/esm/ui/extensions/synced-block/index.js +5 -0
- package/dist/esm/ui/extensions/synced-block/manifest.js +247 -0
- package/dist/esm/ui/extensions/synced-block/utils/ari.js +23 -0
- package/dist/esm/ui/extensions/synced-block/utils/content-property.js +153 -0
- package/dist/esm/ui/extensions/synced-block/utils/synced-block.js +58 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/pm-plugins/SyncClient.d.ts +14 -0
- package/dist/types/pm-plugins/main.d.ts +6 -0
- package/dist/types/pm-plugins/utils.d.ts +5 -0
- package/dist/types/syncedBlockPlugin.d.ts +2 -0
- package/dist/types/syncedBlockPluginType.d.ts +2 -0
- package/dist/types/types/index.d.ts +3 -0
- package/dist/types/ui/extensions/synced-block/components/GlobalStyles.d.ts +6 -0
- package/dist/types/ui/extensions/synced-block/components/SyncedBlockLiveView.d.ts +7 -0
- package/dist/types/ui/extensions/synced-block/components/SyncedBlockRenderer.d.ts +7 -0
- package/dist/types/ui/extensions/synced-block/constants.d.ts +8 -0
- package/dist/types/ui/extensions/synced-block/getSyncedBlockExtensionProvider.d.ts +2 -0
- package/dist/types/ui/extensions/synced-block/hooks/useLiveSyncedBlockContent.d.ts +6 -0
- package/dist/types/ui/extensions/synced-block/hooks/usePollContentProperty.d.ts +7 -0
- package/dist/types/ui/extensions/synced-block/index.d.ts +2 -0
- package/dist/types/ui/extensions/synced-block/manifest.d.ts +2 -0
- package/dist/types/ui/extensions/synced-block/utils/ari.d.ts +4 -0
- package/dist/types/ui/extensions/synced-block/utils/content-property.d.ts +33 -0
- package/dist/types/ui/extensions/synced-block/utils/synced-block.d.ts +24 -0
- package/dist/types-ts4.5/index.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/SyncClient.d.ts +14 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +6 -0
- package/dist/types-ts4.5/pm-plugins/utils.d.ts +5 -0
- package/dist/types-ts4.5/syncedBlockPlugin.d.ts +2 -0
- package/dist/types-ts4.5/syncedBlockPluginType.d.ts +2 -0
- package/dist/types-ts4.5/types/index.d.ts +3 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/components/GlobalStyles.d.ts +6 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/components/SyncedBlockLiveView.d.ts +7 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/components/SyncedBlockRenderer.d.ts +7 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/constants.d.ts +8 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/getSyncedBlockExtensionProvider.d.ts +2 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/hooks/useLiveSyncedBlockContent.d.ts +6 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/hooks/usePollContentProperty.d.ts +7 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/index.d.ts +2 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/manifest.d.ts +2 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/utils/ari.d.ts +4 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/utils/content-property.d.ts +33 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/utils/synced-block.d.ts +24 -0
- package/docs/0-intro.tsx +43 -0
- package/package.json +88 -0
- package/tsconfig.json +8 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# @atlaskit/editor-plugin-synced-block
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`c29118e6ca79d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c29118e6ca79d) -
|
|
8
|
+
ED-28986 create initial version of synced blocks
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Copyright 2019 Atlassian Pty Ltd
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
|
|
4
|
+
compliance with the License. You may obtain a copy of the License at
|
|
5
|
+
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
|
|
8
|
+
Unless required by applicable law or agreed to in writing, software distributed under the License is
|
|
9
|
+
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
10
|
+
implied. See the License for the specific language governing permissions and limitations under the
|
|
11
|
+
License.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Editor plugin synced block
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/editor-plugin-synced-block/SyncedBlock",
|
|
3
|
+
"main": "../dist/cjs/ui/extensions/synced-block/index.js",
|
|
4
|
+
"module": "../dist/esm/ui/extensions/synced-block/index.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/ui/extensions/synced-block/index.js",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"types": "../dist/types/ui/extensions/synced-block/index.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.5 <5.9": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.5/ui/extensions/synced-block/index.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../../tsconfig.entry-points.confluence.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "es5",
|
|
5
|
+
"outDir": "../../../../../confluence/tsDist/@atlaskit__editor-plugin-synced-block",
|
|
6
|
+
"rootDir": "../",
|
|
7
|
+
"composite": true
|
|
8
|
+
},
|
|
9
|
+
"include": [
|
|
10
|
+
"../src/**/*.ts",
|
|
11
|
+
"../src/**/*.tsx"
|
|
12
|
+
],
|
|
13
|
+
"exclude": [
|
|
14
|
+
"../src/**/__tests__/*",
|
|
15
|
+
"../src/**/*.test.*",
|
|
16
|
+
"../src/**/test.*",
|
|
17
|
+
"../src/**/examples.*",
|
|
18
|
+
"../src/**/examples/*",
|
|
19
|
+
"../src/**/examples/**/*",
|
|
20
|
+
"../src/**/*.stories.*",
|
|
21
|
+
"../src/**/stories/*",
|
|
22
|
+
"../src/**/stories/**/*"
|
|
23
|
+
],
|
|
24
|
+
"references": [
|
|
25
|
+
{
|
|
26
|
+
"path": "../../adf-utils/afm-cc/tsconfig.json"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"path": "../../editor-json-transformer/afm-cc/tsconfig.json"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"path": "../../../design-system/icon/afm-cc/tsconfig.json"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"path": "../../renderer/afm-cc/tsconfig.json"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"path": "../../../design-system/tokens/afm-cc/tsconfig.json"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"path": "../../editor-common/afm-cc/tsconfig.json"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "es5",
|
|
5
|
+
"paths": {}
|
|
6
|
+
},
|
|
7
|
+
"include": [
|
|
8
|
+
"../src/**/*.ts",
|
|
9
|
+
"../src/**/*.tsx"
|
|
10
|
+
],
|
|
11
|
+
"exclude": [
|
|
12
|
+
"../src/**/__tests__/*",
|
|
13
|
+
"../src/**/*.test.*",
|
|
14
|
+
"../src/**/test.*",
|
|
15
|
+
"../src/**/examples.*",
|
|
16
|
+
"../src/**/examples/*",
|
|
17
|
+
"../src/**/examples/**/*",
|
|
18
|
+
"../src/**/*.stories.*",
|
|
19
|
+
"../src/**/stories/*",
|
|
20
|
+
"../src/**/stories/**/*"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "syncedBlockPlugin", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _syncedBlockPlugin.syncedBlockPlugin;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _syncedBlockPlugin = require("./syncedBlockPlugin");
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.SyncClient = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
var _editorJsonTransformer = require("@atlaskit/editor-json-transformer");
|
|
14
|
+
var _ari = require("../ui/extensions/synced-block/utils/ari");
|
|
15
|
+
var _contentProperty = require("../ui/extensions/synced-block/utils/content-property");
|
|
16
|
+
var _syncedBlock = require("../ui/extensions/synced-block/utils/synced-block");
|
|
17
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
18
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
19
|
+
var transformer = new _editorJsonTransformer.JSONTransformer();
|
|
20
|
+
var toJSON = function toJSON(node) {
|
|
21
|
+
return transformer.encodeNode(node);
|
|
22
|
+
};
|
|
23
|
+
var getCacheKey = function getCacheKey(_ref) {
|
|
24
|
+
var sourceDocumentAri = _ref.sourceDocumentAri,
|
|
25
|
+
contentAri = _ref.contentAri,
|
|
26
|
+
contentPropertyKey = _ref.contentPropertyKey;
|
|
27
|
+
return "".concat(sourceDocumentAri, "-").concat(contentAri, "-").concat(contentPropertyKey);
|
|
28
|
+
};
|
|
29
|
+
var SyncClient = exports.SyncClient = /*#__PURE__*/function () {
|
|
30
|
+
function SyncClient() {
|
|
31
|
+
(0, _classCallCheck2.default)(this, SyncClient);
|
|
32
|
+
(0, _defineProperty2.default)(this, "requestMap", new Map());
|
|
33
|
+
this.requestMap = new Map();
|
|
34
|
+
}
|
|
35
|
+
return (0, _createClass2.default)(SyncClient, [{
|
|
36
|
+
key: "getRequestState",
|
|
37
|
+
value: function getRequestState(key) {
|
|
38
|
+
return this.requestMap.get(key);
|
|
39
|
+
}
|
|
40
|
+
}, {
|
|
41
|
+
key: "setRequestState",
|
|
42
|
+
value: function setRequestState(key, state) {
|
|
43
|
+
this.requestMap.set(key, state);
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
46
|
+
key: "sendRequest",
|
|
47
|
+
value: function () {
|
|
48
|
+
var _sendRequest = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref2) {
|
|
49
|
+
var sourceDocumentAri, contentAri, contentPropertyKey, value, pageId, contentPropertyId, contentProperty, updatedValue;
|
|
50
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
51
|
+
while (1) switch (_context.prev = _context.next) {
|
|
52
|
+
case 0:
|
|
53
|
+
sourceDocumentAri = _ref2.sourceDocumentAri, contentAri = _ref2.contentAri, contentPropertyKey = _ref2.contentPropertyKey, value = _ref2.value;
|
|
54
|
+
pageId = (0, _ari.getPageIdFromAri)(sourceDocumentAri);
|
|
55
|
+
contentPropertyId = (0, _ari.getContentPropertyIdFromAri)(contentAri);
|
|
56
|
+
_context.prev = 3;
|
|
57
|
+
_context.next = 6;
|
|
58
|
+
return (0, _contentProperty.getContentProperty)({
|
|
59
|
+
pageId: pageId,
|
|
60
|
+
contentPropertyId: contentPropertyId
|
|
61
|
+
});
|
|
62
|
+
case 6:
|
|
63
|
+
contentProperty = _context.sent;
|
|
64
|
+
updatedValue = (0, _syncedBlock.stringifySyncedBlockContentPropertyValue)(_objectSpread(_objectSpread({}, (0, _syncedBlock.parseSyncedBlockContentPropertyValue)(contentProperty.value)), JSON.parse(value)));
|
|
65
|
+
_context.next = 10;
|
|
66
|
+
return (0, _contentProperty.updateContentProperty)({
|
|
67
|
+
pageId: pageId,
|
|
68
|
+
key: contentPropertyKey,
|
|
69
|
+
value: updatedValue,
|
|
70
|
+
signal: undefined
|
|
71
|
+
});
|
|
72
|
+
case 10:
|
|
73
|
+
_context.next = 15;
|
|
74
|
+
break;
|
|
75
|
+
case 12:
|
|
76
|
+
_context.prev = 12;
|
|
77
|
+
_context.t0 = _context["catch"](3);
|
|
78
|
+
// eslint-disable-next-line no-console
|
|
79
|
+
console.error('Failed to update content property:', _context.t0);
|
|
80
|
+
case 15:
|
|
81
|
+
case "end":
|
|
82
|
+
return _context.stop();
|
|
83
|
+
}
|
|
84
|
+
}, _callee, null, [[3, 12]]);
|
|
85
|
+
}));
|
|
86
|
+
function sendRequest(_x) {
|
|
87
|
+
return _sendRequest.apply(this, arguments);
|
|
88
|
+
}
|
|
89
|
+
return sendRequest;
|
|
90
|
+
}()
|
|
91
|
+
}, {
|
|
92
|
+
key: "syncContent",
|
|
93
|
+
value: function syncContent(_ref3) {
|
|
94
|
+
var _this = this;
|
|
95
|
+
var sourceDocumentAri = _ref3.sourceDocumentAri,
|
|
96
|
+
contentAri = _ref3.contentAri,
|
|
97
|
+
contentPropertyKey = _ref3.contentPropertyKey,
|
|
98
|
+
node = _ref3.node;
|
|
99
|
+
var nodeAdf = toJSON(node);
|
|
100
|
+
var key = getCacheKey({
|
|
101
|
+
sourceDocumentAri: sourceDocumentAri,
|
|
102
|
+
contentAri: contentAri,
|
|
103
|
+
contentPropertyKey: contentPropertyKey
|
|
104
|
+
});
|
|
105
|
+
var value = (0, _syncedBlock.stringifySyncedBlockContentPropertyValue)({
|
|
106
|
+
adf: nodeAdf
|
|
107
|
+
});
|
|
108
|
+
var requestState = this.getRequestState(key) || {
|
|
109
|
+
timeout: null,
|
|
110
|
+
pendingValue: null,
|
|
111
|
+
isSending: false
|
|
112
|
+
};
|
|
113
|
+
requestState.pendingValue = value;
|
|
114
|
+
if (requestState.isSending) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (requestState.timeout) {
|
|
118
|
+
clearTimeout(requestState.timeout);
|
|
119
|
+
}
|
|
120
|
+
var send = /*#__PURE__*/function () {
|
|
121
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
122
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
123
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
124
|
+
case 0:
|
|
125
|
+
if (!requestState.isSending) {
|
|
126
|
+
_context2.next = 2;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
return _context2.abrupt("return");
|
|
130
|
+
case 2:
|
|
131
|
+
requestState.isSending = true;
|
|
132
|
+
_context2.prev = 3;
|
|
133
|
+
_context2.next = 6;
|
|
134
|
+
return _this.sendRequest({
|
|
135
|
+
sourceDocumentAri: sourceDocumentAri,
|
|
136
|
+
contentAri: contentAri,
|
|
137
|
+
contentPropertyKey: contentPropertyKey,
|
|
138
|
+
value: requestState.pendingValue || ''
|
|
139
|
+
});
|
|
140
|
+
case 6:
|
|
141
|
+
requestState.pendingValue = null;
|
|
142
|
+
_context2.next = 12;
|
|
143
|
+
break;
|
|
144
|
+
case 9:
|
|
145
|
+
_context2.prev = 9;
|
|
146
|
+
_context2.t0 = _context2["catch"](3);
|
|
147
|
+
// eslint-disable-next-line no-console
|
|
148
|
+
console.error('Failed to send synced block content:', _context2.t0);
|
|
149
|
+
case 12:
|
|
150
|
+
_context2.prev = 12;
|
|
151
|
+
requestState.isSending = false;
|
|
152
|
+
return _context2.finish(12);
|
|
153
|
+
case 15:
|
|
154
|
+
case "end":
|
|
155
|
+
return _context2.stop();
|
|
156
|
+
}
|
|
157
|
+
}, _callee2, null, [[3, 9, 12, 15]]);
|
|
158
|
+
}));
|
|
159
|
+
return function send() {
|
|
160
|
+
return _ref4.apply(this, arguments);
|
|
161
|
+
};
|
|
162
|
+
}();
|
|
163
|
+
requestState.timeout = setTimeout(send, 1000);
|
|
164
|
+
this.setRequestState(key, requestState);
|
|
165
|
+
}
|
|
166
|
+
}]);
|
|
167
|
+
}();
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.syncedBlockPluginKey = exports.createPlugin = void 0;
|
|
7
|
+
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
|
+
var _SyncClient = require("./SyncClient");
|
|
10
|
+
var _utils = require("./utils");
|
|
11
|
+
var syncedBlockPluginKey = exports.syncedBlockPluginKey = new _state.PluginKey('syncedBlockPlugin');
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
14
|
+
|
|
15
|
+
var createPlugin = exports.createPlugin = function createPlugin() {
|
|
16
|
+
var syncClient = new _SyncClient.SyncClient();
|
|
17
|
+
return new _safePlugin.SafePlugin({
|
|
18
|
+
key: syncedBlockPluginKey,
|
|
19
|
+
state: {
|
|
20
|
+
init: function init() {
|
|
21
|
+
return {};
|
|
22
|
+
},
|
|
23
|
+
apply: function apply(tr, currentPluginState) {
|
|
24
|
+
if (tr.docChanged) {
|
|
25
|
+
var $pos = tr.selection.$from;
|
|
26
|
+
var syncedBlockParent = (0, _utils.findSyncedBlockParent)($pos);
|
|
27
|
+
if (syncedBlockParent) {
|
|
28
|
+
var node = syncedBlockParent.node,
|
|
29
|
+
attributes = syncedBlockParent.attributes;
|
|
30
|
+
var _attributes$parameter = attributes.parameters,
|
|
31
|
+
sourceDocumentAri = _attributes$parameter.sourceDocumentAri,
|
|
32
|
+
contentAri = _attributes$parameter.contentAri,
|
|
33
|
+
contentPropertyKey = _attributes$parameter.contentPropertyKey;
|
|
34
|
+
syncClient.syncContent({
|
|
35
|
+
sourceDocumentAri: sourceDocumentAri,
|
|
36
|
+
contentAri: contentAri,
|
|
37
|
+
contentPropertyKey: contentPropertyKey,
|
|
38
|
+
node: node
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
var meta = tr.getMeta(syncedBlockPluginKey);
|
|
43
|
+
if (meta) {
|
|
44
|
+
return meta;
|
|
45
|
+
}
|
|
46
|
+
return currentPluginState;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.findSyncedBlockParent = void 0;
|
|
7
|
+
var _syncedBlock = require("../ui/extensions/synced-block/utils/synced-block");
|
|
8
|
+
var findSyncedBlockParent = exports.findSyncedBlockParent = function findSyncedBlockParent($pos) {
|
|
9
|
+
for (var i = 0; i <= $pos.depth; i++) {
|
|
10
|
+
var node = $pos.node(i);
|
|
11
|
+
if ((0, _syncedBlock.isSyncedBlockAttributes)(node.attrs)) {
|
|
12
|
+
return {
|
|
13
|
+
node: node,
|
|
14
|
+
attributes: node.attrs
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return;
|
|
19
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.syncedBlockPlugin = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _main = require("./pm-plugins/main");
|
|
10
|
+
var _GlobalStyles = require("./ui/extensions/synced-block/components/GlobalStyles");
|
|
11
|
+
var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin() {
|
|
12
|
+
return {
|
|
13
|
+
name: 'syncedBlock',
|
|
14
|
+
pmPlugins: function pmPlugins() {
|
|
15
|
+
return [{
|
|
16
|
+
name: 'syncedBlockPlugin',
|
|
17
|
+
plugin: _main.createPlugin
|
|
18
|
+
}];
|
|
19
|
+
},
|
|
20
|
+
contentComponent: function contentComponent() {
|
|
21
|
+
return /*#__PURE__*/_react.default.createElement(_GlobalStyles.GlobalStylesWrapper, null);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.GlobalStylesWrapper = void 0;
|
|
7
|
+
var _react = require("@emotion/react");
|
|
8
|
+
/**
|
|
9
|
+
* @jsxRuntime classic
|
|
10
|
+
* @jsx jsx
|
|
11
|
+
*/
|
|
12
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @atlaskit/ui-styling-standard/no-global-styles
|
|
13
|
+
|
|
14
|
+
var extensionStyles = (0, _react.css)({
|
|
15
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
16
|
+
'[extensionkey="synced-block:reference"] .ak-renderer-wrapper > div:last-of-type': {
|
|
17
|
+
padding: "var(--ds-space-250, 20px)",
|
|
18
|
+
paddingRight: "var(--ds-space-250, 20px)"
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWrapper() {
|
|
22
|
+
return (0, _react.jsx)(_react.Global, {
|
|
23
|
+
styles: [extensionStyles]
|
|
24
|
+
});
|
|
25
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _useLiveSyncedBlockContent = require("../hooks/useLiveSyncedBlockContent");
|
|
10
|
+
var _SyncedBlockRenderer = _interopRequireDefault(require("./SyncedBlockRenderer"));
|
|
11
|
+
var SyncedBlockLiveView = function SyncedBlockLiveView(_ref) {
|
|
12
|
+
var sourceDocumentAri = _ref.sourceDocumentAri,
|
|
13
|
+
contentAri = _ref.contentAri;
|
|
14
|
+
var syncedBlockContent = (0, _useLiveSyncedBlockContent.useLiveSyncedBlockContent)({
|
|
15
|
+
sourceDocumentAri: sourceDocumentAri,
|
|
16
|
+
contentAri: contentAri
|
|
17
|
+
});
|
|
18
|
+
if (!syncedBlockContent) {
|
|
19
|
+
return /*#__PURE__*/_react.default.createElement("div", null, "Loading...");
|
|
20
|
+
}
|
|
21
|
+
return /*#__PURE__*/_react.default.createElement(_SyncedBlockRenderer.default, {
|
|
22
|
+
syncedBlockContent: syncedBlockContent
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var _default = exports.default = SyncedBlockLiveView;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _renderer = require("@atlaskit/renderer");
|
|
10
|
+
var _actions = require("@atlaskit/renderer/actions");
|
|
11
|
+
var SyncedBlockRenderer = function SyncedBlockRenderer(_ref) {
|
|
12
|
+
var syncedBlockContent = _ref.syncedBlockContent;
|
|
13
|
+
return /*#__PURE__*/_react.default.createElement(_actions.RendererActionsContext, null, /*#__PURE__*/_react.default.createElement(_renderer.ReactRenderer, {
|
|
14
|
+
adfStage: "stage0"
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
,
|
|
17
|
+
document: {
|
|
18
|
+
type: 'doc',
|
|
19
|
+
version: 1,
|
|
20
|
+
content: syncedBlockContent.adf.content
|
|
21
|
+
},
|
|
22
|
+
appearance: "full-page"
|
|
23
|
+
}));
|
|
24
|
+
};
|
|
25
|
+
var _default = exports.default = SyncedBlockRenderer;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getPageId = exports.getCloudId = void 0;
|
|
7
|
+
// hello.atlassian.net cloud id
|
|
8
|
+
var HELLO_CLOUD_ID = 'a436116f-02ce-4520-8fbb-7301462a1674';
|
|
9
|
+
|
|
10
|
+
// spike page https://hello.atlassian.net/wiki/spaces/~7120208ef57ce4d614485e876489301a16b906/pages/5626233808
|
|
11
|
+
var TEST_PAGE_ID = '5626233808';
|
|
12
|
+
var getPageId = exports.getPageId = function getPageId() {
|
|
13
|
+
var _window$location$href, _window$location$href2, _window$location$path;
|
|
14
|
+
return (
|
|
15
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
16
|
+
((_window$location$href = window.location.href.match(/pageId=(\d+)/)) === null || _window$location$href === void 0 ? void 0 : _window$location$href[1]) || ( // eslint-disable-next-line require-unicode-regexp
|
|
17
|
+
(_window$location$href2 = window.location.href.match(/pages\/edit-v2\/(\d+)/)) === null || _window$location$href2 === void 0 ? void 0 : _window$location$href2[1]) || ( // eslint-disable-next-line require-unicode-regexp
|
|
18
|
+
(_window$location$path = window.location.pathname.match(/pages\/(\d+)/)) === null || _window$location$path === void 0 ? void 0 : _window$location$path[1]) ||
|
|
19
|
+
// view page or live doc
|
|
20
|
+
TEST_PAGE_ID
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* This by no means is a stable way to get the cloud id, but it works for now.
|
|
25
|
+
* We should switch passing the cloud id from Confluence to a Editor plugin,
|
|
26
|
+
* for instance the user preferences plugin would have a seperate place for user and cloud info
|
|
27
|
+
* @returns the cloud id from the initial state
|
|
28
|
+
*/
|
|
29
|
+
var getCloudId = exports.getCloudId = function getCloudId() {
|
|
30
|
+
var _INITIAL_STATE__;
|
|
31
|
+
return ((_INITIAL_STATE__ = window.__INITIAL_STATE__) === null || _INITIAL_STATE__ === void 0 || (_INITIAL_STATE__ = _INITIAL_STATE__.meta) === null || _INITIAL_STATE__ === void 0 ? void 0 : _INITIAL_STATE__['cloud-id']) || HELLO_CLOUD_ID;
|
|
32
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getSyncedBlockExtensionProvider = void 0;
|
|
7
|
+
var _extensions = require("@atlaskit/editor-common/extensions");
|
|
8
|
+
var _manifest = require("./manifest");
|
|
9
|
+
var getSyncedBlockExtensionProvider = exports.getSyncedBlockExtensionProvider = function getSyncedBlockExtensionProvider() {
|
|
10
|
+
return new _extensions.DefaultExtensionProvider([(0, _manifest.getSyncedBlockManifest)()]);
|
|
11
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useLiveSyncedBlockContent = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _usePollContentProperty = require("../hooks/usePollContentProperty");
|
|
9
|
+
var _syncedBlock = require("../utils/synced-block");
|
|
10
|
+
var useLiveSyncedBlockContent = exports.useLiveSyncedBlockContent = function useLiveSyncedBlockContent(_ref) {
|
|
11
|
+
var sourceDocumentAri = _ref.sourceDocumentAri,
|
|
12
|
+
contentAri = _ref.contentAri;
|
|
13
|
+
var contentProperty = (0, _usePollContentProperty.usePollContentProperty)({
|
|
14
|
+
sourceDocumentAri: sourceDocumentAri,
|
|
15
|
+
contentAri: contentAri
|
|
16
|
+
});
|
|
17
|
+
return (0, _react.useMemo)(function () {
|
|
18
|
+
if (!contentProperty) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
return (0, _syncedBlock.parseSyncedBlockContentPropertyValue)(contentProperty.value);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
25
|
+
console.error('Failed to extract synced block content:', error);
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}, [contentProperty]);
|
|
29
|
+
};
|