@atlaskit/editor-core 208.0.1 → 208.1.1

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,21 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 208.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#173477](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/173477)
8
+ [`bfdfefb6b7135`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/bfdfefb6b7135) -
9
+ [ux] Set focus before editor
10
+
11
+ ## 208.1.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [#173344](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/173344)
16
+ [`a0e9c4a83afe5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a0e9c4a83afe5) -
17
+ Add EditorNextProps export from composable-editor entry point
18
+
3
19
  ## 208.0.1
4
20
 
5
21
  ### Patch Changes
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.focusEditorElement = focusEditorElement;
7
+ function focusEditorElement(editorId) {
8
+ var parentElement = document.querySelector("[data-focus-id=\"".concat(editorId, "\"]"));
9
+ if (!(parentElement instanceof HTMLElement)) {
10
+ return;
11
+ }
12
+ parentElement.focus();
13
+ }
@@ -42,6 +42,7 @@ var _createEditor = require("./create-editor");
42
42
  var _createPluginsList = _interopRequireDefault(require("./create-plugins-list"));
43
43
  var _createSchema = require("./create-schema");
44
44
  var _messages = require("./messages");
45
+ var _focusEditorElement = require("./ReactEditorView/focusEditorElement");
45
46
  var _getUAPrefix = require("./ReactEditorView/getUAPrefix");
46
47
  var _handleEditorFocus = require("./ReactEditorView/handleEditorFocus");
47
48
  var _useDispatchTransaction = require("./ReactEditorView/useDispatchTransaction");
@@ -494,6 +495,11 @@ function ReactEditorView(props) {
494
495
  if (!liveDocWithContent || !(0, _platformFeatureFlags.fg)('platform_editor_no_cursor_on_live_doc_init')) {
495
496
  focusTimeoutId.current = (0, _handleEditorFocus.handleEditorFocus)(editorView);
496
497
  }
498
+ if ((0, _expValEquals.expValEquals)('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('cc_editor_focus_before_editor_on_load')) {
499
+ if (!disabled && shouldFocus && !(0, _document.isEmptyDocument)(editorView.state.doc)) {
500
+ (0, _focusEditorElement.focusEditorElement)(editorId.current);
501
+ }
502
+ }
497
503
  }
498
504
  } else {
499
505
  var _liveDocWithContent = (__livePage || (0, _expValEquals.expValEquals)('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true)) && !(0, _document.isEmptyDocument)(editorView.state.doc);
@@ -502,7 +508,7 @@ function ReactEditorView(props) {
502
508
  }
503
509
  }
504
510
  }
505
- }, [editorView, shouldFocus, __livePage, mitigateScrollJump]);
511
+ }, [editorView, shouldFocus, __livePage, mitigateScrollJump, disabled]);
506
512
  var scrollElement = _react.default.useRef();
507
513
  var possibleListeners = _react.default.useRef([]);
508
514
  _react.default.useEffect(function () {
@@ -619,6 +625,11 @@ function ReactEditorView(props) {
619
625
  if (!isLivePageWithContent && shouldFocus && view.props.editable && view.props.editable(view.state)) {
620
626
  focusTimeoutId.current = (0, _handleEditorFocus.handleEditorFocus)(view);
621
627
  }
628
+ if ((0, _expValEquals.expValEquals)('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('cc_editor_focus_before_editor_on_load')) {
629
+ if (shouldFocus && view.props.editable && view.props.editable(view.state) && !(0, _document.isEmptyDocument)(view.state.doc)) {
630
+ (0, _focusEditorElement.focusEditorElement)(editorId.current);
631
+ }
632
+ }
622
633
  }
623
634
  } else {
624
635
  var _isLivePageWithContent = (__livePage || (0, _expValEquals.expValEquals)('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true)) && !(0, _document.isEmptyDocument)(view.state.doc) && (0, _platformFeatureFlags.fg)('platform_editor_no_cursor_on_live_doc_init');
@@ -658,7 +669,11 @@ function ReactEditorView(props) {
658
669
  }
659
670
  }, [createEditorView, onEditorCreated, eventDispatcher, shouldFocus, __livePage, onEditorDestroyed, handleAnalyticsEvent, mitigateScrollJump]);
660
671
  var createEditor = (0, _react.useCallback)(function (assistiveLabel, assistiveDescribedBy) {
661
- return /*#__PURE__*/_react.default.createElement("div", {
672
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, (0, _platformFeatureFlags.fg)('cc_editor_focus_before_editor_on_load') && /*#__PURE__*/_react.default.createElement("div", {
673
+ tabIndex: -1,
674
+ "data-focus-id": editorId.current,
675
+ "data-testid": "react-editor-view-inital-focus-element"
676
+ }), /*#__PURE__*/_react.default.createElement("div", {
662
677
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
663
678
  className: ((0, _expValEquals.expValEquals)('platform_editor_stable_editorview_classname', 'isEnabled', true) ? 'ProseMirror ' : '') + (0, _getUAPrefix.getUAPrefix)(),
664
679
  key: "ProseMirror",
@@ -675,7 +690,7 @@ function ReactEditorView(props) {
675
690
  id: EDIT_AREA_ID,
676
691
  "aria-describedby": assistiveDescribedBy,
677
692
  "data-editor-id": editorId.current
678
- });
693
+ }));
679
694
  }, [handleEditorViewRef, props.intl]);
680
695
  var previousPreset = (0, _hooks.usePreviousState)(preset);
681
696
  (0, _react.useLayoutEffect)(function () {
@@ -696,6 +711,11 @@ function ReactEditorView(props) {
696
711
  if (!disabled && shouldFocus && !isLivePageWithContent) {
697
712
  focusTimeoutId.current = (0, _handleEditorFocus.handleEditorFocus)(viewRef.current);
698
713
  }
714
+ if ((0, _expValEquals.expValEquals)('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('cc_editor_focus_before_editor_on_load')) {
715
+ if (!disabled && shouldFocus && !(0, _document.isEmptyDocument)(viewRef.current.state.doc)) {
716
+ (0, _focusEditorElement.focusEditorElement)(editorId.current);
717
+ }
718
+ }
699
719
  }
700
720
  }, [disabled, shouldFocus, previousDisabledState, __livePage]);
701
721
  (0, _useFireFullWidthEvent.useFireFullWidthEvent)(nextAppearance, dispatchAnalyticsEvent);
@@ -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 = "208.0.0";
8
+ var version = exports.version = "208.1.0";
@@ -0,0 +1,7 @@
1
+ export function focusEditorElement(editorId) {
2
+ const parentElement = document.querySelector(`[data-focus-id="${editorId}"]`);
3
+ if (!(parentElement instanceof HTMLElement)) {
4
+ return;
5
+ }
6
+ parentElement.focus();
7
+ }
@@ -30,6 +30,7 @@ import { createErrorReporter, createPMPlugins, processPluginsList } from './crea
30
30
  import createPluginsList from './create-plugins-list';
31
31
  import { createSchema } from './create-schema';
32
32
  import { editorMessages } from './messages';
33
+ import { focusEditorElement } from './ReactEditorView/focusEditorElement';
33
34
  import { getUAPrefix } from './ReactEditorView/getUAPrefix';
34
35
  import { handleEditorFocus } from './ReactEditorView/handleEditorFocus';
35
36
  import { useDispatchTransaction } from './ReactEditorView/useDispatchTransaction';
@@ -461,6 +462,11 @@ export function ReactEditorView(props) {
461
462
  if (!liveDocWithContent || !fg('platform_editor_no_cursor_on_live_doc_init')) {
462
463
  focusTimeoutId.current = handleEditorFocus(editorView);
463
464
  }
465
+ if (expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true) && fg('cc_editor_focus_before_editor_on_load')) {
466
+ if (!disabled && shouldFocus && !isEmptyDocument(editorView.state.doc)) {
467
+ focusEditorElement(editorId.current);
468
+ }
469
+ }
464
470
  }
465
471
  } else {
466
472
  const liveDocWithContent = (__livePage || expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true)) && !isEmptyDocument(editorView.state.doc);
@@ -469,7 +475,7 @@ export function ReactEditorView(props) {
469
475
  }
470
476
  }
471
477
  }
472
- }, [editorView, shouldFocus, __livePage, mitigateScrollJump]);
478
+ }, [editorView, shouldFocus, __livePage, mitigateScrollJump, disabled]);
473
479
  const scrollElement = React.useRef();
474
480
  const possibleListeners = React.useRef([]);
475
481
  React.useEffect(() => {
@@ -566,6 +572,11 @@ export function ReactEditorView(props) {
566
572
  if (!isLivePageWithContent && shouldFocus && view.props.editable && view.props.editable(view.state)) {
567
573
  focusTimeoutId.current = handleEditorFocus(view);
568
574
  }
575
+ if (expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true) && fg('cc_editor_focus_before_editor_on_load')) {
576
+ if (shouldFocus && view.props.editable && view.props.editable(view.state) && !isEmptyDocument(view.state.doc)) {
577
+ focusEditorElement(editorId.current);
578
+ }
579
+ }
569
580
  }
570
581
  } else {
571
582
  const isLivePageWithContent = (__livePage || expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true)) && !isEmptyDocument(view.state.doc) && fg('platform_editor_no_cursor_on_live_doc_init');
@@ -605,7 +616,11 @@ export function ReactEditorView(props) {
605
616
  }
606
617
  }, [createEditorView, onEditorCreated, eventDispatcher, shouldFocus, __livePage, onEditorDestroyed, handleAnalyticsEvent, mitigateScrollJump]);
607
618
  const createEditor = useCallback((assistiveLabel, assistiveDescribedBy) => {
608
- return /*#__PURE__*/React.createElement("div", {
619
+ return /*#__PURE__*/React.createElement(React.Fragment, null, fg('cc_editor_focus_before_editor_on_load') && /*#__PURE__*/React.createElement("div", {
620
+ tabIndex: -1,
621
+ "data-focus-id": editorId.current,
622
+ "data-testid": "react-editor-view-inital-focus-element"
623
+ }), /*#__PURE__*/React.createElement("div", {
609
624
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
610
625
  className: (expValEquals('platform_editor_stable_editorview_classname', 'isEnabled', true) ? 'ProseMirror ' : '') + getUAPrefix(),
611
626
  key: "ProseMirror",
@@ -622,7 +637,7 @@ export function ReactEditorView(props) {
622
637
  id: EDIT_AREA_ID,
623
638
  "aria-describedby": assistiveDescribedBy,
624
639
  "data-editor-id": editorId.current
625
- });
640
+ }));
626
641
  }, [handleEditorViewRef, props.intl]);
627
642
  const previousPreset = usePreviousState(preset);
628
643
  useLayoutEffect(() => {
@@ -641,6 +656,11 @@ export function ReactEditorView(props) {
641
656
  if (!disabled && shouldFocus && !isLivePageWithContent) {
642
657
  focusTimeoutId.current = handleEditorFocus(viewRef.current);
643
658
  }
659
+ if (expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true) && fg('cc_editor_focus_before_editor_on_load')) {
660
+ if (!disabled && shouldFocus && !isEmptyDocument(viewRef.current.state.doc)) {
661
+ focusEditorElement(editorId.current);
662
+ }
663
+ }
644
664
  }
645
665
  }, [disabled, shouldFocus, previousDisabledState, __livePage]);
646
666
  useFireFullWidthEvent(nextAppearance, dispatchAnalyticsEvent);
@@ -1,2 +1,2 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "208.0.0";
2
+ export const version = "208.1.0";
@@ -0,0 +1,7 @@
1
+ export function focusEditorElement(editorId) {
2
+ var parentElement = document.querySelector("[data-focus-id=\"".concat(editorId, "\"]"));
3
+ if (!(parentElement instanceof HTMLElement)) {
4
+ return;
5
+ }
6
+ parentElement.focus();
7
+ }
@@ -38,6 +38,7 @@ import { createErrorReporter, createPMPlugins, processPluginsList } from './crea
38
38
  import createPluginsList from './create-plugins-list';
39
39
  import { createSchema } from './create-schema';
40
40
  import { editorMessages } from './messages';
41
+ import { focusEditorElement } from './ReactEditorView/focusEditorElement';
41
42
  import { getUAPrefix } from './ReactEditorView/getUAPrefix';
42
43
  import { handleEditorFocus } from './ReactEditorView/handleEditorFocus';
43
44
  import { useDispatchTransaction } from './ReactEditorView/useDispatchTransaction';
@@ -484,6 +485,11 @@ export function ReactEditorView(props) {
484
485
  if (!liveDocWithContent || !fg('platform_editor_no_cursor_on_live_doc_init')) {
485
486
  focusTimeoutId.current = handleEditorFocus(editorView);
486
487
  }
488
+ if (expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true) && fg('cc_editor_focus_before_editor_on_load')) {
489
+ if (!disabled && shouldFocus && !isEmptyDocument(editorView.state.doc)) {
490
+ focusEditorElement(editorId.current);
491
+ }
492
+ }
487
493
  }
488
494
  } else {
489
495
  var _liveDocWithContent = (__livePage || expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true)) && !isEmptyDocument(editorView.state.doc);
@@ -492,7 +498,7 @@ export function ReactEditorView(props) {
492
498
  }
493
499
  }
494
500
  }
495
- }, [editorView, shouldFocus, __livePage, mitigateScrollJump]);
501
+ }, [editorView, shouldFocus, __livePage, mitigateScrollJump, disabled]);
496
502
  var scrollElement = React.useRef();
497
503
  var possibleListeners = React.useRef([]);
498
504
  React.useEffect(function () {
@@ -609,6 +615,11 @@ export function ReactEditorView(props) {
609
615
  if (!isLivePageWithContent && shouldFocus && view.props.editable && view.props.editable(view.state)) {
610
616
  focusTimeoutId.current = handleEditorFocus(view);
611
617
  }
618
+ if (expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true) && fg('cc_editor_focus_before_editor_on_load')) {
619
+ if (shouldFocus && view.props.editable && view.props.editable(view.state) && !isEmptyDocument(view.state.doc)) {
620
+ focusEditorElement(editorId.current);
621
+ }
622
+ }
612
623
  }
613
624
  } else {
614
625
  var _isLivePageWithContent = (__livePage || expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true)) && !isEmptyDocument(view.state.doc) && fg('platform_editor_no_cursor_on_live_doc_init');
@@ -648,7 +659,11 @@ export function ReactEditorView(props) {
648
659
  }
649
660
  }, [createEditorView, onEditorCreated, eventDispatcher, shouldFocus, __livePage, onEditorDestroyed, handleAnalyticsEvent, mitigateScrollJump]);
650
661
  var createEditor = useCallback(function (assistiveLabel, assistiveDescribedBy) {
651
- return /*#__PURE__*/React.createElement("div", {
662
+ return /*#__PURE__*/React.createElement(React.Fragment, null, fg('cc_editor_focus_before_editor_on_load') && /*#__PURE__*/React.createElement("div", {
663
+ tabIndex: -1,
664
+ "data-focus-id": editorId.current,
665
+ "data-testid": "react-editor-view-inital-focus-element"
666
+ }), /*#__PURE__*/React.createElement("div", {
652
667
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
653
668
  className: (expValEquals('platform_editor_stable_editorview_classname', 'isEnabled', true) ? 'ProseMirror ' : '') + getUAPrefix(),
654
669
  key: "ProseMirror",
@@ -665,7 +680,7 @@ export function ReactEditorView(props) {
665
680
  id: EDIT_AREA_ID,
666
681
  "aria-describedby": assistiveDescribedBy,
667
682
  "data-editor-id": editorId.current
668
- });
683
+ }));
669
684
  }, [handleEditorViewRef, props.intl]);
670
685
  var previousPreset = usePreviousState(preset);
671
686
  useLayoutEffect(function () {
@@ -686,6 +701,11 @@ export function ReactEditorView(props) {
686
701
  if (!disabled && shouldFocus && !isLivePageWithContent) {
687
702
  focusTimeoutId.current = handleEditorFocus(viewRef.current);
688
703
  }
704
+ if (expValEquals('platform_editor_no_cursor_on_edit_page_init', 'isEnabled', true) && fg('cc_editor_focus_before_editor_on_load')) {
705
+ if (!disabled && shouldFocus && !isEmptyDocument(viewRef.current.state.doc)) {
706
+ focusEditorElement(editorId.current);
707
+ }
708
+ }
689
709
  }
690
710
  }, [disabled, shouldFocus, previousDisabledState, __livePage]);
691
711
  useFireFullWidthEvent(nextAppearance, dispatchAnalyticsEvent);
@@ -1,2 +1,2 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "208.0.0";
2
+ export var version = "208.1.0";
@@ -1 +1,2 @@
1
1
  export { ComposableEditor } from './composable-editor/composable-editor';
2
+ export type { EditorNextProps } from './types/editor-props';
@@ -0,0 +1 @@
1
+ export declare function focusEditorElement(editorId: string): void;
@@ -1 +1,2 @@
1
1
  export { ComposableEditor } from './composable-editor/composable-editor';
2
+ export type { EditorNextProps } from './types/editor-props';
@@ -0,0 +1 @@
1
+ export declare function focusEditorElement(editorId: string): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "208.0.1",
3
+ "version": "208.1.1",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -105,7 +105,7 @@
105
105
  "@atlaskit/primitives": "^14.9.0",
106
106
  "@atlaskit/renderer": "^119.0.0",
107
107
  "@atlaskit/section-message": "^8.2.0",
108
- "@atlaskit/smart-card": "^38.10.0",
108
+ "@atlaskit/smart-card": "^38.11.0",
109
109
  "@atlaskit/synchrony-test-helpers": "workspace:^",
110
110
  "@atlaskit/toggle": "^15.0.0",
111
111
  "@atlaskit/util-data-test": "^18.0.0",
@@ -556,10 +556,6 @@
556
556
  "type": "boolean",
557
557
  "referenceOnly": true
558
558
  },
559
- "platform_editor_controls_patch_8": {
560
- "type": "boolean",
561
- "referenceOnly": true
562
- },
563
559
  "platform_editor_controls_patch_9": {
564
560
  "type": "boolean",
565
561
  "referenceOnly": true
@@ -584,10 +580,6 @@
584
580
  "type": "boolean",
585
581
  "referenceOnly": true
586
582
  },
587
- "platform_editor_controls_table_picker": {
588
- "type": "boolean",
589
- "referenceOnly": true
590
- },
591
583
  "platform_editor_tables_table_selector": {
592
584
  "type": "boolean",
593
585
  "referenceOnly": true
@@ -640,6 +632,9 @@
640
632
  },
641
633
  "platform_editor_system_fake_text_highlight_colour": {
642
634
  "type": "boolean"
635
+ },
636
+ "cc_editor_focus_before_editor_on_load": {
637
+ "type": "boolean"
643
638
  }
644
639
  },
645
640
  "stricter": {