@atlaskit/editor-synced-block-renderer 14.1.0 → 15.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/afm-products/tsconfig.json +3 -0
- package/dist/cjs/getSyncedBlockRenderer.js +4 -2
- package/dist/cjs/ui/AKRendererWrapper.js +21 -3
- package/dist/cjs/ui/SyncedBlockNodeComponentRenderer.js +7 -1
- package/dist/cjs/ui/SyncedBlockRenderer.js +4 -2
- package/dist/cjs/ui/renderSyncedBlockContent.js +4 -2
- package/dist/es2019/getSyncedBlockRenderer.js +4 -2
- package/dist/es2019/ui/AKRendererWrapper.js +21 -3
- package/dist/es2019/ui/SyncedBlockNodeComponentRenderer.js +7 -1
- package/dist/es2019/ui/SyncedBlockRenderer.js +4 -2
- package/dist/es2019/ui/renderSyncedBlockContent.js +4 -2
- package/dist/esm/getSyncedBlockRenderer.js +4 -2
- package/dist/esm/ui/AKRendererWrapper.js +21 -3
- package/dist/esm/ui/SyncedBlockNodeComponentRenderer.js +7 -1
- package/dist/esm/ui/SyncedBlockRenderer.js +4 -2
- package/dist/esm/ui/renderSyncedBlockContent.js +4 -2
- package/dist/types/getSyncedBlockRenderer.d.ts +1 -1
- package/dist/types/types.d.ts +1 -1
- package/dist/types/ui/AKRendererWrapper.d.ts +10 -2
- package/dist/types/ui/SyncedBlockRenderer.d.ts +7 -1
- package/dist/types/ui/renderSyncedBlockContent.d.ts +8 -1
- package/dist/types/useSyncedBlockNodeComponent.d.ts +1 -1
- package/package.json +16 -49
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-renderer
|
|
2
2
|
|
|
3
|
+
## 15.0.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`149408be91016`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/149408be91016) -
|
|
8
|
+
Thread the reference node's `localId` through the editor synced-block rendering path so products
|
|
9
|
+
can namespace heading ids inside synced block content.
|
|
10
|
+
|
|
11
|
+
`SyncedBlockRendererProps` gains an optional `localId`, which `SyncBlockRendererWrapper` now
|
|
12
|
+
forwards to the product-supplied `syncedBlockRenderer`. `SyncedBlockRenderer` accepts a matching
|
|
13
|
+
`localId` prop and passes it to `renderSyncedBlockContent` as `headingIdPrefix`.
|
|
14
|
+
|
|
15
|
+
This mirrors the existing view-page node component behaviour. Heading ids are still only emitted
|
|
16
|
+
when a prefix is supplied alongside `allowHeadingAnchorLinks`, so there is no change for consumers
|
|
17
|
+
that do not pass `localId`.
|
|
18
|
+
|
|
19
|
+
Confluence enables the new Table of Contents and heading-anchor behavior behind the
|
|
20
|
+
`confluence_toc_synced_block_exp` experiment.
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
|
|
26
|
+
## 14.2.0
|
|
27
|
+
|
|
28
|
+
### Minor Changes
|
|
29
|
+
|
|
30
|
+
- [`70beff9491f9d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/70beff9491f9d) -
|
|
31
|
+
Forward `mentionNodeDataProvider` into the synced block renderer so mention avatars resolve inside
|
|
32
|
+
a synced block replica location, matching the behaviour already gated by
|
|
33
|
+
`platform_editor_mention_node_avatar` elsewhere. The forwarding itself is gated behind a new
|
|
34
|
+
`platform_editor_mention_avatar_synced_block` experiment so this integration can be rolled out
|
|
35
|
+
independently.
|
|
36
|
+
|
|
3
37
|
## 14.1.0
|
|
4
38
|
|
|
5
39
|
### Minor Changes
|
|
@@ -13,12 +13,14 @@ var getSyncedBlockRenderer = exports.getSyncedBlockRenderer = function getSynced
|
|
|
13
13
|
getAccountId = _ref.getAccountId;
|
|
14
14
|
return function (_ref2) {
|
|
15
15
|
var syncBlockFetchResult = _ref2.syncBlockFetchResult,
|
|
16
|
-
api = _ref2.api
|
|
16
|
+
api = _ref2.api,
|
|
17
|
+
localId = _ref2.localId;
|
|
17
18
|
return /*#__PURE__*/_react.default.createElement(_SyncedBlockRenderer.SyncedBlockRenderer, {
|
|
18
19
|
syncBlockRendererOptions: syncBlockRendererOptions,
|
|
19
20
|
syncBlockFetchResult: syncBlockFetchResult,
|
|
20
21
|
api: api,
|
|
21
|
-
getAccountId: getAccountId
|
|
22
|
+
getAccountId: getAccountId,
|
|
23
|
+
localId: localId
|
|
22
24
|
});
|
|
23
25
|
};
|
|
24
26
|
};
|
|
@@ -12,6 +12,7 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _reactIntl = require("react-intl");
|
|
14
14
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
15
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
15
16
|
var _renderer = require("@atlaskit/renderer");
|
|
16
17
|
var _rendererActionsContext = require("@atlaskit/renderer/actions/renderer-actions-context");
|
|
17
18
|
var _rendererContext = require("@atlaskit/renderer/renderer-context");
|
|
@@ -72,7 +73,8 @@ var defaultOptions = {
|
|
|
72
73
|
var AKRendererWrapper = exports.AKRendererWrapper = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
|
|
73
74
|
var doc = _ref3.doc,
|
|
74
75
|
dataProviders = _ref3.dataProviders,
|
|
75
|
-
options = _ref3.options
|
|
76
|
+
options = _ref3.options,
|
|
77
|
+
headingIdPrefix = _ref3.headingIdPrefix;
|
|
76
78
|
var mergedOptions = _objectSpread(_objectSpread({}, defaultOptions), options);
|
|
77
79
|
var _ref4 = mergedOptions !== null && mergedOptions !== void 0 ? mergedOptions : {},
|
|
78
80
|
appearance = _ref4.appearance,
|
|
@@ -90,9 +92,18 @@ var AKRendererWrapper = exports.AKRendererWrapper = /*#__PURE__*/(0, _react.memo
|
|
|
90
92
|
emojiResourceConfig = _ref4.emojiResourceConfig,
|
|
91
93
|
eventHandlers = _ref4.eventHandlers,
|
|
92
94
|
media = _ref4.media,
|
|
95
|
+
mentionNodeDataProvider = _ref4.mentionNodeDataProvider,
|
|
93
96
|
smartLinks = _ref4.smartLinks,
|
|
94
97
|
stickyHeaders = _ref4.stickyHeaders,
|
|
95
98
|
contentMode = _ref4.contentMode;
|
|
99
|
+
|
|
100
|
+
// Only stamp heading ids when a prefix is supplied AND the consumer has
|
|
101
|
+
// opted into heading anchor links. This keeps the change scoped: consumers
|
|
102
|
+
// that enable ToC/anchor support (e.g. Confluence, behind its experiment)
|
|
103
|
+
// pass both a per-instance prefix (the reference block's localId) and
|
|
104
|
+
// `allowHeadingAnchorLinks`; every other consumer keeps id-less headings and
|
|
105
|
+
// is unaffected.
|
|
106
|
+
var headingIdsEnabled = typeof headingIdPrefix === 'string' && headingIdPrefix.length > 0 && Boolean(allowHeadingAnchorLinks);
|
|
96
107
|
var nodeComponents = (0, _react.useMemo)(function () {
|
|
97
108
|
return {
|
|
98
109
|
taskItem: function taskItem(props) {
|
|
@@ -119,7 +130,8 @@ var AKRendererWrapper = exports.AKRendererWrapper = /*#__PURE__*/(0, _react.memo
|
|
|
119
130
|
appearance: appearance,
|
|
120
131
|
adfStage: "stage0",
|
|
121
132
|
document: doc,
|
|
122
|
-
disableHeadingIDs:
|
|
133
|
+
disableHeadingIDs: !headingIdsEnabled,
|
|
134
|
+
headingIdPrefix: headingIdsEnabled ? headingIdPrefix : undefined,
|
|
123
135
|
dataProviders: dataProviders,
|
|
124
136
|
nodeComponents: nodeComponents,
|
|
125
137
|
allowAltTextOnImages: allowAltTextOnImages,
|
|
@@ -136,7 +148,13 @@ var AKRendererWrapper = exports.AKRendererWrapper = /*#__PURE__*/(0, _react.memo
|
|
|
136
148
|
disableTableOverflowShadow: true,
|
|
137
149
|
emojiResourceConfig: emojiResourceConfig,
|
|
138
150
|
eventHandlers: eventHandlers,
|
|
139
|
-
media: media
|
|
151
|
+
media: media
|
|
152
|
+
// Synced block replica locations render through this wrapper rather than the
|
|
153
|
+
// main editor/renderer surfaces, so forwarding the provider here is gated
|
|
154
|
+
// independently of `platform_editor_mention_node_avatar` (which still controls
|
|
155
|
+
// whether the avatar itself renders once a provider is present).
|
|
156
|
+
,
|
|
157
|
+
mentionNodeDataProvider: (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_mention_avatar_synced_block') ? mentionNodeDataProvider : undefined,
|
|
140
158
|
smartLinks: smartLinks,
|
|
141
159
|
stickyHeaders: stickyHeaders,
|
|
142
160
|
contentMode: contentMode
|
|
@@ -91,7 +91,13 @@ var SyncedBlockNodeComponentRenderer = exports.SyncedBlockNodeComponentRenderer
|
|
|
91
91
|
fireAnalyticsEvent: syncBlockFireAnalyticsEvent,
|
|
92
92
|
resourceId: resourceId,
|
|
93
93
|
error: errorForDisplay,
|
|
94
|
-
getAccountId: getAccountId
|
|
94
|
+
getAccountId: getAccountId,
|
|
95
|
+
// Prefix heading ids with the reference node's localId so ToC deep links
|
|
96
|
+
// and heading anchor links resolve, and so the same source block embedded
|
|
97
|
+
// twice on a page produces distinct, stable ids. Only takes effect when the
|
|
98
|
+
// renderer options enable heading anchor links; otherwise the prefix is set
|
|
99
|
+
// but ids stay disabled inside AKRendererWrapper.
|
|
100
|
+
headingIdPrefix: localId
|
|
95
101
|
});
|
|
96
102
|
if (result.isSuccess) {
|
|
97
103
|
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
@@ -18,7 +18,8 @@ var SyncedBlockRendererComponent = function SyncedBlockRendererComponent(_ref) {
|
|
|
18
18
|
var syncBlockRendererOptions = _ref.syncBlockRendererOptions,
|
|
19
19
|
syncBlockFetchResult = _ref.syncBlockFetchResult,
|
|
20
20
|
api = _ref.api,
|
|
21
|
-
getAccountId = _ref.getAccountId
|
|
21
|
+
getAccountId = _ref.getAccountId,
|
|
22
|
+
localId = _ref.localId;
|
|
22
23
|
(0, _react.useEffect)(function () {
|
|
23
24
|
var timeoutId = setTimeout(function () {
|
|
24
25
|
var _api$analytics;
|
|
@@ -73,7 +74,8 @@ var SyncedBlockRendererComponent = function SyncedBlockRendererComponent(_ref) {
|
|
|
73
74
|
fireAnalyticsEvent: api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.fireAnalyticsEvent,
|
|
74
75
|
resourceId: syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.resourceId,
|
|
75
76
|
isOffline: isCollabOffline,
|
|
76
|
-
getAccountId: getAccountId
|
|
77
|
+
getAccountId: getAccountId,
|
|
78
|
+
headingIdPrefix: localId
|
|
77
79
|
});
|
|
78
80
|
return result.element;
|
|
79
81
|
};
|
|
@@ -29,7 +29,8 @@ function renderSyncedBlockContent(_ref) {
|
|
|
29
29
|
resourceId = _ref.resourceId,
|
|
30
30
|
isOffline = _ref.isOffline,
|
|
31
31
|
error = _ref.error,
|
|
32
|
-
getAccountId = _ref.getAccountId
|
|
32
|
+
getAccountId = _ref.getAccountId,
|
|
33
|
+
headingIdPrefix = _ref.headingIdPrefix;
|
|
33
34
|
var isSSRMode = (0, _coreUtils.isSSR)();
|
|
34
35
|
if (isOffline && !isSSRMode) {
|
|
35
36
|
return {
|
|
@@ -99,7 +100,8 @@ function renderSyncedBlockContent(_ref) {
|
|
|
99
100
|
element: /*#__PURE__*/_react.default.createElement(_AKRendererWrapper.AKRendererWrapper, {
|
|
100
101
|
doc: syncBlockDoc,
|
|
101
102
|
dataProviders: providerFactory,
|
|
102
|
-
options: rendererOptions
|
|
103
|
+
options: rendererOptions,
|
|
104
|
+
headingIdPrefix: headingIdPrefix
|
|
103
105
|
}),
|
|
104
106
|
isSuccess: true
|
|
105
107
|
};
|
|
@@ -6,12 +6,14 @@ export const getSyncedBlockRenderer = ({
|
|
|
6
6
|
getAccountId
|
|
7
7
|
}) => ({
|
|
8
8
|
syncBlockFetchResult,
|
|
9
|
-
api
|
|
9
|
+
api,
|
|
10
|
+
localId
|
|
10
11
|
}) => {
|
|
11
12
|
return /*#__PURE__*/React.createElement(SyncedBlockRenderer, {
|
|
12
13
|
syncBlockRendererOptions: syncBlockRendererOptions,
|
|
13
14
|
syncBlockFetchResult: syncBlockFetchResult,
|
|
14
15
|
api: api,
|
|
15
|
-
getAccountId: getAccountId
|
|
16
|
+
getAccountId: getAccountId,
|
|
17
|
+
localId: localId
|
|
16
18
|
});
|
|
17
19
|
};
|
|
@@ -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';
|
|
4
4
|
import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
5
6
|
import { ReactRenderer, ValidationContextProvider, defaultNodeComponents } from '@atlaskit/renderer';
|
|
6
7
|
import { RendererActionsContext } from '@atlaskit/renderer/actions/renderer-actions-context';
|
|
7
8
|
import { RendererContextProvider } from '@atlaskit/renderer/renderer-context';
|
|
@@ -59,7 +60,8 @@ const defaultOptions = {
|
|
|
59
60
|
export const AKRendererWrapper = /*#__PURE__*/memo(({
|
|
60
61
|
doc,
|
|
61
62
|
dataProviders,
|
|
62
|
-
options
|
|
63
|
+
options,
|
|
64
|
+
headingIdPrefix
|
|
63
65
|
}) => {
|
|
64
66
|
const mergedOptions = {
|
|
65
67
|
...defaultOptions,
|
|
@@ -81,10 +83,19 @@ export const AKRendererWrapper = /*#__PURE__*/memo(({
|
|
|
81
83
|
emojiResourceConfig,
|
|
82
84
|
eventHandlers,
|
|
83
85
|
media,
|
|
86
|
+
mentionNodeDataProvider,
|
|
84
87
|
smartLinks,
|
|
85
88
|
stickyHeaders,
|
|
86
89
|
contentMode
|
|
87
90
|
} = mergedOptions !== null && mergedOptions !== void 0 ? mergedOptions : {};
|
|
91
|
+
|
|
92
|
+
// Only stamp heading ids when a prefix is supplied AND the consumer has
|
|
93
|
+
// opted into heading anchor links. This keeps the change scoped: consumers
|
|
94
|
+
// that enable ToC/anchor support (e.g. Confluence, behind its experiment)
|
|
95
|
+
// pass both a per-instance prefix (the reference block's localId) and
|
|
96
|
+
// `allowHeadingAnchorLinks`; every other consumer keeps id-less headings and
|
|
97
|
+
// is unaffected.
|
|
98
|
+
const headingIdsEnabled = typeof headingIdPrefix === 'string' && headingIdPrefix.length > 0 && Boolean(allowHeadingAnchorLinks);
|
|
88
99
|
const nodeComponents = useMemo(() => {
|
|
89
100
|
return {
|
|
90
101
|
taskItem: props => {
|
|
@@ -111,7 +122,8 @@ export const AKRendererWrapper = /*#__PURE__*/memo(({
|
|
|
111
122
|
appearance: appearance,
|
|
112
123
|
adfStage: "stage0",
|
|
113
124
|
document: doc,
|
|
114
|
-
disableHeadingIDs:
|
|
125
|
+
disableHeadingIDs: !headingIdsEnabled,
|
|
126
|
+
headingIdPrefix: headingIdsEnabled ? headingIdPrefix : undefined,
|
|
115
127
|
dataProviders: dataProviders,
|
|
116
128
|
nodeComponents: nodeComponents,
|
|
117
129
|
allowAltTextOnImages: allowAltTextOnImages,
|
|
@@ -128,7 +140,13 @@ export const AKRendererWrapper = /*#__PURE__*/memo(({
|
|
|
128
140
|
disableTableOverflowShadow: true,
|
|
129
141
|
emojiResourceConfig: emojiResourceConfig,
|
|
130
142
|
eventHandlers: eventHandlers,
|
|
131
|
-
media: media
|
|
143
|
+
media: media
|
|
144
|
+
// Synced block replica locations render through this wrapper rather than the
|
|
145
|
+
// main editor/renderer surfaces, so forwarding the provider here is gated
|
|
146
|
+
// independently of `platform_editor_mention_node_avatar` (which still controls
|
|
147
|
+
// whether the avatar itself renders once a provider is present).
|
|
148
|
+
,
|
|
149
|
+
mentionNodeDataProvider: isExperimentEnabled('platform_editor_mention_avatar_synced_block') ? mentionNodeDataProvider : undefined,
|
|
132
150
|
smartLinks: smartLinks,
|
|
133
151
|
stickyHeaders: stickyHeaders,
|
|
134
152
|
contentMode: contentMode
|
|
@@ -84,7 +84,13 @@ export const SyncedBlockNodeComponentRenderer = ({
|
|
|
84
84
|
fireAnalyticsEvent: syncBlockFireAnalyticsEvent,
|
|
85
85
|
resourceId,
|
|
86
86
|
error: errorForDisplay,
|
|
87
|
-
getAccountId
|
|
87
|
+
getAccountId,
|
|
88
|
+
// Prefix heading ids with the reference node's localId so ToC deep links
|
|
89
|
+
// and heading anchor links resolve, and so the same source block embedded
|
|
90
|
+
// twice on a page produces distinct, stable ids. Only takes effect when the
|
|
91
|
+
// renderer options enable heading anchor links; otherwise the prefix is set
|
|
92
|
+
// but ids stay disabled inside AKRendererWrapper.
|
|
93
|
+
headingIdPrefix: localId
|
|
88
94
|
});
|
|
89
95
|
if (result.isSuccess) {
|
|
90
96
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -7,7 +7,8 @@ const SyncedBlockRendererComponent = ({
|
|
|
7
7
|
syncBlockRendererOptions,
|
|
8
8
|
syncBlockFetchResult,
|
|
9
9
|
api,
|
|
10
|
-
getAccountId
|
|
10
|
+
getAccountId,
|
|
11
|
+
localId
|
|
11
12
|
}) => {
|
|
12
13
|
var _api$analytics2;
|
|
13
14
|
useEffect(() => {
|
|
@@ -69,7 +70,8 @@ const SyncedBlockRendererComponent = ({
|
|
|
69
70
|
fireAnalyticsEvent: api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.fireAnalyticsEvent,
|
|
70
71
|
resourceId: syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.resourceId,
|
|
71
72
|
isOffline: isCollabOffline,
|
|
72
|
-
getAccountId
|
|
73
|
+
getAccountId,
|
|
74
|
+
headingIdPrefix: localId
|
|
73
75
|
});
|
|
74
76
|
return result.element;
|
|
75
77
|
};
|
|
@@ -22,7 +22,8 @@ export function renderSyncedBlockContent({
|
|
|
22
22
|
resourceId,
|
|
23
23
|
isOffline,
|
|
24
24
|
error,
|
|
25
|
-
getAccountId
|
|
25
|
+
getAccountId,
|
|
26
|
+
headingIdPrefix
|
|
26
27
|
}) {
|
|
27
28
|
const isSSRMode = isSSR();
|
|
28
29
|
if (isOffline && !isSSRMode) {
|
|
@@ -93,7 +94,8 @@ export function renderSyncedBlockContent({
|
|
|
93
94
|
element: /*#__PURE__*/React.createElement(AKRendererWrapper, {
|
|
94
95
|
doc: syncBlockDoc,
|
|
95
96
|
dataProviders: providerFactory,
|
|
96
|
-
options: rendererOptions
|
|
97
|
+
options: rendererOptions,
|
|
98
|
+
headingIdPrefix: headingIdPrefix
|
|
97
99
|
}),
|
|
98
100
|
isSuccess: true
|
|
99
101
|
};
|
|
@@ -6,12 +6,14 @@ export var getSyncedBlockRenderer = function getSyncedBlockRenderer(_ref) {
|
|
|
6
6
|
getAccountId = _ref.getAccountId;
|
|
7
7
|
return function (_ref2) {
|
|
8
8
|
var syncBlockFetchResult = _ref2.syncBlockFetchResult,
|
|
9
|
-
api = _ref2.api
|
|
9
|
+
api = _ref2.api,
|
|
10
|
+
localId = _ref2.localId;
|
|
10
11
|
return /*#__PURE__*/React.createElement(SyncedBlockRenderer, {
|
|
11
12
|
syncBlockRendererOptions: syncBlockRendererOptions,
|
|
12
13
|
syncBlockFetchResult: syncBlockFetchResult,
|
|
13
14
|
api: api,
|
|
14
|
-
getAccountId: getAccountId
|
|
15
|
+
getAccountId: getAccountId,
|
|
16
|
+
localId: localId
|
|
15
17
|
});
|
|
16
18
|
};
|
|
17
19
|
};
|
|
@@ -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';
|
|
9
9
|
import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
10
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
10
11
|
import { ReactRenderer, ValidationContextProvider, defaultNodeComponents } from '@atlaskit/renderer';
|
|
11
12
|
import { RendererActionsContext } from '@atlaskit/renderer/actions/renderer-actions-context';
|
|
12
13
|
import { RendererContextProvider } from '@atlaskit/renderer/renderer-context';
|
|
@@ -63,7 +64,8 @@ var defaultOptions = {
|
|
|
63
64
|
export var AKRendererWrapper = /*#__PURE__*/memo(function (_ref3) {
|
|
64
65
|
var doc = _ref3.doc,
|
|
65
66
|
dataProviders = _ref3.dataProviders,
|
|
66
|
-
options = _ref3.options
|
|
67
|
+
options = _ref3.options,
|
|
68
|
+
headingIdPrefix = _ref3.headingIdPrefix;
|
|
67
69
|
var mergedOptions = _objectSpread(_objectSpread({}, defaultOptions), options);
|
|
68
70
|
var _ref4 = mergedOptions !== null && mergedOptions !== void 0 ? mergedOptions : {},
|
|
69
71
|
appearance = _ref4.appearance,
|
|
@@ -81,9 +83,18 @@ export var AKRendererWrapper = /*#__PURE__*/memo(function (_ref3) {
|
|
|
81
83
|
emojiResourceConfig = _ref4.emojiResourceConfig,
|
|
82
84
|
eventHandlers = _ref4.eventHandlers,
|
|
83
85
|
media = _ref4.media,
|
|
86
|
+
mentionNodeDataProvider = _ref4.mentionNodeDataProvider,
|
|
84
87
|
smartLinks = _ref4.smartLinks,
|
|
85
88
|
stickyHeaders = _ref4.stickyHeaders,
|
|
86
89
|
contentMode = _ref4.contentMode;
|
|
90
|
+
|
|
91
|
+
// Only stamp heading ids when a prefix is supplied AND the consumer has
|
|
92
|
+
// opted into heading anchor links. This keeps the change scoped: consumers
|
|
93
|
+
// that enable ToC/anchor support (e.g. Confluence, behind its experiment)
|
|
94
|
+
// pass both a per-instance prefix (the reference block's localId) and
|
|
95
|
+
// `allowHeadingAnchorLinks`; every other consumer keeps id-less headings and
|
|
96
|
+
// is unaffected.
|
|
97
|
+
var headingIdsEnabled = typeof headingIdPrefix === 'string' && headingIdPrefix.length > 0 && Boolean(allowHeadingAnchorLinks);
|
|
87
98
|
var nodeComponents = useMemo(function () {
|
|
88
99
|
return {
|
|
89
100
|
taskItem: function taskItem(props) {
|
|
@@ -110,7 +121,8 @@ export var AKRendererWrapper = /*#__PURE__*/memo(function (_ref3) {
|
|
|
110
121
|
appearance: appearance,
|
|
111
122
|
adfStage: "stage0",
|
|
112
123
|
document: doc,
|
|
113
|
-
disableHeadingIDs:
|
|
124
|
+
disableHeadingIDs: !headingIdsEnabled,
|
|
125
|
+
headingIdPrefix: headingIdsEnabled ? headingIdPrefix : undefined,
|
|
114
126
|
dataProviders: dataProviders,
|
|
115
127
|
nodeComponents: nodeComponents,
|
|
116
128
|
allowAltTextOnImages: allowAltTextOnImages,
|
|
@@ -127,7 +139,13 @@ export var AKRendererWrapper = /*#__PURE__*/memo(function (_ref3) {
|
|
|
127
139
|
disableTableOverflowShadow: true,
|
|
128
140
|
emojiResourceConfig: emojiResourceConfig,
|
|
129
141
|
eventHandlers: eventHandlers,
|
|
130
|
-
media: media
|
|
142
|
+
media: media
|
|
143
|
+
// Synced block replica locations render through this wrapper rather than the
|
|
144
|
+
// main editor/renderer surfaces, so forwarding the provider here is gated
|
|
145
|
+
// independently of `platform_editor_mention_node_avatar` (which still controls
|
|
146
|
+
// whether the avatar itself renders once a provider is present).
|
|
147
|
+
,
|
|
148
|
+
mentionNodeDataProvider: isExperimentEnabled('platform_editor_mention_avatar_synced_block') ? mentionNodeDataProvider : undefined,
|
|
131
149
|
smartLinks: smartLinks,
|
|
132
150
|
stickyHeaders: stickyHeaders,
|
|
133
151
|
contentMode: contentMode
|
|
@@ -82,7 +82,13 @@ export var SyncedBlockNodeComponentRenderer = function SyncedBlockNodeComponentR
|
|
|
82
82
|
fireAnalyticsEvent: syncBlockFireAnalyticsEvent,
|
|
83
83
|
resourceId: resourceId,
|
|
84
84
|
error: errorForDisplay,
|
|
85
|
-
getAccountId: getAccountId
|
|
85
|
+
getAccountId: getAccountId,
|
|
86
|
+
// Prefix heading ids with the reference node's localId so ToC deep links
|
|
87
|
+
// and heading anchor links resolve, and so the same source block embedded
|
|
88
|
+
// twice on a page produces distinct, stable ids. Only takes effect when the
|
|
89
|
+
// renderer options enable heading anchor links; otherwise the prefix is set
|
|
90
|
+
// but ids stay disabled inside AKRendererWrapper.
|
|
91
|
+
headingIdPrefix: localId
|
|
86
92
|
});
|
|
87
93
|
if (result.isSuccess) {
|
|
88
94
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
@@ -11,7 +11,8 @@ var SyncedBlockRendererComponent = function SyncedBlockRendererComponent(_ref) {
|
|
|
11
11
|
var syncBlockRendererOptions = _ref.syncBlockRendererOptions,
|
|
12
12
|
syncBlockFetchResult = _ref.syncBlockFetchResult,
|
|
13
13
|
api = _ref.api,
|
|
14
|
-
getAccountId = _ref.getAccountId
|
|
14
|
+
getAccountId = _ref.getAccountId,
|
|
15
|
+
localId = _ref.localId;
|
|
15
16
|
useEffect(function () {
|
|
16
17
|
var timeoutId = setTimeout(function () {
|
|
17
18
|
var _api$analytics;
|
|
@@ -66,7 +67,8 @@ var SyncedBlockRendererComponent = function SyncedBlockRendererComponent(_ref) {
|
|
|
66
67
|
fireAnalyticsEvent: api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.fireAnalyticsEvent,
|
|
67
68
|
resourceId: syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.resourceId,
|
|
68
69
|
isOffline: isCollabOffline,
|
|
69
|
-
getAccountId: getAccountId
|
|
70
|
+
getAccountId: getAccountId,
|
|
71
|
+
headingIdPrefix: localId
|
|
70
72
|
});
|
|
71
73
|
return result.element;
|
|
72
74
|
};
|
|
@@ -22,7 +22,8 @@ export function renderSyncedBlockContent(_ref) {
|
|
|
22
22
|
resourceId = _ref.resourceId,
|
|
23
23
|
isOffline = _ref.isOffline,
|
|
24
24
|
error = _ref.error,
|
|
25
|
-
getAccountId = _ref.getAccountId
|
|
25
|
+
getAccountId = _ref.getAccountId,
|
|
26
|
+
headingIdPrefix = _ref.headingIdPrefix;
|
|
26
27
|
var isSSRMode = isSSR();
|
|
27
28
|
if (isOffline && !isSSRMode) {
|
|
28
29
|
return {
|
|
@@ -92,7 +93,8 @@ export function renderSyncedBlockContent(_ref) {
|
|
|
92
93
|
element: /*#__PURE__*/React.createElement(AKRendererWrapper, {
|
|
93
94
|
doc: syncBlockDoc,
|
|
94
95
|
dataProviders: providerFactory,
|
|
95
|
-
options: rendererOptions
|
|
96
|
+
options: rendererOptions,
|
|
97
|
+
headingIdPrefix: headingIdPrefix
|
|
96
98
|
}),
|
|
97
99
|
isSuccess: true
|
|
98
100
|
};
|
|
@@ -5,5 +5,5 @@ type GetSyncedBlockRendererProps = {
|
|
|
5
5
|
getAccountId?: () => string | null;
|
|
6
6
|
syncBlockRendererOptions: SyncedBlockRendererOptions | undefined;
|
|
7
7
|
};
|
|
8
|
-
export declare const getSyncedBlockRenderer: ({ syncBlockRendererOptions, getAccountId }: GetSyncedBlockRendererProps) => ({ syncBlockFetchResult, api }: SyncedBlockRendererProps) => React.JSX.Element;
|
|
8
|
+
export declare const getSyncedBlockRenderer: ({ syncBlockRendererOptions, getAccountId }: GetSyncedBlockRendererProps) => ({ syncBlockFetchResult, api, localId }: SyncedBlockRendererProps) => React.JSX.Element;
|
|
9
9
|
export {};
|
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' | 'contentMode'>;
|
|
2
|
+
export type SyncedBlockRendererOptions = Pick<RendererProps, 'appearance' | 'allowAltTextOnImages' | 'allowAnnotations' | 'allowColumnSorting' | 'allowCopyToClipboard' | 'allowCustomPanels' | 'allowHeadingAnchorLinks' | 'allowPlaceholderText' | 'allowRendererContainerStyles' | 'allowSelectAllTrap' | 'allowUgcScrubber' | 'allowWrapCodeBlock' | 'emojiResourceConfig' | 'eventHandlers' | 'media' | 'mentionNodeDataProvider' | 'smartLinks' | 'stickyHeaders' | 'contentMode'>;
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { DocNode } from '@atlaskit/adf-schema';
|
|
2
|
+
import type { DocNode } from '@atlaskit/adf-schema/doc';
|
|
3
3
|
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
4
4
|
import type { SyncedBlockRendererOptions } from '../types';
|
|
5
|
-
export declare const AKRendererWrapper: React.MemoExoticComponent<({ doc, dataProviders, options, }: {
|
|
5
|
+
export declare const AKRendererWrapper: React.MemoExoticComponent<({ doc, dataProviders, options, headingIdPrefix, }: {
|
|
6
6
|
dataProviders: ProviderFactory | undefined;
|
|
7
7
|
doc: DocNode;
|
|
8
|
+
/**
|
|
9
|
+
* When provided, headings inside the synced block are rendered with stable
|
|
10
|
+
* ids prefixed by this value (typically the reference node's `localId`),
|
|
11
|
+
* enabling heading anchor links and Table-of-Contents deep links. When
|
|
12
|
+
* omitted, heading ids are disabled (the historical default) so unrelated
|
|
13
|
+
* consumers are unaffected.
|
|
14
|
+
*/
|
|
15
|
+
headingIdPrefix?: string;
|
|
8
16
|
options: SyncedBlockRendererOptions | undefined;
|
|
9
17
|
}) => React.JSX.Element>;
|
|
@@ -6,7 +6,13 @@ import type { SyncedBlockRendererOptions } from '../types';
|
|
|
6
6
|
export type SyncedBlockRendererProps = {
|
|
7
7
|
api?: ExtractInjectionAPI<SyncedBlockPlugin>;
|
|
8
8
|
getAccountId?: () => string | null;
|
|
9
|
+
/**
|
|
10
|
+
* `localId` of the reference node, used to prefix heading ids rendered inside
|
|
11
|
+
* the synced block content. Heading ids are only emitted when this is provided
|
|
12
|
+
* alongside `syncBlockRendererOptions.allowHeadingAnchorLinks`.
|
|
13
|
+
*/
|
|
14
|
+
localId?: string;
|
|
9
15
|
syncBlockFetchResult: UseFetchSyncBlockDataResult;
|
|
10
16
|
syncBlockRendererOptions?: SyncedBlockRendererOptions;
|
|
11
17
|
};
|
|
12
|
-
export declare const SyncedBlockRenderer: React.MemoExoticComponent<({ syncBlockRendererOptions, syncBlockFetchResult, api, getAccountId, }: SyncedBlockRendererProps) => React.JSX.Element>;
|
|
18
|
+
export declare const SyncedBlockRenderer: React.MemoExoticComponent<({ syncBlockRendererOptions, syncBlockFetchResult, api, getAccountId, localId, }: SyncedBlockRendererProps) => React.JSX.Element>;
|
|
@@ -7,6 +7,13 @@ export type RenderSyncedBlockContentParams = {
|
|
|
7
7
|
error?: SyncBlockInstance['error'];
|
|
8
8
|
fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void;
|
|
9
9
|
getAccountId?: () => string | null;
|
|
10
|
+
/**
|
|
11
|
+
* When provided, headings within the rendered synced block get stable,
|
|
12
|
+
* prefixed ids (typically the reference node's `localId`) so heading anchor
|
|
13
|
+
* links and Table-of-Contents deep links resolve. When omitted, heading ids
|
|
14
|
+
* remain disabled (historical default).
|
|
15
|
+
*/
|
|
16
|
+
headingIdPrefix?: string;
|
|
10
17
|
isLoading: boolean;
|
|
11
18
|
isOffline?: boolean;
|
|
12
19
|
providerFactory: ProviderFactory | undefined;
|
|
@@ -22,7 +29,7 @@ export type RenderSyncedBlockContentParams = {
|
|
|
22
29
|
* Handles the common branching: loading -> SSR error -> error/deleted -> unpublished -> success.
|
|
23
30
|
* Returns null if the caller should handle rendering itself (e.g. wrapping in a container div).
|
|
24
31
|
*/
|
|
25
|
-
export declare function renderSyncedBlockContent({ syncBlockInstance, isLoading, rendererOptions, providerFactory, reloadData, fireAnalyticsEvent, resourceId, isOffline, error, getAccountId, }: RenderSyncedBlockContentParams): {
|
|
32
|
+
export declare function renderSyncedBlockContent({ syncBlockInstance, isLoading, rendererOptions, providerFactory, reloadData, fireAnalyticsEvent, resourceId, isOffline, error, getAccountId, headingIdPrefix, }: RenderSyncedBlockContentParams): {
|
|
26
33
|
element: React.JSX.Element;
|
|
27
34
|
isSuccess: boolean;
|
|
28
35
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { DocNode } from '@atlaskit/adf-schema';
|
|
2
|
+
import type { DocNode } from '@atlaskit/adf-schema/doc';
|
|
3
3
|
import type { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import type { SyncBlockNode, SyncedBlockProvider, SyncBlockPrefetchData } from '@atlaskit/editor-synced-block-provider';
|
|
5
5
|
import type { SyncedBlockRendererOptions } from './types';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-synced-block-renderer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.0",
|
|
4
4
|
"description": "SyncedBlockRenderer for @atlaskit/editor-plugin-synced-block",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -30,30 +30,30 @@
|
|
|
30
30
|
"sideEffects": false,
|
|
31
31
|
"atlaskit:src": "src/index.ts",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@atlaskit/adf-schema": "^57.
|
|
34
|
-
"@atlaskit/button": "^25.
|
|
33
|
+
"@atlaskit/adf-schema": "^57.4.0",
|
|
34
|
+
"@atlaskit/button": "^25.3.0",
|
|
35
35
|
"@atlaskit/css": "^1.1.0",
|
|
36
|
-
"@atlaskit/editor-json-transformer": "^9.
|
|
37
|
-
"@atlaskit/editor-plugin-synced-block": "^
|
|
38
|
-
"@atlaskit/editor-synced-block-provider": "^
|
|
39
|
-
"@atlaskit/heading": "^7.
|
|
40
|
-
"@atlaskit/icon": "^37.
|
|
41
|
-
"@atlaskit/icon-lab": "^7.
|
|
42
|
-
"@atlaskit/image": "^5.
|
|
36
|
+
"@atlaskit/editor-json-transformer": "^9.8.0",
|
|
37
|
+
"@atlaskit/editor-plugin-synced-block": "^15.0.0",
|
|
38
|
+
"@atlaskit/editor-synced-block-provider": "^13.0.0",
|
|
39
|
+
"@atlaskit/heading": "^7.2.0",
|
|
40
|
+
"@atlaskit/icon": "^37.6.0",
|
|
41
|
+
"@atlaskit/icon-lab": "^7.8.0",
|
|
42
|
+
"@atlaskit/image": "^5.2.0",
|
|
43
43
|
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
44
|
-
"@atlaskit/primitives": "^22.
|
|
44
|
+
"@atlaskit/primitives": "^22.5.0",
|
|
45
45
|
"@atlaskit/react-compiler-gating": "^0.2.0",
|
|
46
|
-
"@atlaskit/renderer": "^
|
|
47
|
-
"@atlaskit/spinner": "^20.
|
|
48
|
-
"@atlaskit/tokens": "^16.
|
|
49
|
-
"@atlaskit/tooltip": "^24.
|
|
46
|
+
"@atlaskit/renderer": "^138.0.0",
|
|
47
|
+
"@atlaskit/spinner": "^20.4.0",
|
|
48
|
+
"@atlaskit/tokens": "^16.11.0",
|
|
49
|
+
"@atlaskit/tooltip": "^24.3.0",
|
|
50
50
|
"@babel/runtime": "^7.0.0",
|
|
51
51
|
"@compiled/react": "^1.0.2",
|
|
52
52
|
"react-relay": "^20.1.1",
|
|
53
53
|
"relay-runtime": "^20.1.1"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@atlaskit/editor-common": "^
|
|
56
|
+
"@atlaskit/editor-common": "^121.0.0",
|
|
57
57
|
"react": "^18.2.0 || ^19.2.0",
|
|
58
58
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
59
59
|
},
|
|
@@ -62,38 +62,5 @@
|
|
|
62
62
|
"react-intl": "^7.0.0",
|
|
63
63
|
"typescript": "npm:@typescript/typescript6@^6.0.2"
|
|
64
64
|
},
|
|
65
|
-
"techstack": {
|
|
66
|
-
"@atlassian/frontend": {
|
|
67
|
-
"import-structure": [
|
|
68
|
-
"atlassian-conventions"
|
|
69
|
-
],
|
|
70
|
-
"circular-dependencies": [
|
|
71
|
-
"file-and-folder-level"
|
|
72
|
-
]
|
|
73
|
-
},
|
|
74
|
-
"@repo/internal": {
|
|
75
|
-
"dom-events": "use-bind-event-listener",
|
|
76
|
-
"analytics": [
|
|
77
|
-
"analytics-next"
|
|
78
|
-
],
|
|
79
|
-
"design-tokens": [
|
|
80
|
-
"color"
|
|
81
|
-
],
|
|
82
|
-
"theming": [
|
|
83
|
-
"react-context"
|
|
84
|
-
],
|
|
85
|
-
"ui-components": [
|
|
86
|
-
"lite-mode"
|
|
87
|
-
],
|
|
88
|
-
"deprecation": "no-deprecated-imports",
|
|
89
|
-
"styling": [
|
|
90
|
-
"emotion",
|
|
91
|
-
"emotion"
|
|
92
|
-
],
|
|
93
|
-
"imports": [
|
|
94
|
-
"import-no-extraneous-disable-for-examples-and-docs"
|
|
95
|
-
]
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
65
|
"platform-feature-flags": {}
|
|
99
66
|
}
|