@atlaskit/adf-schema 52.9.5 → 52.11.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 +27 -0
- package/dist/cjs/index.js +30 -0
- package/dist/cjs/next-schema/generated/nodeTypes.js +126 -1
- package/dist/cjs/next-schema/nodes/layoutColumn.js +29 -14
- package/dist/cjs/next-schema/nodes/tableNodes.js +63 -62
- package/dist/cjs/schema/default-schema.js +3 -2
- package/dist/cjs/schema/index.js +30 -0
- package/dist/cjs/schema/nodes/index.js +30 -0
- package/dist/cjs/schema/nodes/layout-column.js +87 -54
- package/dist/cjs/schema/nodes/tableNodes.js +69 -1
- package/dist/cjs/schema/nodes/types/valign.js +20 -0
- package/dist/cjs/validator-schema/generated/validatorSpec.js +15 -0
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/next-schema/generated/nodeTypes.js +125 -0
- package/dist/es2019/next-schema/nodes/layoutColumn.js +25 -13
- package/dist/es2019/next-schema/nodes/tableNodes.js +62 -60
- package/dist/es2019/schema/default-schema.js +4 -3
- package/dist/es2019/schema/index.js +1 -1
- package/dist/es2019/schema/nodes/index.js +2 -2
- package/dist/es2019/schema/nodes/layout-column.js +79 -58
- package/dist/es2019/schema/nodes/tableNodes.js +61 -1
- package/dist/es2019/schema/nodes/types/valign.js +14 -0
- package/dist/es2019/validator-schema/generated/validatorSpec.js +15 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/next-schema/generated/nodeTypes.js +125 -0
- package/dist/esm/next-schema/nodes/layoutColumn.js +28 -14
- package/dist/esm/next-schema/nodes/tableNodes.js +63 -62
- package/dist/esm/schema/default-schema.js +4 -3
- package/dist/esm/schema/index.js +1 -1
- package/dist/esm/schema/nodes/index.js +2 -2
- package/dist/esm/schema/nodes/layout-column.js +85 -54
- package/dist/esm/schema/nodes/tableNodes.js +69 -1
- package/dist/esm/schema/nodes/types/valign.js +14 -0
- package/dist/esm/validator-schema/generated/validatorSpec.js +15 -0
- package/dist/json-schema/v1/stage-0.json +9 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/next-schema/generated/nodeTypes.d.ts +77 -5
- package/dist/types/schema/index.d.ts +2 -2
- package/dist/types/schema/nodes/index.d.ts +6 -6
- package/dist/types/schema/nodes/layout-column.d.ts +7 -0
- package/dist/types/schema/nodes/tableNodes.d.ts +10 -0
- package/dist/types/schema/nodes/types/valign.d.ts +6 -0
- package/dist/types/validator-schema/generated/validatorSpec.d.ts +15 -0
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/next-schema/generated/nodeTypes.d.ts +77 -5
- package/dist/types-ts4.5/schema/index.d.ts +2 -2
- package/dist/types-ts4.5/schema/nodes/index.d.ts +6 -6
- package/dist/types-ts4.5/schema/nodes/layout-column.d.ts +7 -0
- package/dist/types-ts4.5/schema/nodes/tableNodes.d.ts +10 -0
- package/dist/types-ts4.5/schema/nodes/types/valign.d.ts +6 -0
- package/dist/types-ts4.5/validator-schema/generated/validatorSpec.d.ts +15 -0
- package/json-schema/v1/stage-0.json +9 -0
- package/package.json +3 -3
|
@@ -9,42 +9,55 @@ import { unsupportedBlock } from './unsupportedBlock';
|
|
|
9
9
|
|
|
10
10
|
// Declare early to allow for circular references within the file
|
|
11
11
|
const table = adfNode('table');
|
|
12
|
+
const valign = {
|
|
13
|
+
type: 'enum',
|
|
14
|
+
values: ['top', 'middle', 'bottom'],
|
|
15
|
+
default: null,
|
|
16
|
+
optional: true
|
|
17
|
+
};
|
|
18
|
+
const cellAttributes = {
|
|
19
|
+
colspan: {
|
|
20
|
+
type: 'number',
|
|
21
|
+
default: 1,
|
|
22
|
+
optional: true
|
|
23
|
+
},
|
|
24
|
+
rowspan: {
|
|
25
|
+
type: 'number',
|
|
26
|
+
default: 1,
|
|
27
|
+
optional: true
|
|
28
|
+
},
|
|
29
|
+
colwidth: {
|
|
30
|
+
type: 'array',
|
|
31
|
+
items: {
|
|
32
|
+
type: 'number'
|
|
33
|
+
},
|
|
34
|
+
default: null,
|
|
35
|
+
optional: true
|
|
36
|
+
},
|
|
37
|
+
background: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
default: null,
|
|
40
|
+
optional: true
|
|
41
|
+
},
|
|
42
|
+
localId: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
default: null,
|
|
45
|
+
optional: true
|
|
46
|
+
}
|
|
47
|
+
};
|
|
12
48
|
const tableCell = adfNode('tableCell').define({
|
|
13
49
|
isolating: true,
|
|
14
50
|
selectable: false,
|
|
15
51
|
tableRole: 'cell',
|
|
16
52
|
marks: [unsupportedMark, unsupportedNodeAttribute],
|
|
17
|
-
attrs:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
localId: {
|
|
42
|
-
type: 'string',
|
|
43
|
-
default: null,
|
|
44
|
-
optional: true
|
|
53
|
+
attrs: cellAttributes,
|
|
54
|
+
content: [tableCellContentPseudoGroup],
|
|
55
|
+
stage0: {
|
|
56
|
+
attrs: {
|
|
57
|
+
...cellAttributes,
|
|
58
|
+
valign
|
|
45
59
|
}
|
|
46
60
|
},
|
|
47
|
-
content: [tableCellContentPseudoGroup],
|
|
48
61
|
DANGEROUS_MANUAL_OVERRIDE: {
|
|
49
62
|
'validator-spec': {
|
|
50
63
|
required: {
|
|
@@ -55,44 +68,27 @@ const tableCell = adfNode('tableCell').define({
|
|
|
55
68
|
}
|
|
56
69
|
}).variant('with_nested_table', {
|
|
57
70
|
content: [$onePlus($or(...tableCellContentNodes, unsupportedBlock, table))],
|
|
58
|
-
ignore: ['json-schema', 'validator-spec']
|
|
71
|
+
ignore: ['json-schema', 'validator-spec'],
|
|
72
|
+
stage0: {
|
|
73
|
+
attrs: {
|
|
74
|
+
...cellAttributes,
|
|
75
|
+
valign
|
|
76
|
+
}
|
|
77
|
+
}
|
|
59
78
|
});
|
|
60
79
|
const tableHeader = adfNode('tableHeader').define({
|
|
61
80
|
isolating: true,
|
|
62
81
|
selectable: false,
|
|
63
82
|
tableRole: 'header_cell',
|
|
64
83
|
marks: [unsupportedMark, unsupportedNodeAttribute],
|
|
65
|
-
attrs:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
rowspan: {
|
|
72
|
-
type: 'number',
|
|
73
|
-
default: 1,
|
|
74
|
-
optional: true
|
|
75
|
-
},
|
|
76
|
-
colwidth: {
|
|
77
|
-
type: 'array',
|
|
78
|
-
items: {
|
|
79
|
-
type: 'number'
|
|
80
|
-
},
|
|
81
|
-
default: null,
|
|
82
|
-
optional: true
|
|
83
|
-
},
|
|
84
|
-
background: {
|
|
85
|
-
type: 'string',
|
|
86
|
-
default: null,
|
|
87
|
-
optional: true
|
|
88
|
-
},
|
|
89
|
-
localId: {
|
|
90
|
-
type: 'string',
|
|
91
|
-
default: null,
|
|
92
|
-
optional: true
|
|
84
|
+
attrs: cellAttributes,
|
|
85
|
+
content: [tableHeaderContentPseudoGroup],
|
|
86
|
+
stage0: {
|
|
87
|
+
attrs: {
|
|
88
|
+
...cellAttributes,
|
|
89
|
+
valign
|
|
93
90
|
}
|
|
94
91
|
},
|
|
95
|
-
content: [tableHeaderContentPseudoGroup],
|
|
96
92
|
DANGEROUS_MANUAL_OVERRIDE: {
|
|
97
93
|
'validator-spec': {
|
|
98
94
|
required: {
|
|
@@ -103,7 +99,13 @@ const tableHeader = adfNode('tableHeader').define({
|
|
|
103
99
|
}
|
|
104
100
|
}).variant('with_nested_table', {
|
|
105
101
|
content: [$onePlus($or(...tableCellContentNodes, nestedExpand, table))],
|
|
106
|
-
ignore: ['json-schema', 'validator-spec']
|
|
102
|
+
ignore: ['json-schema', 'validator-spec'],
|
|
103
|
+
stage0: {
|
|
104
|
+
attrs: {
|
|
105
|
+
...cellAttributes,
|
|
106
|
+
valign
|
|
107
|
+
}
|
|
108
|
+
}
|
|
107
109
|
});
|
|
108
110
|
const tableRow = adfNode('tableRow').define({
|
|
109
111
|
selectable: false,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import memoizeOne from 'memoize-one';
|
|
2
|
-
import { extensionFrame, layoutSectionWithSingleColumn, multiBodiedExtension, expandWithNestedExpand, tableWithNestedTable, tableRowWithNestedTable,
|
|
2
|
+
import { extensionFrame, layoutSectionWithSingleColumn, multiBodiedExtension, expandWithNestedExpand, tableWithNestedTable, tableRowWithNestedTable, tableCellWithNestedTableStage0, tableHeaderWithNestedTableStage0, layoutColumnStage0, codeBlockWithExtendedAttributes } from './nodes';
|
|
3
3
|
import { createSchema } from './create-schema';
|
|
4
4
|
const getDefaultSchemaConfig = () => {
|
|
5
5
|
const defaultSchemaConfig = {
|
|
@@ -20,13 +20,14 @@ export const getSchemaBasedOnStage = memoizeOne(
|
|
|
20
20
|
if (stage === 'stage0') {
|
|
21
21
|
defaultSchemaConfig.customNodeSpecs = {
|
|
22
22
|
layoutSection: layoutSectionWithSingleColumn,
|
|
23
|
+
layoutColumn: layoutColumnStage0,
|
|
23
24
|
multiBodiedExtension: multiBodiedExtension,
|
|
24
25
|
extensionFrame: extensionFrame,
|
|
25
26
|
expand: expandWithNestedExpand,
|
|
26
27
|
table: tableWithNestedTable,
|
|
27
28
|
tableRow: tableRowWithNestedTable,
|
|
28
|
-
tableCell:
|
|
29
|
-
tableHeader:
|
|
29
|
+
tableCell: tableCellWithNestedTableStage0,
|
|
30
|
+
tableHeader: tableHeaderWithNestedTableStage0,
|
|
30
31
|
codeBlock: codeBlockWithExtendedAttributes
|
|
31
32
|
};
|
|
32
33
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
2
|
-
export { PanelType, blockCard, blockCardWithLocalId, blockquote, extendedBlockquote, extendedBlockquoteWithLocalId, bodiedExtension, bulletList, bulletListSelector, bulletListWithLocalId, caption, captionWithLocalId, codeBlock, codeBlockWithLocalId, codeBlockWithExtendedAttributes, codeBlockToJSON, confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, date, dateWithLocalId, decisionItem, decisionList, decisionListSelector, doc, embedCard, embedCardWithLocalId, emoji, emojiWithLocalId, expandWithNestedExpand, expandWithNestedExpandLocalId, expandToJSON, extension, hardBreak, heading, image, inlineCard, inlineCardWithLocalId, inlineExtension, layoutColumn, layoutColumnWithLocalId, layoutSection, layoutSectionWithLocalId, layoutSectionWithSingleColumn, layoutSectionWithSingleColumnLocalId, listItem, listItemWithLocalId, media, mediaGroup, mediaSingle, mediaSingleSpec, mediaInline, mediaSingleWithCaption, mediaSingleWithWidthType, mediaSingleFull, mediaSingleFullWithLocalId, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, nestedExpandWithLocalId, orderedList, orderedListSelector, orderedListWithLocalId, orderedListWithOrder, orderedListWithOrderAndLocalId, extendedPanel, extendedPanelWithLocalId, paragraph, placeholder, placeholderWithLocalId, rule, ruleWithLocalId, getCellAttrs, getCellDomAttrs, status, table, tableStage0, tableWithCustomWidth, tableBackgroundBorderColor, tableBackgroundColorNames, tableBackgroundColorPalette, tableCell, tableCellContentDomSelector, tableCellContentWrapperSelector, tableCellSelector, tableHeader, tableHeaderSelector, tablePrefixSelector, tableRow, tableToJSON, taskItem, blockTaskItem, taskList, taskListSelector, text, toJSONTableCell, toJSONTableHeader, unknownBlock, unsupportedBlock, unsupportedInline, extensionFrame, multiBodiedExtension, syncBlock, bodiedSyncBlock, tableWithNestedTable, tableRowWithNestedTable, tableCellWithNestedTable, tableHeaderWithNestedTable, tableRowWithLocalId, tableCellWithLocalId, tableHeaderWithLocalId, tableRowWithNestedTableWithLocalId, tableCellWithNestedTableWithLocalId, tableHeaderWithNestedTableWithLocalId } from './nodes';
|
|
2
|
+
export { PanelType, blockCard, blockCardWithLocalId, blockquote, extendedBlockquote, extendedBlockquoteWithLocalId, bodiedExtension, bulletList, bulletListSelector, bulletListWithLocalId, caption, captionWithLocalId, codeBlock, codeBlockWithLocalId, codeBlockWithExtendedAttributes, codeBlockToJSON, confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, date, dateWithLocalId, decisionItem, decisionList, decisionListSelector, doc, embedCard, embedCardWithLocalId, emoji, emojiWithLocalId, expandWithNestedExpand, expandWithNestedExpandLocalId, expandToJSON, extension, hardBreak, heading, image, inlineCard, inlineCardWithLocalId, inlineExtension, layoutColumn, layoutColumnStage0, layoutColumnWithLocalId, layoutSection, layoutSectionWithLocalId, layoutSectionWithSingleColumn, layoutSectionWithSingleColumnLocalId, listItem, listItemWithLocalId, media, mediaGroup, mediaSingle, mediaSingleSpec, mediaInline, mediaSingleWithCaption, mediaSingleWithWidthType, mediaSingleFull, mediaSingleFullWithLocalId, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, nestedExpandWithLocalId, orderedList, orderedListSelector, orderedListWithLocalId, orderedListWithOrder, orderedListWithOrderAndLocalId, extendedPanel, extendedPanelWithLocalId, paragraph, placeholder, placeholderWithLocalId, rule, ruleWithLocalId, getCellAttrs, getCellDomAttrs, status, table, tableStage0, tableWithCustomWidth, tableBackgroundBorderColor, tableBackgroundColorNames, tableBackgroundColorPalette, tableCell, tableCellContentDomSelector, tableCellContentWrapperSelector, tableCellSelector, tableHeader, tableHeaderSelector, tablePrefixSelector, tableRow, tableToJSON, taskItem, blockTaskItem, taskList, taskListSelector, text, toJSONTableCell, toJSONTableHeader, unknownBlock, unsupportedBlock, unsupportedInline, extensionFrame, multiBodiedExtension, syncBlock, bodiedSyncBlock, tableWithNestedTable, tableRowWithNestedTable, tableCellWithNestedTable, tableHeaderWithNestedTable, tableCellStage0, tableHeaderStage0, tableCellWithNestedTableStage0, tableHeaderWithNestedTableStage0, tableRowWithLocalId, tableCellWithLocalId, tableHeaderWithLocalId, tableRowWithNestedTableWithLocalId, tableCellWithNestedTableWithLocalId, tableHeaderWithNestedTableWithLocalId } from './nodes';
|
|
3
3
|
export { AnnotationTypes, alignment, alignmentPositionMap, annotation, fontSize, breakout, code, colorPalette,
|
|
4
4
|
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required
|
|
5
5
|
/** @deprecated [ED-15849] The extended palette is now rolled into the main one. Use `colorPalette` instead. */
|
|
@@ -24,7 +24,7 @@ export { media, copyPrivateAttributes as copyPrivateMediaAttributes, toJSON as m
|
|
|
24
24
|
export { mediaGroup } from './media-group';
|
|
25
25
|
export { mediaInline } from './media-inline';
|
|
26
26
|
export { mediaSingle, mediaSingleSpec, mediaSingleWithCaption, mediaSingleWithWidthType, mediaSingleFull, mediaSingleFullWithLocalId, toJSON as mediaSingleToJSON } from './media-single';
|
|
27
|
-
export { table, tableWithNestedTable, tableRowWithNestedTable, tableCellWithNestedTable, tableHeaderWithNestedTable, tableRowWithLocalId, tableCellWithLocalId, tableHeaderWithLocalId, tableRowWithNestedTableWithLocalId, tableCellWithNestedTableWithLocalId, tableHeaderWithNestedTableWithLocalId, tableStage0, tableWithCustomWidth, tableToJSON, tableCell, toJSONTableCell, tableHeader, toJSONTableHeader, tableRow, tableBackgroundColorPalette, tableBackgroundBorderColor, tableBackgroundColorNames, getCellAttrs, getCellDomAttrs, tablePrefixSelector, tableCellSelector, tableHeaderSelector, tableCellContentWrapperSelector, tableCellContentDomSelector } from './tableNodes';
|
|
27
|
+
export { table, tableWithNestedTable, tableRowWithNestedTable, tableCellWithNestedTable, tableHeaderWithNestedTable, tableCellStage0, tableHeaderStage0, tableCellWithNestedTableStage0, tableHeaderWithNestedTableStage0, tableRowWithLocalId, tableCellWithLocalId, tableHeaderWithLocalId, tableRowWithNestedTableWithLocalId, tableCellWithNestedTableWithLocalId, tableHeaderWithNestedTableWithLocalId, tableStage0, tableWithCustomWidth, tableToJSON, tableCell, toJSONTableCell, tableHeader, toJSONTableHeader, tableRow, tableBackgroundColorPalette, tableBackgroundBorderColor, tableBackgroundColorNames, getCellAttrs, getCellDomAttrs, tablePrefixSelector, tableCellSelector, tableHeaderSelector, tableCellContentWrapperSelector, tableCellContentDomSelector } from './tableNodes';
|
|
28
28
|
export { decisionList, decisionListSelector } from './decision-list';
|
|
29
29
|
export { decisionItem } from './decision-item';
|
|
30
30
|
export { taskList, taskListSelector } from './task-list';
|
|
@@ -32,7 +32,7 @@ export { taskItem, blockTaskItem } from './task-item';
|
|
|
32
32
|
export { date, dateWithLocalId } from './date';
|
|
33
33
|
export { placeholder, placeholderWithLocalId } from './placeholder';
|
|
34
34
|
export { layoutSection, layoutSectionWithLocalId, layoutSectionWithSingleColumn, layoutSectionWithSingleColumnLocalId } from './layout-section';
|
|
35
|
-
export { layoutColumn, layoutColumnWithLocalId } from './layout-column';
|
|
35
|
+
export { layoutColumn, layoutColumnStage0, layoutColumnWithLocalId } from './layout-column';
|
|
36
36
|
export { inlineCard, inlineCardWithLocalId } from './inline-card';
|
|
37
37
|
export { blockCard, blockCardWithLocalId } from './block-card';
|
|
38
38
|
export { unsupportedBlock } from './unsupported-block';
|
|
@@ -1,6 +1,57 @@
|
|
|
1
|
-
import { layoutColumn as layoutColumnFactory } from '../../next-schema/generated/nodeTypes';
|
|
1
|
+
import { layoutColumn as layoutColumnFactory, layoutColumnStage0 as layoutColumnStage0Factory } from '../../next-schema/generated/nodeTypes';
|
|
2
2
|
import { uuid } from '../../utils/uuid';
|
|
3
3
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
|
+
import { parseValign } from './types/valign';
|
|
5
|
+
const setColumnAttributes = (node, {
|
|
6
|
+
withLocalId = false,
|
|
7
|
+
withValign = false
|
|
8
|
+
} = {}) => {
|
|
9
|
+
const attrs = {
|
|
10
|
+
'data-layout-column': 'true'
|
|
11
|
+
};
|
|
12
|
+
const {
|
|
13
|
+
width,
|
|
14
|
+
valign,
|
|
15
|
+
localId
|
|
16
|
+
} = node.attrs;
|
|
17
|
+
if (width) {
|
|
18
|
+
const baseStyle = `flex-basis: ${width}%`;
|
|
19
|
+
const columnWidthVar = editorExperiment('platform_editor_layout_column_resize_handle', true) ? `; --column-width: ${width}%` : '';
|
|
20
|
+
attrs['style'] = baseStyle + columnWidthVar;
|
|
21
|
+
attrs['data-column-width'] = `${width}`;
|
|
22
|
+
}
|
|
23
|
+
if (withValign && valign) {
|
|
24
|
+
attrs['data-valign'] = valign;
|
|
25
|
+
}
|
|
26
|
+
if (withLocalId && localId) {
|
|
27
|
+
attrs['data-local-id'] = localId;
|
|
28
|
+
}
|
|
29
|
+
return attrs;
|
|
30
|
+
};
|
|
31
|
+
const getColumnAttrs = ({
|
|
32
|
+
withLocalId = false,
|
|
33
|
+
withValign = false
|
|
34
|
+
} = {}) => domNode => {
|
|
35
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
36
|
+
const dom = domNode;
|
|
37
|
+
const base = {
|
|
38
|
+
width: Number(dom.getAttribute('data-column-width')) || undefined,
|
|
39
|
+
...(withLocalId && {
|
|
40
|
+
localId: uuid.generate()
|
|
41
|
+
})
|
|
42
|
+
};
|
|
43
|
+
const valign = parseValign(dom.getAttribute('data-valign'));
|
|
44
|
+
return withValign && valign ? {
|
|
45
|
+
...base,
|
|
46
|
+
valign
|
|
47
|
+
} : base;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// We need to apply an attribute to the innermost child to help ProseMirror
|
|
51
|
+
// identify its boundaries better.
|
|
52
|
+
const LAYOUT_CONTENT_ATTRS = {
|
|
53
|
+
'data-layout-content': 'true'
|
|
54
|
+
};
|
|
4
55
|
|
|
5
56
|
/**
|
|
6
57
|
* @name layoutColumn_node
|
|
@@ -13,34 +64,29 @@ export const layoutColumn = layoutColumnFactory({
|
|
|
13
64
|
skip: true
|
|
14
65
|
}, {
|
|
15
66
|
tag: 'div[data-layout-column]',
|
|
16
|
-
getAttrs:
|
|
17
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
18
|
-
const dom = domNode;
|
|
19
|
-
return {
|
|
20
|
-
width: Number(dom.getAttribute('data-column-width')) || undefined
|
|
21
|
-
};
|
|
22
|
-
}
|
|
67
|
+
getAttrs: getColumnAttrs()
|
|
23
68
|
}],
|
|
24
69
|
toDOM(node) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
70
|
+
return ['div', setColumnAttributes(node), ['div', LAYOUT_CONTENT_ATTRS, 0]];
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
export const layoutColumnStage0 = layoutColumnStage0Factory({
|
|
74
|
+
parseDOM: [{
|
|
75
|
+
context: 'layoutColumn//',
|
|
76
|
+
tag: 'div[data-layout-column]',
|
|
77
|
+
skip: true
|
|
78
|
+
}, {
|
|
79
|
+
tag: 'div[data-layout-column]',
|
|
80
|
+
getAttrs: getColumnAttrs({
|
|
81
|
+
withLocalId: true,
|
|
82
|
+
withValign: true
|
|
83
|
+
})
|
|
84
|
+
}],
|
|
85
|
+
toDOM(node) {
|
|
86
|
+
return ['div', setColumnAttributes(node, {
|
|
87
|
+
withLocalId: true,
|
|
88
|
+
withValign: true
|
|
89
|
+
}), ['div', LAYOUT_CONTENT_ATTRS, 0]];
|
|
44
90
|
}
|
|
45
91
|
});
|
|
46
92
|
export const layoutColumnWithLocalId = layoutColumnFactory({
|
|
@@ -50,38 +96,13 @@ export const layoutColumnWithLocalId = layoutColumnFactory({
|
|
|
50
96
|
skip: true
|
|
51
97
|
}, {
|
|
52
98
|
tag: 'div[data-layout-column]',
|
|
53
|
-
getAttrs:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
width: Number(dom.getAttribute('data-column-width')) || undefined,
|
|
58
|
-
localId: uuid.generate()
|
|
59
|
-
};
|
|
60
|
-
}
|
|
99
|
+
getAttrs: getColumnAttrs({
|
|
100
|
+
withLocalId: true
|
|
101
|
+
})
|
|
61
102
|
}],
|
|
62
103
|
toDOM(node) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
67
|
-
if ((node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) !== undefined) {
|
|
68
|
-
attrs['data-local-id'] = node.attrs.localId;
|
|
69
|
-
}
|
|
70
|
-
const {
|
|
71
|
-
width
|
|
72
|
-
} = node.attrs;
|
|
73
|
-
if (width) {
|
|
74
|
-
const baseStyle = `flex-basis: ${width}%`;
|
|
75
|
-
const columnWidthVar = editorExperiment('platform_editor_layout_column_resize_handle', true) ? `; --column-width: ${width}%` : '';
|
|
76
|
-
attrs['style'] = baseStyle + columnWidthVar;
|
|
77
|
-
attrs['data-column-width'] = `${width}`;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// We need to apply a attribute to the inner most child to help
|
|
81
|
-
// ProseMirror identify its boundaries better.
|
|
82
|
-
const contentAttrs = {
|
|
83
|
-
'data-layout-content': 'true'
|
|
84
|
-
};
|
|
85
|
-
return ['div', attrs, ['div', contentAttrs, 0]];
|
|
104
|
+
return ['div', setColumnAttributes(node, {
|
|
105
|
+
withLocalId: true
|
|
106
|
+
}), ['div', LAYOUT_CONTENT_ATTRS, 0]];
|
|
86
107
|
}
|
|
87
108
|
});
|
|
@@ -2,7 +2,8 @@ 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, 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';
|
|
5
|
+
import { table as tableFactory, tableWithNestedTable as tableWithNestedTableFactory, tableRow as tableRowFactory, tableRowWithNestedTable as tableRowWithNestedTableFactory, tableHeader as tableHeaderFactory, tableHeaderWithNestedTable as tableHeaderWithNestedTableFactory, tableHeaderWithNestedTableStage0 as tableHeaderWithNestedTableStage0Factory, tableHeaderStage0 as tableHeaderStage0Factory, tableCell as tableCellFactory, tableCellWithNestedTable as tableCellWithNestedTableFactory, tableCellWithNestedTableStage0 as tableCellWithNestedTableStage0Factory, tableCellStage0 as tableCellStage0Factory } from '../../next-schema/generated/nodeTypes';
|
|
6
|
+
import { parseValign } from './types/valign';
|
|
6
7
|
export const tablePrefixSelector = 'pm-table';
|
|
7
8
|
export const tableCellSelector = `${tablePrefixSelector}-cell-content-wrap`;
|
|
8
9
|
export const tableHeaderSelector = `${tablePrefixSelector}-header-content-wrap`;
|
|
@@ -182,6 +183,26 @@ export const getCellDomAttrs = node => {
|
|
|
182
183
|
}
|
|
183
184
|
return attrs;
|
|
184
185
|
};
|
|
186
|
+
const getCellAttrsWithValign = (dom, defaultValues) => {
|
|
187
|
+
const base = getCellAttrs(dom, defaultValues);
|
|
188
|
+
const valign = parseValign(dom.getAttribute('data-valign'));
|
|
189
|
+
return valign ? {
|
|
190
|
+
...base,
|
|
191
|
+
valign
|
|
192
|
+
} : base;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* @stage 0
|
|
197
|
+
* Valign-aware variant of getCellDomAttrs — emits the `valign` HTML attribute when set to a non-default value.
|
|
198
|
+
*/
|
|
199
|
+
const getCellDomAttrsWithValign = node => {
|
|
200
|
+
const attrs = getCellDomAttrs(node);
|
|
201
|
+
if (node.attrs.valign) {
|
|
202
|
+
attrs['data-valign'] = node.attrs.valign;
|
|
203
|
+
}
|
|
204
|
+
return attrs;
|
|
205
|
+
};
|
|
185
206
|
export const tableBackgroundColorPalette = new Map();
|
|
186
207
|
export const tableBackgroundBorderColor = hexToRgba(N800, 0.12) || N0;
|
|
187
208
|
export const tableBackgroundColorNames = new Map();
|
|
@@ -293,6 +314,10 @@ const cellAttrs = {
|
|
|
293
314
|
localId: {
|
|
294
315
|
default: null,
|
|
295
316
|
optional: true
|
|
317
|
+
},
|
|
318
|
+
valign: {
|
|
319
|
+
default: null,
|
|
320
|
+
optional: true
|
|
296
321
|
}
|
|
297
322
|
};
|
|
298
323
|
const tableCellNodeSpecOptions = {
|
|
@@ -337,6 +362,41 @@ export const tableWithNestedTable = tableWithNestedTableFactory(tableNodeSpecOpt
|
|
|
337
362
|
export const tableRowWithNestedTable = tableRowWithNestedTableFactory(tableRowNodeSpecOptions);
|
|
338
363
|
export const tableCellWithNestedTable = tableCellWithNestedTableFactory(tableCellNodeSpecOptions);
|
|
339
364
|
export const tableHeaderWithNestedTable = tableHeaderWithNestedTableFactory(tableHeaderNodeSpecOptions);
|
|
365
|
+
|
|
366
|
+
// stage-0 table cell nodes with vertical alignment and localId support
|
|
367
|
+
const tableCellNodeStage0SpecOptions = {
|
|
368
|
+
parseDOM: [
|
|
369
|
+
// Ignore number cell copied from renderer
|
|
370
|
+
{
|
|
371
|
+
tag: '.ak-renderer-table-number-column',
|
|
372
|
+
ignore: true
|
|
373
|
+
}, {
|
|
374
|
+
tag: 'td',
|
|
375
|
+
getAttrs: dom => getCellAttrsWithValign(
|
|
376
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
377
|
+
dom, {
|
|
378
|
+
localId: uuid.generate()
|
|
379
|
+
})
|
|
380
|
+
}],
|
|
381
|
+
toDOM: node => ['td', getCellDomAttrsWithValign(node), 0]
|
|
382
|
+
};
|
|
383
|
+
const tableHeaderNodeStage0SpecOptions = {
|
|
384
|
+
parseDOM: [{
|
|
385
|
+
tag: 'th',
|
|
386
|
+
getAttrs: dom =>
|
|
387
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
388
|
+
getCellAttrsWithValign(dom, {
|
|
389
|
+
background: DEFAULT_TABLE_HEADER_CELL_BACKGROUND,
|
|
390
|
+
localId: uuid.generate()
|
|
391
|
+
})
|
|
392
|
+
}],
|
|
393
|
+
toDOM: node => ['th', getCellDomAttrsWithValign(node), 0]
|
|
394
|
+
};
|
|
395
|
+
export const tableCellStage0 = tableCellStage0Factory(tableCellNodeStage0SpecOptions);
|
|
396
|
+
export const tableHeaderStage0 = tableHeaderStage0Factory(tableHeaderNodeStage0SpecOptions);
|
|
397
|
+
export const tableCellWithNestedTableStage0 = tableCellWithNestedTableStage0Factory(tableCellNodeStage0SpecOptions);
|
|
398
|
+
export const tableHeaderWithNestedTableStage0 = tableHeaderWithNestedTableStage0Factory(tableHeaderNodeStage0SpecOptions);
|
|
399
|
+
|
|
340
400
|
// table nodes with localId support
|
|
341
401
|
const tableRowNodeSpecOptionsWithLocalId = {
|
|
342
402
|
parseDOM: [{
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses a raw DOM attribute string into a valid {@link Valign}, or `undefined` if
|
|
3
|
+
* the value is absent or not one of the allowed values.
|
|
4
|
+
*/
|
|
5
|
+
export const parseValign = raw => {
|
|
6
|
+
switch (raw) {
|
|
7
|
+
case 'top':
|
|
8
|
+
case 'middle':
|
|
9
|
+
case 'bottom':
|
|
10
|
+
return raw;
|
|
11
|
+
default:
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -992,6 +992,11 @@ export const layoutColumn = {
|
|
|
992
992
|
optional: true,
|
|
993
993
|
type: 'string'
|
|
994
994
|
},
|
|
995
|
+
valign: {
|
|
996
|
+
optional: true,
|
|
997
|
+
type: 'enum',
|
|
998
|
+
values: ['top', 'middle', 'bottom']
|
|
999
|
+
},
|
|
995
1000
|
width: {
|
|
996
1001
|
maximum: 100,
|
|
997
1002
|
minimum: 0,
|
|
@@ -1832,6 +1837,11 @@ export const tableCell = {
|
|
|
1832
1837
|
rowspan: {
|
|
1833
1838
|
optional: true,
|
|
1834
1839
|
type: 'number'
|
|
1840
|
+
},
|
|
1841
|
+
valign: {
|
|
1842
|
+
optional: true,
|
|
1843
|
+
type: 'enum',
|
|
1844
|
+
values: ['top', 'middle', 'bottom']
|
|
1835
1845
|
}
|
|
1836
1846
|
}
|
|
1837
1847
|
},
|
|
@@ -1875,6 +1885,11 @@ export const tableHeader = {
|
|
|
1875
1885
|
rowspan: {
|
|
1876
1886
|
optional: true,
|
|
1877
1887
|
type: 'number'
|
|
1888
|
+
},
|
|
1889
|
+
valign: {
|
|
1890
|
+
optional: true,
|
|
1891
|
+
type: 'enum',
|
|
1892
|
+
values: ['top', 'middle', 'bottom']
|
|
1878
1893
|
}
|
|
1879
1894
|
}
|
|
1880
1895
|
},
|
package/dist/esm/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export { PanelType, AnnotationTypes, alignment, alignmentPositionMap, annotation, blockCard, blockCardWithLocalId, blockquote, extendedBlockquote, extendedBlockquoteWithLocalId, bodiedExtension, fontSize, breakout, bulletList, bulletListSelector, bulletListWithLocalId, caption, captionWithLocalId, code, codeBlock, codeBlockWithLocalId, codeBlockWithExtendedAttributes, codeBlockToJSON, colorPalette,
|
|
3
3
|
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required
|
|
4
4
|
/** @deprecated [ED-15849] The extended palette is now rolled into the main one. Use `colorPalette` instead. */
|
|
5
|
-
colorPaletteExtended, confluenceInlineComment, confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, createSchema, dataConsumer, dataConsumerToJSON, date, dateWithLocalId, decisionItem, decisionList, decisionListSelector, doc, em, embedCard, embedCardWithLocalId, emoji, emojiWithLocalId, expandWithNestedExpand, expandWithNestedExpandLocalId, expandToJSON, extension, fragment, fragmentToJSON, hardBreak, heading, image, indentation, inlineCard, inlineCardWithLocalId, inlineExtension, inlineNodes, layoutColumn, layoutColumnWithLocalId, layoutSection, layoutSectionWithLocalId, layoutSectionWithSingleColumn, layoutSectionWithSingleColumnLocalId, link, linkToJSON, listItem, listItemWithLocalId, media, mediaGroup, mediaSingle, mediaSingleWithCaption, mediaSingleWithWidthType, mediaSingleFull, mediaSingleFullWithLocalId, mediaSingleSpec, mediaInline, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, nestedExpandWithLocalId, orderedList, orderedListSelector, orderedListWithLocalId, orderedListWithOrder, orderedListWithOrderAndLocalId, extendedPanel, extendedPanelWithLocalId, paragraph, placeholder, placeholderWithLocalId, rule, ruleWithLocalId, sanitizeNodes, getCellAttrs, getCellDomAttrs, status, strike, strong, subsup, table, tableStage0, tableWithCustomWidth, tableBackgroundBorderColor, tableBackgroundColorNames, tableBackgroundColorPalette, tableCell, tableCellContentDomSelector, tableCellContentWrapperSelector, tableCellSelector, tableHeader, tableHeaderSelector, tablePrefixSelector, tableRow, tableToJSON, taskItem, blockTaskItem, taskList, taskListSelector, text, textColor, toJSONTableCell, toJSONTableHeader, typeAheadQuery, underline, unknownBlock, unsupportedBlock, unsupportedInline, unsupportedNodeTypesForMediaCards, buildAnnotationMarkDataAttributes, AnnotationMarkStates, unsupportedMark, unsupportedNodeAttribute, border, borderColorPalette, extensionFrame, multiBodiedExtension, backgroundColor, backgroundColorPalette, syncBlock, bodiedSyncBlock, tableWithNestedTable, tableRowWithNestedTable, tableCellWithNestedTable, tableHeaderWithNestedTable, tableRowWithLocalId, tableCellWithLocalId, tableHeaderWithLocalId, tableRowWithNestedTableWithLocalId, tableCellWithNestedTableWithLocalId, tableHeaderWithNestedTableWithLocalId } from './schema';
|
|
5
|
+
colorPaletteExtended, confluenceInlineComment, confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, createSchema, dataConsumer, dataConsumerToJSON, date, dateWithLocalId, decisionItem, decisionList, decisionListSelector, doc, em, embedCard, embedCardWithLocalId, emoji, emojiWithLocalId, expandWithNestedExpand, expandWithNestedExpandLocalId, expandToJSON, extension, fragment, fragmentToJSON, hardBreak, heading, image, indentation, inlineCard, inlineCardWithLocalId, inlineExtension, inlineNodes, layoutColumn, layoutColumnStage0, layoutColumnWithLocalId, layoutSection, layoutSectionWithLocalId, layoutSectionWithSingleColumn, layoutSectionWithSingleColumnLocalId, link, linkToJSON, listItem, listItemWithLocalId, media, mediaGroup, mediaSingle, mediaSingleWithCaption, mediaSingleWithWidthType, mediaSingleFull, mediaSingleFullWithLocalId, mediaSingleSpec, mediaInline, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, nestedExpandWithLocalId, orderedList, orderedListSelector, orderedListWithLocalId, orderedListWithOrder, orderedListWithOrderAndLocalId, extendedPanel, extendedPanelWithLocalId, paragraph, placeholder, placeholderWithLocalId, rule, ruleWithLocalId, sanitizeNodes, getCellAttrs, getCellDomAttrs, status, strike, strong, subsup, table, tableStage0, tableWithCustomWidth, tableBackgroundBorderColor, tableBackgroundColorNames, tableBackgroundColorPalette, tableCell, tableCellContentDomSelector, tableCellContentWrapperSelector, tableCellSelector, tableHeader, tableHeaderSelector, tablePrefixSelector, tableRow, tableToJSON, taskItem, blockTaskItem, taskList, taskListSelector, text, textColor, toJSONTableCell, toJSONTableHeader, typeAheadQuery, underline, unknownBlock, unsupportedBlock, unsupportedInline, unsupportedNodeTypesForMediaCards, buildAnnotationMarkDataAttributes, AnnotationMarkStates, unsupportedMark, unsupportedNodeAttribute, border, borderColorPalette, extensionFrame, multiBodiedExtension, backgroundColor, backgroundColorPalette, syncBlock, bodiedSyncBlock, tableWithNestedTable, tableRowWithNestedTable, tableCellWithNestedTable, tableHeaderWithNestedTable, tableCellStage0, tableHeaderStage0, tableCellWithNestedTableStage0, tableHeaderWithNestedTableStage0, tableRowWithLocalId, tableCellWithLocalId, tableHeaderWithLocalId, tableRowWithNestedTableWithLocalId, tableCellWithNestedTableWithLocalId, tableHeaderWithNestedTableWithLocalId } from './schema';
|
|
6
6
|
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';
|
|
7
7
|
|
|
8
8
|
// ADF createPMSpecFactory
|