@atlaskit/editor-synced-block-renderer 5.9.4 → 5.9.6
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 +16 -0
- package/dist/cjs/index.js +8 -1
- package/dist/cjs/ui/AKRendererWrapper.js +5 -2
- package/dist/cjs/ui/SyncedBlockNodeComponentRenderer.js +37 -8
- package/dist/cjs/ui/SyncedBlockRenderer.js +29 -8
- package/dist/cjs/ui/renderSyncedBlockContent.js +100 -0
- package/dist/es2019/index.js +2 -1
- package/dist/es2019/ui/AKRendererWrapper.js +5 -2
- package/dist/es2019/ui/SyncedBlockNodeComponentRenderer.js +39 -8
- package/dist/es2019/ui/SyncedBlockRenderer.js +30 -8
- package/dist/es2019/ui/renderSyncedBlockContent.js +94 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/ui/AKRendererWrapper.js +5 -2
- package/dist/esm/ui/SyncedBlockNodeComponentRenderer.js +37 -8
- package/dist/esm/ui/SyncedBlockRenderer.js +29 -8
- package/dist/esm/ui/renderSyncedBlockContent.js +93 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/types.d.ts +1 -1
- package/dist/types/ui/renderSyncedBlockContent.d.ts +27 -0
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/dist/types-ts4.5/types.d.ts +1 -1
- package/dist/types-ts4.5/ui/renderSyncedBlockContent.d.ts +27 -0
- package/package.json +8 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-renderer
|
|
2
2
|
|
|
3
|
+
## 5.9.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`514037bd94288`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/514037bd94288) -
|
|
8
|
+
[ux] EDITOR-5588 pass content mode setting to reference sync block
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 5.9.5
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`6424f86f6390a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6424f86f6390a) -
|
|
16
|
+
Improve Synced Blocks robustness
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 5.9.4
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "getSyncedBlockRenderer", {
|
|
|
15
15
|
return _getSyncedBlockRenderer.getSyncedBlockRenderer;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
+
Object.defineProperty(exports, "renderSyncedBlockContent", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _renderSyncedBlockContent.renderSyncedBlockContent;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
18
24
|
Object.defineProperty(exports, "useMemoizedSyncedBlockNodeComponent", {
|
|
19
25
|
enumerable: true,
|
|
20
26
|
get: function get() {
|
|
@@ -22,4 +28,5 @@ Object.defineProperty(exports, "useMemoizedSyncedBlockNodeComponent", {
|
|
|
22
28
|
}
|
|
23
29
|
});
|
|
24
30
|
var _useSyncedBlockNodeComponent = require("./useSyncedBlockNodeComponent");
|
|
25
|
-
var _getSyncedBlockRenderer = require("./getSyncedBlockRenderer");
|
|
31
|
+
var _getSyncedBlockRenderer = require("./getSyncedBlockRenderer");
|
|
32
|
+
var _renderSyncedBlockContent = require("./ui/renderSyncedBlockContent");
|
|
@@ -12,6 +12,7 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _reactIntlNext = require("react-intl-next");
|
|
14
14
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
16
|
var _renderer = require("@atlaskit/renderer");
|
|
16
17
|
var _actions = require("@atlaskit/renderer/actions");
|
|
17
18
|
var _rendererContext = require("@atlaskit/renderer/renderer-context");
|
|
@@ -91,7 +92,8 @@ var AKRendererWrapper = exports.AKRendererWrapper = /*#__PURE__*/(0, _react.memo
|
|
|
91
92
|
eventHandlers = _ref4.eventHandlers,
|
|
92
93
|
media = _ref4.media,
|
|
93
94
|
smartLinks = _ref4.smartLinks,
|
|
94
|
-
stickyHeaders = _ref4.stickyHeaders
|
|
95
|
+
stickyHeaders = _ref4.stickyHeaders,
|
|
96
|
+
contentMode = _ref4.contentMode;
|
|
95
97
|
var nodeComponents = (0, _react.useMemo)(function () {
|
|
96
98
|
return {
|
|
97
99
|
taskItem: function taskItem(props) {
|
|
@@ -136,6 +138,7 @@ var AKRendererWrapper = exports.AKRendererWrapper = /*#__PURE__*/(0, _react.memo
|
|
|
136
138
|
eventHandlers: eventHandlers,
|
|
137
139
|
media: media,
|
|
138
140
|
smartLinks: smartLinks,
|
|
139
|
-
stickyHeaders: stickyHeaders
|
|
141
|
+
stickyHeaders: stickyHeaders,
|
|
142
|
+
contentMode: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_5') ? contentMode : undefined
|
|
140
143
|
})))));
|
|
141
144
|
});
|
|
@@ -14,13 +14,14 @@ var _syncBlock = require("@atlaskit/editor-common/sync-block");
|
|
|
14
14
|
var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
|
|
15
15
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
16
|
var _AKRendererWrapper = require("./AKRendererWrapper");
|
|
17
|
+
var _renderSyncedBlockContent = require("./renderSyncedBlockContent");
|
|
17
18
|
var _SyncedBlockErrorComponent = require("./SyncedBlockErrorComponent");
|
|
18
19
|
var _SyncedBlockLoadingState = require("./SyncedBlockLoadingState");
|
|
19
20
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
20
21
|
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; }
|
|
21
22
|
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; }
|
|
22
23
|
var SyncedBlockNodeComponentRenderer = exports.SyncedBlockNodeComponentRenderer = function SyncedBlockNodeComponentRenderer(_ref) {
|
|
23
|
-
var _syncBlockInstance$
|
|
24
|
+
var _syncBlockInstance$da6;
|
|
24
25
|
var nodeProps = _ref.nodeProps,
|
|
25
26
|
syncBlockStoreManager = _ref.syncBlockStoreManager,
|
|
26
27
|
rendererOptions = _ref.rendererOptions;
|
|
@@ -64,6 +65,34 @@ var SyncedBlockNodeComponentRenderer = exports.SyncedBlockNodeComponentRenderer
|
|
|
64
65
|
})
|
|
65
66
|
});
|
|
66
67
|
}, [rendererOptions, ssrProviders]);
|
|
68
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_5')) {
|
|
69
|
+
var _syncBlockInstance$er, _syncBlockInstance$da, _syncBlockInstance$da2;
|
|
70
|
+
var errorForDisplay = (_syncBlockInstance$er = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : (syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.status) === 'deleted' ? {
|
|
71
|
+
type: _editorSyncedBlockProvider.SyncBlockError.NotFound,
|
|
72
|
+
reason: (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.deletionReason
|
|
73
|
+
} : {
|
|
74
|
+
type: _editorSyncedBlockProvider.SyncBlockError.Errored,
|
|
75
|
+
reason: !resourceId ? 'missing resource id' : "missing data for block ".concat(resourceId)
|
|
76
|
+
};
|
|
77
|
+
var result = (0, _renderSyncedBlockContent.renderSyncedBlockContent)({
|
|
78
|
+
syncBlockInstance: syncBlockInstance !== null && syncBlockInstance !== void 0 ? syncBlockInstance : undefined,
|
|
79
|
+
isLoading: isLoading,
|
|
80
|
+
rendererOptions: finalRendererOptions,
|
|
81
|
+
providerFactory: providerFactory,
|
|
82
|
+
reloadData: reloadData,
|
|
83
|
+
fireAnalyticsEvent: fireAnalyticsEvent,
|
|
84
|
+
resourceId: resourceId,
|
|
85
|
+
error: errorForDisplay
|
|
86
|
+
});
|
|
87
|
+
if (result.isSuccess) {
|
|
88
|
+
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
89
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
90
|
+
className: _syncBlock.SyncBlockSharedCssClassName.renderer
|
|
91
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
92
|
+
}, (0, _defineProperty2.default)({}, _syncBlock.SyncBlockRendererDataAttributeName, true)), result.element);
|
|
93
|
+
}
|
|
94
|
+
return result.element;
|
|
95
|
+
}
|
|
67
96
|
if (isLoading && !syncBlockInstance) {
|
|
68
97
|
return /*#__PURE__*/_react.default.createElement(_SyncedBlockLoadingState.SyncedBlockLoadingState, null);
|
|
69
98
|
}
|
|
@@ -74,16 +103,16 @@ var SyncedBlockNodeComponentRenderer = exports.SyncedBlockNodeComponentRenderer
|
|
|
74
103
|
return /*#__PURE__*/_react.default.createElement(_SyncedBlockLoadingState.SyncedBlockLoadingState, null);
|
|
75
104
|
}
|
|
76
105
|
if (!resourceId || syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.error || !(syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.data) || syncBlockInstance.data.status === 'deleted') {
|
|
77
|
-
var _syncBlockInstance$
|
|
78
|
-
var errorMessage = (_syncBlockInstance$
|
|
106
|
+
var _syncBlockInstance$er2, _syncBlockInstance$da3, _syncBlockInstance$da4, _syncBlockInstance$er3, _syncBlockInstance$da5;
|
|
107
|
+
var errorMessage = (_syncBlockInstance$er2 = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _syncBlockInstance$er2 !== void 0 ? _syncBlockInstance$er2 : (syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da3 = syncBlockInstance.data) === null || _syncBlockInstance$da3 === void 0 ? void 0 : _syncBlockInstance$da3.status) === 'deleted' ? {
|
|
79
108
|
type: _editorSyncedBlockProvider.SyncBlockError.NotFound,
|
|
80
|
-
reason: (_syncBlockInstance$
|
|
109
|
+
reason: (_syncBlockInstance$da4 = syncBlockInstance.data) === null || _syncBlockInstance$da4 === void 0 ? void 0 : _syncBlockInstance$da4.deletionReason
|
|
81
110
|
} : {
|
|
82
111
|
type: _editorSyncedBlockProvider.SyncBlockError.Errored,
|
|
83
112
|
reason: !resourceId ? 'missing resource id' : "missing data for block ".concat(resourceId)
|
|
84
113
|
};
|
|
85
114
|
return /*#__PURE__*/_react.default.createElement(_SyncedBlockErrorComponent.SyncedBlockErrorComponent, {
|
|
86
|
-
error: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') ? errorMessage : (_syncBlockInstance$
|
|
115
|
+
error: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') ? errorMessage : (_syncBlockInstance$er3 = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _syncBlockInstance$er3 !== void 0 ? _syncBlockInstance$er3 : (syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da5 = syncBlockInstance.data) === null || _syncBlockInstance$da5 === void 0 ? void 0 : _syncBlockInstance$da5.status) === 'deleted' ? {
|
|
87
116
|
type: _editorSyncedBlockProvider.SyncBlockError.NotFound
|
|
88
117
|
} : {
|
|
89
118
|
type: _editorSyncedBlockProvider.SyncBlockError.Errored
|
|
@@ -94,14 +123,14 @@ var SyncedBlockNodeComponentRenderer = exports.SyncedBlockNodeComponentRenderer
|
|
|
94
123
|
fireAnalyticsEvent: fireAnalyticsEvent
|
|
95
124
|
});
|
|
96
125
|
}
|
|
97
|
-
if ((syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$
|
|
98
|
-
var _syncBlockInstance$
|
|
126
|
+
if ((syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da6 = syncBlockInstance.data) === null || _syncBlockInstance$da6 === void 0 ? void 0 : _syncBlockInstance$da6.status) === 'unpublished') {
|
|
127
|
+
var _syncBlockInstance$da7;
|
|
99
128
|
return /*#__PURE__*/_react.default.createElement(_SyncedBlockErrorComponent.SyncedBlockErrorComponent, {
|
|
100
129
|
error: {
|
|
101
130
|
type: _editorSyncedBlockProvider.SyncBlockError.Unpublished
|
|
102
131
|
},
|
|
103
132
|
resourceId: syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.resourceId,
|
|
104
|
-
sourceURL: (_syncBlockInstance$
|
|
133
|
+
sourceURL: (_syncBlockInstance$da7 = syncBlockInstance.data) === null || _syncBlockInstance$da7 === void 0 ? void 0 : _syncBlockInstance$da7.sourceURL,
|
|
105
134
|
fireAnalyticsEvent: fireAnalyticsEvent
|
|
106
135
|
});
|
|
107
136
|
}
|
|
@@ -12,7 +12,9 @@ var _coreUtils = require("@atlaskit/editor-common/core-utils");
|
|
|
12
12
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
13
13
|
var _syncBlock = require("@atlaskit/editor-common/sync-block");
|
|
14
14
|
var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
16
|
var _AKRendererWrapper = require("./AKRendererWrapper");
|
|
17
|
+
var _renderSyncedBlockContent = require("./renderSyncedBlockContent");
|
|
16
18
|
var _SyncedBlockErrorComponent = require("./SyncedBlockErrorComponent");
|
|
17
19
|
var _SyncedBlockLoadingState = require("./SyncedBlockLoadingState");
|
|
18
20
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
@@ -56,13 +58,32 @@ var SyncedBlockRendererComponent = function SyncedBlockRendererComponent(_ref) {
|
|
|
56
58
|
})
|
|
57
59
|
});
|
|
58
60
|
}, [syncBlockRendererOptions, ssrProviders, isSSRMode]);
|
|
59
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['connectivity'], function (_ref2) {
|
|
60
|
-
var connectivityState = _ref2.connectivityState
|
|
61
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['connectivity', 'contentFormat'], function (_ref2) {
|
|
62
|
+
var connectivityState = _ref2.connectivityState,
|
|
63
|
+
contentFormatState = _ref2.contentFormatState;
|
|
61
64
|
return {
|
|
62
|
-
isCollabOffline: (connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode) === 'collab-offline'
|
|
65
|
+
isCollabOffline: (connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode) === 'collab-offline',
|
|
66
|
+
contentMode: contentFormatState === null || contentFormatState === void 0 ? void 0 : contentFormatState.contentMode
|
|
63
67
|
};
|
|
64
68
|
}),
|
|
65
|
-
isCollabOffline = _useSharedPluginState.isCollabOffline
|
|
69
|
+
isCollabOffline = _useSharedPluginState.isCollabOffline,
|
|
70
|
+
contentMode = _useSharedPluginState.contentMode;
|
|
71
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_5')) {
|
|
72
|
+
var _api$analytics2;
|
|
73
|
+
var result = (0, _renderSyncedBlockContent.renderSyncedBlockContent)({
|
|
74
|
+
syncBlockInstance: syncBlockInstance,
|
|
75
|
+
isLoading: isLoading,
|
|
76
|
+
rendererOptions: contentMode ? _objectSpread(_objectSpread({}, rendererOptions), {}, {
|
|
77
|
+
contentMode: contentMode
|
|
78
|
+
}) : rendererOptions,
|
|
79
|
+
providerFactory: providerFactory,
|
|
80
|
+
reloadData: reloadData,
|
|
81
|
+
fireAnalyticsEvent: api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.fireAnalyticsEvent,
|
|
82
|
+
resourceId: syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.resourceId,
|
|
83
|
+
isOffline: isCollabOffline
|
|
84
|
+
});
|
|
85
|
+
return result.element;
|
|
86
|
+
}
|
|
66
87
|
|
|
67
88
|
// Show offline error only when collaboration is offline and not in SSR mode
|
|
68
89
|
// In SSR, we should always attempt to render content
|
|
@@ -83,7 +104,7 @@ var SyncedBlockRendererComponent = function SyncedBlockRendererComponent(_ref) {
|
|
|
83
104
|
return /*#__PURE__*/_react.default.createElement(_SyncedBlockLoadingState.SyncedBlockLoadingState, null);
|
|
84
105
|
}
|
|
85
106
|
if (syncBlockInstance.error || !syncBlockInstance.data || syncBlockInstance.data.status === 'deleted') {
|
|
86
|
-
var _syncBlockInstance$er, _syncBlockInstance$da, _api$
|
|
107
|
+
var _syncBlockInstance$er, _syncBlockInstance$da, _api$analytics3;
|
|
87
108
|
return /*#__PURE__*/_react.default.createElement(_SyncedBlockErrorComponent.SyncedBlockErrorComponent, {
|
|
88
109
|
error: (_syncBlockInstance$er = syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : (syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.status) === 'deleted' ? {
|
|
89
110
|
type: _editorSyncedBlockProvider.SyncBlockError.NotFound
|
|
@@ -93,20 +114,20 @@ var SyncedBlockRendererComponent = function SyncedBlockRendererComponent(_ref) {
|
|
|
93
114
|
resourceId: syncBlockInstance.resourceId,
|
|
94
115
|
onRetry: reloadData,
|
|
95
116
|
isLoading: isLoading,
|
|
96
|
-
fireAnalyticsEvent: api === null || api === void 0 || (_api$
|
|
117
|
+
fireAnalyticsEvent: api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.fireAnalyticsEvent
|
|
97
118
|
});
|
|
98
119
|
}
|
|
99
120
|
|
|
100
121
|
// Check for unpublished status
|
|
101
122
|
if (((_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.status) === 'unpublished') {
|
|
102
|
-
var _syncBlockInstance$da3, _api$
|
|
123
|
+
var _syncBlockInstance$da3, _api$analytics4;
|
|
103
124
|
return /*#__PURE__*/_react.default.createElement(_SyncedBlockErrorComponent.SyncedBlockErrorComponent, {
|
|
104
125
|
error: {
|
|
105
126
|
type: _editorSyncedBlockProvider.SyncBlockError.Unpublished
|
|
106
127
|
},
|
|
107
128
|
resourceId: syncBlockInstance.resourceId,
|
|
108
129
|
sourceURL: (_syncBlockInstance$da3 = syncBlockInstance.data) === null || _syncBlockInstance$da3 === void 0 ? void 0 : _syncBlockInstance$da3.sourceURL,
|
|
109
|
-
fireAnalyticsEvent: api === null || api === void 0 || (_api$
|
|
130
|
+
fireAnalyticsEvent: api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions.fireAnalyticsEvent
|
|
110
131
|
});
|
|
111
132
|
}
|
|
112
133
|
var syncBlockDoc = {
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.renderSyncedBlockContent = renderSyncedBlockContent;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _coreUtils = require("@atlaskit/editor-common/core-utils");
|
|
10
|
+
var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
|
|
11
|
+
var _AKRendererWrapper = require("./AKRendererWrapper");
|
|
12
|
+
var _SyncedBlockErrorComponent = require("./SyncedBlockErrorComponent");
|
|
13
|
+
var _SyncedBlockLoadingState = require("./SyncedBlockLoadingState");
|
|
14
|
+
/**
|
|
15
|
+
* Shared rendering logic for synced block content used by both
|
|
16
|
+
* SyncedBlockRenderer (editor mode) and SyncedBlockNodeComponentRenderer (renderer mode).
|
|
17
|
+
*
|
|
18
|
+
* Handles the common branching: loading -> SSR error -> error/deleted -> unpublished -> success.
|
|
19
|
+
* Returns null if the caller should handle rendering itself (e.g. wrapping in a container div).
|
|
20
|
+
*/
|
|
21
|
+
function renderSyncedBlockContent(_ref) {
|
|
22
|
+
var _syncBlockInstance$da2;
|
|
23
|
+
var syncBlockInstance = _ref.syncBlockInstance,
|
|
24
|
+
isLoading = _ref.isLoading,
|
|
25
|
+
rendererOptions = _ref.rendererOptions,
|
|
26
|
+
providerFactory = _ref.providerFactory,
|
|
27
|
+
reloadData = _ref.reloadData,
|
|
28
|
+
fireAnalyticsEvent = _ref.fireAnalyticsEvent,
|
|
29
|
+
resourceId = _ref.resourceId,
|
|
30
|
+
isOffline = _ref.isOffline,
|
|
31
|
+
error = _ref.error;
|
|
32
|
+
var isSSRMode = (0, _coreUtils.isSSR)();
|
|
33
|
+
if (isOffline && !isSSRMode) {
|
|
34
|
+
return {
|
|
35
|
+
element: /*#__PURE__*/_react.default.createElement(_SyncedBlockErrorComponent.SyncedBlockErrorComponent, {
|
|
36
|
+
error: {
|
|
37
|
+
type: _editorSyncedBlockProvider.SyncBlockError.Offline
|
|
38
|
+
}
|
|
39
|
+
}),
|
|
40
|
+
isSuccess: false
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (isLoading && !syncBlockInstance) {
|
|
44
|
+
return {
|
|
45
|
+
element: /*#__PURE__*/_react.default.createElement(_SyncedBlockLoadingState.SyncedBlockLoadingState, null),
|
|
46
|
+
isSuccess: false
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (isSSRMode && syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.error) {
|
|
50
|
+
return {
|
|
51
|
+
element: /*#__PURE__*/_react.default.createElement(_SyncedBlockLoadingState.SyncedBlockLoadingState, null),
|
|
52
|
+
isSuccess: false
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (!resourceId || syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.error || !(syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.data) || syncBlockInstance.data.status === 'deleted') {
|
|
56
|
+
var _ref2, _syncBlockInstance$da;
|
|
57
|
+
var errorToDisplay = (_ref2 = error !== null && error !== void 0 ? error : syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _ref2 !== void 0 ? _ref2 : (syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.status) === 'deleted' ? {
|
|
58
|
+
type: _editorSyncedBlockProvider.SyncBlockError.NotFound
|
|
59
|
+
} : {
|
|
60
|
+
type: _editorSyncedBlockProvider.SyncBlockError.Errored
|
|
61
|
+
};
|
|
62
|
+
return {
|
|
63
|
+
element: /*#__PURE__*/_react.default.createElement(_SyncedBlockErrorComponent.SyncedBlockErrorComponent, {
|
|
64
|
+
error: errorToDisplay,
|
|
65
|
+
resourceId: resourceId,
|
|
66
|
+
onRetry: reloadData,
|
|
67
|
+
isLoading: isLoading,
|
|
68
|
+
fireAnalyticsEvent: fireAnalyticsEvent
|
|
69
|
+
}),
|
|
70
|
+
isSuccess: false
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if ((syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.status) === 'unpublished') {
|
|
74
|
+
var _syncBlockInstance$da3;
|
|
75
|
+
return {
|
|
76
|
+
element: /*#__PURE__*/_react.default.createElement(_SyncedBlockErrorComponent.SyncedBlockErrorComponent, {
|
|
77
|
+
error: {
|
|
78
|
+
type: _editorSyncedBlockProvider.SyncBlockError.Unpublished
|
|
79
|
+
},
|
|
80
|
+
resourceId: resourceId,
|
|
81
|
+
sourceURL: (_syncBlockInstance$da3 = syncBlockInstance.data) === null || _syncBlockInstance$da3 === void 0 ? void 0 : _syncBlockInstance$da3.sourceURL,
|
|
82
|
+
fireAnalyticsEvent: fireAnalyticsEvent
|
|
83
|
+
}),
|
|
84
|
+
isSuccess: false
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
var syncBlockDoc = {
|
|
88
|
+
content: syncBlockInstance.data.content,
|
|
89
|
+
version: 1,
|
|
90
|
+
type: 'doc'
|
|
91
|
+
};
|
|
92
|
+
return {
|
|
93
|
+
element: /*#__PURE__*/_react.default.createElement(_AKRendererWrapper.AKRendererWrapper, {
|
|
94
|
+
doc: syncBlockDoc,
|
|
95
|
+
dataProviders: providerFactory,
|
|
96
|
+
options: rendererOptions
|
|
97
|
+
}),
|
|
98
|
+
isSuccess: true
|
|
99
|
+
};
|
|
100
|
+
}
|
package/dist/es2019/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
2
2
|
export { getSyncBlockNodesFromDoc, useMemoizedSyncedBlockNodeComponent } from './useSyncedBlockNodeComponent';
|
|
3
|
-
export { getSyncedBlockRenderer } from './getSyncedBlockRenderer';
|
|
3
|
+
export { getSyncedBlockRenderer } from './getSyncedBlockRenderer';
|
|
4
|
+
export { renderSyncedBlockContent } from './ui/renderSyncedBlockContent';
|
|
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import React, { memo, useMemo } from 'react';
|
|
3
3
|
import { useIntl } from 'react-intl-next';
|
|
4
4
|
import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { ReactRenderer, ValidationContextProvider, defaultNodeComponents } from '@atlaskit/renderer';
|
|
6
7
|
import { RendererActionsContext } from '@atlaskit/renderer/actions';
|
|
7
8
|
import { RendererContextProvider } from '@atlaskit/renderer/renderer-context';
|
|
@@ -82,7 +83,8 @@ export const AKRendererWrapper = /*#__PURE__*/memo(({
|
|
|
82
83
|
eventHandlers,
|
|
83
84
|
media,
|
|
84
85
|
smartLinks,
|
|
85
|
-
stickyHeaders
|
|
86
|
+
stickyHeaders,
|
|
87
|
+
contentMode
|
|
86
88
|
} = mergedOptions !== null && mergedOptions !== void 0 ? mergedOptions : {};
|
|
87
89
|
const nodeComponents = useMemo(() => {
|
|
88
90
|
return {
|
|
@@ -128,6 +130,7 @@ export const AKRendererWrapper = /*#__PURE__*/memo(({
|
|
|
128
130
|
eventHandlers: eventHandlers,
|
|
129
131
|
media: media,
|
|
130
132
|
smartLinks: smartLinks,
|
|
131
|
-
stickyHeaders: stickyHeaders
|
|
133
|
+
stickyHeaders: stickyHeaders,
|
|
134
|
+
contentMode: fg('platform_synced_block_patch_5') ? contentMode : undefined
|
|
132
135
|
})))));
|
|
133
136
|
});
|
|
@@ -4,6 +4,7 @@ import { SyncBlockSharedCssClassName, SyncBlockRendererDataAttributeName, handle
|
|
|
4
4
|
import { SyncBlockError, useFetchSyncBlockData } from '@atlaskit/editor-synced-block-provider';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
6
|
import { AKRendererWrapper } from './AKRendererWrapper';
|
|
7
|
+
import { renderSyncedBlockContent } from './renderSyncedBlockContent';
|
|
7
8
|
import { SyncedBlockErrorComponent } from './SyncedBlockErrorComponent';
|
|
8
9
|
import { SyncedBlockLoadingState } from './SyncedBlockLoadingState';
|
|
9
10
|
export const SyncedBlockNodeComponentRenderer = ({
|
|
@@ -11,7 +12,7 @@ export const SyncedBlockNodeComponentRenderer = ({
|
|
|
11
12
|
syncBlockStoreManager,
|
|
12
13
|
rendererOptions
|
|
13
14
|
}) => {
|
|
14
|
-
var _syncBlockInstance$
|
|
15
|
+
var _syncBlockInstance$da6;
|
|
15
16
|
const {
|
|
16
17
|
resourceId,
|
|
17
18
|
localId,
|
|
@@ -57,6 +58,36 @@ export const SyncedBlockNodeComponentRenderer = ({
|
|
|
57
58
|
}
|
|
58
59
|
};
|
|
59
60
|
}, [rendererOptions, ssrProviders]);
|
|
61
|
+
if (fg('platform_synced_block_patch_5')) {
|
|
62
|
+
var _syncBlockInstance$er, _syncBlockInstance$da, _syncBlockInstance$da2;
|
|
63
|
+
const errorForDisplay = (_syncBlockInstance$er = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : (syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.status) === 'deleted' ? {
|
|
64
|
+
type: SyncBlockError.NotFound,
|
|
65
|
+
reason: (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.deletionReason
|
|
66
|
+
} : {
|
|
67
|
+
type: SyncBlockError.Errored,
|
|
68
|
+
reason: !resourceId ? 'missing resource id' : `missing data for block ${resourceId}`
|
|
69
|
+
};
|
|
70
|
+
const result = renderSyncedBlockContent({
|
|
71
|
+
syncBlockInstance: syncBlockInstance !== null && syncBlockInstance !== void 0 ? syncBlockInstance : undefined,
|
|
72
|
+
isLoading,
|
|
73
|
+
rendererOptions: finalRendererOptions,
|
|
74
|
+
providerFactory,
|
|
75
|
+
reloadData,
|
|
76
|
+
fireAnalyticsEvent,
|
|
77
|
+
resourceId,
|
|
78
|
+
error: errorForDisplay
|
|
79
|
+
});
|
|
80
|
+
if (result.isSuccess) {
|
|
81
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
82
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
83
|
+
className: SyncBlockSharedCssClassName.renderer
|
|
84
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
85
|
+
,
|
|
86
|
+
[SyncBlockRendererDataAttributeName]: true
|
|
87
|
+
}, result.element);
|
|
88
|
+
}
|
|
89
|
+
return result.element;
|
|
90
|
+
}
|
|
60
91
|
if (isLoading && !syncBlockInstance) {
|
|
61
92
|
return /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null);
|
|
62
93
|
}
|
|
@@ -67,16 +98,16 @@ export const SyncedBlockNodeComponentRenderer = ({
|
|
|
67
98
|
return /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null);
|
|
68
99
|
}
|
|
69
100
|
if (!resourceId || syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.error || !(syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.data) || syncBlockInstance.data.status === 'deleted') {
|
|
70
|
-
var _syncBlockInstance$
|
|
71
|
-
const errorMessage = (_syncBlockInstance$
|
|
101
|
+
var _syncBlockInstance$er2, _syncBlockInstance$da3, _syncBlockInstance$da4, _syncBlockInstance$er3, _syncBlockInstance$da5;
|
|
102
|
+
const errorMessage = (_syncBlockInstance$er2 = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _syncBlockInstance$er2 !== void 0 ? _syncBlockInstance$er2 : (syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : (_syncBlockInstance$da3 = syncBlockInstance.data) === null || _syncBlockInstance$da3 === void 0 ? void 0 : _syncBlockInstance$da3.status) === 'deleted' ? {
|
|
72
103
|
type: SyncBlockError.NotFound,
|
|
73
|
-
reason: (_syncBlockInstance$
|
|
104
|
+
reason: (_syncBlockInstance$da4 = syncBlockInstance.data) === null || _syncBlockInstance$da4 === void 0 ? void 0 : _syncBlockInstance$da4.deletionReason
|
|
74
105
|
} : {
|
|
75
106
|
type: SyncBlockError.Errored,
|
|
76
107
|
reason: !resourceId ? 'missing resource id' : `missing data for block ${resourceId}`
|
|
77
108
|
};
|
|
78
109
|
return /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
|
|
79
|
-
error: fg('platform_synced_block_patch_3') ? errorMessage : (_syncBlockInstance$
|
|
110
|
+
error: fg('platform_synced_block_patch_3') ? errorMessage : (_syncBlockInstance$er3 = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _syncBlockInstance$er3 !== void 0 ? _syncBlockInstance$er3 : (syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : (_syncBlockInstance$da5 = syncBlockInstance.data) === null || _syncBlockInstance$da5 === void 0 ? void 0 : _syncBlockInstance$da5.status) === 'deleted' ? {
|
|
80
111
|
type: SyncBlockError.NotFound
|
|
81
112
|
} : {
|
|
82
113
|
type: SyncBlockError.Errored
|
|
@@ -87,14 +118,14 @@ export const SyncedBlockNodeComponentRenderer = ({
|
|
|
87
118
|
fireAnalyticsEvent: fireAnalyticsEvent
|
|
88
119
|
});
|
|
89
120
|
}
|
|
90
|
-
if ((syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : (_syncBlockInstance$
|
|
91
|
-
var _syncBlockInstance$
|
|
121
|
+
if ((syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : (_syncBlockInstance$da6 = syncBlockInstance.data) === null || _syncBlockInstance$da6 === void 0 ? void 0 : _syncBlockInstance$da6.status) === 'unpublished') {
|
|
122
|
+
var _syncBlockInstance$da7;
|
|
92
123
|
return /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
|
|
93
124
|
error: {
|
|
94
125
|
type: SyncBlockError.Unpublished
|
|
95
126
|
},
|
|
96
127
|
resourceId: syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.resourceId,
|
|
97
|
-
sourceURL: (_syncBlockInstance$
|
|
128
|
+
sourceURL: (_syncBlockInstance$da7 = syncBlockInstance.data) === null || _syncBlockInstance$da7 === void 0 ? void 0 : _syncBlockInstance$da7.sourceURL,
|
|
98
129
|
fireAnalyticsEvent: fireAnalyticsEvent
|
|
99
130
|
});
|
|
100
131
|
}
|
|
@@ -3,7 +3,9 @@ import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
|
3
3
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
4
|
import { handleSSRErrorsAnalytics } from '@atlaskit/editor-common/sync-block';
|
|
5
5
|
import { SyncBlockError } from '@atlaskit/editor-synced-block-provider';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { AKRendererWrapper } from './AKRendererWrapper';
|
|
8
|
+
import { renderSyncedBlockContent } from './renderSyncedBlockContent';
|
|
7
9
|
import { SyncedBlockErrorComponent } from './SyncedBlockErrorComponent';
|
|
8
10
|
import { SyncedBlockLoadingState } from './SyncedBlockLoadingState';
|
|
9
11
|
const SyncedBlockRendererComponent = ({
|
|
@@ -50,12 +52,32 @@ const SyncedBlockRendererComponent = ({
|
|
|
50
52
|
};
|
|
51
53
|
}, [syncBlockRendererOptions, ssrProviders, isSSRMode]);
|
|
52
54
|
const {
|
|
53
|
-
isCollabOffline
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
isCollabOffline,
|
|
56
|
+
contentMode
|
|
57
|
+
} = useSharedPluginStateWithSelector(api, ['connectivity', 'contentFormat'], ({
|
|
58
|
+
connectivityState,
|
|
59
|
+
contentFormatState
|
|
56
60
|
}) => ({
|
|
57
|
-
isCollabOffline: (connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode) === 'collab-offline'
|
|
61
|
+
isCollabOffline: (connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode) === 'collab-offline',
|
|
62
|
+
contentMode: contentFormatState === null || contentFormatState === void 0 ? void 0 : contentFormatState.contentMode
|
|
58
63
|
}));
|
|
64
|
+
if (fg('platform_synced_block_patch_5')) {
|
|
65
|
+
var _api$analytics2;
|
|
66
|
+
const result = renderSyncedBlockContent({
|
|
67
|
+
syncBlockInstance,
|
|
68
|
+
isLoading,
|
|
69
|
+
rendererOptions: contentMode ? {
|
|
70
|
+
...rendererOptions,
|
|
71
|
+
contentMode
|
|
72
|
+
} : rendererOptions,
|
|
73
|
+
providerFactory,
|
|
74
|
+
reloadData,
|
|
75
|
+
fireAnalyticsEvent: api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.fireAnalyticsEvent,
|
|
76
|
+
resourceId: syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.resourceId,
|
|
77
|
+
isOffline: isCollabOffline
|
|
78
|
+
});
|
|
79
|
+
return result.element;
|
|
80
|
+
}
|
|
59
81
|
|
|
60
82
|
// Show offline error only when collaboration is offline and not in SSR mode
|
|
61
83
|
// In SSR, we should always attempt to render content
|
|
@@ -76,7 +98,7 @@ const SyncedBlockRendererComponent = ({
|
|
|
76
98
|
return /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null);
|
|
77
99
|
}
|
|
78
100
|
if (syncBlockInstance.error || !syncBlockInstance.data || syncBlockInstance.data.status === 'deleted') {
|
|
79
|
-
var _syncBlockInstance$er, _syncBlockInstance$da, _api$
|
|
101
|
+
var _syncBlockInstance$er, _syncBlockInstance$da, _api$analytics3;
|
|
80
102
|
return /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
|
|
81
103
|
error: (_syncBlockInstance$er = syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : (syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.status) === 'deleted' ? {
|
|
82
104
|
type: SyncBlockError.NotFound
|
|
@@ -86,20 +108,20 @@ const SyncedBlockRendererComponent = ({
|
|
|
86
108
|
resourceId: syncBlockInstance.resourceId,
|
|
87
109
|
onRetry: reloadData,
|
|
88
110
|
isLoading: isLoading,
|
|
89
|
-
fireAnalyticsEvent: api === null || api === void 0 ? void 0 : (_api$
|
|
111
|
+
fireAnalyticsEvent: api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.fireAnalyticsEvent
|
|
90
112
|
});
|
|
91
113
|
}
|
|
92
114
|
|
|
93
115
|
// Check for unpublished status
|
|
94
116
|
if (((_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.status) === 'unpublished') {
|
|
95
|
-
var _syncBlockInstance$da3, _api$
|
|
117
|
+
var _syncBlockInstance$da3, _api$analytics4;
|
|
96
118
|
return /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
|
|
97
119
|
error: {
|
|
98
120
|
type: SyncBlockError.Unpublished
|
|
99
121
|
},
|
|
100
122
|
resourceId: syncBlockInstance.resourceId,
|
|
101
123
|
sourceURL: (_syncBlockInstance$da3 = syncBlockInstance.data) === null || _syncBlockInstance$da3 === void 0 ? void 0 : _syncBlockInstance$da3.sourceURL,
|
|
102
|
-
fireAnalyticsEvent: api === null || api === void 0 ? void 0 : (_api$
|
|
124
|
+
fireAnalyticsEvent: api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions.fireAnalyticsEvent
|
|
103
125
|
});
|
|
104
126
|
}
|
|
105
127
|
const syncBlockDoc = {
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
3
|
+
import { SyncBlockError } from '@atlaskit/editor-synced-block-provider';
|
|
4
|
+
import { AKRendererWrapper } from './AKRendererWrapper';
|
|
5
|
+
import { SyncedBlockErrorComponent } from './SyncedBlockErrorComponent';
|
|
6
|
+
import { SyncedBlockLoadingState } from './SyncedBlockLoadingState';
|
|
7
|
+
/**
|
|
8
|
+
* Shared rendering logic for synced block content used by both
|
|
9
|
+
* SyncedBlockRenderer (editor mode) and SyncedBlockNodeComponentRenderer (renderer mode).
|
|
10
|
+
*
|
|
11
|
+
* Handles the common branching: loading -> SSR error -> error/deleted -> unpublished -> success.
|
|
12
|
+
* Returns null if the caller should handle rendering itself (e.g. wrapping in a container div).
|
|
13
|
+
*/
|
|
14
|
+
export function renderSyncedBlockContent({
|
|
15
|
+
syncBlockInstance,
|
|
16
|
+
isLoading,
|
|
17
|
+
rendererOptions,
|
|
18
|
+
providerFactory,
|
|
19
|
+
reloadData,
|
|
20
|
+
fireAnalyticsEvent,
|
|
21
|
+
resourceId,
|
|
22
|
+
isOffline,
|
|
23
|
+
error
|
|
24
|
+
}) {
|
|
25
|
+
var _syncBlockInstance$da2;
|
|
26
|
+
const isSSRMode = isSSR();
|
|
27
|
+
if (isOffline && !isSSRMode) {
|
|
28
|
+
return {
|
|
29
|
+
element: /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
|
|
30
|
+
error: {
|
|
31
|
+
type: SyncBlockError.Offline
|
|
32
|
+
}
|
|
33
|
+
}),
|
|
34
|
+
isSuccess: false
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (isLoading && !syncBlockInstance) {
|
|
38
|
+
return {
|
|
39
|
+
element: /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null),
|
|
40
|
+
isSuccess: false
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (isSSRMode && syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.error) {
|
|
44
|
+
return {
|
|
45
|
+
element: /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null),
|
|
46
|
+
isSuccess: false
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (!resourceId || syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.error || !(syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.data) || syncBlockInstance.data.status === 'deleted') {
|
|
50
|
+
var _ref, _syncBlockInstance$da;
|
|
51
|
+
const errorToDisplay = (_ref = error !== null && error !== void 0 ? error : syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _ref !== void 0 ? _ref : (syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.status) === 'deleted' ? {
|
|
52
|
+
type: SyncBlockError.NotFound
|
|
53
|
+
} : {
|
|
54
|
+
type: SyncBlockError.Errored
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
element: /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
|
|
58
|
+
error: errorToDisplay,
|
|
59
|
+
resourceId: resourceId,
|
|
60
|
+
onRetry: reloadData,
|
|
61
|
+
isLoading: isLoading,
|
|
62
|
+
fireAnalyticsEvent: fireAnalyticsEvent
|
|
63
|
+
}),
|
|
64
|
+
isSuccess: false
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if ((syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.status) === 'unpublished') {
|
|
68
|
+
var _syncBlockInstance$da3;
|
|
69
|
+
return {
|
|
70
|
+
element: /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
|
|
71
|
+
error: {
|
|
72
|
+
type: SyncBlockError.Unpublished
|
|
73
|
+
},
|
|
74
|
+
resourceId: resourceId,
|
|
75
|
+
sourceURL: (_syncBlockInstance$da3 = syncBlockInstance.data) === null || _syncBlockInstance$da3 === void 0 ? void 0 : _syncBlockInstance$da3.sourceURL,
|
|
76
|
+
fireAnalyticsEvent: fireAnalyticsEvent
|
|
77
|
+
}),
|
|
78
|
+
isSuccess: false
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const syncBlockDoc = {
|
|
82
|
+
content: syncBlockInstance.data.content,
|
|
83
|
+
version: 1,
|
|
84
|
+
type: 'doc'
|
|
85
|
+
};
|
|
86
|
+
return {
|
|
87
|
+
element: /*#__PURE__*/React.createElement(AKRendererWrapper, {
|
|
88
|
+
doc: syncBlockDoc,
|
|
89
|
+
dataProviders: providerFactory,
|
|
90
|
+
options: rendererOptions
|
|
91
|
+
}),
|
|
92
|
+
isSuccess: true
|
|
93
|
+
};
|
|
94
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
2
2
|
export { getSyncBlockNodesFromDoc, useMemoizedSyncedBlockNodeComponent } from './useSyncedBlockNodeComponent';
|
|
3
|
-
export { getSyncedBlockRenderer } from './getSyncedBlockRenderer';
|
|
3
|
+
export { getSyncedBlockRenderer } from './getSyncedBlockRenderer';
|
|
4
|
+
export { renderSyncedBlockContent } from './ui/renderSyncedBlockContent';
|
|
@@ -7,6 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
7
7
|
import React, { memo, useMemo } from 'react';
|
|
8
8
|
import { useIntl } from 'react-intl-next';
|
|
9
9
|
import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
import { ReactRenderer, ValidationContextProvider, defaultNodeComponents } from '@atlaskit/renderer';
|
|
11
12
|
import { RendererActionsContext } from '@atlaskit/renderer/actions';
|
|
12
13
|
import { RendererContextProvider } from '@atlaskit/renderer/renderer-context';
|
|
@@ -82,7 +83,8 @@ export var AKRendererWrapper = /*#__PURE__*/memo(function (_ref3) {
|
|
|
82
83
|
eventHandlers = _ref4.eventHandlers,
|
|
83
84
|
media = _ref4.media,
|
|
84
85
|
smartLinks = _ref4.smartLinks,
|
|
85
|
-
stickyHeaders = _ref4.stickyHeaders
|
|
86
|
+
stickyHeaders = _ref4.stickyHeaders,
|
|
87
|
+
contentMode = _ref4.contentMode;
|
|
86
88
|
var nodeComponents = useMemo(function () {
|
|
87
89
|
return {
|
|
88
90
|
taskItem: function taskItem(props) {
|
|
@@ -127,6 +129,7 @@ export var AKRendererWrapper = /*#__PURE__*/memo(function (_ref3) {
|
|
|
127
129
|
eventHandlers: eventHandlers,
|
|
128
130
|
media: media,
|
|
129
131
|
smartLinks: smartLinks,
|
|
130
|
-
stickyHeaders: stickyHeaders
|
|
132
|
+
stickyHeaders: stickyHeaders,
|
|
133
|
+
contentMode: fg('platform_synced_block_patch_5') ? contentMode : undefined
|
|
131
134
|
})))));
|
|
132
135
|
});
|
|
@@ -8,10 +8,11 @@ import { SyncBlockSharedCssClassName, SyncBlockRendererDataAttributeName, handle
|
|
|
8
8
|
import { SyncBlockError, useFetchSyncBlockData } from '@atlaskit/editor-synced-block-provider';
|
|
9
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
10
|
import { AKRendererWrapper } from './AKRendererWrapper';
|
|
11
|
+
import { renderSyncedBlockContent } from './renderSyncedBlockContent';
|
|
11
12
|
import { SyncedBlockErrorComponent } from './SyncedBlockErrorComponent';
|
|
12
13
|
import { SyncedBlockLoadingState } from './SyncedBlockLoadingState';
|
|
13
14
|
export var SyncedBlockNodeComponentRenderer = function SyncedBlockNodeComponentRenderer(_ref) {
|
|
14
|
-
var _syncBlockInstance$
|
|
15
|
+
var _syncBlockInstance$da6;
|
|
15
16
|
var nodeProps = _ref.nodeProps,
|
|
16
17
|
syncBlockStoreManager = _ref.syncBlockStoreManager,
|
|
17
18
|
rendererOptions = _ref.rendererOptions;
|
|
@@ -55,6 +56,34 @@ export var SyncedBlockNodeComponentRenderer = function SyncedBlockNodeComponentR
|
|
|
55
56
|
})
|
|
56
57
|
});
|
|
57
58
|
}, [rendererOptions, ssrProviders]);
|
|
59
|
+
if (fg('platform_synced_block_patch_5')) {
|
|
60
|
+
var _syncBlockInstance$er, _syncBlockInstance$da, _syncBlockInstance$da2;
|
|
61
|
+
var errorForDisplay = (_syncBlockInstance$er = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : (syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.status) === 'deleted' ? {
|
|
62
|
+
type: SyncBlockError.NotFound,
|
|
63
|
+
reason: (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.deletionReason
|
|
64
|
+
} : {
|
|
65
|
+
type: SyncBlockError.Errored,
|
|
66
|
+
reason: !resourceId ? 'missing resource id' : "missing data for block ".concat(resourceId)
|
|
67
|
+
};
|
|
68
|
+
var result = renderSyncedBlockContent({
|
|
69
|
+
syncBlockInstance: syncBlockInstance !== null && syncBlockInstance !== void 0 ? syncBlockInstance : undefined,
|
|
70
|
+
isLoading: isLoading,
|
|
71
|
+
rendererOptions: finalRendererOptions,
|
|
72
|
+
providerFactory: providerFactory,
|
|
73
|
+
reloadData: reloadData,
|
|
74
|
+
fireAnalyticsEvent: fireAnalyticsEvent,
|
|
75
|
+
resourceId: resourceId,
|
|
76
|
+
error: errorForDisplay
|
|
77
|
+
});
|
|
78
|
+
if (result.isSuccess) {
|
|
79
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
80
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
81
|
+
className: SyncBlockSharedCssClassName.renderer
|
|
82
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
83
|
+
}, _defineProperty({}, SyncBlockRendererDataAttributeName, true)), result.element);
|
|
84
|
+
}
|
|
85
|
+
return result.element;
|
|
86
|
+
}
|
|
58
87
|
if (isLoading && !syncBlockInstance) {
|
|
59
88
|
return /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null);
|
|
60
89
|
}
|
|
@@ -65,16 +94,16 @@ export var SyncedBlockNodeComponentRenderer = function SyncedBlockNodeComponentR
|
|
|
65
94
|
return /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null);
|
|
66
95
|
}
|
|
67
96
|
if (!resourceId || syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.error || !(syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.data) || syncBlockInstance.data.status === 'deleted') {
|
|
68
|
-
var _syncBlockInstance$
|
|
69
|
-
var errorMessage = (_syncBlockInstance$
|
|
97
|
+
var _syncBlockInstance$er2, _syncBlockInstance$da3, _syncBlockInstance$da4, _syncBlockInstance$er3, _syncBlockInstance$da5;
|
|
98
|
+
var errorMessage = (_syncBlockInstance$er2 = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _syncBlockInstance$er2 !== void 0 ? _syncBlockInstance$er2 : (syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da3 = syncBlockInstance.data) === null || _syncBlockInstance$da3 === void 0 ? void 0 : _syncBlockInstance$da3.status) === 'deleted' ? {
|
|
70
99
|
type: SyncBlockError.NotFound,
|
|
71
|
-
reason: (_syncBlockInstance$
|
|
100
|
+
reason: (_syncBlockInstance$da4 = syncBlockInstance.data) === null || _syncBlockInstance$da4 === void 0 ? void 0 : _syncBlockInstance$da4.deletionReason
|
|
72
101
|
} : {
|
|
73
102
|
type: SyncBlockError.Errored,
|
|
74
103
|
reason: !resourceId ? 'missing resource id' : "missing data for block ".concat(resourceId)
|
|
75
104
|
};
|
|
76
105
|
return /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
|
|
77
|
-
error: fg('platform_synced_block_patch_3') ? errorMessage : (_syncBlockInstance$
|
|
106
|
+
error: fg('platform_synced_block_patch_3') ? errorMessage : (_syncBlockInstance$er3 = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _syncBlockInstance$er3 !== void 0 ? _syncBlockInstance$er3 : (syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da5 = syncBlockInstance.data) === null || _syncBlockInstance$da5 === void 0 ? void 0 : _syncBlockInstance$da5.status) === 'deleted' ? {
|
|
78
107
|
type: SyncBlockError.NotFound
|
|
79
108
|
} : {
|
|
80
109
|
type: SyncBlockError.Errored
|
|
@@ -85,14 +114,14 @@ export var SyncedBlockNodeComponentRenderer = function SyncedBlockNodeComponentR
|
|
|
85
114
|
fireAnalyticsEvent: fireAnalyticsEvent
|
|
86
115
|
});
|
|
87
116
|
}
|
|
88
|
-
if ((syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$
|
|
89
|
-
var _syncBlockInstance$
|
|
117
|
+
if ((syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da6 = syncBlockInstance.data) === null || _syncBlockInstance$da6 === void 0 ? void 0 : _syncBlockInstance$da6.status) === 'unpublished') {
|
|
118
|
+
var _syncBlockInstance$da7;
|
|
90
119
|
return /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
|
|
91
120
|
error: {
|
|
92
121
|
type: SyncBlockError.Unpublished
|
|
93
122
|
},
|
|
94
123
|
resourceId: syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.resourceId,
|
|
95
|
-
sourceURL: (_syncBlockInstance$
|
|
124
|
+
sourceURL: (_syncBlockInstance$da7 = syncBlockInstance.data) === null || _syncBlockInstance$da7 === void 0 ? void 0 : _syncBlockInstance$da7.sourceURL,
|
|
96
125
|
fireAnalyticsEvent: fireAnalyticsEvent
|
|
97
126
|
});
|
|
98
127
|
}
|
|
@@ -6,7 +6,9 @@ import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
|
6
6
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
7
7
|
import { handleSSRErrorsAnalytics } from '@atlaskit/editor-common/sync-block';
|
|
8
8
|
import { SyncBlockError } from '@atlaskit/editor-synced-block-provider';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
10
|
import { AKRendererWrapper } from './AKRendererWrapper';
|
|
11
|
+
import { renderSyncedBlockContent } from './renderSyncedBlockContent';
|
|
10
12
|
import { SyncedBlockErrorComponent } from './SyncedBlockErrorComponent';
|
|
11
13
|
import { SyncedBlockLoadingState } from './SyncedBlockLoadingState';
|
|
12
14
|
var SyncedBlockRendererComponent = function SyncedBlockRendererComponent(_ref) {
|
|
@@ -47,13 +49,32 @@ var SyncedBlockRendererComponent = function SyncedBlockRendererComponent(_ref) {
|
|
|
47
49
|
})
|
|
48
50
|
});
|
|
49
51
|
}, [syncBlockRendererOptions, ssrProviders, isSSRMode]);
|
|
50
|
-
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['connectivity'], function (_ref2) {
|
|
51
|
-
var connectivityState = _ref2.connectivityState
|
|
52
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['connectivity', 'contentFormat'], function (_ref2) {
|
|
53
|
+
var connectivityState = _ref2.connectivityState,
|
|
54
|
+
contentFormatState = _ref2.contentFormatState;
|
|
52
55
|
return {
|
|
53
|
-
isCollabOffline: (connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode) === 'collab-offline'
|
|
56
|
+
isCollabOffline: (connectivityState === null || connectivityState === void 0 ? void 0 : connectivityState.mode) === 'collab-offline',
|
|
57
|
+
contentMode: contentFormatState === null || contentFormatState === void 0 ? void 0 : contentFormatState.contentMode
|
|
54
58
|
};
|
|
55
59
|
}),
|
|
56
|
-
isCollabOffline = _useSharedPluginState.isCollabOffline
|
|
60
|
+
isCollabOffline = _useSharedPluginState.isCollabOffline,
|
|
61
|
+
contentMode = _useSharedPluginState.contentMode;
|
|
62
|
+
if (fg('platform_synced_block_patch_5')) {
|
|
63
|
+
var _api$analytics2;
|
|
64
|
+
var result = renderSyncedBlockContent({
|
|
65
|
+
syncBlockInstance: syncBlockInstance,
|
|
66
|
+
isLoading: isLoading,
|
|
67
|
+
rendererOptions: contentMode ? _objectSpread(_objectSpread({}, rendererOptions), {}, {
|
|
68
|
+
contentMode: contentMode
|
|
69
|
+
}) : rendererOptions,
|
|
70
|
+
providerFactory: providerFactory,
|
|
71
|
+
reloadData: reloadData,
|
|
72
|
+
fireAnalyticsEvent: api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.fireAnalyticsEvent,
|
|
73
|
+
resourceId: syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.resourceId,
|
|
74
|
+
isOffline: isCollabOffline
|
|
75
|
+
});
|
|
76
|
+
return result.element;
|
|
77
|
+
}
|
|
57
78
|
|
|
58
79
|
// Show offline error only when collaboration is offline and not in SSR mode
|
|
59
80
|
// In SSR, we should always attempt to render content
|
|
@@ -74,7 +95,7 @@ var SyncedBlockRendererComponent = function SyncedBlockRendererComponent(_ref) {
|
|
|
74
95
|
return /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null);
|
|
75
96
|
}
|
|
76
97
|
if (syncBlockInstance.error || !syncBlockInstance.data || syncBlockInstance.data.status === 'deleted') {
|
|
77
|
-
var _syncBlockInstance$er, _syncBlockInstance$da, _api$
|
|
98
|
+
var _syncBlockInstance$er, _syncBlockInstance$da, _api$analytics3;
|
|
78
99
|
return /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
|
|
79
100
|
error: (_syncBlockInstance$er = syncBlockInstance.error) !== null && _syncBlockInstance$er !== void 0 ? _syncBlockInstance$er : (syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.status) === 'deleted' ? {
|
|
80
101
|
type: SyncBlockError.NotFound
|
|
@@ -84,20 +105,20 @@ var SyncedBlockRendererComponent = function SyncedBlockRendererComponent(_ref) {
|
|
|
84
105
|
resourceId: syncBlockInstance.resourceId,
|
|
85
106
|
onRetry: reloadData,
|
|
86
107
|
isLoading: isLoading,
|
|
87
|
-
fireAnalyticsEvent: api === null || api === void 0 || (_api$
|
|
108
|
+
fireAnalyticsEvent: api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.fireAnalyticsEvent
|
|
88
109
|
});
|
|
89
110
|
}
|
|
90
111
|
|
|
91
112
|
// Check for unpublished status
|
|
92
113
|
if (((_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.status) === 'unpublished') {
|
|
93
|
-
var _syncBlockInstance$da3, _api$
|
|
114
|
+
var _syncBlockInstance$da3, _api$analytics4;
|
|
94
115
|
return /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
|
|
95
116
|
error: {
|
|
96
117
|
type: SyncBlockError.Unpublished
|
|
97
118
|
},
|
|
98
119
|
resourceId: syncBlockInstance.resourceId,
|
|
99
120
|
sourceURL: (_syncBlockInstance$da3 = syncBlockInstance.data) === null || _syncBlockInstance$da3 === void 0 ? void 0 : _syncBlockInstance$da3.sourceURL,
|
|
100
|
-
fireAnalyticsEvent: api === null || api === void 0 || (_api$
|
|
121
|
+
fireAnalyticsEvent: api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions.fireAnalyticsEvent
|
|
101
122
|
});
|
|
102
123
|
}
|
|
103
124
|
var syncBlockDoc = {
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
3
|
+
import { SyncBlockError } from '@atlaskit/editor-synced-block-provider';
|
|
4
|
+
import { AKRendererWrapper } from './AKRendererWrapper';
|
|
5
|
+
import { SyncedBlockErrorComponent } from './SyncedBlockErrorComponent';
|
|
6
|
+
import { SyncedBlockLoadingState } from './SyncedBlockLoadingState';
|
|
7
|
+
/**
|
|
8
|
+
* Shared rendering logic for synced block content used by both
|
|
9
|
+
* SyncedBlockRenderer (editor mode) and SyncedBlockNodeComponentRenderer (renderer mode).
|
|
10
|
+
*
|
|
11
|
+
* Handles the common branching: loading -> SSR error -> error/deleted -> unpublished -> success.
|
|
12
|
+
* Returns null if the caller should handle rendering itself (e.g. wrapping in a container div).
|
|
13
|
+
*/
|
|
14
|
+
export function renderSyncedBlockContent(_ref) {
|
|
15
|
+
var _syncBlockInstance$da2;
|
|
16
|
+
var syncBlockInstance = _ref.syncBlockInstance,
|
|
17
|
+
isLoading = _ref.isLoading,
|
|
18
|
+
rendererOptions = _ref.rendererOptions,
|
|
19
|
+
providerFactory = _ref.providerFactory,
|
|
20
|
+
reloadData = _ref.reloadData,
|
|
21
|
+
fireAnalyticsEvent = _ref.fireAnalyticsEvent,
|
|
22
|
+
resourceId = _ref.resourceId,
|
|
23
|
+
isOffline = _ref.isOffline,
|
|
24
|
+
error = _ref.error;
|
|
25
|
+
var isSSRMode = isSSR();
|
|
26
|
+
if (isOffline && !isSSRMode) {
|
|
27
|
+
return {
|
|
28
|
+
element: /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
|
|
29
|
+
error: {
|
|
30
|
+
type: SyncBlockError.Offline
|
|
31
|
+
}
|
|
32
|
+
}),
|
|
33
|
+
isSuccess: false
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (isLoading && !syncBlockInstance) {
|
|
37
|
+
return {
|
|
38
|
+
element: /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null),
|
|
39
|
+
isSuccess: false
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (isSSRMode && syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.error) {
|
|
43
|
+
return {
|
|
44
|
+
element: /*#__PURE__*/React.createElement(SyncedBlockLoadingState, null),
|
|
45
|
+
isSuccess: false
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (!resourceId || syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.error || !(syncBlockInstance !== null && syncBlockInstance !== void 0 && syncBlockInstance.data) || syncBlockInstance.data.status === 'deleted') {
|
|
49
|
+
var _ref2, _syncBlockInstance$da;
|
|
50
|
+
var errorToDisplay = (_ref2 = error !== null && error !== void 0 ? error : syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error) !== null && _ref2 !== void 0 ? _ref2 : (syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.status) === 'deleted' ? {
|
|
51
|
+
type: SyncBlockError.NotFound
|
|
52
|
+
} : {
|
|
53
|
+
type: SyncBlockError.Errored
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
element: /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
|
|
57
|
+
error: errorToDisplay,
|
|
58
|
+
resourceId: resourceId,
|
|
59
|
+
onRetry: reloadData,
|
|
60
|
+
isLoading: isLoading,
|
|
61
|
+
fireAnalyticsEvent: fireAnalyticsEvent
|
|
62
|
+
}),
|
|
63
|
+
isSuccess: false
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
if ((syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.status) === 'unpublished') {
|
|
67
|
+
var _syncBlockInstance$da3;
|
|
68
|
+
return {
|
|
69
|
+
element: /*#__PURE__*/React.createElement(SyncedBlockErrorComponent, {
|
|
70
|
+
error: {
|
|
71
|
+
type: SyncBlockError.Unpublished
|
|
72
|
+
},
|
|
73
|
+
resourceId: resourceId,
|
|
74
|
+
sourceURL: (_syncBlockInstance$da3 = syncBlockInstance.data) === null || _syncBlockInstance$da3 === void 0 ? void 0 : _syncBlockInstance$da3.sourceURL,
|
|
75
|
+
fireAnalyticsEvent: fireAnalyticsEvent
|
|
76
|
+
}),
|
|
77
|
+
isSuccess: false
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
var syncBlockDoc = {
|
|
81
|
+
content: syncBlockInstance.data.content,
|
|
82
|
+
version: 1,
|
|
83
|
+
type: 'doc'
|
|
84
|
+
};
|
|
85
|
+
return {
|
|
86
|
+
element: /*#__PURE__*/React.createElement(AKRendererWrapper, {
|
|
87
|
+
doc: syncBlockDoc,
|
|
88
|
+
dataProviders: providerFactory,
|
|
89
|
+
options: rendererOptions
|
|
90
|
+
}),
|
|
91
|
+
isSuccess: true
|
|
92
|
+
};
|
|
93
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { getSyncBlockNodesFromDoc, useMemoizedSyncedBlockNodeComponent, type GetSyncedBlockNodeComponentProps, } from './useSyncedBlockNodeComponent';
|
|
2
2
|
export { getSyncedBlockRenderer } from './getSyncedBlockRenderer';
|
|
3
3
|
export type { SyncedBlockNodeProps } from './ui/SyncedBlockNodeComponentRenderer';
|
|
4
|
+
export { renderSyncedBlockContent, type RenderSyncedBlockContentParams, } from './ui/renderSyncedBlockContent';
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type RendererProps } from '@atlaskit/renderer';
|
|
2
|
-
export type SyncedBlockRendererOptions = Pick<RendererProps, 'appearance' | 'allowAltTextOnImages' | 'allowAnnotations' | 'allowColumnSorting' | 'allowCopyToClipboard' | 'allowCustomPanels' | 'allowHeadingAnchorLinks' | 'allowPlaceholderText' | 'allowRendererContainerStyles' | 'allowSelectAllTrap' | 'allowUgcScrubber' | 'allowWrapCodeBlock' | 'emojiResourceConfig' | 'eventHandlers' | 'media' | 'smartLinks' | 'stickyHeaders'>;
|
|
2
|
+
export type SyncedBlockRendererOptions = Pick<RendererProps, 'appearance' | 'allowAltTextOnImages' | 'allowAnnotations' | 'allowColumnSorting' | 'allowCopyToClipboard' | 'allowCustomPanels' | 'allowHeadingAnchorLinks' | 'allowPlaceholderText' | 'allowRendererContainerStyles' | 'allowSelectAllTrap' | 'allowUgcScrubber' | 'allowWrapCodeBlock' | 'emojiResourceConfig' | 'eventHandlers' | 'media' | 'smartLinks' | 'stickyHeaders' | 'contentMode'>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
4
|
+
import { type SyncBlockInstance } from '@atlaskit/editor-synced-block-provider';
|
|
5
|
+
import type { SyncedBlockRendererOptions } from '../types';
|
|
6
|
+
export type RenderSyncedBlockContentParams = {
|
|
7
|
+
error?: SyncBlockInstance['error'];
|
|
8
|
+
fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
isOffline?: boolean;
|
|
11
|
+
providerFactory: ProviderFactory | undefined;
|
|
12
|
+
reloadData?: () => void;
|
|
13
|
+
rendererOptions: SyncedBlockRendererOptions | undefined;
|
|
14
|
+
resourceId?: string;
|
|
15
|
+
syncBlockInstance: SyncBlockInstance | null | undefined;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Shared rendering logic for synced block content used by both
|
|
19
|
+
* SyncedBlockRenderer (editor mode) and SyncedBlockNodeComponentRenderer (renderer mode).
|
|
20
|
+
*
|
|
21
|
+
* Handles the common branching: loading -> SSR error -> error/deleted -> unpublished -> success.
|
|
22
|
+
* Returns null if the caller should handle rendering itself (e.g. wrapping in a container div).
|
|
23
|
+
*/
|
|
24
|
+
export declare function renderSyncedBlockContent({ syncBlockInstance, isLoading, rendererOptions, providerFactory, reloadData, fireAnalyticsEvent, resourceId, isOffline, error, }: RenderSyncedBlockContentParams): {
|
|
25
|
+
element: React.JSX.Element;
|
|
26
|
+
isSuccess: boolean;
|
|
27
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { getSyncBlockNodesFromDoc, useMemoizedSyncedBlockNodeComponent, type GetSyncedBlockNodeComponentProps, } from './useSyncedBlockNodeComponent';
|
|
2
2
|
export { getSyncedBlockRenderer } from './getSyncedBlockRenderer';
|
|
3
3
|
export type { SyncedBlockNodeProps } from './ui/SyncedBlockNodeComponentRenderer';
|
|
4
|
+
export { renderSyncedBlockContent, type RenderSyncedBlockContentParams, } from './ui/renderSyncedBlockContent';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type RendererProps } from '@atlaskit/renderer';
|
|
2
|
-
export type SyncedBlockRendererOptions = Pick<RendererProps, 'appearance' | 'allowAltTextOnImages' | 'allowAnnotations' | 'allowColumnSorting' | 'allowCopyToClipboard' | 'allowCustomPanels' | 'allowHeadingAnchorLinks' | 'allowPlaceholderText' | 'allowRendererContainerStyles' | 'allowSelectAllTrap' | 'allowUgcScrubber' | 'allowWrapCodeBlock' | 'emojiResourceConfig' | 'eventHandlers' | 'media' | 'smartLinks' | 'stickyHeaders'>;
|
|
2
|
+
export type SyncedBlockRendererOptions = Pick<RendererProps, 'appearance' | 'allowAltTextOnImages' | 'allowAnnotations' | 'allowColumnSorting' | 'allowCopyToClipboard' | 'allowCustomPanels' | 'allowHeadingAnchorLinks' | 'allowPlaceholderText' | 'allowRendererContainerStyles' | 'allowSelectAllTrap' | 'allowUgcScrubber' | 'allowWrapCodeBlock' | 'emojiResourceConfig' | 'eventHandlers' | 'media' | 'smartLinks' | 'stickyHeaders' | 'contentMode'>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { RendererSyncBlockEventPayload } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
4
|
+
import { type SyncBlockInstance } from '@atlaskit/editor-synced-block-provider';
|
|
5
|
+
import type { SyncedBlockRendererOptions } from '../types';
|
|
6
|
+
export type RenderSyncedBlockContentParams = {
|
|
7
|
+
error?: SyncBlockInstance['error'];
|
|
8
|
+
fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
isOffline?: boolean;
|
|
11
|
+
providerFactory: ProviderFactory | undefined;
|
|
12
|
+
reloadData?: () => void;
|
|
13
|
+
rendererOptions: SyncedBlockRendererOptions | undefined;
|
|
14
|
+
resourceId?: string;
|
|
15
|
+
syncBlockInstance: SyncBlockInstance | null | undefined;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Shared rendering logic for synced block content used by both
|
|
19
|
+
* SyncedBlockRenderer (editor mode) and SyncedBlockNodeComponentRenderer (renderer mode).
|
|
20
|
+
*
|
|
21
|
+
* Handles the common branching: loading -> SSR error -> error/deleted -> unpublished -> success.
|
|
22
|
+
* Returns null if the caller should handle rendering itself (e.g. wrapping in a container div).
|
|
23
|
+
*/
|
|
24
|
+
export declare function renderSyncedBlockContent({ syncBlockInstance, isLoading, rendererOptions, providerFactory, reloadData, fireAnalyticsEvent, resourceId, isOffline, error, }: RenderSyncedBlockContentParams): {
|
|
25
|
+
element: React.JSX.Element;
|
|
26
|
+
isSuccess: boolean;
|
|
27
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-synced-block-renderer",
|
|
3
|
-
"version": "5.9.
|
|
3
|
+
"version": "5.9.6",
|
|
4
4
|
"description": "SyncedBlockRenderer for @atlaskit/editor-plugin-synced-block",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"atlaskit:src": "src/index.ts",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@atlaskit/button": "^23.
|
|
31
|
+
"@atlaskit/button": "^23.10.0",
|
|
32
32
|
"@atlaskit/css": "^0.19.0",
|
|
33
|
-
"@atlaskit/editor-plugin-synced-block": "^5.
|
|
33
|
+
"@atlaskit/editor-plugin-synced-block": "^5.4.0",
|
|
34
34
|
"@atlaskit/editor-synced-block-provider": "^3.31.0",
|
|
35
35
|
"@atlaskit/heading": "^5.3.0",
|
|
36
36
|
"@atlaskit/icon": "^32.0.0",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@atlaskit/image": "^3.0.0",
|
|
39
39
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
40
40
|
"@atlaskit/primitives": "^18.0.0",
|
|
41
|
-
"@atlaskit/renderer": "^126.
|
|
41
|
+
"@atlaskit/renderer": "^126.14.0",
|
|
42
42
|
"@atlaskit/spinner": "^19.0.0",
|
|
43
43
|
"@atlaskit/tokens": "^11.0.0",
|
|
44
44
|
"@atlaskit/tooltip": "^20.14.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"relay-runtime": "npm:atl-relay-runtime@0.0.0-main-39e79f66"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@atlaskit/editor-common": "^111.
|
|
51
|
+
"@atlaskit/editor-common": "^111.23.0",
|
|
52
52
|
"react": "^18.2.0",
|
|
53
53
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
54
54
|
},
|
|
@@ -94,6 +94,9 @@
|
|
|
94
94
|
},
|
|
95
95
|
"platform_synced_block_patch_4": {
|
|
96
96
|
"type": "boolean"
|
|
97
|
+
},
|
|
98
|
+
"platform_synced_block_patch_5": {
|
|
99
|
+
"type": "boolean"
|
|
97
100
|
}
|
|
98
101
|
}
|
|
99
102
|
}
|