Make the aceAttribClasses hook harder to misuse

pull/4406/head
Richard Hansen 2020-10-06 17:47:03 -04:00 committed by John McLear
parent 5aa318a09b
commit ba6bdf35be
2 changed files with 13 additions and 9 deletions

View File

@ -679,18 +679,21 @@ exports.stylesForExport = function(hook, padId, cb){
## aceAttribClasses
Called from: src/static/js/linestylefilter.js
Things in context:
1. Attributes - Object of Attributes
This hook is called when attributes are investigated on a line. It is useful if
you want to add another attribute type or property type to a pad.
This hook is called when attributes are investigated on a line. It is useful if you want to add another attribute type or property type to a pad.
An attributes object is passed to the aceAttribClasses hook functions instead of
the usual context object. A hook function can either modify this object directly
or provide an object whose properties will be assigned to the attributes object.
Example:
```
exports.aceAttribClasses = function(hook_name, attr, cb){
attr.sub = 'tag:sub';
cb(attr);
}
exports.aceAttribClasses = (hookName, attrs, cb) => {
return cb([{
sub: 'tag:sub',
}]);
};
```
## exportFileName

View File

@ -59,8 +59,9 @@ linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFun
{
// Plugin Hook to add more Attrib Classes
const results = hooks.callAll('aceAttribClasses', linestylefilter.ATTRIB_CLASSES);
if (results.length >= 1) linestylefilter.ATTRIB_CLASSES = results[0];
for (const attribClasses of hooks.callAll('aceAttribClasses', linestylefilter.ATTRIB_CLASSES)) {
Object.assign(linestylefilter.ATTRIB_CLASSES, attribClasses);
}
if (lineLength == 0) return textAndClassFunc;