Events: Allow for easier application extension with hook points.
How does it work?
Every time someone wants to extend the application, instead of modifying original `publishing.js` file, he or she can subscribe to given events, e.g.
Scenario: Table Of Contents extension
```
// resources/public/js/toc.js
events.subscribe('content:rendered', function () {
// Prepend table of contents in edit mode on updates
});
events.subscribe('document:loaded', function () {
// Prepend table of contents on initial load in edit view and preview
});
```
Now, having structured way to hook into app allows to keep the main codebase maintainable and pretty stable and extremely extensible at the same time.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
<link href="/style.css" rel="stylesheet" type="text/css" />
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/marked/0.3.5/marked.min.js" type="text/javascript"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/blueimp-md5/1.0.1/js/md5.min.js" type="text/javascript"></script>
|
||||
<script src="/js/events.js" type="text/javascript"></script>
|
||||
<script src="/js/publishing.js" type="text/javascript"></script>
|
||||
<base target="_blank">
|
||||
</head>
|
||||
|
||||
Reference in New Issue
Block a user