Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,16 @@ class LiveTranslatorManager {
badge.addEventListener('mouseleave', () => this.hideBox());
badges.push(badge);
cacheKeyParts.push(meta.path);
if (attribute.name === 'href') {
node.onclick = (ev) => {
ev.stopPropagation();
ev.preventDefault();
const clone = node.cloneNode();
const href = ZeroWidthEncoder.cleanString(clone.getAttribute('href'));
clone.setAttribute('href', href);
clone.click();
};
}
}
}
if (badges.length) {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/demo/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@
<div class="item translated" v-for="i in 5">{{ t('LTPlugin.ListItemN', [i]) }}</div>
</div>
<h3>Attribute</h3>
<img class="image" src="https://source.unsplash.com/random/500x500" :alt="t('LTPlugin.Attrs.ImageAlt')"
<img class="image" src="https://picsum.photos/600/400" :alt="t('LTPlugin.Attrs.ImageAlt')"
:title="t('LTPlugin.Attrs.ImageTitle')">
<h3>HREF attribute</h3>
<a :href="t('LTPlugin.Link.Href')" target="_blank">{{ t('LTPlugin.Link.Title') }}</a>

<div id="draggable" draggable @mousedown="dragStart" @mousemove="dragMove" @mouseup="dragEnd" ref="draggable" :title="t('LTPlugin.PositionAbsolute')">
<h3>Absolute position</h3>
Expand Down Expand Up @@ -142,7 +144,6 @@ function dragEnd() {
}

.image {
width: 80%;
border-radius: 8px;
}

Expand Down
6 changes: 5 additions & 1 deletion src/demo/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"ListItemN": "Item {0}",
"MultipleTitle": "Multiple strings inside one tag",
"Draggable": "Drag me around to cover elements",
"PositionAbsolute": "Position is absolute"
"PositionAbsolute": "Position is absolute",
"Link": {
"Href": "https://en.wikipedia.org/",
"Title": "Link to Wikipedia"
}
}
}
6 changes: 5 additions & 1 deletion src/demo/lang/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"ListItemN": "Elem {0}",
"MultipleTitle": "Több string egy tagen belül",
"Draggable": "Mozgass egy elem fölé, hogy eltakard azt",
"PositionAbsolute": "'absolute' pozíció"
"PositionAbsolute": "'absolute' pozíció",
"Link": {
"Href": "https://hu.wikipedia.org/",
"Title": "Link a Wikipediára"
}
}
}
11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,17 @@ class LiveTranslatorManager {
badge.addEventListener('mouseleave', () => this.hideBox())
badges.push(badge)
cacheKeyParts.push(meta.path)

if (attribute.name === 'href') {
node.onclick = (ev) => {
ev.stopPropagation()
ev.preventDefault()
const clone = node.cloneNode() as HTMLElement
const href = ZeroWidthEncoder.cleanString(clone.getAttribute('href'))
clone.setAttribute('href', href)
clone.click()
}
}
}
}

Expand Down