@atlaskit/editor-plugin-breakout 24.0.2 → 24.0.4
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 +18 -0
- package/dist/cjs/breakoutPlugin.js +21 -229
- package/dist/cjs/pm-plugins/utils/single-player-expand.js +6 -17
- package/dist/es2019/breakoutPlugin.js +13 -211
- package/dist/es2019/pm-plugins/utils/single-player-expand.js +6 -17
- package/dist/esm/breakoutPlugin.js +21 -227
- package/dist/esm/pm-plugins/utils/single-player-expand.js +6 -17
- package/package.json +2 -2
- package/dist/cjs/editor-commands/remove-breakout.js +0 -41
- package/dist/cjs/editor-commands/set-breakout-mode.js +0 -49
- package/dist/cjs/pm-plugins/plugin-key.js +0 -11
- package/dist/cjs/pm-plugins/utils/find-breakout-node.js +0 -42
- package/dist/cjs/pm-plugins/utils/get-breakout-mode.js +0 -24
- package/dist/cjs/pm-plugins/utils/is-breakout-mark-allowed.js +0 -27
- package/dist/cjs/pm-plugins/utils/is-supported-node.js +0 -20
- package/dist/cjs/ui/LayoutButton.js +0 -176
- package/dist/es2019/editor-commands/remove-breakout.js +0 -33
- package/dist/es2019/editor-commands/set-breakout-mode.js +0 -43
- package/dist/es2019/pm-plugins/plugin-key.js +0 -3
- package/dist/es2019/pm-plugins/utils/find-breakout-node.js +0 -37
- package/dist/es2019/pm-plugins/utils/get-breakout-mode.js +0 -17
- package/dist/es2019/pm-plugins/utils/is-breakout-mark-allowed.js +0 -22
- package/dist/es2019/pm-plugins/utils/is-supported-node.js +0 -14
- package/dist/es2019/ui/LayoutButton.js +0 -171
- package/dist/esm/editor-commands/remove-breakout.js +0 -35
- package/dist/esm/editor-commands/set-breakout-mode.js +0 -43
- package/dist/esm/pm-plugins/plugin-key.js +0 -5
- package/dist/esm/pm-plugins/utils/find-breakout-node.js +0 -37
- package/dist/esm/pm-plugins/utils/get-breakout-mode.js +0 -19
- package/dist/esm/pm-plugins/utils/is-breakout-mark-allowed.js +0 -22
- package/dist/esm/pm-plugins/utils/is-supported-node.js +0 -14
- package/dist/esm/ui/LayoutButton.js +0 -166
- package/dist/types/editor-commands/remove-breakout.d.ts +0 -2
- package/dist/types/editor-commands/set-breakout-mode.d.ts +0 -2
- package/dist/types/pm-plugins/plugin-key.d.ts +0 -5
- package/dist/types/pm-plugins/utils/find-breakout-node.d.ts +0 -9
- package/dist/types/pm-plugins/utils/get-breakout-mode.d.ts +0 -7
- package/dist/types/pm-plugins/utils/is-breakout-mark-allowed.d.ts +0 -9
- package/dist/types/pm-plugins/utils/is-supported-node.d.ts +0 -6
- package/dist/types/ui/LayoutButton.d.ts +0 -20
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { findSupportedNodeForBreakout } from './find-breakout-node';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Check if breakout should be allowed for the current selection. If a node is selected,
|
|
5
|
-
* can this node be broken out, if text, can the enclosing parent node be broken out.
|
|
6
|
-
*
|
|
7
|
-
* Currently breakout of a node is not possible if it's nested in anything but the document, however
|
|
8
|
-
* this logic supports this changing.
|
|
9
|
-
*/
|
|
10
|
-
export function isBreakoutMarkAllowed(state) {
|
|
11
|
-
if (!state.schema.marks.breakout) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
var supportedNodeParent = findSupportedNodeForBreakout(state.selection);
|
|
15
|
-
if (!supportedNodeParent) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
// At the moment we can only breakout when the depth is 0, ie. doc is the only node
|
|
19
|
-
// that supports breakout. This *could* change though.
|
|
20
|
-
var parent = state.selection.$from.node(supportedNodeParent.depth);
|
|
21
|
-
return parent.type.allowsMarkType(state.schema.marks.breakout);
|
|
22
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
2
|
-
var supportedNodesForBreakout = ['codeBlock', 'layoutSection', 'expand'];
|
|
3
|
-
var supportedNodesForBreakoutAdvancedLayouts = ['codeBlock', 'expand'];
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Check if breakout can be applied to a node
|
|
7
|
-
* @param node Node to check
|
|
8
|
-
*/
|
|
9
|
-
export function isSupportedNodeForBreakout(node) {
|
|
10
|
-
if (editorExperiment('advanced_layouts', true)) {
|
|
11
|
-
return supportedNodesForBreakoutAdvancedLayouts.indexOf(node.type.name) !== -1;
|
|
12
|
-
}
|
|
13
|
-
return supportedNodesForBreakout.indexOf(node.type.name) !== -1;
|
|
14
|
-
}
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
/**
|
|
3
|
-
* @jsxRuntime classic
|
|
4
|
-
* @jsx jsx
|
|
5
|
-
*/
|
|
6
|
-
import { useCallback } from 'react';
|
|
7
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
|
-
import { css, jsx } from '@emotion/react';
|
|
9
|
-
import { injectIntl } from 'react-intl';
|
|
10
|
-
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
11
|
-
import { BreakoutCssClassName } from '@atlaskit/editor-common/styles';
|
|
12
|
-
import { Popup } from '@atlaskit/editor-common/ui';
|
|
13
|
-
import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
14
|
-
import { getNextBreakoutMode, getTitle } from '@atlaskit/editor-common/utils';
|
|
15
|
-
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
16
|
-
import { findDomRefAtPos, findParentDomRefOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
17
|
-
import { akEditorFullPageNarrowBreakout } from '@atlaskit/editor-shared-styles';
|
|
18
|
-
import GrowHorizontalIcon from '@atlaskit/icon/core/grow-horizontal';
|
|
19
|
-
import ShrinkHorizontalIcon from '@atlaskit/icon/core/shrink-horizontal';
|
|
20
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-atlaskit-theme
|
|
21
|
-
import { layers } from '@atlaskit/theme/constants';
|
|
22
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
23
|
-
import { removeBreakout } from '../editor-commands/remove-breakout';
|
|
24
|
-
import { setBreakoutMode } from '../editor-commands/set-breakout-mode';
|
|
25
|
-
import { getPluginState } from '../pm-plugins/plugin-key';
|
|
26
|
-
import { isBreakoutMarkAllowed } from '../pm-plugins/utils/is-breakout-mark-allowed';
|
|
27
|
-
import { isSupportedNodeForBreakout } from '../pm-plugins/utils/is-supported-node';
|
|
28
|
-
var toolbarButtonWrapperStyles = css({
|
|
29
|
-
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles, @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
30
|
-
'&& button': {
|
|
31
|
-
background: "var(--ds-background-neutral, #0515240F)",
|
|
32
|
-
color: "var(--ds-icon, #292A2E)",
|
|
33
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
34
|
-
':hover': {
|
|
35
|
-
background: "var(--ds-background-neutral-hovered, #0B120E24)",
|
|
36
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
|
|
37
|
-
color: "var(--ds-icon, #292A2E)".concat(" !important")
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
var toolbarButtonNarrowScreenStyles = css(_defineProperty({}, "@container editor-area (max-width: ".concat(akEditorFullPageNarrowBreakout, "px)"), {
|
|
42
|
-
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles, @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
43
|
-
'&& button': {
|
|
44
|
-
visibility: 'hidden',
|
|
45
|
-
opacity: 0
|
|
46
|
-
}
|
|
47
|
-
}));
|
|
48
|
-
function getBreakoutNodeElement(pluginState, selection, editorView) {
|
|
49
|
-
if (!pluginState.breakoutNode) {
|
|
50
|
-
return undefined;
|
|
51
|
-
}
|
|
52
|
-
if (selection instanceof NodeSelection && isSupportedNodeForBreakout(selection.node)) {
|
|
53
|
-
// Ignored via go/ees005
|
|
54
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
55
|
-
return findDomRefAtPos(selection.from, editorView.domAtPos.bind(editorView));
|
|
56
|
-
}
|
|
57
|
-
// Ignored via go/ees005
|
|
58
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
59
|
-
return findParentDomRefOfType(pluginState.breakoutNode.node.type, editorView.domAtPos.bind(editorView))(selection);
|
|
60
|
-
}
|
|
61
|
-
var LayoutButton = function LayoutButton(_ref) {
|
|
62
|
-
var _api$analytics3;
|
|
63
|
-
var formatMessage = _ref.intl.formatMessage,
|
|
64
|
-
mountPoint = _ref.mountPoint,
|
|
65
|
-
boundariesElement = _ref.boundariesElement,
|
|
66
|
-
scrollableElement = _ref.scrollableElement,
|
|
67
|
-
editorView = _ref.editorView,
|
|
68
|
-
isLivePage = _ref.isLivePage,
|
|
69
|
-
isBreakoutNodePresent = _ref.isBreakoutNodePresent,
|
|
70
|
-
breakoutModeProp = _ref.breakoutMode,
|
|
71
|
-
api = _ref.api;
|
|
72
|
-
var handleClick = useCallback(function (breakoutMode) {
|
|
73
|
-
var _getPluginState;
|
|
74
|
-
if (!editorView) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
var state = editorView.state,
|
|
78
|
-
dispatch = editorView.dispatch;
|
|
79
|
-
var breakoutNode = (_getPluginState = getPluginState(state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.breakoutNode;
|
|
80
|
-
if (['wide', 'full-width'].indexOf(breakoutMode) !== -1) {
|
|
81
|
-
var _api$analytics;
|
|
82
|
-
setBreakoutMode(breakoutMode, isLivePage)(state, dispatch);
|
|
83
|
-
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
|
|
84
|
-
action: ACTION.CHANGED_BREAKOUT_MODE,
|
|
85
|
-
actionSubject: ACTION_SUBJECT.ELEMENT,
|
|
86
|
-
eventType: EVENT_TYPE.TRACK,
|
|
87
|
-
attributes: {
|
|
88
|
-
mode: breakoutMode,
|
|
89
|
-
nodeType: breakoutNode === null || breakoutNode === void 0 ? void 0 : breakoutNode.node.type.name
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
} else {
|
|
93
|
-
var _api$analytics2;
|
|
94
|
-
removeBreakout(isLivePage)(state, dispatch);
|
|
95
|
-
api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.fireAnalyticsEvent({
|
|
96
|
-
action: ACTION.CHANGED_BREAKOUT_MODE,
|
|
97
|
-
actionSubject: ACTION_SUBJECT.ELEMENT,
|
|
98
|
-
eventType: EVENT_TYPE.TRACK,
|
|
99
|
-
attributes: {
|
|
100
|
-
mode: 'center',
|
|
101
|
-
nodeType: breakoutNode === null || breakoutNode === void 0 ? void 0 : breakoutNode.node.type.name
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}, [api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, editorView, isLivePage]);
|
|
106
|
-
if (!editorView) {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
if (!isBreakoutNodePresent || !isBreakoutMarkAllowed(editorView.state)) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
var breakoutMode = breakoutModeProp;
|
|
113
|
-
var titleMessage = getTitle(breakoutMode);
|
|
114
|
-
var title = formatMessage(titleMessage);
|
|
115
|
-
var nextBreakoutMode = getNextBreakoutMode(breakoutMode);
|
|
116
|
-
var belowOtherPopupsZIndex = layers.layer() - 1;
|
|
117
|
-
var pluginState = getPluginState(editorView.state);
|
|
118
|
-
if (!pluginState) {
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
var element = getBreakoutNodeElement(pluginState, editorView.state.selection, editorView);
|
|
122
|
-
if (!element) {
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
var closestEl = element.querySelector(".".concat(BreakoutCssClassName.BREAKOUT_MARK_DOM));
|
|
126
|
-
if (closestEl && closestEl.firstChild) {
|
|
127
|
-
// Ignored via go/ees005
|
|
128
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
129
|
-
element = closestEl.firstChild;
|
|
130
|
-
}
|
|
131
|
-
return jsx(Popup, {
|
|
132
|
-
ariaLabel: title,
|
|
133
|
-
target: element
|
|
134
|
-
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
135
|
-
,
|
|
136
|
-
offset: [5, 0],
|
|
137
|
-
alignY: "start",
|
|
138
|
-
alignX: "end",
|
|
139
|
-
mountTo: mountPoint,
|
|
140
|
-
boundariesElement: boundariesElement,
|
|
141
|
-
scrollableElement: scrollableElement,
|
|
142
|
-
stick: true,
|
|
143
|
-
forcePlacement: true,
|
|
144
|
-
zIndex: belowOtherPopupsZIndex
|
|
145
|
-
}, jsx("div", {
|
|
146
|
-
css: [toolbarButtonWrapperStyles, editorExperiment('platform_editor_preview_panel_responsiveness', true) && toolbarButtonNarrowScreenStyles]
|
|
147
|
-
}, jsx(ToolbarButton, {
|
|
148
|
-
title: title,
|
|
149
|
-
testId: titleMessage.id
|
|
150
|
-
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
151
|
-
,
|
|
152
|
-
onClick: function onClick() {
|
|
153
|
-
return handleClick(nextBreakoutMode);
|
|
154
|
-
},
|
|
155
|
-
iconBefore: breakoutMode === 'full-width' ? jsx(ShrinkHorizontalIcon, {
|
|
156
|
-
label: title,
|
|
157
|
-
spacing: "spacious"
|
|
158
|
-
}) : jsx(GrowHorizontalIcon, {
|
|
159
|
-
label: title,
|
|
160
|
-
spacing: "spacious"
|
|
161
|
-
})
|
|
162
|
-
})));
|
|
163
|
-
};
|
|
164
|
-
LayoutButton.displayName = 'LayoutButton';
|
|
165
|
-
var _default_1 = injectIntl(LayoutButton);
|
|
166
|
-
export default _default_1;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type { BreakoutPluginState } from '../breakoutPluginType';
|
|
4
|
-
export declare const pluginKey: PluginKey<BreakoutPluginState>;
|
|
5
|
-
export declare const getPluginState: (state: EditorState) => BreakoutPluginState | undefined;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
-
/**
|
|
4
|
-
* Find the nearest parent node to the selection that supports breakout, or if the nearest
|
|
5
|
-
* matching parent node is the doc, return undefined.
|
|
6
|
-
* For depth, if a node is selected and supports breakout, return the depth of the node.
|
|
7
|
-
* @param selection Current editor selection
|
|
8
|
-
*/
|
|
9
|
-
export declare function findSupportedNodeForBreakout(selection: Selection): ContentNodeWithPos | undefined;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { BreakoutMode } from '@atlaskit/editor-common/types';
|
|
2
|
-
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
/**
|
|
4
|
-
* Get the current mode of the breakout at the selection
|
|
5
|
-
* @param state Current EditorState
|
|
6
|
-
*/
|
|
7
|
-
export declare function getBreakoutMode(state: EditorState): BreakoutMode | undefined;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
/**
|
|
3
|
-
* Check if breakout should be allowed for the current selection. If a node is selected,
|
|
4
|
-
* can this node be broken out, if text, can the enclosing parent node be broken out.
|
|
5
|
-
*
|
|
6
|
-
* Currently breakout of a node is not possible if it's nested in anything but the document, however
|
|
7
|
-
* this logic supports this changing.
|
|
8
|
-
*/
|
|
9
|
-
export declare function isBreakoutMarkAllowed(state: EditorState): boolean;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { ComponentType, FC } from 'react';
|
|
2
|
-
import type { WithIntlProps, WrappedComponentProps } from 'react-intl';
|
|
3
|
-
import type { BreakoutMode, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
-
import type { BreakoutPlugin } from '../breakoutPluginType';
|
|
6
|
-
export interface Props {
|
|
7
|
-
api: ExtractInjectionAPI<BreakoutPlugin> | undefined;
|
|
8
|
-
boundariesElement?: HTMLElement;
|
|
9
|
-
breakoutMode: BreakoutMode | undefined;
|
|
10
|
-
editorView: EditorView | undefined;
|
|
11
|
-
handleClick?: Function;
|
|
12
|
-
isBreakoutNodePresent: boolean;
|
|
13
|
-
isLivePage?: boolean;
|
|
14
|
-
mountPoint?: HTMLElement;
|
|
15
|
-
scrollableElement?: HTMLElement;
|
|
16
|
-
}
|
|
17
|
-
declare const _default_1: FC<WithIntlProps<Props & WrappedComponentProps>> & {
|
|
18
|
-
WrappedComponent: ComponentType<Props & WrappedComponentProps>;
|
|
19
|
-
};
|
|
20
|
-
export default _default_1;
|