@atlaskit/editor-core 193.24.15 → 193.24.19
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 +16 -0
- package/dist/cjs/create-editor/ReactEditorView.js +44 -27
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/create-editor/ReactEditorView.js +44 -27
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/create-editor/ReactEditorView.js +44 -27
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/create-editor/ReactEditorView.d.ts +0 -1
- package/dist/types/create-editor/create-preset.d.ts +31 -0
- package/dist/types/presets/default.d.ts +22 -0
- package/dist/types/presets/universal.d.ts +31 -0
- package/dist/types/presets/useUniversalPreset.d.ts +31 -0
- package/dist/types-ts4.5/create-editor/ReactEditorView.d.ts +0 -1
- package/dist/types-ts4.5/create-editor/create-preset.d.ts +31 -0
- package/dist/types-ts4.5/presets/default.d.ts +22 -0
- package/dist/types-ts4.5/presets/universal.d.ts +31 -0
- package/dist/types-ts4.5/presets/useUniversalPreset.d.ts +31 -0
- package/package.json +7 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 193.24.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#103607](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103607)
|
|
8
|
+
[`104c7a82d1a7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/104c7a82d1a7) -
|
|
9
|
+
[ux] ED-23363 If you load a live page in view mode, an empty selection will be set.
|
|
10
|
+
|
|
11
|
+
## 193.24.18
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#107335](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/107335)
|
|
16
|
+
[`d5457c8afe5f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d5457c8afe5f) -
|
|
17
|
+
Cleaned up FF platform.editor.media.autoselect-inserted-image_oumto
|
|
18
|
+
|
|
3
19
|
## 193.24.15
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -25,6 +25,7 @@ var _ui = require("@atlaskit/editor-common/ui");
|
|
|
25
25
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
26
26
|
var _state2 = require("@atlaskit/editor-prosemirror/state");
|
|
27
27
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
28
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
28
29
|
var _eventDispatcher = require("../event-dispatcher");
|
|
29
30
|
var _document = require("../utils/document");
|
|
30
31
|
var _isFullPage = require("../utils/is-full-page");
|
|
@@ -45,7 +46,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
45
46
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
46
47
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
47
48
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
48
|
-
function handleEditorFocus(view
|
|
49
|
+
function handleEditorFocus(view) {
|
|
49
50
|
if (view.hasFocus()) {
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
@@ -57,12 +58,6 @@ function handleEditorFocus(view, viewMode) {
|
|
|
57
58
|
view.focus();
|
|
58
59
|
return;
|
|
59
60
|
}
|
|
60
|
-
if (viewMode === 'view') {
|
|
61
|
-
var emptySelection = new _state2.TextSelection(view.state.doc.resolve(0));
|
|
62
|
-
var _tr = view.state.tr.setSelection(emptySelection);
|
|
63
|
-
view.dispatch(_tr);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
61
|
var domSelection = window.getSelection();
|
|
67
62
|
if (!domSelection || domSelection.rangeCount === 0) {
|
|
68
63
|
view.focus();
|
|
@@ -119,11 +114,6 @@ var ReactEditorView = exports.ReactEditorView = /*#__PURE__*/function (_React$Co
|
|
|
119
114
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getEditorView", function () {
|
|
120
115
|
return _this.view;
|
|
121
116
|
});
|
|
122
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getViewMode", function () {
|
|
123
|
-
var _editorApi$editorView;
|
|
124
|
-
var editorApi = _this.pluginInjectionAPI.api();
|
|
125
|
-
return (_editorApi$editorView = editorApi.editorViewMode) === null || _editorApi$editorView === void 0 ? void 0 : _editorApi$editorView.sharedState.currentState().mode;
|
|
126
|
-
});
|
|
127
117
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "formatFullWidthAppearance", function (appearance) {
|
|
128
118
|
if (appearance === 'full-width') {
|
|
129
119
|
return _analytics.FULL_WIDTH_MODE.FULL_WIDTH;
|
|
@@ -176,6 +166,7 @@ var ReactEditorView = exports.ReactEditorView = /*#__PURE__*/function (_React$Co
|
|
|
176
166
|
});
|
|
177
167
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "editorPlugins", []);
|
|
178
168
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "createEditorState", function (options) {
|
|
169
|
+
var _api$editorViewMode;
|
|
179
170
|
var schema;
|
|
180
171
|
if (_this.view) {
|
|
181
172
|
if (options.resetting) {
|
|
@@ -226,18 +217,44 @@ var ReactEditorView = exports.ReactEditorView = /*#__PURE__*/function (_React$Co
|
|
|
226
217
|
if (options.doc) {
|
|
227
218
|
doc = (0, _utils.processRawValue)(schema, options.doc, options.props.providerFactory, options.props.editorProps.sanitizePrivateContent, _this.contentTransformer, _this.dispatchAnalyticsEvent);
|
|
228
219
|
}
|
|
220
|
+
var api = _this.pluginInjectionAPI.api();
|
|
221
|
+
var isViewMode = (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.currentState().mode) === 'view';
|
|
229
222
|
var selection;
|
|
230
|
-
if (
|
|
231
|
-
|
|
223
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-view.no-editor-selection-in-view-mode')) {
|
|
224
|
+
if (doc) {
|
|
225
|
+
if (isViewMode) {
|
|
226
|
+
var emptySelection = new _state2.TextSelection(doc.resolve(0));
|
|
227
|
+
return _state2.EditorState.create({
|
|
228
|
+
schema: schema,
|
|
229
|
+
plugins: plugins,
|
|
230
|
+
doc: doc,
|
|
231
|
+
selection: emptySelection
|
|
232
|
+
});
|
|
233
|
+
} else {
|
|
234
|
+
selection = options.selectionAtStart ? _state2.Selection.atStart(doc) : _state2.Selection.atEnd(doc);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
// Workaround for ED-3507: When media node is the last element, scrollIntoView throws an error
|
|
238
|
+
var patchedSelection = selection ? _state2.Selection.findFrom(selection.$head, -1, true) || undefined : undefined;
|
|
239
|
+
return _state2.EditorState.create({
|
|
240
|
+
schema: schema,
|
|
241
|
+
plugins: plugins,
|
|
242
|
+
doc: doc,
|
|
243
|
+
selection: patchedSelection
|
|
244
|
+
});
|
|
245
|
+
} else {
|
|
246
|
+
if (doc) {
|
|
247
|
+
selection = options.selectionAtStart ? _state2.Selection.atStart(doc) : _state2.Selection.atEnd(doc);
|
|
248
|
+
}
|
|
249
|
+
// Workaround for ED-3507: When media node is the last element, scrollIntoView throws an error
|
|
250
|
+
var _patchedSelection = selection ? _state2.Selection.findFrom(selection.$head, -1, true) || undefined : undefined;
|
|
251
|
+
return _state2.EditorState.create({
|
|
252
|
+
schema: schema,
|
|
253
|
+
plugins: plugins,
|
|
254
|
+
doc: doc,
|
|
255
|
+
selection: _patchedSelection
|
|
256
|
+
});
|
|
232
257
|
}
|
|
233
|
-
// Workaround for ED-3507: When media node is the last element, scrollIntoView throws an error
|
|
234
|
-
var patchedSelection = selection ? _state2.Selection.findFrom(selection.$head, -1, true) || undefined : undefined;
|
|
235
|
-
return _state2.EditorState.create({
|
|
236
|
-
schema: schema,
|
|
237
|
-
plugins: plugins,
|
|
238
|
-
doc: doc,
|
|
239
|
-
selection: patchedSelection
|
|
240
|
-
});
|
|
241
258
|
});
|
|
242
259
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onEditorViewStateUpdated", function (_ref2) {
|
|
243
260
|
var originalTransaction = _ref2.originalTransaction,
|
|
@@ -462,7 +479,7 @@ var ReactEditorView = exports.ReactEditorView = /*#__PURE__*/function (_React$Co
|
|
|
462
479
|
transformer: _this.contentTransformer
|
|
463
480
|
});
|
|
464
481
|
if (_this.props.editorProps.shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
465
|
-
_this.focusTimeoutId = handleEditorFocus(view
|
|
482
|
+
_this.focusTimeoutId = handleEditorFocus(view);
|
|
466
483
|
}
|
|
467
484
|
if (_this.featureFlags.ufo) {
|
|
468
485
|
_this.experienceStore = _ufo.ExperienceStore.getInstance(view);
|
|
@@ -548,11 +565,11 @@ var ReactEditorView = exports.ReactEditorView = /*#__PURE__*/function (_React$Co
|
|
|
548
565
|
getEditorState: _this.getEditorState,
|
|
549
566
|
getEditorView: _this.getEditorView
|
|
550
567
|
});
|
|
551
|
-
var
|
|
552
|
-
(_props$setEditorApi = props.setEditorApi) === null || _props$setEditorApi === void 0 || _props$setEditorApi.call(props,
|
|
568
|
+
var _api = _this.pluginInjectionAPI.api();
|
|
569
|
+
(_props$setEditorApi = props.setEditorApi) === null || _props$setEditorApi === void 0 || _props$setEditorApi.call(props, _api);
|
|
553
570
|
if (props.editorProps.editorActions) {
|
|
554
571
|
// @ts-expect-error
|
|
555
|
-
props.editorProps.editorActions.__EDITOR_INTERNALS_DO_NOT_USE__API =
|
|
572
|
+
props.editorProps.editorActions.__EDITOR_INTERNALS_DO_NOT_USE__API = _api;
|
|
556
573
|
}
|
|
557
574
|
_this.eventDispatcher = new _eventDispatcher.EventDispatcher();
|
|
558
575
|
_this.dispatch = (0, _eventDispatcher.createDispatch)(_this.eventDispatcher);
|
|
@@ -642,7 +659,7 @@ var ReactEditorView = exports.ReactEditorView = /*#__PURE__*/function (_React$Co
|
|
|
642
659
|
}
|
|
643
660
|
});
|
|
644
661
|
if (!nextProps.editorProps.disabled && nextProps.editorProps.shouldFocus) {
|
|
645
|
-
this.focusTimeoutId = handleEditorFocus(this.view
|
|
662
|
+
this.focusTimeoutId = handleEditorFocus(this.view);
|
|
646
663
|
}
|
|
647
664
|
}
|
|
648
665
|
var appearance = this.props.editorProps.appearance;
|
|
@@ -11,6 +11,7 @@ import { EDIT_AREA_ID } from '@atlaskit/editor-common/ui';
|
|
|
11
11
|
import { analyticsEventKey, browser, countNodes, getAnalyticsEventSeverity, getResponseEndTime, measureRender, processRawValue, shouldForceTracking, startMeasure, stopMeasure } from '@atlaskit/editor-common/utils';
|
|
12
12
|
import { EditorState, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
13
13
|
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
14
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
14
15
|
import { createDispatch, EventDispatcher } from '../event-dispatcher';
|
|
15
16
|
import { getNodesCount } from '../utils/document';
|
|
16
17
|
import { isFullPage } from '../utils/is-full-page';
|
|
@@ -27,7 +28,7 @@ import { createSchema } from './create-schema';
|
|
|
27
28
|
import { createFeatureFlagsFromProps } from './feature-flags-from-props';
|
|
28
29
|
import { editorMessages } from './messages';
|
|
29
30
|
import ReactEditorViewContext from './ReactEditorViewContext';
|
|
30
|
-
function handleEditorFocus(view
|
|
31
|
+
function handleEditorFocus(view) {
|
|
31
32
|
if (view.hasFocus()) {
|
|
32
33
|
return;
|
|
33
34
|
}
|
|
@@ -39,12 +40,6 @@ function handleEditorFocus(view, viewMode) {
|
|
|
39
40
|
view.focus();
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
42
|
-
if (viewMode === 'view') {
|
|
43
|
-
const emptySelection = new TextSelection(view.state.doc.resolve(0));
|
|
44
|
-
const tr = view.state.tr.setSelection(emptySelection);
|
|
45
|
-
view.dispatch(tr);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
43
|
const domSelection = window.getSelection();
|
|
49
44
|
if (!domSelection || domSelection.rangeCount === 0) {
|
|
50
45
|
view.focus();
|
|
@@ -114,11 +109,6 @@ export class ReactEditorView extends React.Component {
|
|
|
114
109
|
return (_this$view = this.view) === null || _this$view === void 0 ? void 0 : _this$view.state;
|
|
115
110
|
});
|
|
116
111
|
_defineProperty(this, "getEditorView", () => this.view);
|
|
117
|
-
_defineProperty(this, "getViewMode", () => {
|
|
118
|
-
var _editorApi$editorView;
|
|
119
|
-
const editorApi = this.pluginInjectionAPI.api();
|
|
120
|
-
return (_editorApi$editorView = editorApi.editorViewMode) === null || _editorApi$editorView === void 0 ? void 0 : _editorApi$editorView.sharedState.currentState().mode;
|
|
121
|
-
});
|
|
122
112
|
_defineProperty(this, "formatFullWidthAppearance", appearance => {
|
|
123
113
|
if (appearance === 'full-width') {
|
|
124
114
|
return FULL_WIDTH_MODE.FULL_WIDTH;
|
|
@@ -172,6 +162,7 @@ export class ReactEditorView extends React.Component {
|
|
|
172
162
|
});
|
|
173
163
|
_defineProperty(this, "editorPlugins", []);
|
|
174
164
|
_defineProperty(this, "createEditorState", options => {
|
|
165
|
+
var _api$editorViewMode;
|
|
175
166
|
let schema;
|
|
176
167
|
if (this.view) {
|
|
177
168
|
if (options.resetting) {
|
|
@@ -220,18 +211,44 @@ export class ReactEditorView extends React.Component {
|
|
|
220
211
|
if (options.doc) {
|
|
221
212
|
doc = processRawValue(schema, options.doc, options.props.providerFactory, options.props.editorProps.sanitizePrivateContent, this.contentTransformer, this.dispatchAnalyticsEvent);
|
|
222
213
|
}
|
|
214
|
+
const api = this.pluginInjectionAPI.api();
|
|
215
|
+
const isViewMode = (api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.currentState().mode) === 'view';
|
|
223
216
|
let selection;
|
|
224
|
-
if (
|
|
225
|
-
|
|
217
|
+
if (getBooleanFF('platform.editor.live-view.no-editor-selection-in-view-mode')) {
|
|
218
|
+
if (doc) {
|
|
219
|
+
if (isViewMode) {
|
|
220
|
+
const emptySelection = new TextSelection(doc.resolve(0));
|
|
221
|
+
return EditorState.create({
|
|
222
|
+
schema,
|
|
223
|
+
plugins: plugins,
|
|
224
|
+
doc,
|
|
225
|
+
selection: emptySelection
|
|
226
|
+
});
|
|
227
|
+
} else {
|
|
228
|
+
selection = options.selectionAtStart ? Selection.atStart(doc) : Selection.atEnd(doc);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
// Workaround for ED-3507: When media node is the last element, scrollIntoView throws an error
|
|
232
|
+
const patchedSelection = selection ? Selection.findFrom(selection.$head, -1, true) || undefined : undefined;
|
|
233
|
+
return EditorState.create({
|
|
234
|
+
schema,
|
|
235
|
+
plugins: plugins,
|
|
236
|
+
doc,
|
|
237
|
+
selection: patchedSelection
|
|
238
|
+
});
|
|
239
|
+
} else {
|
|
240
|
+
if (doc) {
|
|
241
|
+
selection = options.selectionAtStart ? Selection.atStart(doc) : Selection.atEnd(doc);
|
|
242
|
+
}
|
|
243
|
+
// Workaround for ED-3507: When media node is the last element, scrollIntoView throws an error
|
|
244
|
+
const patchedSelection = selection ? Selection.findFrom(selection.$head, -1, true) || undefined : undefined;
|
|
245
|
+
return EditorState.create({
|
|
246
|
+
schema,
|
|
247
|
+
plugins: plugins,
|
|
248
|
+
doc,
|
|
249
|
+
selection: patchedSelection
|
|
250
|
+
});
|
|
226
251
|
}
|
|
227
|
-
// Workaround for ED-3507: When media node is the last element, scrollIntoView throws an error
|
|
228
|
-
const patchedSelection = selection ? Selection.findFrom(selection.$head, -1, true) || undefined : undefined;
|
|
229
|
-
return EditorState.create({
|
|
230
|
-
schema,
|
|
231
|
-
plugins: plugins,
|
|
232
|
-
doc,
|
|
233
|
-
selection: patchedSelection
|
|
234
|
-
});
|
|
235
252
|
});
|
|
236
253
|
_defineProperty(this, "onEditorViewStateUpdated", ({
|
|
237
254
|
originalTransaction,
|
|
@@ -458,7 +475,7 @@ export class ReactEditorView extends React.Component {
|
|
|
458
475
|
transformer: this.contentTransformer
|
|
459
476
|
});
|
|
460
477
|
if (this.props.editorProps.shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
461
|
-
this.focusTimeoutId = handleEditorFocus(view
|
|
478
|
+
this.focusTimeoutId = handleEditorFocus(view);
|
|
462
479
|
}
|
|
463
480
|
if (this.featureFlags.ufo) {
|
|
464
481
|
this.experienceStore = ExperienceStore.getInstance(view);
|
|
@@ -544,11 +561,11 @@ export class ReactEditorView extends React.Component {
|
|
|
544
561
|
getEditorState: this.getEditorState,
|
|
545
562
|
getEditorView: this.getEditorView
|
|
546
563
|
});
|
|
547
|
-
const
|
|
548
|
-
(_props$setEditorApi = props.setEditorApi) === null || _props$setEditorApi === void 0 ? void 0 : _props$setEditorApi.call(props,
|
|
564
|
+
const _api = this.pluginInjectionAPI.api();
|
|
565
|
+
(_props$setEditorApi = props.setEditorApi) === null || _props$setEditorApi === void 0 ? void 0 : _props$setEditorApi.call(props, _api);
|
|
549
566
|
if (props.editorProps.editorActions) {
|
|
550
567
|
// @ts-expect-error
|
|
551
|
-
props.editorProps.editorActions.__EDITOR_INTERNALS_DO_NOT_USE__API =
|
|
568
|
+
props.editorProps.editorActions.__EDITOR_INTERNALS_DO_NOT_USE__API = _api;
|
|
552
569
|
}
|
|
553
570
|
this.eventDispatcher = new EventDispatcher();
|
|
554
571
|
this.dispatch = createDispatch(this.eventDispatcher);
|
|
@@ -594,7 +611,7 @@ export class ReactEditorView extends React.Component {
|
|
|
594
611
|
editable: _state => !nextProps.editorProps.disabled
|
|
595
612
|
});
|
|
596
613
|
if (!nextProps.editorProps.disabled && nextProps.editorProps.shouldFocus) {
|
|
597
|
-
this.focusTimeoutId = handleEditorFocus(this.view
|
|
614
|
+
this.focusTimeoutId = handleEditorFocus(this.view);
|
|
598
615
|
}
|
|
599
616
|
}
|
|
600
617
|
const {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = "@atlaskit/editor-core";
|
|
2
|
-
export const version = "193.24.
|
|
2
|
+
export const version = "193.24.19";
|
|
@@ -22,6 +22,7 @@ import { EDIT_AREA_ID } from '@atlaskit/editor-common/ui';
|
|
|
22
22
|
import { analyticsEventKey, browser, countNodes as _countNodes, getAnalyticsEventSeverity, getResponseEndTime, measureRender, processRawValue, shouldForceTracking, startMeasure, stopMeasure } from '@atlaskit/editor-common/utils';
|
|
23
23
|
import { EditorState, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
24
24
|
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
25
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
25
26
|
import { createDispatch, EventDispatcher } from '../event-dispatcher';
|
|
26
27
|
import { getNodesCount } from '../utils/document';
|
|
27
28
|
import { isFullPage } from '../utils/is-full-page';
|
|
@@ -38,7 +39,7 @@ import { createSchema } from './create-schema';
|
|
|
38
39
|
import { createFeatureFlagsFromProps } from './feature-flags-from-props';
|
|
39
40
|
import { editorMessages } from './messages';
|
|
40
41
|
import ReactEditorViewContext from './ReactEditorViewContext';
|
|
41
|
-
function handleEditorFocus(view
|
|
42
|
+
function handleEditorFocus(view) {
|
|
42
43
|
if (view.hasFocus()) {
|
|
43
44
|
return;
|
|
44
45
|
}
|
|
@@ -50,12 +51,6 @@ function handleEditorFocus(view, viewMode) {
|
|
|
50
51
|
view.focus();
|
|
51
52
|
return;
|
|
52
53
|
}
|
|
53
|
-
if (viewMode === 'view') {
|
|
54
|
-
var emptySelection = new TextSelection(view.state.doc.resolve(0));
|
|
55
|
-
var _tr = view.state.tr.setSelection(emptySelection);
|
|
56
|
-
view.dispatch(_tr);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
54
|
var domSelection = window.getSelection();
|
|
60
55
|
if (!domSelection || domSelection.rangeCount === 0) {
|
|
61
56
|
view.focus();
|
|
@@ -112,11 +107,6 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
|
|
|
112
107
|
_defineProperty(_assertThisInitialized(_this), "getEditorView", function () {
|
|
113
108
|
return _this.view;
|
|
114
109
|
});
|
|
115
|
-
_defineProperty(_assertThisInitialized(_this), "getViewMode", function () {
|
|
116
|
-
var _editorApi$editorView;
|
|
117
|
-
var editorApi = _this.pluginInjectionAPI.api();
|
|
118
|
-
return (_editorApi$editorView = editorApi.editorViewMode) === null || _editorApi$editorView === void 0 ? void 0 : _editorApi$editorView.sharedState.currentState().mode;
|
|
119
|
-
});
|
|
120
110
|
_defineProperty(_assertThisInitialized(_this), "formatFullWidthAppearance", function (appearance) {
|
|
121
111
|
if (appearance === 'full-width') {
|
|
122
112
|
return FULL_WIDTH_MODE.FULL_WIDTH;
|
|
@@ -169,6 +159,7 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
|
|
|
169
159
|
});
|
|
170
160
|
_defineProperty(_assertThisInitialized(_this), "editorPlugins", []);
|
|
171
161
|
_defineProperty(_assertThisInitialized(_this), "createEditorState", function (options) {
|
|
162
|
+
var _api$editorViewMode;
|
|
172
163
|
var schema;
|
|
173
164
|
if (_this.view) {
|
|
174
165
|
if (options.resetting) {
|
|
@@ -219,18 +210,44 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
|
|
|
219
210
|
if (options.doc) {
|
|
220
211
|
doc = processRawValue(schema, options.doc, options.props.providerFactory, options.props.editorProps.sanitizePrivateContent, _this.contentTransformer, _this.dispatchAnalyticsEvent);
|
|
221
212
|
}
|
|
213
|
+
var api = _this.pluginInjectionAPI.api();
|
|
214
|
+
var isViewMode = (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.currentState().mode) === 'view';
|
|
222
215
|
var selection;
|
|
223
|
-
if (
|
|
224
|
-
|
|
216
|
+
if (getBooleanFF('platform.editor.live-view.no-editor-selection-in-view-mode')) {
|
|
217
|
+
if (doc) {
|
|
218
|
+
if (isViewMode) {
|
|
219
|
+
var emptySelection = new TextSelection(doc.resolve(0));
|
|
220
|
+
return EditorState.create({
|
|
221
|
+
schema: schema,
|
|
222
|
+
plugins: plugins,
|
|
223
|
+
doc: doc,
|
|
224
|
+
selection: emptySelection
|
|
225
|
+
});
|
|
226
|
+
} else {
|
|
227
|
+
selection = options.selectionAtStart ? Selection.atStart(doc) : Selection.atEnd(doc);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
// Workaround for ED-3507: When media node is the last element, scrollIntoView throws an error
|
|
231
|
+
var patchedSelection = selection ? Selection.findFrom(selection.$head, -1, true) || undefined : undefined;
|
|
232
|
+
return EditorState.create({
|
|
233
|
+
schema: schema,
|
|
234
|
+
plugins: plugins,
|
|
235
|
+
doc: doc,
|
|
236
|
+
selection: patchedSelection
|
|
237
|
+
});
|
|
238
|
+
} else {
|
|
239
|
+
if (doc) {
|
|
240
|
+
selection = options.selectionAtStart ? Selection.atStart(doc) : Selection.atEnd(doc);
|
|
241
|
+
}
|
|
242
|
+
// Workaround for ED-3507: When media node is the last element, scrollIntoView throws an error
|
|
243
|
+
var _patchedSelection = selection ? Selection.findFrom(selection.$head, -1, true) || undefined : undefined;
|
|
244
|
+
return EditorState.create({
|
|
245
|
+
schema: schema,
|
|
246
|
+
plugins: plugins,
|
|
247
|
+
doc: doc,
|
|
248
|
+
selection: _patchedSelection
|
|
249
|
+
});
|
|
225
250
|
}
|
|
226
|
-
// Workaround for ED-3507: When media node is the last element, scrollIntoView throws an error
|
|
227
|
-
var patchedSelection = selection ? Selection.findFrom(selection.$head, -1, true) || undefined : undefined;
|
|
228
|
-
return EditorState.create({
|
|
229
|
-
schema: schema,
|
|
230
|
-
plugins: plugins,
|
|
231
|
-
doc: doc,
|
|
232
|
-
selection: patchedSelection
|
|
233
|
-
});
|
|
234
251
|
});
|
|
235
252
|
_defineProperty(_assertThisInitialized(_this), "onEditorViewStateUpdated", function (_ref2) {
|
|
236
253
|
var originalTransaction = _ref2.originalTransaction,
|
|
@@ -455,7 +472,7 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
|
|
|
455
472
|
transformer: _this.contentTransformer
|
|
456
473
|
});
|
|
457
474
|
if (_this.props.editorProps.shouldFocus && view.props.editable && view.props.editable(view.state)) {
|
|
458
|
-
_this.focusTimeoutId = handleEditorFocus(view
|
|
475
|
+
_this.focusTimeoutId = handleEditorFocus(view);
|
|
459
476
|
}
|
|
460
477
|
if (_this.featureFlags.ufo) {
|
|
461
478
|
_this.experienceStore = ExperienceStore.getInstance(view);
|
|
@@ -541,11 +558,11 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
|
|
|
541
558
|
getEditorState: _this.getEditorState,
|
|
542
559
|
getEditorView: _this.getEditorView
|
|
543
560
|
});
|
|
544
|
-
var
|
|
545
|
-
(_props$setEditorApi = props.setEditorApi) === null || _props$setEditorApi === void 0 || _props$setEditorApi.call(props,
|
|
561
|
+
var _api = _this.pluginInjectionAPI.api();
|
|
562
|
+
(_props$setEditorApi = props.setEditorApi) === null || _props$setEditorApi === void 0 || _props$setEditorApi.call(props, _api);
|
|
546
563
|
if (props.editorProps.editorActions) {
|
|
547
564
|
// @ts-expect-error
|
|
548
|
-
props.editorProps.editorActions.__EDITOR_INTERNALS_DO_NOT_USE__API =
|
|
565
|
+
props.editorProps.editorActions.__EDITOR_INTERNALS_DO_NOT_USE__API = _api;
|
|
549
566
|
}
|
|
550
567
|
_this.eventDispatcher = new EventDispatcher();
|
|
551
568
|
_this.dispatch = createDispatch(_this.eventDispatcher);
|
|
@@ -635,7 +652,7 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
|
|
|
635
652
|
}
|
|
636
653
|
});
|
|
637
654
|
if (!nextProps.editorProps.disabled && nextProps.editorProps.shouldFocus) {
|
|
638
|
-
this.focusTimeoutId = handleEditorFocus(this.view
|
|
655
|
+
this.focusTimeoutId = handleEditorFocus(this.view);
|
|
639
656
|
}
|
|
640
657
|
}
|
|
641
658
|
var appearance = this.props.editorProps.appearance;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export var name = "@atlaskit/editor-core";
|
|
2
|
-
export var version = "193.24.
|
|
2
|
+
export var version = "193.24.19";
|
|
@@ -92,7 +92,6 @@ export declare class ReactEditorView<T = {}> extends React.Component<EditorViewP
|
|
|
92
92
|
constructor(props: EditorViewProps & WrappedComponentProps & T, context: EditorReactContext);
|
|
93
93
|
getEditorState: () => EditorState | undefined;
|
|
94
94
|
getEditorView: () => EditorView | undefined;
|
|
95
|
-
getViewMode: () => 'edit' | 'view' | undefined;
|
|
96
95
|
UNSAFE_componentWillReceiveProps(nextProps: EditorViewProps): void;
|
|
97
96
|
formatFullWidthAppearance: (appearance: EditorAppearance | undefined) => FULL_WIDTH_MODE;
|
|
98
97
|
resetEditorState: ({ doc, shouldScrollToBottom, }: {
|