@atlaskit/editor-plugin-table 19.0.1 → 21.0.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 +47 -0
- package/dist/cjs/nodeviews/TableComponent.js +2 -2
- package/dist/cjs/nodeviews/TableResizer.js +2 -2
- package/dist/cjs/nodeviews/table.js +18 -2
- package/dist/cjs/nodeviews/toDOM.js +18 -4
- package/dist/cjs/pm-plugins/main.js +38 -4
- package/dist/cjs/pm-plugins/table-width.js +10 -0
- package/dist/cjs/pm-plugins/transforms/content-mode.js +48 -0
- package/dist/cjs/pm-plugins/transforms/fix-tables.js +4 -35
- package/dist/cjs/pm-plugins/transforms/table-transform-utils.js +62 -0
- package/dist/cjs/pm-plugins/utils/decoration.js +2 -2
- package/dist/cjs/pm-plugins/utils/tableMode.js +149 -0
- package/dist/cjs/pm-plugins/view-mode-sort/index.js +2 -2
- package/dist/cjs/ui/ColumnResizeWidget/index.js +2 -2
- package/dist/cjs/ui/DragHandle/index.js +2 -2
- package/dist/cjs/ui/FloatingContextualButton/index.js +2 -2
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +2 -2
- package/dist/cjs/ui/FloatingDeleteButton/DeleteButton.js +2 -2
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/cjs/ui/FloatingInsertButton/InsertButton.js +3 -3
- package/dist/cjs/ui/FloatingInsertButton/index.js +2 -2
- package/dist/cjs/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +2 -2
- package/dist/cjs/ui/TableFloatingControls/CornerControls/DragCornerControls.js +3 -3
- package/dist/cjs/ui/TableFloatingControls/RowControls/ClassicControls.js +2 -2
- package/dist/cjs/ui/TableFullWidthLabel/index.js +2 -2
- package/dist/cjs/ui/event-handlers.js +3 -2
- package/dist/cjs/ui/toolbar.js +25 -2
- package/dist/es2019/nodeviews/TableComponent.js +1 -1
- package/dist/es2019/nodeviews/TableResizer.js +1 -1
- package/dist/es2019/nodeviews/table.js +18 -2
- package/dist/es2019/nodeviews/toDOM.js +18 -4
- package/dist/es2019/pm-plugins/main.js +38 -4
- package/dist/es2019/pm-plugins/table-width.js +10 -0
- package/dist/es2019/pm-plugins/transforms/content-mode.js +39 -0
- package/dist/es2019/pm-plugins/transforms/fix-tables.js +2 -33
- package/dist/es2019/pm-plugins/transforms/table-transform-utils.js +56 -0
- package/dist/es2019/pm-plugins/utils/decoration.js +1 -1
- package/dist/es2019/pm-plugins/utils/tableMode.js +148 -0
- package/dist/es2019/pm-plugins/view-mode-sort/index.js +1 -1
- package/dist/es2019/ui/ColumnResizeWidget/index.js +1 -1
- package/dist/es2019/ui/DragHandle/index.js +1 -1
- package/dist/es2019/ui/FloatingContextualButton/index.js +1 -1
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
- package/dist/es2019/ui/FloatingDeleteButton/DeleteButton.js +1 -1
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +1 -1
- package/dist/es2019/ui/FloatingInsertButton/InsertButton.js +1 -1
- package/dist/es2019/ui/FloatingInsertButton/index.js +1 -1
- package/dist/es2019/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +1 -1
- package/dist/es2019/ui/TableFloatingControls/CornerControls/DragCornerControls.js +1 -1
- package/dist/es2019/ui/TableFloatingControls/RowControls/ClassicControls.js +1 -1
- package/dist/es2019/ui/TableFullWidthLabel/index.js +1 -1
- package/dist/es2019/ui/event-handlers.js +4 -3
- package/dist/es2019/ui/toolbar.js +23 -2
- package/dist/esm/nodeviews/TableComponent.js +1 -1
- package/dist/esm/nodeviews/TableResizer.js +1 -1
- package/dist/esm/nodeviews/table.js +18 -2
- package/dist/esm/nodeviews/toDOM.js +18 -4
- package/dist/esm/pm-plugins/main.js +38 -4
- package/dist/esm/pm-plugins/table-width.js +10 -0
- package/dist/esm/pm-plugins/transforms/content-mode.js +41 -0
- package/dist/esm/pm-plugins/transforms/fix-tables.js +2 -33
- package/dist/esm/pm-plugins/transforms/table-transform-utils.js +56 -0
- package/dist/esm/pm-plugins/utils/decoration.js +1 -1
- package/dist/esm/pm-plugins/utils/tableMode.js +143 -0
- package/dist/esm/pm-plugins/view-mode-sort/index.js +1 -1
- package/dist/esm/ui/ColumnResizeWidget/index.js +1 -1
- package/dist/esm/ui/DragHandle/index.js +1 -1
- package/dist/esm/ui/FloatingContextualButton/index.js +1 -1
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
- package/dist/esm/ui/FloatingDeleteButton/DeleteButton.js +1 -1
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +1 -1
- package/dist/esm/ui/FloatingInsertButton/InsertButton.js +1 -1
- package/dist/esm/ui/FloatingInsertButton/index.js +1 -1
- package/dist/esm/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +1 -1
- package/dist/esm/ui/TableFloatingControls/CornerControls/DragCornerControls.js +1 -1
- package/dist/esm/ui/TableFloatingControls/RowControls/ClassicControls.js +1 -1
- package/dist/esm/ui/TableFullWidthLabel/index.js +1 -1
- package/dist/esm/ui/event-handlers.js +4 -3
- package/dist/esm/ui/toolbar.js +25 -2
- package/dist/types/nodeviews/TableComponent.d.ts +2 -2
- package/dist/types/pm-plugins/commands/column-resize.d.ts +1 -1
- package/dist/types/pm-plugins/commands/commands-with-analytics.d.ts +1 -1
- package/dist/types/pm-plugins/commands/go-to-next-cell.d.ts +1 -1
- package/dist/types/pm-plugins/commands/selection.d.ts +1 -1
- package/dist/types/pm-plugins/decorations/utils/column-resizing.d.ts +1 -1
- package/dist/types/pm-plugins/drag-and-drop/commands-with-analytics.d.ts +1 -1
- package/dist/types/pm-plugins/keymap.d.ts +1 -1
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/pm-plugins/table-selection-keymap.d.ts +1 -1
- package/dist/types/pm-plugins/transforms/content-mode.d.ts +8 -0
- package/dist/types/pm-plugins/transforms/table-transform-utils.d.ts +11 -0
- package/dist/types/pm-plugins/utils/decoration.d.ts +1 -1
- package/dist/types/pm-plugins/utils/table.d.ts +1 -1
- package/dist/types/pm-plugins/utils/tableMode.d.ts +22 -0
- package/dist/types/types/index.d.ts +4 -1
- package/dist/types/ui/DragHandle/index.d.ts +2 -2
- package/dist/types/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -2
- package/dist/types/ui/FloatingDeleteButton/DeleteButton.d.ts +2 -2
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +2 -2
- package/dist/types/ui/FloatingInsertButton/InsertButton.d.ts +3 -3
- package/dist/types/ui/FloatingInsertButton/index.d.ts +2 -2
- package/dist/types/ui/TableFloatingControls/CornerControls/ClassicCornerControls.d.ts +2 -2
- package/dist/types/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +3 -3
- package/dist/types/ui/TableFloatingControls/RowControls/ClassicControls.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/commands/column-resize.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/commands/commands-with-analytics.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/commands/go-to-next-cell.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/commands/selection.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/decorations/utils/column-resizing.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/commands-with-analytics.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-selection-keymap.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/transforms/content-mode.d.ts +8 -0
- package/dist/types-ts4.5/pm-plugins/transforms/table-transform-utils.d.ts +11 -0
- package/dist/types-ts4.5/pm-plugins/utils/decoration.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/utils/table.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/utils/tableMode.d.ts +22 -0
- package/dist/types-ts4.5/types/index.d.ts +4 -1
- package/dist/types-ts4.5/ui/DragHandle/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -2
- package/dist/types-ts4.5/ui/FloatingDeleteButton/DeleteButton.d.ts +2 -2
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +2 -2
- package/dist/types-ts4.5/ui/FloatingInsertButton/InsertButton.d.ts +3 -3
- package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/ClassicCornerControls.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +3 -3
- package/dist/types-ts4.5/ui/TableFloatingControls/RowControls/ClassicControls.d.ts +2 -2
- package/package.json +25 -21
- package/report.api.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 21.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [`901c87a57486e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/901c87a57486e) -
|
|
8
|
+
Removed `react-intl-next` alias and replaced all usages with `react-intl` directly.
|
|
9
|
+
|
|
10
|
+
What changed: The `react-intl-next` npm alias (which resolved to `react-intl@^5`) has been
|
|
11
|
+
removed. All imports now reference `react-intl` directly, and `peerDependencies` have been updated
|
|
12
|
+
to `"^5.25.1 || ^6.0.0 || ^7.0.0"`.
|
|
13
|
+
|
|
14
|
+
How consumer should update their code: Ensure `react-intl` is installed at a version satisfying
|
|
15
|
+
`^5.25.1 || ^6.0.0 || ^7.0.0`. If your application was using `react-intl-next` as an npm alias, it
|
|
16
|
+
can be safely removed. Replace any remaining `react-intl-next` imports with `react-intl`.
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
22
|
+
## 20.0.0
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- [`b10c935ca9497`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b10c935ca9497) -
|
|
27
|
+
Removed deprecated `browser` singleton from editor-common. This has been replaced with a
|
|
28
|
+
`getBrowserInfo` function that returns the same information. This change was made to avoid issues
|
|
29
|
+
with module loading order and to provide a more consistent API for accessing browser information.
|
|
30
|
+
|
|
31
|
+
Please update any imports of `browser` to use `getBrowserInfo` instead. For example, the following
|
|
32
|
+
imports have been removed:
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
import { browser } from '@atlaskit/editor-common/utils';
|
|
36
|
+
import { browser } from '@atlaskit/editor-common/browser';
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Instead, please use:
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
import { getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
If you were previously using `browser.ie_version`, you would now use
|
|
46
|
+
`getBrowserInfo().ie_version`.
|
|
47
|
+
|
|
48
|
+
- Updated dependencies
|
|
49
|
+
|
|
3
50
|
## 19.0.1
|
|
4
51
|
|
|
5
52
|
### Patch Changes
|
|
@@ -15,7 +15,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
15
15
|
var _react = _interopRequireDefault(require("react"));
|
|
16
16
|
var _classnames2 = _interopRequireDefault(require("classnames"));
|
|
17
17
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
18
|
-
var
|
|
18
|
+
var _reactIntl = require("react-intl");
|
|
19
19
|
var _browser = require("@atlaskit/editor-common/browser");
|
|
20
20
|
var _collab = require("@atlaskit/editor-common/collab");
|
|
21
21
|
var _nesting = require("@atlaskit/editor-common/nesting");
|
|
@@ -993,4 +993,4 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
993
993
|
}]);
|
|
994
994
|
}(_react.default.Component);
|
|
995
995
|
(0, _defineProperty2.default)(TableComponent, "displayName", 'TableComponent');
|
|
996
|
-
var _default = exports.default = (0,
|
|
996
|
+
var _default = exports.default = (0, _reactIntl.injectIntl)(TableComponent);
|
|
@@ -10,7 +10,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
13
|
-
var
|
|
13
|
+
var _reactIntl = require("react-intl");
|
|
14
14
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
15
15
|
var _browser = require("@atlaskit/editor-common/browser");
|
|
16
16
|
var _guideline = require("@atlaskit/editor-common/guideline");
|
|
@@ -159,7 +159,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
159
159
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
160
160
|
snappingEnabled = _useState2[0],
|
|
161
161
|
setSnappingEnabled = _useState2[1];
|
|
162
|
-
var _useIntl = (0,
|
|
162
|
+
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
163
163
|
formatMessage = _useIntl.formatMessage;
|
|
164
164
|
var currentSelection = (_editorView$state = editorView.state) === null || _editorView$state === void 0 ? void 0 : _editorView$state.selection;
|
|
165
165
|
var tableFromSelection = (0, _react.useMemo)(function () {
|
|
@@ -22,10 +22,12 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
|
22
22
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
23
23
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
24
24
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
25
|
+
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
25
26
|
var _createPluginConfig = require("../pm-plugins/create-plugin-config");
|
|
26
27
|
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
27
28
|
var _tableWidth = require("../pm-plugins/table-width");
|
|
28
29
|
var _nodes = require("../pm-plugins/utils/nodes");
|
|
30
|
+
var _tableMode = require("../pm-plugins/utils/tableMode");
|
|
29
31
|
var _TableComponentWithSharedState = require("./TableComponentWithSharedState");
|
|
30
32
|
var _toDOM = require("./toDOM");
|
|
31
33
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
@@ -205,7 +207,7 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
205
207
|
key: "setDomAttrs",
|
|
206
208
|
value: function setDomAttrs(node) {
|
|
207
209
|
var _this3 = this,
|
|
208
|
-
_this$
|
|
210
|
+
_this$reactComponentP8,
|
|
209
211
|
_this$getEditorFeatur2,
|
|
210
212
|
_this$options3,
|
|
211
213
|
_this$options4;
|
|
@@ -213,12 +215,26 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
213
215
|
return; // width / attribute application to actual table will happen later when table is set
|
|
214
216
|
}
|
|
215
217
|
var attrs = tableAttributes(node);
|
|
218
|
+
if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true)) {
|
|
219
|
+
var _this$reactComponentP6, _this$reactComponentP7;
|
|
220
|
+
if ((0, _tableMode.isTableInContentMode)({
|
|
221
|
+
node: node,
|
|
222
|
+
allowColumnResizing: !!this.reactComponentProps.allowColumnResizing,
|
|
223
|
+
allowTableResizing: !!this.reactComponentProps.allowTableResizing,
|
|
224
|
+
isFullPageEditor: !((_this$reactComponentP6 = this.reactComponentProps.options) !== null && _this$reactComponentP6 !== void 0 && _this$reactComponentP6.isCommentEditor) && !((_this$reactComponentP7 = this.reactComponentProps.options) !== null && _this$reactComponentP7 !== void 0 && _this$reactComponentP7.isChromelessEditor),
|
|
225
|
+
isTableNested: (0, _nodes.isTableNested)(this.view.state, this.getPos())
|
|
226
|
+
}) && (0, _expValEquals.expValEquals)('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true)) {
|
|
227
|
+
attrs['data-initial-width-mode'] = 'content';
|
|
228
|
+
} else {
|
|
229
|
+
this.table.removeAttribute('data-initial-width-mode');
|
|
230
|
+
}
|
|
231
|
+
}
|
|
216
232
|
Object.keys(attrs).forEach(function (attr) {
|
|
217
233
|
// Ignored via go/ees005
|
|
218
234
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
219
235
|
_this3.table.setAttribute(attr, attrs[attr]);
|
|
220
236
|
});
|
|
221
|
-
var isTableFixedColumnWidthsOptionEnabled = ((0, _platformFeatureFlags.fg)('platform_editor_table_fixed_column_width_prop') ? (_this$
|
|
237
|
+
var isTableFixedColumnWidthsOptionEnabled = ((0, _platformFeatureFlags.fg)('platform_editor_table_fixed_column_width_prop') ? (_this$reactComponentP8 = this.reactComponentProps) === null || _this$reactComponentP8 === void 0 ? void 0 : _this$reactComponentP8.allowFixedColumnWidthOption : (_this$getEditorFeatur2 = this.getEditorFeatureFlags) === null || _this$getEditorFeatur2 === void 0 ? void 0 : _this$getEditorFeatur2.call(this).tableWithFixedColumnWidthsOption) || false;
|
|
222
238
|
// Preserve Table Width cannot have inline width set on the table
|
|
223
239
|
if (!((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.isTableScalingEnabled) || (_this$options4 = this.options) !== null && _this$options4 !== void 0 && _this$options4.isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled && node.attrs.displayMode === 'fixed') {
|
|
224
240
|
var _tableWidthPluginKey$;
|
|
@@ -8,6 +8,7 @@ exports.tableNodeSpecWithFixedToDOM = void 0;
|
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
12
|
var _kebabCase = _interopRequireDefault(require("lodash/kebabCase"));
|
|
12
13
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
13
14
|
var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
|
|
@@ -15,6 +16,7 @@ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
|
15
16
|
var _colgroup = require("../pm-plugins/table-resizing/utils/colgroup");
|
|
16
17
|
var _consts = require("../pm-plugins/table-resizing/utils/consts");
|
|
17
18
|
var _misc = require("../pm-plugins/table-resizing/utils/misc");
|
|
19
|
+
var _tableMode = require("../pm-plugins/utils/tableMode");
|
|
18
20
|
var _tableContainerStyles = require("./table-container-styles");
|
|
19
21
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
20
22
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -22,6 +24,14 @@ var tableNodeSpecWithFixedToDOM = exports.tableNodeSpecWithFixedToDOM = function
|
|
|
22
24
|
var tableNode = config.isNestingSupported ? _adfSchema.tableWithNestedTable : _adfSchema.table;
|
|
23
25
|
return _objectSpread(_objectSpread({}, tableNode), {}, {
|
|
24
26
|
toDOM: function toDOM(node) {
|
|
27
|
+
var isFullPageEditor = !config.isChromelessEditor && !config.isCommentEditor;
|
|
28
|
+
var isInContentMode = (0, _tableMode.isTableInContentMode)({
|
|
29
|
+
node: node,
|
|
30
|
+
allowColumnResizing: config.allowColumnResizing,
|
|
31
|
+
allowTableResizing: config.tableResizingEnabled,
|
|
32
|
+
isFullPageEditor: isFullPageEditor,
|
|
33
|
+
isTableNested: config.isNested
|
|
34
|
+
}) && (0, _expValEquals.expValEquals)('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true);
|
|
25
35
|
var alignmentStyle = Object.entries((0, _tableContainerStyles.getAlignmentStyle)(node.attrs.layout)).map(function (_ref) {
|
|
26
36
|
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
27
37
|
k = _ref2[0],
|
|
@@ -29,7 +39,6 @@ var tableNodeSpecWithFixedToDOM = exports.tableNodeSpecWithFixedToDOM = function
|
|
|
29
39
|
return "".concat((0, _kebabCase.default)(k), ": ").concat((0, _kebabCase.default)(v));
|
|
30
40
|
}).join(';');
|
|
31
41
|
var tableMinWidth = (0, _colgroup.getResizerMinWidth)(node);
|
|
32
|
-
var isFullPageEditor = !config.isChromelessEditor && !config.isCommentEditor;
|
|
33
42
|
var attrs = {
|
|
34
43
|
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
35
44
|
'data-layout': node.attrs.layout,
|
|
@@ -39,6 +48,9 @@ var tableNodeSpecWithFixedToDOM = exports.tableNodeSpecWithFixedToDOM = function
|
|
|
39
48
|
'data-ssr-placeholder': "table-".concat(node.attrs.localId),
|
|
40
49
|
'data-ssr-placeholder-replace': "table-".concat(node.attrs.localId)
|
|
41
50
|
};
|
|
51
|
+
if (isInContentMode) {
|
|
52
|
+
attrs['data-initial-width-mode'] = 'content';
|
|
53
|
+
}
|
|
42
54
|
if ((0, _expValEquals.expValEquals)('platform_editor_table_display_mode_in_to_dom', 'isEnabled', true)) {
|
|
43
55
|
attrs['data-table-display-mode'] = node.attrs.displayMode;
|
|
44
56
|
}
|
|
@@ -91,11 +103,13 @@ var tableNodeSpecWithFixedToDOM = exports.tableNodeSpecWithFixedToDOM = function
|
|
|
91
103
|
class: 'pm-table-resizer-container',
|
|
92
104
|
style: (0, _lazyNodeView.convertToInlineCss)({
|
|
93
105
|
'--ak-editor-table-gutter-padding': config.isTableScalingEnabled ? 'calc(var(--ak-editor--large-gutter-padding) * 2)' : 'calc(var(--ak-editor--large-gutter-padding) * 2 - var(--ak-editor-resizer-handle-spacing))',
|
|
94
|
-
'--ak-editor-table-width': resizableTableWidth,
|
|
106
|
+
'--ak-editor-table-width': isInContentMode ? 'max-content' : resizableTableWidth,
|
|
95
107
|
width: "var(--ak-editor-table-width)"
|
|
96
108
|
})
|
|
97
109
|
}, ['div', {
|
|
98
|
-
class: 'resizer-item display-handle',
|
|
110
|
+
class: (0, _expValEquals.expValEquals)('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true) ? 'resizer-item display-handle' : (0, _classnames.default)('resizer-item', {
|
|
111
|
+
'display-handle': !isInContentMode
|
|
112
|
+
}),
|
|
99
113
|
style: (0, _lazyNodeView.convertToInlineCss)({
|
|
100
114
|
position: 'relative',
|
|
101
115
|
userSelect: 'auto',
|
|
@@ -104,7 +118,7 @@ var tableNodeSpecWithFixedToDOM = exports.tableNodeSpecWithFixedToDOM = function
|
|
|
104
118
|
'--ak-editor-table-min-width': "".concat(tableMinWidth, "px"),
|
|
105
119
|
minWidth: 'var(--ak-editor-table-min-width)',
|
|
106
120
|
maxWidth: (0, _misc.getTableResizerContainerMaxWidthInCSS)(config.isCommentEditor, config.isChromelessEditor, config.isTableScalingEnabled),
|
|
107
|
-
width: (0, _misc.getTableResizerItemWidthInCSS)(node, config.isCommentEditor, config.isChromelessEditor)
|
|
121
|
+
width: isInContentMode ? 'auto' : (0, _misc.getTableResizerItemWidthInCSS)(node, config.isCommentEditor, config.isChromelessEditor)
|
|
108
122
|
})
|
|
109
123
|
}, ['span', {
|
|
110
124
|
class: 'resizer-hover-zone'
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.createPlugin = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _bindEventListener = require("bind-event-listener");
|
|
9
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
11
|
var _browser = require("@atlaskit/editor-common/browser");
|
|
11
12
|
var _coreUtils = require("@atlaskit/editor-common/core-utils");
|
|
@@ -32,12 +33,15 @@ var _fixTables = require("./transforms/fix-tables");
|
|
|
32
33
|
var _replaceTable = require("./transforms/replace-table");
|
|
33
34
|
var _decoration = require("./utils/decoration");
|
|
34
35
|
var _paste = require("./utils/paste");
|
|
36
|
+
var _tableMode = require("./utils/tableMode");
|
|
35
37
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
36
38
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
37
39
|
var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, nodeViewPortalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, fullWidthModeEnabled, previousFullWidthModeEnabled, dragAndDropEnabled, editorAnalyticsAPI, pluginInjectionApi, isTableScalingEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor, allowFixedColumnWidthOption) {
|
|
38
40
|
var _accessibilityUtils;
|
|
39
41
|
var state = (0, _pluginFactory.createPluginState)(dispatch, _objectSpread(_objectSpread(_objectSpread({
|
|
40
42
|
pluginConfig: pluginConfig,
|
|
43
|
+
isCommentEditor: isCommentEditor,
|
|
44
|
+
isChromelessEditor: isChromelessEditor,
|
|
41
45
|
isTableHovered: false,
|
|
42
46
|
insertColumnButtonIndex: undefined,
|
|
43
47
|
insertRowButtonIndex: undefined,
|
|
@@ -132,8 +136,34 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
132
136
|
}
|
|
133
137
|
},
|
|
134
138
|
view: function view(editorView) {
|
|
139
|
+
var _pluginInjectionApi$e;
|
|
135
140
|
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
136
141
|
editorViewRef = editorView;
|
|
142
|
+
var contentModeSizeTableId = null;
|
|
143
|
+
var focusListenerBinding = null;
|
|
144
|
+
if ((pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$e = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e === void 0 || (_pluginInjectionApi$e = _pluginInjectionApi$e.sharedState.currentState()) === null || _pluginInjectionApi$e === void 0 ? void 0 : _pluginInjectionApi$e.mode) !== 'view' && (0, _tableMode.isContentModeSupported)({
|
|
145
|
+
allowColumnResizing: !!pluginConfig.allowColumnResizing,
|
|
146
|
+
allowTableResizing: !!pluginConfig.allowTableResizing,
|
|
147
|
+
isFullPageEditor: !isChromelessEditor && !isCommentEditor
|
|
148
|
+
}) && (0, _expValEquals.expValEquals)('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true)) {
|
|
149
|
+
focusListenerBinding = (0, _bindEventListener.bind)(editorView.dom, {
|
|
150
|
+
type: 'focus',
|
|
151
|
+
listener: function listener() {
|
|
152
|
+
if (contentModeSizeTableId) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
contentModeSizeTableId = requestAnimationFrame(function () {
|
|
156
|
+
if (!editorViewRef) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
(0, _tableMode.applyMeasuredWidthToAllTables)(editorViewRef, pluginInjectionApi);
|
|
160
|
+
});
|
|
161
|
+
},
|
|
162
|
+
options: {
|
|
163
|
+
once: true
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
137
167
|
return {
|
|
138
168
|
update: function update(view, prevState) {
|
|
139
169
|
var state = view.state,
|
|
@@ -142,12 +172,12 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
142
172
|
var pluginState = (0, _pluginFactory.getPluginState)(state);
|
|
143
173
|
var tableRef;
|
|
144
174
|
if ((0, _platformFeatureFlags.fg)('platform_editor_enable_table_dnd')) {
|
|
145
|
-
var _pluginInjectionApi$
|
|
175
|
+
var _pluginInjectionApi$e2;
|
|
146
176
|
var parent = (0, _utils2.findParentDomRefOfType)(state.schema.nodes.table, domAtPos)(selection);
|
|
147
|
-
var shouldSetTableRef = (0, _platformFeatureFlags.fg)('platform_editor_enable_table_dnd_patch_1') ? parent && (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
177
|
+
var shouldSetTableRef = (0, _platformFeatureFlags.fg)('platform_editor_enable_table_dnd_patch_1') ? parent && (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$e2 = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e2 === void 0 || (_pluginInjectionApi$e2 = _pluginInjectionApi$e2.sharedState.currentState()) === null || _pluginInjectionApi$e2 === void 0 ? void 0 : _pluginInjectionApi$e2.mode) !== 'view' : parent;
|
|
148
178
|
if ((0, _expValEquals.expValEquals)('platform_editor_table_update_table_ref', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('platform_editor_update_table_ref_fix')) {
|
|
149
|
-
var _pluginInjectionApi$
|
|
150
|
-
shouldSetTableRef = parent && (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
179
|
+
var _pluginInjectionApi$e3, _pluginInjectionApi$i;
|
|
180
|
+
shouldSetTableRef = parent && (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$e3 = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e3 === void 0 || (_pluginInjectionApi$e3 = _pluginInjectionApi$e3.sharedState.currentState()) === null || _pluginInjectionApi$e3 === void 0 ? void 0 : _pluginInjectionApi$e3.mode) !== 'view' && (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$i = pluginInjectionApi.interaction) === null || _pluginInjectionApi$i === void 0 || (_pluginInjectionApi$i = _pluginInjectionApi$i.sharedState.currentState()) === null || _pluginInjectionApi$i === void 0 ? void 0 : _pluginInjectionApi$i.interactionState) !== 'hasNotHadInteraction';
|
|
151
181
|
}
|
|
152
182
|
if (shouldSetTableRef) {
|
|
153
183
|
tableRef =
|
|
@@ -209,6 +239,10 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
209
239
|
} else if (pluginState.isResizeHandleWidgetAdded) {
|
|
210
240
|
(0, _misc.removeResizeHandleDecorations)()(state, dispatch);
|
|
211
241
|
}
|
|
242
|
+
},
|
|
243
|
+
destroy: function destroy() {
|
|
244
|
+
contentModeSizeTableId && cancelAnimationFrame(contentModeSizeTableId);
|
|
245
|
+
focusListenerBinding && focusListenerBinding();
|
|
212
246
|
}
|
|
213
247
|
};
|
|
214
248
|
},
|
|
@@ -15,6 +15,7 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
|
15
15
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
16
16
|
var _consts = require("./table-resizing/utils/consts");
|
|
17
17
|
var _alignment = require("./utils/alignment");
|
|
18
|
+
var _tableMode = require("./utils/tableMode");
|
|
18
19
|
var _excluded = ["width"];
|
|
19
20
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
20
21
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /**
|
|
@@ -68,6 +69,15 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, dispat
|
|
|
68
69
|
var tr = newState.tr;
|
|
69
70
|
if (isReplaceDocumentOperation && !isCommentEditor) {
|
|
70
71
|
newState.doc.forEach(function (node, offset) {
|
|
72
|
+
if ((0, _tableMode.isTableInContentMode)({
|
|
73
|
+
node: node,
|
|
74
|
+
allowColumnResizing: true,
|
|
75
|
+
allowTableResizing: true,
|
|
76
|
+
isFullPageEditor: true,
|
|
77
|
+
isTableNested: false
|
|
78
|
+
})) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
71
81
|
if (node.type === table) {
|
|
72
82
|
var width = node.attrs.width;
|
|
73
83
|
var layout = node.attrs.layout;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getTableMeasurement = exports.applyTableMeasurement = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _styles = require("@atlaskit/editor-common/styles");
|
|
10
|
+
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
11
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
12
|
+
var _tableTransformUtils = require("./table-transform-utils");
|
|
13
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
|
+
var tableWidth = function tableWidth(contentWidth) {
|
|
16
|
+
var maxEditorWidth = (0, _expValEquals.expValEquals)('editor_tinymce_full_width_mode', 'isEnabled', true) || (0, _expValEquals.expValEquals)('confluence_max_width_content_appearance', 'isEnabled', true) ? _editorSharedStyles.akEditorMaxLayoutWidth : _editorSharedStyles.akEditorFullWidthLayoutWidth;
|
|
17
|
+
return Math.min(maxEditorWidth, contentWidth);
|
|
18
|
+
};
|
|
19
|
+
var getTableMeasurement = exports.getTableMeasurement = function getTableMeasurement(tableRef) {
|
|
20
|
+
var colWidths = getRenderedColgroupColumnWidths(tableRef);
|
|
21
|
+
var totalContentWidth = colWidths.reduce(function (acc, current) {
|
|
22
|
+
return acc + current;
|
|
23
|
+
}, 0);
|
|
24
|
+
return {
|
|
25
|
+
colWidths: colWidths,
|
|
26
|
+
tableWidth: tableWidth(totalContentWidth)
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
var applyTableMeasurement = exports.applyTableMeasurement = function applyTableMeasurement(tr, tableNode, _ref, tablePos) {
|
|
30
|
+
var colWidths = _ref.colWidths,
|
|
31
|
+
tableWidth = _ref.tableWidth;
|
|
32
|
+
tr = (0, _tableTransformUtils.updateCellsMarkup)(tr, tableNode, tablePos, function (cell, _rowIndex, colIndex) {
|
|
33
|
+
var newColWidths = colWidths.slice(colIndex, colIndex + cell.attrs.colspan);
|
|
34
|
+
return cell.type.createChecked(_objectSpread(_objectSpread({}, cell.attrs), {}, {
|
|
35
|
+
colwidth: newColWidths.length ? newColWidths : null
|
|
36
|
+
}), cell.content, cell.marks);
|
|
37
|
+
});
|
|
38
|
+
return tr.setNodeMarkup(tablePos, undefined, _objectSpread(_objectSpread({}, tableNode.attrs), {}, {
|
|
39
|
+
width: tableWidth
|
|
40
|
+
}));
|
|
41
|
+
};
|
|
42
|
+
function getRenderedColgroupColumnWidths(tableRef) {
|
|
43
|
+
var cols = Array.from(tableRef.querySelectorAll(':scope > colgroup > col'));
|
|
44
|
+
return cols.map(function (col) {
|
|
45
|
+
var width = col.getBoundingClientRect().width;
|
|
46
|
+
return Math.max(Math.round(width), _styles.tableCellMinWidth);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
@@ -11,6 +11,7 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
|
11
11
|
var _columnState = require("../table-resizing/utils/column-state");
|
|
12
12
|
var _contentWidth = require("../table-resizing/utils/content-width");
|
|
13
13
|
var _misc = require("../table-resizing/utils/misc");
|
|
14
|
+
var _tableTransformUtils = require("./table-transform-utils");
|
|
14
15
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15
16
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16
17
|
var validateTableCellNodeAttrs = function validateTableCellNodeAttrs(_ref, reportInvalidTableCellSpanAttrs) {
|
|
@@ -47,7 +48,7 @@ var validateTableCellNodeAttrs = function validateTableCellNodeAttrs(_ref, repor
|
|
|
47
48
|
// We remove the third width here, assumed duplicate content.
|
|
48
49
|
var removeExtraneousColumnWidths = exports.removeExtraneousColumnWidths = function removeExtraneousColumnWidths(node, basePos, tr, reportInvalidTableCellSpanAttrs) {
|
|
49
50
|
var hasProblems = false;
|
|
50
|
-
tr = replaceCells(tr, node, basePos, function (cell) {
|
|
51
|
+
tr = (0, _tableTransformUtils.replaceCells)(tr, node, basePos, function (cell) {
|
|
51
52
|
var _cell$attrs = cell.attrs,
|
|
52
53
|
colwidth = _cell$attrs.colwidth,
|
|
53
54
|
colspan = _cell$attrs.colspan,
|
|
@@ -117,7 +118,7 @@ var fixAutoSizedTable = exports.fixAutoSizedTable = function fixAutoSizedTable(v
|
|
|
117
118
|
var scaledColumnWidths = colWidths.map(function (width) {
|
|
118
119
|
return Math.floor(width * scale);
|
|
119
120
|
});
|
|
120
|
-
tr = replaceCells(tr, tableNode, tablePos, function (cell, _rowIndex, colIndex) {
|
|
121
|
+
tr = (0, _tableTransformUtils.replaceCells)(tr, tableNode, tablePos, function (cell, _rowIndex, colIndex) {
|
|
121
122
|
var newColWidths = scaledColumnWidths.slice(colIndex, colIndex + cell.attrs.colspan);
|
|
122
123
|
return cell.type.createChecked(_objectSpread(_objectSpread({}, cell.attrs), {}, {
|
|
123
124
|
colwidth: newColWidths.length ? newColWidths : null
|
|
@@ -160,36 +161,4 @@ function parseDOMColumnWidths(domAtPos, tableNode, tableStart, tableRef) {
|
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
163
|
return cols;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// TODO: ED-26961 - move to prosemirror-utils
|
|
166
|
-
var replaceCells = function replaceCells(tr, table, tablePos, modifyCell) {
|
|
167
|
-
var rows = [];
|
|
168
|
-
var modifiedCells = 0;
|
|
169
|
-
for (var rowIndex = 0; rowIndex < table.childCount; rowIndex++) {
|
|
170
|
-
var row = table.child(rowIndex);
|
|
171
|
-
var cells = [];
|
|
172
|
-
for (var colIndex = 0; colIndex < row.childCount; colIndex++) {
|
|
173
|
-
var cell = row.child(colIndex);
|
|
174
|
-
|
|
175
|
-
// TODO: ED-26961 - The rowIndex and colIndex are not accurate in a merged cell scenario
|
|
176
|
-
// e.g. table with 5 columns might have only one cell in a row, colIndex will be 1, where it should be 4
|
|
177
|
-
var node = modifyCell(cell, rowIndex, colIndex);
|
|
178
|
-
if (node.sameMarkup(cell) === false) {
|
|
179
|
-
modifiedCells++;
|
|
180
|
-
}
|
|
181
|
-
cells.push(node);
|
|
182
|
-
}
|
|
183
|
-
if (cells.length) {
|
|
184
|
-
rows.push(row.type.createChecked(row.attrs, cells, row.marks));
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// Check if the table has changed before replacing.
|
|
189
|
-
// If no cells are modified our counter will be zero.
|
|
190
|
-
if (rows.length && modifiedCells !== 0) {
|
|
191
|
-
var newTable = table.type.createChecked(table.attrs, rows, table.marks);
|
|
192
|
-
return tr.replaceWith(tablePos, tablePos + table.nodeSize, newTable);
|
|
193
|
-
}
|
|
194
|
-
return tr;
|
|
195
|
-
};
|
|
164
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.updateCellsMarkup = exports.replaceCells = void 0;
|
|
7
|
+
// TODO: ED-26961 - move to prosemirror-utils
|
|
8
|
+
var replaceCells = exports.replaceCells = function replaceCells(tr, table, tablePos, modifyCell) {
|
|
9
|
+
var rows = [];
|
|
10
|
+
var modifiedCells = 0;
|
|
11
|
+
for (var rowIndex = 0; rowIndex < table.childCount; rowIndex++) {
|
|
12
|
+
var row = table.child(rowIndex);
|
|
13
|
+
var cells = [];
|
|
14
|
+
for (var colIndex = 0; colIndex < row.childCount; colIndex++) {
|
|
15
|
+
var cell = row.child(colIndex);
|
|
16
|
+
|
|
17
|
+
// TODO: ED-26961 - The rowIndex and colIndex are not accurate in a merged cell scenario
|
|
18
|
+
// e.g. table with 5 columns might have only one cell in a row, colIndex will be 1, where it should be 4
|
|
19
|
+
var node = modifyCell(cell, rowIndex, colIndex);
|
|
20
|
+
if (node.sameMarkup(cell) === false) {
|
|
21
|
+
modifiedCells++;
|
|
22
|
+
}
|
|
23
|
+
cells.push(node);
|
|
24
|
+
}
|
|
25
|
+
if (cells.length) {
|
|
26
|
+
rows.push(row.type.createChecked(row.attrs, cells, row.marks));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Check if the table has changed before replacing.
|
|
31
|
+
// If no cells are modified our counter will be zero.
|
|
32
|
+
if (rows.length && modifiedCells !== 0) {
|
|
33
|
+
var newTable = table.type.createChecked(table.attrs, rows, table.marks);
|
|
34
|
+
return tr.replaceWith(tablePos, tablePos + table.nodeSize, newTable);
|
|
35
|
+
}
|
|
36
|
+
return tr;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Position-preserving alternative to `replaceCells`.
|
|
41
|
+
*
|
|
42
|
+
* Uses `setNodeMarkup` per cell instead of rebuilding the whole table with
|
|
43
|
+
* `replaceWith`, so document positions inside cells are never invalidated.
|
|
44
|
+
* This preserves any existing selection through `tr.mapping`.
|
|
45
|
+
*/
|
|
46
|
+
var updateCellsMarkup = exports.updateCellsMarkup = function updateCellsMarkup(tr, table, tablePos, modifyCell) {
|
|
47
|
+
var rowOffset = tablePos + 1;
|
|
48
|
+
for (var rowIndex = 0; rowIndex < table.childCount; rowIndex++) {
|
|
49
|
+
var row = table.child(rowIndex);
|
|
50
|
+
var cellOffset = rowOffset + 1;
|
|
51
|
+
for (var colIndex = 0; colIndex < row.childCount; colIndex++) {
|
|
52
|
+
var cell = row.child(colIndex);
|
|
53
|
+
var modified = modifyCell(cell, rowIndex, colIndex);
|
|
54
|
+
if (!modified.sameMarkup(cell)) {
|
|
55
|
+
tr.setNodeMarkup(cellOffset, modified.type, modified.attrs, modified.marks);
|
|
56
|
+
}
|
|
57
|
+
cellOffset += cell.nodeSize;
|
|
58
|
+
}
|
|
59
|
+
rowOffset += row.nodeSize;
|
|
60
|
+
}
|
|
61
|
+
return tr;
|
|
62
|
+
};
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.updateDecorations = exports.findControlsHoverDecoration = exports.findColumnControlSelectedDecoration = exports.createRowInsertLine = exports.createResizeHandleDecoration = exports.createControlsHoverDecoration = exports.createColumnSelectedDecoration = exports.createColumnLineResize = exports.createColumnInsertLine = exports.createColumnControlsDecoration = exports.createCellHoverDecoration = void 0;
|
|
8
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
9
|
var _react = require("react");
|
|
10
|
-
var
|
|
10
|
+
var _reactIntl = require("react-intl");
|
|
11
11
|
var _v = _interopRequireDefault(require("uuid/v4"));
|
|
12
12
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
13
13
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
@@ -277,7 +277,7 @@ var createResizeHandleDecoration = exports.createResizeHandleDecoration = functi
|
|
|
277
277
|
return _view.Decoration.widget(position, function () {
|
|
278
278
|
var element = document.createElement('div');
|
|
279
279
|
nodeViewPortalProviderAPI.render(function () {
|
|
280
|
-
return /*#__PURE__*/(0, _react.createElement)(
|
|
280
|
+
return /*#__PURE__*/(0, _react.createElement)(_reactIntl.RawIntlProvider, {
|
|
281
281
|
value: getIntl()
|
|
282
282
|
}, /*#__PURE__*/(0, _react.createElement)(_ColumnResizeWidget.ColumnResizeWidget, {
|
|
283
283
|
startIndex: cellColumnPositioning.left,
|