@tolgee/core 4.5.0 → 4.6.0-rc.2e9d3c7.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.
- package/dist/tolgee.cjs.js +103 -97
- 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.esm.js +1 -1
- package/dist/tolgee.esm.js.map +1 -1
- package/dist/tolgee.umd.js +103 -97
- package/dist/tolgee.umd.js.map +1 -1
- package/dist/tolgee.umd.min.js +1 -1
- package/dist/tolgee.umd.min.js.map +1 -1
- package/lib/Constants/Global.d.ts +0 -0
- package/lib/Constants/ModifierKey.d.ts +0 -0
- package/lib/Errors/ApiHttpError.d.ts +0 -0
- package/lib/Observer.d.ts +0 -0
- package/lib/Properties.d.ts +0 -0
- package/lib/Tolgee.d.ts +0 -0
- package/lib/TolgeeConfig.d.ts +0 -0
- package/lib/helpers/NodeHelper.d.ts +0 -0
- package/lib/helpers/TextHelper.d.ts +0 -0
- package/lib/helpers/commonTypes.d.ts +0 -0
- package/lib/helpers/encoderPolyfill.d.ts +0 -0
- package/lib/helpers/secret.d.ts +0 -0
- package/lib/helpers/sleep.d.ts +0 -0
- package/lib/highlighter/HighlightFunctionsInitializer.d.ts +1 -0
- package/lib/highlighter/MouseEventHandler.d.ts +7 -12
- package/lib/highlighter/TranslationHighlighter.d.ts +1 -1
- package/lib/index.d.ts +0 -0
- package/lib/modules/IcuFormatter.d.ts +0 -0
- package/lib/modules/index.d.ts +0 -0
- package/lib/services/ApiHttpService.d.ts +0 -0
- package/lib/services/CoreService.d.ts +0 -0
- package/lib/services/DependencyService.d.ts +0 -0
- package/lib/services/ElementRegistrar.d.ts +0 -0
- package/lib/services/EventEmitter.d.ts +0 -0
- package/lib/services/EventService.d.ts +0 -0
- package/lib/services/ModuleService.d.ts +0 -0
- package/lib/services/ScreenshotService.d.ts +0 -0
- package/lib/services/Subscription.d.ts +0 -0
- package/lib/services/TextService.d.ts +0 -0
- package/lib/services/TranslationService.d.ts +0 -0
- package/lib/toolsManager/Messages.d.ts +0 -0
- package/lib/toolsManager/PluginManager.d.ts +0 -0
- package/lib/types/DTOs.d.ts +0 -0
- package/lib/types/apiSchema.generated.d.ts +0 -0
- package/lib/types.d.ts +1 -0
- package/lib/wrappers/AbstractWrapper.d.ts +0 -0
- package/lib/wrappers/NodeHandler.d.ts +0 -0
- package/lib/wrappers/WrappedHandler.d.ts +0 -0
- package/lib/wrappers/invisible/AttributeHandler.d.ts +0 -0
- package/lib/wrappers/invisible/Coder.d.ts +0 -0
- package/lib/wrappers/invisible/ContentHandler.d.ts +0 -0
- package/lib/wrappers/invisible/CoreHandler.d.ts +0 -0
- package/lib/wrappers/invisible/InvisibleWrapper.d.ts +0 -0
- package/lib/wrappers/invisible/ValueMemory.d.ts +0 -0
- package/lib/wrappers/text/AttributeHandler.d.ts +0 -0
- package/lib/wrappers/text/Coder.d.ts +0 -0
- package/lib/wrappers/text/ContentHandler.d.ts +0 -0
- package/lib/wrappers/text/CoreHandler.d.ts +0 -0
- package/lib/wrappers/text/TextWrapper.d.ts +0 -0
- package/package.json +4 -4
package/dist/tolgee.umd.js
CHANGED
|
@@ -915,42 +915,35 @@
|
|
|
915
915
|
ModifierKey[ModifierKey["Meta"] = 3] = "Meta";
|
|
916
916
|
})(exports.ModifierKey || (exports.ModifierKey = {}));
|
|
917
917
|
|
|
918
|
+
var eCapture = {
|
|
919
|
+
capture: true,
|
|
920
|
+
};
|
|
918
921
|
var MouseEventHandler = /** @class */ (function () {
|
|
919
|
-
function MouseEventHandler(
|
|
922
|
+
function MouseEventHandler(dependencies) {
|
|
920
923
|
var _this = this;
|
|
921
|
-
this.
|
|
924
|
+
this.dependencies = dependencies;
|
|
922
925
|
this.keysDown = new Set();
|
|
923
|
-
this.mouseOn = new Set();
|
|
924
926
|
this.mouseOnChanged = new EventEmitterImpl();
|
|
925
927
|
this.keysChanged = new EventEmitterImpl();
|
|
926
|
-
this.
|
|
927
|
-
_this.
|
|
928
|
-
|
|
929
|
-
|
|
928
|
+
this.highlight = function (el) {
|
|
929
|
+
if (_this.highlighted !== el) {
|
|
930
|
+
_this.unhighlight();
|
|
931
|
+
if (el) {
|
|
932
|
+
el._tolgee.preventClean = true;
|
|
933
|
+
el._tolgee.highlight();
|
|
934
|
+
_this.highlighted = el;
|
|
935
|
+
_this.mouseOnChanged.emit(el);
|
|
936
|
+
}
|
|
930
937
|
}
|
|
931
938
|
};
|
|
932
|
-
this.highlight = function () {
|
|
933
|
-
_this.getMouseOn()._tolgee.highlight();
|
|
934
|
-
_this.highlighted = _this.getMouseOn();
|
|
935
|
-
};
|
|
936
939
|
this.unhighlight = function () {
|
|
937
940
|
if (_this.highlighted) {
|
|
941
|
+
_this.highlighted._tolgee.preventClean = false;
|
|
938
942
|
_this.highlighted._tolgee.unhighlight();
|
|
939
|
-
_this.highlighted =
|
|
943
|
+
_this.highlighted = undefined;
|
|
944
|
+
_this.mouseOnChanged.emit(_this.highlighted);
|
|
940
945
|
}
|
|
941
946
|
};
|
|
942
|
-
this.onMouseOut = function (element) {
|
|
943
|
-
element._tolgee.preventClean = false;
|
|
944
|
-
_this.mouseOn.delete(element);
|
|
945
|
-
_this.mouseOnChanged.emit(_this.getMouseOn());
|
|
946
|
-
};
|
|
947
|
-
this.onMouseOver = function (element) {
|
|
948
|
-
_this.filterMouseOn();
|
|
949
|
-
element._tolgee.preventClean = true;
|
|
950
|
-
_this.mouseOn.delete(element); //to get in to last place
|
|
951
|
-
_this.mouseOn.add(element);
|
|
952
|
-
_this.mouseOnChanged.emit(_this.getMouseOn());
|
|
953
|
-
};
|
|
954
947
|
}
|
|
955
948
|
MouseEventHandler.prototype.run = function () {
|
|
956
949
|
if (typeof window !== 'undefined') {
|
|
@@ -958,88 +951,82 @@
|
|
|
958
951
|
return;
|
|
959
952
|
}
|
|
960
953
|
};
|
|
961
|
-
MouseEventHandler.prototype.
|
|
962
|
-
var
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
return;
|
|
954
|
+
MouseEventHandler.prototype.updateHighlight = function () {
|
|
955
|
+
var position = this.cursorPosition;
|
|
956
|
+
var newHighlighted;
|
|
957
|
+
if (position && this.areKeysDown()) {
|
|
958
|
+
newHighlighted = this.getClosestTolgeeElement(document.elementFromPoint(position.x, position.y));
|
|
967
959
|
}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
}
|
|
974
|
-
});
|
|
975
|
-
this.keysChanged.subscribe(function () {
|
|
976
|
-
_this.onConditionsChanged();
|
|
977
|
-
});
|
|
960
|
+
this.highlight(newHighlighted);
|
|
961
|
+
};
|
|
962
|
+
MouseEventHandler.prototype.updateCursorPosition = function (position) {
|
|
963
|
+
this.cursorPosition = position;
|
|
964
|
+
this.updateHighlight();
|
|
978
965
|
};
|
|
979
|
-
MouseEventHandler.prototype.
|
|
966
|
+
MouseEventHandler.prototype.initKeyListener = function () {
|
|
980
967
|
var _this = this;
|
|
981
|
-
var
|
|
982
|
-
var onMouseOut = function () { return _this.onMouseOut(element); };
|
|
983
|
-
var onClick = function (e) {
|
|
984
|
-
if (_this.areKeysDown() && _this.highlighted === e.currentTarget) {
|
|
985
|
-
e.stopPropagation();
|
|
986
|
-
e.preventDefault();
|
|
987
|
-
onclick(e);
|
|
988
|
-
}
|
|
989
|
-
};
|
|
990
|
-
element.addEventListener('mouseover', onMouseOver);
|
|
991
|
-
element.addEventListener('click', onClick, { capture: true });
|
|
992
|
-
var onMouseDownOrUp = function (e) {
|
|
968
|
+
var defaultEventBlock = function (e) {
|
|
993
969
|
if (_this.areKeysDown()) {
|
|
994
970
|
e.stopPropagation();
|
|
995
971
|
e.preventDefault();
|
|
996
972
|
}
|
|
997
973
|
};
|
|
998
|
-
|
|
999
|
-
element.addEventListener('mouseup', onMouseDownOrUp);
|
|
1000
|
-
element.addEventListener('mouseout', onMouseOut);
|
|
1001
|
-
element._tolgee.removeAllEventListeners = function () {
|
|
1002
|
-
element.removeEventListener('mousedown', onMouseDownOrUp);
|
|
1003
|
-
element.removeEventListener('mouseup', onMouseDownOrUp);
|
|
1004
|
-
element.removeEventListener('mouseover', onMouseOver);
|
|
1005
|
-
element.removeEventListener('click', onClick, { capture: true });
|
|
1006
|
-
element.removeEventListener('mouseout', onMouseOut);
|
|
1007
|
-
};
|
|
1008
|
-
};
|
|
1009
|
-
MouseEventHandler.prototype.getMouseOn = function () {
|
|
1010
|
-
var mouseOnArray = Array.from(this.mouseOn);
|
|
1011
|
-
return mouseOnArray.length ? mouseOnArray[0] : undefined;
|
|
1012
|
-
};
|
|
1013
|
-
MouseEventHandler.prototype.initKeyListener = function () {
|
|
1014
|
-
var _this = this;
|
|
1015
|
-
window.addEventListener('blur', function () {
|
|
974
|
+
document.addEventListener('blur', function () {
|
|
1016
975
|
_this.keysDown = new Set();
|
|
1017
976
|
_this.keysChanged.emit(_this.areKeysDown());
|
|
1018
|
-
|
|
1019
|
-
|
|
977
|
+
_this.updateHighlight();
|
|
978
|
+
}, eCapture);
|
|
979
|
+
document.addEventListener('keydown', function (e) {
|
|
1020
980
|
var modifierKey = exports.ModifierKey[e.key];
|
|
1021
981
|
if (modifierKey !== undefined) {
|
|
1022
982
|
_this.keysDown.add(modifierKey);
|
|
1023
983
|
_this.keysChanged.emit(_this.areKeysDown());
|
|
1024
984
|
}
|
|
1025
|
-
|
|
1026
|
-
|
|
985
|
+
_this.updateHighlight();
|
|
986
|
+
}, eCapture);
|
|
987
|
+
document.addEventListener('keyup', function (e) {
|
|
1027
988
|
_this.keysDown.delete(exports.ModifierKey[e.key]);
|
|
1028
989
|
_this.keysChanged.emit(_this.areKeysDown());
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
990
|
+
_this.updateHighlight();
|
|
991
|
+
}, eCapture);
|
|
992
|
+
document.addEventListener('mousemove', function (e) {
|
|
993
|
+
defaultEventBlock(e);
|
|
994
|
+
_this.updateCursorPosition({ x: e.clientX, y: e.clientY });
|
|
995
|
+
}, { passive: true, capture: true });
|
|
996
|
+
document.addEventListener('mouseenter', defaultEventBlock, eCapture);
|
|
997
|
+
document.addEventListener('mouseover', defaultEventBlock, eCapture);
|
|
998
|
+
document.addEventListener('mouseout', defaultEventBlock, eCapture);
|
|
999
|
+
document.addEventListener('mouseleave', defaultEventBlock, eCapture);
|
|
1000
|
+
document.addEventListener('mousedown', defaultEventBlock, eCapture);
|
|
1001
|
+
document.addEventListener('mouseup', defaultEventBlock, eCapture);
|
|
1002
|
+
document.addEventListener('scroll', function () {
|
|
1003
|
+
var _a;
|
|
1004
|
+
(_a = _this.highlighted) === null || _a === void 0 ? void 0 : _a._tolgee.highlight();
|
|
1005
|
+
}, { capture: true, passive: true });
|
|
1006
|
+
document.addEventListener('click', function (e) {
|
|
1007
|
+
defaultEventBlock(e);
|
|
1008
|
+
if (_this.areKeysDown()) {
|
|
1009
|
+
var element = _this.getClosestTolgeeElement(e.target);
|
|
1010
|
+
if (element && element === _this.highlighted) {
|
|
1011
|
+
_this.dependencies.translationHighlighter.translationEdit(e, element);
|
|
1012
|
+
_this.unhighlight();
|
|
1013
|
+
}
|
|
1036
1014
|
}
|
|
1037
|
-
});
|
|
1015
|
+
}, eCapture);
|
|
1016
|
+
};
|
|
1017
|
+
MouseEventHandler.prototype.getClosestTolgeeElement = function (element) {
|
|
1018
|
+
if (element === null || element === void 0 ? void 0 : element._tolgee) {
|
|
1019
|
+
return element;
|
|
1020
|
+
}
|
|
1021
|
+
if (element === null || element === void 0 ? void 0 : element.parentElement) {
|
|
1022
|
+
return this.getClosestTolgeeElement(element.parentElement);
|
|
1023
|
+
}
|
|
1024
|
+
return undefined;
|
|
1038
1025
|
};
|
|
1039
1026
|
MouseEventHandler.prototype.areKeysDown = function () {
|
|
1040
1027
|
var e_1, _a;
|
|
1041
1028
|
try {
|
|
1042
|
-
for (var _b = __values(this.properties.config.highlightKeys), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1029
|
+
for (var _b = __values(this.dependencies.properties.config.highlightKeys), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1043
1030
|
var key = _c.value;
|
|
1044
1031
|
if (!this.keysDown.has(key)) {
|
|
1045
1032
|
return false;
|
|
@@ -1091,14 +1078,11 @@
|
|
|
1091
1078
|
}); })), false); }, []);
|
|
1092
1079
|
};
|
|
1093
1080
|
TranslationHighlighter.prototype.listen = function (element) {
|
|
1094
|
-
var _this = this;
|
|
1095
1081
|
this.dependencies.highlightFunctionInitializer.initFunctions(element);
|
|
1096
|
-
this.dependencies.mouseEventHandler.handle(
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
}
|
|
1101
|
-
}); }); });
|
|
1082
|
+
// this.dependencies.mouseEventHandler.handle(
|
|
1083
|
+
// element,
|
|
1084
|
+
// async (e) => await this.translationEdit(e, element)
|
|
1085
|
+
// );
|
|
1102
1086
|
};
|
|
1103
1087
|
TranslationHighlighter.prototype.getRenderer = function () {
|
|
1104
1088
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1672,7 +1656,7 @@
|
|
|
1672
1656
|
this.highlightKeys = [exports.ModifierKey.Alt];
|
|
1673
1657
|
this.passToParent = ['option', 'optgroup'];
|
|
1674
1658
|
this.restrictedElements = ['script', 'style'];
|
|
1675
|
-
this.highlightColor = 'rgb(
|
|
1659
|
+
this.highlightColor = 'rgb(255, 0, 0)';
|
|
1676
1660
|
this.wrapperMode = 'text';
|
|
1677
1661
|
/**
|
|
1678
1662
|
* When true, fallback language will be preloaded on Tolgee.run
|
|
@@ -1773,7 +1757,7 @@
|
|
|
1773
1757
|
this.handshake = function () {
|
|
1774
1758
|
var sharedConfiguration = __assign(__assign({}, _this.properties), { config: __assign(__assign({}, _this.properties.config), {
|
|
1775
1759
|
//remove properties, which cannot be sent by window.postMessage
|
|
1776
|
-
staticData: undefined, targetElement: undefined, _targetElement: undefined, ui: undefined }), uiPresent: Boolean(_this.properties.config.ui), uiVersion: "4.
|
|
1760
|
+
staticData: undefined, targetElement: undefined, _targetElement: undefined, ui: undefined }), uiPresent: Boolean(_this.properties.config.ui), uiVersion: "4.6.0-rc.2e9d3c7.0" });
|
|
1777
1761
|
var timer = null;
|
|
1778
1762
|
var ping = function () {
|
|
1779
1763
|
_this.messages.send('TOLGEE_READY', sharedConfiguration);
|
|
@@ -1873,6 +1857,7 @@
|
|
|
1873
1857
|
return Messages;
|
|
1874
1858
|
}());
|
|
1875
1859
|
|
|
1860
|
+
var BORDER_WIDTH = 5;
|
|
1876
1861
|
var HighlightFunctionsInitializer = /** @class */ (function () {
|
|
1877
1862
|
function HighlightFunctionsInitializer(properties) {
|
|
1878
1863
|
this.properties = properties;
|
|
@@ -1884,13 +1869,34 @@
|
|
|
1884
1869
|
HighlightFunctionsInitializer.prototype.initHighlightFunction = function (element) {
|
|
1885
1870
|
var _this = this;
|
|
1886
1871
|
element._tolgee.highlight = function () {
|
|
1887
|
-
element.
|
|
1888
|
-
|
|
1872
|
+
if (!element.isConnected) {
|
|
1873
|
+
return;
|
|
1874
|
+
}
|
|
1875
|
+
var highlightEl = element._tolgee.highlightEl;
|
|
1876
|
+
if (!highlightEl) {
|
|
1877
|
+
highlightEl = document.createElement('div');
|
|
1878
|
+
highlightEl.style.pointerEvents = 'none';
|
|
1879
|
+
highlightEl.style.border = "".concat(BORDER_WIDTH, "px solid ").concat(_this.properties.config.highlightColor);
|
|
1880
|
+
highlightEl.style.position = 'fixed';
|
|
1881
|
+
highlightEl.style.boxSizing = 'border-box';
|
|
1882
|
+
highlightEl.style.zIndex = String(Number.MAX_SAFE_INTEGER);
|
|
1883
|
+
highlightEl.style.contain = 'layout';
|
|
1884
|
+
element._tolgee.highlightEl = highlightEl;
|
|
1885
|
+
document.body.appendChild(highlightEl);
|
|
1886
|
+
}
|
|
1887
|
+
var shape = element.getBoundingClientRect();
|
|
1888
|
+
highlightEl.style.top = shape.top - BORDER_WIDTH + 'px';
|
|
1889
|
+
highlightEl.style.left = shape.left - BORDER_WIDTH + 'px';
|
|
1890
|
+
highlightEl.style.width = shape.width + 2 * BORDER_WIDTH + 'px';
|
|
1891
|
+
highlightEl.style.height = shape.height + 2 * BORDER_WIDTH + 'px';
|
|
1892
|
+
highlightEl.style.display = 'block';
|
|
1889
1893
|
};
|
|
1890
1894
|
};
|
|
1891
1895
|
HighlightFunctionsInitializer.prototype.initUnhighlightFunction = function (element) {
|
|
1892
1896
|
element._tolgee.unhighlight = function () {
|
|
1893
|
-
|
|
1897
|
+
var _a;
|
|
1898
|
+
(_a = element._tolgee.highlightEl) === null || _a === void 0 ? void 0 : _a.remove();
|
|
1899
|
+
element._tolgee.highlightEl = null;
|
|
1894
1900
|
};
|
|
1895
1901
|
};
|
|
1896
1902
|
return HighlightFunctionsInitializer;
|
|
@@ -2914,7 +2920,7 @@
|
|
|
2914
2920
|
this.properties = new Properties();
|
|
2915
2921
|
this.eventService = new EventService();
|
|
2916
2922
|
this.apiHttpService = new ApiHttpService(this.properties);
|
|
2917
|
-
this.mouseEventHandler = new MouseEventHandler(this
|
|
2923
|
+
this.mouseEventHandler = new MouseEventHandler(this);
|
|
2918
2924
|
this.moduleService = new ModuleService();
|
|
2919
2925
|
this.coreService = new CoreService(this.properties, this.apiHttpService);
|
|
2920
2926
|
this.screenshotService = new ScreenshotService(this.coreService, this.apiHttpService);
|