@atlaskit/adf-schema 44.1.0 → 44.2.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 +6 -0
- package/dist/cjs/index.js +24 -0
- package/dist/cjs/next-schema/generated/nodeTypes.js +77 -1
- package/dist/cjs/next-schema/groups/blockContentGroup.js +4 -2
- package/dist/cjs/next-schema/groups/blockGroup.js +4 -2
- package/dist/cjs/next-schema/groups/nonNestableBlockContentGroup.js +4 -2
- package/dist/cjs/next-schema/groups/tableCellContentPseudoGroup.js +2 -2
- package/dist/cjs/next-schema/nodes/extensionFrame.js +4 -2
- package/dist/cjs/next-schema/nodes/tableNodes.js +166 -0
- package/dist/cjs/schema/default-schema.js +5 -1
- package/dist/cjs/schema/index.js +24 -0
- package/dist/cjs/schema/nodes/index.js +24 -0
- package/dist/cjs/schema/nodes/tableNodes.js +52 -40
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/next-schema/generated/nodeTypes.js +76 -0
- package/dist/es2019/next-schema/groups/blockContentGroup.js +4 -2
- package/dist/es2019/next-schema/groups/blockGroup.js +4 -2
- package/dist/es2019/next-schema/groups/nonNestableBlockContentGroup.js +4 -2
- package/dist/es2019/next-schema/groups/tableCellContentPseudoGroup.js +1 -1
- package/dist/es2019/next-schema/nodes/extensionFrame.js +4 -2
- package/dist/es2019/next-schema/nodes/tableNodes.js +160 -0
- package/dist/es2019/schema/default-schema.js +6 -2
- package/dist/es2019/schema/index.js +1 -1
- package/dist/es2019/schema/nodes/index.js +1 -1
- package/dist/es2019/schema/nodes/tableNodes.js +23 -14
- package/dist/esm/index.js +1 -1
- package/dist/esm/next-schema/generated/nodeTypes.js +76 -0
- package/dist/esm/next-schema/groups/blockContentGroup.js +4 -2
- package/dist/esm/next-schema/groups/blockGroup.js +4 -2
- package/dist/esm/next-schema/groups/nonNestableBlockContentGroup.js +4 -2
- package/dist/esm/next-schema/groups/tableCellContentPseudoGroup.js +1 -1
- package/dist/esm/next-schema/nodes/extensionFrame.js +4 -2
- package/dist/esm/next-schema/nodes/tableNodes.js +161 -0
- package/dist/esm/schema/default-schema.js +6 -2
- package/dist/esm/schema/index.js +1 -1
- package/dist/esm/schema/nodes/index.js +1 -1
- package/dist/esm/schema/nodes/tableNodes.js +52 -43
- package/dist/types/index.d.ts +1 -1
- package/dist/types/next-schema/generated/nodeGroupTypes.d.ts +3 -3
- package/dist/types/next-schema/generated/nodeTypes.d.ts +52 -4
- package/dist/types/next-schema/groups/nonNestableBlockContentGroup.d.ts +1 -55
- package/dist/types/next-schema/groups/tableCellContentPseudoGroup.d.ts +71 -0
- package/dist/types/next-schema/nodes/tableNodes.d.ts +2 -0
- package/dist/types/schema/index.d.ts +2 -2
- package/dist/types/schema/nodes/index.d.ts +2 -2
- package/dist/types/schema/nodes/tableNodes.d.ts +27 -0
- package/package.json +2 -2
- package/dist/cjs/next-schema/nodes/table.js +0 -53
- package/dist/cjs/next-schema/nodes/tableCell.js +0 -50
- package/dist/cjs/next-schema/nodes/tableHeader.js +0 -50
- package/dist/cjs/next-schema/nodes/tableRow.js +0 -26
- package/dist/es2019/next-schema/nodes/table.js +0 -47
- package/dist/es2019/next-schema/nodes/tableCell.js +0 -44
- package/dist/es2019/next-schema/nodes/tableHeader.js +0 -44
- package/dist/es2019/next-schema/nodes/tableRow.js +0 -20
- package/dist/esm/next-schema/nodes/table.js +0 -47
- package/dist/esm/next-schema/nodes/tableCell.js +0 -44
- package/dist/esm/next-schema/nodes/tableHeader.js +0 -44
- package/dist/esm/next-schema/nodes/tableRow.js +0 -20
- package/dist/types/next-schema/nodes/table.d.ts +0 -1
- package/dist/types/next-schema/nodes/tableCell.d.ts +0 -1
- package/dist/types/next-schema/nodes/tableHeader.d.ts +0 -1
- package/dist/types/next-schema/nodes/tableRow.d.ts +0 -1
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
5
5
|
value: true
|
6
6
|
});
|
7
|
-
exports.toJSONTableHeader = exports.toJSONTableCell = exports.tableWithCustomWidth = exports.tableToJSON = exports.tableStage0 = exports.tableRow = exports.tablePrefixSelector = exports.tableHeaderSelector = exports.tableHeader = exports.tableCellSelector = exports.tableCellContentWrapperSelector = exports.tableCellContentDomSelector = exports.tableCell = exports.tableBackgroundColorPalette = exports.tableBackgroundColorNames = exports.tableBackgroundBorderColor = exports.table = exports.setGlobalTheme = exports.getCellDomAttrs = exports.getCellAttrs = void 0;
|
7
|
+
exports.toJSONTableHeader = exports.toJSONTableCell = exports.tableWithNestedTable = exports.tableWithCustomWidth = exports.tableToJSON = exports.tableStage0 = exports.tableRowWithNestedTable = exports.tableRow = exports.tablePrefixSelector = exports.tableHeaderWithNestedTable = exports.tableHeaderSelector = exports.tableHeader = exports.tableCellWithNestedTable = exports.tableCellSelector = exports.tableCellContentWrapperSelector = exports.tableCellContentDomSelector = exports.tableCell = exports.tableBackgroundColorPalette = exports.tableBackgroundColorNames = exports.tableBackgroundBorderColor = exports.table = exports.setGlobalTheme = exports.getCellDomAttrs = exports.getCellAttrs = void 0;
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
10
10
|
var _editorPalette = require("../../utils/editor-palette");
|
@@ -211,40 +211,43 @@ var tableBackgroundColorNames = exports.tableBackgroundColorNames = new Map();
|
|
211
211
|
* @name table_header_node
|
212
212
|
*/
|
213
213
|
|
214
|
-
//
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
};
|
234
|
-
}
|
235
|
-
}],
|
236
|
-
toDOM: function toDOM(node) {
|
237
|
-
var attrs = {
|
238
|
-
'data-number-column': node.attrs.isNumberColumnEnabled,
|
239
|
-
'data-layout': node.attrs.layout,
|
240
|
-
'data-autosize': node.attrs.__autoSize,
|
241
|
-
'data-table-local-id': node.attrs.localId,
|
242
|
-
'data-table-width': node.attrs.width,
|
243
|
-
'data-table-display-mode': node.attrs.displayMode
|
214
|
+
// table nodes with nested tables support
|
215
|
+
|
216
|
+
var tableNodeSpecOptions = {
|
217
|
+
parseDOM: [{
|
218
|
+
tag: 'table',
|
219
|
+
getAttrs: function getAttrs(node) {
|
220
|
+
var _dom$parentElement;
|
221
|
+
var dom = node;
|
222
|
+
var breakoutWrapper = (_dom$parentElement = dom.parentElement) === null || _dom$parentElement === void 0 ? void 0 : _dom$parentElement.parentElement;
|
223
|
+
return {
|
224
|
+
isNumberColumnEnabled: dom.getAttribute('data-number-column') === 'true',
|
225
|
+
layout:
|
226
|
+
// copying from editor
|
227
|
+
dom.getAttribute('data-layout') || ( // copying from renderer
|
228
|
+
breakoutWrapper === null || breakoutWrapper === void 0 ? void 0 : breakoutWrapper.getAttribute('data-layout')) || 'default',
|
229
|
+
__autoSize: dom.getAttribute('data-autosize') === 'true',
|
230
|
+
localId: dom.getAttribute('data-table-local-id') || _uuid.uuid.generate(),
|
231
|
+
width: Number(dom.getAttribute('data-table-width')) || null,
|
232
|
+
displayMode: dom.getAttribute('data-table-display-mode') || null
|
244
233
|
};
|
245
|
-
return ['table', attrs, ['tbody', 0]];
|
246
234
|
}
|
247
|
-
}
|
235
|
+
}],
|
236
|
+
toDOM: function toDOM(node) {
|
237
|
+
var attrs = {
|
238
|
+
'data-number-column': node.attrs.isNumberColumnEnabled,
|
239
|
+
'data-layout': node.attrs.layout,
|
240
|
+
'data-autosize': node.attrs.__autoSize,
|
241
|
+
'data-table-local-id': node.attrs.localId,
|
242
|
+
'data-table-width': node.attrs.width,
|
243
|
+
'data-table-display-mode': node.attrs.displayMode
|
244
|
+
};
|
245
|
+
return ['table', attrs, ['tbody', 0]];
|
246
|
+
}
|
247
|
+
};
|
248
|
+
// TODO: Fix any, potential issue. ED-5048
|
249
|
+
var createTableSpec = function createTableSpec() {
|
250
|
+
return (0, _nodeTypes.table)(tableNodeSpecOptions);
|
248
251
|
};
|
249
252
|
|
250
253
|
// TODO: assuming breaking changes aren't allowed, so retaining both exports
|
@@ -265,14 +268,15 @@ var tableToJSON = exports.tableToJSON = function tableToJSON(node) {
|
|
265
268
|
}, {})
|
266
269
|
};
|
267
270
|
};
|
268
|
-
var
|
271
|
+
var tableRowNodeSpecOptions = {
|
269
272
|
parseDOM: [{
|
270
273
|
tag: 'tr'
|
271
274
|
}],
|
272
275
|
toDOM: function toDOM() {
|
273
276
|
return ['tr', 0];
|
274
277
|
}
|
275
|
-
}
|
278
|
+
};
|
279
|
+
var tableRow = exports.tableRow = (0, _nodeTypes.tableRow)(tableRowNodeSpecOptions);
|
276
280
|
var cellAttrs = {
|
277
281
|
colspan: {
|
278
282
|
default: 1
|
@@ -287,7 +291,7 @@ var cellAttrs = {
|
|
287
291
|
default: null
|
288
292
|
}
|
289
293
|
};
|
290
|
-
var
|
294
|
+
var tableCellNodeSpecOptions = {
|
291
295
|
parseDOM: [
|
292
296
|
// Ignore number cell copied from renderer
|
293
297
|
{
|
@@ -302,7 +306,8 @@ var tableCell = exports.tableCell = (0, _nodeTypes.tableCell)({
|
|
302
306
|
toDOM: function toDOM(node) {
|
303
307
|
return ['td', getCellDomAttrs(node), 0];
|
304
308
|
}
|
305
|
-
}
|
309
|
+
};
|
310
|
+
var tableCell = exports.tableCell = (0, _nodeTypes.tableCell)(tableCellNodeSpecOptions);
|
306
311
|
var toJSONTableCell = exports.toJSONTableCell = function toJSONTableCell(node) {
|
307
312
|
return {
|
308
313
|
attrs: Object.keys(node.attrs).reduce(function (obj, key) {
|
@@ -313,7 +318,7 @@ var toJSONTableCell = exports.toJSONTableCell = function toJSONTableCell(node) {
|
|
313
318
|
}, {})
|
314
319
|
};
|
315
320
|
};
|
316
|
-
var
|
321
|
+
var tableHeaderNodeSpecOptions = {
|
317
322
|
parseDOM: [{
|
318
323
|
tag: 'th',
|
319
324
|
getAttrs: function getAttrs(dom) {
|
@@ -325,5 +330,12 @@ var tableHeader = exports.tableHeader = (0, _nodeTypes.tableHeader)({
|
|
325
330
|
toDOM: function toDOM(node) {
|
326
331
|
return ['th', getCellDomAttrs(node), 0];
|
327
332
|
}
|
328
|
-
}
|
329
|
-
var
|
333
|
+
};
|
334
|
+
var tableHeader = exports.tableHeader = (0, _nodeTypes.tableHeader)(tableHeaderNodeSpecOptions);
|
335
|
+
var toJSONTableHeader = exports.toJSONTableHeader = toJSONTableCell;
|
336
|
+
|
337
|
+
// table nodes with nested table support
|
338
|
+
var tableWithNestedTable = exports.tableWithNestedTable = (0, _nodeTypes.tableWithNestedTable)(tableNodeSpecOptions);
|
339
|
+
var tableRowWithNestedTable = exports.tableRowWithNestedTable = (0, _nodeTypes.tableRowWithNestedTable)(tableRowNodeSpecOptions);
|
340
|
+
var tableCellWithNestedTable = exports.tableCellWithNestedTable = (0, _nodeTypes.tableCellWithNestedTable)(tableCellNodeSpecOptions);
|
341
|
+
var tableHeaderWithNestedTable = exports.tableHeaderWithNestedTable = (0, _nodeTypes.tableHeaderWithNestedTable)(tableHeaderNodeSpecOptions);
|
package/dist/es2019/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
export { PanelType, AnnotationTypes, alignment, alignmentPositionMap, annotation, blockCard, blockquote, blockquoteWithList, blockquoteWithNestedCodeblockOrMedia, bodiedExtension, breakout, bulletList, bulletListSelector, caption, code, codeBlock, codeBlockToJSON, colorPalette, /** @deprecated [ED-15849] The extended palette is now rolled into the main one. Use `colorPalette` instead. */
|
2
|
-
colorPaletteExtended, confluenceInlineComment, confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, createSchema, dataConsumer, dataConsumerToJSON, date, decisionItem, decisionList, decisionListSelector, doc, em, embedCard, emoji, expand, expandWithNestedExpand, expandToJSON, extension, fragment, fragmentToJSON, hardBreak, heading, image, indentation, inlineCard, inlineExtension, inlineNodes, layoutColumn, layoutSection, link, linkToJSON, listItem, listItemWithTask, listItemWithDecisionStage0, media, mediaGroup, mediaSingle, mediaSingleWithCaption, mediaSingleWithWidthType, mediaSingleFull, mediaSingleSpec, mediaInline, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, orderedList, orderedListSelector, orderedListWithOrder, extendedPanel, panelWithBlockquoteStage0, paragraph, placeholder, rule, sanitizeNodes, getCellAttrs, getCellDomAttrs, status, strike, strong, subsup, table, tableStage0, tableWithCustomWidth, tableBackgroundBorderColor, tableBackgroundColorNames, tableBackgroundColorPalette, tableCell, tableCellContentDomSelector, tableCellContentWrapperSelector, tableCellSelector, tableHeader, tableHeaderSelector, tablePrefixSelector, tableRow, tableToJSON, taskItem, taskList, taskListSelector, text, textColor, toJSONTableCell, toJSONTableHeader, typeAheadQuery, underline, unknownBlock, unsupportedBlock, unsupportedInline, unsupportedNodeTypesForMediaCards, buildAnnotationMarkDataAttributes, AnnotationMarkStates, unsupportedMark, unsupportedNodeAttribute, border, borderColorPalette, extensionFrame, multiBodiedExtension, backgroundColor, backgroundColorPalette } from './schema';
|
2
|
+
colorPaletteExtended, confluenceInlineComment, confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, createSchema, dataConsumer, dataConsumerToJSON, date, decisionItem, decisionList, decisionListSelector, doc, em, embedCard, emoji, expand, expandWithNestedExpand, expandToJSON, extension, fragment, fragmentToJSON, hardBreak, heading, image, indentation, inlineCard, inlineExtension, inlineNodes, layoutColumn, layoutSection, link, linkToJSON, listItem, listItemWithTask, listItemWithDecisionStage0, media, mediaGroup, mediaSingle, mediaSingleWithCaption, mediaSingleWithWidthType, mediaSingleFull, mediaSingleSpec, mediaInline, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, orderedList, orderedListSelector, orderedListWithOrder, extendedPanel, panelWithBlockquoteStage0, paragraph, placeholder, rule, sanitizeNodes, getCellAttrs, getCellDomAttrs, status, strike, strong, subsup, table, tableStage0, tableWithCustomWidth, tableBackgroundBorderColor, tableBackgroundColorNames, tableBackgroundColorPalette, tableCell, tableCellContentDomSelector, tableCellContentWrapperSelector, tableCellSelector, tableHeader, tableHeaderSelector, tablePrefixSelector, tableRow, tableToJSON, taskItem, taskList, taskListSelector, text, textColor, toJSONTableCell, toJSONTableHeader, typeAheadQuery, underline, unknownBlock, unsupportedBlock, unsupportedInline, unsupportedNodeTypesForMediaCards, buildAnnotationMarkDataAttributes, AnnotationMarkStates, unsupportedMark, unsupportedNodeAttribute, border, borderColorPalette, extensionFrame, multiBodiedExtension, backgroundColor, backgroundColorPalette, tableWithNestedTable, tableRowWithNestedTable, tableCellWithNestedTable, tableHeaderWithNestedTable } from './schema';
|
3
3
|
export { B100, B400, B50, B500, B75, G200, G300, G400, G50, G500, G75, N0, N20, N200, N30, N300, N40, N50, N500, N60, N80, N800, N90, P100, P300, P400, P50, P500, P75, R100, R300, R400, R50, R500, R75, T100, T300, T50, T500, T75, Y200, Y400, Y50, Y500, Y75, acNameToEmoji, acShortcutToEmoji, emojiIdToAcName, generateUuid, getEmojiAcName, getLinkMatch, hexToRgb, hexToRgba, isHex, isRgb, isSafeUrl, linkify, linkifyMatch, normalizeHexColor, normalizeUrl, rgbToHex, uuid, getDarkModeLCHColor } from './utils';
|
4
4
|
|
5
5
|
// ADF createPMSpecFactory
|
@@ -1030,6 +1030,34 @@ export const table = createPMNodeSpecFactory({
|
|
1030
1030
|
isolating: true,
|
1031
1031
|
tableRole: 'table'
|
1032
1032
|
});
|
1033
|
+
export const tableWithNestedTable = createPMNodeSpecFactory({
|
1034
|
+
content: 'tableRow+',
|
1035
|
+
marks: 'unsupportedMark unsupportedNodeAttribute',
|
1036
|
+
group: 'block',
|
1037
|
+
attrs: {
|
1038
|
+
displayMode: {
|
1039
|
+
default: null
|
1040
|
+
},
|
1041
|
+
isNumberColumnEnabled: {
|
1042
|
+
default: false
|
1043
|
+
},
|
1044
|
+
layout: {
|
1045
|
+
default: 'default'
|
1046
|
+
},
|
1047
|
+
localId: {
|
1048
|
+
default: ''
|
1049
|
+
},
|
1050
|
+
width: {
|
1051
|
+
default: null
|
1052
|
+
},
|
1053
|
+
__autoSize: {
|
1054
|
+
default: false
|
1055
|
+
}
|
1056
|
+
},
|
1057
|
+
selectable: true,
|
1058
|
+
isolating: true,
|
1059
|
+
tableRole: 'table'
|
1060
|
+
});
|
1033
1061
|
export const tableCell = createPMNodeSpecFactory({
|
1034
1062
|
content: '(paragraph | panel | blockquote | orderedList | bulletList | rule | heading | codeBlock | mediaSingle | mediaGroup | decisionList | taskList | blockCard | embedCard | extension | nestedExpand | unsupportedBlock)+',
|
1035
1063
|
marks: 'alignment unsupportedMark unsupportedNodeAttribute dataConsumer fragment',
|
@@ -1051,6 +1079,27 @@ export const tableCell = createPMNodeSpecFactory({
|
|
1051
1079
|
isolating: true,
|
1052
1080
|
tableRole: 'cell'
|
1053
1081
|
});
|
1082
|
+
export const tableCellWithNestedTable = createPMNodeSpecFactory({
|
1083
|
+
content: '(paragraph | panel | blockquote | orderedList | bulletList | rule | heading | codeBlock | mediaSingle | mediaGroup | decisionList | taskList | blockCard | embedCard | extension | nestedExpand | unsupportedBlock | table)+',
|
1084
|
+
marks: 'alignment unsupportedMark unsupportedNodeAttribute dataConsumer fragment',
|
1085
|
+
attrs: {
|
1086
|
+
colspan: {
|
1087
|
+
default: 1
|
1088
|
+
},
|
1089
|
+
rowspan: {
|
1090
|
+
default: 1
|
1091
|
+
},
|
1092
|
+
colwidth: {
|
1093
|
+
default: null
|
1094
|
+
},
|
1095
|
+
background: {
|
1096
|
+
default: null
|
1097
|
+
}
|
1098
|
+
},
|
1099
|
+
selectable: false,
|
1100
|
+
isolating: true,
|
1101
|
+
tableRole: 'cell'
|
1102
|
+
});
|
1054
1103
|
export const tableHeader = createPMNodeSpecFactory({
|
1055
1104
|
content: '(paragraph | panel | blockquote | orderedList | bulletList | rule | heading | codeBlock | mediaSingle | mediaGroup | decisionList | taskList | blockCard | embedCard | extension | nestedExpand)+',
|
1056
1105
|
marks: 'alignment unsupportedMark unsupportedNodeAttribute dataConsumer fragment',
|
@@ -1072,12 +1121,39 @@ export const tableHeader = createPMNodeSpecFactory({
|
|
1072
1121
|
isolating: true,
|
1073
1122
|
tableRole: 'header_cell'
|
1074
1123
|
});
|
1124
|
+
export const tableHeaderWithNestedTable = createPMNodeSpecFactory({
|
1125
|
+
content: '(paragraph | panel | blockquote | orderedList | bulletList | rule | heading | codeBlock | mediaSingle | mediaGroup | decisionList | taskList | blockCard | embedCard | extension | nestedExpand | table)+',
|
1126
|
+
marks: 'alignment unsupportedMark unsupportedNodeAttribute dataConsumer fragment',
|
1127
|
+
attrs: {
|
1128
|
+
colspan: {
|
1129
|
+
default: 1
|
1130
|
+
},
|
1131
|
+
rowspan: {
|
1132
|
+
default: 1
|
1133
|
+
},
|
1134
|
+
colwidth: {
|
1135
|
+
default: null
|
1136
|
+
},
|
1137
|
+
background: {
|
1138
|
+
default: null
|
1139
|
+
}
|
1140
|
+
},
|
1141
|
+
selectable: false,
|
1142
|
+
isolating: true,
|
1143
|
+
tableRole: 'header_cell'
|
1144
|
+
});
|
1075
1145
|
export const tableRow = createPMNodeSpecFactory({
|
1076
1146
|
content: '(tableCell | tableHeader)+',
|
1077
1147
|
marks: 'unsupportedMark unsupportedNodeAttribute',
|
1078
1148
|
selectable: false,
|
1079
1149
|
tableRole: 'row'
|
1080
1150
|
});
|
1151
|
+
export const tableRowWithNestedTable = createPMNodeSpecFactory({
|
1152
|
+
content: '(tableCell | tableHeader)+',
|
1153
|
+
marks: 'unsupportedMark unsupportedNodeAttribute',
|
1154
|
+
selectable: false,
|
1155
|
+
tableRole: 'row'
|
1156
|
+
});
|
1081
1157
|
export const taskItem = createPMNodeSpecFactory({
|
1082
1158
|
content: 'inline*',
|
1083
1159
|
marks: '_',
|
@@ -15,7 +15,7 @@ import { mediaSingle } from '../nodes/mediaSingle';
|
|
15
15
|
import { panel } from '../nodes/panel';
|
16
16
|
import { paragraph } from '../nodes/paragraph';
|
17
17
|
import { rule } from '../nodes/rule';
|
18
|
-
import { table } from '../nodes/
|
18
|
+
import { table } from '../nodes/tableNodes';
|
19
19
|
import { taskList } from '../nodes/task';
|
20
20
|
import { unsupportedBlock } from '../nodes/unsupportedBlock';
|
21
21
|
|
@@ -32,6 +32,8 @@ import { unsupportedBlock } from '../nodes/unsupportedBlock';
|
|
32
32
|
* - no base heading
|
33
33
|
* - no base expand
|
34
34
|
*/
|
35
|
-
export const blockContentGroup = adfNodeGroup('block_content', [blockCard, paragraph.use('with_no_marks'), paragraph.use('with_alignment'), paragraph.use('with_indentation'), mediaSingle.use('caption'), mediaSingle.use('full'), codeBlock.use('with_no_marks'), taskList, bulletList, orderedList, heading.use('with_no_marks'), heading.use('with_alignment'), heading.use('with_indentation'), mediaGroup, decisionList, rule, panel, panel.use('with_nested_blockquote'), blockquote, blockquote.use('without_nested_codeblock_or_media'), extension.use('with_marks'), embedCard, table,
|
35
|
+
export const blockContentGroup = adfNodeGroup('block_content', [blockCard, paragraph.use('with_no_marks'), paragraph.use('with_alignment'), paragraph.use('with_indentation'), mediaSingle.use('caption'), mediaSingle.use('full'), codeBlock.use('with_no_marks'), taskList, bulletList, orderedList, heading.use('with_no_marks'), heading.use('with_alignment'), heading.use('with_indentation'), mediaGroup, decisionList, rule, panel, panel.use('with_nested_blockquote'), blockquote, blockquote.use('without_nested_codeblock_or_media'), extension.use('with_marks'), embedCard, table,
|
36
|
+
// @ts-expect-error - types don't deal well with circular references for the variant
|
37
|
+
table.use('with_nested_table'), expand.use('without_nested_expand'), expand.use('with_no_mark'), bodiedExtension.use('with_marks'), confluenceUnsupportedBlock, unsupportedBlock], {
|
36
38
|
ignore: ['pm-spec', 'json-schema']
|
37
39
|
});
|
@@ -15,10 +15,12 @@ import { mediaSingle } from '../nodes/mediaSingle';
|
|
15
15
|
import { panel } from '../nodes/panel';
|
16
16
|
import { paragraph } from '../nodes/paragraph';
|
17
17
|
import { rule } from '../nodes/rule';
|
18
|
-
import { table } from '../nodes/
|
18
|
+
import { table } from '../nodes/tableNodes';
|
19
19
|
import { taskList } from '../nodes/task';
|
20
20
|
import { unsupportedBlock } from '../nodes/unsupportedBlock';
|
21
|
-
export const blockGroup = adfNodeGroup('block', [blockCard, codeBlock, codeBlock.use('with_marks'), codeBlock.use('with_no_marks'), mediaSingle, mediaSingle.use('caption'), mediaSingle.use('full'), mediaSingle.use('width_type'), paragraph, paragraph.use('with_alignment'), paragraph.use('with_indentation'), paragraph.use('with_no_marks'), taskList, orderedList, bulletList, blockquote, blockquote.use('legacy'), blockquote.use('without_nested_codeblock_or_media'), decisionList, embedCard, extension, extension.use('with_marks'), heading, heading.use('with_indentation'), heading.use('with_no_marks'), heading.use('with_alignment'), mediaGroup, rule, panel, panel.use('with_nested_blockquote'), table,
|
21
|
+
export const blockGroup = adfNodeGroup('block', [blockCard, codeBlock, codeBlock.use('with_marks'), codeBlock.use('with_no_marks'), mediaSingle, mediaSingle.use('caption'), mediaSingle.use('full'), mediaSingle.use('width_type'), paragraph, paragraph.use('with_alignment'), paragraph.use('with_indentation'), paragraph.use('with_no_marks'), taskList, orderedList, bulletList, blockquote, blockquote.use('legacy'), blockquote.use('without_nested_codeblock_or_media'), decisionList, embedCard, extension, extension.use('with_marks'), heading, heading.use('with_indentation'), heading.use('with_no_marks'), heading.use('with_alignment'), mediaGroup, rule, panel, panel.use('with_nested_blockquote'), table,
|
22
|
+
// @ts-expect-error - types don't deal well with circular references for the variant
|
23
|
+
table.use('with_nested_table'), bodiedExtension, bodiedExtension.use('with_marks'), expand, expand.use('with_no_mark'), expand.use('with_breakout_mark'), expand.use('without_nested_expand'), confluenceUnsupportedBlock, unsupportedBlock], {
|
22
24
|
// @DSLCompatibilityException
|
23
25
|
// Block group in PM doesn't match ADF
|
24
26
|
ignore: ['validator-spec']
|
@@ -12,13 +12,15 @@ import { mediaSingle } from '../nodes/mediaSingle';
|
|
12
12
|
import { panel } from '../nodes/panel';
|
13
13
|
import { paragraph } from '../nodes/paragraph';
|
14
14
|
import { rule } from '../nodes/rule';
|
15
|
-
import { table } from '../nodes/
|
15
|
+
import { table } from '../nodes/tableNodes';
|
16
16
|
import { taskList } from '../nodes/task';
|
17
17
|
import { unsupportedBlock } from '../nodes/unsupportedBlock';
|
18
18
|
|
19
19
|
// Not an actual group, but a collection of nodes that can't be nested inside each other
|
20
20
|
// TODO: make it an actual group
|
21
|
-
export const nonNestableBlockContent = [paragraph.use('with_no_marks'), panel, blockquote, orderedList, bulletList, rule, heading.use('with_no_marks'), codeBlock.use('with_no_marks'), mediaGroup, mediaSingle.use('caption'), mediaSingle.use('full'), decisionList, taskList, table,
|
21
|
+
export const nonNestableBlockContent = [paragraph.use('with_no_marks'), panel, blockquote, orderedList, bulletList, rule, heading.use('with_no_marks'), codeBlock.use('with_no_marks'), mediaGroup, mediaSingle.use('caption'), mediaSingle.use('full'), decisionList, taskList, table,
|
22
|
+
// @ts-expect-error - types don't deal well with circular references for the variant
|
23
|
+
table.use('with_nested_table'), blockCard, embedCard, extension.use('with_marks'), unsupportedBlock];
|
22
24
|
|
23
25
|
/**
|
24
26
|
* @DSLCompatibilityException
|
@@ -15,7 +15,7 @@ import { paragraph } from '../nodes/paragraph';
|
|
15
15
|
import { rule } from '../nodes/rule';
|
16
16
|
import { taskList } from '../nodes/task';
|
17
17
|
import { unsupportedBlock } from '../nodes/unsupportedBlock';
|
18
|
-
const tableCellContentNodes = [paragraph.use('with_no_marks'), paragraph.use('with_alignment'), panel, blockquote, orderedList, bulletList, rule, heading.use('with_no_marks'), heading.use('with_alignment'), heading.use('with_indentation'), codeBlock.use('with_no_marks'), mediaSingle.use('caption'), mediaSingle.use('full'), mediaGroup, decisionList, taskList, blockCard, embedCard, extension.use('with_marks'), nestedExpand.use('content'), nestedExpand.use('with_no_marks')];
|
18
|
+
export const tableCellContentNodes = [paragraph.use('with_no_marks'), paragraph.use('with_alignment'), panel, blockquote, orderedList, bulletList, rule, heading.use('with_no_marks'), heading.use('with_alignment'), heading.use('with_indentation'), codeBlock.use('with_no_marks'), mediaSingle.use('caption'), mediaSingle.use('full'), mediaGroup, decisionList, taskList, blockCard, embedCard, extension.use('with_marks'), nestedExpand.use('content'), nestedExpand.use('with_no_marks')];
|
19
19
|
|
20
20
|
// This is not an actual group, but a collection of nodes
|
21
21
|
// @DSLCompatibilityException JSON Schema and PM Spec are not in sync. We need to fix it
|
@@ -17,7 +17,7 @@ import { mediaSingle } from './mediaSingle';
|
|
17
17
|
import { panel } from './panel';
|
18
18
|
import { paragraph } from './paragraph';
|
19
19
|
import { rule } from './rule';
|
20
|
-
import { table } from './
|
20
|
+
import { table } from './tableNodes';
|
21
21
|
import { taskList } from './task';
|
22
22
|
import { unsupportedBlock } from './unsupportedBlock';
|
23
23
|
export const extensionFrame = adfNode('extensionFrame').define({
|
@@ -30,7 +30,9 @@ export const extensionFrame = adfNode('extensionFrame').define({
|
|
30
30
|
// packages/adf-schema-generator/src/transforms/adfToPm/buildPmSpec.ts
|
31
31
|
marks: [dataConsumer, fragment, unsupportedMark, unsupportedNodeAttribute],
|
32
32
|
attrs: {},
|
33
|
-
content: [$onePlus($or(paragraph.use('with_no_marks'), panel, blockquote, orderedList, bulletList, rule, heading.use('with_no_marks'), codeBlock.use('with_no_marks'), mediaGroup, mediaSingle.use('full'), mediaSingle.use('caption'), decisionList, taskList, table,
|
33
|
+
content: [$onePlus($or(paragraph.use('with_no_marks'), panel, blockquote, orderedList, bulletList, rule, heading.use('with_no_marks'), codeBlock.use('with_no_marks'), mediaGroup, mediaSingle.use('full'), mediaSingle.use('caption'), decisionList, taskList, table,
|
34
|
+
// @ts-expect-error - types don't deal well with circular references for the variant
|
35
|
+
table.use('with_nested_table'), extension.use('with_marks'), bodiedExtension.use('with_marks'), unsupportedBlock, blockCard, embedCard))],
|
34
36
|
DANGEROUS_MANUAL_OVERRIDE: {
|
35
37
|
'validator-spec': {
|
36
38
|
'props.content.allowUnsupportedBlock': {
|
@@ -0,0 +1,160 @@
|
|
1
|
+
import { $onePlus, $or, adfNode } from '@atlaskit/adf-schema-generator';
|
2
|
+
import { fragment } from '../marks/fragment';
|
3
|
+
import { unsupportedMark } from '../marks/unsupportedMark';
|
4
|
+
import { unsupportedNodeAttribute } from '../marks/unsupportedNodeAttribute';
|
5
|
+
import { tableCellContentPseudoGroup, tableCellContentNodes, tableHeaderContentPseudoGroup } from '../groups/tableCellContentPseudoGroup';
|
6
|
+
import { tableCellContent } from './tableCellContent';
|
7
|
+
import { nestedExpand } from './nestedExpand';
|
8
|
+
import { unsupportedBlock } from './unsupportedBlock';
|
9
|
+
|
10
|
+
// Declare early to allow for circular references within the file
|
11
|
+
const table = adfNode('table');
|
12
|
+
const tableCell = adfNode('tableCell').define({
|
13
|
+
isolating: true,
|
14
|
+
selectable: false,
|
15
|
+
tableRole: 'cell',
|
16
|
+
marks: [unsupportedMark, unsupportedNodeAttribute],
|
17
|
+
attrs: {
|
18
|
+
colspan: {
|
19
|
+
type: 'number',
|
20
|
+
default: 1,
|
21
|
+
optional: true
|
22
|
+
},
|
23
|
+
rowspan: {
|
24
|
+
type: 'number',
|
25
|
+
default: 1,
|
26
|
+
optional: true
|
27
|
+
},
|
28
|
+
colwidth: {
|
29
|
+
type: 'array',
|
30
|
+
items: {
|
31
|
+
type: 'number'
|
32
|
+
},
|
33
|
+
default: null,
|
34
|
+
optional: true
|
35
|
+
},
|
36
|
+
background: {
|
37
|
+
type: 'string',
|
38
|
+
default: null,
|
39
|
+
optional: true
|
40
|
+
}
|
41
|
+
},
|
42
|
+
content: [tableCellContentPseudoGroup],
|
43
|
+
DANGEROUS_MANUAL_OVERRIDE: {
|
44
|
+
'validator-spec': {
|
45
|
+
required: {
|
46
|
+
reason: '@DSLCompatibilityException - required for tableCell validator spec',
|
47
|
+
value: ['content']
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}).variant('with_nested_table', {
|
52
|
+
content: [$onePlus($or(...tableCellContentNodes, unsupportedBlock, table))],
|
53
|
+
ignore: ['json-schema', 'validator-spec']
|
54
|
+
});
|
55
|
+
const tableHeader = adfNode('tableHeader').define({
|
56
|
+
isolating: true,
|
57
|
+
selectable: false,
|
58
|
+
tableRole: 'header_cell',
|
59
|
+
marks: [unsupportedMark, unsupportedNodeAttribute],
|
60
|
+
attrs: {
|
61
|
+
colspan: {
|
62
|
+
type: 'number',
|
63
|
+
default: 1,
|
64
|
+
optional: true
|
65
|
+
},
|
66
|
+
rowspan: {
|
67
|
+
type: 'number',
|
68
|
+
default: 1,
|
69
|
+
optional: true
|
70
|
+
},
|
71
|
+
colwidth: {
|
72
|
+
type: 'array',
|
73
|
+
items: {
|
74
|
+
type: 'number'
|
75
|
+
},
|
76
|
+
default: null,
|
77
|
+
optional: true
|
78
|
+
},
|
79
|
+
background: {
|
80
|
+
type: 'string',
|
81
|
+
default: null,
|
82
|
+
optional: true
|
83
|
+
}
|
84
|
+
},
|
85
|
+
content: [tableHeaderContentPseudoGroup],
|
86
|
+
DANGEROUS_MANUAL_OVERRIDE: {
|
87
|
+
'validator-spec': {
|
88
|
+
required: {
|
89
|
+
reason: '@DSLCompatibilityException - required for tableHeader validator spec',
|
90
|
+
value: ['content']
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}).variant('with_nested_table', {
|
95
|
+
content: [$onePlus($or(...tableCellContentNodes, nestedExpand, table))],
|
96
|
+
ignore: ['json-schema', 'validator-spec']
|
97
|
+
});
|
98
|
+
const tableRow = adfNode('tableRow').define({
|
99
|
+
selectable: false,
|
100
|
+
marks: [unsupportedMark, unsupportedNodeAttribute],
|
101
|
+
content: [$onePlus($or(tableCell, tableHeader, tableCellContent))],
|
102
|
+
tableRole: 'row',
|
103
|
+
DANGEROUS_MANUAL_OVERRIDE: {
|
104
|
+
'validator-spec': {
|
105
|
+
'props.content.minItems': {
|
106
|
+
reason: '@DSLCompatibilityException - required for tableRow validator spec',
|
107
|
+
remove: true
|
108
|
+
}
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}).variant('with_nested_table', {
|
112
|
+
content: [$onePlus($or(tableCell.use('with_nested_table'), tableHeader.use('with_nested_table')))],
|
113
|
+
ignore: ['json-schema', 'validator-spec']
|
114
|
+
});
|
115
|
+
table.define({
|
116
|
+
isolating: true,
|
117
|
+
selectable: true,
|
118
|
+
tableRole: 'table',
|
119
|
+
marks: [fragment, unsupportedMark, unsupportedNodeAttribute],
|
120
|
+
attrs: {
|
121
|
+
displayMode: {
|
122
|
+
type: 'enum',
|
123
|
+
values: ['default', 'fixed'],
|
124
|
+
default: null,
|
125
|
+
optional: true
|
126
|
+
},
|
127
|
+
isNumberColumnEnabled: {
|
128
|
+
type: 'boolean',
|
129
|
+
default: false,
|
130
|
+
optional: true
|
131
|
+
},
|
132
|
+
layout: {
|
133
|
+
type: 'enum',
|
134
|
+
values: ['wide', 'full-width', 'center', 'align-end', 'align-start', 'default'],
|
135
|
+
default: 'default',
|
136
|
+
optional: true
|
137
|
+
},
|
138
|
+
localId: {
|
139
|
+
type: 'string',
|
140
|
+
minLength: 1,
|
141
|
+
default: '',
|
142
|
+
optional: true
|
143
|
+
},
|
144
|
+
width: {
|
145
|
+
type: 'number',
|
146
|
+
default: null,
|
147
|
+
optional: true
|
148
|
+
},
|
149
|
+
__autoSize: {
|
150
|
+
type: 'boolean',
|
151
|
+
default: false,
|
152
|
+
optional: true
|
153
|
+
}
|
154
|
+
},
|
155
|
+
content: [$onePlus($or(tableRow))]
|
156
|
+
}).variant('with_nested_table', {
|
157
|
+
content: [$onePlus($or(tableRow.use('with_nested_table')))],
|
158
|
+
ignore: ['json-schema', 'validator-spec']
|
159
|
+
});
|
160
|
+
export { table };
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import memoizeOne from 'memoize-one';
|
2
|
-
import { extensionFrame, layoutSectionWithSingleColumn, multiBodiedExtension, expandWithNestedExpand, blockquoteWithNestedCodeblockOrMedia, listItemWithDecisionStage0, panelWithBlockquoteStage0 } from './nodes';
|
2
|
+
import { extensionFrame, layoutSectionWithSingleColumn, multiBodiedExtension, expandWithNestedExpand, blockquoteWithNestedCodeblockOrMedia, listItemWithDecisionStage0, panelWithBlockquoteStage0, tableWithNestedTable, tableRowWithNestedTable, tableCellWithNestedTable, tableHeaderWithNestedTable } from './nodes';
|
3
3
|
import { createSchema } from './create-schema';
|
4
4
|
const getDefaultSchemaConfig = () => {
|
5
5
|
const defaultSchemaConfig = {
|
@@ -21,7 +21,11 @@ export const getSchemaBasedOnStage = memoizeOne((stage = 'final') => {
|
|
21
21
|
expand: expandWithNestedExpand,
|
22
22
|
blockquote: blockquoteWithNestedCodeblockOrMedia,
|
23
23
|
listItem: listItemWithDecisionStage0,
|
24
|
-
panel: panelWithBlockquoteStage0(true)
|
24
|
+
panel: panelWithBlockquoteStage0(true),
|
25
|
+
table: tableWithNestedTable,
|
26
|
+
tableRow: tableRowWithNestedTable,
|
27
|
+
tableCell: tableCellWithNestedTable,
|
28
|
+
tableHeader: tableHeaderWithNestedTable
|
25
29
|
};
|
26
30
|
}
|
27
31
|
return createSchema(defaultSchemaConfig);
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export { PanelType, blockCard, blockquote, blockquoteWithList, blockquoteWithNestedCodeblockOrMedia, bodiedExtension, bulletList, bulletListSelector, caption, codeBlock, codeBlockToJSON, confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, date, decisionItem, decisionList, decisionListSelector, doc, embedCard, emoji, expand, expandWithNestedExpand, expandToJSON, extension, hardBreak, heading, image, inlineCard, inlineExtension, layoutColumn, layoutSection, layoutSectionWithSingleColumn, listItem, listItemWithTask, listItemWithDecisionStage0, media, mediaGroup, mediaSingle, mediaSingleSpec, mediaInline, mediaSingleWithCaption, mediaSingleWithWidthType, mediaSingleFull, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, orderedList, orderedListSelector, orderedListWithOrder, extendedPanel, panelWithBlockquoteStage0, paragraph, placeholder, rule, getCellAttrs, getCellDomAttrs, status, table, tableStage0, tableWithCustomWidth, tableBackgroundBorderColor, tableBackgroundColorNames, tableBackgroundColorPalette, tableCell, tableCellContentDomSelector, tableCellContentWrapperSelector, tableCellSelector, tableHeader, tableHeaderSelector, tablePrefixSelector, tableRow, tableToJSON, taskItem, taskList, taskListSelector, text, toJSONTableCell, toJSONTableHeader, unknownBlock, unsupportedBlock, unsupportedInline, extensionFrame, multiBodiedExtension } from './nodes';
|
1
|
+
export { PanelType, blockCard, blockquote, blockquoteWithList, blockquoteWithNestedCodeblockOrMedia, bodiedExtension, bulletList, bulletListSelector, caption, codeBlock, codeBlockToJSON, confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, date, decisionItem, decisionList, decisionListSelector, doc, embedCard, emoji, expand, expandWithNestedExpand, expandToJSON, extension, hardBreak, heading, image, inlineCard, inlineExtension, layoutColumn, layoutSection, layoutSectionWithSingleColumn, listItem, listItemWithTask, listItemWithDecisionStage0, media, mediaGroup, mediaSingle, mediaSingleSpec, mediaInline, mediaSingleWithCaption, mediaSingleWithWidthType, mediaSingleFull, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, orderedList, orderedListSelector, orderedListWithOrder, extendedPanel, panelWithBlockquoteStage0, paragraph, placeholder, rule, getCellAttrs, getCellDomAttrs, status, table, tableStage0, tableWithCustomWidth, tableBackgroundBorderColor, tableBackgroundColorNames, tableBackgroundColorPalette, tableCell, tableCellContentDomSelector, tableCellContentWrapperSelector, tableCellSelector, tableHeader, tableHeaderSelector, tablePrefixSelector, tableRow, tableToJSON, taskItem, taskList, taskListSelector, text, toJSONTableCell, toJSONTableHeader, unknownBlock, unsupportedBlock, unsupportedInline, extensionFrame, multiBodiedExtension, tableWithNestedTable, tableRowWithNestedTable, tableCellWithNestedTable, tableHeaderWithNestedTable } from './nodes';
|
2
2
|
export { AnnotationTypes, alignment, alignmentPositionMap, annotation, breakout, code, colorPalette, /** @deprecated [ED-15849] The extended palette is now rolled into the main one. Use `colorPalette` instead. */
|
3
3
|
colorPaletteExtended, confluenceInlineComment, dataConsumer, dataConsumerToJSON, em, fragment, fragmentToJSON, indentation, link, linkToJSON, strike, strong, subsup, textColor, typeAheadQuery, underline, buildAnnotationMarkDataAttributes, AnnotationMarkStates, unsupportedMark, unsupportedNodeAttribute, border, borderColorPalette, backgroundColor, backgroundColorPalette } from './marks';
|
4
4
|
export { unsupportedNodeTypesForMediaCards } from './unsupported';
|
@@ -23,7 +23,7 @@ export { media, copyPrivateAttributes as copyPrivateMediaAttributes, toJSON as m
|
|
23
23
|
export { mediaGroup } from './media-group';
|
24
24
|
export { mediaInline } from './media-inline';
|
25
25
|
export { mediaSingle, mediaSingleSpec, mediaSingleWithCaption, mediaSingleWithWidthType, mediaSingleFull, toJSON as mediaSingleToJSON } from './media-single';
|
26
|
-
export { table, tableStage0, tableWithCustomWidth, tableToJSON, tableCell, toJSONTableCell, tableHeader, toJSONTableHeader, tableRow, tableBackgroundColorPalette, tableBackgroundBorderColor, tableBackgroundColorNames, getCellAttrs, getCellDomAttrs, tablePrefixSelector, tableCellSelector, tableHeaderSelector, tableCellContentWrapperSelector, tableCellContentDomSelector } from './tableNodes';
|
26
|
+
export { table, tableWithNestedTable, tableRowWithNestedTable, tableCellWithNestedTable, tableHeaderWithNestedTable, tableStage0, tableWithCustomWidth, tableToJSON, tableCell, toJSONTableCell, tableHeader, toJSONTableHeader, tableRow, tableBackgroundColorPalette, tableBackgroundBorderColor, tableBackgroundColorNames, getCellAttrs, getCellDomAttrs, tablePrefixSelector, tableCellSelector, tableHeaderSelector, tableCellContentWrapperSelector, tableCellContentDomSelector } from './tableNodes';
|
27
27
|
export { decisionList, decisionListSelector } from './decision-list';
|
28
28
|
export { decisionItem } from './decision-item';
|
29
29
|
export { taskList, taskListSelector } from './task-list';
|
@@ -2,10 +2,7 @@ import { hexToEditorBackgroundPaletteRawValue } from '../../utils/editor-palette
|
|
2
2
|
import { B100, B50, B75, G200, G50, G75, hexToRgba, isHex, isRgb, N0, N20, N60, N800, P100, P50, P75, R100, R50, R75, rgbToHex, T100, T50, T75, Y200, Y50, Y75 } from '../../utils/colors';
|
3
3
|
import { uuid } from '../../utils/uuid';
|
4
4
|
import { getDarkModeLCHColor } from '../../utils/lch-color-inversion';
|
5
|
-
import { table as tableFactory } from '../../next-schema/generated/nodeTypes';
|
6
|
-
import { tableCell as tableCellFactory } from '../../next-schema/generated/nodeTypes';
|
7
|
-
import { tableHeader as tableHeaderFactory } from '../../next-schema/generated/nodeTypes';
|
8
|
-
import { tableRow as tableRowFactory } from '../../next-schema/generated/nodeTypes';
|
5
|
+
import { table as tableFactory, tableWithNestedTable as tableWithNestedTableFactory, tableRow as tableRowFactory, tableRowWithNestedTable as tableRowWithNestedTableFactory, tableHeader as tableHeaderFactory, tableHeaderWithNestedTable as tableHeaderWithNestedTableFactory, tableCell as tableCellFactory, tableCellWithNestedTable as tableCellWithNestedTableFactory } from '../../next-schema/generated/nodeTypes';
|
9
6
|
export const tablePrefixSelector = 'pm-table';
|
10
7
|
export const tableCellSelector = `${tablePrefixSelector}-cell-content-wrap`;
|
11
8
|
export const tableHeaderSelector = `${tablePrefixSelector}-header-content-wrap`;
|
@@ -201,8 +198,9 @@ export const tableBackgroundColorNames = new Map();
|
|
201
198
|
* @name table_header_node
|
202
199
|
*/
|
203
200
|
|
204
|
-
//
|
205
|
-
|
201
|
+
// table nodes with nested tables support
|
202
|
+
|
203
|
+
const tableNodeSpecOptions = {
|
206
204
|
parseDOM: [{
|
207
205
|
tag: 'table',
|
208
206
|
getAttrs: node => {
|
@@ -233,7 +231,9 @@ const createTableSpec = () => tableFactory({
|
|
233
231
|
};
|
234
232
|
return ['table', attrs, ['tbody', 0]];
|
235
233
|
}
|
236
|
-
}
|
234
|
+
};
|
235
|
+
// TODO: Fix any, potential issue. ED-5048
|
236
|
+
const createTableSpec = () => tableFactory(tableNodeSpecOptions);
|
237
237
|
|
238
238
|
// TODO: assuming breaking changes aren't allowed, so retaining both exports
|
239
239
|
/** Includes table width attribute */
|
@@ -250,14 +250,15 @@ export const tableToJSON = node => ({
|
|
250
250
|
};
|
251
251
|
}, {})
|
252
252
|
});
|
253
|
-
|
253
|
+
const tableRowNodeSpecOptions = {
|
254
254
|
parseDOM: [{
|
255
255
|
tag: 'tr'
|
256
256
|
}],
|
257
257
|
toDOM() {
|
258
258
|
return ['tr', 0];
|
259
259
|
}
|
260
|
-
}
|
260
|
+
};
|
261
|
+
export const tableRow = tableRowFactory(tableRowNodeSpecOptions);
|
261
262
|
const cellAttrs = {
|
262
263
|
colspan: {
|
263
264
|
default: 1
|
@@ -272,7 +273,7 @@ const cellAttrs = {
|
|
272
273
|
default: null
|
273
274
|
}
|
274
275
|
};
|
275
|
-
|
276
|
+
const tableCellNodeSpecOptions = {
|
276
277
|
parseDOM: [
|
277
278
|
// Ignore number cell copied from renderer
|
278
279
|
{
|
@@ -283,7 +284,8 @@ export const tableCell = tableCellFactory({
|
|
283
284
|
getAttrs: dom => getCellAttrs(dom)
|
284
285
|
}],
|
285
286
|
toDOM: node => ['td', getCellDomAttrs(node), 0]
|
286
|
-
}
|
287
|
+
};
|
288
|
+
export const tableCell = tableCellFactory(tableCellNodeSpecOptions);
|
287
289
|
export const toJSONTableCell = node => ({
|
288
290
|
attrs: Object.keys(node.attrs).reduce((obj, key) => {
|
289
291
|
if (cellAttrs[key].default !== node.attrs[key]) {
|
@@ -292,7 +294,7 @@ export const toJSONTableCell = node => ({
|
|
292
294
|
return obj;
|
293
295
|
}, {})
|
294
296
|
});
|
295
|
-
|
297
|
+
const tableHeaderNodeSpecOptions = {
|
296
298
|
parseDOM: [{
|
297
299
|
tag: 'th',
|
298
300
|
getAttrs: dom => getCellAttrs(dom, {
|
@@ -300,5 +302,12 @@ export const tableHeader = tableHeaderFactory({
|
|
300
302
|
})
|
301
303
|
}],
|
302
304
|
toDOM: node => ['th', getCellDomAttrs(node), 0]
|
303
|
-
}
|
304
|
-
export const
|
305
|
+
};
|
306
|
+
export const tableHeader = tableHeaderFactory(tableHeaderNodeSpecOptions);
|
307
|
+
export const toJSONTableHeader = toJSONTableCell;
|
308
|
+
|
309
|
+
// table nodes with nested table support
|
310
|
+
export const tableWithNestedTable = tableWithNestedTableFactory(tableNodeSpecOptions);
|
311
|
+
export const tableRowWithNestedTable = tableRowWithNestedTableFactory(tableRowNodeSpecOptions);
|
312
|
+
export const tableCellWithNestedTable = tableCellWithNestedTableFactory(tableCellNodeSpecOptions);
|
313
|
+
export const tableHeaderWithNestedTable = tableHeaderWithNestedTableFactory(tableHeaderNodeSpecOptions);
|