-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(js sdk): Allow element wrapping & test TG-280 (#435)
- Loading branch information
Showing
45 changed files
with
44,472 additions
and
35,800 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { NodeHelper } from '../helpers/NodeHelper'; | ||
import { Properties } from '../Properties'; | ||
import { TranslationHighlighter } from '../highlighter/TranslationHighlighter'; | ||
import { TextService } from '../services/TextService'; | ||
import { AbstractHandler } from './AbstractHandler'; | ||
import { ElementRegistrar } from '../services/ElementRegistrar'; | ||
import { TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE } from '../Constants/Global'; | ||
|
||
export class WrappedHandler extends AbstractHandler { | ||
constructor( | ||
protected properties: Properties, | ||
protected translationHighlighter: TranslationHighlighter, | ||
protected textService: TextService, | ||
protected elementRegistrar: ElementRegistrar | ||
) { | ||
super(properties, textService, elementRegistrar, translationHighlighter); | ||
} | ||
|
||
async handle(node: Node): Promise<void> { | ||
const xPath = `./descendant-or-self::*[@${TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE}]`; | ||
const nodes = NodeHelper.evaluate(xPath, node); | ||
const filtered: Element[] = this.filterRestricted(nodes as Element[]); | ||
filtered.forEach((element) => { | ||
const elementWithMeta = AbstractHandler.initParentElement(element); | ||
elementWithMeta._tolgee.wrappedWithElementOnlyKey = element.getAttribute( | ||
TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE | ||
); | ||
this.elementRegistrar.register(elementWithMeta); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
import { Tolgee } from './Tolgee'; | ||
import { TolgeeConfig } from './TolgeeConfig'; | ||
import { ModifierKey } from './Constants/ModifierKey'; | ||
import { TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE } from './Constants/Global'; | ||
import { TranslationData } from './DTOs/TranslationData'; | ||
|
||
export { Tolgee, TolgeeConfig, ModifierKey }; | ||
export { | ||
Tolgee, | ||
TolgeeConfig, | ||
ModifierKey, | ||
TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE, | ||
TranslationData, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.