@atlaskit/editor-common 103.20.0 → 103.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-common
2
2
 
3
+ ## 103.21.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#142736](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/142736)
8
+ [`0ec12ef9f6524`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0ec12ef9f6524) -
9
+ [ux] scrollToPos function added to the core plugin. It can be accessed via
10
+ editorAPI.core.actions.scrollToPos().
11
+
3
12
  ## 103.20.0
4
13
 
5
14
  ### Minor Changes
@@ -17,7 +17,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
17
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
18
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
19
19
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
20
- var packageVersion = "103.20.0";
20
+ var packageVersion = "103.21.0";
21
21
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
22
22
  // Remove URL as it has UGC
23
23
  // Ignored via go/ees007
@@ -54,6 +54,29 @@ var corePlugin = exports.corePlugin = function corePlugin(_ref) {
54
54
  editorView.dom.blur();
55
55
  return true;
56
56
  },
57
+ scrollToPos: function scrollToPos(pos, scrollOptions) {
58
+ var editorView = config === null || config === void 0 ? void 0 : config.getEditorView();
59
+ if (!editorView) {
60
+ return false;
61
+ }
62
+ var tr = editorView.state.tr;
63
+ var isValidPos = typeof pos === 'number' && pos >= 0 && pos <= tr.doc.content.size;
64
+ if (!isValidPos) {
65
+ return false;
66
+ }
67
+ var dom = editorView.domAtPos(pos).node;
68
+ if (!(dom instanceof Element)) {
69
+ // If it's not an element (e.g. #text node), we'll try the parent.
70
+ // This is expected to cover most of the scenarios, if not, window.scrollTo is an alternative
71
+ if (dom.parentNode instanceof Element) {
72
+ dom.parentNode.scrollIntoView(scrollOptions);
73
+ return true;
74
+ }
75
+ return false;
76
+ }
77
+ dom.scrollIntoView(scrollOptions);
78
+ return true;
79
+ },
57
80
  replaceDocument: function replaceDocument(replaceValue, options) {
58
81
  var editorView = config === null || config === void 0 ? void 0 : config.getEditorView();
59
82
  if (!editorView || replaceValue === undefined || replaceValue === null) {
@@ -23,7 +23,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
23
23
  * @jsx jsx
24
24
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
25
25
  var packageName = "@atlaskit/editor-common";
26
- var packageVersion = "103.20.0";
26
+ var packageVersion = "103.21.0";
27
27
  var halfFocusRing = 1;
28
28
  var dropOffset = '0, 8';
29
29
  // Ignored via go/ees005
@@ -1,7 +1,7 @@
1
1
  import { isFedRamp } from './environment';
2
2
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
3
3
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
4
- const packageVersion = "103.20.0";
4
+ const packageVersion = "103.21.0";
5
5
  const sanitiseSentryEvents = (data, _hint) => {
6
6
  // Remove URL as it has UGC
7
7
  // Ignored via go/ees007
@@ -52,6 +52,29 @@ export const corePlugin = ({
52
52
  editorView.dom.blur();
53
53
  return true;
54
54
  },
55
+ scrollToPos(pos, scrollOptions) {
56
+ const editorView = config === null || config === void 0 ? void 0 : config.getEditorView();
57
+ if (!editorView) {
58
+ return false;
59
+ }
60
+ const tr = editorView.state.tr;
61
+ const isValidPos = typeof pos === 'number' && pos >= 0 && pos <= tr.doc.content.size;
62
+ if (!isValidPos) {
63
+ return false;
64
+ }
65
+ const dom = editorView.domAtPos(pos).node;
66
+ if (!(dom instanceof Element)) {
67
+ // If it's not an element (e.g. #text node), we'll try the parent.
68
+ // This is expected to cover most of the scenarios, if not, window.scrollTo is an alternative
69
+ if (dom.parentNode instanceof Element) {
70
+ dom.parentNode.scrollIntoView(scrollOptions);
71
+ return true;
72
+ }
73
+ return false;
74
+ }
75
+ dom.scrollIntoView(scrollOptions);
76
+ return true;
77
+ },
55
78
  replaceDocument: (replaceValue, options) => {
56
79
  const editorView = config === null || config === void 0 ? void 0 : config.getEditorView();
57
80
  if (!editorView || replaceValue === undefined || replaceValue === null) {
@@ -13,7 +13,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
13
13
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
14
14
  import Layer from '../Layer';
15
15
  const packageName = "@atlaskit/editor-common";
16
- const packageVersion = "103.20.0";
16
+ const packageVersion = "103.21.0";
17
17
  const halfFocusRing = 1;
18
18
  const dropOffset = '0, 8';
19
19
  // Ignored via go/ees005
@@ -7,7 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
7
7
  import { isFedRamp } from './environment';
8
8
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
9
9
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
10
- var packageVersion = "103.20.0";
10
+ var packageVersion = "103.21.0";
11
11
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
12
12
  // Remove URL as it has UGC
13
13
  // Ignored via go/ees007
@@ -49,6 +49,29 @@ export var corePlugin = function corePlugin(_ref) {
49
49
  editorView.dom.blur();
50
50
  return true;
51
51
  },
52
+ scrollToPos: function scrollToPos(pos, scrollOptions) {
53
+ var editorView = config === null || config === void 0 ? void 0 : config.getEditorView();
54
+ if (!editorView) {
55
+ return false;
56
+ }
57
+ var tr = editorView.state.tr;
58
+ var isValidPos = typeof pos === 'number' && pos >= 0 && pos <= tr.doc.content.size;
59
+ if (!isValidPos) {
60
+ return false;
61
+ }
62
+ var dom = editorView.domAtPos(pos).node;
63
+ if (!(dom instanceof Element)) {
64
+ // If it's not an element (e.g. #text node), we'll try the parent.
65
+ // This is expected to cover most of the scenarios, if not, window.scrollTo is an alternative
66
+ if (dom.parentNode instanceof Element) {
67
+ dom.parentNode.scrollIntoView(scrollOptions);
68
+ return true;
69
+ }
70
+ return false;
71
+ }
72
+ dom.scrollIntoView(scrollOptions);
73
+ return true;
74
+ },
52
75
  replaceDocument: function replaceDocument(replaceValue, options) {
53
76
  var editorView = config === null || config === void 0 ? void 0 : config.getEditorView();
54
77
  if (!editorView || replaceValue === undefined || replaceValue === null) {
@@ -20,7 +20,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
20
20
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
21
21
  import Layer from '../Layer';
22
22
  var packageName = "@atlaskit/editor-common";
23
- var packageVersion = "103.20.0";
23
+ var packageVersion = "103.21.0";
24
24
  var halfFocusRing = 1;
25
25
  var dropOffset = '0, 8';
26
26
  // Ignored via go/ees005
@@ -50,6 +50,14 @@ export type CorePlugin = NextEditorPlugin<'core', {
50
50
  * @returns (boolean) if the blur was successful
51
51
  */
52
52
  blur: () => boolean;
53
+ /**
54
+ * Scroll to a specific position in the editor using native Element.scrollIntoView
55
+ *
56
+ * @param pos - Position number scroll to
57
+ * @param scrollOptions - [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/scrollIntoView)
58
+ * @returns (boolean) if scroll was successful
59
+ */
60
+ scrollToPos: (pos: number, scrollOptions?: boolean | ScrollIntoViewOptions) => boolean;
53
61
  /**
54
62
  * Replaces the current content of the editor with the provided raw value.
55
63
  *
@@ -50,6 +50,14 @@ export type CorePlugin = NextEditorPlugin<'core', {
50
50
  * @returns (boolean) if the blur was successful
51
51
  */
52
52
  blur: () => boolean;
53
+ /**
54
+ * Scroll to a specific position in the editor using native Element.scrollIntoView
55
+ *
56
+ * @param pos - Position number scroll to
57
+ * @param scrollOptions - [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/scrollIntoView)
58
+ * @returns (boolean) if scroll was successful
59
+ */
60
+ scrollToPos: (pos: number, scrollOptions?: boolean | ScrollIntoViewOptions) => boolean;
53
61
  /**
54
62
  * Replaces the current content of the editor with the provided raw value.
55
63
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "103.20.0",
3
+ "version": "103.21.0",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -156,10 +156,10 @@
156
156
  "@atlaskit/platform-feature-flags": "^1.1.0",
157
157
  "@atlaskit/popper": "^7.0.0",
158
158
  "@atlaskit/primitives": "^14.4.0",
159
- "@atlaskit/profilecard": "^23.9.0",
159
+ "@atlaskit/profilecard": "^23.10.0",
160
160
  "@atlaskit/react-ufo": "^3.9.0",
161
161
  "@atlaskit/section-message": "^8.2.0",
162
- "@atlaskit/smart-card": "^36.11.0",
162
+ "@atlaskit/smart-card": "^36.12.0",
163
163
  "@atlaskit/smart-user-picker": "^8.0.0",
164
164
  "@atlaskit/spinner": "^18.0.0",
165
165
  "@atlaskit/task-decision": "^19.2.0",