KB : comment linked to text selection - #24944
Conversation
b1cb4ce to
350e5e5
Compare
008caed to
cd08f3f
Compare
|
|
||
| let response; | ||
| try { | ||
| response = await post(`Knowbase/${this.#getKbId()}/AddComment`, body); |
There was a problem hiding this comment.
If an error occurs, the comment button does not return to its original state (kept loader icon, which btw looks broken when reduced motion is requested because it doesn't spin then).
There was a problem hiding this comment.
The reset was after the await instead of in a finally. Same bug on the comment-edit path, fixed both.
Reduced motion isn't specific to this button: FontAwesome 7 kills .fa-spin entirely, and ti-loader-2 is a partial arc so it freezes into something broken-looking. 8 occurrences across templates/, 3 outside the KB. Separate issue rather than fixing only ours ?
There was a problem hiding this comment.
I would prefer not using .fa-spin at all. See #18752
The .icon-rotate class still works with reduced motion.
It would be nice if we could eventually drop FontAwesome completely, but it sticks around because some user features allowed selecting FA icons for things.
|
|
||
| /* global TiptapCore, TiptapPMState, TiptapPMView */ | ||
|
|
||
| import { locateAnchor, overlaps } from '/js/modules/Knowbase/CommentAnchor.js'; |
There was a problem hiding this comment.
Editing content that is part of the comment's anchor text breaks the comment link. The anchor data still exists in the DB but is is no longer valid.
There was a problem hiding this comment.
Agreed, the stale row was the real issue. Editing the passage away now drops the anchor on save, so nothing lingers. The comment survives as a plain one. Text matching can't make a broken anchor recoverable, which is another argument for your mark model.
There was a problem hiding this comment.
I'm not entirely sure how it should work for GLPI. In Outline, editing the text obviously keeps the link while removing all of the linked text removed the link while preserving the comment.
Description
Selecting text, in read mode or in the editor, shows a Comment button that opens the Comments panel with the passage pre-filled. Anchored comments underline their passage; clicking a highlight scrolls to the thread.
An anchor stores what was selected rather than where (
prefix/exact/suffix/occurrence, a W3C TextQuoteSelector)and is relocated at display time, so editing around the passage keeps it valid. If the passage is deleted, the comment remains without highlight or quote. The same logic runs on the DOM in read mode and on the ProseMirror doc in edit mode, where highlights are decorations rather than marks so saved HTML and revision history stay unchanged.
Server side : 4 nullable columns on
glpi_knowbaseitems_comments(additive migration), anchors restricted to root comments inprepareInputForAdd(), no new right (existingcanComment()guard).Screenshots :