@atlaskit/editor-core 193.20.0 → 193.21.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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 193.21.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#101412](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/101412)
8
+ [`2ad17f5bf590`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2ad17f5bf590) -
9
+ [ux] [ED-23363] If you are on a live page in view mode, there is no text selection when you
10
+ first load the page.
11
+
3
12
  ## 193.20.0
4
13
 
5
14
  ### Minor Changes
@@ -45,7 +45,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
45
45
  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
46
  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
47
  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) {
48
+ function handleEditorFocus(view, viewMode) {
49
49
  if (view.hasFocus()) {
50
50
  return;
51
51
  }
@@ -57,6 +57,12 @@ function handleEditorFocus(view) {
57
57
  view.focus();
58
58
  return;
59
59
  }
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
+ }
60
66
  var domSelection = window.getSelection();
61
67
  if (!domSelection || domSelection.rangeCount === 0) {
62
68
  view.focus();
@@ -113,6 +119,11 @@ var ReactEditorView = exports.ReactEditorView = /*#__PURE__*/function (_React$Co
113
119
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getEditorView", function () {
114
120
  return _this.view;
115
121
  });
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
+ });
116
127
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "formatFullWidthAppearance", function (appearance) {
117
128
  if (appearance === 'full-width') {
118
129
  return _analytics.FULL_WIDTH_MODE.FULL_WIDTH;
@@ -451,7 +462,7 @@ var ReactEditorView = exports.ReactEditorView = /*#__PURE__*/function (_React$Co
451
462
  transformer: _this.contentTransformer
452
463
  });
453
464
  if (_this.props.editorProps.shouldFocus && view.props.editable && view.props.editable(view.state)) {
454
- _this.focusTimeoutId = handleEditorFocus(view);
465
+ _this.focusTimeoutId = handleEditorFocus(view, _this.getViewMode());
455
466
  }
456
467
  if (_this.featureFlags.ufo) {
457
468
  _this.experienceStore = _ufo.ExperienceStore.getInstance(view);
@@ -630,7 +641,7 @@ var ReactEditorView = exports.ReactEditorView = /*#__PURE__*/function (_React$Co
630
641
  }
631
642
  });
632
643
  if (!nextProps.editorProps.disabled && nextProps.editorProps.shouldFocus) {
633
- this.focusTimeoutId = handleEditorFocus(this.view);
644
+ this.focusTimeoutId = handleEditorFocus(this.view, this.getViewMode());
634
645
  }
635
646
  }
636
647
  var appearance = this.props.editorProps.appearance;
@@ -5,4 +5,4 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = exports.name = void 0;
7
7
  var name = exports.name = "@atlaskit/editor-core";
8
- var version = exports.version = "193.20.0";
8
+ var version = exports.version = "193.21.0";
@@ -8,8 +8,7 @@ import { getEnabledFeatureFlagKeys } from '@atlaskit/editor-common/normalize-fea
8
8
  import { EditorPluginInjectionAPI } from '@atlaskit/editor-common/preset';
9
9
  import { EditorExperience, ExperienceStore, RELIABILITY_INTERVAL } from '@atlaskit/editor-common/ufo';
10
10
  import { EDIT_AREA_ID } from '@atlaskit/editor-common/ui';
11
- import { countNodes } from '@atlaskit/editor-common/utils';
12
- import { analyticsEventKey, browser, getAnalyticsEventSeverity, getResponseEndTime, measureRender, processRawValue, shouldForceTracking, startMeasure, stopMeasure } from '@atlaskit/editor-common/utils';
11
+ import { analyticsEventKey, browser, countNodes, getAnalyticsEventSeverity, getResponseEndTime, measureRender, processRawValue, shouldForceTracking, startMeasure, stopMeasure } from '@atlaskit/editor-common/utils';
13
12
  import { EditorState, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
14
13
  import { EditorView } from '@atlaskit/editor-prosemirror/view';
15
14
  import { createDispatch, EventDispatcher } from '../event-dispatcher';
@@ -28,7 +27,7 @@ import { createSchema } from './create-schema';
28
27
  import { createFeatureFlagsFromProps } from './feature-flags-from-props';
29
28
  import { editorMessages } from './messages';
30
29
  import ReactEditorViewContext from './ReactEditorViewContext';
31
- function handleEditorFocus(view) {
30
+ function handleEditorFocus(view, viewMode) {
32
31
  if (view.hasFocus()) {
33
32
  return;
34
33
  }
@@ -40,6 +39,12 @@ function handleEditorFocus(view) {
40
39
  view.focus();
41
40
  return;
42
41
  }
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
+ }
43
48
  const domSelection = window.getSelection();
44
49
  if (!domSelection || domSelection.rangeCount === 0) {
45
50
  view.focus();
@@ -109,6 +114,11 @@ export class ReactEditorView extends React.Component {
109
114
  return (_this$view = this.view) === null || _this$view === void 0 ? void 0 : _this$view.state;
110
115
  });
111
116
  _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
+ });
112
122
  _defineProperty(this, "formatFullWidthAppearance", appearance => {
113
123
  if (appearance === 'full-width') {
114
124
  return FULL_WIDTH_MODE.FULL_WIDTH;
@@ -448,7 +458,7 @@ export class ReactEditorView extends React.Component {
448
458
  transformer: this.contentTransformer
449
459
  });
450
460
  if (this.props.editorProps.shouldFocus && view.props.editable && view.props.editable(view.state)) {
451
- this.focusTimeoutId = handleEditorFocus(view);
461
+ this.focusTimeoutId = handleEditorFocus(view, this.getViewMode());
452
462
  }
453
463
  if (this.featureFlags.ufo) {
454
464
  this.experienceStore = ExperienceStore.getInstance(view);
@@ -583,7 +593,7 @@ export class ReactEditorView extends React.Component {
583
593
  editable: _state => !nextProps.editorProps.disabled
584
594
  });
585
595
  if (!nextProps.editorProps.disabled && nextProps.editorProps.shouldFocus) {
586
- this.focusTimeoutId = handleEditorFocus(this.view);
596
+ this.focusTimeoutId = handleEditorFocus(this.view, this.getViewMode());
587
597
  }
588
598
  }
589
599
  const {
@@ -1,2 +1,2 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "193.20.0";
2
+ export const version = "193.21.0";
@@ -19,8 +19,7 @@ import { getEnabledFeatureFlagKeys } from '@atlaskit/editor-common/normalize-fea
19
19
  import { EditorPluginInjectionAPI } from '@atlaskit/editor-common/preset';
20
20
  import { EditorExperience, ExperienceStore, RELIABILITY_INTERVAL } from '@atlaskit/editor-common/ufo';
21
21
  import { EDIT_AREA_ID } from '@atlaskit/editor-common/ui';
22
- import { countNodes as _countNodes } from '@atlaskit/editor-common/utils';
23
- import { analyticsEventKey, browser, getAnalyticsEventSeverity, getResponseEndTime, measureRender, processRawValue, shouldForceTracking, startMeasure, stopMeasure } from '@atlaskit/editor-common/utils';
22
+ import { analyticsEventKey, browser, countNodes as _countNodes, getAnalyticsEventSeverity, getResponseEndTime, measureRender, processRawValue, shouldForceTracking, startMeasure, stopMeasure } from '@atlaskit/editor-common/utils';
24
23
  import { EditorState, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
25
24
  import { EditorView } from '@atlaskit/editor-prosemirror/view';
26
25
  import { createDispatch, EventDispatcher } from '../event-dispatcher';
@@ -39,7 +38,7 @@ import { createSchema } from './create-schema';
39
38
  import { createFeatureFlagsFromProps } from './feature-flags-from-props';
40
39
  import { editorMessages } from './messages';
41
40
  import ReactEditorViewContext from './ReactEditorViewContext';
42
- function handleEditorFocus(view) {
41
+ function handleEditorFocus(view, viewMode) {
43
42
  if (view.hasFocus()) {
44
43
  return;
45
44
  }
@@ -51,6 +50,12 @@ function handleEditorFocus(view) {
51
50
  view.focus();
52
51
  return;
53
52
  }
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
+ }
54
59
  var domSelection = window.getSelection();
55
60
  if (!domSelection || domSelection.rangeCount === 0) {
56
61
  view.focus();
@@ -107,6 +112,11 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
107
112
  _defineProperty(_assertThisInitialized(_this), "getEditorView", function () {
108
113
  return _this.view;
109
114
  });
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
+ });
110
120
  _defineProperty(_assertThisInitialized(_this), "formatFullWidthAppearance", function (appearance) {
111
121
  if (appearance === 'full-width') {
112
122
  return FULL_WIDTH_MODE.FULL_WIDTH;
@@ -445,7 +455,7 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
445
455
  transformer: _this.contentTransformer
446
456
  });
447
457
  if (_this.props.editorProps.shouldFocus && view.props.editable && view.props.editable(view.state)) {
448
- _this.focusTimeoutId = handleEditorFocus(view);
458
+ _this.focusTimeoutId = handleEditorFocus(view, _this.getViewMode());
449
459
  }
450
460
  if (_this.featureFlags.ufo) {
451
461
  _this.experienceStore = ExperienceStore.getInstance(view);
@@ -624,7 +634,7 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
624
634
  }
625
635
  });
626
636
  if (!nextProps.editorProps.disabled && nextProps.editorProps.shouldFocus) {
627
- this.focusTimeoutId = handleEditorFocus(this.view);
637
+ this.focusTimeoutId = handleEditorFocus(this.view, this.getViewMode());
628
638
  }
629
639
  }
630
640
  var appearance = this.props.editorProps.appearance;
@@ -1,2 +1,2 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "193.20.0";
2
+ export var version = "193.21.0";
@@ -92,6 +92,7 @@ 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;
95
96
  UNSAFE_componentWillReceiveProps(nextProps: EditorViewProps): void;
96
97
  formatFullWidthAppearance: (appearance: EditorAppearance | undefined) => FULL_WIDTH_MODE;
97
98
  resetEditorState: ({ doc, shouldScrollToBottom, }: {
@@ -92,6 +92,7 @@ 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;
95
96
  UNSAFE_componentWillReceiveProps(nextProps: EditorViewProps): void;
96
97
  formatFullWidthAppearance: (appearance: EditorAppearance | undefined) => FULL_WIDTH_MODE;
97
98
  resetEditorState: ({ doc, shouldScrollToBottom, }: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "193.20.0",
3
+ "version": "193.21.0",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -45,7 +45,7 @@
45
45
  "@atlaskit/analytics-next": "^9.3.0",
46
46
  "@atlaskit/analytics-next-stable-react-context": "1.0.1",
47
47
  "@atlaskit/button": "^17.15.0",
48
- "@atlaskit/editor-common": "^80.4.0",
48
+ "@atlaskit/editor-common": "^80.5.0",
49
49
  "@atlaskit/editor-json-transformer": "^8.13.0",
50
50
  "@atlaskit/editor-plugins": "^2.6.0",
51
51
  "@atlaskit/editor-prosemirror": "4.0.1",