@atlaskit/editor-core 205.3.2 → 205.4.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 +12 -0
- package/dist/cjs/actions/index.js +12 -1
- package/dist/cjs/create-editor/ReactEditorView.js +47 -10
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/actions/index.js +13 -2
- package/dist/es2019/create-editor/ReactEditorView.js +47 -10
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/actions/index.js +12 -1
- package/dist/esm/create-editor/ReactEditorView.js +47 -10
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/actions/index.d.ts +3 -1
- package/dist/types-ts4.5/actions/index.d.ts +3 -1
- package/package.json +8 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 205.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#141575](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/141575)
|
|
8
|
+
[`53faa261e39a6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/53faa261e39a6) -
|
|
9
|
+
Adds support for overriding language names in the code block language list.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 205.3.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -17,6 +17,7 @@ var _analytics2 = require("@atlaskit/editor-common/utils/analytics");
|
|
|
17
17
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
18
18
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
19
19
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
20
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
20
21
|
var _action = require("../utils/action");
|
|
21
22
|
var _deprecationWarnings = _interopRequireDefault(require("../utils/deprecation-warnings"));
|
|
22
23
|
var _nodesByLocalIds = require("../utils/nodes-by-localIds");
|
|
@@ -188,11 +189,21 @@ var EditorActions = exports.default = /*#__PURE__*/function () {
|
|
|
188
189
|
}, {
|
|
189
190
|
key: "focus",
|
|
190
191
|
value: function focus() {
|
|
192
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
193
|
+
scrollIntoView: true
|
|
194
|
+
},
|
|
195
|
+
scrollIntoView = _ref2.scrollIntoView;
|
|
191
196
|
if (!this.editorView || this.editorView.hasFocus()) {
|
|
192
197
|
return false;
|
|
193
198
|
}
|
|
194
199
|
this.editorView.focus();
|
|
195
|
-
|
|
200
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_reduce_scroll_jump_on_editor_start')) {
|
|
201
|
+
if (scrollIntoView !== null && scrollIntoView !== void 0 ? scrollIntoView : true) {
|
|
202
|
+
this.editorView.dispatch(this.editorView.state.tr.scrollIntoView());
|
|
203
|
+
}
|
|
204
|
+
} else {
|
|
205
|
+
this.editorView.dispatch(this.editorView.state.tr.scrollIntoView());
|
|
206
|
+
}
|
|
196
207
|
return true;
|
|
197
208
|
}
|
|
198
209
|
}, {
|
|
@@ -55,7 +55,7 @@ var focusElementOutsideEditor = function focusElementOutsideEditor() {
|
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
function ReactEditorView(props) {
|
|
58
|
-
var _pluginInjectionAPI$c, _media, _linking, _props$render, _props$render2;
|
|
58
|
+
var _pluginInjectionAPI$c, _media, _linking, _document$querySelect, _props$render, _props$render2;
|
|
59
59
|
var preset = props.preset,
|
|
60
60
|
_props$editorProps = props.editorProps,
|
|
61
61
|
nextAppearance = _props$editorProps.appearance,
|
|
@@ -497,20 +497,46 @@ function ReactEditorView(props) {
|
|
|
497
497
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
498
498
|
editorView = _useState4[0],
|
|
499
499
|
setEditorView = _useState4[1];
|
|
500
|
+
var originalScrollToRestore = _react.default.useRef((0, _isFullPage.isFullPage)(props.editorProps.appearance) && (0, _platformFeatureFlags.fg)('platform_editor_reduce_scroll_jump_on_editor_start') ? (_document$querySelect = document.querySelector('[data-editor-scroll-container]')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.scrollTop : undefined);
|
|
501
|
+
var mitigateScrollJump =
|
|
502
|
+
// The feature gate here is being used to avoid potential bugs with the scroll restoration code
|
|
503
|
+
// moving it to the end of the expression negates the point of the feature gate
|
|
504
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
505
|
+
(0, _isFullPage.isFullPage)(props.editorProps.appearance) && (0, _platformFeatureFlags.fg)('platform_editor_reduce_scroll_jump_on_editor_start') && originalScrollToRestore.current && originalScrollToRestore.current !== 0;
|
|
500
506
|
(0, _react.useLayoutEffect)(function () {
|
|
501
507
|
var _editorView$props$edi, _editorView$props;
|
|
502
508
|
if (shouldFocus && editorView !== null && editorView !== void 0 && (_editorView$props$edi = (_editorView$props = editorView.props).editable) !== null && _editorView$props$edi !== void 0 && _editorView$props$edi.call(_editorView$props, editorView.state) && (0, _platformFeatureFlags.fg)('platform_editor_react_18_autofocus_fix')) {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
509
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_reduce_scroll_jump_on_editor_start')) {
|
|
510
|
+
if (!mitigateScrollJump) {
|
|
511
|
+
var liveDocWithContent = __livePage && !(0, _document.isEmptyDocument)(editorView.state.doc);
|
|
512
|
+
if (liveDocWithContent && (0, _platformFeatureFlags.fg)('platform_editor_no_cursor_on_live_doc_init')) {
|
|
513
|
+
focusElementOutsideEditor();
|
|
514
|
+
} else {
|
|
515
|
+
focusTimeoutId.current = (0, _handleEditorFocus.handleEditorFocus)(editorView);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
506
518
|
} else {
|
|
507
|
-
|
|
519
|
+
var _liveDocWithContent = __livePage && !(0, _document.isEmptyDocument)(editorView.state.doc);
|
|
520
|
+
if (_liveDocWithContent && (0, _platformFeatureFlags.fg)('platform_editor_no_cursor_on_live_doc_init')) {
|
|
521
|
+
focusElementOutsideEditor();
|
|
522
|
+
} else {
|
|
523
|
+
focusTimeoutId.current = (0, _handleEditorFocus.handleEditorFocus)(editorView);
|
|
524
|
+
}
|
|
508
525
|
}
|
|
509
526
|
}
|
|
510
|
-
}, [editorView, shouldFocus, __livePage]);
|
|
527
|
+
}, [editorView, shouldFocus, __livePage, mitigateScrollJump]);
|
|
511
528
|
var handleEditorViewRef = (0, _react.useCallback)(function (node) {
|
|
512
529
|
if (!viewRef.current && node) {
|
|
513
530
|
var view = createEditorView(node);
|
|
531
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_reduce_scroll_jump_on_editor_start')) {
|
|
532
|
+
if (mitigateScrollJump) {
|
|
533
|
+
var scrollElement = document.querySelector('[data-editor-scroll-container]');
|
|
534
|
+
scrollElement === null || scrollElement === void 0 || scrollElement.scrollTo({
|
|
535
|
+
top: originalScrollToRestore.current,
|
|
536
|
+
behavior: 'instant'
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
}
|
|
514
540
|
onEditorCreated({
|
|
515
541
|
view: view,
|
|
516
542
|
config: config.current,
|
|
@@ -532,9 +558,20 @@ function ReactEditorView(props) {
|
|
|
532
558
|
setEditorView(view);
|
|
533
559
|
});
|
|
534
560
|
} else {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
561
|
+
if (shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
562
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_reduce_scroll_jump_on_editor_start')) {
|
|
563
|
+
if (!mitigateScrollJump) {
|
|
564
|
+
var isLivePageWithContent = __livePage && !(0, _document.isEmptyDocument)(view.state.doc) && (0, _platformFeatureFlags.fg)('platform_editor_no_cursor_on_live_doc_init');
|
|
565
|
+
if (!isLivePageWithContent && shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
566
|
+
focusTimeoutId.current = (0, _handleEditorFocus.handleEditorFocus)(view);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
} else {
|
|
570
|
+
var _isLivePageWithContent = __livePage && !(0, _document.isEmptyDocument)(view.state.doc) && (0, _platformFeatureFlags.fg)('platform_editor_no_cursor_on_live_doc_init');
|
|
571
|
+
if (!_isLivePageWithContent && shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
572
|
+
focusTimeoutId.current = (0, _handleEditorFocus.handleEditorFocus)(view);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
538
575
|
}
|
|
539
576
|
|
|
540
577
|
// Force React to re-render so consumers get a reference to the editor view
|
|
@@ -562,7 +599,7 @@ function ReactEditorView(props) {
|
|
|
562
599
|
}
|
|
563
600
|
viewRef.current = undefined;
|
|
564
601
|
}
|
|
565
|
-
}, [createEditorView, onEditorCreated, eventDispatcher, shouldFocus, __livePage, onEditorDestroyed, handleAnalyticsEvent]);
|
|
602
|
+
}, [createEditorView, onEditorCreated, eventDispatcher, shouldFocus, __livePage, onEditorDestroyed, handleAnalyticsEvent, mitigateScrollJump]);
|
|
566
603
|
var createEditor = (0, _react.useCallback)(function (assistiveLabel, assistiveDescribedBy) {
|
|
567
604
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
568
605
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
@@ -6,6 +6,7 @@ import { analyticsEventKey } from '@atlaskit/editor-common/utils/analytics';
|
|
|
6
6
|
import { Node } from '@atlaskit/editor-prosemirror/model';
|
|
7
7
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
8
|
import { findParentNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
10
|
import { getEditorValueWithMedia } from '../utils/action';
|
|
10
11
|
import deprecationWarnings from '../utils/deprecation-warnings';
|
|
11
12
|
import { findNodePosByFragmentLocalIds } from '../utils/nodes-by-localIds';
|
|
@@ -130,12 +131,22 @@ export default class EditorActions {
|
|
|
130
131
|
}
|
|
131
132
|
//#endregion
|
|
132
133
|
|
|
133
|
-
focus(
|
|
134
|
+
focus({
|
|
135
|
+
scrollIntoView
|
|
136
|
+
} = {
|
|
137
|
+
scrollIntoView: true
|
|
138
|
+
}) {
|
|
134
139
|
if (!this.editorView || this.editorView.hasFocus()) {
|
|
135
140
|
return false;
|
|
136
141
|
}
|
|
137
142
|
this.editorView.focus();
|
|
138
|
-
|
|
143
|
+
if (fg('platform_editor_reduce_scroll_jump_on_editor_start')) {
|
|
144
|
+
if (scrollIntoView !== null && scrollIntoView !== void 0 ? scrollIntoView : true) {
|
|
145
|
+
this.editorView.dispatch(this.editorView.state.tr.scrollIntoView());
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
this.editorView.dispatch(this.editorView.state.tr.scrollIntoView());
|
|
149
|
+
}
|
|
139
150
|
return true;
|
|
140
151
|
}
|
|
141
152
|
blur() {
|
|
@@ -40,7 +40,7 @@ const focusElementOutsideEditor = () => {
|
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
export function ReactEditorView(props) {
|
|
43
|
-
var _pluginInjectionAPI$c, _pluginInjectionAPI$c2, _pluginInjectionAPI$c3, _media, _linking, _linking$smartLinks, _props$render, _props$render2;
|
|
43
|
+
var _pluginInjectionAPI$c, _pluginInjectionAPI$c2, _pluginInjectionAPI$c3, _media, _linking, _linking$smartLinks, _document$querySelect, _props$render, _props$render2;
|
|
44
44
|
const {
|
|
45
45
|
preset,
|
|
46
46
|
editorProps: {
|
|
@@ -467,20 +467,46 @@ export function ReactEditorView(props) {
|
|
|
467
467
|
return view;
|
|
468
468
|
}, [getDirectEditorProps, dispatchAnalyticsEvent]);
|
|
469
469
|
const [editorView, setEditorView] = useState(undefined);
|
|
470
|
+
const originalScrollToRestore = React.useRef(isFullPage(props.editorProps.appearance) && fg('platform_editor_reduce_scroll_jump_on_editor_start') ? (_document$querySelect = document.querySelector('[data-editor-scroll-container]')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.scrollTop : undefined);
|
|
471
|
+
const mitigateScrollJump =
|
|
472
|
+
// The feature gate here is being used to avoid potential bugs with the scroll restoration code
|
|
473
|
+
// moving it to the end of the expression negates the point of the feature gate
|
|
474
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
475
|
+
isFullPage(props.editorProps.appearance) && fg('platform_editor_reduce_scroll_jump_on_editor_start') && originalScrollToRestore.current && originalScrollToRestore.current !== 0;
|
|
470
476
|
useLayoutEffect(() => {
|
|
471
477
|
var _editorView$props$edi, _editorView$props;
|
|
472
478
|
if (shouldFocus && editorView !== null && editorView !== void 0 && (_editorView$props$edi = (_editorView$props = editorView.props).editable) !== null && _editorView$props$edi !== void 0 && _editorView$props$edi.call(_editorView$props, editorView.state) && fg('platform_editor_react_18_autofocus_fix')) {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
479
|
+
if (fg('platform_editor_reduce_scroll_jump_on_editor_start')) {
|
|
480
|
+
if (!mitigateScrollJump) {
|
|
481
|
+
const liveDocWithContent = __livePage && !isEmptyDocument(editorView.state.doc);
|
|
482
|
+
if (liveDocWithContent && fg('platform_editor_no_cursor_on_live_doc_init')) {
|
|
483
|
+
focusElementOutsideEditor();
|
|
484
|
+
} else {
|
|
485
|
+
focusTimeoutId.current = handleEditorFocus(editorView);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
476
488
|
} else {
|
|
477
|
-
|
|
489
|
+
const liveDocWithContent = __livePage && !isEmptyDocument(editorView.state.doc);
|
|
490
|
+
if (liveDocWithContent && fg('platform_editor_no_cursor_on_live_doc_init')) {
|
|
491
|
+
focusElementOutsideEditor();
|
|
492
|
+
} else {
|
|
493
|
+
focusTimeoutId.current = handleEditorFocus(editorView);
|
|
494
|
+
}
|
|
478
495
|
}
|
|
479
496
|
}
|
|
480
|
-
}, [editorView, shouldFocus, __livePage]);
|
|
497
|
+
}, [editorView, shouldFocus, __livePage, mitigateScrollJump]);
|
|
481
498
|
const handleEditorViewRef = useCallback(node => {
|
|
482
499
|
if (!viewRef.current && node) {
|
|
483
500
|
const view = createEditorView(node);
|
|
501
|
+
if (fg('platform_editor_reduce_scroll_jump_on_editor_start')) {
|
|
502
|
+
if (mitigateScrollJump) {
|
|
503
|
+
const scrollElement = document.querySelector('[data-editor-scroll-container]');
|
|
504
|
+
scrollElement === null || scrollElement === void 0 ? void 0 : scrollElement.scrollTo({
|
|
505
|
+
top: originalScrollToRestore.current,
|
|
506
|
+
behavior: 'instant'
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
}
|
|
484
510
|
onEditorCreated({
|
|
485
511
|
view,
|
|
486
512
|
config: config.current,
|
|
@@ -500,9 +526,20 @@ export function ReactEditorView(props) {
|
|
|
500
526
|
setEditorView(view);
|
|
501
527
|
});
|
|
502
528
|
} else {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
529
|
+
if (shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
530
|
+
if (fg('platform_editor_reduce_scroll_jump_on_editor_start')) {
|
|
531
|
+
if (!mitigateScrollJump) {
|
|
532
|
+
const isLivePageWithContent = __livePage && !isEmptyDocument(view.state.doc) && fg('platform_editor_no_cursor_on_live_doc_init');
|
|
533
|
+
if (!isLivePageWithContent && shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
534
|
+
focusTimeoutId.current = handleEditorFocus(view);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
} else {
|
|
538
|
+
const isLivePageWithContent = __livePage && !isEmptyDocument(view.state.doc) && fg('platform_editor_no_cursor_on_live_doc_init');
|
|
539
|
+
if (!isLivePageWithContent && shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
540
|
+
focusTimeoutId.current = handleEditorFocus(view);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
506
543
|
}
|
|
507
544
|
|
|
508
545
|
// Force React to re-render so consumers get a reference to the editor view
|
|
@@ -530,7 +567,7 @@ export function ReactEditorView(props) {
|
|
|
530
567
|
}
|
|
531
568
|
viewRef.current = undefined;
|
|
532
569
|
}
|
|
533
|
-
}, [createEditorView, onEditorCreated, eventDispatcher, shouldFocus, __livePage, onEditorDestroyed, handleAnalyticsEvent]);
|
|
570
|
+
}, [createEditorView, onEditorCreated, eventDispatcher, shouldFocus, __livePage, onEditorDestroyed, handleAnalyticsEvent, mitigateScrollJump]);
|
|
534
571
|
const createEditor = useCallback((assistiveLabel, assistiveDescribedBy) => {
|
|
535
572
|
return /*#__PURE__*/React.createElement("div", {
|
|
536
573
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = "@atlaskit/editor-core";
|
|
2
|
-
export const version = "205.
|
|
2
|
+
export const version = "205.4.0";
|
|
@@ -10,6 +10,7 @@ import { analyticsEventKey } from '@atlaskit/editor-common/utils/analytics';
|
|
|
10
10
|
import { Node } from '@atlaskit/editor-prosemirror/model';
|
|
11
11
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
12
12
|
import { findParentNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
13
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
14
|
import { getEditorValueWithMedia } from '../utils/action';
|
|
14
15
|
import deprecationWarnings from '../utils/deprecation-warnings';
|
|
15
16
|
import { findNodePosByFragmentLocalIds } from '../utils/nodes-by-localIds';
|
|
@@ -182,11 +183,21 @@ var EditorActions = /*#__PURE__*/function () {
|
|
|
182
183
|
}, {
|
|
183
184
|
key: "focus",
|
|
184
185
|
value: function focus() {
|
|
186
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
187
|
+
scrollIntoView: true
|
|
188
|
+
},
|
|
189
|
+
scrollIntoView = _ref2.scrollIntoView;
|
|
185
190
|
if (!this.editorView || this.editorView.hasFocus()) {
|
|
186
191
|
return false;
|
|
187
192
|
}
|
|
188
193
|
this.editorView.focus();
|
|
189
|
-
|
|
194
|
+
if (fg('platform_editor_reduce_scroll_jump_on_editor_start')) {
|
|
195
|
+
if (scrollIntoView !== null && scrollIntoView !== void 0 ? scrollIntoView : true) {
|
|
196
|
+
this.editorView.dispatch(this.editorView.state.tr.scrollIntoView());
|
|
197
|
+
}
|
|
198
|
+
} else {
|
|
199
|
+
this.editorView.dispatch(this.editorView.state.tr.scrollIntoView());
|
|
200
|
+
}
|
|
190
201
|
return true;
|
|
191
202
|
}
|
|
192
203
|
}, {
|
|
@@ -44,7 +44,7 @@ var focusElementOutsideEditor = function focusElementOutsideEditor() {
|
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
export function ReactEditorView(props) {
|
|
47
|
-
var _pluginInjectionAPI$c, _media, _linking, _props$render, _props$render2;
|
|
47
|
+
var _pluginInjectionAPI$c, _media, _linking, _document$querySelect, _props$render, _props$render2;
|
|
48
48
|
var preset = props.preset,
|
|
49
49
|
_props$editorProps = props.editorProps,
|
|
50
50
|
nextAppearance = _props$editorProps.appearance,
|
|
@@ -486,20 +486,46 @@ export function ReactEditorView(props) {
|
|
|
486
486
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
487
487
|
editorView = _useState4[0],
|
|
488
488
|
setEditorView = _useState4[1];
|
|
489
|
+
var originalScrollToRestore = React.useRef(isFullPage(props.editorProps.appearance) && fg('platform_editor_reduce_scroll_jump_on_editor_start') ? (_document$querySelect = document.querySelector('[data-editor-scroll-container]')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.scrollTop : undefined);
|
|
490
|
+
var mitigateScrollJump =
|
|
491
|
+
// The feature gate here is being used to avoid potential bugs with the scroll restoration code
|
|
492
|
+
// moving it to the end of the expression negates the point of the feature gate
|
|
493
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
494
|
+
isFullPage(props.editorProps.appearance) && fg('platform_editor_reduce_scroll_jump_on_editor_start') && originalScrollToRestore.current && originalScrollToRestore.current !== 0;
|
|
489
495
|
useLayoutEffect(function () {
|
|
490
496
|
var _editorView$props$edi, _editorView$props;
|
|
491
497
|
if (shouldFocus && editorView !== null && editorView !== void 0 && (_editorView$props$edi = (_editorView$props = editorView.props).editable) !== null && _editorView$props$edi !== void 0 && _editorView$props$edi.call(_editorView$props, editorView.state) && fg('platform_editor_react_18_autofocus_fix')) {
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
498
|
+
if (fg('platform_editor_reduce_scroll_jump_on_editor_start')) {
|
|
499
|
+
if (!mitigateScrollJump) {
|
|
500
|
+
var liveDocWithContent = __livePage && !isEmptyDocument(editorView.state.doc);
|
|
501
|
+
if (liveDocWithContent && fg('platform_editor_no_cursor_on_live_doc_init')) {
|
|
502
|
+
focusElementOutsideEditor();
|
|
503
|
+
} else {
|
|
504
|
+
focusTimeoutId.current = handleEditorFocus(editorView);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
495
507
|
} else {
|
|
496
|
-
|
|
508
|
+
var _liveDocWithContent = __livePage && !isEmptyDocument(editorView.state.doc);
|
|
509
|
+
if (_liveDocWithContent && fg('platform_editor_no_cursor_on_live_doc_init')) {
|
|
510
|
+
focusElementOutsideEditor();
|
|
511
|
+
} else {
|
|
512
|
+
focusTimeoutId.current = handleEditorFocus(editorView);
|
|
513
|
+
}
|
|
497
514
|
}
|
|
498
515
|
}
|
|
499
|
-
}, [editorView, shouldFocus, __livePage]);
|
|
516
|
+
}, [editorView, shouldFocus, __livePage, mitigateScrollJump]);
|
|
500
517
|
var handleEditorViewRef = useCallback(function (node) {
|
|
501
518
|
if (!viewRef.current && node) {
|
|
502
519
|
var view = createEditorView(node);
|
|
520
|
+
if (fg('platform_editor_reduce_scroll_jump_on_editor_start')) {
|
|
521
|
+
if (mitigateScrollJump) {
|
|
522
|
+
var scrollElement = document.querySelector('[data-editor-scroll-container]');
|
|
523
|
+
scrollElement === null || scrollElement === void 0 || scrollElement.scrollTo({
|
|
524
|
+
top: originalScrollToRestore.current,
|
|
525
|
+
behavior: 'instant'
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
}
|
|
503
529
|
onEditorCreated({
|
|
504
530
|
view: view,
|
|
505
531
|
config: config.current,
|
|
@@ -521,9 +547,20 @@ export function ReactEditorView(props) {
|
|
|
521
547
|
setEditorView(view);
|
|
522
548
|
});
|
|
523
549
|
} else {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
550
|
+
if (shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
551
|
+
if (fg('platform_editor_reduce_scroll_jump_on_editor_start')) {
|
|
552
|
+
if (!mitigateScrollJump) {
|
|
553
|
+
var isLivePageWithContent = __livePage && !isEmptyDocument(view.state.doc) && fg('platform_editor_no_cursor_on_live_doc_init');
|
|
554
|
+
if (!isLivePageWithContent && shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
555
|
+
focusTimeoutId.current = handleEditorFocus(view);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
} else {
|
|
559
|
+
var _isLivePageWithContent = __livePage && !isEmptyDocument(view.state.doc) && fg('platform_editor_no_cursor_on_live_doc_init');
|
|
560
|
+
if (!_isLivePageWithContent && shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
561
|
+
focusTimeoutId.current = handleEditorFocus(view);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
527
564
|
}
|
|
528
565
|
|
|
529
566
|
// Force React to re-render so consumers get a reference to the editor view
|
|
@@ -551,7 +588,7 @@ export function ReactEditorView(props) {
|
|
|
551
588
|
}
|
|
552
589
|
viewRef.current = undefined;
|
|
553
590
|
}
|
|
554
|
-
}, [createEditorView, onEditorCreated, eventDispatcher, shouldFocus, __livePage, onEditorDestroyed, handleAnalyticsEvent]);
|
|
591
|
+
}, [createEditorView, onEditorCreated, eventDispatcher, shouldFocus, __livePage, onEditorDestroyed, handleAnalyticsEvent, mitigateScrollJump]);
|
|
555
592
|
var createEditor = useCallback(function (assistiveLabel, assistiveDescribedBy) {
|
|
556
593
|
return /*#__PURE__*/React.createElement("div", {
|
|
557
594
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export var name = "@atlaskit/editor-core";
|
|
2
|
-
export var version = "205.
|
|
2
|
+
export var version = "205.4.0";
|
|
@@ -26,7 +26,9 @@ export default class EditorActions<T = any> implements EditorActionsOptions<T> {
|
|
|
26
26
|
_privateUnregisterEditor(): void;
|
|
27
27
|
_privateSubscribe(cb: ContextUpdateHandler): void;
|
|
28
28
|
_privateUnsubscribe(cb: ContextUpdateHandler): void;
|
|
29
|
-
focus(
|
|
29
|
+
focus({ scrollIntoView }?: {
|
|
30
|
+
scrollIntoView: boolean;
|
|
31
|
+
}): boolean;
|
|
30
32
|
blur(): boolean;
|
|
31
33
|
clear(): boolean;
|
|
32
34
|
/**
|
|
@@ -26,7 +26,9 @@ export default class EditorActions<T = any> implements EditorActionsOptions<T> {
|
|
|
26
26
|
_privateUnregisterEditor(): void;
|
|
27
27
|
_privateSubscribe(cb: ContextUpdateHandler): void;
|
|
28
28
|
_privateUnsubscribe(cb: ContextUpdateHandler): void;
|
|
29
|
-
focus(
|
|
29
|
+
focus({ scrollIntoView }?: {
|
|
30
|
+
scrollIntoView: boolean;
|
|
31
|
+
}): boolean;
|
|
30
32
|
blur(): boolean;
|
|
31
33
|
clear(): boolean;
|
|
32
34
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-core",
|
|
3
|
-
"version": "205.
|
|
3
|
+
"version": "205.4.0",
|
|
4
4
|
"description": "A package contains Atlassian editor core functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -54,14 +54,14 @@
|
|
|
54
54
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
55
55
|
"@atlaskit/editor-shared-styles": "^3.4.0",
|
|
56
56
|
"@atlaskit/emoji": "^69.0.0",
|
|
57
|
-
"@atlaskit/icon": "^25.
|
|
57
|
+
"@atlaskit/icon": "^25.6.0",
|
|
58
58
|
"@atlaskit/media-card": "^79.0.0",
|
|
59
59
|
"@atlaskit/mention": "^24.1.0",
|
|
60
60
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
61
61
|
"@atlaskit/platform-feature-flags-react": "^0.1.0",
|
|
62
62
|
"@atlaskit/react-ufo": "^3.5.0",
|
|
63
63
|
"@atlaskit/task-decision": "^19.1.0",
|
|
64
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
64
|
+
"@atlaskit/tmp-editor-statsig": "^4.8.0",
|
|
65
65
|
"@atlaskit/tokens": "^4.7.0",
|
|
66
66
|
"@atlaskit/tooltip": "^20.0.0",
|
|
67
67
|
"@atlaskit/width-detector": "^5.0.0",
|
|
@@ -101,8 +101,8 @@
|
|
|
101
101
|
"@atlaskit/media-test-helpers": "^35.0.0",
|
|
102
102
|
"@atlaskit/modal-dialog": "^14.1.0",
|
|
103
103
|
"@atlaskit/primitives": "^14.4.0",
|
|
104
|
-
"@atlaskit/renderer": "^114.
|
|
105
|
-
"@atlaskit/smart-card": "^36.
|
|
104
|
+
"@atlaskit/renderer": "^114.9.0",
|
|
105
|
+
"@atlaskit/smart-card": "^36.6.0",
|
|
106
106
|
"@atlaskit/synchrony-test-helpers": "^3.1.0",
|
|
107
107
|
"@atlaskit/toggle": "^15.0.0",
|
|
108
108
|
"@atlaskit/util-data-test": "^18.0.0",
|
|
@@ -154,6 +154,9 @@
|
|
|
154
154
|
"type": "boolean",
|
|
155
155
|
"referenceOnly": true
|
|
156
156
|
},
|
|
157
|
+
"platform_editor_reduce_scroll_jump_on_editor_start": {
|
|
158
|
+
"type": "boolean"
|
|
159
|
+
},
|
|
157
160
|
"platform_editor_fe--performance_metrics": {
|
|
158
161
|
"type": "boolean"
|
|
159
162
|
},
|
|
@@ -262,10 +265,6 @@
|
|
|
262
265
|
"type": "boolean",
|
|
263
266
|
"referenceOnly": true
|
|
264
267
|
},
|
|
265
|
-
"platform_editor_merge_unconfirmed_steps": {
|
|
266
|
-
"type": "boolean",
|
|
267
|
-
"referenceOnly": true
|
|
268
|
-
},
|
|
269
268
|
"platform_editor_catch_missing_injection_states": {
|
|
270
269
|
"type": "boolean"
|
|
271
270
|
},
|
|
@@ -565,10 +564,6 @@
|
|
|
565
564
|
"type": "boolean",
|
|
566
565
|
"referenceOnly": true
|
|
567
566
|
},
|
|
568
|
-
"platform_editor_collab_text_selection_override": {
|
|
569
|
-
"type": "boolean",
|
|
570
|
-
"referenceOnly": true
|
|
571
|
-
},
|
|
572
567
|
"platform_editor_controls_patch_2": {
|
|
573
568
|
"type": "boolean",
|
|
574
569
|
"referenceOnly": true
|