@atlaskit/renderer 149.0.1 → 149.0.2

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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/renderer
2
2
 
3
+ ## 149.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`8fe99b7e9d198`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8fe99b7e9d198) -
8
+ Add `resolveAnnotatableTargetFromLocalId`, which resolves a `localId` to the node an annotation
9
+ can be applied to — the node itself when it accepts the annotation mark or is a supported block
10
+ node, otherwise its closest accepting ancestor. Mirrors the editor implementation so both sides
11
+ resolve the same node. Internal helper, not yet used by any code path.
12
+ - [`06e85e54427d1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/06e85e54427d1) -
13
+ Correct Forge named viewport height reservation in View and Editor behind
14
+ confluence_forge_early_render_reserve_height while preserving numeric Connect heights.
15
+ - Updated dependencies
16
+
3
17
  ## 149.0.1
4
18
 
5
19
  ### Patch Changes
@@ -112,6 +112,8 @@ var renderExtension = exports.renderExtension = function renderExtension(content
112
112
  */
113
113
  var viewportSize = getViewportSize(extensionId, extensionViewportSizes);
114
114
  var extensionHeight = nodeHeight || viewportSize;
115
+ // Forge manifest heights already include px; Connect node heights are numeric strings.
116
+ var extensionMinHeight = extensionHeight !== null && extensionHeight !== void 0 && extensionHeight.endsWith('px') && (0, _fg.fg)('confluence_forge_early_render_reserve_height') ? extensionHeight : extensionHeight && "".concat(extensionHeight, "px");
115
117
  /**
116
118
  * Scoped to nodes inserted by an app declaring `layout: inline-bodied`, which is what writes
117
119
  * `atlassianForgeInlineBodied`. The output-type marker alone would also match migrated Connect
@@ -165,7 +167,7 @@ var renderExtension = exports.renderExtension = function renderExtension(content
165
167
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
166
168
  (0, _breakout.calcBreakoutWidthCss)(layout) : (0, _expValEquals.expValEquals)('platform_editor_remove_important_in_render_ext', 'isEnabled', true) ? undefined : '100%',
167
169
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
168
- minHeight: isInline ? undefined : extensionHeight && "".concat(extensionHeight, "px")
170
+ minHeight: isInline ? undefined : extensionMinHeight
169
171
  },
170
172
  "data-layout": layout,
171
173
  "data-local-id": localId,
@@ -72,7 +72,7 @@ var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
72
72
  var TABLE_INFO_TIMEOUT = 10000;
73
73
  var RENDER_EVENT_SAMPLE_RATE = 0.1;
74
74
  var packageName = "@atlaskit/renderer";
75
- var packageVersion = "149.0.0";
75
+ var packageVersion = "149.0.1";
76
76
  var setAsQueryContainerStyles = (0, _react2.css)({
77
77
  containerName: 'ak-renderer-wrapper',
78
78
  containerType: 'inline-size'
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.resolveAnnotatableTargetFromLocalId = void 0;
7
+ /** The node to annotate, with the position immediately before it (`doc.nodeAt(pos) === node`). */
8
+
9
+ /** Renderer copy of the editor's `isSupportedBlockNode`, kept identical so both resolve alike. */
10
+ var isSupportedBlockNode = function isSupportedBlockNode(node) {
11
+ var supportedBlockNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
12
+ return supportedBlockNodes.indexOf(node.type.name) >= 0 || node.type.name === 'mediaSingle' && supportedBlockNodes.indexOf('media') >= 0;
13
+ };
14
+
15
+ /**
16
+ * Renderer equivalent of the editor's `resolveAnnotatableTargetFromLocalId`: resolves the node to
17
+ * annotate for a `localId`, climbing to the closest accepting ancestor when the node itself does
18
+ * not accept an annotation. Returns undefined when nothing in the chain accepts one.
19
+ *
20
+ * Kept in sync with the editor implementation so both sides resolve the same node.
21
+ */
22
+ var resolveAnnotatableTargetFromLocalId = exports.resolveAnnotatableTargetFromLocalId = function resolveAnnotatableTargetFromLocalId(doc, localId) {
23
+ var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
24
+ var supportedBlockNodes = opts.supportedBlockNodes;
25
+
26
+ // No `EditorState` here, so walk the doc directly like `findNodePosByLocalIds` does.
27
+ var match;
28
+ doc.descendants(function (node, pos) {
29
+ var _node$attrs;
30
+ if (match) {
31
+ return false;
32
+ }
33
+ if (((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) === localId) {
34
+ match = {
35
+ node: node,
36
+ pos: pos
37
+ };
38
+ return false;
39
+ }
40
+ return true;
41
+ });
42
+ if (!match) {
43
+ return undefined;
44
+ }
45
+ var annotationMarkType = doc.type.schema.marks.annotation;
46
+ var nodeAcceptsAnnotation = function nodeAcceptsAnnotation(node) {
47
+ return !!annotationMarkType && node.type.allowsMarkType(annotationMarkType) || isSupportedBlockNode(node, supportedBlockNodes);
48
+ };
49
+ if (nodeAcceptsAnnotation(match.node)) {
50
+ return match;
51
+ }
52
+
53
+ // Ancestors only — never descendants.
54
+ var $pos = doc.resolve(match.pos);
55
+ for (var depth = $pos.depth; depth >= 0; depth--) {
56
+ var ancestor = $pos.node(depth);
57
+ if (nodeAcceptsAnnotation(ancestor)) {
58
+ return {
59
+ node: ancestor,
60
+ pos: depth === 0 ? 0 : $pos.before(depth)
61
+ };
62
+ }
63
+ }
64
+ return undefined;
65
+ };
@@ -94,6 +94,8 @@ export const renderExtension = (content, layout, options = {}, removeOverflow, e
94
94
  */
95
95
  const viewportSize = getViewportSize(extensionId, extensionViewportSizes);
96
96
  const extensionHeight = nodeHeight || viewportSize;
97
+ // Forge manifest heights already include px; Connect node heights are numeric strings.
98
+ const extensionMinHeight = extensionHeight !== null && extensionHeight !== void 0 && extensionHeight.endsWith('px') && fg('confluence_forge_early_render_reserve_height') ? extensionHeight : extensionHeight && `${extensionHeight}px`;
97
99
  /**
98
100
  * Scoped to nodes inserted by an app declaring `layout: inline-bodied`, which is what writes
99
101
  * `atlassianForgeInlineBodied`. The output-type marker alone would also match migrated Connect
@@ -147,7 +149,7 @@ export const renderExtension = (content, layout, options = {}, removeOverflow, e
147
149
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
148
150
  calcBreakoutWidthCss(layout) : expValEquals('platform_editor_remove_important_in_render_ext', 'isEnabled', true) ? undefined : '100%',
149
151
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
150
- minHeight: isInline ? undefined : extensionHeight && `${extensionHeight}px`
152
+ minHeight: isInline ? undefined : extensionMinHeight
151
153
  },
152
154
  "data-layout": layout,
153
155
  "data-local-id": localId,
@@ -57,7 +57,7 @@ export const DEGRADED_SEVERITY_THRESHOLD = 3000;
57
57
  const TABLE_INFO_TIMEOUT = 10000;
58
58
  const RENDER_EVENT_SAMPLE_RATE = 0.1;
59
59
  const packageName = "@atlaskit/renderer";
60
- const packageVersion = "149.0.0";
60
+ const packageVersion = "149.0.1";
61
61
  const setAsQueryContainerStyles = css({
62
62
  containerName: 'ak-renderer-wrapper',
63
63
  containerType: 'inline-size'
@@ -0,0 +1,57 @@
1
+ /** The node to annotate, with the position immediately before it (`doc.nodeAt(pos) === node`). */
2
+
3
+ /** Renderer copy of the editor's `isSupportedBlockNode`, kept identical so both resolve alike. */
4
+ const isSupportedBlockNode = (node, supportedBlockNodes = []) => {
5
+ return supportedBlockNodes.indexOf(node.type.name) >= 0 || node.type.name === 'mediaSingle' && supportedBlockNodes.indexOf('media') >= 0;
6
+ };
7
+
8
+ /**
9
+ * Renderer equivalent of the editor's `resolveAnnotatableTargetFromLocalId`: resolves the node to
10
+ * annotate for a `localId`, climbing to the closest accepting ancestor when the node itself does
11
+ * not accept an annotation. Returns undefined when nothing in the chain accepts one.
12
+ *
13
+ * Kept in sync with the editor implementation so both sides resolve the same node.
14
+ */
15
+ export const resolveAnnotatableTargetFromLocalId = (doc, localId, opts = {}) => {
16
+ const {
17
+ supportedBlockNodes
18
+ } = opts;
19
+
20
+ // No `EditorState` here, so walk the doc directly like `findNodePosByLocalIds` does.
21
+ let match;
22
+ doc.descendants((node, pos) => {
23
+ var _node$attrs;
24
+ if (match) {
25
+ return false;
26
+ }
27
+ if (((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) === localId) {
28
+ match = {
29
+ node,
30
+ pos
31
+ };
32
+ return false;
33
+ }
34
+ return true;
35
+ });
36
+ if (!match) {
37
+ return undefined;
38
+ }
39
+ const annotationMarkType = doc.type.schema.marks.annotation;
40
+ const nodeAcceptsAnnotation = node => !!annotationMarkType && node.type.allowsMarkType(annotationMarkType) || isSupportedBlockNode(node, supportedBlockNodes);
41
+ if (nodeAcceptsAnnotation(match.node)) {
42
+ return match;
43
+ }
44
+
45
+ // Ancestors only — never descendants.
46
+ const $pos = doc.resolve(match.pos);
47
+ for (let depth = $pos.depth; depth >= 0; depth--) {
48
+ const ancestor = $pos.node(depth);
49
+ if (nodeAcceptsAnnotation(ancestor)) {
50
+ return {
51
+ node: ancestor,
52
+ pos: depth === 0 ? 0 : $pos.before(depth)
53
+ };
54
+ }
55
+ }
56
+ return undefined;
57
+ };
@@ -107,6 +107,8 @@ export var renderExtension = function renderExtension(content, layout) {
107
107
  */
108
108
  var viewportSize = getViewportSize(extensionId, extensionViewportSizes);
109
109
  var extensionHeight = nodeHeight || viewportSize;
110
+ // Forge manifest heights already include px; Connect node heights are numeric strings.
111
+ var extensionMinHeight = extensionHeight !== null && extensionHeight !== void 0 && extensionHeight.endsWith('px') && fg('confluence_forge_early_render_reserve_height') ? extensionHeight : extensionHeight && "".concat(extensionHeight, "px");
110
112
  /**
111
113
  * Scoped to nodes inserted by an app declaring `layout: inline-bodied`, which is what writes
112
114
  * `atlassianForgeInlineBodied`. The output-type marker alone would also match migrated Connect
@@ -160,7 +162,7 @@ export var renderExtension = function renderExtension(content, layout) {
160
162
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
161
163
  calcBreakoutWidthCss(layout) : expValEquals('platform_editor_remove_important_in_render_ext', 'isEnabled', true) ? undefined : '100%',
162
164
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
163
- minHeight: isInline ? undefined : extensionHeight && "".concat(extensionHeight, "px")
165
+ minHeight: isInline ? undefined : extensionMinHeight
164
166
  },
165
167
  "data-layout": layout,
166
168
  "data-local-id": localId,
@@ -62,7 +62,7 @@ export var DEGRADED_SEVERITY_THRESHOLD = 3000;
62
62
  var TABLE_INFO_TIMEOUT = 10000;
63
63
  var RENDER_EVENT_SAMPLE_RATE = 0.1;
64
64
  var packageName = "@atlaskit/renderer";
65
- var packageVersion = "149.0.0";
65
+ var packageVersion = "149.0.1";
66
66
  var setAsQueryContainerStyles = css({
67
67
  containerName: 'ak-renderer-wrapper',
68
68
  containerType: 'inline-size'
@@ -0,0 +1,59 @@
1
+ /** The node to annotate, with the position immediately before it (`doc.nodeAt(pos) === node`). */
2
+
3
+ /** Renderer copy of the editor's `isSupportedBlockNode`, kept identical so both resolve alike. */
4
+ var isSupportedBlockNode = function isSupportedBlockNode(node) {
5
+ var supportedBlockNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
6
+ return supportedBlockNodes.indexOf(node.type.name) >= 0 || node.type.name === 'mediaSingle' && supportedBlockNodes.indexOf('media') >= 0;
7
+ };
8
+
9
+ /**
10
+ * Renderer equivalent of the editor's `resolveAnnotatableTargetFromLocalId`: resolves the node to
11
+ * annotate for a `localId`, climbing to the closest accepting ancestor when the node itself does
12
+ * not accept an annotation. Returns undefined when nothing in the chain accepts one.
13
+ *
14
+ * Kept in sync with the editor implementation so both sides resolve the same node.
15
+ */
16
+ export var resolveAnnotatableTargetFromLocalId = function resolveAnnotatableTargetFromLocalId(doc, localId) {
17
+ var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
18
+ var supportedBlockNodes = opts.supportedBlockNodes;
19
+
20
+ // No `EditorState` here, so walk the doc directly like `findNodePosByLocalIds` does.
21
+ var match;
22
+ doc.descendants(function (node, pos) {
23
+ var _node$attrs;
24
+ if (match) {
25
+ return false;
26
+ }
27
+ if (((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) === localId) {
28
+ match = {
29
+ node: node,
30
+ pos: pos
31
+ };
32
+ return false;
33
+ }
34
+ return true;
35
+ });
36
+ if (!match) {
37
+ return undefined;
38
+ }
39
+ var annotationMarkType = doc.type.schema.marks.annotation;
40
+ var nodeAcceptsAnnotation = function nodeAcceptsAnnotation(node) {
41
+ return !!annotationMarkType && node.type.allowsMarkType(annotationMarkType) || isSupportedBlockNode(node, supportedBlockNodes);
42
+ };
43
+ if (nodeAcceptsAnnotation(match.node)) {
44
+ return match;
45
+ }
46
+
47
+ // Ancestors only — never descendants.
48
+ var $pos = doc.resolve(match.pos);
49
+ for (var depth = $pos.depth; depth >= 0; depth--) {
50
+ var ancestor = $pos.node(depth);
51
+ if (nodeAcceptsAnnotation(ancestor)) {
52
+ return {
53
+ node: ancestor,
54
+ pos: depth === 0 ? 0 : $pos.before(depth)
55
+ };
56
+ }
57
+ }
58
+ return undefined;
59
+ };
@@ -0,0 +1,17 @@
1
+ import type { Node } from '@atlaskit/editor-prosemirror/model';
2
+ /** The node to annotate, with the position immediately before it (`doc.nodeAt(pos) === node`). */
3
+ type ResolvedAnnotatableTarget = {
4
+ node: Node;
5
+ pos: number;
6
+ };
7
+ /**
8
+ * Renderer equivalent of the editor's `resolveAnnotatableTargetFromLocalId`: resolves the node to
9
+ * annotate for a `localId`, climbing to the closest accepting ancestor when the node itself does
10
+ * not accept an annotation. Returns undefined when nothing in the chain accepts one.
11
+ *
12
+ * Kept in sync with the editor implementation so both sides resolve the same node.
13
+ */
14
+ export declare const resolveAnnotatableTargetFromLocalId: (doc: Node, localId: string, opts?: {
15
+ supportedBlockNodes?: string[];
16
+ }) => ResolvedAnnotatableTarget | undefined;
17
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer",
3
- "version": "149.0.1",
3
+ "version": "149.0.2",
4
4
  "description": "Renderer component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -47,7 +47,7 @@
47
47
  "@atlaskit/editor-json-transformer": "^10.0.0",
48
48
  "@atlaskit/editor-palette": "^3.5.0",
49
49
  "@atlaskit/editor-prosemirror": "^9.0.0",
50
- "@atlaskit/editor-shared-styles": "^4.3.0",
50
+ "@atlaskit/editor-shared-styles": "^4.4.0",
51
51
  "@atlaskit/editor-smart-link-draggable": "^1.2.0",
52
52
  "@atlaskit/emoji": "^72.5.0",
53
53
  "@atlaskit/feature-gate-js-client": "^7.0.0",
@@ -69,11 +69,11 @@
69
69
  "@atlaskit/pragmatic-drag-and-drop": "^4.0.0",
70
70
  "@atlaskit/react-compiler-gating": "^0.2.0",
71
71
  "@atlaskit/react-ufo": "^8.1.0",
72
- "@atlaskit/smart-card": "^46.5.0",
72
+ "@atlaskit/smart-card": "^46.6.0",
73
73
  "@atlaskit/status": "^5.13.0",
74
74
  "@atlaskit/task-decision": "^21.12.0",
75
75
  "@atlaskit/theme": "^28.2.0",
76
- "@atlaskit/tmp-editor-statsig": "^228.0.0",
76
+ "@atlaskit/tmp-editor-statsig": "^229.0.0",
77
77
  "@atlaskit/tokens": "^20.4.0",
78
78
  "@atlaskit/tooltip": "^24.4.0",
79
79
  "@atlaskit/visually-hidden": "^4.4.0",
@@ -88,7 +88,7 @@
88
88
  "uuid": "^11.1.1"
89
89
  },
90
90
  "peerDependencies": {
91
- "@atlaskit/editor-common": "^130.1.0",
91
+ "@atlaskit/editor-common": "^130.3.0",
92
92
  "@atlaskit/link-provider": "^6.0.0",
93
93
  "@atlaskit/media-core": "^39.0.0",
94
94
  "react": "^18.2.0 || ^19.2.0",
@@ -149,6 +149,10 @@
149
149
  "worker-plugin": "^4.0.2"
150
150
  },
151
151
  "platform-feature-flags": {
152
+ "confluence_forge_early_render_reserve_height": {
153
+ "type": "boolean",
154
+ "referenceOnly": true
155
+ },
152
156
  "platform_editor_a11y_codeblock_haspopup": {
153
157
  "type": "boolean"
154
158
  },