@atlaskit/editor-plugin-show-diff 17.1.0 → 17.1.1

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,14 @@
1
1
  # @atlaskit/editor-plugin-show-diff
2
2
 
3
+ ## 17.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`296193f8a499b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/296193f8a499b) -
8
+ Keep table diff indicators aligned with the visible table edge when the viewport narrows and the
9
+ table scrolls horizontally, behind platform_editor_ai_show_diff_patch_2.
10
+ - Updated dependencies
11
+
3
12
  ## 17.1.0
4
13
 
5
14
  ### Minor Changes
@@ -88,6 +88,17 @@ var edgeCases = function edgeCases(doc, from) {
88
88
  if (!node.firstChild) {
89
89
  return undefined;
90
90
  }
91
+ if ((0, _fg.fg)('platform_editor_ai_show_diff_patch_2')) {
92
+ // The row retains its full width when the table scrolls. Centering that
93
+ // width against the editor would push the anchor off-screen. Measure the
94
+ // visible container's edge instead, including start-aligned tables.
95
+ return {
96
+ beforePos: beforePos,
97
+ measurePos: beforePos,
98
+ measureSelector: '.pm-table-container',
99
+ measureLeft: true
100
+ };
101
+ }
91
102
 
92
103
  // Measure the first row (`nodeStart` is just inside the table, i.e. the
93
104
  // position of the first row): its width matches the table's.
@@ -175,19 +186,28 @@ var createLeftAnchorWidget = exports.createLeftAnchorWidget = function createLef
175
186
  var nodeDOM = view.nodeDOM(edgeCase.measurePos);
176
187
  var dom = edgeCase.measureSelector && nodeDOM instanceof HTMLElement ? (_nodeDOM$querySelecto = nodeDOM.querySelector(edgeCase.measureSelector)) !== null && _nodeDOM$querySelecto !== void 0 ? _nodeDOM$querySelecto : nodeDOM : nodeDOM;
177
188
  if (dom instanceof HTMLElement) {
178
- // The left anchor only needs the container width so the
179
- // IndicatorBar can align against the block's horizontal extent.
180
- anchor.style.setProperty('width', "".concat(dom.offsetWidth, "px"));
189
+ var updateAnchor = function updateAnchor() {
190
+ if (getPos() === undefined) {
191
+ return;
192
+ }
193
+ if (edgeCase.measureLeft) {
194
+ var left = dom.getBoundingClientRect().left - wrapper.getBoundingClientRect().left;
195
+ anchor.style.setProperty('left', "".concat(left, "px"));
196
+ anchor.style.setProperty('transform', 'none');
197
+ }
198
+ anchor.style.setProperty('width', "".concat(dom.offsetWidth, "px"));
199
+ };
200
+ // Align against the block's horizontal extent.
201
+ updateAnchor();
181
202
 
182
203
  // Observe the measured element for size changes (e.g. page
183
204
  // resize) so the indicator stays aligned. CCI-17981
184
205
  if (!leftResizeObserver) {
185
- leftResizeObserver = new ResizeObserver(function () {
186
- if (getPos() !== undefined) {
187
- anchor.style.setProperty('width', "".concat(dom.offsetWidth, "px"));
188
- }
189
- });
206
+ leftResizeObserver = new ResizeObserver(updateAnchor);
190
207
  leftResizeObserver.observe(dom);
208
+ if (edgeCase.measureLeft) {
209
+ leftResizeObserver.observe(wrapper);
210
+ }
191
211
  }
192
212
  }
193
213
  };
@@ -79,6 +79,17 @@ const edgeCases = (doc, from) => {
79
79
  if (!node.firstChild) {
80
80
  return undefined;
81
81
  }
82
+ if (fg('platform_editor_ai_show_diff_patch_2')) {
83
+ // The row retains its full width when the table scrolls. Centering that
84
+ // width against the editor would push the anchor off-screen. Measure the
85
+ // visible container's edge instead, including start-aligned tables.
86
+ return {
87
+ beforePos,
88
+ measurePos: beforePos,
89
+ measureSelector: '.pm-table-container',
90
+ measureLeft: true
91
+ };
92
+ }
82
93
 
83
94
  // Measure the first row (`nodeStart` is just inside the table, i.e. the
84
95
  // position of the first row): its width matches the table's.
@@ -169,19 +180,28 @@ export const createLeftAnchorWidget = ({
169
180
  const nodeDOM = view.nodeDOM(edgeCase.measurePos);
170
181
  const dom = edgeCase.measureSelector && nodeDOM instanceof HTMLElement ? (_nodeDOM$querySelecto = nodeDOM.querySelector(edgeCase.measureSelector)) !== null && _nodeDOM$querySelecto !== void 0 ? _nodeDOM$querySelecto : nodeDOM : nodeDOM;
171
182
  if (dom instanceof HTMLElement) {
172
- // The left anchor only needs the container width so the
173
- // IndicatorBar can align against the block's horizontal extent.
174
- anchor.style.setProperty('width', `${dom.offsetWidth}px`);
183
+ const updateAnchor = () => {
184
+ if (getPos() === undefined) {
185
+ return;
186
+ }
187
+ if (edgeCase.measureLeft) {
188
+ const left = dom.getBoundingClientRect().left - wrapper.getBoundingClientRect().left;
189
+ anchor.style.setProperty('left', `${left}px`);
190
+ anchor.style.setProperty('transform', 'none');
191
+ }
192
+ anchor.style.setProperty('width', `${dom.offsetWidth}px`);
193
+ };
194
+ // Align against the block's horizontal extent.
195
+ updateAnchor();
175
196
 
176
197
  // Observe the measured element for size changes (e.g. page
177
198
  // resize) so the indicator stays aligned. CCI-17981
178
199
  if (!leftResizeObserver) {
179
- leftResizeObserver = new ResizeObserver(() => {
180
- if (getPos() !== undefined) {
181
- anchor.style.setProperty('width', `${dom.offsetWidth}px`);
182
- }
183
- });
200
+ leftResizeObserver = new ResizeObserver(updateAnchor);
184
201
  leftResizeObserver.observe(dom);
202
+ if (edgeCase.measureLeft) {
203
+ leftResizeObserver.observe(wrapper);
204
+ }
185
205
  }
186
206
  }
187
207
  };
@@ -82,6 +82,17 @@ var edgeCases = function edgeCases(doc, from) {
82
82
  if (!node.firstChild) {
83
83
  return undefined;
84
84
  }
85
+ if (fg('platform_editor_ai_show_diff_patch_2')) {
86
+ // The row retains its full width when the table scrolls. Centering that
87
+ // width against the editor would push the anchor off-screen. Measure the
88
+ // visible container's edge instead, including start-aligned tables.
89
+ return {
90
+ beforePos: beforePos,
91
+ measurePos: beforePos,
92
+ measureSelector: '.pm-table-container',
93
+ measureLeft: true
94
+ };
95
+ }
85
96
 
86
97
  // Measure the first row (`nodeStart` is just inside the table, i.e. the
87
98
  // position of the first row): its width matches the table's.
@@ -169,19 +180,28 @@ export var createLeftAnchorWidget = function createLeftAnchorWidget(_ref) {
169
180
  var nodeDOM = view.nodeDOM(edgeCase.measurePos);
170
181
  var dom = edgeCase.measureSelector && nodeDOM instanceof HTMLElement ? (_nodeDOM$querySelecto = nodeDOM.querySelector(edgeCase.measureSelector)) !== null && _nodeDOM$querySelecto !== void 0 ? _nodeDOM$querySelecto : nodeDOM : nodeDOM;
171
182
  if (dom instanceof HTMLElement) {
172
- // The left anchor only needs the container width so the
173
- // IndicatorBar can align against the block's horizontal extent.
174
- anchor.style.setProperty('width', "".concat(dom.offsetWidth, "px"));
183
+ var updateAnchor = function updateAnchor() {
184
+ if (getPos() === undefined) {
185
+ return;
186
+ }
187
+ if (edgeCase.measureLeft) {
188
+ var left = dom.getBoundingClientRect().left - wrapper.getBoundingClientRect().left;
189
+ anchor.style.setProperty('left', "".concat(left, "px"));
190
+ anchor.style.setProperty('transform', 'none');
191
+ }
192
+ anchor.style.setProperty('width', "".concat(dom.offsetWidth, "px"));
193
+ };
194
+ // Align against the block's horizontal extent.
195
+ updateAnchor();
175
196
 
176
197
  // Observe the measured element for size changes (e.g. page
177
198
  // resize) so the indicator stays aligned. CCI-17981
178
199
  if (!leftResizeObserver) {
179
- leftResizeObserver = new ResizeObserver(function () {
180
- if (getPos() !== undefined) {
181
- anchor.style.setProperty('width', "".concat(dom.offsetWidth, "px"));
182
- }
183
- });
200
+ leftResizeObserver = new ResizeObserver(updateAnchor);
184
201
  leftResizeObserver.observe(dom);
202
+ if (edgeCase.measureLeft) {
203
+ leftResizeObserver.observe(wrapper);
204
+ }
185
205
  }
186
206
  }
187
207
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-show-diff",
3
- "version": "17.1.0",
3
+ "version": "17.1.1",
4
4
  "description": "ShowDiff plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -39,7 +39,7 @@
39
39
  "@atlaskit/platform-feature-experiments": "^0.3.0",
40
40
  "@atlaskit/platform-feature-flags": "^2.2.0",
41
41
  "@atlaskit/primitives": "^22.5.0",
42
- "@atlaskit/tmp-editor-statsig": "^200.0.0",
42
+ "@atlaskit/tmp-editor-statsig": "^201.0.0",
43
43
  "@atlaskit/tokens": "^18.2.0",
44
44
  "@babel/runtime": "^7.0.0",
45
45
  "@compiled/react": "^1.0.2",