Add docs for aceRegisterLineAttributes hook (#7512)

* Add docs for aceRegisterLineAttributes hook

Documents the new hook in both .md and .adoc client-side hook references.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Fix: correct source file path from .js to .ts

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
John McLear 2026-04-14 13:48:33 +01:00 committed by GitHub
parent 5e0602c5ee
commit 649f960341
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 55 additions and 0 deletions

View file

@ -211,6 +211,34 @@ The return value of this hook will add elements into the "lineMarkerAttribute"
category, making the aceDomLineProcessLineAttributes hook (documented below)
call for those elements.
=== aceRegisterLineAttributes
Called from: `src/static/js/ace2_inner.ts`
Things in context: None
Tells Etherpad which line attributes should be preserved when a user presses
Enter to split a line. Without this hook, custom line attributes (such as
headings or alignment) are lost when a line is split.
The return value should be an array of attribute names:
[source,javascript]
----
exports.aceRegisterLineAttributes = function(){
return [ 'heading' ];
}
----
When Enter is pressed on a line that has a registered attribute:
* **Middle or end of line:** the attribute is copied to the new line below.
* **Start of line (column 0):** the attribute moves down with the text content,
and the now-empty line above is cleared.
This is backwards compatible — on Etherpad versions that do not have this hook,
the registration is silently ignored.
=== aceInitialized
Called from: `src/static/js/ace2_inner.js`

View file

@ -207,6 +207,33 @@ The return value of this hook will add elements into the "lineMarkerAttribute"
category, making the aceDomLineProcessLineAttributes hook (documented below)
call for those elements.
## aceRegisterLineAttributes
Called from: `src/static/js/ace2_inner.ts`
Things in context: None
Tells Etherpad which line attributes should be preserved when a user presses
Enter to split a line. Without this hook, custom line attributes (such as
headings or alignment) are lost when a line is split.
The return value should be an array of attribute names:
```
exports.aceRegisterLineAttributes = function(){
return [ 'heading' ];
}
```
When Enter is pressed on a line that has a registered attribute:
* **Middle or end of line:** the attribute is copied to the new line below.
* **Start of line (column 0):** the attribute moves down with the text content,
and the now-empty line above is cleared.
This is backwards compatible — on Etherpad versions that do not have this hook,
the registration is silently ignored.
## aceInitialized
Called from: `src/static/js/ace2_inner.js`