@tolgee/core 1.2.4 → 1.5.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/dist/tolgee.cjs.js +558 -156
- package/dist/tolgee.cjs.js.map +1 -1
- package/dist/tolgee.cjs.min.js +1 -1
- package/dist/tolgee.cjs.min.js.map +1 -1
- package/dist/tolgee.umd.js +558 -156
- package/dist/tolgee.umd.js.map +1 -1
- package/dist/tolgee.umd.min.js +16 -0
- package/dist/tolgee.umd.min.js.map +1 -0
- package/lib/Constants/Global.d.ts +1 -0
- package/lib/Constants/Global.js +1 -0
- package/lib/Constants/Global.js.map +1 -1
- package/lib/DTOs/TranslationData.d.ts +2 -1
- package/lib/DTOs/TranslationData.js +2 -1
- package/lib/DTOs/TranslationData.js.map +1 -1
- package/lib/Tolgee.d.ts +6 -6
- package/lib/Tolgee.js +66 -33
- package/lib/Tolgee.js.map +1 -1
- package/lib/handlers/AbstractHandler.d.ts +2 -2
- package/lib/handlers/AbstractHandler.js.map +1 -1
- package/lib/handlers/CoreHandler.d.ts +3 -1
- package/lib/handlers/CoreHandler.js +5 -1
- package/lib/handlers/CoreHandler.js.map +1 -1
- package/lib/handlers/WrappedHandler.d.ts +13 -0
- package/lib/handlers/WrappedHandler.js +85 -0
- package/lib/handlers/WrappedHandler.js.map +1 -0
- package/lib/helpers/TextHelper.d.ts +1 -1
- package/lib/helpers/TextHelper.js +30 -10
- package/lib/helpers/TextHelper.js.map +1 -1
- package/lib/highlighter/HighlightFunctionsInitializer.d.ts +9 -0
- package/lib/highlighter/HighlightFunctionsInitializer.js +24 -0
- package/lib/highlighter/HighlightFunctionsInitializer.js.map +1 -0
- package/lib/highlighter/MouseEventHandler.js +2 -6
- package/lib/highlighter/MouseEventHandler.js.map +1 -1
- package/lib/highlighter/TranslationHighlighter.d.ts +7 -13
- package/lib/highlighter/TranslationHighlighter.js +24 -29
- package/lib/highlighter/TranslationHighlighter.js.map +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/services/DependencyStore.d.ts +8 -0
- package/lib/services/DependencyStore.js +12 -3
- package/lib/services/DependencyStore.js.map +1 -1
- package/lib/services/ElementRegistrar.d.ts +4 -1
- package/lib/services/ElementRegistrar.js +49 -8
- package/lib/services/ElementRegistrar.js.map +1 -1
- package/lib/services/EventService.d.ts +2 -0
- package/lib/services/EventService.js +1 -0
- package/lib/services/EventService.js.map +1 -1
- package/lib/services/TextService.d.ts +5 -5
- package/lib/services/TextService.js +124 -40
- package/lib/services/TextService.js.map +1 -1
- package/lib/services/TranslationService.d.ts +4 -3
- package/lib/services/TranslationService.js +53 -25
- package/lib/services/TranslationService.js.map +1 -1
- package/lib/toolsManager/PluginManager.d.ts +18 -0
- package/lib/toolsManager/PluginManager.js +118 -0
- package/lib/toolsManager/PluginManager.js.map +1 -0
- package/lib/types.d.ts +20 -1
- package/package.json +2 -2
package/lib/Tolgee.js
CHANGED
|
@@ -40,34 +40,6 @@ import { DependencyStore } from './services/DependencyStore';
|
|
|
40
40
|
var Tolgee = /** @class */ (function () {
|
|
41
41
|
function Tolgee(config) {
|
|
42
42
|
var _this = this;
|
|
43
|
-
this.translate = function (key, params, noWrap) {
|
|
44
|
-
if (params === void 0) { params = {}; }
|
|
45
|
-
if (noWrap === void 0) { noWrap = false; }
|
|
46
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
47
|
-
return __generator(this, function (_a) {
|
|
48
|
-
switch (_a.label) {
|
|
49
|
-
case 0:
|
|
50
|
-
if (!(this.properties.config.mode === 'development' && !noWrap)) return [3 /*break*/, 3];
|
|
51
|
-
return [4 /*yield*/, this.loadScopes()];
|
|
52
|
-
case 1:
|
|
53
|
-
_a.sent();
|
|
54
|
-
return [4 /*yield*/, this.translationService.loadTranslations()];
|
|
55
|
-
case 2:
|
|
56
|
-
_a.sent();
|
|
57
|
-
return [2 /*return*/, this.dependencyStore.textService.wrap(key, params)];
|
|
58
|
-
case 3: return [2 /*return*/, this.dependencyStore.textService.translate(key, params)];
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
this.instant = function (key, params, noWrap, orEmpty) {
|
|
64
|
-
if (params === void 0) { params = {}; }
|
|
65
|
-
if (noWrap === void 0) { noWrap = false; }
|
|
66
|
-
if (_this.properties.config.mode === 'development' && !noWrap) {
|
|
67
|
-
return _this.dependencyStore.textService.wrap(key, params);
|
|
68
|
-
}
|
|
69
|
-
return _this.dependencyStore.textService.instant(key, params, undefined, orEmpty);
|
|
70
|
-
};
|
|
71
43
|
this.stop = function () {
|
|
72
44
|
_this.dependencyStore.observer.stopObserving();
|
|
73
45
|
_this.dependencyStore.elementRegistrar.cleanAll();
|
|
@@ -122,6 +94,13 @@ var Tolgee = /** @class */ (function () {
|
|
|
122
94
|
enumerable: false,
|
|
123
95
|
configurable: true
|
|
124
96
|
});
|
|
97
|
+
Object.defineProperty(Tolgee.prototype, "onTranslationChange", {
|
|
98
|
+
get: function () {
|
|
99
|
+
return this.dependencyStore.eventService.TRANSLATION_CHANGED;
|
|
100
|
+
},
|
|
101
|
+
enumerable: false,
|
|
102
|
+
configurable: true
|
|
103
|
+
});
|
|
125
104
|
Object.defineProperty(Tolgee.prototype, "onLangLoaded", {
|
|
126
105
|
get: function () {
|
|
127
106
|
return this.dependencyStore.eventService.LANGUAGE_LOADED;
|
|
@@ -167,13 +146,16 @@ var Tolgee = /** @class */ (function () {
|
|
|
167
146
|
case 2: return [4 /*yield*/, this.translationService.loadTranslations()];
|
|
168
147
|
case 3:
|
|
169
148
|
_a.sent();
|
|
170
|
-
|
|
171
|
-
return [4 /*yield*/, this.translationService.loadTranslations(this.properties.config.fallbackLanguage)];
|
|
149
|
+
return [4 /*yield*/, this.dependencyStore.pluginManager.run()];
|
|
172
150
|
case 4:
|
|
173
151
|
_a.sent();
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
case
|
|
152
|
+
if (!this.properties.config.preloadFallback) return [3 /*break*/, 6];
|
|
153
|
+
return [4 /*yield*/, this.translationService.loadTranslations(this.properties.config.fallbackLanguage)];
|
|
154
|
+
case 5:
|
|
155
|
+
_a.sent();
|
|
156
|
+
_a.label = 6;
|
|
157
|
+
case 6: return [4 /*yield*/, this.refresh()];
|
|
158
|
+
case 7:
|
|
177
159
|
_a.sent();
|
|
178
160
|
if (this.properties.config.watch) {
|
|
179
161
|
this.dependencyStore.observer.observe();
|
|
@@ -190,6 +172,57 @@ var Tolgee = /** @class */ (function () {
|
|
|
190
172
|
});
|
|
191
173
|
});
|
|
192
174
|
};
|
|
175
|
+
Tolgee.prototype.translate = function (keyOrProps, params, noWrap, defaultValue) {
|
|
176
|
+
if (params === void 0) { params = {}; }
|
|
177
|
+
if (noWrap === void 0) { noWrap = false; }
|
|
178
|
+
if (defaultValue === void 0) { defaultValue = undefined; }
|
|
179
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
180
|
+
var key, props;
|
|
181
|
+
return __generator(this, function (_a) {
|
|
182
|
+
switch (_a.label) {
|
|
183
|
+
case 0:
|
|
184
|
+
key = typeof keyOrProps === 'string' ? keyOrProps : keyOrProps.key;
|
|
185
|
+
if (typeof keyOrProps === 'object') {
|
|
186
|
+
props = keyOrProps;
|
|
187
|
+
// if values are not provided in props object, get them from function
|
|
188
|
+
// params defaults
|
|
189
|
+
params = props.params !== undefined ? props.params : params;
|
|
190
|
+
noWrap = props.noWrap !== undefined ? props.noWrap : noWrap;
|
|
191
|
+
defaultValue =
|
|
192
|
+
props.defaultValue !== undefined ? props.defaultValue : defaultValue;
|
|
193
|
+
}
|
|
194
|
+
if (!(this.properties.config.mode === 'development' && !noWrap)) return [3 /*break*/, 3];
|
|
195
|
+
return [4 /*yield*/, this.loadScopes()];
|
|
196
|
+
case 1:
|
|
197
|
+
_a.sent();
|
|
198
|
+
return [4 /*yield*/, this.translationService.loadTranslations()];
|
|
199
|
+
case 2:
|
|
200
|
+
_a.sent();
|
|
201
|
+
return [2 /*return*/, this.dependencyStore.textService.wrap(key, params, defaultValue)];
|
|
202
|
+
case 3: return [2 /*return*/, this.dependencyStore.textService.translate(key, params, undefined, undefined, defaultValue)];
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
Tolgee.prototype.instant = function (keyOrProps, params, noWrap, orEmpty, defaultValue) {
|
|
208
|
+
if (params === void 0) { params = {}; }
|
|
209
|
+
if (noWrap === void 0) { noWrap = false; }
|
|
210
|
+
var key = typeof keyOrProps === 'string' ? keyOrProps : keyOrProps.key;
|
|
211
|
+
if (typeof keyOrProps === 'object') {
|
|
212
|
+
var props = keyOrProps;
|
|
213
|
+
// if values are not provided in props object, get them from function
|
|
214
|
+
// params defaults
|
|
215
|
+
params = props.params !== undefined ? props.params : params;
|
|
216
|
+
noWrap = props.noWrap !== undefined ? props.noWrap : noWrap;
|
|
217
|
+
defaultValue =
|
|
218
|
+
props.defaultValue !== undefined ? props.defaultValue : defaultValue;
|
|
219
|
+
orEmpty = props.orEmpty !== undefined ? props.orEmpty : orEmpty;
|
|
220
|
+
}
|
|
221
|
+
if (this.properties.config.mode === 'development' && !noWrap) {
|
|
222
|
+
return this.dependencyStore.textService.wrap(key, params, defaultValue);
|
|
223
|
+
}
|
|
224
|
+
return this.dependencyStore.textService.instant(key, params, undefined, orEmpty, defaultValue);
|
|
225
|
+
};
|
|
193
226
|
Tolgee.prototype.loadScopes = function () {
|
|
194
227
|
return __awaiter(this, void 0, void 0, function () {
|
|
195
228
|
var _a;
|
package/lib/Tolgee.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tolgee.js","sourceRoot":"","sources":["../src/Tolgee.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEl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ties } from '../Properties';
|
|
2
|
-
import { KeyAndParams, NodeWithMeta } from '../types';
|
|
2
|
+
import { ElementWithMeta, KeyAndParams, NodeWithMeta } from '../types';
|
|
3
3
|
import { TextService } from '../services/TextService';
|
|
4
4
|
import { ElementRegistrar } from '../services/ElementRegistrar';
|
|
5
5
|
import { TranslationHighlighter } from '../highlighter/TranslationHighlighter';
|
|
@@ -9,7 +9,7 @@ export declare abstract class AbstractHandler {
|
|
|
9
9
|
protected elementRegistrar: ElementRegistrar;
|
|
10
10
|
protected translationHighlighter: TranslationHighlighter;
|
|
11
11
|
protected constructor(properties: Properties, textService: TextService, elementRegistrar: ElementRegistrar, translationHighlighter: TranslationHighlighter);
|
|
12
|
-
|
|
12
|
+
protected static initParentElement(element: Element): ElementWithMeta;
|
|
13
13
|
abstract handle(node: Node): any;
|
|
14
14
|
protected filterRestricted<T extends Element | Text>(nodes: T[]): T[];
|
|
15
15
|
protected handleNodes(nodes: Array<Text | Attr>): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractHandler.js","sourceRoot":"","sources":["../../src/handlers/AbstractHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAcnD,OAAO,EACL,8BAA8B,EAC9B,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAE7B;IACE,yBACY,UAAsB,EACtB,WAAwB,EACxB,gBAAkC,EAClC,sBAA8C;QAH9C,eAAU,GAAV,UAAU,CAAY;QACtB,gBAAW,GAAX,WAAW,CAAa;QACxB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,2BAAsB,GAAtB,sBAAsB,CAAwB;IACvD,CAAC;
|
|
1
|
+
{"version":3,"file":"AbstractHandler.js","sourceRoot":"","sources":["../../src/handlers/AbstractHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;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S,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE;gBACvE,OAAO,SAAS,CAAC;aAClB;SACF;QAED,IAAI,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY,KAAK,UAAU,EAAE;YAC7D,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE;gBACnD,OAAO,SAAS,CAAC;aAClB;SACF;QAED,OAAO,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC3C,CAAC;IACH,sBAAC;AAAD,CAAC,AA1HD,IA0HC"}
|
|
@@ -4,6 +4,7 @@ import { EventService } from '../services/EventService';
|
|
|
4
4
|
import { Properties } from '../Properties';
|
|
5
5
|
import { AttributeHandler } from './AttributeHandler';
|
|
6
6
|
import { TextService } from '../services/TextService';
|
|
7
|
+
import { WrappedHandler } from './WrappedHandler';
|
|
7
8
|
export declare class CoreHandler {
|
|
8
9
|
private service;
|
|
9
10
|
private textHandler;
|
|
@@ -11,7 +12,8 @@ export declare class CoreHandler {
|
|
|
11
12
|
private properties;
|
|
12
13
|
private attributeHandler;
|
|
13
14
|
private textService;
|
|
14
|
-
|
|
15
|
+
private wrappedHandler;
|
|
16
|
+
constructor(service: CoreService, textHandler: TextHandler, eventService: EventService, properties: Properties, attributeHandler: AttributeHandler, textService: TextService, wrappedHandler: WrappedHandler);
|
|
15
17
|
handleSubtree(target: Element): Promise<void>;
|
|
16
18
|
private refresh;
|
|
17
19
|
}
|
|
@@ -47,13 +47,14 @@ var __values = (this && this.__values) || function(o) {
|
|
|
47
47
|
};
|
|
48
48
|
import { NodeHelper } from '../helpers/NodeHelper';
|
|
49
49
|
var CoreHandler = /** @class */ (function () {
|
|
50
|
-
function CoreHandler(service, textHandler, eventService, properties, attributeHandler, textService) {
|
|
50
|
+
function CoreHandler(service, textHandler, eventService, properties, attributeHandler, textService, wrappedHandler) {
|
|
51
51
|
this.service = service;
|
|
52
52
|
this.textHandler = textHandler;
|
|
53
53
|
this.eventService = eventService;
|
|
54
54
|
this.properties = properties;
|
|
55
55
|
this.attributeHandler = attributeHandler;
|
|
56
56
|
this.textService = textService;
|
|
57
|
+
this.wrappedHandler = wrappedHandler;
|
|
57
58
|
eventService.LANGUAGE_CHANGED.subscribe(this.refresh.bind(this));
|
|
58
59
|
eventService.TRANSLATION_CHANGED.subscribe(this.refresh.bind(this));
|
|
59
60
|
}
|
|
@@ -66,6 +67,9 @@ var CoreHandler = /** @class */ (function () {
|
|
|
66
67
|
_a.sent();
|
|
67
68
|
return [4 /*yield*/, this.textHandler.handle(target)];
|
|
68
69
|
case 2:
|
|
70
|
+
_a.sent();
|
|
71
|
+
return [4 /*yield*/, this.wrappedHandler.handle(target)];
|
|
72
|
+
case 3:
|
|
69
73
|
_a.sent();
|
|
70
74
|
return [2 /*return*/];
|
|
71
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreHandler.js","sourceRoot":"","sources":["../../src/handlers/CoreHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"CoreHandler.js","sourceRoot":"","sources":["../../src/handlers/CoreHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAUnD;IACE,qBACU,OAAoB,EACpB,WAAwB,EACxB,YAA0B,EAC1B,UAAsB,EACtB,gBAAkC,EAClC,WAAwB,EACxB,cAA8B;QAN9B,YAAO,GAAP,OAAO,CAAa;QACpB,gBAAW,GAAX,WAAW,CAAa;QACxB,iBAAY,GAAZ,YAAY,CAAc;QAC1B,eAAU,GAAV,UAAU,CAAY;QACtB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC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
2
|
+
import { TranslationHighlighter } from '../highlighter/TranslationHighlighter';
|
|
3
|
+
import { TextService } from '../services/TextService';
|
|
4
|
+
import { AbstractHandler } from './AbstractHandler';
|
|
5
|
+
import { ElementRegistrar } from '../services/ElementRegistrar';
|
|
6
|
+
export declare class WrappedHandler extends AbstractHandler {
|
|
7
|
+
protected properties: Properties;
|
|
8
|
+
protected translationHighlighter: TranslationHighlighter;
|
|
9
|
+
protected textService: TextService;
|
|
10
|
+
protected elementRegistrar: ElementRegistrar;
|
|
11
|
+
constructor(properties: Properties, translationHighlighter: TranslationHighlighter, textService: TextService, elementRegistrar: ElementRegistrar);
|
|
12
|
+
handle(node: Node): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
27
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
+
function step(op) {
|
|
30
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
+
while (_) try {
|
|
32
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
33
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
+
switch (op[0]) {
|
|
35
|
+
case 0: case 1: t = op; break;
|
|
36
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
+
default:
|
|
40
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
+
if (t[2]) _.ops.pop();
|
|
45
|
+
_.trys.pop(); continue;
|
|
46
|
+
}
|
|
47
|
+
op = body.call(thisArg, _);
|
|
48
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
import { NodeHelper } from '../helpers/NodeHelper';
|
|
53
|
+
import { AbstractHandler } from './AbstractHandler';
|
|
54
|
+
import { TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE } from '../Constants/Global';
|
|
55
|
+
var WrappedHandler = /** @class */ (function (_super) {
|
|
56
|
+
__extends(WrappedHandler, _super);
|
|
57
|
+
function WrappedHandler(properties, translationHighlighter, textService, elementRegistrar) {
|
|
58
|
+
var _this = _super.call(this, properties, textService, elementRegistrar, translationHighlighter) || this;
|
|
59
|
+
_this.properties = properties;
|
|
60
|
+
_this.translationHighlighter = translationHighlighter;
|
|
61
|
+
_this.textService = textService;
|
|
62
|
+
_this.elementRegistrar = elementRegistrar;
|
|
63
|
+
return _this;
|
|
64
|
+
}
|
|
65
|
+
WrappedHandler.prototype.handle = function (node) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
+
var xPath, nodes, filtered;
|
|
68
|
+
var _this = this;
|
|
69
|
+
return __generator(this, function (_a) {
|
|
70
|
+
xPath = "./descendant-or-self::*[@" + TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE + "]";
|
|
71
|
+
nodes = NodeHelper.evaluate(xPath, node);
|
|
72
|
+
filtered = this.filterRestricted(nodes);
|
|
73
|
+
filtered.forEach(function (element) {
|
|
74
|
+
var elementWithMeta = AbstractHandler.initParentElement(element);
|
|
75
|
+
elementWithMeta._tolgee.wrappedWithElementOnlyKey = element.getAttribute(TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE);
|
|
76
|
+
_this.elementRegistrar.register(elementWithMeta);
|
|
77
|
+
});
|
|
78
|
+
return [2 /*return*/];
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
return WrappedHandler;
|
|
83
|
+
}(AbstractHandler));
|
|
84
|
+
export { WrappedHandler };
|
|
85
|
+
//# sourceMappingURL=WrappedHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WrappedHandler.js","sourceRoot":"","sources":["../../src/handlers/WrappedHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAInD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAC;AAEzE;IAAoC,kCAAe;IACjD,wBACY,UAAsB,EACtB,sBAA8C,EAC9C,WAAwB,EACxB,gBAAkC;QAJ9C,YAME,kBAAM,UAAU,EAAE,WAAW,EAAE,gBAAgB,EAAE,sBAAsB,CAAC,SACzE;QANW,gBAAU,GAAV,UAAU,CAAY;QACtB,4BAAsB,GAAtB,sBAAsB,CAAwB;QAC9C,iBAAW,GAAX,WAAW,CAAa;QACxB,sBAAgB,GAAhB,gBAAgB,CAAkB;;IAG9C,CAAC;IAEK,+BAAM,GAAZ,UAAa,IAAU;;;;;gBACf,KAAK,GAAG,8BAA4B,kCAAkC,MAAG,CAAC;gBAC1E,KAAK,GAAG,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;gBACzC,QAAQ,GAAc,IAAI,CAAC,gBAAgB,CAAC,KAAkB,CAAC,CAAC;gBACtE,QAAQ,CAAC,OAAO,CAAC,UAAC,OAAO;oBACvB,IAAM,eAAe,GAAG,eAAe,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;oBACnE,eAAe,CAAC,OAAO,CAAC,yBAAyB,GAAG,OAAO,CAAC,YAAY,CACtE,kCAAkC,CACnC,CAAC;oBACF,KAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;gBAClD,CAAC,CAAC,CAAC;;;;KACJ;IACH,qBAAC;AAAD,CAAC,AAtBD,CAAoC,eAAe,GAsBlD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare class TextHelper {
|
|
2
2
|
static splitOnNonEscapedDelimiter(string: string, delimiter: string): string[];
|
|
3
3
|
static isCharEscaped(position: number, fullString: string): boolean;
|
|
4
|
-
static removeEscapes(
|
|
4
|
+
static removeEscapes(string: string): string;
|
|
5
5
|
}
|
|
@@ -4,16 +4,26 @@ var TextHelper = /** @class */ (function () {
|
|
|
4
4
|
TextHelper.splitOnNonEscapedDelimiter = function (string, delimiter) {
|
|
5
5
|
var result = [];
|
|
6
6
|
var actual = '';
|
|
7
|
+
var escaped = false;
|
|
7
8
|
for (var i = 0; i < string.length; i++) {
|
|
8
9
|
var char = string[i];
|
|
9
|
-
if (char ===
|
|
10
|
-
|
|
10
|
+
if (char === '\\' && !escaped) {
|
|
11
|
+
escaped = true;
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
if (escaped) {
|
|
15
|
+
escaped = false;
|
|
16
|
+
actual += char;
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (char === delimiter) {
|
|
20
|
+
result.push(actual);
|
|
11
21
|
actual = '';
|
|
12
22
|
continue;
|
|
13
23
|
}
|
|
14
|
-
actual +=
|
|
24
|
+
actual += char;
|
|
15
25
|
}
|
|
16
|
-
result.push(
|
|
26
|
+
result.push(actual);
|
|
17
27
|
return result;
|
|
18
28
|
};
|
|
19
29
|
TextHelper.isCharEscaped = function (position, fullString) {
|
|
@@ -24,13 +34,23 @@ var TextHelper = /** @class */ (function () {
|
|
|
24
34
|
}
|
|
25
35
|
return escapeCharsCount % 2 == 1;
|
|
26
36
|
};
|
|
27
|
-
TextHelper.removeEscapes = function (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
TextHelper.removeEscapes = function (string) {
|
|
38
|
+
var result = '';
|
|
39
|
+
var escaped = false;
|
|
40
|
+
for (var i = 0; i < string.length; i++) {
|
|
41
|
+
var char = string[i];
|
|
42
|
+
if (char === '\\' && !escaped) {
|
|
43
|
+
escaped = true;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (escaped) {
|
|
47
|
+
escaped = false;
|
|
48
|
+
result += char;
|
|
49
|
+
continue;
|
|
31
50
|
}
|
|
32
|
-
|
|
33
|
-
}
|
|
51
|
+
result += char;
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
34
54
|
};
|
|
35
55
|
return TextHelper;
|
|
36
56
|
}());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextHelper.js","sourceRoot":"","sources":["../../src/helpers/TextHelper.ts"],"names":[],"mappings":"AAAA;IAAA;
|
|
1
|
+
{"version":3,"file":"TextHelper.js","sourceRoot":"","sources":["../../src/helpers/TextHelper.ts"],"names":[],"mappings":"AAAA;IAAA;IAyDA,CAAC;IAxDe,qCAA0B,GAAxC,UACE,MAAc,EACd,SAAiB;QAEjB,IAAM,MAAM,GAAG,EAAE,CAAC;QAClB,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACtC,IAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACvB,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE;gBAC7B,OAAO,GAAG,IAAI,CAAC;gBACf,SAAS;aACV;YACD,IAAI,OAAO,EAAE;gBACX,OAAO,GAAG,KAAK,CAAC;gBAChB,MAAM,IAAI,IAAI,CAAC;gBACf,SAAS;aACV;YACD,IAAI,IAAI,KAAK,SAAS,EAAE;gBACtB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACpB,MAAM,GAAG,EAAE,CAAC;gBACZ,SAAS;aACV;YACD,MAAM,IAAI,IAAI,CAAC;SAChB;QACD,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACpB,OAAO,MAAM,CAAC;IAChB,CAAC;IAEa,wBAAa,GAA3B,UAA4B,QAAgB,EAAE,UAAkB;QAC9D,IAAI,gBAAgB,GAAG,CAAC,CAAC;QACzB,OAAO,QAAQ,GAAG,CAAC,CAAC,IAAI,UAAU,CAAC,QAAQ,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE;YACzD,gBAAgB,EAAE,CAAC;YACnB,QAAQ,EAAE,CAAC;SACZ;QACD,OAAO,gBAAgB,GAAG,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAEa,wBAAa,GAA3B,UAA4B,MAAc;QACxC,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACtC,IAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACvB,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE;gBAC7B,OAAO,GAAG,IAAI,CAAC;gBACf,SAAS;aACV;YACD,IAAI,OAAO,EAAE;gBACX,OAAO,GAAG,KAAK,CAAC;gBAChB,MAAM,IAAI,IAAI,CAAC;gBACf,SAAS;aACV;YACD,MAAM,IAAI,IAAI,CAAC;SAChB;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IACH,iBAAC;AAAD,CAAC,AAzDD,IAyDC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Properties } from '../Properties';
|
|
2
|
+
import { ElementWithMeta } from '../types';
|
|
3
|
+
export declare class HighlightFunctionsInitializer {
|
|
4
|
+
private properties;
|
|
5
|
+
constructor(properties: Properties);
|
|
6
|
+
initFunctions(element: ElementWithMeta): void;
|
|
7
|
+
private initHighlightFunction;
|
|
8
|
+
private initUnhighlightFunction;
|
|
9
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var HighlightFunctionsInitializer = /** @class */ (function () {
|
|
2
|
+
function HighlightFunctionsInitializer(properties) {
|
|
3
|
+
this.properties = properties;
|
|
4
|
+
}
|
|
5
|
+
HighlightFunctionsInitializer.prototype.initFunctions = function (element) {
|
|
6
|
+
this.initHighlightFunction(element);
|
|
7
|
+
this.initUnhighlightFunction(element);
|
|
8
|
+
};
|
|
9
|
+
HighlightFunctionsInitializer.prototype.initHighlightFunction = function (element) {
|
|
10
|
+
var _this = this;
|
|
11
|
+
element._tolgee.highlight = function () {
|
|
12
|
+
element._tolgee.initialBackgroundColor = element.style.backgroundColor;
|
|
13
|
+
element.style.backgroundColor = _this.properties.config.highlightColor;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
HighlightFunctionsInitializer.prototype.initUnhighlightFunction = function (element) {
|
|
17
|
+
element._tolgee.unhighlight = function () {
|
|
18
|
+
element.style.backgroundColor = element._tolgee.initialBackgroundColor;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
return HighlightFunctionsInitializer;
|
|
22
|
+
}());
|
|
23
|
+
export { HighlightFunctionsInitializer };
|
|
24
|
+
//# sourceMappingURL=HighlightFunctionsInitializer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HighlightFunctionsInitializer.js","sourceRoot":"","sources":["../../src/highlighter/HighlightFunctionsInitializer.ts"],"names":[],"mappings":"AAGA;IACE,uCAAoB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAE9C,qDAAa,GAAb,UAAc,OAAwB;QACpC,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACpC,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IAEO,6DAAqB,GAA7B,UAA8B,OAAwB;QAAtD,iBAKC;QAJC,OAAO,CAAC,OAAO,CAAC,SAAS,GAAG;YAC1B,OAAO,CAAC,OAAO,CAAC,sBAAsB,GAAG,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC;YACvE,OAAO,CAAC,KAAK,CAAC,eAAe,GAAG,KAAI,CAAC,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC;QACxE,CAAC,CAAC;IACJ,CAAC;IAEO,+DAAuB,GAA/B,UAAgC,OAAwB;QACtD,OAAO,CAAC,OAAO,CAAC,WAAW,GAAG;YAC5B,OAAO,CAAC,KAAK,CAAC,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,sBAAsB,CAAC;QACzE,CAAC,CAAC;IACJ,CAAC;IACH,oCAAC;AAAD,CAAC,AApBD,IAoBC"}
|
|
@@ -78,16 +78,12 @@ var MouseEventHandler = /** @class */ (function () {
|
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
80
|
MouseEventHandler.prototype.highlight = function () {
|
|
81
|
-
this.
|
|
82
|
-
this.getMouseOn().style.backgroundColor;
|
|
83
|
-
this.getMouseOn().style.backgroundColor =
|
|
84
|
-
this.properties.config.highlightColor;
|
|
81
|
+
this.getMouseOn()._tolgee.highlight();
|
|
85
82
|
this.highlighted = this.getMouseOn();
|
|
86
83
|
};
|
|
87
84
|
MouseEventHandler.prototype.unhighlight = function () {
|
|
88
85
|
if (this.highlighted) {
|
|
89
|
-
this.highlighted.
|
|
90
|
-
this.highlightedInitialBackgroundColor;
|
|
86
|
+
this.highlighted._tolgee.unhighlight();
|
|
91
87
|
this.highlighted = null;
|
|
92
88
|
}
|
|
93
89
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MouseEventHandler.js","sourceRoot":"","sources":["../../src/highlighter/MouseEventHandler.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D;IASE,2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AM,CAAC,aAAa,CAAA,gBAAA,4BAAE;gBAAnD,IAAM,GAAG,WAAA;gBACZ,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;oBAC3B,OAAO,KAAK,CAAC;iBACd;aACF;;;;;;;;;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACH,wBAAC;AAAD,CAAC,AArJD,IAqJC"}
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
import { CoreService } from '../services/CoreService';
|
|
2
1
|
import { ElementWithMeta } from '../types';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { TranslationService } from '../services/TranslationService';
|
|
6
|
-
import { MouseEventHandler } from './MouseEventHandler';
|
|
2
|
+
import { PluginManager } from '../toolsManager/PluginManager';
|
|
3
|
+
import { DependencyStore } from '../services/DependencyStore';
|
|
7
4
|
export declare class TranslationHighlighter {
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
private translationService;
|
|
12
|
-
private mouseEventHandler;
|
|
5
|
+
private dependencies;
|
|
6
|
+
pluginManager: PluginManager;
|
|
7
|
+
constructor(dependencies: DependencyStore);
|
|
13
8
|
private _renderer;
|
|
14
|
-
|
|
9
|
+
private get renderer();
|
|
10
|
+
private static getKeyOptions;
|
|
15
11
|
listen(element: ElementWithMeta & ElementCSSInlineStyle): void;
|
|
16
12
|
private getKey;
|
|
17
|
-
private static getKeyOptions;
|
|
18
13
|
private translationEdit;
|
|
19
|
-
private get renderer();
|
|
20
14
|
}
|
|
@@ -56,13 +56,9 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
|
56
56
|
return to;
|
|
57
57
|
};
|
|
58
58
|
var TranslationHighlighter = /** @class */ (function () {
|
|
59
|
-
function TranslationHighlighter(
|
|
59
|
+
function TranslationHighlighter(dependencies) {
|
|
60
60
|
var _this = this;
|
|
61
|
-
this.
|
|
62
|
-
this.properties = properties;
|
|
63
|
-
this.eventService = eventService;
|
|
64
|
-
this.translationService = translationService;
|
|
65
|
-
this.mouseEventHandler = mouseEventHandler;
|
|
61
|
+
this.dependencies = dependencies;
|
|
66
62
|
this.translationEdit = function (e, element) { return __awaiter(_this, void 0, void 0, function () {
|
|
67
63
|
var key;
|
|
68
64
|
return __generator(this, function (_a) {
|
|
@@ -86,9 +82,27 @@ var TranslationHighlighter = /** @class */ (function () {
|
|
|
86
82
|
});
|
|
87
83
|
}); };
|
|
88
84
|
}
|
|
85
|
+
Object.defineProperty(TranslationHighlighter.prototype, "renderer", {
|
|
86
|
+
get: function () {
|
|
87
|
+
if (this._renderer === undefined) {
|
|
88
|
+
if (typeof this.dependencies.properties.config.ui === 'function') {
|
|
89
|
+
this._renderer = new this.dependencies.properties.config.ui(this.dependencies);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return this._renderer;
|
|
93
|
+
},
|
|
94
|
+
enumerable: false,
|
|
95
|
+
configurable: true
|
|
96
|
+
});
|
|
97
|
+
TranslationHighlighter.getKeyOptions = function (node) {
|
|
98
|
+
var nodes = Array.from(node._tolgee.nodes);
|
|
99
|
+
var keys = nodes.reduce(function (acc, curr) { return __spreadArray(__spreadArray([], __read(acc)), __read(curr._tolgee.keys.map(function (k) { return k.key; }))); }, []);
|
|
100
|
+
return new Set(keys);
|
|
101
|
+
};
|
|
89
102
|
TranslationHighlighter.prototype.listen = function (element) {
|
|
90
103
|
var _this = this;
|
|
91
|
-
this.
|
|
104
|
+
this.dependencies.highlightFunctionInitializer.initFunctions(element);
|
|
105
|
+
this.dependencies.mouseEventHandler.handle(element, function (e) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
92
106
|
switch (_a.label) {
|
|
93
107
|
case 0: return [4 /*yield*/, this.translationEdit(e, element)];
|
|
94
108
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -101,6 +115,9 @@ var TranslationHighlighter = /** @class */ (function () {
|
|
|
101
115
|
return __generator(this, function (_a) {
|
|
102
116
|
switch (_a.label) {
|
|
103
117
|
case 0:
|
|
118
|
+
if (element._tolgee.wrappedWithElementOnlyKey) {
|
|
119
|
+
return [2 /*return*/, element._tolgee.wrappedWithElementOnlyKey];
|
|
120
|
+
}
|
|
104
121
|
keys = TranslationHighlighter.getKeyOptions(element);
|
|
105
122
|
if (!(keys.size > 1)) return [3 /*break*/, 2];
|
|
106
123
|
return [4 /*yield*/, this.renderer.getKey({ keys: keys, openEvent: mouseEvent })];
|
|
@@ -116,28 +133,6 @@ var TranslationHighlighter = /** @class */ (function () {
|
|
|
116
133
|
});
|
|
117
134
|
});
|
|
118
135
|
};
|
|
119
|
-
TranslationHighlighter.getKeyOptions = function (node) {
|
|
120
|
-
var nodes = Array.from(node._tolgee.nodes);
|
|
121
|
-
var keys = nodes.reduce(function (acc, curr) { return __spreadArray(__spreadArray([], __read(acc)), __read(curr._tolgee.keys.map(function (k) { return k.key; }))); }, []);
|
|
122
|
-
return new Set(keys);
|
|
123
|
-
};
|
|
124
|
-
Object.defineProperty(TranslationHighlighter.prototype, "renderer", {
|
|
125
|
-
get: function () {
|
|
126
|
-
if (this._renderer === undefined) {
|
|
127
|
-
if (typeof this.properties.config.ui === 'function') {
|
|
128
|
-
this._renderer = new this.properties.config.ui({
|
|
129
|
-
coreService: this.service,
|
|
130
|
-
properties: this.properties,
|
|
131
|
-
eventService: this.eventService,
|
|
132
|
-
translationService: this.translationService,
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return this._renderer;
|
|
137
|
-
},
|
|
138
|
-
enumerable: false,
|
|
139
|
-
configurable: true
|
|
140
|
-
});
|
|
141
136
|
return TranslationHighlighter;
|
|
142
137
|
}());
|
|
143
138
|
export { TranslationHighlighter };
|