@atlaskit/editor-core 185.5.0 → 185.5.5
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 +13 -0
- package/dist/cjs/plugins/breakout/ui/LayoutButton.js +5 -28
- package/dist/cjs/plugins/card/index.js +20 -6
- package/dist/cjs/plugins/card/nodeviews/datasource.js +39 -4
- package/dist/cjs/plugins/card/pm-plugins/actions.js +31 -1
- package/dist/cjs/plugins/card/pm-plugins/main.js +48 -3
- package/dist/cjs/plugins/card/pm-plugins/reducers.js +22 -0
- package/dist/cjs/plugins/card/styles.js +1 -1
- package/dist/cjs/plugins/card/ui/LayoutButton/index.js +113 -0
- package/dist/cjs/plugins/card/ui/LayoutButton/styled.js +17 -0
- package/dist/cjs/plugins/card/ui/LayoutButton/types.js +5 -0
- package/dist/cjs/plugins/card/ui/LayoutButton/utils.js +19 -0
- package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +1 -0
- package/dist/cjs/plugins/media/pm-plugins/main.js +20 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/breakout/ui/LayoutButton.js +3 -26
- package/dist/es2019/plugins/breakout/utils/get-breakout-mode.js +0 -1
- package/dist/es2019/plugins/card/index.js +20 -3
- package/dist/es2019/plugins/card/nodeviews/datasource.js +38 -1
- package/dist/es2019/plugins/card/pm-plugins/actions.js +16 -0
- package/dist/es2019/plugins/card/pm-plugins/main.js +55 -4
- package/dist/es2019/plugins/card/pm-plugins/reducers.js +25 -0
- package/dist/es2019/plugins/card/styles.js +6 -0
- package/dist/es2019/plugins/card/ui/LayoutButton/index.js +106 -0
- package/dist/es2019/plugins/card/ui/LayoutButton/styled.js +10 -0
- package/dist/es2019/plugins/card/ui/LayoutButton/types.js +1 -0
- package/dist/es2019/plugins/card/ui/LayoutButton/utils.js +15 -0
- package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +1 -0
- package/dist/es2019/plugins/media/pm-plugins/main.js +25 -3
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/breakout/ui/LayoutButton.js +3 -26
- package/dist/esm/plugins/breakout/utils/get-breakout-mode.js +0 -1
- package/dist/esm/plugins/card/index.js +20 -3
- package/dist/esm/plugins/card/nodeviews/datasource.js +37 -3
- package/dist/esm/plugins/card/pm-plugins/actions.js +27 -0
- package/dist/esm/plugins/card/pm-plugins/main.js +49 -4
- package/dist/esm/plugins/card/pm-plugins/reducers.js +22 -0
- package/dist/esm/plugins/card/styles.js +1 -1
- package/dist/esm/plugins/card/ui/LayoutButton/index.js +102 -0
- package/dist/esm/plugins/card/ui/LayoutButton/styled.js +10 -0
- package/dist/esm/plugins/card/ui/LayoutButton/types.js +1 -0
- package/dist/esm/plugins/card/ui/LayoutButton/utils.js +12 -0
- package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +1 -0
- package/dist/esm/plugins/media/pm-plugins/main.js +22 -3
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/breakout/commands/set-breakout-mode.d.ts +1 -1
- package/dist/types/plugins/breakout/utils/get-breakout-mode.d.ts +1 -1
- package/dist/types/plugins/card/index.d.ts +3 -1
- package/dist/types/plugins/card/nodeviews/datasource.d.ts +18 -2
- package/dist/types/plugins/card/pm-plugins/actions.d.ts +7 -0
- package/dist/types/plugins/card/pm-plugins/plugin-key.d.ts +2 -1
- package/dist/types/plugins/card/pm-plugins/util/state.d.ts +2 -0
- package/dist/types/plugins/card/types.d.ts +17 -1
- package/dist/types/plugins/card/ui/LayoutButton/index.d.ts +9 -0
- package/dist/types/plugins/card/ui/LayoutButton/styled.d.ts +1 -0
- package/dist/types/plugins/card/ui/LayoutButton/types.d.ts +19 -0
- package/dist/types/plugins/card/ui/LayoutButton/utils.d.ts +5 -0
- package/dist/types-ts4.5/plugins/breakout/commands/set-breakout-mode.d.ts +1 -1
- package/dist/types-ts4.5/plugins/breakout/utils/get-breakout-mode.d.ts +1 -1
- package/dist/types-ts4.5/plugins/card/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/card/nodeviews/datasource.d.ts +18 -2
- package/dist/types-ts4.5/plugins/card/pm-plugins/actions.d.ts +7 -0
- package/dist/types-ts4.5/plugins/card/pm-plugins/plugin-key.d.ts +2 -1
- package/dist/types-ts4.5/plugins/card/pm-plugins/util/state.d.ts +2 -0
- package/dist/types-ts4.5/plugins/card/types.d.ts +17 -1
- package/dist/types-ts4.5/plugins/card/ui/LayoutButton/index.d.ts +9 -0
- package/dist/types-ts4.5/plugins/card/ui/LayoutButton/styled.d.ts +1 -0
- package/dist/types-ts4.5/plugins/card/ui/LayoutButton/types.d.ts +19 -0
- package/dist/types-ts4.5/plugins/card/ui/LayoutButton/utils.d.ts +5 -0
- package/package.json +6 -6
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = "@atlaskit/editor-core";
|
|
8
8
|
exports.name = name;
|
|
9
|
-
var version = "185.5.
|
|
9
|
+
var version = "185.5.5";
|
|
10
10
|
exports.version = version;
|
|
11
11
|
var nextMajorVersion = function nextMajorVersion() {
|
|
12
12
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
package/dist/cjs/version.json
CHANGED
|
@@ -12,13 +12,13 @@ import ToolbarButton from '../../../ui/ToolbarButton';
|
|
|
12
12
|
import { getBreakoutMode } from '../utils/get-breakout-mode';
|
|
13
13
|
import { setBreakoutMode } from '../commands/set-breakout-mode';
|
|
14
14
|
import { removeBreakout } from '../commands/remove-breakout';
|
|
15
|
-
import commonMessages from '../../../messages';
|
|
16
15
|
import { BreakoutCssClassName } from '../constants';
|
|
17
16
|
import { isBreakoutMarkAllowed } from '../utils/is-breakout-mark-allowed';
|
|
18
17
|
import { getPluginState } from '../plugin-key';
|
|
19
18
|
import { NodeSelection } from 'prosemirror-state';
|
|
20
19
|
import { isSupportedNodeForBreakout } from '../utils/is-supported-node';
|
|
21
20
|
import { layers } from '@atlaskit/theme/constants';
|
|
21
|
+
import { getNextBreakoutMode, getTitle } from '@atlaskit/editor-common/utils';
|
|
22
22
|
const toolbarButtonWrapper = css`
|
|
23
23
|
&& button {
|
|
24
24
|
background: ${`var(--ds-background-neutral, ${N20A})`};
|
|
@@ -29,29 +29,6 @@ const toolbarButtonWrapper = css`
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
`;
|
|
32
|
-
const BREAKOUT_MODE = {
|
|
33
|
-
FULL_WIDTH: 'full-width',
|
|
34
|
-
CENTER: 'center',
|
|
35
|
-
WIDE: 'wide'
|
|
36
|
-
};
|
|
37
|
-
const getNextBreakoutMode = currentMode => {
|
|
38
|
-
if (currentMode === BREAKOUT_MODE.FULL_WIDTH) {
|
|
39
|
-
return BREAKOUT_MODE.CENTER;
|
|
40
|
-
} else if (currentMode === BREAKOUT_MODE.WIDE) {
|
|
41
|
-
return BREAKOUT_MODE.FULL_WIDTH;
|
|
42
|
-
}
|
|
43
|
-
return BREAKOUT_MODE.WIDE;
|
|
44
|
-
};
|
|
45
|
-
const getTitle = layout => {
|
|
46
|
-
switch (layout) {
|
|
47
|
-
case BREAKOUT_MODE.FULL_WIDTH:
|
|
48
|
-
return commonMessages.layoutFixedWidth;
|
|
49
|
-
case BREAKOUT_MODE.WIDE:
|
|
50
|
-
return commonMessages.layoutFullWidth;
|
|
51
|
-
default:
|
|
52
|
-
return commonMessages.layoutWide;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
32
|
function getBreakoutNodeElement(pluginState, selection, editorView) {
|
|
56
33
|
if (selection instanceof NodeSelection && isSupportedNodeForBreakout(selection.node)) {
|
|
57
34
|
return findDomRefAtPos(selection.from, editorView.domAtPos.bind(editorView));
|
|
@@ -66,7 +43,7 @@ class LayoutButton extends React.Component {
|
|
|
66
43
|
state,
|
|
67
44
|
dispatch
|
|
68
45
|
} = this.props.editorView;
|
|
69
|
-
if ([
|
|
46
|
+
if (['wide', 'full-width'].indexOf(breakoutMode) !== -1) {
|
|
70
47
|
setBreakoutMode(breakoutMode)(state, dispatch);
|
|
71
48
|
} else {
|
|
72
49
|
removeBreakout()(state, dispatch);
|
|
@@ -122,7 +99,7 @@ class LayoutButton extends React.Component {
|
|
|
122
99
|
title: title,
|
|
123
100
|
testId: titleMessage.id,
|
|
124
101
|
onClick: this.handleClick(nextBreakoutMode),
|
|
125
|
-
iconBefore: breakoutMode ===
|
|
102
|
+
iconBefore: breakoutMode === 'full-width' ? jsx(CollapseIcon, {
|
|
126
103
|
label: title
|
|
127
104
|
}) : jsx(ExpandIcon, {
|
|
128
105
|
label: title
|
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { inlineCard, blockCard, embedCard } from '@atlaskit/adf-schema';
|
|
3
3
|
import { createPlugin } from './pm-plugins/main';
|
|
4
4
|
import { floatingToolbar } from './toolbar';
|
|
5
5
|
import { EditorSmartCardEvents } from './ui/EditorSmartCardEvents';
|
|
6
6
|
import { cardKeymap } from './pm-plugins/keymap';
|
|
7
7
|
import { EditorSmartCardEventsNext } from './ui/EditorSmartCardEventsNext';
|
|
8
|
+
import LayoutButton from './ui/LayoutButton';
|
|
9
|
+
import { pluginKey } from './pm-plugins/plugin-key';
|
|
8
10
|
const cardPlugin = (options, api) => {
|
|
9
11
|
var _api$dependencies, _api$dependencies$fea;
|
|
10
12
|
const featureFlags = (api === null || api === void 0 ? void 0 : (_api$dependencies = api.dependencies) === null || _api$dependencies === void 0 ? void 0 : (_api$dependencies$fea = _api$dependencies.featureFlags) === null || _api$dependencies$fea === void 0 ? void 0 : _api$dependencies$fea.sharedState.currentState()) || {};
|
|
11
13
|
return {
|
|
12
14
|
name: 'card',
|
|
15
|
+
getSharedState(editorState) {
|
|
16
|
+
if (!editorState) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return pluginKey.getState(editorState);
|
|
20
|
+
},
|
|
13
21
|
nodes() {
|
|
14
22
|
const nodes = [{
|
|
15
23
|
name: 'inlineCard',
|
|
@@ -55,15 +63,24 @@ const cardPlugin = (options, api) => {
|
|
|
55
63
|
return plugins;
|
|
56
64
|
},
|
|
57
65
|
contentComponent({
|
|
58
|
-
editorView
|
|
66
|
+
editorView,
|
|
67
|
+
popupsMountPoint,
|
|
68
|
+
popupsScrollableElement,
|
|
69
|
+
popupsBoundariesElement
|
|
59
70
|
}) {
|
|
60
71
|
const {
|
|
61
72
|
lpAnalyticsEventsNext
|
|
62
73
|
} = featureFlags;
|
|
63
|
-
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(EditorSmartCardEvents, {
|
|
74
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditorSmartCardEvents, {
|
|
64
75
|
editorView: editorView
|
|
65
76
|
}), lpAnalyticsEventsNext && /*#__PURE__*/React.createElement(EditorSmartCardEventsNext, {
|
|
66
77
|
editorView: editorView
|
|
78
|
+
}), /*#__PURE__*/React.createElement(LayoutButton, {
|
|
79
|
+
api: api,
|
|
80
|
+
editorView: editorView,
|
|
81
|
+
mountPoint: popupsMountPoint,
|
|
82
|
+
scrollableElement: popupsScrollableElement,
|
|
83
|
+
boundariesElement: popupsBoundariesElement
|
|
67
84
|
}));
|
|
68
85
|
},
|
|
69
86
|
pluginsOptions: {
|
|
@@ -5,6 +5,9 @@ import PropTypes from 'prop-types';
|
|
|
5
5
|
import { css, jsx } from '@emotion/react';
|
|
6
6
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
7
7
|
import { DatasourceTableView } from '@atlaskit/link-datasource';
|
|
8
|
+
import { SmartCardSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
9
|
+
import { calcBreakoutWidthPx } from '@atlaskit/editor-common/utils';
|
|
10
|
+
export const DATASOURCE_INNER_CONTAINER_CLASSNAME = 'datasourceView-content-inner-wrap';
|
|
8
11
|
const containerStyles = css({
|
|
9
12
|
height: '500px',
|
|
10
13
|
overflow: 'auto'
|
|
@@ -88,9 +91,43 @@ _defineProperty(DatasourceComponent, "contextTypes", {
|
|
|
88
91
|
contextAdapter: PropTypes.object
|
|
89
92
|
});
|
|
90
93
|
export class Datasource extends ReactNodeView {
|
|
94
|
+
constructor(props) {
|
|
95
|
+
var _props$pluginInjectio, _props$pluginInjectio2, _props$pluginInjectio3, _sharedState$currentS;
|
|
96
|
+
super(props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props, undefined, true, undefined, props.hasIntlContext);
|
|
97
|
+
_defineProperty(this, "calcTableWidth", (layout, containerWidth) => {
|
|
98
|
+
if (layout === 'center') {
|
|
99
|
+
return 'inherit';
|
|
100
|
+
}
|
|
101
|
+
return calcBreakoutWidthPx(layout, containerWidth);
|
|
102
|
+
});
|
|
103
|
+
const sharedState = props === null || props === void 0 ? void 0 : (_props$pluginInjectio = props.pluginInjectionApi) === null || _props$pluginInjectio === void 0 ? void 0 : (_props$pluginInjectio2 = _props$pluginInjectio.dependencies) === null || _props$pluginInjectio2 === void 0 ? void 0 : (_props$pluginInjectio3 = _props$pluginInjectio2.width) === null || _props$pluginInjectio3 === void 0 ? void 0 : _props$pluginInjectio3.sharedState;
|
|
104
|
+
this.tableWidth = sharedState === null || sharedState === void 0 ? void 0 : (_sharedState$currentS = sharedState.currentState()) === null || _sharedState$currentS === void 0 ? void 0 : _sharedState$currentS.width;
|
|
105
|
+
sharedState === null || sharedState === void 0 ? void 0 : sharedState.onChange(({
|
|
106
|
+
nextSharedState
|
|
107
|
+
}) => {
|
|
108
|
+
if (nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.width && this.tableWidth !== (nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.width)) {
|
|
109
|
+
this.tableWidth = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.width;
|
|
110
|
+
this.update(this.node, []); // required to update the width when page is resized.
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
createDomRef() {
|
|
116
|
+
const domRef = document.createElement('div');
|
|
117
|
+
domRef.classList.add(SmartCardSharedCssClassName.DATASOURCE_CONTAINER);
|
|
118
|
+
return domRef;
|
|
119
|
+
}
|
|
91
120
|
render() {
|
|
121
|
+
const {
|
|
122
|
+
attrs
|
|
123
|
+
} = this.node;
|
|
124
|
+
const calculatedWidth = this.calcTableWidth(attrs.layout, this.tableWidth);
|
|
92
125
|
return jsx("div", {
|
|
93
|
-
|
|
126
|
+
className: DATASOURCE_INNER_CONTAINER_CLASSNAME,
|
|
127
|
+
css: containerStyles,
|
|
128
|
+
style: {
|
|
129
|
+
minWidth: calculatedWidth
|
|
130
|
+
}
|
|
94
131
|
}, jsx(DatasourceComponent, {
|
|
95
132
|
node: this.node,
|
|
96
133
|
view: this.view,
|
|
@@ -26,6 +26,22 @@ export const setProvider = cardProvider => tr => cardAction(tr, {
|
|
|
26
26
|
type: 'SET_PROVIDER',
|
|
27
27
|
provider: cardProvider
|
|
28
28
|
});
|
|
29
|
+
export const setDatasourceTableRef = datasourceTableRef => tr => cardAction(tr, {
|
|
30
|
+
type: 'SET_DATASOURCE_TABLE_REF',
|
|
31
|
+
datasourceTableRef
|
|
32
|
+
});
|
|
33
|
+
export const setCardLayout = layout => tr => cardAction(tr, {
|
|
34
|
+
type: 'SET_CARD_LAYOUT',
|
|
35
|
+
layout
|
|
36
|
+
});
|
|
37
|
+
export const setCardLayoutAndDatasourceTableRef = ({
|
|
38
|
+
layout,
|
|
39
|
+
datasourceTableRef
|
|
40
|
+
}) => tr => cardAction(tr, {
|
|
41
|
+
type: 'SET_CARD_LAYOUT_AND_DATASOURCE_TABLE_REF',
|
|
42
|
+
layout,
|
|
43
|
+
datasourceTableRef
|
|
44
|
+
});
|
|
29
45
|
export const showLinkToolbar = tr => cardAction(tr, {
|
|
30
46
|
type: 'SHOW_LINK_TOOLBAR'
|
|
31
47
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { NodeSelection } from 'prosemirror-state';
|
|
2
3
|
import rafSchedule from 'raf-schd';
|
|
3
4
|
import { getInlineNodeViewProducer } from '@atlaskit/editor-common/react-node-view';
|
|
4
5
|
import { BlockCard } from '../nodeviews/blockCard';
|
|
@@ -9,7 +10,9 @@ import reducer from './reducers';
|
|
|
9
10
|
import { handleProvider, resolveWithProvider } from './util/resolve';
|
|
10
11
|
import { getNewRequests, getPluginState, getPluginStateWithUpdatedPos } from './util/state';
|
|
11
12
|
import { createAnalyticsQueue, eventsFromTransaction } from './analytics';
|
|
12
|
-
import { Datasource } from '../nodeviews/datasource';
|
|
13
|
+
import { DATASOURCE_INNER_CONTAINER_CLASSNAME, Datasource } from '../nodeviews/datasource';
|
|
14
|
+
import { setDatasourceTableRef, setCardLayoutAndDatasourceTableRef } from './actions';
|
|
15
|
+
import { findDomRefAtPos } from 'prosemirror-utils';
|
|
13
16
|
export { pluginKey } from './plugin-key';
|
|
14
17
|
export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryParams => {
|
|
15
18
|
const {
|
|
@@ -36,7 +39,9 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
36
39
|
smartLinkEvents: undefined,
|
|
37
40
|
smartLinkEventsNext: undefined,
|
|
38
41
|
createAnalyticsEvent,
|
|
39
|
-
editorAppearance
|
|
42
|
+
editorAppearance,
|
|
43
|
+
datasourceTableRef: undefined,
|
|
44
|
+
layout: undefined
|
|
40
45
|
};
|
|
41
46
|
},
|
|
42
47
|
apply(tr, pluginState, prevEditorState) {
|
|
@@ -60,12 +65,48 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
60
65
|
},
|
|
61
66
|
view(view) {
|
|
62
67
|
const subscriptionHandler = (name, provider) => handleProvider(name, provider, view);
|
|
68
|
+
const domAtPos = view.domAtPos.bind(view);
|
|
63
69
|
const rafCancellationCallbacks = [];
|
|
64
70
|
pmPluginFactoryParams.providerFactory.subscribe('cardProvider', subscriptionHandler);
|
|
65
71
|
return {
|
|
66
72
|
update(view, prevState) {
|
|
73
|
+
var _selection$node;
|
|
67
74
|
const currentState = getPluginState(view.state);
|
|
68
75
|
const oldState = getPluginState(prevState);
|
|
76
|
+
const {
|
|
77
|
+
state,
|
|
78
|
+
dispatch
|
|
79
|
+
} = view;
|
|
80
|
+
const {
|
|
81
|
+
selection,
|
|
82
|
+
tr,
|
|
83
|
+
schema
|
|
84
|
+
} = state;
|
|
85
|
+
const isBlockCardSelected = selection instanceof NodeSelection && ((_selection$node = selection.node) === null || _selection$node === void 0 ? void 0 : _selection$node.type) === schema.nodes.blockCard;
|
|
86
|
+
if (isBlockCardSelected) {
|
|
87
|
+
var _findDomRefAtPos, _node$attrs;
|
|
88
|
+
const datasourceTableRef = (_findDomRefAtPos = findDomRefAtPos(selection.from, domAtPos)) === null || _findDomRefAtPos === void 0 ? void 0 : _findDomRefAtPos.querySelector(`.${DATASOURCE_INNER_CONTAINER_CLASSNAME}`);
|
|
89
|
+
const {
|
|
90
|
+
node
|
|
91
|
+
} = selection;
|
|
92
|
+
const isDatasource = !!(node !== null && node !== void 0 && (_node$attrs = node.attrs) !== null && _node$attrs !== void 0 && _node$attrs.datasource);
|
|
93
|
+
const shouldUpdateTableRef = datasourceTableRef && (currentState === null || currentState === void 0 ? void 0 : currentState.datasourceTableRef) !== datasourceTableRef;
|
|
94
|
+
if (isDatasource && shouldUpdateTableRef) {
|
|
95
|
+
var _node$attrs2;
|
|
96
|
+
// since we use the plugin state, which is a shared state, we need to update the datasourceTableRef, layout on each selection
|
|
97
|
+
const layout = (node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.layout) || 'center';
|
|
98
|
+
|
|
99
|
+
// we use cardAction to set the same meta, hence, we will need to combine both layout+datasourceTableRef in one transaction
|
|
100
|
+
dispatch(setCardLayoutAndDatasourceTableRef({
|
|
101
|
+
datasourceTableRef,
|
|
102
|
+
layout
|
|
103
|
+
})(tr));
|
|
104
|
+
}
|
|
105
|
+
} else {
|
|
106
|
+
if (currentState !== null && currentState !== void 0 && currentState.datasourceTableRef) {
|
|
107
|
+
dispatch(setDatasourceTableRef(undefined)(tr));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
69
110
|
if (currentState && currentState.provider) {
|
|
70
111
|
// Find requests in this state that weren't in the old one.
|
|
71
112
|
const newRequests = getNewRequests(oldState, currentState);
|
|
@@ -111,6 +152,7 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
111
152
|
}
|
|
112
153
|
}),
|
|
113
154
|
blockCard: (node, view, getPos) => {
|
|
155
|
+
var _node$attrs3;
|
|
114
156
|
const {
|
|
115
157
|
portalProviderAPI,
|
|
116
158
|
eventDispatcher
|
|
@@ -120,8 +162,17 @@ export const createPlugin = (options, pluginInjectionApi) => pmPluginFactoryPara
|
|
|
120
162
|
showServerActions
|
|
121
163
|
};
|
|
122
164
|
const hasIntlContext = true;
|
|
123
|
-
|
|
124
|
-
|
|
165
|
+
const isDatasource = !!(node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.datasource);
|
|
166
|
+
if (isDatasource) {
|
|
167
|
+
return new Datasource({
|
|
168
|
+
node,
|
|
169
|
+
view,
|
|
170
|
+
getPos,
|
|
171
|
+
portalProviderAPI,
|
|
172
|
+
eventDispatcher,
|
|
173
|
+
hasIntlContext,
|
|
174
|
+
pluginInjectionApi
|
|
175
|
+
}).init();
|
|
125
176
|
}
|
|
126
177
|
return new BlockCard(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, undefined, true, undefined, hasIntlContext).init();
|
|
127
178
|
},
|
|
@@ -28,6 +28,25 @@ const setProvider = (state, action) => {
|
|
|
28
28
|
provider: action.provider
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
|
+
const setCardLayout = (state, action) => {
|
|
32
|
+
return {
|
|
33
|
+
...state,
|
|
34
|
+
layout: action.layout
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
const setDatasourceTableRef = (state, action) => {
|
|
38
|
+
return {
|
|
39
|
+
...state,
|
|
40
|
+
datasourceTableRef: action.datasourceTableRef
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
const setCardLayoutDatasourceTableRef = (state, action) => {
|
|
44
|
+
return {
|
|
45
|
+
...state,
|
|
46
|
+
datasourceTableRef: action.datasourceTableRef,
|
|
47
|
+
layout: action.layout
|
|
48
|
+
};
|
|
49
|
+
};
|
|
31
50
|
const registerEvents = (state, action) => {
|
|
32
51
|
return {
|
|
33
52
|
...state,
|
|
@@ -60,6 +79,12 @@ export default ((state, action) => {
|
|
|
60
79
|
return registerEvents(state, action);
|
|
61
80
|
case 'REGISTER_EVENTS_NEXT':
|
|
62
81
|
return registerEventsNext(state, action);
|
|
82
|
+
case 'SET_DATASOURCE_TABLE_REF':
|
|
83
|
+
return setDatasourceTableRef(state, action);
|
|
84
|
+
case 'SET_CARD_LAYOUT':
|
|
85
|
+
return setCardLayout(state, action);
|
|
86
|
+
case 'SET_CARD_LAYOUT_AND_DATASOURCE_TABLE_REF':
|
|
87
|
+
return setCardLayoutDatasourceTableRef(state, action);
|
|
63
88
|
case 'SHOW_LINK_TOOLBAR':
|
|
64
89
|
case 'HIDE_LINK_TOOLBAR':
|
|
65
90
|
return setLinkToolbar(state, action);
|
|
@@ -67,6 +67,12 @@ export const smartCardStyles = css`
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
.${SmartCardSharedCssClassName.DATASOURCE_CONTAINER}.${SmartCardSharedCssClassName.BLOCK_CARD_CONTAINER} {
|
|
71
|
+
max-width: 100%;
|
|
72
|
+
display: flex;
|
|
73
|
+
justify-content: center;
|
|
74
|
+
}
|
|
75
|
+
|
|
70
76
|
.${SmartCardSharedCssClassName.EMBED_CARD_CONTAINER} {
|
|
71
77
|
.${SmartCardSharedCssClassName.LOADER_WRAPPER} > div {
|
|
72
78
|
cursor: pointer;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React, { useCallback, useMemo } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import { Popup } from '@atlaskit/editor-common/ui';
|
|
5
|
+
import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
6
|
+
import CollapseIcon from '@atlaskit/icon/glyph/editor/collapse';
|
|
7
|
+
import ExpandIcon from '@atlaskit/icon/glyph/editor/expand';
|
|
8
|
+
import { injectIntl } from 'react-intl-next';
|
|
9
|
+
import { toolbarButtonWrapper } from './styled';
|
|
10
|
+
import { getDatasource } from './utils';
|
|
11
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
12
|
+
import { setCardLayout } from '../../pm-plugins/actions';
|
|
13
|
+
import { getNextBreakoutMode, getTitle } from '@atlaskit/editor-common/utils';
|
|
14
|
+
export const LayoutButton = ({
|
|
15
|
+
onLayoutChange,
|
|
16
|
+
layout = 'center',
|
|
17
|
+
intl: {
|
|
18
|
+
formatMessage
|
|
19
|
+
},
|
|
20
|
+
mountPoint,
|
|
21
|
+
boundariesElement,
|
|
22
|
+
scrollableElement,
|
|
23
|
+
targetElement,
|
|
24
|
+
testId = 'datasource-table-layout-button'
|
|
25
|
+
}) => {
|
|
26
|
+
const handleClick = useCallback(() => {
|
|
27
|
+
onLayoutChange && onLayoutChange(getNextBreakoutMode(layout));
|
|
28
|
+
}, [layout, onLayoutChange]);
|
|
29
|
+
const title = useMemo(() => {
|
|
30
|
+
return formatMessage(getTitle(layout));
|
|
31
|
+
}, [formatMessage, layout]);
|
|
32
|
+
if (!targetElement) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return jsx(Popup, {
|
|
36
|
+
mountTo: mountPoint,
|
|
37
|
+
boundariesElement: boundariesElement,
|
|
38
|
+
scrollableElement: scrollableElement,
|
|
39
|
+
target: targetElement,
|
|
40
|
+
alignY: "start",
|
|
41
|
+
alignX: "end",
|
|
42
|
+
forcePlacement: true,
|
|
43
|
+
stick: true,
|
|
44
|
+
ariaLabel: title
|
|
45
|
+
}, jsx(ToolbarButton, {
|
|
46
|
+
testId: testId,
|
|
47
|
+
css: toolbarButtonWrapper,
|
|
48
|
+
title: title,
|
|
49
|
+
onClick: handleClick,
|
|
50
|
+
iconBefore: layout === 'full-width' ? jsx(CollapseIcon, {
|
|
51
|
+
label: title
|
|
52
|
+
}) : jsx(ExpandIcon, {
|
|
53
|
+
label: title
|
|
54
|
+
})
|
|
55
|
+
}));
|
|
56
|
+
};
|
|
57
|
+
const LayoutButtonWrapper = ({
|
|
58
|
+
editorView,
|
|
59
|
+
mountPoint,
|
|
60
|
+
scrollableElement,
|
|
61
|
+
boundariesElement,
|
|
62
|
+
intl,
|
|
63
|
+
api
|
|
64
|
+
}) => {
|
|
65
|
+
var _node$attrs, _node$attrs2;
|
|
66
|
+
const {
|
|
67
|
+
cardState
|
|
68
|
+
} = useSharedPluginState(api, ['card']);
|
|
69
|
+
const {
|
|
70
|
+
node,
|
|
71
|
+
pos
|
|
72
|
+
} = getDatasource(editorView);
|
|
73
|
+
const {
|
|
74
|
+
datasourceTableRef,
|
|
75
|
+
layout = (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.layout) || 'center'
|
|
76
|
+
} = cardState !== null && cardState !== void 0 ? cardState : {};
|
|
77
|
+
const isDatasource = !!(node !== null && node !== void 0 && (_node$attrs2 = node.attrs) !== null && _node$attrs2 !== void 0 && _node$attrs2.datasource);
|
|
78
|
+
const onLayoutChange = layout => {
|
|
79
|
+
if (pos === undefined) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const {
|
|
83
|
+
state,
|
|
84
|
+
dispatch
|
|
85
|
+
} = editorView;
|
|
86
|
+
const tr = state.tr.setNodeMarkup(pos, undefined, {
|
|
87
|
+
...(node === null || node === void 0 ? void 0 : node.attrs),
|
|
88
|
+
layout
|
|
89
|
+
});
|
|
90
|
+
tr.setMeta('scrollIntoView', false);
|
|
91
|
+
dispatch(setCardLayout(layout)(tr));
|
|
92
|
+
};
|
|
93
|
+
if (!isDatasource) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
return jsx(LayoutButton, {
|
|
97
|
+
mountPoint: mountPoint,
|
|
98
|
+
scrollableElement: scrollableElement,
|
|
99
|
+
boundariesElement: boundariesElement,
|
|
100
|
+
targetElement: datasourceTableRef,
|
|
101
|
+
layout: layout,
|
|
102
|
+
onLayoutChange: onLayoutChange,
|
|
103
|
+
intl: intl
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
export default injectIntl(LayoutButtonWrapper);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
import { B300, N300, N20A } from '@atlaskit/theme/colors';
|
|
3
|
+
export const toolbarButtonWrapper = css({
|
|
4
|
+
background: `${`var(--ds-background-neutral, ${N20A})`}`,
|
|
5
|
+
color: `${`var(--ds-icon, ${N300})`}`,
|
|
6
|
+
':hover': {
|
|
7
|
+
background: `${`var(--ds-background-neutral-hovered, ${B300})`}`,
|
|
8
|
+
color: `${"var(--ds-icon, white)"} !important`
|
|
9
|
+
}
|
|
10
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { findSelectedNodeOfType } from 'prosemirror-utils';
|
|
2
|
+
export const getDatasource = editorView => {
|
|
3
|
+
var _findSelectedNodeOfTy;
|
|
4
|
+
const {
|
|
5
|
+
selection,
|
|
6
|
+
schema
|
|
7
|
+
} = editorView.state;
|
|
8
|
+
const {
|
|
9
|
+
blockCard
|
|
10
|
+
} = schema.nodes;
|
|
11
|
+
return (_findSelectedNodeOfTy = findSelectedNodeOfType([blockCard])(selection)) !== null && _findSelectedNodeOfTy !== void 0 ? _findSelectedNodeOfTy : {
|
|
12
|
+
node: undefined,
|
|
13
|
+
pos: undefined
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -656,6 +656,7 @@ export class HyperlinkLinkAddToolbar extends PureComponent {
|
|
|
656
656
|
// for details: https://a11y-internal.atlassian.net/browse/AK-740
|
|
657
657
|
const screenReaderText = browser.safari && this.getScreenReaderText();
|
|
658
658
|
return jsx("div", {
|
|
659
|
+
"aria-label": "Hyperlink Edit",
|
|
659
660
|
className: "recent-list"
|
|
660
661
|
}, jsx("div", {
|
|
661
662
|
css: [container, !!activityProvider && containerWithProvider],
|
|
@@ -2,12 +2,12 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import ReactDOM from 'react-dom';
|
|
4
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
|
-
import { NodeSelection, TextSelection, AllSelection } from 'prosemirror-state';
|
|
5
|
+
import { NodeSelection, TextSelection, AllSelection, Selection } from 'prosemirror-state';
|
|
6
6
|
import { insertPoint } from 'prosemirror-transform';
|
|
7
7
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
8
8
|
import { ErrorReporter, browser } from '@atlaskit/editor-common/utils';
|
|
9
9
|
import assert from 'assert';
|
|
10
|
-
import { findDomRefAtPos, isNodeSelection } from 'prosemirror-utils';
|
|
10
|
+
import { findDomRefAtPos, isNodeSelection, findSelectedNodeOfType, findParentNodeOfType } from 'prosemirror-utils';
|
|
11
11
|
import { insertMediaSingleNode, isMediaSingle } from '../utils/media-single';
|
|
12
12
|
import DropPlaceholder from '../ui/Media/DropPlaceholder';
|
|
13
13
|
import { insertMediaGroupNode, insertMediaInlineNode, canInsertMediaInline } from '../utils/media-files';
|
|
@@ -379,8 +379,30 @@ export class MediaPluginStateImplementation {
|
|
|
379
379
|
dispatch,
|
|
380
380
|
state
|
|
381
381
|
} = this.view;
|
|
382
|
+
const {
|
|
383
|
+
tr,
|
|
384
|
+
selection,
|
|
385
|
+
doc
|
|
386
|
+
} = state;
|
|
387
|
+
const {
|
|
388
|
+
media,
|
|
389
|
+
mediaGroup
|
|
390
|
+
} = state.schema.nodes;
|
|
391
|
+
|
|
392
|
+
// Workaround for wrong upload position
|
|
393
|
+
// @see https://product-fabric.atlassian.net/browse/MEX-2457
|
|
394
|
+
// If the media node is the last selectable item in the current cursor position and it is located within a mediaGroup,
|
|
395
|
+
// we relocate the cursor to the first child of the mediaGroup.
|
|
396
|
+
const sel = Selection.findFrom(doc.resolve(selection.$from.pos - 1), -1);
|
|
397
|
+
if (sel && findSelectedNodeOfType(media)(sel)) {
|
|
398
|
+
const parent = findParentNodeOfType(mediaGroup)(sel);
|
|
399
|
+
if (parent) {
|
|
400
|
+
tr.setSelection(NodeSelection.create(tr.doc, parent.start));
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
382
404
|
// Trigger state change to be able to pick it up in the decorations handler
|
|
383
|
-
dispatch(
|
|
405
|
+
dispatch(tr);
|
|
384
406
|
});
|
|
385
407
|
this.options = options;
|
|
386
408
|
this.mediaOptions = mediaOptions;
|
package/dist/es2019/version.json
CHANGED
|
@@ -22,37 +22,14 @@ import ToolbarButton from '../../../ui/ToolbarButton';
|
|
|
22
22
|
import { getBreakoutMode } from '../utils/get-breakout-mode';
|
|
23
23
|
import { setBreakoutMode } from '../commands/set-breakout-mode';
|
|
24
24
|
import { removeBreakout } from '../commands/remove-breakout';
|
|
25
|
-
import commonMessages from '../../../messages';
|
|
26
25
|
import { BreakoutCssClassName } from '../constants';
|
|
27
26
|
import { isBreakoutMarkAllowed } from '../utils/is-breakout-mark-allowed';
|
|
28
27
|
import { getPluginState } from '../plugin-key';
|
|
29
28
|
import { NodeSelection } from 'prosemirror-state';
|
|
30
29
|
import { isSupportedNodeForBreakout } from '../utils/is-supported-node';
|
|
31
30
|
import { layers } from '@atlaskit/theme/constants';
|
|
31
|
+
import { getNextBreakoutMode, getTitle } from '@atlaskit/editor-common/utils';
|
|
32
32
|
var toolbarButtonWrapper = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n && button {\n background: ", ";\n color: ", ";\n :hover {\n background: ", ";\n color: ", " !important;\n }\n }\n"])), "var(--ds-background-neutral, ".concat(N20A, ")"), "var(--ds-icon, ".concat(N300, ")"), "var(--ds-background-neutral-hovered, ".concat(B300, ")"), "var(--ds-icon, white)");
|
|
33
|
-
var BREAKOUT_MODE = {
|
|
34
|
-
FULL_WIDTH: 'full-width',
|
|
35
|
-
CENTER: 'center',
|
|
36
|
-
WIDE: 'wide'
|
|
37
|
-
};
|
|
38
|
-
var getNextBreakoutMode = function getNextBreakoutMode(currentMode) {
|
|
39
|
-
if (currentMode === BREAKOUT_MODE.FULL_WIDTH) {
|
|
40
|
-
return BREAKOUT_MODE.CENTER;
|
|
41
|
-
} else if (currentMode === BREAKOUT_MODE.WIDE) {
|
|
42
|
-
return BREAKOUT_MODE.FULL_WIDTH;
|
|
43
|
-
}
|
|
44
|
-
return BREAKOUT_MODE.WIDE;
|
|
45
|
-
};
|
|
46
|
-
var getTitle = function getTitle(layout) {
|
|
47
|
-
switch (layout) {
|
|
48
|
-
case BREAKOUT_MODE.FULL_WIDTH:
|
|
49
|
-
return commonMessages.layoutFixedWidth;
|
|
50
|
-
case BREAKOUT_MODE.WIDE:
|
|
51
|
-
return commonMessages.layoutFullWidth;
|
|
52
|
-
default:
|
|
53
|
-
return commonMessages.layoutWide;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
33
|
function getBreakoutNodeElement(pluginState, selection, editorView) {
|
|
57
34
|
if (selection instanceof NodeSelection && isSupportedNodeForBreakout(selection.node)) {
|
|
58
35
|
return findDomRefAtPos(selection.from, editorView.domAtPos.bind(editorView));
|
|
@@ -74,7 +51,7 @@ var LayoutButton = /*#__PURE__*/function (_React$Component) {
|
|
|
74
51
|
var _this$props$editorVie = _this.props.editorView,
|
|
75
52
|
state = _this$props$editorVie.state,
|
|
76
53
|
dispatch = _this$props$editorVie.dispatch;
|
|
77
|
-
if ([
|
|
54
|
+
if (['wide', 'full-width'].indexOf(breakoutMode) !== -1) {
|
|
78
55
|
setBreakoutMode(breakoutMode)(state, dispatch);
|
|
79
56
|
} else {
|
|
80
57
|
removeBreakout()(state, dispatch);
|
|
@@ -129,7 +106,7 @@ var LayoutButton = /*#__PURE__*/function (_React$Component) {
|
|
|
129
106
|
title: title,
|
|
130
107
|
testId: titleMessage.id,
|
|
131
108
|
onClick: this.handleClick(nextBreakoutMode),
|
|
132
|
-
iconBefore: breakoutMode ===
|
|
109
|
+
iconBefore: breakoutMode === 'full-width' ? jsx(CollapseIcon, {
|
|
133
110
|
label: title
|
|
134
111
|
}) : jsx(ExpandIcon, {
|
|
135
112
|
label: title
|