mirror of
https://github.com/ether/etherpad-lite.git
synced 2026-07-18 09:04:54 +00:00
fix: appendText API now attributes text to the specified author (#7446)
* fix: appendText API now attributes text to the specified author spliceText() was calling makeSplice() without passing author attributes, so inserted text had no authorship attribution in the changeset — even though the authorId was recorded in the revision metadata. Now passes [['author', authorId]] and the pool to makeSplice() so the changeset ops carry the author attribute, making the text show the author's color in the editor and appear in listAuthorsOfPad. Also fixed the same issue in pad init (first changeset creation) and updated PadType interface to include the authorId parameter. Fixes #6873 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * test: assert API response code on createPad and anonymous appendText 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:
parent
928eef8978
commit
f7e4100aba
3 changed files with 101 additions and 3 deletions
|
|
@ -294,7 +294,8 @@ class Pad {
|
|||
(!ins && start > 0 && orig[start - 1] === '\n');
|
||||
if (!willEndWithNewline) ins += '\n';
|
||||
if (ndel === 0 && ins.length === 0) return;
|
||||
const changeset = makeSplice(orig, start, ndel, ins);
|
||||
const attribs = authorId ? [['author', authorId] as [string, string]] : undefined;
|
||||
const changeset = makeSplice(orig, start, ndel, ins, attribs, this.pool);
|
||||
await this.appendRevision(changeset, authorId);
|
||||
}
|
||||
|
||||
|
|
@ -394,7 +395,8 @@ class Pad {
|
|||
if (context.type !== 'text') throw new Error(`unsupported content type: ${context.type}`);
|
||||
text = exports.cleanText(context.content);
|
||||
}
|
||||
const firstChangeset = makeSplice('\n', 0, 0, text);
|
||||
const firstAttribs = authorId ? [['author', authorId] as [string, string]] : undefined;
|
||||
const firstChangeset = makeSplice('\n', 0, 0, text, firstAttribs, this.pool);
|
||||
await this.appendRevision(firstChangeset, authorId);
|
||||
}
|
||||
await hooks.aCallAll('padLoad', {pad: this});
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export type PadType = {
|
|||
remove: ()=>Promise<void>,
|
||||
text: ()=>string,
|
||||
setText: (text: string, authorId?: string)=>Promise<void>,
|
||||
appendText: (text: string)=>Promise<void>,
|
||||
appendText: (text: string, authorId?: string)=>Promise<void>,
|
||||
getHeadRevisionNumber: ()=>number,
|
||||
getRevisionDate: (rev: number)=>Promise<number>,
|
||||
getRevisionChangeset: (rev: number)=>Promise<AChangeSet>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue