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 CHANGED
@@ -1,3 +1,7 @@
1
+ ### 3.2.4
2
+
3
+ - fix startStandalone: added handler for committed message
4
+
1
5
  ### 3.2.3
2
6
 
3
7
  - fix startStandalone: added missing functions for implementation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "locize",
3
- "version": "3.2.3",
3
+ "version": "3.2.4",
4
4
  "description": "This package adds the incontext editor to your i18next setup.",
5
5
  "keywords": [
6
6
  "i18next",
@@ -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 && handlers[message]) {
163
- handlers[message].forEach(fc => {
164
- fc(payload, e)
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 => {