- Notifications
You must be signed in to change notification settings - Fork1.1k
Content Not Refreshed Correctly when Modifying Pasted Content in Callbacks#1107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…aste and trix-change callbacks are refreshed in the editor when pasting plain text
danielnc commentedApr 12, 2024
Bump to see what are the plans to get this merged and/or a workaround based on issue#1103 |
jondkinney commentedJan 16, 2025
I'm seeing this as well and have a feature where I want to copy some text from a spot in my UI and paste it into Trix to be processed as another instance of an existing ContentAttachment. However, because of this bug, it doesn't work until you press space or type another character, as described above. I ended up working around this by having the copy feature write HTML to the clipboard even though I really only need plain text. For whatever reason Trix does process the paste with HTML properly. functioncopyDateTag(button){consttaskDiv=button.closest('.task-date-tag');constpastableString=taskDiv.querySelector('.pastable-date-tag-string');constcontent=`${pastableString.textContent.trim()}`;// Need to use HTML because if you paste plain text into Trix it will not// process the pasted content as a ContentAttachment until another char// is pressed. See https://github.com/basecamp/trix/pull/1107constclipboardItem=newClipboardItem({'text/html':newBlob([content],{type:'text/html'}),'text/plain':newBlob([content],{type:'text/plain'})});navigator.clipboard.write([clipboardItem]).then(()=>{// Update button text while preserving the iconconstoriginalText=button.innerHTML;consticon=button.querySelector('svg').outerHTML;button.innerHTML=`${icon} Copied!`;setTimeout(()=>{button.innerHTML=originalText;},2000);}).catch(error=>console.error('Failed to copy:',error));} But it'd be nice to get this one merged! |
Fixes#1103.
Whenpasting plain text content or aURL, if you modify the content in a
trix-changeortrix-pastecallback, the changes aren't reflected in the editor after the paste is finished. The changes are reflected later if you start to type in the editor.This pull request updates how the render is performed to match other areas likethis.