feat: commentaire ancré sur la SÉLECTION de texte (pas le bloc) + retrait du bouton bleu « 💬 Comment » (v7.65.0)
- commentBlock() : l'ancre est la sélection vivante dans le bloc (repli : la plage mémorisée par la toolbar de sélection, qui survit au clic du bouton), sinon tout le bloc ; offsets via _srcOffset() → anchor_start/anchor_end exacts dans le texte source, l'ancre jaune ne couvre que le texte choisi. - Suppression de #_commentSelBtn (bouton bleu flottant « 💬 Comment » au-dessus de la sélection), de showCommentBtn()/hideCommentBtn() et du listener mousedown associé ; déclencheurs restants : 💬 de la toolbar de sélection, menu de bloc, Ctrl+⇧+M. - toggleComments() remet _commentSel à zéro à la fermeture du tiroir : un brouillon abandonné ne peut plus ancrer le commentaire suivant ailleurs. - e2e v764_comments_reactions : sous-sélection « reaction a un » → ancre = la plage seule (avant/après reload), #_commentSelBtn absent. Tests: pytest tests/ -q -n auto → 1383 passed ; ruff check app tests → OK ; e2e v764/v762/v763/v7641/regression_editor_mount → 5 passed sur :8081.
This commit is contained in:
@@ -54,6 +54,30 @@ async function newPage(page, body) {
|
||||
return id;
|
||||
}
|
||||
|
||||
// sélectionne une SOUS-chaîne du bloc (ancre = plage, pas le bloc entier)
|
||||
async function selectSub(page, sub) {
|
||||
await page.evaluate((sub) => {
|
||||
const el = document.querySelector('#_blocksCt [data-bid]');
|
||||
const w = document.createTreeWalker(el, NodeFilter.SHOW_TEXT);
|
||||
let n;
|
||||
while ((n = w.nextNode())) {
|
||||
if (n.parentElement && n.parentElement.closest('.fd-react-chip')) continue;
|
||||
const i = n.nodeValue.indexOf(sub);
|
||||
if (i < 0) continue;
|
||||
const r = document.createRange();
|
||||
r.setStart(n, i);
|
||||
r.setEnd(n, i + sub.length);
|
||||
const s = getSelection();
|
||||
s.removeAllRanges();
|
||||
s.addRange(r);
|
||||
el.dispatchEvent(new MouseEvent('mouseup', { bubbles: true }));
|
||||
return;
|
||||
}
|
||||
throw new Error('sous-chaîne introuvable : ' + sub);
|
||||
}, sub);
|
||||
await expect(page.locator('.format-toolbar')).toBeVisible({ timeout: 5000 });
|
||||
}
|
||||
|
||||
// sélectionne tout le bloc et simule la fin du glisser-souris
|
||||
async function selectBlock(page) {
|
||||
await page.evaluate(() => {
|
||||
@@ -100,10 +124,10 @@ test('réaction emoji + commentaires ancrés', async ({ page }) => {
|
||||
expect(content).toBe('Prise de reaction a un texte'); // la pastille n'est pas du contenu
|
||||
await page.screenshot({ path: 'shots/v764-chip.png' });
|
||||
|
||||
// ── 4. commentaire : bouton 💬 → tiroir refondu → envoi ──
|
||||
await selectBlock(page);
|
||||
await expect(page.locator('#_commentSelBtn')).toBeVisible();
|
||||
await page.locator('#_commentSelBtn').click();
|
||||
// ── 4. commentaire sur une SOUS-sélection : toolbar 💬 → tiroir refondu → envoi ──
|
||||
await expect(page.locator('#_commentSelBtn')).toHaveCount(0); // bouton bleu retiré
|
||||
await selectSub(page, 'reaction a un');
|
||||
await page.locator('.format-toolbar .ft-item[data-tooltip="Comment — Ctrl+⇧+M"]').click();
|
||||
const drawer = page.locator('.comments-drawer');
|
||||
await expect(drawer).toBeVisible();
|
||||
await drawer.locator('textarea').fill('Ceci est mon premier commentaire');
|
||||
@@ -115,7 +139,9 @@ test('réaction emoji + commentaires ancrés', async ({ page }) => {
|
||||
await expect(thread.locator('.ct-name')).not.toHaveText('');
|
||||
await expect(thread.locator('.ct-act')).toHaveCount(2); // ✓ + ⋯
|
||||
await expect(thread.locator('.ct-body')).toHaveText('Ceci est mon premier commentaire');
|
||||
// l'ancre jaune = UNIQUEMENT la plage sélectionnée, pas le bloc
|
||||
await expect(page.locator('#_blocksCt .fd-anchor[data-cid]')).toHaveCount(1);
|
||||
await expect(page.locator('#_blocksCt .fd-anchor[data-cid]')).toHaveText('reaction a un');
|
||||
await page.screenshot({ path: 'shots/v764-drawer.png' });
|
||||
|
||||
// ── 5. menu ⋯ du fil (Copy link / Delete) ──
|
||||
@@ -140,5 +166,6 @@ test('réaction emoji + commentaires ancrés', async ({ page }) => {
|
||||
await page.reload({ waitUntil: 'domcontentloaded' });
|
||||
await page.waitForSelector('#_blocksCt [data-bid]', { timeout: 15000 });
|
||||
await expect(page.locator('#_blocksCt .fd-anchor[data-cid]')).toHaveCount(1, { timeout: 10000 });
|
||||
await expect(page.locator('#_blocksCt .fd-anchor[data-cid]')).toHaveText('reaction a un');
|
||||
await expect(page.locator('#_blocksCt .fd-react-chip')).toHaveCount(1, { timeout: 10000 });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user