@plait/core 0.76.0 → 0.77.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plait/core",
3
- "version": "0.76.0",
3
+ "version": "0.77.1",
4
4
  "peerDependencies": {
5
5
  "immer": "^10.0.3",
6
6
  "is-hotkey": "^0.2.0",
@@ -7,3 +7,4 @@ export * from './with-moving';
7
7
  export * from './with-options';
8
8
  export * from './with-related-fragment';
9
9
  export * from './with-selection';
10
+ export * from './with-i18n';
@@ -0,0 +1,6 @@
1
+ import { PlaitBoard } from '../interfaces/board';
2
+ export interface PlaitI18nBoard extends PlaitBoard {
3
+ getI18nValue: (key: string) => string | null;
4
+ }
5
+ export declare const withI18n: (board: PlaitBoard) => PlaitI18nBoard;
6
+ export declare const getI18nValue: (board: PlaitBoard, key: string, defaultValue?: string) => string;
@@ -1,18 +1,34 @@
1
1
  import { PlaitBoard, Point, RectangleClient } from '../interfaces';
2
- export declare function getViewportContainerRect(board: PlaitBoard): {
3
- width: number;
4
- height: number;
5
- };
6
- export declare function getElementHostBBox(board: PlaitBoard, zoom: number): {
2
+ export declare const VIEWPORT_PADDING_RATIO = 0.75;
3
+ export interface ElementHostBBox {
7
4
  left: number;
8
5
  right: number;
9
6
  top: number;
10
7
  bottom: number;
8
+ }
9
+ export declare function getViewportContainerRect(board: PlaitBoard): {
10
+ width: number;
11
+ height: number;
11
12
  };
13
+ export declare function getElementHostBBox(board: PlaitBoard, zoom: number): ElementHostBBox;
12
14
  /**
13
15
  * Normalize the scaling ratio, or return the corrected scaling ratio if the limit is exceeded
14
16
  */
15
17
  export declare function clampZoomLevel(zoom: number, minZoom?: number, maxZoom?: number): number;
18
+ /**
19
+ * Prepares element bounding box with minimum size constraints
20
+ */
21
+ export declare function prepareElementBBox(board: PlaitBoard, zoom: number): {
22
+ elementHostBBox: ElementHostBBox;
23
+ containerWidth: number;
24
+ containerHeight: number;
25
+ width: number;
26
+ height: number;
27
+ };
28
+ /**
29
+ * Calculates viewBox based on element bounding box with padding
30
+ */
31
+ export declare function calculateViewBox(elementHostBBox: ElementHostBBox, containerWidth: number, containerHeight: number, width: number, height: number, zoom: number, paddingRatio?: number): number[];
16
32
  export declare function calcNewViewBox(board: PlaitBoard, zoom: number): number[];
17
33
  export declare function getViewBoxCenterPoint(board: PlaitBoard): Point;
18
34
  export declare function setSVGViewBox(board: PlaitBoard, viewBox: number[]): void;
@@ -21,6 +37,7 @@ export declare function updateViewportContainerScroll(board: PlaitBoard, left: n
21
37
  export declare function updateViewportByScrolling(board: PlaitBoard, scrollLeft: number, scrollTop: number): void;
22
38
  export declare function initializeViewportContainer(board: PlaitBoard): void;
23
39
  export declare function initializeViewBox(board: PlaitBoard): void;
40
+ export declare function updateViewBox(board: PlaitBoard): void;
24
41
  export declare function initializeViewportOffset(board: PlaitBoard): void;
25
42
  export declare const updateViewportOrigination: (board: PlaitBoard, origination: Point) => void;
26
43
  export declare const clearViewportOrigination: (board: PlaitBoard) => void;