@atlaskit/editor-plugin-table 5.1.0 → 5.2.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 +12 -0
- package/dist/cjs/plugins/table/index.js +3 -2
- package/dist/cjs/plugins/table/nodeviews/TableCell.js +111 -0
- package/dist/cjs/plugins/table/nodeviews/TableNodeViewBase.js +30 -0
- package/dist/cjs/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.js → nodeviews/TableRow.js} +363 -303
- package/dist/cjs/plugins/table/pm-plugins/main.js +16 -13
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/index.js +1 -8
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -9
- package/dist/cjs/plugins/table/types.js +4 -1
- package/dist/cjs/plugins/table/utils/dom.js +31 -1
- package/dist/cjs/plugins/table/utils/index.js +12 -0
- package/dist/cjs/plugins/table/utils/nodes.js +31 -7
- package/dist/es2019/plugins/table/index.js +3 -2
- package/dist/es2019/plugins/table/nodeviews/{tableCell.js → TableCell.js} +28 -24
- package/dist/es2019/plugins/table/nodeviews/TableNodeViewBase.js +22 -0
- package/dist/es2019/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.js → nodeviews/TableRow.js} +324 -280
- package/dist/es2019/plugins/table/pm-plugins/main.js +8 -8
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/index.js +1 -2
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -9
- package/dist/es2019/plugins/table/types.js +5 -1
- package/dist/es2019/plugins/table/utils/dom.js +30 -0
- package/dist/es2019/plugins/table/utils/index.js +1 -1
- package/dist/es2019/plugins/table/utils/nodes.js +16 -0
- package/dist/esm/plugins/table/index.js +3 -2
- package/dist/esm/plugins/table/nodeviews/TableCell.js +105 -0
- package/dist/esm/plugins/table/nodeviews/TableNodeViewBase.js +24 -0
- package/dist/esm/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.js → nodeviews/TableRow.js} +364 -303
- package/dist/esm/plugins/table/pm-plugins/main.js +16 -13
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/index.js +1 -2
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -9
- package/dist/esm/plugins/table/types.js +5 -1
- package/dist/esm/plugins/table/utils/dom.js +30 -0
- package/dist/esm/plugins/table/utils/index.js +1 -1
- package/dist/esm/plugins/table/utils/nodes.js +24 -0
- package/dist/types/plugins/table/nodeviews/TableCell.d.ts +13 -0
- package/dist/types/plugins/table/nodeviews/TableNodeViewBase.d.ts +18 -0
- package/dist/types/plugins/table/nodeviews/TableRow.d.ts +62 -0
- package/dist/types/plugins/table/pm-plugins/main.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/sticky-headers/index.d.ts +0 -1
- package/dist/types/plugins/table/pm-plugins/sticky-headers/plugin.d.ts +1 -1
- package/dist/types/plugins/table/types.d.ts +15 -0
- package/dist/types/plugins/table/utils/dom.d.ts +6 -0
- package/dist/types/plugins/table/utils/index.d.ts +1 -1
- package/dist/types/plugins/table/utils/nodes.d.ts +12 -2
- package/dist/types-ts4.5/plugins/table/nodeviews/TableCell.d.ts +13 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/TableNodeViewBase.d.ts +18 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/TableRow.d.ts +62 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/types.d.ts +15 -0
- package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/utils/nodes.d.ts +12 -2
- package/package.json +4 -2
- package/src/__tests__/unit/nodeviews/cell.ts +2 -2
- package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +25 -148
- package/src/plugins/table/index.tsx +2 -0
- package/src/plugins/table/nodeviews/{tableCell.tsx → TableCell.ts} +41 -46
- package/src/plugins/table/nodeviews/TableNodeViewBase.ts +32 -0
- package/src/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.ts → nodeviews/TableRow.ts} +246 -246
- package/src/plugins/table/pm-plugins/main.ts +10 -19
- package/src/plugins/table/pm-plugins/sticky-headers/index.ts +0 -1
- package/src/plugins/table/pm-plugins/sticky-headers/plugin.ts +1 -9
- package/src/plugins/table/types.ts +18 -0
- package/src/plugins/table/utils/dom.ts +38 -0
- package/src/plugins/table/utils/index.ts +2 -0
- package/src/plugins/table/utils/nodes.ts +30 -2
- package/tsconfig.app.json +6 -0
- package/dist/cjs/plugins/table/nodeviews/tableCell.js +0 -99
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +0 -35
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +0 -29
- package/dist/esm/plugins/table/nodeviews/tableCell.js +0 -93
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +0 -29
- package/dist/types/plugins/table/nodeviews/tableCell.d.ts +0 -17
- package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.d.ts +0 -6
- package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +0 -73
- package/dist/types-ts4.5/plugins/table/nodeviews/tableCell.d.ts +0 -17
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.d.ts +0 -6
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +0 -73
- package/src/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.ts +0 -37
|
@@ -4,288 +4,210 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.default = void 0;
|
|
8
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
11
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
12
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
10
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
15
|
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
12
16
|
var _throttle = _interopRequireDefault(require("lodash/throttle"));
|
|
13
17
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
14
18
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var _commands = require("../commands");
|
|
20
|
-
var
|
|
19
|
+
var _closestEdge = require("@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge");
|
|
20
|
+
var _element = require("@atlaskit/pragmatic-drag-and-drop/adapter/element");
|
|
21
|
+
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
22
|
+
var _pluginKey = require("../pm-plugins/plugin-key");
|
|
23
|
+
var _commands = require("../pm-plugins/sticky-headers/commands");
|
|
24
|
+
var _dom = require("../pm-plugins/table-resizing/utils/dom");
|
|
25
|
+
var _types = require("../types");
|
|
26
|
+
var _consts = require("../ui/consts");
|
|
27
|
+
var _dom2 = require("../utils/dom");
|
|
28
|
+
var _nodes = require("../utils/nodes");
|
|
29
|
+
var _TableNodeViewBase = _interopRequireDefault(require("./TableNodeViewBase"));
|
|
30
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
31
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
21
32
|
// limit scroll event calls
|
|
22
33
|
var HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200;
|
|
23
34
|
|
|
24
35
|
// timeout for resetting the scroll class - if it’s too long then users won’t be able to click on the header cells,
|
|
25
36
|
// if too short it would trigger too many dom updates.
|
|
26
37
|
var HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT = 400;
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*/
|
|
43
|
-
var supportedHeaderRow = exports.supportedHeaderRow = function supportedHeaderRow(node) {
|
|
44
|
-
var allHeaders = (0, _utils.mapChildren)(node, function (child) {
|
|
45
|
-
return child.type.name === 'tableHeader';
|
|
46
|
-
}).every(Boolean);
|
|
47
|
-
var someMerged = anyChildCellMergedAcrossRow(node);
|
|
48
|
-
return allHeaders && !someMerged;
|
|
49
|
-
};
|
|
50
|
-
var TableRowNodeView = exports.TableRowNodeView = /*#__PURE__*/function () {
|
|
51
|
-
function TableRowNodeView(node, view, getPos, eventDispatcher) {
|
|
52
|
-
var _this = this;
|
|
53
|
-
(0, _classCallCheck2.default)(this, TableRowNodeView);
|
|
54
|
-
// this is the sticky header table row
|
|
55
|
-
(0, _defineProperty2.default)(this, "colControlsOffset", 0);
|
|
56
|
-
(0, _defineProperty2.default)(this, "focused", false);
|
|
57
|
-
(0, _defineProperty2.default)(this, "topPosEditorElement", 0);
|
|
58
|
-
(0, _defineProperty2.default)(this, "sentinels", {});
|
|
59
|
-
/* external events */
|
|
60
|
-
(0, _defineProperty2.default)(this, "listening", false);
|
|
61
|
-
(0, _defineProperty2.default)(this, "headerRowMouseScrollEnd", (0, _debounce.default)(function () {
|
|
38
|
+
var TableRow = exports.default = /*#__PURE__*/function (_ref) {
|
|
39
|
+
(0, _inherits2.default)(TableRow, _ref);
|
|
40
|
+
var _super = _createSuper(TableRow);
|
|
41
|
+
function TableRow(node, view, getPos, eventDispatcher) {
|
|
42
|
+
var _this;
|
|
43
|
+
(0, _classCallCheck2.default)(this, TableRow);
|
|
44
|
+
_this = _super.call(this, node, view, getPos, eventDispatcher);
|
|
45
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "colControlsOffset", 0);
|
|
46
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "focused", false);
|
|
47
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "topPosEditorElement", 0);
|
|
48
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "sentinels", {});
|
|
49
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "listening", false);
|
|
50
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "padding", 0);
|
|
51
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "top", 0);
|
|
52
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "headerRowMouseScrollEnd", (0, _debounce.default)(function () {
|
|
62
53
|
_this.dom.classList.remove('no-pointer-events');
|
|
63
54
|
}, HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT));
|
|
64
55
|
// When the header is sticky, the header row is set to position: fixed
|
|
65
56
|
// This prevents mouse wheel scrolling on the scroll-parent div when user's mouse is hovering the header row.
|
|
66
57
|
// This fix sets pointer-events: none on the header row briefly to avoid this behaviour
|
|
67
|
-
(0, _defineProperty2.default)(
|
|
58
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "headerRowMouseScroll", (0, _throttle.default)(function () {
|
|
68
59
|
if (_this.isSticky) {
|
|
69
60
|
_this.dom.classList.add('no-pointer-events');
|
|
70
61
|
_this.headerRowMouseScrollEnd();
|
|
71
62
|
}
|
|
72
63
|
}, HEADER_ROW_SCROLL_THROTTLE_TIMEOUT));
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
64
|
+
_this.isHeaderRow = (0, _nodes.supportedHeaderRow)(node);
|
|
65
|
+
_this.isSticky = false;
|
|
66
|
+
var _getPluginState = (0, _pluginFactory.getPluginState)(view.state),
|
|
67
|
+
pluginConfig = _getPluginState.pluginConfig,
|
|
68
|
+
isDragAndDropEnabled = _getPluginState.isDragAndDropEnabled;
|
|
69
|
+
_this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
|
|
70
|
+
_this.isDragAndDropEnabled = !!isDragAndDropEnabled;
|
|
71
|
+
if (_this.isHeaderRow) {
|
|
72
|
+
_this.dom.setAttribute('data-header-row', 'true');
|
|
73
|
+
if (_this.isStickyHeaderEnabled) {
|
|
74
|
+
_this.subscribe();
|
|
79
75
|
}
|
|
76
|
+
}
|
|
77
|
+
if (_this.isDragAndDropEnabled) {
|
|
78
|
+
_this.addDropTarget(_this.contentDOM);
|
|
79
|
+
}
|
|
80
|
+
return _this;
|
|
81
|
+
}
|
|
80
82
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (el) {
|
|
85
|
-
delete el.dataset.isObserved;
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
var isCurrentTableSelected = tableRef === tree.table;
|
|
83
|
+
/**
|
|
84
|
+
* Variables
|
|
85
|
+
*/
|
|
90
86
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
if (layoutContainer && layoutContainer.getAttribute('data-layout-content')) {
|
|
103
|
-
// move table a little out of the way
|
|
104
|
-
// to provide spacing for table controls
|
|
105
|
-
tableContentWrapper.style.paddingLeft = '11px';
|
|
106
|
-
}
|
|
107
|
-
} else {
|
|
108
|
-
_this.colControlsOffset = 0;
|
|
109
|
-
if (layoutContainer && layoutContainer.getAttribute('data-layout-content')) {
|
|
110
|
-
tableContentWrapper.style.removeProperty('padding-left');
|
|
111
|
-
}
|
|
87
|
+
// @ts-ignore
|
|
88
|
+
(0, _createClass2.default)(TableRow, [{
|
|
89
|
+
key: "update",
|
|
90
|
+
value:
|
|
91
|
+
/**
|
|
92
|
+
* Methods: Nodeview Lifecycle
|
|
93
|
+
*/
|
|
94
|
+
function update(node) {
|
|
95
|
+
// do nothing if nodes were identical
|
|
96
|
+
if (node === this.node) {
|
|
97
|
+
return true;
|
|
112
98
|
}
|
|
113
99
|
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
(0, _defineProperty2.default)(this, "updateStickyHeaderWidth", function () {
|
|
120
|
-
// table width might have changed, sync that back to sticky row
|
|
121
|
-
var tree = _this.tree;
|
|
122
|
-
if (!tree) {
|
|
123
|
-
return;
|
|
100
|
+
// see if we're changing into a header row or
|
|
101
|
+
// changing away from one
|
|
102
|
+
var newNodeIsHeaderRow = (0, _nodes.supportedHeaderRow)(node);
|
|
103
|
+
if (this.isHeaderRow !== newNodeIsHeaderRow) {
|
|
104
|
+
return false; // re-create nodeview
|
|
124
105
|
}
|
|
125
|
-
(0, _dom.syncStickyRowToTable)(tree.table);
|
|
126
|
-
});
|
|
127
|
-
(0, _defineProperty2.default)(this, "shouldHeaderStick", function (tree) {
|
|
128
|
-
var wrapper = tree.wrapper;
|
|
129
|
-
var tableWrapperRect = wrapper.getBoundingClientRect();
|
|
130
|
-
var editorAreaRect = _this.editorScrollableElement.getBoundingClientRect();
|
|
131
|
-
var stickyHeaderRect = _this.contentDOM.getBoundingClientRect();
|
|
132
|
-
var firstHeaderRow = !_this.dom.previousElementSibling;
|
|
133
|
-
var subsequentRows = !!_this.dom.nextElementSibling;
|
|
134
|
-
var isHeaderValid = firstHeaderRow && subsequentRows;
|
|
135
106
|
|
|
136
|
-
//
|
|
137
|
-
|
|
138
|
-
// but bottom is still in the viewport.
|
|
139
|
-
if (tableWrapperRect.top < editorAreaRect.top && tableWrapperRect.bottom > editorAreaRect.top && isHeaderValid) {
|
|
140
|
-
return true;
|
|
141
|
-
}
|
|
107
|
+
// node is different but no need to re-create nodeview
|
|
108
|
+
this.node = node;
|
|
142
109
|
|
|
143
|
-
//
|
|
144
|
-
if (
|
|
145
|
-
return
|
|
110
|
+
// don't do anything if we're just a regular tr
|
|
111
|
+
if (!this.isHeaderRow) {
|
|
112
|
+
return true;
|
|
146
113
|
}
|
|
147
114
|
|
|
148
|
-
//
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
* Useful when the header may have detached from the table.
|
|
154
|
-
*/
|
|
155
|
-
(0, _defineProperty2.default)(this, "refireIntersectionObservers", function () {
|
|
156
|
-
if (_this.isSticky) {
|
|
157
|
-
[_this.sentinels.top, _this.sentinels.bottom].forEach(function (el) {
|
|
158
|
-
if (el && _this.intersectionObserver) {
|
|
159
|
-
_this.intersectionObserver.unobserve(el);
|
|
160
|
-
_this.intersectionObserver.observe(el);
|
|
161
|
-
}
|
|
162
|
-
});
|
|
115
|
+
// something changed, sync widths
|
|
116
|
+
if (this.isStickyHeaderEnabled) {
|
|
117
|
+
var tbody = this.dom.parentElement;
|
|
118
|
+
var table = tbody && tbody.parentElement;
|
|
119
|
+
(0, _dom.syncStickyRowToTable)(table);
|
|
163
120
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
}, {
|
|
124
|
+
key: "destroy",
|
|
125
|
+
value: function destroy() {
|
|
126
|
+
var _this$dropTargetClean;
|
|
127
|
+
if (this.isStickyHeaderEnabled) {
|
|
128
|
+
this.unsubscribe();
|
|
129
|
+
var tree = (0, _dom2.getTree)(this.dom);
|
|
130
|
+
if (tree) {
|
|
131
|
+
this.makeRowHeaderNotSticky(tree.table, true);
|
|
132
|
+
}
|
|
133
|
+
this.emitOff(true);
|
|
170
134
|
}
|
|
171
|
-
var table = tree.table,
|
|
172
|
-
wrapper = tree.wrapper;
|
|
173
135
|
|
|
174
|
-
//
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
136
|
+
// If a drop target cleanup method has been set then we should call it.
|
|
137
|
+
(_this$dropTargetClean = this.dropTargetCleanup) === null || _this$dropTargetClean === void 0 || _this$dropTargetClean.call(this);
|
|
138
|
+
}
|
|
139
|
+
}, {
|
|
140
|
+
key: "ignoreMutation",
|
|
141
|
+
value: function ignoreMutation(mutationRecord) {
|
|
142
|
+
/* tableRows are not directly editable by the user
|
|
143
|
+
* so it should be safe to ignore mutations that we cause
|
|
144
|
+
* by updating styles and classnames on this DOM element
|
|
145
|
+
*
|
|
146
|
+
* Update: should not ignore mutations for row selection to avoid known issue with table selection highlight in firefox
|
|
147
|
+
* Related bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1289673
|
|
148
|
+
* */
|
|
149
|
+
var isTableSelection = mutationRecord.type === 'selection' && mutationRecord.target.nodeName === 'TR';
|
|
150
|
+
/**
|
|
151
|
+
* Update: should not ignore mutations when an node is added, as this interferes with
|
|
152
|
+
* prosemirrors handling of some language inputs in Safari (ie. Pinyin, Hiragana).
|
|
153
|
+
*
|
|
154
|
+
* In paticular, when a composition occurs at the start of the first node inside a table cell, if the resulting mutation
|
|
155
|
+
* from the composition end is ignored than prosemirror will end up with; invalid table markup nesting and a misplaced
|
|
156
|
+
* selection and insertion.
|
|
157
|
+
*/
|
|
158
|
+
var isNodeInsertion = mutationRecord.type === 'childList' && mutationRecord.target.nodeName === 'TR' && mutationRecord.addedNodes.length;
|
|
159
|
+
if (isTableSelection || isNodeInsertion) {
|
|
160
|
+
return false;
|
|
183
161
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
var _this$editorScrollabl;
|
|
187
|
-
(0, _dom.syncStickyRowToTable)(table);
|
|
188
|
-
_this.dom.classList.add('sticky');
|
|
189
|
-
table.classList.add(_types.TableCssClassName.TABLE_STICKY);
|
|
190
|
-
_this.isSticky = true;
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
191
164
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
});
|
|
201
|
-
var fastScrollThresholdMs = 500;
|
|
202
|
-
setTimeout(function () {
|
|
203
|
-
_this.refireIntersectionObservers();
|
|
204
|
-
}, fastScrollThresholdMs);
|
|
205
|
-
}
|
|
206
|
-
_this.dom.style.top = "".concat(domTop, "px");
|
|
207
|
-
(0, _dom.updateStickyMargins)(table);
|
|
208
|
-
_this.dom.scrollLeft = wrapper.scrollLeft;
|
|
209
|
-
_this.emitOn(domTop, _this.colControlsOffset);
|
|
210
|
-
});
|
|
211
|
-
(0, _defineProperty2.default)(this, "makeRowHeaderNotSticky", function (table) {
|
|
212
|
-
var isEditorDestroyed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
213
|
-
if (!_this.isSticky || !table || !_this.dom) {
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
_this.dom.style.removeProperty('width');
|
|
217
|
-
_this.dom.classList.remove('sticky');
|
|
218
|
-
table.classList.remove(_types.TableCssClassName.TABLE_STICKY);
|
|
219
|
-
_this.isSticky = false;
|
|
220
|
-
_this.dom.style.top = '';
|
|
221
|
-
table.style.removeProperty('margin-top');
|
|
222
|
-
_this.emitOff(isEditorDestroyed);
|
|
223
|
-
});
|
|
224
|
-
(0, _defineProperty2.default)(this, "getWrapperoffset", function () {
|
|
225
|
-
var inverse = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
226
|
-
var focusValue = inverse ? !_this.focused : _this.focused;
|
|
227
|
-
return focusValue ? 0 : _consts.tableControlsSpacing;
|
|
228
|
-
});
|
|
229
|
-
(0, _defineProperty2.default)(this, "getWrapperRefTop", function (wrapper) {
|
|
230
|
-
return Math.round((0, _dom2.getTop)(wrapper)) + _this.getWrapperoffset();
|
|
231
|
-
});
|
|
232
|
-
// TODO: rename!
|
|
233
|
-
(0, _defineProperty2.default)(this, "getScrolledTableTop", function (wrapper) {
|
|
234
|
-
return _this.getWrapperRefTop(wrapper) - _this.topPosEditorElement;
|
|
235
|
-
});
|
|
236
|
-
(0, _defineProperty2.default)(this, "getCurrentTableTop", function (tree) {
|
|
237
|
-
return _this.getScrolledTableTop(tree.wrapper) + tree.table.clientHeight;
|
|
238
|
-
});
|
|
239
|
-
/* emit external events */
|
|
240
|
-
(0, _defineProperty2.default)(this, "padding", 0);
|
|
241
|
-
(0, _defineProperty2.default)(this, "top", 0);
|
|
242
|
-
(0, _defineProperty2.default)(this, "emitOn", function (top, padding) {
|
|
243
|
-
if (top === _this.top && padding === _this.padding) {
|
|
165
|
+
/**
|
|
166
|
+
* Methods
|
|
167
|
+
*/
|
|
168
|
+
}, {
|
|
169
|
+
key: "addDropTarget",
|
|
170
|
+
value: function addDropTarget(element) {
|
|
171
|
+
var pos = this.getPos();
|
|
172
|
+
if (!Number.isFinite(pos)) {
|
|
244
173
|
return;
|
|
245
174
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
(0, _commands.updateStickyState)({
|
|
249
|
-
pos: _this.getPos(),
|
|
250
|
-
top: top,
|
|
251
|
-
sticky: true,
|
|
252
|
-
padding: padding
|
|
253
|
-
})(_this.view.state, _this.view.dispatch, _this.view);
|
|
254
|
-
});
|
|
255
|
-
(0, _defineProperty2.default)(this, "emitOff", function (isEditorDestroyed) {
|
|
256
|
-
if (_this.top === 0 && _this.padding === 0) {
|
|
257
|
-
return;
|
|
175
|
+
if (this.dropTargetCleanup) {
|
|
176
|
+
this.dropTargetCleanup();
|
|
258
177
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
178
|
+
var resolvedPos = this.view.state.doc.resolve(pos);
|
|
179
|
+
var targetIndex = resolvedPos.index();
|
|
180
|
+
var localId = resolvedPos.parent.attrs.localId;
|
|
181
|
+
this.dropTargetCleanup = (0, _element.dropTargetForElements)({
|
|
182
|
+
element: element,
|
|
183
|
+
canDrop: function canDrop(_ref2) {
|
|
184
|
+
var _data$indexes, _data$indexes2;
|
|
185
|
+
var source = _ref2.source;
|
|
186
|
+
var data = source.data;
|
|
187
|
+
return (
|
|
188
|
+
// Only draggables of row type can be dropped on this target
|
|
189
|
+
data.type === 'table-row' &&
|
|
190
|
+
// Only draggables which came from the same table can be dropped on this target
|
|
191
|
+
data.localId === localId &&
|
|
192
|
+
// Only draggables which DO NOT include this drop targets index can be dropped
|
|
193
|
+
!!((_data$indexes = data.indexes) !== null && _data$indexes !== void 0 && _data$indexes.length) && ((_data$indexes2 = data.indexes) === null || _data$indexes2 === void 0 ? void 0 : _data$indexes2.indexOf(targetIndex)) === -1
|
|
194
|
+
);
|
|
195
|
+
},
|
|
196
|
+
getData: function getData(_ref3) {
|
|
197
|
+
var input = _ref3.input,
|
|
198
|
+
element = _ref3.element;
|
|
199
|
+
var data = {
|
|
200
|
+
localId: localId,
|
|
201
|
+
type: 'table-row',
|
|
202
|
+
targetIndex: targetIndex
|
|
203
|
+
};
|
|
204
|
+
return (0, _closestEdge.attachClosestEdge)(data, {
|
|
205
|
+
input: input,
|
|
206
|
+
element: element,
|
|
207
|
+
allowedEdges: ['top', 'bottom']
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
});
|
|
289
211
|
}
|
|
290
212
|
}, {
|
|
291
213
|
key: "subscribe",
|
|
@@ -295,8 +217,8 @@ var TableRowNodeView = exports.TableRowNodeView = /*#__PURE__*/function () {
|
|
|
295
217
|
this.initObservers();
|
|
296
218
|
this.topPosEditorElement = (0, _dom2.getTop)(this.editorScrollableElement);
|
|
297
219
|
}
|
|
298
|
-
this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth);
|
|
299
|
-
this.eventDispatcher.on(_pluginKey.pluginKey.key, this.onTablePluginState);
|
|
220
|
+
this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth.bind(this));
|
|
221
|
+
this.eventDispatcher.on(_pluginKey.pluginKey.key, this.onTablePluginState.bind(this));
|
|
300
222
|
this.listening = true;
|
|
301
223
|
this.dom.addEventListener('wheel', this.headerRowMouseScroll.bind(this), {
|
|
302
224
|
passive: true
|
|
@@ -350,9 +272,9 @@ var TableRowNodeView = exports.TableRowNodeView = /*#__PURE__*/function () {
|
|
|
350
272
|
this.resizeObserver.observe(this.editorScrollableElement);
|
|
351
273
|
}
|
|
352
274
|
window.requestAnimationFrame(function () {
|
|
353
|
-
var
|
|
275
|
+
var _getTree;
|
|
354
276
|
// we expect tree to be defined after animation frame
|
|
355
|
-
var tableContainer = (
|
|
277
|
+
var tableContainer = (_getTree = (0, _dom2.getTree)(_this2.dom)) === null || _getTree === void 0 ? void 0 : _getTree.wrapper.closest(".".concat(_types.TableCssClassName.NODEVIEW_WRAPPER));
|
|
356
278
|
if (tableContainer) {
|
|
357
279
|
_this2.sentinels.top = tableContainer.getElementsByClassName(_types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP).item(0);
|
|
358
280
|
_this2.sentinels.bottom = tableContainer.getElementsByClassName(_types.TableCssClassName.TABLE_STICKY_SENTINEL_BOTTOM).item(0);
|
|
@@ -374,10 +296,11 @@ var TableRowNodeView = exports.TableRowNodeView = /*#__PURE__*/function () {
|
|
|
374
296
|
value: function createResizeObserver() {
|
|
375
297
|
var _this3 = this;
|
|
376
298
|
this.resizeObserver = new ResizeObserver(function (entries) {
|
|
377
|
-
|
|
299
|
+
var tree = (0, _dom2.getTree)(_this3.dom);
|
|
300
|
+
if (!tree) {
|
|
378
301
|
return;
|
|
379
302
|
}
|
|
380
|
-
var table =
|
|
303
|
+
var table = tree.table;
|
|
381
304
|
entries.forEach(function (entry) {
|
|
382
305
|
var _this3$editorScrollab;
|
|
383
306
|
// On resize of the parent scroll element we need to adjust the width
|
|
@@ -403,10 +326,11 @@ var TableRowNodeView = exports.TableRowNodeView = /*#__PURE__*/function () {
|
|
|
403
326
|
value: function createIntersectionObserver() {
|
|
404
327
|
var _this4 = this;
|
|
405
328
|
this.intersectionObserver = new IntersectionObserver(function (entries, _) {
|
|
406
|
-
|
|
329
|
+
var tree = (0, _dom2.getTree)(_this4.dom);
|
|
330
|
+
if (!tree) {
|
|
407
331
|
return;
|
|
408
332
|
}
|
|
409
|
-
var table =
|
|
333
|
+
var table = tree.table;
|
|
410
334
|
if (table.rows.length < 2) {
|
|
411
335
|
// ED-19307 - When there's only one row in a table the top & bottom sentinels become inverted. This creates some nasty visiblity
|
|
412
336
|
// toggling side-effects because the intersection observers gets confused.
|
|
@@ -425,7 +349,7 @@ var TableRowNodeView = exports.TableRowNodeView = /*#__PURE__*/function () {
|
|
|
425
349
|
var sentinelIsBelowScrollArea = (((_entry$rootBounds2 = entry.rootBounds) === null || _entry$rootBounds2 === void 0 ? void 0 : _entry$rootBounds2.bottom) || 0) < entry.boundingClientRect.bottom;
|
|
426
350
|
if (!entry.isIntersecting && !sentinelIsBelowScrollArea) {
|
|
427
351
|
var _entry$rootBounds3;
|
|
428
|
-
|
|
352
|
+
tree && _this4.makeHeaderRowSticky(tree, (_entry$rootBounds3 = entry.rootBounds) === null || _entry$rootBounds3 === void 0 ? void 0 : _entry$rootBounds3.top);
|
|
429
353
|
_this4.lastStickyTimestamp = Date.now();
|
|
430
354
|
} else {
|
|
431
355
|
table && _this4.makeRowHeaderNotSticky(table);
|
|
@@ -445,7 +369,7 @@ var TableRowNodeView = exports.TableRowNodeView = /*#__PURE__*/function () {
|
|
|
445
369
|
}
|
|
446
370
|
} else if (entry.isIntersecting && sentinelIsAboveScrollArea) {
|
|
447
371
|
var _entry$rootBounds5;
|
|
448
|
-
|
|
372
|
+
tree && _this4.makeHeaderRowSticky(tree, entry === null || entry === void 0 || (_entry$rootBounds5 = entry.rootBounds) === null || _entry$rootBounds5 === void 0 ? void 0 : _entry$rootBounds5.top);
|
|
449
373
|
_this4.lastStickyTimestamp = Date.now();
|
|
450
374
|
}
|
|
451
375
|
}
|
|
@@ -455,72 +379,208 @@ var TableRowNodeView = exports.TableRowNodeView = /*#__PURE__*/function () {
|
|
|
455
379
|
root: this.editorScrollableElement
|
|
456
380
|
});
|
|
457
381
|
}
|
|
458
|
-
|
|
459
|
-
/* paint/update loop */
|
|
382
|
+
/* receive external events */
|
|
460
383
|
}, {
|
|
461
|
-
key: "
|
|
462
|
-
value:
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
if (
|
|
466
|
-
return
|
|
384
|
+
key: "onTablePluginState",
|
|
385
|
+
value: function onTablePluginState(state) {
|
|
386
|
+
var tableRef = state.tableRef;
|
|
387
|
+
var tree = (0, _dom2.getTree)(this.dom);
|
|
388
|
+
if (!tree) {
|
|
389
|
+
return;
|
|
467
390
|
}
|
|
468
391
|
|
|
469
|
-
//
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
392
|
+
// when header rows are toggled off - mark sentinels as unobserved
|
|
393
|
+
if (!state.isHeaderRowEnabled) {
|
|
394
|
+
[this.sentinels.top, this.sentinels.bottom].forEach(function (el) {
|
|
395
|
+
if (el) {
|
|
396
|
+
delete el.dataset.isObserved;
|
|
397
|
+
}
|
|
398
|
+
});
|
|
474
399
|
}
|
|
400
|
+
var isCurrentTableSelected = tableRef === tree.table;
|
|
475
401
|
|
|
476
|
-
//
|
|
477
|
-
|
|
402
|
+
// If current table selected and header row is toggled off, turn off sticky header
|
|
403
|
+
if (isCurrentTableSelected && !state.isHeaderRowEnabled && tree) {
|
|
404
|
+
this.makeRowHeaderNotSticky(tree.table);
|
|
405
|
+
}
|
|
406
|
+
this.focused = isCurrentTableSelected;
|
|
407
|
+
var wrapper = tree.wrapper;
|
|
408
|
+
var tableContainer = wrapper.parentElement;
|
|
409
|
+
var tableContentWrapper = tableContainer.parentElement;
|
|
410
|
+
var layoutContainer = tableContentWrapper && tableContentWrapper.parentElement;
|
|
411
|
+
if (isCurrentTableSelected) {
|
|
412
|
+
this.colControlsOffset = _consts.tableControlsSpacing;
|
|
413
|
+
if (layoutContainer && layoutContainer.getAttribute('data-layout-content')) {
|
|
414
|
+
// move table a little out of the way
|
|
415
|
+
// to provide spacing for table controls
|
|
416
|
+
tableContentWrapper.style.paddingLeft = '11px';
|
|
417
|
+
}
|
|
418
|
+
} else {
|
|
419
|
+
this.colControlsOffset = 0;
|
|
420
|
+
if (layoutContainer && layoutContainer.getAttribute('data-layout-content')) {
|
|
421
|
+
tableContentWrapper.style.removeProperty('padding-left');
|
|
422
|
+
}
|
|
423
|
+
}
|
|
478
424
|
|
|
479
|
-
//
|
|
480
|
-
|
|
481
|
-
|
|
425
|
+
// run after table style changes have been committed
|
|
426
|
+
setTimeout(function () {
|
|
427
|
+
(0, _dom.syncStickyRowToTable)(tree.table);
|
|
428
|
+
}, 0);
|
|
429
|
+
}
|
|
430
|
+
}, {
|
|
431
|
+
key: "updateStickyHeaderWidth",
|
|
432
|
+
value: function updateStickyHeaderWidth() {
|
|
433
|
+
// table width might have changed, sync that back to sticky row
|
|
434
|
+
var tree = (0, _dom2.getTree)(this.dom);
|
|
435
|
+
if (!tree) {
|
|
436
|
+
return;
|
|
482
437
|
}
|
|
438
|
+
(0, _dom.syncStickyRowToTable)(tree.table);
|
|
439
|
+
}
|
|
483
440
|
|
|
484
|
-
|
|
441
|
+
/**
|
|
442
|
+
* Manually refire the intersection observers.
|
|
443
|
+
* Useful when the header may have detached from the table.
|
|
444
|
+
*/
|
|
445
|
+
}, {
|
|
446
|
+
key: "refireIntersectionObservers",
|
|
447
|
+
value: function refireIntersectionObservers() {
|
|
448
|
+
var _this5 = this;
|
|
449
|
+
if (this.isSticky) {
|
|
450
|
+
[this.sentinels.top, this.sentinels.bottom].forEach(function (el) {
|
|
451
|
+
if (el && _this5.intersectionObserver) {
|
|
452
|
+
_this5.intersectionObserver.unobserve(el);
|
|
453
|
+
_this5.intersectionObserver.observe(el);
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}, {
|
|
459
|
+
key: "makeHeaderRowSticky",
|
|
460
|
+
value: function makeHeaderRowSticky(tree, scrollTop) {
|
|
461
|
+
var _tbody$firstChild,
|
|
462
|
+
_this6 = this;
|
|
463
|
+
// If header row height is more than 50% of viewport height don't do this
|
|
464
|
+
if (this.isSticky || this.stickyRowHeight && this.stickyRowHeight > window.innerHeight / 2) {
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
var table = tree.table,
|
|
468
|
+
wrapper = tree.wrapper;
|
|
469
|
+
|
|
470
|
+
// ED-16035 Make sure sticky header is only applied to first row
|
|
485
471
|
var tbody = this.dom.parentElement;
|
|
486
|
-
var
|
|
487
|
-
|
|
488
|
-
|
|
472
|
+
var isFirstHeader = tbody === null || tbody === void 0 || (_tbody$firstChild = tbody.firstChild) === null || _tbody$firstChild === void 0 ? void 0 : _tbody$firstChild.isEqualNode(this.dom);
|
|
473
|
+
if (!isFirstHeader) {
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
var currentTableTop = this.getCurrentTableTop(tree);
|
|
477
|
+
if (!scrollTop) {
|
|
478
|
+
scrollTop = (0, _dom2.getTop)(this.editorScrollableElement);
|
|
479
|
+
}
|
|
480
|
+
var domTop = currentTableTop > 0 ? scrollTop : scrollTop + currentTableTop;
|
|
481
|
+
if (!this.isSticky) {
|
|
482
|
+
var _this$editorScrollabl;
|
|
483
|
+
(0, _dom.syncStickyRowToTable)(table);
|
|
484
|
+
this.dom.classList.add('sticky');
|
|
485
|
+
table.classList.add(_types.TableCssClassName.TABLE_STICKY);
|
|
486
|
+
this.isSticky = true;
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* The logic below is not desirable, but acts as a fail safe for scenarios where the sticky header
|
|
490
|
+
* detaches from the table. This typically happens during a fast scroll by the user which causes
|
|
491
|
+
* the intersection observer logic to not fire as expected.
|
|
492
|
+
*/
|
|
493
|
+
(_this$editorScrollabl = this.editorScrollableElement) === null || _this$editorScrollabl === void 0 || _this$editorScrollabl.addEventListener('scrollend', this.refireIntersectionObservers, {
|
|
494
|
+
passive: true,
|
|
495
|
+
once: true
|
|
496
|
+
});
|
|
497
|
+
var fastScrollThresholdMs = 500;
|
|
498
|
+
setTimeout(function () {
|
|
499
|
+
_this6.refireIntersectionObservers();
|
|
500
|
+
}, fastScrollThresholdMs);
|
|
501
|
+
}
|
|
502
|
+
this.dom.style.top = "".concat(domTop, "px");
|
|
503
|
+
(0, _dom.updateStickyMargins)(table);
|
|
504
|
+
this.dom.scrollLeft = wrapper.scrollLeft;
|
|
505
|
+
this.emitOn(domTop, this.colControlsOffset);
|
|
489
506
|
}
|
|
490
507
|
}, {
|
|
491
|
-
key: "
|
|
492
|
-
value: function
|
|
493
|
-
|
|
494
|
-
if (this.
|
|
495
|
-
|
|
508
|
+
key: "makeRowHeaderNotSticky",
|
|
509
|
+
value: function makeRowHeaderNotSticky(table) {
|
|
510
|
+
var isEditorDestroyed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
511
|
+
if (!this.isSticky || !table || !this.dom) {
|
|
512
|
+
return;
|
|
496
513
|
}
|
|
497
|
-
this.
|
|
514
|
+
this.dom.style.removeProperty('width');
|
|
515
|
+
this.dom.classList.remove('sticky');
|
|
516
|
+
table.classList.remove(_types.TableCssClassName.TABLE_STICKY);
|
|
517
|
+
this.isSticky = false;
|
|
518
|
+
this.dom.style.top = '';
|
|
519
|
+
table.style.removeProperty('margin-top');
|
|
520
|
+
this.emitOff(isEditorDestroyed);
|
|
498
521
|
}
|
|
499
522
|
}, {
|
|
500
|
-
key: "
|
|
501
|
-
value: function
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
523
|
+
key: "getWrapperoffset",
|
|
524
|
+
value: function getWrapperoffset() {
|
|
525
|
+
var inverse = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
526
|
+
var focusValue = inverse ? !this.focused : this.focused;
|
|
527
|
+
return focusValue ? 0 : _consts.tableControlsSpacing;
|
|
528
|
+
}
|
|
529
|
+
}, {
|
|
530
|
+
key: "getWrapperRefTop",
|
|
531
|
+
value: function getWrapperRefTop(wrapper) {
|
|
532
|
+
return Math.round((0, _dom2.getTop)(wrapper)) + this.getWrapperoffset();
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
// TODO: rename!
|
|
536
|
+
}, {
|
|
537
|
+
key: "getScrolledTableTop",
|
|
538
|
+
value: function getScrolledTableTop(wrapper) {
|
|
539
|
+
return this.getWrapperRefTop(wrapper) - this.topPosEditorElement;
|
|
540
|
+
}
|
|
541
|
+
}, {
|
|
542
|
+
key: "getCurrentTableTop",
|
|
543
|
+
value: function getCurrentTableTop(tree) {
|
|
544
|
+
return this.getScrolledTableTop(tree.wrapper) + tree.table.clientHeight;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/* emit external events */
|
|
548
|
+
}, {
|
|
549
|
+
key: "emitOn",
|
|
550
|
+
value: function emitOn(top, padding) {
|
|
551
|
+
if (top === this.top && padding === this.padding) {
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
this.top = top;
|
|
555
|
+
this.padding = padding;
|
|
556
|
+
var pos = this.getPos();
|
|
557
|
+
if (Number.isFinite(pos)) {
|
|
558
|
+
(0, _commands.updateStickyState)({
|
|
559
|
+
pos: pos,
|
|
560
|
+
top: top,
|
|
561
|
+
sticky: true,
|
|
562
|
+
padding: padding
|
|
563
|
+
})(this.view.state, this.view.dispatch, this.view);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}, {
|
|
567
|
+
key: "emitOff",
|
|
568
|
+
value: function emitOff(isEditorDestroyed) {
|
|
569
|
+
if (this.top === 0 && this.padding === 0) {
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
this.top = 0;
|
|
573
|
+
this.padding = 0;
|
|
574
|
+
var pos = this.getPos();
|
|
575
|
+
if (!isEditorDestroyed && Number.isFinite(pos)) {
|
|
576
|
+
(0, _commands.updateStickyState)({
|
|
577
|
+
pos: pos,
|
|
578
|
+
sticky: false,
|
|
579
|
+
top: this.top,
|
|
580
|
+
padding: this.padding
|
|
581
|
+
})(this.view.state, this.view.dispatch, this.view);
|
|
521
582
|
}
|
|
522
|
-
return true;
|
|
523
583
|
}
|
|
524
584
|
}]);
|
|
525
|
-
return
|
|
526
|
-
}();
|
|
585
|
+
return TableRow;
|
|
586
|
+
}(_TableNodeViewBase.default);
|