Hyphenation for node and Polyfill for client-side hyphenation.
Hyphenopoly fires a bunch of events while executing. As a user, you can extend or overwrite the actions performed by these events. Some events have a default action that may be prevented (if the event is cancellable).
To handle some of these events, you may specify a ‘handleEvent’ property in the global ‘Hyphenopoly’ object:
Hyphenopoly.config({
require: {
//[...]
},
handleEvent: {
"hyphenopolyEnd": function () {
console.log("Hyphenopoly ended");
}
}
});
Internally, events in Hyphenopoly are implemented as Promises that are fulfilled with a certain value.
Fired after an element has been hyphenated.
Default-action: none
cancellable: true
Fields: `el` (element), `lang` (language-code)
Fired before an element gets hyphenated.
Default-action: none
cancellable: true
Fields: `el` (element), `lang` (language-code)
Fired when engine and pattern files are ready.
Default-action: none
cancellable: true
Fields: `lang` (language-code)
Fired when an error occurs.
Default-action: `window.console.warn(e);`
cancellable: true
Fields: e (Error)
To silence errors, prevent the default of this event:
Hyphenopoly.config({
require: {
//[...]
},
handleEvent: {
error: function (e) {
e.preventDefault(); //don't show error messages in console
}
}
});
Fired when all collected elements are hyphenated.
Default-action: none
cancellable: true
Fields: null
Fired when Hyphenopoly starts.
Default-action: none
cancellable: true
Fields: null
Fired when Hyphenopoly_Loader.js decides to load Hyphenopoly.js.
Default-action: none
cancellable: true
Fields: null
Fired when Hyphenopoly_Loader.js decides NOT to load Hyphenopoly.js and before it deletes the global ‘Hyphenopoly’ object. This event can be used to invoke other scripts, if native CSS hyphenation is available.
Default-action: none
cancellable: true
Fields: null