@tolgee/core 5.4.4 → 5.6.0-prerelease.b5ab209e.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.
@@ -37,6 +37,7 @@ export declare type WrapperAttributeXPathGetter = (props: {
37
37
  attribute: string;
38
38
  }) => string;
39
39
  export declare type HighlightInterface = (key?: string, ns?: NsFallback) => Highlighter;
40
+ export declare type FindPositionsInterface = (key?: string, ns?: NsFallback) => KeyPosition[];
40
41
  export declare type ObserverRunProps = {
41
42
  mouseHighlight: boolean;
42
43
  options: ObserverOptionsInternal;
@@ -51,6 +52,7 @@ export declare type ObserverMiddleware = () => {
51
52
  run: (props: ObserverRunProps) => void;
52
53
  highlight: HighlightInterface;
53
54
  outputNotFormattable: boolean;
55
+ findPositions: FindPositionsInterface;
54
56
  };
55
57
  export declare type LanguageDetectorProps = {
56
58
  availableLanguages: string[];
@@ -91,11 +93,22 @@ export declare type Highlighter = {
91
93
  export declare type FinalFormatterMiddleware = {
92
94
  format: (props: FormatterMiddlewareFormatParams) => any;
93
95
  };
96
+ export declare type KeyPosition = {
97
+ position: {
98
+ x: number;
99
+ y: number;
100
+ width: number;
101
+ height: number;
102
+ };
103
+ keyName: string;
104
+ keyNamespace: string;
105
+ };
94
106
  export declare type UiProps = {
95
107
  apiUrl: string;
96
108
  apiKey: string;
97
109
  projectId: number | string | undefined;
98
110
  highlight: HighlightInterface;
111
+ findPositions: (key?: string | undefined, ns?: NsFallback) => KeyPosition[];
99
112
  changeTranslation: ChangeTranslationInterface;
100
113
  };
101
114
  export declare type UiKeyOption = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tolgee/core",
3
- "version": "5.4.4",
3
+ "version": "5.6.0-prerelease.b5ab209e.0",
4
4
  "description": "Library providing ability to translate messages directly in context of developed application.",
5
5
  "main": "./dist/tolgee.cjs.js",
6
6
  "module": "./dist/tolgee.esm.js",
@@ -67,5 +67,5 @@
67
67
  "access": "public"
68
68
  },
69
69
  "sideEffects": false,
70
- "gitHead": "de1a0c320f5a712c5bfa3ecceb086dc3d2b1d057"
70
+ "gitHead": "bfb41a3dc1c220d02a17a485e7f062d4e2a19dca"
71
71
  }
@@ -21,6 +21,7 @@ import {
21
21
  TolgeeInstance,
22
22
  TolgeeOptionsInternal,
23
23
  FormatErrorHandler,
24
+ FindPositionsInterface,
24
25
  } from '../../types';
25
26
  import { DEFAULT_FORMAT_ERROR } from '../State/initState';
26
27
 
@@ -73,6 +74,10 @@ export const Plugins = (
73
74
  return instances.observer?.highlight?.(key, ns) || { unhighlight() {} };
74
75
  };
75
76
 
77
+ const findPositions: FindPositionsInterface = (key, ns) => {
78
+ return instances.observer?.findPositions(key, ns) || [];
79
+ };
80
+
76
81
  const translate = (props: TranslatePropsInternal) => {
77
82
  const translation = getTranslation({
78
83
  key: props.key,
@@ -178,6 +183,7 @@ export const Plugins = (
178
183
  projectId,
179
184
  highlight,
180
185
  changeTranslation,
186
+ findPositions,
181
187
  });
182
188
 
183
189
  instances.observer?.run({
@@ -31,6 +31,7 @@ const testObserver =
31
31
  stop,
32
32
  retranslate,
33
33
  highlight: () => ({ unhighlight: () => {} }),
34
+ findPositions: () => [],
34
35
  outputNotFormattable,
35
36
  });
36
37
  };
@@ -57,6 +57,10 @@ export type WrapperAttributeXPathGetter = (props: {
57
57
  }) => string;
58
58
 
59
59
  export type HighlightInterface = (key?: string, ns?: NsFallback) => Highlighter;
60
+ export type FindPositionsInterface = (
61
+ key?: string,
62
+ ns?: NsFallback
63
+ ) => KeyPosition[];
60
64
 
61
65
  export type ObserverRunProps = {
62
66
  mouseHighlight: boolean;
@@ -73,6 +77,7 @@ export type ObserverMiddleware = () => {
73
77
  run: (props: ObserverRunProps) => void;
74
78
  highlight: HighlightInterface;
75
79
  outputNotFormattable: boolean;
80
+ findPositions: FindPositionsInterface;
76
81
  };
77
82
 
78
83
  export type LanguageDetectorProps = {
@@ -127,11 +132,23 @@ export type FinalFormatterMiddleware = {
127
132
  format: (props: FormatterMiddlewareFormatParams) => any;
128
133
  };
129
134
 
135
+ export type KeyPosition = {
136
+ position: {
137
+ x: number;
138
+ y: number;
139
+ width: number;
140
+ height: number;
141
+ };
142
+ keyName: string;
143
+ keyNamespace: string;
144
+ };
145
+
130
146
  export type UiProps = {
131
147
  apiUrl: string;
132
148
  apiKey: string;
133
149
  projectId: number | string | undefined;
134
150
  highlight: HighlightInterface;
151
+ findPositions: (key?: string | undefined, ns?: NsFallback) => KeyPosition[];
135
152
  changeTranslation: ChangeTranslationInterface;
136
153
  };
137
154