{"action":"created","issue":{"url":"https://api.github.com/repos/yabwe/medium-editor/issues/684","labels_url":"https://api.github.com/repos/yabwe/medium-editor/issues/684/labels{/name}","comments_url":"https://api.github.com/repos/yabwe/medium-editor/issues/684/comments","events_url":"https://api.github.com/repos/yabwe/medium-editor/issues/684/events","html_url":"https://github.com/yabwe/medium-editor/issues/684","id":87769031,"number":684,"title":"Inject the global dependancies in extensions","user":{"login":"be-next-hotdog","id":10281179,"avatar_url":"https://avatars.githubusercontent.com/u/10281179?v=3","gravatar_id":"","url":"https://api.github.com/users/be-next-hotdog","html_url":"https://github.com/be-next-hotdog","followers_url":"https://api.github.com/users/be-next-hotdog/followers","following_url":"https://api.github.com/users/be-next-hotdog/following{/other_user}","gists_url":"https://api.github.com/users/be-next-hotdog/gists{/gist_id}","starred_url":"https://api.github.com/users/be-next-hotdog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/be-next-hotdog/subscriptions","organizations_url":"https://api.github.com/users/be-next-hotdog/orgs","repos_url":"https://api.github.com/users/be-next-hotdog/repos","events_url":"https://api.github.com/users/be-next-hotdog/events{/privacy}","received_events_url":"https://api.github.com/users/be-next-hotdog/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yabwe/medium-editor/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-06-12T15:50:52Z","updated_at":"2015-06-17T15:31:08Z","closed_at":null,"body":"Heyy, I m looking for suggestions while extending the components( ie. toolbar, anchor form and etc) via \" MediumEditor.extensions.XXXX.extend() \".\r\n\r\nIn order to factorize the my extensions scripts, I did just in main script :\r\n\r\noptions = { XXXX : new MediumEditor.extensions.XXXX.extend(MyExtensions)}  before instantiation.\r\n\r\nSo I try to find a better way to inject the Util, Selection global classes in my extensions cuz obviously I didnt define them in my extensions objects, or any tips to facilitate the refactoring ?    "},"comment":{"url":"https://api.github.com/repos/yabwe/medium-editor/issues/comments/112847949","html_url":"https://github.com/yabwe/medium-editor/issues/684#issuecomment-112847949","issue_url":"https://api.github.com/repos/yabwe/medium-editor/issues/684","id":112847949,"user":{"login":"nmielnik","id":2444240,"avatar_url":"https://avatars.githubusercontent.com/u/2444240?v=3","gravatar_id":"","url":"https://api.github.com/users/nmielnik","html_url":"https://github.com/nmielnik","followers_url":"https://api.github.com/users/nmielnik/followers","following_url":"https://api.github.com/users/nmielnik/following{/other_user}","gists_url":"https://api.github.com/users/nmielnik/gists{/gist_id}","starred_url":"https://api.github.com/users/nmielnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmielnik/subscriptions","organizations_url":"https://api.github.com/users/nmielnik/orgs","repos_url":"https://api.github.com/users/nmielnik/repos","events_url":"https://api.github.com/users/nmielnik/events{/privacy}","received_events_url":"https://api.github.com/users/nmielnik/received_events","type":"User","site_admin":false},"created_at":"2015-06-17T15:31:08Z","updated_at":"2015-06-17T15:31:08Z","body":"1. Let me know what didn't work for you, if it's something in our code I'd like to fix it before we cut the official v5.0.0\r\n\r\n2. The `MediumEditor.extensions.form` is basically a class that defines the methods that need to exist for MediumEditor to support displaying a custom form in the toolbar.  The Anchor extension and the FontSize extension both extend the `MediumEditor.extensions.form` base class.  You can see the code here: [form.js](https://github.com/yabwe/medium-editor/blob/v5/src/js/extensions/form.js)\r\n\r\nIf you're looking to have your extension behave similar to the anchor form or font size form, you can extend either of those for your extension:\r\n\r\n```js\r\nvar MyAnchor = MediumEditor.extensions.anchor.extend({ /* overrides */ });\r\nvar MyFontSize = MediumEditor.extensions.fontSize.extend({ /* overrides */});\r\nvar editor = new MediumEditor('.editor', {\r\n  toolbar: {\r\n    buttons: ['anchor', 'fontSize']\r\n  },\r\n  extensions: {\r\n    anchor: new MyAnchor(),\r\n    fontSize: new MyFontSize()\r\n  }\r\n});\r\n```\r\n\r\nYou can then start adding or removing methods to mess around with modifying the behavior.  Eventually, you'll probably just want to use `MediumEditor.extensions.form.extend()` to define your custom extension so that you won't have a dependency on the anchor/fontSize, but extending from those existing extensions could be a good way to figure things out."}}