Changeset 5190152 in Klonkt for test


Ignore:
Timestamp:
07/19/2026 05:38:25 PM (7 weeks ago)
Author:
Robin <roboburr@…>
Branches:
main
Children:
e9c9ae1
Parents:
feced2c
git-author:
Robin <roboburr@…> (07/19/2026 05:38:00 PM)
git-committer:
Robin <roboburr@…> (07/19/2026 05:38:25 PM)
Message:

Feature: rich editor on the edit forms too (klonkt-demo-c7f, last slice)

Editing a sent reply (Messages + the interact page's manage list) now opens the
same shared editor as new replies, instead of a bare textarea. Prutter stays
plain on purpose (Robin: not part of this).

  • reply-editor partial: initialHtml/initialText prefill for edit mode, and a noAttach flag that omits the media UI (an edit never touches attachments). JS grew canAttach guards so the component runs without the attach elements; pasted files are still swallowed there rather than becoming base64 blobs.
  • deliverOutboxUpdate(site, id, text, {html, language}): rich path with the same sanitize + enrichment + mention-first-paragraph logic as deliverReply; language updated via COALESCE (bogus codes keep the old one); attachments survive untouched. Plain path unchanged.
  • /fediverse/:id/edit passes content + language; listOutbox and the Messages sent-projection carry language so the select preselects correctly.
  • The interact page's edit-toggle focuses the rich editor when present.

2 new tests (93 green). Browser-verified on /messages: prefilled editor
(mention-stripped HTML + plain fallback + language preselected, no paperclip),
edit saved -> content replaced with markup, mention re-attached inline,
language nl->en, no console errors.

Co-Authored-By: Claude Opus 4.8 <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/rich-reply.test.js

    rfeced2c r5190152  
    120120  assert.equal(r, null);
    121121});
     122
     123test('rich edit: content replaced, language updated, attachments survive', async () => {
     124  const r = await AP.deliverReply(site, {
     125    postId: 'p1', postSlug: 'hallo', parent, text: 'origineel', html: '',
     126    attachments: [{ url: '/media/reply-media/keep.webp', mediaType: 'image/webp', name: 'blijft' }],
     127    language: 'nl',
     128  });
     129  const upd = await AP.deliverOutboxUpdate(site, r.id, '', { html: '<p>bewerkt met <em>nadruk</em></p>', language: 'en' });
     130  assert.ok(upd && upd.ok);
     131  const row = db.prepare('SELECT * FROM ap_outbox WHERE id = ?').get(r.id);
     132  assert.match(row.content, /bewerkt met <em>nadruk<\/em>/);
     133  assert.match(row.content, /^<p><a [^>]*class="u-url mention"/); // mention re-attached inline
     134  assert.equal(row.language, 'en');
     135  assert.equal(JSON.parse(row.attachments)[0].url, '/media/reply-media/keep.webp');
     136});
     137
     138test('plain edit path unchanged; bogus language keeps the old one', async () => {
     139  const r = await AP.deliverReply(site, { postId: 'p1', postSlug: 'hallo', parent, text: 'plain start', language: 'nl' });
     140  const upd = await AP.deliverOutboxUpdate(site, r.id, 'plain bewerkt', { language: '???' });
     141  assert.ok(upd && upd.ok);
     142  const row = db.prepare('SELECT * FROM ap_outbox WHERE id = ?').get(r.id);
     143  assert.match(row.content, /plain bewerkt/);
     144  assert.equal(row.language, 'nl');
     145});
Note: See TracChangeset for help on using the changeset viewer.