Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transform Plugin API #1699

Closed

Conversation

wadethestealth
Copy link
Member

@wadethestealth wadethestealth commented Jul 4, 2019

This PR has grown stale and I do not want to continue to update. For any future contributors, this code is 100% free for you to use without asking.

🌟 Support Custom Transforms

Adds the ability for plugins to add their own transforms, which can add more language specific transforms. It also allows for other custom rendering of current supported transforms. Such as custom markdown flavors mentioned in #1630.

See #1697 for other related issues

Discussions:

Should we allow to add default props to their transforms?
Should we allow to add default children to their transforms?
Should we go the provider route (current) or the consumer route (discussed below)?

This example (the provider route) allows for dynamic creation as well as control over all transforms available.
We may want to limit access to them, but control is nice. Currently, it is a part of the plugin provider.

However, we could make hydrogen be a consumer instead. This will mean that a transform can only be activated on activation of hydrogen or of their package. It could be removed anytime by calling a disposable, but then it won't be able to be added until one of the packages reactivates themselves. This will also remove all control of transforms that are not theirs. This works similar to autocomplete provider/consumer.


Example Custom Transform Inside A Package

Note: the transform must be able to be used to create a react element

consumeHydrogen(hydrogen: Hydrogen) {
   this.hydrogen = hydrogen;

   function test(props) {
      console.log('test');
      return null; //put your element here
   }

   test.defaultProps = { mediaType: "text/markdown" }

   this.hydrogen.registerTransform(test, "mark");

   return new Disposable(function(){
      this.hydrogen.unregisterTransform("mark");
   });
}

Example package.json Inside A Package

{
   "consumedServices": {
      "hydrogen.provider": {
         "versions": {
            "^1.3.0": "consumeHydrogen"
         }
      }
   }
}

To-Do

  • Test adding a transform
  • Test old plugins
    • hydrogen-launcher
    • hydrogen-python
    • data-explorer
  • Create test cases
    • Hydrogen Plugin
    • Transform Manager
  • Update Docs

Incompatible PRs:


Closes #1697

@wadethestealth wadethestealth changed the title [WIP] Transform Plugin API Transform Plugin API Jul 4, 2019
@wadethestealth wadethestealth changed the title Transform Plugin API [WIP] Transform Plugin API Jul 4, 2019
@wadethestealth wadethestealth changed the title [WIP] Transform Plugin API Transform Plugin API Jul 5, 2019
@wadethestealth wadethestealth mentioned this pull request Jul 8, 2019
1 task
@wadethestealth wadethestealth added the help wanted Help is desired label Sep 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion 💬 Discussion is wanted enhancement 🌟 New feature ideas help wanted Help is desired on hold 🛑
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to add custom transforms
1 participant