@tolgee/core
Advanced tools
Comparing version 1.0.0-alpha.54 to 1.0.0-alpha.55
@@ -17,4 +17,6 @@ import { Properties } from '../Properties'; | ||
protected translateChildNode(node: Text | Attr, newValue: any, keys: KeyAndParams[]): NodeWithMeta; | ||
private lockNode; | ||
private unlockNode; | ||
private getParentElement; | ||
private getSuitableParent; | ||
} |
@@ -79,3 +79,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var nodes_1, nodes_1_1, textNode, result, tolgeeData, text, keys, translatedNode, parentElement, e_1_1; | ||
var nodes_1, nodes_1_1, textNode, tolgeeData, result, text, keys, translatedNode, parentElement, e_1_1; | ||
var e_1, _a; | ||
@@ -91,15 +91,19 @@ return __generator(this, function (_b) { | ||
textNode = nodes_1_1.value; | ||
if (textNode[Global_1.TOLGEE_ATTRIBUTE_NAME] === undefined) { | ||
textNode[Global_1.TOLGEE_ATTRIBUTE_NAME] = {}; | ||
} | ||
tolgeeData = textNode[Global_1.TOLGEE_ATTRIBUTE_NAME]; | ||
if (!((tolgeeData === null || tolgeeData === void 0 ? void 0 : tolgeeData.locked) !== true)) return [3 /*break*/, 3]; | ||
this.lockNode(textNode); | ||
return [4 /*yield*/, this.textService.replace(textNode.textContent)]; | ||
case 2: | ||
result = _b.sent(); | ||
tolgeeData = textNode[Global_1.TOLGEE_ATTRIBUTE_NAME]; | ||
if ((tolgeeData === null || tolgeeData === void 0 ? void 0 : tolgeeData.oldTextContent) == undefined) { | ||
if (result) { | ||
text = result.text, keys = result.keys; | ||
translatedNode = this.translateChildNode(textNode, text, keys); | ||
parentElement = this.getParentElement(translatedNode); | ||
parentElement._tolgee.nodes.add(translatedNode); | ||
this.elementRegistrar.register(parentElement); | ||
} | ||
if (result) { | ||
text = result.text, keys = result.keys; | ||
translatedNode = this.translateChildNode(textNode, text, keys); | ||
parentElement = this.getParentElement(translatedNode); | ||
parentElement._tolgee.nodes.add(translatedNode); | ||
this.elementRegistrar.register(parentElement); | ||
} | ||
this.unlockNode(textNode); | ||
_b.label = 3; | ||
@@ -133,2 +137,17 @@ case 3: | ||
}; | ||
AbstractHandler.prototype.lockNode = function (node) { | ||
if (node[Global_1.TOLGEE_ATTRIBUTE_NAME] === undefined) { | ||
node[Global_1.TOLGEE_ATTRIBUTE_NAME] = {}; | ||
} | ||
var tolgeeData = node[Global_1.TOLGEE_ATTRIBUTE_NAME]; | ||
if ((tolgeeData === null || tolgeeData === void 0 ? void 0 : tolgeeData.locked) !== true) { | ||
tolgeeData.locked = true; | ||
} | ||
return node; | ||
}; | ||
AbstractHandler.prototype.unlockNode = function (node) { | ||
if (node[Global_1.TOLGEE_ATTRIBUTE_NAME]) { | ||
node[Global_1.TOLGEE_ATTRIBUTE_NAME].locked = false; | ||
} | ||
}; | ||
AbstractHandler.prototype.getParentElement = function (node) { | ||
@@ -135,0 +154,0 @@ var parent = this.getSuitableParent(node); |
@@ -39,2 +39,5 @@ export interface TolgeeTextInputElement extends HTMLElement { | ||
}; | ||
export declare type NodeWithLock = Node & { | ||
_tolgee: NodeLock; | ||
}; | ||
export declare type ElementWithMeta = Element & ElementCSSInlineStyle & { | ||
@@ -51,4 +54,7 @@ _tolgee: ElementMeta; | ||
keys: KeyAndParams[]; | ||
} & NodeLock; | ||
export declare type NodeLock = { | ||
locked?: boolean; | ||
}; | ||
export declare type Scope = 'translations.edit' | 'translations.view' | 'keys.edit'; | ||
export declare type Mode = 'development' | 'production'; |
{ | ||
"name": "@tolgee/core", | ||
"version": "1.0.0-alpha.54", | ||
"version": "1.0.0-alpha.55", | ||
"description": "Library providing ability to translate messages directly in context of developed application.", | ||
@@ -65,3 +65,3 @@ "main": "dist/tolgee.umd.js", | ||
}, | ||
"gitHead": "2431593b9777ced1b86860b79ea4c5bb5673a997", | ||
"gitHead": "741eb2caf7c27dfe6497d64f625fc4ebf27a5223", | ||
"publishConfig": { | ||
@@ -68,0 +68,0 @@ "access": "public" |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2062995
4823