create-shortcuts-plugin.ts 668 B

1234567891011121314151617181920212223
  1. import { bindContributionProvider, definePluginCreator } from '@flowgram.ai/core';
  2. import { ShortcutsRegistry, ShortcutsContribution } from './shortcuts-contribution';
  3. import { ShortcutsLayer } from './layers';
  4. /**
  5. * @param opts
  6. *
  7. * createShortcutsPlugin({
  8. * registerShortcuts(registry) {
  9. * }
  10. * })
  11. */
  12. export const createShortcutsPlugin = definePluginCreator<ShortcutsContribution>({
  13. onBind: ({ bind }) => {
  14. bind(ShortcutsRegistry).toSelf().inSingletonScope();
  15. bindContributionProvider(bind, ShortcutsContribution);
  16. },
  17. onInit: (ctx) => {
  18. ctx.playground.registerLayer(ShortcutsLayer);
  19. },
  20. contributionKeys: [ShortcutsContribution],
  21. });