diff --git a/doc/api/hooks_server-side.md b/doc/api/hooks_server-side.md index 57ae1c117..9c8630b4d 100644 --- a/doc/api/hooks_server-side.md +++ b/doc/api/hooks_server-side.md @@ -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 diff --git a/src/static/js/linestylefilter.js b/src/static/js/linestylefilter.js index a3cf68433..b3496a818 100644 --- a/src/static/js/linestylefilter.js +++ b/src/static/js/linestylefilter.js @@ -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;