@atlaskit/editor-common 75.5.1 → 75.6.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 +13 -0
- package/dist/cjs/analytics/fire-analytics-event.js +2 -1
- package/dist/cjs/analytics/index.js +6 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/styles/shared/shadow.js +2 -1
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/ui-menu/ColorPickerButton/index.js +204 -0
- package/dist/cjs/ui-menu/DropdownContainer/index.js +33 -0
- package/dist/cjs/ui-menu/index.js +14 -0
- package/dist/cjs/utils/index.js +29 -2
- package/dist/cjs/utils/nodes.js +13 -2
- package/dist/es2019/analytics/fire-analytics-event.js +1 -1
- package/dist/es2019/analytics/index.js +1 -1
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/styles/shared/shadow.js +5 -2
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/ui-menu/ColorPickerButton/index.js +212 -0
- package/dist/es2019/ui-menu/DropdownContainer/index.js +21 -0
- package/dist/es2019/ui-menu/index.js +3 -1
- package/dist/es2019/utils/index.js +21 -2
- package/dist/es2019/utils/nodes.js +9 -1
- package/dist/esm/analytics/fire-analytics-event.js +1 -1
- package/dist/esm/analytics/index.js +1 -1
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/styles/shared/shadow.js +2 -1
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/ui-menu/ColorPickerButton/index.js +197 -0
- package/dist/esm/ui-menu/DropdownContainer/index.js +23 -0
- package/dist/esm/ui-menu/index.js +3 -1
- package/dist/esm/utils/index.js +18 -2
- package/dist/esm/utils/nodes.js +9 -1
- package/dist/types/analytics/fire-analytics-event.d.ts +2 -0
- package/dist/types/analytics/index.d.ts +1 -1
- package/dist/types/ui/DropList/index.d.ts +1 -1
- package/dist/types/ui/index.d.ts +1 -0
- package/dist/types/ui-menu/ColorPickerButton/index.d.ts +28 -0
- package/dist/types/ui-menu/DropdownContainer/index.d.ts +3 -0
- package/dist/types/ui-menu/ToolbarButton/index.d.ts +1 -1
- package/dist/types/ui-menu/index.d.ts +2 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/nodes.d.ts +3 -0
- package/dist/types-ts4.5/analytics/fire-analytics-event.d.ts +2 -0
- package/dist/types-ts4.5/analytics/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/DropList/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/index.d.ts +1 -0
- package/dist/types-ts4.5/ui-menu/ColorPickerButton/index.d.ts +28 -0
- package/dist/types-ts4.5/ui-menu/DropdownContainer/index.d.ts +3 -0
- package/dist/types-ts4.5/ui-menu/ToolbarButton/index.d.ts +1 -1
- package/dist/types-ts4.5/ui-menu/index.d.ts +2 -0
- package/dist/types-ts4.5/utils/index.d.ts +2 -0
- package/dist/types-ts4.5/utils/nodes.d.ts +3 -0
- package/package.json +8 -5
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { css, jsx } from '@emotion/react';
|
|
4
|
+
import { withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
5
|
+
import Button from '@atlaskit/button';
|
|
6
|
+
import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
7
|
+
import { DN50, N0, N30A, N60A } from '@atlaskit/theme/colors';
|
|
8
|
+
import { themed } from '@atlaskit/theme/components';
|
|
9
|
+
import { borderRadius } from '@atlaskit/theme/constants';
|
|
10
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
11
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, editorAnalyticsChannel, EVENT_TYPE } from '../../analytics';
|
|
12
|
+
import { ColorPalette, DEFAULT_BORDER_COLOR, getSelectedRowAndColumnFromPalette } from '../../ui-color';
|
|
13
|
+
import { default as Popup } from '../../ui/Popup';
|
|
14
|
+
import { default as withOuterListeners } from '../../ui/with-outer-listeners';
|
|
15
|
+
import { ArrowKeyNavigationProvider } from '../ArrowKeyNavigationProvider';
|
|
16
|
+
import { ArrowKeyNavigationType } from '../ArrowKeyNavigationProvider/types';
|
|
17
|
+
|
|
18
|
+
// helps adjusts position of popup
|
|
19
|
+
const colorPickerButtonWrapper = css`
|
|
20
|
+
position: relative;
|
|
21
|
+
`;
|
|
22
|
+
const colorPickerExpandContainer = css`
|
|
23
|
+
margin: 0px ${"var(--ds-space-negative-050, -4px)"};
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
// Control the size of color picker buttons and preview
|
|
27
|
+
// TODO: https://product-fabric.atlassian.net/browse/DSP-4134
|
|
28
|
+
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
29
|
+
const colorPickerWrapper = theme => css`
|
|
30
|
+
border-radius: ${borderRadius()}px;
|
|
31
|
+
background-color: ${themed({
|
|
32
|
+
light: `var(--ds-surface-overlay, ${N0})`,
|
|
33
|
+
dark: `var(--ds-surface-overlay, ${DN50})`
|
|
34
|
+
})(theme)};
|
|
35
|
+
box-shadow: 0 4px 8px -2px ${N60A}, 0 0 1px ${N60A};
|
|
36
|
+
padding: ${"var(--ds-space-100, 8px)"} 0px;
|
|
37
|
+
`;
|
|
38
|
+
/* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
|
|
39
|
+
|
|
40
|
+
const ColorPaletteWithListeners = withOuterListeners(ColorPalette);
|
|
41
|
+
const ColorPickerButton = props => {
|
|
42
|
+
const buttonRef = React.useRef(null);
|
|
43
|
+
const [isPopupOpen, setIsPopupOpen] = React.useState(false);
|
|
44
|
+
const [isPopupPositioned, setIsPopupPositioned] = React.useState(false);
|
|
45
|
+
const [isOpenedByKeyboard, setIsOpenedByKeyboard] = React.useState(false);
|
|
46
|
+
const togglePopup = () => {
|
|
47
|
+
setIsPopupOpen(!isPopupOpen);
|
|
48
|
+
if (!isPopupOpen) {
|
|
49
|
+
setIsOpenedByKeyboard(false);
|
|
50
|
+
setIsPopupPositioned(false);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
React.useEffect(() => {
|
|
54
|
+
if (props.setDisableParentScroll) {
|
|
55
|
+
props.setDisableParentScroll(isPopupOpen);
|
|
56
|
+
}
|
|
57
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
58
|
+
}, [isPopupOpen]);
|
|
59
|
+
const focusButton = () => {
|
|
60
|
+
var _buttonRef$current;
|
|
61
|
+
(_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.focus();
|
|
62
|
+
};
|
|
63
|
+
const handleEsc = React.useCallback(() => {
|
|
64
|
+
setIsOpenedByKeyboard(false);
|
|
65
|
+
setIsPopupPositioned(false);
|
|
66
|
+
setIsPopupOpen(false);
|
|
67
|
+
focusButton();
|
|
68
|
+
}, []);
|
|
69
|
+
const onPositionCalculated = React.useCallback(position => {
|
|
70
|
+
setIsPopupPositioned(true);
|
|
71
|
+
return position;
|
|
72
|
+
}, []);
|
|
73
|
+
const {
|
|
74
|
+
onChange,
|
|
75
|
+
createAnalyticsEvent,
|
|
76
|
+
colorPalette,
|
|
77
|
+
placement,
|
|
78
|
+
skipFocusButtonAfterPick
|
|
79
|
+
} = props;
|
|
80
|
+
const onColorSelected = React.useCallback((color, label) => {
|
|
81
|
+
setIsOpenedByKeyboard(false);
|
|
82
|
+
setIsPopupOpen(false);
|
|
83
|
+
setIsPopupPositioned(false);
|
|
84
|
+
if (onChange) {
|
|
85
|
+
if (createAnalyticsEvent) {
|
|
86
|
+
// fire analytics
|
|
87
|
+
const payload = {
|
|
88
|
+
action: ACTION.UPDATED,
|
|
89
|
+
actionSubject: ACTION_SUBJECT.PICKER,
|
|
90
|
+
actionSubjectId: ACTION_SUBJECT_ID.PICKER_COLOR,
|
|
91
|
+
attributes: {
|
|
92
|
+
color,
|
|
93
|
+
label,
|
|
94
|
+
placement: placement
|
|
95
|
+
},
|
|
96
|
+
eventType: EVENT_TYPE.TRACK
|
|
97
|
+
};
|
|
98
|
+
createAnalyticsEvent(payload).fire(editorAnalyticsChannel);
|
|
99
|
+
}
|
|
100
|
+
const newPalette = colorPalette.find(colorPalette => colorPalette.value === color);
|
|
101
|
+
newPalette && onChange(newPalette);
|
|
102
|
+
}
|
|
103
|
+
if (!skipFocusButtonAfterPick) {
|
|
104
|
+
focusButton();
|
|
105
|
+
}
|
|
106
|
+
}, [colorPalette, onChange, createAnalyticsEvent, placement, skipFocusButtonAfterPick]);
|
|
107
|
+
const renderPopup = () => {
|
|
108
|
+
if (!isPopupOpen || !buttonRef.current) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const selectedColor = props.currentColor || null;
|
|
112
|
+
const {
|
|
113
|
+
selectedRowIndex,
|
|
114
|
+
selectedColumnIndex
|
|
115
|
+
} = getSelectedRowAndColumnFromPalette(props.colorPalette, selectedColor, props.cols);
|
|
116
|
+
return jsx(Popup, {
|
|
117
|
+
target: buttonRef.current,
|
|
118
|
+
fitHeight: 350,
|
|
119
|
+
fitWidth: 350,
|
|
120
|
+
offset: [0, 10],
|
|
121
|
+
alignX: props.alignX,
|
|
122
|
+
mountTo: props.setDisableParentScroll ? props.mountPoint : undefined
|
|
123
|
+
// Confluence inline comment editor has z-index: 500
|
|
124
|
+
// if the toolbar is scrollable, this will be mounted in the root editor
|
|
125
|
+
// we need an index of > 500 to display over it
|
|
126
|
+
,
|
|
127
|
+
zIndex: props.setDisableParentScroll ? 600 : undefined,
|
|
128
|
+
ariaLabel: "Color picker popup",
|
|
129
|
+
onPositionCalculated: onPositionCalculated
|
|
130
|
+
}, jsx("div", {
|
|
131
|
+
css: colorPickerWrapper,
|
|
132
|
+
"data-test-id": "color-picker-menu"
|
|
133
|
+
}, jsx(ArrowKeyNavigationProvider, {
|
|
134
|
+
type: ArrowKeyNavigationType.COLOR,
|
|
135
|
+
selectedRowIndex: selectedRowIndex,
|
|
136
|
+
selectedColumnIndex: selectedColumnIndex,
|
|
137
|
+
closeOnTab: true,
|
|
138
|
+
handleClose: () => setIsPopupOpen(false),
|
|
139
|
+
isOpenedByKeyboard: isOpenedByKeyboard,
|
|
140
|
+
isPopupPositioned: isPopupPositioned
|
|
141
|
+
}, jsx(ColorPaletteWithListeners, {
|
|
142
|
+
cols: props.cols,
|
|
143
|
+
selectedColor: selectedColor,
|
|
144
|
+
onClick: onColorSelected,
|
|
145
|
+
handleClickOutside: togglePopup,
|
|
146
|
+
handleEscapeKeydown: handleEsc,
|
|
147
|
+
paletteOptions: {
|
|
148
|
+
palette: props.colorPalette,
|
|
149
|
+
hexToPaletteColor: props.hexToPaletteColor,
|
|
150
|
+
paletteColorTooltipMessages: props.paletteColorTooltipMessages
|
|
151
|
+
}
|
|
152
|
+
}))));
|
|
153
|
+
};
|
|
154
|
+
const title = props.title || '';
|
|
155
|
+
const currentColor = props.currentColor && props.hexToPaletteColor ? props.hexToPaletteColor(props.currentColor) : props.currentColor;
|
|
156
|
+
const buttonStyle = theme => {
|
|
157
|
+
var _props$size, _props$size2, _props$size3;
|
|
158
|
+
return css`
|
|
159
|
+
padding: 0 10px;
|
|
160
|
+
background-color: ${"var(--ds-background-neutral-subtle, transparent)"};
|
|
161
|
+
${
|
|
162
|
+
/* If custom props size height, override the button base height property */!!((_props$size = props.size) !== null && _props$size !== void 0 && _props$size.height) && `height: inherit;`}
|
|
163
|
+
&:before {
|
|
164
|
+
display: flex;
|
|
165
|
+
justify-content: center;
|
|
166
|
+
align-items: center;
|
|
167
|
+
align-self: center;
|
|
168
|
+
content: '';
|
|
169
|
+
border: 1px solid ${DEFAULT_BORDER_COLOR};
|
|
170
|
+
border-radius: ${borderRadius()}px;
|
|
171
|
+
background-color: ${currentColor || 'transparent'};
|
|
172
|
+
width: ${((_props$size2 = props.size) === null || _props$size2 === void 0 ? void 0 : _props$size2.width) || '14px'};
|
|
173
|
+
height: ${((_props$size3 = props.size) === null || _props$size3 === void 0 ? void 0 : _props$size3.height) || '14px'};
|
|
174
|
+
padding: 0;
|
|
175
|
+
margin: 0px ${"var(--ds-space-025, 2px)"};
|
|
176
|
+
}
|
|
177
|
+
&:hover {
|
|
178
|
+
background: ${themed({
|
|
179
|
+
light: `var(--ds-background-neutral-subtle-hovered, ${N30A})`,
|
|
180
|
+
dark: `var(--ds-background-neutral-subtle-hovered, ${N30A})`
|
|
181
|
+
})(theme)};
|
|
182
|
+
}
|
|
183
|
+
`;
|
|
184
|
+
};
|
|
185
|
+
return jsx("div", {
|
|
186
|
+
css: colorPickerButtonWrapper
|
|
187
|
+
}, jsx(Tooltip, {
|
|
188
|
+
content: title,
|
|
189
|
+
position: "top"
|
|
190
|
+
}, jsx(Button, {
|
|
191
|
+
ref: buttonRef,
|
|
192
|
+
"aria-label": title,
|
|
193
|
+
spacing: "compact",
|
|
194
|
+
onClick: togglePopup,
|
|
195
|
+
onKeyDown: event => {
|
|
196
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
197
|
+
event.preventDefault();
|
|
198
|
+
togglePopup();
|
|
199
|
+
setIsOpenedByKeyboard(true);
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
css: buttonStyle,
|
|
203
|
+
iconAfter: jsx("span", {
|
|
204
|
+
css: colorPickerExpandContainer
|
|
205
|
+
}, jsx(ExpandIcon, {
|
|
206
|
+
label: ""
|
|
207
|
+
}))
|
|
208
|
+
})), renderPopup());
|
|
209
|
+
};
|
|
210
|
+
export default withAnalyticsContext({
|
|
211
|
+
source: 'ConfigPanel'
|
|
212
|
+
})(withAnalyticsEvents()(ColorPickerButton));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import React, { useContext } from 'react';
|
|
4
|
+
import { jsx } from '@emotion/react';
|
|
5
|
+
import DropdownComponent from '../Dropdown';
|
|
6
|
+
import { KeyDownHandlerContext } from '../ToolbarArrowKeyNavigationProvider';
|
|
7
|
+
export const DropdownContainer = /*#__PURE__*/React.memo(({
|
|
8
|
+
...props
|
|
9
|
+
}) => {
|
|
10
|
+
const keyDownHandlerContext = useContext(KeyDownHandlerContext);
|
|
11
|
+
return (
|
|
12
|
+
//This context is to handle the tab, Arrow Right/Left key events for dropdown.
|
|
13
|
+
//Default context has the void callbacks for above key events
|
|
14
|
+
jsx(DropdownComponent, _extends({
|
|
15
|
+
arrowKeyNavigationProviderOptions: {
|
|
16
|
+
...props.arrowKeyNavigationProviderOptions,
|
|
17
|
+
keyDownHandlerContext
|
|
18
|
+
}
|
|
19
|
+
}, props))
|
|
20
|
+
);
|
|
21
|
+
});
|
|
@@ -4,4 +4,6 @@ export { ArrowKeyNavigationProvider } from './ArrowKeyNavigationProvider';
|
|
|
4
4
|
export { ToolbarArrowKeyNavigationProvider, KeyDownHandlerContext } from './ToolbarArrowKeyNavigationProvider';
|
|
5
5
|
export { ArrowKeyNavigationType } from './ArrowKeyNavigationProvider/types';
|
|
6
6
|
export { ColorPaletteArrowKeyNavigationProvider } from './ArrowKeyNavigationProvider/ColorPaletteArrowKeyNavigationProvider';
|
|
7
|
-
export { default as Dropdown } from './Dropdown';
|
|
7
|
+
export { default as Dropdown } from './Dropdown';
|
|
8
|
+
export { default as ColorPickerButton } from './ColorPickerButton';
|
|
9
|
+
export { DropdownContainer } from './DropdownContainer';
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
2
|
+
import { hasDocAsParent } from './document';
|
|
3
|
+
import { isEmptyParagraph } from './editor-core-utils';
|
|
2
4
|
export { canApplyAnnotationOnRange, getAnnotationIdsFromRange } from './annotation';
|
|
3
5
|
export { getExtensionLozengeData } from './macro';
|
|
4
6
|
export { default as browser } from './browser';
|
|
5
7
|
export { default as ErrorReporter } from './error-reporter';
|
|
6
8
|
export { isPastDate, timestampToIsoFormat, timestampToString, timestampToTaskContext, timestampToUTCDate, todayTimestampInUTC } from './date';
|
|
7
9
|
export { isElementInTableCell, isTextSelection, isLastItemMediaGroup, setNodeSelection, setTextSelection, nonNullable, stepAddsOneOf, stepHasSlice, extractSliceFromStep, isValidPosition, isEmptyParagraph, isInLayoutColumn, removeBlockMarks, filterChildrenBetween } from './editor-core-utils';
|
|
8
|
-
import { isEmptyParagraph } from './editor-core-utils';
|
|
9
10
|
export { withImageLoader } from './imageLoader';
|
|
10
11
|
export { absoluteBreakoutWidth, calcBreakoutWidth, calcWideWidth, breakoutConsts, calculateBreakoutStyles, calcBreakoutWidthPx, getNextBreakoutMode, getTitle } from './breakout';
|
|
11
12
|
export { findChangedNodesFromTransaction, validNode, validateNodes, isType, isParagraph, isText, isLinkMark, SelectedState, isNodeSelectedOrInRange, isSupportedInParent, isMediaNode, isNodeBeforeMediaNode } from './nodes';
|
|
@@ -193,6 +194,24 @@ export function isNodeEmpty(node) {
|
|
|
193
194
|
});
|
|
194
195
|
return !nonBlock.length && !block.filter(childNode => !!childNode.childCount && !(childNode.childCount === 1 && isEmptyParagraph(childNode.firstChild)) || childNode.isAtom).length;
|
|
195
196
|
}
|
|
197
|
+
export function isInEmptyLine(state) {
|
|
198
|
+
const {
|
|
199
|
+
selection
|
|
200
|
+
} = state;
|
|
201
|
+
const {
|
|
202
|
+
$cursor,
|
|
203
|
+
$anchor
|
|
204
|
+
} = selection;
|
|
205
|
+
if (!$cursor) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
const node = $cursor.node();
|
|
209
|
+
if (!node) {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
return isEmptyParagraph(node) && hasDocAsParent($anchor);
|
|
213
|
+
}
|
|
196
214
|
export { dedupe } from './dedupe';
|
|
197
215
|
export { createWrapSelectionTransaction } from './create-wrap-selection-transaction';
|
|
198
|
-
export { wrapSelectionIn } from './wrap-selection-in';
|
|
216
|
+
export { wrapSelectionIn } from './wrap-selection-in';
|
|
217
|
+
export { toJSON, nodeToJSON } from './nodes';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { JSONTransformer } from '@atlaskit/editor-json-transformer';
|
|
1
2
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
2
3
|
/**
|
|
3
4
|
* Finds all top level nodes affected by the transaction
|
|
@@ -114,4 +115,11 @@ export const isNodeBeforeMediaNode = ($pos, state) => {
|
|
|
114
115
|
return ['media', 'mediaInline', 'mediaGroup', 'mediaSingle'].includes(nodeBefore.type.name);
|
|
115
116
|
}
|
|
116
117
|
return false;
|
|
117
|
-
};
|
|
118
|
+
};
|
|
119
|
+
const transformer = new JSONTransformer();
|
|
120
|
+
export function toJSON(node) {
|
|
121
|
+
return transformer.encode(node);
|
|
122
|
+
}
|
|
123
|
+
export function nodeToJSON(node) {
|
|
124
|
+
return transformer.encodeNode(node);
|
|
125
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FabricChannel } from '@atlaskit/analytics-listeners';
|
|
2
2
|
import { AnalyticsQueue } from './analytics-queue';
|
|
3
|
-
var editorAnalyticsChannel = FabricChannel.editor;
|
|
3
|
+
export var editorAnalyticsChannel = FabricChannel.editor;
|
|
4
4
|
export var fireAnalyticsEvent = function fireAnalyticsEvent(createAnalyticsEvent) {
|
|
5
5
|
return function (_ref) {
|
|
6
6
|
var payload = _ref.payload,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, BROWSER_FREEZE_INTERACTION_TYPE, CONTENT_COMPONENT, DELETE_DIRECTION, EVENT_TYPE, FLOATING_CONTROLS_TITLE, FULL_WIDTH_MODE, GAP_CURSOR_POSITION, INDENT_DIRECTION, INDENT_TYPE, INPUT_METHOD, LAYOUT_TYPE, LINK_REPRESENTATION, LINK_RESOURCE, LINK_STATUS, LIST_TEXT_SCENARIOS, JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST, OUTDENT_SCENARIOS, MODE, PLATFORMS, PUNC, PasteContents, PasteSources, PasteTypes, RESOLVE_METHOD, SELECTION_TYPE, SELECTION_POSITION, SMART_LINK_TYPE, SYMBOL, SmartLinkNodeContexts, TABLE_ACTION, TABLE_BREAKOUT, TABLE_OVERFLOW_CHANGE_TRIGGER, TARGET_SELECTION_SOURCE, TOOLBAR_ACTION_SUBJECT_ID, TRIGGER_METHOD, USER_CONTEXT } from './types';
|
|
2
|
-
export { fireAnalyticsEvent } from './fire-analytics-event';
|
|
2
|
+
export { editorAnalyticsChannel, fireAnalyticsEvent } from './fire-analytics-event';
|
|
3
3
|
export { getAnalyticsEventsFromTransaction } from './utils';
|
|
4
4
|
export { buildEditLinkPayload, buildVisitedLinkPayload, buildOpenedSettingsPayload, unlinkPayload } from './linking-utils';
|
|
@@ -6,7 +6,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
6
6
|
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; }
|
|
7
7
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
8
8
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
9
|
-
var packageVersion = "75.
|
|
9
|
+
var packageVersion = "75.6.0";
|
|
10
10
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
11
11
|
// Remove URL as it has UGC
|
|
12
12
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -4,6 +4,7 @@ var _templateObject;
|
|
|
4
4
|
|
|
5
5
|
import { css } from '@emotion/react';
|
|
6
6
|
import { akEditorShadowZIndex } from '@atlaskit/editor-shared-styles';
|
|
7
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { N40A } from '@atlaskit/theme/colors';
|
|
8
9
|
import { shadowClassNames } from '../../ui/OverflowShadow';
|
|
9
10
|
import { shadowObserverClassNames } from '../../ui/OverflowShadow/shadowObserver';
|
|
@@ -23,5 +24,5 @@ var shadowWidth = 8;
|
|
|
23
24
|
* background-attachment: local, local, scroll, scroll;
|
|
24
25
|
*/
|
|
25
26
|
|
|
26
|
-
var shadowSharedStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &\n .", "::before,\n .", "::after,\n .", "::before,\n .", "::after {\n display: none;\n position: absolute;\n pointer-events: none;\n z-index: ", ";\n width: ", "px;\n content: '';\n /* Scrollbar is outside the content in IE, inset in other browsers. */\n height: calc(100%);\n }\n\n & .", ", .", " {\n position: relative;\n }\n\n & .", "::before {\n background: linear-gradient(\n to left,\n transparent 0,\n ", "
|
|
27
|
+
var shadowSharedStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &\n .", "::before,\n .", "::after,\n .", "::before,\n .", "::after {\n display: none;\n position: absolute;\n pointer-events: none;\n z-index: ", ";\n width: ", "px;\n content: '';\n /* Scrollbar is outside the content in IE, inset in other browsers. */\n height: calc(100%);\n }\n\n & .", ", .", " {\n position: relative;\n }\n\n & .", "::before {\n background: linear-gradient(\n to left,\n transparent 0,\n ", "\n ", "%\n ),\n linear-gradient(\n to right,\n ", " 0px,\n transparent 1px\n );\n top: 0px;\n left: 0;\n display: block;\n }\n\n & .", "::after {\n background: linear-gradient(\n to right,\n transparent 0,\n ", "\n ", "%\n ),\n linear-gradient(\n to left,\n ", " 0px,\n transparent 1px\n );\n left: calc(100% - ", "px);\n top: 0px;\n display: block;\n }\n\n & .", " {\n height: 100%;\n width: 0px;\n min-width: 0px;\n }\n\n & .", " {\n height: 100%;\n width: 0px;\n min-width: 0px;\n }\n"])), shadowClassNames.RIGHT_SHADOW, shadowClassNames.RIGHT_SHADOW, shadowClassNames.LEFT_SHADOW, shadowClassNames.LEFT_SHADOW, akEditorShadowZIndex, shadowWidth, shadowClassNames.RIGHT_SHADOW, shadowClassNames.LEFT_SHADOW, shadowClassNames.LEFT_SHADOW, "var(--ds-shadow-overflow-spread, ".concat(N40A, ")"), getBooleanFF('platform.editor.table.increase-shadow-visibility_lh89r') ? 140 : 100, "var(--ds-shadow-overflow-perimeter, transparent)", shadowClassNames.RIGHT_SHADOW, "var(--ds-shadow-overflow-spread, ".concat(N40A, ")"), getBooleanFF('platform.editor.table.increase-shadow-visibility_lh89r') ? 140 : 100, "var(--ds-shadow-overflow-perimeter, transparent)", shadowWidth, shadowObserverClassNames.SENTINEL_LEFT, shadowObserverClassNames.SENTINEL_RIGHT);
|
|
27
28
|
export { shadowSharedStyle };
|
|
@@ -19,7 +19,7 @@ import { themed } from '@atlaskit/theme/components';
|
|
|
19
19
|
import { borderRadius } from '@atlaskit/theme/constants';
|
|
20
20
|
import Layer from '../Layer';
|
|
21
21
|
var packageName = "@atlaskit/editor-common";
|
|
22
|
-
var packageVersion = "75.
|
|
22
|
+
var packageVersion = "75.6.0";
|
|
23
23
|
var halfFocusRing = 1;
|
|
24
24
|
var dropOffset = '0, 8';
|
|
25
25
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
4
|
+
/** @jsx jsx */
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { css, jsx } from '@emotion/react';
|
|
7
|
+
import { withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
8
|
+
import Button from '@atlaskit/button';
|
|
9
|
+
import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
10
|
+
import { DN50, N0, N30A, N60A } from '@atlaskit/theme/colors';
|
|
11
|
+
import { themed } from '@atlaskit/theme/components';
|
|
12
|
+
import { borderRadius } from '@atlaskit/theme/constants';
|
|
13
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
14
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, editorAnalyticsChannel, EVENT_TYPE } from '../../analytics';
|
|
15
|
+
import { ColorPalette, DEFAULT_BORDER_COLOR, getSelectedRowAndColumnFromPalette } from '../../ui-color';
|
|
16
|
+
import { default as Popup } from '../../ui/Popup';
|
|
17
|
+
import { default as withOuterListeners } from '../../ui/with-outer-listeners';
|
|
18
|
+
import { ArrowKeyNavigationProvider } from '../ArrowKeyNavigationProvider';
|
|
19
|
+
import { ArrowKeyNavigationType } from '../ArrowKeyNavigationProvider/types';
|
|
20
|
+
|
|
21
|
+
// helps adjusts position of popup
|
|
22
|
+
var colorPickerButtonWrapper = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n"])));
|
|
23
|
+
var colorPickerExpandContainer = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n margin: 0px ", ";\n"])), "var(--ds-space-negative-050, -4px)");
|
|
24
|
+
|
|
25
|
+
// Control the size of color picker buttons and preview
|
|
26
|
+
// TODO: https://product-fabric.atlassian.net/browse/DSP-4134
|
|
27
|
+
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
28
|
+
var colorPickerWrapper = function colorPickerWrapper(theme) {
|
|
29
|
+
return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n border-radius: ", "px;\n background-color: ", ";\n box-shadow: 0 4px 8px -2px ", ", 0 0 1px ", ";\n padding: ", " 0px;\n"])), borderRadius(), themed({
|
|
30
|
+
light: "var(--ds-surface-overlay, ".concat(N0, ")"),
|
|
31
|
+
dark: "var(--ds-surface-overlay, ".concat(DN50, ")")
|
|
32
|
+
})(theme), N60A, N60A, "var(--ds-space-100, 8px)");
|
|
33
|
+
};
|
|
34
|
+
/* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
|
|
35
|
+
|
|
36
|
+
var ColorPaletteWithListeners = withOuterListeners(ColorPalette);
|
|
37
|
+
var ColorPickerButton = function ColorPickerButton(props) {
|
|
38
|
+
var buttonRef = React.useRef(null);
|
|
39
|
+
var _React$useState = React.useState(false),
|
|
40
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
41
|
+
isPopupOpen = _React$useState2[0],
|
|
42
|
+
setIsPopupOpen = _React$useState2[1];
|
|
43
|
+
var _React$useState3 = React.useState(false),
|
|
44
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
45
|
+
isPopupPositioned = _React$useState4[0],
|
|
46
|
+
setIsPopupPositioned = _React$useState4[1];
|
|
47
|
+
var _React$useState5 = React.useState(false),
|
|
48
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
49
|
+
isOpenedByKeyboard = _React$useState6[0],
|
|
50
|
+
setIsOpenedByKeyboard = _React$useState6[1];
|
|
51
|
+
var togglePopup = function togglePopup() {
|
|
52
|
+
setIsPopupOpen(!isPopupOpen);
|
|
53
|
+
if (!isPopupOpen) {
|
|
54
|
+
setIsOpenedByKeyboard(false);
|
|
55
|
+
setIsPopupPositioned(false);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
React.useEffect(function () {
|
|
59
|
+
if (props.setDisableParentScroll) {
|
|
60
|
+
props.setDisableParentScroll(isPopupOpen);
|
|
61
|
+
}
|
|
62
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
63
|
+
}, [isPopupOpen]);
|
|
64
|
+
var focusButton = function focusButton() {
|
|
65
|
+
var _buttonRef$current;
|
|
66
|
+
(_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.focus();
|
|
67
|
+
};
|
|
68
|
+
var handleEsc = React.useCallback(function () {
|
|
69
|
+
setIsOpenedByKeyboard(false);
|
|
70
|
+
setIsPopupPositioned(false);
|
|
71
|
+
setIsPopupOpen(false);
|
|
72
|
+
focusButton();
|
|
73
|
+
}, []);
|
|
74
|
+
var onPositionCalculated = React.useCallback(function (position) {
|
|
75
|
+
setIsPopupPositioned(true);
|
|
76
|
+
return position;
|
|
77
|
+
}, []);
|
|
78
|
+
var onChange = props.onChange,
|
|
79
|
+
createAnalyticsEvent = props.createAnalyticsEvent,
|
|
80
|
+
colorPalette = props.colorPalette,
|
|
81
|
+
placement = props.placement,
|
|
82
|
+
skipFocusButtonAfterPick = props.skipFocusButtonAfterPick;
|
|
83
|
+
var onColorSelected = React.useCallback(function (color, label) {
|
|
84
|
+
setIsOpenedByKeyboard(false);
|
|
85
|
+
setIsPopupOpen(false);
|
|
86
|
+
setIsPopupPositioned(false);
|
|
87
|
+
if (onChange) {
|
|
88
|
+
if (createAnalyticsEvent) {
|
|
89
|
+
// fire analytics
|
|
90
|
+
var payload = {
|
|
91
|
+
action: ACTION.UPDATED,
|
|
92
|
+
actionSubject: ACTION_SUBJECT.PICKER,
|
|
93
|
+
actionSubjectId: ACTION_SUBJECT_ID.PICKER_COLOR,
|
|
94
|
+
attributes: {
|
|
95
|
+
color: color,
|
|
96
|
+
label: label,
|
|
97
|
+
placement: placement
|
|
98
|
+
},
|
|
99
|
+
eventType: EVENT_TYPE.TRACK
|
|
100
|
+
};
|
|
101
|
+
createAnalyticsEvent(payload).fire(editorAnalyticsChannel);
|
|
102
|
+
}
|
|
103
|
+
var newPalette = colorPalette.find(function (colorPalette) {
|
|
104
|
+
return colorPalette.value === color;
|
|
105
|
+
});
|
|
106
|
+
newPalette && onChange(newPalette);
|
|
107
|
+
}
|
|
108
|
+
if (!skipFocusButtonAfterPick) {
|
|
109
|
+
focusButton();
|
|
110
|
+
}
|
|
111
|
+
}, [colorPalette, onChange, createAnalyticsEvent, placement, skipFocusButtonAfterPick]);
|
|
112
|
+
var renderPopup = function renderPopup() {
|
|
113
|
+
if (!isPopupOpen || !buttonRef.current) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
var selectedColor = props.currentColor || null;
|
|
117
|
+
var _getSelectedRowAndCol = getSelectedRowAndColumnFromPalette(props.colorPalette, selectedColor, props.cols),
|
|
118
|
+
selectedRowIndex = _getSelectedRowAndCol.selectedRowIndex,
|
|
119
|
+
selectedColumnIndex = _getSelectedRowAndCol.selectedColumnIndex;
|
|
120
|
+
return jsx(Popup, {
|
|
121
|
+
target: buttonRef.current,
|
|
122
|
+
fitHeight: 350,
|
|
123
|
+
fitWidth: 350,
|
|
124
|
+
offset: [0, 10],
|
|
125
|
+
alignX: props.alignX,
|
|
126
|
+
mountTo: props.setDisableParentScroll ? props.mountPoint : undefined
|
|
127
|
+
// Confluence inline comment editor has z-index: 500
|
|
128
|
+
// if the toolbar is scrollable, this will be mounted in the root editor
|
|
129
|
+
// we need an index of > 500 to display over it
|
|
130
|
+
,
|
|
131
|
+
zIndex: props.setDisableParentScroll ? 600 : undefined,
|
|
132
|
+
ariaLabel: "Color picker popup",
|
|
133
|
+
onPositionCalculated: onPositionCalculated
|
|
134
|
+
}, jsx("div", {
|
|
135
|
+
css: colorPickerWrapper,
|
|
136
|
+
"data-test-id": "color-picker-menu"
|
|
137
|
+
}, jsx(ArrowKeyNavigationProvider, {
|
|
138
|
+
type: ArrowKeyNavigationType.COLOR,
|
|
139
|
+
selectedRowIndex: selectedRowIndex,
|
|
140
|
+
selectedColumnIndex: selectedColumnIndex,
|
|
141
|
+
closeOnTab: true,
|
|
142
|
+
handleClose: function handleClose() {
|
|
143
|
+
return setIsPopupOpen(false);
|
|
144
|
+
},
|
|
145
|
+
isOpenedByKeyboard: isOpenedByKeyboard,
|
|
146
|
+
isPopupPositioned: isPopupPositioned
|
|
147
|
+
}, jsx(ColorPaletteWithListeners, {
|
|
148
|
+
cols: props.cols,
|
|
149
|
+
selectedColor: selectedColor,
|
|
150
|
+
onClick: onColorSelected,
|
|
151
|
+
handleClickOutside: togglePopup,
|
|
152
|
+
handleEscapeKeydown: handleEsc,
|
|
153
|
+
paletteOptions: {
|
|
154
|
+
palette: props.colorPalette,
|
|
155
|
+
hexToPaletteColor: props.hexToPaletteColor,
|
|
156
|
+
paletteColorTooltipMessages: props.paletteColorTooltipMessages
|
|
157
|
+
}
|
|
158
|
+
}))));
|
|
159
|
+
};
|
|
160
|
+
var title = props.title || '';
|
|
161
|
+
var currentColor = props.currentColor && props.hexToPaletteColor ? props.hexToPaletteColor(props.currentColor) : props.currentColor;
|
|
162
|
+
var buttonStyle = function buttonStyle(theme) {
|
|
163
|
+
var _props$size, _props$size2, _props$size3;
|
|
164
|
+
return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n padding: 0 10px;\n background-color: ", ";\n ", "\n &:before {\n display: flex;\n justify-content: center;\n align-items: center;\n align-self: center;\n content: '';\n border: 1px solid ", ";\n border-radius: ", "px;\n background-color: ", ";\n width: ", ";\n height: ", ";\n padding: 0;\n margin: 0px ", ";\n }\n &:hover {\n background: ", ";\n }\n "])), "var(--ds-background-neutral-subtle, transparent)", /* If custom props size height, override the button base height property */
|
|
165
|
+
!!((_props$size = props.size) !== null && _props$size !== void 0 && _props$size.height) && "height: inherit;", DEFAULT_BORDER_COLOR, borderRadius(), currentColor || 'transparent', ((_props$size2 = props.size) === null || _props$size2 === void 0 ? void 0 : _props$size2.width) || '14px', ((_props$size3 = props.size) === null || _props$size3 === void 0 ? void 0 : _props$size3.height) || '14px', "var(--ds-space-025, 2px)", themed({
|
|
166
|
+
light: "var(--ds-background-neutral-subtle-hovered, ".concat(N30A, ")"),
|
|
167
|
+
dark: "var(--ds-background-neutral-subtle-hovered, ".concat(N30A, ")")
|
|
168
|
+
})(theme));
|
|
169
|
+
};
|
|
170
|
+
return jsx("div", {
|
|
171
|
+
css: colorPickerButtonWrapper
|
|
172
|
+
}, jsx(Tooltip, {
|
|
173
|
+
content: title,
|
|
174
|
+
position: "top"
|
|
175
|
+
}, jsx(Button, {
|
|
176
|
+
ref: buttonRef,
|
|
177
|
+
"aria-label": title,
|
|
178
|
+
spacing: "compact",
|
|
179
|
+
onClick: togglePopup,
|
|
180
|
+
onKeyDown: function onKeyDown(event) {
|
|
181
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
182
|
+
event.preventDefault();
|
|
183
|
+
togglePopup();
|
|
184
|
+
setIsOpenedByKeyboard(true);
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
css: buttonStyle,
|
|
188
|
+
iconAfter: jsx("span", {
|
|
189
|
+
css: colorPickerExpandContainer
|
|
190
|
+
}, jsx(ExpandIcon, {
|
|
191
|
+
label: ""
|
|
192
|
+
}))
|
|
193
|
+
})), renderPopup());
|
|
194
|
+
};
|
|
195
|
+
export default withAnalyticsContext({
|
|
196
|
+
source: 'ConfigPanel'
|
|
197
|
+
})(withAnalyticsEvents()(ColorPickerButton));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _objectDestructuringEmpty from "@babel/runtime/helpers/objectDestructuringEmpty";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
/** @jsx jsx */
|
|
7
|
+
import React, { useContext } from 'react';
|
|
8
|
+
import { jsx } from '@emotion/react';
|
|
9
|
+
import DropdownComponent from '../Dropdown';
|
|
10
|
+
import { KeyDownHandlerContext } from '../ToolbarArrowKeyNavigationProvider';
|
|
11
|
+
export var DropdownContainer = /*#__PURE__*/React.memo(function (_ref) {
|
|
12
|
+
var props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
13
|
+
var keyDownHandlerContext = useContext(KeyDownHandlerContext);
|
|
14
|
+
return (
|
|
15
|
+
//This context is to handle the tab, Arrow Right/Left key events for dropdown.
|
|
16
|
+
//Default context has the void callbacks for above key events
|
|
17
|
+
jsx(DropdownComponent, _extends({
|
|
18
|
+
arrowKeyNavigationProviderOptions: _objectSpread(_objectSpread({}, props.arrowKeyNavigationProviderOptions), {}, {
|
|
19
|
+
keyDownHandlerContext: keyDownHandlerContext
|
|
20
|
+
})
|
|
21
|
+
}, props))
|
|
22
|
+
);
|
|
23
|
+
});
|
|
@@ -4,4 +4,6 @@ export { ArrowKeyNavigationProvider } from './ArrowKeyNavigationProvider';
|
|
|
4
4
|
export { ToolbarArrowKeyNavigationProvider, KeyDownHandlerContext } from './ToolbarArrowKeyNavigationProvider';
|
|
5
5
|
export { ArrowKeyNavigationType } from './ArrowKeyNavigationProvider/types';
|
|
6
6
|
export { ColorPaletteArrowKeyNavigationProvider } from './ArrowKeyNavigationProvider/ColorPaletteArrowKeyNavigationProvider';
|
|
7
|
-
export { default as Dropdown } from './Dropdown';
|
|
7
|
+
export { default as Dropdown } from './Dropdown';
|
|
8
|
+
export { default as ColorPickerButton } from './ColorPickerButton';
|
|
9
|
+
export { DropdownContainer } from './DropdownContainer';
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
2
|
+
import { hasDocAsParent } from './document';
|
|
3
|
+
import { isEmptyParagraph } from './editor-core-utils';
|
|
2
4
|
export { canApplyAnnotationOnRange, getAnnotationIdsFromRange } from './annotation';
|
|
3
5
|
export { getExtensionLozengeData } from './macro';
|
|
4
6
|
export { default as browser } from './browser';
|
|
5
7
|
export { default as ErrorReporter } from './error-reporter';
|
|
6
8
|
export { isPastDate, timestampToIsoFormat, timestampToString, timestampToTaskContext, timestampToUTCDate, todayTimestampInUTC } from './date';
|
|
7
9
|
export { isElementInTableCell, isTextSelection, isLastItemMediaGroup, setNodeSelection, setTextSelection, nonNullable, stepAddsOneOf, stepHasSlice, extractSliceFromStep, isValidPosition, isEmptyParagraph, isInLayoutColumn, removeBlockMarks, filterChildrenBetween } from './editor-core-utils';
|
|
8
|
-
import { isEmptyParagraph } from './editor-core-utils';
|
|
9
10
|
export { withImageLoader } from './imageLoader';
|
|
10
11
|
export { absoluteBreakoutWidth, calcBreakoutWidth, calcWideWidth, breakoutConsts, calculateBreakoutStyles, calcBreakoutWidthPx, getNextBreakoutMode, getTitle } from './breakout';
|
|
11
12
|
export { findChangedNodesFromTransaction, validNode, validateNodes, isType, isParagraph, isText, isLinkMark, SelectedState, isNodeSelectedOrInRange, isSupportedInParent, isMediaNode, isNodeBeforeMediaNode } from './nodes';
|
|
@@ -199,6 +200,21 @@ export function isNodeEmpty(node) {
|
|
|
199
200
|
return !!childNode.childCount && !(childNode.childCount === 1 && isEmptyParagraph(childNode.firstChild)) || childNode.isAtom;
|
|
200
201
|
}).length;
|
|
201
202
|
}
|
|
203
|
+
export function isInEmptyLine(state) {
|
|
204
|
+
var selection = state.selection;
|
|
205
|
+
var _ref = selection,
|
|
206
|
+
$cursor = _ref.$cursor,
|
|
207
|
+
$anchor = _ref.$anchor;
|
|
208
|
+
if (!$cursor) {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
var node = $cursor.node();
|
|
212
|
+
if (!node) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
return isEmptyParagraph(node) && hasDocAsParent($anchor);
|
|
216
|
+
}
|
|
202
217
|
export { dedupe } from './dedupe';
|
|
203
218
|
export { createWrapSelectionTransaction } from './create-wrap-selection-transaction';
|
|
204
|
-
export { wrapSelectionIn } from './wrap-selection-in';
|
|
219
|
+
export { wrapSelectionIn } from './wrap-selection-in';
|
|
220
|
+
export { toJSON, nodeToJSON } from './nodes';
|
package/dist/esm/utils/nodes.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { JSONTransformer } from '@atlaskit/editor-json-transformer';
|
|
1
2
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
2
3
|
/**
|
|
3
4
|
* Finds all top level nodes affected by the transaction
|
|
@@ -127,4 +128,11 @@ export var isNodeBeforeMediaNode = function isNodeBeforeMediaNode($pos, state) {
|
|
|
127
128
|
return ['media', 'mediaInline', 'mediaGroup', 'mediaSingle'].includes(nodeBefore.type.name);
|
|
128
129
|
}
|
|
129
130
|
return false;
|
|
130
|
-
};
|
|
131
|
+
};
|
|
132
|
+
var transformer = new JSONTransformer();
|
|
133
|
+
export function toJSON(node) {
|
|
134
|
+
return transformer.encode(node);
|
|
135
|
+
}
|
|
136
|
+
export function nodeToJSON(node) {
|
|
137
|
+
return transformer.encodeNode(node);
|
|
138
|
+
}
|