@atlaskit/editor-plugin-table 10.10.7 → 10.11.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.
@@ -3,11 +3,13 @@ import throttle from 'lodash/throttle';
3
3
 
4
4
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
5
5
  import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
6
+ import { nodeVisibilityManager } from '@atlaskit/editor-common/node-visibility';
6
7
  import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
7
8
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
8
9
  import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
9
10
  import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
10
11
  import { fg } from '@atlaskit/platform-feature-flags';
12
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
11
13
 
12
14
  import { getPluginState } from '../pm-plugins/plugin-factory';
13
15
  import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
@@ -44,6 +46,8 @@ const HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200;
44
46
  const HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT = 400;
45
47
 
46
48
  export default class TableRow extends TableNodeView<HTMLTableRowElement> implements NodeView {
49
+ private nodeVisibilityObserverCleanupFn?: () => void;
50
+
47
51
  constructor(
48
52
  node: PMNode,
49
53
  view: EditorView,
@@ -66,13 +70,31 @@ export default class TableRow extends TableNodeView<HTMLTableRowElement> impleme
66
70
  }
67
71
 
68
72
  if (this.isHeaderRow) {
69
- this.dom.setAttribute('data-header-row', 'true');
70
- if (this.isStickyHeaderEnabled) {
71
- this.subscribe();
73
+ if (editorExperiment('platform_editor_nodevisibility', false)) {
74
+ this.subscribeWhenRowVisible();
75
+ } else {
76
+ const { observe } = nodeVisibilityManager(view.dom);
77
+ this.nodeVisibilityObserverCleanupFn = observe({
78
+ element: this.contentDOM,
79
+ onFirstVisible: () => {
80
+ this.subscribeWhenRowVisible();
81
+ },
82
+ });
72
83
  }
73
84
  }
74
85
  }
75
86
 
87
+ subscribeWhenRowVisible() {
88
+ if (this.listening) {
89
+ return;
90
+ }
91
+
92
+ this.dom.setAttribute('data-header-row', 'true');
93
+ if (this.isStickyHeaderEnabled) {
94
+ this.subscribe();
95
+ }
96
+ }
97
+
76
98
  /**
77
99
  * Variables
78
100
  */
@@ -151,6 +173,8 @@ export default class TableRow extends TableNodeView<HTMLTableRowElement> impleme
151
173
  if (this.isStickyHeaderEnabled) {
152
174
  this.unsubscribe();
153
175
 
176
+ this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
177
+
154
178
  const tree = getTree(this.dom);
155
179
  if (tree) {
156
180
  this.makeRowHeaderNotSticky(tree.table, true);
@@ -14,6 +14,7 @@ import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmo
14
14
  import type { ExtensionPlugin } from '@atlaskit/editor-plugin-extension';
15
15
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
16
16
  import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
17
+ import type { InteractionPlugin } from '@atlaskit/editor-plugin-interaction';
17
18
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
18
19
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
19
20
 
@@ -82,6 +83,7 @@ export type TablePluginDependencies = [
82
83
  OptionalPlugin<EditorViewModePlugin>,
83
84
  OptionalPlugin<FeatureFlagsPlugin>,
84
85
  OptionalPlugin<ExtensionPlugin>,
86
+ OptionalPlugin<InteractionPlugin>,
85
87
  ];
86
88
 
87
89
  export type TablePlugin = NextEditorPlugin<
package/tsconfig.app.json CHANGED
@@ -68,6 +68,9 @@
68
68
  {
69
69
  "path": "../editor-plugin-guideline/tsconfig.app.json"
70
70
  },
71
+ {
72
+ "path": "../editor-plugin-interaction/tsconfig.app.json"
73
+ },
71
74
  {
72
75
  "path": "../editor-plugin-selection/tsconfig.app.json"
73
76
  },