@atlaskit/adf-schema 33.1.2 → 33.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 +12 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/schema/create-schema.js +6 -0
- package/dist/cjs/schema/index.js +12 -0
- package/dist/cjs/schema/marks/text-color.js +33 -31
- package/dist/cjs/schema/nodes/index.js +17 -4
- package/dist/cjs/schema/nodes/multi-bodied-extension.js +102 -0
- package/dist/cjs/schema/nodes/tableNodes.js +34 -33
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/schema/create-schema.js +7 -1
- package/dist/es2019/schema/index.js +1 -1
- package/dist/es2019/schema/marks/text-color.js +33 -31
- package/dist/es2019/schema/nodes/index.js +6 -4
- package/dist/es2019/schema/nodes/multi-bodied-extension.js +94 -0
- package/dist/es2019/schema/nodes/tableNodes.js +34 -33
- package/dist/esm/index.js +1 -1
- package/dist/esm/schema/create-schema.js +7 -1
- package/dist/esm/schema/index.js +1 -1
- package/dist/esm/schema/marks/text-color.js +33 -31
- package/dist/esm/schema/nodes/index.js +6 -4
- package/dist/esm/schema/nodes/multi-bodied-extension.js +96 -0
- package/dist/esm/schema/nodes/tableNodes.js +34 -33
- package/dist/json-schema/v1/stage-0.json +138 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/schema/index.d.ts +2 -2
- package/dist/types/schema/nodes/doc.d.ts +2 -1
- package/dist/types/schema/nodes/index.d.ts +8 -6
- package/dist/types/schema/nodes/multi-bodied-extension.d.ts +50 -0
- package/json-schema/v1/stage-0.json +138 -0
- package/package.json +1 -12
@@ -0,0 +1,94 @@
|
|
1
|
+
import { getExtensionAttrs } from '../../utils/extensions';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @stage 0
|
5
|
+
* @name extensionFrame_node
|
6
|
+
* @description Wraps the block content
|
7
|
+
*/
|
8
|
+
|
9
|
+
/**
|
10
|
+
* @returns NodeSpec for ExtensionFrameDefinition
|
11
|
+
*/
|
12
|
+
export const extensionFrame = {
|
13
|
+
type: 'extensionFrame',
|
14
|
+
content: '(panel | paragraph | blockquote | orderedList | bulletList | rule | heading | codeBlock | mediaGroup | mediaSingle | decisionList | taskList | table | extension | bodiedExtension | unsupportedBlock | blockCard | embedCard)+',
|
15
|
+
isolating: true,
|
16
|
+
marks: 'alignment indentation dataConsumer fragment unsupportedMark unsupportedNodeAttribute',
|
17
|
+
selectable: true,
|
18
|
+
attrs: {},
|
19
|
+
parseDOM: [{
|
20
|
+
context: 'extensionFrame//',
|
21
|
+
tag: 'div[data-extension-frame]',
|
22
|
+
skip: true
|
23
|
+
}, {
|
24
|
+
tag: 'div[data-extension-frame]'
|
25
|
+
}],
|
26
|
+
toDOM() {
|
27
|
+
const attrs = {
|
28
|
+
'data-extension-frame': 'true'
|
29
|
+
};
|
30
|
+
return ['div', attrs, 0];
|
31
|
+
}
|
32
|
+
};
|
33
|
+
|
34
|
+
/**
|
35
|
+
* @stage 0
|
36
|
+
* @name multiBodiedExtension_node
|
37
|
+
* @description Wraps multiple extensionFrame objects.
|
38
|
+
*/
|
39
|
+
|
40
|
+
/**
|
41
|
+
* @returns NodeSpec for MultiBodiedExtensionDefinition
|
42
|
+
*/
|
43
|
+
const createMultiBodiedExtensionNodeSpec = () => {
|
44
|
+
const nodeSpec = {
|
45
|
+
inline: false,
|
46
|
+
group: 'block',
|
47
|
+
marks: 'dataConsumer fragment',
|
48
|
+
content: 'extensionFrame+',
|
49
|
+
defining: true,
|
50
|
+
selectable: true,
|
51
|
+
attrs: {
|
52
|
+
extensionKey: {
|
53
|
+
default: ''
|
54
|
+
},
|
55
|
+
extensionType: {
|
56
|
+
default: ''
|
57
|
+
},
|
58
|
+
parameters: {
|
59
|
+
default: null
|
60
|
+
},
|
61
|
+
text: {
|
62
|
+
default: null
|
63
|
+
},
|
64
|
+
layout: {
|
65
|
+
default: 'default'
|
66
|
+
},
|
67
|
+
localId: {
|
68
|
+
default: null
|
69
|
+
}
|
70
|
+
},
|
71
|
+
parseDOM: [{
|
72
|
+
context: 'multiBodiedExtension//',
|
73
|
+
tag: '[data-node-type="multi-bodied-extension"]',
|
74
|
+
skip: true
|
75
|
+
}, {
|
76
|
+
tag: '[data-node-type="multi-bodied-extension"]',
|
77
|
+
getAttrs: domNode => getExtensionAttrs(domNode)
|
78
|
+
}],
|
79
|
+
toDOM(node) {
|
80
|
+
const attrs = {
|
81
|
+
'data-node-type': 'multi-bodied-extension',
|
82
|
+
'data-extension-type': node.attrs.extensionType,
|
83
|
+
'data-extension-key': node.attrs.extensionKey,
|
84
|
+
'data-text': node.attrs.text,
|
85
|
+
'data-parameters': JSON.stringify(node.attrs.parameters),
|
86
|
+
'data-layout': node.attrs.layout,
|
87
|
+
'data-local-id:': node.attrs.localId
|
88
|
+
};
|
89
|
+
return ['div', attrs, 0];
|
90
|
+
}
|
91
|
+
};
|
92
|
+
return nodeSpec;
|
93
|
+
};
|
94
|
+
export const multiBodiedExtension = createMultiBodiedExtensionNodeSpec();
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
2
1
|
import { hexToEditorBackgroundPaletteRawValue } from '../../utils/editor-palette';
|
3
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';
|
4
3
|
import { uuid } from '../../utils/uuid';
|
@@ -56,6 +55,12 @@ function invertCustomColor(customColor) {
|
|
56
55
|
hex = customColor;
|
57
56
|
} else if (isRgb(customColor)) {
|
58
57
|
hex = rgbToHex(customColor);
|
58
|
+
if (hex === null) {
|
59
|
+
// in some cases the rgb color is invalid, in this case we just return the color
|
60
|
+
// See https://product-fabric.atlassian.net/browse/DTR-2003 for a ticket to improve the isRgb function
|
61
|
+
// to align with the rgbToHex function
|
62
|
+
return customColor;
|
63
|
+
}
|
59
64
|
} else {
|
60
65
|
return customColor;
|
61
66
|
}
|
@@ -123,40 +128,36 @@ export const getCellDomAttrs = node => {
|
|
123
128
|
attrs.style = '';
|
124
129
|
} else {
|
125
130
|
const color = isRgb(background) && rgbToHex(background) ? rgbToHex(background) : background;
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
131
|
+
|
132
|
+
/**
|
133
|
+
* The Editor supports users pasting content from external sources with custom table cell backgrounds and having those
|
134
|
+
* backgrounds persisted.
|
135
|
+
*
|
136
|
+
* This feature predates the introduction of dark mode.
|
137
|
+
*
|
138
|
+
* Without the inversion logic below, tokenised content (ie. text), can be hard to read when the user loads the page in dark mode.
|
139
|
+
*
|
140
|
+
* This introduces inversion of the presentation of the custom background color when the user is in dark mode.
|
141
|
+
*
|
142
|
+
* This can be done without additional changes to account for users copying and pasting content inside the Editor, because of
|
143
|
+
* how we detect table cell background colors copied from external editor sources. Where we load the background color from a
|
144
|
+
* seperate attribute (data-cell-background), instead of the inline style.
|
145
|
+
*
|
146
|
+
* See the following document for more details on this behaviour
|
147
|
+
* https://hello.atlassian.net/wiki/spaces/CCECO/pages/2892247168/Unsupported+custom+table+cell+background+colors+in+dark+theme+Editor+Job+Story
|
148
|
+
*/
|
149
|
+
const tokenColor = hexToEditorBackgroundPaletteRawValue(color);
|
150
|
+
if (tokenColor) {
|
151
|
+
attrs.style = `background-color: ${tokenColor};`;
|
152
|
+
} else {
|
153
|
+
// if we have a custom color, we need to check if we are in dark mode
|
154
|
+
if (getGlobalTheme().colorMode === 'dark') {
|
148
155
|
// if we have a custom color, we need to check if we are in dark mode
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
// if we are in light mode, we can just set the color
|
154
|
-
attrs.style = `background-color: ${background};`;
|
155
|
-
}
|
156
|
+
attrs.style = `background-color: ${invertCustomColor(color)};`;
|
157
|
+
} else {
|
158
|
+
// if we are in light mode, we can just set the color
|
159
|
+
attrs.style = `background-color: ${background};`;
|
156
160
|
}
|
157
|
-
} else {
|
158
|
-
const tokenColor = hexToEditorBackgroundPaletteRawValue(color) || color;
|
159
|
-
attrs.style = `${attrs.style || ''}background-color: ${tokenColor};`;
|
160
161
|
}
|
161
162
|
|
162
163
|
/**
|
package/dist/esm/index.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
export { PanelType, AnnotationTypes, alignment, alignmentPositionMap, annotation, blockCard, blockquote, 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, expandToJSON, extension, fragment, fragmentToJSON, hardBreak, heading, image, indentation, inlineCard, inlineExtension, inlineNodes, layoutColumn, layoutSection, link, linkToJSON, listItem, media, mediaGroup, mediaSingle, mediaSingleWithCaption, mediaSingleWithWidthType, mediaSingleFull, mediaSingleSpec, mediaInline, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, orderedList, orderedListSelector, orderedListWithOrder, panel, paragraph, placeholder, rule, sanitizeNodes, getCellAttrs, getCellDomAttrs, status, strike, strong, subsup, table, 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 } from './schema';
|
2
|
+
colorPaletteExtended, confluenceInlineComment, confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, createSchema, dataConsumer, dataConsumerToJSON, date, decisionItem, decisionList, decisionListSelector, doc, em, embedCard, emoji, expand, expandToJSON, extension, fragment, fragmentToJSON, hardBreak, heading, image, indentation, inlineCard, inlineExtension, inlineNodes, layoutColumn, layoutSection, link, linkToJSON, listItem, media, mediaGroup, mediaSingle, mediaSingleWithCaption, mediaSingleWithWidthType, mediaSingleFull, mediaSingleSpec, mediaInline, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, orderedList, orderedListSelector, orderedListWithOrder, panel, paragraph, placeholder, rule, sanitizeNodes, getCellAttrs, getCellDomAttrs, status, strike, strong, subsup, table, 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 } 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 } from './utils';
|
@@ -4,7 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
4
4
|
import { Schema } from '@atlaskit/editor-prosemirror/model';
|
5
5
|
import { COLOR, FONT_STYLE, SEARCH_QUERY, LINK } from './groups';
|
6
6
|
import { link, em, strong, textColor, strike, subsup, underline, code, typeAheadQuery, confluenceInlineComment, breakout, alignment, indentation, annotation, unsupportedMark, unsupportedNodeAttribute, dataConsumer, fragment, border } from './marks';
|
7
|
-
import { confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, doc, paragraph, text, bulletList, orderedListWithOrder, listItem, heading, blockquote, codeBlock, panel, rule, image, mention, media, mediaInline, mediaSingleFull, mediaGroup, hardBreak, emoji, table, tableCell, tableHeader, tableRow, decisionList, decisionItem, taskList, taskItem, unknownBlock, extension, inlineExtension, bodiedExtension, date, placeholder, layoutSection, layoutColumn, inlineCard, blockCard, unsupportedBlock, unsupportedInline, status, expand, nestedExpand, embedCard, caption } from './nodes';
|
7
|
+
import { confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, doc, paragraph, text, bulletList, orderedListWithOrder, listItem, heading, blockquote, codeBlock, panel, rule, image, mention, media, mediaInline, mediaSingleFull, mediaGroup, hardBreak, emoji, table, tableCell, tableHeader, tableRow, decisionList, decisionItem, taskList, taskItem, unknownBlock, extension, inlineExtension, bodiedExtension, multiBodiedExtension, extensionFrame, date, placeholder, layoutSection, layoutColumn, inlineCard, blockCard, unsupportedBlock, unsupportedInline, status, expand, nestedExpand, embedCard, caption } from './nodes';
|
8
8
|
function addItems(builtInItems, config) {
|
9
9
|
var customSpecs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
10
10
|
if (!config) {
|
@@ -177,6 +177,12 @@ var nodesInOrder = [{
|
|
177
177
|
}, {
|
178
178
|
name: 'bodiedExtension',
|
179
179
|
spec: bodiedExtension
|
180
|
+
}, {
|
181
|
+
name: 'multiBodiedExtension',
|
182
|
+
spec: multiBodiedExtension
|
183
|
+
}, {
|
184
|
+
name: 'extensionFrame',
|
185
|
+
spec: extensionFrame
|
180
186
|
}, {
|
181
187
|
name: 'inlineCard',
|
182
188
|
spec: inlineCard
|
package/dist/esm/schema/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
export { PanelType, blockCard, blockquote, bodiedExtension, bulletList, bulletListSelector, caption, codeBlock, codeBlockToJSON, confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, date, decisionItem, decisionList, decisionListSelector, doc, embedCard, emoji, expand, expandToJSON, extension, hardBreak, heading, image, inlineCard, inlineExtension, layoutColumn, layoutSection, layoutSectionWithSingleColumn, listItem, media, mediaGroup, mediaSingle, mediaSingleSpec, mediaInline, mediaSingleWithCaption, mediaSingleWithWidthType, mediaSingleFull, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, orderedList, orderedListSelector, orderedListWithOrder, panel, paragraph, placeholder, rule, getCellAttrs, getCellDomAttrs, status, table, tableWithCustomWidth, tableBackgroundBorderColor, tableBackgroundColorNames, tableBackgroundColorPalette, tableCell, tableCellContentDomSelector, tableCellContentWrapperSelector, tableCellSelector, tableHeader, tableHeaderSelector, tablePrefixSelector, tableRow, tableToJSON, taskItem, taskList, taskListSelector, text, toJSONTableCell, toJSONTableHeader, unknownBlock, unsupportedBlock, unsupportedInline } from './nodes';
|
1
|
+
export { PanelType, blockCard, blockquote, bodiedExtension, bulletList, bulletListSelector, caption, codeBlock, codeBlockToJSON, confluenceJiraIssue, confluenceUnsupportedBlock, confluenceUnsupportedInline, copyPrivateMediaAttributes, date, decisionItem, decisionList, decisionListSelector, doc, embedCard, emoji, expand, expandToJSON, extension, hardBreak, heading, image, inlineCard, inlineExtension, layoutColumn, layoutSection, layoutSectionWithSingleColumn, listItem, media, mediaGroup, mediaSingle, mediaSingleSpec, mediaInline, mediaSingleWithCaption, mediaSingleWithWidthType, mediaSingleFull, mediaSingleToJSON, mediaToJSON, mention, mentionToJSON, nestedExpand, orderedList, orderedListSelector, orderedListWithOrder, panel, paragraph, placeholder, rule, getCellAttrs, getCellDomAttrs, status, table, 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';
|
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 } from './marks';
|
4
4
|
export { unsupportedNodeTypesForMediaCards } from './unsupported';
|
@@ -3,7 +3,6 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import { hexToEditorTextPaletteColor } from '../../utils/editor-palette';
|
4
4
|
import { COLOR } from '../groups';
|
5
5
|
import { rgbToHex, N0, N80, P50, P300, P500, T75, T300, T500, G75, G300, G500, R75, R300, R500, Y75, Y200, Y400, B75, B100, B500, isHex, isRgb } from '../../utils/colors';
|
6
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
7
6
|
|
8
7
|
/**
|
9
8
|
* @name textColor_mark
|
@@ -76,6 +75,12 @@ function invertCustomColor(customColor) {
|
|
76
75
|
hex = customColor;
|
77
76
|
} else if (isRgb(customColor)) {
|
78
77
|
hex = rgbToHex(customColor);
|
78
|
+
if (hex === null) {
|
79
|
+
// in some cases the rgb color is invalid, in this case we just return the color
|
80
|
+
// See https://product-fabric.atlassian.net/browse/DTR-2003 for a ticket to improve the isRgb function
|
81
|
+
// to align with the rgbToHex function
|
82
|
+
return customColor;
|
83
|
+
}
|
79
84
|
} else {
|
80
85
|
return customColor;
|
81
86
|
}
|
@@ -159,38 +164,35 @@ export var textColor = {
|
|
159
164
|
// Note -- while there is no way to create custom colors using default tooling
|
160
165
|
// the editor does supported ad hoc color values -- and there may be content
|
161
166
|
// which has been migrated or created via apis which use such values.
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
167
|
+
|
168
|
+
/**
|
169
|
+
* The Editor persists custom text colors when content has been migrated from the old editor, or created via
|
170
|
+
* apis.
|
171
|
+
*
|
172
|
+
* This behaviour predates the introduction of dark mode.
|
173
|
+
*
|
174
|
+
* Without the inversion logic below, text with custom colors, can be hard to read when the user loads the page in dark mode.
|
175
|
+
*
|
176
|
+
* This introduces inversion of the presentation of the custom text colors when the user is in dark mode.
|
177
|
+
*
|
178
|
+
* This can be done without additional changes to account for users copying and pasting content inside the Editor, because of
|
179
|
+
* how we detect text colors copied from external editor sources. Where we load the background color from a
|
180
|
+
* seperate attribute (data-text-custom-color), instead of the inline style.
|
181
|
+
*
|
182
|
+
* See the following document for more details on this behaviour
|
183
|
+
* https://hello.atlassian.net/wiki/spaces/CCECO/pages/2908658046/Unsupported+custom+text+colors+in+dark+theme+Editor+Job+Story
|
184
|
+
*/
|
185
|
+
var tokenColor = hexToEditorTextPaletteColor(mark.attrs.color);
|
186
|
+
if (tokenColor) {
|
187
|
+
paletteColorValue = hexToEditorTextPaletteColor(mark.attrs.color) || mark.attrs.color;
|
188
|
+
} else {
|
189
|
+
if (getGlobalTheme().colorMode === 'dark') {
|
190
|
+
// if we have a custom color, we need to check if we are in dark mode
|
191
|
+
paletteColorValue = invertCustomColor(mark.attrs.color);
|
183
192
|
} else {
|
184
|
-
if
|
185
|
-
|
186
|
-
paletteColorValue = invertCustomColor(mark.attrs.color);
|
187
|
-
} else {
|
188
|
-
// if we are in light mode, we can just set the color
|
189
|
-
paletteColorValue = mark.attrs.color;
|
190
|
-
}
|
193
|
+
// if we are in light mode, we can just set the color
|
194
|
+
paletteColorValue = mark.attrs.color;
|
191
195
|
}
|
192
|
-
} else {
|
193
|
-
paletteColorValue = hexToEditorTextPaletteColor(mark.attrs.color) || mark.attrs.color;
|
194
196
|
}
|
195
197
|
return ['span', _defineProperty({
|
196
198
|
class: 'fabric-text-color-mark',
|
@@ -28,9 +28,6 @@ export { decisionList, decisionListSelector } from './decision-list';
|
|
28
28
|
export { decisionItem } from './decision-item';
|
29
29
|
export { taskList, taskListSelector } from './task-list';
|
30
30
|
export { taskItem } from './task-item';
|
31
|
-
export { extension } from './extension';
|
32
|
-
export { inlineExtension } from './inline-extension';
|
33
|
-
export { bodiedExtension } from './bodied-extension';
|
34
31
|
export { date } from './date';
|
35
32
|
export { placeholder } from './placeholder';
|
36
33
|
export { layoutSection, layoutSectionWithSingleColumn } from './layout-section';
|
@@ -41,4 +38,9 @@ export { unsupportedBlock } from './unsupported-block';
|
|
41
38
|
export { unsupportedInline } from './unsupported-inline';
|
42
39
|
export { status } from './status';
|
43
40
|
export { nestedExpand } from './nested-expand';
|
44
|
-
export { embedCard } from './embed-card';
|
41
|
+
export { embedCard } from './embed-card';
|
42
|
+
// Extensions
|
43
|
+
export { extension } from './extension';
|
44
|
+
export { inlineExtension } from './inline-extension';
|
45
|
+
export { bodiedExtension } from './bodied-extension';
|
46
|
+
export { extensionFrame, multiBodiedExtension } from './multi-bodied-extension';
|
@@ -0,0 +1,96 @@
|
|
1
|
+
import { getExtensionAttrs } from '../../utils/extensions';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @stage 0
|
5
|
+
* @name extensionFrame_node
|
6
|
+
* @description Wraps the block content
|
7
|
+
*/
|
8
|
+
|
9
|
+
/**
|
10
|
+
* @returns NodeSpec for ExtensionFrameDefinition
|
11
|
+
*/
|
12
|
+
export var extensionFrame = {
|
13
|
+
type: 'extensionFrame',
|
14
|
+
content: '(panel | paragraph | blockquote | orderedList | bulletList | rule | heading | codeBlock | mediaGroup | mediaSingle | decisionList | taskList | table | extension | bodiedExtension | unsupportedBlock | blockCard | embedCard)+',
|
15
|
+
isolating: true,
|
16
|
+
marks: 'alignment indentation dataConsumer fragment unsupportedMark unsupportedNodeAttribute',
|
17
|
+
selectable: true,
|
18
|
+
attrs: {},
|
19
|
+
parseDOM: [{
|
20
|
+
context: 'extensionFrame//',
|
21
|
+
tag: 'div[data-extension-frame]',
|
22
|
+
skip: true
|
23
|
+
}, {
|
24
|
+
tag: 'div[data-extension-frame]'
|
25
|
+
}],
|
26
|
+
toDOM: function toDOM() {
|
27
|
+
var attrs = {
|
28
|
+
'data-extension-frame': 'true'
|
29
|
+
};
|
30
|
+
return ['div', attrs, 0];
|
31
|
+
}
|
32
|
+
};
|
33
|
+
|
34
|
+
/**
|
35
|
+
* @stage 0
|
36
|
+
* @name multiBodiedExtension_node
|
37
|
+
* @description Wraps multiple extensionFrame objects.
|
38
|
+
*/
|
39
|
+
|
40
|
+
/**
|
41
|
+
* @returns NodeSpec for MultiBodiedExtensionDefinition
|
42
|
+
*/
|
43
|
+
var createMultiBodiedExtensionNodeSpec = function createMultiBodiedExtensionNodeSpec() {
|
44
|
+
var nodeSpec = {
|
45
|
+
inline: false,
|
46
|
+
group: 'block',
|
47
|
+
marks: 'dataConsumer fragment',
|
48
|
+
content: 'extensionFrame+',
|
49
|
+
defining: true,
|
50
|
+
selectable: true,
|
51
|
+
attrs: {
|
52
|
+
extensionKey: {
|
53
|
+
default: ''
|
54
|
+
},
|
55
|
+
extensionType: {
|
56
|
+
default: ''
|
57
|
+
},
|
58
|
+
parameters: {
|
59
|
+
default: null
|
60
|
+
},
|
61
|
+
text: {
|
62
|
+
default: null
|
63
|
+
},
|
64
|
+
layout: {
|
65
|
+
default: 'default'
|
66
|
+
},
|
67
|
+
localId: {
|
68
|
+
default: null
|
69
|
+
}
|
70
|
+
},
|
71
|
+
parseDOM: [{
|
72
|
+
context: 'multiBodiedExtension//',
|
73
|
+
tag: '[data-node-type="multi-bodied-extension"]',
|
74
|
+
skip: true
|
75
|
+
}, {
|
76
|
+
tag: '[data-node-type="multi-bodied-extension"]',
|
77
|
+
getAttrs: function getAttrs(domNode) {
|
78
|
+
return getExtensionAttrs(domNode);
|
79
|
+
}
|
80
|
+
}],
|
81
|
+
toDOM: function toDOM(node) {
|
82
|
+
var attrs = {
|
83
|
+
'data-node-type': 'multi-bodied-extension',
|
84
|
+
'data-extension-type': node.attrs.extensionType,
|
85
|
+
'data-extension-key': node.attrs.extensionKey,
|
86
|
+
'data-text': node.attrs.text,
|
87
|
+
'data-parameters': JSON.stringify(node.attrs.parameters),
|
88
|
+
'data-layout': node.attrs.layout,
|
89
|
+
'data-local-id:': node.attrs.localId
|
90
|
+
};
|
91
|
+
return ['div', attrs, 0];
|
92
|
+
}
|
93
|
+
};
|
94
|
+
return nodeSpec;
|
95
|
+
};
|
96
|
+
export var multiBodiedExtension = createMultiBodiedExtensionNodeSpec();
|
@@ -2,7 +2,6 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
3
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
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 { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
6
5
|
import { hexToEditorBackgroundPaletteRawValue } from '../../utils/editor-palette';
|
7
6
|
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';
|
8
7
|
import { uuid } from '../../utils/uuid';
|
@@ -61,6 +60,12 @@ function invertCustomColor(customColor) {
|
|
61
60
|
hex = customColor;
|
62
61
|
} else if (isRgb(customColor)) {
|
63
62
|
hex = rgbToHex(customColor);
|
63
|
+
if (hex === null) {
|
64
|
+
// in some cases the rgb color is invalid, in this case we just return the color
|
65
|
+
// See https://product-fabric.atlassian.net/browse/DTR-2003 for a ticket to improve the isRgb function
|
66
|
+
// to align with the rgbToHex function
|
67
|
+
return customColor;
|
68
|
+
}
|
64
69
|
} else {
|
65
70
|
return customColor;
|
66
71
|
}
|
@@ -126,40 +131,36 @@ export var getCellDomAttrs = function getCellDomAttrs(node) {
|
|
126
131
|
attrs.style = '';
|
127
132
|
} else {
|
128
133
|
var color = isRgb(background) && rgbToHex(background) ? rgbToHex(background) : background;
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
134
|
+
|
135
|
+
/**
|
136
|
+
* The Editor supports users pasting content from external sources with custom table cell backgrounds and having those
|
137
|
+
* backgrounds persisted.
|
138
|
+
*
|
139
|
+
* This feature predates the introduction of dark mode.
|
140
|
+
*
|
141
|
+
* Without the inversion logic below, tokenised content (ie. text), can be hard to read when the user loads the page in dark mode.
|
142
|
+
*
|
143
|
+
* This introduces inversion of the presentation of the custom background color when the user is in dark mode.
|
144
|
+
*
|
145
|
+
* This can be done without additional changes to account for users copying and pasting content inside the Editor, because of
|
146
|
+
* how we detect table cell background colors copied from external editor sources. Where we load the background color from a
|
147
|
+
* seperate attribute (data-cell-background), instead of the inline style.
|
148
|
+
*
|
149
|
+
* See the following document for more details on this behaviour
|
150
|
+
* https://hello.atlassian.net/wiki/spaces/CCECO/pages/2892247168/Unsupported+custom+table+cell+background+colors+in+dark+theme+Editor+Job+Story
|
151
|
+
*/
|
152
|
+
var tokenColor = hexToEditorBackgroundPaletteRawValue(color);
|
153
|
+
if (tokenColor) {
|
154
|
+
attrs.style = "background-color: ".concat(tokenColor, ";");
|
155
|
+
} else {
|
156
|
+
// if we have a custom color, we need to check if we are in dark mode
|
157
|
+
if (getGlobalTheme().colorMode === 'dark') {
|
151
158
|
// if we have a custom color, we need to check if we are in dark mode
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
// if we are in light mode, we can just set the color
|
157
|
-
attrs.style = "background-color: ".concat(background, ";");
|
158
|
-
}
|
159
|
+
attrs.style = "background-color: ".concat(invertCustomColor(color), ";");
|
160
|
+
} else {
|
161
|
+
// if we are in light mode, we can just set the color
|
162
|
+
attrs.style = "background-color: ".concat(background, ";");
|
159
163
|
}
|
160
|
-
} else {
|
161
|
-
var _tokenColor = hexToEditorBackgroundPaletteRawValue(color) || color;
|
162
|
-
attrs.style = "".concat(attrs.style || '', "background-color: ").concat(_tokenColor, ";");
|
163
164
|
}
|
164
165
|
|
165
166
|
/**
|