@atlaskit/editor-synced-block-renderer 14.2.0 → 15.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/cjs/getSyncedBlockRenderer.js +4 -2
  3. package/dist/cjs/ui/AKRendererWrapper.js +12 -2
  4. package/dist/cjs/ui/SyncedBlockEntityNotFoundError.js +1 -1
  5. package/dist/cjs/ui/SyncedBlockErrorStateCard.js +1 -1
  6. package/dist/cjs/ui/SyncedBlockLoadError.js +1 -1
  7. package/dist/cjs/ui/SyncedBlockLoadingState.js +1 -1
  8. package/dist/cjs/ui/SyncedBlockNodeComponentRenderer.js +7 -1
  9. package/dist/cjs/ui/SyncedBlockNotFoundError.js +1 -1
  10. package/dist/cjs/ui/SyncedBlockPermissionDenied.js +1 -1
  11. package/dist/cjs/ui/SyncedBlockRenderer.js +4 -2
  12. package/dist/cjs/ui/SyncedBlockUnpublishedError.js +1 -1
  13. package/dist/cjs/ui/renderSyncedBlockContent.js +4 -2
  14. package/dist/cjs/useSyncedBlockNodeComponent.js +5 -2
  15. package/dist/es2019/getSyncedBlockRenderer.js +4 -2
  16. package/dist/es2019/ui/AKRendererWrapper.js +12 -2
  17. package/dist/es2019/ui/SyncedBlockEntityNotFoundError.js +1 -1
  18. package/dist/es2019/ui/SyncedBlockErrorStateCard.js +1 -1
  19. package/dist/es2019/ui/SyncedBlockLoadError.js +1 -1
  20. package/dist/es2019/ui/SyncedBlockLoadingState.js +1 -1
  21. package/dist/es2019/ui/SyncedBlockNodeComponentRenderer.js +7 -1
  22. package/dist/es2019/ui/SyncedBlockNotFoundError.js +1 -1
  23. package/dist/es2019/ui/SyncedBlockPermissionDenied.js +1 -1
  24. package/dist/es2019/ui/SyncedBlockRenderer.js +4 -2
  25. package/dist/es2019/ui/SyncedBlockUnpublishedError.js +1 -1
  26. package/dist/es2019/ui/renderSyncedBlockContent.js +4 -2
  27. package/dist/es2019/useSyncedBlockNodeComponent.js +5 -2
  28. package/dist/esm/getSyncedBlockRenderer.js +4 -2
  29. package/dist/esm/ui/AKRendererWrapper.js +12 -2
  30. package/dist/esm/ui/SyncedBlockEntityNotFoundError.js +1 -1
  31. package/dist/esm/ui/SyncedBlockErrorStateCard.js +1 -1
  32. package/dist/esm/ui/SyncedBlockLoadError.js +1 -1
  33. package/dist/esm/ui/SyncedBlockLoadingState.js +1 -1
  34. package/dist/esm/ui/SyncedBlockNodeComponentRenderer.js +7 -1
  35. package/dist/esm/ui/SyncedBlockNotFoundError.js +1 -1
  36. package/dist/esm/ui/SyncedBlockPermissionDenied.js +1 -1
  37. package/dist/esm/ui/SyncedBlockRenderer.js +4 -2
  38. package/dist/esm/ui/SyncedBlockUnpublishedError.js +1 -1
  39. package/dist/esm/ui/renderSyncedBlockContent.js +4 -2
  40. package/dist/esm/useSyncedBlockNodeComponent.js +5 -2
  41. package/dist/types/getSyncedBlockRenderer.d.ts +1 -1
  42. package/dist/types/ui/AKRendererWrapper.d.ts +9 -1
  43. package/dist/types/ui/SyncedBlockRenderer.d.ts +7 -1
  44. package/dist/types/ui/renderSyncedBlockContent.d.ts +8 -1
  45. package/dist/types/useSyncedBlockNodeComponent.d.ts +10 -1
  46. package/package.json +7 -7
  47. package/afm-cc/tsconfig.json +0 -80
package/CHANGELOG.md CHANGED
@@ -1,5 +1,51 @@
1
1
  # @atlaskit/editor-synced-block-renderer
2
2
 
3
+ ## 15.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`5dd6cdd8c1d11`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5dd6cdd8c1d11) -
8
+ Allow a surface to opt out of real-time synced block subscriptions.
9
+
10
+ `SyncBlockStoreManager` and `useMemoizedSyncBlockStoreManager` accept a new
11
+ `SyncBlockStoreManagerOptions` argument, and `useMemoizedSyncedBlockNodeComponent` accepts a
12
+ matching `enableRealTimeSubscriptions` prop. Both default to `true`, so existing behaviour is
13
+ unchanged.
14
+
15
+ When set to `false`, real-time updates are turned off at construction, so no
16
+ `blockService_onBlockUpdated` subscription is ever opened for that store's reference blocks. This
17
+ is deliberately independent of `viewMode`: a live doc in read mode is the editor in view mode and
18
+ must stay live. Consumed by the Confluence classic renderer behind the
19
+ `platform_editor_sync_block_renderer_no_realtime` experiment, so a page being read no longer
20
+ changes under the reader.
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies
25
+
26
+ ## 15.0.0
27
+
28
+ ### Minor Changes
29
+
30
+ - [`149408be91016`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/149408be91016) -
31
+ Thread the reference node's `localId` through the editor synced-block rendering path so products
32
+ can namespace heading ids inside synced block content.
33
+
34
+ `SyncedBlockRendererProps` gains an optional `localId`, which `SyncBlockRendererWrapper` now
35
+ forwards to the product-supplied `syncedBlockRenderer`. `SyncedBlockRenderer` accepts a matching
36
+ `localId` prop and passes it to `renderSyncedBlockContent` as `headingIdPrefix`.
37
+
38
+ This mirrors the existing view-page node component behaviour. Heading ids are still only emitted
39
+ when a prefix is supplied alongside `allowHeadingAnchorLinks`, so there is no change for consumers
40
+ that do not pass `localId`.
41
+
42
+ Confluence enables the new Table of Contents and heading-anchor behavior behind the
43
+ `confluence_toc_synced_block_exp` experiment.
44
+
45
+ ### Patch Changes
46
+
47
+ - Updated dependencies
48
+
3
49
  ## 14.2.0
4
50
 
5
51
  ### 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
  };
@@ -73,7 +73,8 @@ var defaultOptions = {
73
73
  var AKRendererWrapper = exports.AKRendererWrapper = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
74
74
  var doc = _ref3.doc,
75
75
  dataProviders = _ref3.dataProviders,
76
- options = _ref3.options;
76
+ options = _ref3.options,
77
+ headingIdPrefix = _ref3.headingIdPrefix;
77
78
  var mergedOptions = _objectSpread(_objectSpread({}, defaultOptions), options);
78
79
  var _ref4 = mergedOptions !== null && mergedOptions !== void 0 ? mergedOptions : {},
79
80
  appearance = _ref4.appearance,
@@ -95,6 +96,14 @@ var AKRendererWrapper = exports.AKRendererWrapper = /*#__PURE__*/(0, _react.memo
95
96
  smartLinks = _ref4.smartLinks,
96
97
  stickyHeaders = _ref4.stickyHeaders,
97
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);
98
107
  var nodeComponents = (0, _react.useMemo)(function () {
99
108
  return {
100
109
  taskItem: function taskItem(props) {
@@ -121,7 +130,8 @@ var AKRendererWrapper = exports.AKRendererWrapper = /*#__PURE__*/(0, _react.memo
121
130
  appearance: appearance,
122
131
  adfStage: "stage0",
123
132
  document: doc,
124
- disableHeadingIDs: true,
133
+ disableHeadingIDs: !headingIdsEnabled,
134
+ headingIdPrefix: headingIdsEnabled ? headingIdPrefix : undefined,
125
135
  dataProviders: dataProviders,
126
136
  nodeComponents: nodeComponents,
127
137
  allowAltTextOnImages: allowAltTextOnImages,
@@ -1,4 +1,4 @@
1
- /* SyncedBlockEntityNotFoundError.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* SyncedBlockEntityNotFoundError.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -1,4 +1,4 @@
1
- /* SyncedBlockErrorStateCard.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* SyncedBlockErrorStateCard.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -1,4 +1,4 @@
1
- /* SyncedBlockLoadError.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* SyncedBlockLoadError.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -1,4 +1,4 @@
1
- /* SyncedBlockLoadingState.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* SyncedBlockLoadingState.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -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)({
@@ -1,4 +1,4 @@
1
- /* SyncedBlockNotFoundError.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* SyncedBlockNotFoundError.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -1,4 +1,4 @@
1
- /* SyncedBlockPermissionDenied.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* SyncedBlockPermissionDenied.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -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
  };
@@ -1,4 +1,4 @@
1
- /* SyncedBlockUnpublishedError.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* SyncedBlockUnpublishedError.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -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
  };
@@ -28,8 +28,11 @@ var useMemoizedSyncedBlockNodeComponent = exports.useMemoizedSyncedBlockNodeComp
28
28
  syncBlockRendererOptions = _ref.syncBlockRendererOptions,
29
29
  fireAnalyticsEvent = _ref.fireAnalyticsEvent,
30
30
  getAccountId = _ref.getAccountId,
31
- getPrefetchedData = _ref.getPrefetchedData;
32
- var syncBlockStoreManager = (0, _editorSyncedBlockProvider.useMemoizedSyncBlockStoreManager)(syncBlockProvider, fireAnalyticsEvent);
31
+ getPrefetchedData = _ref.getPrefetchedData,
32
+ enableRealTimeSubscriptions = _ref.enableRealTimeSubscriptions;
33
+ var syncBlockStoreManager = (0, _editorSyncedBlockProvider.useMemoizedSyncBlockStoreManager)(syncBlockProvider, fireAnalyticsEvent, {
34
+ enableRealTimeSubscriptions: enableRealTimeSubscriptions
35
+ });
33
36
 
34
37
  // Process prefetched data early, if available
35
38
  (0, _react.useEffect)(function () {
@@ -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
  };
@@ -60,7 +60,8 @@ const defaultOptions = {
60
60
  export const AKRendererWrapper = /*#__PURE__*/memo(({
61
61
  doc,
62
62
  dataProviders,
63
- options
63
+ options,
64
+ headingIdPrefix
64
65
  }) => {
65
66
  const mergedOptions = {
66
67
  ...defaultOptions,
@@ -87,6 +88,14 @@ export const AKRendererWrapper = /*#__PURE__*/memo(({
87
88
  stickyHeaders,
88
89
  contentMode
89
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);
90
99
  const nodeComponents = useMemo(() => {
91
100
  return {
92
101
  taskItem: props => {
@@ -113,7 +122,8 @@ export const AKRendererWrapper = /*#__PURE__*/memo(({
113
122
  appearance: appearance,
114
123
  adfStage: "stage0",
115
124
  document: doc,
116
- disableHeadingIDs: true,
125
+ disableHeadingIDs: !headingIdsEnabled,
126
+ headingIdPrefix: headingIdsEnabled ? headingIdPrefix : undefined,
117
127
  dataProviders: dataProviders,
118
128
  nodeComponents: nodeComponents,
119
129
  allowAltTextOnImages: allowAltTextOnImages,
@@ -1,4 +1,4 @@
1
- /* SyncedBlockEntityNotFoundError.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* SyncedBlockEntityNotFoundError.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import "./SyncedBlockEntityNotFoundError.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
@@ -1,4 +1,4 @@
1
- /* SyncedBlockErrorStateCard.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* SyncedBlockErrorStateCard.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import "./SyncedBlockErrorStateCard.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
@@ -1,4 +1,4 @@
1
- /* SyncedBlockLoadError.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* SyncedBlockLoadError.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import "./SyncedBlockLoadError.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
@@ -1,4 +1,4 @@
1
- /* SyncedBlockLoadingState.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* SyncedBlockLoadingState.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import "./SyncedBlockLoadingState.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
@@ -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", {
@@ -1,4 +1,4 @@
1
- /* SyncedBlockNotFoundError.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* SyncedBlockNotFoundError.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import "./SyncedBlockNotFoundError.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React, { useEffect, useState } from 'react';
@@ -1,4 +1,4 @@
1
- /* SyncedBlockPermissionDenied.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* SyncedBlockPermissionDenied.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import "./SyncedBlockPermissionDenied.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import _SyncedBlockPermissionDeniedRequestAccessMutation from "./__generated__/SyncedBlockPermissionDeniedRequestAccessMutation.graphql";
@@ -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
  };
@@ -1,4 +1,4 @@
1
- /* SyncedBlockUnpublishedError.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* SyncedBlockUnpublishedError.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import "./SyncedBlockUnpublishedError.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
@@ -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
  };
@@ -18,9 +18,12 @@ export const useMemoizedSyncedBlockNodeComponent = ({
18
18
  syncBlockRendererOptions,
19
19
  fireAnalyticsEvent,
20
20
  getAccountId,
21
- getPrefetchedData
21
+ getPrefetchedData,
22
+ enableRealTimeSubscriptions
22
23
  }) => {
23
- const syncBlockStoreManager = useMemoizedSyncBlockStoreManager(syncBlockProvider, fireAnalyticsEvent);
24
+ const syncBlockStoreManager = useMemoizedSyncBlockStoreManager(syncBlockProvider, fireAnalyticsEvent, {
25
+ enableRealTimeSubscriptions
26
+ });
24
27
 
25
28
  // Process prefetched data early, if available
26
29
  useEffect(() => {
@@ -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
  };
@@ -64,7 +64,8 @@ var defaultOptions = {
64
64
  export var AKRendererWrapper = /*#__PURE__*/memo(function (_ref3) {
65
65
  var doc = _ref3.doc,
66
66
  dataProviders = _ref3.dataProviders,
67
- options = _ref3.options;
67
+ options = _ref3.options,
68
+ headingIdPrefix = _ref3.headingIdPrefix;
68
69
  var mergedOptions = _objectSpread(_objectSpread({}, defaultOptions), options);
69
70
  var _ref4 = mergedOptions !== null && mergedOptions !== void 0 ? mergedOptions : {},
70
71
  appearance = _ref4.appearance,
@@ -86,6 +87,14 @@ export var AKRendererWrapper = /*#__PURE__*/memo(function (_ref3) {
86
87
  smartLinks = _ref4.smartLinks,
87
88
  stickyHeaders = _ref4.stickyHeaders,
88
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);
89
98
  var nodeComponents = useMemo(function () {
90
99
  return {
91
100
  taskItem: function taskItem(props) {
@@ -112,7 +121,8 @@ export var AKRendererWrapper = /*#__PURE__*/memo(function (_ref3) {
112
121
  appearance: appearance,
113
122
  adfStage: "stage0",
114
123
  document: doc,
115
- disableHeadingIDs: true,
124
+ disableHeadingIDs: !headingIdsEnabled,
125
+ headingIdPrefix: headingIdsEnabled ? headingIdPrefix : undefined,
116
126
  dataProviders: dataProviders,
117
127
  nodeComponents: nodeComponents,
118
128
  allowAltTextOnImages: allowAltTextOnImages,
@@ -1,4 +1,4 @@
1
- /* SyncedBlockEntityNotFoundError.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* SyncedBlockEntityNotFoundError.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import "./SyncedBlockEntityNotFoundError.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
@@ -1,4 +1,4 @@
1
- /* SyncedBlockErrorStateCard.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* SyncedBlockErrorStateCard.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import "./SyncedBlockErrorStateCard.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
@@ -1,4 +1,4 @@
1
- /* SyncedBlockLoadError.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* SyncedBlockLoadError.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import "./SyncedBlockLoadError.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
@@ -1,4 +1,4 @@
1
- /* SyncedBlockLoadingState.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* SyncedBlockLoadingState.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import "./SyncedBlockLoadingState.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
@@ -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({
@@ -1,4 +1,4 @@
1
- /* SyncedBlockNotFoundError.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* SyncedBlockNotFoundError.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import "./SyncedBlockNotFoundError.compiled.css";
@@ -1,4 +1,4 @@
1
- /* SyncedBlockPermissionDenied.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* SyncedBlockPermissionDenied.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import "./SyncedBlockPermissionDenied.compiled.css";
@@ -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
  };
@@ -1,4 +1,4 @@
1
- /* SyncedBlockUnpublishedError.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* SyncedBlockUnpublishedError.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import "./SyncedBlockUnpublishedError.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
@@ -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
  };
@@ -20,8 +20,11 @@ export var useMemoizedSyncedBlockNodeComponent = function useMemoizedSyncedBlock
20
20
  syncBlockRendererOptions = _ref.syncBlockRendererOptions,
21
21
  fireAnalyticsEvent = _ref.fireAnalyticsEvent,
22
22
  getAccountId = _ref.getAccountId,
23
- getPrefetchedData = _ref.getPrefetchedData;
24
- var syncBlockStoreManager = useMemoizedSyncBlockStoreManager(syncBlockProvider, fireAnalyticsEvent);
23
+ getPrefetchedData = _ref.getPrefetchedData,
24
+ enableRealTimeSubscriptions = _ref.enableRealTimeSubscriptions;
25
+ var syncBlockStoreManager = useMemoizedSyncBlockStoreManager(syncBlockProvider, fireAnalyticsEvent, {
26
+ enableRealTimeSubscriptions: enableRealTimeSubscriptions
27
+ });
25
28
 
26
29
  // Process prefetched data early, if available
27
30
  useEffect(function () {
@@ -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 {};
@@ -2,8 +2,16 @@ import React from 'react';
2
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
  };
@@ -5,6 +5,15 @@ import type { SyncBlockNode, SyncedBlockProvider, SyncBlockPrefetchData } from '
5
5
  import type { SyncedBlockRendererOptions } from './types';
6
6
  import type { SyncedBlockNodeProps } from './ui/SyncedBlockNodeComponentRenderer';
7
7
  export type GetSyncedBlockNodeComponentProps = {
8
+ /**
9
+ * Whether reference blocks should hold a real-time subscription and refresh in
10
+ * place when their source is edited elsewhere. Defaults to `true`.
11
+ *
12
+ * Surfaces that must show content as of page load — the Confluence classic
13
+ * page/blog renderer — pass `false`, so no `blockService_onBlockUpdated`
14
+ * subscription is ever opened.
15
+ */
16
+ enableRealTimeSubscriptions?: boolean;
8
17
  fireAnalyticsEvent?: (payload: AnalyticsEventPayload) => void;
9
18
  getAccountId?: () => string | null;
10
19
  getPrefetchedData?: () => SyncBlockPrefetchData | undefined;
@@ -13,4 +22,4 @@ export type GetSyncedBlockNodeComponentProps = {
13
22
  syncBlockRendererOptions: SyncedBlockRendererOptions | undefined;
14
23
  };
15
24
  export declare const getSyncBlockNodesFromDoc: (doc: DocNode) => SyncBlockNode[];
16
- export declare const useMemoizedSyncedBlockNodeComponent: ({ syncBlockNodes, syncBlockProvider, syncBlockRendererOptions, fireAnalyticsEvent, getAccountId, getPrefetchedData, }: GetSyncedBlockNodeComponentProps) => ((props: SyncedBlockNodeProps) => React.JSX.Element);
25
+ export declare const useMemoizedSyncedBlockNodeComponent: ({ syncBlockNodes, syncBlockProvider, syncBlockRendererOptions, fireAnalyticsEvent, getAccountId, getPrefetchedData, enableRealTimeSubscriptions, }: GetSyncedBlockNodeComponentProps) => ((props: SyncedBlockNodeProps) => React.JSX.Element);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-synced-block-renderer",
3
- "version": "14.2.0",
3
+ "version": "15.1.0",
4
4
  "description": "SyncedBlockRenderer for @atlaskit/editor-plugin-synced-block",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -30,12 +30,12 @@
30
30
  "sideEffects": false,
31
31
  "atlaskit:src": "src/index.ts",
32
32
  "dependencies": {
33
- "@atlaskit/adf-schema": "^57.3.0",
33
+ "@atlaskit/adf-schema": "^57.4.0",
34
34
  "@atlaskit/button": "^25.3.0",
35
35
  "@atlaskit/css": "^1.1.0",
36
36
  "@atlaskit/editor-json-transformer": "^9.8.0",
37
- "@atlaskit/editor-plugin-synced-block": "^14.0.0",
38
- "@atlaskit/editor-synced-block-provider": "^12.2.0",
37
+ "@atlaskit/editor-plugin-synced-block": "^15.0.0",
38
+ "@atlaskit/editor-synced-block-provider": "^13.2.0",
39
39
  "@atlaskit/heading": "^7.2.0",
40
40
  "@atlaskit/icon": "^37.6.0",
41
41
  "@atlaskit/icon-lab": "^7.8.0",
@@ -43,9 +43,9 @@
43
43
  "@atlaskit/platform-feature-experiments": "^0.3.0",
44
44
  "@atlaskit/primitives": "^22.5.0",
45
45
  "@atlaskit/react-compiler-gating": "^0.2.0",
46
- "@atlaskit/renderer": "^137.4.0",
46
+ "@atlaskit/renderer": "^138.1.0",
47
47
  "@atlaskit/spinner": "^20.4.0",
48
- "@atlaskit/tokens": "^16.11.0",
48
+ "@atlaskit/tokens": "^16.12.0",
49
49
  "@atlaskit/tooltip": "^24.3.0",
50
50
  "@babel/runtime": "^7.0.0",
51
51
  "@compiled/react": "^1.0.2",
@@ -53,7 +53,7 @@
53
53
  "relay-runtime": "^20.1.1"
54
54
  },
55
55
  "peerDependencies": {
56
- "@atlaskit/editor-common": "^120.16.0",
56
+ "@atlaskit/editor-common": "^121.4.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
  },
@@ -1,80 +0,0 @@
1
- {
2
- "extends": "../../../../tsconfig.local-consumption.json",
3
- "compilerOptions": {
4
- "outDir": "../../../../../confluence/tsDist/@atlaskit__editor-synced-block-renderer",
5
- "rootDir": "../",
6
- "composite": true,
7
- "noCheck": true
8
- },
9
- "include": [
10
- "../src/**/*.ts",
11
- "../src/**/*.tsx"
12
- ],
13
- "exclude": [
14
- "../src/**/__tests__/*",
15
- "../src/**/*.test.*",
16
- "../src/**/test.*",
17
- "../src/**/examples.*",
18
- "../src/**/examples/*",
19
- "../src/**/examples/**/*",
20
- "../src/**/*.stories.*",
21
- "../src/**/stories/*",
22
- "../src/**/stories/**/*"
23
- ],
24
- "references": [
25
- {
26
- "path": "../../adf-schema/afm-cc/tsconfig.json"
27
- },
28
- {
29
- "path": "../../../design-system/button/afm-cc/tsconfig.json"
30
- },
31
- {
32
- "path": "../../../design-system/css/afm-cc/tsconfig.json"
33
- },
34
- {
35
- "path": "../../editor-json-transformer/afm-cc/tsconfig.json"
36
- },
37
- {
38
- "path": "../../editor-plugin-synced-block/afm-cc/tsconfig.json"
39
- },
40
- {
41
- "path": "../../editor-synced-block-provider/afm-cc/tsconfig.json"
42
- },
43
- {
44
- "path": "../../../design-system/heading/afm-cc/tsconfig.json"
45
- },
46
- {
47
- "path": "../../../design-system/icon/afm-cc/tsconfig.json"
48
- },
49
- {
50
- "path": "../../../design-system/icon-lab/afm-cc/tsconfig.json"
51
- },
52
- {
53
- "path": "../../../design-system/image/afm-cc/tsconfig.json"
54
- },
55
- {
56
- "path": "../../../platform/feature-experiments/afm-cc/tsconfig.json"
57
- },
58
- {
59
- "path": "../../../design-system/primitives/afm-cc/tsconfig.json"
60
- },
61
- {
62
- "path": "../../../react-compiler/react-compiler-gating/afm-cc/tsconfig.json"
63
- },
64
- {
65
- "path": "../../renderer/afm-cc/tsconfig.json"
66
- },
67
- {
68
- "path": "../../../design-system/spinner/afm-cc/tsconfig.json"
69
- },
70
- {
71
- "path": "../../../design-system/tokens/afm-cc/tsconfig.json"
72
- },
73
- {
74
- "path": "../../../design-system/tooltip/afm-cc/tsconfig.json"
75
- },
76
- {
77
- "path": "../../editor-common/afm-cc/tsconfig.json"
78
- }
79
- ]
80
- }