locize 3.2.3 → 3.2.4
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/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/src/api/postMessage.js +15 -4
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/api/postMessage.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { getIframeUrl } from '../vars.js'
|
|
2
2
|
import { store } from '../store.js'
|
|
3
3
|
|
|
4
|
+
const legacyEventMapping = {
|
|
5
|
+
committed: 'commitKeys'
|
|
6
|
+
}
|
|
7
|
+
function getMappedLegacyEvent (msg) {
|
|
8
|
+
if (legacyEventMapping[msg]) return legacyEventMapping[msg]
|
|
9
|
+
return msg
|
|
10
|
+
}
|
|
11
|
+
|
|
4
12
|
export function addLocizeSavedHandler (handler) {
|
|
5
13
|
api.locizeSavedHandler = handler
|
|
6
14
|
}
|
|
@@ -159,10 +167,13 @@ if (typeof window !== 'undefined') {
|
|
|
159
167
|
window.addEventListener('message', e => {
|
|
160
168
|
const { sender, /* senderAPIVersion, */ action, message, payload } = e.data
|
|
161
169
|
|
|
162
|
-
if (message
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
170
|
+
if (message) {
|
|
171
|
+
const usedEventName = getMappedLegacyEvent(message)
|
|
172
|
+
if (handlers[usedEventName]) {
|
|
173
|
+
handlers[usedEventName].forEach(fc => {
|
|
174
|
+
fc(payload, e)
|
|
175
|
+
})
|
|
176
|
+
}
|
|
166
177
|
} else if (sender === 'i18next-editor-frame' && handlers[action]) {
|
|
167
178
|
// console.warn('ok in', action, payload);
|
|
168
179
|
handlers[action].forEach(fc => {
|