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

Pass options object to plugins #291

Merged
merged 2 commits into from
Jul 5, 2022
Merged

Conversation

abeforgit
Copy link
Member

Allows host-app to pass options to plugins.
solves https://binnenland.atlassian.net/browse/GN-3106
fully backwards-compat

Usage

The @plugins argument to the rdfa-editor component now takes a list of either strings or objects.
If an object, the plugin name should be in the name field, and the options field (which can have any value) will be passed to the plugin's initialize method as a second argument. All other fields will be ignored.

e.g.:

template:

<RdfaEditor @plugins={this.plugins} />

template controller:

this.plugins = [
   "plugin-without-options", 
   { 
      name: "plugin-with-options",
      options: { /* anything you want */ }
    }
];

plugin:

initialize(controller: Controller, options: MyOptions) {
   if (options.tralala) {
      this.doWololo();
      }
  }

@abeforgit abeforgit added the enhancement New feature or request label Jul 4, 2022
Copy link
Member

@nvdk nvdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me!

@abeforgit abeforgit merged commit 5ec7896 into development Jul 5, 2022
@abeforgit abeforgit deleted the feature/plugin-options branch July 5, 2022 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants