Struggling to register a function for use in Plasmic Studio

It’s my first time registering a function for use in Plasmic Studio,
and I’m not sure how to access it.

My goal is using this pinyin converter (website/repo) to convert dynamic value chinese characters to latin characters, something like “很好” → “hen hao”.

  • I’ve installed the package as they suggested npm install pinyin
  • Here’s what I added in plasmic.init:
import pinyin from "pinyin";
PLASMIC.registerFunction(pinyin, {
  name: 'pinyin'
});
  • And then, I couldn’t figure out how to use it in Plasmic Studio :thinking:
    I assumed it would be something like $$.pinyin().$state.name.value

Hey @leafer_design,

Can you try using $$.pinyin($state.name.value) instead?

1 Like

Thanks for the pointer!

Turns out a missing dependency (wasn’t added by npm during install) was causing it to not show in Studio :grimacing: