@atlaskit/editor-core 214.2.1 → 214.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/cjs/actions/index.js +3 -8
- package/dist/cjs/create-editor/ReactEditorView.js +25 -41
- package/dist/cjs/ui/Addon/ClickAreaBlock/index.js +1 -1
- package/dist/cjs/utils/findChangedNodesFromTransaction.js +3 -13
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/actions/index.js +3 -8
- package/dist/es2019/create-editor/ReactEditorView.js +21 -37
- package/dist/es2019/ui/Addon/ClickAreaBlock/index.js +1 -1
- package/dist/es2019/utils/findChangedNodesFromTransaction.js +3 -14
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/actions/index.js +3 -8
- package/dist/esm/create-editor/ReactEditorView.js +25 -41
- package/dist/esm/ui/Addon/ClickAreaBlock/index.js +1 -1
- package/dist/esm/utils/findChangedNodesFromTransaction.js +3 -14
- package/dist/esm/version-wrapper.js +1 -1
- package/package.json +2 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 214.2.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`bcadfe969f22d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/bcadfe969f22d) -
|
|
8
|
+
Cleanup editor_load_conf_collab_docs_without_checks
|
|
9
|
+
- [`3b6549e4af2db`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3b6549e4af2db) -
|
|
10
|
+
Cleanup platform_editor_reduce_scroll_jump_on_editor_start
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 214.2.2
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [`124f42c79b002`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/124f42c79b002) -
|
|
18
|
+
Clean up feature gate cc_complexit_fe_improve_node_validation
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 214.2.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -17,7 +17,6 @@ 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");
|
|
21
20
|
var _action = require("../utils/action");
|
|
22
21
|
var _deprecationWarnings = _interopRequireDefault(require("../utils/deprecation-warnings"));
|
|
23
22
|
var _nodesByLocalIds = require("../utils/nodes-by-localIds");
|
|
@@ -45,7 +44,7 @@ var fakePluginKey = {
|
|
|
45
44
|
* If you were using editorActions.getNodeByLocalId(localId) replace with:
|
|
46
45
|
const { editorApi, preset } = usePreset(...);
|
|
47
46
|
const extensionAPI = editorAPI?.extension?.actions?.api();
|
|
48
|
-
// Use nodeWithPos as desired
|
|
47
|
+
// Use nodeWithPos as desired
|
|
49
48
|
const nodeWithPos = extensionAPI.getNodeWithPosByLocalId(localId);
|
|
50
49
|
const node = nodeWithPos.node;
|
|
51
50
|
const nodePos = nodeWithPos.pos;
|
|
@@ -205,11 +204,7 @@ var EditorActions = exports.default = /*#__PURE__*/function () {
|
|
|
205
204
|
return false;
|
|
206
205
|
}
|
|
207
206
|
this.editorView.focus();
|
|
208
|
-
if (
|
|
209
|
-
if (scrollIntoView !== null && scrollIntoView !== void 0 ? scrollIntoView : true) {
|
|
210
|
-
this.editorView.dispatch(this.editorView.state.tr.scrollIntoView());
|
|
211
|
-
}
|
|
212
|
-
} else {
|
|
207
|
+
if (scrollIntoView !== null && scrollIntoView !== void 0 ? scrollIntoView : true) {
|
|
213
208
|
this.editorView.dispatch(this.editorView.state.tr.scrollIntoView());
|
|
214
209
|
}
|
|
215
210
|
return true;
|
|
@@ -306,7 +301,7 @@ var EditorActions = exports.default = /*#__PURE__*/function () {
|
|
|
306
301
|
}() // eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
307
302
|
/**
|
|
308
303
|
* @deprecated - please use `getNodeWithPosByLocalId` found in the core plugin actions instead
|
|
309
|
-
* @example
|
|
304
|
+
* @example
|
|
310
305
|
const { editorApi, preset } = usePreset(...);
|
|
311
306
|
const extensionAPI = editorAPI?.extension?.actions?.api();
|
|
312
307
|
// Use nodeWithPos as desired
|
|
@@ -175,7 +175,7 @@ function ReactEditorView(props) {
|
|
|
175
175
|
if (options.doc) {
|
|
176
176
|
// if the collabEdit API is set, skip this validation due to potential pm validation errors
|
|
177
177
|
// from docs that end up with invalid marks after processing (See #hot-111702 for more details)
|
|
178
|
-
if ((api === null || api === void 0 ? void 0 : api.collabEdit) !== undefined
|
|
178
|
+
if ((api === null || api === void 0 ? void 0 : api.collabEdit) !== undefined || options.props.editorProps.skipValidation) {
|
|
179
179
|
doc = (0, _processRawValue.processRawValueWithoutValidation)(schema, options.doc, dispatchAnalyticsEvent);
|
|
180
180
|
} else {
|
|
181
181
|
doc = (0, _processRawValue.processRawValue)(schema, options.doc, options.props.providerFactory, options.props.editorProps.sanitizePrivateContent, contentTransformer.current, dispatchAnalyticsEvent);
|
|
@@ -477,32 +477,25 @@ function ReactEditorView(props) {
|
|
|
477
477
|
isNestedEditorCalculated.current = true;
|
|
478
478
|
}
|
|
479
479
|
}
|
|
480
|
-
var originalScrollToRestore = _react.default.useRef(!isNestedEditor.current && (0, _isFullPage.isFullPage)(props.editorProps.appearance)
|
|
480
|
+
var originalScrollToRestore = _react.default.useRef(!isNestedEditor.current && (0, _isFullPage.isFullPage)(props.editorProps.appearance) ? (_document$querySelect = document.querySelector('[data-editor-scroll-container]')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.scrollTop : undefined);
|
|
481
481
|
var mitigateScrollJump =
|
|
482
482
|
// The feature gate here is being used to avoid potential bugs with the scroll restoration code
|
|
483
483
|
// moving it to the end of the expression negates the point of the feature gate
|
|
484
484
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
485
|
-
(0, _isFullPage.isFullPage)(props.editorProps.appearance) &&
|
|
485
|
+
(0, _isFullPage.isFullPage)(props.editorProps.appearance) && originalScrollToRestore.current && originalScrollToRestore.current !== 0;
|
|
486
486
|
(0, _react.useLayoutEffect)(function () {
|
|
487
487
|
var _editorView$props$edi, _editorView$props;
|
|
488
488
|
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')) {
|
|
489
|
-
if (
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
if (!liveDocWithContent) {
|
|
493
|
-
focusTimeoutId.current = (0, _handleEditorFocus.handleEditorFocus)(editorView);
|
|
494
|
-
}
|
|
495
|
-
if ((0, _expValEquals.expValEquals)('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('cc_editor_focus_before_editor_on_load')) {
|
|
496
|
-
if (!disabled && shouldFocus && !(0, _document.isEmptyDocument)(editorView.state.doc)) {
|
|
497
|
-
(0, _focusEditorElement.focusEditorElement)(editorId.current);
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
} else {
|
|
502
|
-
var _liveDocWithContent = (__livePage || (0, _expValEquals.expValEquals)('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true)) && !(0, _document.isEmptyDocument)(editorView.state.doc);
|
|
503
|
-
if (!_liveDocWithContent) {
|
|
489
|
+
if (!mitigateScrollJump) {
|
|
490
|
+
var liveDocWithContent = (__livePage || (0, _expValEquals.expValEquals)('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true)) && !(0, _document.isEmptyDocument)(editorView.state.doc);
|
|
491
|
+
if (!liveDocWithContent) {
|
|
504
492
|
focusTimeoutId.current = (0, _handleEditorFocus.handleEditorFocus)(editorView);
|
|
505
493
|
}
|
|
494
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('cc_editor_focus_before_editor_on_load')) {
|
|
495
|
+
if (!disabled && shouldFocus && !(0, _document.isEmptyDocument)(editorView.state.doc)) {
|
|
496
|
+
(0, _focusEditorElement.focusEditorElement)(editorId.current);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
506
499
|
}
|
|
507
500
|
}
|
|
508
501
|
}, [editorView, shouldFocus, __livePage, mitigateScrollJump, disabled]);
|
|
@@ -580,14 +573,12 @@ function ReactEditorView(props) {
|
|
|
580
573
|
if (!viewRef.current && node) {
|
|
581
574
|
(0, _nodeVisibility.nodeVisibilityManager)(node).initialiseNodeObserver();
|
|
582
575
|
var view = createEditorView(node);
|
|
583
|
-
if (
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
});
|
|
590
|
-
}
|
|
576
|
+
if (mitigateScrollJump) {
|
|
577
|
+
var _scrollElement = document.querySelector('[data-editor-scroll-container]');
|
|
578
|
+
_scrollElement === null || _scrollElement === void 0 || _scrollElement.scrollTo({
|
|
579
|
+
top: originalScrollToRestore.current,
|
|
580
|
+
behavior: 'instant'
|
|
581
|
+
});
|
|
591
582
|
}
|
|
592
583
|
onEditorCreated({
|
|
593
584
|
view: view,
|
|
@@ -611,23 +602,16 @@ function ReactEditorView(props) {
|
|
|
611
602
|
});
|
|
612
603
|
} else {
|
|
613
604
|
if (shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
614
|
-
if (
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
if (!isLivePageWithContent && shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
618
|
-
focusTimeoutId.current = (0, _handleEditorFocus.handleEditorFocus)(view);
|
|
619
|
-
}
|
|
620
|
-
if ((0, _expValEquals.expValEquals)('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('cc_editor_focus_before_editor_on_load')) {
|
|
621
|
-
if (shouldFocus && view.props.editable && view.props.editable(view.state) && !(0, _document.isEmptyDocument)(view.state.doc)) {
|
|
622
|
-
(0, _focusEditorElement.focusEditorElement)(editorId.current);
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
} else {
|
|
627
|
-
var _isLivePageWithContent = (__livePage || (0, _expValEquals.expValEquals)('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true)) && !(0, _document.isEmptyDocument)(view.state.doc);
|
|
628
|
-
if (!_isLivePageWithContent && shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
605
|
+
if (!mitigateScrollJump) {
|
|
606
|
+
var isLivePageWithContent = (__livePage || (0, _expValEquals.expValEquals)('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true)) && !(0, _document.isEmptyDocument)(view.state.doc);
|
|
607
|
+
if (!isLivePageWithContent && shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
629
608
|
focusTimeoutId.current = (0, _handleEditorFocus.handleEditorFocus)(view);
|
|
630
609
|
}
|
|
610
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('cc_editor_focus_before_editor_on_load')) {
|
|
611
|
+
if (shouldFocus && view.props.editable && view.props.editable(view.state) && !(0, _document.isEmptyDocument)(view.state.doc)) {
|
|
612
|
+
(0, _focusEditorElement.focusEditorElement)(editorId.current);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
631
615
|
}
|
|
632
616
|
}
|
|
633
617
|
|
|
@@ -32,7 +32,7 @@ var ClickAreaBlock = exports.ClickAreaBlock = function ClickAreaBlock(_ref) {
|
|
|
32
32
|
}
|
|
33
33
|
}, [editorView, editorDisabled]);
|
|
34
34
|
return (
|
|
35
|
-
// eslint-disable-next-line
|
|
35
|
+
// eslint-disable-next-line @atlassian/a11y/no-static-element-interactions
|
|
36
36
|
(0, _react2.jsx)("div", {
|
|
37
37
|
"data-editor-click-wrapper": true,
|
|
38
38
|
"data-testid": "click-wrapper",
|
|
@@ -4,8 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.findChangedNodesFromTransaction = void 0;
|
|
7
|
-
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
8
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
9
7
|
/**
|
|
10
8
|
* Finds all top level nodes affected by the transaction
|
|
11
9
|
* Uses from/to positions in transaction's steps to work out which nodes will
|
|
@@ -15,20 +13,12 @@ var findChangedNodesFromTransaction = exports.findChangedNodesFromTransaction =
|
|
|
15
13
|
var nodes = [];
|
|
16
14
|
var steps = tr.steps || [];
|
|
17
15
|
steps.forEach(function (step) {
|
|
18
|
-
step.getMap().forEach(function (
|
|
16
|
+
step.getMap().forEach(function (_oldStart, _oldEnd, newStart, newEnd) {
|
|
19
17
|
tr.doc.nodesBetween(newStart, Math.min(newEnd, tr.doc.content.size), function (node) {
|
|
20
|
-
var nodeToCheck = node;
|
|
21
|
-
if ((0, _platformFeatureFlags.fg)('cc_complexit_fe_improve_node_validation')) {
|
|
22
|
-
var schema = tr.selection.$from.doc.type.schema;
|
|
23
|
-
var parentNode = (0, _utils.findParentNode)(function (node) {
|
|
24
|
-
return node.type !== schema.nodes.paragraph;
|
|
25
|
-
})(tr.selection);
|
|
26
|
-
nodeToCheck = parentNode ? parentNode.node : node;
|
|
27
|
-
}
|
|
28
18
|
if (!nodes.find(function (n) {
|
|
29
|
-
return n ===
|
|
19
|
+
return n === node;
|
|
30
20
|
})) {
|
|
31
|
-
nodes.push(
|
|
21
|
+
nodes.push(node);
|
|
32
22
|
}
|
|
33
23
|
return false;
|
|
34
24
|
});
|
|
@@ -6,7 +6,6 @@ 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';
|
|
10
9
|
import { getEditorValueWithMedia } from '../utils/action';
|
|
11
10
|
import deprecationWarnings from '../utils/deprecation-warnings';
|
|
12
11
|
import { findNodePosByFragmentLocalIds } from '../utils/nodes-by-localIds';
|
|
@@ -35,7 +34,7 @@ const fakePluginKey = {
|
|
|
35
34
|
* If you were using editorActions.getNodeByLocalId(localId) replace with:
|
|
36
35
|
const { editorApi, preset } = usePreset(...);
|
|
37
36
|
const extensionAPI = editorAPI?.extension?.actions?.api();
|
|
38
|
-
// Use nodeWithPos as desired
|
|
37
|
+
// Use nodeWithPos as desired
|
|
39
38
|
const nodeWithPos = extensionAPI.getNodeWithPosByLocalId(localId);
|
|
40
39
|
const node = nodeWithPos.node;
|
|
41
40
|
const nodePos = nodeWithPos.pos;
|
|
@@ -148,11 +147,7 @@ export default class EditorActions {
|
|
|
148
147
|
return false;
|
|
149
148
|
}
|
|
150
149
|
this.editorView.focus();
|
|
151
|
-
if (
|
|
152
|
-
if (scrollIntoView !== null && scrollIntoView !== void 0 ? scrollIntoView : true) {
|
|
153
|
-
this.editorView.dispatch(this.editorView.state.tr.scrollIntoView());
|
|
154
|
-
}
|
|
155
|
-
} else {
|
|
150
|
+
if (scrollIntoView !== null && scrollIntoView !== void 0 ? scrollIntoView : true) {
|
|
156
151
|
this.editorView.dispatch(this.editorView.state.tr.scrollIntoView());
|
|
157
152
|
}
|
|
158
153
|
return true;
|
|
@@ -225,7 +220,7 @@ export default class EditorActions {
|
|
|
225
220
|
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
226
221
|
/**
|
|
227
222
|
* @deprecated - please use `getNodeWithPosByLocalId` found in the core plugin actions instead
|
|
228
|
-
* @example
|
|
223
|
+
* @example
|
|
229
224
|
const { editorApi, preset } = usePreset(...);
|
|
230
225
|
const extensionAPI = editorAPI?.extension?.actions?.api();
|
|
231
226
|
// Use nodeWithPos as desired
|
|
@@ -147,7 +147,7 @@ export function ReactEditorView(props) {
|
|
|
147
147
|
if (options.doc) {
|
|
148
148
|
// if the collabEdit API is set, skip this validation due to potential pm validation errors
|
|
149
149
|
// from docs that end up with invalid marks after processing (See #hot-111702 for more details)
|
|
150
|
-
if ((api === null || api === void 0 ? void 0 : api.collabEdit) !== undefined
|
|
150
|
+
if ((api === null || api === void 0 ? void 0 : api.collabEdit) !== undefined || options.props.editorProps.skipValidation) {
|
|
151
151
|
doc = processRawValueWithoutValidation(schema, options.doc, dispatchAnalyticsEvent);
|
|
152
152
|
} else {
|
|
153
153
|
doc = processRawValue(schema, options.doc, options.props.providerFactory, options.props.editorProps.sanitizePrivateContent, contentTransformer.current, dispatchAnalyticsEvent);
|
|
@@ -444,32 +444,25 @@ export function ReactEditorView(props) {
|
|
|
444
444
|
isNestedEditorCalculated.current = true;
|
|
445
445
|
}
|
|
446
446
|
}
|
|
447
|
-
const originalScrollToRestore = React.useRef(!isNestedEditor.current && isFullPage(props.editorProps.appearance)
|
|
447
|
+
const originalScrollToRestore = React.useRef(!isNestedEditor.current && isFullPage(props.editorProps.appearance) ? (_document$querySelect = document.querySelector('[data-editor-scroll-container]')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.scrollTop : undefined);
|
|
448
448
|
const mitigateScrollJump =
|
|
449
449
|
// The feature gate here is being used to avoid potential bugs with the scroll restoration code
|
|
450
450
|
// moving it to the end of the expression negates the point of the feature gate
|
|
451
451
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
452
|
-
isFullPage(props.editorProps.appearance) &&
|
|
452
|
+
isFullPage(props.editorProps.appearance) && originalScrollToRestore.current && originalScrollToRestore.current !== 0;
|
|
453
453
|
useLayoutEffect(() => {
|
|
454
454
|
var _editorView$props$edi, _editorView$props;
|
|
455
455
|
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')) {
|
|
456
|
-
if (
|
|
457
|
-
if (!mitigateScrollJump) {
|
|
458
|
-
const liveDocWithContent = (__livePage || expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true)) && !isEmptyDocument(editorView.state.doc);
|
|
459
|
-
if (!liveDocWithContent) {
|
|
460
|
-
focusTimeoutId.current = handleEditorFocus(editorView);
|
|
461
|
-
}
|
|
462
|
-
if (expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true) && fg('cc_editor_focus_before_editor_on_load')) {
|
|
463
|
-
if (!disabled && shouldFocus && !isEmptyDocument(editorView.state.doc)) {
|
|
464
|
-
focusEditorElement(editorId.current);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
} else {
|
|
456
|
+
if (!mitigateScrollJump) {
|
|
469
457
|
const liveDocWithContent = (__livePage || expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true)) && !isEmptyDocument(editorView.state.doc);
|
|
470
458
|
if (!liveDocWithContent) {
|
|
471
459
|
focusTimeoutId.current = handleEditorFocus(editorView);
|
|
472
460
|
}
|
|
461
|
+
if (expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true) && fg('cc_editor_focus_before_editor_on_load')) {
|
|
462
|
+
if (!disabled && shouldFocus && !isEmptyDocument(editorView.state.doc)) {
|
|
463
|
+
focusEditorElement(editorId.current);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
473
466
|
}
|
|
474
467
|
}
|
|
475
468
|
}, [editorView, shouldFocus, __livePage, mitigateScrollJump, disabled]);
|
|
@@ -529,14 +522,12 @@ export function ReactEditorView(props) {
|
|
|
529
522
|
if (!viewRef.current && node) {
|
|
530
523
|
nodeVisibilityManager(node).initialiseNodeObserver();
|
|
531
524
|
const view = createEditorView(node);
|
|
532
|
-
if (
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
});
|
|
539
|
-
}
|
|
525
|
+
if (mitigateScrollJump) {
|
|
526
|
+
const scrollElement = document.querySelector('[data-editor-scroll-container]');
|
|
527
|
+
scrollElement === null || scrollElement === void 0 ? void 0 : scrollElement.scrollTo({
|
|
528
|
+
top: originalScrollToRestore.current,
|
|
529
|
+
behavior: 'instant'
|
|
530
|
+
});
|
|
540
531
|
}
|
|
541
532
|
onEditorCreated({
|
|
542
533
|
view,
|
|
@@ -558,23 +549,16 @@ export function ReactEditorView(props) {
|
|
|
558
549
|
});
|
|
559
550
|
} else {
|
|
560
551
|
if (shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
561
|
-
if (
|
|
562
|
-
if (!mitigateScrollJump) {
|
|
563
|
-
const isLivePageWithContent = (__livePage || expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true)) && !isEmptyDocument(view.state.doc);
|
|
564
|
-
if (!isLivePageWithContent && shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
565
|
-
focusTimeoutId.current = handleEditorFocus(view);
|
|
566
|
-
}
|
|
567
|
-
if (expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true) && fg('cc_editor_focus_before_editor_on_load')) {
|
|
568
|
-
if (shouldFocus && view.props.editable && view.props.editable(view.state) && !isEmptyDocument(view.state.doc)) {
|
|
569
|
-
focusEditorElement(editorId.current);
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
} else {
|
|
552
|
+
if (!mitigateScrollJump) {
|
|
574
553
|
const isLivePageWithContent = (__livePage || expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true)) && !isEmptyDocument(view.state.doc);
|
|
575
554
|
if (!isLivePageWithContent && shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
576
555
|
focusTimeoutId.current = handleEditorFocus(view);
|
|
577
556
|
}
|
|
557
|
+
if (expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true) && fg('cc_editor_focus_before_editor_on_load')) {
|
|
558
|
+
if (shouldFocus && view.props.editable && view.props.editable(view.state) && !isEmptyDocument(view.state.doc)) {
|
|
559
|
+
focusEditorElement(editorId.current);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
578
562
|
}
|
|
579
563
|
}
|
|
580
564
|
|
|
@@ -25,7 +25,7 @@ export const ClickAreaBlock = ({
|
|
|
25
25
|
}
|
|
26
26
|
}, [editorView, editorDisabled]);
|
|
27
27
|
return (
|
|
28
|
-
// eslint-disable-next-line
|
|
28
|
+
// eslint-disable-next-line @atlassian/a11y/no-static-element-interactions
|
|
29
29
|
jsx("div", {
|
|
30
30
|
"data-editor-click-wrapper": true,
|
|
31
31
|
"data-testid": "click-wrapper",
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
2
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
2
|
* Finds all top level nodes affected by the transaction
|
|
6
3
|
* Uses from/to positions in transaction's steps to work out which nodes will
|
|
@@ -10,18 +7,10 @@ export const findChangedNodesFromTransaction = tr => {
|
|
|
10
7
|
const nodes = [];
|
|
11
8
|
const steps = tr.steps || [];
|
|
12
9
|
steps.forEach(step => {
|
|
13
|
-
step.getMap().forEach((
|
|
10
|
+
step.getMap().forEach((_oldStart, _oldEnd, newStart, newEnd) => {
|
|
14
11
|
tr.doc.nodesBetween(newStart, Math.min(newEnd, tr.doc.content.size), node => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const {
|
|
18
|
-
schema
|
|
19
|
-
} = tr.selection.$from.doc.type;
|
|
20
|
-
const parentNode = findParentNode(node => node.type !== schema.nodes.paragraph)(tr.selection);
|
|
21
|
-
nodeToCheck = parentNode ? parentNode.node : node;
|
|
22
|
-
}
|
|
23
|
-
if (!nodes.find(n => n === nodeToCheck)) {
|
|
24
|
-
nodes.push(nodeToCheck);
|
|
12
|
+
if (!nodes.find(n => n === node)) {
|
|
13
|
+
nodes.push(node);
|
|
25
14
|
}
|
|
26
15
|
return false;
|
|
27
16
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = "@atlaskit/editor-core";
|
|
2
|
-
export const version = "214.2.
|
|
2
|
+
export const version = "214.2.2";
|
|
@@ -10,7 +10,6 @@ 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';
|
|
14
13
|
import { getEditorValueWithMedia } from '../utils/action';
|
|
15
14
|
import deprecationWarnings from '../utils/deprecation-warnings';
|
|
16
15
|
import { findNodePosByFragmentLocalIds } from '../utils/nodes-by-localIds';
|
|
@@ -39,7 +38,7 @@ var fakePluginKey = {
|
|
|
39
38
|
* If you were using editorActions.getNodeByLocalId(localId) replace with:
|
|
40
39
|
const { editorApi, preset } = usePreset(...);
|
|
41
40
|
const extensionAPI = editorAPI?.extension?.actions?.api();
|
|
42
|
-
// Use nodeWithPos as desired
|
|
41
|
+
// Use nodeWithPos as desired
|
|
43
42
|
const nodeWithPos = extensionAPI.getNodeWithPosByLocalId(localId);
|
|
44
43
|
const node = nodeWithPos.node;
|
|
45
44
|
const nodePos = nodeWithPos.pos;
|
|
@@ -199,11 +198,7 @@ var EditorActions = /*#__PURE__*/function () {
|
|
|
199
198
|
return false;
|
|
200
199
|
}
|
|
201
200
|
this.editorView.focus();
|
|
202
|
-
if (
|
|
203
|
-
if (scrollIntoView !== null && scrollIntoView !== void 0 ? scrollIntoView : true) {
|
|
204
|
-
this.editorView.dispatch(this.editorView.state.tr.scrollIntoView());
|
|
205
|
-
}
|
|
206
|
-
} else {
|
|
201
|
+
if (scrollIntoView !== null && scrollIntoView !== void 0 ? scrollIntoView : true) {
|
|
207
202
|
this.editorView.dispatch(this.editorView.state.tr.scrollIntoView());
|
|
208
203
|
}
|
|
209
204
|
return true;
|
|
@@ -300,7 +295,7 @@ var EditorActions = /*#__PURE__*/function () {
|
|
|
300
295
|
}() // eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
301
296
|
/**
|
|
302
297
|
* @deprecated - please use `getNodeWithPosByLocalId` found in the core plugin actions instead
|
|
303
|
-
* @example
|
|
298
|
+
* @example
|
|
304
299
|
const { editorApi, preset } = usePreset(...);
|
|
305
300
|
const extensionAPI = editorAPI?.extension?.actions?.api();
|
|
306
301
|
// Use nodeWithPos as desired
|
|
@@ -165,7 +165,7 @@ export function ReactEditorView(props) {
|
|
|
165
165
|
if (options.doc) {
|
|
166
166
|
// if the collabEdit API is set, skip this validation due to potential pm validation errors
|
|
167
167
|
// from docs that end up with invalid marks after processing (See #hot-111702 for more details)
|
|
168
|
-
if ((api === null || api === void 0 ? void 0 : api.collabEdit) !== undefined
|
|
168
|
+
if ((api === null || api === void 0 ? void 0 : api.collabEdit) !== undefined || options.props.editorProps.skipValidation) {
|
|
169
169
|
doc = processRawValueWithoutValidation(schema, options.doc, dispatchAnalyticsEvent);
|
|
170
170
|
} else {
|
|
171
171
|
doc = processRawValue(schema, options.doc, options.props.providerFactory, options.props.editorProps.sanitizePrivateContent, contentTransformer.current, dispatchAnalyticsEvent);
|
|
@@ -467,32 +467,25 @@ export function ReactEditorView(props) {
|
|
|
467
467
|
isNestedEditorCalculated.current = true;
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
|
-
var originalScrollToRestore = React.useRef(!isNestedEditor.current && isFullPage(props.editorProps.appearance)
|
|
470
|
+
var originalScrollToRestore = React.useRef(!isNestedEditor.current && isFullPage(props.editorProps.appearance) ? (_document$querySelect = document.querySelector('[data-editor-scroll-container]')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.scrollTop : undefined);
|
|
471
471
|
var mitigateScrollJump =
|
|
472
472
|
// The feature gate here is being used to avoid potential bugs with the scroll restoration code
|
|
473
473
|
// moving it to the end of the expression negates the point of the feature gate
|
|
474
474
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
475
|
-
isFullPage(props.editorProps.appearance) &&
|
|
475
|
+
isFullPage(props.editorProps.appearance) && originalScrollToRestore.current && originalScrollToRestore.current !== 0;
|
|
476
476
|
useLayoutEffect(function () {
|
|
477
477
|
var _editorView$props$edi, _editorView$props;
|
|
478
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')) {
|
|
479
|
-
if (
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
if (!liveDocWithContent) {
|
|
483
|
-
focusTimeoutId.current = handleEditorFocus(editorView);
|
|
484
|
-
}
|
|
485
|
-
if (expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true) && fg('cc_editor_focus_before_editor_on_load')) {
|
|
486
|
-
if (!disabled && shouldFocus && !isEmptyDocument(editorView.state.doc)) {
|
|
487
|
-
focusEditorElement(editorId.current);
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
} else {
|
|
492
|
-
var _liveDocWithContent = (__livePage || expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true)) && !isEmptyDocument(editorView.state.doc);
|
|
493
|
-
if (!_liveDocWithContent) {
|
|
479
|
+
if (!mitigateScrollJump) {
|
|
480
|
+
var liveDocWithContent = (__livePage || expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true)) && !isEmptyDocument(editorView.state.doc);
|
|
481
|
+
if (!liveDocWithContent) {
|
|
494
482
|
focusTimeoutId.current = handleEditorFocus(editorView);
|
|
495
483
|
}
|
|
484
|
+
if (expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true) && fg('cc_editor_focus_before_editor_on_load')) {
|
|
485
|
+
if (!disabled && shouldFocus && !isEmptyDocument(editorView.state.doc)) {
|
|
486
|
+
focusEditorElement(editorId.current);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
496
489
|
}
|
|
497
490
|
}
|
|
498
491
|
}, [editorView, shouldFocus, __livePage, mitigateScrollJump, disabled]);
|
|
@@ -570,14 +563,12 @@ export function ReactEditorView(props) {
|
|
|
570
563
|
if (!viewRef.current && node) {
|
|
571
564
|
nodeVisibilityManager(node).initialiseNodeObserver();
|
|
572
565
|
var view = createEditorView(node);
|
|
573
|
-
if (
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
});
|
|
580
|
-
}
|
|
566
|
+
if (mitigateScrollJump) {
|
|
567
|
+
var _scrollElement = document.querySelector('[data-editor-scroll-container]');
|
|
568
|
+
_scrollElement === null || _scrollElement === void 0 || _scrollElement.scrollTo({
|
|
569
|
+
top: originalScrollToRestore.current,
|
|
570
|
+
behavior: 'instant'
|
|
571
|
+
});
|
|
581
572
|
}
|
|
582
573
|
onEditorCreated({
|
|
583
574
|
view: view,
|
|
@@ -601,23 +592,16 @@ export function ReactEditorView(props) {
|
|
|
601
592
|
});
|
|
602
593
|
} else {
|
|
603
594
|
if (shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
604
|
-
if (
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
if (!isLivePageWithContent && shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
608
|
-
focusTimeoutId.current = handleEditorFocus(view);
|
|
609
|
-
}
|
|
610
|
-
if (expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true) && fg('cc_editor_focus_before_editor_on_load')) {
|
|
611
|
-
if (shouldFocus && view.props.editable && view.props.editable(view.state) && !isEmptyDocument(view.state.doc)) {
|
|
612
|
-
focusEditorElement(editorId.current);
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
} else {
|
|
617
|
-
var _isLivePageWithContent = (__livePage || expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true)) && !isEmptyDocument(view.state.doc);
|
|
618
|
-
if (!_isLivePageWithContent && shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
595
|
+
if (!mitigateScrollJump) {
|
|
596
|
+
var isLivePageWithContent = (__livePage || expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true)) && !isEmptyDocument(view.state.doc);
|
|
597
|
+
if (!isLivePageWithContent && shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
619
598
|
focusTimeoutId.current = handleEditorFocus(view);
|
|
620
599
|
}
|
|
600
|
+
if (expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true) && fg('cc_editor_focus_before_editor_on_load')) {
|
|
601
|
+
if (shouldFocus && view.props.editable && view.props.editable(view.state) && !isEmptyDocument(view.state.doc)) {
|
|
602
|
+
focusEditorElement(editorId.current);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
621
605
|
}
|
|
622
606
|
}
|
|
623
607
|
|
|
@@ -24,7 +24,7 @@ export var ClickAreaBlock = function ClickAreaBlock(_ref) {
|
|
|
24
24
|
}
|
|
25
25
|
}, [editorView, editorDisabled]);
|
|
26
26
|
return (
|
|
27
|
-
// eslint-disable-next-line
|
|
27
|
+
// eslint-disable-next-line @atlassian/a11y/no-static-element-interactions
|
|
28
28
|
jsx("div", {
|
|
29
29
|
"data-editor-click-wrapper": true,
|
|
30
30
|
"data-testid": "click-wrapper",
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
2
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
2
|
* Finds all top level nodes affected by the transaction
|
|
6
3
|
* Uses from/to positions in transaction's steps to work out which nodes will
|
|
@@ -10,20 +7,12 @@ export var findChangedNodesFromTransaction = function findChangedNodesFromTransa
|
|
|
10
7
|
var nodes = [];
|
|
11
8
|
var steps = tr.steps || [];
|
|
12
9
|
steps.forEach(function (step) {
|
|
13
|
-
step.getMap().forEach(function (
|
|
10
|
+
step.getMap().forEach(function (_oldStart, _oldEnd, newStart, newEnd) {
|
|
14
11
|
tr.doc.nodesBetween(newStart, Math.min(newEnd, tr.doc.content.size), function (node) {
|
|
15
|
-
var nodeToCheck = node;
|
|
16
|
-
if (fg('cc_complexit_fe_improve_node_validation')) {
|
|
17
|
-
var schema = tr.selection.$from.doc.type.schema;
|
|
18
|
-
var parentNode = findParentNode(function (node) {
|
|
19
|
-
return node.type !== schema.nodes.paragraph;
|
|
20
|
-
})(tr.selection);
|
|
21
|
-
nodeToCheck = parentNode ? parentNode.node : node;
|
|
22
|
-
}
|
|
23
12
|
if (!nodes.find(function (n) {
|
|
24
|
-
return n ===
|
|
13
|
+
return n === node;
|
|
25
14
|
})) {
|
|
26
|
-
nodes.push(
|
|
15
|
+
nodes.push(node);
|
|
27
16
|
}
|
|
28
17
|
return false;
|
|
29
18
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export var name = "@atlaskit/editor-core";
|
|
2
|
-
export var version = "214.2.
|
|
2
|
+
export var version = "214.2.2";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-core",
|
|
3
|
-
"version": "214.2.
|
|
3
|
+
"version": "214.2.3",
|
|
4
4
|
"description": "A package contains Atlassian editor core functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"uuid": "^3.1.0"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
|
-
"@atlaskit/editor-common": "^110.
|
|
84
|
+
"@atlaskit/editor-common": "^110.8.0",
|
|
85
85
|
"@atlaskit/link-provider": "^4.0.0",
|
|
86
86
|
"@atlaskit/media-core": "^37.0.0",
|
|
87
87
|
"react": "^18.2.0",
|
|
@@ -150,18 +150,12 @@
|
|
|
150
150
|
}
|
|
151
151
|
},
|
|
152
152
|
"platform-feature-flags": {
|
|
153
|
-
"cc_complexit_fe_improve_node_validation": {
|
|
154
|
-
"type": "boolean"
|
|
155
|
-
},
|
|
156
153
|
"cc_editor_abort_ufo_load_on_editor_scroll": {
|
|
157
154
|
"type": "boolean"
|
|
158
155
|
},
|
|
159
156
|
"confluence_floating_toolbar_animation": {
|
|
160
157
|
"type": "boolean"
|
|
161
158
|
},
|
|
162
|
-
"platform_editor_reduce_scroll_jump_on_editor_start": {
|
|
163
|
-
"type": "boolean"
|
|
164
|
-
},
|
|
165
159
|
"annotations_defensive_node_name_calculations": {
|
|
166
160
|
"type": "boolean",
|
|
167
161
|
"referenceOnly": "true"
|
|
@@ -210,9 +204,6 @@
|
|
|
210
204
|
"type": "boolean",
|
|
211
205
|
"referenceOnly": true
|
|
212
206
|
},
|
|
213
|
-
"editor_load_conf_collab_docs_without_checks": {
|
|
214
|
-
"type": "boolean"
|
|
215
|
-
},
|
|
216
207
|
"platform_editor_toolbar_responsive_fixes": {
|
|
217
208
|
"type": "boolean"
|
|
218
209
|
},
|
|
@@ -266,10 +257,6 @@
|
|
|
266
257
|
"type": "boolean",
|
|
267
258
|
"referenceOnly": true
|
|
268
259
|
},
|
|
269
|
-
"platform_editor_live_page_prevent_table_recreation": {
|
|
270
|
-
"type": "boolean",
|
|
271
|
-
"referenceOnly": true
|
|
272
|
-
},
|
|
273
260
|
"platform_editor_safari_media_clipboard_fix": {
|
|
274
261
|
"type": "boolean",
|
|
275
262
|
"referenceOnly": true
|