@ckeditor/ckeditor5-minimap 41.3.1 → 41.4.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.
@@ -0,0 +1,113 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module minimap/minimapview
11
+ */
12
+ import { View } from 'ckeditor5/src/ui.js';
13
+ import { type Locale } from 'ckeditor5/src/utils.js';
14
+ export type MinimapViewOptions = {
15
+ domRootClone: HTMLElement;
16
+ pageStyles: Array<string | {
17
+ href: string;
18
+ }>;
19
+ scaleRatio: number;
20
+ useSimplePreview?: boolean;
21
+ extraClasses?: string;
22
+ };
23
+ /**
24
+ * The main view of the minimap. It renders the original content but scaled down with a tracker element
25
+ * visualizing the subset of the content visible to the user and allowing interactions (scrolling, dragging).
26
+ *
27
+ * @internal
28
+ */
29
+ export default class MinimapView extends View {
30
+ /**
31
+ * An instance of the tracker view displayed over the minimap.
32
+ */
33
+ private readonly _positionTrackerView;
34
+ /**
35
+ * The scale ratio of the minimap relative to the original editing DOM root with the content.
36
+ */
37
+ private readonly _scaleRatio;
38
+ /**
39
+ * An instance of the iframe view that hosts the minimap.
40
+ */
41
+ private readonly _minimapIframeView;
42
+ /**
43
+ * Creates an instance of the minimap view.
44
+ */
45
+ constructor({ locale, scaleRatio, pageStyles, extraClasses, useSimplePreview, domRootClone }: {
46
+ locale: Locale;
47
+ } & MinimapViewOptions);
48
+ /**
49
+ * @inheritDoc
50
+ */
51
+ destroy(): void;
52
+ /**
53
+ * Returns the DOM {@link module:utils/dom/rect~Rect} height of the minimap.
54
+ */
55
+ get height(): number;
56
+ /**
57
+ * Returns the number of available space (pixels) the position tracker (visible subset of the content) can use to scroll vertically.
58
+ */
59
+ get scrollHeight(): number;
60
+ /**
61
+ * @inheritDoc
62
+ */
63
+ render(): void;
64
+ /**
65
+ * Sets the new height of the minimap (in px) to respond to the changes in the original editing DOM root.
66
+ *
67
+ * **Note**:The provided value should be the `offsetHeight` of the original editing DOM root.
68
+ */
69
+ setContentHeight(newHeight: number): void;
70
+ /**
71
+ * Sets the minimap scroll progress.
72
+ *
73
+ * The minimap scroll progress is linked to the original editing DOM root and its scrollable container (ancestor).
74
+ * Changing the progress will alter the vertical position of the minimap (and its position tracker) and give the user an accurate
75
+ * overview of the visible document.
76
+ *
77
+ * **Note**: The value should be between 0 and 1. 0 when the DOM root has not been scrolled, 1 when the
78
+ * scrolling has reached the end.
79
+ */
80
+ setScrollProgress(newScrollProgress: number): void;
81
+ /**
82
+ * Sets the new height of the tracker (in px) to visualize the subset of the content visible to the user.
83
+ */
84
+ setPositionTrackerHeight(trackerHeight: number): void;
85
+ /**
86
+ * @param data DOM event data
87
+ */
88
+ private _handleMinimapClick;
89
+ /**
90
+ * @param data DOM event data
91
+ */
92
+ private _handleMinimapMouseWheel;
93
+ }
94
+ /**
95
+ * Fired when the minimap view is clicked.
96
+ *
97
+ * @eventName ~MinimapView#click
98
+ * @param percentage The number between 0 and 1 representing a place in the minimap (its height) that was clicked.
99
+ */
100
+ export type MinimapClickEvent = {
101
+ name: 'click';
102
+ args: [percentage: number];
103
+ };
104
+ /**
105
+ * Fired when the position tracker is dragged or the minimap is scrolled via mouse wheel.
106
+ *
107
+ * @eventName ~MinimapView#drag
108
+ * @param movementY The vertical movement of the minimap as a result of dragging or scrolling.
109
+ */
110
+ export type MinimapDragEvent = {
111
+ name: 'drag';
112
+ args: [movementY: number];
113
+ };
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module minimap/utils
11
+ */
12
+ import { Rect } from 'ckeditor5/src/utils.js';
13
+ import type { Editor } from 'ckeditor5/src/core.js';
14
+ /**
15
+ * Clones the editing view DOM root by using a dedicated pair of {@link module:engine/view/renderer~Renderer} and
16
+ * {@link module:engine/view/domconverter~DomConverter}. The DOM root clone updates incrementally to stay in sync with the
17
+ * source root.
18
+ *
19
+ * @internal
20
+ * @param editor The editor instance the original editing root belongs to.
21
+ * @param rootName The name of the root to clone.
22
+ * @returns The editing root DOM clone element.
23
+ */
24
+ export declare function cloneEditingViewDomRoot(editor: Editor, rootName?: string): HTMLElement;
25
+ /**
26
+ * Harvests all web page styles, for instance, to allow re-using them in an `<iframe>` preserving the look of the content.
27
+ *
28
+ * The returned data format is as follows:
29
+ *
30
+ * ```ts
31
+ * [
32
+ * 'p { color: red; ... } h2 { font-size: 2em; ... } ...',
33
+ * '.spacing { padding: 1em; ... }; ...',
34
+ * '...',
35
+ * { href: 'http://link.to.external.stylesheet' },
36
+ * { href: '...' }
37
+ * ]
38
+ * ```
39
+ *
40
+ * **Note**: For stylesheets with `href` different than window origin, an object is returned because
41
+ * accessing rules of these styles may cause CORS errors (depending on the configuration of the web page).
42
+ *
43
+ * @internal
44
+ */
45
+ export declare function getPageStyles(): Array<string | {
46
+ href: string;
47
+ }>;
48
+ /**
49
+ * Gets dimensions rectangle according to passed DOM element. Returns whole window's size for `body` element.
50
+ *
51
+ * @internal
52
+ */
53
+ export declare function getDomElementRect(domElement: HTMLElement): Rect;
54
+ /**
55
+ * Gets client height according to passed DOM element. Returns window's height for `body` element.
56
+ *
57
+ * @internal
58
+ */
59
+ export declare function getClientHeight(domElement: HTMLElement): number;
60
+ /**
61
+ * Returns the DOM element itself if it's not a `body` element, whole window otherwise.
62
+ *
63
+ * @internal
64
+ */
65
+ export declare function getScrollable(domElement: HTMLElement): Window | HTMLElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-minimap",
3
- "version": "41.3.1",
3
+ "version": "41.4.0",
4
4
  "description": "Content minimap feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -13,7 +13,7 @@
13
13
  "type": "module",
14
14
  "main": "src/index.js",
15
15
  "dependencies": {
16
- "ckeditor5": "41.3.1"
16
+ "ckeditor5": "41.4.0"
17
17
  },
18
18
  "author": "CKSource (http://cksource.com/)",
19
19
  "license": "GPL-2.0-or-later",
@@ -25,6 +25,7 @@
25
25
  "directory": "packages/ckeditor5-minimap"
26
26
  },
27
27
  "files": [
28
+ "dist",
28
29
  "lang",
29
30
  "src/**/*.js",
30
31
  "src/**/*.d.ts",
@@ -26,6 +26,7 @@ export default class MinimapIframeView extends IframeView {
26
26
  this.extendTemplate({
27
27
  attributes: {
28
28
  tabindex: -1,
29
+ 'aria-hidden': 'true',
29
30
  class: [
30
31
  'ck-minimap__iframe'
31
32
  ],
package/theme/minimap.css CHANGED
@@ -38,6 +38,11 @@
38
38
  z-index: 1;
39
39
  transition: background 100ms ease-in-out;
40
40
 
41
+
42
+ @media (prefers-reduced-motion: reduce) {
43
+ transition: none;
44
+ }
45
+
41
46
  &:hover {
42
47
  background:hsla( var(--ck-color-minimap-tracker-background), .3 );
43
48
  }
@@ -64,6 +69,11 @@
64
69
  border-radius: 3px;
65
70
  opacity: 0;
66
71
  transition: opacity 100ms ease-in-out;
72
+
73
+
74
+ @media (prefers-reduced-motion: reduce) {
75
+ transition: none;
76
+ }
67
77
  }
68
78
  }
69
79
  }