@atlaskit/editor-core 177.0.1 → 178.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 +83 -0
- package/codemods/__tests__/next-remove-allow-more-text-colors-prop.ts +147 -0
- package/codemods/migrates/next-remove-allow-more-text-colors-prop.ts +58 -0
- package/dist/cjs/create-editor/ErrorBoundary.js +3 -1
- package/dist/cjs/create-editor/ReactEditorView.js +3 -2
- package/dist/cjs/create-editor/create-editor.js +3 -1
- package/dist/cjs/editor.js +7 -0
- package/dist/cjs/plugins/block-type/commands/delete-and-move-cursor.js +67 -0
- package/dist/cjs/plugins/block-type/commands/index.js +9 -1
- package/dist/cjs/plugins/block-type/pm-plugins/keymap.js +8 -3
- package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +12 -12
- package/dist/cjs/plugins/floating-toolbar/ui/DropdownMenu.js +39 -11
- package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +8 -15
- package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +2 -0
- package/dist/cjs/plugins/text-color/commands/change-color.js +1 -2
- package/dist/cjs/plugins/text-color/pm-plugins/main.js +1 -1
- package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/index.js +2 -10
- package/dist/cjs/ui/Appearance/FullPage/FullPageToolbar.js +19 -1
- package/dist/cjs/ui/ColorPalette/Palettes/textColorPalette.js +0 -6
- package/dist/cjs/ui/ColorPickerButton/index.js +3 -8
- package/dist/cjs/ui/ToolbarArrowKeyNavigationProvider/index.js +27 -2
- package/dist/cjs/utils/performance/instrumented-plugin.js +6 -3
- package/dist/cjs/utils/performance/safer-transactions.js +8 -2
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/create-editor/ErrorBoundary.js +3 -1
- package/dist/es2019/create-editor/ReactEditorView.js +3 -2
- package/dist/es2019/create-editor/create-editor.js +3 -1
- package/dist/es2019/editor.js +7 -0
- package/dist/es2019/plugins/block-type/commands/delete-and-move-cursor.js +63 -0
- package/dist/es2019/plugins/block-type/commands/index.js +2 -1
- package/dist/es2019/plugins/block-type/pm-plugins/keymap.js +7 -4
- package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +12 -12
- package/dist/es2019/plugins/floating-toolbar/ui/DropdownMenu.js +42 -11
- package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +9 -17
- package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +2 -0
- package/dist/es2019/plugins/text-color/commands/change-color.js +1 -2
- package/dist/es2019/plugins/text-color/pm-plugins/main.js +2 -2
- package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/index.js +2 -6
- package/dist/es2019/ui/Appearance/FullPage/FullPageToolbar.js +19 -1
- package/dist/es2019/ui/ColorPalette/Palettes/textColorPalette.js +1 -1
- package/dist/es2019/ui/ColorPickerButton/index.js +20 -9
- package/dist/es2019/ui/ToolbarArrowKeyNavigationProvider/index.js +27 -2
- package/dist/es2019/utils/performance/instrumented-plugin.js +5 -3
- package/dist/es2019/utils/performance/safer-transactions.js +8 -2
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/create-editor/ErrorBoundary.js +3 -1
- package/dist/esm/create-editor/ReactEditorView.js +3 -2
- package/dist/esm/create-editor/create-editor.js +3 -1
- package/dist/esm/editor.js +7 -0
- package/dist/esm/plugins/block-type/commands/delete-and-move-cursor.js +58 -0
- package/dist/esm/plugins/block-type/commands/index.js +2 -1
- package/dist/esm/plugins/block-type/pm-plugins/keymap.js +7 -4
- package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +12 -12
- package/dist/esm/plugins/floating-toolbar/ui/DropdownMenu.js +40 -12
- package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +9 -17
- package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +2 -0
- package/dist/esm/plugins/text-color/commands/change-color.js +1 -2
- package/dist/esm/plugins/text-color/pm-plugins/main.js +2 -2
- package/dist/esm/plugins/text-color/ui/ToolbarTextColor/index.js +2 -9
- package/dist/esm/ui/Appearance/FullPage/FullPageToolbar.js +19 -1
- package/dist/esm/ui/ColorPalette/Palettes/textColorPalette.js +1 -1
- package/dist/esm/ui/ColorPickerButton/index.js +5 -10
- package/dist/esm/ui/ToolbarArrowKeyNavigationProvider/index.js +27 -2
- package/dist/esm/utils/performance/instrumented-plugin.js +6 -3
- package/dist/esm/utils/performance/safer-transactions.js +8 -2
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/block-type/commands/delete-and-move-cursor.d.ts +12 -0
- package/dist/types/plugins/block-type/commands/index.d.ts +1 -0
- package/dist/types/plugins/floating-toolbar/ui/DropdownMenu.d.ts +1 -0
- package/dist/types/plugins/text-color/pm-plugins/main.d.ts +1 -1
- package/dist/types/ui/ColorPalette/Palettes/textColorPalette.d.ts +1 -1
- package/dist/types/ui/ToolbarArrowKeyNavigationProvider/index.d.ts +2 -1
- package/dist/types/utils/performance/instrumented-plugin.d.ts +1 -0
- package/dist/types/utils/performance/safer-transactions.d.ts +2 -1
- package/package.json +9 -10
- package/report.api.md +18 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { useState, useCallback } from 'react';
|
|
2
|
+
import { useState, useCallback, useEffect, createRef } from 'react';
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
4
|
import { Component } from 'react';
|
|
5
5
|
import { gridSize } from '@atlaskit/theme/constants';
|
|
@@ -31,6 +31,10 @@ const menuContainer = css`
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
`;
|
|
34
|
+
const label = css`
|
|
35
|
+
display: inline-block;
|
|
36
|
+
width: 100%;
|
|
37
|
+
`;
|
|
34
38
|
export const itemSpacing = gridSize() / 2;
|
|
35
39
|
const DropdownButtonItem = ButtonItem;
|
|
36
40
|
|
|
@@ -42,17 +46,24 @@ const DropdownMenuItem = ({
|
|
|
42
46
|
iconBefore
|
|
43
47
|
}) => {
|
|
44
48
|
const [tooltipContent, setTooltipContent] = useState(item.tooltip || '');
|
|
45
|
-
const
|
|
49
|
+
const handleItemMouseOut = useCallback(() => {
|
|
46
50
|
setTooltipContent('');
|
|
47
|
-
|
|
51
|
+
|
|
52
|
+
if (item.onMouseOut) {
|
|
53
|
+
dispatchCommand(item.onMouseOut);
|
|
54
|
+
}
|
|
55
|
+
}, [item.onMouseOut, dispatchCommand]);
|
|
48
56
|
const handleItemMouseDown = useCallback(e => {
|
|
49
|
-
e.preventDefault();
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
e.preventDefault(); // ED-16204 - This is needed for safari to get handleItemClick() to work
|
|
58
|
+
|
|
59
|
+
if (item.onMouseDown) {
|
|
60
|
+
dispatchCommand(item.onMouseDown);
|
|
61
|
+
}
|
|
62
|
+
}, [item.onMouseDown, dispatchCommand]);
|
|
63
|
+
const handleItemMouseOver = useCallback(() => {
|
|
52
64
|
setTooltipContent(item.tooltip || '');
|
|
53
65
|
|
|
54
66
|
if (item.onMouseOver) {
|
|
55
|
-
e.preventDefault();
|
|
56
67
|
dispatchCommand(item.onMouseOver);
|
|
57
68
|
}
|
|
58
69
|
}, [item.tooltip, item.onMouseOver, dispatchCommand]);
|
|
@@ -94,6 +105,24 @@ const DropdownMenuItem = ({
|
|
|
94
105
|
editorView === null || editorView === void 0 ? void 0 : editorView.focus();
|
|
95
106
|
}
|
|
96
107
|
}, [dispatchCommand, item.onClick, hide, editorView]);
|
|
108
|
+
/* ED-16704 - Native mouse event handler to overcome firefox issue on disabled <button> - https://github.com/whatwg/html/issues/5886 */
|
|
109
|
+
|
|
110
|
+
const labelRef = /*#__PURE__*/createRef();
|
|
111
|
+
const handleTitleWrapperMouseEvent = useCallback(e => {
|
|
112
|
+
if (item.disabled) {
|
|
113
|
+
e.stopPropagation();
|
|
114
|
+
e.preventDefault();
|
|
115
|
+
}
|
|
116
|
+
}, [item.disabled]);
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
const labelRefCurrent = labelRef.current;
|
|
119
|
+
labelRefCurrent === null || labelRefCurrent === void 0 ? void 0 : labelRefCurrent.addEventListener('click', handleTitleWrapperMouseEvent);
|
|
120
|
+
labelRefCurrent === null || labelRefCurrent === void 0 ? void 0 : labelRefCurrent.addEventListener('mousedown', handleTitleWrapperMouseEvent);
|
|
121
|
+
return () => {
|
|
122
|
+
labelRefCurrent === null || labelRefCurrent === void 0 ? void 0 : labelRefCurrent.removeEventListener('click', handleTitleWrapperMouseEvent);
|
|
123
|
+
labelRefCurrent === null || labelRefCurrent === void 0 ? void 0 : labelRefCurrent.removeEventListener('mousedown', handleTitleWrapperMouseEvent);
|
|
124
|
+
};
|
|
125
|
+
});
|
|
97
126
|
const itemContent = jsx(DropdownButtonItem, {
|
|
98
127
|
iconBefore: iconBefore,
|
|
99
128
|
iconAfter: item.elemAfter,
|
|
@@ -104,16 +133,18 @@ const DropdownMenuItem = ({
|
|
|
104
133
|
onMouseOver: handleItemMouseOver,
|
|
105
134
|
onMouseEnter: handleItemMouseEnter,
|
|
106
135
|
onMouseLeave: handleItemMouseLeave,
|
|
136
|
+
onMouseOut: handleItemMouseOut,
|
|
107
137
|
onFocus: handleItemOnFocus,
|
|
108
138
|
onBlur: handleItemOnBlur
|
|
109
|
-
},
|
|
139
|
+
}, jsx("span", {
|
|
140
|
+
ref: labelRef,
|
|
141
|
+
css: label
|
|
142
|
+
}, item.title));
|
|
110
143
|
|
|
111
144
|
if (tooltipContent) {
|
|
112
145
|
return jsx(Tooltip, {
|
|
113
146
|
content: tooltipContent
|
|
114
|
-
},
|
|
115
|
-
onMouseOut: handleTooltipMouseOut
|
|
116
|
-
}, itemContent));
|
|
147
|
+
}, itemContent);
|
|
117
148
|
}
|
|
118
149
|
|
|
119
150
|
return itemContent;
|
|
@@ -10,7 +10,7 @@ import { themed } from '@atlaskit/theme/components';
|
|
|
10
10
|
import { borderRadius, gridSize } from '@atlaskit/theme/constants';
|
|
11
11
|
import { DN70 } from '@atlaskit/theme/colors';
|
|
12
12
|
import { getFeatureFlags } from '../../feature-flags-context';
|
|
13
|
-
import { compareArrays,
|
|
13
|
+
import { compareArrays, shallowEqual } from '../utils';
|
|
14
14
|
import { showConfirmDialog } from '../pm-plugins/toolbar-data/commands';
|
|
15
15
|
import Button from './Button';
|
|
16
16
|
import Dropdown from './Dropdown';
|
|
@@ -331,14 +331,6 @@ class Toolbar extends Component {
|
|
|
331
331
|
constructor(props) {
|
|
332
332
|
super(props);
|
|
333
333
|
|
|
334
|
-
_defineProperty(this, "focusToolbar", event => {
|
|
335
|
-
if (event.altKey && event.keyCode === 121) {
|
|
336
|
-
var _getFirstFocusableEle, _this$toolbarContaine;
|
|
337
|
-
|
|
338
|
-
(_getFirstFocusableEle = getFirstFocusableElement((_this$toolbarContaine = this.toolbarContainerRef) === null || _this$toolbarContaine === void 0 ? void 0 : _this$toolbarContaine.current)) === null || _getFirstFocusableEle === void 0 ? void 0 : _getFirstFocusableEle.focus();
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
|
|
342
334
|
_defineProperty(this, "shouldHandleArrowKeys", () => {
|
|
343
335
|
var _this$props$items;
|
|
344
336
|
|
|
@@ -409,7 +401,6 @@ class Toolbar extends Component {
|
|
|
409
401
|
this.setState({
|
|
410
402
|
mounted: true
|
|
411
403
|
});
|
|
412
|
-
document.addEventListener('keydown', this.focusToolbar);
|
|
413
404
|
}
|
|
414
405
|
|
|
415
406
|
componentDidUpdate(prevProps) {
|
|
@@ -424,13 +415,7 @@ class Toolbar extends Component {
|
|
|
424
415
|
this.resetStyling({
|
|
425
416
|
table: this.props.node.type.name === 'table'
|
|
426
417
|
});
|
|
427
|
-
document.removeEventListener('keydown', this.focusToolbar);
|
|
428
418
|
}
|
|
429
|
-
/**
|
|
430
|
-
* To listen to keyboard shortcut Alt+F10 and focus floating toolbar's first focusable element.
|
|
431
|
-
* @param event
|
|
432
|
-
*/
|
|
433
|
-
|
|
434
419
|
|
|
435
420
|
render() {
|
|
436
421
|
const {
|
|
@@ -448,11 +433,18 @@ class Toolbar extends Component {
|
|
|
448
433
|
|
|
449
434
|
const firstElementIsSelect = items[0].type === 'select';
|
|
450
435
|
const hasSelect = items.find(item => item.type === 'select' && item.selectType === 'list');
|
|
436
|
+
|
|
437
|
+
const isShortcutToFocusToolbar = event => {
|
|
438
|
+
//Alt + F10 to reach first element in this floating toolbar
|
|
439
|
+
return event.altKey && (event.key === 'F10' || event.keyCode === 121);
|
|
440
|
+
};
|
|
441
|
+
|
|
451
442
|
return jsx(React.Fragment, null, jsx(ToolbarArrowKeyNavigationProvider, {
|
|
452
443
|
editorView: this.props.editorView,
|
|
453
444
|
handleEscape: this.handleEscape,
|
|
454
445
|
disableArrowKeyNavigation: !this.shouldHandleArrowKeys(),
|
|
455
|
-
childComponentSelector: "[data-testid='editor-floating-toolbar']"
|
|
446
|
+
childComponentSelector: "[data-testid='editor-floating-toolbar']",
|
|
447
|
+
isShortcutToFocusToolbar: isShortcutToFocusToolbar
|
|
456
448
|
}, jsx("div", {
|
|
457
449
|
ref: this.toolbarContainerRef,
|
|
458
450
|
css: theme => [toolbarContainer({
|
|
@@ -770,6 +770,7 @@ export class HyperlinkLinkAddToolbar extends PureComponent {
|
|
|
770
770
|
}), displayUrl && jsx(Tooltip, {
|
|
771
771
|
content: formatClearLinkText
|
|
772
772
|
}, jsx("button", {
|
|
773
|
+
type: "button",
|
|
773
774
|
css: clearText,
|
|
774
775
|
onClick: this.handleClearText
|
|
775
776
|
}, jsx(CrossCircleIcon, {
|
|
@@ -795,6 +796,7 @@ export class HyperlinkLinkAddToolbar extends PureComponent {
|
|
|
795
796
|
}), displayText && jsx(Tooltip, {
|
|
796
797
|
content: formatMessage(messages.clearText)
|
|
797
798
|
}, jsx("button", {
|
|
799
|
+
type: "button",
|
|
798
800
|
css: clearText,
|
|
799
801
|
onClick: this.handleClearDisplayText,
|
|
800
802
|
onKeyDown: this.handleClearTextKeyDown
|
|
@@ -40,8 +40,7 @@ export const changeColor = color => (state, dispatch) => {
|
|
|
40
40
|
if (textColor) {
|
|
41
41
|
const pluginState = pluginKey.getState(state);
|
|
42
42
|
const activeColor = getActiveColor(state);
|
|
43
|
-
const withColorAnalytics = createWithColorAnalytics(color, activeColor,
|
|
44
|
-
pluginState.paletteExpanded || pluginState.palette);
|
|
43
|
+
const withColorAnalytics = createWithColorAnalytics(color, activeColor, pluginState.palette);
|
|
45
44
|
|
|
46
45
|
if (pluginState.disabled) {
|
|
47
46
|
return false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
2
|
import { PluginKey } from 'prosemirror-state';
|
|
3
|
-
import {
|
|
3
|
+
import { textColorPalette } from '../../../ui/ColorPalette/Palettes/textColorPalette';
|
|
4
4
|
import { DEFAULT_BORDER_COLOR } from '../../../ui/ColorPalette/Palettes/common';
|
|
5
5
|
import { DEFAULT_COLOR, getActiveColor } from '../utils/color';
|
|
6
6
|
import { getDisabledState } from '../utils/disabled';
|
|
@@ -11,7 +11,7 @@ export function createInitialPluginState(editorState, pluginConfig) {
|
|
|
11
11
|
value: defaultColor.color,
|
|
12
12
|
label: defaultColor.label,
|
|
13
13
|
border: DEFAULT_BORDER_COLOR
|
|
14
|
-
}, ...
|
|
14
|
+
}, ...textColorPalette];
|
|
15
15
|
const state = {
|
|
16
16
|
color: getActiveColor(editorState),
|
|
17
17
|
disabled: getDisabledState(editorState),
|
|
@@ -7,7 +7,6 @@ import { defineMessages, injectIntl } from 'react-intl-next';
|
|
|
7
7
|
import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
|
|
8
8
|
import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
9
9
|
import ColorPalette from '../../../../ui/ColorPalette';
|
|
10
|
-
import { textColorPalette as originalTextColors } from '../../../../ui/ColorPalette/Palettes/textColorPalette';
|
|
11
10
|
import Dropdown from '../../../../ui/Dropdown';
|
|
12
11
|
import { expandIconWrapperStyle, wrapperStyle, separatorStyles, triggerWrapperStyles } from '../../../../ui/styles';
|
|
13
12
|
import ToolbarButton, { TOOLBAR_BUTTON } from '../../../../ui/ToolbarButton';
|
|
@@ -51,16 +50,13 @@ export class ToolbarTextColor extends React.Component {
|
|
|
51
50
|
|
|
52
51
|
const {
|
|
53
52
|
pluginState: {
|
|
54
|
-
palette
|
|
55
|
-
defaultColor
|
|
53
|
+
palette
|
|
56
54
|
}
|
|
57
55
|
} = this.props; // we store color names in analytics
|
|
58
56
|
|
|
59
57
|
const swatch = palette.find(sw => sw.value === color);
|
|
60
|
-
const isNewColor = color !== defaultColor && !originalTextColors.some(col => col.value === color);
|
|
61
58
|
this.dispatchAnalyticsEvent(this.buildAnalyticsSelectColor({
|
|
62
|
-
color: (swatch ? swatch.label : color).toLowerCase()
|
|
63
|
-
isNewColor
|
|
59
|
+
color: (swatch ? swatch.label : color).toLowerCase()
|
|
64
60
|
}));
|
|
65
61
|
this.handleOpenChange({
|
|
66
62
|
isOpen: false,
|
|
@@ -65,6 +65,22 @@ export const EditorToolbar = /*#__PURE__*/React.memo(props => {
|
|
|
65
65
|
return () => window.removeEventListener('resize', updateOnResize);
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
|
+
|
|
69
|
+
const isShortcutToFocusToolbar = event => {
|
|
70
|
+
//Alt + F9 to reach first element in this main toolbar
|
|
71
|
+
return event.altKey && (event.key === 'F9' || event.keyCode === 120);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const handleEscape = event => {
|
|
75
|
+
var _props$editorView;
|
|
76
|
+
|
|
77
|
+
if (!((_props$editorView = props.editorView) !== null && _props$editorView !== void 0 && _props$editorView.hasFocus())) {
|
|
78
|
+
var _props$editorView2;
|
|
79
|
+
|
|
80
|
+
(_props$editorView2 = props.editorView) === null || _props$editorView2 === void 0 ? void 0 : _props$editorView2.focus();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
68
84
|
return jsx(ContextPanelConsumer, null, ({
|
|
69
85
|
width: contextPanelWidth
|
|
70
86
|
}) => {
|
|
@@ -72,7 +88,9 @@ export const EditorToolbar = /*#__PURE__*/React.memo(props => {
|
|
|
72
88
|
|
|
73
89
|
return jsx(ToolbarArrowKeyNavigationProvider, {
|
|
74
90
|
editorView: props.editorView,
|
|
75
|
-
childComponentSelector: "[data-testid='ak-editor-main-toolbar']"
|
|
91
|
+
childComponentSelector: "[data-testid='ak-editor-main-toolbar']",
|
|
92
|
+
isShortcutToFocusToolbar: isShortcutToFocusToolbar,
|
|
93
|
+
handleEscape: handleEscape
|
|
76
94
|
}, jsx("div", {
|
|
77
95
|
css: mainToolbarStyle(props.showKeyline || contextPanelWidth > 0, !!((_props$featureFlags8 = props.featureFlags) !== null && _props$featureFlags8 !== void 0 && _props$featureFlags8.twoLineEditorToolbar)),
|
|
78
96
|
"data-testid": "ak-editor-main-toolbar"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { textColorPalette
|
|
1
|
+
export { textColorPalette } from '@atlaskit/editor-common/ui-color';
|
|
@@ -10,8 +10,8 @@ import ColorPalette from '../ColorPalette';
|
|
|
10
10
|
import { DEFAULT_BORDER_COLOR } from '../ColorPalette/Palettes/common';
|
|
11
11
|
import { withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
12
12
|
import { editorAnalyticsChannel } from '../../plugins/analytics/consts';
|
|
13
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../../plugins/analytics/types';
|
|
14
|
-
|
|
13
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../../plugins/analytics/types';
|
|
14
|
+
// helps adjusts position of popup
|
|
15
15
|
const colorPickerButtonWrapper = css`
|
|
16
16
|
position: relative;
|
|
17
17
|
`; // Control the size of color picker buttons and preview
|
|
@@ -100,6 +100,23 @@ const ColorPickerButton = props => {
|
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
const title = props.title || '';
|
|
103
|
+
const buttonStyle = css`
|
|
104
|
+
padding: 6px;
|
|
105
|
+
background-color: ${"var(--ds-background-neutral, transparent)"};
|
|
106
|
+
&:before {
|
|
107
|
+
display: flex;
|
|
108
|
+
justify-content: center;
|
|
109
|
+
align-items: center;
|
|
110
|
+
align-self: center;
|
|
111
|
+
content: '';
|
|
112
|
+
border: 1px solid ${DEFAULT_BORDER_COLOR};
|
|
113
|
+
border-radius: ${borderRadius()}px;
|
|
114
|
+
background-color: ${props.currentColor || 'transparent'};
|
|
115
|
+
width: ${((_props$size = props.size) === null || _props$size === void 0 ? void 0 : _props$size.width) || 14}px;
|
|
116
|
+
height: ${((_props$size2 = props.size) === null || _props$size2 === void 0 ? void 0 : _props$size2.height) || 14}px;
|
|
117
|
+
padding: 0;
|
|
118
|
+
}
|
|
119
|
+
`;
|
|
103
120
|
return jsx("div", {
|
|
104
121
|
css: colorPickerButtonWrapper
|
|
105
122
|
}, jsx(Tooltip, {
|
|
@@ -110,13 +127,7 @@ const ColorPickerButton = props => {
|
|
|
110
127
|
"aria-label": title,
|
|
111
128
|
spacing: "compact",
|
|
112
129
|
onClick: togglePopup,
|
|
113
|
-
|
|
114
|
-
backgroundColor: props.currentColor || 'transparent',
|
|
115
|
-
border: `1px solid ${DEFAULT_BORDER_COLOR}`,
|
|
116
|
-
width: `${((_props$size = props.size) === null || _props$size === void 0 ? void 0 : _props$size.width) || 20}px`,
|
|
117
|
-
height: `${((_props$size2 = props.size) === null || _props$size2 === void 0 ? void 0 : _props$size2.height) || 20}px`,
|
|
118
|
-
padding: 0
|
|
119
|
-
}
|
|
130
|
+
css: buttonStyle
|
|
120
131
|
})), renderPopup());
|
|
121
132
|
};
|
|
122
133
|
|
|
@@ -23,7 +23,8 @@ export const ToolbarArrowKeyNavigationProvider = ({
|
|
|
23
23
|
editorView,
|
|
24
24
|
childComponentSelector,
|
|
25
25
|
handleEscape,
|
|
26
|
-
disableArrowKeyNavigation
|
|
26
|
+
disableArrowKeyNavigation,
|
|
27
|
+
isShortcutToFocusToolbar
|
|
27
28
|
}) => {
|
|
28
29
|
const wrapperRef = useRef(null);
|
|
29
30
|
const selectedItemIndex = useRef(0);
|
|
@@ -142,11 +143,35 @@ export const ToolbarArrowKeyNavigationProvider = ({
|
|
|
142
143
|
}
|
|
143
144
|
};
|
|
144
145
|
|
|
146
|
+
const globalKeyDownHandler = event => {
|
|
147
|
+
//To focus the first element in the toolbar
|
|
148
|
+
if (isShortcutToFocusToolbar(event)) {
|
|
149
|
+
var _filteredFocusableEle4, _filteredFocusableEle5;
|
|
150
|
+
|
|
151
|
+
const filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
152
|
+
(_filteredFocusableEle4 = filteredFocusableElements[0]) === null || _filteredFocusableEle4 === void 0 ? void 0 : _filteredFocusableEle4.focus();
|
|
153
|
+
(_filteredFocusableEle5 = filteredFocusableElements[0]) === null || _filteredFocusableEle5 === void 0 ? void 0 : _filteredFocusableEle5.scrollIntoView({
|
|
154
|
+
behavior: 'smooth',
|
|
155
|
+
block: 'center',
|
|
156
|
+
inline: 'nearest'
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
145
161
|
element === null || element === void 0 ? void 0 : element.addEventListener('keydown', handleKeyDown);
|
|
162
|
+
|
|
163
|
+
if (isShortcutToFocusToolbar) {
|
|
164
|
+
document.addEventListener('keydown', globalKeyDownHandler);
|
|
165
|
+
}
|
|
166
|
+
|
|
146
167
|
return () => {
|
|
147
168
|
element === null || element === void 0 ? void 0 : element.removeEventListener('keydown', handleKeyDown);
|
|
169
|
+
|
|
170
|
+
if (isShortcutToFocusToolbar) {
|
|
171
|
+
document.removeEventListener('keydown', globalKeyDownHandler);
|
|
172
|
+
}
|
|
148
173
|
};
|
|
149
|
-
}, [selectedItemIndex, wrapperRef, editorView, disableArrowKeyNavigation, handleEscape, childComponentSelector, incrementIndex, decrementIndex]);
|
|
174
|
+
}, [selectedItemIndex, wrapperRef, editorView, disableArrowKeyNavigation, handleEscape, childComponentSelector, incrementIndex, decrementIndex, isShortcutToFocusToolbar]);
|
|
150
175
|
return /*#__PURE__*/React.createElement("div", {
|
|
151
176
|
className: "custom-key-handler-wrapper",
|
|
152
177
|
ref: wrapperRef
|
|
@@ -11,18 +11,20 @@ export class InstrumentedPlugin extends SafePlugin {
|
|
|
11
11
|
enabled: false
|
|
12
12
|
},
|
|
13
13
|
saferDispatchedTransactions = false,
|
|
14
|
+
saferDispatchedTransactionsAnalyticsOnly = false,
|
|
14
15
|
dispatchAnalyticsEvent
|
|
15
16
|
} = options;
|
|
16
|
-
const shouldOverrideApply = transactionTracking.enabled && transactionTracker || saferDispatchedTransactions;
|
|
17
|
+
const shouldOverrideApply = transactionTracking.enabled && transactionTracker || saferDispatchedTransactions || saferDispatchedTransactionsAnalyticsOnly;
|
|
17
18
|
|
|
18
19
|
if (shouldOverrideApply && spec.state) {
|
|
19
20
|
const originalApply = spec.state.apply.bind(spec.state);
|
|
20
21
|
|
|
21
22
|
spec.state.apply = (aTr, value, oldState, newState) => {
|
|
22
23
|
const self = this;
|
|
23
|
-
const tr = saferDispatchedTransactions ? new Proxy(aTr, freezeUnsafeTransactionProperties({
|
|
24
|
+
const tr = saferDispatchedTransactions || saferDispatchedTransactionsAnalyticsOnly ? new Proxy(aTr, freezeUnsafeTransactionProperties({
|
|
24
25
|
dispatchAnalyticsEvent,
|
|
25
|
-
pluginKey: self.key
|
|
26
|
+
pluginKey: self.key,
|
|
27
|
+
analyticsOnly: saferDispatchedTransactionsAnalyticsOnly
|
|
26
28
|
})) : aTr;
|
|
27
29
|
const shouldTrackTransactions = transactionTracker === null || transactionTracker === void 0 ? void 0 : transactionTracker.shouldTrackTransaction(transactionTracking);
|
|
28
30
|
|
|
@@ -7,7 +7,8 @@ const isReadOnlyProperty = prop => ['doc', 'docs', 'steps', 'selection'].include
|
|
|
7
7
|
|
|
8
8
|
export const freezeUnsafeTransactionProperties = ({
|
|
9
9
|
dispatchAnalyticsEvent,
|
|
10
|
-
pluginKey
|
|
10
|
+
pluginKey,
|
|
11
|
+
analyticsOnly
|
|
11
12
|
}) => {
|
|
12
13
|
const isUnsafe = () => {
|
|
13
14
|
if (dispatchAnalyticsEvent) {
|
|
@@ -17,11 +18,16 @@ export const freezeUnsafeTransactionProperties = ({
|
|
|
17
18
|
eventType: EVENT_TYPE.OPERATIONAL,
|
|
18
19
|
attributes: {
|
|
19
20
|
pluginKey: pluginKey || 'unknown'
|
|
21
|
+
},
|
|
22
|
+
nonPrivacySafeAttributes: {
|
|
23
|
+
stack: new Error().stack
|
|
20
24
|
}
|
|
21
25
|
});
|
|
22
26
|
}
|
|
23
27
|
|
|
24
|
-
|
|
28
|
+
if (!analyticsOnly) {
|
|
29
|
+
throw new Error(UNSAFE_PROPERTY_SET_ERROR);
|
|
30
|
+
}
|
|
25
31
|
};
|
|
26
32
|
|
|
27
33
|
return {
|
package/dist/es2019/version.json
CHANGED
|
@@ -97,8 +97,10 @@ export var ErrorBoundaryWithEditorView = /*#__PURE__*/function (_React$Component
|
|
|
97
97
|
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
98
98
|
eventType: EVENT_TYPE.OPERATIONAL,
|
|
99
99
|
attributes: {
|
|
100
|
-
errorStack: errorStack,
|
|
101
100
|
errorId: sharedId
|
|
101
|
+
},
|
|
102
|
+
nonPrivacySafeAttributes: {
|
|
103
|
+
errorStack: errorStack
|
|
102
104
|
}
|
|
103
105
|
});
|
|
104
106
|
|
|
@@ -354,9 +354,10 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
|
|
|
354
354
|
|
|
355
355
|
var nodes = findChangedNodesFromTransaction(unsafeTransaction);
|
|
356
356
|
var changedNodesValid = validateNodes(nodes);
|
|
357
|
-
var transaction = _this.featureFlags.saferDispatchedTransactions ? new Proxy(unsafeTransaction, freezeUnsafeTransactionProperties({
|
|
357
|
+
var transaction = _this.featureFlags.saferDispatchedTransactions || _this.featureFlags.saferDispatchedTransactionsAnalyticsOnly ? new Proxy(unsafeTransaction, freezeUnsafeTransactionProperties({
|
|
358
358
|
dispatchAnalyticsEvent: _this.dispatchAnalyticsEvent,
|
|
359
|
-
pluginKey: 'unknown-reacteditorview'
|
|
359
|
+
pluginKey: 'unknown-reacteditorview',
|
|
360
|
+
analyticsOnly: _this.featureFlags.saferDispatchedTransactionsAnalyticsOnly
|
|
360
361
|
})) : unsafeTransaction;
|
|
361
362
|
|
|
362
363
|
if (changedNodesValid) {
|
|
@@ -106,7 +106,8 @@ export function createPMPlugins(config) {
|
|
|
106
106
|
_performanceTracking$2 = performanceTracking.transactionTracking,
|
|
107
107
|
transactionTracking = _performanceTracking$2 === void 0 ? TRACKING_DEFAULT : _performanceTracking$2;
|
|
108
108
|
var saferDispatchedTransactions = featureFlags.saferDispatchedTransactions;
|
|
109
|
-
var
|
|
109
|
+
var saferDispatchedTransactionsAnalyticsOnly = featureFlags.saferDispatchedTransactionsAnalyticsOnly;
|
|
110
|
+
var useInstrumentedPlugin = uiTracking.enabled || transactionTracking.enabled || saferDispatchedTransactions || saferDispatchedTransactionsAnalyticsOnly;
|
|
110
111
|
|
|
111
112
|
if (process.env.NODE_ENV === 'development' && transactionTracking.enabled && !transactionTracker) {
|
|
112
113
|
// eslint-disable-next-line no-console
|
|
@@ -118,6 +119,7 @@ export function createPMPlugins(config) {
|
|
|
118
119
|
uiTracking: uiTracking,
|
|
119
120
|
transactionTracking: transactionTracking,
|
|
120
121
|
saferDispatchedTransactions: saferDispatchedTransactions,
|
|
122
|
+
saferDispatchedTransactionsAnalyticsOnly: saferDispatchedTransactionsAnalyticsOnly,
|
|
121
123
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
122
124
|
}, transactionTracker);
|
|
123
125
|
} : function (plugin) {
|
package/dist/esm/editor.js
CHANGED
|
@@ -401,6 +401,8 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
401
401
|
}, {
|
|
402
402
|
key: "deprecationWarnings",
|
|
403
403
|
value: function deprecationWarnings(props) {
|
|
404
|
+
var _props$allowTextColor;
|
|
405
|
+
|
|
404
406
|
if (process.env.NODE_ENV === 'production') {
|
|
405
407
|
return;
|
|
406
408
|
}
|
|
@@ -433,6 +435,11 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
433
435
|
// eslint-disable-next-line no-console
|
|
434
436
|
console.warn("Advanced table options are deprecated (except isHeaderRowRequired) to continue using advanced table features use - <Editor allowTables={{ advanced: true }} /> [Will be changed in editor-core@".concat(nextVersion, "]"));
|
|
435
437
|
}
|
|
438
|
+
|
|
439
|
+
if (props.hasOwnProperty('allowTextColor') && typeof props.allowTextColor !== 'boolean' && (props === null || props === void 0 ? void 0 : (_props$allowTextColor = props.allowTextColor) === null || _props$allowTextColor === void 0 ? void 0 : _props$allowTextColor.allowMoreTextColors) !== undefined) {
|
|
440
|
+
// eslint-disable-next-line no-console
|
|
441
|
+
console.warn("\"allowMoreTextColors\" field of \"allowTextColor\" property is deprecated. It will be removedin editor-core@".concat(nextVersion, ". The color palette now shows more colors by default."));
|
|
442
|
+
}
|
|
436
443
|
}
|
|
437
444
|
}, {
|
|
438
445
|
key: "onEditorDestroyed",
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Selection, TextSelection } from 'prosemirror-state';
|
|
2
|
+
|
|
3
|
+
// We should override default behaviour when selection spans node depths or
|
|
4
|
+
// ends at a node junction
|
|
5
|
+
var shouldMoveCursorAfterDelete = function shouldMoveCursorAfterDelete(state) {
|
|
6
|
+
var _state$selection = state.selection,
|
|
7
|
+
$from = _state$selection.$from,
|
|
8
|
+
$to = _state$selection.$to;
|
|
9
|
+
var nodeRange = $from.blockRange($to);
|
|
10
|
+
|
|
11
|
+
if (!nodeRange) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
var hasSameAncestor = $from.depth === $to.depth && $from.depth - 1 === nodeRange.depth;
|
|
16
|
+
var toPositionHasNodeAfter = !!$to.nodeAfter;
|
|
17
|
+
|
|
18
|
+
if (hasSameAncestor || toPositionHasNodeAfter) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return true;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Fixes cursor position after delete for list/task in panel and table
|
|
26
|
+
*
|
|
27
|
+
* ED-13873 fixes a bug where after deleting a list the cursor would move
|
|
28
|
+
* to the cell to the right. Uses setSelection to position the cursor as expected after deleting.
|
|
29
|
+
*
|
|
30
|
+
* @param state EditorState<any>
|
|
31
|
+
* @param dispatch CommandDispatch
|
|
32
|
+
* @returns boolean
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
export var deleteAndMoveCursor = function deleteAndMoveCursor(state, dispatch) {
|
|
37
|
+
if (state.selection.empty || !(state.selection instanceof TextSelection)) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!shouldMoveCursorAfterDelete(state)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var tr = state.tr;
|
|
46
|
+
tr.deleteSelection(); // Make sure the next position is not out of boundaries
|
|
47
|
+
|
|
48
|
+
var previousPosition = Math.min(Math.max(state.selection.$from.pos, 0), tr.doc.content.size); // Override default delete behaviour that moves the cursor to first suitable position after selection (postive bias).
|
|
49
|
+
// See. selectionToInsertionEnd. We will override behavior with negative bias (search for suitable cursor position backwards).
|
|
50
|
+
|
|
51
|
+
tr.setSelection(Selection.near(tr.doc.resolve(previousPosition), -1));
|
|
52
|
+
|
|
53
|
+
if (dispatch) {
|
|
54
|
+
dispatch(tr.scrollIntoView());
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return true;
|
|
58
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { cleanUpAtTheStartOfDocument, insertBlockType, insertBlockTypesWithAnalytics, setBlockType, setBlockTypeWithAnalytics, setHeading, setHeadingWithAnalytics, setNormalText, setNormalTextWithAnalytics } from './block-type';
|
|
2
2
|
export { insertBlock } from './insert-block';
|
|
3
|
-
export { isConvertableToCodeBlock, transformToCodeBlockAction } from './transform-to-code-block';
|
|
3
|
+
export { isConvertableToCodeBlock, transformToCodeBlockAction } from './transform-to-code-block';
|
|
4
|
+
export { deleteAndMoveCursor } from './delete-and-move-cursor';
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { redo, undo } from 'prosemirror-history';
|
|
2
|
+
import { chainCommands } from 'prosemirror-commands';
|
|
2
3
|
import * as keymaps from '../../../keymaps';
|
|
3
4
|
import * as commands from '../../../commands';
|
|
4
5
|
import * as blockTypes from '../types';
|
|
5
6
|
import { keymap } from '../../../utils/keymap';
|
|
6
|
-
import { cleanUpAtTheStartOfDocument, insertBlockTypesWithAnalytics } from '../commands';
|
|
7
|
+
import { cleanUpAtTheStartOfDocument, deleteAndMoveCursor, insertBlockTypesWithAnalytics } from '../commands';
|
|
7
8
|
import { deleteEmptyParagraphAndMoveBlockUp } from '../../../utils/commands';
|
|
8
9
|
import { INPUT_METHOD } from '../../analytics';
|
|
9
10
|
import { isNodeAWrappingBlockNode } from '../utils';
|
|
11
|
+
var backspace = chainCommands(cleanUpAtTheStartOfDocument, deleteAndMoveCursor);
|
|
12
|
+
var del = chainCommands(deleteEmptyParagraphAndMoveBlockUp(isNodeAWrappingBlockNode), deleteAndMoveCursor);
|
|
10
13
|
export default function keymapPlugin(schema, featureFlags) {
|
|
11
14
|
var list = {};
|
|
12
15
|
keymaps.bindKeymapWithCommand(keymaps.insertNewLine.common, commands.insertNewLineWithAnalytics, list);
|
|
@@ -14,9 +17,9 @@ export default function keymapPlugin(schema, featureFlags) {
|
|
|
14
17
|
keymaps.bindKeymapWithCommand(keymaps.moveDown.common, commands.createNewParagraphBelow, list);
|
|
15
18
|
keymaps.bindKeymapWithCommand(keymaps.findKeyMapForBrowser(keymaps.redo), redo, list);
|
|
16
19
|
keymaps.bindKeymapWithCommand(keymaps.undo.common, undo, list);
|
|
17
|
-
keymaps.bindKeymapWithCommand(keymaps.backspace.common,
|
|
18
|
-
keymaps.bindKeymapWithCommand(keymaps.deleteKey.common,
|
|
19
|
-
keymaps.bindKeymapWithCommand(keymaps.forwardDelete.mac,
|
|
20
|
+
keymaps.bindKeymapWithCommand(keymaps.backspace.common, backspace, list);
|
|
21
|
+
keymaps.bindKeymapWithCommand(keymaps.deleteKey.common, del, list);
|
|
22
|
+
keymaps.bindKeymapWithCommand(keymaps.forwardDelete.mac, del, list);
|
|
20
23
|
|
|
21
24
|
if (schema.nodes[blockTypes.BLOCK_QUOTE.nodeName]) {
|
|
22
25
|
keymaps.bindKeymapWithCommand(keymaps.findShortcutByKeymap(keymaps.toggleBlockQuote), insertBlockTypesWithAnalytics(blockTypes.BLOCK_QUOTE.name, INPUT_METHOD.KEYBOARD), list);
|