@atlaskit/editor-plugin-table 9.4.1 → 9.5.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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 9.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#112673](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/112673)
8
+ [`df389f09ee177`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/df389f09ee177) -
9
+ ED-25870 disable table sticky header inside layout for Safari
10
+
3
11
  ## 9.4.1
4
12
 
5
13
  ### Patch Changes
@@ -14,6 +14,8 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
14
14
  var _debounce = _interopRequireDefault(require("lodash/debounce"));
15
15
  var _throttle = _interopRequireDefault(require("lodash/throttle"));
16
16
  var _ui = require("@atlaskit/editor-common/ui");
17
+ var _utils = require("@atlaskit/editor-prosemirror/utils");
18
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
19
  var _pluginFactory = require("../pm-plugins/plugin-factory");
18
20
  var _pluginKey = require("../pm-plugins/plugin-key");
19
21
  var _commands = require("../pm-plugins/sticky-headers/commands");
@@ -343,7 +345,7 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
343
345
  return;
344
346
  }
345
347
  var table = tree.table;
346
- var shouldStick = this.isHeaderSticky();
348
+ var shouldStick = this.shouldSticky();
347
349
  if (this.isSticky !== shouldStick) {
348
350
  if (shouldStick) {
349
351
  var _this$sentinelData$to;
@@ -355,6 +357,30 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
355
357
  }
356
358
  }
357
359
  }
360
+ }, {
361
+ key: "shouldSticky",
362
+ value: function shouldSticky() {
363
+ if (
364
+ // is Safari
365
+ navigator.userAgent.includes('AppleWebKit') && !navigator.userAgent.includes('Chrome') && (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_4')) {
366
+ var pos = this.getPos();
367
+ if (typeof pos === 'number') {
368
+ var $tableRowPos = this.view.state.doc.resolve(pos);
369
+
370
+ // layout -> layout column -> table -> table row
371
+ if ($tableRowPos.depth >= 3) {
372
+ var _findParentNodeCloses;
373
+ var isInsideLayout = (_findParentNodeCloses = (0, _utils.findParentNodeClosestToPos)($tableRowPos, function (node) {
374
+ return node.type.name === 'layoutColumn';
375
+ })) === null || _findParentNodeCloses === void 0 ? void 0 : _findParentNodeCloses.node;
376
+ if (isInsideLayout) {
377
+ return false;
378
+ }
379
+ }
380
+ }
381
+ }
382
+ return this.isHeaderSticky();
383
+ }
358
384
  }, {
359
385
  key: "isHeaderSticky",
360
386
  value: function isHeaderSticky() {
@@ -2,6 +2,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import debounce from 'lodash/debounce';
3
3
  import throttle from 'lodash/throttle';
4
4
  import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
5
+ import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
6
+ import { fg } from '@atlaskit/platform-feature-flags';
5
7
  import { getPluginState } from '../pm-plugins/plugin-factory';
6
8
  import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
7
9
  import { updateStickyState } from '../pm-plugins/sticky-headers/commands';
@@ -311,7 +313,7 @@ export default class TableRow extends TableNodeView {
311
313
  const {
312
314
  table
313
315
  } = tree;
314
- const shouldStick = this.isHeaderSticky();
316
+ const shouldStick = this.shouldSticky();
315
317
  if (this.isSticky !== shouldStick) {
316
318
  if (shouldStick) {
317
319
  var _this$sentinelData$to;
@@ -323,6 +325,28 @@ export default class TableRow extends TableNodeView {
323
325
  }
324
326
  }
325
327
  }
328
+ shouldSticky() {
329
+ if (
330
+ // is Safari
331
+ navigator.userAgent.includes('AppleWebKit') && !navigator.userAgent.includes('Chrome') && fg('platform_editor_advanced_layouts_post_fix_patch_4')) {
332
+ const pos = this.getPos();
333
+ if (typeof pos === 'number') {
334
+ const $tableRowPos = this.view.state.doc.resolve(pos);
335
+
336
+ // layout -> layout column -> table -> table row
337
+ if ($tableRowPos.depth >= 3) {
338
+ var _findParentNodeCloses;
339
+ const isInsideLayout = (_findParentNodeCloses = findParentNodeClosestToPos($tableRowPos, node => {
340
+ return node.type.name === 'layoutColumn';
341
+ })) === null || _findParentNodeCloses === void 0 ? void 0 : _findParentNodeCloses.node;
342
+ if (isInsideLayout) {
343
+ return false;
344
+ }
345
+ }
346
+ }
347
+ }
348
+ return this.isHeaderSticky();
349
+ }
326
350
  isHeaderSticky() {
327
351
  var _sentinelTop$rootBoun;
328
352
  /*
@@ -9,6 +9,8 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
9
9
  import debounce from 'lodash/debounce';
10
10
  import throttle from 'lodash/throttle';
11
11
  import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
12
+ import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
13
+ import { fg } from '@atlaskit/platform-feature-flags';
12
14
  import { getPluginState } from '../pm-plugins/plugin-factory';
13
15
  import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
14
16
  import { updateStickyState } from '../pm-plugins/sticky-headers/commands';
@@ -336,7 +338,7 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
336
338
  return;
337
339
  }
338
340
  var table = tree.table;
339
- var shouldStick = this.isHeaderSticky();
341
+ var shouldStick = this.shouldSticky();
340
342
  if (this.isSticky !== shouldStick) {
341
343
  if (shouldStick) {
342
344
  var _this$sentinelData$to;
@@ -348,6 +350,30 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
348
350
  }
349
351
  }
350
352
  }
353
+ }, {
354
+ key: "shouldSticky",
355
+ value: function shouldSticky() {
356
+ if (
357
+ // is Safari
358
+ navigator.userAgent.includes('AppleWebKit') && !navigator.userAgent.includes('Chrome') && fg('platform_editor_advanced_layouts_post_fix_patch_4')) {
359
+ var pos = this.getPos();
360
+ if (typeof pos === 'number') {
361
+ var $tableRowPos = this.view.state.doc.resolve(pos);
362
+
363
+ // layout -> layout column -> table -> table row
364
+ if ($tableRowPos.depth >= 3) {
365
+ var _findParentNodeCloses;
366
+ var isInsideLayout = (_findParentNodeCloses = findParentNodeClosestToPos($tableRowPos, function (node) {
367
+ return node.type.name === 'layoutColumn';
368
+ })) === null || _findParentNodeCloses === void 0 ? void 0 : _findParentNodeCloses.node;
369
+ if (isInsideLayout) {
370
+ return false;
371
+ }
372
+ }
373
+ }
374
+ }
375
+ return this.isHeaderSticky();
376
+ }
351
377
  }, {
352
378
  key: "isHeaderSticky",
353
379
  value: function isHeaderSticky() {
@@ -42,6 +42,7 @@ export default class TableRow extends TableNodeView<HTMLTableRowElement> impleme
42
42
  private createResizeObserver;
43
43
  private createIntersectionObserver;
44
44
  private refreshStickyState;
45
+ private shouldSticky;
45
46
  private isHeaderSticky;
46
47
  private onTablePluginState;
47
48
  private updateStickyHeaderWidth;
@@ -42,6 +42,7 @@ export default class TableRow extends TableNodeView<HTMLTableRowElement> impleme
42
42
  private createResizeObserver;
43
43
  private createIntersectionObserver;
44
44
  private refreshStickyState;
45
+ private shouldSticky;
45
46
  private isHeaderSticky;
46
47
  private onTablePluginState;
47
48
  private updateStickyHeaderWidth;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "9.4.1",
3
+ "version": "9.5.0",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -146,6 +146,9 @@
146
146
  },
147
147
  "platform_editor_table_layout_shift_fix": {
148
148
  "type": "boolean"
149
+ },
150
+ "platform_editor_advanced_layouts_post_fix_patch_4": {
151
+ "type": "boolean"
149
152
  }
150
153
  }
151
154
  }
@@ -4,7 +4,9 @@ import throttle from 'lodash/throttle';
4
4
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
5
5
  import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
6
6
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
7
+ import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
7
8
  import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
9
+ import { fg } from '@atlaskit/platform-feature-flags';
8
10
 
9
11
  import { getPluginState } from '../pm-plugins/plugin-factory';
10
12
  import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
@@ -384,7 +386,7 @@ export default class TableRow extends TableNodeView<HTMLTableRowElement> impleme
384
386
  return;
385
387
  }
386
388
  const { table } = tree;
387
- const shouldStick = this.isHeaderSticky();
389
+ const shouldStick = this.shouldSticky();
388
390
  if (this.isSticky !== shouldStick) {
389
391
  if (shouldStick) {
390
392
  // The rootRect is kept in sync across sentinels so it doesn't matter which one we use.
@@ -396,6 +398,33 @@ export default class TableRow extends TableNodeView<HTMLTableRowElement> impleme
396
398
  }
397
399
  }
398
400
 
401
+ private shouldSticky() {
402
+ if (
403
+ // is Safari
404
+ navigator.userAgent.includes('AppleWebKit') &&
405
+ !navigator.userAgent.includes('Chrome') &&
406
+ fg('platform_editor_advanced_layouts_post_fix_patch_4')
407
+ ) {
408
+ const pos = this.getPos();
409
+ if (typeof pos === 'number') {
410
+ const $tableRowPos = this.view.state.doc.resolve(pos);
411
+
412
+ // layout -> layout column -> table -> table row
413
+ if ($tableRowPos.depth >= 3) {
414
+ const isInsideLayout = findParentNodeClosestToPos($tableRowPos, (node) => {
415
+ return node.type.name === 'layoutColumn';
416
+ })?.node;
417
+
418
+ if (isInsideLayout) {
419
+ return false;
420
+ }
421
+ }
422
+ }
423
+ }
424
+
425
+ return this.isHeaderSticky();
426
+ }
427
+
399
428
  private isHeaderSticky() {
400
429
  /*
401
430
  # Overview