@atlaskit/editor-core 164.0.3 → 166.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/dist/cjs/actions/index.js +9 -0
- package/dist/cjs/create-editor/ReactEditorView.js +14 -6
- package/dist/cjs/create-editor/create-plugins-list.js +1 -2
- package/dist/cjs/editor.js +32 -1
- package/dist/cjs/event-dispatcher/index.js +9 -0
- package/dist/cjs/nodeviews/ReactNodeView.js +1 -11
- package/dist/cjs/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
- package/dist/cjs/nodeviews/getPerformanceOptions.js +1 -1
- package/dist/cjs/plugins/analytics/types/enums.js +1 -0
- package/dist/cjs/plugins/base/pm-plugins/frozen-editor.js +128 -79
- package/dist/cjs/plugins/base/utils/input-latency-tracking.js +157 -0
- package/dist/cjs/plugins/card/styles.js +3 -1
- package/dist/cjs/plugins/code-block/styles.js +6 -4
- package/dist/cjs/plugins/collab-edit/plugin-state.js +23 -5
- package/dist/cjs/plugins/date/styles.js +3 -1
- package/dist/cjs/plugins/emoji/index.js +30 -34
- package/dist/cjs/plugins/emoji/nodeviews/emoji.js +12 -66
- package/dist/cjs/plugins/emoji/styles.js +3 -17
- package/dist/cjs/plugins/expand/ui/styles.js +2 -2
- package/dist/cjs/plugins/extension/ui/styles.js +3 -1
- package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +20 -22
- package/dist/cjs/plugins/hyperlink/pm-plugins/input-rule.js +1 -9
- package/dist/cjs/plugins/hyperlink/pm-plugins/keymap.js +1 -9
- package/dist/cjs/plugins/layout/styles.js +3 -1
- package/dist/cjs/plugins/list/commands/indent-list.js +5 -1
- package/dist/cjs/plugins/list/commands/outdent-list.js +5 -1
- package/dist/cjs/plugins/list/transforms.js +11 -3
- package/dist/cjs/plugins/media/styles.js +3 -1
- package/dist/cjs/plugins/mentions/index.js +10 -14
- package/dist/cjs/plugins/mentions/nodeviews/mention.js +15 -67
- package/dist/cjs/plugins/mentions/pm-plugins/main.js +19 -10
- package/dist/cjs/plugins/mentions/type-ahead/index.js +7 -2
- package/dist/cjs/plugins/panel/styles.js +3 -1
- package/dist/cjs/plugins/placeholder-text/placeholder-text-nodeview.js +3 -1
- package/dist/cjs/plugins/rule/styles.js +3 -1
- package/dist/cjs/plugins/selection/utils.js +39 -23
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +24 -0
- package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
- package/dist/cjs/plugins/table/ui/consts.js +6 -4
- package/dist/cjs/plugins/tasks-and-decisions/styles.js +3 -1
- package/dist/cjs/plugins/type-ahead/index.js +6 -2
- package/dist/cjs/plugins/unsupported-content/index.js +22 -10
- package/dist/cjs/plugins/unsupported-content/styles.js +4 -2
- package/dist/cjs/plugins/unsupported-content/unsupported-inline-node-view.js +21 -0
- package/dist/cjs/ui/Appearance/Chromeless.js +6 -3
- package/dist/cjs/ui/Appearance/Comment/Comment.js +6 -4
- package/dist/cjs/ui/ChromeCollapsed/styles.js +3 -1
- package/dist/cjs/ui/ContentStyles/index.js +2 -2
- package/dist/cjs/ui/PortalProvider/PortalProviderThemesProvider.js +57 -0
- package/dist/cjs/ui/PortalProvider/index.js +66 -19
- package/dist/cjs/utils/check-if-mobile-bridge.js +19 -0
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/actions/index.js +12 -1
- package/dist/es2019/create-editor/ReactEditorView.js +14 -6
- package/dist/es2019/create-editor/create-plugins-list.js +1 -2
- package/dist/es2019/editor.js +33 -2
- package/dist/es2019/event-dispatcher/index.js +8 -0
- package/dist/es2019/nodeviews/ReactNodeView.js +1 -10
- package/dist/es2019/nodeviews/getInlineNodeViewProducer.styles.js +9 -0
- package/dist/es2019/plugins/analytics/types/enums.js +1 -0
- package/dist/es2019/plugins/base/pm-plugins/frozen-editor.js +138 -80
- package/dist/es2019/plugins/base/utils/input-latency-tracking.js +128 -0
- package/dist/es2019/plugins/card/styles.js +9 -5
- package/dist/es2019/plugins/code-block/styles.js +11 -8
- package/dist/es2019/plugins/collab-edit/plugin-state.js +23 -8
- package/dist/es2019/plugins/date/styles.js +3 -1
- package/dist/es2019/plugins/emoji/index.js +16 -21
- package/dist/es2019/plugins/emoji/nodeviews/emoji.js +12 -31
- package/dist/es2019/plugins/emoji/styles.js +1 -82
- package/dist/es2019/plugins/expand/ui/styles.js +2 -2
- package/dist/es2019/plugins/extension/ui/styles.js +4 -2
- package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +20 -22
- package/dist/es2019/plugins/hyperlink/pm-plugins/input-rule.js +1 -8
- package/dist/es2019/plugins/hyperlink/pm-plugins/keymap.js +1 -8
- package/dist/es2019/plugins/layout/styles.js +3 -2
- package/dist/es2019/plugins/list/commands/indent-list.js +4 -1
- package/dist/es2019/plugins/list/commands/outdent-list.js +4 -1
- package/dist/es2019/plugins/list/transforms.js +9 -4
- package/dist/es2019/plugins/media/styles.js +9 -7
- package/dist/es2019/plugins/mentions/index.js +1 -6
- package/dist/es2019/plugins/mentions/nodeviews/mention.js +16 -35
- package/dist/es2019/plugins/mentions/pm-plugins/main.js +18 -10
- package/dist/es2019/plugins/mentions/type-ahead/index.js +7 -2
- package/dist/es2019/plugins/panel/styles.js +5 -4
- package/dist/es2019/plugins/placeholder-text/placeholder-text-nodeview.js +3 -1
- package/dist/es2019/plugins/rule/styles.js +2 -1
- package/dist/es2019/plugins/selection/utils.js +35 -20
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +22 -0
- package/dist/es2019/plugins/table/ui/common-styles.js +4 -0
- package/dist/es2019/plugins/table/ui/consts.js +5 -4
- package/dist/es2019/plugins/tasks-and-decisions/styles.js +4 -2
- package/dist/es2019/plugins/type-ahead/index.js +5 -1
- package/dist/es2019/plugins/unsupported-content/index.js +23 -12
- package/dist/es2019/plugins/unsupported-content/styles.js +5 -3
- package/dist/es2019/plugins/unsupported-content/unsupported-inline-node-view.js +7 -0
- package/dist/es2019/ui/Appearance/Chromeless.js +5 -2
- package/dist/es2019/ui/Appearance/Comment/Comment.js +5 -2
- package/dist/es2019/ui/ChromeCollapsed/styles.js +2 -1
- package/dist/es2019/ui/ContentStyles/index.js +3 -3
- package/dist/es2019/ui/PortalProvider/PortalProviderThemesProvider.js +39 -0
- package/dist/es2019/ui/PortalProvider/index.js +39 -3
- package/dist/es2019/utils/check-if-mobile-bridge.js +12 -0
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/actions/index.js +8 -0
- package/dist/esm/create-editor/ReactEditorView.js +14 -6
- package/dist/esm/create-editor/create-plugins-list.js +1 -2
- package/dist/esm/editor.js +33 -2
- package/dist/esm/event-dispatcher/index.js +9 -0
- package/dist/esm/nodeviews/ReactNodeView.js +1 -10
- package/dist/esm/nodeviews/getInlineNodeViewProducer.styles.js +1 -1
- package/dist/esm/plugins/analytics/types/enums.js +1 -0
- package/dist/esm/plugins/base/pm-plugins/frozen-editor.js +128 -79
- package/dist/esm/plugins/base/utils/input-latency-tracking.js +149 -0
- package/dist/esm/plugins/card/styles.js +2 -1
- package/dist/esm/plugins/code-block/styles.js +5 -4
- package/dist/esm/plugins/collab-edit/plugin-state.js +21 -6
- package/dist/esm/plugins/date/styles.js +2 -1
- package/dist/esm/plugins/emoji/index.js +26 -29
- package/dist/esm/plugins/emoji/nodeviews/emoji.js +11 -56
- package/dist/esm/plugins/emoji/styles.js +3 -14
- package/dist/esm/plugins/expand/ui/styles.js +2 -2
- package/dist/esm/plugins/extension/ui/styles.js +2 -1
- package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +20 -22
- package/dist/esm/plugins/hyperlink/pm-plugins/input-rule.js +1 -8
- package/dist/esm/plugins/hyperlink/pm-plugins/keymap.js +1 -8
- package/dist/esm/plugins/layout/styles.js +2 -1
- package/dist/esm/plugins/list/commands/indent-list.js +4 -1
- package/dist/esm/plugins/list/commands/outdent-list.js +4 -1
- package/dist/esm/plugins/list/transforms.js +9 -4
- package/dist/esm/plugins/media/styles.js +2 -1
- package/dist/esm/plugins/mentions/index.js +10 -14
- package/dist/esm/plugins/mentions/nodeviews/mention.js +13 -58
- package/dist/esm/plugins/mentions/pm-plugins/main.js +18 -10
- package/dist/esm/plugins/mentions/type-ahead/index.js +7 -2
- package/dist/esm/plugins/panel/styles.js +2 -1
- package/dist/esm/plugins/placeholder-text/placeholder-text-nodeview.js +3 -1
- package/dist/esm/plugins/rule/styles.js +2 -1
- package/dist/esm/plugins/selection/utils.js +35 -20
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +23 -0
- package/dist/esm/plugins/table/ui/common-styles.js +1 -1
- package/dist/esm/plugins/table/ui/consts.js +5 -4
- package/dist/esm/plugins/tasks-and-decisions/styles.js +2 -1
- package/dist/esm/plugins/type-ahead/index.js +6 -2
- package/dist/esm/plugins/unsupported-content/index.js +21 -11
- package/dist/esm/plugins/unsupported-content/styles.js +3 -2
- package/dist/esm/plugins/unsupported-content/unsupported-inline-node-view.js +7 -0
- package/dist/esm/ui/Appearance/Chromeless.js +6 -3
- package/dist/esm/ui/Appearance/Comment/Comment.js +6 -4
- package/dist/esm/ui/ChromeCollapsed/styles.js +2 -1
- package/dist/esm/ui/ContentStyles/index.js +3 -3
- package/dist/esm/ui/PortalProvider/PortalProviderThemesProvider.js +39 -0
- package/dist/esm/ui/PortalProvider/index.js +61 -19
- package/dist/esm/utils/check-if-mobile-bridge.js +12 -0
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/actions/index.d.ts +3 -1
- package/dist/types/editor.d.ts +3 -0
- package/dist/types/event-dispatcher/index.d.ts +1 -0
- package/dist/types/nodeviews/ReactNodeView.d.ts +1 -5
- package/dist/types/plugins/analytics/types/enums.d.ts +1 -0
- package/dist/types/plugins/analytics/types/events.d.ts +2 -2
- package/dist/types/plugins/analytics/types/general-events.d.ts +10 -1
- package/dist/types/plugins/base/utils/input-latency-tracking.d.ts +44 -0
- package/dist/types/plugins/collab-edit/plugin-state.d.ts +4 -0
- package/dist/types/plugins/emoji/index.d.ts +2 -6
- package/dist/types/plugins/emoji/nodeviews/emoji.d.ts +4 -14
- package/dist/types/plugins/emoji/styles.d.ts +0 -1
- package/dist/types/plugins/emoji/types.d.ts +0 -1
- package/dist/types/plugins/list/transforms.d.ts +10 -1
- package/dist/types/plugins/mentions/nodeviews/mention.d.ts +6 -14
- package/dist/types/plugins/mentions/pm-plugins/main.d.ts +2 -5
- package/dist/types/plugins/selection/utils.d.ts +7 -15
- package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +3 -0
- package/dist/types/plugins/table/ui/consts.d.ts +2 -2
- package/dist/types/plugins/type-ahead/types.d.ts +1 -0
- package/dist/types/plugins/unsupported-content/unsupported-inline-node-view.d.ts +11 -0
- package/dist/types/types/editor-appearance-component.d.ts +1 -0
- package/dist/types/types/editor-props.d.ts +1 -0
- package/dist/types/types/feature-flags.d.ts +0 -14
- package/dist/types/ui/Appearance/Chromeless.d.ts +1 -0
- package/dist/types/ui/Appearance/Comment/Comment.d.ts +1 -0
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +5 -5
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types/ui/PortalProvider/PortalProviderThemesProvider.d.ts +6 -0
- package/dist/types/ui/PortalProvider/index.d.ts +5 -1
- package/dist/types/utils/check-if-mobile-bridge.d.ts +1 -0
- package/package.json +24 -23
- package/dist/cjs/plugins/emoji/nodeviews/emoji-next.js +0 -250
- package/dist/es2019/plugins/emoji/nodeviews/emoji-next.js +0 -177
- package/dist/esm/plugins/emoji/nodeviews/emoji-next.js +0 -234
- package/dist/types/plugins/emoji/nodeviews/emoji-next.d.ts +0 -31
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
2
|
import { SLI_EVENT_TYPE, SMART_EVENT_TYPE, buildSliPayload } from '@atlaskit/mention/resource';
|
|
3
|
-
import
|
|
3
|
+
import { getInlineNodeViewProducer } from '../../../nodeviews/getInlineNodeViewProducer';
|
|
4
|
+
import { MentionNodeView } from '../nodeviews/mention';
|
|
4
5
|
import { mentionPluginKey } from './key';
|
|
5
6
|
const ACTIONS = {
|
|
6
7
|
SET_PROVIDER: 'SET_PROVIDER',
|
|
@@ -32,7 +33,7 @@ export const setContext = context => (state, dispatch) => {
|
|
|
32
33
|
|
|
33
34
|
return true;
|
|
34
35
|
};
|
|
35
|
-
export function createMentionPlugin(
|
|
36
|
+
export function createMentionPlugin(pmPluginFactoryParams, fireEvent, options) {
|
|
36
37
|
let mentionProvider;
|
|
37
38
|
|
|
38
39
|
const sendAnalytics = (event, actionSubject, action, attributes) => {
|
|
@@ -63,14 +64,14 @@ export function createMentionPlugin(dispatch, providerFactory, portalProviderAPI
|
|
|
63
64
|
newPluginState = { ...pluginState,
|
|
64
65
|
mentionProvider: params.provider
|
|
65
66
|
};
|
|
66
|
-
dispatch(mentionPluginKey, newPluginState);
|
|
67
|
+
pmPluginFactoryParams.dispatch(mentionPluginKey, newPluginState);
|
|
67
68
|
return newPluginState;
|
|
68
69
|
|
|
69
70
|
case ACTIONS.SET_CONTEXT:
|
|
70
71
|
newPluginState = { ...pluginState,
|
|
71
72
|
contextIdentifierProvider: params.context
|
|
72
73
|
};
|
|
73
|
-
dispatch(mentionPluginKey, newPluginState);
|
|
74
|
+
pmPluginFactoryParams.dispatch(mentionPluginKey, newPluginState);
|
|
74
75
|
return newPluginState;
|
|
75
76
|
}
|
|
76
77
|
|
|
@@ -80,7 +81,14 @@ export function createMentionPlugin(dispatch, providerFactory, portalProviderAPI
|
|
|
80
81
|
},
|
|
81
82
|
props: {
|
|
82
83
|
nodeViews: {
|
|
83
|
-
mention:
|
|
84
|
+
mention: getInlineNodeViewProducer({
|
|
85
|
+
pmPluginFactoryParams,
|
|
86
|
+
Component: MentionNodeView,
|
|
87
|
+
extraComponentProps: {
|
|
88
|
+
providerFactory: pmPluginFactoryParams.providerFactory,
|
|
89
|
+
options
|
|
90
|
+
}
|
|
91
|
+
})
|
|
84
92
|
}
|
|
85
93
|
},
|
|
86
94
|
|
|
@@ -117,13 +125,13 @@ export function createMentionPlugin(dispatch, providerFactory, portalProviderAPI
|
|
|
117
125
|
return;
|
|
118
126
|
};
|
|
119
127
|
|
|
120
|
-
providerFactory.subscribe('mentionProvider', providerHandler);
|
|
121
|
-
providerFactory.subscribe('contextIdentifierProvider', providerHandler);
|
|
128
|
+
pmPluginFactoryParams.providerFactory.subscribe('mentionProvider', providerHandler);
|
|
129
|
+
pmPluginFactoryParams.providerFactory.subscribe('contextIdentifierProvider', providerHandler);
|
|
122
130
|
return {
|
|
123
131
|
destroy() {
|
|
124
|
-
if (providerFactory) {
|
|
125
|
-
providerFactory.unsubscribe('mentionProvider', providerHandler);
|
|
126
|
-
providerFactory.unsubscribe('contextIdentifierProvider', providerHandler);
|
|
132
|
+
if (pmPluginFactoryParams.providerFactory) {
|
|
133
|
+
pmPluginFactoryParams.providerFactory.unsubscribe('mentionProvider', providerHandler);
|
|
134
|
+
pmPluginFactoryParams.providerFactory.unsubscribe('contextIdentifierProvider', providerHandler);
|
|
127
135
|
}
|
|
128
136
|
|
|
129
137
|
if (mentionProvider) {
|
|
@@ -364,11 +364,16 @@ export const createTypeAheadConfig = ({
|
|
|
364
364
|
dismiss({
|
|
365
365
|
editorState,
|
|
366
366
|
query,
|
|
367
|
-
stats
|
|
367
|
+
stats,
|
|
368
|
+
wasItemInserted
|
|
368
369
|
}) {
|
|
369
370
|
firstQueryWithoutResults = null;
|
|
370
371
|
const pickerElapsedTime = stats.startedAt ? Date.now() - stats.startedAt : 0;
|
|
371
|
-
|
|
372
|
+
|
|
373
|
+
if (!wasItemInserted) {
|
|
374
|
+
fireEvent(buildTypeAheadCancelPayload(pickerElapsedTime, stats.keyCount.arrowUp, stats.keyCount.arrowDown, sessionId, query || ''));
|
|
375
|
+
}
|
|
376
|
+
|
|
372
377
|
const pluginState = getMentionPluginState(editorState);
|
|
373
378
|
|
|
374
379
|
if (pluginState !== null && pluginState !== void 0 && pluginState.mentionProvider) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
2
|
import { panelSharedStyles, PanelSharedCssClassName } from '@atlaskit/editor-common/panel';
|
|
3
3
|
import { SelectionStyle, getSelectionStyles, akEditorDeleteBackground, akEditorDeleteBackgroundWithOpacity, akEditorDeleteBorder, akEditorSelectedBorderSize, akEditorDeleteIconColor, akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
|
|
4
|
+
import { token } from '@atlaskit/tokens';
|
|
4
5
|
export const panelStyles = props => css`
|
|
5
6
|
.ProseMirror {
|
|
6
7
|
.${PanelSharedCssClassName.prefix} {
|
|
@@ -10,10 +11,10 @@ export const panelStyles = props => css`
|
|
|
10
11
|
&.danger {
|
|
11
12
|
box-shadow: 0 0 0 ${akEditorSelectedBorderSize}px
|
|
12
13
|
${akEditorDeleteBorder};
|
|
13
|
-
background-color: ${akEditorDeleteBackground} !important;
|
|
14
|
+
background-color: ${token('color.background.danger', akEditorDeleteBackground)} !important;
|
|
14
15
|
|
|
15
16
|
.${PanelSharedCssClassName.icon} {
|
|
16
|
-
color: ${akEditorDeleteIconColor} !important;
|
|
17
|
+
color: ${token('color.icon.danger', akEditorDeleteIconColor)} !important;
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
}
|
|
@@ -25,10 +26,10 @@ export const panelStyles = props => css`
|
|
|
25
26
|
/* Danger when nested node */
|
|
26
27
|
.danger .${PanelSharedCssClassName.prefix} {
|
|
27
28
|
&[data-panel-type] {
|
|
28
|
-
background-color: ${akEditorDeleteBackgroundWithOpacity};
|
|
29
|
+
background-color: ${token('color.blanket.danger', akEditorDeleteBackgroundWithOpacity)};
|
|
29
30
|
|
|
30
31
|
.${PanelSharedCssClassName.icon} {
|
|
31
|
-
color: ${akEditorDeleteIconColor};
|
|
32
|
+
color: ${token('color.icon.danger', akEditorDeleteIconColor)};
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
}
|
|
@@ -3,7 +3,9 @@ import { browser, ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
|
|
|
3
3
|
|
|
4
4
|
const serializePlaceholderNode = node => {
|
|
5
5
|
const element = document.createElement('span');
|
|
6
|
-
element.classList.add('pm-placeholder');
|
|
6
|
+
element.classList.add('pm-placeholder'); // the inline node api test suite requires the following class name
|
|
7
|
+
|
|
8
|
+
element.classList.add('placeholderView-content-wrap');
|
|
7
9
|
|
|
8
10
|
if (browser.gecko) {
|
|
9
11
|
element.setAttribute('contenteditable', 'true');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
2
|
import { ruleSharedStyles } from '@atlaskit/editor-common/styles';
|
|
3
3
|
import { akEditorLineHeight, akEditorSelectedBorderColor, akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
|
|
4
|
+
import { token } from '@atlaskit/tokens';
|
|
4
5
|
export const ruleStyles = props => css`
|
|
5
6
|
.ProseMirror {
|
|
6
7
|
${ruleSharedStyles(props)};
|
|
@@ -13,7 +14,7 @@ export const ruleStyles = props => css`
|
|
|
13
14
|
|
|
14
15
|
&.${akEditorSelectedNodeClassName} {
|
|
15
16
|
outline: none;
|
|
16
|
-
background-color: ${akEditorSelectedBorderColor};
|
|
17
|
+
background-color: ${token('color.border.selected', akEditorSelectedBorderColor)};
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
}
|
|
@@ -39,7 +39,7 @@ export const getDecorations = tr => {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
if (tr.selection instanceof TextSelection || tr.selection instanceof AllSelection) {
|
|
42
|
-
const decorations =
|
|
42
|
+
const decorations = getNodesToDecorateFromSelection(tr.selection, tr.doc).map(({
|
|
43
43
|
node,
|
|
44
44
|
pos
|
|
45
45
|
}) => {
|
|
@@ -92,24 +92,17 @@ export function getCellSelectionAnalyticsPayload(state) {
|
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
+
const topLevelBlockNodesThatHaveSelectionStyles = ['table', 'panel', 'expand', 'layoutSection', 'decisionList', 'decisionItem', 'codeBlock'];
|
|
95
96
|
/**
|
|
96
|
-
* Use `
|
|
97
|
-
* a list of
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* For example, using the following document:
|
|
103
|
-
* ```
|
|
104
|
-
* doc(p('{<}one'), blockquote(p('hello')), p(expand({ title: 'two' })(p('three'))), p('four{>}'))))
|
|
105
|
-
* ```
|
|
106
|
-
* we would expect `getTopLevelNodesFromSelection` to return:
|
|
107
|
-
* ```
|
|
108
|
-
* [blockquote(p('hello')), expand({ title: 'two' })(p('three')))]
|
|
109
|
-
* ```
|
|
97
|
+
* Use `getNodesToDecorateFromSelection` to collect and return
|
|
98
|
+
* a list of nodes within the Selection that should have Selection
|
|
99
|
+
* decorations applied. This allows selection styles to be added to
|
|
100
|
+
* nested nodes. It will ignore text nodes as decorations are
|
|
101
|
+
* applied natively and also ignore nodes that don't completely
|
|
102
|
+
* sit within the given `Selection`.
|
|
110
103
|
*/
|
|
111
104
|
|
|
112
|
-
export const
|
|
105
|
+
export const getNodesToDecorateFromSelection = (selection, doc) => {
|
|
113
106
|
const nodes = [];
|
|
114
107
|
|
|
115
108
|
if (selection.from !== selection.to) {
|
|
@@ -118,14 +111,36 @@ export const getTopLevelNodesFromSelection = (selection, doc) => {
|
|
|
118
111
|
to
|
|
119
112
|
} = selection;
|
|
120
113
|
doc.nodesBetween(from, to, (node, pos) => {
|
|
121
|
-
const withinSelection = from <= pos && pos + node.nodeSize <= to;
|
|
122
|
-
|
|
123
|
-
|
|
114
|
+
const withinSelection = from <= pos && pos + node.nodeSize <= to; // The reason we need to check for these nodes is to stop
|
|
115
|
+
// traversing their children if they are within a selection -
|
|
116
|
+
// this is to prevent selection styles from being added to
|
|
117
|
+
// the children as well as the parent node.
|
|
118
|
+
// Example scenario is if an entire table has been selected
|
|
119
|
+
// we should not traverse its children so we can apply the
|
|
120
|
+
// selection styles to the table. But if an entire tableRow
|
|
121
|
+
// has been selected (but the parent table has not) we should
|
|
122
|
+
// traverse it as it could contain other nodes that need
|
|
123
|
+
// selection styles. I couldn’t see a clear way to differentiate
|
|
124
|
+
// without explicitly stating which nodes should be traversed
|
|
125
|
+
// and which shouldn’t.
|
|
126
|
+
|
|
127
|
+
const isTopLevelNodeThatHasSelectionStyles = topLevelBlockNodesThatHaveSelectionStyles.includes(node.type.name); // If the node is a top-level block node and completely sits within
|
|
128
|
+
// the selection, we do not recurse it's children to prevent selection
|
|
129
|
+
// styles being added to its child nodes. The expected behaviour
|
|
130
|
+
// is that selection styles are only added to the parent.
|
|
131
|
+
|
|
132
|
+
if (node && withinSelection && isTopLevelNodeThatHasSelectionStyles) {
|
|
133
|
+
nodes.push({
|
|
134
|
+
node,
|
|
135
|
+
pos
|
|
136
|
+
});
|
|
137
|
+
return false; // Otherwise we recurse the children and return them so we can apply
|
|
138
|
+
// selection styles. Text is handled by the browser.
|
|
139
|
+
} else if (node && withinSelection && !node.isText) {
|
|
124
140
|
nodes.push({
|
|
125
141
|
node,
|
|
126
142
|
pos
|
|
127
143
|
});
|
|
128
|
-
return false;
|
|
129
144
|
}
|
|
130
145
|
|
|
131
146
|
return true;
|
|
@@ -9,6 +9,13 @@ import { syncStickyRowToTable, updateStickyMargins as updateTableMargin } from '
|
|
|
9
9
|
import { updateStickyState } from '../commands';
|
|
10
10
|
import { getTop, getTree } from './dom';
|
|
11
11
|
import { getFeatureFlags } from '../../../../feature-flags-context';
|
|
12
|
+
import debounce from 'lodash/debounce';
|
|
13
|
+
import throttle from 'lodash/throttle'; // limit scroll event calls
|
|
14
|
+
|
|
15
|
+
const HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200; // timeout for resetting the scroll class - if it’s too long then users won’t be able to click on the header cells,
|
|
16
|
+
// if too short it would trigger too many dom udpates.
|
|
17
|
+
|
|
18
|
+
const HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT = 400;
|
|
12
19
|
export const supportedHeaderRow = node => {
|
|
13
20
|
const allHeaders = mapChildren(node, child => child.type.name === 'tableHeader').every(Boolean);
|
|
14
21
|
const someMerged = mapChildren(node, child => child.attrs.rowspan || 0).some(rowspan => rowspan > 1);
|
|
@@ -33,6 +40,17 @@ export class TableRowNodeView {
|
|
|
33
40
|
|
|
34
41
|
_defineProperty(this, "listening", false);
|
|
35
42
|
|
|
43
|
+
_defineProperty(this, "headerRowMouseScrollEnd", debounce(() => {
|
|
44
|
+
this.dom.classList.remove('no-pointer-events');
|
|
45
|
+
}, HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT));
|
|
46
|
+
|
|
47
|
+
_defineProperty(this, "headerRowMouseScroll", throttle(() => {
|
|
48
|
+
if (this.isSticky) {
|
|
49
|
+
this.dom.classList.add('no-pointer-events');
|
|
50
|
+
this.headerRowMouseScrollEnd();
|
|
51
|
+
}
|
|
52
|
+
}, HEADER_ROW_SCROLL_THROTTLE_TIMEOUT));
|
|
53
|
+
|
|
36
54
|
_defineProperty(this, "onScroll", () => {
|
|
37
55
|
if (!this.tree) {
|
|
38
56
|
return;
|
|
@@ -322,6 +340,8 @@ export class TableRowNodeView {
|
|
|
322
340
|
this.eventDispatcher.on(widthPluginKey.key, this.onWidthPluginState);
|
|
323
341
|
this.eventDispatcher.on(tablePluginKey.key, this.onTablePluginState);
|
|
324
342
|
this.listening = true;
|
|
343
|
+
this.dom.addEventListener('wheel', this.headerRowMouseScroll.bind(this));
|
|
344
|
+
this.dom.addEventListener('touchmove', this.headerRowMouseScroll.bind(this));
|
|
325
345
|
}
|
|
326
346
|
|
|
327
347
|
unsubscribe() {
|
|
@@ -344,6 +364,8 @@ export class TableRowNodeView {
|
|
|
344
364
|
this.eventDispatcher.off(widthPluginKey.key, this.onWidthPluginState);
|
|
345
365
|
this.eventDispatcher.off(tablePluginKey.key, this.onTablePluginState);
|
|
346
366
|
this.listening = false;
|
|
367
|
+
this.dom.removeEventListener('wheel', this.headerRowMouseScroll);
|
|
368
|
+
this.dom.removeEventListener('touchmove', this.headerRowMouseScroll);
|
|
347
369
|
} // initialize intersection observer to track if table is within scroll area
|
|
348
370
|
|
|
349
371
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { B200, B300, B75, N0, N20, R50, R400, R75, DN400, N200, DN30 } from '@atlaskit/theme/colors';
|
|
2
2
|
import { tableCellBorderWidth, tableMarginTop } from '@atlaskit/editor-common/styles';
|
|
3
3
|
import { akEditorTableBorder, akEditorTableBorderDark, akEditorTableToolbar, akEditorTableToolbarDark, akEditorTableToolbarSize, akEditorUnitZIndex, akRichMediaResizeZIndex } from '@atlaskit/editor-shared-styles';
|
|
4
|
+
import { token } from '@atlaskit/tokens';
|
|
4
5
|
import { RESIZE_HANDLE_AREA_DECORATION_GAP } from '../types';
|
|
5
6
|
import { themed } from '@atlaskit/theme/components';
|
|
6
7
|
/**
|
|
@@ -12,16 +13,16 @@ export const tableCellBackgroundColor = themed({
|
|
|
12
13
|
dark: DN30
|
|
13
14
|
});
|
|
14
15
|
export const tableToolbarColor = themed({
|
|
15
|
-
light: akEditorTableToolbar,
|
|
16
|
-
dark: akEditorTableToolbarDark
|
|
16
|
+
light: token('color.background.neutral', akEditorTableToolbar),
|
|
17
|
+
dark: token('color.background.neutral', akEditorTableToolbarDark)
|
|
17
18
|
});
|
|
18
19
|
export const tableTextColor = themed({
|
|
19
20
|
light: N200,
|
|
20
21
|
dark: DN400
|
|
21
22
|
});
|
|
22
23
|
export const tableBorderColor = themed({
|
|
23
|
-
light: akEditorTableBorder,
|
|
24
|
-
dark: akEditorTableBorderDark
|
|
24
|
+
light: token('color.border', akEditorTableBorder),
|
|
25
|
+
dark: token('color.border', akEditorTableBorderDark)
|
|
25
26
|
});
|
|
26
27
|
export const tableFloatingControlsColor = N20;
|
|
27
28
|
export const tableCellSelectedColor = B75;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
2
|
import { TaskDecisionSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
3
3
|
import { SelectionStyle, getSelectionStyles, akEditorDeleteBackgroundWithOpacity, akEditorDeleteBorder, akEditorSelectedBorderSize, akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
|
|
4
|
+
import { token } from '@atlaskit/tokens';
|
|
4
5
|
export const taskDecisionStyles = css`
|
|
5
6
|
[data-decision-wrapper] {
|
|
6
7
|
cursor: pointer;
|
|
@@ -15,8 +16,9 @@ export const taskDecisionStyles = css`
|
|
|
15
16
|
.danger {
|
|
16
17
|
.${TaskDecisionSharedCssClassName.DECISION_CONTAINER}.${akEditorSelectedNodeClassName}
|
|
17
18
|
> div {
|
|
18
|
-
box-shadow: 0 0 0 ${akEditorSelectedBorderSize}px
|
|
19
|
-
|
|
19
|
+
box-shadow: 0 0 0 ${akEditorSelectedBorderSize}px
|
|
20
|
+
${token('color.border.danger', akEditorDeleteBorder)};
|
|
21
|
+
background-color: ${token('color.blanket.danger', akEditorDeleteBackgroundWithOpacity)};
|
|
20
22
|
&::after {
|
|
21
23
|
content: none; /* reset the Blanket selection style */
|
|
22
24
|
}
|
|
@@ -180,6 +180,7 @@ const typeAheadPlugin = options => {
|
|
|
180
180
|
},
|
|
181
181
|
|
|
182
182
|
onEditorViewStateUpdated({
|
|
183
|
+
originalTransaction,
|
|
183
184
|
oldEditorState,
|
|
184
185
|
newEditorState
|
|
185
186
|
}) {
|
|
@@ -199,10 +200,13 @@ const typeAheadPlugin = options => {
|
|
|
199
200
|
const isANewHandler = oldTriggerHandler !== newTriggerHandler;
|
|
200
201
|
|
|
201
202
|
if (oldTriggerHandler !== null && oldTriggerHandler !== void 0 && oldTriggerHandler.dismiss && isANewHandler) {
|
|
203
|
+
const typeAheadMessage = originalTransaction.getMeta(typeAheadPluginKey);
|
|
204
|
+
const wasItemInserted = typeAheadMessage && typeAheadMessage.action === 'INSERT_RAW_QUERY';
|
|
202
205
|
oldTriggerHandler.dismiss({
|
|
203
206
|
editorState: newEditorState,
|
|
204
207
|
query: oldPluginState.query,
|
|
205
|
-
stats: (oldPluginState.stats || new StatsModifier()).serialize()
|
|
208
|
+
stats: (oldPluginState.stats || new StatsModifier()).serialize(),
|
|
209
|
+
wasItemInserted
|
|
206
210
|
});
|
|
207
211
|
}
|
|
208
212
|
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
2
|
import { PluginKey } from 'prosemirror-state';
|
|
3
3
|
import { confluenceUnsupportedBlock, confluenceUnsupportedInline, unsupportedBlock, unsupportedInline, unsupportedMark, unsupportedNodeAttribute } from '@atlaskit/adf-schema';
|
|
4
|
-
import { UnsupportedBlock
|
|
4
|
+
import { UnsupportedBlock } from '@atlaskit/editor-common/ui';
|
|
5
|
+
import { UnsupportedInlineNodeView } from './unsupported-inline-node-view';
|
|
5
6
|
import { ReactNodeView } from '../../nodeviews';
|
|
7
|
+
import { getInlineNodeViewProducer } from '../../nodeviews/getInlineNodeViewProducer';
|
|
6
8
|
export const pluginKey = new PluginKey('unsupportedContentPlugin');
|
|
7
9
|
|
|
8
|
-
const createPlugin =
|
|
9
|
-
portalProviderAPI,
|
|
10
|
-
eventDispatcher,
|
|
11
|
-
dispatchAnalyticsEvent
|
|
12
|
-
}) => {
|
|
10
|
+
const createPlugin = pmPluginFactoryParams => {
|
|
13
11
|
const hasIntlContext = true;
|
|
12
|
+
const {
|
|
13
|
+
portalProviderAPI,
|
|
14
|
+
eventDispatcher,
|
|
15
|
+
dispatchAnalyticsEvent
|
|
16
|
+
} = pmPluginFactoryParams;
|
|
14
17
|
return new SafePlugin({
|
|
15
18
|
key: pluginKey,
|
|
16
19
|
props: {
|
|
@@ -18,15 +21,23 @@ const createPlugin = ({
|
|
|
18
21
|
confluenceUnsupportedBlock: ReactNodeView.fromComponent(UnsupportedBlock, portalProviderAPI, eventDispatcher, {
|
|
19
22
|
dispatchAnalyticsEvent
|
|
20
23
|
}, undefined, hasIntlContext),
|
|
21
|
-
confluenceUnsupportedInline:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
confluenceUnsupportedInline: getInlineNodeViewProducer({
|
|
25
|
+
pmPluginFactoryParams,
|
|
26
|
+
Component: UnsupportedInlineNodeView,
|
|
27
|
+
extraComponentProps: {
|
|
28
|
+
dispatchAnalyticsEvent
|
|
29
|
+
}
|
|
30
|
+
}),
|
|
24
31
|
unsupportedBlock: ReactNodeView.fromComponent(UnsupportedBlock, portalProviderAPI, eventDispatcher, {
|
|
25
32
|
dispatchAnalyticsEvent
|
|
26
33
|
}, undefined, hasIntlContext),
|
|
27
|
-
unsupportedInline:
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
unsupportedInline: getInlineNodeViewProducer({
|
|
35
|
+
pmPluginFactoryParams,
|
|
36
|
+
Component: UnsupportedInlineNodeView,
|
|
37
|
+
extraComponentProps: {
|
|
38
|
+
dispatchAnalyticsEvent
|
|
39
|
+
}
|
|
40
|
+
})
|
|
30
41
|
}
|
|
31
42
|
}
|
|
32
43
|
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
2
|
import { SelectionStyle, getSelectionStyles, akEditorDeleteBackgroundWithOpacity, akEditorSelectedBorderSize, akEditorDeleteBorder, akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
|
|
3
|
+
import { token } from '@atlaskit/tokens';
|
|
3
4
|
export const UnsupportedSharedCssClassName = {
|
|
4
5
|
BLOCK_CONTAINER: 'unsupportedBlockView-content-wrap',
|
|
5
6
|
INLINE_CONTAINER: 'unsupportedInlineView-content-wrap'
|
|
6
7
|
};
|
|
7
|
-
const inlineUnsupportedSelector = `.${UnsupportedSharedCssClassName.INLINE_CONTAINER} > span`;
|
|
8
|
+
const inlineUnsupportedSelector = `.${UnsupportedSharedCssClassName.INLINE_CONTAINER} > span:nth-child(2)`;
|
|
8
9
|
const blockUnsupportedSelector = `.${UnsupportedSharedCssClassName.BLOCK_CONTAINER} > div`;
|
|
9
10
|
export const unsupportedStyles = css`
|
|
10
11
|
${blockUnsupportedSelector}, ${inlineUnsupportedSelector} {
|
|
@@ -19,8 +20,9 @@ export const unsupportedStyles = css`
|
|
|
19
20
|
.danger {
|
|
20
21
|
.${akEditorSelectedNodeClassName}${blockUnsupportedSelector},
|
|
21
22
|
.${akEditorSelectedNodeClassName}${inlineUnsupportedSelector} {
|
|
22
|
-
border: ${akEditorSelectedBorderSize}px solid
|
|
23
|
-
|
|
23
|
+
border: ${akEditorSelectedBorderSize}px solid
|
|
24
|
+
${token('color.border.danger', akEditorDeleteBorder)};
|
|
25
|
+
background-color: ${token('color.blanket.danger', akEditorDeleteBackgroundWithOpacity)};
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
28
|
`;
|
|
@@ -12,7 +12,6 @@ import WithFlash from '../WithFlash';
|
|
|
12
12
|
const chromelessEditor = css`
|
|
13
13
|
line-height: 20px;
|
|
14
14
|
height: auto;
|
|
15
|
-
min-height: 30px;
|
|
16
15
|
|
|
17
16
|
overflow-x: hidden;
|
|
18
17
|
overflow-y: auto;
|
|
@@ -50,6 +49,7 @@ export default class Editor extends React.Component {
|
|
|
50
49
|
contentComponents,
|
|
51
50
|
customContentComponents,
|
|
52
51
|
maxHeight,
|
|
52
|
+
minHeight = 30,
|
|
53
53
|
popupsMountPoint,
|
|
54
54
|
popupsBoundariesElement,
|
|
55
55
|
popupsScrollableElement,
|
|
@@ -62,7 +62,10 @@ export default class Editor extends React.Component {
|
|
|
62
62
|
}, jsx("div", {
|
|
63
63
|
css: [chromelessEditor, maxHeight && css`
|
|
64
64
|
max-height: ${maxHeight}px;
|
|
65
|
-
`
|
|
65
|
+
`, css`
|
|
66
|
+
min-height: ${minHeight}px;
|
|
67
|
+
`],
|
|
68
|
+
"data-testid": "chromeless-editor",
|
|
66
69
|
ref: ref => this.containerElement = ref
|
|
67
70
|
}, jsx(ContentArea, null, customContentComponents, jsx(PluginSlot, {
|
|
68
71
|
editorView: editorView,
|
|
@@ -37,7 +37,7 @@ const commentEditorStyle = css`
|
|
|
37
37
|
min-width: 272px;
|
|
38
38
|
/* Border + Toolbar + Footer + (Paragraph + ((Parahraph + Margin) * (DefaultLines - 1)) */
|
|
39
39
|
/* calc(2px + 40px + 24px + ( 20px + (32px * 2))) */
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
height: auto;
|
|
42
42
|
background-color: white;
|
|
43
43
|
border: 1px solid ${N40};
|
|
@@ -117,6 +117,7 @@ class Editor extends React.Component {
|
|
|
117
117
|
popupsBoundariesElement,
|
|
118
118
|
popupsScrollableElement,
|
|
119
119
|
maxHeight,
|
|
120
|
+
minHeight = 150,
|
|
120
121
|
onSave,
|
|
121
122
|
onCancel,
|
|
122
123
|
disabled,
|
|
@@ -129,7 +130,9 @@ class Editor extends React.Component {
|
|
|
129
130
|
return jsx(WithFlash, {
|
|
130
131
|
animate: maxContentSizeReached
|
|
131
132
|
}, jsx("div", {
|
|
132
|
-
css: commentEditorStyle,
|
|
133
|
+
css: [commentEditorStyle, css`
|
|
134
|
+
min-height: ${minHeight}px;
|
|
135
|
+
`],
|
|
133
136
|
className: "akEditor"
|
|
134
137
|
}, jsx(MainToolbar, {
|
|
135
138
|
useStickyToolbar: useStickyToolbar
|
|
@@ -2,11 +2,12 @@ import { css } from '@emotion/react';
|
|
|
2
2
|
import { akEditorSubtleAccent, relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
|
|
3
3
|
import { borderRadius } from '@atlaskit/theme/constants';
|
|
4
4
|
import { N300, N50 } from '@atlaskit/theme/colors';
|
|
5
|
+
import { token } from '@atlaskit/tokens';
|
|
5
6
|
export const inputStyle = css`
|
|
6
7
|
/* Normal .className gets overridden by input[type=text] hence this hack to produce input.className */
|
|
7
8
|
input& {
|
|
8
9
|
background-color: white;
|
|
9
|
-
border: 1px solid ${akEditorSubtleAccent};
|
|
10
|
+
border: 1px solid ${token('color.border.input', akEditorSubtleAccent)};
|
|
10
11
|
border-radius: ${borderRadius()}px;
|
|
11
12
|
box-sizing: border-box;
|
|
12
13
|
height: 40px;
|
|
@@ -17,7 +17,7 @@ import { layoutStyles } from '../../plugins/layout/styles';
|
|
|
17
17
|
import { panelStyles } from '../../plugins/panel/styles';
|
|
18
18
|
import { fakeCursorStyles } from '../../plugins/fake-text-cursor/styles';
|
|
19
19
|
import { mentionsStyles } from '../../plugins/mentions/styles';
|
|
20
|
-
import { emojiStyles
|
|
20
|
+
import { emojiStyles } from '../../plugins/emoji/styles';
|
|
21
21
|
import { textFormattingStyles } from '../../plugins/text-formatting/styles';
|
|
22
22
|
import { placeholderTextStyles } from '../../plugins/placeholder-text/styles';
|
|
23
23
|
import { gridStyles } from '../../plugins/grid/styles';
|
|
@@ -35,7 +35,7 @@ import { useFeatureFlags } from '../../plugins/feature-flags-context';
|
|
|
35
35
|
import { InlineNodeViewSharedStyles } from '../../nodeviews/getInlineNodeViewProducer.styles';
|
|
36
36
|
|
|
37
37
|
const contentStyles = props => {
|
|
38
|
-
var _props$featureFlags
|
|
38
|
+
var _props$featureFlags;
|
|
39
39
|
|
|
40
40
|
return css`
|
|
41
41
|
.ProseMirror {
|
|
@@ -89,7 +89,7 @@ const contentStyles = props => {
|
|
|
89
89
|
${panelStyles(props)}
|
|
90
90
|
${fakeCursorStyles}
|
|
91
91
|
${mentionsStyles}
|
|
92
|
-
${
|
|
92
|
+
${emojiStyles}
|
|
93
93
|
${tasksAndDecisionsStyles}
|
|
94
94
|
${gridStyles}
|
|
95
95
|
${linkStyles}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import AtlaskitTheme from '@atlaskit/theme/components';
|
|
3
|
+
import { CHANNEL } from '@atlaskit/theme/constants';
|
|
4
|
+
import { ThemeProvider } from '@emotion/react';
|
|
5
|
+
import { ThemeProvider as DeprectateStyledComponentsProvider } from 'styled-components';
|
|
6
|
+
export function PortalProviderThemeProviders(props) {
|
|
7
|
+
const {
|
|
8
|
+
children,
|
|
9
|
+
mode
|
|
10
|
+
} = props;
|
|
11
|
+
const styledComponentsAndEmotionTheme = React.useMemo( // This return value should only be one of the following
|
|
12
|
+
// - { [CHANNEL]: { mode },
|
|
13
|
+
// - { theme: { [CHANNEL]: { mode } }
|
|
14
|
+
// However, it appears that consumers have inconsistent expectations
|
|
15
|
+
// regarding the shape.
|
|
16
|
+
// This can be revisited in future work, and for the purposes of
|
|
17
|
+
// fixing https://product-fabric.atlassian.net/browse/ED-14956
|
|
18
|
+
// we are merging the two shapes consumers expect.
|
|
19
|
+
() => ({
|
|
20
|
+
[CHANNEL]: {
|
|
21
|
+
mode
|
|
22
|
+
},
|
|
23
|
+
theme: {
|
|
24
|
+
[CHANNEL]: {
|
|
25
|
+
mode
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}), [mode]);
|
|
29
|
+
const atlaskitTheme = React.useCallback(() => ({
|
|
30
|
+
mode
|
|
31
|
+
}), [mode]);
|
|
32
|
+
return /*#__PURE__*/React.createElement(DeprectateStyledComponentsProvider, {
|
|
33
|
+
theme: styledComponentsAndEmotionTheme
|
|
34
|
+
}, /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
35
|
+
theme: styledComponentsAndEmotionTheme
|
|
36
|
+
}, /*#__PURE__*/React.createElement(AtlaskitTheme.Provider, {
|
|
37
|
+
value: atlaskitTheme
|
|
38
|
+
}, children)));
|
|
39
|
+
}
|