Skip to content

Commit 649f960

Browse files
JohnMcLearclaude
andauthored
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>
1 parent 5e0602c commit 649f960

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

doc/api/hooks_client-side.adoc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,34 @@ The return value of this hook will add elements into the "lineMarkerAttribute"
211211
category, making the aceDomLineProcessLineAttributes hook (documented below)
212212
call for those elements.
213213

214+
=== aceRegisterLineAttributes
215+
216+
Called from: `src/static/js/ace2_inner.ts`
217+
218+
Things in context: None
219+
220+
Tells Etherpad which line attributes should be preserved when a user presses
221+
Enter to split a line. Without this hook, custom line attributes (such as
222+
headings or alignment) are lost when a line is split.
223+
224+
The return value should be an array of attribute names:
225+
226+
[source,javascript]
227+
----
228+
exports.aceRegisterLineAttributes = function(){
229+
return [ 'heading' ];
230+
}
231+
----
232+
233+
When Enter is pressed on a line that has a registered attribute:
234+
235+
* **Middle or end of line:** the attribute is copied to the new line below.
236+
* **Start of line (column 0):** the attribute moves down with the text content,
237+
and the now-empty line above is cleared.
238+
239+
This is backwards compatible — on Etherpad versions that do not have this hook,
240+
the registration is silently ignored.
241+
214242
=== aceInitialized
215243

216244
Called from: `src/static/js/ace2_inner.js`

doc/api/hooks_client-side.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,33 @@ The return value of this hook will add elements into the "lineMarkerAttribute"
207207
category, making the aceDomLineProcessLineAttributes hook (documented below)
208208
call for those elements.
209209

210+
## aceRegisterLineAttributes
211+
212+
Called from: `src/static/js/ace2_inner.ts`
213+
214+
Things in context: None
215+
216+
Tells Etherpad which line attributes should be preserved when a user presses
217+
Enter to split a line. Without this hook, custom line attributes (such as
218+
headings or alignment) are lost when a line is split.
219+
220+
The return value should be an array of attribute names:
221+
222+
```
223+
exports.aceRegisterLineAttributes = function(){
224+
return [ 'heading' ];
225+
}
226+
```
227+
228+
When Enter is pressed on a line that has a registered attribute:
229+
230+
* **Middle or end of line:** the attribute is copied to the new line below.
231+
* **Start of line (column 0):** the attribute moves down with the text content,
232+
and the now-empty line above is cleared.
233+
234+
This is backwards compatible — on Etherpad versions that do not have this hook,
235+
the registration is silently ignored.
236+
210237
## aceInitialized
211238

212239
Called from: `src/static/js/ace2_inner.js`

0 commit comments

Comments
 (0)