@translation-cms/sync 1.1.86 → 1.1.87

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.
Files changed (2) hide show
  1. package/README.md +50 -9
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -290,17 +290,58 @@ export function NavMenu() {
290
290
  }
291
291
  ```
292
292
 
293
- When an editor in the CMS clicks "Show in app" for a translation key like
294
- `nav:home`, the CMS:
293
+ #### Setting up action_id in the CMS
295
294
 
296
- 1. Loads your app in an iframe
297
- 2. Sends a `CMS_TRIGGER_ACTION` message for `'nav.menu'`
298
- 3. Your app calls the registered callback (`setOpen(true)`)
299
- 4. The menu opens
300
- 5. The listener highlights the matching `data-cms-key` element
295
+ In the Translations CMS, each translation key can have an `action_id`:
301
296
 
302
- **Action IDs** are usually namespaced like keys: `'nav.menu'`, `'modal.signup'`,
303
- etc. Choose IDs that make sense in context.
297
+ 1. Click the **Edit** button (pencil icon) on a translation key
298
+ 2. Fill in **Preview action** field with your action ID (e.g., `nav.menu`,
299
+ `modal.signup`)
300
+ 3. Click **Update**
301
+
302
+ When an editor clicks "Show in app" for that key, the CMS will:
303
+
304
+ 1. Load your app in an iframe
305
+ 2. Auto-open the menu/dialog/modal by sending a `CMS_TRIGGER_ACTION` message
306
+ 3. Highlight the matching `data-cms-key` element
307
+
308
+ **Action IDs** are namespaced identifiers you define — they should match action
309
+ names registered during initialization. Common patterns:
310
+
311
+ ```
312
+ nav.menu → Opens main navigation menu
313
+ nav.mobile-menu → Opens mobile hamburger menu
314
+ modal.signup → Opens signup modal
315
+ modal.login → Opens login modal
316
+ dropdown.language → Opens language selector
317
+ sidebar.filter → Opens filter sidebar
318
+ accordion.faq → Opens FAQ accordion
319
+ tabs.pricing → Switches to pricing tab
320
+ ```
321
+
322
+ **Complete workflow example:**
323
+
324
+ 1. **Client app registers action:**
325
+
326
+ ```ts
327
+ registerPreviewAction('nav.mobile-menu', () => setMobileMenuOpen(true));
328
+ ```
329
+
330
+ 2. **CMS Editor:**
331
+ - Selects key `common:nav.home`
332
+ - Clicks Edit
333
+ - Sets **Preview action** to `nav.mobile-menu`
334
+ - Clicks Update
335
+
336
+ 3. **CMS Preview:**
337
+ - Editor clicks "Show in app"
338
+ - Mobile menu auto-opens
339
+ - `<span data-cms-key="common:nav.home">` element is highlighted in yellow
340
+ - Editor sees the translation in context
341
+
342
+ ---
343
+
344
+ ### How it works
304
345
 
305
346
  ---
306
347
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@translation-cms/sync",
3
- "version": "1.1.86",
3
+ "version": "1.1.87",
4
4
  "description": "Scan translation keys in your codebase and sync them to the Translations CMS",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",