@atlaskit/editor-plugin-table 7.25.25 → 7.25.27
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 +19 -0
- package/dist/cjs/pm-plugins/main.js +6 -0
- package/dist/cjs/utils/paste.js +19 -2
- package/dist/es2019/pm-plugins/main.js +7 -1
- package/dist/es2019/utils/paste.js +19 -2
- package/dist/esm/pm-plugins/main.js +7 -1
- package/dist/esm/utils/paste.js +19 -2
- package/dist/types/utils/paste.d.ts +1 -0
- package/dist/types-ts4.5/utils/paste.d.ts +1 -0
- package/package.json +6 -6
- package/src/pm-plugins/main.ts +12 -1
- package/src/utils/paste.ts +17 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.25.27
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 7.25.26
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#137474](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/137474)
|
|
14
|
+
[`53c1e842c98c7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/53c1e842c98c7) -
|
|
15
|
+
ED-24840: Fix for pasting default table in comment losing width
|
|
16
|
+
- [#139334](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/139334)
|
|
17
|
+
[`30793649657c0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/30793649657c0) -
|
|
18
|
+
[HOT-111629] We had an incident where the last character disappears when hitting the enter key on
|
|
19
|
+
windows OS for Korean characters. Bumping to prosemirror-view@1.34.2 for the fix.
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 7.25.25
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -173,6 +173,12 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
173
173
|
if (!(0, _coreUtils.insideTable)(editorState) && (0, _paste.isHeaderRowRequired)(editorState)) {
|
|
174
174
|
slice = (0, _misc.transformSliceToAddTableHeaders)(slice, schema);
|
|
175
175
|
}
|
|
176
|
+
|
|
177
|
+
// fix for when pasting a table with default layout into comment editor
|
|
178
|
+
// table lose width and expand to full width
|
|
179
|
+
if (!(0, _coreUtils.insideTable)(editorState) && isCommentEditor && isTableAlignmentEnabled && isTableScalingEnabled) {
|
|
180
|
+
slice = (0, _paste.transformSliceTableLayoutDefaultToCenter)(slice, schema);
|
|
181
|
+
}
|
|
176
182
|
slice = (0, _utils4.transformSliceToFixHardBreakProblemOnCopyFromCell)(slice, schema);
|
|
177
183
|
|
|
178
184
|
// We do this separately, so it also applies to drag/drop events
|
package/dist/cjs/utils/paste.js
CHANGED
|
@@ -5,12 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.isHeaderRowRequired = isHeaderRowRequired;
|
|
8
|
-
exports.unwrapContentFromTable = exports.transformSliceToRemoveOpenTable = exports.transformSliceToFixHardBreakProblemOnCopyFromCell = exports.transformSliceToCorrectEmptyTableCells = exports.removeTableFromLastChild = exports.removeTableFromFirstChild = void 0;
|
|
8
|
+
exports.unwrapContentFromTable = exports.transformSliceToRemoveOpenTable = exports.transformSliceToFixHardBreakProblemOnCopyFromCell = exports.transformSliceToCorrectEmptyTableCells = exports.transformSliceTableLayoutDefaultToCenter = exports.removeTableFromLastChild = exports.removeTableFromFirstChild = void 0;
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
11
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
11
12
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
12
13
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
13
14
|
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
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; }
|
|
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; }
|
|
14
17
|
// lifts up the content of each cell, returning an array of nodes
|
|
15
18
|
var unwrapContentFromTable = exports.unwrapContentFromTable = function unwrapContentFromTable(maybeTable) {
|
|
16
19
|
var schema = maybeTable.type.schema;
|
|
@@ -113,4 +116,18 @@ var transformSliceToCorrectEmptyTableCells = exports.transformSliceToCorrectEmpt
|
|
|
113
116
|
function isHeaderRowRequired(state) {
|
|
114
117
|
var tableState = (0, _pluginFactory.getPluginState)(state);
|
|
115
118
|
return tableState && tableState.pluginConfig.isHeaderRowRequired;
|
|
116
|
-
}
|
|
119
|
+
}
|
|
120
|
+
var transformSliceTableLayoutDefaultToCenter = exports.transformSliceTableLayoutDefaultToCenter = function transformSliceTableLayoutDefaultToCenter(slice, schema) {
|
|
121
|
+
var table = schema.nodes.table;
|
|
122
|
+
var children = [];
|
|
123
|
+
(0, _utils.mapChildren)(slice.content, function (node) {
|
|
124
|
+
if (node.type === table && node.attrs.layout === 'default') {
|
|
125
|
+
children.push(table.createChecked(_objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
126
|
+
layout: 'center'
|
|
127
|
+
}), node.content, node.marks));
|
|
128
|
+
} else {
|
|
129
|
+
children.push(node);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
return new _model.Slice(_model.Fragment.fromArray(children), slice.openStart, slice.openEnd);
|
|
133
|
+
};
|
|
@@ -15,7 +15,7 @@ import { pluginKey as decorationsPluginKey } from '../pm-plugins/decorations/plu
|
|
|
15
15
|
import { fixTables, replaceSelectedTable } from '../transforms';
|
|
16
16
|
import { TableCssClassName as ClassName } from '../types';
|
|
17
17
|
import { findControlsHoverDecoration, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell, transformSliceToRemoveOpenTable } from '../utils';
|
|
18
|
-
import { isHeaderRowRequired } from '../utils/paste';
|
|
18
|
+
import { isHeaderRowRequired, transformSliceTableLayoutDefaultToCenter } from '../utils/paste';
|
|
19
19
|
import { defaultHoveredCell, defaultTableSelection } from './default-table-selection';
|
|
20
20
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
21
21
|
import { pluginKey } from './plugin-key';
|
|
@@ -165,6 +165,12 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
165
165
|
if (!insideTable(editorState) && isHeaderRowRequired(editorState)) {
|
|
166
166
|
slice = transformSliceToAddTableHeaders(slice, schema);
|
|
167
167
|
}
|
|
168
|
+
|
|
169
|
+
// fix for when pasting a table with default layout into comment editor
|
|
170
|
+
// table lose width and expand to full width
|
|
171
|
+
if (!insideTable(editorState) && isCommentEditor && isTableAlignmentEnabled && isTableScalingEnabled) {
|
|
172
|
+
slice = transformSliceTableLayoutDefaultToCenter(slice, schema);
|
|
173
|
+
}
|
|
168
174
|
slice = transformSliceToFixHardBreakProblemOnCopyFromCell(slice, schema);
|
|
169
175
|
|
|
170
176
|
// We do this separately, so it also applies to drag/drop events
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { flatmap, mapSlice } from '@atlaskit/editor-common/utils';
|
|
1
|
+
import { flatmap, mapChildren, mapSlice } from '@atlaskit/editor-common/utils';
|
|
2
2
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import { flatten } from '@atlaskit/editor-prosemirror/utils';
|
|
4
4
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
@@ -108,4 +108,21 @@ export const transformSliceToCorrectEmptyTableCells = (slice, schema) => {
|
|
|
108
108
|
export function isHeaderRowRequired(state) {
|
|
109
109
|
const tableState = getPluginState(state);
|
|
110
110
|
return tableState && tableState.pluginConfig.isHeaderRowRequired;
|
|
111
|
-
}
|
|
111
|
+
}
|
|
112
|
+
export const transformSliceTableLayoutDefaultToCenter = (slice, schema) => {
|
|
113
|
+
const {
|
|
114
|
+
table
|
|
115
|
+
} = schema.nodes;
|
|
116
|
+
const children = [];
|
|
117
|
+
mapChildren(slice.content, node => {
|
|
118
|
+
if (node.type === table && node.attrs.layout === 'default') {
|
|
119
|
+
children.push(table.createChecked({
|
|
120
|
+
...node.attrs,
|
|
121
|
+
layout: 'center'
|
|
122
|
+
}, node.content, node.marks));
|
|
123
|
+
} else {
|
|
124
|
+
children.push(node);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
return new Slice(Fragment.fromArray(children), slice.openStart, slice.openEnd);
|
|
128
|
+
};
|
|
@@ -18,7 +18,7 @@ import { pluginKey as decorationsPluginKey } from '../pm-plugins/decorations/plu
|
|
|
18
18
|
import { fixTables, replaceSelectedTable } from '../transforms';
|
|
19
19
|
import { TableCssClassName as ClassName } from '../types';
|
|
20
20
|
import { findControlsHoverDecoration, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell, transformSliceToRemoveOpenTable } from '../utils';
|
|
21
|
-
import { isHeaderRowRequired } from '../utils/paste';
|
|
21
|
+
import { isHeaderRowRequired, transformSliceTableLayoutDefaultToCenter } from '../utils/paste';
|
|
22
22
|
import { defaultHoveredCell, defaultTableSelection } from './default-table-selection';
|
|
23
23
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
24
24
|
import { pluginKey } from './plugin-key';
|
|
@@ -166,6 +166,12 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
166
166
|
if (!insideTable(editorState) && isHeaderRowRequired(editorState)) {
|
|
167
167
|
slice = transformSliceToAddTableHeaders(slice, schema);
|
|
168
168
|
}
|
|
169
|
+
|
|
170
|
+
// fix for when pasting a table with default layout into comment editor
|
|
171
|
+
// table lose width and expand to full width
|
|
172
|
+
if (!insideTable(editorState) && isCommentEditor && isTableAlignmentEnabled && isTableScalingEnabled) {
|
|
173
|
+
slice = transformSliceTableLayoutDefaultToCenter(slice, schema);
|
|
174
|
+
}
|
|
169
175
|
slice = transformSliceToFixHardBreakProblemOnCopyFromCell(slice, schema);
|
|
170
176
|
|
|
171
177
|
// We do this separately, so it also applies to drag/drop events
|
package/dist/esm/utils/paste.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
|
|
3
|
+
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; }
|
|
4
|
+
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) { _defineProperty(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; }
|
|
5
|
+
import { flatmap, mapChildren, mapSlice } from '@atlaskit/editor-common/utils';
|
|
3
6
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
4
7
|
import { flatten } from '@atlaskit/editor-prosemirror/utils';
|
|
5
8
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
@@ -106,4 +109,18 @@ export var transformSliceToCorrectEmptyTableCells = function transformSliceToCor
|
|
|
106
109
|
export function isHeaderRowRequired(state) {
|
|
107
110
|
var tableState = getPluginState(state);
|
|
108
111
|
return tableState && tableState.pluginConfig.isHeaderRowRequired;
|
|
109
|
-
}
|
|
112
|
+
}
|
|
113
|
+
export var transformSliceTableLayoutDefaultToCenter = function transformSliceTableLayoutDefaultToCenter(slice, schema) {
|
|
114
|
+
var table = schema.nodes.table;
|
|
115
|
+
var children = [];
|
|
116
|
+
mapChildren(slice.content, function (node) {
|
|
117
|
+
if (node.type === table && node.attrs.layout === 'default') {
|
|
118
|
+
children.push(table.createChecked(_objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
119
|
+
layout: 'center'
|
|
120
|
+
}), node.content, node.marks));
|
|
121
|
+
} else {
|
|
122
|
+
children.push(node);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
return new Slice(Fragment.fromArray(children), slice.openStart, slice.openEnd);
|
|
126
|
+
};
|
|
@@ -13,3 +13,4 @@ export declare const transformSliceToFixHardBreakProblemOnCopyFromCell: (slice:
|
|
|
13
13
|
export declare const transformSliceToRemoveOpenTable: (slice: Slice, schema: Schema) => Slice;
|
|
14
14
|
export declare const transformSliceToCorrectEmptyTableCells: (slice: Slice, schema: Schema) => Slice;
|
|
15
15
|
export declare function isHeaderRowRequired(state: EditorState): boolean | undefined;
|
|
16
|
+
export declare const transformSliceTableLayoutDefaultToCenter: (slice: Slice, schema: Schema) => Slice;
|
|
@@ -13,3 +13,4 @@ export declare const transformSliceToFixHardBreakProblemOnCopyFromCell: (slice:
|
|
|
13
13
|
export declare const transformSliceToRemoveOpenTable: (slice: Slice, schema: Schema) => Slice;
|
|
14
14
|
export declare const transformSliceToCorrectEmptyTableCells: (slice: Slice, schema: Schema) => Slice;
|
|
15
15
|
export declare function isHeaderRowRequired(state: EditorState): boolean | undefined;
|
|
16
|
+
export declare const transformSliceTableLayoutDefaultToCenter: (slice: Slice, schema: Schema) => Slice;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "7.25.
|
|
3
|
+
"version": "7.25.27",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -30,20 +30,20 @@
|
|
|
30
30
|
"@atlaskit/adf-schema": "^40.9.0",
|
|
31
31
|
"@atlaskit/button": "^20.1.0",
|
|
32
32
|
"@atlaskit/custom-steps": "^0.7.0",
|
|
33
|
-
"@atlaskit/editor-common": "^89.
|
|
33
|
+
"@atlaskit/editor-common": "^89.2.0",
|
|
34
34
|
"@atlaskit/editor-palette": "1.6.0",
|
|
35
35
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.8.0",
|
|
37
|
-
"@atlaskit/editor-plugin-batch-attribute-updates": "1.0.
|
|
37
|
+
"@atlaskit/editor-plugin-batch-attribute-updates": "1.0.4",
|
|
38
38
|
"@atlaskit/editor-plugin-content-insertion": "^1.8.0",
|
|
39
39
|
"@atlaskit/editor-plugin-editor-viewmode": "^2.1.0",
|
|
40
40
|
"@atlaskit/editor-plugin-guideline": "^1.2.0",
|
|
41
41
|
"@atlaskit/editor-plugin-selection": "^1.4.0",
|
|
42
42
|
"@atlaskit/editor-plugin-width": "^1.3.0",
|
|
43
|
-
"@atlaskit/editor-prosemirror": "
|
|
43
|
+
"@atlaskit/editor-prosemirror": "6.0.0",
|
|
44
44
|
"@atlaskit/editor-shared-styles": "^2.13.0",
|
|
45
45
|
"@atlaskit/editor-tables": "^2.8.0",
|
|
46
|
-
"@atlaskit/icon": "^22.
|
|
46
|
+
"@atlaskit/icon": "^22.18.0",
|
|
47
47
|
"@atlaskit/menu": "^2.12.0",
|
|
48
48
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
49
49
|
"@atlaskit/pragmatic-drag-and-drop": "^1.3.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@atlaskit/theme": "^13.0.0",
|
|
54
54
|
"@atlaskit/tmp-editor-statsig": "^2.1.8",
|
|
55
55
|
"@atlaskit/toggle": "^13.4.0",
|
|
56
|
-
"@atlaskit/tokens": "^1.
|
|
56
|
+
"@atlaskit/tokens": "^1.60.0",
|
|
57
57
|
"@atlaskit/tooltip": "^18.7.0",
|
|
58
58
|
"@babel/runtime": "^7.0.0",
|
|
59
59
|
"@emotion/react": "^11.7.1",
|
package/src/pm-plugins/main.ts
CHANGED
|
@@ -69,7 +69,7 @@ import {
|
|
|
69
69
|
transformSliceToFixHardBreakProblemOnCopyFromCell,
|
|
70
70
|
transformSliceToRemoveOpenTable,
|
|
71
71
|
} from '../utils';
|
|
72
|
-
import { isHeaderRowRequired } from '../utils/paste';
|
|
72
|
+
import { isHeaderRowRequired, transformSliceTableLayoutDefaultToCenter } from '../utils/paste';
|
|
73
73
|
|
|
74
74
|
import { defaultHoveredCell, defaultTableSelection } from './default-table-selection';
|
|
75
75
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
@@ -262,6 +262,17 @@ export const createPlugin = (
|
|
|
262
262
|
slice = transformSliceToAddTableHeaders(slice, schema);
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
+
// fix for when pasting a table with default layout into comment editor
|
|
266
|
+
// table lose width and expand to full width
|
|
267
|
+
if (
|
|
268
|
+
!insideTable(editorState) &&
|
|
269
|
+
isCommentEditor &&
|
|
270
|
+
isTableAlignmentEnabled &&
|
|
271
|
+
isTableScalingEnabled
|
|
272
|
+
) {
|
|
273
|
+
slice = transformSliceTableLayoutDefaultToCenter(slice, schema);
|
|
274
|
+
}
|
|
275
|
+
|
|
265
276
|
slice = transformSliceToFixHardBreakProblemOnCopyFromCell(slice, schema);
|
|
266
277
|
|
|
267
278
|
// We do this separately, so it also applies to drag/drop events
|
package/src/utils/paste.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { flatmap, mapSlice } from '@atlaskit/editor-common/utils';
|
|
1
|
+
import { flatmap, mapChildren, mapSlice } from '@atlaskit/editor-common/utils';
|
|
2
2
|
import type { Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -148,3 +148,19 @@ export function isHeaderRowRequired(state: EditorState) {
|
|
|
148
148
|
const tableState = getPluginState(state);
|
|
149
149
|
return tableState && tableState.pluginConfig.isHeaderRowRequired;
|
|
150
150
|
}
|
|
151
|
+
|
|
152
|
+
export const transformSliceTableLayoutDefaultToCenter = (slice: Slice, schema: Schema): Slice => {
|
|
153
|
+
const { table } = schema.nodes;
|
|
154
|
+
const children = [] as PMNode[];
|
|
155
|
+
mapChildren(slice.content, (node: PMNode) => {
|
|
156
|
+
if (node.type === table && node.attrs.layout === 'default') {
|
|
157
|
+
children.push(
|
|
158
|
+
table.createChecked({ ...node.attrs, layout: 'center' }, node.content, node.marks),
|
|
159
|
+
);
|
|
160
|
+
} else {
|
|
161
|
+
children.push(node);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
return new Slice(Fragment.fromArray(children), slice.openStart, slice.openEnd);
|
|
166
|
+
};
|