@ckeditor/ckeditor5-engine 37.0.0-alpha.1 → 37.0.0-alpha.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-engine",
3
- "version": "37.0.0-alpha.1",
3
+ "version": "37.0.0-alpha.3",
4
4
  "description": "The editing engine of CKEditor 5 – the best browser-based rich text editor.",
5
5
  "keywords": [
6
6
  "wysiwyg",
@@ -23,30 +23,30 @@
23
23
  ],
24
24
  "main": "src/index.js",
25
25
  "dependencies": {
26
- "@ckeditor/ckeditor5-utils": "^37.0.0-alpha.1",
26
+ "@ckeditor/ckeditor5-utils": "^37.0.0-alpha.3",
27
27
  "lodash-es": "^4.17.15"
28
28
  },
29
29
  "devDependencies": {
30
- "@ckeditor/ckeditor5-basic-styles": "^37.0.0-alpha.1",
31
- "@ckeditor/ckeditor5-block-quote": "^37.0.0-alpha.1",
32
- "@ckeditor/ckeditor5-clipboard": "^37.0.0-alpha.1",
33
- "@ckeditor/ckeditor5-cloud-services": "^37.0.0-alpha.1",
34
- "@ckeditor/ckeditor5-core": "^37.0.0-alpha.1",
35
- "@ckeditor/ckeditor5-editor-classic": "^37.0.0-alpha.1",
36
- "@ckeditor/ckeditor5-enter": "^37.0.0-alpha.1",
37
- "@ckeditor/ckeditor5-essentials": "^37.0.0-alpha.1",
38
- "@ckeditor/ckeditor5-heading": "^37.0.0-alpha.1",
39
- "@ckeditor/ckeditor5-image": "^37.0.0-alpha.1",
40
- "@ckeditor/ckeditor5-link": "^37.0.0-alpha.1",
41
- "@ckeditor/ckeditor5-list": "^37.0.0-alpha.1",
42
- "@ckeditor/ckeditor5-mention": "^37.0.0-alpha.1",
43
- "@ckeditor/ckeditor5-paragraph": "^37.0.0-alpha.1",
44
- "@ckeditor/ckeditor5-table": "^37.0.0-alpha.1",
45
- "@ckeditor/ckeditor5-theme-lark": "^37.0.0-alpha.1",
46
- "@ckeditor/ckeditor5-typing": "^37.0.0-alpha.1",
47
- "@ckeditor/ckeditor5-ui": "^37.0.0-alpha.1",
48
- "@ckeditor/ckeditor5-undo": "^37.0.0-alpha.1",
49
- "@ckeditor/ckeditor5-widget": "^37.0.0-alpha.1",
30
+ "@ckeditor/ckeditor5-basic-styles": "^37.0.0-alpha.3",
31
+ "@ckeditor/ckeditor5-block-quote": "^37.0.0-alpha.3",
32
+ "@ckeditor/ckeditor5-clipboard": "^37.0.0-alpha.3",
33
+ "@ckeditor/ckeditor5-cloud-services": "^37.0.0-alpha.3",
34
+ "@ckeditor/ckeditor5-core": "^37.0.0-alpha.3",
35
+ "@ckeditor/ckeditor5-editor-classic": "^37.0.0-alpha.3",
36
+ "@ckeditor/ckeditor5-enter": "^37.0.0-alpha.3",
37
+ "@ckeditor/ckeditor5-essentials": "^37.0.0-alpha.3",
38
+ "@ckeditor/ckeditor5-heading": "^37.0.0-alpha.3",
39
+ "@ckeditor/ckeditor5-image": "^37.0.0-alpha.3",
40
+ "@ckeditor/ckeditor5-link": "^37.0.0-alpha.3",
41
+ "@ckeditor/ckeditor5-list": "^37.0.0-alpha.3",
42
+ "@ckeditor/ckeditor5-mention": "^37.0.0-alpha.3",
43
+ "@ckeditor/ckeditor5-paragraph": "^37.0.0-alpha.3",
44
+ "@ckeditor/ckeditor5-table": "^37.0.0-alpha.3",
45
+ "@ckeditor/ckeditor5-theme-lark": "^37.0.0-alpha.3",
46
+ "@ckeditor/ckeditor5-typing": "^37.0.0-alpha.3",
47
+ "@ckeditor/ckeditor5-ui": "^37.0.0-alpha.3",
48
+ "@ckeditor/ckeditor5-undo": "^37.0.0-alpha.3",
49
+ "@ckeditor/ckeditor5-widget": "^37.0.0-alpha.3",
50
50
  "typescript": "^4.8.4",
51
51
  "webpack": "^5.58.1",
52
52
  "webpack-cli": "^4.9.0"
@@ -17,6 +17,7 @@ import type { StylesProcessor } from './stylesmap';
17
17
  import type Element from './element';
18
18
  import type Node from './node';
19
19
  import type Item from './item';
20
+ type IfTrue<T> = T extends true ? true : never;
20
21
  declare const View_base: {
21
22
  new (): import("@ckeditor/ckeditor5-utils").Observable;
22
23
  prototype: import("@ckeditor/ckeditor5-utils").Observable;
@@ -183,9 +184,26 @@ export default class View extends View_base {
183
184
  enableObservers(): void;
184
185
  /**
185
186
  * Scrolls the page viewport and {@link #domRoots} with their ancestors to reveal the
186
- * caret, if not already visible to the user.
187
- */
188
- scrollToTheSelection(): void;
187
+ * caret, **if not already visible to the user**.
188
+ *
189
+ * @param options Additional configuration of the scrolling behavior.
190
+ * @param options.viewportOffset A distance between the DOM selection and the viewport boundary to be maintained
191
+ * while scrolling to the selection (default is 20px). Setting this value to `0` will reveal the selection precisely at
192
+ * the viewport boundary.
193
+ * @param options.ancestorOffset A distance between the DOM selection and scrollable DOM root ancestor(s) to be maintained
194
+ * while scrolling to the selection (default is 20px). Setting this value to `0` will reveal the selection precisely at
195
+ * the scrollable ancestor(s) boundary.
196
+ * @param options.alignToTop When set `true`, the DOM selection will be aligned to the top of the viewport if not already visible
197
+ * (see `forceScroll` to learn more).
198
+ * @param options.forceScroll When set `true`, the DOM selection will be aligned to the top of the viewport and scrollable ancestors
199
+ * whether it is already visible or not. This option will only work when `alignToTop` is `true`.
200
+ */
201
+ scrollToTheSelection<T extends boolean, U extends IfTrue<T>>({ alignToTop, forceScroll, viewportOffset, ancestorOffset }?: {
202
+ readonly viewportOffset?: number;
203
+ readonly ancestorOffset?: number;
204
+ readonly alignToTop?: T;
205
+ readonly forceScroll?: U;
206
+ }): void;
189
207
  /**
190
208
  * It will focus DOM element representing {@link module:engine/view/editableelement~EditableElement EditableElement}
191
209
  * that is currently having selection inside.
package/src/view/view.js CHANGED
@@ -278,14 +278,29 @@ export default class View extends ObservableMixin() {
278
278
  }
279
279
  /**
280
280
  * Scrolls the page viewport and {@link #domRoots} with their ancestors to reveal the
281
- * caret, if not already visible to the user.
281
+ * caret, **if not already visible to the user**.
282
+ *
283
+ * @param options Additional configuration of the scrolling behavior.
284
+ * @param options.viewportOffset A distance between the DOM selection and the viewport boundary to be maintained
285
+ * while scrolling to the selection (default is 20px). Setting this value to `0` will reveal the selection precisely at
286
+ * the viewport boundary.
287
+ * @param options.ancestorOffset A distance between the DOM selection and scrollable DOM root ancestor(s) to be maintained
288
+ * while scrolling to the selection (default is 20px). Setting this value to `0` will reveal the selection precisely at
289
+ * the scrollable ancestor(s) boundary.
290
+ * @param options.alignToTop When set `true`, the DOM selection will be aligned to the top of the viewport if not already visible
291
+ * (see `forceScroll` to learn more).
292
+ * @param options.forceScroll When set `true`, the DOM selection will be aligned to the top of the viewport and scrollable ancestors
293
+ * whether it is already visible or not. This option will only work when `alignToTop` is `true`.
282
294
  */
283
- scrollToTheSelection() {
295
+ scrollToTheSelection({ alignToTop, forceScroll, viewportOffset = 20, ancestorOffset = 20 } = {}) {
284
296
  const range = this.document.selection.getFirstRange();
285
297
  if (range) {
286
298
  scrollViewportToShowTarget({
287
299
  target: this.domConverter.viewRangeToDom(range),
288
- viewportOffset: 20
300
+ viewportOffset,
301
+ ancestorOffset,
302
+ alignToTop,
303
+ forceScroll
289
304
  });
290
305
  }
291
306
  }