Active format/state tracking for toolbar buttons.
Access:
app.activeState
app.getModule('activeState')
app.invoke('activeState.method', …)
getActiveKeys#
Returns active rule keys for the current selection context, checking tag, block, and custom rules.
Parameters:
- keys (
Array) — rule keys or hotkey names
Returns: string[]
app.activeState.getActiveKeys(['bold','heading']);
check#
Returns whether a single registered rule key matches the current selection context.
Parameters:
- key (
string) — lookup key
Returns: boolean
app.activeState.check('bold');
addTagRule#
Registers a CSS-selector tag rule for an active-state key.
Parameters:
- key (
string) — lookup key - selector (
string) — CSS selector
app.activeState.addTagRule('bold', 'strong, b');
addBlockRule#
Registers block-type rule(s) that activate the given key.
Parameters:
- key (
string) — lookup key - types (
Array) — block types filter
app.activeState.addBlockRule('heading', ['heading']);
addCustomRule#
Registers a custom predicate function for an active-state key.
Parameters:
- key (
string) — lookup key - fn (
function) — predicate or callback function
app.activeState.addCustomRule('custom', ({ blocks }) => blocks.length > 1);
remove#
Removes tag, block, and custom rules for the given key.
Parameters:
- key (
string) — lookup key
app.activeState.remove('bold');
list#
Lists all registered active-state rule keys.
Returns: string[]
app.activeState.list();
setAll#
Bulk-registers rules from a config object (string, array, or function per key).
Parameters:
- config (
object) — configuration object
app.activeState.setAll({ bold: 'strong', h2: ['heading'] });
getActiveStyles#
Collects inline CSS property values from the caret/selection inline ancestor chain.
Parameters:
- props (
Array) — CSS property names to collect
Returns: object (prop → value map)
app.activeState.getActiveStyles(['color']);