trix icon indicating copy to clipboard operation
trix copied to clipboard

Add Link then Undo Leaves Behind Background Color Highlight

Open chadrschroeder opened this issue 2 years ago • 1 comments

  1. Select text.
  2. Click the link icon and apply a link.
  3. Click the undo button.

This leaves behind a span with background-color: highlight;. If you have a background color picker, that can be used to remove the color. Otherwise, you have to delete the selection and re-enter it to get the highlighting to go away.

When the editor opens a dialog it calls freezeSelection it uses the frozen attribute which uses a background color of highlight. When the dialog is recording the undo entry recordUndoEntry -> createEntry -> this.composition.getSnapshot() gets the current snapshot of the rich text which includes attributes that include "frozen": true.

Maybe getSnapshot should ignore the frozen attribute since that's an internal attribute that is only used to keep the selected text highlighted while the dialog is open?

One way to work around the issue is to disable the frozen attribute during the trix-before-initialize event with:

Trix.config.textAttributes.frozen = {}
Details
  • Trix version: 2.0.5

chadrschroeder avatar Oct 02 '23 17:10 chadrschroeder

How do you change this background color of the selection UI? I think it would be cleaner if it was wrapped in a tag which could be styled in CSS and is a bit more semantic.

Screenshot 2024-05-30 at 8 44 05 AM

Sorry if this is unrelated but found this issue trying to figure out how to change the style of it.

moladukes avatar May 30 '24 13:05 moladukes